dodopayments-cli 2.0.3 → 2.2.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/.prettierrc.mjs +11 -0
- package/CONTRIBUTING.md +28 -7
- package/README.md +31 -8
- package/build-binaries.ts +27 -4
- package/dist/index.js +25 -28
- package/package.json +3 -3
- package/dodo-webhooks/functions/generate-dispute-data.ts +0 -123
- package/dodo-webhooks/functions/generate-licence-data.ts +0 -39
- package/dodo-webhooks/functions/generate-payment-data.ts +0 -101
- package/dodo-webhooks/functions/generate-refund-data.ts +0 -44
- package/dodo-webhooks/functions/generate-subscription-data.ts +0 -153
- package/dodo-webhooks/functions/supported-events.ts +0 -24
- package/dodo-webhooks/index.ts +0 -207
- package/dodo-webhooks/types/baseArgs.ts +0 -9
- package/index.ts +0 -490
- package/utils/currency-to-symbol-map.ts +0 -8
package/dist/index.js
CHANGED
|
@@ -1,32 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
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 AD=(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=AD((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=AD((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,W0=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=W0;var KF=new W0;function w8(D){return KF.encode(D)}m.encode=w8;function R8(D){return KF.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}(W0);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 KF.encodedLength(D)};m.maxDecodedLength=function(D){return KF.maxDecodedLength(D)};m.decodedLength=function(D){return KF.decodedLength(D)}});var cu=AD((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,_,V,S,q,b,H,w,R,f,h,a;while(T>=64){W=A[0],O=A[1],_=A[2],V=A[3],S=A[4],q=A[5],b=A[6],H=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],a=(w>>>7|w<<25)^(w>>>18|w<<14)^w>>>3,Z[R]=(h+Z[R-7]|0)+(a+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)+(H+(F[R]+Z[R]|0)|0)|0,a=((W>>>2|W<<30)^(W>>>13|W<<19)^(W>>>22|W<<10))+(W&O^W&_^O&_)|0,H=b,b=q,q=S,S=V+h|0,V=_,_=O,O=W,W=h+a|0;A[0]+=W,A[1]+=O,A[2]+=_,A[3]+=V,A[4]+=S,A[5]+=q,A[6]+=b,A[7]+=H,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),V=_.length,S=new Uint8Array(G);for(var q=0;q<G;q++){if(V===_.length)Q(_,O,J,T),V=0;S[q]=_[V++]}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),V=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(V);for(var H=0;H<W;H++)_[H]=V[H];for(var H=2;H<=J;H++){T.reset(),T.update(V).finish(V);for(var w=0;w<W;w++)_[w]^=V[w]}for(var H=0;H<W&&q*W+H<G;H++)S[q*W+H]=_[H]}for(var q=0;q<W;q++)_[q]=V[q]=0;for(var q=0;q<4;q++)O[q]=0;return T.clean(),S}D.pbkdf2=Y})});var au=AD((nu)=>{Object.defineProperty(nu,"__esModule",{value:!0});nu.Webhook=nu.WebhookVerificationError=void 0;var I8=yu(),lu=mu(),L8=cu(),pu=300;class O0 extends Error{constructor(D){super(D);Object.setPrototypeOf(this,O0.prototype),this.name="ExtendableError",this.stack=Error(D).stack}}class CD extends O0{constructor(D){super(D);Object.setPrototypeOf(this,CD.prototype),this.name="WebhookVerificationError"}}nu.WebhookVerificationError=CD;class _F{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(_F.prefix))D=D.substring(_F.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 CD("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 CD("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 CD("Invalid Signature Headers");if(F-u>pu)throw new CD("Message timestamp too old");if(u>F+pu)throw new CD("Message timestamp too new");return new Date(u*1000)}}nu.Webhook=_F;_F.prefix="whsec_"});var TF=(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",NF=(D)=>D.name==="backspace",U0=(D)=>D.name==="tab",V0=(D)=>"1234567890".includes(D.name),UF=(D)=>D.name==="enter"||D.name==="return";var H0,q0,lF,M0,VF;var pF=M(()=>{H0=class H0 extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(D){super();this.cause=D?.cause}};q0=class q0 extends Error{name="CancelPromptError";message="Prompt was canceled"};lF=class lF extends Error{name="ExitPromptError"};M0=class M0 extends Error{name="HookError"};VF=class VF 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 XD(){let D=ou.getStore();if(!D)throw new M0("[Inquirer] Hook functions can only be called from within a prompt");return D}function x0(){return XD().rl}function S0(D){let F=(...u)=>{let C=XD(),E=!1,B=C.handleChange;C.handleChange=()=>{E=!0};let $=D(...u);if(E)B();return C.handleChange=B,$};return v8.bind(F)}function cD(D){let F=XD(),{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(){XD().handleChange()}var ou,GD;var YD=M(()=>{pF();ou=new b8;GD={queue(D){let F=XD(),{index:u}=F;F.hooksEffect.push(()=>{F.hooksCleanup[u]?.();let C=D(x0());if(C!=null&&typeof C!=="function")throw new VF("useEffect return value must be a cleanup function or nothing.");F.hooksCleanup[u]=C})},run(){let D=XD();S0(()=>{D.hooksEffect.forEach((F)=>{F()}),D.hooksEffect.length=0})()},clearAll(){let D=XD();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 cD((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(()=>{YD()});function t(D,F){cD((u)=>{let C=u.get();if(!Array.isArray(C)||F.some((B,$)=>!Object.is(B,C[$])))GD.queue(D);u.set(F)})}var iF=M(()=>{YD()});import i from"node:process";function g8(){if(i.platform!=="win32")return i.env.TERM!=="linux";return Boolean(i.env.WT_SESSION)||Boolean(i.env.TERMINUS_SUBLIME)||i.env.ConEmuTask==="{cmd::Cmder}"||i.env.TERM_PROGRAM==="Terminus-Sublime"||i.env.TERM_PROGRAM==="vscode"||i.env.TERM==="xterm-256color"||i.env.TERM==="alacritty"||i.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var F2,u2,m8,d8,c8,l8,p8,lD,uB;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,lD=p8,uB=Object.entries(u2)});import{styleText as n}from"node:util";var C2;var E2=M(()=>{aF();C2={prefix:{idle:n("blue","?"),done:n("green",lD.tick)},spinner:{interval:80,frames:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"].map((D)=>n("yellow",D))},style:{answer:(D)=>n("cyan",D),message:(D)=>n("bold",D),error:(D)=>n("red",`> ${D}`),defaultAnswer:(D)=>n("dim",`(${D})`),help:(D)=>n("dim",D),highlight:(D)=>n("cyan",D),key:(D)=>n("cyan",n("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 zD(...D){let F=[C2,...D.filter((u)=>u!=null)];return A2(...F)}var w0=M(()=>{E2()});function HF({status:D="idle",theme:F}){let[u,C]=g(!1),[E,B]=g(0),{prefix:$,spinner:Q}=zD(F);if(t(()=>{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();w0()});function qF(D,F){return cD((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(()=>{YD()});function KD(D){return g({current:D})[0]}var rF=M(()=>{nF()});function MF(D){let F=KD(D);F.current=D,t((u)=>{let C=!1,E=S0((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();YD()});var X2=AD((UB,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 R0({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 xF(D){if(typeof D!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof D}\``);return D.replace(a8,"")}var a8;var j0=M(()=>{a8=R0()});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=AD((RB,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 _D(D,F={}){if(typeof D!=="string"||D.length===0)return 0;let{ambiguousIsNarrow:u=!0,countAnsiEscapeCodes:C=!1}=F;if(!C)D=xF(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 U2=M(()=>{j0();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=V2(),I.color.ansi256=H2(),I.color.ansi16m=q2(),I.bgColor.ansi=V2(10),I.bgColor.ansi256=H2(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 V2=(D=0)=>(F)=>`\x1B[${F+D}m`,H2=(D=0)=>(F)=>`\x1B[${38+D};5;${F}m`,q2=(D=0)=>(F,u,C)=>`\x1B[${38+D};2;${F};${u};${C}m`,I,LB,o8,e8,fB,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]}},LB=Object.keys(I.modifier),o8=Object.keys(I.color),e8=Object.keys(I.bgColor),fB=[...o8,...e8];F6=D6(),M2=F6});function L0(D,F,u){return String(D).normalize().replaceAll(`\r
|
|
3
|
-
|
|
4
|
-
`).
|
|
5
|
-
`)
|
|
6
|
-
`)
|
|
7
|
-
`)
|
|
8
|
-
`)
|
|
9
|
-
`)
|
|
10
|
-
`).
|
|
11
|
-
`).
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
`).
|
|
19
|
-
|
|
20
|
-
at ${b}`)}let[S,q]=typeof V==="string"?[V]:V;Y.render(S,q),GD.run()}catch(V){J(V)}}),Object.assign(Z.then((V)=>{return GD.clearAll(),V},(V)=>{throw GD.clearAll(),V}).finally(()=>{Q.forEach((V)=>V()),Y.done({clearContent:Boolean(E.clearPromptOnDone)}),z.end()}).then(()=>Z),{cancel:G})})}}var t2;var s2=M(()=>{d2();i2();a2();YD();pF();t2=LF(b2(),1)});import{styleText as _6}from"node:util";class ED{separator=_6("dim",Array.from({length:15}).join(lD.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 p0=M(()=>{$2();nF();iF();Z2();rF();Q2();w0();L2();s2();o2();pF()});var W6,j;var e2=M(()=>{p0();W6={validationFailureMode:"keep"},j=wF((D,F)=>{let{prefill:u="tab"}=D,C=zD(W6,D.theme),[E,B]=g("idle"),[$="",Q]=g(D.default),[z,X]=g(),[Y,Z]=g(""),A=HF({status:E,theme:C});async function J(_){let{required:V,pattern:S,patternError:q="Invalid input"}=D;if(V&&!_)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}MF(async(_,V)=>{if(E!=="idle")return;if(UF(_)){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 V.write(Y);X(q),B("idle")}}else if(NF(_)&&!Y)Q(void 0);else if(U0(_)&&!Y)Q(void 0),V.clearLine(0),V.write($),Z($);else Z(V.line),X(void 0)}),t((_)=>{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 RF}from"node:util";function pD(D){return!ED.isSeparator(D)&&!D.disabled}function T6(D){return D.map((F)=>{if(ED.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,nD;var D3=M(()=>{p0();aF();O6={icon:{cursor:lD.pointer},style:{disabled:(D)=>RF("dim",`- ${D}`),description:(D)=>RF("cyan",D),keysHelpTip:(D)=>D.map(([F,u])=>`${RF("bold",F)} ${RF("dim",u)}`).join(RF("dim"," • "))},indexMode:"hidden",keybindings:[]};nD=wF((D,F)=>{let{loop:u=!0,pageSize:C=7}=D,E=zD(O6,D.theme),{keybindings:B}=E,[$,Q]=g("idle"),z=HF({status:$,theme:E}),X=KD(),Y=!B.includes("vim"),Z=qF(()=>T6(D.choices),[D.choices]),A=qF(()=>{let H=Z.findIndex(pD),w=Z.findLastIndex(pD);if(H===-1)throw new VF("[select prompt] No selectable choices. All choices are disabled.");return{first:H,last:w}},[Z]),J=qF(()=>{if(!("default"in D))return-1;return Z.findIndex((H)=>pD(H)&&H.value===D.default)},[D.default,Z]),[G,T]=g(J===-1?A.first:J),W=Z[G];MF((H,w)=>{if(clearTimeout(X.current),UF(H))Q("done"),F(W.value);else if(TF(H,B)||cF(H,B)){if(w.clearLine(0),u||TF(H,B)&&G!==A.first||cF(H,B)&&G!==A.last){let R=TF(H,B)?-1:1,f=G;do f=(f+R+Z.length)%Z.length;while(!pD(Z[f]));T(f)}}else if(V0(H)&&!Number.isNaN(Number(w.line))){let R=Number(w.line)-1,f=-1,h=Z.findIndex((tD)=>{if(ED.isSeparator(tD))return!1;return f++,f===R}),a=Z[h];if(a!=null&&pD(a))T(h);X.current=setTimeout(()=>{w.clearLine(0)},700)}else if(NF(H))w.clearLine(0);else if(Y){let R=w.line.toLowerCase(),f=Z.findIndex((h)=>{if(ED.isSeparator(h)||!pD(h))return!1;return h.name.toLowerCase().startsWith(R)});if(f!==-1)T(f);X.current=setTimeout(()=>{w.clearLine(0)},700)}}),t(()=>()=>{clearTimeout(X.current)},[]);let O=E.style.message(D.message,$),_=E.style.keysHelpTip([["↑↓","navigate"],["⏎","select"]]),V=0,S=P0({items:Z,active:G,renderItem({item:H,isActive:w,index:R}){if(ED.isSeparator(H))return V++,` ${H.separator}`;let f=E.indexMode==="number"?`${R+1-V}. `:"";if(H.disabled){let tD=typeof H.disabled==="string"?H.disabled:"(disabled)";return E.style.disabled(`${f}${H.name} ${tD}`)}let h=w?E.style.highlight:(tD)=>tD,a=w?E.icon.cursor:" ";return h(`${a} ${f}${H.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(`
|
|
21
|
-
|
|
22
|
-
Received Response Code: ${C.status}
|
|
23
|
-
Received Response Body: ${await C.text()}`),console.log()}).catch((C)=>{console.error("❌ Webhook Event Failed:",C),console.log()})}});import AC from"node:os";import UD from"node:path";function qD(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 e(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 $0=function(){let{crypto:D}=globalThis;if(D?.randomUUID)return $0=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 sD=(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 $D({message:u,cause:sD(F)});let E=F;if(D===400)return new eD(D,E,u,C);if(D===401)return new DF(D,E,u,C);if(D===403)return new FF(D,E,u,C);if(D===404)return new uF(D,E,u,C);if(D===409)return new CF(D,E,u,C);if(D===422)return new EF(D,E,u,C);if(D===429)return new BF(D,E,u,C);if(D>=500)return new AF(D,E,u,C);return new P(D,E,u,C)}}class MD extends P{constructor({message:D}={}){super(void 0,void 0,D||"Request was aborted.",void 0)}}class $D extends P{constructor({message:D,cause:F}){super(void 0,void 0,D||"Connection error.",void 0);if(F)this.cause=F}}class oD extends $D{constructor({message:D}={}){super({message:D??"Request timed out."})}}class eD extends P{}class DF extends P{}class FF extends P{}class uF extends P{}class CF extends P{}class EF extends P{}class BF extends P{}class AF extends P{}var E8=/^[a-z][a-z0-9+.-]*:/i,Ku=(D)=>{return E8.test(D)},Z0=(D)=>(Z0=Array.isArray,Z0(D)),Q0=Z0;function J0(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 DD="2.17.2";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":DD,"X-Stainless-OS":Vu(Deno.build.os),"X-Stainless-Arch":Uu(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":DD,"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":DD,"X-Stainless-OS":Vu(globalThis.process.platform??"unknown"),"X-Stainless-Arch":Uu(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":DD,"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":DD,"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 Uu=(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"},Vu=(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"},Hu,qu=()=>{return Hu??(Hu=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 X0(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},G0=(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 $F(){}function fF(D,F,u){if(!F||PF[D]>PF[u])return $F;else return F[D].bind(F)}var X8={error:$F,warn:$F,info:$F,debug:$F},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 r=(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`,r({retryOfRequestLogID:E,url:u.url,status:u.status,body:$,durationMs:Date.now()-B})),$}var ZF;class ZD extends Promise{constructor(D,F,u=bF){super((C)=>{C(null)});this.responsePromise=F,this.parseResponse=u,ZF.set(this,void 0),qD(this,ZF,D,"f")}_thenUnwrap(D){return new ZD(e(this,ZF,"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(e(this,ZF,"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)}}ZF=new WeakMap;var vF;class Y0{constructor(D,F,u,C){vF.set(this,void 0),qD(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 e(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 ZD{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 Y0{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:{...J0(this.options.query),page_number:F+1}}}}class z0 extends Y0{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:{...J0(this.options.query),iterator:D}}}}var K0=()=>{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 K0(),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(K0(),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 _0(E),F,u)}let C=await _0(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 _0(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 _0(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:
|
|
24
|
-
${B.map((A)=>A.error).join(`
|
|
2
|
+
import{createRequire as V3}from"node:module";var T3=Object.create;var{getPrototypeOf:N3,defineProperty:T1,getOwnPropertyNames:B3}=Object;var H3=Object.prototype.hasOwnProperty;function M3($){return this[$]}var U3,x3,W_=($,_,F)=>{var J=$!=null&&typeof $==="object";if(J){var G=_?U3??=new WeakMap:x3??=new WeakMap,Z=G.get($);if(Z)return Z}F=$!=null?T3(N3($)):{};let X=_||!$||!$.__esModule?T1(F,"default",{value:$,enumerable:!0}):F;for(let Y of B3($))if(!H3.call(X,Y))T1(X,Y,{get:M3.bind($,Y),enumerable:!0});if(J)G.set($,X);return X};var S$=($,_)=>()=>(_||$((_={exports:{}}).exports,_),_.exports);var k=($,_)=>()=>($&&(_=$($=0)),_);var N1=V3(import.meta.url);var c1=S$((g1)=>{Object.defineProperty(g1,"__esModule",{value:!0});g1.timingSafeEqual=void 0;function v1($,_=""){if(!$)throw Error(_)}function p3($,_){if($.byteLength!==_.byteLength)return!1;if(!($ instanceof DataView))$=new DataView(ArrayBuffer.isView($)?$.buffer:$);if(!(_ instanceof DataView))_=new DataView(ArrayBuffer.isView(_)?_.buffer:_);v1($ instanceof DataView),v1(_ instanceof DataView);let F=$.byteLength,J=0,G=-1;while(++G<F)J|=$.getUint8(G)^_.getUint8(G);return J===0}g1.timingSafeEqual=p3});var u1=S$((l)=>{var n3=l&&l.__extends||function(){var $=function(_,F){return $=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(J,G){J.__proto__=G}||function(J,G){for(var Z in G)if(G.hasOwnProperty(Z))J[Z]=G[Z]},$(_,F)};return function(_,F){$(_,F);function J(){this.constructor=_}_.prototype=F===null?Object.create(F):(J.prototype=F.prototype,new J)}}();Object.defineProperty(l,"__esModule",{value:!0});var v=256,q_=function(){function $(_){if(_===void 0)_="=";this._paddingCharacter=_}return $.prototype.encodedLength=function(_){if(!this._paddingCharacter)return(_*8+5)/6|0;return(_+2)/3*4|0},$.prototype.encode=function(_){var F="",J=0;for(;J<_.length-2;J+=3){var G=_[J]<<16|_[J+1]<<8|_[J+2];F+=this._encodeByte(G>>>18&63),F+=this._encodeByte(G>>>12&63),F+=this._encodeByte(G>>>6&63),F+=this._encodeByte(G>>>0&63)}var Z=_.length-J;if(Z>0){var G=_[J]<<16|(Z===2?_[J+1]<<8:0);if(F+=this._encodeByte(G>>>18&63),F+=this._encodeByte(G>>>12&63),Z===2)F+=this._encodeByte(G>>>6&63);else F+=this._paddingCharacter||"";F+=this._paddingCharacter||""}return F},$.prototype.maxDecodedLength=function(_){if(!this._paddingCharacter)return(_*6+7)/8|0;return _/4*3|0},$.prototype.decodedLength=function(_){return this.maxDecodedLength(_.length-this._getPaddingLength(_))},$.prototype.decode=function(_){if(_.length===0)return new Uint8Array(0);var F=this._getPaddingLength(_),J=_.length-F,G=new Uint8Array(this.maxDecodedLength(J)),Z=0,X=0,Y=0,z=0,O=0,T=0,K=0;for(;X<J-4;X+=4)z=this._decodeChar(_.charCodeAt(X+0)),O=this._decodeChar(_.charCodeAt(X+1)),T=this._decodeChar(_.charCodeAt(X+2)),K=this._decodeChar(_.charCodeAt(X+3)),G[Z++]=z<<2|O>>>4,G[Z++]=O<<4|T>>>2,G[Z++]=T<<6|K,Y|=z&v,Y|=O&v,Y|=T&v,Y|=K&v;if(X<J-1)z=this._decodeChar(_.charCodeAt(X)),O=this._decodeChar(_.charCodeAt(X+1)),G[Z++]=z<<2|O>>>4,Y|=z&v,Y|=O&v;if(X<J-2)T=this._decodeChar(_.charCodeAt(X+2)),G[Z++]=O<<4|T>>>2,Y|=T&v;if(X<J-3)K=this._decodeChar(_.charCodeAt(X+3)),G[Z++]=T<<6|K,Y|=K&v;if(Y!==0)throw Error("Base64Coder: incorrect characters for decoding");return G},$.prototype._encodeByte=function(_){var F=_;return F+=65,F+=25-_>>>8&6,F+=51-_>>>8&-75,F+=61-_>>>8&-15,F+=62-_>>>8&3,String.fromCharCode(F)},$.prototype._decodeChar=function(_){var F=v;return F+=(42-_&_-44)>>>8&-v+_-43+62,F+=(46-_&_-48)>>>8&-v+_-47+63,F+=(47-_&_-58)>>>8&-v+_-48+52,F+=(64-_&_-91)>>>8&-v+_-65+0,F+=(96-_&_-123)>>>8&-v+_-97+26,F},$.prototype._getPaddingLength=function(_){var F=0;if(this._paddingCharacter){for(var J=_.length-1;J>=0;J--){if(_[J]!==this._paddingCharacter)break;F++}if(_.length<4||F>2)throw Error("Base64Coder: incorrect padding")}return F},$}();l.Coder=q_;var H0=new q_;function i3($){return H0.encode($)}l.encode=i3;function a3($){return H0.decode($)}l.decode=a3;var m1=function($){n3(_,$);function _(){return $!==null&&$.apply(this,arguments)||this}return _.prototype._encodeByte=function(F){var J=F;return J+=65,J+=25-F>>>8&6,J+=51-F>>>8&-75,J+=61-F>>>8&-13,J+=62-F>>>8&49,String.fromCharCode(J)},_.prototype._decodeChar=function(F){var J=v;return J+=(44-F&F-46)>>>8&-v+F-45+62,J+=(94-F&F-96)>>>8&-v+F-95+63,J+=(47-F&F-58)>>>8&-v+F-48+52,J+=(64-F&F-91)>>>8&-v+F-65+0,J+=(96-F&F-123)>>>8&-v+F-97+26,J},_}(q_);l.URLSafeCoder=m1;var d1=new m1;function t3($){return d1.encode($)}l.encodeURLSafe=t3;function r3($){return d1.decode($)}l.decodeURLSafe=r3;l.encodedLength=function($){return H0.encodedLength($)};l.maxDecodedLength=function($){return H0.maxDecodedLength($)};l.decodedLength=function($){return H0.decodedLength($)}});var p1=S$((l1,u0)=>{(function($,_){var F={};_(F);var J=F.default;for(var G in F)J[G]=F[G];if(typeof u0==="object"&&typeof u0.exports==="object")u0.exports=J;else if(typeof define==="function"&&define.amd)define(function(){return J});else $.sha256=J})(l1,function($){$.__esModule=!0,$.digestLength=32,$.blockSize=64;var _=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 F(K,Q,W,N,M){var H,x,U,C,w,A,g,D,f,q,L,P,y;while(M>=64){H=Q[0],x=Q[1],U=Q[2],C=Q[3],w=Q[4],A=Q[5],g=Q[6],D=Q[7];for(q=0;q<16;q++)L=N+q*4,K[q]=(W[L]&255)<<24|(W[L+1]&255)<<16|(W[L+2]&255)<<8|W[L+3]&255;for(q=16;q<64;q++)f=K[q-2],P=(f>>>17|f<<15)^(f>>>19|f<<13)^f>>>10,f=K[q-15],y=(f>>>7|f<<25)^(f>>>18|f<<14)^f>>>3,K[q]=(P+K[q-7]|0)+(y+K[q-16]|0);for(q=0;q<64;q++)P=(((w>>>6|w<<26)^(w>>>11|w<<21)^(w>>>25|w<<7))+(w&A^~w&g)|0)+(D+(_[q]+K[q]|0)|0)|0,y=((H>>>2|H<<30)^(H>>>13|H<<19)^(H>>>22|H<<10))+(H&x^H&U^x&U)|0,D=g,g=A,A=w,w=C+P|0,C=U,U=x,x=H,H=P+y|0;Q[0]+=H,Q[1]+=x,Q[2]+=U,Q[3]+=C,Q[4]+=w,Q[5]+=A,Q[6]+=g,Q[7]+=D,N+=64,M-=64}return N}var J=function(){function K(){this.digestLength=$.digestLength,this.blockSize=$.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 K.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},K.prototype.clean=function(){for(var Q=0;Q<this.buffer.length;Q++)this.buffer[Q]=0;for(var Q=0;Q<this.temp.length;Q++)this.temp[Q]=0;this.reset()},K.prototype.update=function(Q,W){if(W===void 0)W=Q.length;if(this.finished)throw Error("SHA256: can't update because hash was finished.");var N=0;if(this.bytesHashed+=W,this.bufferLength>0){while(this.bufferLength<64&&W>0)this.buffer[this.bufferLength++]=Q[N++],W--;if(this.bufferLength===64)F(this.temp,this.state,this.buffer,0,64),this.bufferLength=0}if(W>=64)N=F(this.temp,this.state,Q,N,W),W%=64;while(W>0)this.buffer[this.bufferLength++]=Q[N++],W--;return this},K.prototype.finish=function(Q){if(!this.finished){var W=this.bytesHashed,N=this.bufferLength,M=W/536870912|0,H=W<<3,x=W%64<56?64:128;this.buffer[N]=128;for(var U=N+1;U<x-8;U++)this.buffer[U]=0;this.buffer[x-8]=M>>>24&255,this.buffer[x-7]=M>>>16&255,this.buffer[x-6]=M>>>8&255,this.buffer[x-5]=M>>>0&255,this.buffer[x-4]=H>>>24&255,this.buffer[x-3]=H>>>16&255,this.buffer[x-2]=H>>>8&255,this.buffer[x-1]=H>>>0&255,F(this.temp,this.state,this.buffer,0,x),this.finished=!0}for(var U=0;U<8;U++)Q[U*4+0]=this.state[U]>>>24&255,Q[U*4+1]=this.state[U]>>>16&255,Q[U*4+2]=this.state[U]>>>8&255,Q[U*4+3]=this.state[U]>>>0&255;return this},K.prototype.digest=function(){var Q=new Uint8Array(this.digestLength);return this.finish(Q),Q},K.prototype._saveState=function(Q){for(var W=0;W<this.state.length;W++)Q[W]=this.state[W]},K.prototype._restoreState=function(Q,W){for(var N=0;N<this.state.length;N++)this.state[N]=Q[N];this.bytesHashed=W,this.finished=!1,this.bufferLength=0},K}();$.Hash=J;var G=function(){function K(Q){this.inner=new J,this.outer=new J,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var W=new Uint8Array(this.blockSize);if(Q.length>this.blockSize)new J().update(Q).finish(W).clean();else for(var N=0;N<Q.length;N++)W[N]=Q[N];for(var N=0;N<W.length;N++)W[N]^=54;this.inner.update(W);for(var N=0;N<W.length;N++)W[N]^=106;this.outer.update(W),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var N=0;N<W.length;N++)W[N]=0}return K.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},K.prototype.clean=function(){for(var Q=0;Q<this.istate.length;Q++)this.ostate[Q]=this.istate[Q]=0;this.inner.clean(),this.outer.clean()},K.prototype.update=function(Q){return this.inner.update(Q),this},K.prototype.finish=function(Q){if(this.outer.finished)this.outer.finish(Q);else this.inner.finish(Q),this.outer.update(Q,this.digestLength).finish(Q);return this},K.prototype.digest=function(){var Q=new Uint8Array(this.digestLength);return this.finish(Q),Q},K}();$.HMAC=G;function Z(K){var Q=new J().update(K),W=Q.digest();return Q.clean(),W}$.hash=Z,$.default=Z;function X(K,Q){var W=new G(K).update(Q),N=W.digest();return W.clean(),N}$.hmac=X;function Y(K,Q,W,N){var M=N[0];if(M===0)throw Error("hkdf: cannot expand more");if(Q.reset(),M>1)Q.update(K);if(W)Q.update(W);Q.update(N),Q.finish(K),N[0]++}var z=new Uint8Array($.digestLength);function O(K,Q,W,N){if(Q===void 0)Q=z;if(N===void 0)N=32;var M=new Uint8Array([1]),H=X(Q,K),x=new G(H),U=new Uint8Array(x.digestLength),C=U.length,w=new Uint8Array(N);for(var A=0;A<N;A++){if(C===U.length)Y(U,x,W,M),C=0;w[A]=U[C++]}return x.clean(),U.fill(0),M.fill(0),w}$.hkdf=O;function T(K,Q,W,N){var M=new G(K),H=M.digestLength,x=new Uint8Array(4),U=new Uint8Array(H),C=new Uint8Array(H),w=new Uint8Array(N);for(var A=0;A*H<N;A++){var g=A+1;x[0]=g>>>24&255,x[1]=g>>>16&255,x[2]=g>>>8&255,x[3]=g>>>0&255,M.reset(),M.update(Q),M.update(x),M.finish(C);for(var D=0;D<H;D++)U[D]=C[D];for(var D=2;D<=W;D++){M.reset(),M.update(C).finish(C);for(var f=0;f<H;f++)U[f]^=C[f]}for(var D=0;D<H&&A*H+D<N;D++)w[A*H+D]=U[D]}for(var A=0;A<H;A++)U[A]=C[A]=0;for(var A=0;A<4;A++)x[A]=0;return M.clean(),w}$.pbkdf2=T})});var r1=S$((a1)=>{Object.defineProperty(a1,"__esModule",{value:!0});a1.Webhook=a1.WebhookVerificationError=void 0;var s3=c1(),n1=u1(),o3=p1(),i1=300;class E_ extends Error{constructor($){super($);Object.setPrototypeOf(this,E_.prototype),this.name="ExtendableError",this.stack=Error($).stack}}class X$ extends E_{constructor($){super($);Object.setPrototypeOf(this,X$.prototype),this.name="WebhookVerificationError"}}a1.WebhookVerificationError=X$;class M0{constructor($,_){if(!$)throw Error("Secret can't be empty.");if((_===null||_===void 0?void 0:_.format)==="raw")if($ instanceof Uint8Array)this.key=$;else this.key=Uint8Array.from($,(F)=>F.charCodeAt(0));else{if(typeof $!=="string")throw Error("Expected secret to be of type string");if($.startsWith(M0.prefix))$=$.substring(M0.prefix.length);this.key=n1.decode($)}}verify($,_){let F={};for(let K of Object.keys(_))F[K.toLowerCase()]=_[K];let J=F["webhook-id"],G=F["webhook-signature"],Z=F["webhook-timestamp"];if(!G||!J||!Z)throw new X$("Missing required headers");let X=this.verifyTimestamp(Z),z=this.sign(J,X,$).split(",")[1],O=G.split(" "),T=new globalThis.TextEncoder;for(let K of O){let[Q,W]=K.split(",");if(Q!=="v1")continue;if((0,s3.timingSafeEqual)(T.encode(W),T.encode(z)))return JSON.parse($.toString())}throw new X$("No matching signature found")}sign($,_,F){if(typeof F==="string");else if(F.constructor.name==="Buffer")F=F.toString();else throw Error("Expected payload to be of type string or Buffer.");let J=new TextEncoder,G=Math.floor(_.getTime()/1000),Z=J.encode(`${$}.${G}.${F}`);return`v1,${n1.encode(o3.hmac(this.key,Z))}`}verifyTimestamp($){let _=Math.floor(Date.now()/1000),F=parseInt($,10);if(isNaN(F))throw new X$("Invalid Signature Headers");if(_-F>i1)throw new X$("Message timestamp too old");if(F>_+i1)throw new X$("Message timestamp too new");return new Date(F*1000)}}a1.Webhook=M0;M0.prefix="whsec_"});var x0=($,_=[])=>$.name==="up"||_.includes("vim")&&$.name==="k"||_.includes("emacs")&&$.ctrl&&$.name==="p",n0=($,_=[])=>$.name==="down"||_.includes("vim")&&$.name==="j"||_.includes("emacs")&&$.ctrl&&$.name==="n",V0=($)=>$.name==="backspace",w_=($)=>$.name==="tab",R_=($)=>"1234567890".includes($.name),q0=($)=>$.name==="enter"||$.name==="return";var D_,k_,i0,f_,E0;var a0=k(()=>{D_=class D_ extends Error{name="AbortPromptError";message="Prompt was aborted";constructor($){super();this.cause=$?.cause}};k_=class k_ extends Error{name="CancelPromptError";message="Prompt was canceled"};i0=class i0 extends Error{name="ExitPromptError"};f_=class f_ extends Error{name="HookError"};E0=class E0 extends Error{name="ValidationError"}});import{AsyncLocalStorage as _4,AsyncResource as F4}from"node:async_hooks";function J4($){return{rl:$,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function F2($,_){let F=J4($);return _2.run(F,()=>{function J(G){F.handleChange=()=>{F.index=0,G()},F.handleChange()}return _(J)})}function N$(){let $=_2.getStore();if(!$)throw new f_("[Inquirer] Hook functions can only be called from within a prompt");return $}function I_(){return N$().rl}function j_($){let _=(...F)=>{let J=N$(),G=!1,Z=J.handleChange;J.handleChange=()=>{G=!0};let X=$(...F);if(G)Z();return J.handleChange=Z,X};return F4.bind(_)}function l$($){let _=N$(),{index:F}=_,J={get(){return _.hooks[F]},set(Z){_.hooks[F]=Z},initialized:F in _.hooks},G=$(J);return _.index++,G}function J2(){N$().handleChange()}var _2,B$;var H$=k(()=>{a0();_2=new _4;B$={queue($){let _=N$(),{index:F}=_;_.hooksEffect.push(()=>{_.hooksCleanup[F]?.();let J=$(I_());if(J!=null&&typeof J!=="function")throw new E0("useEffect return value must be a cleanup function or nothing.");_.hooksCleanup[F]=J})},run(){let $=N$();j_(()=>{$.hooksEffect.forEach((_)=>{_()}),$.hooksEffect.length=0})()},clearAll(){let $=N$();$.hooksCleanup.forEach((_)=>{_?.()}),$.hooksEffect.length=0,$.hooksCleanup.length=0}}});import{AsyncResource as G4}from"node:async_hooks";function d($){return l$((_)=>{let F=G4.bind(function(Z){if(_.get()!==Z)_.set(Z),J2()});if(_.initialized)return[_.get(),F];let J=typeof $==="function"?$():$;return _.set(J),[J,F]})}var t0=k(()=>{H$()});function e($,_){l$((F)=>{let J=F.get();if(!Array.isArray(J)||_.some((Z,X)=>!Object.is(Z,J[X])))B$.queue($);F.set(_)})}var r0=k(()=>{H$()});import r from"node:process";function Z4(){if(r.platform!=="win32")return r.env.TERM!=="linux";return Boolean(r.env.WT_SESSION)||Boolean(r.env.TERMINUS_SUBLIME)||r.env.ConEmuTask==="{cmd::Cmder}"||r.env.TERM_PROGRAM==="Terminus-Sublime"||r.env.TERM_PROGRAM==="vscode"||r.env.TERM==="xterm-256color"||r.env.TERM==="alacritty"||r.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var G2,Z2,Q4,X4,K4,Y4,W4,p$,r6;var s0=k(()=>{G2={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:"╱"},Z2={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:"⅒"},Q4={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"},X4={...G2,...Z2},K4={...G2,...Q4},Y4=Z4(),W4=Y4?X4:K4,p$=W4,r6=Object.entries(Z2)});import{styleText as i}from"node:util";var Q2;var X2=k(()=>{s0();Q2={prefix:{idle:i("blue","?"),done:i("green",p$.tick)},spinner:{interval:80,frames:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"].map(($)=>i("yellow",$))},style:{answer:($)=>i("cyan",$),message:($)=>i("bold",$),error:($)=>i("red",`> ${$}`),defaultAnswer:($)=>i("dim",`(${$})`),help:($)=>i("dim",$),highlight:($)=>i("cyan",$),key:($)=>i("cyan",i("bold",`<${$}>`))}}});function K2($){if(typeof $!=="object"||$===null)return!1;let _=$;while(Object.getPrototypeOf(_)!==null)_=Object.getPrototypeOf(_);return Object.getPrototypeOf($)===_}function Y2(...$){let _={};for(let F of $)for(let[J,G]of Object.entries(F)){let Z=_[J];_[J]=K2(Z)&&K2(G)?Y2(Z,G):G}return _}function M$(...$){let _=[Q2,...$.filter((F)=>F!=null)];return Y2(..._)}var L_=k(()=>{X2()});function S0({status:$="idle",theme:_}){let[F,J]=d(!1),[G,Z]=d(0),{prefix:X,spinner:Y}=M$(_);if(e(()=>{if($==="loading"){let O,T=-1,K=setTimeout(()=>{J(!0),O=setInterval(()=>{T=T+1,Z(T%Y.frames.length)},Y.interval)},300);return()=>{clearTimeout(K),clearInterval(O)}}else J(!1)},[$]),F)return Y.frames[G];return typeof X==="string"?X:X[$==="loading"?"idle":$]??X.idle}var W2=k(()=>{t0();r0();L_()});function A0($,_){return l$((F)=>{let J=F.get();if(!J||J.dependencies.length!==_.length||J.dependencies.some((G,Z)=>G!==_[Z])){let G=$();return F.set({value:G,dependencies:_}),G}return J.value})}var z2=k(()=>{H$()});function U$($){return d({current:$})[0]}var o0=k(()=>{t0()});function C0($){let _=U$($);_.current=$,e((F)=>{let J=!1,G=j_((Z,X)=>{if(J)return;_.current(X,F)});return F.input.on("keypress",G),()=>{J=!0,F.input.removeListener("keypress",G)}},[])}var O2=k(()=>{o0();r0();H$()});var N2=S$((BG,T2)=>{T2.exports=O4;function z4($){let _={defaultWidth:0,output:process.stdout,tty:N1("tty")};if(!$)return _;return Object.keys(_).forEach(function(F){if(!$[F])$[F]=_[F]}),$}function O4($){let _=z4($);if(_.output.getWindowSize)return _.output.getWindowSize()[0]||_.defaultWidth;if(_.tty.getWindowSize)return _.tty.getWindowSize()[1]||_.defaultWidth;if(_.output.columns)return _.output.columns;if(process.env.CLI_WIDTH){let F=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(F)&&F!==0)return F}return _.defaultWidth}});var B2,H2=($)=>{return $===12288||$>=65281&&$<=65376||$>=65504&&$<=65510},M2=($)=>{return $===8987||$===9001||$>=12272&&$<=12287||$>=12289&&$<=12350||$>=12441&&$<=12543||$>=12549&&$<=12591||$>=12593&&$<=12686||$>=12688&&$<=12771||$>=12783&&$<=12830||$>=12832&&$<=12871||$>=12880&&$<=19903||$>=65040&&$<=65049||$>=65072&&$<=65106||$>=65108&&$<=65126||$>=65128&&$<=65131||$>=127488&&$<=127490||$>=127504&&$<=127547||$>=127552&&$<=127560||$>=131072&&$<=196605||$>=196608&&$<=262141};var U2=k(()=>{B2=(()=>{let $=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(_)=>{let F=0;$.lastIndex=0;while($.test(_))F+=1;return _.length-F}})()});var T4,N4,x2,B4,V2,H4,M4,U4,q2=($,_={},F={})=>{let J=_.limit??1/0,G=_.ellipsis??"",Z=_?.ellipsisWidth??(G?q2(G,U4,F).width:0),X=0,Y=F.controlWidth??0,z=F.tabWidth??8,O=F.emojiWidth??2,T=2,K=F.regularWidth??1,Q=F.wideWidth??2,W=[[H4,K],[T4,0],[N4,Y],[B4,z],[V2,O],[x2,Q]],N=0,M=0,H=$.length,x=0,U=!1,C=H,w=Math.max(0,J-Z),A=0,g=0,D=0,f=0;$:while(!0){if(g>A||M>=H&&M>N){let q=$.slice(A,g)||$.slice(N,M);x=0;for(let L of q.replaceAll(M4,"")){let P=L.codePointAt(0)||0;if(H2(P))f=2;else if(M2(P))f=Q;else f=K;if(D+f>w)C=Math.min(C,Math.max(A,N)+x);if(D+f>J){U=!0;break $}x+=L.length,D+=f}A=g=0}if(M>=H)break $;for(let q=0,L=W.length;q<L;q++){let[P,y]=W[q];if(P.lastIndex=M,P.test($)){if(x=P===x2?B2($.slice(M,P.lastIndex)):P===V2?1:P.lastIndex-M,f=x*y,D+f>w)C=Math.min(C,M+Math.floor((w-D)/y));if(D+f>J){U=!0;break $}D+=f,A=N,g=M,M=N=P.lastIndex;continue $}}M+=1}return{width:U?w:D,index:U?C:H,truncated:U,ellipsed:U&&J>=Z}},E2;var S2=k(()=>{U2();T4=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,N4=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,x2=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,B4=/\t{1,1000}/y,V2=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,H4=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,M4=/\p{M}+/gu,U4={limit:1/0,ellipsis:""},E2=q2});var x4,V4=($,_={})=>{return E2($,x4,_).width},$$;var A2=k(()=>{S2();x4={limit:1/0,ellipsis:"",ellipsisWidth:0},$$=V4});function j2($,_,F){return String($).normalize().split(C4).map((J)=>A4(J,_,F)).join(`
|
|
3
|
+
`)}var e0="\x1B",k2="",q4=39,b_="\x07",f2="[",E4="]",I2="m",y_,C2,w2=($)=>{if($>=30&&$<=37)return 39;if($>=90&&$<=97)return 39;if($>=40&&$<=47)return 49;if($>=100&&$<=107)return 49;if($===1||$===2)return 22;if($===3)return 23;if($===4)return 24;if($===7)return 27;if($===8)return 28;if($===9)return 29;if($===0)return 0;return},R2=($)=>`${e0}${f2}${$}${I2}`,D2=($)=>`${e0}${y_}${$}${b_}`,P_=($,_,F)=>{let J=_[Symbol.iterator](),G=!1,Z=!1,X=$.at(-1),Y=X===void 0?0:$$(X),z=J.next(),O=J.next(),T=0;while(!z.done){let K=z.value,Q=$$(K);if(Y+Q<=F)$[$.length-1]+=K;else $.push(K),Y=0;if(K===e0||K===k2)G=!0,Z=_.startsWith(y_,T+1);if(G){if(Z){if(K===b_)G=!1,Z=!1}else if(K===I2)G=!1}else if(Y+=Q,Y===F&&!O.done)$.push(""),Y=0;z=O,O=J.next(),T+=K.length}if(X=$.at(-1),!Y&&X!==void 0&&X.length&&$.length>1)$[$.length-2]+=$.pop()},S4=($)=>{let _=$.split(" "),F=_.length;while(F){if($$(_[F-1]))break;F--}if(F===_.length)return $;return _.slice(0,F).join(" ")+_.slice(F).join("")},A4=($,_,F={})=>{if(F.trim!==!1&&$.trim()==="")return"";let J="",G,Z,X=$.split(" "),Y=[""],z=0;for(let K=0;K<X.length;K++){let Q=X[K];if(F.trim!==!1){let N=Y.at(-1)??"",M=N.trimStart();if(N.length!==M.length)Y[Y.length-1]=M,z=$$(M)}if(K!==0){if(z>=_&&(F.wordWrap===!1||F.trim===!1))Y.push(""),z=0;if(z||F.trim===!1)Y[Y.length-1]+=" ",z++}let W=$$(Q);if(F.hard&&W>_){let N=_-z,M=1+Math.floor((W-N-1)/_);if(Math.floor((W-1)/_)<M)Y.push("");P_(Y,Q,_),z=$$(Y.at(-1)??"");continue}if(z+W>_&&z&&W){if(F.wordWrap===!1&&z<_){P_(Y,Q,_),z=$$(Y.at(-1)??"");continue}Y.push(""),z=0}if(z+W>_&&F.wordWrap===!1){P_(Y,Q,_),z=$$(Y.at(-1)??"");continue}Y[Y.length-1]+=Q,z+=W}if(F.trim!==!1)Y=Y.map((K)=>S4(K));let O=Y.join(`
|
|
4
|
+
`),T=!1;for(let K=0;K<O.length;K++){let Q=O[K];if(J+=Q,!T){if(T=Q>="\uD800"&&Q<="\uDBFF",T)continue}else T=!1;if(Q===e0||Q===k2){C2.lastIndex=K+1;let N=C2.exec(O)?.groups;if(N?.code!==void 0){let M=Number.parseFloat(N.code);G=M===q4?void 0:M}else if(N?.uri!==void 0)Z=N.uri.length===0?void 0:N.uri}if(O[K+1]===`
|
|
5
|
+
`){if(Z)J+=D2("");let W=G?w2(G):void 0;if(G&&W)J+=R2(W)}else if(Q===`
|
|
6
|
+
`){if(G&&w2(G))J+=R2(G);if(Z)J+=D2(Z)}}return J},C4;var L2=k(()=>{A2();y_=`${E4}8;;`,C2=new RegExp(`(?:\\${f2}(?<code>\\d+)m|\\${y_}(?<uri>.*)${b_})`,"y"),C4=/\r?\n/});function w0($,_){return $.split(`
|
|
7
|
+
`).flatMap((F)=>j2(F,_,{trim:!1,hard:!0}).split(`
|
|
8
|
+
`).map((J)=>J.trimEnd())).join(`
|
|
9
|
+
`)}function $_(){return P2.default({defaultWidth:80,output:I_().output})}var P2;var v_=k(()=>{L2();H$();P2=W_(N2(),1)});function w4({active:$,renderedItems:_,pageSize:F,loop:J}){let G=U$({lastPointer:$,lastActive:void 0}),{lastPointer:Z,lastActive:X}=G.current,Y=Math.floor(F/2),z=_.reduce((K,Q)=>K+Q.length,0),O=_.slice(0,$).reduce((K,Q)=>K+Q.length,0),T=O;if(z>F)if(J){if(T=Z,X!=null&&X<$&&$-X<F)T=Math.min(Y,Math.abs($-X)===1?Math.min(Z+(_[X]?.length??0),Math.max(O,Z)):Z+$-X)}else{let K=_.slice($).reduce((Q,W)=>Q+W.length,0);T=K<F-Y?F-K:Math.min(O,Y)}return G.current.lastPointer=T,G.current.lastActive=$,T}function g_({items:$,active:_,renderItem:F,pageSize:J,loop:G=!0}){let Z=$_(),X=(x)=>(x%$.length+$.length)%$.length,Y=$.map((x,U)=>{if(x==null)return[];return w0(F({item:x,index:U,isActive:U===_}),Z).split(`
|
|
10
|
+
`)}),z=Y.reduce((x,U)=>x+U.length,0),O=(x)=>Y[x]??[],T=w4({active:_,renderedItems:Y,pageSize:J,loop:G}),K=O(_).slice(0,J),Q=T+K.length<=J?T:J-K.length,W=Array.from({length:J});W.splice(Q,K.length,...K);let N=new Set([_]),M=Q+K.length,H=X(_+1);while(M<J&&!N.has(H)&&(G&&z>J?H!==_:H>_)){let U=O(H).slice(0,J-M);W.splice(M,U.length,...U),N.add(H),M+=U.length,H=X(H+1)}M=Q-1,H=X(_-1);while(M>=0&&!N.has(H)&&(G&&z>J?H!==_:H<_)){let x=O(H),U=x.slice(Math.max(0,x.length-M-1));W.splice(M-U.length+1,U.length,...U),N.add(H),M-=U.length,H=X(H-1)}return W.filter((x)=>typeof x==="string").join(`
|
|
11
|
+
`)}var b2=k(()=>{o0();v_()});var g2=S$((kG,v2)=>{var R4=N1("stream");class y2 extends R4{#F=null;constructor($={}){super($);this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=$.replace,this._prompt=$.prompt||null,this._hadControl=!1}#_($,_){if(this._dest)return this._dest[$];if(this._src)return this._src[$];return _}#$($,..._){if(typeof this._dest?.[$]==="function")this._dest[$](..._);if(typeof this._src?.[$]==="function")this._src[$](..._)}get isTTY(){if(this.#F!==null)return this.#F;return this.#_("isTTY",!1)}set isTTY($){this.#F=$}get rows(){return this.#_("rows")}get columns(){return this.#_("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe($){this._src=$}pipe($,_){return this._dest=$,super.pipe($,_)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write($){if(this.muted){if(!this.replace)return!0;if($.match(/^\u001b/)){if($.indexOf(this._prompt)===0)$=$.slice(this._prompt.length),$=$.replace(/./g,this.replace),$=this._prompt+$;return this._hadControl=!0,this.emit("data",$)}else{if(this._prompt&&this._hadControl&&$.indexOf(this._prompt)===0)this._hadControl=!1,this.emit("data",this._prompt),$=$.slice(this._prompt.length);$=$.toString().replace(/./g,this.replace)}}this.emit("data",$)}end($){if(this.muted)if($&&this.replace)$=$.toString().replace(/./g,this.replace);else $=null;if($)this.emit("data",$);this.emit("end")}destroy(...$){return this.#$("destroy",...$)}destroySoon(...$){return this.#$("destroySoon",...$)}close(...$){return this.#$("close",...$)}}v2.exports=y2});var x$;var h2=k(()=>{x$=[];x$.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")x$.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")x$.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")});class c2{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(c_[h_])return c_[h_];D4(c_,h_,{value:this,writable:!1,enumerable:!1,configurable:!1})}on($,_){this.listeners[$].push(_)}removeListener($,_){let F=this.listeners[$],J=F.indexOf(_);if(J===-1)return;if(J===0&&F.length===1)F.length=0;else F.splice(J,1)}emit($,_,F){if(this.emitted[$])return!1;this.emitted[$]=!0;let J=!1;for(let G of this.listeners[$])J=G(_,F)===!0||J;if($==="exit")J=this.emit("afterExit",_,F)||J;return J}}class d_{}var __=($)=>!!$&&typeof $==="object"&&typeof $.removeListener==="function"&&typeof $.emit==="function"&&typeof $.reallyExit==="function"&&typeof $.listeners==="function"&&typeof $.kill==="function"&&typeof $.pid==="number"&&typeof $.on==="function",h_,c_,D4,k4=($)=>{return{onExit(_,F){return $.onExit(_,F)},load(){return $.load()},unload(){return $.unload()}}},m2,d2,m_,u2,jG,LG;var l2=k(()=>{h2();h_=Symbol.for("signal-exit emitter"),c_=globalThis,D4=Object.defineProperty.bind(Object);m2=class m2 extends d_{onExit(){return()=>{}}load(){}unload(){}};d2=class d2 extends d_{#F=m_.platform==="win32"?"SIGINT":"SIGHUP";#_=new c2;#$;#Z;#Q;#G={};#J=!1;constructor($){super();this.#$=$,this.#G={};for(let _ of x$)this.#G[_]=()=>{let F=this.#$.listeners(_),{count:J}=this.#_,G=$;if(typeof G.__signal_exit_emitter__==="object"&&typeof G.__signal_exit_emitter__.count==="number")J+=G.__signal_exit_emitter__.count;if(F.length===J){this.unload();let Z=this.#_.emit("exit",null,_),X=_==="SIGHUP"?this.#F:_;if(!Z)$.kill($.pid,X)}};this.#Q=$.reallyExit,this.#Z=$.emit}onExit($,_){if(!__(this.#$))return()=>{};if(this.#J===!1)this.load();let F=_?.alwaysLast?"afterExit":"exit";return this.#_.on(F,$),()=>{if(this.#_.removeListener(F,$),this.#_.listeners.exit.length===0&&this.#_.listeners.afterExit.length===0)this.unload()}}load(){if(this.#J)return;this.#J=!0,this.#_.count+=1;for(let $ of x$)try{let _=this.#G[$];if(_)this.#$.on($,_)}catch(_){}this.#$.emit=($,..._)=>{return this.#K($,..._)},this.#$.reallyExit=($)=>{return this.#X($)}}unload(){if(!this.#J)return;this.#J=!1,x$.forEach(($)=>{let _=this.#G[$];if(!_)throw Error("Listener not defined for signal: "+$);try{this.#$.removeListener($,_)}catch(F){}}),this.#$.emit=this.#Z,this.#$.reallyExit=this.#Q,this.#_.count-=1}#X($){if(!__(this.#$))return 0;return this.#$.exitCode=$||0,this.#_.emit("exit",this.#$.exitCode,null),this.#Q.call(this.#$,this.#$.exitCode)}#K($,..._){let F=this.#Z;if($==="exit"&&__(this.#$)){if(typeof _[0]==="number")this.#$.exitCode=_[0];let J=F.call(this.#$,$,..._);return this.#_.emit("exit",this.#$.exitCode,null),J}else return F.call(this.#$,$,..._)}};m_=globalThis.process,{onExit:u2,load:jG,unload:LG}=k4(__(m_)?new d2(m_):new m2)});var f4="\x1B[G",n2="\x1B[?25l",i2="\x1B[?25h",u_=($=1)=>$>0?`\x1B[${$}A`:"",l_=($=1)=>$>0?`\x1B[${$}B`:"",p_=($,_)=>{if(typeof _==="number"&&!Number.isNaN(_))return`\x1B[${_+1};${$+1}H`;return`\x1B[${$+1}G`},p2="\x1B[2K",n_=($)=>$>0?(p2+u_(1)).repeat($-1)+p2+f4:"";import{stripVTControlCharacters as I4}from"node:util";class F_{height=0;extraLinesUnderPrompt=0;cursorPos;rl;constructor($){this.rl=$,this.cursorPos=$.getCursorPos()}write($){this.rl.output.unmute(),this.rl.output.write($),this.rl.output.mute()}render($,_=""){let F=j4($),J=I4(F),G=J;if(this.rl.line.length>0)G=G.slice(0,-this.rl.line.length);this.rl.setPrompt(G),this.cursorPos=this.rl.getCursorPos();let Z=$_();if($=w0($,Z),_=w0(_,Z),J.length%Z===0)$+=`
|
|
12
|
+
`;let X=$+(_?`
|
|
13
|
+
`+_:""),z=Math.floor(J.length/Z)-this.cursorPos.rows+(_?a2(_):0);if(z>0)X+=u_(z);X+=p_(this.cursorPos.cols),this.write(l_(this.extraLinesUnderPrompt)+n_(this.height)+X),this.extraLinesUnderPrompt=z,this.height=a2(X)}checkCursorPos(){let $=this.rl.getCursorPos();if($.cols!==this.cursorPos.cols)this.write(p_($.cols)),this.cursorPos=$}done({clearContent:$}){this.rl.setPrompt("");let _=l_(this.extraLinesUnderPrompt);_+=$?n_(this.height):`
|
|
14
|
+
`,_+=i2,this.write(_),this.rl.close()}}var a2=($)=>$.split(`
|
|
15
|
+
`).length,j4=($)=>$.split(`
|
|
16
|
+
`).pop()??"";var t2=k(()=>{v_()});var i_;var r2=k(()=>{i_=class i_ extends Promise{static withResolver(){let $,_;return{promise:new Promise((J,G)=>{$=J,_=G}),resolve:$,reject:_}}}});import*as s2 from"node:readline";import{AsyncResource as L4}from"node:async_hooks";function b4(){let $=Error.prepareStackTrace,_=[];try{Error.prepareStackTrace=(F,J)=>{let G=J.slice(1);return _=G,G},Error().stack}catch{return _}return Error.prepareStackTrace=$,_}function R0($){let _=b4();return(J,G={})=>{let{input:Z=process.stdin,signal:X}=G,Y=new Set,z=new o2.default;z.pipe(G.output??process.stdout),z.mute();let O=s2.createInterface({terminal:!0,input:Z,output:z}),T=new F_(O),{promise:K,resolve:Q,reject:W}=i_.withResolver(),N=()=>W(new k_);if(X){let H=()=>W(new D_({cause:X.reason}));if(X.aborted)return H(),Object.assign(K,{cancel:N});X.addEventListener("abort",H),Y.add(()=>X.removeEventListener("abort",H))}Y.add(u2((H,x)=>{W(new i0(`User force closed the prompt with ${H} ${x}`))}));let M=()=>W(new i0("User force closed the prompt with SIGINT"));return O.on("SIGINT",M),Y.add(()=>O.removeListener("SIGINT",M)),F2(O,(H)=>{let x=L4.bind(()=>B$.clearAll());O.on("close",x),Y.add(()=>O.removeListener("close",x));let U=()=>{let C=()=>T.checkCursorPos();O.input.on("keypress",C),Y.add(()=>O.input.removeListener("keypress",C)),H(()=>{try{let w=$(J,(D)=>{setImmediate(()=>Q(D))});if(w===void 0){let D=_[1]?.getFileName();throw Error(`Prompt functions must return a string.
|
|
17
|
+
at ${D}`)}let[A,g]=typeof w==="string"?[w]:w;T.render(A,g),B$.run()}catch(w){W(w)}})};if("readableFlowing"in Z)P4(U);else U();return Object.assign(K.then((C)=>{return B$.clearAll(),C},(C)=>{throw B$.clearAll(),C}).finally(()=>{Y.forEach((C)=>C()),T.done({clearContent:Boolean(G.clearPromptOnDone)}),z.end()}).then(()=>K),{cancel:N})})}}var o2,P4;var e2=k(()=>{l2();t2();r2();H$();a0();o2=W_(g2(),1),P4=globalThis.setImmediate});import{styleText as y4}from"node:util";class _${separator=y4("dim",Array.from({length:15}).join(p$.line));type="separator";constructor($){if($)this.separator=$}static isSeparator($){return Boolean($&&typeof $==="object"&&"type"in $&&$.type==="separator")}}var $F=k(()=>{s0()});var a_=k(()=>{W2();t0();r0();z2();o0();O2();L_();b2();e2();$F();a0()});var v4,S;var _F=k(()=>{a_();v4={validationFailureMode:"keep"},S=R0(($,_)=>{let{prefill:F="tab"}=$,J=M$(v4,$.theme),[G,Z]=d("idle"),[X,Y]=d(String($.default??"")),[z,O]=d(),[T,K]=d(""),Q=S0({status:G,theme:J});async function W(U){let{required:C,pattern:w,patternError:A="Invalid input"}=$;if(C&&!U)return"You must provide a value";if(w&&!w.test(U))return A;if(typeof $.validate==="function")return await $.validate(U)||"You must provide a valid value";return!0}C0(async(U,C)=>{if(G!=="idle")return;if(q0(U)){let w=T||X;Z("loading");let A=await W(w);if(A===!0)K(w),Z("done"),_(w);else{if(J.validationFailureMode==="clear")K("");else C.write(T);O(A),Z("idle")}}else if(V0(U)&&!T)Y("");else if(w_(U)&&!T)Y(""),C.clearLine(0),C.write(X),K(X);else K(C.line),O(void 0)}),e((U)=>{if(F==="editable"&&X)U.write(X),K(X)},[]);let N=J.style.message($.message,G),M=T;if(typeof $.transformer==="function")M=$.transformer(T,{isFinal:G==="done"});else if(G==="done")M=J.style.answer(T);let H;if(X&&G!=="done"&&!T)H=J.style.defaultAnswer(X);let x="";if(z)x=J.style.error(z);return[[Q,N,H,M].filter((U)=>U!==void 0).join(" "),x]})});import{styleText as D0}from"node:util";function t_($){return!_$.isSeparator($)&&!$.disabled}function r_($){return!_$.isSeparator($)}function h4($){return $.map((_)=>{if(_$.isSeparator(_))return _;if(typeof _!=="object"||_===null||!("value"in _)){let G=String(_);return{value:_,name:G,short:G,disabled:!1}}let F=_.name??String(_.value),J={value:_.value,name:F,short:_.short??F,disabled:_.disabled??!1};if(_.description)J.description=_.description;return J})}var g4,a;var FF=k(()=>{a_();s0();g4={icon:{cursor:p$.pointer},style:{disabled:($)=>D0("dim",$),description:($)=>D0("cyan",$),keysHelpTip:($)=>$.map(([_,F])=>`${D0("bold",_)} ${D0("dim",F)}`).join(D0("dim"," • "))},i18n:{disabledError:"This option is disabled and cannot be selected."},indexMode:"hidden",keybindings:[]};a=R0(($,_)=>{let{loop:F=!0,pageSize:J=7}=$,G=M$(g4,$.theme),{keybindings:Z}=G,[X,Y]=d("idle"),z=S0({status:X,theme:G}),O=U$(),T=!Z.includes("vim"),K=A0(()=>h4($.choices),[$.choices]),Q=A0(()=>{let q=K.findIndex(r_),L=K.findLastIndex(r_);if(q===-1)throw new E0("[select prompt] No selectable choices. All choices are disabled.");return{first:q,last:L}},[K]),W=A0(()=>{if(!("default"in $))return-1;return K.findIndex((q)=>t_(q)&&q.value===$.default)},[$.default,K]),[N,M]=d(W===-1?Q.first:W),H=K[N],[x,U]=d();C0((q,L)=>{if(clearTimeout(O.current),x)U(void 0);if(q0(q))if(H.disabled)U(G.i18n.disabledError);else Y("done"),_(H.value);else if(x0(q,Z)||n0(q,Z)){if(L.clearLine(0),F||x0(q,Z)&&N!==Q.first||n0(q,Z)&&N!==Q.last){let P=x0(q,Z)?-1:1,y=N;do y=(y+P+K.length)%K.length;while(!r_(K[y]));M(y)}}else if(R_(q)&&!Number.isNaN(Number(L.line))){let P=Number(L.line)-1,y=-1,s=K.findIndex((r$)=>{if(_$.isSeparator(r$))return!1;return y++,y===P}),Y_=K[s];if(Y_!=null&&t_(Y_))M(s);O.current=setTimeout(()=>{L.clearLine(0)},700)}else if(V0(q))L.clearLine(0);else if(T){let P=L.line.toLowerCase(),y=K.findIndex((s)=>{if(_$.isSeparator(s)||!t_(s))return!1;return s.name.toLowerCase().startsWith(P)});if(y!==-1)M(y);O.current=setTimeout(()=>{L.clearLine(0)},700)}}),e(()=>()=>{clearTimeout(O.current)},[]);let C=G.style.message($.message,X),w=G.style.keysHelpTip([["↑↓","navigate"],["⏎","select"]]),A=0,g=g_({items:K,active:N,renderItem({item:q,isActive:L,index:P}){if(_$.isSeparator(q))return A++,` ${q.separator}`;let y=L?G.icon.cursor:" ",s=G.indexMode==="number"?`${P+1-A}. `:"";if(q.disabled){let r$=typeof q.disabled==="string"?q.disabled:"(disabled)",O3=L?G.icon.cursor:"-";return G.style.disabled(`${O3} ${s}${q.name} ${r$}`)}return(L?G.style.highlight:(r$)=>r$)(`${y} ${s}${q.name}`)},pageSize:J,loop:F});if(X==="done")return[z,C,G.style.answer(H.short)].filter(Boolean).join(" ");let{description:D}=H;return`${[[z,C].filter(Boolean).join(" "),g," ",D?G.style.description(D):"",x?G.style.error(x):"",w].filter(Boolean).join(`
|
|
18
|
+
`).trimEnd()}${n2}`})});var p=k(()=>{_F();FF()});var PF;var bF=k(()=>{PF=["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 K$=({business_id:$="bus_test",product_id:_="pdt_test",subscription_id:F="sub_test",qty:J=1,metadata:G,email:Z,customer_id:X})=>{return{business_id:$,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:X,email:Z,name:"Test user",phone_number:null},discount_cycles_remaining:null,discount_id:null,expires_at:null,metadata:G,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:_,quantity:J,recurring_pre_tax_amount:400,status:"active",subscription_id:F,subscription_period_count:10,subscription_period_interval:"Year",tax_inclusive:!1,trial_period_days:0},timestamp:new Date().toISOString()}},yF=($)=>{return{...K$($),type:"subscription.active"}},vF=($)=>{let _=K$($);return{..._,type:"subscription.updated",data:{..._.data,status:"active"}}},gF=($)=>{let _=K$($);return{..._,type:"subscription.on_hold",data:{..._.data,status:"on_hold"}}},hF=($)=>{return{...K$($),type:"subscription.renewed"}},cF=($)=>{let _=K$($);return{..._,type:"subscription.plan_changed",data:{..._.data,status:"active"}}},mF=($)=>{let _=K$($);return{..._,type:"subscription.cancelled",data:{..._.data,cancel_at_next_billing_date:!0,status:"cancelled"}}},dF=($)=>{let _=K$($);return{..._,type:"subscription.failed",data:{..._.data,status:"failed"}}},uF=($)=>{let _=K$($);return{..._,type:"subscription.expired",data:{..._.data,status:"expired"}}};var lF=()=>{};var K_=({business_id:$="bus_test",product_id:_="pdt_test",qty:F=1,email:J,customer_id:G})=>{return{business_id:$,data:{billing:{city:"New York",country:"US",state:"New York",street:"New York, New York",zipcode:"12345"},brand_id:$,business_id:$,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:G,email:J,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:_,quantity:F}],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()}},pF=($)=>{return{...K_($),type:"payment.succeeded"}},nF=($)=>{return{...K_($),type:"payment.failed"}},iF=($)=>{return{...K_($),type:"payment.processing"}},aF=($)=>{return{...K_($),type:"payment.cancelled"}};var tF=()=>{};var rF=({business_id:$="bus_test",email:_,customer_id:F})=>{return{business_id:$,data:{amount:400,business_id:$,created_at:new Date().toISOString(),currency:"USD",customer:{customer_id:F,email:_,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()}},sF=($)=>{return{...rF($),type:"refund.succeeded"}},oF=($)=>{return{...rF($),type:"refund.failed"}};var eF=()=>{};var E$=({business_id:$="bus_test",email:_,customer_id:F})=>{return{business_id:$,data:{amount:400,business_id:$,created_at:new Date().toISOString(),currency:"USD",customer:{customer_id:F,email:_,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()}},$3=($)=>{let _=E$($);return{..._,type:"dispute.opened",data:{..._.data,dispute_status:"dispute_opened"}}},_3=($)=>{let _=E$($);return{..._,type:"dispute.expired",data:{..._.data,dispute_status:"dispute_expired"}}},F3=($)=>{let _=E$($);return{..._,type:"dispute.accepted",data:{..._.data,dispute_status:"dispute_accepted"}}},J3=($)=>{let _=E$($);return{..._,type:"dispute.cancelled",data:{..._.data,dispute_status:"dispute_cancelled"}}},G3=($)=>{let _=E$($);return{..._,type:"dispute.challenged",data:{..._.data,dispute_status:"dispute_challenged"}}},Z3=($)=>{let _=E$($);return{..._,type:"dispute.won",data:{..._.data,dispute_status:"dispute_won"}}},Q3=($)=>{let _=E$($);return{..._,type:"dispute.lost",data:{..._.data,dispute_status:"dispute_lost"}}};var X3=()=>{};var C8=({business_id:$="bus_test",product_id:_="pdt_test",subscription_id:F,customer_id:J})=>{return{business_id:$,data:{activations_limit:null,business_id:$,created_at:new Date().toISOString(),customer_id:J,expires_at:null,id:"lic_test",instances_count:0,key:"db44b22c-fe9b-4a68-bf0d-b0e0d6c6c8c0",payload_type:"LicenseKey",payment_id:"pay_test",product_id:_,status:"active",subscription_id:F},timestamp:new Date().toISOString()}},K3=($)=>{return{...C8($),type:"license_key.created"}};var Y3=()=>{};var D8={};var w8,j0,O1,R8,L0,P0;var W3=k(async()=>{p();bF();lF();tF();eF();X3();Y3();w8=await S({message:"What is your endpoint?",validate:($)=>{if(!$.startsWith("http"))return"Please enter a valid URL starting with http or https";return!0}}),j0=await S({message:"What is your Dodo Payments business ID? (Optional)",default:"bus_test"}),O1=await S({message:"What is your product ID? (Optional)",default:"pdt_test"}),R8=await S({message:"What is your metadata? (JSON stringified, Optional)",default:"{}"}),L0=await S({message:"What is the customer's email? (Optional)",default:"john.doe@example.com"}),P0=await S({message:"What is the customer's id? (Optional)",default:"cus_test"});while(!0){let $=await a({message:"Select an event to send:",choices:[...PF,"exit"].map((J)=>({value:J,name:J})),loop:!1});if($==="exit")console.log("Exiting..."),process.exit();let _,F=JSON.parse(R8);if($.startsWith("subscription.")){let J={business_id:j0,product_id:O1,metadata:F,email:L0,customer_id:P0};if($==="subscription.active")_=yF(J);else if($==="subscription.updated")_=vF(J);else if($==="subscription.on_hold")_=gF(J);else if($==="subscription.renewed")_=hF(J);else if($==="subscription.plan_changed")_=cF(J);else if($==="subscription.cancelled")_=mF(J);else if($==="subscription.failed")_=dF(J);else if($==="subscription.expired")_=uF(J)}if($.startsWith("payment.")){let J={business_id:j0,product_id:O1,metadata:F,email:L0,customer_id:P0};if($==="payment.success")_=pF(J);else if($==="payment.failed")_=nF(J);else if($==="payment.processing")_=iF(J);else if($==="payment.cancelled")_=aF(J)}if($.startsWith("refund.")){let J={business_id:j0,email:L0,customer_id:P0};if($==="refund.success")_=sF(J);else if($==="refund.failed")_=oF(J)}if($.startsWith("dispute.")){let J={business_id:j0,email:L0,customer_id:P0};if($==="dispute.opened")_=$3(J);else if($==="dispute.expired")_=_3(J);else if($==="dispute.accepted")_=F3(J);else if($==="dispute.cancelled")_=J3(J);else if($==="dispute.challenged")_=G3(J);else if($==="dispute.won")_=Z3(J);else if($==="dispute.lost")_=Q3(J)}if($.startsWith("licence.")){let J={business_id:j0,product_id:O1,email:L0,customer_id:P0};if($==="licence.created")_=K3(J)}await fetch(w8,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)}).then(async(J)=>{console.log(`✅ Webhook Event Sent!
|
|
19
|
+
Received Response Code: ${J.status}
|
|
20
|
+
Received Response Body: ${await J.text()}`),console.log()}).catch((J)=>{console.error("❌ Webhook Event Failed:",J),console.log()})}});function A$($,_,F,J,G){if(J==="m")throw TypeError("Private method is not writable");if(J==="a"&&!G)throw TypeError("Private accessor was defined without a setter");if(typeof _==="function"?$!==_||!G:!_.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return J==="a"?G.call($,F):G?G.value=F:_.set($,F),F}function J$($,_,F,J){if(F==="a"&&!J)throw TypeError("Private accessor was defined without a getter");if(typeof _==="function"?$!==_||!J:!_.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return F==="m"?J:F==="a"?J.call($):J?J.value:_.get($)}var z_=function(){let{crypto:$}=globalThis;if($?.randomUUID)return z_=$.randomUUID.bind($),$.randomUUID();let _=new Uint8Array(1),F=$?()=>$.getRandomValues(_)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(J)=>(+J^F()&15>>+J/4).toString(16))};function B1($){return typeof $==="object"&&$!==null&&(("name"in $)&&$.name==="AbortError"||("message"in $)&&String($.message).includes("FetchRequestCanceledException"))}var s$=($)=>{if($ instanceof Error)return $;if(typeof $==="object"&&$!==null){try{if(Object.prototype.toString.call($)==="[object Error]"){let _=Error($.message,$.cause?{cause:$.cause}:{});if($.stack)_.stack=$.stack;if($.cause&&!_.cause)_.cause=$.cause;if($.name)_.name=$.name;return _}}catch{}try{return Error(JSON.stringify($))}catch{}}return Error($)};class c extends Error{}class h extends c{constructor($,_,F,J){super(`${h.makeMessage($,_,F)}`);this.status=$,this.headers=J,this.error=_}static makeMessage($,_,F){let J=_?.message?typeof _.message==="string"?_.message:JSON.stringify(_.message):_?JSON.stringify(_):F;if($&&J)return`${$} ${J}`;if($)return`${$} status code (no body)`;if(J)return J;return"(no status code or body)"}static generate($,_,F,J){if(!$||!J)return new Y$({message:F,cause:s$(_)});let G=_;if($===400)return new e$($,G,F,J);if($===401)return new $0($,G,F,J);if($===403)return new _0($,G,F,J);if($===404)return new F0($,G,F,J);if($===409)return new J0($,G,F,J);if($===422)return new G0($,G,F,J);if($===429)return new Z0($,G,F,J);if($>=500)return new Q0($,G,F,J);return new h($,G,F,J)}}class C$ extends h{constructor({message:$}={}){super(void 0,void 0,$||"Request was aborted.",void 0)}}class Y$ extends h{constructor({message:$,cause:_}){super(void 0,void 0,$||"Connection error.",void 0);if(_)this.cause=_}}class o$ extends Y${constructor({message:$}={}){super({message:$??"Request timed out."})}}class e$ extends h{}class $0 extends h{}class _0 extends h{}class F0 extends h{}class J0 extends h{}class G0 extends h{}class Z0 extends h{}class Q0 extends h{}var E3=/^[a-z][a-z0-9+.-]*:/i,H1=($)=>{return E3.test($)},O_=($)=>(O_=Array.isArray,O_($)),T_=O_;function N_($){if(typeof $!=="object")return{};return $??{}}function M1($){if(!$)return!0;for(let _ in $)return!1;return!0}function U1($,_){return Object.prototype.hasOwnProperty.call($,_)}var x1=($,_)=>{if(typeof _!=="number"||!Number.isInteger(_))throw new c(`${$} must be an integer`);if(_<0)throw new c(`${$} must be a positive integer`);return _};var V1=($)=>{try{return JSON.parse($)}catch(_){return}};var q1=($)=>new Promise((_)=>setTimeout(_,$));var G$="2.23.2";function S3(){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 A3=()=>{let $=S3();if($==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":G$,"X-Stainless-OS":S1(Deno.build.os),"X-Stainless-Arch":E1(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":G$,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if($==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":G$,"X-Stainless-OS":S1(globalThis.process.platform??"unknown"),"X-Stainless-Arch":E1(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let _=C3();if(_)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":G$,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${_.browser}`,"X-Stainless-Runtime-Version":_.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":G$,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function C3(){if(typeof navigator>"u"||!navigator)return null;let $=[{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:_,pattern:F}of $){let J=F.exec(navigator.userAgent);if(J){let G=J[1]||0,Z=J[2]||0,X=J[3]||0;return{browser:_,version:`${G}.${Z}.${X}`}}}return null}var E1=($)=>{if($==="x32")return"x32";if($==="x86_64"||$==="x64")return"x64";if($==="arm")return"arm";if($==="aarch64"||$==="arm64")return"arm64";if($)return`other:${$}`;return"unknown"},S1=($)=>{if($=$.toLowerCase(),$.includes("ios"))return"iOS";if($==="android")return"Android";if($==="darwin")return"MacOS";if($==="win32")return"Windows";if($==="freebsd")return"FreeBSD";if($==="openbsd")return"OpenBSD";if($==="linux")return"Linux";if($)return`Other:${$}`;return"Unknown"},A1,C1=()=>{return A1??(A1=A3())};function w1(){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 w3(...$){let _=globalThis.ReadableStream;if(typeof _>"u")throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new _(...$)}function B_($){let _=Symbol.asyncIterator in $?$[Symbol.asyncIterator]():$[Symbol.iterator]();return w3({start(){},async pull(F){let{done:J,value:G}=await _.next();if(J)F.close();else F.enqueue(G)},async cancel(){await _.return?.()}})}async function R1($){if($===null||typeof $!=="object")return;if($[Symbol.asyncIterator]){await $[Symbol.asyncIterator]().return?.();return}let _=$.getReader(),F=_.cancel();_.releaseLock(),await F}var D1=({headers:$,body:_})=>{return{bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(_)}};function k1($){return Object.entries($).filter(([_,F])=>typeof F<"u").map(([_,F])=>{if(typeof F==="string"||typeof F==="number"||typeof F==="boolean")return`${encodeURIComponent(_)}=${encodeURIComponent(F)}`;if(F===null)return`${encodeURIComponent(_)}=`;throw new c(`Cannot stringify type ${typeof F}; 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("&")}var v0={off:0,error:200,warn:300,info:400,debug:500},H_=($,_,F)=>{if(!$)return;if(U1(v0,$))return $;m(F).warn(`${_} was set to ${JSON.stringify($)}, expected one of ${JSON.stringify(Object.keys(v0))}`);return};function X0(){}function y0($,_,F){if(!_||v0[$]>v0[F])return X0;else return _[$].bind(_)}var k3={error:X0,warn:X0,info:X0,debug:X0},f1=new WeakMap;function m($){let _=$.logger,F=$.logLevel??"off";if(!_)return k3;let J=f1.get(_);if(J&&J[0]===F)return J[1];let G={error:y0("error",_,F),warn:y0("warn",_,F),info:y0("info",_,F),debug:y0("debug",_,F)};return f1.set(_,[F,G]),G}var o=($)=>{if($.options)$.options={...$.options},delete $.options.headers;if($.headers)$.headers=Object.fromEntries(($.headers instanceof Headers?[...$.headers]:Object.entries($.headers)).map(([_,F])=>[_,_.toLowerCase()==="authorization"||_.toLowerCase()==="cookie"||_.toLowerCase()==="set-cookie"?"***":F]));if("retryOfRequestLogID"in $){if($.retryOfRequestLogID)$.retryOf=$.retryOfRequestLogID;delete $.retryOfRequestLogID}return $};async function g0($,_){let{response:F,requestLogID:J,retryOfRequestLogID:G,startTime:Z}=_,X=await(async()=>{if(F.status===204)return null;if(_.options.__binaryResponse)return F;let z=F.headers.get("content-type")?.split(";")[0]?.trim();if(z?.includes("application/json")||z?.endsWith("+json")){if(F.headers.get("content-length")==="0")return;return await F.json()}return await F.text()})();return m($).debug(`[${J}] response parsed`,o({retryOfRequestLogID:G,url:F.url,status:F.status,body:X,durationMs:Date.now()-Z})),X}var K0;class W$ extends Promise{constructor($,_,F=g0){super((J)=>{J(null)});this.responsePromise=_,this.parseResponse=F,K0.set(this,void 0),A$(this,K0,$,"f")}_thenUnwrap($){return new W$(J$(this,K0,"f"),this.responsePromise,async(_,F)=>$(await this.parseResponse(_,F),F))}asResponse(){return this.responsePromise.then(($)=>$.response)}async withResponse(){let[$,_]=await Promise.all([this.parse(),this.asResponse()]);return{data:$,response:_}}parse(){if(!this.parsedPromise)this.parsedPromise=this.responsePromise.then(($)=>this.parseResponse(J$(this,K0,"f"),$));return this.parsedPromise}then($,_){return this.parse().then($,_)}catch($){return this.parse().catch($)}finally($){return this.parse().finally($)}}K0=new WeakMap;var h0;class M_{constructor($,_,F,J){h0.set(this,void 0),A$(this,h0,$,"f"),this.options=J,this.response=_,this.body=F}hasNextPage(){if(!this.getPaginatedItems().length)return!1;return this.nextPageRequestOptions()!=null}async getNextPage(){let $=this.nextPageRequestOptions();if(!$)throw new c("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await J$(this,h0,"f").requestAPIList(this.constructor,$)}async*iterPages(){let $=this;yield $;while($.hasNextPage())$=await $.getNextPage(),yield $}async*[(h0=new WeakMap,Symbol.asyncIterator)](){for await(let $ of this.iterPages())for(let _ of $.getPaginatedItems())yield _}}class c0 extends W${constructor($,_,F){super($,_,async(J,G)=>new F(J,G.response,await g0(J,G),G.options))}async*[Symbol.asyncIterator](){let $=await this;for await(let _ of $)yield _}}class R extends M_{constructor($,_,F,J){super($,_,F,J);this.items=F.items||[]}getPaginatedItems(){return this.items??[]}nextPageRequestOptions(){let _=this.options.query?.page_number??1;return{...this.options,query:{...N_(this.options.query),page_number:_+1}}}}class U_ extends M_{constructor($,_,F,J){super($,_,F,J);this.data=F.data||[],this.iterator=F.iterator||"",this.done=F.done||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.done===!1)return!1;return super.hasNextPage()}nextPageRequestOptions(){let $=this.iterator;if(!$)return null;return{...this.options,query:{...N_(this.options.query),iterator:$}}}}var x_=()=>{if(typeof File>"u"){let{process:$}=globalThis,_=typeof $?.versions?.node==="string"&&parseInt($.versions.node.split("."))<20;throw Error("`File` is not defined as a global, which is required for file uploads."+(_?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function m0($,_,F){return x_(),new File($,_??"unknown_file",F)}function I1($){return(typeof $==="object"&&$!==null&&(("name"in $)&&$.name&&String($.name)||("url"in $)&&$.url&&String($.url)||("filename"in $)&&$.filename&&String($.filename)||("path"in $)&&$.path&&String($.path))||"").split(/[\\/]/).pop()||void 0}var j1=($)=>$!=null&&typeof $==="object"&&typeof $[Symbol.asyncIterator]==="function";var L1=($)=>$!=null&&typeof $==="object"&&typeof $.size==="number"&&typeof $.type==="string"&&typeof $.text==="function"&&typeof $.slice==="function"&&typeof $.arrayBuffer==="function",I3=($)=>$!=null&&typeof $==="object"&&typeof $.name==="string"&&typeof $.lastModified==="number"&&L1($),j3=($)=>$!=null&&typeof $==="object"&&typeof $.url==="string"&&typeof $.blob==="function";async function d0($,_,F){if(x_(),$=await $,I3($)){if($ instanceof File)return $;return m0([await $.arrayBuffer()],$.name)}if(j3($)){let G=await $.blob();return _||(_=new URL($.url).pathname.split(/[\\/]/).pop()),m0(await V_(G),_,F)}let J=await V_($);if(_||(_=I1($)),!F?.type){let G=J.find((Z)=>typeof Z==="object"&&("type"in Z)&&Z.type);if(typeof G==="string")F={...F,type:G}}return m0(J,_,F)}async function V_($){let _=[];if(typeof $==="string"||ArrayBuffer.isView($)||$ instanceof ArrayBuffer)_.push($);else if(L1($))_.push($ instanceof Blob?$:await $.arrayBuffer());else if(j1($))for await(let F of $)_.push(...await V_(F));else{let F=$?.constructor?.name;throw Error(`Unexpected data type: ${typeof $}${F?`; constructor: ${F}`:""}${L3($)}`)}return _}function L3($){if(typeof $!=="object"||$===null)return"";return`; props: [${Object.getOwnPropertyNames($).map((F)=>`"${F}"`).join(", ")}]`}class V{constructor($){this._client=$}}function b1($){return $.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var P1=Object.freeze(Object.create(null)),b3=($=b1)=>function(F,...J){if(F.length===1)return F[0];let G=!1,Z=[],X=F.reduce((T,K,Q)=>{if(/[?#]/.test(K))G=!0;let W=J[Q],N=(G?encodeURIComponent:$)(""+W);if(Q!==J.length&&(W==null||typeof W==="object"&&W.toString===Object.getPrototypeOf(Object.getPrototypeOf(W.hasOwnProperty??P1)??P1)?.toString))N=W+"",Z.push({start:T.length+K.length,length:N.length,error:`Value of type ${Object.prototype.toString.call(W).slice(8,-1)} is not a valid path parameter`});return T+K+(Q===J.length?"":N)},""),Y=X.split(/[?#]/,1)[0],z=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,O;while((O=z.exec(Y))!==null)Z.push({start:O.index,length:O[0].length,error:`Value "${O[0]}" can't be safely passed as a path parameter`});if(Z.sort((T,K)=>T.start-K.start),Z.length>0){let T=0,K=Z.reduce((Q,W)=>{let N=" ".repeat(W.start-T),M="^".repeat(W.length);return T=W.start+W.length,Q+N+M},"");throw new c(`Path parameters result in path with invalid segments:
|
|
21
|
+
${Z.map((Q)=>Q.error).join(`
|
|
25
22
|
`)}
|
|
26
|
-
${
|
|
27
|
-
${Z}`)}return $},K=W8(Lu);class xD 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 SD 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 wD 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 QF 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 JF 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 RD extends N{constructor(){super(...arguments);this.ledgerEntries=new JF(this._client)}list(D,F){return this._client.get(K`/customers/${D}/wallets`,F)}}RD.LedgerEntries=JF;class FD extends N{constructor(){super(...arguments);this.customerPortal=new QF(this._client),this.wallets=new RD(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)}}FD.CustomerPortal=QF;FD.Wallets=RD;var fu=Symbol("brand.privateNullableHeaders");function*U8(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(Q0(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=Q0(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 U8(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 jD 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 kD 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 XF 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 QD extends N{constructor(){super(...arguments);this.payments=new XF(this._client)}}QD.Payments=XF;class ID 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 LD 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 fD 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 PD 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 bD extends N{listSupportedCountries(D){return this._client.get("/checkout/supported_countries",D)}}class vD 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 yD extends N{list(D={},F){return this._client.getAPIList("/payouts",x,{query:D,...F})}}class GF 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 YF 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 uD extends N{constructor(){super(...arguments);this.images=new GF(this._client),this.shortLinks=new YF(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})}}uD.Images=GF;uD.ShortLinks=YF;class hD 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 gD 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 mD 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 dD extends N{}class zF 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 JD extends N{constructor(){super(...arguments);this.headers=new zF(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",z0,{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)}}JD.Headers=zF;var WF=(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 T0,N0,dF,tu,su={live_mode:"https://live.dodopayments.com",test_mode:"https://test.dodopayments.com"};class U{constructor({baseURL:D=WF("DODO_PAYMENTS_BASE_URL"),bearerToken:F=WF("DODO_PAYMENTS_API_KEY"),webhookKey:u=WF("DODO_PAYMENTS_WEBHOOK_KEY")??null,...C}={}){if(T0.add(this),dF.set(this,void 0),this.checkoutSessions=new wD(this),this.payments=new vD(this),this.subscriptions=new gD(this),this.invoices=new QD(this),this.licenses=new fD(this),this.licenseKeys=new LD(this),this.licenseKeyInstances=new ID(this),this.customers=new FD(this),this.refunds=new hD(this),this.disputes=new kD(this),this.payouts=new yD(this),this.products=new uD(this),this.misc=new bD(this),this.discounts=new jD(this),this.addons=new xD(this),this.brands=new SD(this),this.webhooks=new JD(this),this.webhookEvents=new dD(this),this.usageEvents=new mD(this),this.meters=new PD(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??N0.DEFAULT_TIMEOUT,this.logger=E.logger??console;let B="warn";this.logLevel=B,this.logLevel=G0(E.logLevel,"ClientOptions.logLevel",this)??G0(WF("DODO_PAYMENTS_LOG"),"process.env['DODO_PAYMENTS_LOG']",this)??B,this.fetchOptions=E.fetchOptions,this.maxRetries=E.maxRetries??2,this.fetch=E.fetch??Mu(),qD(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 ${DD}`}defaultIdempotencyKey(){return`stainless-node-retry-${$0()}`}makeStatusError(D,F,u,C){return P.generate(D,F,u,C)}buildURL(D,F,u){let C=!e(this,T0,"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 ZD(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`,r({retryOfRequestLogID:u,method:C.method,url:$,options:C,headers:B.headers})),C.signal?.aborted)throw new MD;let Z=new AbortController,A=await this.fetchWithTimeout($,B,Q,Z).catch(sD),J=Date.now();if(A instanceof globalThis.Error){let T=`retrying, ${F} attempts remaining`;if(C.signal?.aborted)throw new MD;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})`,r({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)`,r({retryOfRequestLogID:u,url:$,durationMs:J-Y,message:A.message})),W)throw new oD;throw new $D({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})`,r({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)=>sD(q).message),_=Tu(O),V=_?void 0:O;throw y(this).debug(`[${z}] response error (${W})`,r({retryOfRequestLogID:u,url:A.url,status:A.status,headers:A.headers,message:V,durationMs:Date.now()-Y})),this.makeStatusError(A.status,_,V,A.headers)}return y(this).info(G),y(this).debug(`[${z}] response start`,r({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:X0(D)};else return e(this,dF,"f").call(this,{body:D,headers:u})}}N0=U,dF=new WeakMap,T0=new WeakSet,tu=function(){return this.baseURL!==su[this._options.environment||"live_mode"]};U.DodoPayments=N0;U.DEFAULT_TIMEOUT=60000;U.DodoPaymentsError=v;U.APIError=P;U.APIConnectionError=$D;U.APIConnectionTimeoutError=oD;U.APIUserAbortError=MD;U.NotFoundError=uF;U.ConflictError=CF;U.RateLimitError=BF;U.BadRequestError=eD;U.AuthenticationError=DF;U.InternalServerError=AF;U.PermissionDeniedError=FF;U.UnprocessableEntityError=EF;U.toFile=gF;U.CheckoutSessions=wD;U.Payments=vD;U.Subscriptions=gD;U.Invoices=QD;U.Licenses=fD;U.LicenseKeys=LD;U.LicenseKeyInstances=ID;U.Customers=FD;U.Refunds=hD;U.Disputes=kD;U.Payouts=yD;U.Products=uD;U.Misc=bD;U.Discounts=jD;U.Addons=xD;U.Brands=SD;U.Webhooks=JD;U.WebhookEvents=dD;U.UsageEvents=mD;U.Meters=PD;n0();import Bu 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 s0,{constants as $3}from"node:fs/promises";import C3 from"node:process";import q6 from"node:os";import M6 from"node:fs";import V6 from"node:fs";import F3 from"node:fs";var i0;function N6(){try{return F3.statSync("/.dockerenv"),!0}catch{return!1}}function U6(){try{return F3.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function a0(){if(i0===void 0)i0=N6()||U6();return i0}var r0,H6=()=>{try{return V6.statSync("/run/.containerenv"),!0}catch{return!1}};function iD(){if(r0===void 0)r0=H6()||a0();return r0}var u3=()=>{if(C3.platform!=="linux")return!1;if(q6.release().toLowerCase().includes("microsoft")){if(iD())return!1;return!0}try{return M6.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!iD():!1}catch{return!1}},s=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),t0=()=>`${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??t0(),[...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(`
|
|
28
|
-
`)){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 s0.access(u,$3.F_OK),C=!0}catch{}if(!C)return"/mnt/";let E=await s0.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=s?f6:t0,A3,Z3=async()=>{return A3??=(async()=>{try{let D=await F0();return await s0.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 OD(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 uu 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 o0(){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 W9}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 e0(D){return X3(`tell application "Finder" to set app_path to application file id "${D}" as string
|
|
29
|
-
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 Du extends Error{}async function Fu(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 Du(`Cannot find Windows browser in stdout: ${JSON.stringify(F)}`);let{id:C}=u.groups,E=G3[C];if(!E)throw new Du(`Unknown browser ID: ${C}`);return E}var a6=n6(i6),r6=(D)=>D.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,(F)=>F.toUpperCase());async function Cu(){if(uu.platform==="darwin"){let D=await o0();return{name:await e0(D),id:D}}if(uu.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(uu.platform==="win32")return Fu();throw Error("Only macOS, Linux, and Windows are supported")}import Eu from"node:process";var t6=Boolean(Eu.env.SSH_CONNECTION||Eu.env.SSH_CLIENT||Eu.env.SSH_TTY),Y3=t6;var C0=Symbol("fallbackAttempt"),Au=import.meta.url?O3.dirname(s6(import.meta.url)):"",z3=O3.join(Au,"xdg-open"),{platform:aD,arch:K3}=Bu,_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(s){let A=await Q3();Z=u0.get(A)??{}}else Z=await Cu();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:rD[A],arguments:C}})}throw Error(`${Z.name} is not supported as a default browser`)}let E,B=[],$={},Q=!1;if(s&&!iD()&&!Y3&&!u)Q=await Z3();if(aD==="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(aD==="win32"||Q){if(E=await F0(),B.push(...d.argumentsPrefix),!s)$.windowsVerbatimArguments=!0;if(s&&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=!Au||Au==="/",Y=!1;try{await e6.access(z3,DC.X_OK),Y=!0}catch{}E=Bu.versions.electron??(aD==="android"||X||!Y)?"xdg-open":z3}if(C.length>0)B.push(...C);if(!D.wait)$.stdio="ignore",$.detached=!0}if(aD==="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 jF({[aD]:D},{wsl:F}={}){if(F&&s)return W3(F);if(!D)throw Error(`${aD} is not supported`);return W3(D)}var rD={browser:"browser",browserPrivate:"browserPrivate"};OD(rD,"chrome",()=>jF({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"]}}));OD(rD,"brave",()=>jF({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"]}}));OD(rD,"firefox",()=>jF({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));OD(rD,"edge",()=>jF({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));OD(rD,"safari",()=>jF({darwin:"Safari"}));var $u=FC;var TD={USD:"$",INR:"₹",EUR:"€",GBP:"£"};import VD from"node:fs";var $C=`
|
|
23
|
+
${X}
|
|
24
|
+
${K}`)}return X},B=b3(b1);class w$ extends V{create($,_){return this._client.post("/addons",{body:$,..._})}retrieve($,_){return this._client.get(B`/addons/${$}`,_)}update($,_,F){return this._client.patch(B`/addons/${$}`,{body:_,...F})}list($={},_){return this._client.getAPIList("/addons",R,{query:$,..._})}updateImages($,_){return this._client.put(B`/addons/${$}/images`,_)}}class R$ extends V{retrieveLedger($={},_){return this._client.getAPIList("/balances/ledger",R,{query:$,..._})}}class D$ extends V{create($,_){return this._client.post("/brands",{body:$,..._})}retrieve($,_){return this._client.get(B`/brands/${$}`,_)}update($,_,F){return this._client.patch(B`/brands/${$}`,{body:_,...F})}list($){return this._client.get("/brands",$)}updateImages($,_){return this._client.put(B`/brands/${$}/images`,_)}}class k$ extends V{create($,_){return this._client.post("/checkouts",{body:$,..._})}retrieve($,_){return this._client.get(B`/checkouts/${$}`,_)}preview($,_){return this._client.post("/checkouts/preview",{body:$,..._})}}class Y0 extends V{retrieve($,_,F){let{credit_entitlement_id:J}=_;return this._client.get(B`/credit-entitlements/${J}/balances/${$}`,F)}list($,_={},F){return this._client.getAPIList(B`/credit-entitlements/${$}/balances`,R,{query:_,...F})}createLedgerEntry($,_,F){let{credit_entitlement_id:J,...G}=_;return this._client.post(B`/credit-entitlements/${J}/balances/${$}/ledger-entries`,{body:G,...F})}listGrants($,_,F){let{credit_entitlement_id:J,...G}=_;return this._client.getAPIList(B`/credit-entitlements/${J}/balances/${$}/grants`,R,{query:G,...F})}listLedger($,_,F){let{credit_entitlement_id:J,...G}=_;return this._client.getAPIList(B`/credit-entitlements/${J}/balances/${$}/ledger`,R,{query:G,...F})}}var y1=Symbol("brand.privateNullableHeaders");function*v3($){if(!$)return;if(y1 in $){let{values:J,nulls:G}=$;yield*J.entries();for(let Z of G)yield[Z,null];return}let _=!1,F;if($ instanceof Headers)F=$.entries();else if(T_($))F=$;else _=!0,F=Object.entries($??{});for(let J of F){let G=J[0];if(typeof G!=="string")throw TypeError("expected header name to be a string");let Z=T_(J[1])?J[1]:[J[1]],X=!1;for(let Y of Z){if(Y===void 0)continue;if(_&&!X)X=!0,yield[G,null];yield[G,Y]}}}var I=($)=>{let _=new Headers,F=new Set;for(let J of $){let G=new Set;for(let[Z,X]of v3(J)){let Y=Z.toLowerCase();if(!G.has(Y))_.delete(Z),G.add(Y);if(X===null)_.delete(Z),F.add(Y);else _.append(Z,X),F.delete(Y)}}return{[y1]:!0,values:_,nulls:F}};class z$ extends V{constructor(){super(...arguments);this.balances=new Y0(this._client)}create($,_){return this._client.post("/credit-entitlements",{body:$,..._})}retrieve($,_){return this._client.get(B`/credit-entitlements/${$}`,_)}update($,_,F){return this._client.patch(B`/credit-entitlements/${$}`,{body:_,...F,headers:I([{Accept:"*/*"},F?.headers])})}list($={},_){return this._client.getAPIList("/credit-entitlements",R,{query:$,..._})}delete($,_){return this._client.delete(B`/credit-entitlements/${$}`,{..._,headers:I([{Accept:"*/*"},_?.headers])})}undelete($,_){return this._client.post(B`/credit-entitlements/${$}/undelete`,{..._,headers:I([{Accept:"*/*"},_?.headers])})}}z$.Balances=Y0;class W0 extends V{create($,_={},F){let{send_email:J}=_??{};return this._client.post(B`/customers/${$}/customer-portal/session`,{query:{send_email:J},...F})}}class z0 extends V{create($,_,F){return this._client.post(B`/customers/${$}/wallets/ledger-entries`,{body:_,...F})}list($,_={},F){return this._client.getAPIList(B`/customers/${$}/wallets/ledger-entries`,R,{query:_,...F})}}class f$ extends V{constructor(){super(...arguments);this.ledgerEntries=new z0(this._client)}list($,_){return this._client.get(B`/customers/${$}/wallets`,_)}}f$.LedgerEntries=z0;class Z$ extends V{constructor(){super(...arguments);this.customerPortal=new W0(this._client),this.wallets=new f$(this._client)}create($,_){return this._client.post("/customers",{body:$,..._})}retrieve($,_){return this._client.get(B`/customers/${$}`,_)}update($,_,F){return this._client.patch(B`/customers/${$}`,{body:_,...F})}list($={},_){return this._client.getAPIList("/customers",R,{query:$,..._})}listCreditEntitlements($,_){return this._client.get(B`/customers/${$}/credit-entitlements`,_)}retrievePaymentMethods($,_){return this._client.get(B`/customers/${$}/payment-methods`,_)}}Z$.CustomerPortal=W0;Z$.Wallets=f$;class I$ extends V{create($,_){return this._client.post("/discounts",{body:$,..._})}retrieve($,_){return this._client.get(B`/discounts/${$}`,_)}update($,_,F){return this._client.patch(B`/discounts/${$}`,{body:_,...F})}list($={},_){return this._client.getAPIList("/discounts",R,{query:$,..._})}delete($,_){return this._client.delete(B`/discounts/${$}`,{..._,headers:I([{Accept:"*/*"},_?.headers])})}retrieveByCode($,_){return this._client.get(B`/discounts/code/${$}`,_)}}class j$ extends V{retrieve($,_){return this._client.get(B`/disputes/${$}`,_)}list($={},_){return this._client.getAPIList("/disputes",R,{query:$,..._})}}class O0 extends V{retrieve($,_){return this._client.get(B`/invoices/payments/${$}`,{..._,headers:I([{Accept:"application/pdf"},_?.headers]),__binaryResponse:!0})}retrieveRefund($,_){return this._client.get(B`/invoices/refunds/${$}`,{..._,headers:I([{Accept:"application/pdf"},_?.headers]),__binaryResponse:!0})}}class O$ extends V{constructor(){super(...arguments);this.payments=new O0(this._client)}}O$.Payments=O0;class L$ extends V{retrieve($,_){return this._client.get(B`/license_key_instances/${$}`,_)}update($,_,F){return this._client.patch(B`/license_key_instances/${$}`,{body:_,...F})}list($={},_){return this._client.getAPIList("/license_key_instances",R,{query:$,..._})}}class P$ extends V{retrieve($,_){return this._client.get(B`/license_keys/${$}`,_)}update($,_,F){return this._client.patch(B`/license_keys/${$}`,{body:_,...F})}list($={},_){return this._client.getAPIList("/license_keys",R,{query:$,..._})}}class b$ extends V{activate($,_){return this._client.post("/licenses/activate",{body:$,..._})}deactivate($,_){return this._client.post("/licenses/deactivate",{body:$,..._,headers:I([{Accept:"*/*"},_?.headers])})}validate($,_){return this._client.post("/licenses/validate",{body:$,..._})}}class y$ extends V{create($,_){return this._client.post("/meters",{body:$,..._})}retrieve($,_){return this._client.get(B`/meters/${$}`,_)}list($={},_){return this._client.getAPIList("/meters",R,{query:$,..._})}archive($,_){return this._client.delete(B`/meters/${$}`,{..._,headers:I([{Accept:"*/*"},_?.headers])})}unarchive($,_){return this._client.post(B`/meters/${$}/unarchive`,{..._,headers:I([{Accept:"*/*"},_?.headers])})}}class v$ extends V{listSupportedCountries($){return this._client.get("/checkout/supported_countries",$)}}class g$ extends V{create($,_){return this._client.post("/payments",{body:$,..._})}retrieve($,_){return this._client.get(B`/payments/${$}`,_)}list($={},_){return this._client.getAPIList("/payments",R,{query:$,..._})}retrieveLineItems($,_){return this._client.get(B`/payments/${$}/line-items`,_)}}class h$ extends V{list($={},_){return this._client.getAPIList("/payouts",R,{query:$,..._})}}class T0 extends V{update($,_={},F){let{force_update:J}=_??{};return this._client.put(B`/products/${$}/images`,{query:{force_update:J},...F})}}class N0 extends V{create($,_,F){return this._client.post(B`/products/${$}/short_links`,{body:_,...F})}list($={},_){return this._client.getAPIList("/products/short_links",R,{query:$,..._})}}class Q$ extends V{constructor(){super(...arguments);this.images=new T0(this._client),this.shortLinks=new N0(this._client)}create($,_){return this._client.post("/products",{body:$,..._})}retrieve($,_){return this._client.get(B`/products/${$}`,_)}update($,_,F){return this._client.patch(B`/products/${$}`,{body:_,...F,headers:I([{Accept:"*/*"},F?.headers])})}list($={},_){return this._client.getAPIList("/products",R,{query:$,..._})}archive($,_){return this._client.delete(B`/products/${$}`,{..._,headers:I([{Accept:"*/*"},_?.headers])})}unarchive($,_){return this._client.post(B`/products/${$}/unarchive`,{..._,headers:I([{Accept:"*/*"},_?.headers])})}updateFiles($,_,F){return this._client.put(B`/products/${$}/files`,{body:_,...F})}}Q$.Images=T0;Q$.ShortLinks=N0;class c$ extends V{create($,_){return this._client.post("/refunds",{body:$,..._})}retrieve($,_){return this._client.get(B`/refunds/${$}`,_)}list($={},_){return this._client.getAPIList("/refunds",R,{query:$,..._})}}class m$ extends V{create($,_){return this._client.post("/subscriptions",{body:$,..._})}retrieve($,_){return this._client.get(B`/subscriptions/${$}`,_)}update($,_,F){return this._client.patch(B`/subscriptions/${$}`,{body:_,...F})}list($={},_){return this._client.getAPIList("/subscriptions",R,{query:$,..._})}changePlan($,_,F){return this._client.post(B`/subscriptions/${$}/change-plan`,{body:_,...F,headers:I([{Accept:"*/*"},F?.headers])})}charge($,_,F){return this._client.post(B`/subscriptions/${$}/charge`,{body:_,...F})}previewChangePlan($,_,F){return this._client.post(B`/subscriptions/${$}/change-plan/preview`,{body:_,...F})}retrieveCreditUsage($,_){return this._client.get(B`/subscriptions/${$}/credit-usage`,_)}retrieveUsageHistory($,_={},F){return this._client.getAPIList(B`/subscriptions/${$}/usage-history`,R,{query:_,...F})}updatePaymentMethod($,_,F){return this._client.post(B`/subscriptions/${$}/update-payment-method`,{body:_,...F})}}class d$ extends V{retrieve($,_){return this._client.get(B`/events/${$}`,_)}list($={},_){return this._client.getAPIList("/events",R,{query:$,..._})}ingest($,_){return this._client.post("/events/ingest",{body:$,..._})}}class u$ extends V{}class B0 extends V{retrieve($,_){return this._client.get(B`/webhooks/${$}/headers`,_)}update($,_,F){return this._client.patch(B`/webhooks/${$}/headers`,{body:_,...F,headers:I([{Accept:"*/*"},F?.headers])})}}var s1=W_(r1(),1);class T$ extends V{constructor(){super(...arguments);this.headers=new B0(this._client)}create($,_){return this._client.post("/webhooks",{body:$,..._})}retrieve($,_){return this._client.get(B`/webhooks/${$}`,_)}update($,_,F){return this._client.patch(B`/webhooks/${$}`,{body:_,...F})}list($={},_){return this._client.getAPIList("/webhooks",U_,{query:$,..._})}delete($,_){return this._client.delete(B`/webhooks/${$}`,{..._,headers:I([{Accept:"*/*"},_?.headers])})}retrieveSecret($,_){return this._client.get(B`/webhooks/${$}/secret`,_)}unsafeUnwrap($){return JSON.parse($)}unwrap($,{headers:_,key:F}){if(_!==void 0){let J=F===void 0?this._client.webhookKey:F;if(J===null)throw Error("Webhook key must not be null in order to unwrap");new s1.Webhook(J).verify($,_)}return JSON.parse($)}}T$.Headers=B0;var U0=($)=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[$]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.($)?.trim();return};var S_,A_,l0,o1,e1={live_mode:"https://live.dodopayments.com",test_mode:"https://test.dodopayments.com"};class E{constructor({baseURL:$=U0("DODO_PAYMENTS_BASE_URL"),bearerToken:_=U0("DODO_PAYMENTS_API_KEY"),webhookKey:F=U0("DODO_PAYMENTS_WEBHOOK_KEY")??null,...J}={}){if(S_.add(this),l0.set(this,void 0),this.checkoutSessions=new k$(this),this.payments=new g$(this),this.subscriptions=new m$(this),this.invoices=new O$(this),this.licenses=new b$(this),this.licenseKeys=new P$(this),this.licenseKeyInstances=new L$(this),this.customers=new Z$(this),this.refunds=new c$(this),this.disputes=new j$(this),this.payouts=new h$(this),this.products=new Q$(this),this.misc=new v$(this),this.discounts=new I$(this),this.addons=new w$(this),this.brands=new D$(this),this.webhooks=new T$(this),this.webhookEvents=new u$(this),this.usageEvents=new d$(this),this.meters=new y$(this),this.balances=new R$(this),this.creditEntitlements=new z$(this),_===void 0)throw new c("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 G={bearerToken:_,webhookKey:F,...J,baseURL:$,environment:J.environment??"live_mode"};if($&&J.environment)throw new c("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=G.baseURL||e1[G.environment||"live_mode"],this.timeout=G.timeout??A_.DEFAULT_TIMEOUT,this.logger=G.logger??console;let Z="warn";this.logLevel=Z,this.logLevel=H_(G.logLevel,"ClientOptions.logLevel",this)??H_(U0("DODO_PAYMENTS_LOG"),"process.env['DODO_PAYMENTS_LOG']",this)??Z,this.fetchOptions=G.fetchOptions,this.maxRetries=G.maxRetries??2,this.fetch=G.fetch??w1(),A$(this,l0,D1,"f"),this._options=G,this.bearerToken=_,this.webhookKey=F}withOptions($){return new this.constructor({...this._options,environment:$.environment?$.environment:void 0,baseURL:$.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,...$})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:$,nulls:_}){return}async authHeaders($){return I([{Authorization:`Bearer ${this.bearerToken}`}])}stringifyQuery($){return k1($)}getUserAgent(){return`${this.constructor.name}/JS ${G$}`}defaultIdempotencyKey(){return`stainless-node-retry-${z_()}`}makeStatusError($,_,F,J){return h.generate($,_,F,J)}buildURL($,_,F){let J=!J$(this,S_,"m",o1).call(this)&&F||this.baseURL,G=H1($)?new URL($):new URL(J+(J.endsWith("/")&&$.startsWith("/")?$.slice(1):$)),Z=this.defaultQuery();if(!M1(Z))_={...Z,..._};if(typeof _==="object"&&_&&!Array.isArray(_))G.search=this.stringifyQuery(_);return G.toString()}async prepareOptions($){}async prepareRequest($,{url:_,options:F}){}get($,_){return this.methodRequest("get",$,_)}post($,_){return this.methodRequest("post",$,_)}patch($,_){return this.methodRequest("patch",$,_)}put($,_){return this.methodRequest("put",$,_)}delete($,_){return this.methodRequest("delete",$,_)}methodRequest($,_,F){return this.request(Promise.resolve(F).then((J)=>{return{method:$,path:_,...J}}))}request($,_=null){return new W$(this,this.makeRequest($,_,void 0))}async makeRequest($,_,F){let J=await $,G=J.maxRetries??this.maxRetries;if(_==null)_=G;await this.prepareOptions(J);let{req:Z,url:X,timeout:Y}=await this.buildRequest(J,{retryCount:G-_});await this.prepareRequest(Z,{url:X,options:J});let z="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),O=F===void 0?"":`, retryOf: ${F}`,T=Date.now();if(m(this).debug(`[${z}] sending request`,o({retryOfRequestLogID:F,method:J.method,url:X,options:J,headers:Z.headers})),J.signal?.aborted)throw new C$;let K=new AbortController,Q=await this.fetchWithTimeout(X,Z,Y,K).catch(s$),W=Date.now();if(Q instanceof globalThis.Error){let M=`retrying, ${_} attempts remaining`;if(J.signal?.aborted)throw new C$;let H=B1(Q)||/timed? ?out/i.test(String(Q)+("cause"in Q?String(Q.cause):""));if(_)return m(this).info(`[${z}] connection ${H?"timed out":"failed"} - ${M}`),m(this).debug(`[${z}] connection ${H?"timed out":"failed"} (${M})`,o({retryOfRequestLogID:F,url:X,durationMs:W-T,message:Q.message})),this.retryRequest(J,_,F??z);if(m(this).info(`[${z}] connection ${H?"timed out":"failed"} - error; no more retries left`),m(this).debug(`[${z}] connection ${H?"timed out":"failed"} (error; no more retries left)`,o({retryOfRequestLogID:F,url:X,durationMs:W-T,message:Q.message})),H)throw new o$;throw new Y$({cause:Q})}let N=`[${z}${O}] ${Z.method} ${X} ${Q.ok?"succeeded":"failed"} with status ${Q.status} in ${W-T}ms`;if(!Q.ok){let M=await this.shouldRetry(Q);if(_&&M){let A=`retrying, ${_} attempts remaining`;return await R1(Q.body),m(this).info(`${N} - ${A}`),m(this).debug(`[${z}] response error (${A})`,o({retryOfRequestLogID:F,url:Q.url,status:Q.status,headers:Q.headers,durationMs:W-T})),this.retryRequest(J,_,F??z,Q.headers)}let H=M?"error; no more retries left":"error; not retryable";m(this).info(`${N} - ${H}`);let x=await Q.text().catch((A)=>s$(A).message),U=V1(x),C=U?void 0:x;throw m(this).debug(`[${z}] response error (${H})`,o({retryOfRequestLogID:F,url:Q.url,status:Q.status,headers:Q.headers,message:C,durationMs:Date.now()-T})),this.makeStatusError(Q.status,U,C,Q.headers)}return m(this).info(N),m(this).debug(`[${z}] response start`,o({retryOfRequestLogID:F,url:Q.url,status:Q.status,headers:Q.headers,durationMs:W-T})),{response:Q,options:J,controller:K,requestLogID:z,retryOfRequestLogID:F,startTime:T}}getAPIList($,_,F){return this.requestAPIList(_,F&&"then"in F?F.then((J)=>({method:"get",path:$,...J})):{method:"get",path:$,...F})}requestAPIList($,_){let F=this.makeRequest(_,null,void 0);return new c0(this,F,$)}async fetchWithTimeout($,_,F,J){let{signal:G,method:Z,...X}=_||{},Y=this._makeAbort(J);if(G)G.addEventListener("abort",Y,{once:!0});let z=setTimeout(Y,F),O=globalThis.ReadableStream&&X.body instanceof globalThis.ReadableStream||typeof X.body==="object"&&X.body!==null&&Symbol.asyncIterator in X.body,T={signal:J.signal,...O?{duplex:"half"}:{},method:"GET",...X};if(Z)T.method=Z.toUpperCase();try{return await this.fetch.call(void 0,$,T)}finally{clearTimeout(z)}}async shouldRetry($){let _=$.headers.get("x-should-retry");if(_==="true")return!0;if(_==="false")return!1;if($.status===408)return!0;if($.status===409)return!0;if($.status===429)return!0;if($.status>=500)return!0;return!1}async retryRequest($,_,F,J){let G,Z=J?.get("retry-after-ms");if(Z){let Y=parseFloat(Z);if(!Number.isNaN(Y))G=Y}let X=J?.get("retry-after");if(X&&!G){let Y=parseFloat(X);if(!Number.isNaN(Y))G=Y*1000;else G=Date.parse(X)-Date.now()}if(G===void 0){let Y=$.maxRetries??this.maxRetries;G=this.calculateDefaultRetryTimeoutMillis(_,Y)}return await q1(G),this.makeRequest($,_-1,F)}calculateDefaultRetryTimeoutMillis($,_){let G=_-$,Z=Math.min(0.5*Math.pow(2,G),8),X=1-Math.random()*0.25;return Z*X*1000}async buildRequest($,{retryCount:_=0}={}){let F={...$},{method:J,path:G,query:Z,defaultBaseURL:X}=F,Y=this.buildURL(G,Z,X);if("timeout"in F)x1("timeout",F.timeout);F.timeout=F.timeout??this.timeout;let{bodyHeaders:z,body:O}=this.buildBody({options:F}),T=await this.buildHeaders({options:$,method:J,bodyHeaders:z,retryCount:_});return{req:{method:J,headers:T,...F.signal&&{signal:F.signal},...globalThis.ReadableStream&&O instanceof globalThis.ReadableStream&&{duplex:"half"},...O&&{body:O},...this.fetchOptions??{},...F.fetchOptions??{}},url:Y,timeout:F.timeout}}async buildHeaders({options:$,method:_,bodyHeaders:F,retryCount:J}){let G={};if(this.idempotencyHeader&&_!=="get"){if(!$.idempotencyKey)$.idempotencyKey=this.defaultIdempotencyKey();G[this.idempotencyHeader]=$.idempotencyKey}let Z=I([G,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(J),...$.timeout?{"X-Stainless-Timeout":String(Math.trunc($.timeout/1000))}:{},...C1()},await this.authHeaders($),this._options.defaultHeaders,F,$.headers]);return this.validateHeaders(Z),Z.values}_makeAbort($){return()=>$.abort()}buildBody({options:{body:$,headers:_}}){if(!$)return{bodyHeaders:void 0,body:void 0};let F=I([_]);if(ArrayBuffer.isView($)||$ instanceof ArrayBuffer||$ instanceof DataView||typeof $==="string"&&F.values.has("content-type")||globalThis.Blob&&$ instanceof globalThis.Blob||$ instanceof FormData||$ instanceof URLSearchParams||globalThis.ReadableStream&&$ instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:$};else if(typeof $==="object"&&((Symbol.asyncIterator in $)||(Symbol.iterator in $)&&("next"in $)&&typeof $.next==="function"))return{bodyHeaders:void 0,body:B_($)};else if(typeof $==="object"&&F.values.get("content-type")==="application/x-www-form-urlencoded")return{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery($)};else return J$(this,l0,"f").call(this,{body:$,headers:F})}}A_=E,l0=new WeakMap,S_=new WeakSet,o1=function(){return this.baseURL!==e1[this._options.environment||"live_mode"]};E.DodoPayments=A_;E.DEFAULT_TIMEOUT=60000;E.DodoPaymentsError=c;E.APIError=h;E.APIConnectionError=Y$;E.APIConnectionTimeoutError=o$;E.APIUserAbortError=C$;E.NotFoundError=F0;E.ConflictError=J0;E.RateLimitError=Z0;E.BadRequestError=e$;E.AuthenticationError=$0;E.InternalServerError=Q0;E.PermissionDeniedError=_0;E.UnprocessableEntityError=G0;E.toFile=d0;E.CheckoutSessions=k$;E.Payments=g$;E.Subscriptions=m$;E.Invoices=O$;E.Licenses=b$;E.LicenseKeys=P$;E.LicenseKeyInstances=L$;E.Customers=Z$;E.Refunds=c$;E.Disputes=j$;E.Payouts=h$;E.Products=Q$;E.Misc=v$;E.Discounts=I$;E.Addons=w$;E.Brands=D$;E.Webhooks=T$;E.WebhookEvents=u$;E.UsageEvents=d$;E.Meters=y$;E.Balances=R$;E.CreditEntitlements=z$;var b={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"}],licences:[{command:"list",description:"List licences"}],addons:[{command:"create",description:"Create an addon"},{command:"list",description:"List addons"},{command:"info",description:"Get addon info"}],refunds:[{command:"list",description:"List refunds"},{command:"info",description:"Get refund info"}],wh:[{command:"listen",description:"Listen to webhook events directly from Dodo Payments"},{command:"trigger",description:"Trigger a webhook event"}],checkout:[{command:"new",description:"Create a checkout session"}]};var $2=`
|
|
30
25
|
/$$$$$$$ /$$ /$$$$$$ /$$ /$$$$$$
|
|
31
26
|
| $$__ $$ | $$ /$$__ $$| $$ |_ $$_/
|
|
32
27
|
| $$ \\ $$ /$$$$$$ /$$$$$$$ /$$$$$$ | $$ \\__/| $$ | $$
|
|
@@ -37,4 +32,6 @@ tell application "System Events" to get value of property list item "CFBundleNam
|
|
|
37
32
|
|_______/ \\______/ \\_______/ \\______/ \\______/ |________/|______/
|
|
38
33
|
|
|
39
34
|
The CLI to manage Dodo Payments!
|
|
40
|
-
`;
|
|
35
|
+
`;var p0=($)=>{if(console.log($2),$&&$ in b){let _=b[$];console.log($),_.forEach(({command:F,description:J},G)=>{let Z=G===_.length-1;console.log(`${Z?"└──":"├──"} dodo ${$} ${F} - ${J}`)})}else{let _=Object.entries(b);_.forEach(([F,J],G)=>{let Z=G===_.length-1;if(console.log(`${Z?"└──":"├──"} ${F}`),J.forEach(({command:X,description:Y},z)=>{let O=z===J.length-1;console.log(`${Z?" ":"│ "}${O?"└──":"├──"} dodo ${F} ${X} - ${Y}`)}),!Z)console.log("│")})}};p();import c4 from"node:os";import JF from"node:path";import n$ from"node:fs";var GF=JF.join(c4.homedir(),".dodopayments"),k0=JF.join(GF,"api-key");function m4(){n$.mkdirSync(GF,{recursive:!0})}function f0(){return n$.existsSync(k0)}function d4(){if(!f0())throw Error("CONFIG_NOT_FOUND");try{let $=JSON.parse(n$.readFileSync(k0,"utf-8"));if(typeof $!=="object"||$===null)throw Error("INVALID_CONFIG");return $}catch{throw Error("INVALID_CONFIG")}}function ZF($,_){m4();let F={};if(f0())try{F=JSON.parse(n$.readFileSync(k0,"utf-8"))}catch{F={}}F[$]=_,n$.writeFileSync(k0,JSON.stringify(F,null,2),"utf-8")}function u4(){n$.rmSync(k0,{force:!0})}async function QF(){if(!f0())console.error("Please run `dodo login` first."),process.exit(1);let $;try{$=d4()}catch{console.error("Failed to load credentials. Please try login again."),u4(),process.exit(1)}let _=Object.keys($);if(_.length===0)console.error("No valid credentials found. Please login again."),process.exit(1);if(_.length===1){let J=_[0];return{mode:J,apiKey:$[J]}}let F=await a({message:"Choose the environment:",choices:_.map((J)=>({name:J==="test_mode"?"Test Mode":"Live Mode",value:J}))});return{mode:F,apiKey:$[F]}}p();import Y1 from"node:process";import AF from"node:path";import{fileURLToPath as V8}from"node:url";import q8 from"node:child_process";import E8,{constants as S8}from"node:fs/promises";import{promisify as e4}from"node:util";import $8 from"node:child_process";import F1,{constants as TF}from"node:fs/promises";import YF from"node:process";import a4 from"node:os";import $1 from"node:fs";import n4 from"node:fs";import XF from"node:fs";var s_;function l4(){try{return XF.statSync("/.dockerenv"),!0}catch{return!1}}function p4(){try{return XF.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function o_(){if(s_===void 0)s_=l4()||p4();return s_}var e_,i4=()=>{try{return n4.statSync("/run/.containerenv"),!0}catch{return!1}};function V$(){if(e_===void 0)e_=i4()||o_();return e_}var KF=()=>{if(YF.platform!=="linux")return!1;if(a4.release().toLowerCase().includes("microsoft")){if(V$())return!1;return!0}try{if($1.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft"))return!V$()}catch{}if($1.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop")||$1.existsSync("/run/WSL"))return!V$();return!1},F$=YF.env.__IS_WSL_TEST__?KF:KF();import WF from"node:process";import{Buffer as t4}from"node:buffer";import{promisify as r4}from"node:util";import s4 from"node:child_process";var o4=r4(s4.execFile),_1=()=>`${WF.env.SYSTEMROOT||WF.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;var n=async($,_={})=>{let{powerShellPath:F,...J}=_,G=n.encodeCommand($);return o4(F??_1(),[...n.argumentsPrefix,G],{encoding:"utf8",...J})};n.argumentsPrefix=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"];n.encodeCommand=($)=>t4.from($,"utf16le").toString("base64");n.escapeArgument=($)=>`'${String($).replaceAll("'","''")}'`;function zF($){for(let _ of $.split(`
|
|
36
|
+
`)){if(/^\s*#/.test(_))continue;let F=/^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(_);if(!F)continue;return F.groups.mountPoint.trim().replaceAll(/^["']|["']$/g,"")}}var _8=e4($8.execFile),F8=(()=>{let _;return async function(){if(_)return _;let F="/etc/wsl.conf",J=!1;try{await F1.access(F,TF.F_OK),J=!0}catch{}if(!J)return"/mnt/";let G=await F1.readFile(F,{encoding:"utf8"}),Z=zF(G);if(Z===void 0)return"/mnt/";return _=Z,_=_.endsWith("/")?_:`${_}/`,_}})(),J8=async()=>{return`${await F8()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`},J_=F$?J8:_1,OF,NF=async()=>{return OF??=(async()=>{try{let $=await J_();return await F1.access($,TF.X_OK),!0}catch{return!1}})(),OF},BF=async()=>{let $=await J_(),_=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:F}=await n(_,{powerShellPath:$});return F.trim()},HF=async($)=>{if(/^[a-z]+:\/\//i.test($))return $;try{let{stdout:_}=await _8("wslpath",["-aw",$],{encoding:"utf8"});return _.trim()}catch{return $}};function q$($,_,F){let J=(G)=>Object.defineProperty($,_,{value:G,enumerable:!0,writable:!0});return Object.defineProperty($,_,{configurable:!0,enumerable:!0,get(){let G=F();return J(G),G},set(G){J(G)}}),$}import{promisify as B8}from"node:util";import Q1 from"node:process";import{execFile as H8}from"node:child_process";import{promisify as G8}from"node:util";import Z8 from"node:process";import{execFile as Q8}from"node:child_process";var X8=G8(Q8);async function J1(){if(Z8.platform!=="darwin")throw Error("macOS only");let{stdout:$}=await X8("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),F=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec($)?.groups.id??"com.apple.Safari";if(F==="com.apple.safari")return"com.apple.Safari";return F}import K8 from"node:process";import{promisify as Y8}from"node:util";import{execFile as W8,execFileSync as E7}from"node:child_process";var z8=Y8(W8);async function MF($,{humanReadableOutput:_=!0,signal:F}={}){if(K8.platform!=="darwin")throw Error("macOS only");let J=_?[]:["-ss"],G={};if(F)G.signal=F;let{stdout:Z}=await z8("osascript",["-e",$,J],G);return Z.trim()}async function G1($){return MF(`tell application "Finder" to set app_path to application file id "${$}" as string
|
|
37
|
+
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}import{promisify as O8}from"node:util";import{execFile as T8}from"node:child_process";var N8=O8(T8),G_={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"}},Z_=new Map(Object.entries(G_));class UF extends Error{}async function Z1($=N8){let{stdout:_}=await $("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),F=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(_);if(!F)throw new UF(`Cannot find Windows browser in stdout: ${JSON.stringify(_)}`);let{id:J}=F.groups,G=J.lastIndexOf("."),Z=J.lastIndexOf("-"),X=G===-1?void 0:J.slice(0,G),Y=Z===-1?void 0:J.slice(0,Z);return G_[J]??G_[X]??G_[Y]??{name:J,id:J}}var M8=B8(H8),U8=($)=>$.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,(_)=>_.toUpperCase());async function X1(){if(Q1.platform==="darwin"){let $=await J1();return{name:await G1($),id:$}}if(Q1.platform==="linux"){let{stdout:$}=await M8("xdg-mime",["query","default","x-scheme-handler/http"]),_=$.trim();return{name:U8(_.replace(/.desktop$/,"").replace("-"," ")),id:_}}if(Q1.platform==="win32")return Z1();throw Error("Only macOS, Linux, and Windows are supported")}import K1 from"node:process";var x8=Boolean(K1.env.SSH_CONNECTION||K1.env.SSH_CLIENT||K1.env.SSH_TTY),xF=x8;var Q_=Symbol("fallbackAttempt"),W1=import.meta.url?AF.dirname(V8(import.meta.url)):"",VF=AF.join(W1,"xdg-open"),{platform:i$,arch:qF}=Y1,EF=async($,_)=>{if($.length===0)return;let F=[];for(let J of $)try{return await _(J)}catch(G){F.push(G)}throw AggregateError(F,"Failed to open in all supported apps")},X_=async($)=>{$={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...$};let _=$[Q_]===!0;if(delete $[Q_],Array.isArray($.app))return EF($.app,(O)=>X_({...$,app:O,[Q_]:!0}));let{name:F,arguments:J=[]}=$.app??{};if(J=[...J],Array.isArray(F))return EF(F,(O)=>X_({...$,app:{name:O,arguments:J},[Q_]:!0}));if(F==="browser"||F==="browserPrivate"){let O={"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"},T={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},K;if(F$){let Q=await BF();K=Z_.get(Q)??{}}else K=await X1();if(K.id in O){let Q=O[K.id.toLowerCase()];if(F==="browserPrivate"){if(Q==="safari")throw Error("Safari doesn't support opening in private mode via command line");J.push(T[Q])}return X_({...$,app:{name:a$[Q],arguments:J}})}throw Error(`${K.name} is not supported as a default browser`)}let G,Z=[],X={},Y=!1;if(F$&&!V$()&&!xF&&!F)Y=await NF();if(i$==="darwin"){if(G="open",$.wait)Z.push("--wait-apps");if($.background)Z.push("--background");if($.newInstance)Z.push("--new");if(F)Z.push("-a",F)}else if(i$==="win32"||Y){if(G=await J_(),Z.push(...n.argumentsPrefix),!F$)X.windowsVerbatimArguments=!0;if(F$&&$.target)$.target=await HF($.target);let O=["$ProgressPreference = 'SilentlyContinue';","Start"];if($.wait)O.push("-Wait");if(F){if(O.push(n.escapeArgument(F)),$.target)J.push($.target)}else if($.target)O.push(n.escapeArgument($.target));if(J.length>0)J=J.map((T)=>n.escapeArgument(T)),O.push("-ArgumentList",J.join(","));if($.target=n.encodeCommand(O.join(" ")),!$.wait)X.stdio="ignore"}else{if(F)G=F;else{let O=!W1||W1==="/",T=!1;try{await E8.access(VF,S8.X_OK),T=!0}catch{}G=Y1.versions.electron??(i$==="android"||O||!T)?"xdg-open":VF}if(J.length>0)Z.push(...J);if(!$.wait)X.stdio="ignore",X.detached=!0}if(i$==="darwin"&&J.length>0)Z.push("--args",...J);if($.target)Z.push($.target);let z=q8.spawn(G,Z,X);if($.wait)return new Promise((O,T)=>{z.once("error",T),z.once("close",(K)=>{if(!$.allowNonzeroExitCode&&K!==0){T(Error(`Exited with code ${K}`));return}O(z)})});if(_)return new Promise((O,T)=>{z.once("error",T),z.once("spawn",()=>{z.once("close",(K)=>{if(z.off("error",T),K!==0){T(Error(`Exited with code ${K}`));return}z.unref(),O(z)})})});return z.unref(),new Promise((O,T)=>{z.once("error",T),z.once("spawn",()=>{z.off("error",T),O(z)})})},A8=($,_)=>{if(typeof $!=="string")throw TypeError("Expected a `target`");return X_({..._,target:$})};function SF($){if(typeof $==="string"||Array.isArray($))return $;let{[qF]:_}=$;if(!_)throw Error(`${qF} is not supported`);return _}function I0({[i$]:$},{wsl:_}={}){if(_&&F$)return SF(_);if(!$)throw Error(`${i$} is not supported`);return SF($)}var a$={browser:"browser",browserPrivate:"browserPrivate"};q$(a$,"chrome",()=>I0({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"]}}));q$(a$,"brave",()=>I0({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"]}}));q$(a$,"firefox",()=>I0({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));q$(a$,"edge",()=>I0({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));q$(a$,"safari",()=>I0({darwin:"Safari"}));var t$=A8;async function CF(){await t$("https://app.dodopayments.com/developer/api-keys");let $=await S({message:"Enter your Dodo Payments API Key:",required:!0}),_=await a({choices:[{name:"Test Mode",value:"test_mode"},{name:"Live Mode",value:"live_mode"}],message:"Choose the environment:"}),F=new E({bearerToken:$,environment:_});console.log("Verifying Dodo Payments API Key");try{await F.products.list({page_size:1}),console.log("Successfully verified your Dodo Payments API Key!")}catch{console.log("Something went wrong while authenticating, please check your API key!"),process.exit(1)}console.log("Storing / Updating existing configuration..."),ZF(_,$),console.log("Setup complete successfully!"),process.exit(0)}p();var u={USD:"$",INR:"₹",EUR:"€",GBP:"£"};function j($){return typeof $==="object"&&$!==null&&"error"in $&&typeof $.error?.code==="string"}async function wF($,_){if(_==="list"){let F=await S({message:"Enter page:",default:"1",validate:(J)=>J.trim()!==""});try{let G=(await $.products.list({page_number:parseInt(F)-1,page_size:100})).items.map((Z)=>({name:Z.name,"product id":Z.product_id,created_at:new Date(Z.created_at).toLocaleString(),...Z.is_recurring?{price:`${u[Z.price_detail.currency]||Z.price_detail.currency+" "}${(Z.price*0.01).toFixed(2)} Every ${Z.price_detail.payment_frequency_count} ${Z.price_detail?.payment_frequency_interval}`}:{price:`${u[Z.price_detail.currency]||Z.price_detail.currency+" "}${(Z.price*0.01).toFixed(2)} (One Time)`}}));console.table(G),console.log("To edit a product, go to https://app.dodopayments.com/products/edit?id={product_id}")}catch(J){if(j(J))console.log("Failed to fetch products:",J.error.message);else console.error(J)}}else if(_==="create")try{await t$("https://app.dodopayments.com/products/create")}catch(F){console.error("Failed to open browser:",F)}else if(_==="info"){let F=await S({message:"Enter product ID:",validate:(J)=>J.startsWith("pdt_")||"Please enter a valid product ID!"});try{let J=await $.products.retrieve(F);console.table({"product id":J.product_id,name:J.name,...J.description?.trim()!==""&&{description:J.description},created_at:new Date(J.created_at).toLocaleString(),updated_at:new Date(J.updated_at).toLocaleString(),...J.is_recurring?{price:`${u[J.price.currency]||J.price.currency+" "}${((J.price.price||J.price.fixed_price)*0.01).toFixed(2)} Every ${J.price.payment_frequency_count} ${J.price.payment_frequency_interval}`}:{price:`${u[J.price.currency]||J.price.currency+" "}${(J.price.price*0.01).toFixed(2)} (One Time)`},tax_category:J.tax_category}),console.log(`To edit the product, go to https://app.dodopayments.com/products/edit?id=${J.product_id}`)}catch(J){if(j(J)&&J.error.code==="NOT_FOUND")console.log("Incorrect product ID!");else console.error(J)}}else b.products.forEach((F)=>console.log(`dodo products ${F.command} - ${F.description}`))}p();async function RF($,_){if(_==="list"){let F=await S({message:"Enter page:",default:"1",validate:(J)=>J.trim()!==""});try{let J=(await $.payments.list({page_number:parseInt(F)-1,page_size:100})).items;console.table(J.map((G)=>({"payment id":G.payment_id,"created at":new Date(G.created_at).toLocaleString(),"subscription id":G.subscription_id,"total amount":`${u[G.currency]||G.currency+" "}${(G.total_amount*0.01).toFixed(2)}`,status:G.status}))),console.log("To view a payment, go to https://app.dodopayments.com/transactions/payments/{payment_id}")}catch(J){if(j(J))console.log("Failed to fetch payments:",J.error.message);else console.error(J)}}else if(_==="info"){let F=await S({message:"Enter payment ID:",validate:(J)=>J.startsWith("pay_")||"Please enter a valid payment ID!"});try{let J=await $.payments.retrieve(F);console.table({"payment id":J.payment_id,status:J.status,"total amount":`${u[J.currency]||J.currency+" "}${(J.total_amount*0.01).toFixed(2)}`,"payment method":J.payment_method,createdAt:new Date(J.created_at).toLocaleString(),customer:J.customer.customer_id,"customer email":J.customer.email,...J.subscription_id&&{"subscription id":J.subscription_id},"billing address street":J.billing.street,"billing address state":J.billing.state,"billing address city":J.billing.city,"billing address country":J.billing.country,"billing address zipcode":J.billing.zipcode}),console.log(`To view the payment, go to https://app.dodopayments.com/transactions/payments/${J.payment_id}`)}catch(J){if(j(J)&&J.error.code==="NOT_FOUND")console.log("Incorrect payment ID!");else console.error(J)}}else b.payments.forEach((F)=>console.log(`dodo payments ${F.command} - ${F.description}`))}p();async function DF($,_){if(_==="list"){let F=await S({message:"Enter page:",default:"1",validate:(J)=>J.trim()!==""});try{let J=(await $.customers.list({page_number:parseInt(F)-1,page_size:100})).items;console.table(J,["customer_id","name","email","phone_number"])}catch(J){if(j(J))console.log("Failed to fetch customers:",J.error.message);else console.error(J)}}else if(_==="create"){let F=await S({message:"Enter Name:",validate:(Z)=>Z.trim()!==""}),J=await S({message:"Enter Email:",validate:(Z)=>Z.trim()!==""}),G=await S({message:"Enter Phone Number:"});try{let Z=await $.customers.create({name:F,email:J,phone_number:G.trim()!==""?G:null});console.log("Customer Successfully Created!"),console.table([Z],["customer_id","name","email","phone_number"])}catch(Z){if(j(Z))console.log("Failed to create customer:",Z.error.message);else console.error(Z)}}else if(_==="update"){let F=await S({message:"Enter customer ID:",validate:(J)=>J.startsWith("cus_")||"Please enter a valid customer ID!"});try{let J=await $.customers.retrieve(F),G=await S({message:"Enter customer name:",default:J.name}),Z=await S({message:"Enter customer phone:",default:J.phone_number?.toString()}),X=await $.customers.update(F,{name:G,phone_number:Z.trim()!==""?Z:null});console.table([X],["customer_id","name","email","phone_number"])}catch(J){if(J?.name==="ExitPromptError")process.exit(0);if(j(J)&&J.error.code==="NOT_FOUND")console.log("Incorrect customer ID!");else if(j(J))console.log("Failed to update customer:",J.error.message);else console.error(J)}}else b.customers.forEach((F)=>console.log(`dodo customers ${F.command} - ${F.description}`))}p();async function kF($,_){if(_==="list"){let F=await S({message:"Enter page:",default:"1",validate:(J)=>J.trim()!==""});try{let G=(await $.discounts.list({page_number:parseInt(F)-1,page_size:100})).items.map((Z)=>({name:Z.name,code:Z.code,"discount id":Z.discount_id,"created at":new Date(Z.created_at).toLocaleString(),...Z.type==="percentage"?{amount:`${(Z.amount*0.01).toFixed(2)}%`}:{amount:Z.amount}}));console.table(G),console.log("To view a discount, go to https://app.dodopayments.com/sales/discounts/edit?id={discount_id}")}catch(J){if(j(J))console.log("Failed to fetch discounts:",J.error.message);else console.error(J)}}else if(_==="create"){let F=await S({message:"Enter discount name:",validate:(X)=>X.trim()!==""}),J=await S({message:"Enter discount percentage:",validate:(X)=>{let Y=parseFloat(X);return!Number.isNaN(Y)&&Y>0&&Y<=100}}),G=await S({message:"Enter discount code (Optional):"}),Z=await S({message:"Enter discount cycles (Optional):"});try{let X=await $.discounts.create({name:F,code:G.trim()!==""?G:null,amount:parseFloat(J)*100,type:"percentage",...Z.trim()!==""&&{subscription_cycles:parseInt(Z)}});console.log("Discount created successfully!"),console.table({name:X.name,code:X.code,"discount id":X.discount_id,...Z.trim()!==""&&{"subscription cycles":X.subscription_cycles}})}catch(X){if(j(X))console.log("Failed to create discount:",X.error.message);else console.error(X)}}else if(_==="delete")try{let F=await S({message:"Enter discount ID to be deleted:",validate:(J)=>J.startsWith("dsc_")||"Please enter a valid discount ID!"});await $.discounts.delete(F),console.log("Successfully deleted discount!")}catch(F){if(j(F)&&F.error.code==="NOT_FOUND")console.log("Incorrect discount ID!");else if(j(F))console.log("Failed to delete discount:",F.error.message);else console.error(F)}else b.discounts.forEach((F)=>console.log(`dodo discounts ${F.command} - ${F.description}`))}p();async function fF($,_){if(_==="list"){let F=await S({message:"Enter page:",default:"1",validate:(J)=>J.trim()!==""});try{let J=await $.licenseKeys.list({page_number:parseInt(F)-1,page_size:100});console.log(J.items)}catch(J){if(j(J))console.log("Failed to fetch licences:",J.error.message);else console.error(J)}}else b.licences.forEach((F)=>console.log(`dodo licences ${F.command} - ${F.description}`))}p();async function IF($,_){if(_==="create")t$("https://app.dodopayments.com/products/create/add-on");else if(_==="list"){let F=await S({message:"Enter page:",default:"1",validate:(J)=>J.trim()!==""});try{let G=(await $.addons.list({page_number:parseInt(F)-1,page_size:100})).items.map((Z)=>({id:Z.id,name:Z.name,price:`${u[Z.currency]||Z.currency+" "}${(Z.price*0.01).toFixed(2)}`,"created on":new Date(Z.created_at).toLocaleString()}));console.table(G)}catch(J){if(j(J))console.log("Failed to fetch addons:",J.error.message);else console.error(J)}}else if(_==="info"){let F=await S({message:"Enter addon ID:",validate:(J)=>J.startsWith("adn_")||"Please enter a valid addon ID!"});try{let J=await $.addons.retrieve(F);console.table({"addon id":J.id,name:J.name,price:`${u[J.currency]||J.currency+" "}${J.price*0.01}`,...J.description?.trim()!==""&&{description:J.description},created_at:new Date(J.created_at).toLocaleString(),updated_at:new Date(J.updated_at).toLocaleString(),tax_category:J.tax_category}),console.log(`To edit the addon, go to https://app.dodopayments.com/products/edit/add-on?id=${J.id}`)}catch(J){if(j(J)&&J.error.code==="NOT_FOUND")console.log("Incorrect addon ID!");else if(j(J))console.log("Failed to fetch addon:",J.error.message);else console.error(J)}}else b.addons.forEach((F)=>console.log(`dodo addons ${F.command} - ${F.description}`))}p();async function jF($,_){if(_==="list"){let F=await S({message:"Enter page:",default:"1",validate:(J)=>J.trim()!==""});try{let G=(await $.refunds.list({page_number:parseInt(F)-1,page_size:100})).items.map((Z)=>({id:Z.refund_id,"payment id":Z.payment_id,price:`${u[Z.currency||""]||Z.currency+" "}${((Z.amount||0)*0.01).toFixed(2)}`,"created on":new Date(Z.created_at).toLocaleString()}));console.table(G)}catch(J){if(j(J))console.log("Failed to fetch refunds:",J.error.message);else console.error(J)}}else if(_==="info"){let F=await S({message:"Enter refund ID:",validate:(J)=>J.startsWith("ref_")||"Please enter a valid refund ID!"});try{let J=await $.refunds.retrieve(F);console.table({"refund id":J.refund_id,"payment id":J.payment_id,...Object.keys(J.metadata).length>0&&{metadata:J.metadata},"customer id":J.customer.email,"refund type":J.is_partial?"Partial":"Full",price:`${u[J.currency||""]||J.currency+" "}${((J.amount||0)*0.01).toFixed(2)}`,...J.reason?.trim()!==""&&{reason:J.reason},created_at:new Date(J.created_at).toLocaleString()})}catch(J){if(j(J)&&J.error.code==="NOT_FOUND")console.log("Incorrect refund ID!");else if(j(J))console.log("Failed to fetch refund:",J.error.message);else console.error(J)}}else b.refunds.forEach((F)=>console.log(`dodo refunds ${F.command} - ${F.description}`))}p();async function LF($,_){if(_==="new"){let F={product_cart:[]},J=await S({message:"Enter product:",validate:(Z)=>Z.startsWith("pdt_")});if(F.product_cart=[{product_id:J,quantity:1}],await a({message:"Use advanced options?",choices:[{name:"Yes",value:!0},{name:"No",value:!1}],default:!1})){F.minimal_address=await a({message:"Enable minimal address:",choices:[{name:"Yes",value:!0},{name:"No",value:!1}],default:!1});let Z=await S({message:"Enter return URL (Optional):"});if(Z.trim()!=="")F.return_url=Z;F.force_3ds=await a({message:"Force 3DS?",choices:[{name:"Yes",value:!0},{name:"No",value:!1}]});let X=await S({message:"Enter discount code (Optional):"});if(X.trim()!=="")F.discount_code=X;let Y=await S({message:"Enter metadata (Optional, JSON stringified):"});if(Y.trim()!=="")F.metadata=JSON.parse(Y)}try{let Z=await $.checkoutSessions.create(F);console.log("Checkout Session URL:",Z.checkout_url)}catch(Z){if(j(Z))console.log(`Error: ${Z.error.message}`);else console.error(Z)}}else b.checkout.forEach((F)=>console.log(`dodo checkout ${F.command} - ${F.description}`))}p();async function z1({API_KEY:$,dodoClient:_}){let F=await S({message:"Enter the endpoint URL: "}),J;if(process.env.DODO_WH_TEST_SERVER_URL)J=`https://${process.env.DODO_WH_TEST_SERVER_URL}/`;else J="https://wsserver.dodopayments.tech/";let G=!1;if((await _.webhooks.list({limit:100})).data.forEach((z)=>{if(z.url===J)G=!0}),!G)await _.webhooks.create({url:J,description:"This webhook as been automatically added by Dodo Payments CLI for testing webhooks"});let X;if(process.env.DODO_WH_TEST_SERVER_URL)X=`wss://${process.env.DODO_WH_TEST_SERVER_URL}/connect`;else X="wss://wsserver.dodopayments.tech/connect";let Y=new WebSocket(X,{headers:{"api-key":$}});Y.onopen=()=>{console.log("Successfully connected to Dodo Payments CLI Webhook Server ✅")},Y.onmessage=async(z)=>{try{let O=JSON.parse(z.data.toString());if(O.requestId){console.log("Received webhook!"),console.log("Event Type:",O.payload.type);let T=await fetch(F,{method:"POST",headers:{"Content-Type":"application/json",...O.headers},body:JSON.stringify(O.payload)}),K=await T.text(),Q;try{Q=JSON.parse(K)}catch(N){Q=K}let W={};T.headers.forEach((N,M)=>{W[M]=N}),console.log("Status:",T.status),console.log("Response:",Q),console.log(),Y.send(JSON.stringify({type:"webhook_response",requestId:O.requestId,status:T.status,body:Q,headers:W}))}}catch(O){console.error("Failed to parse or respond to message",O)}},Y.onclose=(z)=>{console.log("Disconnected from Dodo Payments CLI Webhook Server"),console.log("Reason:",z.reason),console.log("Code:",z.code)},Y.onerror=(z)=>{console.log("Error in Dodo Payments CLI Webhook Server:",z)}}async function z3($,_,F){switch(F){case"listen":z1({API_KEY:_,dodoClient:$});break;case"trigger":W3();break;default:b.wh.forEach((J)=>console.log(`dodo wh ${J.command} - ${J.description}`))}}process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));var b0=process.argv[2],t=process.argv[3];try{if(b0==="login")await CF(),process.exit(0);if(!f0()){if(b0&&!t)p0(b0),console.log();else if(!b0&&!t)p0(),console.log();console.log("Please login using `dodo login` command first!"),process.exit(0)}let{apiKey:$,mode:_}=await QF(),F=new E({bearerToken:$,environment:_});switch(b0){case"products":await wF(F,t);break;case"payments":await RF(F,t);break;case"customers":await DF(F,t);break;case"discounts":await kF(F,t);break;case"licences":await fF(F,t);break;case"addons":await IF(F,t);break;case"refunds":await jF(F,t);break;case"checkout":await LF(F,t);break;case"wh":await z3(F,$,t);break;default:p0()}}catch($){if($?.name==="ExitPromptError")process.exit(0);console.error("An unexpected error occurred:",$),process.exit(1)}
|