dodopayments-cli 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ import{createRequire as u8}from"node:module";var o3=Object.create;var{getPrototypeOf:e3,defineProperty:Gu,getOwnPropertyNames:D8}=Object;var F8=Object.prototype.hasOwnProperty;var LF=(D,F,u)=>{u=D!=null?o3(e3(D)):{};let C=F||!D||!D.__esModule?Gu(u,"default",{value:D,enumerable:!0}):u;for(let E of D8(D))if(!F8.call(C,E))Gu(C,E,{get:()=>D[E],enumerable:!0});return C};var ED=(D,F)=>()=>(F||D((F={exports:{}}).exports,F),F.exports);var M=(D,F)=>()=>(D&&(F=D(D=0)),F);var Yu=u8(import.meta.url);var yu=ED((bu)=>{Object.defineProperty(bu,"__esModule",{value:!0});bu.timingSafeEqual=void 0;function Pu(D,F=""){if(!D)throw Error(F)}function x8(D,F){if(D.byteLength!==F.byteLength)return!1;if(!(D instanceof DataView))D=new DataView(ArrayBuffer.isView(D)?D.buffer:D);if(!(F instanceof DataView))F=new DataView(ArrayBuffer.isView(F)?F.buffer:F);Pu(D instanceof DataView),Pu(F instanceof DataView);let u=D.byteLength,C=0,E=-1;while(++E<u)C|=D.getUint8(E)^F.getUint8(E);return C===0}bu.timingSafeEqual=x8});var mu=ED((m)=>{var S8=m&&m.__extends||function(){var D=function(F,u){return D=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(C,E){C.__proto__=E}||function(C,E){for(var B in E)if(E.hasOwnProperty(B))C[B]=E[B]},D(F,u)};return function(F,u){D(F,u);function C(){this.constructor=F}F.prototype=u===null?Object.create(u):(C.prototype=u.prototype,new C)}}();Object.defineProperty(m,"__esModule",{value:!0});var L=256,O0=function(){function D(F){if(F===void 0)F="=";this._paddingCharacter=F}return D.prototype.encodedLength=function(F){if(!this._paddingCharacter)return(F*8+5)/6|0;return(F+2)/3*4|0},D.prototype.encode=function(F){var u="",C=0;for(;C<F.length-2;C+=3){var E=F[C]<<16|F[C+1]<<8|F[C+2];u+=this._encodeByte(E>>>18&63),u+=this._encodeByte(E>>>12&63),u+=this._encodeByte(E>>>6&63),u+=this._encodeByte(E>>>0&63)}var B=F.length-C;if(B>0){var E=F[C]<<16|(B===2?F[C+1]<<8:0);if(u+=this._encodeByte(E>>>18&63),u+=this._encodeByte(E>>>12&63),B===2)u+=this._encodeByte(E>>>6&63);else u+=this._paddingCharacter||"";u+=this._paddingCharacter||""}return u},D.prototype.maxDecodedLength=function(F){if(!this._paddingCharacter)return(F*6+7)/8|0;return F/4*3|0},D.prototype.decodedLength=function(F){return this.maxDecodedLength(F.length-this._getPaddingLength(F))},D.prototype.decode=function(F){if(F.length===0)return new Uint8Array(0);var u=this._getPaddingLength(F),C=F.length-u,E=new Uint8Array(this.maxDecodedLength(C)),B=0,$=0,Q=0,z=0,X=0,Y=0,Z=0;for(;$<C-4;$+=4)z=this._decodeChar(F.charCodeAt($+0)),X=this._decodeChar(F.charCodeAt($+1)),Y=this._decodeChar(F.charCodeAt($+2)),Z=this._decodeChar(F.charCodeAt($+3)),E[B++]=z<<2|X>>>4,E[B++]=X<<4|Y>>>2,E[B++]=Y<<6|Z,Q|=z&L,Q|=X&L,Q|=Y&L,Q|=Z&L;if($<C-1)z=this._decodeChar(F.charCodeAt($)),X=this._decodeChar(F.charCodeAt($+1)),E[B++]=z<<2|X>>>4,Q|=z&L,Q|=X&L;if($<C-2)Y=this._decodeChar(F.charCodeAt($+2)),E[B++]=X<<4|Y>>>2,Q|=Y&L;if($<C-3)Z=this._decodeChar(F.charCodeAt($+3)),E[B++]=Y<<6|Z,Q|=Z&L;if(Q!==0)throw Error("Base64Coder: incorrect characters for decoding");return E},D.prototype._encodeByte=function(F){var u=F;return u+=65,u+=25-F>>>8&6,u+=51-F>>>8&-75,u+=61-F>>>8&-15,u+=62-F>>>8&3,String.fromCharCode(u)},D.prototype._decodeChar=function(F){var u=L;return u+=(42-F&F-44)>>>8&-L+F-43+62,u+=(46-F&F-48)>>>8&-L+F-47+63,u+=(47-F&F-58)>>>8&-L+F-48+52,u+=(64-F&F-91)>>>8&-L+F-65+0,u+=(96-F&F-123)>>>8&-L+F-97+26,u},D.prototype._getPaddingLength=function(F){var u=0;if(this._paddingCharacter){for(var C=F.length-1;C>=0;C--){if(F[C]!==this._paddingCharacter)break;u++}if(F.length<4||u>2)throw Error("Base64Coder: incorrect padding")}return u},D}();m.Coder=O0;var XF=new O0;function w8(D){return XF.encode(D)}m.encode=w8;function R8(D){return XF.decode(D)}m.decode=R8;var hu=function(D){S8(F,D);function F(){return D!==null&&D.apply(this,arguments)||this}return F.prototype._encodeByte=function(u){var C=u;return C+=65,C+=25-u>>>8&6,C+=51-u>>>8&-75,C+=61-u>>>8&-13,C+=62-u>>>8&49,String.fromCharCode(C)},F.prototype._decodeChar=function(u){var C=L;return C+=(44-u&u-46)>>>8&-L+u-45+62,C+=(94-u&u-96)>>>8&-L+u-95+63,C+=(47-u&u-58)>>>8&-L+u-48+52,C+=(64-u&u-91)>>>8&-L+u-65+0,C+=(96-u&u-123)>>>8&-L+u-97+26,C},F}(O0);m.URLSafeCoder=hu;var gu=new hu;function j8(D){return gu.encode(D)}m.encodeURLSafe=j8;function k8(D){return gu.decode(D)}m.decodeURLSafe=k8;m.encodedLength=function(D){return XF.encodedLength(D)};m.maxDecodedLength=function(D){return XF.maxDecodedLength(D)};m.decodedLength=function(D){return XF.decodedLength(D)}});var cu=ED((du,mF)=>{(function(D,F){var u={};F(u);var C=u.default;for(var E in u)C[E]=u[E];if(typeof mF==="object"&&typeof mF.exports==="object")mF.exports=C;else if(typeof define==="function"&&define.amd)define(function(){return C});else D.sha256=C})(du,function(D){D.__esModule=!0,D.digestLength=32,D.blockSize=64;var F=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function u(Z,A,J,G,T){var W,O,_,U,S,q,b,V,w,R,f,h,i;while(T>=64){W=A[0],O=A[1],_=A[2],U=A[3],S=A[4],q=A[5],b=A[6],V=A[7];for(R=0;R<16;R++)f=G+R*4,Z[R]=(J[f]&255)<<24|(J[f+1]&255)<<16|(J[f+2]&255)<<8|J[f+3]&255;for(R=16;R<64;R++)w=Z[R-2],h=(w>>>17|w<<15)^(w>>>19|w<<13)^w>>>10,w=Z[R-15],i=(w>>>7|w<<25)^(w>>>18|w<<14)^w>>>3,Z[R]=(h+Z[R-7]|0)+(i+Z[R-16]|0);for(R=0;R<64;R++)h=(((S>>>6|S<<26)^(S>>>11|S<<21)^(S>>>25|S<<7))+(S&q^~S&b)|0)+(V+(F[R]+Z[R]|0)|0)|0,i=((W>>>2|W<<30)^(W>>>13|W<<19)^(W>>>22|W<<10))+(W&O^W&_^O&_)|0,V=b,b=q,q=S,S=U+h|0,U=_,_=O,O=W,W=h+i|0;A[0]+=W,A[1]+=O,A[2]+=_,A[3]+=U,A[4]+=S,A[5]+=q,A[6]+=b,A[7]+=V,G+=64,T-=64}return G}var C=function(){function Z(){this.digestLength=D.digestLength,this.blockSize=D.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return Z.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},Z.prototype.clean=function(){for(var A=0;A<this.buffer.length;A++)this.buffer[A]=0;for(var A=0;A<this.temp.length;A++)this.temp[A]=0;this.reset()},Z.prototype.update=function(A,J){if(J===void 0)J=A.length;if(this.finished)throw Error("SHA256: can't update because hash was finished.");var G=0;if(this.bytesHashed+=J,this.bufferLength>0){while(this.bufferLength<64&&J>0)this.buffer[this.bufferLength++]=A[G++],J--;if(this.bufferLength===64)u(this.temp,this.state,this.buffer,0,64),this.bufferLength=0}if(J>=64)G=u(this.temp,this.state,A,G,J),J%=64;while(J>0)this.buffer[this.bufferLength++]=A[G++],J--;return this},Z.prototype.finish=function(A){if(!this.finished){var J=this.bytesHashed,G=this.bufferLength,T=J/536870912|0,W=J<<3,O=J%64<56?64:128;this.buffer[G]=128;for(var _=G+1;_<O-8;_++)this.buffer[_]=0;this.buffer[O-8]=T>>>24&255,this.buffer[O-7]=T>>>16&255,this.buffer[O-6]=T>>>8&255,this.buffer[O-5]=T>>>0&255,this.buffer[O-4]=W>>>24&255,this.buffer[O-3]=W>>>16&255,this.buffer[O-2]=W>>>8&255,this.buffer[O-1]=W>>>0&255,u(this.temp,this.state,this.buffer,0,O),this.finished=!0}for(var _=0;_<8;_++)A[_*4+0]=this.state[_]>>>24&255,A[_*4+1]=this.state[_]>>>16&255,A[_*4+2]=this.state[_]>>>8&255,A[_*4+3]=this.state[_]>>>0&255;return this},Z.prototype.digest=function(){var A=new Uint8Array(this.digestLength);return this.finish(A),A},Z.prototype._saveState=function(A){for(var J=0;J<this.state.length;J++)A[J]=this.state[J]},Z.prototype._restoreState=function(A,J){for(var G=0;G<this.state.length;G++)this.state[G]=A[G];this.bytesHashed=J,this.finished=!1,this.bufferLength=0},Z}();D.Hash=C;var E=function(){function Z(A){this.inner=new C,this.outer=new C,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var J=new Uint8Array(this.blockSize);if(A.length>this.blockSize)new C().update(A).finish(J).clean();else for(var G=0;G<A.length;G++)J[G]=A[G];for(var G=0;G<J.length;G++)J[G]^=54;this.inner.update(J);for(var G=0;G<J.length;G++)J[G]^=106;this.outer.update(J),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var G=0;G<J.length;G++)J[G]=0}return Z.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},Z.prototype.clean=function(){for(var A=0;A<this.istate.length;A++)this.ostate[A]=this.istate[A]=0;this.inner.clean(),this.outer.clean()},Z.prototype.update=function(A){return this.inner.update(A),this},Z.prototype.finish=function(A){if(this.outer.finished)this.outer.finish(A);else this.inner.finish(A),this.outer.update(A,this.digestLength).finish(A);return this},Z.prototype.digest=function(){var A=new Uint8Array(this.digestLength);return this.finish(A),A},Z}();D.HMAC=E;function B(Z){var A=new C().update(Z),J=A.digest();return A.clean(),J}D.hash=B,D.default=B;function $(Z,A){var J=new E(Z).update(A),G=J.digest();return J.clean(),G}D.hmac=$;function Q(Z,A,J,G){var T=G[0];if(T===0)throw Error("hkdf: cannot expand more");if(A.reset(),T>1)A.update(Z);if(J)A.update(J);A.update(G),A.finish(Z),G[0]++}var z=new Uint8Array(D.digestLength);function X(Z,A,J,G){if(A===void 0)A=z;if(G===void 0)G=32;var T=new Uint8Array([1]),W=$(A,Z),O=new E(W),_=new Uint8Array(O.digestLength),U=_.length,S=new Uint8Array(G);for(var q=0;q<G;q++){if(U===_.length)Q(_,O,J,T),U=0;S[q]=_[U++]}return O.clean(),_.fill(0),T.fill(0),S}D.hkdf=X;function Y(Z,A,J,G){var T=new E(Z),W=T.digestLength,O=new Uint8Array(4),_=new Uint8Array(W),U=new Uint8Array(W),S=new Uint8Array(G);for(var q=0;q*W<G;q++){var b=q+1;O[0]=b>>>24&255,O[1]=b>>>16&255,O[2]=b>>>8&255,O[3]=b>>>0&255,T.reset(),T.update(A),T.update(O),T.finish(U);for(var V=0;V<W;V++)_[V]=U[V];for(var V=2;V<=J;V++){T.reset(),T.update(U).finish(U);for(var w=0;w<W;w++)_[w]^=U[w]}for(var V=0;V<W&&q*W+V<G;V++)S[q*W+V]=_[V]}for(var q=0;q<W;q++)_[q]=U[q]=0;for(var q=0;q<4;q++)O[q]=0;return T.clean(),S}D.pbkdf2=Y})});var au=ED((nu)=>{Object.defineProperty(nu,"__esModule",{value:!0});nu.Webhook=nu.WebhookVerificationError=void 0;var I8=yu(),lu=mu(),L8=cu(),pu=300;class T0 extends Error{constructor(D){super(D);Object.setPrototypeOf(this,T0.prototype),this.name="ExtendableError",this.stack=Error(D).stack}}class FD extends T0{constructor(D){super(D);Object.setPrototypeOf(this,FD.prototype),this.name="WebhookVerificationError"}}nu.WebhookVerificationError=FD;class GF{constructor(D,F){if(!D)throw Error("Secret can't be empty.");if((F===null||F===void 0?void 0:F.format)==="raw")if(D instanceof Uint8Array)this.key=D;else this.key=Uint8Array.from(D,(u)=>u.charCodeAt(0));else{if(typeof D!=="string")throw Error("Expected secret to be of type string");if(D.startsWith(GF.prefix))D=D.substring(GF.prefix.length);this.key=lu.decode(D)}}verify(D,F){let u={};for(let Z of Object.keys(F))u[Z.toLowerCase()]=F[Z];let C=u["webhook-id"],E=u["webhook-signature"],B=u["webhook-timestamp"];if(!E||!C||!B)throw new FD("Missing required headers");let $=this.verifyTimestamp(B),z=this.sign(C,$,D).split(",")[1],X=E.split(" "),Y=new globalThis.TextEncoder;for(let Z of X){let[A,J]=Z.split(",");if(A!=="v1")continue;if((0,I8.timingSafeEqual)(Y.encode(J),Y.encode(z)))return JSON.parse(D.toString())}throw new FD("No matching signature found")}sign(D,F,u){if(typeof u==="string");else if(u.constructor.name==="Buffer")u=u.toString();else throw Error("Expected payload to be of type string or Buffer.");let C=new TextEncoder,E=Math.floor(F.getTime()/1000),B=C.encode(`${D}.${E}.${u}`);return`v1,${lu.encode(L8.hmac(this.key,B))}`}verifyTimestamp(D){let F=Math.floor(Date.now()/1000),u=parseInt(D,10);if(isNaN(u))throw new FD("Invalid Signature Headers");if(F-u>pu)throw new FD("Message timestamp too old");if(u>F+pu)throw new FD("Message timestamp too new");return new Date(u*1000)}}nu.Webhook=GF;GF.prefix="whsec_"});var KF=(D,F=[])=>D.name==="up"||F.includes("vim")&&D.name==="k"||F.includes("emacs")&&D.ctrl&&D.name==="p",cF=(D,F=[])=>D.name==="down"||F.includes("vim")&&D.name==="j"||F.includes("emacs")&&D.ctrl&&D.name==="n",_F=(D)=>D.name==="backspace",U0=(D)=>D.name==="tab",V0=(D)=>"1234567890".includes(D.name),WF=(D)=>D.name==="enter"||D.name==="return";var q0,M0,lF,x0,OF;var pF=M(()=>{q0=class q0 extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(D){super();this.cause=D?.cause}};M0=class M0 extends Error{name="CancelPromptError";message="Prompt was canceled"};lF=class lF extends Error{name="ExitPromptError"};x0=class x0 extends Error{name="HookError"};OF=class OF extends Error{name="ValidationError"}});import{AsyncLocalStorage as b8,AsyncResource as v8}from"node:async_hooks";function y8(D){return{rl:D,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function eu(D,F){let u=y8(D);return ou.run(u,()=>{function C(E){u.handleChange=()=>{u.index=0,E()},u.handleChange()}return F(C)})}function QD(){let D=ou.getStore();if(!D)throw new x0("[Inquirer] Hook functions can only be called from within a prompt");return D}function S0(){return QD().rl}function w0(D){let F=(...u)=>{let C=QD(),E=!1,B=C.handleChange;C.handleChange=()=>{E=!0};let $=D(...u);if(E)B();return C.handleChange=B,$};return v8.bind(F)}function hD(D){let F=QD(),{index:u}=F,C={get(){return F.hooks[u]},set(B){F.hooks[u]=B},initialized:u in F.hooks},E=D(C);return F.index++,E}function D2(){QD().handleChange()}var ou,JD;var XD=M(()=>{pF();ou=new b8;JD={queue(D){let F=QD(),{index:u}=F;F.hooksEffect.push(()=>{F.hooksCleanup[u]?.();let C=D(S0());if(C!=null&&typeof C!=="function")throw new OF("useEffect return value must be a cleanup function or nothing.");F.hooksCleanup[u]=C})},run(){let D=QD();w0(()=>{D.hooksEffect.forEach((F)=>{F()}),D.hooksEffect.length=0})()},clearAll(){let D=QD();D.hooksCleanup.forEach((F)=>{F?.()}),D.hooksEffect.length=0,D.hooksCleanup.length=0}}});import{AsyncResource as h8}from"node:async_hooks";function g(D){return hD((F)=>{let u=h8.bind(function(B){if(F.get()!==B)F.set(B),D2()});if(F.initialized)return[F.get(),u];let C=typeof D==="function"?D():D;return F.set(C),[C,u]})}var nF=M(()=>{XD()});function r(D,F){hD((u)=>{let C=u.get();if(!Array.isArray(C)||F.some((B,$)=>!Object.is(B,C[$])))JD.queue(D);u.set(F)})}var iF=M(()=>{XD()});import n from"node:process";function g8(){if(n.platform!=="win32")return n.env.TERM!=="linux";return Boolean(n.env.WT_SESSION)||Boolean(n.env.TERMINUS_SUBLIME)||n.env.ConEmuTask==="{cmd::Cmder}"||n.env.TERM_PROGRAM==="Terminus-Sublime"||n.env.TERM_PROGRAM==="vscode"||n.env.TERM==="xterm-256color"||n.env.TERM==="alacritty"||n.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var F2,u2,m8,d8,c8,l8,p8,gD,FB;var aF=M(()=>{F2={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:"╱"},u2={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:"⅒"},m8={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"},d8={...F2,...u2},c8={...F2,...m8},l8=g8(),p8=l8?d8:c8,gD=p8,FB=Object.entries(u2)});import{styleText as p}from"node:util";var C2;var E2=M(()=>{aF();C2={prefix:{idle:p("blue","?"),done:p("green",gD.tick)},spinner:{interval:80,frames:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"].map((D)=>p("yellow",D))},style:{answer:(D)=>p("cyan",D),message:(D)=>p("bold",D),error:(D)=>p("red",`> ${D}`),defaultAnswer:(D)=>p("dim",`(${D})`),help:(D)=>p("dim",D),highlight:(D)=>p("cyan",D),key:(D)=>p("cyan",p("bold",`<${D}>`))}}});function B2(D){if(typeof D!=="object"||D===null)return!1;let F=D;while(Object.getPrototypeOf(F)!==null)F=Object.getPrototypeOf(F);return Object.getPrototypeOf(D)===F}function A2(...D){let F={};for(let u of D)for(let[C,E]of Object.entries(u)){let B=F[C];F[C]=B2(B)&&B2(E)?A2(B,E):E}return F}function GD(...D){let F=[C2,...D.filter((u)=>u!=null)];return A2(...F)}var R0=M(()=>{E2()});function TF({status:D="idle",theme:F}){let[u,C]=g(!1),[E,B]=g(0),{prefix:$,spinner:Q}=GD(F);if(r(()=>{if(D==="loading"){let X,Y=-1,Z=setTimeout(()=>{C(!0),X=setInterval(()=>{Y=Y+1,B(Y%Q.frames.length)},Q.interval)},300);return()=>{clearTimeout(Z),clearInterval(X)}}else C(!1)},[D]),u)return Q.frames[E];return typeof $==="string"?$:$[D==="loading"?"idle":D]??$.idle}var $2=M(()=>{nF();iF();R0()});function NF(D,F){return hD((u)=>{let C=u.get();if(!C||C.dependencies.length!==F.length||C.dependencies.some((E,B)=>E!==F[B])){let E=D();return u.set({value:E,dependencies:F}),E}return C.value})}var Z2=M(()=>{XD()});function YD(D){return g({current:D})[0]}var rF=M(()=>{nF()});function HF(D){let F=YD(D);F.current=D,r((u)=>{let C=!1,E=w0((B,$)=>{if(C)return;F.current($,u)});return u.input.on("keypress",E),()=>{C=!0,u.input.removeListener("keypress",E)}},[])}var Q2=M(()=>{rF();iF();XD()});var X2=ED((NB,J2)=>{J2.exports=i8;function n8(D){let F={defaultWidth:0,output:process.stdout,tty:Yu("tty")};if(!D)return F;return Object.keys(F).forEach(function(u){if(!D[u])D[u]=F[u]}),D}function i8(D){let F=n8(D);if(F.output.getWindowSize)return F.output.getWindowSize()[0]||F.defaultWidth;if(F.tty.getWindowSize)return F.tty.getWindowSize()[1]||F.defaultWidth;if(F.output.columns)return F.output.columns;if(process.env.CLI_WIDTH){let u=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(u)&&u!==0)return u}return F.defaultWidth}});function j0({onlyFirst:D=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",D?void 0:"g")}function UF(D){if(typeof D!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof D}\``);return D.replace(a8,"")}var a8;var k0=M(()=>{a8=j0()});function G2(D){return D===161||D===164||D===167||D===168||D===170||D===173||D===174||D>=176&&D<=180||D>=182&&D<=186||D>=188&&D<=191||D===198||D===208||D===215||D===216||D>=222&&D<=225||D===230||D>=232&&D<=234||D===236||D===237||D===240||D===242||D===243||D>=247&&D<=250||D===252||D===254||D===257||D===273||D===275||D===283||D===294||D===295||D===299||D>=305&&D<=307||D===312||D>=319&&D<=322||D===324||D>=328&&D<=331||D===333||D===338||D===339||D===358||D===359||D===363||D===462||D===464||D===466||D===468||D===470||D===472||D===474||D===476||D===593||D===609||D===708||D===711||D>=713&&D<=715||D===717||D===720||D>=728&&D<=731||D===733||D===735||D>=768&&D<=879||D>=913&&D<=929||D>=931&&D<=937||D>=945&&D<=961||D>=963&&D<=969||D===1025||D>=1040&&D<=1103||D===1105||D===8208||D>=8211&&D<=8214||D===8216||D===8217||D===8220||D===8221||D>=8224&&D<=8226||D>=8228&&D<=8231||D===8240||D===8242||D===8243||D===8245||D===8251||D===8254||D===8308||D===8319||D>=8321&&D<=8324||D===8364||D===8451||D===8453||D===8457||D===8467||D===8470||D===8481||D===8482||D===8486||D===8491||D===8531||D===8532||D>=8539&&D<=8542||D>=8544&&D<=8555||D>=8560&&D<=8569||D===8585||D>=8592&&D<=8601||D===8632||D===8633||D===8658||D===8660||D===8679||D===8704||D===8706||D===8707||D===8711||D===8712||D===8715||D===8719||D===8721||D===8725||D===8730||D>=8733&&D<=8736||D===8739||D===8741||D>=8743&&D<=8748||D===8750||D>=8756&&D<=8759||D===8764||D===8765||D===8776||D===8780||D===8786||D===8800||D===8801||D>=8804&&D<=8807||D===8810||D===8811||D===8814||D===8815||D===8834||D===8835||D===8838||D===8839||D===8853||D===8857||D===8869||D===8895||D===8978||D>=9312&&D<=9449||D>=9451&&D<=9547||D>=9552&&D<=9587||D>=9600&&D<=9615||D>=9618&&D<=9621||D===9632||D===9633||D>=9635&&D<=9641||D===9650||D===9651||D===9654||D===9655||D===9660||D===9661||D===9664||D===9665||D>=9670&&D<=9672||D===9675||D>=9678&&D<=9681||D>=9698&&D<=9701||D===9711||D===9733||D===9734||D===9737||D===9742||D===9743||D===9756||D===9758||D===9792||D===9794||D===9824||D===9825||D>=9827&&D<=9829||D>=9831&&D<=9834||D===9836||D===9837||D===9839||D===9886||D===9887||D===9919||D>=9926&&D<=9933||D>=9935&&D<=9939||D>=9941&&D<=9953||D===9955||D===9960||D===9961||D>=9963&&D<=9969||D===9972||D>=9974&&D<=9977||D===9979||D===9980||D===9982||D===9983||D===10045||D>=10102&&D<=10111||D>=11094&&D<=11097||D>=12872&&D<=12879||D>=57344&&D<=63743||D>=65024&&D<=65039||D===65533||D>=127232&&D<=127242||D>=127248&&D<=127277||D>=127280&&D<=127337||D>=127344&&D<=127373||D===127375||D===127376||D>=127387&&D<=127404||D>=917760&&D<=917999||D>=983040&&D<=1048573||D>=1048576&&D<=1114109}function Y2(D){return D===12288||D>=65281&&D<=65376||D>=65504&&D<=65510}function z2(D){return D>=4352&&D<=4447||D===8986||D===8987||D===9001||D===9002||D>=9193&&D<=9196||D===9200||D===9203||D===9725||D===9726||D===9748||D===9749||D>=9776&&D<=9783||D>=9800&&D<=9811||D===9855||D>=9866&&D<=9871||D===9875||D===9889||D===9898||D===9899||D===9917||D===9918||D===9924||D===9925||D===9934||D===9940||D===9962||D===9970||D===9971||D===9973||D===9978||D===9981||D===9989||D===9994||D===9995||D===10024||D===10060||D===10062||D>=10067&&D<=10069||D===10071||D>=10133&&D<=10135||D===10160||D===10175||D===11035||D===11036||D===11088||D===11093||D>=11904&&D<=11929||D>=11931&&D<=12019||D>=12032&&D<=12245||D>=12272&&D<=12287||D>=12289&&D<=12350||D>=12353&&D<=12438||D>=12441&&D<=12543||D>=12549&&D<=12591||D>=12593&&D<=12686||D>=12688&&D<=12773||D>=12783&&D<=12830||D>=12832&&D<=12871||D>=12880&&D<=42124||D>=42128&&D<=42182||D>=43360&&D<=43388||D>=44032&&D<=55203||D>=63744&&D<=64255||D>=65040&&D<=65049||D>=65072&&D<=65106||D>=65108&&D<=65126||D>=65128&&D<=65131||D>=94176&&D<=94180||D>=94192&&D<=94198||D>=94208&&D<=101589||D>=101631&&D<=101662||D>=101760&&D<=101874||D>=110576&&D<=110579||D>=110581&&D<=110587||D===110589||D===110590||D>=110592&&D<=110882||D===110898||D>=110928&&D<=110930||D===110933||D>=110948&&D<=110951||D>=110960&&D<=111355||D>=119552&&D<=119638||D>=119648&&D<=119670||D===126980||D===127183||D===127374||D>=127377&&D<=127386||D>=127488&&D<=127490||D>=127504&&D<=127547||D>=127552&&D<=127560||D===127568||D===127569||D>=127584&&D<=127589||D>=127744&&D<=127776||D>=127789&&D<=127797||D>=127799&&D<=127868||D>=127870&&D<=127891||D>=127904&&D<=127946||D>=127951&&D<=127955||D>=127968&&D<=127984||D===127988||D>=127992&&D<=128062||D===128064||D>=128066&&D<=128252||D>=128255&&D<=128317||D>=128331&&D<=128334||D>=128336&&D<=128359||D===128378||D===128405||D===128406||D===128420||D>=128507&&D<=128591||D>=128640&&D<=128709||D===128716||D>=128720&&D<=128722||D>=128725&&D<=128728||D>=128732&&D<=128735||D===128747||D===128748||D>=128756&&D<=128764||D>=128992&&D<=129003||D===129008||D>=129292&&D<=129338||D>=129340&&D<=129349||D>=129351&&D<=129535||D>=129648&&D<=129660||D>=129664&&D<=129674||D>=129678&&D<=129734||D===129736||D>=129741&&D<=129756||D>=129759&&D<=129770||D>=129775&&D<=129784||D>=131072&&D<=196605||D>=196608&&D<=262141}var K2=()=>{};function r8(D){if(!Number.isSafeInteger(D))throw TypeError(`Expected a code point, got \`${typeof D}\`.`)}function _2(D,{ambiguousAsWide:F=!1}={}){if(r8(D),Y2(D)||z2(D)||F&&G2(D))return 2;return 1}var W2=M(()=>{K2()});var T2=ED((wB,O2)=>{O2.exports=()=>{return/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\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-\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]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\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)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\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]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\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]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\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]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\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]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\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]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\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(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\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]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\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]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\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]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\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]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\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]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g}});function zD(D,F={}){if(typeof D!=="string"||D.length===0)return 0;let{ambiguousIsNarrow:u=!0,countAnsiEscapeCodes:C=!1}=F;if(!C)D=UF(D);if(D.length===0)return 0;let E=0,B={ambiguousAsWide:!u};for(let{segment:$}of t8.segment(D)){let Q=$.codePointAt(0);if(Q<=31||Q>=127&&Q<=159)continue;if(Q>=8203&&Q<=8207||Q===65279)continue;if(Q>=768&&Q<=879||Q>=6832&&Q<=6911||Q>=7616&&Q<=7679||Q>=8400&&Q<=8447||Q>=65056&&Q<=65071)continue;if(Q>=55296&&Q<=57343)continue;if(Q>=65024&&Q<=65039)continue;if(s8.test($))continue;if(N2.default().test($)){E+=2;continue}E+=_2(Q,B)}return E}var N2,t8,s8;var H2=M(()=>{k0();W2();N2=LF(T2(),1),t8=new Intl.Segmenter,s8=/^\p{Default_Ignorable_Code_Point}$/u});function D6(){let D=new Map;for(let[F,u]of Object.entries(I)){for(let[C,E]of Object.entries(u))I[C]={open:`\x1B[${E[0]}m`,close:`\x1B[${E[1]}m`},u[C]=I[C],D.set(E[0],E[1]);Object.defineProperty(I,F,{value:u,enumerable:!1})}return Object.defineProperty(I,"codes",{value:D,enumerable:!1}),I.color.close="\x1B[39m",I.bgColor.close="\x1B[49m",I.color.ansi=U2(),I.color.ansi256=V2(),I.color.ansi16m=q2(),I.bgColor.ansi=U2(10),I.bgColor.ansi256=V2(10),I.bgColor.ansi16m=q2(10),Object.defineProperties(I,{rgbToAnsi256:{value(F,u,C){if(F===u&&u===C){if(F<8)return 16;if(F>248)return 231;return Math.round((F-8)/247*24)+232}return 16+36*Math.round(F/255*5)+6*Math.round(u/255*5)+Math.round(C/255*5)},enumerable:!1},hexToRgb:{value(F){let u=/[a-f\d]{6}|[a-f\d]{3}/i.exec(F.toString(16));if(!u)return[0,0,0];let[C]=u;if(C.length===3)C=[...C].map((B)=>B+B).join("");let E=Number.parseInt(C,16);return[E>>16&255,E>>8&255,E&255]},enumerable:!1},hexToAnsi256:{value:(F)=>I.rgbToAnsi256(...I.hexToRgb(F)),enumerable:!1},ansi256ToAnsi:{value(F){if(F<8)return 30+F;if(F<16)return 90+(F-8);let u,C,E;if(F>=232)u=((F-232)*10+8)/255,C=u,E=u;else{F-=16;let Q=F%36;u=Math.floor(F/36)/5,C=Math.floor(Q/6)/5,E=Q%6/5}let B=Math.max(u,C,E)*2;if(B===0)return 30;let $=30+(Math.round(E)<<2|Math.round(C)<<1|Math.round(u));if(B===2)$+=60;return $},enumerable:!1},rgbToAnsi:{value:(F,u,C)=>I.ansi256ToAnsi(I.rgbToAnsi256(F,u,C)),enumerable:!1},hexToAnsi:{value:(F)=>I.ansi256ToAnsi(I.hexToAnsi256(F)),enumerable:!1}}),I}var U2=(D=0)=>(F)=>`\x1B[${F+D}m`,V2=(D=0)=>(F)=>`\x1B[${38+D};5;${F}m`,q2=(D=0)=>(F,u,C)=>`\x1B[${38+D};2;${F};${u};${C}m`,I,IB,o8,e8,LB,F6,M2;var x2=M(()=>{I={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},IB=Object.keys(I.modifier),o8=Object.keys(I.color),e8=Object.keys(I.bgColor),LB=[...o8,...e8];F6=D6(),M2=F6});function f0(D,F,u){return String(D).normalize().replaceAll(`\r
2
+ `,`
3
+ `).split(`
4
+ `).map((C)=>A6(C,F,u)).join(`
5
+ `)}var sF,u6=39,L0="\x07",R2="[",C6="]",j2="m",tF,S2=(D)=>`${sF.values().next().value}${R2}${D}${j2}`,w2=(D)=>`${sF.values().next().value}${tF}${D}${L0}`,E6=(D)=>D.split(" ").map((F)=>zD(F)),I0=(D,F,u)=>{let C=[...F],E=!1,B=!1,$=zD(UF(D.at(-1)));for(let[Q,z]of C.entries()){let X=zD(z);if($+X<=u)D[D.length-1]+=z;else D.push(z),$=0;if(sF.has(z))E=!0,B=C.slice(Q+1,Q+1+tF.length).join("")===tF;if(E){if(B){if(z===L0)E=!1,B=!1}else if(z===j2)E=!1;continue}if($+=X,$===u&&Q<C.length-1)D.push(""),$=0}if(!$&&D.at(-1).length>0&&D.length>1)D[D.length-2]+=D.pop()},B6=(D)=>{let F=D.split(" "),u=F.length;while(u>0){if(zD(F[u-1])>0)break;u--}if(u===F.length)return D;return F.slice(0,u).join(" ")+F.slice(u).join("")},A6=(D,F,u={})=>{if(u.trim!==!1&&D.trim()==="")return"";let C="",E,B,$=E6(D),Q=[""];for(let[Z,A]of D.split(" ").entries()){if(u.trim!==!1)Q[Q.length-1]=Q.at(-1).trimStart();let J=zD(Q.at(-1));if(Z!==0){if(J>=F&&(u.wordWrap===!1||u.trim===!1))Q.push(""),J=0;if(J>0||u.trim===!1)Q[Q.length-1]+=" ",J++}if(u.hard&&$[Z]>F){let G=F-J,T=1+Math.floor(($[Z]-G-1)/F);if(Math.floor(($[Z]-1)/F)<T)Q.push("");I0(Q,A,F);continue}if(J+$[Z]>F&&J>0&&$[Z]>0){if(u.wordWrap===!1&&J<F){I0(Q,A,F);continue}Q.push("")}if(J+$[Z]>F&&u.wordWrap===!1){I0(Q,A,F);continue}Q[Q.length-1]+=A}if(u.trim!==!1)Q=Q.map((Z)=>B6(Z));let z=Q.join(`
6
+ `),X=[...z],Y=0;for(let[Z,A]of X.entries()){if(C+=A,sF.has(A)){let{groups:G}=new RegExp(`(?:\\${R2}(?<code>\\d+)m|\\${tF}(?<uri>.*)${L0})`).exec(z.slice(Y))||{groups:{}};if(G.code!==void 0){let T=Number.parseFloat(G.code);E=T===u6?void 0:T}else if(G.uri!==void 0)B=G.uri.length===0?void 0:G.uri}let J=M2.codes.get(Number(E));if(X[Z+1]===`
7
+ `){if(B)C+=w2("");if(E&&J)C+=S2(J)}else if(A===`
8
+ `){if(E&&J)C+=S2(E);if(B)C+=w2(B)}Y+=A.length}return C};var k2=M(()=>{H2();k0();x2();sF=new Set(["\x1B","›"]),tF=`${C6}8;;`});function VF(D,F){return D.split(`
9
+ `).flatMap((u)=>f0(u,F,{trim:!1,hard:!0}).split(`
10
+ `).map((C)=>C.trimEnd())).join(`
11
+ `)}function oF(){return I2.default({defaultWidth:80,output:S0().output})}var I2;var P0=M(()=>{k2();XD();I2=LF(X2(),1)});function $6({active:D,renderedItems:F,pageSize:u,loop:C}){let E=YD({lastPointer:D,lastActive:void 0}),{lastPointer:B,lastActive:$}=E.current,Q=Math.floor(u/2),z=F.reduce((Z,A)=>Z+A.length,0),X=F.slice(0,D).reduce((Z,A)=>Z+A.length,0),Y=X;if(z>u)if(C){if(Y=B,$!=null&&$<D&&D-$<u)Y=Math.min(Q,Math.abs(D-$)===1?Math.min(B+(F[$]?.length??0),Math.max(X,B)):B+D-$)}else{let Z=F.slice(D).reduce((A,J)=>A+J.length,0);Y=Z<u-Q?u-Z:Math.min(X,Q)}return E.current.lastPointer=Y,E.current.lastActive=D,Y}function b0({items:D,active:F,renderItem:u,pageSize:C,loop:E=!0}){let B=oF(),$=(O)=>(O%D.length+D.length)%D.length,Q=D.map((O,_)=>{if(O==null)return[];return VF(u({item:O,index:_,isActive:_===F}),B).split(`
12
+ `)}),z=Q.reduce((O,_)=>O+_.length,0),X=(O)=>Q[O]??[],Y=$6({active:F,renderedItems:Q,pageSize:C,loop:E}),Z=X(F).slice(0,C),A=Y+Z.length<=C?Y:C-Z.length,J=Array.from({length:C});J.splice(A,Z.length,...Z);let G=new Set([F]),T=A+Z.length,W=$(F+1);while(T<C&&!G.has(W)&&(E&&z>C?W!==F:W>F)){let _=X(W).slice(0,C-T);J.splice(T,_.length,..._),G.add(W),T+=_.length,W=$(W+1)}T=A-1,W=$(F-1);while(T>=0&&!G.has(W)&&(E&&z>C?W!==F:W<F)){let O=X(W),_=O.slice(Math.max(0,O.length-T-1));J.splice(T-_.length+1,_.length,..._),G.add(W),T-=_.length,W=$(W-1)}return J.filter((O)=>typeof O==="string").join(`
13
+ `)}var L2=M(()=>{rF();P0()});var b2=ED((pB,P2)=>{var Z6=Yu("stream");class f2 extends Z6{#u=null;constructor(D={}){super(D);this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=D.replace,this._prompt=D.prompt||null,this._hadControl=!1}#F(D,F){if(this._dest)return this._dest[D];if(this._src)return this._src[D];return F}#D(D,...F){if(typeof this._dest?.[D]==="function")this._dest[D](...F);if(typeof this._src?.[D]==="function")this._src[D](...F)}get isTTY(){if(this.#u!==null)return this.#u;return this.#F("isTTY",!1)}set isTTY(D){this.#u=D}get rows(){return this.#F("rows")}get columns(){return this.#F("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(D){this._src=D}pipe(D,F){return this._dest=D,super.pipe(D,F)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(D){if(this.muted){if(!this.replace)return!0;if(D.match(/^\u001b/)){if(D.indexOf(this._prompt)===0)D=D.slice(this._prompt.length),D=D.replace(/./g,this.replace),D=this._prompt+D;return this._hadControl=!0,this.emit("data",D)}else{if(this._prompt&&this._hadControl&&D.indexOf(this._prompt)===0)this._hadControl=!1,this.emit("data",this._prompt),D=D.slice(this._prompt.length);D=D.toString().replace(/./g,this.replace)}}this.emit("data",D)}end(D){if(this.muted)if(D&&this.replace)D=D.toString().replace(/./g,this.replace);else D=null;if(D)this.emit("data",D);this.emit("end")}destroy(...D){return this.#D("destroy",...D)}destroySoon(...D){return this.#D("destroySoon",...D)}close(...D){return this.#D("close",...D)}}P2.exports=f2});var KD;var v2=M(()=>{KD=[];KD.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")KD.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")KD.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")});class y2{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(y0[v0])return y0[v0];Q6(y0,v0,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(D,F){this.listeners[D].push(F)}removeListener(D,F){let u=this.listeners[D],C=u.indexOf(F);if(C===-1)return;if(C===0&&u.length===1)u.length=0;else u.splice(C,1)}emit(D,F,u){if(this.emitted[D])return!1;this.emitted[D]=!0;let C=!1;for(let E of this.listeners[D])C=E(F,u)===!0||C;if(D==="exit")C=this.emit("afterExit",F,u)||C;return C}}class g0{}var eF=(D)=>!!D&&typeof D==="object"&&typeof D.removeListener==="function"&&typeof D.emit==="function"&&typeof D.reallyExit==="function"&&typeof D.listeners==="function"&&typeof D.kill==="function"&&typeof D.pid==="number"&&typeof D.on==="function",v0,y0,Q6,J6=(D)=>{return{onExit(F,u){return D.onExit(F,u)},load(){return D.load()},unload(){return D.unload()}}},h2,g2,h0,m2,aB,rB;var d2=M(()=>{v2();v0=Symbol.for("signal-exit emitter"),y0=globalThis,Q6=Object.defineProperty.bind(Object);h2=class h2 extends g0{onExit(){return()=>{}}load(){}unload(){}};g2=class g2 extends g0{#u=h0.platform==="win32"?"SIGINT":"SIGHUP";#F=new y2;#D;#B;#A;#E={};#C=!1;constructor(D){super();this.#D=D,this.#E={};for(let F of KD)this.#E[F]=()=>{let u=this.#D.listeners(F),{count:C}=this.#F,E=D;if(typeof E.__signal_exit_emitter__==="object"&&typeof E.__signal_exit_emitter__.count==="number")C+=E.__signal_exit_emitter__.count;if(u.length===C){this.unload();let B=this.#F.emit("exit",null,F),$=F==="SIGHUP"?this.#u:F;if(!B)D.kill(D.pid,$)}};this.#A=D.reallyExit,this.#B=D.emit}onExit(D,F){if(!eF(this.#D))return()=>{};if(this.#C===!1)this.load();let u=F?.alwaysLast?"afterExit":"exit";return this.#F.on(u,D),()=>{if(this.#F.removeListener(u,D),this.#F.listeners.exit.length===0&&this.#F.listeners.afterExit.length===0)this.unload()}}load(){if(this.#C)return;this.#C=!0,this.#F.count+=1;for(let D of KD)try{let F=this.#E[D];if(F)this.#D.on(D,F)}catch(F){}this.#D.emit=(D,...F)=>{return this.#Z(D,...F)},this.#D.reallyExit=(D)=>{return this.#$(D)}}unload(){if(!this.#C)return;this.#C=!1,KD.forEach((D)=>{let F=this.#E[D];if(!F)throw Error("Listener not defined for signal: "+D);try{this.#D.removeListener(D,F)}catch(u){}}),this.#D.emit=this.#B,this.#D.reallyExit=this.#A,this.#F.count-=1}#$(D){if(!eF(this.#D))return 0;return this.#D.exitCode=D||0,this.#F.emit("exit",this.#D.exitCode,null),this.#A.call(this.#D,this.#D.exitCode)}#Z(D,...F){let u=this.#B;if(D==="exit"&&eF(this.#D)){if(typeof F[0]==="number")this.#D.exitCode=F[0];let C=u.call(this.#D,D,...F);return this.#F.emit("exit",this.#D.exitCode,null),C}else return u.call(this.#D,D,...F)}};h0=globalThis.process,{onExit:m2,load:aB,unload:rB}=J6(eF(h0)?new g2(h0):new h2)});var X6="\x1B[G",l2="\x1B[?25l",p2="\x1B[?25h",m0=(D=1)=>D>0?`\x1B[${D}A`:"",d0=(D=1)=>D>0?`\x1B[${D}B`:"",c0=(D,F)=>{if(typeof F==="number"&&!Number.isNaN(F))return`\x1B[${F+1};${D+1}H`;return`\x1B[${D+1}G`},c2="\x1B[2K",l0=(D)=>D>0?(c2+m0(1)).repeat(D-1)+c2+X6:"";import{stripVTControlCharacters as G6}from"node:util";class D0{height=0;extraLinesUnderPrompt=0;cursorPos;rl;constructor(D){this.rl=D,this.cursorPos=D.getCursorPos()}write(D){this.rl.output.unmute(),this.rl.output.write(D),this.rl.output.mute()}render(D,F=""){let u=Y6(D),C=G6(u),E=C;if(this.rl.line.length>0)E=E.slice(0,-this.rl.line.length);this.rl.setPrompt(E),this.cursorPos=this.rl.getCursorPos();let B=oF();if(D=VF(D,B),F=VF(F,B),C.length%B===0)D+=`
14
+ `;let $=D+(F?`
15
+ `+F:""),z=Math.floor(C.length/B)-this.cursorPos.rows+(F?n2(F):0);if(z>0)$+=m0(z);$+=c0(this.cursorPos.cols),this.write(d0(this.extraLinesUnderPrompt)+l0(this.height)+$),this.extraLinesUnderPrompt=z,this.height=n2($)}checkCursorPos(){let D=this.rl.getCursorPos();if(D.cols!==this.cursorPos.cols)this.write(c0(D.cols)),this.cursorPos=D}done({clearContent:D}){this.rl.setPrompt("");let F=d0(this.extraLinesUnderPrompt);F+=D?l0(this.height):`
16
+ `,F+=p2,this.write(F),this.rl.close()}}var n2=(D)=>D.split(`
17
+ `).length,Y6=(D)=>D.split(`
18
+ `).pop()??"";var i2=M(()=>{P0()});var p0;var a2=M(()=>{p0=class p0 extends Promise{static withResolver(){let D,F;return{promise:new Promise((C,E)=>{D=C,F=E}),resolve:D,reject:F}}}});import*as r2 from"node:readline";import{AsyncResource as z6}from"node:async_hooks";function K6(){let D=Error.prepareStackTrace,F=[];try{Error.prepareStackTrace=(u,C)=>{let E=C.slice(1);return F=E,E},Error().stack}catch{return F}return Error.prepareStackTrace=D,F}function qF(D){let F=K6();return(C,E={})=>{let{input:B=process.stdin,signal:$}=E,Q=new Set,z=new t2.default;z.pipe(E.output??process.stdout);let X=r2.createInterface({terminal:!0,input:B,output:z}),Y=new D0(X),{promise:Z,resolve:A,reject:J}=p0.withResolver(),G=()=>J(new M0);if($){let O=()=>J(new q0({cause:$.reason}));if($.aborted)return O(),Object.assign(Z,{cancel:G});$.addEventListener("abort",O),Q.add(()=>$.removeEventListener("abort",O))}Q.add(m2((O,_)=>{J(new lF(`User force closed the prompt with ${O} ${_}`))}));let T=()=>J(new lF("User force closed the prompt with SIGINT"));X.on("SIGINT",T),Q.add(()=>X.removeListener("SIGINT",T));let W=()=>Y.checkCursorPos();return X.input.on("keypress",W),Q.add(()=>X.input.removeListener("keypress",W)),eu(X,(O)=>{let _=z6.bind(()=>JD.clearAll());return X.on("close",_),Q.add(()=>X.removeListener("close",_)),O(()=>{try{let U=D(C,(b)=>{setImmediate(()=>A(b))});if(U===void 0){let b=F[1]?.getFileName();throw Error(`Prompt functions must return a string.
19
+ at ${b}`)}let[S,q]=typeof U==="string"?[U]:U;Y.render(S,q),JD.run()}catch(U){J(U)}}),Object.assign(Z.then((U)=>{return JD.clearAll(),U},(U)=>{throw JD.clearAll(),U}).finally(()=>{Q.forEach((U)=>U()),Y.done({clearContent:Boolean(E.clearPromptOnDone)}),z.end()}).then(()=>Z),{cancel:G})})}}var t2;var s2=M(()=>{d2();i2();a2();XD();pF();t2=LF(b2(),1)});import{styleText as _6}from"node:util";class uD{separator=_6("dim",Array.from({length:15}).join(gD.line));type="separator";constructor(D){if(D)this.separator=D}static isSeparator(D){return Boolean(D&&typeof D==="object"&&"type"in D&&D.type==="separator")}}var o2=M(()=>{aF()});var n0=M(()=>{$2();nF();iF();Z2();rF();Q2();R0();L2();s2();o2();pF()});var W6,j;var e2=M(()=>{n0();W6={validationFailureMode:"keep"},j=qF((D,F)=>{let{prefill:u="tab"}=D,C=GD(W6,D.theme),[E,B]=g("idle"),[$="",Q]=g(D.default),[z,X]=g(),[Y,Z]=g(""),A=TF({status:E,theme:C});async function J(_){let{required:U,pattern:S,patternError:q="Invalid input"}=D;if(U&&!_)return"You must provide a value";if(S&&!S.test(_))return q;if(typeof D.validate==="function")return await D.validate(_)||"You must provide a valid value";return!0}HF(async(_,U)=>{if(E!=="idle")return;if(WF(_)){let S=Y||$;B("loading");let q=await J(S);if(q===!0)Z(S),B("done"),F(S);else{if(C.validationFailureMode==="clear")Z("");else U.write(Y);X(q),B("idle")}}else if(_F(_)&&!Y)Q(void 0);else if(U0(_)&&!Y)Q(void 0),U.clearLine(0),U.write($),Z($);else Z(U.line),X(void 0)}),r((_)=>{if(u==="editable"&&$)_.write($),Z($)},[]);let G=C.style.message(D.message,E),T=Y;if(typeof D.transformer==="function")T=D.transformer(Y,{isFinal:E==="done"});else if(E==="done")T=C.style.answer(Y);let W;if($&&E!=="done"&&!Y)W=C.style.defaultAnswer($);let O="";if(z)O=C.style.error(z);return[[A,G,W,T].filter((_)=>_!==void 0).join(" "),O]})});import{styleText as MF}from"node:util";function mD(D){return!uD.isSeparator(D)&&!D.disabled}function T6(D){return D.map((F)=>{if(uD.isSeparator(F))return F;if(typeof F!=="object"||F===null||!("value"in F)){let E=String(F);return{value:F,name:E,short:E,disabled:!1}}let u=F.name??String(F.value),C={value:F.value,name:u,short:F.short??u,disabled:F.disabled??!1};if(F.description)C.description=F.description;return C})}var O6,dD;var D3=M(()=>{n0();aF();O6={icon:{cursor:gD.pointer},style:{disabled:(D)=>MF("dim",`- ${D}`),description:(D)=>MF("cyan",D),keysHelpTip:(D)=>D.map(([F,u])=>`${MF("bold",F)} ${MF("dim",u)}`).join(MF("dim"," • "))},indexMode:"hidden",keybindings:[]};dD=qF((D,F)=>{let{loop:u=!0,pageSize:C=7}=D,E=GD(O6,D.theme),{keybindings:B}=E,[$,Q]=g("idle"),z=TF({status:$,theme:E}),X=YD(),Y=!B.includes("vim"),Z=NF(()=>T6(D.choices),[D.choices]),A=NF(()=>{let V=Z.findIndex(mD),w=Z.findLastIndex(mD);if(V===-1)throw new OF("[select prompt] No selectable choices. All choices are disabled.");return{first:V,last:w}},[Z]),J=NF(()=>{if(!("default"in D))return-1;return Z.findIndex((V)=>mD(V)&&V.value===D.default)},[D.default,Z]),[G,T]=g(J===-1?A.first:J),W=Z[G];HF((V,w)=>{if(clearTimeout(X.current),WF(V))Q("done"),F(W.value);else if(KF(V,B)||cF(V,B)){if(w.clearLine(0),u||KF(V,B)&&G!==A.first||cF(V,B)&&G!==A.last){let R=KF(V,B)?-1:1,f=G;do f=(f+R+Z.length)%Z.length;while(!mD(Z[f]));T(f)}}else if(V0(V)&&!Number.isNaN(Number(w.line))){let R=Number(w.line)-1,f=-1,h=Z.findIndex((nD)=>{if(uD.isSeparator(nD))return!1;return f++,f===R}),i=Z[h];if(i!=null&&mD(i))T(h);X.current=setTimeout(()=>{w.clearLine(0)},700)}else if(_F(V))w.clearLine(0);else if(Y){let R=w.line.toLowerCase(),f=Z.findIndex((h)=>{if(uD.isSeparator(h)||!mD(h))return!1;return h.name.toLowerCase().startsWith(R)});if(f!==-1)T(f);X.current=setTimeout(()=>{w.clearLine(0)},700)}}),r(()=>()=>{clearTimeout(X.current)},[]);let O=E.style.message(D.message,$),_=E.style.keysHelpTip([["↑↓","navigate"],["⏎","select"]]),U=0,S=b0({items:Z,active:G,renderItem({item:V,isActive:w,index:R}){if(uD.isSeparator(V))return U++,` ${V.separator}`;let f=E.indexMode==="number"?`${R+1-U}. `:"";if(V.disabled){let nD=typeof V.disabled==="string"?V.disabled:"(disabled)";return E.style.disabled(`${f}${V.name} ${nD}`)}let h=w?E.style.highlight:(nD)=>nD,i=w?E.icon.cursor:" ";return h(`${i} ${f}${V.name}`)},pageSize:C,loop:u});if($==="done")return[z,O,E.style.answer(W.short)].filter(Boolean).join(" ");let{description:q}=W;return`${[[z,O].filter(Boolean).join(" "),S," ",q?E.style.description(q):"",_].filter(Boolean).join(`
20
+ `).trimEnd()}${l2}`})});var i0=M(()=>{e2();D3()});var T3;var N3=M(()=>{T3=["subscription.active","subscription.updated","subscription.on_hold","subscription.renewed","subscription.plan_changed","subscription.cancelled","subscription.failed","subscription.expired","payment.success","payment.failed","payment.processing","payment.cancelled","licence.created","refund.success","refund.failed","dispute.opened","dispute.expired","dispute.accepted","dispute.cancelled","dispute.challenged","dispute.won","dispute.lost"]});var CD=({business_id:D="bus_test",product_id:F="pdt_test",subscription_id:u="sub_test",qty:C=1,metadata:E})=>{return{business_id:D,data:{addons:[],billing:{city:"New York",country:"US",state:"New York",street:"11th Main",zipcode:"12345"},cancel_at_next_billing_date:!1,cancelled_at:null,created_at:new Date().toISOString(),currency:"USD",customer:{customer_id:"cus_123456",email:"test@acme.com",name:"Test user",phone_number:null},discount_cycles_remaining:null,discount_id:null,expires_at:null,metadata:E,meters:[],next_billing_date:new Date(new Date().setMonth(new Date().getMonth()+1)),on_demand:!1,payload_type:"Subscription",payment_frequency_count:1,payment_frequency_interval:"Month",previous_billing_date:new Date().toISOString(),product_id:F,quantity:C,recurring_pre_tax_amount:400,status:"active",subscription_id:u,subscription_period_count:10,subscription_period_interval:"Year",tax_inclusive:!1,trial_period_days:0},timestamp:new Date().toISOString()}},H3=(D)=>{return{...CD(D),type:"subscription.active"}},U3=(D)=>{let F=CD(D);return{...F,type:"subscription.updated",data:{...F.data,status:"active"}}},V3=(D)=>{let F=CD(D);return{...F,type:"subscription.on_hold",data:{...F.data,status:"on_hold"}}},q3=(D)=>{return{...CD(D),type:"subscription.renewed"}},M3=(D)=>{let F=CD(D);return{...F,type:"subscription.plan_changed",data:{...F.data,status:"active"}}},x3=(D)=>{let F=CD(D);return{...F,type:"subscription.cancelled",data:{...F.data,cancel_at_next_billing_date:!0,status:"cancelled"}}},S3=(D)=>{let F=CD(D);return{...F,type:"subscription.failed",data:{...F.data,status:"failed"}}},w3=(D)=>{let F=CD(D);return{...F,type:"subscription.expired",data:{...F.data,status:"expired"}}};var R3=()=>{};var B0=({business_id:D="bus_test",product_id:F="pdt_test",qty:u=1})=>{return{business_id:D,data:{billing:{city:"New York",country:"US",state:"New York",street:"New York, New York",zipcode:"12345"},brand_id:D,business_id:D,card_issuing_country:"GB",card_last_four:"4242",card_network:"VISA",card_type:"CREDIT",checkout_session_id:"cks_123",created_at:new Date().toISOString(),currency:"USD",customer:{customer_id:"cus_test",email:"test@acme.com",metadata:{},name:"Test user",phone_number:"+15555550100"},digital_products_delivered:!1,discount_id:null,disputes:[],error_code:null,error_message:null,invoice_id:"inv_test",metadata:{},payload_type:"Payment",payment_id:"pay_test",payment_link:"https://test.checkout.dodopayments.com/cbq",payment_method:"card",payment_method_type:"card",product_cart:[{product_id:F,quantity:u}],refunds:[],settlement_amount:400,settlement_currency:"USD",settlement_tax:null,status:"succeeded",subscription_id:null,tax:null,total_amount:400,updated_at:null},timestamp:new Date().toISOString()}},j3=(D)=>{return{...B0(D),type:"payment.succeeded"}},k3=(D)=>{return{...B0(D),type:"payment.failed"}},I3=(D)=>{return{...B0(D),type:"payment.processing"}},L3=(D)=>{return{...B0(D),type:"payment.cancelled"}};var f3=()=>{};var P3=({business_id:D="bus_test"})=>{return{business_id:D,data:{amount:400,business_id:D,created_at:new Date().toISOString(),currency:"USD",customer:{customer_id:"cus_test",email:"test@acme.com",name:"Test user",phone_number:null},is_partial:!1,payload_type:"Refund",payment_id:"pay_test",reason:"Testing success refund",refund_id:"ref_test",status:"succeeded"},timestamp:new Date().toISOString()}},b3=(D)=>{return{...P3(D),type:"refund.succeeded"}},v3=(D)=>{return{...P3(D),type:"refund.failed"}};var y3=()=>{};var WD=({business_id:D="bus_test"})=>{return{business_id:D,data:{amount:400,business_id:D,created_at:new Date().toISOString(),currency:"USD",customer:{customer_id:"cus_test",email:"test@acme.com",name:"Test user",phone_number:"+447700900123"},dispute_id:"dp_test",dispute_stage:"dispute",dispute_status:"dispute_opened",payload_type:"Dispute",payment_id:"pay_test",reason:"testing dispute",remarks:null},timestamp:new Date().toISOString()}},h3=(D)=>{let F=WD(D);return{...F,type:"dispute.opened",data:{...F.data,dispute_status:"dispute_opened"}}},g3=(D)=>{let F=WD(D);return{...F,type:"dispute.expired",data:{...F.data,dispute_status:"dispute_expired"}}},m3=(D)=>{let F=WD(D);return{...F,type:"dispute.accepted",data:{...F.data,dispute_status:"dispute_accepted"}}},d3=(D)=>{let F=WD(D);return{...F,type:"dispute.cancelled",data:{...F.data,dispute_status:"dispute_cancelled"}}},c3=(D)=>{let F=WD(D);return{...F,type:"dispute.challenged",data:{...F.data,dispute_status:"dispute_challenged"}}},l3=(D)=>{let F=WD(D);return{...F,type:"dispute.won",data:{...F.data,dispute_status:"dispute_won"}}},p3=(D)=>{let F=WD(D);return{...F,type:"dispute.lost",data:{...F.data,dispute_status:"dispute_lost"}}};var n3=()=>{};var uC=({business_id:D="bus_test",product_id:F="pdt_test",subscription_id:u})=>{return{business_id:D,data:{activations_limit:null,business_id:D,created_at:new Date().toISOString(),customer_id:"cus_test",expires_at:null,id:"lic_test",instances_count:0,key:"db44b22c-fe9b-4a68-bf0d-b0e0d6c6c8c0",payload_type:"LicenseKey",payment_id:"pay_test",product_id:F,status:"active",subscription_id:u},timestamp:new Date().toISOString()}},i3=(D)=>{return{...uC(D),type:"license_key.created"}};var a3=()=>{};var BC={};var CC,wF,Qu,EC;var r3=M(async()=>{i0();N3();R3();f3();y3();n3();a3();CC=await j({message:"What is your endpoint?",validate:(D)=>{if(!D.startsWith("http"))return"Please enter a valid URL starting with http or https";return!0}}),wF=await j({message:"What is your Dodo Payments business ID? (Optional)",default:"bus_test"}),Qu=await j({message:"What is your product ID? (Optional)",default:"pdt_test"}),EC=await j({message:"What is your metadata? (JSON stringified, Optional)",default:"{}"});while(!0){let D=await dD({message:"Select an event to send:",choices:[...T3,"exit"].map((C)=>({value:C,name:C})),loop:!1});if(D==="exit")console.log("Exiting..."),process.exit();let F,u=JSON.parse(EC);if(D.startsWith("subscription.")){let C={business_id:wF,product_id:Qu,metadata:u};if(D==="subscription.active")F=H3(C);else if(D==="subscription.updated")F=U3(C);else if(D==="subscription.on_hold")F=V3(C);else if(D==="subscription.renewed")F=q3(C);else if(D==="subscription.plan_changed")F=M3(C);else if(D==="subscription.cancelled")F=x3(C);else if(D==="subscription.failed")F=S3(C);else if(D==="subscription.expired")F=w3(C)}if(D.startsWith("payment.")){let C={business_id:wF,product_id:Qu,metadata:u};if(D==="payment.success")F=j3(C);else if(D==="payment.failed")F=k3(C);else if(D==="payment.processing")F=I3(C);else if(D==="payment.cancelled")F=L3(C)}if(D.startsWith("refund.")){let C={business_id:wF};if(D==="refund.success")F=b3(C);else if(D==="refund.failed")F=v3(C)}if(D.startsWith("dispute.")){let C={business_id:wF};if(D==="dispute.opened")F=h3(C);else if(D==="dispute.expired")F=g3(C);else if(D==="dispute.accepted")F=m3(C);else if(D==="dispute.cancelled")F=d3(C);else if(D==="dispute.challenged")F=c3(C);else if(D==="dispute.won")F=l3(C);else if(D==="dispute.lost")F=p3(C)}if(D.startsWith("licence.")){let C={business_id:wF,product_id:Qu};if(D==="licence.created")F=i3(C)}await fetch(CC,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)}).then(async(C)=>{console.log(`✅ Webhook Event Sent!
21
+ Received Response Code: ${C.status}
22
+ Received Response Body: ${await C.text()}`),console.log()}).catch((C)=>{console.error("❌ Webhook Event Failed:",C),console.log()})}});import AC from"node:os";import jF from"node:path";function ND(D,F,u,C,E){if(C==="m")throw TypeError("Private method is not writable");if(C==="a"&&!E)throw TypeError("Private accessor was defined without a setter");if(typeof F==="function"?D!==F||!E:!F.has(D))throw TypeError("Cannot write private member to an object whose class did not declare it");return C==="a"?E.call(D,u):E?E.value=u:F.set(D,u),u}function s(D,F,u,C){if(u==="a"&&!C)throw TypeError("Private accessor was defined without a getter");if(typeof F==="function"?D!==F||!C:!F.has(D))throw TypeError("Cannot read private member from an object whose class did not declare it");return u==="m"?C:u==="a"?C.call(D):C?C.value:F.get(D)}var Z0=function(){let{crypto:D}=globalThis;if(D?.randomUUID)return Z0=D.randomUUID.bind(D),D.randomUUID();let F=new Uint8Array(1),u=D?()=>D.getRandomValues(F)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(C)=>(+C^u()&15>>+C/4).toString(16))};function zu(D){return typeof D==="object"&&D!==null&&(("name"in D)&&D.name==="AbortError"||("message"in D)&&String(D.message).includes("FetchRequestCanceledException"))}var iD=(D)=>{if(D instanceof Error)return D;if(typeof D==="object"&&D!==null){try{if(Object.prototype.toString.call(D)==="[object Error]"){let F=Error(D.message,D.cause?{cause:D.cause}:{});if(D.stack)F.stack=D.stack;if(D.cause&&!F.cause)F.cause=D.cause;if(D.name)F.name=D.name;return F}}catch{}try{return Error(JSON.stringify(D))}catch{}}return Error(D)};class v extends Error{}class P extends v{constructor(D,F,u,C){super(`${P.makeMessage(D,F,u)}`);this.status=D,this.headers=C,this.error=F}static makeMessage(D,F,u){let C=F?.message?typeof F.message==="string"?F.message:JSON.stringify(F.message):F?JSON.stringify(F):u;if(D&&C)return`${D} ${C}`;if(D)return`${D} status code (no body)`;if(C)return C;return"(no status code or body)"}static generate(D,F,u,C){if(!D||!C)return new BD({message:u,cause:iD(F)});let E=F;if(D===400)return new rD(D,E,u,C);if(D===401)return new tD(D,E,u,C);if(D===403)return new sD(D,E,u,C);if(D===404)return new oD(D,E,u,C);if(D===409)return new eD(D,E,u,C);if(D===422)return new DF(D,E,u,C);if(D===429)return new FF(D,E,u,C);if(D>=500)return new uF(D,E,u,C);return new P(D,E,u,C)}}class HD extends P{constructor({message:D}={}){super(void 0,void 0,D||"Request was aborted.",void 0)}}class BD extends P{constructor({message:D,cause:F}){super(void 0,void 0,D||"Connection error.",void 0);if(F)this.cause=F}}class aD extends BD{constructor({message:D}={}){super({message:D??"Request timed out."})}}class rD extends P{}class tD extends P{}class sD extends P{}class oD extends P{}class eD extends P{}class DF extends P{}class FF extends P{}class uF extends P{}var E8=/^[a-z][a-z0-9+.-]*:/i,Ku=(D)=>{return E8.test(D)},Q0=(D)=>(Q0=Array.isArray,Q0(D)),J0=Q0;function X0(D){if(typeof D!=="object")return{};return D??{}}function _u(D){if(!D)return!0;for(let F in D)return!1;return!0}function Wu(D,F){return Object.prototype.hasOwnProperty.call(D,F)}var Ou=(D,F)=>{if(typeof F!=="number"||!Number.isInteger(F))throw new v(`${D} must be an integer`);if(F<0)throw new v(`${D} must be a positive integer`);return F};var Tu=(D)=>{try{return JSON.parse(D)}catch(F){return}};var Nu=(D)=>new Promise((F)=>setTimeout(F,D));var o="2.17.1";function B8(){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 A8=()=>{let D=B8();if(D==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":o,"X-Stainless-OS":Uu(Deno.build.os),"X-Stainless-Arch":Hu(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":o,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(D==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":o,"X-Stainless-OS":Uu(globalThis.process.platform??"unknown"),"X-Stainless-Arch":Hu(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let F=$8();if(F)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":o,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${F.browser}`,"X-Stainless-Runtime-Version":F.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":o,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function $8(){if(typeof navigator>"u"||!navigator)return null;let D=[{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:F,pattern:u}of D){let C=u.exec(navigator.userAgent);if(C){let E=C[1]||0,B=C[2]||0,$=C[3]||0;return{browser:F,version:`${E}.${B}.${$}`}}}return null}var Hu=(D)=>{if(D==="x32")return"x32";if(D==="x86_64"||D==="x64")return"x64";if(D==="arm")return"arm";if(D==="aarch64"||D==="arm64")return"arm64";if(D)return`other:${D}`;return"unknown"},Uu=(D)=>{if(D=D.toLowerCase(),D.includes("ios"))return"iOS";if(D==="android")return"Android";if(D==="darwin")return"MacOS";if(D==="win32")return"Windows";if(D==="freebsd")return"FreeBSD";if(D==="openbsd")return"OpenBSD";if(D==="linux")return"Linux";if(D)return`Other:${D}`;return"Unknown"},Vu,qu=()=>{return Vu??(Vu=A8())};function Mu(){if(typeof fetch<"u")return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new DodoPayments({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function Z8(...D){let F=globalThis.ReadableStream;if(typeof F>"u")throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new F(...D)}function G0(D){let F=Symbol.asyncIterator in D?D[Symbol.asyncIterator]():D[Symbol.iterator]();return Z8({start(){},async pull(u){let{done:C,value:E}=await F.next();if(C)u.close();else u.enqueue(E)},async cancel(){await F.return?.()}})}async function xu(D){if(D===null||typeof D!=="object")return;if(D[Symbol.asyncIterator]){await D[Symbol.asyncIterator]().return?.();return}let F=D.getReader(),u=F.cancel();F.releaseLock(),await u}var Su=({headers:D,body:F})=>{return{bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(F)}};var PF={off:0,error:200,warn:300,info:400,debug:500},Y0=(D,F,u)=>{if(!D)return;if(Wu(PF,D))return D;y(u).warn(`${F} was set to ${JSON.stringify(D)}, expected one of ${JSON.stringify(Object.keys(PF))}`);return};function CF(){}function fF(D,F,u){if(!F||PF[D]>PF[u])return CF;else return F[D].bind(F)}var X8={error:CF,warn:CF,info:CF,debug:CF},wu=new WeakMap;function y(D){let F=D.logger,u=D.logLevel??"off";if(!F)return X8;let C=wu.get(F);if(C&&C[0]===u)return C[1];let E={error:fF("error",F,u),warn:fF("warn",F,u),info:fF("info",F,u),debug:fF("debug",F,u)};return wu.set(F,[u,E]),E}var a=(D)=>{if(D.options)D.options={...D.options},delete D.options.headers;if(D.headers)D.headers=Object.fromEntries((D.headers instanceof Headers?[...D.headers]:Object.entries(D.headers)).map(([F,u])=>[F,F.toLowerCase()==="authorization"||F.toLowerCase()==="cookie"||F.toLowerCase()==="set-cookie"?"***":u]));if("retryOfRequestLogID"in D){if(D.retryOfRequestLogID)D.retryOf=D.retryOfRequestLogID;delete D.retryOfRequestLogID}return D};async function bF(D,F){let{response:u,requestLogID:C,retryOfRequestLogID:E,startTime:B}=F,$=await(async()=>{if(u.status===204)return null;if(F.options.__binaryResponse)return u;let z=u.headers.get("content-type")?.split(";")[0]?.trim();if(z?.includes("application/json")||z?.endsWith("+json"))return await u.json();return await u.text()})();return y(D).debug(`[${C}] response parsed`,a({retryOfRequestLogID:E,url:u.url,status:u.status,body:$,durationMs:Date.now()-B})),$}var EF;class AD extends Promise{constructor(D,F,u=bF){super((C)=>{C(null)});this.responsePromise=F,this.parseResponse=u,EF.set(this,void 0),ND(this,EF,D,"f")}_thenUnwrap(D){return new AD(s(this,EF,"f"),this.responsePromise,async(F,u)=>D(await this.parseResponse(F,u),u))}asResponse(){return this.responsePromise.then((D)=>D.response)}async withResponse(){let[D,F]=await Promise.all([this.parse(),this.asResponse()]);return{data:D,response:F}}parse(){if(!this.parsedPromise)this.parsedPromise=this.responsePromise.then((D)=>this.parseResponse(s(this,EF,"f"),D));return this.parsedPromise}then(D,F){return this.parse().then(D,F)}catch(D){return this.parse().catch(D)}finally(D){return this.parse().finally(D)}}EF=new WeakMap;var vF;class z0{constructor(D,F,u,C){vF.set(this,void 0),ND(this,vF,D,"f"),this.options=C,this.response=F,this.body=u}hasNextPage(){if(!this.getPaginatedItems().length)return!1;return this.nextPageRequestOptions()!=null}async getNextPage(){let D=this.nextPageRequestOptions();if(!D)throw new v("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await s(this,vF,"f").requestAPIList(this.constructor,D)}async*iterPages(){let D=this;yield D;while(D.hasNextPage())D=await D.getNextPage(),yield D}async*[(vF=new WeakMap,Symbol.asyncIterator)](){for await(let D of this.iterPages())for(let F of D.getPaginatedItems())yield F}}class yF extends AD{constructor(D,F,u){super(D,F,async(C,E)=>new u(C,E.response,await bF(C,E),E.options))}async*[Symbol.asyncIterator](){let D=await this;for await(let F of D)yield F}}class x extends z0{constructor(D,F,u,C){super(D,F,u,C);this.items=u.items||[]}getPaginatedItems(){return this.items??[]}nextPageRequestOptions(){let F=this.options.query?.page_number??1;return{...this.options,query:{...X0(this.options.query),page_number:F+1}}}}class K0 extends z0{constructor(D,F,u,C){super(D,F,u,C);this.data=u.data||[],this.iterator=u.iterator||"",this.done=u.done||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.done===!1)return!1;return super.hasNextPage()}nextPageRequestOptions(){let D=this.iterator;if(!D)return null;return{...this.options,query:{...X0(this.options.query),iterator:D}}}}var _0=()=>{if(typeof File>"u"){let{process:D}=globalThis,F=typeof D?.versions?.node==="string"&&parseInt(D.versions.node.split("."))<20;throw Error("`File` is not defined as a global, which is required for file uploads."+(F?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function hF(D,F,u){return _0(),new File(D,F??"unknown_file",u)}function Ru(D){return(typeof D==="object"&&D!==null&&(("name"in D)&&D.name&&String(D.name)||("url"in D)&&D.url&&String(D.url)||("filename"in D)&&D.filename&&String(D.filename)||("path"in D)&&D.path&&String(D.path))||"").split(/[\\/]/).pop()||void 0}var ju=(D)=>D!=null&&typeof D==="object"&&typeof D[Symbol.asyncIterator]==="function";var ku=(D)=>D!=null&&typeof D==="object"&&typeof D.size==="number"&&typeof D.type==="string"&&typeof D.text==="function"&&typeof D.slice==="function"&&typeof D.arrayBuffer==="function",Y8=(D)=>D!=null&&typeof D==="object"&&typeof D.name==="string"&&typeof D.lastModified==="number"&&ku(D),z8=(D)=>D!=null&&typeof D==="object"&&typeof D.url==="string"&&typeof D.blob==="function";async function gF(D,F,u){if(_0(),D=await D,Y8(D)){if(D instanceof File)return D;return hF([await D.arrayBuffer()],D.name)}if(z8(D)){let E=await D.blob();return F||(F=new URL(D.url).pathname.split(/[\\/]/).pop()),hF(await W0(E),F,u)}let C=await W0(D);if(F||(F=Ru(D)),!u?.type){let E=C.find((B)=>typeof B==="object"&&("type"in B)&&B.type);if(typeof E==="string")u={...u,type:E}}return hF(C,F,u)}async function W0(D){let F=[];if(typeof D==="string"||ArrayBuffer.isView(D)||D instanceof ArrayBuffer)F.push(D);else if(ku(D))F.push(D instanceof Blob?D:await D.arrayBuffer());else if(ju(D))for await(let u of D)F.push(...await W0(u));else{let u=D?.constructor?.name;throw Error(`Unexpected data type: ${typeof D}${u?`; constructor: ${u}`:""}${K8(D)}`)}return F}function K8(D){if(typeof D!=="object"||D===null)return"";return`; props: [${Object.getOwnPropertyNames(D).map((u)=>`"${u}"`).join(", ")}]`}class N{constructor(D){this._client=D}}function Lu(D){return D.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var Iu=Object.freeze(Object.create(null)),W8=(D=Lu)=>function(u,...C){if(u.length===1)return u[0];let E=!1,B=[],$=u.reduce((Y,Z,A)=>{if(/[?#]/.test(Z))E=!0;let J=C[A],G=(E?encodeURIComponent:D)(""+J);if(A!==C.length&&(J==null||typeof J==="object"&&J.toString===Object.getPrototypeOf(Object.getPrototypeOf(J.hasOwnProperty??Iu)??Iu)?.toString))G=J+"",B.push({start:Y.length+Z.length,length:G.length,error:`Value of type ${Object.prototype.toString.call(J).slice(8,-1)} is not a valid path parameter`});return Y+Z+(A===C.length?"":G)},""),Q=$.split(/[?#]/,1)[0],z=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,X;while((X=z.exec(Q))!==null)B.push({start:X.index,length:X[0].length,error:`Value "${X[0]}" can't be safely passed as a path parameter`});if(B.sort((Y,Z)=>Y.start-Z.start),B.length>0){let Y=0,Z=B.reduce((A,J)=>{let G=" ".repeat(J.start-Y),T="^".repeat(J.length);return Y=J.start+J.length,A+G+T},"");throw new v(`Path parameters result in path with invalid segments:
23
+ ${B.map((A)=>A.error).join(`
24
+ `)}
25
+ ${$}
26
+ ${Z}`)}return $},K=W8(Lu);class UD extends N{create(D,F){return this._client.post("/addons",{body:D,...F})}retrieve(D,F){return this._client.get(K`/addons/${D}`,F)}update(D,F,u){return this._client.patch(K`/addons/${D}`,{body:F,...u})}list(D={},F){return this._client.getAPIList("/addons",x,{query:D,...F})}updateImages(D,F){return this._client.put(K`/addons/${D}/images`,F)}}class VD extends N{create(D,F){return this._client.post("/brands",{body:D,...F})}retrieve(D,F){return this._client.get(K`/brands/${D}`,F)}update(D,F,u){return this._client.patch(K`/brands/${D}`,{body:F,...u})}list(D){return this._client.get("/brands",D)}updateImages(D,F){return this._client.put(K`/brands/${D}/images`,F)}}class qD extends N{create(D,F){return this._client.post("/checkouts",{body:D,...F})}retrieve(D,F){return this._client.get(K`/checkouts/${D}`,F)}preview(D,F){return this._client.post("/checkouts/preview",{body:D,...F})}}class BF extends N{create(D,F={},u){let{send_email:C}=F??{};return this._client.post(K`/customers/${D}/customer-portal/session`,{query:{send_email:C},...u})}}class AF extends N{create(D,F,u){return this._client.post(K`/customers/${D}/wallets/ledger-entries`,{body:F,...u})}list(D,F={},u){return this._client.getAPIList(K`/customers/${D}/wallets/ledger-entries`,x,{query:F,...u})}}class MD extends N{constructor(){super(...arguments);this.ledgerEntries=new AF(this._client)}list(D,F){return this._client.get(K`/customers/${D}/wallets`,F)}}MD.LedgerEntries=AF;class e extends N{constructor(){super(...arguments);this.customerPortal=new BF(this._client),this.wallets=new MD(this._client)}create(D,F){return this._client.post("/customers",{body:D,...F})}retrieve(D,F){return this._client.get(K`/customers/${D}`,F)}update(D,F,u){return this._client.patch(K`/customers/${D}`,{body:F,...u})}list(D={},F){return this._client.getAPIList("/customers",x,{query:D,...F})}retrievePaymentMethods(D,F){return this._client.get(K`/customers/${D}/payment-methods`,F)}}e.CustomerPortal=BF;e.Wallets=MD;var fu=Symbol("brand.privateNullableHeaders");function*H8(D){if(!D)return;if(fu in D){let{values:C,nulls:E}=D;yield*C.entries();for(let B of E)yield[B,null];return}let F=!1,u;if(D instanceof Headers)u=D.entries();else if(J0(D))u=D;else F=!0,u=Object.entries(D??{});for(let C of u){let E=C[0];if(typeof E!=="string")throw TypeError("expected header name to be a string");let B=J0(C[1])?C[1]:[C[1]],$=!1;for(let Q of B){if(Q===void 0)continue;if(F&&!$)$=!0,yield[E,null];yield[E,Q]}}}var k=(D)=>{let F=new Headers,u=new Set;for(let C of D){let E=new Set;for(let[B,$]of H8(C)){let Q=B.toLowerCase();if(!E.has(Q))F.delete(B),E.add(Q);if($===null)F.delete(B),u.add(Q);else F.append(B,$),u.delete(Q)}}return{[fu]:!0,values:F,nulls:u}};class xD extends N{create(D,F){return this._client.post("/discounts",{body:D,...F})}retrieve(D,F){return this._client.get(K`/discounts/${D}`,F)}update(D,F,u){return this._client.patch(K`/discounts/${D}`,{body:F,...u})}list(D={},F){return this._client.getAPIList("/discounts",x,{query:D,...F})}delete(D,F){return this._client.delete(K`/discounts/${D}`,{...F,headers:k([{Accept:"*/*"},F?.headers])})}retrieveByCode(D,F){return this._client.get(K`/discounts/code/${D}`,F)}}class SD extends N{retrieve(D,F){return this._client.get(K`/disputes/${D}`,F)}list(D={},F){return this._client.getAPIList("/disputes",x,{query:D,...F})}}class $F extends N{retrieve(D,F){return this._client.get(K`/invoices/payments/${D}`,{...F,headers:k([{Accept:"application/pdf"},F?.headers]),__binaryResponse:!0})}retrieveRefund(D,F){return this._client.get(K`/invoices/refunds/${D}`,{...F,headers:k([{Accept:"application/pdf"},F?.headers]),__binaryResponse:!0})}}class $D extends N{constructor(){super(...arguments);this.payments=new $F(this._client)}}$D.Payments=$F;class wD extends N{retrieve(D,F){return this._client.get(K`/license_key_instances/${D}`,F)}update(D,F,u){return this._client.patch(K`/license_key_instances/${D}`,{body:F,...u})}list(D={},F){return this._client.getAPIList("/license_key_instances",x,{query:D,...F})}}class RD extends N{retrieve(D,F){return this._client.get(K`/license_keys/${D}`,F)}update(D,F,u){return this._client.patch(K`/license_keys/${D}`,{body:F,...u})}list(D={},F){return this._client.getAPIList("/license_keys",x,{query:D,...F})}}class jD extends N{activate(D,F){return this._client.post("/licenses/activate",{body:D,...F})}deactivate(D,F){return this._client.post("/licenses/deactivate",{body:D,...F,headers:k([{Accept:"*/*"},F?.headers])})}validate(D,F){return this._client.post("/licenses/validate",{body:D,...F})}}class kD extends N{create(D,F){return this._client.post("/meters",{body:D,...F})}retrieve(D,F){return this._client.get(K`/meters/${D}`,F)}list(D={},F){return this._client.getAPIList("/meters",x,{query:D,...F})}archive(D,F){return this._client.delete(K`/meters/${D}`,{...F,headers:k([{Accept:"*/*"},F?.headers])})}unarchive(D,F){return this._client.post(K`/meters/${D}/unarchive`,{...F,headers:k([{Accept:"*/*"},F?.headers])})}}class ID extends N{listSupportedCountries(D){return this._client.get("/checkout/supported_countries",D)}}class LD extends N{create(D,F){return this._client.post("/payments",{body:D,...F})}retrieve(D,F){return this._client.get(K`/payments/${D}`,F)}list(D={},F){return this._client.getAPIList("/payments",x,{query:D,...F})}retrieveLineItems(D,F){return this._client.get(K`/payments/${D}/line-items`,F)}}class fD extends N{list(D={},F){return this._client.getAPIList("/payouts",x,{query:D,...F})}}class ZF extends N{update(D,F={},u){let{force_update:C}=F??{};return this._client.put(K`/products/${D}/images`,{query:{force_update:C},...u})}}class QF extends N{create(D,F,u){return this._client.post(K`/products/${D}/short_links`,{body:F,...u})}list(D={},F){return this._client.getAPIList("/products/short_links",x,{query:D,...F})}}class DD extends N{constructor(){super(...arguments);this.images=new ZF(this._client),this.shortLinks=new QF(this._client)}create(D,F){return this._client.post("/products",{body:D,...F})}retrieve(D,F){return this._client.get(K`/products/${D}`,F)}update(D,F,u){return this._client.patch(K`/products/${D}`,{body:F,...u,headers:k([{Accept:"*/*"},u?.headers])})}list(D={},F){return this._client.getAPIList("/products",x,{query:D,...F})}archive(D,F){return this._client.delete(K`/products/${D}`,{...F,headers:k([{Accept:"*/*"},F?.headers])})}unarchive(D,F){return this._client.post(K`/products/${D}/unarchive`,{...F,headers:k([{Accept:"*/*"},F?.headers])})}updateFiles(D,F,u){return this._client.put(K`/products/${D}/files`,{body:F,...u})}}DD.Images=ZF;DD.ShortLinks=QF;class PD extends N{create(D,F){return this._client.post("/refunds",{body:D,...F})}retrieve(D,F){return this._client.get(K`/refunds/${D}`,F)}list(D={},F){return this._client.getAPIList("/refunds",x,{query:D,...F})}}class bD extends N{create(D,F){return this._client.post("/subscriptions",{body:D,...F})}retrieve(D,F){return this._client.get(K`/subscriptions/${D}`,F)}update(D,F,u){return this._client.patch(K`/subscriptions/${D}`,{body:F,...u})}list(D={},F){return this._client.getAPIList("/subscriptions",x,{query:D,...F})}changePlan(D,F,u){return this._client.post(K`/subscriptions/${D}/change-plan`,{body:F,...u,headers:k([{Accept:"*/*"},u?.headers])})}charge(D,F,u){return this._client.post(K`/subscriptions/${D}/charge`,{body:F,...u})}previewChangePlan(D,F,u){return this._client.post(K`/subscriptions/${D}/change-plan/preview`,{body:F,...u})}retrieveUsageHistory(D,F={},u){return this._client.getAPIList(K`/subscriptions/${D}/usage-history`,x,{query:F,...u})}updatePaymentMethod(D,F,u){return this._client.post(K`/subscriptions/${D}/update-payment-method`,{body:F,...u})}}class vD extends N{retrieve(D,F){return this._client.get(K`/events/${D}`,F)}list(D={},F){return this._client.getAPIList("/events",x,{query:D,...F})}ingest(D,F){return this._client.post("/events/ingest",{body:D,...F})}}class yD extends N{}class JF extends N{retrieve(D,F){return this._client.get(K`/webhooks/${D}/headers`,F)}update(D,F,u){return this._client.patch(K`/webhooks/${D}/headers`,{body:F,...u,headers:k([{Accept:"*/*"},u?.headers])})}}var ru=LF(au(),1);class ZD extends N{constructor(){super(...arguments);this.headers=new JF(this._client)}create(D,F){return this._client.post("/webhooks",{body:D,...F})}retrieve(D,F){return this._client.get(K`/webhooks/${D}`,F)}update(D,F,u){return this._client.patch(K`/webhooks/${D}`,{body:F,...u})}list(D={},F){return this._client.getAPIList("/webhooks",K0,{query:D,...F})}delete(D,F){return this._client.delete(K`/webhooks/${D}`,{...F,headers:k([{Accept:"*/*"},F?.headers])})}retrieveSecret(D,F){return this._client.get(K`/webhooks/${D}/secret`,F)}unsafeUnwrap(D){return JSON.parse(D)}unwrap(D,{headers:F,key:u}){if(F!==void 0){let C=u===void 0?this._client.webhookKey:u;if(C===null)throw Error("Webhook key must not be null in order to unwrap");new ru.Webhook(C).verify(D,F)}return JSON.parse(D)}}ZD.Headers=JF;var YF=(D)=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[D]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(D)?.trim();return};var N0,H0,dF,tu,su={live_mode:"https://live.dodopayments.com",test_mode:"https://test.dodopayments.com"};class H{constructor({baseURL:D=YF("DODO_PAYMENTS_BASE_URL"),bearerToken:F=YF("DODO_PAYMENTS_API_KEY"),webhookKey:u=YF("DODO_PAYMENTS_WEBHOOK_KEY")??null,...C}={}){if(N0.add(this),dF.set(this,void 0),this.checkoutSessions=new qD(this),this.payments=new LD(this),this.subscriptions=new bD(this),this.invoices=new $D(this),this.licenses=new jD(this),this.licenseKeys=new RD(this),this.licenseKeyInstances=new wD(this),this.customers=new e(this),this.refunds=new PD(this),this.disputes=new SD(this),this.payouts=new fD(this),this.products=new DD(this),this.misc=new ID(this),this.discounts=new xD(this),this.addons=new UD(this),this.brands=new VD(this),this.webhooks=new ZD(this),this.webhookEvents=new yD(this),this.usageEvents=new vD(this),this.meters=new kD(this),F===void 0)throw new v("The DODO_PAYMENTS_API_KEY environment variable is missing or empty; either provide it, or instantiate the DodoPayments client with an bearerToken option, like new DodoPayments({ bearerToken: 'My Bearer Token' }).");let E={bearerToken:F,webhookKey:u,...C,baseURL:D,environment:C.environment??"live_mode"};if(D&&C.environment)throw new v("Ambiguous URL; The `baseURL` option (or DODO_PAYMENTS_BASE_URL env var) and the `environment` option are given. If you want to use the environment you must pass baseURL: null");this.baseURL=E.baseURL||su[E.environment||"live_mode"],this.timeout=E.timeout??H0.DEFAULT_TIMEOUT,this.logger=E.logger??console;let B="warn";this.logLevel=B,this.logLevel=Y0(E.logLevel,"ClientOptions.logLevel",this)??Y0(YF("DODO_PAYMENTS_LOG"),"process.env['DODO_PAYMENTS_LOG']",this)??B,this.fetchOptions=E.fetchOptions,this.maxRetries=E.maxRetries??2,this.fetch=E.fetch??Mu(),ND(this,dF,Su,"f"),this._options=E,this.bearerToken=F,this.webhookKey=u}withOptions(D){return new this.constructor({...this._options,environment:D.environment?D.environment:void 0,baseURL:D.environment?void 0:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,bearerToken:this.bearerToken,webhookKey:this.webhookKey,...D})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:D,nulls:F}){return}async authHeaders(D){return k([{Authorization:`Bearer ${this.bearerToken}`}])}stringifyQuery(D){return Object.entries(D).filter(([F,u])=>typeof u<"u").map(([F,u])=>{if(typeof u==="string"||typeof u==="number"||typeof u==="boolean")return`${encodeURIComponent(F)}=${encodeURIComponent(u)}`;if(u===null)return`${encodeURIComponent(F)}=`;throw new v(`Cannot stringify type ${typeof u}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}getUserAgent(){return`${this.constructor.name}/JS ${o}`}defaultIdempotencyKey(){return`stainless-node-retry-${Z0()}`}makeStatusError(D,F,u,C){return P.generate(D,F,u,C)}buildURL(D,F,u){let C=!s(this,N0,"m",tu).call(this)&&u||this.baseURL,E=Ku(D)?new URL(D):new URL(C+(C.endsWith("/")&&D.startsWith("/")?D.slice(1):D)),B=this.defaultQuery();if(!_u(B))F={...B,...F};if(typeof F==="object"&&F&&!Array.isArray(F))E.search=this.stringifyQuery(F);return E.toString()}async prepareOptions(D){}async prepareRequest(D,{url:F,options:u}){}get(D,F){return this.methodRequest("get",D,F)}post(D,F){return this.methodRequest("post",D,F)}patch(D,F){return this.methodRequest("patch",D,F)}put(D,F){return this.methodRequest("put",D,F)}delete(D,F){return this.methodRequest("delete",D,F)}methodRequest(D,F,u){return this.request(Promise.resolve(u).then((C)=>{return{method:D,path:F,...C}}))}request(D,F=null){return new AD(this,this.makeRequest(D,F,void 0))}async makeRequest(D,F,u){let C=await D,E=C.maxRetries??this.maxRetries;if(F==null)F=E;await this.prepareOptions(C);let{req:B,url:$,timeout:Q}=await this.buildRequest(C,{retryCount:E-F});await this.prepareRequest(B,{url:$,options:C});let z="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),X=u===void 0?"":`, retryOf: ${u}`,Y=Date.now();if(y(this).debug(`[${z}] sending request`,a({retryOfRequestLogID:u,method:C.method,url:$,options:C,headers:B.headers})),C.signal?.aborted)throw new HD;let Z=new AbortController,A=await this.fetchWithTimeout($,B,Q,Z).catch(iD),J=Date.now();if(A instanceof globalThis.Error){let T=`retrying, ${F} attempts remaining`;if(C.signal?.aborted)throw new HD;let W=zu(A)||/timed? ?out/i.test(String(A)+("cause"in A?String(A.cause):""));if(F)return y(this).info(`[${z}] connection ${W?"timed out":"failed"} - ${T}`),y(this).debug(`[${z}] connection ${W?"timed out":"failed"} (${T})`,a({retryOfRequestLogID:u,url:$,durationMs:J-Y,message:A.message})),this.retryRequest(C,F,u??z);if(y(this).info(`[${z}] connection ${W?"timed out":"failed"} - error; no more retries left`),y(this).debug(`[${z}] connection ${W?"timed out":"failed"} (error; no more retries left)`,a({retryOfRequestLogID:u,url:$,durationMs:J-Y,message:A.message})),W)throw new aD;throw new BD({cause:A})}let G=`[${z}${X}] ${B.method} ${$} ${A.ok?"succeeded":"failed"} with status ${A.status} in ${J-Y}ms`;if(!A.ok){let T=await this.shouldRetry(A);if(F&&T){let q=`retrying, ${F} attempts remaining`;return await xu(A.body),y(this).info(`${G} - ${q}`),y(this).debug(`[${z}] response error (${q})`,a({retryOfRequestLogID:u,url:A.url,status:A.status,headers:A.headers,durationMs:J-Y})),this.retryRequest(C,F,u??z,A.headers)}let W=T?"error; no more retries left":"error; not retryable";y(this).info(`${G} - ${W}`);let O=await A.text().catch((q)=>iD(q).message),_=Tu(O),U=_?void 0:O;throw y(this).debug(`[${z}] response error (${W})`,a({retryOfRequestLogID:u,url:A.url,status:A.status,headers:A.headers,message:U,durationMs:Date.now()-Y})),this.makeStatusError(A.status,_,U,A.headers)}return y(this).info(G),y(this).debug(`[${z}] response start`,a({retryOfRequestLogID:u,url:A.url,status:A.status,headers:A.headers,durationMs:J-Y})),{response:A,options:C,controller:Z,requestLogID:z,retryOfRequestLogID:u,startTime:Y}}getAPIList(D,F,u){return this.requestAPIList(F,{method:"get",path:D,...u})}requestAPIList(D,F){let u=this.makeRequest(F,null,void 0);return new yF(this,u,D)}async fetchWithTimeout(D,F,u,C){let{signal:E,method:B,...$}=F||{};if(E)E.addEventListener("abort",()=>C.abort());let Q=setTimeout(()=>C.abort(),u),z=globalThis.ReadableStream&&$.body instanceof globalThis.ReadableStream||typeof $.body==="object"&&$.body!==null&&Symbol.asyncIterator in $.body,X={signal:C.signal,...z?{duplex:"half"}:{},method:"GET",...$};if(B)X.method=B.toUpperCase();try{return await this.fetch.call(void 0,D,X)}finally{clearTimeout(Q)}}async shouldRetry(D){let F=D.headers.get("x-should-retry");if(F==="true")return!0;if(F==="false")return!1;if(D.status===408)return!0;if(D.status===409)return!0;if(D.status===429)return!0;if(D.status>=500)return!0;return!1}async retryRequest(D,F,u,C){let E,B=C?.get("retry-after-ms");if(B){let Q=parseFloat(B);if(!Number.isNaN(Q))E=Q}let $=C?.get("retry-after");if($&&!E){let Q=parseFloat($);if(!Number.isNaN(Q))E=Q*1000;else E=Date.parse($)-Date.now()}if(!(E&&0<=E&&E<60000)){let Q=D.maxRetries??this.maxRetries;E=this.calculateDefaultRetryTimeoutMillis(F,Q)}return await Nu(E),this.makeRequest(D,F-1,u)}calculateDefaultRetryTimeoutMillis(D,F){let E=F-D,B=Math.min(0.5*Math.pow(2,E),8),$=1-Math.random()*0.25;return B*$*1000}async buildRequest(D,{retryCount:F=0}={}){let u={...D},{method:C,path:E,query:B,defaultBaseURL:$}=u,Q=this.buildURL(E,B,$);if("timeout"in u)Ou("timeout",u.timeout);u.timeout=u.timeout??this.timeout;let{bodyHeaders:z,body:X}=this.buildBody({options:u}),Y=await this.buildHeaders({options:D,method:C,bodyHeaders:z,retryCount:F});return{req:{method:C,headers:Y,...u.signal&&{signal:u.signal},...globalThis.ReadableStream&&X instanceof globalThis.ReadableStream&&{duplex:"half"},...X&&{body:X},...this.fetchOptions??{},...u.fetchOptions??{}},url:Q,timeout:u.timeout}}async buildHeaders({options:D,method:F,bodyHeaders:u,retryCount:C}){let E={};if(this.idempotencyHeader&&F!=="get"){if(!D.idempotencyKey)D.idempotencyKey=this.defaultIdempotencyKey();E[this.idempotencyHeader]=D.idempotencyKey}let B=k([E,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(C),...D.timeout?{"X-Stainless-Timeout":String(Math.trunc(D.timeout/1000))}:{},...qu()},await this.authHeaders(D),this._options.defaultHeaders,u,D.headers]);return this.validateHeaders(B),B.values}buildBody({options:{body:D,headers:F}}){if(!D)return{bodyHeaders:void 0,body:void 0};let u=k([F]);if(ArrayBuffer.isView(D)||D instanceof ArrayBuffer||D instanceof DataView||typeof D==="string"&&u.values.has("content-type")||globalThis.Blob&&D instanceof globalThis.Blob||D instanceof FormData||D instanceof URLSearchParams||globalThis.ReadableStream&&D instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:D};else if(typeof D==="object"&&((Symbol.asyncIterator in D)||(Symbol.iterator in D)&&("next"in D)&&typeof D.next==="function"))return{bodyHeaders:void 0,body:G0(D)};else return s(this,dF,"f").call(this,{body:D,headers:u})}}H0=H,dF=new WeakMap,N0=new WeakSet,tu=function(){return this.baseURL!==su[this._options.environment||"live_mode"]};H.DodoPayments=H0;H.DEFAULT_TIMEOUT=60000;H.DodoPaymentsError=v;H.APIError=P;H.APIConnectionError=BD;H.APIConnectionTimeoutError=aD;H.APIUserAbortError=HD;H.NotFoundError=oD;H.ConflictError=eD;H.RateLimitError=FF;H.BadRequestError=rD;H.AuthenticationError=tD;H.InternalServerError=uF;H.PermissionDeniedError=sD;H.UnprocessableEntityError=DF;H.toFile=gF;H.CheckoutSessions=qD;H.Payments=LD;H.Subscriptions=bD;H.Invoices=$D;H.Licenses=jD;H.LicenseKeys=RD;H.LicenseKeyInstances=wD;H.Customers=e;H.Refunds=PD;H.Disputes=SD;H.Payouts=fD;H.Products=DD;H.Misc=ID;H.Discounts=xD;H.Addons=UD;H.Brands=VD;H.Webhooks=ZD;H.WebhookEvents=yD;H.UsageEvents=vD;H.Meters=kD;i0();import Au from"node:process";import O3 from"node:path";import{fileURLToPath as s6}from"node:url";import o6 from"node:child_process";import e6,{constants as DC}from"node:fs/promises";import{promisify as j6}from"node:util";import k6 from"node:child_process";import o0,{constants as $3}from"node:fs/promises";import C3 from"node:process";import q6 from"node:os";import M6 from"node:fs";import U6 from"node:fs";import F3 from"node:fs";var a0;function N6(){try{return F3.statSync("/.dockerenv"),!0}catch{return!1}}function H6(){try{return F3.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function r0(){if(a0===void 0)a0=N6()||H6();return a0}var t0,V6=()=>{try{return U6.statSync("/run/.containerenv"),!0}catch{return!1}};function cD(){if(t0===void 0)t0=V6()||r0();return t0}var u3=()=>{if(C3.platform!=="linux")return!1;if(q6.release().toLowerCase().includes("microsoft")){if(cD())return!1;return!0}try{return M6.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!cD():!1}catch{return!1}},t=C3.env.__IS_WSL_TEST__?u3:u3();import E3 from"node:process";import{Buffer as x6}from"node:buffer";import{promisify as S6}from"node:util";import w6 from"node:child_process";var R6=S6(w6.execFile),s0=()=>`${E3.env.SYSTEMROOT||E3.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;var d=async(D,F={})=>{let{powerShellPath:u,...C}=F,E=d.encodeCommand(D);return R6(u??s0(),[...d.argumentsPrefix,E],{encoding:"utf8",...C})};d.argumentsPrefix=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"];d.encodeCommand=(D)=>x6.from(D,"utf16le").toString("base64");d.escapeArgument=(D)=>`'${String(D).replaceAll("'","''")}'`;function B3(D){for(let F of D.split(`
27
+ `)){if(/^\s*#/.test(F))continue;let u=/^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(F);if(!u)continue;return u.groups.mountPoint.trim().replaceAll(/^["']|["']$/g,"")}}var I6=j6(k6.execFile),L6=(()=>{let F;return async function(){if(F)return F;let u="/etc/wsl.conf",C=!1;try{await o0.access(u,$3.F_OK),C=!0}catch{}if(!C)return"/mnt/";let E=await o0.readFile(u,{encoding:"utf8"}),B=B3(E);if(B===void 0)return"/mnt/";return F=B,F=F.endsWith("/")?F:`${F}/`,F}})(),f6=async()=>{return`${await L6()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`},F0=t?f6:s0,A3,Z3=async()=>{return A3??=(async()=>{try{let D=await F0();return await o0.access(D,$3.X_OK),!0}catch{return!1}})(),A3},Q3=async()=>{let D=await F0(),F=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:u}=await d(F,{powerShellPath:D});return u.trim()},J3=async(D)=>{if(/^[a-z]+:\/\//i.test(D))return D;try{let{stdout:F}=await I6("wslpath",["-aw",D],{encoding:"utf8"});return F.trim()}catch{return D}};function _D(D,F,u){let C=(E)=>Object.defineProperty(D,F,{value:E,enumerable:!0,writable:!0});return Object.defineProperty(D,F,{configurable:!0,enumerable:!0,get(){let E=u();return C(E),E},set(E){C(E)}}),D}import{promisify as n6}from"node:util";import Cu from"node:process";import{execFile as i6}from"node:child_process";import{promisify as P6}from"node:util";import b6 from"node:process";import{execFile as v6}from"node:child_process";var y6=P6(v6);async function e0(){if(b6.platform!=="darwin")throw Error("macOS only");let{stdout:D}=await y6("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),u=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(D)?.groups.id??"com.apple.Safari";if(u==="com.apple.safari")return"com.apple.Safari";return u}import h6 from"node:process";import{promisify as g6}from"node:util";import{execFile as m6,execFileSync as _9}from"node:child_process";var d6=g6(m6);async function X3(D,{humanReadableOutput:F=!0,signal:u}={}){if(h6.platform!=="darwin")throw Error("macOS only");let C=F?[]:["-ss"],E={};if(u)E.signal=u;let{stdout:B}=await d6("osascript",["-e",D,C],E);return B.trim()}async function Du(D){return X3(`tell application "Finder" to set app_path to application file id "${D}" as string
28
+ tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}import{promisify as c6}from"node:util";import{execFile as l6}from"node:child_process";var p6=c6(l6),G3={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},u0=new Map(Object.entries(G3));class Fu extends Error{}async function uu(D=p6){let{stdout:F}=await D("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),u=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(F);if(!u)throw new Fu(`Cannot find Windows browser in stdout: ${JSON.stringify(F)}`);let{id:C}=u.groups,E=G3[C];if(!E)throw new Fu(`Unknown browser ID: ${C}`);return E}var a6=n6(i6),r6=(D)=>D.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,(F)=>F.toUpperCase());async function Eu(){if(Cu.platform==="darwin"){let D=await e0();return{name:await Du(D),id:D}}if(Cu.platform==="linux"){let{stdout:D}=await a6("xdg-mime",["query","default","x-scheme-handler/http"]),F=D.trim();return{name:r6(F.replace(/.desktop$/,"").replace("-"," ")),id:F}}if(Cu.platform==="win32")return uu();throw Error("Only macOS, Linux, and Windows are supported")}import Bu from"node:process";var t6=Boolean(Bu.env.SSH_CONNECTION||Bu.env.SSH_CLIENT||Bu.env.SSH_TTY),Y3=t6;var C0=Symbol("fallbackAttempt"),$u=import.meta.url?O3.dirname(s6(import.meta.url)):"",z3=O3.join($u,"xdg-open"),{platform:lD,arch:K3}=Au,_3=async(D,F)=>{if(D.length===0)return;let u=[];for(let C of D)try{return await F(C)}catch(E){u.push(E)}throw AggregateError(u,"Failed to open in all supported apps")},E0=async(D)=>{D={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...D};let F=D[C0]===!0;if(delete D[C0],Array.isArray(D.app))return _3(D.app,(X)=>E0({...D,app:X,[C0]:!0}));let{name:u,arguments:C=[]}=D.app??{};if(C=[...C],Array.isArray(u))return _3(u,(X)=>E0({...D,app:{name:X,arguments:C},[C0]:!0}));if(u==="browser"||u==="browserPrivate"){let X={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge","com.apple.safari":"safari"},Y={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},Z;if(t){let A=await Q3();Z=u0.get(A)??{}}else Z=await Eu();if(Z.id in X){let A=X[Z.id.toLowerCase()];if(u==="browserPrivate"){if(A==="safari")throw Error("Safari doesn't support opening in private mode via command line");C.push(Y[A])}return E0({...D,app:{name:pD[A],arguments:C}})}throw Error(`${Z.name} is not supported as a default browser`)}let E,B=[],$={},Q=!1;if(t&&!cD()&&!Y3&&!u)Q=await Z3();if(lD==="darwin"){if(E="open",D.wait)B.push("--wait-apps");if(D.background)B.push("--background");if(D.newInstance)B.push("--new");if(u)B.push("-a",u)}else if(lD==="win32"||Q){if(E=await F0(),B.push(...d.argumentsPrefix),!t)$.windowsVerbatimArguments=!0;if(t&&D.target)D.target=await J3(D.target);let X=["$ProgressPreference = 'SilentlyContinue';","Start"];if(D.wait)X.push("-Wait");if(u){if(X.push(d.escapeArgument(u)),D.target)C.push(D.target)}else if(D.target)X.push(d.escapeArgument(D.target));if(C.length>0)C=C.map((Y)=>d.escapeArgument(Y)),X.push("-ArgumentList",C.join(","));if(D.target=d.encodeCommand(X.join(" ")),!D.wait)$.stdio="ignore"}else{if(u)E=u;else{let X=!$u||$u==="/",Y=!1;try{await e6.access(z3,DC.X_OK),Y=!0}catch{}E=Au.versions.electron??(lD==="android"||X||!Y)?"xdg-open":z3}if(C.length>0)B.push(...C);if(!D.wait)$.stdio="ignore",$.detached=!0}if(lD==="darwin"&&C.length>0)B.push("--args",...C);if(D.target)B.push(D.target);let z=o6.spawn(E,B,$);if(D.wait)return new Promise((X,Y)=>{z.once("error",Y),z.once("close",(Z)=>{if(!D.allowNonzeroExitCode&&Z!==0){Y(Error(`Exited with code ${Z}`));return}X(z)})});if(F)return new Promise((X,Y)=>{z.once("error",Y),z.once("spawn",()=>{z.once("close",(Z)=>{if(z.off("error",Y),Z!==0){Y(Error(`Exited with code ${Z}`));return}z.unref(),X(z)})})});return z.unref(),new Promise((X,Y)=>{z.once("error",Y),z.once("spawn",()=>{z.off("error",Y),X(z)})})},FC=(D,F)=>{if(typeof D!=="string")throw TypeError("Expected a `target`");return E0({...F,target:D})};function W3(D){if(typeof D==="string"||Array.isArray(D))return D;let{[K3]:F}=D;if(!F)throw Error(`${K3} is not supported`);return F}function xF({[lD]:D},{wsl:F}={}){if(F&&t)return W3(F);if(!D)throw Error(`${lD} is not supported`);return W3(D)}var pD={browser:"browser",browserPrivate:"browserPrivate"};_D(pD,"chrome",()=>xF({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium","chromium-browser"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));_D(pD,"brave",()=>xF({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));_D(pD,"firefox",()=>xF({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));_D(pD,"edge",()=>xF({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));_D(pD,"safari",()=>xF({darwin:"Safari"}));var Zu=FC;var SF={USD:"$",INR:"₹",EUR:"€",GBP:"£"};import kF from"node:fs";function Ju(D){return typeof D==="object"&&D!==null&&"error"in D&&typeof D.error?.code==="string"}var A0=(D,F)=>`\x1B]8;;${F}\x1B\\${D}\x1B]8;;\x1B\\`,OD={products:[{command:"list",description:"List your products"},{command:"create",description:"Create a new product"},{command:"info",description:"Get info about a product"}],payments:[{command:"list",description:"List your payments"},{command:"info",description:"Information about a payment"}],customers:[{command:"list",description:"List your customers"},{command:"create",description:"Create a customer"},{command:"update",description:"Update a customer"}],discounts:[{command:"list",description:"List your discounts"},{command:"create",description:"Create a discount"},{command:"delete",description:"Remove a discount"}],wh:[{command:"",description:"Send a webhook event"}]},s3=process.argv,TD=s3[2],c=s3[3],IF=AC.homedir();if(TD==="login"){Zu("https://app.dodopayments.com/developer/api-keys");let D=await j({message:"Enter your Dodo Payments API Key:",required:!0}),F=await dD({choices:[{name:"Test Mode",value:"test_mode"},{name:"Live Mode",value:"live_mode"}],message:"Choose the environment:"}),u=new H({bearerToken:D,environment:F});console.log("Verifying Dodo Payments API Key");try{await u.products.list({page_size:1}),console.log("Successfully verified your Dodo Payments API Key!")}catch(E){console.log("Something went wrong while authenticating:",E),process.exit(1)}console.log("Storing / Updating existing configuration...");let C;try{C=Object.create(JSON.parse(kF.readFileSync(jF.join(IF,".dodopayments","api-key"),"utf-8")))}catch{C={}}C[F]=D,kF.writeFileSync(jF.join(IF,".dodopayments","api-key"),JSON.stringify(C)),C[F]=D,console.log("Setup complete successfully!"),process.exit(0)}if(TD==="wh")await r3().then(() => BC);if(!kF.existsSync(jF.join(IF,".dodopayments","api-key")))console.log("Please login using `dodo login` command first!"),process.exit(0);var $0;try{$0=JSON.parse(kF.readFileSync(jF.join(IF,".dodopayments","api-key"),"utf-8"))}catch{kF.rmSync(jF.join(IF,".dodopayments","api-key"),{force:!0}),console.log("Failed to decode API Key configuration. Your config has been reset. Please log in again using `dodo login`"),process.exit(0)}var Xu,RF,t3=Object.keys($0);if(t3.length===1)RF=t3[0],Xu=$0[RF];else RF=await dD({choices:[{name:"Test Mode",value:"test_mode"},{name:"Live Mode",value:"live_mode"}],message:"Choose the environment:"}),Xu=$0[RF];var l=new H({bearerToken:Xu,environment:RF});if(TD==="products")if(c==="list"){let D=await j({message:"Enter page:",default:"1",validate:(F)=>F.trim()!==""});console.table((await l.products.list({page_number:parseInt(D)-1,page_size:100})).items,["name","product_id","updated_at","price"])}else if(c==="create")Zu("https://app.dodopayments.com/products/create");else if(c==="info")try{let D=await j({message:"Enter product ID:",validate:(u)=>u.startsWith("pdt_")||"Please enter a valid product ID!"}),F=await l.products.retrieve(D);console.table({product_id:F.product_id,name:F.name,description:F.description,created_at:F.created_at,...F.is_recurring?{price:`${SF[F.price.currency]||F.price.currency+" "}${(F.price.price*0.01).toFixed(2)}/${F.price.payment_frequency_interval}`}:{price:`${SF[F.price.currency]||F.price.currency+" "}${(F.price.price*0.01).toFixed(2)} (One Time)`},tax_category:F.tax_category,edit_url:A0("CTRL + Click to open",`https://app.dodopayments.com/products/edit?id=${F.product_id}`)})}catch(D){if(Ju(D)&&D.error.code==="NOT_FOUND")console.log("Incorrect product ID!");else console.error(D)}else OD.products.forEach((D)=>{console.log(`dodo products ${D.command} - ${D.description}`)});else if(TD==="payments")if(c==="list"){let D=await j({message:"Enter page:",default:"1",validate:(C)=>C.trim()!==""}),u=(await l.payments.list({page_number:parseInt(D)-1,page_size:100})).items.map((C)=>{return{"payment id":C.payment_id,"created at":new Date(C.created_at).toLocaleString(),"subscription id":C.subscription_id,"total amount":`${SF[C.currency]||C.currency+" "}${(C.total_amount*0.01).toFixed(2)}`,status:C.status,"more info":A0("CTRL + Click to open",`https://app.dodopayments.com/transactions/payments/${C.payment_id}`)}});console.table(u)}else if(c==="info")try{let F=await l.payments.retrieve("pay_0NWiGvZPWxeWeNWISbfat");console.log(F);let u={"payment id":F.payment_id,status:F.status,"total amount":`${SF[F.currency]||F.currency+" "}${(F.total_amount*0.01).toFixed(2)}`,"payment method":F.payment_method,createdAt:new Date(F.created_at).toLocaleString(),customer:F.customer.customer_id,"customer email":F.customer.email,...F.subscription_id&&{"subscription id":F.subscription_id},"billing address street":`${F.billing.street}`,"billing address state":`${F.billing.state}`,"billing address city":`${F.billing.city}`,"billing address country":`${F.billing.country}`,"billing address zipcode":`${F.billing.zipcode}`,"more info":A0("Ctrl + Click to open",`https://app.dodopayments.com/transactions/payments/${F.payment_id}`)};console.table(u)}catch(D){if(Ju(D)&&D.error.code==="NOT_FOUND")console.log("Incorrect payment ID!");else console.error(D)}else OD.payments.forEach((D)=>{console.log(`dodo payments ${D.command} - ${D.description}`)});else if(TD==="customers")if(c==="list"){let D=await j({message:"Enter page:",default:"1",validate:(F)=>F.trim()!==""});console.table((await l.customers.list({page_number:parseInt(D)-1,page_size:100})).items,["customer_id","name","email","phone_number"])}else if(c==="create"){let D=await j({message:"Enter Name: ",validate:(E)=>E.trim()!==""}),F=await j({message:"Enter Email: ",validate:(E)=>E.trim()!==""}),u=await j({message:"Enter Phone Number: "}),C=await l.customers.create({name:D,email:F,phone_number:u.trim()!==""?u:null});console.log("Customer Successfully Created!"),console.table([C],["customer_id","name","email","phone_number"])}else if(c==="update"){let D=await j({message:"Enter customer ID:",validate:(F)=>F.startsWith("cus_")||"Please enter a valid customer ID!"});try{let F=await l.customers.retrieve(D),u=await j({message:"Enter customer name:",default:F.name}),C=await j({message:"Enter customer phone:",default:F.phone_number?.toString()}),E=await l.customers.update(D,{name:u,phone_number:C.trim()!==""?C:null});console.table([E],["customer_id","name","email","phone_number"])}catch(F){if(Ju(F)&&F.error.code==="NOT_FOUND")console.log("Incorrect customer ID!");else console.error(F)}}else OD.products.forEach((D)=>{console.log(`dodo customers ${D.command} - ${D.description}`)});else if(TD==="discounts")if(c==="list"){let D=await j({message:"Enter page:",default:"1",validate:(C)=>C.trim()!==""}),u=(await l.discounts.list({page_number:parseInt(D)-1,page_size:100})).items.map((C)=>({name:C.name,code:C.code,"discount id":C.discount_id,"created at":new Date(C.created_at).toLocaleString(),...C.type==="percentage"?{amount:`${(C.amount*0.01).toFixed(2)}%`}:{amount:C.amount},"more info":A0("Ctrl + Click for more info",`https://app.dodopayments.com/sales/discounts/edit?id=${C.discount_id}`)}));console.table(u)}else if(c==="create"){let D=await j({message:"Enter discount name:",validate:(B)=>B.trim()!==""}),F=await j({message:"Enter discount percentage:",validate:(B)=>{let $=parseFloat(B);if(!Number.isNaN($)&&$>0&&$<=100)return!0;else return!1}}),u=await j({message:"Enter discount code (Optional):"}),C=await j({message:"Enter discount cycles (Optional):"}),E=await l.discounts.create({name:D,code:u.trim()!==""?u:null,amount:parseFloat(F)*100,type:"percentage",...C.trim()!==""&&{subscription_cycles:parseInt(C)}});console.log("Discount created successfully!"),console.table({name:E.name,code:E.code,"discount id":E.discount_id,...C.trim()!==""&&{"subscription cycles":E.subscription_cycles}})}else if(c==="delete")await l.discounts.delete(await j({message:"Enter discount ID to be deleted:",validate:(D)=>D.startsWith("dsc_")})),console.log("Successfully deleted discount!");else OD.discounts.forEach((D)=>{console.log(`dodo discounts ${D.command} - ${D.description}`)});else if(TD==="licences")if(c==="list"){let D=await j({message:"Enter page:",default:"1",validate:(u)=>u.trim()!==""}),F=await l.licenseKeys.list({page_number:parseInt(D)-1,page_size:100});console.log(F.items)}else OD.licences.forEach((D)=>{console.log(`dodo licences ${D.command} - ${D.description}`)});else Object.keys(OD).forEach((D)=>{console.log(`Category: ${D}`),OD[D].forEach((F)=>{console.log(`dodo ${D} ${F.command} - ${F.description}`)}),console.log("")});
@@ -0,0 +1,123 @@
1
+ import { type baseArgs } from "../types/baseArgs";
2
+
3
+ const genBaseDisputeData = ({
4
+ business_id = 'bus_test'
5
+ }: baseArgs) => {
6
+ return {
7
+ "business_id": business_id,
8
+ "data": {
9
+ "amount": 400,
10
+ "business_id": business_id,
11
+ "created_at": new Date().toISOString(),
12
+ "currency": "USD",
13
+ "customer": {
14
+ "customer_id": "cus_test",
15
+ "email": "test@acme.com",
16
+ "name": "Test user",
17
+ "phone_number": "+447700900123"
18
+ },
19
+ "dispute_id": "dp_test",
20
+ "dispute_stage": "dispute",
21
+ "dispute_status": "dispute_opened",
22
+ "payload_type": "Dispute",
23
+ "payment_id": "pay_test",
24
+ "reason": "testing dispute",
25
+ "remarks": null
26
+ },
27
+ "timestamp": new Date().toISOString(),
28
+ }
29
+ }
30
+
31
+ const genDisputeOpened = (args: baseArgs) => {
32
+ const baseData = genBaseDisputeData(args);
33
+ return {
34
+ ...baseData,
35
+ "type": "dispute.opened",
36
+ data: {
37
+ ...baseData.data,
38
+ dispute_status: "dispute_opened"
39
+ }
40
+ }
41
+ }
42
+
43
+ const genDisputeExpired = (args: baseArgs) => {
44
+ const baseData = genBaseDisputeData(args);
45
+ return {
46
+ ...baseData,
47
+ "type": "dispute.expired",
48
+ data: {
49
+ ...baseData.data,
50
+ dispute_status: "dispute_expired"
51
+ }
52
+ }
53
+ }
54
+
55
+ const genDisputeAccepted = (args: baseArgs) => {
56
+ const baseData = genBaseDisputeData(args);
57
+ return {
58
+ ...baseData,
59
+ "type": "dispute.accepted",
60
+ data: {
61
+ ...baseData.data,
62
+ dispute_status: "dispute_accepted"
63
+ }
64
+ }
65
+ }
66
+
67
+ const genDisputeCancelled = (args: baseArgs) => {
68
+ const baseData = genBaseDisputeData(args);
69
+ return {
70
+ ...baseData,
71
+ "type": "dispute.cancelled",
72
+ data: {
73
+ ...baseData.data,
74
+ dispute_status: "dispute_cancelled"
75
+ }
76
+ }
77
+ }
78
+
79
+ const genDisputeChallenged = (args: baseArgs) => {
80
+ const baseData = genBaseDisputeData(args);
81
+ return {
82
+ ...baseData,
83
+ "type": "dispute.challenged",
84
+ data: {
85
+ ...baseData.data,
86
+ dispute_status: "dispute_challenged"
87
+ }
88
+ }
89
+ }
90
+
91
+ const genDisputeWon = (args: baseArgs) => {
92
+ const baseData = genBaseDisputeData(args);
93
+ return {
94
+ ...baseData,
95
+ "type": "dispute.won",
96
+ data: {
97
+ ...baseData.data,
98
+ dispute_status: "dispute_won"
99
+ }
100
+ }
101
+ }
102
+
103
+ const genDisputeLost = (args: baseArgs) => {
104
+ const baseData = genBaseDisputeData(args);
105
+ return {
106
+ ...baseData,
107
+ "type": "dispute.lost",
108
+ data: {
109
+ ...baseData.data,
110
+ dispute_status: "dispute_lost"
111
+ }
112
+ }
113
+ }
114
+
115
+ export {
116
+ genDisputeOpened,
117
+ genDisputeExpired,
118
+ genDisputeAccepted,
119
+ genDisputeCancelled,
120
+ genDisputeChallenged,
121
+ genDisputeWon,
122
+ genDisputeLost
123
+ };
@@ -0,0 +1,39 @@
1
+ import { type baseArgs } from "../types/baseArgs";
2
+
3
+ const genBaseLicenceData = ({
4
+ business_id = 'bus_test',
5
+ product_id = 'pdt_test',
6
+ subscription_id
7
+ }: baseArgs) => {
8
+ return {
9
+ "business_id": business_id,
10
+ "data": {
11
+ "activations_limit": null,
12
+ "business_id": business_id,
13
+ "created_at": new Date().toISOString(),
14
+ "customer_id": "cus_test",
15
+ "expires_at": null,
16
+ "id": "lic_test",
17
+ "instances_count": 0,
18
+ "key": "db44b22c-fe9b-4a68-bf0d-b0e0d6c6c8c0",
19
+ "payload_type": "LicenseKey",
20
+ "payment_id": "pay_test",
21
+ "product_id": product_id,
22
+ "status": "active",
23
+ "subscription_id": subscription_id
24
+ },
25
+ "timestamp": new Date().toISOString()
26
+ }
27
+ }
28
+
29
+
30
+ const genLicenceCreated = (args: baseArgs) => {
31
+ return {
32
+ ...genBaseLicenceData(args),
33
+ "type": "license_key.created"
34
+ }
35
+ }
36
+
37
+ export {
38
+ genLicenceCreated
39
+ };
@@ -0,0 +1,101 @@
1
+ import { type baseArgs } from "../types/baseArgs";
2
+
3
+ // For payment events
4
+ const genBasePaymentData = ({
5
+ business_id = 'bus_test',
6
+ product_id = 'pdt_test',
7
+ qty = 1
8
+ }: baseArgs) => {
9
+ return {
10
+ "business_id": business_id,
11
+ "data": {
12
+ "billing": {
13
+ "city": "New York",
14
+ "country": "US",
15
+ "state": "New York",
16
+ "street": "New York, New York",
17
+ "zipcode": "12345"
18
+ },
19
+ "brand_id": business_id,
20
+ "business_id": business_id,
21
+ "card_issuing_country": "GB",
22
+ "card_last_four": "4242",
23
+ "card_network": "VISA",
24
+ "card_type": "CREDIT",
25
+ "checkout_session_id": "cks_123",
26
+ "created_at": new Date().toISOString(),
27
+ "currency": "USD",
28
+ "customer": {
29
+ "customer_id": "cus_test",
30
+ "email": "test@acme.com",
31
+ "metadata": {},
32
+ "name": "Test user",
33
+ "phone_number": "+15555550100"
34
+ },
35
+ "digital_products_delivered": false,
36
+ "discount_id": null,
37
+ "disputes": [],
38
+ "error_code": null,
39
+ "error_message": null,
40
+ "invoice_id": "inv_test",
41
+ "metadata": {},
42
+ "payload_type": "Payment",
43
+ "payment_id": "pay_test",
44
+ "payment_link": "https://test.checkout.dodopayments.com/cbq",
45
+ "payment_method": "card",
46
+ "payment_method_type": "card",
47
+ "product_cart": [
48
+ {
49
+ "product_id": product_id,
50
+ "quantity": qty
51
+ }
52
+ ],
53
+ "refunds": [],
54
+ "settlement_amount": 400,
55
+ "settlement_currency": "USD",
56
+ "settlement_tax": null,
57
+ "status": "succeeded",
58
+ "subscription_id": null,
59
+ "tax": null,
60
+ "total_amount": 400,
61
+ "updated_at": null
62
+ },
63
+ "timestamp": new Date().toISOString()
64
+ }
65
+ }
66
+
67
+ const genPaymentSuccess = (args: baseArgs) => {
68
+ return {
69
+ ...genBasePaymentData(args),
70
+ "type": "payment.succeeded"
71
+ }
72
+ }
73
+
74
+ const genPaymentFailed = (args: baseArgs) => {
75
+ return {
76
+ ...genBasePaymentData(args),
77
+ "type": "payment.failed"
78
+ }
79
+ }
80
+
81
+ const genPaymentProcessing = (args: baseArgs) => {
82
+ return {
83
+ ...genBasePaymentData(args),
84
+ "type": "payment.processing"
85
+ }
86
+ }
87
+
88
+ const genPaymentCancelled = (args: baseArgs) => {
89
+ return {
90
+ ...genBasePaymentData(args),
91
+ "type": "payment.cancelled"
92
+ }
93
+ }
94
+
95
+
96
+ export {
97
+ genPaymentSuccess,
98
+ genPaymentFailed,
99
+ genPaymentProcessing,
100
+ genPaymentCancelled
101
+ };