dodopayments-cli 2.1.0 → 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.
@@ -0,0 +1,11 @@
1
+ /** @type {import("prettier").Config} */
2
+ export default {
3
+ // Enforce 2-space indentation
4
+ tabWidth: 2,
5
+
6
+ // Use single quotes
7
+ singleQuote: true,
8
+
9
+ // Always add semicolons
10
+ semi: true,
11
+ };
package/CONTRIBUTING.md CHANGED
@@ -61,17 +61,38 @@ This project and everyone participating in it is governed by our [Code of Conduc
61
61
 
62
62
  ```
63
63
  dodopayments-cli/
64
- ├── index.ts # Main CLI entrypoint
65
- ├── utils/ # Utility functions
66
- ├── dodo-webhooks/ # Webhook testing functionality
64
+ ├── src/ # All CLI source code
65
+ ├── index.ts # Main CLI entrypoint (command router)
66
+ │ │
67
+ │ ├── commands/ # Domain-based command modules
68
+ │ │ ├── addons/ # Add-on related commands
69
+ │ │ ├── checkout/ # Checkout commands
70
+ │ │ ├── customer/ # Customer management commands
71
+ │ │ ├── discount/ # Discount/coupon commands
72
+ │ │ ├── licenses/ # License management commands
73
+ │ │ ├── login/ # Authentication/login commands
74
+ │ │ ├── payment/ # Payment-related commands
75
+ │ │ ├── product/ # Product management commands
76
+ │ │ ├── refund/ # Refund commands
77
+ │ │ └── webhook/ # Webhook-related commands
78
+ │ │
79
+ │ ├── ui/ # CLI presentation layer (output/help/logo)
80
+ │ │ ├── help.ts # Help rendering
81
+ │ │ ├── index.ts # Barrel export for UI utilities
82
+ │ │ └── logo.ts # CLI logo/banner
83
+ │ │
84
+ │ └── utils/ # Shared utilities (config, client, helpers)
85
+
86
+ ├── build-binaries.ts # Script to generate distributable binaries
67
87
  ├── .github/
68
- │ ├── ISSUE_TEMPLATE/ # Issue templates
88
+ │ ├── ISSUE_TEMPLATE/
69
89
  │ ├── PULL_REQUEST_TEMPLATE.md
70
- │ └── workflows/ # CI/CD workflows
71
- ├── CONTRIBUTING.md # This file
90
+ │ └── workflows/
91
+
92
+ ├── CONTRIBUTING.md
72
93
  ├── CODE_OF_CONDUCT.md
73
94
  ├── LICENSE
74
- └── README.md
95
+ ├── README.md
75
96
  ```
76
97
 
77
98
  ## How to Contribute
package/README.md CHANGED
@@ -20,7 +20,7 @@
20
20
  <a href="#installation">Installation</a> •
21
21
  <a href="#authentication">Authentication</a> •
22
22
  <a href="#usage">Usage</a> •
23
- <a href="#webhook-testing">Webhooks</a> •
23
+ <a href="#webhooks">Webhooks</a> •
24
24
  <a href="#contributing">Contributing</a>
25
25
  </p>
26
26
 
package/dist/index.js CHANGED
@@ -1,32 +1,27 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as E8}from"node:module";var D8=Object.create;var{getPrototypeOf:F8,defineProperty:z2,getOwnPropertyNames:u8}=Object;var C8=Object.prototype.hasOwnProperty;var PF=(D,F,u)=>{u=D!=null?D8(F8(D)):{};let C=F||!D||!D.__esModule?z2(u,"default",{value:D,enumerable:!0}):u;for(let E of u8(D))if(!C8.call(C,E))z2(C,E,{get:()=>D[E],enumerable:!0});return C};var ZD=(D,F)=>()=>(F||D((F={exports:{}}).exports,F),F.exports);var M=(D,F)=>()=>(D&&(F=D(D=0)),F);var K2=E8(import.meta.url);var g2=ZD((y2)=>{Object.defineProperty(y2,"__esModule",{value:!0});y2.timingSafeEqual=void 0;function v2(D,F=""){if(!D)throw Error(F)}function w8(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);v2(D instanceof DataView),v2(F instanceof DataView);let u=D.byteLength,C=0,E=-1;while(++E<u)C|=D.getUint8(E)^F.getUint8(E);return C===0}y2.timingSafeEqual=w8});var d2=ZD((p)=>{var R8=p&&p.__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 A in E)if(E.hasOwnProperty(A))C[A]=E[A]},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(p,"__esModule",{value:!0});var f=256,V0=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 A=F.length-C;if(A>0){var E=F[C]<<16|(A===2?F[C+1]<<8:0);if(u+=this._encodeByte(E>>>18&63),u+=this._encodeByte(E>>>12&63),A===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)),A=0,$=0,Q=0,Y=0,J=0,X=0,Z=0;for(;$<C-4;$+=4)Y=this._decodeChar(F.charCodeAt($+0)),J=this._decodeChar(F.charCodeAt($+1)),X=this._decodeChar(F.charCodeAt($+2)),Z=this._decodeChar(F.charCodeAt($+3)),E[A++]=Y<<2|J>>>4,E[A++]=J<<4|X>>>2,E[A++]=X<<6|Z,Q|=Y&f,Q|=J&f,Q|=X&f,Q|=Z&f;if($<C-1)Y=this._decodeChar(F.charCodeAt($)),J=this._decodeChar(F.charCodeAt($+1)),E[A++]=Y<<2|J>>>4,Q|=Y&f,Q|=J&f;if($<C-2)X=this._decodeChar(F.charCodeAt($+2)),E[A++]=J<<4|X>>>2,Q|=X&f;if($<C-3)Z=this._decodeChar(F.charCodeAt($+3)),E[A++]=X<<6|Z,Q|=Z&f;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=f;return u+=(42-F&F-44)>>>8&-f+F-43+62,u+=(46-F&F-48)>>>8&-f+F-47+63,u+=(47-F&F-58)>>>8&-f+F-48+52,u+=(64-F&F-91)>>>8&-f+F-65+0,u+=(96-F&F-123)>>>8&-f+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}();p.Coder=V0;var WF=new V0;function j8(D){return WF.encode(D)}p.encode=j8;function k8(D){return WF.decode(D)}p.decode=k8;var m2=function(D){R8(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=f;return C+=(44-u&u-46)>>>8&-f+u-45+62,C+=(94-u&u-96)>>>8&-f+u-95+63,C+=(47-u&u-58)>>>8&-f+u-48+52,C+=(64-u&u-91)>>>8&-f+u-65+0,C+=(96-u&u-123)>>>8&-f+u-97+26,C},F}(V0);p.URLSafeCoder=m2;var c2=new m2;function L8(D){return c2.encode(D)}p.encodeURLSafe=L8;function I8(D){return c2.decode(D)}p.decodeURLSafe=I8;p.encodedLength=function(D){return WF.encodedLength(D)};p.maxDecodedLength=function(D){return WF.maxDecodedLength(D)};p.decodedLength=function(D){return WF.decodedLength(D)}});var p2=ZD((l2,dF)=>{(function(D,F){var u={};F(u);var C=u.default;for(var E in u)C[E]=u[E];if(typeof dF==="object"&&typeof dF.exports==="object")dF.exports=C;else if(typeof define==="function"&&define.amd)define(function(){return C});else D.sha256=C})(l2,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,B,G,z,T){var W,O,_,V,w,q,h,H,R,j,P,c,t;while(T>=64){W=B[0],O=B[1],_=B[2],V=B[3],w=B[4],q=B[5],h=B[6],H=B[7];for(j=0;j<16;j++)P=z+j*4,Z[j]=(G[P]&255)<<24|(G[P+1]&255)<<16|(G[P+2]&255)<<8|G[P+3]&255;for(j=16;j<64;j++)R=Z[j-2],c=(R>>>17|R<<15)^(R>>>19|R<<13)^R>>>10,R=Z[j-15],t=(R>>>7|R<<25)^(R>>>18|R<<14)^R>>>3,Z[j]=(c+Z[j-7]|0)+(t+Z[j-16]|0);for(j=0;j<64;j++)c=(((w>>>6|w<<26)^(w>>>11|w<<21)^(w>>>25|w<<7))+(w&q^~w&h)|0)+(H+(F[j]+Z[j]|0)|0)|0,t=((W>>>2|W<<30)^(W>>>13|W<<19)^(W>>>22|W<<10))+(W&O^W&_^O&_)|0,H=h,h=q,q=w,w=V+c|0,V=_,_=O,O=W,W=c+t|0;B[0]+=W,B[1]+=O,B[2]+=_,B[3]+=V,B[4]+=w,B[5]+=q,B[6]+=h,B[7]+=H,z+=64,T-=64}return z}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 B=0;B<this.buffer.length;B++)this.buffer[B]=0;for(var B=0;B<this.temp.length;B++)this.temp[B]=0;this.reset()},Z.prototype.update=function(B,G){if(G===void 0)G=B.length;if(this.finished)throw Error("SHA256: can't update because hash was finished.");var z=0;if(this.bytesHashed+=G,this.bufferLength>0){while(this.bufferLength<64&&G>0)this.buffer[this.bufferLength++]=B[z++],G--;if(this.bufferLength===64)u(this.temp,this.state,this.buffer,0,64),this.bufferLength=0}if(G>=64)z=u(this.temp,this.state,B,z,G),G%=64;while(G>0)this.buffer[this.bufferLength++]=B[z++],G--;return this},Z.prototype.finish=function(B){if(!this.finished){var G=this.bytesHashed,z=this.bufferLength,T=G/536870912|0,W=G<<3,O=G%64<56?64:128;this.buffer[z]=128;for(var _=z+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;_++)B[_*4+0]=this.state[_]>>>24&255,B[_*4+1]=this.state[_]>>>16&255,B[_*4+2]=this.state[_]>>>8&255,B[_*4+3]=this.state[_]>>>0&255;return this},Z.prototype.digest=function(){var B=new Uint8Array(this.digestLength);return this.finish(B),B},Z.prototype._saveState=function(B){for(var G=0;G<this.state.length;G++)B[G]=this.state[G]},Z.prototype._restoreState=function(B,G){for(var z=0;z<this.state.length;z++)this.state[z]=B[z];this.bytesHashed=G,this.finished=!1,this.bufferLength=0},Z}();D.Hash=C;var E=function(){function Z(B){this.inner=new C,this.outer=new C,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var G=new Uint8Array(this.blockSize);if(B.length>this.blockSize)new C().update(B).finish(G).clean();else for(var z=0;z<B.length;z++)G[z]=B[z];for(var z=0;z<G.length;z++)G[z]^=54;this.inner.update(G);for(var z=0;z<G.length;z++)G[z]^=106;this.outer.update(G),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var z=0;z<G.length;z++)G[z]=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 B=0;B<this.istate.length;B++)this.ostate[B]=this.istate[B]=0;this.inner.clean(),this.outer.clean()},Z.prototype.update=function(B){return this.inner.update(B),this},Z.prototype.finish=function(B){if(this.outer.finished)this.outer.finish(B);else this.inner.finish(B),this.outer.update(B,this.digestLength).finish(B);return this},Z.prototype.digest=function(){var B=new Uint8Array(this.digestLength);return this.finish(B),B},Z}();D.HMAC=E;function A(Z){var B=new C().update(Z),G=B.digest();return B.clean(),G}D.hash=A,D.default=A;function $(Z,B){var G=new E(Z).update(B),z=G.digest();return G.clean(),z}D.hmac=$;function Q(Z,B,G,z){var T=z[0];if(T===0)throw Error("hkdf: cannot expand more");if(B.reset(),T>1)B.update(Z);if(G)B.update(G);B.update(z),B.finish(Z),z[0]++}var Y=new Uint8Array(D.digestLength);function J(Z,B,G,z){if(B===void 0)B=Y;if(z===void 0)z=32;var T=new Uint8Array([1]),W=$(B,Z),O=new E(W),_=new Uint8Array(O.digestLength),V=_.length,w=new Uint8Array(z);for(var q=0;q<z;q++){if(V===_.length)Q(_,O,G,T),V=0;w[q]=_[V++]}return O.clean(),_.fill(0),T.fill(0),w}D.hkdf=J;function X(Z,B,G,z){var T=new E(Z),W=T.digestLength,O=new Uint8Array(4),_=new Uint8Array(W),V=new Uint8Array(W),w=new Uint8Array(z);for(var q=0;q*W<z;q++){var h=q+1;O[0]=h>>>24&255,O[1]=h>>>16&255,O[2]=h>>>8&255,O[3]=h>>>0&255,T.reset(),T.update(B),T.update(O),T.finish(V);for(var H=0;H<W;H++)_[H]=V[H];for(var H=2;H<=G;H++){T.reset(),T.update(V).finish(V);for(var R=0;R<W;R++)_[R]^=V[R]}for(var H=0;H<W&&q*W+H<z;H++)w[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(),w}D.pbkdf2=X})});var t2=ZD((a2)=>{Object.defineProperty(a2,"__esModule",{value:!0});a2.Webhook=a2.WebhookVerificationError=void 0;var f8=g2(),n2=d2(),P8=p2(),i2=300;class H0 extends Error{constructor(D){super(D);Object.setPrototypeOf(this,H0.prototype),this.name="ExtendableError",this.stack=Error(D).stack}}class BD extends H0{constructor(D){super(D);Object.setPrototypeOf(this,BD.prototype),this.name="WebhookVerificationError"}}a2.WebhookVerificationError=BD;class OF{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(OF.prefix))D=D.substring(OF.prefix.length);this.key=n2.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"],A=u["webhook-timestamp"];if(!E||!C||!A)throw new BD("Missing required headers");let $=this.verifyTimestamp(A),Y=this.sign(C,$,D).split(",")[1],J=E.split(" "),X=new globalThis.TextEncoder;for(let Z of J){let[B,G]=Z.split(",");if(B!=="v1")continue;if((0,f8.timingSafeEqual)(X.encode(G),X.encode(Y)))return JSON.parse(D.toString())}throw new BD("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),A=C.encode(`${D}.${E}.${u}`);return`v1,${n2.encode(P8.hmac(this.key,A))}`}verifyTimestamp(D){let F=Math.floor(Date.now()/1000),u=parseInt(D,10);if(isNaN(u))throw new BD("Invalid Signature Headers");if(F-u>i2)throw new BD("Message timestamp too old");if(u>F+i2)throw new BD("Message timestamp too new");return new Date(u*1000)}}a2.Webhook=OF;OF.prefix="whsec_"});var UF=(D,F=[])=>D.name==="up"||F.includes("vim")&&D.name==="k"||F.includes("emacs")&&D.ctrl&&D.name==="p",pF=(D,F=[])=>D.name==="down"||F.includes("vim")&&D.name==="j"||F.includes("emacs")&&D.ctrl&&D.name==="n",VF=(D)=>D.name==="backspace",x0=(D)=>D.name==="tab",S0=(D)=>"1234567890".includes(D.name),HF=(D)=>D.name==="enter"||D.name==="return";var w0,R0,nF,j0,qF;var iF=M(()=>{w0=class w0 extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(D){super();this.cause=D?.cause}};R0=class R0 extends Error{name="CancelPromptError";message="Prompt was canceled"};nF=class nF extends Error{name="ExitPromptError"};j0=class j0 extends Error{name="HookError"};qF=class qF extends Error{name="ValidationError"}});import{AsyncLocalStorage as y8,AsyncResource as h8}from"node:async_hooks";function g8(D){return{rl:D,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function Fu(D,F){let u=g8(D);return Du.run(u,()=>{function C(E){u.handleChange=()=>{u.index=0,E()},u.handleChange()}return F(C)})}function YD(){let D=Du.getStore();if(!D)throw new j0("[Inquirer] Hook functions can only be called from within a prompt");return D}function k0(){return YD().rl}function L0(D){let F=(...u)=>{let C=YD(),E=!1,A=C.handleChange;C.handleChange=()=>{E=!0};let $=D(...u);if(E)A();return C.handleChange=A,$};return h8.bind(F)}function pD(D){let F=YD(),{index:u}=F,C={get(){return F.hooks[u]},set(A){F.hooks[u]=A},initialized:u in F.hooks},E=D(C);return F.index++,E}function uu(){YD().handleChange()}var Du,zD;var KD=M(()=>{iF();Du=new y8;zD={queue(D){let F=YD(),{index:u}=F;F.hooksEffect.push(()=>{F.hooksCleanup[u]?.();let C=D(k0());if(C!=null&&typeof C!=="function")throw new qF("useEffect return value must be a cleanup function or nothing.");F.hooksCleanup[u]=C})},run(){let D=YD();L0(()=>{D.hooksEffect.forEach((F)=>{F()}),D.hooksEffect.length=0})()},clearAll(){let D=YD();D.hooksCleanup.forEach((F)=>{F?.()}),D.hooksEffect.length=0,D.hooksCleanup.length=0}}});import{AsyncResource as m8}from"node:async_hooks";function d(D){return pD((F)=>{let u=m8.bind(function(A){if(F.get()!==A)F.set(A),uu()});if(F.initialized)return[F.get(),u];let C=typeof D==="function"?D():D;return F.set(C),[C,u]})}var aF=M(()=>{KD()});function o(D,F){pD((u)=>{let C=u.get();if(!Array.isArray(C)||F.some((A,$)=>!Object.is(A,C[$])))zD.queue(D);u.set(F)})}var rF=M(()=>{KD()});import r from"node:process";function c8(){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 Cu,Eu,d8,l8,p8,n8,i8,nD,QB;var tF=M(()=>{Cu={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:"╱"},Eu={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:"⅒"},d8={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"},l8={...Cu,...Eu},p8={...Cu,...d8},n8=c8(),i8=n8?l8:p8,nD=i8,QB=Object.entries(Eu)});import{styleText as i}from"node:util";var Bu;var Au=M(()=>{tF();Bu={prefix:{idle:i("blue","?"),done:i("green",nD.tick)},spinner:{interval:80,frames:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"].map((D)=>i("yellow",D))},style:{answer:(D)=>i("cyan",D),message:(D)=>i("bold",D),error:(D)=>i("red",`> ${D}`),defaultAnswer:(D)=>i("dim",`(${D})`),help:(D)=>i("dim",D),highlight:(D)=>i("cyan",D),key:(D)=>i("cyan",i("bold",`<${D}>`))}}});function $u(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 Zu(...D){let F={};for(let u of D)for(let[C,E]of Object.entries(u)){let A=F[C];F[C]=$u(A)&&$u(E)?Zu(A,E):E}return F}function _D(...D){let F=[Bu,...D.filter((u)=>u!=null)];return Zu(...F)}var I0=M(()=>{Au()});function MF({status:D="idle",theme:F}){let[u,C]=d(!1),[E,A]=d(0),{prefix:$,spinner:Q}=_D(F);if(o(()=>{if(D==="loading"){let J,X=-1,Z=setTimeout(()=>{C(!0),J=setInterval(()=>{X=X+1,A(X%Q.frames.length)},Q.interval)},300);return()=>{clearTimeout(Z),clearInterval(J)}}else C(!1)},[D]),u)return Q.frames[E];return typeof $==="string"?$:$[D==="loading"?"idle":D]??$.idle}var Qu=M(()=>{aF();rF();I0()});function xF(D,F){return pD((u)=>{let C=u.get();if(!C||C.dependencies.length!==F.length||C.dependencies.some((E,A)=>E!==F[A])){let E=D();return u.set({value:E,dependencies:F}),E}return C.value})}var Gu=M(()=>{KD()});function WD(D){return d({current:D})[0]}var sF=M(()=>{aF()});function SF(D){let F=WD(D);F.current=D,o((u)=>{let C=!1,E=L0((A,$)=>{if(C)return;F.current($,u)});return u.input.on("keypress",E),()=>{C=!0,u.input.removeListener("keypress",E)}},[])}var Ju=M(()=>{sF();rF();KD()});var Yu=ZD((wB,Xu)=>{Xu.exports=r8;function a8(D){let F={defaultWidth:0,output:process.stdout,tty:K2("tty")};if(!D)return F;return Object.keys(F).forEach(function(u){if(!D[u])D[u]=F[u]}),D}function r8(D){let F=a8(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 f0({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 wF(D){if(typeof D!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof D}\``);return D.replace(t8,"")}var t8;var P0=M(()=>{t8=f0()});function zu(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 Ku(D){return D===12288||D>=65281&&D<=65376||D>=65504&&D<=65510}function _u(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 Wu=()=>{};function s8(D){if(!Number.isSafeInteger(D))throw TypeError(`Expected a code point, got \`${typeof D}\`.`)}function Ou(D,{ambiguousAsWide:F=!1}={}){if(s8(D),Ku(D)||_u(D)||F&&zu(D))return 2;return 1}var Tu=M(()=>{Wu()});var Uu=ZD((bB,Nu)=>{Nu.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 OD(D,F={}){if(typeof D!=="string"||D.length===0)return 0;let{ambiguousIsNarrow:u=!0,countAnsiEscapeCodes:C=!1}=F;if(!C)D=wF(D);if(D.length===0)return 0;let E=0,A={ambiguousAsWide:!u};for(let{segment:$}of o8.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(e8.test($))continue;if(Vu.default().test($)){E+=2;continue}E+=Ou(Q,A)}return E}var Vu,o8,e8;var Hu=M(()=>{P0();Tu();Vu=PF(Uu(),1),o8=new Intl.Segmenter,e8=/^\p{Default_Ignorable_Code_Point}$/u});function u6(){let D=new Map;for(let[F,u]of Object.entries(L)){for(let[C,E]of Object.entries(u))L[C]={open:`\x1B[${E[0]}m`,close:`\x1B[${E[1]}m`},u[C]=L[C],D.set(E[0],E[1]);Object.defineProperty(L,F,{value:u,enumerable:!1})}return Object.defineProperty(L,"codes",{value:D,enumerable:!1}),L.color.close="\x1B[39m",L.bgColor.close="\x1B[49m",L.color.ansi=qu(),L.color.ansi256=Mu(),L.color.ansi16m=xu(),L.bgColor.ansi=qu(10),L.bgColor.ansi256=Mu(10),L.bgColor.ansi16m=xu(10),Object.defineProperties(L,{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((A)=>A+A).join("");let E=Number.parseInt(C,16);return[E>>16&255,E>>8&255,E&255]},enumerable:!1},hexToAnsi256:{value:(F)=>L.rgbToAnsi256(...L.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 A=Math.max(u,C,E)*2;if(A===0)return 30;let $=30+(Math.round(E)<<2|Math.round(C)<<1|Math.round(u));if(A===2)$+=60;return $},enumerable:!1},rgbToAnsi:{value:(F,u,C)=>L.ansi256ToAnsi(L.rgbToAnsi256(F,u,C)),enumerable:!1},hexToAnsi:{value:(F)=>L.ansi256ToAnsi(L.hexToAnsi256(F)),enumerable:!1}}),L}var qu=(D=0)=>(F)=>`\x1B[${F+D}m`,Mu=(D=0)=>(F)=>`\x1B[${38+D};5;${F}m`,xu=(D=0)=>(F,u,C)=>`\x1B[${38+D};2;${F};${u};${C}m`,L,gB,D6,F6,mB,C6,Su;var wu=M(()=>{L={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]}},gB=Object.keys(L.modifier),D6=Object.keys(L.color),F6=Object.keys(L.bgColor),mB=[...D6,...F6];C6=u6(),Su=C6});function y0(D,F,u){return String(D).normalize().replaceAll(`\r
3
- `,`
4
- `).split(`
5
- `).map((C)=>Z6(C,F,u)).join(`
6
- `)}var eF,E6=39,v0="\x07",ku="[",B6="]",Lu="m",oF,Ru=(D)=>`${eF.values().next().value}${ku}${D}${Lu}`,ju=(D)=>`${eF.values().next().value}${oF}${D}${v0}`,A6=(D)=>D.split(" ").map((F)=>OD(F)),b0=(D,F,u)=>{let C=[...F],E=!1,A=!1,$=OD(wF(D.at(-1)));for(let[Q,Y]of C.entries()){let J=OD(Y);if($+J<=u)D[D.length-1]+=Y;else D.push(Y),$=0;if(eF.has(Y))E=!0,A=C.slice(Q+1,Q+1+oF.length).join("")===oF;if(E){if(A){if(Y===v0)E=!1,A=!1}else if(Y===Lu)E=!1;continue}if($+=J,$===u&&Q<C.length-1)D.push(""),$=0}if(!$&&D.at(-1).length>0&&D.length>1)D[D.length-2]+=D.pop()},$6=(D)=>{let F=D.split(" "),u=F.length;while(u>0){if(OD(F[u-1])>0)break;u--}if(u===F.length)return D;return F.slice(0,u).join(" ")+F.slice(u).join("")},Z6=(D,F,u={})=>{if(u.trim!==!1&&D.trim()==="")return"";let C="",E,A,$=A6(D),Q=[""];for(let[Z,B]of D.split(" ").entries()){if(u.trim!==!1)Q[Q.length-1]=Q.at(-1).trimStart();let G=OD(Q.at(-1));if(Z!==0){if(G>=F&&(u.wordWrap===!1||u.trim===!1))Q.push(""),G=0;if(G>0||u.trim===!1)Q[Q.length-1]+=" ",G++}if(u.hard&&$[Z]>F){let z=F-G,T=1+Math.floor(($[Z]-z-1)/F);if(Math.floor(($[Z]-1)/F)<T)Q.push("");b0(Q,B,F);continue}if(G+$[Z]>F&&G>0&&$[Z]>0){if(u.wordWrap===!1&&G<F){b0(Q,B,F);continue}Q.push("")}if(G+$[Z]>F&&u.wordWrap===!1){b0(Q,B,F);continue}Q[Q.length-1]+=B}if(u.trim!==!1)Q=Q.map((Z)=>$6(Z));let Y=Q.join(`
7
- `),J=[...Y],X=0;for(let[Z,B]of J.entries()){if(C+=B,eF.has(B)){let{groups:z}=new RegExp(`(?:\\${ku}(?<code>\\d+)m|\\${oF}(?<uri>.*)${v0})`).exec(Y.slice(X))||{groups:{}};if(z.code!==void 0){let T=Number.parseFloat(z.code);E=T===E6?void 0:T}else if(z.uri!==void 0)A=z.uri.length===0?void 0:z.uri}let G=Su.codes.get(Number(E));if(J[Z+1]===`
8
- `){if(A)C+=ju("");if(E&&G)C+=Ru(G)}else if(B===`
9
- `){if(E&&G)C+=Ru(E);if(A)C+=ju(A)}X+=B.length}return C};var Iu=M(()=>{Hu();P0();wu();eF=new Set(["\x1B","›"]),oF=`${B6}8;;`});function RF(D,F){return D.split(`
10
- `).flatMap((u)=>y0(u,F,{trim:!1,hard:!0}).split(`
11
- `).map((C)=>C.trimEnd())).join(`
12
- `)}function D0(){return fu.default({defaultWidth:80,output:k0().output})}var fu;var h0=M(()=>{Iu();KD();fu=PF(Yu(),1)});function Q6({active:D,renderedItems:F,pageSize:u,loop:C}){let E=WD({lastPointer:D,lastActive:void 0}),{lastPointer:A,lastActive:$}=E.current,Q=Math.floor(u/2),Y=F.reduce((Z,B)=>Z+B.length,0),J=F.slice(0,D).reduce((Z,B)=>Z+B.length,0),X=J;if(Y>u)if(C){if(X=A,$!=null&&$<D&&D-$<u)X=Math.min(Q,Math.abs(D-$)===1?Math.min(A+(F[$]?.length??0),Math.max(J,A)):A+D-$)}else{let Z=F.slice(D).reduce((B,G)=>B+G.length,0);X=Z<u-Q?u-Z:Math.min(J,Q)}return E.current.lastPointer=X,E.current.lastActive=D,X}function g0({items:D,active:F,renderItem:u,pageSize:C,loop:E=!0}){let A=D0(),$=(O)=>(O%D.length+D.length)%D.length,Q=D.map((O,_)=>{if(O==null)return[];return RF(u({item:O,index:_,isActive:_===F}),A).split(`
13
- `)}),Y=Q.reduce((O,_)=>O+_.length,0),J=(O)=>Q[O]??[],X=Q6({active:F,renderedItems:Q,pageSize:C,loop:E}),Z=J(F).slice(0,C),B=X+Z.length<=C?X:C-Z.length,G=Array.from({length:C});G.splice(B,Z.length,...Z);let z=new Set([F]),T=B+Z.length,W=$(F+1);while(T<C&&!z.has(W)&&(E&&Y>C?W!==F:W>F)){let _=J(W).slice(0,C-T);G.splice(T,_.length,..._),z.add(W),T+=_.length,W=$(W+1)}T=B-1,W=$(F-1);while(T>=0&&!z.has(W)&&(E&&Y>C?W!==F:W<F)){let O=J(W),_=O.slice(Math.max(0,O.length-T-1));G.splice(T-_.length+1,_.length,..._),z.add(W),T-=_.length,W=$(W-1)}return G.filter((O)=>typeof O==="string").join(`
14
- `)}var Pu=M(()=>{sF();h0()});var yu=ZD((eB,vu)=>{var G6=K2("stream");class bu extends G6{#u=null;constructor(D={}){super(D);this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=D.replace,this._prompt=D.prompt||null,this._hadControl=!1}#F(D,F){if(this._dest)return this._dest[D];if(this._src)return this._src[D];return F}#D(D,...F){if(typeof this._dest?.[D]==="function")this._dest[D](...F);if(typeof this._src?.[D]==="function")this._src[D](...F)}get isTTY(){if(this.#u!==null)return this.#u;return this.#F("isTTY",!1)}set isTTY(D){this.#u=D}get rows(){return this.#F("rows")}get columns(){return this.#F("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(D){this._src=D}pipe(D,F){return this._dest=D,super.pipe(D,F)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(D){if(this.muted){if(!this.replace)return!0;if(D.match(/^\u001b/)){if(D.indexOf(this._prompt)===0)D=D.slice(this._prompt.length),D=D.replace(/./g,this.replace),D=this._prompt+D;return this._hadControl=!0,this.emit("data",D)}else{if(this._prompt&&this._hadControl&&D.indexOf(this._prompt)===0)this._hadControl=!1,this.emit("data",this._prompt),D=D.slice(this._prompt.length);D=D.toString().replace(/./g,this.replace)}}this.emit("data",D)}end(D){if(this.muted)if(D&&this.replace)D=D.toString().replace(/./g,this.replace);else D=null;if(D)this.emit("data",D);this.emit("end")}destroy(...D){return this.#D("destroy",...D)}destroySoon(...D){return this.#D("destroySoon",...D)}close(...D){return this.#D("close",...D)}}vu.exports=bu});var TD;var hu=M(()=>{TD=[];TD.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")TD.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")TD.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")});class gu{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(c0[m0])return c0[m0];J6(c0,m0,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(D,F){this.listeners[D].push(F)}removeListener(D,F){let u=this.listeners[D],C=u.indexOf(F);if(C===-1)return;if(C===0&&u.length===1)u.length=0;else u.splice(C,1)}emit(D,F,u){if(this.emitted[D])return!1;this.emitted[D]=!0;let C=!1;for(let E of this.listeners[D])C=E(F,u)===!0||C;if(D==="exit")C=this.emit("afterExit",F,u)||C;return C}}class l0{}var F0=(D)=>!!D&&typeof D==="object"&&typeof D.removeListener==="function"&&typeof D.emit==="function"&&typeof D.reallyExit==="function"&&typeof D.listeners==="function"&&typeof D.kill==="function"&&typeof D.pid==="number"&&typeof D.on==="function",m0,c0,J6,X6=(D)=>{return{onExit(F,u){return D.onExit(F,u)},load(){return D.load()},unload(){return D.unload()}}},mu,cu,d0,du,u4,C4;var lu=M(()=>{hu();m0=Symbol.for("signal-exit emitter"),c0=globalThis,J6=Object.defineProperty.bind(Object);mu=class mu extends l0{onExit(){return()=>{}}load(){}unload(){}};cu=class cu extends l0{#u=d0.platform==="win32"?"SIGINT":"SIGHUP";#F=new gu;#D;#B;#A;#E={};#C=!1;constructor(D){super();this.#D=D,this.#E={};for(let F of TD)this.#E[F]=()=>{let u=this.#D.listeners(F),{count:C}=this.#F,E=D;if(typeof E.__signal_exit_emitter__==="object"&&typeof E.__signal_exit_emitter__.count==="number")C+=E.__signal_exit_emitter__.count;if(u.length===C){this.unload();let A=this.#F.emit("exit",null,F),$=F==="SIGHUP"?this.#u:F;if(!A)D.kill(D.pid,$)}};this.#A=D.reallyExit,this.#B=D.emit}onExit(D,F){if(!F0(this.#D))return()=>{};if(this.#C===!1)this.load();let u=F?.alwaysLast?"afterExit":"exit";return this.#F.on(u,D),()=>{if(this.#F.removeListener(u,D),this.#F.listeners.exit.length===0&&this.#F.listeners.afterExit.length===0)this.unload()}}load(){if(this.#C)return;this.#C=!0,this.#F.count+=1;for(let D of TD)try{let F=this.#E[D];if(F)this.#D.on(D,F)}catch(F){}this.#D.emit=(D,...F)=>{return this.#Z(D,...F)},this.#D.reallyExit=(D)=>{return this.#$(D)}}unload(){if(!this.#C)return;this.#C=!1,TD.forEach((D)=>{let F=this.#E[D];if(!F)throw Error("Listener not defined for signal: "+D);try{this.#D.removeListener(D,F)}catch(u){}}),this.#D.emit=this.#B,this.#D.reallyExit=this.#A,this.#F.count-=1}#$(D){if(!F0(this.#D))return 0;return this.#D.exitCode=D||0,this.#F.emit("exit",this.#D.exitCode,null),this.#A.call(this.#D,this.#D.exitCode)}#Z(D,...F){let u=this.#B;if(D==="exit"&&F0(this.#D)){if(typeof F[0]==="number")this.#D.exitCode=F[0];let C=u.call(this.#D,D,...F);return this.#F.emit("exit",this.#D.exitCode,null),C}else return u.call(this.#D,D,...F)}};d0=globalThis.process,{onExit:du,load:u4,unload:C4}=X6(F0(d0)?new cu(d0):new mu)});var Y6="\x1B[G",nu="\x1B[?25l",iu="\x1B[?25h",p0=(D=1)=>D>0?`\x1B[${D}A`:"",n0=(D=1)=>D>0?`\x1B[${D}B`:"",i0=(D,F)=>{if(typeof F==="number"&&!Number.isNaN(F))return`\x1B[${F+1};${D+1}H`;return`\x1B[${D+1}G`},pu="\x1B[2K",a0=(D)=>D>0?(pu+p0(1)).repeat(D-1)+pu+Y6:"";import{stripVTControlCharacters as z6}from"node:util";class u0{height=0;extraLinesUnderPrompt=0;cursorPos;rl;constructor(D){this.rl=D,this.cursorPos=D.getCursorPos()}write(D){this.rl.output.unmute(),this.rl.output.write(D),this.rl.output.mute()}render(D,F=""){let u=K6(D),C=z6(u),E=C;if(this.rl.line.length>0)E=E.slice(0,-this.rl.line.length);this.rl.setPrompt(E),this.cursorPos=this.rl.getCursorPos();let A=D0();if(D=RF(D,A),F=RF(F,A),C.length%A===0)D+=`
15
- `;let $=D+(F?`
16
- `+F:""),Y=Math.floor(C.length/A)-this.cursorPos.rows+(F?au(F):0);if(Y>0)$+=p0(Y);$+=i0(this.cursorPos.cols),this.write(n0(this.extraLinesUnderPrompt)+a0(this.height)+$),this.extraLinesUnderPrompt=Y,this.height=au($)}checkCursorPos(){let D=this.rl.getCursorPos();if(D.cols!==this.cursorPos.cols)this.write(i0(D.cols)),this.cursorPos=D}done({clearContent:D}){this.rl.setPrompt("");let F=n0(this.extraLinesUnderPrompt);F+=D?a0(this.height):`
17
- `,F+=iu,this.write(F),this.rl.close()}}var au=(D)=>D.split(`
18
- `).length,K6=(D)=>D.split(`
19
- `).pop()??"";var ru=M(()=>{h0()});var r0;var tu=M(()=>{r0=class r0 extends Promise{static withResolver(){let D,F;return{promise:new Promise((C,E)=>{D=C,F=E}),resolve:D,reject:F}}}});import*as su from"node:readline";import{AsyncResource as _6}from"node:async_hooks";function W6(){let D=Error.prepareStackTrace,F=[];try{Error.prepareStackTrace=(u,C)=>{let E=C.slice(1);return F=E,E},Error().stack}catch{return F}return Error.prepareStackTrace=D,F}function jF(D){let F=W6();return(C,E={})=>{let{input:A=process.stdin,signal:$}=E,Q=new Set,Y=new ou.default;Y.pipe(E.output??process.stdout);let J=su.createInterface({terminal:!0,input:A,output:Y}),X=new u0(J),{promise:Z,resolve:B,reject:G}=r0.withResolver(),z=()=>G(new R0);if($){let O=()=>G(new w0({cause:$.reason}));if($.aborted)return O(),Object.assign(Z,{cancel:z});$.addEventListener("abort",O),Q.add(()=>$.removeEventListener("abort",O))}Q.add(du((O,_)=>{G(new nF(`User force closed the prompt with ${O} ${_}`))}));let T=()=>G(new nF("User force closed the prompt with SIGINT"));J.on("SIGINT",T),Q.add(()=>J.removeListener("SIGINT",T));let W=()=>X.checkCursorPos();return J.input.on("keypress",W),Q.add(()=>J.input.removeListener("keypress",W)),Fu(J,(O)=>{let _=_6.bind(()=>zD.clearAll());return J.on("close",_),Q.add(()=>J.removeListener("close",_)),O(()=>{try{let V=D(C,(h)=>{setImmediate(()=>B(h))});if(V===void 0){let h=F[1]?.getFileName();throw Error(`Prompt functions must return a string.
20
- at ${h}`)}let[w,q]=typeof V==="string"?[V]:V;X.render(w,q),zD.run()}catch(V){G(V)}}),Object.assign(Z.then((V)=>{return zD.clearAll(),V},(V)=>{throw zD.clearAll(),V}).finally(()=>{Q.forEach((V)=>V()),X.done({clearContent:Boolean(E.clearPromptOnDone)}),Y.end()}).then(()=>Z),{cancel:z})})}}var ou;var eu=M(()=>{lu();ru();tu();KD();iF();ou=PF(yu(),1)});import{styleText as O6}from"node:util";class AD{separator=O6("dim",Array.from({length:15}).join(nD.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 D3=M(()=>{tF()});var t0=M(()=>{Qu();aF();rF();Gu();sF();Ju();I0();Pu();eu();D3();iF()});var T6,x;var F3=M(()=>{t0();T6={validationFailureMode:"keep"},x=jF((D,F)=>{let{prefill:u="tab"}=D,C=_D(T6,D.theme),[E,A]=d("idle"),[$="",Q]=d(D.default),[Y,J]=d(),[X,Z]=d(""),B=MF({status:E,theme:C});async function G(_){let{required:V,pattern:w,patternError:q="Invalid input"}=D;if(V&&!_)return"You must provide a value";if(w&&!w.test(_))return q;if(typeof D.validate==="function")return await D.validate(_)||"You must provide a valid value";return!0}SF(async(_,V)=>{if(E!=="idle")return;if(HF(_)){let w=X||$;A("loading");let q=await G(w);if(q===!0)Z(w),A("done"),F(w);else{if(C.validationFailureMode==="clear")Z("");else V.write(X);J(q),A("idle")}}else if(VF(_)&&!X)Q(void 0);else if(x0(_)&&!X)Q(void 0),V.clearLine(0),V.write($),Z($);else Z(V.line),J(void 0)}),o((_)=>{if(u==="editable"&&$)_.write($),Z($)},[]);let z=C.style.message(D.message,E),T=X;if(typeof D.transformer==="function")T=D.transformer(X,{isFinal:E==="done"});else if(E==="done")T=C.style.answer(X);let W;if($&&E!=="done"&&!X)W=C.style.defaultAnswer($);let O="";if(Y)O=C.style.error(Y);return[[B,z,W,T].filter((_)=>_!==void 0).join(" "),O]})});import{styleText as kF}from"node:util";function iD(D){return!AD.isSeparator(D)&&!D.disabled}function U6(D){return D.map((F)=>{if(AD.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 N6,e;var u3=M(()=>{t0();tF();N6={icon:{cursor:nD.pointer},style:{disabled:(D)=>kF("dim",`- ${D}`),description:(D)=>kF("cyan",D),keysHelpTip:(D)=>D.map(([F,u])=>`${kF("bold",F)} ${kF("dim",u)}`).join(kF("dim"," • "))},indexMode:"hidden",keybindings:[]};e=jF((D,F)=>{let{loop:u=!0,pageSize:C=7}=D,E=_D(N6,D.theme),{keybindings:A}=E,[$,Q]=d("idle"),Y=MF({status:$,theme:E}),J=WD(),X=!A.includes("vim"),Z=xF(()=>U6(D.choices),[D.choices]),B=xF(()=>{let H=Z.findIndex(iD),R=Z.findLastIndex(iD);if(H===-1)throw new qF("[select prompt] No selectable choices. All choices are disabled.");return{first:H,last:R}},[Z]),G=xF(()=>{if(!("default"in D))return-1;return Z.findIndex((H)=>iD(H)&&H.value===D.default)},[D.default,Z]),[z,T]=d(G===-1?B.first:G),W=Z[z];SF((H,R)=>{if(clearTimeout(J.current),HF(H))Q("done"),F(W.value);else if(UF(H,A)||pF(H,A)){if(R.clearLine(0),u||UF(H,A)&&z!==B.first||pF(H,A)&&z!==B.last){let j=UF(H,A)?-1:1,P=z;do P=(P+j+Z.length)%Z.length;while(!iD(Z[P]));T(P)}}else if(S0(H)&&!Number.isNaN(Number(R.line))){let j=Number(R.line)-1,P=-1,c=Z.findIndex((oD)=>{if(AD.isSeparator(oD))return!1;return P++,P===j}),t=Z[c];if(t!=null&&iD(t))T(c);J.current=setTimeout(()=>{R.clearLine(0)},700)}else if(VF(H))R.clearLine(0);else if(X){let j=R.line.toLowerCase(),P=Z.findIndex((c)=>{if(AD.isSeparator(c)||!iD(c))return!1;return c.name.toLowerCase().startsWith(j)});if(P!==-1)T(P);J.current=setTimeout(()=>{R.clearLine(0)},700)}}),o(()=>()=>{clearTimeout(J.current)},[]);let O=E.style.message(D.message,$),_=E.style.keysHelpTip([["↑↓","navigate"],["⏎","select"]]),V=0,w=g0({items:Z,active:z,renderItem({item:H,isActive:R,index:j}){if(AD.isSeparator(H))return V++,` ${H.separator}`;let P=E.indexMode==="number"?`${j+1-V}. `:"";if(H.disabled){let oD=typeof H.disabled==="string"?H.disabled:"(disabled)";return E.style.disabled(`${P}${H.name} ${oD}`)}let c=R?E.style.highlight:(oD)=>oD,t=R?E.icon.cursor:" ";return c(`${t} ${P}${H.name}`)},pageSize:C,loop:u});if($==="done")return[Y,O,E.style.answer(W.short)].filter(Boolean).join(" ");let{description:q}=W;return`${[[Y,O].filter(Boolean).join(" "),w," ",q?E.style.description(q):"",_].filter(Boolean).join(`
21
- `).trimEnd()}${nu}`})});var C0=M(()=>{F3();u3()});var U3;var V3=M(()=>{U3=["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 $D=({business_id:D="bus_test",product_id:F="pdt_test",subscription_id:u="sub_test",qty:C=1,metadata:E})=>{return{business_id:D,data:{addons:[],billing:{city:"New York",country:"US",state:"New York",street:"11th Main",zipcode:"12345"},cancel_at_next_billing_date:!1,cancelled_at:null,created_at:new Date().toISOString(),currency:"USD",customer:{customer_id:"cus_123456",email:"test@acme.com",name:"Test user",phone_number:null},discount_cycles_remaining:null,discount_id:null,expires_at:null,metadata:E,meters:[],next_billing_date:new Date(new Date().setMonth(new Date().getMonth()+1)),on_demand:!1,payload_type:"Subscription",payment_frequency_count:1,payment_frequency_interval:"Month",previous_billing_date:new Date().toISOString(),product_id:F,quantity:C,recurring_pre_tax_amount:400,status:"active",subscription_id:u,subscription_period_count:10,subscription_period_interval:"Year",tax_inclusive:!1,trial_period_days:0},timestamp:new Date().toISOString()}},H3=(D)=>{return{...$D(D),type:"subscription.active"}},q3=(D)=>{let F=$D(D);return{...F,type:"subscription.updated",data:{...F.data,status:"active"}}},M3=(D)=>{let F=$D(D);return{...F,type:"subscription.on_hold",data:{...F.data,status:"on_hold"}}},x3=(D)=>{return{...$D(D),type:"subscription.renewed"}},S3=(D)=>{let F=$D(D);return{...F,type:"subscription.plan_changed",data:{...F.data,status:"active"}}},w3=(D)=>{let F=$D(D);return{...F,type:"subscription.cancelled",data:{...F.data,cancel_at_next_billing_date:!0,status:"cancelled"}}},R3=(D)=>{let F=$D(D);return{...F,type:"subscription.failed",data:{...F.data,status:"failed"}}},j3=(D)=>{let F=$D(D);return{...F,type:"subscription.expired",data:{...F.data,status:"expired"}}};var k3=()=>{};var Q0=({business_id:D="bus_test",product_id:F="pdt_test",qty:u=1})=>{return{business_id:D,data:{billing:{city:"New York",country:"US",state:"New York",street:"New York, New York",zipcode:"12345"},brand_id:D,business_id:D,card_issuing_country:"GB",card_last_four:"4242",card_network:"VISA",card_type:"CREDIT",checkout_session_id:"cks_123",created_at:new Date().toISOString(),currency:"USD",customer:{customer_id:"cus_test",email:"test@acme.com",metadata:{},name:"Test user",phone_number:"+15555550100"},digital_products_delivered:!1,discount_id:null,disputes:[],error_code:null,error_message:null,invoice_id:"inv_test",metadata:{},payload_type:"Payment",payment_id:"pay_test",payment_link:"https://test.checkout.dodopayments.com/cbq",payment_method:"card",payment_method_type:"card",product_cart:[{product_id:F,quantity:u}],refunds:[],settlement_amount:400,settlement_currency:"USD",settlement_tax:null,status:"succeeded",subscription_id:null,tax:null,total_amount:400,updated_at:null},timestamp:new Date().toISOString()}},L3=(D)=>{return{...Q0(D),type:"payment.succeeded"}},I3=(D)=>{return{...Q0(D),type:"payment.failed"}},f3=(D)=>{return{...Q0(D),type:"payment.processing"}},P3=(D)=>{return{...Q0(D),type:"payment.cancelled"}};var b3=()=>{};var v3=({business_id:D="bus_test"})=>{return{business_id:D,data:{amount:400,business_id:D,created_at:new Date().toISOString(),currency:"USD",customer:{customer_id:"cus_test",email:"test@acme.com",name:"Test user",phone_number:null},is_partial:!1,payload_type:"Refund",payment_id:"pay_test",reason:"Testing success refund",refund_id:"ref_test",status:"succeeded"},timestamp:new Date().toISOString()}},y3=(D)=>{return{...v3(D),type:"refund.succeeded"}},h3=(D)=>{return{...v3(D),type:"refund.failed"}};var g3=()=>{};var UD=({business_id:D="bus_test"})=>{return{business_id:D,data:{amount:400,business_id:D,created_at:new Date().toISOString(),currency:"USD",customer:{customer_id:"cus_test",email:"test@acme.com",name:"Test user",phone_number:"+447700900123"},dispute_id:"dp_test",dispute_stage:"dispute",dispute_status:"dispute_opened",payload_type:"Dispute",payment_id:"pay_test",reason:"testing dispute",remarks:null},timestamp:new Date().toISOString()}},m3=(D)=>{let F=UD(D);return{...F,type:"dispute.opened",data:{...F.data,dispute_status:"dispute_opened"}}},c3=(D)=>{let F=UD(D);return{...F,type:"dispute.expired",data:{...F.data,dispute_status:"dispute_expired"}}},d3=(D)=>{let F=UD(D);return{...F,type:"dispute.accepted",data:{...F.data,dispute_status:"dispute_accepted"}}},l3=(D)=>{let F=UD(D);return{...F,type:"dispute.cancelled",data:{...F.data,dispute_status:"dispute_cancelled"}}},p3=(D)=>{let F=UD(D);return{...F,type:"dispute.challenged",data:{...F.data,dispute_status:"dispute_challenged"}}},n3=(D)=>{let F=UD(D);return{...F,type:"dispute.won",data:{...F.data,dispute_status:"dispute_won"}}},i3=(D)=>{let F=UD(D);return{...F,type:"dispute.lost",data:{...F.data,dispute_status:"dispute_lost"}}};var a3=()=>{};var E1=({business_id:D="bus_test",product_id:F="pdt_test",subscription_id:u})=>{return{business_id:D,data:{activations_limit:null,business_id:D,created_at:new Date().toISOString(),customer_id:"cus_test",expires_at:null,id:"lic_test",instances_count:0,key:"db44b22c-fe9b-4a68-bf0d-b0e0d6c6c8c0",payload_type:"LicenseKey",payment_id:"pay_test",product_id:F,status:"active",subscription_id:u},timestamp:new Date().toISOString()}},r3=(D)=>{return{...E1(D),type:"license_key.created"}};var t3=()=>{};var $1={};var B1,IF,X2,A1;var s3=M(async()=>{C0();V3();k3();b3();g3();a3();t3();B1=await x({message:"What is your endpoint?",validate:(D)=>{if(!D.startsWith("http"))return"Please enter a valid URL starting with http or https";return!0}}),IF=await x({message:"What is your Dodo Payments business ID? (Optional)",default:"bus_test"}),X2=await x({message:"What is your product ID? (Optional)",default:"pdt_test"}),A1=await x({message:"What is your metadata? (JSON stringified, Optional)",default:"{}"});while(!0){let D=await e({message:"Select an event to send:",choices:[...U3,"exit"].map((C)=>({value:C,name:C})),loop:!1});if(D==="exit")console.log("Exiting..."),process.exit();let F,u=JSON.parse(A1);if(D.startsWith("subscription.")){let C={business_id:IF,product_id:X2,metadata:u};if(D==="subscription.active")F=H3(C);else if(D==="subscription.updated")F=q3(C);else if(D==="subscription.on_hold")F=M3(C);else if(D==="subscription.renewed")F=x3(C);else if(D==="subscription.plan_changed")F=S3(C);else if(D==="subscription.cancelled")F=w3(C);else if(D==="subscription.failed")F=R3(C);else if(D==="subscription.expired")F=j3(C)}if(D.startsWith("payment.")){let C={business_id:IF,product_id:X2,metadata:u};if(D==="payment.success")F=L3(C);else if(D==="payment.failed")F=I3(C);else if(D==="payment.processing")F=f3(C);else if(D==="payment.cancelled")F=P3(C)}if(D.startsWith("refund.")){let C={business_id:IF};if(D==="refund.success")F=y3(C);else if(D==="refund.failed")F=h3(C)}if(D.startsWith("dispute.")){let C={business_id:IF};if(D==="dispute.opened")F=m3(C);else if(D==="dispute.expired")F=c3(C);else if(D==="dispute.accepted")F=d3(C);else if(D==="dispute.cancelled")F=l3(C);else if(D==="dispute.challenged")F=p3(C);else if(D==="dispute.won")F=n3(C);else if(D==="dispute.lost")F=i3(C)}if(D.startsWith("licence.")){let C={business_id:IF,product_id:X2};if(D==="licence.created")F=r3(C)}await fetch(B1,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)}).then(async(C)=>{console.log(`✅ Webhook Event Sent!
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 Z1 from"node:os";import VD from"node:path";function MD(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 FD(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 X0=function(){let{crypto:D}=globalThis;if(D?.randomUUID)return X0=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 _2(D){return typeof D==="object"&&D!==null&&(("name"in D)&&D.name==="AbortError"||("message"in D)&&String(D.message).includes("FetchRequestCanceledException"))}var eD=(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 g extends Error{}class v extends g{constructor(D,F,u,C){super(`${v.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 QD({message:u,cause:eD(F)});let E=F;if(D===400)return new FF(D,E,u,C);if(D===401)return new uF(D,E,u,C);if(D===403)return new CF(D,E,u,C);if(D===404)return new EF(D,E,u,C);if(D===409)return new BF(D,E,u,C);if(D===422)return new AF(D,E,u,C);if(D===429)return new $F(D,E,u,C);if(D>=500)return new ZF(D,E,u,C);return new v(D,E,u,C)}}class xD extends v{constructor({message:D}={}){super(void 0,void 0,D||"Request was aborted.",void 0)}}class QD extends v{constructor({message:D,cause:F}){super(void 0,void 0,D||"Connection error.",void 0);if(F)this.cause=F}}class DF extends QD{constructor({message:D}={}){super({message:D??"Request timed out."})}}class FF extends v{}class uF extends v{}class CF extends v{}class EF extends v{}class BF extends v{}class AF extends v{}class $F extends v{}class ZF extends v{}var A8=/^[a-z][a-z0-9+.-]*:/i,W2=(D)=>{return A8.test(D)},Y0=(D)=>(Y0=Array.isArray,Y0(D)),z0=Y0;function K0(D){if(typeof D!=="object")return{};return D??{}}function O2(D){if(!D)return!0;for(let F in D)return!1;return!0}function T2(D,F){return Object.prototype.hasOwnProperty.call(D,F)}var N2=(D,F)=>{if(typeof F!=="number"||!Number.isInteger(F))throw new g(`${D} must be an integer`);if(F<0)throw new g(`${D} must be a positive integer`);return F};var U2=(D)=>{try{return JSON.parse(D)}catch(F){return}};var V2=(D)=>new Promise((F)=>setTimeout(F,D));var uD="2.19.0";function $8(){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 Z8=()=>{let D=$8();if(D==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":uD,"X-Stainless-OS":q2(Deno.build.os),"X-Stainless-Arch":H2(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":uD,"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":uD,"X-Stainless-OS":q2(globalThis.process.platform??"unknown"),"X-Stainless-Arch":H2(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let F=Q8();if(F)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":uD,"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":uD,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function Q8(){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,A=C[2]||0,$=C[3]||0;return{browser:F,version:`${E}.${A}.${$}`}}}return null}var H2=(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"},q2=(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"},M2,x2=()=>{return M2??(M2=Z8())};function S2(){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 G8(...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 _0(D){let F=Symbol.asyncIterator in D?D[Symbol.asyncIterator]():D[Symbol.iterator]();return G8({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 w2(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 R2=({headers:D,body:F})=>{return{bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(F)}};var vF={off:0,error:200,warn:300,info:400,debug:500},W0=(D,F,u)=>{if(!D)return;if(T2(vF,D))return D;m(u).warn(`${F} was set to ${JSON.stringify(D)}, expected one of ${JSON.stringify(Object.keys(vF))}`);return};function QF(){}function bF(D,F,u){if(!F||vF[D]>vF[u])return QF;else return F[D].bind(F)}var Y8={error:QF,warn:QF,info:QF,debug:QF},j2=new WeakMap;function m(D){let F=D.logger,u=D.logLevel??"off";if(!F)return Y8;let C=j2.get(F);if(C&&C[0]===u)return C[1];let E={error:bF("error",F,u),warn:bF("warn",F,u),info:bF("info",F,u),debug:bF("debug",F,u)};return j2.set(F,[u,E]),E}var s=(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 yF(D,F){let{response:u,requestLogID:C,retryOfRequestLogID:E,startTime:A}=F,$=await(async()=>{if(u.status===204)return null;if(F.options.__binaryResponse)return u;let Y=u.headers.get("content-type")?.split(";")[0]?.trim();if(Y?.includes("application/json")||Y?.endsWith("+json")){if(u.headers.get("content-length")==="0")return;return await u.json()}return await u.text()})();return m(D).debug(`[${C}] response parsed`,s({retryOfRequestLogID:E,url:u.url,status:u.status,body:$,durationMs:Date.now()-A})),$}var GF;class GD extends Promise{constructor(D,F,u=yF){super((C)=>{C(null)});this.responsePromise=F,this.parseResponse=u,GF.set(this,void 0),MD(this,GF,D,"f")}_thenUnwrap(D){return new GD(FD(this,GF,"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(FD(this,GF,"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)}}GF=new WeakMap;var hF;class O0{constructor(D,F,u,C){hF.set(this,void 0),MD(this,hF,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 g("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await FD(this,hF,"f").requestAPIList(this.constructor,D)}async*iterPages(){let D=this;yield D;while(D.hasNextPage())D=await D.getNextPage(),yield D}async*[(hF=new WeakMap,Symbol.asyncIterator)](){for await(let D of this.iterPages())for(let F of D.getPaginatedItems())yield F}}class gF extends GD{constructor(D,F,u){super(D,F,async(C,E)=>new u(C,E.response,await yF(C,E),E.options))}async*[Symbol.asyncIterator](){let D=await this;for await(let F of D)yield F}}class S extends O0{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:{...K0(this.options.query),page_number:F+1}}}}class T0 extends O0{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:{...K0(this.options.query),iterator:D}}}}var N0=()=>{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 mF(D,F,u){return N0(),new File(D,F??"unknown_file",u)}function k2(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 L2=(D)=>D!=null&&typeof D==="object"&&typeof D[Symbol.asyncIterator]==="function";var I2=(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",K8=(D)=>D!=null&&typeof D==="object"&&typeof D.name==="string"&&typeof D.lastModified==="number"&&I2(D),_8=(D)=>D!=null&&typeof D==="object"&&typeof D.url==="string"&&typeof D.blob==="function";async function cF(D,F,u){if(N0(),D=await D,K8(D)){if(D instanceof File)return D;return mF([await D.arrayBuffer()],D.name)}if(_8(D)){let E=await D.blob();return F||(F=new URL(D.url).pathname.split(/[\\/]/).pop()),mF(await U0(E),F,u)}let C=await U0(D);if(F||(F=k2(D)),!u?.type){let E=C.find((A)=>typeof A==="object"&&("type"in A)&&A.type);if(typeof E==="string")u={...u,type:E}}return mF(C,F,u)}async function U0(D){let F=[];if(typeof D==="string"||ArrayBuffer.isView(D)||D instanceof ArrayBuffer)F.push(D);else if(I2(D))F.push(D instanceof Blob?D:await D.arrayBuffer());else if(L2(D))for await(let u of D)F.push(...await U0(u));else{let u=D?.constructor?.name;throw Error(`Unexpected data type: ${typeof D}${u?`; constructor: ${u}`:""}${W8(D)}`)}return F}function W8(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 P2(D){return D.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var f2=Object.freeze(Object.create(null)),T8=(D=P2)=>function(u,...C){if(u.length===1)return u[0];let E=!1,A=[],$=u.reduce((X,Z,B)=>{if(/[?#]/.test(Z))E=!0;let G=C[B],z=(E?encodeURIComponent:D)(""+G);if(B!==C.length&&(G==null||typeof G==="object"&&G.toString===Object.getPrototypeOf(Object.getPrototypeOf(G.hasOwnProperty??f2)??f2)?.toString))z=G+"",A.push({start:X.length+Z.length,length:z.length,error:`Value of type ${Object.prototype.toString.call(G).slice(8,-1)} is not a valid path parameter`});return X+Z+(B===C.length?"":z)},""),Q=$.split(/[?#]/,1)[0],Y=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,J;while((J=Y.exec(Q))!==null)A.push({start:J.index,length:J[0].length,error:`Value "${J[0]}" can't be safely passed as a path parameter`});if(A.sort((X,Z)=>X.start-Z.start),A.length>0){let X=0,Z=A.reduce((B,G)=>{let z=" ".repeat(G.start-X),T="^".repeat(G.length);return X=G.start+G.length,B+z+T},"");throw new g(`Path parameters result in path with invalid segments:
24
- ${A.map((B)=>B.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=T8(P2);class SD 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",S,{query:D,...F})}updateImages(D,F){return this._client.put(K`/addons/${D}/images`,F)}}class wD extends N{retrieveLedger(D={},F){return this._client.getAPIList("/balances/ledger",S,{query:D,...F})}}class RD 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 jD 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 JF 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 XF 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`,S,{query:F,...u})}}class kD extends N{constructor(){super(...arguments);this.ledgerEntries=new XF(this._client)}list(D,F){return this._client.get(K`/customers/${D}/wallets`,F)}}kD.LedgerEntries=XF;class CD extends N{constructor(){super(...arguments);this.customerPortal=new JF(this._client),this.wallets=new kD(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",S,{query:D,...F})}retrievePaymentMethods(D,F){return this._client.get(K`/customers/${D}/payment-methods`,F)}}CD.CustomerPortal=JF;CD.Wallets=kD;var b2=Symbol("brand.privateNullableHeaders");function*H8(D){if(!D)return;if(b2 in D){let{values:C,nulls:E}=D;yield*C.entries();for(let A of E)yield[A,null];return}let F=!1,u;if(D instanceof Headers)u=D.entries();else if(z0(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 A=z0(C[1])?C[1]:[C[1]],$=!1;for(let Q of A){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[A,$]of H8(C)){let Q=A.toLowerCase();if(!E.has(Q))F.delete(A),E.add(Q);if($===null)F.delete(A),u.add(Q);else F.append(A,$),u.delete(Q)}}return{[b2]:!0,values:F,nulls:u}};class LD 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",S,{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 ID extends N{retrieve(D,F){return this._client.get(K`/disputes/${D}`,F)}list(D={},F){return this._client.getAPIList("/disputes",S,{query:D,...F})}}class YF 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 JD extends N{constructor(){super(...arguments);this.payments=new YF(this._client)}}JD.Payments=YF;class fD 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",S,{query:D,...F})}}class PD 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",S,{query:D,...F})}}class bD 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 vD 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",S,{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 yD extends N{listSupportedCountries(D){return this._client.get("/checkout/supported_countries",D)}}class hD 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",S,{query:D,...F})}retrieveLineItems(D,F){return this._client.get(K`/payments/${D}/line-items`,F)}}class gD extends N{list(D={},F){return this._client.getAPIList("/payouts",S,{query:D,...F})}}class zF extends N{update(D,F={},u){let{force_update:C}=F??{};return this._client.put(K`/products/${D}/images`,{query:{force_update:C},...u})}}class KF 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",S,{query:D,...F})}}class ED extends N{constructor(){super(...arguments);this.images=new zF(this._client),this.shortLinks=new KF(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",S,{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})}}ED.Images=zF;ED.ShortLinks=KF;class mD 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",S,{query:D,...F})}}class cD 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",S,{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`,S,{query:F,...u})}updatePaymentMethod(D,F,u){return this._client.post(K`/subscriptions/${D}/update-payment-method`,{body:F,...u})}}class dD extends N{retrieve(D,F){return this._client.get(K`/events/${D}`,F)}list(D={},F){return this._client.getAPIList("/events",S,{query:D,...F})}ingest(D,F){return this._client.post("/events/ingest",{body:D,...F})}}class lD extends N{}class _F 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 s2=PF(t2(),1);class XD extends N{constructor(){super(...arguments);this.headers=new _F(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",T0,{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 s2.Webhook(C).verify(D,F)}return JSON.parse(D)}}XD.Headers=_F;var TF=(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 q0,M0,lF,o2,e2={live_mode:"https://live.dodopayments.com",test_mode:"https://test.dodopayments.com"};class U{constructor({baseURL:D=TF("DODO_PAYMENTS_BASE_URL"),bearerToken:F=TF("DODO_PAYMENTS_API_KEY"),webhookKey:u=TF("DODO_PAYMENTS_WEBHOOK_KEY")??null,...C}={}){if(q0.add(this),lF.set(this,void 0),this.checkoutSessions=new jD(this),this.payments=new hD(this),this.subscriptions=new cD(this),this.invoices=new JD(this),this.licenses=new bD(this),this.licenseKeys=new PD(this),this.licenseKeyInstances=new fD(this),this.customers=new CD(this),this.refunds=new mD(this),this.disputes=new ID(this),this.payouts=new gD(this),this.products=new ED(this),this.misc=new yD(this),this.discounts=new LD(this),this.addons=new SD(this),this.brands=new RD(this),this.webhooks=new XD(this),this.webhookEvents=new lD(this),this.usageEvents=new dD(this),this.meters=new vD(this),this.balances=new wD(this),F===void 0)throw new g("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 g("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||e2[E.environment||"live_mode"],this.timeout=E.timeout??M0.DEFAULT_TIMEOUT,this.logger=E.logger??console;let A="warn";this.logLevel=A,this.logLevel=W0(E.logLevel,"ClientOptions.logLevel",this)??W0(TF("DODO_PAYMENTS_LOG"),"process.env['DODO_PAYMENTS_LOG']",this)??A,this.fetchOptions=E.fetchOptions,this.maxRetries=E.maxRetries??2,this.fetch=E.fetch??S2(),MD(this,lF,R2,"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 g(`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 ${uD}`}defaultIdempotencyKey(){return`stainless-node-retry-${X0()}`}makeStatusError(D,F,u,C){return v.generate(D,F,u,C)}buildURL(D,F,u){let C=!FD(this,q0,"m",o2).call(this)&&u||this.baseURL,E=W2(D)?new URL(D):new URL(C+(C.endsWith("/")&&D.startsWith("/")?D.slice(1):D)),A=this.defaultQuery();if(!O2(A))F={...A,...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 GD(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:A,url:$,timeout:Q}=await this.buildRequest(C,{retryCount:E-F});await this.prepareRequest(A,{url:$,options:C});let Y="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),J=u===void 0?"":`, retryOf: ${u}`,X=Date.now();if(m(this).debug(`[${Y}] sending request`,s({retryOfRequestLogID:u,method:C.method,url:$,options:C,headers:A.headers})),C.signal?.aborted)throw new xD;let Z=new AbortController,B=await this.fetchWithTimeout($,A,Q,Z).catch(eD),G=Date.now();if(B instanceof globalThis.Error){let T=`retrying, ${F} attempts remaining`;if(C.signal?.aborted)throw new xD;let W=_2(B)||/timed? ?out/i.test(String(B)+("cause"in B?String(B.cause):""));if(F)return m(this).info(`[${Y}] connection ${W?"timed out":"failed"} - ${T}`),m(this).debug(`[${Y}] connection ${W?"timed out":"failed"} (${T})`,s({retryOfRequestLogID:u,url:$,durationMs:G-X,message:B.message})),this.retryRequest(C,F,u??Y);if(m(this).info(`[${Y}] connection ${W?"timed out":"failed"} - error; no more retries left`),m(this).debug(`[${Y}] connection ${W?"timed out":"failed"} (error; no more retries left)`,s({retryOfRequestLogID:u,url:$,durationMs:G-X,message:B.message})),W)throw new DF;throw new QD({cause:B})}let z=`[${Y}${J}] ${A.method} ${$} ${B.ok?"succeeded":"failed"} with status ${B.status} in ${G-X}ms`;if(!B.ok){let T=await this.shouldRetry(B);if(F&&T){let q=`retrying, ${F} attempts remaining`;return await w2(B.body),m(this).info(`${z} - ${q}`),m(this).debug(`[${Y}] response error (${q})`,s({retryOfRequestLogID:u,url:B.url,status:B.status,headers:B.headers,durationMs:G-X})),this.retryRequest(C,F,u??Y,B.headers)}let W=T?"error; no more retries left":"error; not retryable";m(this).info(`${z} - ${W}`);let O=await B.text().catch((q)=>eD(q).message),_=U2(O),V=_?void 0:O;throw m(this).debug(`[${Y}] response error (${W})`,s({retryOfRequestLogID:u,url:B.url,status:B.status,headers:B.headers,message:V,durationMs:Date.now()-X})),this.makeStatusError(B.status,_,V,B.headers)}return m(this).info(z),m(this).debug(`[${Y}] response start`,s({retryOfRequestLogID:u,url:B.url,status:B.status,headers:B.headers,durationMs:G-X})),{response:B,options:C,controller:Z,requestLogID:Y,retryOfRequestLogID:u,startTime:X}}getAPIList(D,F,u){return this.requestAPIList(F,u&&"then"in u?u.then((C)=>({method:"get",path:D,...C})):{method:"get",path:D,...u})}requestAPIList(D,F){let u=this.makeRequest(F,null,void 0);return new gF(this,u,D)}async fetchWithTimeout(D,F,u,C){let{signal:E,method:A,...$}=F||{},Q=this._makeAbort(C);if(E)E.addEventListener("abort",Q,{once:!0});let Y=setTimeout(Q,u),J=globalThis.ReadableStream&&$.body instanceof globalThis.ReadableStream||typeof $.body==="object"&&$.body!==null&&Symbol.asyncIterator in $.body,X={signal:C.signal,...J?{duplex:"half"}:{},method:"GET",...$};if(A)X.method=A.toUpperCase();try{return await this.fetch.call(void 0,D,X)}finally{clearTimeout(Y)}}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,A=C?.get("retry-after-ms");if(A){let Q=parseFloat(A);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 V2(E),this.makeRequest(D,F-1,u)}calculateDefaultRetryTimeoutMillis(D,F){let E=F-D,A=Math.min(0.5*Math.pow(2,E),8),$=1-Math.random()*0.25;return A*$*1000}async buildRequest(D,{retryCount:F=0}={}){let u={...D},{method:C,path:E,query:A,defaultBaseURL:$}=u,Q=this.buildURL(E,A,$);if("timeout"in u)N2("timeout",u.timeout);u.timeout=u.timeout??this.timeout;let{bodyHeaders:Y,body:J}=this.buildBody({options:u}),X=await this.buildHeaders({options:D,method:C,bodyHeaders:Y,retryCount:F});return{req:{method:C,headers:X,...u.signal&&{signal:u.signal},...globalThis.ReadableStream&&J instanceof globalThis.ReadableStream&&{duplex:"half"},...J&&{body:J},...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 A=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))}:{},...x2()},await this.authHeaders(D),this._options.defaultHeaders,u,D.headers]);return this.validateHeaders(A),A.values}_makeAbort(D){return()=>D.abort()}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:_0(D)};else return FD(this,lF,"f").call(this,{body:D,headers:u})}}M0=U,lF=new WeakMap,q0=new WeakSet,o2=function(){return this.baseURL!==e2[this._options.environment||"live_mode"]};U.DodoPayments=M0;U.DEFAULT_TIMEOUT=60000;U.DodoPaymentsError=g;U.APIError=v;U.APIConnectionError=QD;U.APIConnectionTimeoutError=DF;U.APIUserAbortError=xD;U.NotFoundError=EF;U.ConflictError=BF;U.RateLimitError=$F;U.BadRequestError=FF;U.AuthenticationError=uF;U.InternalServerError=ZF;U.PermissionDeniedError=CF;U.UnprocessableEntityError=AF;U.toFile=cF;U.CheckoutSessions=jD;U.Payments=hD;U.Subscriptions=cD;U.Invoices=JD;U.Licenses=bD;U.LicenseKeys=PD;U.LicenseKeyInstances=fD;U.Customers=CD;U.Refunds=mD;U.Disputes=ID;U.Payouts=gD;U.Products=ED;U.Misc=yD;U.Discounts=LD;U.Addons=SD;U.Brands=RD;U.Webhooks=XD;U.WebhookEvents=lD;U.UsageEvents=dD;U.Meters=vD;U.Balances=wD;C0();import Q2 from"node:process";import N3 from"node:path";import{fileURLToPath as e6}from"node:url";import D1 from"node:child_process";import F1,{constants as u1}from"node:fs/promises";import{promisify as L6}from"node:util";import I6 from"node:child_process";import F2,{constants as Q3}from"node:fs/promises";import B3 from"node:process";import x6 from"node:os";import S6 from"node:fs";import q6 from"node:fs";import C3 from"node:fs";var s0;function V6(){try{return C3.statSync("/.dockerenv"),!0}catch{return!1}}function H6(){try{return C3.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function o0(){if(s0===void 0)s0=V6()||H6();return s0}var e0,M6=()=>{try{return q6.statSync("/run/.containerenv"),!0}catch{return!1}};function aD(){if(e0===void 0)e0=M6()||o0();return e0}var E3=()=>{if(B3.platform!=="linux")return!1;if(x6.release().toLowerCase().includes("microsoft")){if(aD())return!1;return!0}try{return S6.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!aD():!1}catch{return!1}},DD=B3.env.__IS_WSL_TEST__?E3:E3();import A3 from"node:process";import{Buffer as w6}from"node:buffer";import{promisify as R6}from"node:util";import j6 from"node:child_process";var k6=R6(j6.execFile),D2=()=>`${A3.env.SYSTEMROOT||A3.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;var n=async(D,F={})=>{let{powerShellPath:u,...C}=F,E=n.encodeCommand(D);return k6(u??D2(),[...n.argumentsPrefix,E],{encoding:"utf8",...C})};n.argumentsPrefix=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"];n.encodeCommand=(D)=>w6.from(D,"utf16le").toString("base64");n.escapeArgument=(D)=>`'${String(D).replaceAll("'","''")}'`;function $3(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 f6=L6(I6.execFile),P6=(()=>{let F;return async function(){if(F)return F;let u="/etc/wsl.conf",C=!1;try{await F2.access(u,Q3.F_OK),C=!0}catch{}if(!C)return"/mnt/";let E=await F2.readFile(u,{encoding:"utf8"}),A=$3(E);if(A===void 0)return"/mnt/";return F=A,F=F.endsWith("/")?F:`${F}/`,F}})(),b6=async()=>{return`${await P6()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`},E0=DD?b6:D2,Z3,G3=async()=>{return Z3??=(async()=>{try{let D=await E0();return await F2.access(D,Q3.X_OK),!0}catch{return!1}})(),Z3},J3=async()=>{let D=await E0(),F=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:u}=await n(F,{powerShellPath:D});return u.trim()},X3=async(D)=>{if(/^[a-z]+:\/\//i.test(D))return D;try{let{stdout:F}=await f6("wslpath",["-aw",D],{encoding:"utf8"});return F.trim()}catch{return D}};function ND(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 a6}from"node:util";import A2 from"node:process";import{execFile as r6}from"node:child_process";import{promisify as v6}from"node:util";import y6 from"node:process";import{execFile as h6}from"node:child_process";var g6=v6(h6);async function u2(){if(y6.platform!=="darwin")throw Error("macOS only");let{stdout:D}=await g6("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 m6 from"node:process";import{promisify as c6}from"node:util";import{execFile as d6,execFileSync as q9}from"node:child_process";var l6=c6(d6);async function Y3(D,{humanReadableOutput:F=!0,signal:u}={}){if(m6.platform!=="darwin")throw Error("macOS only");let C=F?[]:["-ss"],E={};if(u)E.signal=u;let{stdout:A}=await l6("osascript",["-e",D,C],E);return A.trim()}async function C2(D){return Y3(`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 p6}from"node:util";import{execFile as n6}from"node:child_process";var i6=p6(n6),z3={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"}},B0=new Map(Object.entries(z3));class E2 extends Error{}async function B2(D=i6){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 E2(`Cannot find Windows browser in stdout: ${JSON.stringify(F)}`);let{id:C}=u.groups,E=z3[C];if(!E)throw new E2(`Unknown browser ID: ${C}`);return E}var t6=a6(r6),s6=(D)=>D.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,(F)=>F.toUpperCase());async function $2(){if(A2.platform==="darwin"){let D=await u2();return{name:await C2(D),id:D}}if(A2.platform==="linux"){let{stdout:D}=await t6("xdg-mime",["query","default","x-scheme-handler/http"]),F=D.trim();return{name:s6(F.replace(/.desktop$/,"").replace("-"," ")),id:F}}if(A2.platform==="win32")return B2();throw Error("Only macOS, Linux, and Windows are supported")}import Z2 from"node:process";var o6=Boolean(Z2.env.SSH_CONNECTION||Z2.env.SSH_CLIENT||Z2.env.SSH_TTY),K3=o6;var A0=Symbol("fallbackAttempt"),G2=import.meta.url?N3.dirname(e6(import.meta.url)):"",_3=N3.join(G2,"xdg-open"),{platform:rD,arch:W3}=Q2,O3=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")},$0=async(D)=>{D={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...D};let F=D[A0]===!0;if(delete D[A0],Array.isArray(D.app))return O3(D.app,(J)=>$0({...D,app:J,[A0]:!0}));let{name:u,arguments:C=[]}=D.app??{};if(C=[...C],Array.isArray(u))return O3(u,(J)=>$0({...D,app:{name:J,arguments:C},[A0]:!0}));if(u==="browser"||u==="browserPrivate"){let J={"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"},X={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},Z;if(DD){let B=await J3();Z=B0.get(B)??{}}else Z=await $2();if(Z.id in J){let B=J[Z.id.toLowerCase()];if(u==="browserPrivate"){if(B==="safari")throw Error("Safari doesn't support opening in private mode via command line");C.push(X[B])}return $0({...D,app:{name:tD[B],arguments:C}})}throw Error(`${Z.name} is not supported as a default browser`)}let E,A=[],$={},Q=!1;if(DD&&!aD()&&!K3&&!u)Q=await G3();if(rD==="darwin"){if(E="open",D.wait)A.push("--wait-apps");if(D.background)A.push("--background");if(D.newInstance)A.push("--new");if(u)A.push("-a",u)}else if(rD==="win32"||Q){if(E=await E0(),A.push(...n.argumentsPrefix),!DD)$.windowsVerbatimArguments=!0;if(DD&&D.target)D.target=await X3(D.target);let J=["$ProgressPreference = 'SilentlyContinue';","Start"];if(D.wait)J.push("-Wait");if(u){if(J.push(n.escapeArgument(u)),D.target)C.push(D.target)}else if(D.target)J.push(n.escapeArgument(D.target));if(C.length>0)C=C.map((X)=>n.escapeArgument(X)),J.push("-ArgumentList",C.join(","));if(D.target=n.encodeCommand(J.join(" ")),!D.wait)$.stdio="ignore"}else{if(u)E=u;else{let J=!G2||G2==="/",X=!1;try{await F1.access(_3,u1.X_OK),X=!0}catch{}E=Q2.versions.electron??(rD==="android"||J||!X)?"xdg-open":_3}if(C.length>0)A.push(...C);if(!D.wait)$.stdio="ignore",$.detached=!0}if(rD==="darwin"&&C.length>0)A.push("--args",...C);if(D.target)A.push(D.target);let Y=D1.spawn(E,A,$);if(D.wait)return new Promise((J,X)=>{Y.once("error",X),Y.once("close",(Z)=>{if(!D.allowNonzeroExitCode&&Z!==0){X(Error(`Exited with code ${Z}`));return}J(Y)})});if(F)return new Promise((J,X)=>{Y.once("error",X),Y.once("spawn",()=>{Y.once("close",(Z)=>{if(Y.off("error",X),Z!==0){X(Error(`Exited with code ${Z}`));return}Y.unref(),J(Y)})})});return Y.unref(),new Promise((J,X)=>{Y.once("error",X),Y.once("spawn",()=>{Y.off("error",X),J(Y)})})},C1=(D,F)=>{if(typeof D!=="string")throw TypeError("Expected a `target`");return $0({...F,target:D})};function T3(D){if(typeof D==="string"||Array.isArray(D))return D;let{[W3]:F}=D;if(!F)throw Error(`${W3} is not supported`);return F}function LF({[rD]:D},{wsl:F}={}){if(F&&DD)return T3(F);if(!D)throw Error(`${rD} is not supported`);return T3(D)}var tD={browser:"browser",browserPrivate:"browserPrivate"};ND(tD,"chrome",()=>LF({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"]}}));ND(tD,"brave",()=>LF({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"]}}));ND(tD,"firefox",()=>LF({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));ND(tD,"edge",()=>LF({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));ND(tD,"safari",()=>LF({darwin:"Safari"}));var Z0=C1;var a={USD:"$",INR:"₹",EUR:"€",GBP:"£"};import HD from"node:fs";C0();async function J2({API_KEY:D,DodoClient:F}){let u=await x({message:"Enter the endpoint URL: "}),C;if(process.env.DODO_WH_TEST_SERVER_URL)C=`https://${process.env.DODO_WH_TEST_SERVER_URL}/`;else C="https://wsserver.dodopayments.tech/";let E=!1;if((await F.webhooks.list({limit:100})).data.forEach((Y)=>{if(Y.url===C)E=!0}),!E)await F.webhooks.create({url:C,description:"This webhook as been automatically added by Dodo Payments CLI for testing webhooks"});let $;if(process.env.DODO_WH_TEST_SERVER_URL)$=`wss://${process.env.DODO_WH_TEST_SERVER_URL}/connect`;else $="wss://wsserver.dodopayments.tech/connect";let Q=new WebSocket($,{headers:{"api-key":D}});Q.onopen=()=>{console.log("Successfully connected to Dodo Payments CLI Webhook Server ✅")},Q.onmessage=async(Y)=>{try{let J=JSON.parse(Y.data.toString());if(J.requestId){console.log("Received webhook!"),console.log("Event Type:",J.payload.type);let X=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json",...J.headers},body:JSON.stringify(J.payload)}),Z=await X.text(),B;try{B=JSON.parse(Z)}catch(z){B=Z}let G={};X.headers.forEach((z,T)=>{G[T]=z}),console.log("Status:",X.status),console.log("Response:",B),console.log(),Q.send(JSON.stringify({type:"webhook_response",requestId:J.requestId,status:X.status,body:B,headers:G}))}}catch(J){console.error("Failed to parse or respond to message",J)}},Q.onclose=(Y)=>{console.log("Disconnected from Dodo Payments CLI Webhook Server"),console.log("Reason:",Y.reason),console.log("Code:",Y.code)},Q.onerror=(Y)=>{console.log("Error in Dodo Payments CLI Webhook Server:",Y)}}var l={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 Q1=`
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
- `;function sD(D){return typeof D==="object"&&D!==null&&"error"in D&&typeof D.error?.code==="string"}var e3=process.argv,y=e3[2],I=e3[3],qD=Z1.homedir(),Y2=()=>{console.log(Q1),Object.keys(l).forEach((D)=>{console.log(`Category: ${D}`),l[D].forEach((F)=>{console.log(`dodo ${D} ${F.command} - ${F.description}`)}),console.log("")})};if(y==="login"){Z0("https://app.dodopayments.com/developer/api-keys");let D=await x({message:"Enter your Dodo Payments API Key:",required:!0}),F=await e({choices:[{name:"Test Mode",value:"test_mode"},{name:"Live Mode",value:"live_mode"}],message:"Choose the environment:"}),u=new U({bearerToken:D,environment:F});console.log("Verifying Dodo Payments API Key");try{await u.products.list({page_size:1}),console.log("Successfully verified your Dodo Payments API Key!")}catch(E){console.log("Something went wrong while authenticating, please check your API key!"),process.exit(1)}console.log("Storing / Updating existing configuration...");let C;try{C=JSON.parse(HD.readFileSync(VD.join(qD,".dodopayments","api-key"),"utf-8"))}catch{C={}}if(C[F]=D,!HD.existsSync(VD.join(qD,".dodopayments")))HD.mkdirSync(VD.join(qD,".dodopayments"));HD.writeFileSync(VD.join(qD,".dodopayments","api-key"),JSON.stringify(C)),console.log("Setup complete successfully!"),process.exit(0)}if(!HD.existsSync(VD.join(qD,".dodopayments","api-key")))if(y&&I)console.log("Please login using `dodo login` command first!"),process.exit(0);else if(y){if(y in l)console.log(`Category: ${y}`),l[y].forEach((D)=>{console.log(`dodo ${y} ${D.command} - ${D.description}`)}),console.log("\nPlease login using `dodo login` command first!");else Y2();process.exit(0)}else Y2(),console.log("Please login using `dodo login` command first!"),process.exit(0);var G0;try{G0=JSON.parse(HD.readFileSync(VD.join(qD,".dodopayments","api-key"),"utf-8"))}catch{HD.rmSync(VD.join(qD,".dodopayments","api-key"),{force:!0}),console.log("Failed to decode API Key configuration. Your config has been reset. Please log in again using `dodo login`"),process.exit(0)}var J0,fF,o3=Object.keys(G0);if(o3.length===1)fF=o3[0],J0=G0[fF];else fF=await e({choices:[{name:"Test Mode",value:"test_mode"},{name:"Live Mode",value:"live_mode"}],message:"Choose the environment:"}),J0=G0[fF];var b=new U({bearerToken:J0,environment:fF});if(y==="products")if(I==="list"){let D=await x({message:"Enter page:",default:"1",validate:(C)=>C.trim()!==""}),u=(await b.products.list({page_number:parseInt(D)-1,page_size:100})).items.map((C)=>({name:C.name,"product id":C.product_id,created_at:new Date(C.created_at).toLocaleString(),...C.is_recurring?{price:`${a[C.price_detail.currency]||C.price_detail.currency+" "}${(C.price*0.01).toFixed(2)} Every ${C.price_detail.payment_frequency_count} ${C.price_detail?.payment_frequency_interval}`}:{price:`${a[C.price_detail.currency]||C.price_detail.currency+" "}${(C.price*0.01).toFixed(2)} (One Time)`}}));console.table(u),console.log("To edit a product, go to https://app.dodopayments.com/products/edit?id={product_id}")}else if(I==="create")Z0("https://app.dodopayments.com/products/create");else if(I==="info")try{let D=await x({message:"Enter product ID:",validate:(u)=>u.startsWith("pdt_")||"Please enter a valid product ID!"}),F=await b.products.retrieve(D);console.table({"product id":F.product_id,name:F.name,...F.description?.trim()!==""&&{description:F.description},created_at:new Date(F.created_at).toLocaleString(),updated_at:new Date(F.updated_at).toLocaleString(),...F.is_recurring?{price:`${a[F.price.currency]||F.price.currency+" "}${((F.price.price||F.price.fixed_price)*0.01).toFixed(2)} Every ${F.price.payment_frequency_count} ${F.price.payment_frequency_interval}`}:{price:`${a[F.price.currency]||F.price.currency+" "}${(F.price.price*0.01).toFixed(2)} (One Time)`},tax_category:F.tax_category}),console.log(`To edit the product, go to https://app.dodopayments.com/products/edit?id=${F.product_id}`)}catch(D){if(sD(D)&&D.error.code==="NOT_FOUND")console.log("Incorrect product ID!");else console.error(D)}else l.products.forEach((D)=>{console.log(`dodo products ${D.command} - ${D.description}`)});else if(y==="payments")if(I==="list"){let D=await x({message:"Enter page:",default:"1",validate:(C)=>C.trim()!==""}),u=(await b.payments.list({page_number:parseInt(D)-1,page_size:100})).items.map((C)=>{return{"payment id":C.payment_id,"created at":new Date(C.created_at).toLocaleString(),"subscription id":C.subscription_id,"total amount":`${a[C.currency]||C.currency+" "}${(C.total_amount*0.01).toFixed(2)}`,status:C.status}});console.table(u),console.log("To view a payment, go to https://app.dodopayments.com/transactions/payments/{payment_id}")}else if(I==="info")try{let F=await b.payments.retrieve("pay_0NWiGvZPWxeWeNWISbfat");console.log(F);let u={"payment id":F.payment_id,status:F.status,"total amount":`${a[F.currency]||F.currency+" "}${(F.total_amount*0.01).toFixed(2)}`,"payment method":F.payment_method,createdAt:new Date(F.created_at).toLocaleString(),customer:F.customer.customer_id,"customer email":F.customer.email,...F.subscription_id&&{"subscription id":F.subscription_id},"billing address street":`${F.billing.street}`,"billing address state":`${F.billing.state}`,"billing address city":`${F.billing.city}`,"billing address country":`${F.billing.country}`,"billing address zipcode":`${F.billing.zipcode}`};console.table(u),console.log(`To view the payment, go to https://app.dodopayments.com/transactions/payments/${F.payment_id}`)}catch(D){if(sD(D)&&D.error.code==="NOT_FOUND")console.log("Incorrect payment ID!");else console.error(D)}else l.payments.forEach((D)=>{console.log(`dodo payments ${D.command} - ${D.description}`)});else if(y==="customers")if(I==="list"){let D=await x({message:"Enter page:",default:"1",validate:(F)=>F.trim()!==""});console.table((await b.customers.list({page_number:parseInt(D)-1,page_size:100})).items,["customer_id","name","email","phone_number"])}else if(I==="create"){let D=await x({message:"Enter Name: ",validate:(E)=>E.trim()!==""}),F=await x({message:"Enter Email: ",validate:(E)=>E.trim()!==""}),u=await x({message:"Enter Phone Number: "}),C=await b.customers.create({name:D,email:F,phone_number:u.trim()!==""?u:null});console.log("Customer Successfully Created!"),console.table([C],["customer_id","name","email","phone_number"])}else if(I==="update"){let D=await x({message:"Enter customer ID:",validate:(F)=>F.startsWith("cus_")||"Please enter a valid customer ID!"});try{let F=await b.customers.retrieve(D),u=await x({message:"Enter customer name:",default:F.name}),C=await x({message:"Enter customer phone:",default:F.phone_number?.toString()}),E=await b.customers.update(D,{name:u,phone_number:C.trim()!==""?C:null});console.table([E],["customer_id","name","email","phone_number"])}catch(F){if(sD(F)&&F.error.code==="NOT_FOUND")console.log("Incorrect customer ID!");else console.error(F)}}else l.customers.forEach((D)=>{console.log(`dodo customers ${D.command} - ${D.description}`)});else if(y==="discounts")if(I==="list"){let D=await x({message:"Enter page:",default:"1",validate:(C)=>C.trim()!==""}),u=(await b.discounts.list({page_number:parseInt(D)-1,page_size:100})).items.map((C)=>({name:C.name,code:C.code,"discount id":C.discount_id,"created at":new Date(C.created_at).toLocaleString(),...C.type==="percentage"?{amount:`${(C.amount*0.01).toFixed(2)}%`}:{amount:C.amount}}));console.table(u),console.log("To view a discount, go to https://app.dodopayments.com/sales/discounts/edit?id={discount_id}")}else if(I==="create"){let D=await x({message:"Enter discount name:",validate:(A)=>A.trim()!==""}),F=await x({message:"Enter discount percentage:",validate:(A)=>{let $=parseFloat(A);if(!Number.isNaN($)&&$>0&&$<=100)return!0;else return!1}}),u=await x({message:"Enter discount code (Optional):"}),C=await x({message:"Enter discount cycles (Optional):"}),E=await b.discounts.create({name:D,code:u.trim()!==""?u:null,amount:parseFloat(F)*100,type:"percentage",...C.trim()!==""&&{subscription_cycles:parseInt(C)}});console.log("Discount created successfully!"),console.table({name:E.name,code:E.code,"discount id":E.discount_id,...C.trim()!==""&&{"subscription cycles":E.subscription_cycles}})}else if(I==="delete")await b.discounts.delete(await x({message:"Enter discount ID to be deleted:",validate:(D)=>D.startsWith("dsc_")})),console.log("Successfully deleted discount!");else l.discounts.forEach((D)=>{console.log(`dodo discounts ${D.command} - ${D.description}`)});else if(y==="licences")if(I==="list"){let D=await x({message:"Enter page:",default:"1",validate:(u)=>u.trim()!==""}),F=await b.licenseKeys.list({page_number:parseInt(D)-1,page_size:100});console.log(F.items)}else l.licences.forEach((D)=>{console.log(`dodo licences ${D.command} - ${D.description}`)});else if(y==="addons")if(I==="create")Z0("https://app.dodopayments.com/products/create/add-on");else if(I==="list"){let D=await x({message:"Enter page:",default:"1",validate:(C)=>C.trim()!==""}),u=(await b.addons.list({page_number:parseInt(D)-1,page_size:100})).items.map((C)=>({id:C.id,name:C.name,price:`${a[C.currency]||C.currency+" "}${C.price*0.01}`,"created on":new Date(C.created_at).toLocaleString()}));console.table(u)}else if(I==="info")try{let D=await x({message:"Enter addon ID:",validate:(u)=>u.startsWith("adn_")||"Please enter a valid addon ID!"}),F=await b.addons.retrieve(D);console.table({"addon id":F.id,name:F.name,price:`${a[F.currency]||F.currency+" "}${F.price*0.01}`,...F.description?.trim()!==""&&{description:F.description},created_at:new Date(F.created_at).toLocaleString(),updated_at:new Date(F.updated_at).toLocaleString(),tax_category:F.tax_category}),console.log(`To edit the addon, go to https://app.dodopayments.com/products/edit/add-on?id=${F.id}`)}catch(D){if(sD(D)&&D.error.code==="NOT_FOUND")console.log("Incorrect addon ID!");else console.error(D)}else l.addons.forEach((D)=>{console.log(`dodo addons ${D.command} - ${D.description}`)});else if(y==="refund")if(I==="list"){let D=await x({message:"Enter page:",default:"1",validate:(C)=>C.trim()!==""}),u=(await b.refunds.list({page_number:parseInt(D)-1,page_size:100})).items.map((C)=>({id:C.refund_id,"payment id":C.payment_id,price:`${a[C.currency||""]||C.currency+" "}${(C.amount||0)*0.01}`,"created on":new Date(C.created_at).toLocaleString()}));console.table(u)}else if(I==="info")try{let D=await x({message:"Enter refund ID:",validate:(u)=>u.startsWith("ref_")||"Please enter a valid refund ID!"}),F=await b.refunds.retrieve(D);console.table({"refund id":F.refund_id,"payment id":F.payment_id,...Object.keys(F.metadata).length>0&&{metadata:F.metadata},"customer id":F.customer.email,"refund type":F.is_partial?"Partial":"Full",price:`${a[F.currency||""]||F.currency+" "}${(F.amount||0)*0.01}`,...F.reason?.trim()!==""&&{reason:F.reason},created_at:new Date(F.created_at).toLocaleString()})}catch(D){if(sD(D)&&D.error.code==="NOT_FOUND")console.log("Incorrect refund ID!");else console.error(D)}else l.refunds.forEach((D)=>{console.log(`dodo refunds ${D.command} - ${D.description}`)});else if(y==="wh")if(I==="listen")J2({API_KEY:J0,DodoClient:b});else if(I==="trigger")s3();else l.wh.forEach((D)=>{console.log(`dodo wh ${D.command} - ${D.description}`)});else if(y==="checkout")if(I==="new"){let D={product_cart:[]},F=await x({message:"Enter product: ",validate:(u)=>{return u.startsWith("pdt_")}});if(D.product_cart=[{product_id:F,quantity:1}],await e({message:"Use advanced options?",choices:[{name:"Yes",value:!0},{name:"No",value:!1}],default:!1})){D.minimal_address=await e({message:"Enable minimal Address:",choices:[{name:"Yes",value:!0},{name:"No",value:!1}],default:!1});let u=await x({message:"Enter return URL (Optional):"});if(u.trim()!=="")D.return_url=u;D.force_3ds=await e({message:"Force 3DS?",choices:[{name:"Yes",value:!0},{name:"No",value:!1}]});let C=await x({message:"Enter discount code (Optional):"});if(C.trim()!=="")D.discount_code=C;let E=await x({message:"Enter metadata (Optional, JSON stringified):"});if(E.trim()!=="")D.metadata=JSON.parse(E)}try{let u=await b.checkoutSessions.create(D);console.log("Checkout Session URL:",u.checkout_url)}catch(u){if(sD(u))console.log(`Error: ${u.error.message}`)}}else l.checkout.forEach((D)=>{console.log(`dodo checkout ${D.command} - ${D.description}`)});else Y2();
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)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dodopayments-cli",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "A CLI for Dodo Payments",
5
5
  "keywords": [
6
6
  "dodopayments",