resend-cli 2.22.0-preview-inboxes.5 → 2.22.0-preview-inboxes.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs
CHANGED
|
@@ -24,7 +24,7 @@ Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._life
|
|
|
24
24
|
`),this.outputHelp({error:!0}));let i=o||{},r=i.exitCode||1,n=i.code||"commander.error";this._exit(r,n,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in Y.env){let o=t.attributeName();(this.getOptionValue(o)===void 0||["default","config","env"].includes(this.getOptionValueSource(o)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,Y.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new Zm(this.options),o=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&o(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(r=>!o(r)).forEach(r=>{this.setOptionValueWithSource(r,i.implied[r],"implied")})})}missingArgument(t){let o=`error: missing required argument '${t}'`;this.error(o,{code:"commander.missingArgument"})}optionMissingArgument(t){let o=`error: option '${t.flags}' argument missing`;this.error(o,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let o=`error: required option '${t.flags}' not specified`;this.error(o,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,o){let i=s=>{let a=s.attributeName(),l=this.getOptionValue(a),u=this.options.find(p=>p.negate&&a===p.attributeName()),m=this.options.find(p=>!p.negate&&a===p.attributeName());return u&&(u.presetArg===void 0&&l===!1||u.presetArg!==void 0&&l===u.presetArg)?u:m||s},r=s=>{let a=i(s),l=a.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},n=`error: ${r(t)} cannot be used with ${r(o)}`;this.error(n,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let o="";if(t.startsWith("--")&&this._showSuggestionAfterError){let r=[],n=this;do{let s=n.createHelp().visibleOptions(n).filter(a=>a.long).map(a=>a.long);r=r.concat(s),n=n.parent}while(n&&!n._enablePositionalOptions);o=ln(t,r)}let i=`error: unknown option '${t}'${o}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let o=this.registeredArguments.length,i=o===1?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${o} argument${i} but got ${t.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],o="";if(this._showSuggestionAfterError){let r=[];this.createHelp().visibleCommands(this).forEach(n=>{r.push(n.name()),n.alias()&&r.push(n.alias())}),o=ln(t,r)}let i=`error: unknown command '${t}'${o}`;this.error(i,{code:"commander.unknownCommand"})}version(t,o,i){if(t===void 0)return this._version;this._version=t,o=o||"-V, --version",i=i||"output the version number";let r=this.createOption(o,i);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on("option:"+r.name(),()=>{this._outputConfiguration.writeOut(`${t}
|
|
25
25
|
`),this._exit(0,"commander.version",t)}),this}description(t,o){return t===void 0&&o===void 0?this._description:(this._description=t,o&&(this._argsDescription=o),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let o=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(o=this.commands[this.commands.length-1]),t===o._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(t);if(i){let r=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${r}'`)}return o._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(o=>this.alias(o)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let o=this.registeredArguments.map(i=>zm(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?o:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}helpGroup(t){return t===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=t,this)}commandsGroup(t){return t===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=t,this)}optionsGroup(t){return t===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=t,this)}_initOptionGroup(t){this._defaultOptionGroup&&!t.helpGroupHeading&&t.helpGroup(this._defaultOptionGroup)}_initCommandGroup(t){this._defaultCommandGroup&&!t.helpGroup()&&t.helpGroup(this._defaultCommandGroup)}nameFromFilename(t){return this._name=ot.basename(t,ot.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let o=this.createHelp(),i=this._getOutputContext(t);o.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});let r=o.formatHelp(this,o);return i.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(t){t=t||{};let o=!!t.error,i,r,n;return o?(i=a=>this._outputConfiguration.writeErr(a),r=this._outputConfiguration.getErrHasColors(),n=this._outputConfiguration.getErrHelpWidth()):(i=a=>this._outputConfiguration.writeOut(a),r=this._outputConfiguration.getOutHasColors(),n=this._outputConfiguration.getOutHelpWidth()),{error:o,write:a=>(r||(a=this._outputConfiguration.stripColor(a)),i(a)),hasColors:r,helpWidth:n}}outputHelp(t){let o;typeof t=="function"&&(o=t,t=void 0);let i=this._getOutputContext(t),r={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach(s=>s.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let n=this.helpInformation({error:i.error});if(o&&(n=o(n),typeof n!="string"&&!Buffer.isBuffer(n)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(n),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",r),this._getCommandAndAncestors().forEach(s=>s.emit("afterAllHelp",r))}helpOption(t,o){return typeof t=="boolean"?(t?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(t??"-h, --help",o??"display help for command"),(t||o)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this._initOptionGroup(t),this}help(t){this.outputHelp(t);let o=Number(Y.exitCode??0);o===0&&t&&typeof t!="function"&&t.error&&(o=1),this._exit(o,"commander.help","(outputHelp)")}addHelpText(t,o){let i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText.
|
|
26
26
|
Expecting one of '${i.join("', '")}'`);let r=`${t}Help`;return this.on(r,n=>{let s;typeof o=="function"?s=o({error:n.error,command:n.command}):s=o,s&&n.write(`${s}
|
|
27
|
-
`)}),this}_outputHelpIfRequested(t){let o=this._getHelpOption();o&&t.find(r=>o.is(r))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function dn(e){return e.map(t=>{if(!t.startsWith("--inspect"))return t;let o,i="127.0.0.1",r="9229",n;return(n=t.match(/^(--inspect(-brk)?)$/))!==null?o=n[1]:(n=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(o=n[1],/^\d+$/.test(n[3])?r=n[3]:i=n[3]):(n=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(o=n[1],i=n[3],r=n[4]),o&&r!=="0"?`${o}=${i}:${parseInt(r)+1}`:t})}function Li(){if(Y.env.NO_COLOR||Y.env.FORCE_COLOR==="0"||Y.env.FORCE_COLOR==="false")return!1;if(Y.env.FORCE_COLOR||Y.env.CLICOLOR_FORCE!==void 0)return!0}Wi.Command=qi;Wi.useColor=Li});var fn=Re(He=>{var{Argument:un}=ko(),{Command:Ji}=cn(),{CommanderError:ep,InvalidArgumentError:mn}=ro(),{Help:tp}=Pi(),{Option:pn}=Qi();He.program=new Ji;He.createCommand=e=>new Ji(e);He.createOption=(e,t)=>new pn(e,t);He.createArgument=(e,t)=>new un(e,t);He.Command=Ji;He.Option=pn;He.Argument=un;He.Help=tp;He.CommanderError=ep;He.InvalidArgumentError=mn;He.InvalidOptionArgumentError=mn});var gn=Re((Be,hn)=>{var We=fn();Be=hn.exports={};Be.program=new We.Command;Be.Argument=We.Argument;Be.Command=We.Command;Be.CommanderError=We.CommanderError;Be.Help=We.Help;Be.InvalidArgumentError=We.InvalidArgumentError;Be.InvalidOptionArgumentError=We.InvalidArgumentError;Be.Option=We.Option;Be.createCommand=e=>new We.Command(e);Be.createOption=(e,t)=>new We.Option(e,t);Be.createArgument=(e,t)=>new We.Argument(e,t)});var Je=Re((AA,Vi)=>{var Ro=process||{},yn=Ro.argv||[],Fo=Ro.env||{},op=!(Fo.NO_COLOR||yn.includes("--no-color"))&&(!!Fo.FORCE_COLOR||yn.includes("--color")||Ro.platform==="win32"||(Ro.stdout||{}).isTTY&&Fo.TERM!=="dumb"||!!Fo.CI),ip=(e,t,o=e)=>i=>{let r=""+i,n=r.indexOf(t,e.length);return~n?e+rp(r,t,o,n)+t:e+r+t},rp=(e,t,o,i)=>{let r="",n=0;do r+=e.substring(n,i)+o,n=i+t.length,i=e.indexOf(t,n);while(~i);return r+e.substring(n)},Cn=(e=op)=>{let t=e?ip:()=>String;return{isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};Vi.exports=Cn();Vi.exports.createColors=Cn});var er=Re((KA,Bn)=>{"use strict";var Zi={to(e,t){return t?`\x1B[${t+1};${e+1}H`:`\x1B[${e+1}G`},move(e,t){let o="";return e<0?o+=`\x1B[${-e}D`:e>0&&(o+=`\x1B[${e}C`),t<0?o+=`\x1B[${-t}A`:t>0&&(o+=`\x1B[${t}B`),o},up:(e=1)=>`\x1B[${e}A`,down:(e=1)=>`\x1B[${e}B`,forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},xp={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},wp={screen:"\x1B[2J",up:(e=1)=>"\x1B[1J".repeat(e),down:(e=1)=>"\x1B[J".repeat(e),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(e){let t="";for(let o=0;o<e;o++)t+=this.line+(o<e-1?Zi.up():"");return e&&(t+=Zi.left),t}};Bn.exports={cursor:Zi,scroll:xp,erase:wp,beep:"\x07"}});var rr,Zn=be(()=>{rr={name:"resend-cli",version:"2.22.0-preview-inboxes.5",description:"The official CLI for Resend",license:"MIT",repository:{type:"git",url:"https://github.com/resend/resend-cli"},homepage:"https://github.com/resend/resend-cli#readme",keywords:["cli","resend","email","api","tanstack-intent"],engines:{node:">=22"},packageManager:"pnpm@11.8.0",files:["dist/cli.cjs","skills/"],type:"module",bin:{resend:"./dist/cli.cjs"},scripts:{dev:"tsx src/cli.ts","dev:watch":"tsx --watch src/cli.ts",build:"node scripts/build.mjs","build:bin":"pnpm build && pkg dist/cli.cjs --config package.json --compress Brotli --target node24 --output dist/resend",lint:"biome check .","lint:fix":"biome check --write .",typecheck:"tsc --noEmit",test:"vitest run","test:e2e":"vitest run --config vitest.config.e2e.ts",prepack:"pnpm install && pnpm build && node scripts/verify-bundle.mjs"},dependencies:{"@clack/prompts":"1.4.0","@commander-js/extra-typings":"14.0.0",commander:"14.0.3",esbuild:"0.28.1","esbuild-wasm":"0.28.0",picocolors:"1.1.1",resend:"6.32.1-preview-inboxes.3"},pkg:{scripts:["node_modules/esbuild-wasm/bin/esbuild","node_modules/esbuild-wasm/wasm_exec.js","node_modules/esbuild-wasm/wasm_exec_node.js"],assets:["node_modules/esbuild-wasm/esbuild.wasm"]},devDependencies:{"@biomejs/biome":"2.4.11","@types/node":"24.12.4","@yao-pkg/pkg":"6.20.0",tsx:"4.22.4",typescript:"5.9.3",vitest:"4.1.9"}}});var se,es,Kt=be(()=>{"use strict";Zn();se=rr.version,es=rr.name});var ms=Re(Pe=>{"use strict";var mf=Pe&&Pe.__extends||(function(){var e=function(t,o){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var n in r)r.hasOwnProperty(n)&&(i[n]=r[n])},e(t,o)};return function(t,o){e(t,o);function i(){this.constructor=t}t.prototype=o===null?Object.create(o):(i.prototype=o.prototype,new i)}})();Object.defineProperty(Pe,"__esModule",{value:!0});var ce=256,fr=(function(){function e(t){t===void 0&&(t="="),this._paddingCharacter=t}return e.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(t*8+5)/6|0},e.prototype.encode=function(t){for(var o="",i=0;i<t.length-2;i+=3){var r=t[i]<<16|t[i+1]<<8|t[i+2];o+=this._encodeByte(r>>>18&63),o+=this._encodeByte(r>>>12&63),o+=this._encodeByte(r>>>6&63),o+=this._encodeByte(r>>>0&63)}var n=t.length-i;if(n>0){var r=t[i]<<16|(n===2?t[i+1]<<8:0);o+=this._encodeByte(r>>>18&63),o+=this._encodeByte(r>>>12&63),n===2?o+=this._encodeByte(r>>>6&63):o+=this._paddingCharacter||"",o+=this._paddingCharacter||""}return o},e.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(t*6+7)/8|0},e.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},e.prototype.decode=function(t){if(t.length===0)return new Uint8Array(0);for(var o=this._getPaddingLength(t),i=t.length-o,r=new Uint8Array(this.maxDecodedLength(i)),n=0,s=0,a=0,l=0,u=0,m=0,p=0;s<i-4;s+=4)l=this._decodeChar(t.charCodeAt(s+0)),u=this._decodeChar(t.charCodeAt(s+1)),m=this._decodeChar(t.charCodeAt(s+2)),p=this._decodeChar(t.charCodeAt(s+3)),r[n++]=l<<2|u>>>4,r[n++]=u<<4|m>>>2,r[n++]=m<<6|p,a|=l&ce,a|=u&ce,a|=m&ce,a|=p&ce;if(s<i-1&&(l=this._decodeChar(t.charCodeAt(s)),u=this._decodeChar(t.charCodeAt(s+1)),r[n++]=l<<2|u>>>4,a|=l&ce,a|=u&ce),s<i-2&&(m=this._decodeChar(t.charCodeAt(s+2)),r[n++]=u<<4|m>>>2,a|=m&ce),s<i-3&&(p=this._decodeChar(t.charCodeAt(s+3)),r[n++]=m<<6|p,a|=p&ce),a!==0)throw new Error("Base64Coder: incorrect characters for decoding");return r},e.prototype._encodeByte=function(t){var o=t;return o+=65,o+=25-t>>>8&6,o+=51-t>>>8&-75,o+=61-t>>>8&-15,o+=62-t>>>8&3,String.fromCharCode(o)},e.prototype._decodeChar=function(t){var o=ce;return o+=(42-t&t-44)>>>8&-ce+t-43+62,o+=(46-t&t-48)>>>8&-ce+t-47+63,o+=(47-t&t-58)>>>8&-ce+t-48+52,o+=(64-t&t-91)>>>8&-ce+t-65+0,o+=(96-t&t-123)>>>8&-ce+t-97+26,o},e.prototype._getPaddingLength=function(t){var o=0;if(this._paddingCharacter){for(var i=t.length-1;i>=0&&t[i]===this._paddingCharacter;i--)o++;if(t.length<4||o>2)throw new Error("Base64Coder: incorrect padding")}return o},e})();Pe.Coder=fr;var po=new fr;function pf(e){return po.encode(e)}Pe.encode=pf;function ff(e){return po.decode(e)}Pe.decode=ff;var cs=(function(e){mf(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype._encodeByte=function(o){var i=o;return i+=65,i+=25-o>>>8&6,i+=51-o>>>8&-75,i+=61-o>>>8&-13,i+=62-o>>>8&49,String.fromCharCode(i)},t.prototype._decodeChar=function(o){var i=ce;return i+=(44-o&o-46)>>>8&-ce+o-45+62,i+=(94-o&o-96)>>>8&-ce+o-95+63,i+=(47-o&o-58)>>>8&-ce+o-48+52,i+=(64-o&o-91)>>>8&-ce+o-65+0,i+=(96-o&o-123)>>>8&-ce+o-97+26,i},t})(fr);Pe.URLSafeCoder=cs;var us=new cs;function hf(e){return us.encode(e)}Pe.encodeURLSafe=hf;function gf(e){return us.decode(e)}Pe.decodeURLSafe=gf;Pe.encodedLength=function(e){return po.encodedLength(e)};Pe.maxDecodedLength=function(e){return po.maxDecodedLength(e)};Pe.decodedLength=function(e){return po.decodedLength(e)}});var fs=Re((ps,Mo)=>{(function(e,t){var o={};t(o);var i=o.default;for(var r in o)i[r]=o[r];typeof Mo=="object"&&typeof Mo.exports=="object"?Mo.exports=i:typeof define=="function"&&define.amd?define(function(){return i}):e.sha256=i})(ps,function(e){"use strict";e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=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 o(p,f,y,A,b){for(var x,v,U,K,k,j,G,N,$,L,ve,re,Ut;b>=64;){for(x=f[0],v=f[1],U=f[2],K=f[3],k=f[4],j=f[5],G=f[6],N=f[7],L=0;L<16;L++)ve=A+L*4,p[L]=(y[ve]&255)<<24|(y[ve+1]&255)<<16|(y[ve+2]&255)<<8|y[ve+3]&255;for(L=16;L<64;L++)$=p[L-2],re=($>>>17|$<<15)^($>>>19|$<<13)^$>>>10,$=p[L-15],Ut=($>>>7|$<<25)^($>>>18|$<<14)^$>>>3,p[L]=(re+p[L-7]|0)+(Ut+p[L-16]|0);for(L=0;L<64;L++)re=(((k>>>6|k<<26)^(k>>>11|k<<21)^(k>>>25|k<<7))+(k&j^~k&G)|0)+(N+(t[L]+p[L]|0)|0)|0,Ut=((x>>>2|x<<30)^(x>>>13|x<<19)^(x>>>22|x<<10))+(x&v^x&U^v&U)|0,N=G,G=j,j=k,k=K+re|0,K=U,U=v,v=x,x=re+Ut|0;f[0]+=x,f[1]+=v,f[2]+=U,f[3]+=K,f[4]+=k,f[5]+=j,f[6]+=G,f[7]+=N,A+=64,b-=64}return A}var i=(function(){function p(){this.digestLength=e.digestLength,this.blockSize=e.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 p.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},p.prototype.clean=function(){for(var f=0;f<this.buffer.length;f++)this.buffer[f]=0;for(var f=0;f<this.temp.length;f++)this.temp[f]=0;this.reset()},p.prototype.update=function(f,y){if(y===void 0&&(y=f.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var A=0;if(this.bytesHashed+=y,this.bufferLength>0){for(;this.bufferLength<64&&y>0;)this.buffer[this.bufferLength++]=f[A++],y--;this.bufferLength===64&&(o(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(y>=64&&(A=o(this.temp,this.state,f,A,y),y%=64);y>0;)this.buffer[this.bufferLength++]=f[A++],y--;return this},p.prototype.finish=function(f){if(!this.finished){var y=this.bytesHashed,A=this.bufferLength,b=y/536870912|0,x=y<<3,v=y%64<56?64:128;this.buffer[A]=128;for(var U=A+1;U<v-8;U++)this.buffer[U]=0;this.buffer[v-8]=b>>>24&255,this.buffer[v-7]=b>>>16&255,this.buffer[v-6]=b>>>8&255,this.buffer[v-5]=b>>>0&255,this.buffer[v-4]=x>>>24&255,this.buffer[v-3]=x>>>16&255,this.buffer[v-2]=x>>>8&255,this.buffer[v-1]=x>>>0&255,o(this.temp,this.state,this.buffer,0,v),this.finished=!0}for(var U=0;U<8;U++)f[U*4+0]=this.state[U]>>>24&255,f[U*4+1]=this.state[U]>>>16&255,f[U*4+2]=this.state[U]>>>8&255,f[U*4+3]=this.state[U]>>>0&255;return this},p.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},p.prototype._saveState=function(f){for(var y=0;y<this.state.length;y++)f[y]=this.state[y]},p.prototype._restoreState=function(f,y){for(var A=0;A<this.state.length;A++)this.state[A]=f[A];this.bytesHashed=y,this.finished=!1,this.bufferLength=0},p})();e.Hash=i;var r=(function(){function p(f){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var y=new Uint8Array(this.blockSize);if(f.length>this.blockSize)new i().update(f).finish(y).clean();else for(var A=0;A<f.length;A++)y[A]=f[A];for(var A=0;A<y.length;A++)y[A]^=54;this.inner.update(y);for(var A=0;A<y.length;A++)y[A]^=106;this.outer.update(y),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var A=0;A<y.length;A++)y[A]=0}return p.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},p.prototype.clean=function(){for(var f=0;f<this.istate.length;f++)this.ostate[f]=this.istate[f]=0;this.inner.clean(),this.outer.clean()},p.prototype.update=function(f){return this.inner.update(f),this},p.prototype.finish=function(f){return this.outer.finished?this.outer.finish(f):(this.inner.finish(f),this.outer.update(f,this.digestLength).finish(f)),this},p.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},p})();e.HMAC=r;function n(p){var f=new i().update(p),y=f.digest();return f.clean(),y}e.hash=n,e.default=n;function s(p,f){var y=new r(p).update(f),A=y.digest();return y.clean(),A}e.hmac=s;function a(p,f,y,A){var b=A[0];if(b===0)throw new Error("hkdf: cannot expand more");f.reset(),b>1&&f.update(p),y&&f.update(y),f.update(A),f.finish(p),A[0]++}var l=new Uint8Array(e.digestLength);function u(p,f,y,A){f===void 0&&(f=l),A===void 0&&(A=32);for(var b=new Uint8Array([1]),x=s(f,p),v=new r(x),U=new Uint8Array(v.digestLength),K=U.length,k=new Uint8Array(A),j=0;j<A;j++)K===U.length&&(a(U,v,y,b),K=0),k[j]=U[K++];return v.clean(),U.fill(0),b.fill(0),k}e.hkdf=u;function m(p,f,y,A){for(var b=new r(p),x=b.digestLength,v=new Uint8Array(4),U=new Uint8Array(x),K=new Uint8Array(x),k=new Uint8Array(A),j=0;j*x<A;j++){var G=j+1;v[0]=G>>>24&255,v[1]=G>>>16&255,v[2]=G>>>8&255,v[3]=G>>>0&255,b.reset(),b.update(f),b.update(v),b.finish(K);for(var N=0;N<x;N++)U[N]=K[N];for(var N=2;N<=y;N++){b.reset(),b.update(K).finish(K);for(var $=0;$<x;$++)U[$]^=K[$]}for(var N=0;N<x&&j*x+N<A;N++)k[j*x+N]=U[N]}for(var j=0;j<x;j++)U[j]=K[j]=0;for(var j=0;j<4;j++)v[j]=0;return b.clean(),k}e.pbkdf2=m})});var gs=Re(hr=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});hr.timingSafeEqual=Af;function hs(e,t=""){if(!e)throw new Error(t)}function Af(e,t){if(e.byteLength!==t.byteLength)return!1;e instanceof DataView||(e=new DataView(ArrayBuffer.isView(e)?e.buffer:e)),t instanceof DataView||(t=new DataView(ArrayBuffer.isView(t)?t.buffer:t)),hs(e instanceof DataView),hs(t instanceof DataView);let o=e.byteLength,i=0,r=-1;for(;++r<o;)i|=e.getUint8(r)^t.getUint8(r);return i===0}});var ys=Re(Pt=>{"use strict";Object.defineProperty(Pt,"__esModule",{value:!0});Pt.Webhook=Pt.WebhookVerificationError=void 0;var As=ms(),bf=fs(),yf=gs(),bs=300,gr=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype),this.name="ExtendableError",this.stack=new Error(t).stack}},pt=class e extends gr{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype),this.name="WebhookVerificationError"}};Pt.WebhookVerificationError=pt;var qo=class e{constructor(t,o){if(o?.format==="raw")t instanceof Uint8Array?this.key=t:this.key=Uint8Array.from(t,i=>i.charCodeAt(0));else{if(typeof t!="string")throw new Error("Expected secret to be of type string");t.startsWith(e.prefix)&&(t=t.substring(e.prefix.length)),this.key=As.decode(t)}if(this.key.length===0)throw new Error("Secret can't be empty.")}verify(t,o,i){var r;let n=(r=i?.jsonParse)!==null&&r!==void 0?r:!0,s={};for(let b of Object.keys(o))s[b.toLowerCase()]=o[b];let a=s["webhook-id"],l=s["webhook-signature"],u=s["webhook-timestamp"];if(!l||!a||!u)throw new pt("Missing required headers");let m=this.verifyTimestamp(u),f=this.sign(a,m,t).split(",")[1],y=l.split(" "),A=new globalThis.TextEncoder;for(let b of y){let[x,v]=b.split(",");if(x==="v1"&&(0,yf.timingSafeEqual)(A.encode(v),A.encode(f))){let U=t.toString();return U===""?void 0:n?JSON.parse(U):void 0}}throw new pt("No matching signature found")}sign(t,o,i){if(typeof i!="string")if(i.constructor.name==="Buffer")i=i.toString();else throw new Error("Expected payload to be of type string or Buffer.");let r=new TextEncoder,n=Math.floor(o.getTime()/1e3),s=r.encode(`${t}.${n}.${i}`);return`v1,${As.encode(bf.hmac(this.key,s))}`}verifyTimestamp(t){let o=Math.floor(Date.now()/1e3),i=parseInt(t,10);if(Number.isNaN(i))throw new pt("Invalid Signature Headers");if(o-i>bs)throw new pt("Message timestamp too old");if(i>o+bs)throw new pt("Message timestamp too new");return new Date(i*1e3)}};Pt.Webhook=qo;qo.prefix="whsec_"});var Jo,Es=be(()=>{"use strict";Jo=class extends Error{constructor(t){super(`Credentials file is corrupted or contains invalid JSON: ${t}
|
|
27
|
+
`)}),this}_outputHelpIfRequested(t){let o=this._getHelpOption();o&&t.find(r=>o.is(r))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function dn(e){return e.map(t=>{if(!t.startsWith("--inspect"))return t;let o,i="127.0.0.1",r="9229",n;return(n=t.match(/^(--inspect(-brk)?)$/))!==null?o=n[1]:(n=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(o=n[1],/^\d+$/.test(n[3])?r=n[3]:i=n[3]):(n=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(o=n[1],i=n[3],r=n[4]),o&&r!=="0"?`${o}=${i}:${parseInt(r)+1}`:t})}function Li(){if(Y.env.NO_COLOR||Y.env.FORCE_COLOR==="0"||Y.env.FORCE_COLOR==="false")return!1;if(Y.env.FORCE_COLOR||Y.env.CLICOLOR_FORCE!==void 0)return!0}Wi.Command=qi;Wi.useColor=Li});var fn=Re(He=>{var{Argument:un}=ko(),{Command:Ji}=cn(),{CommanderError:ep,InvalidArgumentError:mn}=ro(),{Help:tp}=Pi(),{Option:pn}=Qi();He.program=new Ji;He.createCommand=e=>new Ji(e);He.createOption=(e,t)=>new pn(e,t);He.createArgument=(e,t)=>new un(e,t);He.Command=Ji;He.Option=pn;He.Argument=un;He.Help=tp;He.CommanderError=ep;He.InvalidArgumentError=mn;He.InvalidOptionArgumentError=mn});var gn=Re((Be,hn)=>{var We=fn();Be=hn.exports={};Be.program=new We.Command;Be.Argument=We.Argument;Be.Command=We.Command;Be.CommanderError=We.CommanderError;Be.Help=We.Help;Be.InvalidArgumentError=We.InvalidArgumentError;Be.InvalidOptionArgumentError=We.InvalidArgumentError;Be.Option=We.Option;Be.createCommand=e=>new We.Command(e);Be.createOption=(e,t)=>new We.Option(e,t);Be.createArgument=(e,t)=>new We.Argument(e,t)});var Je=Re((AA,Vi)=>{var Ro=process||{},yn=Ro.argv||[],Fo=Ro.env||{},op=!(Fo.NO_COLOR||yn.includes("--no-color"))&&(!!Fo.FORCE_COLOR||yn.includes("--color")||Ro.platform==="win32"||(Ro.stdout||{}).isTTY&&Fo.TERM!=="dumb"||!!Fo.CI),ip=(e,t,o=e)=>i=>{let r=""+i,n=r.indexOf(t,e.length);return~n?e+rp(r,t,o,n)+t:e+r+t},rp=(e,t,o,i)=>{let r="",n=0;do r+=e.substring(n,i)+o,n=i+t.length,i=e.indexOf(t,n);while(~i);return r+e.substring(n)},Cn=(e=op)=>{let t=e?ip:()=>String;return{isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};Vi.exports=Cn();Vi.exports.createColors=Cn});var er=Re((KA,Bn)=>{"use strict";var Zi={to(e,t){return t?`\x1B[${t+1};${e+1}H`:`\x1B[${e+1}G`},move(e,t){let o="";return e<0?o+=`\x1B[${-e}D`:e>0&&(o+=`\x1B[${e}C`),t<0?o+=`\x1B[${-t}A`:t>0&&(o+=`\x1B[${t}B`),o},up:(e=1)=>`\x1B[${e}A`,down:(e=1)=>`\x1B[${e}B`,forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},xp={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},wp={screen:"\x1B[2J",up:(e=1)=>"\x1B[1J".repeat(e),down:(e=1)=>"\x1B[J".repeat(e),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(e){let t="";for(let o=0;o<e;o++)t+=this.line+(o<e-1?Zi.up():"");return e&&(t+=Zi.left),t}};Bn.exports={cursor:Zi,scroll:xp,erase:wp,beep:"\x07"}});var rr,Zn=be(()=>{rr={name:"resend-cli",version:"2.22.0-preview-inboxes.6",description:"The official CLI for Resend",license:"MIT",repository:{type:"git",url:"https://github.com/resend/resend-cli"},homepage:"https://github.com/resend/resend-cli#readme",keywords:["cli","resend","email","api","tanstack-intent"],engines:{node:">=22"},packageManager:"pnpm@11.8.0",files:["dist/cli.cjs","skills/"],type:"module",bin:{resend:"./dist/cli.cjs"},scripts:{dev:"tsx src/cli.ts","dev:watch":"tsx --watch src/cli.ts",build:"node scripts/build.mjs","build:bin":"pnpm build && pkg dist/cli.cjs --config package.json --compress Brotli --target node24 --output dist/resend",lint:"biome check .","lint:fix":"biome check --write .",typecheck:"tsc --noEmit",test:"vitest run","test:e2e":"vitest run --config vitest.config.e2e.ts",prepack:"pnpm install && pnpm build && node scripts/verify-bundle.mjs"},dependencies:{"@clack/prompts":"1.4.0","@commander-js/extra-typings":"14.0.0",commander:"14.0.3",esbuild:"0.28.1","esbuild-wasm":"0.28.0",picocolors:"1.1.1",resend:"6.32.1-preview-inboxes.4"},pkg:{scripts:["node_modules/esbuild-wasm/bin/esbuild","node_modules/esbuild-wasm/wasm_exec.js","node_modules/esbuild-wasm/wasm_exec_node.js"],assets:["node_modules/esbuild-wasm/esbuild.wasm"]},devDependencies:{"@biomejs/biome":"2.4.11","@types/node":"24.12.4","@yao-pkg/pkg":"6.20.0",tsx:"4.22.4",typescript:"5.9.3",vitest:"4.1.9"}}});var se,es,Kt=be(()=>{"use strict";Zn();se=rr.version,es=rr.name});var ms=Re(Pe=>{"use strict";var mf=Pe&&Pe.__extends||(function(){var e=function(t,o){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var n in r)r.hasOwnProperty(n)&&(i[n]=r[n])},e(t,o)};return function(t,o){e(t,o);function i(){this.constructor=t}t.prototype=o===null?Object.create(o):(i.prototype=o.prototype,new i)}})();Object.defineProperty(Pe,"__esModule",{value:!0});var ce=256,fr=(function(){function e(t){t===void 0&&(t="="),this._paddingCharacter=t}return e.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(t*8+5)/6|0},e.prototype.encode=function(t){for(var o="",i=0;i<t.length-2;i+=3){var r=t[i]<<16|t[i+1]<<8|t[i+2];o+=this._encodeByte(r>>>18&63),o+=this._encodeByte(r>>>12&63),o+=this._encodeByte(r>>>6&63),o+=this._encodeByte(r>>>0&63)}var n=t.length-i;if(n>0){var r=t[i]<<16|(n===2?t[i+1]<<8:0);o+=this._encodeByte(r>>>18&63),o+=this._encodeByte(r>>>12&63),n===2?o+=this._encodeByte(r>>>6&63):o+=this._paddingCharacter||"",o+=this._paddingCharacter||""}return o},e.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(t*6+7)/8|0},e.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},e.prototype.decode=function(t){if(t.length===0)return new Uint8Array(0);for(var o=this._getPaddingLength(t),i=t.length-o,r=new Uint8Array(this.maxDecodedLength(i)),n=0,s=0,a=0,l=0,u=0,m=0,p=0;s<i-4;s+=4)l=this._decodeChar(t.charCodeAt(s+0)),u=this._decodeChar(t.charCodeAt(s+1)),m=this._decodeChar(t.charCodeAt(s+2)),p=this._decodeChar(t.charCodeAt(s+3)),r[n++]=l<<2|u>>>4,r[n++]=u<<4|m>>>2,r[n++]=m<<6|p,a|=l&ce,a|=u&ce,a|=m&ce,a|=p&ce;if(s<i-1&&(l=this._decodeChar(t.charCodeAt(s)),u=this._decodeChar(t.charCodeAt(s+1)),r[n++]=l<<2|u>>>4,a|=l&ce,a|=u&ce),s<i-2&&(m=this._decodeChar(t.charCodeAt(s+2)),r[n++]=u<<4|m>>>2,a|=m&ce),s<i-3&&(p=this._decodeChar(t.charCodeAt(s+3)),r[n++]=m<<6|p,a|=p&ce),a!==0)throw new Error("Base64Coder: incorrect characters for decoding");return r},e.prototype._encodeByte=function(t){var o=t;return o+=65,o+=25-t>>>8&6,o+=51-t>>>8&-75,o+=61-t>>>8&-15,o+=62-t>>>8&3,String.fromCharCode(o)},e.prototype._decodeChar=function(t){var o=ce;return o+=(42-t&t-44)>>>8&-ce+t-43+62,o+=(46-t&t-48)>>>8&-ce+t-47+63,o+=(47-t&t-58)>>>8&-ce+t-48+52,o+=(64-t&t-91)>>>8&-ce+t-65+0,o+=(96-t&t-123)>>>8&-ce+t-97+26,o},e.prototype._getPaddingLength=function(t){var o=0;if(this._paddingCharacter){for(var i=t.length-1;i>=0&&t[i]===this._paddingCharacter;i--)o++;if(t.length<4||o>2)throw new Error("Base64Coder: incorrect padding")}return o},e})();Pe.Coder=fr;var po=new fr;function pf(e){return po.encode(e)}Pe.encode=pf;function ff(e){return po.decode(e)}Pe.decode=ff;var cs=(function(e){mf(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype._encodeByte=function(o){var i=o;return i+=65,i+=25-o>>>8&6,i+=51-o>>>8&-75,i+=61-o>>>8&-13,i+=62-o>>>8&49,String.fromCharCode(i)},t.prototype._decodeChar=function(o){var i=ce;return i+=(44-o&o-46)>>>8&-ce+o-45+62,i+=(94-o&o-96)>>>8&-ce+o-95+63,i+=(47-o&o-58)>>>8&-ce+o-48+52,i+=(64-o&o-91)>>>8&-ce+o-65+0,i+=(96-o&o-123)>>>8&-ce+o-97+26,i},t})(fr);Pe.URLSafeCoder=cs;var us=new cs;function hf(e){return us.encode(e)}Pe.encodeURLSafe=hf;function gf(e){return us.decode(e)}Pe.decodeURLSafe=gf;Pe.encodedLength=function(e){return po.encodedLength(e)};Pe.maxDecodedLength=function(e){return po.maxDecodedLength(e)};Pe.decodedLength=function(e){return po.decodedLength(e)}});var fs=Re((ps,Mo)=>{(function(e,t){var o={};t(o);var i=o.default;for(var r in o)i[r]=o[r];typeof Mo=="object"&&typeof Mo.exports=="object"?Mo.exports=i:typeof define=="function"&&define.amd?define(function(){return i}):e.sha256=i})(ps,function(e){"use strict";e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=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 o(p,f,y,A,b){for(var x,v,U,K,k,j,G,N,$,L,ve,re,Ut;b>=64;){for(x=f[0],v=f[1],U=f[2],K=f[3],k=f[4],j=f[5],G=f[6],N=f[7],L=0;L<16;L++)ve=A+L*4,p[L]=(y[ve]&255)<<24|(y[ve+1]&255)<<16|(y[ve+2]&255)<<8|y[ve+3]&255;for(L=16;L<64;L++)$=p[L-2],re=($>>>17|$<<15)^($>>>19|$<<13)^$>>>10,$=p[L-15],Ut=($>>>7|$<<25)^($>>>18|$<<14)^$>>>3,p[L]=(re+p[L-7]|0)+(Ut+p[L-16]|0);for(L=0;L<64;L++)re=(((k>>>6|k<<26)^(k>>>11|k<<21)^(k>>>25|k<<7))+(k&j^~k&G)|0)+(N+(t[L]+p[L]|0)|0)|0,Ut=((x>>>2|x<<30)^(x>>>13|x<<19)^(x>>>22|x<<10))+(x&v^x&U^v&U)|0,N=G,G=j,j=k,k=K+re|0,K=U,U=v,v=x,x=re+Ut|0;f[0]+=x,f[1]+=v,f[2]+=U,f[3]+=K,f[4]+=k,f[5]+=j,f[6]+=G,f[7]+=N,A+=64,b-=64}return A}var i=(function(){function p(){this.digestLength=e.digestLength,this.blockSize=e.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 p.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},p.prototype.clean=function(){for(var f=0;f<this.buffer.length;f++)this.buffer[f]=0;for(var f=0;f<this.temp.length;f++)this.temp[f]=0;this.reset()},p.prototype.update=function(f,y){if(y===void 0&&(y=f.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var A=0;if(this.bytesHashed+=y,this.bufferLength>0){for(;this.bufferLength<64&&y>0;)this.buffer[this.bufferLength++]=f[A++],y--;this.bufferLength===64&&(o(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(y>=64&&(A=o(this.temp,this.state,f,A,y),y%=64);y>0;)this.buffer[this.bufferLength++]=f[A++],y--;return this},p.prototype.finish=function(f){if(!this.finished){var y=this.bytesHashed,A=this.bufferLength,b=y/536870912|0,x=y<<3,v=y%64<56?64:128;this.buffer[A]=128;for(var U=A+1;U<v-8;U++)this.buffer[U]=0;this.buffer[v-8]=b>>>24&255,this.buffer[v-7]=b>>>16&255,this.buffer[v-6]=b>>>8&255,this.buffer[v-5]=b>>>0&255,this.buffer[v-4]=x>>>24&255,this.buffer[v-3]=x>>>16&255,this.buffer[v-2]=x>>>8&255,this.buffer[v-1]=x>>>0&255,o(this.temp,this.state,this.buffer,0,v),this.finished=!0}for(var U=0;U<8;U++)f[U*4+0]=this.state[U]>>>24&255,f[U*4+1]=this.state[U]>>>16&255,f[U*4+2]=this.state[U]>>>8&255,f[U*4+3]=this.state[U]>>>0&255;return this},p.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},p.prototype._saveState=function(f){for(var y=0;y<this.state.length;y++)f[y]=this.state[y]},p.prototype._restoreState=function(f,y){for(var A=0;A<this.state.length;A++)this.state[A]=f[A];this.bytesHashed=y,this.finished=!1,this.bufferLength=0},p})();e.Hash=i;var r=(function(){function p(f){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var y=new Uint8Array(this.blockSize);if(f.length>this.blockSize)new i().update(f).finish(y).clean();else for(var A=0;A<f.length;A++)y[A]=f[A];for(var A=0;A<y.length;A++)y[A]^=54;this.inner.update(y);for(var A=0;A<y.length;A++)y[A]^=106;this.outer.update(y),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var A=0;A<y.length;A++)y[A]=0}return p.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},p.prototype.clean=function(){for(var f=0;f<this.istate.length;f++)this.ostate[f]=this.istate[f]=0;this.inner.clean(),this.outer.clean()},p.prototype.update=function(f){return this.inner.update(f),this},p.prototype.finish=function(f){return this.outer.finished?this.outer.finish(f):(this.inner.finish(f),this.outer.update(f,this.digestLength).finish(f)),this},p.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},p})();e.HMAC=r;function n(p){var f=new i().update(p),y=f.digest();return f.clean(),y}e.hash=n,e.default=n;function s(p,f){var y=new r(p).update(f),A=y.digest();return y.clean(),A}e.hmac=s;function a(p,f,y,A){var b=A[0];if(b===0)throw new Error("hkdf: cannot expand more");f.reset(),b>1&&f.update(p),y&&f.update(y),f.update(A),f.finish(p),A[0]++}var l=new Uint8Array(e.digestLength);function u(p,f,y,A){f===void 0&&(f=l),A===void 0&&(A=32);for(var b=new Uint8Array([1]),x=s(f,p),v=new r(x),U=new Uint8Array(v.digestLength),K=U.length,k=new Uint8Array(A),j=0;j<A;j++)K===U.length&&(a(U,v,y,b),K=0),k[j]=U[K++];return v.clean(),U.fill(0),b.fill(0),k}e.hkdf=u;function m(p,f,y,A){for(var b=new r(p),x=b.digestLength,v=new Uint8Array(4),U=new Uint8Array(x),K=new Uint8Array(x),k=new Uint8Array(A),j=0;j*x<A;j++){var G=j+1;v[0]=G>>>24&255,v[1]=G>>>16&255,v[2]=G>>>8&255,v[3]=G>>>0&255,b.reset(),b.update(f),b.update(v),b.finish(K);for(var N=0;N<x;N++)U[N]=K[N];for(var N=2;N<=y;N++){b.reset(),b.update(K).finish(K);for(var $=0;$<x;$++)U[$]^=K[$]}for(var N=0;N<x&&j*x+N<A;N++)k[j*x+N]=U[N]}for(var j=0;j<x;j++)U[j]=K[j]=0;for(var j=0;j<4;j++)v[j]=0;return b.clean(),k}e.pbkdf2=m})});var gs=Re(hr=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});hr.timingSafeEqual=Af;function hs(e,t=""){if(!e)throw new Error(t)}function Af(e,t){if(e.byteLength!==t.byteLength)return!1;e instanceof DataView||(e=new DataView(ArrayBuffer.isView(e)?e.buffer:e)),t instanceof DataView||(t=new DataView(ArrayBuffer.isView(t)?t.buffer:t)),hs(e instanceof DataView),hs(t instanceof DataView);let o=e.byteLength,i=0,r=-1;for(;++r<o;)i|=e.getUint8(r)^t.getUint8(r);return i===0}});var ys=Re(Pt=>{"use strict";Object.defineProperty(Pt,"__esModule",{value:!0});Pt.Webhook=Pt.WebhookVerificationError=void 0;var As=ms(),bf=fs(),yf=gs(),bs=300,gr=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype),this.name="ExtendableError",this.stack=new Error(t).stack}},pt=class e extends gr{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype),this.name="WebhookVerificationError"}};Pt.WebhookVerificationError=pt;var qo=class e{constructor(t,o){if(o?.format==="raw")t instanceof Uint8Array?this.key=t:this.key=Uint8Array.from(t,i=>i.charCodeAt(0));else{if(typeof t!="string")throw new Error("Expected secret to be of type string");t.startsWith(e.prefix)&&(t=t.substring(e.prefix.length)),this.key=As.decode(t)}if(this.key.length===0)throw new Error("Secret can't be empty.")}verify(t,o,i){var r;let n=(r=i?.jsonParse)!==null&&r!==void 0?r:!0,s={};for(let b of Object.keys(o))s[b.toLowerCase()]=o[b];let a=s["webhook-id"],l=s["webhook-signature"],u=s["webhook-timestamp"];if(!l||!a||!u)throw new pt("Missing required headers");let m=this.verifyTimestamp(u),f=this.sign(a,m,t).split(",")[1],y=l.split(" "),A=new globalThis.TextEncoder;for(let b of y){let[x,v]=b.split(",");if(x==="v1"&&(0,yf.timingSafeEqual)(A.encode(v),A.encode(f))){let U=t.toString();return U===""?void 0:n?JSON.parse(U):void 0}}throw new pt("No matching signature found")}sign(t,o,i){if(typeof i!="string")if(i.constructor.name==="Buffer")i=i.toString();else throw new Error("Expected payload to be of type string or Buffer.");let r=new TextEncoder,n=Math.floor(o.getTime()/1e3),s=r.encode(`${t}.${n}.${i}`);return`v1,${As.encode(bf.hmac(this.key,s))}`}verifyTimestamp(t){let o=Math.floor(Date.now()/1e3),i=parseInt(t,10);if(Number.isNaN(i))throw new pt("Invalid Signature Headers");if(o-i>bs)throw new pt("Message timestamp too old");if(i>o+bs)throw new pt("Message timestamp too new");return new Date(i*1e3)}};Pt.Webhook=qo;qo.prefix="whsec_"});var Jo,Es=be(()=>{"use strict";Jo=class extends Error{constructor(t){super(`Credentials file is corrupted or contains invalid JSON: ${t}
|
|
28
28
|
The file has been preserved for manual inspection.
|
|
29
29
|
To fix: either repair the JSON manually, or delete the file and run: resend login`),this.name="CorruptedCredentialsError"}}});var br={};io(br,{FileBackend:()=>Ar});var Ar,yr=be(()=>{"use strict";ye();Ar=class{name="plaintext file";isSecure=!1;async get(t,o){let i=Ke();if(!i)return null;let r=i.profiles[o];return(r?.type==="api_key"?r.api_key:null)??null}async set(t,o,i){Cr(i,o)}async delete(t,o){try{return Bs(o),!0}catch{return!1}}async isAvailable(){return!0}}});var js={};io(js,{MacOSBackend:()=>wr});function xr(e,t){return new Promise(o=>{(0,Is.execFile)(e,t,{timeout:5e3},(i,r,n)=>{let s=i&&"code"in i?i.code:0;o({stdout:r??"",stderr:n??"",code:s})})})}var Is,wr,Ps=be(()=>{"use strict";Is=require("node:child_process");wr=class{name="macOS Keychain";isSecure=!0;async get(t,o){let{stdout:i,stderr:r,code:n}=await xr("/usr/bin/security",["find-generic-password","-s",t,"-a",o,"-w"]);if(n===44)return null;if(n!==0)throw new Error(`Failed to read from macOS Keychain (exit code ${n}): ${r.trim()}`);return i.trim()||null}async set(t,o,i){let{code:r,stderr:n}=await xr("/usr/bin/security",["add-generic-password","-s",t,"-a",o,"-w",i,"-U"]);if(r!==0)throw new Error(`Failed to store credential in macOS Keychain: ${n.trim()}`)}async delete(t,o){let{code:i}=await xr("/usr/bin/security",["delete-generic-password","-s",t,"-a",o]);return i===0}async isAvailable(){return process.platform==="darwin"}}});var $s={};io($s,{LinuxBackend:()=>vr});function Vo(e,t,o){return new Promise(i=>{(0,zo.execFile)(e,t,{timeout:o?.timeout??5e3},(r,n,s)=>{let a=r&&"code"in r?r.code:0;i({stdout:n??"",stderr:s??"",code:a})})})}function mh(e,t,o){return new Promise(i=>{let r=(0,zo.spawn)(e,t,{stdio:["pipe","ignore","pipe"],timeout:5e3}),n="";r.stderr?.on("data",s=>{n+=s.toString()}),r.on("close",s=>{i({code:s,stderr:n})}),r.on("error",()=>{i({code:1,stderr:"Failed to spawn process"})}),r.stdin?.on("error",()=>{}),r.stdin?.write(o),r.stdin?.end()})}var zo,vr,Gs=be(()=>{"use strict";zo=require("node:child_process");vr=class{name="Secret Service (libsecret)";isSecure=!0;async get(t,o){let{stdout:i,code:r}=await Vo("secret-tool",["lookup","service",t,"account",o]);return r!==0||!i.trim()?null:i.trim()}async set(t,o,i){let{code:r,stderr:n}=await mh("secret-tool",["store",`--label=Resend CLI (${o})`,"service",t,"account",o],i);if(r!==0)throw new Error(`Failed to store credential in Secret Service: ${n.trim()}`)}async delete(t,o){let{code:i}=await Vo("secret-tool",["clear","service",t,"account",o]);return i===0}async isAvailable(){if(process.platform!=="linux"||(await Vo("which",["secret-tool"])).code!==0)return!1;let o=await Vo("secret-tool",["lookup","service","__resend_cli_probe__"],{timeout:3e3});return o.code===0||o.code===1}}});var Hs={};io(Hs,{WindowsBackend:()=>Ur});function Yo(e){return new Promise(t=>{(0,Xo.execFile)("powershell.exe",["-NoProfile","-NonInteractive","-Command",e],{timeout:1e4},(o,i,r)=>{let n=o&&"code"in o?o.code:0;t({stdout:i??"",stderr:r??"",code:n})})})}function ph(e,t){return new Promise(o=>{let i=(0,Xo.spawn)("powershell.exe",["-NoProfile","-NonInteractive","-Command",e],{stdio:["pipe","pipe","pipe"],timeout:1e4}),r="",n="";i.stdout?.on("data",s=>{r+=s.toString()}),i.stderr?.on("data",s=>{n+=s.toString()}),i.on("close",s=>{o({stdout:r,stderr:n,code:s})}),i.on("error",()=>{o({stdout:"",stderr:"Failed to spawn process",code:1})}),i.stdin?.on("error",()=>{}),i.stdin?.write(t),i.stdin?.end()})}function ft(e){return e.replace(/'/g,"''")}var Xo,ho,Ur,Qs=be(()=>{"use strict";Xo=require("node:child_process");ho=`
|
|
30
30
|
try { $null = [Windows.Security.Credentials.PasswordVault] } catch {
|
|
@@ -277,7 +277,7 @@ ${r}
|
|
|
277
277
|
`&&(t=" "),(t.charCodeAt(0)>=33||[" "," "].includes(t))&&(this.node.value+=t),this.escaped=!1}},lf=50;function ur(e,t){t=t||{};let o=t._depth||0;if(o>lf)return[];let r=new cr(e).tokenize(),n=[],s=[],a=[];if(r.forEach(l=>{l.type==="operator"&&(l.value===","||l.value===";")?(s.length&&n.push(s),s=[]):s.push(l)}),s.length&&n.push(s),n.forEach(l=>{l=af(l,o),l.length&&(a=a.concat(l))}),t.flatten){let l=[],u=m=>{m.forEach(p=>{if(p.group)return u(p.group);l.push(p)})};return u(a),l}return a}var No=ur;function ds(e){for(var t="",o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=new Uint8Array(e),r=i.byteLength,n=r%3,s=r-n,a,l,u,m,p,f=0;f<s;f=f+3)p=i[f]<<16|i[f+1]<<8|i[f+2],a=(p&16515072)>>18,l=(p&258048)>>12,u=(p&4032)>>6,m=p&63,t+=o[a]+o[l]+o[u]+o[m];return n==1?(p=i[s],a=(p&252)>>2,l=(p&3)<<4,t+=o[a]+o[l]+"=="):n==2&&(p=i[s]<<8|i[s+1],a=(p&64512)>>10,l=(p&1008)>>4,u=(p&15)<<2,t+=o[a]+o[l]+o[u]+"="),t}var df=256,cf=2*1024*1024,uf=10;function mr(e){return e.replace(/-(.)/g,(t,o)=>o.toUpperCase())}function pr(e,t,o){if(e==null)return t;if(typeof e!="number"||!Number.isInteger(e)||e<0)throw new TypeError(`${o} must be a non-negative integer`);return e}var mo=class e{static async parse(t,o){return new e(o).parse(t)}constructor(t,o=0){this.options=t||{},this.mimeOptions={maxNestingDepth:pr(this.options.maxNestingDepth,df,"maxNestingDepth"),maxHeadersSize:pr(this.options.maxHeadersSize,cf,"maxHeadersSize")},this.maxRfc822NestingDepth=pr(this.options.maxRfc822NestingDepth,uf,"maxRfc822NestingDepth"),this.rfc822NestingDepth=o,this.root=this.currentNode=new jt({postalMime:this,...this.mimeOptions}),this.boundaries=[],this.textContent={},this.attachments=[],this.attachmentEncoding=(this.options.attachmentEncoding||"").toString().replace(/[-_\s]/g,"").trim().toLowerCase()||"arraybuffer",this.started=!1}async finalize(){await this.root.finalize()}async processLine(t,o){let i=this.boundaries;if(i.length&&t.length>2&&t[0]===45&&t[1]===45)for(let r=i.length-1;r>=0;r--){let n=i[r];if(t.length<n.value.length+2)continue;let s=!0;for(let m=0;m<n.value.length;m++)if(t[m+2]!==n.value[m]){s=!1;break}if(!s)continue;let a=n.value.length+2,l=!1;t.length>=n.value.length+4&&t[n.value.length+2]===45&&t[n.value.length+3]===45&&(l=!0,a=n.value.length+4);let u=!0;for(let m=a;m<t.length;m++)if(t[m]!==32&&t[m]!==9){u=!1;break}if(u)return l?(await n.node.finalize(),this.currentNode=n.node.parentNode||this.root):(await n.node.finalizeChildNodes(),this.currentNode=new jt({postalMime:this,parentNode:n.node,parentMultipartType:n.node.contentType.multipart,...this.mimeOptions})),o?this.finalize():void 0}if(this.currentNode.feed(t),o)return this.finalize()}readLine(){let t=this.readPos,o=this.readPos;for(;this.readPos<this.av.length;){let i=this.av[this.readPos++];if(i!==13&&i!==10&&(o=this.readPos),i===10)return{bytes:new Uint8Array(this.buf,t,o-t),done:this.readPos>=this.av.length}}return{bytes:new Uint8Array(this.buf,t,o-t),done:this.readPos>=this.av.length}}async processNodeTree(){let t={},o=new Set,i=this.textMap=new Map,r=this.forceRfc822Attachments(),n=async(s,a,l)=>{if(a=a||!1,l=l||!1,s.contentType.multipart)s.contentType.multipart==="alternative"?a=s:s.contentType.multipart==="related"&&(l=s);else{let u=this.isInlineMessageRfc822(s)&&!r,m=u&&this.rfc822NestingDepth>=this.maxRfc822NestingDepth;if(u&&!m){let p=new e({...this.mimeOptions,maxRfc822NestingDepth:this.maxRfc822NestingDepth,attachmentEncoding:"arraybuffer"},this.rfc822NestingDepth+1);s.subMessage=await p.parse(s.content),i.has(s)||i.set(s,{});let f=i.get(s);(s.subMessage.text||!s.subMessage.html)&&(f.plain=f.plain||[],f.plain.push({type:"subMessage",value:s.subMessage}),o.add("plain")),s.subMessage.html&&(f.html=f.html||[],f.html.push({type:"subMessage",value:s.subMessage}),o.add("html")),p.textMap&&p.textMap.forEach((y,A)=>{i.set(A,y)});for(let y of s.subMessage.attachments||[])this.attachments.push(y)}else if(this.isInlineTextNode(s)){let p=s.contentType.parsed.value.substr(s.contentType.parsed.value.indexOf("/")+1),f=a||s;i.has(f)||i.set(f,{});let y=i.get(f);y[p]=y[p]||[],y[p].push({type:"text",value:s.getTextContent()}),o.add(p)}else if(s.content){let p=s.contentDisposition?.parsed?.params?.filename||s.contentType.parsed.params.name||null,f={filename:p?kt(p):null,mimeType:s.contentType.parsed.value,disposition:s.contentDisposition?.parsed?.value||null};switch(l&&s.contentId&&!m&&(f.related=!0),m&&(f.rfc822DepthExceeded=!0),s.contentDescription&&(f.description=s.contentDescription),s.contentId&&(f.contentId=s.contentId),s.contentType.parsed.value){case"text/calendar":case"application/ics":{s.contentType.parsed.params.method&&(f.method=s.contentType.parsed.params.method.toString().toUpperCase().trim());let y=s.getTextContent().replace(/\r?\n/g,`
|
|
278
278
|
`).replace(/\n*$/,`
|
|
279
279
|
`);f.content=ut.encode(y);break}default:f.content=s.content}this.attachments.push(f)}}for(let u of s.childNodes)await n(u,a,l)};await n(this.root,!1,!1),i.forEach(s=>{o.forEach(a=>{if(t[a]||(t[a]=[]),s[a])s[a].forEach(l=>{switch(l.type){case"text":t[a].push(l.value);break;case"subMessage":switch(a){case"html":t[a].push(dr(l.value));break;case"plain":t[a].push(lr(l.value));break}break}});else{let l;switch(a){case"html":l="plain";break;case"plain":l="html";break}(s[l]||[]).forEach(u=>{switch(u.type){case"text":switch(a){case"html":t[a].push(ns(u.value));break;case"plain":t[a].push(ss(u.value));break}break;case"subMessage":switch(a){case"html":t[a].push(dr(u.value));break;case"plain":t[a].push(lr(u.value));break}break}})}})}),Object.keys(t).forEach(s=>{t[s]=t[s].join(`
|
|
280
|
-
`)}),this.textContent=t}isInlineTextNode(t){if(t.contentDisposition?.parsed?.value==="attachment")return!1;switch(t.contentType.parsed?.value){case"text/html":case"text/plain":return!0;default:return!1}}isInlineMessageRfc822(t){return t.contentType.parsed?.value!=="message/rfc822"?!1:(t.contentDisposition?.parsed?.value||(this.options.rfc822Attachments?"attachment":"inline"))==="inline"}forceRfc822Attachments(){if(this.options.forceRfc822Attachments)return!0;let t=!1,o=i=>{i.contentType.multipart||i.contentType.parsed&&["message/delivery-status","message/feedback-report"].includes(i.contentType.parsed.value)&&(t=!0);for(let r of i.childNodes)o(r)};return o(this.root),t}async resolveStream(t){let o=0,i=[],r=t.getReader();for(;;){let{done:a,value:l}=await r.read();if(a)break;i.push(l),o+=l.length}let n=new Uint8Array(o),s=0;for(let a of i)n.set(a,s),s+=a.length;return n}async parse(t){if(this.started)throw new Error("Can not reuse parser, create a new PostalMime object");for(this.started=!0,t&&typeof t.getReader=="function"&&(t=await this.resolveStream(t)),t=t||new ArrayBuffer(0),typeof t=="string"&&(t=ut.encode(t)),(t instanceof Blob||Object.prototype.toString.call(t)==="[object Blob]")&&(t=await mt(t)),t.buffer instanceof ArrayBuffer&&(t=new Uint8Array(t).buffer),this.buf=t,this.av=new Uint8Array(t),this.readPos=0;this.readPos<this.av.length;){let r=this.readLine();await this.processLine(r.bytes,r.done)}await this.processNodeTree();let o={headers:this.root.headers.map(r=>({key:r.key,originalKey:r.originalKey,value:r.value})).reverse()};for(let r of["from","sender"]){let n=this.root.headers.find(s=>s.key===r);if(n&&n.value){let s=No(n.value);s&&s.length&&(o[r]=s[0])}}for(let r of["delivered-to","return-path"]){let n=this.root.headers.find(s=>s.key===r);if(n&&n.value){let s=No(n.value);if(s&&s.length&&s[0].address){let a=mr(r);o[a]=s[0].address}}}for(let r of["to","cc","bcc","reply-to"]){let n=this.root.headers.filter(a=>a.key===r),s=[];if(n.filter(a=>a&&a.value).map(a=>No(a.value)).forEach(a=>s=s.concat(a||[])),s&&s.length){let a=mr(r);o[a]=s}}for(let r of["subject","message-id","in-reply-to","references"]){let n=this.root.headers.find(s=>s.key===r);if(n&&n.value){let s=mr(r);o[s]=kt(n.value)}}let i=this.root.headers.find(r=>r.key==="date");if(i){let r=new Date(i.value);r.toString()==="Invalid Date"?r=i.value:r=r.toISOString(),o.date=r}switch(this.textContent?.html&&(o.html=this.textContent.html),this.textContent?.plain&&(o.text=this.textContent.plain),o.attachments=this.attachments,o.headerLines=(this.root.rawHeaderLines||[]).slice().reverse(),this.attachmentEncoding){case"arraybuffer":break;case"base64":for(let n of o.attachments||[])n?.content&&(n.content=ds(n.content),n.encoding="base64");break;case"utf8":let r=new TextDecoder("utf8");for(let n of o.attachments||[])n?.content&&(n.content=r.decode(n.content),n.encoding="utf8");break;default:throw new Error("Unknown attachment encoding")}return o}};var ks=me(ys(),1),Lo=["draft_reply","forward_thread","add_labels","assign_thread","mark_as_spam","archive_thread","delete_thread"],_s=["inbox","archive","spam","sent","trash"],Fs=["inbox","archive","spam","trash"],Wo=["cyan","teal","grass","lime","yellow","orange","iris","plum","crimson","bronze","mauve"],Cf="6.32.1-preview-inboxes.3";function ae(e,t){let o=$t(t);return o?`${e}?${o}`:e}function $t(e){let t=new URLSearchParams;return e.limit!==void 0&&t.set("limit",e.limit.toString()),"after"in e&&e.after!==void 0&&t.set("after",e.after),"before"in e&&e.before!==void 0&&t.set("before",e.before),t.toString()}var xf=class{constructor(e){this.resend=e}async create(e,t={}){return await this.resend.post("/api-keys",e,t)}async list(e={},t={}){let o=ae("/api-keys",e);return await this.resend.get(o,t)}async update(e,t,o={}){return await this.resend.patch(`/api-keys/${e}`,t,o)}async remove(e,t={}){return await this.resend.delete(`/api-keys/${e}`,void 0,t)}},wf=class{constructor(e){this.resend=e}async get(e,t={}){return await this.resend.get(`/automations/${e.automationId}/runs/${e.runId}`,t)}async list(e,t={}){let o=$t(e),i=new URLSearchParams(o);if(e.status){let s=Array.isArray(e.status)?e.status.join(","):e.status;i.set("status",s)}let r=i.toString(),n=r?`/automations/${e.automationId}/runs?${r}`:`/automations/${e.automationId}/runs`;return await this.resend.get(n,t)}};function Rs(e){switch(e.type){case"trigger":return{key:e.key,type:e.type,config:{event_name:e.config.eventName}};case"delay":return{key:e.key,type:e.type,config:e.config};case"send_email":return{key:e.key,type:e.type,config:{template:e.config.template,subject:e.config.subject,from:e.config.from,reply_to:e.config.replyTo}};case"wait_for_event":return{key:e.key,type:e.type,config:{event_name:e.config.eventName,timeout:e.config.timeout,filter_rule:e.config.filterRule}};case"condition":return{key:e.key,type:e.type,config:e.config};case"contact_update":return{key:e.key,type:e.type,config:{first_name:e.config.firstName,last_name:e.config.lastName,unsubscribed:e.config.unsubscribed,properties:e.config.properties}};case"contact_delete":return{key:e.key,type:e.type,config:e.config};case"add_to_segment":return{key:e.key,type:e.type,config:{segment_id:e.config.segmentId}}}}function Ds(e){return{from:e.from,to:e.to,type:e.type}}function vf(e){return{name:e.name,status:e.status,steps:e.steps.map(Rs),connections:e.connections.map(Ds)}}function Uf(e){return{event:e.event,contact_id:e.contactId,email:e.email,payload:e.payload}}var Sf=class{constructor(e){this.resend=e,this.runs=new wf(this.resend)}async create(e,t={}){return await this.resend.post("/automations",vf(e),t)}async list(e={},t={}){let o=[$t(e)];e.status&&o.push(`status=${encodeURIComponent(e.status)}`);let i=o.filter(Boolean).join("&"),r=i?`/automations?${i}`:"/automations";return await this.resend.get(r,t)}async get(e,t={}){return await this.resend.get(`/automations/${e}`,t)}async remove(e,t={}){return await this.resend.delete(`/automations/${e}`,void 0,t)}async update(e,t,o={}){let i={};return t.name!==void 0&&(i.name=t.name),t.status!==void 0&&(i.status=t.status),t.steps!==void 0&&(i.steps=t.steps.map(Rs)),t.connections!==void 0&&(i.connections=t.connections.map(Ds)),await this.resend.patch(`/automations/${e}`,i,o)}async duplicate(e,t={}){return await this.resend.post(`/automations/${e}/duplicate`,void 0,t)}async stop(e,t={}){return await this.resend.post(`/automations/${e}/stop`,void 0,t)}};function Kf(e){return e?.map(t=>({content:t.content,filename:t.filename,path:t.path,content_type:t.contentType,content_id:t.contentId}))}function Ts(e){return{attachments:Kf(e.attachments),bcc:e.bcc,cc:e.cc,from:e.from,headers:e.headers,html:e.html,reply_to:e.replyTo,scheduled_at:e.scheduledAt,subject:e.subject,tags:e.tags,text:e.text,to:e.to,template:e.template?{id:e.template.id,variables:e.template.variables}:void 0,topic_id:e.topicId}}async function fo(e){let t;try{({render:t}=await import("@react-email/render"))}catch{throw new Error("Failed to render React component. Make sure to install `@react-email/render` or `@react-email/components`.")}return t(e)}var kf=class{constructor(e){this.resend=e}async send(e,t){return this.create(e,t)}async create(e,t){let o=[];for(let r of e)r.react&&(r.html=await fo(r.react),r.react=void 0),o.push(Ts(r));let i=new Headers({"x-batch-validation":t?.batchValidation??"strict"});for(let[r,n]of new Headers(t?.headers||void 0))i.set(r,n);return await this.resend.post("/emails/batch",o,{...t,headers:i})}},_f=class{constructor(e){this.resend=e}async create(e,t={}){let o=e.react?await fo(e.react):e.html;return await this.resend.post("/broadcasts",{name:e.name,segment_id:e.segmentId,audience_id:e.audienceId,preview_text:e.previewText,from:e.from,html:o,reply_to:e.replyTo,subject:e.subject,text:e.text,topic_id:e.topicId,send:e.send,scheduled_at:e.scheduledAt},t)}async send(e,t,o={}){return await this.resend.post(`/broadcasts/${e}/send`,{scheduled_at:t?.scheduledAt},o)}async list(e={},t={}){let o=ae("/broadcasts",e);return await this.resend.get(o,t)}async get(e,t={}){return await this.resend.get(`/broadcasts/${e}`,t)}async recipients(e,t,o={}){let i=`/broadcasts/${e}/recipients?${Ff(t)}`;return await this.resend.get(i,o)}async clickedLinks(e,t={},o={}){let i=ae(`/broadcasts/${e}/clicked-links`,t);return await this.resend.get(i,o)}async remove(e,t={}){return await this.resend.delete(`/broadcasts/${e}`,void 0,t)}async cancel(e,t={}){return await this.resend.post(`/broadcasts/${e}/cancel`,void 0,t)}async duplicate(e,t={}){return await this.resend.post(`/broadcasts/${e}/duplicate`,void 0,t)}async update(e,t,o={}){let i=t.react?await fo(t.react):t.html;return await this.resend.patch(`/broadcasts/${e}`,{name:t.name,segment_id:t.segmentId,audience_id:t.audienceId,from:t.from,html:i,text:t.text,subject:t.subject,reply_to:t.replyTo,preview_text:t.previewText,topic_id:t.topicId},o)}};function Ff(e){let{type:t,email:o,bounceType:i,...r}=e,n=new URLSearchParams($t(r));return n.set("type",t),o!==void 0&&n.set("email",o),i!==void 0&&n.set("bounce_type",i),n.toString()}function Cs(e){return{id:e.id,key:e.key,createdAt:e.created_at,type:e.type,fallbackValue:e.fallback_value}}function xs(e){return"key"in e?{key:e.key,type:e.type,fallback_value:e.fallbackValue}:{fallback_value:e.fallbackValue}}var Rf=class{constructor(e){this.resend=e}async create(e,t={}){let o=xs(e);return await this.resend.post("/contact-properties",o,t)}async list(e={},t={}){let o=ae("/contact-properties",e),i=await this.resend.get(o,t);return i.data?{data:{...i.data,data:i.data.data.map(r=>Cs(r))},headers:i.headers,error:null}:i}async get(e,t={}){if(!e)return{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}};let o=await this.resend.get(`/contact-properties/${e}`,t);return o.data?{data:{object:"contact_property",...Cs(o.data)},headers:o.headers,error:null}:o}async update(e,t={}){if(!e.id)return{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}};let o=xs(e);return await this.resend.patch(`/contact-properties/${e.id}`,o,t)}async remove(e,t={}){return e?await this.resend.delete(`/contact-properties/${e}`,void 0,t):{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}}}},Df=class{constructor(e){this.resend=e}async create(e,t={}){let o=this.buildCreateFormData(e);return this.resend.post("/contacts/imports",o,t)}async list(e={},t={}){let o=new URLSearchParams($t(e));e.status!==void 0&&o.set("status",e.status);let i=o.toString(),r=i?`/contacts/imports?${i}`:"/contacts/imports";return this.resend.get(r,t)}async get(e,t={}){return this.resend.get(`/contacts/imports/${e}`,t)}buildCreateFormData(e){let t=new FormData;return t.append("file",e.file),this.appendField(t,"column_map",this.buildColumnMap(e.columnMap??null)),this.appendField(t,"on_conflict",e.onConflict??null),this.appendField(t,"segments",e.segments??null),this.appendField(t,"topics",e.topics??null),t}buildColumnMap(e){return e===null?null:{email:e.email,first_name:e.firstName,last_name:e.lastName,unsubscribed:e.unsubscribed,properties:e.properties}}appendField(e,t,o){o!==null&&e.append(t,typeof o=="string"?o:JSON.stringify(o))}},Tf=class{constructor(e){this.resend=e}async list(e,t={}){if(!e.contactId&&!e.email)return{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}};let o=ae(`/contacts/${e.email?e.email:e.contactId}/segments`,e);return await this.resend.get(o,t)}async add(e,t={}){if(!e.contactId&&!e.email)return{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}};let o=e.email?e.email:e.contactId;return this.resend.post(`/contacts/${o}/segments/${e.segmentId}`,void 0,t)}async remove(e,t={}){if(!e.contactId&&!e.email)return{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}};let o=e.email?e.email:e.contactId;return this.resend.delete(`/contacts/${o}/segments/${e.segmentId}`,void 0,t)}},Of=class{constructor(e){this.resend=e}async update(e,t={}){if(!e.id&&!e.email)return{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}};let o=e.email?e.email:e.id;return this.resend.patch(`/contacts/${o}/topics`,e.topics,t)}async list(e,t={}){if(!e.id&&!e.email)return{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}};let o=ae(`/contacts/${e.email?e.email:e.id}/topics`,e);return this.resend.get(o,t)}},Ef=class{constructor(e){this.resend=e,this.imports=new Df(this.resend),this.topics=new Of(this.resend),this.segments=new Tf(this.resend)}async create(e,t={}){return"audienceId"in e?"segments"in e||"topics"in e?{data:null,headers:null,error:{message:"`audienceId` is deprecated, and cannot be used together with `segments` or `topics`. Use `segments` instead to add one or more segments to the new contact.",statusCode:null,name:"invalid_parameter"}}:await this.resend.post(`/audiences/${e.audienceId}/contacts`,{unsubscribed:e.unsubscribed,email:e.email,first_name:e.firstName,last_name:e.lastName,properties:e.properties},t):await this.resend.post("/contacts",{unsubscribed:e.unsubscribed,email:e.email,first_name:e.firstName,last_name:e.lastName,properties:e.properties,segments:e.segments,topics:e.topics},t)}async list(e={},t={}){let o=e.segmentId??e.audienceId;if(!o){let r=ae("/contacts",e);return await this.resend.get(r,t)}let i=ae(`/segments/${o}/contacts`,e);return await this.resend.get(i,t)}async get(e,t={}){return typeof e=="string"?this.resend.get(`/contacts/${e}`,t):!e.id&&!e.email?{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}}:e.audienceId?this.resend.get(`/audiences/${e.audienceId}/contacts/${e?.email?e?.email:e?.id}`,t):this.resend.get(`/contacts/${e?.email?e?.email:e?.id}`,t)}async update(e,t={}){return!e.id&&!e.email?{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}}:e.audienceId?await this.resend.patch(`/audiences/${e.audienceId}/contacts/${e?.email?e?.email:e?.id}`,{unsubscribed:e.unsubscribed,first_name:e.firstName,last_name:e.lastName,properties:e.properties},t):await this.resend.patch(`/contacts/${e?.email?e?.email:e?.id}`,{unsubscribed:e.unsubscribed,first_name:e.firstName,last_name:e.lastName,properties:e.properties},t)}async remove(e,t={}){return typeof e=="string"?this.resend.delete(`/contacts/${e}`,void 0,t):!e.id&&!e.email?{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}}:e.audienceId?this.resend.delete(`/audiences/${e.audienceId}/contacts/${e?.email?e?.email:e?.id}`,void 0,t):this.resend.delete(`/contacts/${e?.email?e?.email:e?.id}`,void 0,t)}};function Bf(e){return{name:e.name,region:e.region,custom_return_path:e.customReturnPath,capabilities:e.capabilities,open_tracking:e.openTracking,click_tracking:e.clickTracking,tls:e.tls,tracking_subdomain:e.trackingSubdomain}}var If=class{constructor(e){this.resend=e}async create(e,t={}){return await this.resend.post("/domains/claim",{name:e.name,region:e.region,custom_return_path:e.customReturnPath,open_tracking:e.openTracking,click_tracking:e.clickTracking,tracking_subdomain:e.trackingSubdomain},t)}async get(e,t={}){return await this.resend.get(`/domains/${e}/claim`,t)}async verify(e,t={}){return await this.resend.post(`/domains/${e}/claim/verify`,void 0,t)}},jf=class{constructor(e){this.resend=e,this.claims=new If(this.resend)}async create(e,t={}){return await this.resend.post("/domains",Bf(e),t)}async list(e={},t={}){let o=ae("/domains",e);return await this.resend.get(o,t)}async get(e,t={}){return await this.resend.get(`/domains/${e}`,t)}async update(e,t={}){return await this.resend.patch(`/domains/${e.id}`,{click_tracking:e.clickTracking,open_tracking:e.openTracking,tls:e.tls,capabilities:e.capabilities,tracking_subdomain:e.trackingSubdomain},t)}async remove(e,t={}){return await this.resend.delete(`/domains/${e}`,void 0,t)}async verify(e,t={}){return await this.resend.post(`/domains/${e}/verify`,void 0,t)}},Pf=class{constructor(e){this.resend=e}async get(e,t={}){let{emailId:o,id:i}=e;return await this.resend.get(`/emails/${o}/attachments/${i}`,t)}async list(e,t={}){let{emailId:o}=e,i=ae(`/emails/${o}/attachments`,e);return await this.resend.get(i,t)}},$f=class{constructor(e){this.resend=e}async get(e,t={}){let{emailId:o,id:i}=e;return await this.resend.get(`/emails/receiving/${o}/attachments/${i}`,t)}async list(e,t={}){let{emailId:o}=e,i=ae(`/emails/receiving/${o}/attachments`,e);return await this.resend.get(i,t)}},Gf=class{constructor(e){this.resend=e,this.attachments=new $f(e)}async get(e,t={},o={}){let i=new URLSearchParams;t.html_format!==void 0&&i.set("html_format",t.html_format);let r=i.toString(),n=r?`/emails/receiving/${e}?${r}`:`/emails/receiving/${e}`;return await this.resend.get(n,o)}async list(e={},t={}){let o=ae("/emails/receiving",e);return await this.resend.get(o,t)}async forward(e,t={}){let{emailId:o,to:i,from:r}=e,n=e.passthrough!==!1,s=await this.get(o,{},{signal:t.signal});if(s.error)return{data:null,error:s.error,headers:s.headers};let a=s.data,l=a.subject||"(no subject)";if(n)return this.forwardPassthrough(a,{to:i,from:r,subject:l},t);let u=l.startsWith("Fwd:")?l:`Fwd: ${l}`;return this.forwardWrapped(a,{to:i,from:r,subject:u,text:"text"in e?e.text:void 0,html:"html"in e?e.html:void 0},t)}async forwardPassthrough(e,t,o){let{to:i,from:r,subject:n}=t;if(!e.raw?.download_url)return{data:null,error:{name:"validation_error",message:"Raw email content is not available for this email",statusCode:400},headers:null};let s=await this.downloadRaw(e.raw.download_url,o.signal);if(s.error)return{data:null,error:s.error,headers:null};let a=await mo.parse(s.content,{attachmentEncoding:"base64"}),l=a.attachments.map(u=>{let m=u.contentId?u.contentId.replace(/^<|>$/g,""):void 0;return{filename:u.filename,content:u.content.toString(),content_type:u.mimeType,content_id:m||void 0}});return await this.resend.post("/emails",{from:r,to:i,subject:n,text:a.text||void 0,html:a.html||void 0,attachments:l.length>0?l:void 0},o)}async forwardWrapped(e,t,o){let{to:i,from:r,subject:n,text:s,html:a}=t;if(!e.raw?.download_url)return{data:null,error:{name:"validation_error",message:"Raw email content is not available for this email",statusCode:400},headers:null};let l=await this.downloadRaw(e.raw.download_url,o.signal);return l.error?{data:null,error:l.error,headers:null}:await this.resend.post("/emails",{from:r,to:i,subject:n,text:s,html:a,attachments:[{filename:"forwarded_message.eml",content:Buffer.from(l.content).toString("base64"),content_type:"message/rfc822"}]},o)}async downloadRaw(e,t){try{let o=await fetch(e,{signal:t});return o.ok?{content:await o.text(),error:null}:{content:null,error:{name:"application_error",message:"Failed to download raw email content",statusCode:o.status}}}catch{return{content:null,error:{name:"application_error",message:"Failed to download raw email content",statusCode:null}}}}},Hf=class{constructor(e){this.resend=e,this.attachments=new Pf(e),this.receiving=new Gf(e)}async send(e,t={}){return this.create(e,t)}async create(e,t={}){let o={...e};return e.react&&(o.html=await fo(e.react)),await this.resend.post("/emails",Ts(o),t)}async get(e,t={}){return await this.resend.get(`/emails/${e}`,t)}async list(e={},t={}){let o=ae("/emails",e);return await this.resend.get(o,t)}async update(e,t={}){return await this.resend.patch(`/emails/${e.id}`,{scheduled_at:e.scheduledAt},t)}async cancel(e,t={}){return await this.resend.post(`/emails/${e}/cancel`,void 0,t)}async share(e,t,o={}){return await this.resend.post(`/emails/${e}/share`,{expires_in:t?.expiresIn},o)}async metrics(e={},t={}){let o=Qf(e),i=o?`/emails/metrics?${o}`:"/emails/metrics";return await this.resend.get(i,t)}};function Qf(e){let t={start_date:e.startDate,end_date:e.endDate,timezone:e.timezone,granularity:e.granularity,metrics:e.metrics?.join(","),dimensions:e.dimensions?.join(","),domain_id:e.domainId?.join(","),email_id:e.emailId?.join(","),broadcast_id:e.broadcastId?.join(",")},o=new URLSearchParams;for(let[i,r]of Object.entries(t))r!==void 0&&r!==""&&o.set(i,r);return o.toString()}var Nf=class{constructor(e){this.resend=e}async send(e,t={}){return await this.resend.post("/events/send",Uf(e),t)}async create(e,t={}){return await this.resend.post("/events",e,t)}async get(e,t={}){return await this.resend.get(`/events/${encodeURIComponent(e)}`,t)}async list(e={},t={}){let o=ae("/events",e);return await this.resend.get(o,t)}async update(e,t,o={}){return await this.resend.patch(`/events/${encodeURIComponent(e)}`,t,o)}async remove(e,t={}){return await this.resend.delete(`/events/${encodeURIComponent(e)}`,void 0,t)}},Mf=class{constructor(e){this.resend=e}async get(e,t={}){return this.resend.get(`/inboxes/${e.inboxId}/agent`,t)}async update(e,t={}){let{inboxId:o,instructions:i,tone:r,enabledActions:n}=e;return this.resend.patch(`/inboxes/${o}/agent`,{instructions:i,tone:r,enabled_actions:n},t)}};function Os(e,t={}){let o=new URLSearchParams;t.folder!==void 0&&o.set("folder",t.folder),t.query!==void 0&&o.set("query",t.query),t.from!==void 0&&o.set("from",t.from),t.limit!==void 0&&o.set("limit",String(t.limit)),t.after!==void 0&&o.set("after",t.after),t.before!==void 0&&o.set("before",t.before);let i=t.label===void 0?[]:Array.isArray(t.label)?t.label:[t.label];for(let n of i)o.append("label",n);let r=o.toString();return r?`${e}?${r}`:e}var qf=class{constructor(e){this.resend=e}async list(e,t={}){let{inboxId:o,limit:i,after:r,before:n}=e,s=Os(`/inboxes/${o}/drafts`,{limit:i,after:r,before:n});return this.resend.get(s,t)}async create(e,t={}){let{inboxId:o,threadId:i,replyToEmailId:r,...n}=e;return this.resend.post(`/inboxes/${o}/drafts`,{...n,thread_id:i,reply_to_email_id:r},t)}async get(e,t={}){let{inboxId:o,draftId:i}=e;return this.resend.get(`/inboxes/${o}/drafts/${i}`,t)}async update(e,t={}){let{inboxId:o,draftId:i,...r}=e;return this.resend.patch(`/inboxes/${o}/drafts/${i}`,r,t)}async remove(e,t={}){let{inboxId:o,draftId:i}=e;return this.resend.delete(`/inboxes/${o}/drafts/${i}`,void 0,t)}async send(e,t={}){let{inboxId:o,draftId:i}=e;return this.resend.post(`/inboxes/${o}/drafts/${i}/send`,void 0,t)}},Lf=class{constructor(e){this.resend=e}async list(e,t={}){return this.resend.get(`/inboxes/${e.inboxId}/labels`,t)}async create(e,t={}){let{inboxId:o,name:i,color:r}=e;return this.resend.post(`/inboxes/${o}/labels`,{name:i,color:r},t)}async update(e,t={}){let{inboxId:o,labelId:i,name:r,color:n}=e;return this.resend.patch(`/inboxes/${o}/labels/${i}`,{name:r,color:n},t)}async remove(e,t={}){let{inboxId:o,labelId:i}=e;return this.resend.delete(`/inboxes/${o}/labels/${i}`,void 0,t)}},Wf=class{constructor(e){this.resend=e}async list(e,t={}){let{inboxId:o,threadId:i,...r}=e,n=ae(`/inboxes/${o}/threads/${i}/emails`,r);return this.resend.get(n,t)}async get(e,t={}){let{inboxId:o,threadId:i,emailId:r}=e;return this.resend.get(`/inboxes/${o}/threads/${i}/emails/${r}`,t)}async reply(e,t={}){let{inboxId:o,threadId:i,emailId:r,cc:n,bcc:s,html:a,text:l,subject:u}=e;return this.resend.post(`/inboxes/${o}/threads/${i}/emails/${r}/reply`,{cc:n,bcc:s,html:a,text:l,subject:u},t)}async forward(e,t={}){let{inboxId:o,threadId:i,emailId:r,to:n,cc:s,bcc:a,html:l,text:u,subject:m}=e;return this.resend.post(`/inboxes/${o}/threads/${i}/emails/${r}/forward`,{to:n,cc:s,bcc:a,html:l,text:u,subject:m},t)}},Jf=class{constructor(e){this.resend=e,this.emails=new Wf(e)}async list(e,t={}){let{inboxId:o,...i}=e,r=Os(`/inboxes/${o}/threads`,i);return this.resend.get(r,t)}async get(e,t={}){let{inboxId:o,threadId:i}=e;return this.resend.get(`/inboxes/${o}/threads/${i}`,t)}async update(e,t={}){let{inboxId:o,threadId:i,read:r,folder:n,labelId:s}=e;return this.resend.patch(`/inboxes/${o}/threads/${i}`,{read:r,folder:n,label_id:s},t)}async remove(e,t={}){let{inboxId:o,threadId:i}=e;return this.resend.delete(`/inboxes/${o}/threads/${i}`,void 0,t)}},Vf=class{constructor(e){this.resend=e,this.threads=new Jf(e),this.labels=new Lf(e),this.drafts=new qf(e),this.agent=new Mf(e)}async create(e,t={}){return this.resend.post("/inboxes",{email_address:e.emailAddress,name:e.name,forwarding:e.forwarding,from_name:e.fromName},t)}async list(e={},t={}){let o=ae("/inboxes",e);return this.resend.get(o,t)}async get(e,t={}){return this.resend.get(`/inboxes/${encodeURIComponent(e)}`,t)}async update(e,t,o={}){return this.resend.patch(`/inboxes/${e}`,{name:t.name,from_name:t.fromName},o)}async remove(e,t={}){return this.resend.delete(`/inboxes/${e}`,void 0,t)}},zf=class{constructor(e){this.resend=e}async list(e={},t={}){let o=ae("/logs",e);return await this.resend.get(o,t)}async get(e,t={}){return await this.resend.get(`/logs/${e}`,t)}},Yf=class{constructor(e){this.resend=e}async list(e={},t={}){let o=ae("/oauth/grants",e);return await this.resend.get(o,t)}async revoke(e,t={}){return await this.resend.delete(`/oauth/grants/${e}`,void 0,t)}},Xf=class{constructor(e){this.resend=e}async create(e,t={}){return await this.resend.post("/segments",e,t)}async list(e={},t={}){let o=ae("/segments",e);return await this.resend.get(o,t)}async get(e,t={}){return await this.resend.get(`/segments/${e}`,t)}async update(e,t,o={}){return await this.resend.patch(`/segments/${e}`,t,o)}async remove(e,t={}){return await this.resend.delete(`/segments/${e}`,void 0,t)}},Zf=class{constructor(e){this.resend=e}async add(e,t={}){return this.resend.post("/suppressions/batch/add",e,t)}async remove(e,t={}){return this.resend.post("/suppressions/batch/remove",e,t)}},ws=()=>({data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}}),eh=class{constructor(e){this.resend=e,this.batch=new Zf(e)}async add(e,t={}){return this.resend.post("/suppressions",e,t)}async list(e={},t={}){let o=th(e),i=o?`/suppressions?${o}`:"/suppressions";return this.resend.get(i,t)}async get(e,t={}){return e?this.resend.get(`/suppressions/${encodeURIComponent(e)}`,t):ws()}async remove(e,t={}){return e?this.resend.delete(`/suppressions/${encodeURIComponent(e)}`,void 0,t):ws()}};function th(e){let{origin:t,...o}=e,i=new URLSearchParams($t(o));return t&&i.set("origin",t),i.toString()}function oh(e={}){let t=new URLSearchParams;return e.before&&t.set("before",e.before),e.after&&t.set("after",e.after),e.limit&&t.set("limit",e.limit.toString()),t.size>0?`?${t.toString()}`:""}function ih(e){return e?.map(t=>({key:t.key,type:t.type,fallback_value:t.fallbackValue}))}function vs(e){return{name:"name"in e?e.name:void 0,subject:e.subject,html:e.html,text:e.text,alias:e.alias,from:e.from,reply_to:e.replyTo,variables:ih(e.variables)}}var Us=class{constructor(e,t){this.promise=e,this.publishFn=t}then(e,t){return this.promise.then(e,t)}async publish(e={}){let{data:t,error:o}=await this.promise;return o?{data:null,headers:null,error:o}:this.publishFn(t.id,e)}},rh=class{constructor(e){this.resend=e}create(e,t={}){return new Us(this.performCreate(e,t),this.publish.bind(this))}async performCreate(e,t){let o={...e};return e.react&&(o.html=await fo(e.react)),this.resend.post("/templates",vs(o),t)}async remove(e,t={}){return await this.resend.delete(`/templates/${e}`,void 0,t)}async get(e,t={}){return await this.resend.get(`/templates/${e}`,t)}async list(e={},t={}){return this.resend.get(`/templates${oh(e)}`,t)}duplicate(e,t={}){return new Us(this.resend.post(`/templates/${e}/duplicate`,void 0,t),this.publish.bind(this))}async publish(e,t={}){return await this.resend.post(`/templates/${e}/publish`,void 0,t)}async update(e,t,o={}){return await this.resend.patch(`/templates/${e}`,vs(t),o)}},nh=class{constructor(e){this.resend=e}async create(e,t={}){let{defaultSubscription:o,...i}=e;return await this.resend.post("/topics",{...i,default_subscription:o},t)}async list(e={}){return await this.resend.get("/topics",e)}async get(e,t={}){return e?await this.resend.get(`/topics/${e}`,t):{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}}}async update(e,t={}){return e.id?await this.resend.patch(`/topics/${e.id}`,e,t):{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}}}async remove(e,t={}){return e?await this.resend.delete(`/topics/${e}`,void 0,t):{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}}}},sh=class{constructor(e){this.resend=e}async get(e={}){return await this.resend.get("/usage",e)}},ah=class{constructor(e){this.resend=e}async list(e,t={}){let{webhookId:o,eventId:i}=e,r=ae(`/webhooks/${o}/events/${i}/attempts`,e);return await this.resend.get(r,t)}},lh=class{constructor(e){this.resend=e,this.attempts=new ah(e)}async list(e,t={}){let{webhookId:o}=e,i=ae(`/webhooks/${o}/events`,e);return await this.resend.get(i,t)}async get(e,t={}){let{webhookId:o,eventId:i}=e;return await this.resend.get(`/webhooks/${o}/events/${i}`,t)}async replay(e,t={}){let{webhookId:o,eventId:i}=e;return await this.resend.post(`/webhooks/${o}/events/${i}/replay`,void 0,t)}},dh=class{constructor(e){this.resend=e,this.events=new lh(e)}async create(e,t={}){return await this.resend.post("/webhooks",e,t)}async get(e,t={}){return await this.resend.get(`/webhooks/${e}`,t)}async list(e={},t={}){let o=ae("/webhooks",e);return await this.resend.get(o,t)}async update(e,t,o={}){return await this.resend.patch(`/webhooks/${e}`,t,o)}async remove(e,t={}){return await this.resend.delete(`/webhooks/${e}`,void 0,t)}async rotateSigningSecret(e,t={}){return await this.resend.post(`/webhooks/${e}/signing-secret/rotate`,void 0,t)}verify(e){return new ks.Webhook(e.webhookSecret).verify(e.payload,{"webhook-id":e.headers.id,"webhook-timestamp":e.headers.timestamp,"webhook-signature":e.headers.signature})}},Ss="https://api.resend.com",Ks=`resend-node:${Cf}`;function ch(){return typeof process<"u"&&process.env&&process.env.RESEND_BASE_URL||Ss}function uh(){return typeof process<"u"&&process.env&&process.env.RESEND_USER_AGENT||Ks}var Gt=class{constructor(e,t){if(this.key=e,this.segments=new Xf(this),this.apiKeys=new xf(this),this.audiences=this.segments,this.automations=new Sf(this),this.batch=new kf(this),this.broadcasts=new _f(this),this.contactProperties=new Rf(this),this.contacts=new Ef(this),this.domains=new jf(this),this.emails=new Hf(this),this.events=new Nf(this),this.inboxes=new Vf(this),this.logs=new zf(this),this.oauthGrants=new Yf(this),this.suppressions=new eh(this),this.templates=new rh(this),this.topics=new nh(this),this.usage=new sh(this),this.webhooks=new dh(this),!e&&(typeof process<"u"&&process.env&&(this.key=process.env.RESEND_API_KEY),!this.key))throw new Error('Missing API key. Pass it to the constructor `new Resend("re_123")`');this.baseUrl=t?.baseUrl??ch(),this.userAgent=t?.userAgent??uh(),this.headers=new Headers({Authorization:`Bearer ${this.key}`,"User-Agent":this.userAgent,"Content-Type":"application/json"})}logError(e,t,o){typeof process<"u"&&process.env&&process.env.NODE_ENV!=="production"&&console.error("[Resend API Error]:",{...o!==void 0&&{status:o},error:e,path:t})}async fetchRequest(e,t={}){let{signal:o}=t;try{let i=await fetch(`${this.baseUrl}${e}`,t);if(!i.ok)try{let r=await i.text(),n=JSON.parse(r);return this.logError(n,e,i.status),{data:null,error:n,headers:Object.fromEntries(i.headers.entries())}}catch(r){if(o?.aborted&&r===o.reason)throw r;if(r instanceof SyntaxError){let s={name:"application_error",statusCode:i.status,message:"Internal server error. We are unable to process your request right now, please try again later."};return this.logError(s,e,i.status),{data:null,error:s,headers:Object.fromEntries(i.headers.entries())}}let n={message:i.statusText,statusCode:i.status,name:"application_error"};if(r instanceof Error){let s={...n,message:r.message};return this.logError(s,e,i.status),{data:null,error:s,headers:Object.fromEntries(i.headers.entries())}}return this.logError(n,e,i.status),{data:null,error:n,headers:Object.fromEntries(i.headers.entries())}}return{data:await i.json(),error:null,headers:Object.fromEntries(i.headers.entries())}}catch{let i={name:"application_error",statusCode:null,message:"Unable to fetch data. The request could not be resolved."};return this.logError(i,e),{data:null,error:i,headers:null}}}async post(e,t,o={}){let i=new Headers(this.headers),r=typeof FormData<"u"&&t instanceof FormData;if(r&&i.delete("Content-Type"),o.headers)for(let[s,a]of new Headers(o.headers).entries())i.set(s,a);o.idempotencyKey&&i.set("Idempotency-Key",o.idempotencyKey);let n={method:"POST",body:r?t:JSON.stringify(t),...o,headers:i};return this.fetchRequest(e,n)}async get(e,t={}){let o=new Headers(this.headers);if(t.headers)for(let[r,n]of new Headers(t.headers).entries())o.set(r,n);let i={method:"GET",...t,headers:o};return this.fetchRequest(e,i)}async put(e,t,o={}){let i=new Headers(this.headers);if(o.headers)for(let[n,s]of new Headers(o.headers).entries())i.set(n,s);let r={method:"PUT",body:JSON.stringify(t),...o,headers:i};return this.fetchRequest(e,r)}async patch(e,t,o={}){let i=new Headers(this.headers);if(o.headers)for(let[n,s]of new Headers(o.headers).entries())i.set(n,s);let r={method:"PATCH",body:JSON.stringify(t),...o,headers:i};return this.fetchRequest(e,r)}async delete(e,t,o={}){let i=new Headers(this.headers);if(o.headers)for(let[n,s]of new Headers(o.headers).entries())i.set(n,s);let r={method:"DELETE",body:t===void 0?void 0:JSON.stringify(t),...o,headers:i};return this.fetchRequest(e,r)}};ye();var Or=me(Je(),1);function W(e,t){return e instanceof Error?e.message:t}function pa(e){return!!(e||!process.stdout.isTTY)}function M(e,t={}){pa(t.json)?console.log(JSON.stringify(e,null,2)):console.log(typeof e=="string"?e:JSON.stringify(e,null,2)),t.exitCode!==void 0&&process.exit(t.exitCode)}var Sh=new Set(["content-type","retry-after"]);function Kh(e){let t={};for(let[o,i]of Object.entries(e)){let r=o.toLowerCase();(Sh.has(r)||r.startsWith("x-"))&&(t[r]=i)}return t}function h(e,t={}){let o=t.exitCode??1,i=e.headers&&Object.keys(e.headers).length>0?Kh(e.headers):void 0,r=i!==void 0&&Object.keys(i).length>0;if(pa(t.json)){let n={message:e.message,code:e.code??"unknown"};typeof e.statusCode=="number"&&(n.statusCode=e.statusCode),r&&(n.headers=i),typeof e.body=="string"&&e.body.length>0&&(n.body=e.body),console.error(JSON.stringify({error:n},null,2))}else{console.error(`${Or.default.red("Error:")} ${e.message}`);let n=[];if(typeof e.statusCode=="number"&&n.push(`HTTP ${e.statusCode}`),r)for(let[s,a]of Object.entries(i))n.push(`${s}: ${a}`);n.length>0&&console.error(Or.default.dim(`[${n.join("; ")}]`))}process.exit(o)}var fa={sending_access:0,full_access:1};function kh(e,t){return fa[e]>=fa[t]}async function ee(e,t){let o=e.profile;try{let i=await Rt(e.apiKey,o);if(!i){if(o){let s=Fe();if(!s.some(l=>l.name===o))throw new Error(`Profile "${o}" not found. Available profiles: ${s.map(l=>l.name).join(", ")||"(none)"}`)}throw new Error("No API key found. Set RESEND_API_KEY, use --api-key, or run: resend login")}let r;if(i.type==="api_key")r=i.permission;else{let s=i.scope.split(" ").filter(Boolean);s.includes("full_access")?r="full_access":s.includes("emails:send")?r="sending_access":h({message:`Unrecognized credential scope${i.scope?` "${i.scope}"`:""}. Run \`resend login\` to re-authenticate.`,code:"unrecognized_scope"},{json:e.json})}if(r){let s=t?.permission??"full_access";kh(r,s)||h({message:`This command requires full access. Your current credential has sending access only.
|
|
280
|
+
`)}),this.textContent=t}isInlineTextNode(t){if(t.contentDisposition?.parsed?.value==="attachment")return!1;switch(t.contentType.parsed?.value){case"text/html":case"text/plain":return!0;default:return!1}}isInlineMessageRfc822(t){return t.contentType.parsed?.value!=="message/rfc822"?!1:(t.contentDisposition?.parsed?.value||(this.options.rfc822Attachments?"attachment":"inline"))==="inline"}forceRfc822Attachments(){if(this.options.forceRfc822Attachments)return!0;let t=!1,o=i=>{i.contentType.multipart||i.contentType.parsed&&["message/delivery-status","message/feedback-report"].includes(i.contentType.parsed.value)&&(t=!0);for(let r of i.childNodes)o(r)};return o(this.root),t}async resolveStream(t){let o=0,i=[],r=t.getReader();for(;;){let{done:a,value:l}=await r.read();if(a)break;i.push(l),o+=l.length}let n=new Uint8Array(o),s=0;for(let a of i)n.set(a,s),s+=a.length;return n}async parse(t){if(this.started)throw new Error("Can not reuse parser, create a new PostalMime object");for(this.started=!0,t&&typeof t.getReader=="function"&&(t=await this.resolveStream(t)),t=t||new ArrayBuffer(0),typeof t=="string"&&(t=ut.encode(t)),(t instanceof Blob||Object.prototype.toString.call(t)==="[object Blob]")&&(t=await mt(t)),t.buffer instanceof ArrayBuffer&&(t=new Uint8Array(t).buffer),this.buf=t,this.av=new Uint8Array(t),this.readPos=0;this.readPos<this.av.length;){let r=this.readLine();await this.processLine(r.bytes,r.done)}await this.processNodeTree();let o={headers:this.root.headers.map(r=>({key:r.key,originalKey:r.originalKey,value:r.value})).reverse()};for(let r of["from","sender"]){let n=this.root.headers.find(s=>s.key===r);if(n&&n.value){let s=No(n.value);s&&s.length&&(o[r]=s[0])}}for(let r of["delivered-to","return-path"]){let n=this.root.headers.find(s=>s.key===r);if(n&&n.value){let s=No(n.value);if(s&&s.length&&s[0].address){let a=mr(r);o[a]=s[0].address}}}for(let r of["to","cc","bcc","reply-to"]){let n=this.root.headers.filter(a=>a.key===r),s=[];if(n.filter(a=>a&&a.value).map(a=>No(a.value)).forEach(a=>s=s.concat(a||[])),s&&s.length){let a=mr(r);o[a]=s}}for(let r of["subject","message-id","in-reply-to","references"]){let n=this.root.headers.find(s=>s.key===r);if(n&&n.value){let s=mr(r);o[s]=kt(n.value)}}let i=this.root.headers.find(r=>r.key==="date");if(i){let r=new Date(i.value);r.toString()==="Invalid Date"?r=i.value:r=r.toISOString(),o.date=r}switch(this.textContent?.html&&(o.html=this.textContent.html),this.textContent?.plain&&(o.text=this.textContent.plain),o.attachments=this.attachments,o.headerLines=(this.root.rawHeaderLines||[]).slice().reverse(),this.attachmentEncoding){case"arraybuffer":break;case"base64":for(let n of o.attachments||[])n?.content&&(n.content=ds(n.content),n.encoding="base64");break;case"utf8":let r=new TextDecoder("utf8");for(let n of o.attachments||[])n?.content&&(n.content=r.decode(n.content),n.encoding="utf8");break;default:throw new Error("Unknown attachment encoding")}return o}};var ks=me(ys(),1),Lo=["draft_reply","forward_thread","add_labels","assign_thread","mark_as_spam","archive_thread","delete_thread"],_s=["inbox","archive","spam","sent","trash"],Fs=["inbox","archive","spam","trash"],Wo=["cyan","teal","grass","lime","yellow","orange","iris","plum","crimson","bronze","mauve"],Cf="6.32.1-preview-inboxes.4";function ae(e,t){let o=$t(t);return o?`${e}?${o}`:e}function $t(e){let t=new URLSearchParams;return e.limit!==void 0&&t.set("limit",e.limit.toString()),"after"in e&&e.after!==void 0&&t.set("after",e.after),"before"in e&&e.before!==void 0&&t.set("before",e.before),t.toString()}var xf=class{constructor(e){this.resend=e}async create(e,t={}){return await this.resend.post("/api-keys",e,t)}async list(e={},t={}){let o=ae("/api-keys",e);return await this.resend.get(o,t)}async update(e,t,o={}){return await this.resend.patch(`/api-keys/${e}`,t,o)}async remove(e,t={}){return await this.resend.delete(`/api-keys/${e}`,void 0,t)}},wf=class{constructor(e){this.resend=e}async get(e,t={}){return await this.resend.get(`/automations/${e.automationId}/runs/${e.runId}`,t)}async list(e,t={}){let o=$t(e),i=new URLSearchParams(o);if(e.status){let s=Array.isArray(e.status)?e.status.join(","):e.status;i.set("status",s)}let r=i.toString(),n=r?`/automations/${e.automationId}/runs?${r}`:`/automations/${e.automationId}/runs`;return await this.resend.get(n,t)}};function Rs(e){switch(e.type){case"trigger":return{key:e.key,type:e.type,config:{event_name:e.config.eventName}};case"delay":return{key:e.key,type:e.type,config:e.config};case"send_email":return{key:e.key,type:e.type,config:{template:e.config.template,subject:e.config.subject,from:e.config.from,reply_to:e.config.replyTo}};case"wait_for_event":return{key:e.key,type:e.type,config:{event_name:e.config.eventName,timeout:e.config.timeout,filter_rule:e.config.filterRule}};case"condition":return{key:e.key,type:e.type,config:e.config};case"contact_update":return{key:e.key,type:e.type,config:{first_name:e.config.firstName,last_name:e.config.lastName,unsubscribed:e.config.unsubscribed,properties:e.config.properties}};case"contact_delete":return{key:e.key,type:e.type,config:e.config};case"add_to_segment":return{key:e.key,type:e.type,config:{segment_id:e.config.segmentId}}}}function Ds(e){return{from:e.from,to:e.to,type:e.type}}function vf(e){return{name:e.name,status:e.status,steps:e.steps.map(Rs),connections:e.connections.map(Ds)}}function Uf(e){return{event:e.event,contact_id:e.contactId,email:e.email,payload:e.payload}}var Sf=class{constructor(e){this.resend=e,this.runs=new wf(this.resend)}async create(e,t={}){return await this.resend.post("/automations",vf(e),t)}async list(e={},t={}){let o=[$t(e)];e.status&&o.push(`status=${encodeURIComponent(e.status)}`);let i=o.filter(Boolean).join("&"),r=i?`/automations?${i}`:"/automations";return await this.resend.get(r,t)}async get(e,t={}){return await this.resend.get(`/automations/${e}`,t)}async remove(e,t={}){return await this.resend.delete(`/automations/${e}`,void 0,t)}async update(e,t,o={}){let i={};return t.name!==void 0&&(i.name=t.name),t.status!==void 0&&(i.status=t.status),t.steps!==void 0&&(i.steps=t.steps.map(Rs)),t.connections!==void 0&&(i.connections=t.connections.map(Ds)),await this.resend.patch(`/automations/${e}`,i,o)}async duplicate(e,t={}){return await this.resend.post(`/automations/${e}/duplicate`,void 0,t)}async stop(e,t={}){return await this.resend.post(`/automations/${e}/stop`,void 0,t)}};function Kf(e){return e?.map(t=>({content:t.content,filename:t.filename,path:t.path,content_type:t.contentType,content_id:t.contentId}))}function Ts(e){return{attachments:Kf(e.attachments),bcc:e.bcc,cc:e.cc,from:e.from,headers:e.headers,html:e.html,reply_to:e.replyTo,scheduled_at:e.scheduledAt,subject:e.subject,tags:e.tags,text:e.text,to:e.to,template:e.template?{id:e.template.id,variables:e.template.variables}:void 0,topic_id:e.topicId}}async function fo(e){let t;try{({render:t}=await import("@react-email/render"))}catch{throw new Error("Failed to render React component. Make sure to install `@react-email/render` or `@react-email/components`.")}return t(e)}var kf=class{constructor(e){this.resend=e}async send(e,t){return this.create(e,t)}async create(e,t){let o=[];for(let r of e)r.react&&(r.html=await fo(r.react),r.react=void 0),o.push(Ts(r));let i=new Headers({"x-batch-validation":t?.batchValidation??"strict"});for(let[r,n]of new Headers(t?.headers||void 0))i.set(r,n);return await this.resend.post("/emails/batch",o,{...t,headers:i})}},_f=class{constructor(e){this.resend=e}async create(e,t={}){let o=e.react?await fo(e.react):e.html;return await this.resend.post("/broadcasts",{name:e.name,segment_id:e.segmentId,audience_id:e.audienceId,preview_text:e.previewText,from:e.from,html:o,reply_to:e.replyTo,subject:e.subject,text:e.text,topic_id:e.topicId,send:e.send,scheduled_at:e.scheduledAt},t)}async send(e,t,o={}){return await this.resend.post(`/broadcasts/${e}/send`,{scheduled_at:t?.scheduledAt},o)}async list(e={},t={}){let o=ae("/broadcasts",e);return await this.resend.get(o,t)}async get(e,t={}){return await this.resend.get(`/broadcasts/${e}`,t)}async recipients(e,t,o={}){let i=`/broadcasts/${e}/recipients?${Ff(t)}`;return await this.resend.get(i,o)}async clickedLinks(e,t={},o={}){let i=ae(`/broadcasts/${e}/clicked-links`,t);return await this.resend.get(i,o)}async remove(e,t={}){return await this.resend.delete(`/broadcasts/${e}`,void 0,t)}async cancel(e,t={}){return await this.resend.post(`/broadcasts/${e}/cancel`,void 0,t)}async duplicate(e,t={}){return await this.resend.post(`/broadcasts/${e}/duplicate`,void 0,t)}async update(e,t,o={}){let i=t.react?await fo(t.react):t.html;return await this.resend.patch(`/broadcasts/${e}`,{name:t.name,segment_id:t.segmentId,audience_id:t.audienceId,from:t.from,html:i,text:t.text,subject:t.subject,reply_to:t.replyTo,preview_text:t.previewText,topic_id:t.topicId},o)}};function Ff(e){let{type:t,email:o,bounceType:i,...r}=e,n=new URLSearchParams($t(r));return n.set("type",t),o!==void 0&&n.set("email",o),i!==void 0&&n.set("bounce_type",i),n.toString()}function Cs(e){return{id:e.id,key:e.key,createdAt:e.created_at,type:e.type,fallbackValue:e.fallback_value}}function xs(e){return"key"in e?{key:e.key,type:e.type,fallback_value:e.fallbackValue}:{fallback_value:e.fallbackValue}}var Rf=class{constructor(e){this.resend=e}async create(e,t={}){let o=xs(e);return await this.resend.post("/contact-properties",o,t)}async list(e={},t={}){let o=ae("/contact-properties",e),i=await this.resend.get(o,t);return i.data?{data:{...i.data,data:i.data.data.map(r=>Cs(r))},headers:i.headers,error:null}:i}async get(e,t={}){if(!e)return{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}};let o=await this.resend.get(`/contact-properties/${e}`,t);return o.data?{data:{object:"contact_property",...Cs(o.data)},headers:o.headers,error:null}:o}async update(e,t={}){if(!e.id)return{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}};let o=xs(e);return await this.resend.patch(`/contact-properties/${e.id}`,o,t)}async remove(e,t={}){return e?await this.resend.delete(`/contact-properties/${e}`,void 0,t):{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}}}},Df=class{constructor(e){this.resend=e}async create(e,t={}){let o=this.buildCreateFormData(e);return this.resend.post("/contacts/imports",o,t)}async list(e={},t={}){let o=new URLSearchParams($t(e));e.status!==void 0&&o.set("status",e.status);let i=o.toString(),r=i?`/contacts/imports?${i}`:"/contacts/imports";return this.resend.get(r,t)}async get(e,t={}){return this.resend.get(`/contacts/imports/${e}`,t)}buildCreateFormData(e){let t=new FormData;return t.append("file",e.file),this.appendField(t,"column_map",this.buildColumnMap(e.columnMap??null)),this.appendField(t,"on_conflict",e.onConflict??null),this.appendField(t,"segments",e.segments??null),this.appendField(t,"topics",e.topics??null),t}buildColumnMap(e){return e===null?null:{email:e.email,first_name:e.firstName,last_name:e.lastName,unsubscribed:e.unsubscribed,properties:e.properties}}appendField(e,t,o){o!==null&&e.append(t,typeof o=="string"?o:JSON.stringify(o))}},Tf=class{constructor(e){this.resend=e}async list(e,t={}){if(!e.contactId&&!e.email)return{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}};let o=ae(`/contacts/${e.email?e.email:e.contactId}/segments`,e);return await this.resend.get(o,t)}async add(e,t={}){if(!e.contactId&&!e.email)return{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}};let o=e.email?e.email:e.contactId;return this.resend.post(`/contacts/${o}/segments/${e.segmentId}`,void 0,t)}async remove(e,t={}){if(!e.contactId&&!e.email)return{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}};let o=e.email?e.email:e.contactId;return this.resend.delete(`/contacts/${o}/segments/${e.segmentId}`,void 0,t)}},Of=class{constructor(e){this.resend=e}async update(e,t={}){if(!e.id&&!e.email)return{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}};let o=e.email?e.email:e.id;return this.resend.patch(`/contacts/${o}/topics`,e.topics,t)}async list(e,t={}){if(!e.id&&!e.email)return{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}};let o=ae(`/contacts/${e.email?e.email:e.id}/topics`,e);return this.resend.get(o,t)}},Ef=class{constructor(e){this.resend=e,this.imports=new Df(this.resend),this.topics=new Of(this.resend),this.segments=new Tf(this.resend)}async create(e,t={}){return"audienceId"in e?"segments"in e||"topics"in e?{data:null,headers:null,error:{message:"`audienceId` is deprecated, and cannot be used together with `segments` or `topics`. Use `segments` instead to add one or more segments to the new contact.",statusCode:null,name:"invalid_parameter"}}:await this.resend.post(`/audiences/${e.audienceId}/contacts`,{unsubscribed:e.unsubscribed,email:e.email,first_name:e.firstName,last_name:e.lastName,properties:e.properties},t):await this.resend.post("/contacts",{unsubscribed:e.unsubscribed,email:e.email,first_name:e.firstName,last_name:e.lastName,properties:e.properties,segments:e.segments,topics:e.topics},t)}async list(e={},t={}){let o=e.segmentId??e.audienceId;if(!o){let r=ae("/contacts",e);return await this.resend.get(r,t)}let i=ae(`/segments/${o}/contacts`,e);return await this.resend.get(i,t)}async get(e,t={}){return typeof e=="string"?this.resend.get(`/contacts/${e}`,t):!e.id&&!e.email?{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}}:e.audienceId?this.resend.get(`/audiences/${e.audienceId}/contacts/${e?.email?e?.email:e?.id}`,t):this.resend.get(`/contacts/${e?.email?e?.email:e?.id}`,t)}async update(e,t={}){return!e.id&&!e.email?{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}}:e.audienceId?await this.resend.patch(`/audiences/${e.audienceId}/contacts/${e?.email?e?.email:e?.id}`,{unsubscribed:e.unsubscribed,first_name:e.firstName,last_name:e.lastName,properties:e.properties},t):await this.resend.patch(`/contacts/${e?.email?e?.email:e?.id}`,{unsubscribed:e.unsubscribed,first_name:e.firstName,last_name:e.lastName,properties:e.properties},t)}async remove(e,t={}){return typeof e=="string"?this.resend.delete(`/contacts/${e}`,void 0,t):!e.id&&!e.email?{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}}:e.audienceId?this.resend.delete(`/audiences/${e.audienceId}/contacts/${e?.email?e?.email:e?.id}`,void 0,t):this.resend.delete(`/contacts/${e?.email?e?.email:e?.id}`,void 0,t)}};function Bf(e){return{name:e.name,region:e.region,custom_return_path:e.customReturnPath,capabilities:e.capabilities,open_tracking:e.openTracking,click_tracking:e.clickTracking,tls:e.tls,tracking_subdomain:e.trackingSubdomain}}var If=class{constructor(e){this.resend=e}async create(e,t={}){return await this.resend.post("/domains/claim",{name:e.name,region:e.region,custom_return_path:e.customReturnPath,open_tracking:e.openTracking,click_tracking:e.clickTracking,tracking_subdomain:e.trackingSubdomain},t)}async get(e,t={}){return await this.resend.get(`/domains/${e}/claim`,t)}async verify(e,t={}){return await this.resend.post(`/domains/${e}/claim/verify`,void 0,t)}},jf=class{constructor(e){this.resend=e,this.claims=new If(this.resend)}async create(e,t={}){return await this.resend.post("/domains",Bf(e),t)}async list(e={},t={}){let o=ae("/domains",e);return await this.resend.get(o,t)}async get(e,t={}){return await this.resend.get(`/domains/${e}`,t)}async update(e,t={}){return await this.resend.patch(`/domains/${e.id}`,{click_tracking:e.clickTracking,open_tracking:e.openTracking,tls:e.tls,capabilities:e.capabilities,tracking_subdomain:e.trackingSubdomain},t)}async remove(e,t={}){return await this.resend.delete(`/domains/${e}`,void 0,t)}async verify(e,t={}){return await this.resend.post(`/domains/${e}/verify`,void 0,t)}},Pf=class{constructor(e){this.resend=e}async get(e,t={}){let{emailId:o,id:i}=e;return await this.resend.get(`/emails/${o}/attachments/${i}`,t)}async list(e,t={}){let{emailId:o}=e,i=ae(`/emails/${o}/attachments`,e);return await this.resend.get(i,t)}},$f=class{constructor(e){this.resend=e}async get(e,t={}){let{emailId:o,id:i}=e;return await this.resend.get(`/emails/receiving/${o}/attachments/${i}`,t)}async list(e,t={}){let{emailId:o}=e,i=ae(`/emails/receiving/${o}/attachments`,e);return await this.resend.get(i,t)}},Gf=class{constructor(e){this.resend=e,this.attachments=new $f(e)}async get(e,t={},o={}){let i=new URLSearchParams;t.html_format!==void 0&&i.set("html_format",t.html_format);let r=i.toString(),n=r?`/emails/receiving/${e}?${r}`:`/emails/receiving/${e}`;return await this.resend.get(n,o)}async list(e={},t={}){let o=ae("/emails/receiving",e);return await this.resend.get(o,t)}async forward(e,t={}){let{emailId:o,to:i,from:r}=e,n=e.passthrough!==!1,s=await this.get(o,{},{signal:t.signal});if(s.error)return{data:null,error:s.error,headers:s.headers};let a=s.data,l=a.subject||"(no subject)";if(n)return this.forwardPassthrough(a,{to:i,from:r,subject:l},t);let u=l.startsWith("Fwd:")?l:`Fwd: ${l}`;return this.forwardWrapped(a,{to:i,from:r,subject:u,text:"text"in e?e.text:void 0,html:"html"in e?e.html:void 0},t)}async forwardPassthrough(e,t,o){let{to:i,from:r,subject:n}=t;if(!e.raw?.download_url)return{data:null,error:{name:"validation_error",message:"Raw email content is not available for this email",statusCode:400},headers:null};let s=await this.downloadRaw(e.raw.download_url,o.signal);if(s.error)return{data:null,error:s.error,headers:null};let a=await mo.parse(s.content,{attachmentEncoding:"base64"}),l=a.attachments.map(u=>{let m=u.contentId?u.contentId.replace(/^<|>$/g,""):void 0;return{filename:u.filename,content:u.content.toString(),content_type:u.mimeType,content_id:m||void 0}});return await this.resend.post("/emails",{from:r,to:i,subject:n,text:a.text||void 0,html:a.html||void 0,attachments:l.length>0?l:void 0},o)}async forwardWrapped(e,t,o){let{to:i,from:r,subject:n,text:s,html:a}=t;if(!e.raw?.download_url)return{data:null,error:{name:"validation_error",message:"Raw email content is not available for this email",statusCode:400},headers:null};let l=await this.downloadRaw(e.raw.download_url,o.signal);return l.error?{data:null,error:l.error,headers:null}:await this.resend.post("/emails",{from:r,to:i,subject:n,text:s,html:a,attachments:[{filename:"forwarded_message.eml",content:Buffer.from(l.content).toString("base64"),content_type:"message/rfc822"}]},o)}async downloadRaw(e,t){try{let o=await fetch(e,{signal:t});return o.ok?{content:await o.text(),error:null}:{content:null,error:{name:"application_error",message:"Failed to download raw email content",statusCode:o.status}}}catch{return{content:null,error:{name:"application_error",message:"Failed to download raw email content",statusCode:null}}}}},Hf=class{constructor(e){this.resend=e,this.attachments=new Pf(e),this.receiving=new Gf(e)}async send(e,t={}){return this.create(e,t)}async create(e,t={}){let o={...e};return e.react&&(o.html=await fo(e.react)),await this.resend.post("/emails",Ts(o),t)}async get(e,t={}){return await this.resend.get(`/emails/${e}`,t)}async list(e={},t={}){let o=ae("/emails",e);return await this.resend.get(o,t)}async update(e,t={}){return await this.resend.patch(`/emails/${e.id}`,{scheduled_at:e.scheduledAt},t)}async cancel(e,t={}){return await this.resend.post(`/emails/${e}/cancel`,void 0,t)}async share(e,t,o={}){return await this.resend.post(`/emails/${e}/share`,{expires_in:t?.expiresIn},o)}async metrics(e={},t={}){let o=Qf(e),i=o?`/emails/metrics?${o}`:"/emails/metrics";return await this.resend.get(i,t)}};function Qf(e){let t={start_date:e.startDate,end_date:e.endDate,timezone:e.timezone,granularity:e.granularity,metrics:e.metrics?.join(","),dimensions:e.dimensions?.join(","),domain_id:e.domainId?.join(","),email_id:e.emailId?.join(","),broadcast_id:e.broadcastId?.join(",")},o=new URLSearchParams;for(let[i,r]of Object.entries(t))r!==void 0&&r!==""&&o.set(i,r);return o.toString()}var Nf=class{constructor(e){this.resend=e}async send(e,t={}){return await this.resend.post("/events/send",Uf(e),t)}async create(e,t={}){return await this.resend.post("/events",e,t)}async get(e,t={}){return await this.resend.get(`/events/${encodeURIComponent(e)}`,t)}async list(e={},t={}){let o=ae("/events",e);return await this.resend.get(o,t)}async update(e,t,o={}){return await this.resend.patch(`/events/${encodeURIComponent(e)}`,t,o)}async remove(e,t={}){return await this.resend.delete(`/events/${encodeURIComponent(e)}`,void 0,t)}},Mf=class{constructor(e){this.resend=e}async get(e,t={}){return this.resend.get(`/inboxes/${e.inboxId}/agent`,t)}async update(e,t={}){let{inboxId:o,instructions:i,tone:r,enabledActions:n}=e;return this.resend.patch(`/inboxes/${o}/agent`,{instructions:i,tone:r,enabled_actions:n},t)}};function Os(e,t={}){let o=new URLSearchParams;t.folder!==void 0&&o.set("folder",t.folder),t.query!==void 0&&o.set("query",t.query),t.from!==void 0&&o.set("from",t.from),t.limit!==void 0&&o.set("limit",String(t.limit)),t.after!==void 0&&o.set("after",t.after),t.before!==void 0&&o.set("before",t.before);let i=t.label===void 0?[]:Array.isArray(t.label)?t.label:[t.label];for(let n of i)o.append("label",n);let r=o.toString();return r?`${e}?${r}`:e}var qf=class{constructor(e){this.resend=e}async list(e,t={}){let{inboxId:o,limit:i,after:r,before:n}=e,s=Os(`/inboxes/${o}/drafts`,{limit:i,after:r,before:n});return this.resend.get(s,t)}async create(e,t={}){let{inboxId:o,threadId:i,replyToEmailId:r,...n}=e;return this.resend.post(`/inboxes/${o}/drafts`,{...n,thread_id:i,reply_to_email_id:r},t)}async get(e,t={}){let{inboxId:o,draftId:i}=e;return this.resend.get(`/inboxes/${o}/drafts/${i}`,t)}async update(e,t={}){let{inboxId:o,draftId:i,...r}=e;return this.resend.patch(`/inboxes/${o}/drafts/${i}`,r,t)}async remove(e,t={}){let{inboxId:o,draftId:i}=e;return this.resend.delete(`/inboxes/${o}/drafts/${i}`,void 0,t)}async send(e,t={}){let{inboxId:o,draftId:i}=e;return this.resend.post(`/inboxes/${o}/drafts/${i}/send`,void 0,t)}},Lf=class{constructor(e){this.resend=e}async list(e,t={}){return this.resend.get(`/inboxes/${e.inboxId}/labels`,t)}async create(e,t={}){let{inboxId:o,name:i,color:r}=e;return this.resend.post(`/inboxes/${o}/labels`,{name:i,color:r},t)}async update(e,t={}){let{inboxId:o,labelId:i,name:r,color:n}=e;return this.resend.patch(`/inboxes/${o}/labels/${i}`,{name:r,color:n},t)}async remove(e,t={}){let{inboxId:o,labelId:i}=e;return this.resend.delete(`/inboxes/${o}/labels/${i}`,void 0,t)}},Wf=class{constructor(e){this.resend=e}async list(e,t={}){let{inboxId:o,threadId:i,...r}=e,n=ae(`/inboxes/${o}/threads/${i}/emails`,r);return this.resend.get(n,t)}async get(e,t={}){let{inboxId:o,threadId:i,emailId:r}=e;return this.resend.get(`/inboxes/${o}/threads/${i}/emails/${r}`,t)}async reply(e,t={}){let{inboxId:o,threadId:i,emailId:r,cc:n,bcc:s,html:a,text:l,subject:u,replyAll:m}=e;return this.resend.post(`/inboxes/${o}/threads/${i}/emails/${r}/reply`,{cc:n,bcc:s,html:a,text:l,subject:u,reply_all:m},t)}async forward(e,t={}){let{inboxId:o,threadId:i,emailId:r,to:n,cc:s,bcc:a,html:l,text:u,subject:m}=e;return this.resend.post(`/inboxes/${o}/threads/${i}/emails/${r}/forward`,{to:n,cc:s,bcc:a,html:l,text:u,subject:m},t)}},Jf=class{constructor(e){this.resend=e,this.emails=new Wf(e)}async list(e,t={}){let{inboxId:o,...i}=e,r=Os(`/inboxes/${o}/threads`,i);return this.resend.get(r,t)}async get(e,t={}){let{inboxId:o,threadId:i}=e;return this.resend.get(`/inboxes/${o}/threads/${i}`,t)}async update(e,t={}){let{inboxId:o,threadId:i,read:r,folder:n,labelId:s}=e;return this.resend.patch(`/inboxes/${o}/threads/${i}`,{read:r,folder:n,label_id:s},t)}async remove(e,t={}){let{inboxId:o,threadId:i}=e;return this.resend.delete(`/inboxes/${o}/threads/${i}`,void 0,t)}},Vf=class{constructor(e){this.resend=e,this.threads=new Jf(e),this.labels=new Lf(e),this.drafts=new qf(e),this.agent=new Mf(e)}async create(e,t={}){return this.resend.post("/inboxes",{email_address:e.emailAddress,name:e.name,forwarding:e.forwarding,from_name:e.fromName},t)}async list(e={},t={}){let o=ae("/inboxes",e);return this.resend.get(o,t)}async get(e,t={}){return this.resend.get(`/inboxes/${encodeURIComponent(e)}`,t)}async update(e,t,o={}){return this.resend.patch(`/inboxes/${e}`,{name:t.name,from_name:t.fromName},o)}async remove(e,t={}){return this.resend.delete(`/inboxes/${e}`,void 0,t)}},zf=class{constructor(e){this.resend=e}async list(e={},t={}){let o=ae("/logs",e);return await this.resend.get(o,t)}async get(e,t={}){return await this.resend.get(`/logs/${e}`,t)}},Yf=class{constructor(e){this.resend=e}async list(e={},t={}){let o=ae("/oauth/grants",e);return await this.resend.get(o,t)}async revoke(e,t={}){return await this.resend.delete(`/oauth/grants/${e}`,void 0,t)}},Xf=class{constructor(e){this.resend=e}async create(e,t={}){return await this.resend.post("/segments",e,t)}async list(e={},t={}){let o=ae("/segments",e);return await this.resend.get(o,t)}async get(e,t={}){return await this.resend.get(`/segments/${e}`,t)}async update(e,t,o={}){return await this.resend.patch(`/segments/${e}`,t,o)}async remove(e,t={}){return await this.resend.delete(`/segments/${e}`,void 0,t)}},Zf=class{constructor(e){this.resend=e}async add(e,t={}){return this.resend.post("/suppressions/batch/add",e,t)}async remove(e,t={}){return this.resend.post("/suppressions/batch/remove",e,t)}},ws=()=>({data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}}),eh=class{constructor(e){this.resend=e,this.batch=new Zf(e)}async add(e,t={}){return this.resend.post("/suppressions",e,t)}async list(e={},t={}){let o=th(e),i=o?`/suppressions?${o}`:"/suppressions";return this.resend.get(i,t)}async get(e,t={}){return e?this.resend.get(`/suppressions/${encodeURIComponent(e)}`,t):ws()}async remove(e,t={}){return e?this.resend.delete(`/suppressions/${encodeURIComponent(e)}`,void 0,t):ws()}};function th(e){let{origin:t,...o}=e,i=new URLSearchParams($t(o));return t&&i.set("origin",t),i.toString()}function oh(e={}){let t=new URLSearchParams;return e.before&&t.set("before",e.before),e.after&&t.set("after",e.after),e.limit&&t.set("limit",e.limit.toString()),t.size>0?`?${t.toString()}`:""}function ih(e){return e?.map(t=>({key:t.key,type:t.type,fallback_value:t.fallbackValue}))}function vs(e){return{name:"name"in e?e.name:void 0,subject:e.subject,html:e.html,text:e.text,alias:e.alias,from:e.from,reply_to:e.replyTo,variables:ih(e.variables)}}var Us=class{constructor(e,t){this.promise=e,this.publishFn=t}then(e,t){return this.promise.then(e,t)}async publish(e={}){let{data:t,error:o}=await this.promise;return o?{data:null,headers:null,error:o}:this.publishFn(t.id,e)}},rh=class{constructor(e){this.resend=e}create(e,t={}){return new Us(this.performCreate(e,t),this.publish.bind(this))}async performCreate(e,t){let o={...e};return e.react&&(o.html=await fo(e.react)),this.resend.post("/templates",vs(o),t)}async remove(e,t={}){return await this.resend.delete(`/templates/${e}`,void 0,t)}async get(e,t={}){return await this.resend.get(`/templates/${e}`,t)}async list(e={},t={}){return this.resend.get(`/templates${oh(e)}`,t)}duplicate(e,t={}){return new Us(this.resend.post(`/templates/${e}/duplicate`,void 0,t),this.publish.bind(this))}async publish(e,t={}){return await this.resend.post(`/templates/${e}/publish`,void 0,t)}async update(e,t,o={}){return await this.resend.patch(`/templates/${e}`,vs(t),o)}},nh=class{constructor(e){this.resend=e}async create(e,t={}){let{defaultSubscription:o,...i}=e;return await this.resend.post("/topics",{...i,default_subscription:o},t)}async list(e={}){return await this.resend.get("/topics",e)}async get(e,t={}){return e?await this.resend.get(`/topics/${e}`,t):{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}}}async update(e,t={}){return e.id?await this.resend.patch(`/topics/${e.id}`,e,t):{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}}}async remove(e,t={}){return e?await this.resend.delete(`/topics/${e}`,void 0,t):{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}}}},sh=class{constructor(e){this.resend=e}async get(e={}){return await this.resend.get("/usage",e)}},ah=class{constructor(e){this.resend=e}async list(e,t={}){let{webhookId:o,eventId:i}=e,r=ae(`/webhooks/${o}/events/${i}/attempts`,e);return await this.resend.get(r,t)}},lh=class{constructor(e){this.resend=e,this.attempts=new ah(e)}async list(e,t={}){let{webhookId:o}=e,i=ae(`/webhooks/${o}/events`,e);return await this.resend.get(i,t)}async get(e,t={}){let{webhookId:o,eventId:i}=e;return await this.resend.get(`/webhooks/${o}/events/${i}`,t)}async replay(e,t={}){let{webhookId:o,eventId:i}=e;return await this.resend.post(`/webhooks/${o}/events/${i}/replay`,void 0,t)}},dh=class{constructor(e){this.resend=e,this.events=new lh(e)}async create(e,t={}){return await this.resend.post("/webhooks",e,t)}async get(e,t={}){return await this.resend.get(`/webhooks/${e}`,t)}async list(e={},t={}){let o=ae("/webhooks",e);return await this.resend.get(o,t)}async update(e,t,o={}){return await this.resend.patch(`/webhooks/${e}`,t,o)}async remove(e,t={}){return await this.resend.delete(`/webhooks/${e}`,void 0,t)}async rotateSigningSecret(e,t={}){return await this.resend.post(`/webhooks/${e}/signing-secret/rotate`,void 0,t)}verify(e){return new ks.Webhook(e.webhookSecret).verify(e.payload,{"webhook-id":e.headers.id,"webhook-timestamp":e.headers.timestamp,"webhook-signature":e.headers.signature})}},Ss="https://api.resend.com",Ks=`resend-node:${Cf}`;function ch(){return typeof process<"u"&&process.env&&process.env.RESEND_BASE_URL||Ss}function uh(){return typeof process<"u"&&process.env&&process.env.RESEND_USER_AGENT||Ks}var Gt=class{constructor(e,t){if(this.key=e,this.segments=new Xf(this),this.apiKeys=new xf(this),this.audiences=this.segments,this.automations=new Sf(this),this.batch=new kf(this),this.broadcasts=new _f(this),this.contactProperties=new Rf(this),this.contacts=new Ef(this),this.domains=new jf(this),this.emails=new Hf(this),this.events=new Nf(this),this.inboxes=new Vf(this),this.logs=new zf(this),this.oauthGrants=new Yf(this),this.suppressions=new eh(this),this.templates=new rh(this),this.topics=new nh(this),this.usage=new sh(this),this.webhooks=new dh(this),!e&&(typeof process<"u"&&process.env&&(this.key=process.env.RESEND_API_KEY),!this.key))throw new Error('Missing API key. Pass it to the constructor `new Resend("re_123")`');this.baseUrl=t?.baseUrl??ch(),this.userAgent=t?.userAgent??uh(),this.headers=new Headers({Authorization:`Bearer ${this.key}`,"User-Agent":this.userAgent,"Content-Type":"application/json"})}logError(e,t,o){typeof process<"u"&&process.env&&process.env.NODE_ENV!=="production"&&console.error("[Resend API Error]:",{...o!==void 0&&{status:o},error:e,path:t})}async fetchRequest(e,t={}){let{signal:o}=t;try{let i=await fetch(`${this.baseUrl}${e}`,t);if(!i.ok)try{let r=await i.text(),n=JSON.parse(r);return this.logError(n,e,i.status),{data:null,error:n,headers:Object.fromEntries(i.headers.entries())}}catch(r){if(o?.aborted&&r===o.reason)throw r;if(r instanceof SyntaxError){let s={name:"application_error",statusCode:i.status,message:"Internal server error. We are unable to process your request right now, please try again later."};return this.logError(s,e,i.status),{data:null,error:s,headers:Object.fromEntries(i.headers.entries())}}let n={message:i.statusText,statusCode:i.status,name:"application_error"};if(r instanceof Error){let s={...n,message:r.message};return this.logError(s,e,i.status),{data:null,error:s,headers:Object.fromEntries(i.headers.entries())}}return this.logError(n,e,i.status),{data:null,error:n,headers:Object.fromEntries(i.headers.entries())}}return{data:await i.json(),error:null,headers:Object.fromEntries(i.headers.entries())}}catch{let i={name:"application_error",statusCode:null,message:"Unable to fetch data. The request could not be resolved."};return this.logError(i,e),{data:null,error:i,headers:null}}}async post(e,t,o={}){let i=new Headers(this.headers),r=typeof FormData<"u"&&t instanceof FormData;if(r&&i.delete("Content-Type"),o.headers)for(let[s,a]of new Headers(o.headers).entries())i.set(s,a);o.idempotencyKey&&i.set("Idempotency-Key",o.idempotencyKey);let n={method:"POST",body:r?t:JSON.stringify(t),...o,headers:i};return this.fetchRequest(e,n)}async get(e,t={}){let o=new Headers(this.headers);if(t.headers)for(let[r,n]of new Headers(t.headers).entries())o.set(r,n);let i={method:"GET",...t,headers:o};return this.fetchRequest(e,i)}async put(e,t,o={}){let i=new Headers(this.headers);if(o.headers)for(let[n,s]of new Headers(o.headers).entries())i.set(n,s);let r={method:"PUT",body:JSON.stringify(t),...o,headers:i};return this.fetchRequest(e,r)}async patch(e,t,o={}){let i=new Headers(this.headers);if(o.headers)for(let[n,s]of new Headers(o.headers).entries())i.set(n,s);let r={method:"PATCH",body:JSON.stringify(t),...o,headers:i};return this.fetchRequest(e,r)}async delete(e,t,o={}){let i=new Headers(this.headers);if(o.headers)for(let[n,s]of new Headers(o.headers).entries())i.set(n,s);let r={method:"DELETE",body:t===void 0?void 0:JSON.stringify(t),...o,headers:i};return this.fetchRequest(e,r)}};ye();var Or=me(Je(),1);function W(e,t){return e instanceof Error?e.message:t}function pa(e){return!!(e||!process.stdout.isTTY)}function M(e,t={}){pa(t.json)?console.log(JSON.stringify(e,null,2)):console.log(typeof e=="string"?e:JSON.stringify(e,null,2)),t.exitCode!==void 0&&process.exit(t.exitCode)}var Sh=new Set(["content-type","retry-after"]);function Kh(e){let t={};for(let[o,i]of Object.entries(e)){let r=o.toLowerCase();(Sh.has(r)||r.startsWith("x-"))&&(t[r]=i)}return t}function h(e,t={}){let o=t.exitCode??1,i=e.headers&&Object.keys(e.headers).length>0?Kh(e.headers):void 0,r=i!==void 0&&Object.keys(i).length>0;if(pa(t.json)){let n={message:e.message,code:e.code??"unknown"};typeof e.statusCode=="number"&&(n.statusCode=e.statusCode),r&&(n.headers=i),typeof e.body=="string"&&e.body.length>0&&(n.body=e.body),console.error(JSON.stringify({error:n},null,2))}else{console.error(`${Or.default.red("Error:")} ${e.message}`);let n=[];if(typeof e.statusCode=="number"&&n.push(`HTTP ${e.statusCode}`),r)for(let[s,a]of Object.entries(i))n.push(`${s}: ${a}`);n.length>0&&console.error(Or.default.dim(`[${n.join("; ")}]`))}process.exit(o)}var fa={sending_access:0,full_access:1};function kh(e,t){return fa[e]>=fa[t]}async function ee(e,t){let o=e.profile;try{let i=await Rt(e.apiKey,o);if(!i){if(o){let s=Fe();if(!s.some(l=>l.name===o))throw new Error(`Profile "${o}" not found. Available profiles: ${s.map(l=>l.name).join(", ")||"(none)"}`)}throw new Error("No API key found. Set RESEND_API_KEY, use --api-key, or run: resend login")}let r;if(i.type==="api_key")r=i.permission;else{let s=i.scope.split(" ").filter(Boolean);s.includes("full_access")?r="full_access":s.includes("emails:send")?r="sending_access":h({message:`Unrecognized credential scope${i.scope?` "${i.scope}"`:""}. Run \`resend login\` to re-authenticate.`,code:"unrecognized_scope"},{json:e.json})}if(r){let s=t?.permission??"full_access";kh(r,s)||h({message:`This command requires full access. Your current credential has sending access only.
|
|
281
281
|
${Qt}`,code:"insufficient_permissions"},{json:e.json})}let n=i.type==="api_key"?i.key:i.access_token;return new Gt(n)}catch(i){h({message:W(i,"Failed to create client"),code:"auth_error"},{json:e.json})}}var ha=130;function _h(){process.stderr.isTTY&&process.stderr.write("\r\x1B[2K"),console.error("Cancelled."),process.exit(ha)}var Nt;function ga(){Nt=_h,process.on("SIGINT",Nt),process.on("uncaughtException",e=>{h({message:W(e,"An unexpected error occurred"),code:"unexpected_error"},{}),process.exit(1)})}function ni(e){Nt&&process.removeListener("SIGINT",Nt),Nt=e,process.on("SIGINT",Nt)}function Mt(){return ha}ye();var si=me(Je(),1);X();var Aa=[1,2,4],Fh=Aa.length,Rh=new Set(["internal_server_error","service_unavailable","gateway_timeout"]),Dh=(e,t)=>!!(e==="rate_limit_exceeded"||t&&e!==void 0&&Rh.has(e)),Th=e=>{let t=e?.["retry-after"];if(!t)return;let o=Number(t);if(Number.isFinite(o)&&o>=0)return o;let i=Date.parse(t);if(!Number.isNaN(i)){let r=(i-Date.now())/1e3;return r>0?r:0}},Oh=e=>new Promise(t=>setTimeout(t,e)),bo=async(e,t,o=0)=>{let i=await e(),r=t?.retryTransient??!1;if(i.error&&o<Fh&&Dh(i.error.name,r)){let n=Th(i.headers)??Aa[o];return t?.onRetry?.(o,n,i.error.name??""),await Oh(n*1e3),bo(e,t,o+1)}return i};var ba=(e,t)=>new Promise((o,i)=>{let r=setTimeout(()=>{i(new Error(`Request timed out after ${t/1e3}s`))},t);r.unref(),e.then(n=>{clearTimeout(r),o(n)},n=>{clearTimeout(r),i(n)})});var Bh=st?String.fromCodePoint(10004):"v",Ih=st?String.fromCodePoint(9888):"!",jh=st?String.fromCodePoint(10007):"x",Ph=["\u2839","\u2838","\u2834","\u2826","\u2807","\u280F","\u2819","\u2839"],$h=80;async function de(e,t,o,i,r={}){let n=le(e,i.quiet);try{let{data:s,error:a,headers:l}=await bo(()=>ba(t(),3e4),{retryTransient:r.retryTransient,onRetry:(u,m,p)=>{n.update(p==="rate_limit_exceeded"?`Rate limited, retrying in ${m}s...`:`Server error, retrying in ${m}s...`)}});return a&&(n.stop(),h({message:a.message,code:o,statusCode:a.statusCode,headers:l},{json:i.json})),s===null&&(n.stop(),h({message:"Unexpected empty response",code:o,headers:l},{json:i.json})),n.stop(),s}catch(s){return n.stop(),h({message:W(s,"Unknown error"),code:o},{json:i.json})}}function le(e,t){if(t||!w())return{update(a){},stop(a){},clear(){},warn(a){},fail(a){}};let o=st?Ph:["-","\\","|","/"],i=$h,r=0,n=e,s=setInterval(()=>{process.stderr.write(`\r\x1B[2K ${o[r++%o.length]} ${n}`)},i);return{update(a){n=a},stop(a){clearInterval(s),a?process.stderr.write(`\r\x1B[2K ${si.default.green(Bh)} ${a}
|
|
282
282
|
`):process.stderr.write("\r\x1B[2K")},clear(){clearInterval(s),process.stderr.write("\r\x1B[2K")},warn(a){clearInterval(s),process.stderr.write(`\r\x1B[2K ${si.default.yellow(Ih)} ${a}
|
|
283
283
|
`)},fail(a){clearInterval(s),process.stderr.write(`\r\x1B[2K ${si.default.red(jh)} ${a}
|
|
@@ -756,10 +756,13 @@ filter with "resend inboxes threads list --inbox_id <inbox_id> --label <label_id
|
|
|
756
756
|
ID: ${r.id}
|
|
757
757
|
All messages in this thread will be removed.`,loading:"Deleting thread...",object:"inbox_thread",successMsg:"Thread deleted",sdkCall:n=>n.inboxes.threads.remove({inboxId:i,threadId:r.id})},o)});var zr=(e,t)=>[...t,e],Vc=new d("forward").description("Forward an email in a thread to other recipients").option("--inbox_id <id>","Inbox UUID").option("--thread_id <id>","Thread UUID").option("--email_id <id>",'Email UUID to forward (from "threads emails list")').option("--to <address>","Recipient address (repeat the flag for multiple recipients)",zr,[]).option("--cc <address>","Cc address (repeat the flag for multiple addresses)",zr,[]).option("--bcc <address>","Bcc address (repeat the flag for multiple addresses)",zr,[]).option("--text <text>","Plain text note to include with the forward").option("--html <html>","HTML note to include with the forward").option("--subject <subject>","Override the forwarded subject").option("--idempotency-key <key>","Deduplicate this send request using this key").addHelpText("after",c({context:`Forwards the email from the inbox address. --to is required; --text/--html add an optional note.
|
|
758
758
|
--to, --cc, and --bcc combined cannot exceed 50 recipients.`,output:' {"id":"<uuid>","email_id":"<uuid>","direction":"outbound","from":"<inbox-address>","to":["<recipient>"],"cc":[],"bcc":[],"reply_to":[],"subject":"<subject>|null","message_id":"<message-id>|null","html":"<html>|null","text":"<text>|null","attachments":[],"read":true,"received_at":"<date>"}',errorCodes:["auth_error","missing_id","missing_to","create_error"],examples:["resend inboxes threads emails forward --inbox_id <inbox_id> --thread_id <thread_id> --email_id <email_id> --to teammate@example.com",'resend inboxes threads emails forward --inbox_id <inbox_id> --thread_id <thread_id> --email_id <email_id> --to a@x.com --to b@x.com --cc c@x.com --text "FYI" --json']})).action(async(e,t)=>{let o=t.optsWithGlobals();e.to.length===0&&h({message:"Provide at least one recipient with --to.",code:"missing_to"},{json:o.json});let i=await g(e.inbox_id,H,o),r=await g(e.thread_id,Ee(i),o),n=await E(e.email_id,{message:"Email ID to forward",placeholder:'from "threads emails list"'},{message:"Missing --email_id flag.",code:"missing_id"},o);await P({loading:"Forwarding email...",sdkCall:s=>s.inboxes.threads.emails.forward({inboxId:i,threadId:r,emailId:n,to:e.to,...e.cc.length>0&&{cc:e.cc},...e.bcc.length>0&&{bcc:e.bcc},...e.text&&{text:e.text},...e.html&&{html:e.html},...e.subject&&{subject:e.subject}},e.idempotencyKey?{idempotencyKey:e.idempotencyKey}:void 0),onInteractive:s=>{console.log(`Email forwarded: ${s.email_id}`),console.log(`To: ${s.to.join(", ")}`)}},o)});var zc=new d("get").description("Retrieve a single email from a thread").option("--inbox_id <id>","Inbox UUID").option("--thread_id <id>","Thread UUID").option("--email_id <id>",'Email UUID (from "threads emails list")').addHelpText("after",c({output:' {"id":"<uuid>","direction":"inbound|outbound","from":"<sender>","to":[],"cc":[],"bcc":[],"reply_to":[],"subject":"<subject>|null","message_id":"<message-id>|null","html":"<html>|null","text":"<text>|null","attachments":[{"id":"<id>","filename":"<name>|null","size":123|null}],"read":true,"received_at":"<date>"}',errorCodes:["auth_error","missing_id","fetch_error"],examples:["resend inboxes threads emails get --inbox_id <inbox_id> --thread_id <thread_id> --email_id <email_id>","resend inboxes threads emails get --inbox_id <inbox_id> --thread_id <thread_id> --email_id <email_id> --json"]})).action(async(e,t)=>{let o=t.optsWithGlobals(),i=await g(e.inbox_id,H,o),r=await g(e.thread_id,Ee(i),o),n=await E(e.email_id,{message:"Email ID",placeholder:'from "threads emails list"'},{message:"Missing --email_id flag.",code:"missing_id"},o);await B({loading:"Fetching email...",sdkCall:s=>s.inboxes.threads.emails.get({inboxId:i,threadId:r,emailId:n}),onInteractive:s=>{console.log(`${s.subject??"(no subject)"}`),console.log(`ID: ${s.id}`),console.log(`[${s.direction}] ${s.from} \xB7 ${s.received_at}`),console.log(`To: ${s.to.join(", ")}`),s.attachments.length>0&&console.log(`Attachments: ${s.attachments.map(a=>a.filename??a.id).join(", ")}`),console.log(""),console.log(s.text??s.html??"(no body)")}},o)});var Yc=new d("list").alias("ls").description("List the emails in a thread").option("--inbox_id <id>","Inbox UUID").option("--thread_id <id>","Thread UUID").option("--limit <n>","Maximum number of emails to return (1-100)","10").option("--after <cursor>","Cursor for forward pagination \u2014 list emails after this email ID").option("--before <cursor>","Cursor for backward pagination \u2014 list emails before this email ID").addHelpText("after",c({context:`Emails are ordered oldest first and include their html and text bodies.
|
|
759
|
-
Pass the last email ID of the previous page as --after to fetch the next page.`,output:' {"object":"list","has_more":false,"data":[{"id":"<uuid>","direction":"inbound|outbound","from":"<sender>","to":[],"cc":[],"bcc":[],"reply_to":[],"subject":"<subject>|null","message_id":"<message-id>|null","html":"<html>|null","text":"<text>|null","attachments":[],"read":true,"received_at":"<date>"}]}',errorCodes:["auth_error","invalid_limit","invalid_pagination","list_error"],examples:["resend inboxes threads emails list --inbox_id <inbox_id> --thread_id <thread_id>","resend inboxes threads emails list --inbox_id <inbox_id> --thread_id <thread_id> --json","resend inboxes threads emails list --inbox_id <inbox_id> --thread_id <thread_id> --limit 25 --after <email_id> --json"]})).action(async(e,t)=>{let o=t.optsWithGlobals(),i=D(e.limit,o),r=I(i,e.after,e.before,o),n=await g(e.inbox_id,H,o),s=await g(e.thread_id,Ee(n),o);await S({loading:"Fetching emails...",sdkCall:a=>a.inboxes.threads.emails.list({inboxId:n,threadId:s,...r}),onInteractive:a=>{console.log(Wc(a.data)),T(a,"inboxes threads emails list",{limit:i,before:e.before,apiKey:o.apiKey,profile:o.profile,extraFlags:`--inbox_id ${n} --thread_id ${s}`})}},o)});var Xc=(e,t)=>[...t,e],Zc=new d("reply").description("Reply to an email in a thread").option("--inbox_id <id>","Inbox UUID").option("--thread_id <id>","Thread UUID").option("--email_id <id>",'Email UUID to reply to (from "threads emails list")').option("--cc <address>","Cc address (repeat the flag for multiple addresses)",Xc,[]).option("--bcc <address>","Bcc address (repeat the flag for multiple addresses)",Xc,[]).option("--text <text>","Plain text body of the reply").option("--html <html>","HTML body of the reply").option("--subject <subject>","Override the reply subject").option("--idempotency-key <key>","Deduplicate this send request using this key").addHelpText("after",c({context:`Sends the reply from the inbox address. The
|
|
759
|
+
Pass the last email ID of the previous page as --after to fetch the next page.`,output:' {"object":"list","has_more":false,"data":[{"id":"<uuid>","direction":"inbound|outbound","from":"<sender>","to":[],"cc":[],"bcc":[],"reply_to":[],"subject":"<subject>|null","message_id":"<message-id>|null","html":"<html>|null","text":"<text>|null","attachments":[],"read":true,"received_at":"<date>"}]}',errorCodes:["auth_error","invalid_limit","invalid_pagination","list_error"],examples:["resend inboxes threads emails list --inbox_id <inbox_id> --thread_id <thread_id>","resend inboxes threads emails list --inbox_id <inbox_id> --thread_id <thread_id> --json","resend inboxes threads emails list --inbox_id <inbox_id> --thread_id <thread_id> --limit 25 --after <email_id> --json"]})).action(async(e,t)=>{let o=t.optsWithGlobals(),i=D(e.limit,o),r=I(i,e.after,e.before,o),n=await g(e.inbox_id,H,o),s=await g(e.thread_id,Ee(n),o);await S({loading:"Fetching emails...",sdkCall:a=>a.inboxes.threads.emails.list({inboxId:n,threadId:s,...r}),onInteractive:a=>{console.log(Wc(a.data)),T(a,"inboxes threads emails list",{limit:i,before:e.before,apiKey:o.apiKey,profile:o.profile,extraFlags:`--inbox_id ${n} --thread_id ${s}`})}},o)});var Xc=(e,t)=>[...t,e],Zc=new d("reply").description("Reply to an email in a thread").option("--inbox_id <id>","Inbox UUID").option("--thread_id <id>","Thread UUID").option("--email_id <id>",'Email UUID to reply to (from "threads emails list")').option("--cc <address>","Cc address (repeat the flag for multiple addresses)",Xc,[]).option("--bcc <address>","Bcc address (repeat the flag for multiple addresses)",Xc,[]).option("--text <text>","Plain text body of the reply").option("--html <html>","HTML body of the reply").option("--subject <subject>","Override the reply subject").option("--reply-all","Reply to everyone on the original email, not only the sender").option("--idempotency-key <key>","Deduplicate this send request using this key").addHelpText("after",c({context:`Sends the reply from the inbox address. The recipients come from the original email.
|
|
760
760
|
At least one of --text or --html is required.
|
|
761
|
-
--cc and --bcc are not copied from the original email
|
|
762
|
-
|
|
761
|
+
--cc and --bcc are not copied from the original email, unless you pass --reply-all,
|
|
762
|
+
which copies cc. Pass --cc and --bcc to add recipients.
|
|
763
|
+
--reply-all keeps the sender in "to" and carries the other "to" and "cc" recipients
|
|
764
|
+
of the original email into "cc", without the inbox address.
|
|
765
|
+
The total number of recipients cannot exceed 50.`,output:' {"id":"<uuid>","email_id":"<uuid>","direction":"outbound","from":"<inbox-address>","to":["<recipient>"],"cc":[],"bcc":[],"reply_to":[],"subject":"<subject>|null","message_id":"<message-id>|null","html":"<html>|null","text":"<text>|null","attachments":[],"read":true,"received_at":"<date>"}',errorCodes:["auth_error","missing_id","missing_content","create_error"],examples:['resend inboxes threads emails reply --inbox_id <inbox_id> --thread_id <thread_id> --email_id <email_id> --text "On it \u2014 reply to follow."','resend inboxes threads emails reply --inbox_id <inbox_id> --thread_id <thread_id> --email_id <email_id> --html "<p>Done!</p>" --json','resend inboxes threads emails reply --inbox_id <inbox_id> --thread_id <thread_id> --email_id <email_id> --text "Looping in finance." --cc finance@example.com','resend inboxes threads emails reply --inbox_id <inbox_id> --thread_id <thread_id> --email_id <email_id> --text "Thanks, all." --reply-all']})).action(async(e,t)=>{let o=t.optsWithGlobals(),{text:i,html:r}=e;!i&&!r&&h({message:"Provide --text or --html for the reply body.",code:"missing_content"},{json:o.json});let n=await g(e.inbox_id,H,o),s=await g(e.thread_id,Ee(n),o),a=await E(e.email_id,{message:"Email ID to reply to",placeholder:'from "threads emails list"'},{message:"Missing --email_id flag.",code:"missing_id"},o),l=i?{text:i,...r&&{html:r}}:{html:r};await P({loading:"Sending reply...",sdkCall:u=>u.inboxes.threads.emails.reply({inboxId:n,threadId:s,emailId:a,...l,...e.cc.length>0&&{cc:e.cc},...e.bcc.length>0&&{bcc:e.bcc},...e.subject&&{subject:e.subject},...e.replyAll&&{replyAll:!0}},e.idempotencyKey?{idempotencyKey:e.idempotencyKey}:void 0),onInteractive:u=>{console.log(`Reply sent: ${u.email_id}`),console.log(`To: ${u.to.join(", ")}`),u.cc.length>0&&console.log(`Cc: ${u.cc.join(", ")}`)}},o)});var eu=new d("emails").description("Work with individual emails in a thread").addHelpText("after",c({context:'Email IDs come from "resend inboxes threads emails list", which lists the messages in a thread.',examples:["resend inboxes threads emails list --inbox_id <inbox_id> --thread_id <thread_id>","resend inboxes threads emails get --inbox_id <inbox_id> --thread_id <thread_id> --email_id <email_id>",'resend inboxes threads emails reply --inbox_id <inbox_id> --thread_id <thread_id> --email_id <email_id> --text "Thanks!"',"resend inboxes threads emails forward --inbox_id <inbox_id> --thread_id <thread_id> --email_id <email_id> --to teammate@example.com"]})).addCommand(Yc,{isDefault:!0}).addCommand(zc).addCommand(Zc).addCommand(Vc);var tu=new d("get").description("Retrieve a thread").option("--inbox_id <id>","Inbox UUID").option("--thread_id <id>","Thread UUID").addHelpText("after",c({context:'Returns the thread summary. To read its messages, use "resend inboxes threads emails list".',output:' {"object":"inbox_thread","id":"<uuid>","subject":"<subject>|null","folder":"inbox|archive|spam|sent|trash","labels":[],"read":true}',errorCodes:["auth_error","fetch_error"],examples:["resend inboxes threads get --inbox_id 78261eea-8f8b-4381-83c6-79fa7120f1cf --thread_id 3deaccfa-f572-443c-be6f-92b74f9d5c48","resend inboxes threads get --inbox_id 78261eea-8f8b-4381-83c6-79fa7120f1cf --thread_id 3deaccfa-f572-443c-be6f-92b74f9d5c48 --json"]})).action(async(e,t)=>{let o=t.optsWithGlobals(),i=await g(e.inbox_id,H,o),r=await g(e.thread_id,Ee(i),o);await B({loading:"Fetching thread...",sdkCall:n=>n.inboxes.threads.get({inboxId:i,threadId:r}),onInteractive:n=>{console.log(`${n.subject??"(no subject)"}`),console.log(`ID: ${n.id}`),console.log(`Folder: ${n.folder}`),n.labels.length>0&&console.log(`Labels: ${n.labels.map(s=>s.name).join(", ")}`),console.log(`Read: ${n.read?"yes":"no"}`)}},o)});var kg=(e,t)=>[...t,e],ou=new d("list").alias("ls").description("List threads in an inbox").option("--inbox_id <id>","Inbox UUID").addOption(new q("--folder <folder>","Folder to list (default: inbox)").choices(_s)).option("--query <text>","Case-insensitive match against thread subjects and label names").option("--label <label_id>","Filter by label UUID (repeat the flag for multiple labels)",kg,[]).option("--limit <n>","Maximum number of threads to return (1-100)","10").option("--after <cursor>","Cursor for forward pagination \u2014 list threads after this thread ID").option("--before <cursor>","Cursor for backward pagination \u2014 list threads before this thread ID").addHelpText("after",c({context:`Threads are ordered by newest activity first. Pass the last thread ID of the
|
|
763
766
|
previous page as --after to fetch the next page.
|
|
764
767
|
|
|
765
768
|
--label takes label UUIDs (from "resend inboxes labels list"), not label names.`,output:' {"object":"list","has_more":false,"data":[{"id":"<uuid>","subject":"<subject>|null","from":"<sender>|null","to":[],"cc":[],"bcc":[],"labels":[],"message_count":1,"has_attachment":false,"has_draft":false,"read":false,"received_at":"<date>"}]}',errorCodes:["auth_error","invalid_limit","invalid_pagination","list_error"],examples:["resend inboxes threads list --inbox_id 78261eea-8f8b-4381-83c6-79fa7120f1cf","resend inboxes threads list --inbox_id 78261eea-8f8b-4381-83c6-79fa7120f1cf --folder archive --json","resend inboxes threads list --inbox_id 78261eea-8f8b-4381-83c6-79fa7120f1cf --query billing --json","resend inboxes threads list --inbox_id 78261eea-8f8b-4381-83c6-79fa7120f1cf --limit 25 --after <thread_id> --json"]})).action(async(e,t)=>{let o=t.optsWithGlobals(),i=D(e.limit,o),r=I(i,e.after,e.before,o),n=await g(e.inbox_id,H,o);await S({loading:"Fetching threads...",sdkCall:s=>s.inboxes.threads.list({inboxId:n,...e.folder&&{folder:e.folder},...e.query&&{query:e.query},...e.label.length>0&&{label:e.label},...r}),onInteractive:s=>{console.log(Lc(s.data)),T(s,"inboxes threads list",{limit:i,before:e.before,apiKey:o.apiKey,profile:o.profile,extraFlags:[`--inbox_id ${n}`,e.folder&&`--folder ${e.folder}`,e.query&&`--query ${e.query}`,...e.label.map(a=>`--label ${a}`)].filter(Boolean).join(" ")})}},o)});var iu=new d("update").description("Mark a thread read or unread, move it, or apply a label").option("--inbox_id <id>","Inbox UUID").option("--thread_id <id>","Thread UUID").option("--read","Mark every message in the thread as read").option("--unread","Mark every message in the thread as unread").addOption(new q("--folder <folder>","Move the thread to a folder").choices(Fs)).option("--label_id <label_id>","Apply this label (UUID) to the thread").addHelpText("after",c({context:`At least one of --read/--unread, --folder, or --label_id is required.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resend-cli",
|
|
3
|
-
"version": "2.22.0-preview-inboxes.
|
|
3
|
+
"version": "2.22.0-preview-inboxes.6",
|
|
4
4
|
"description": "The official CLI for Resend",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"esbuild": "0.28.1",
|
|
47
47
|
"esbuild-wasm": "0.28.0",
|
|
48
48
|
"picocolors": "1.1.1",
|
|
49
|
-
"resend": "6.32.1-preview-inboxes.
|
|
49
|
+
"resend": "6.32.1-preview-inboxes.4"
|
|
50
50
|
},
|
|
51
51
|
"pkg": {
|
|
52
52
|
"scripts": [
|
|
@@ -171,7 +171,7 @@ Retrieve a single email from a thread.
|
|
|
171
171
|
## inboxes threads emails reply
|
|
172
172
|
|
|
173
173
|
Reply to a specific email in a thread. The reply is sent from the inbox
|
|
174
|
-
address. The
|
|
174
|
+
address. The recipients come from the original email. The total number of
|
|
175
175
|
recipients cannot exceed 50.
|
|
176
176
|
|
|
177
177
|
**Flags:** `--inbox_id <id> --thread_id <id> --email_id <id>` — required in
|
|
@@ -179,11 +179,12 @@ non-interactive mode; the email ID comes from `inboxes threads emails list`
|
|
|
179
179
|
|
|
180
180
|
| Flag | Type | Required | Description |
|
|
181
181
|
|------|------|----------|-------------|
|
|
182
|
-
| `--cc <address>` | string | No | Cc address; repeat for multiple. Not copied from the original email |
|
|
182
|
+
| `--cc <address>` | string | No | Cc address; repeat for multiple. Not copied from the original email, except with `--reply-all` |
|
|
183
183
|
| `--bcc <address>` | string | No | Bcc address; repeat for multiple. Not copied from the original email |
|
|
184
184
|
| `--text <text>` | string | One of text/html | Plain text reply body |
|
|
185
185
|
| `--html <html>` | string | One of text/html | HTML reply body |
|
|
186
186
|
| `--subject <subject>` | string | No | Override the reply subject |
|
|
187
|
+
| `--reply-all` | boolean | No | Reply to everyone on the original email. The sender stays in `to`; the other `to` and `cc` recipients go to `cc`, without the inbox address |
|
|
187
188
|
| `--idempotency-key <key>` | string | No | Deduplicate request |
|
|
188
189
|
|
|
189
190
|
**Output:** `{"id":"<uuid>","email_id":"<uuid>","direction":"outbound","from":"<inbox-address>","to":["<recipient>"],"cc":[],"bcc":[],"reply_to":[],"subject":"<subject>"|null,"message_id":"<message-id>"|null,"html":"<html>"|null,"text":"<text>"|null,"attachments":[],"read":true,"received_at":"<date>"}`
|