diff --git a/README.md b/README.md index a170eb0..1992b62 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This integration does the following things: -* Disable default Chec emails (on `integrations.create` event, first run only) +* Disable default Chec emails (on `integrations.ready` event, first run only) * Create transactional email templates in SendGrid, unless a template ID was provided for each email type * Assemble data for transactional emails and send them using the SendGrid API @@ -32,7 +32,7 @@ npm run build | Event | Action | Template | | -------------------------- | ----------------------------------- | ---------------------- | | `readiness.probe` | API checking on readiness | - | -| `integrations.create` | Initial setup | - | +| `integrations.ready` | Initial setup | - | | `orders.create` | Send customer receipt | "Order receipt" | | `orders.physical.shipment` | Send customer shipment notification | "Item shipped" | | `customers.login.token` | Send customer login token | "Customer login token" | @@ -40,7 +40,7 @@ npm run build ## Initial setup When the integration first runs, it will run an initial setup phase. This is triggered by the event being -"integrations.create", which only runs for an integration at the time it is created. We can assume the integration +"integrations.ready", which only runs for an integration at the time it is created. We can assume the integration has been provisioned at this point, however DNS may not be available for it yet. The initial setup process does the following: diff --git a/dist/index.js b/dist/index.js index 2da88dc..e8d2862 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -(()=>{var __webpack_modules__={4431:e=>{"use strict";e.exports=JSON.parse('{"name":"@sendgrid/client","description":"Twilio SendGrid NodeJS API client","version":"7.5.0","author":"Twilio SendGrid (sendgrid.com)","contributors":["Kyle Partridge ","David Tomberlin ","Swift ","Brandon West ","Scott Motte ","Robert Acosta ","Elmer Thomas ","Adam Reis "],"license":"MIT","homepage":"https://sendgrid.com","repository":{"type":"git","url":"git://github.com/sendgrid/sendgrid-nodejs.git"},"publishConfig":{"access":"public"},"main":"index.js","engines":{"node":"6.* || 8.* || >=10.*"},"dependencies":{"@sendgrid/helpers":"^7.5.0","axios":"^0.21.4"},"devDependencies":{"chai":"4.2.0","nock":"^10.0.6"},"resolutions":{"chai":"4.2.0"},"tags":["http","rest","api","mail","sendgrid"],"gitHead":"a3307fda9318973ef9410f604a4d117ff7548e24"}')},2932:(e,t,r)=>{const{readFileSync:s}=r(5747);const{resolve:n}=r(5622);const{verifyWebhook:i}=r(8402);const o=r(6686);const a=r(2449);function getTemplateId(e,t){const r=t.config.templates[data.event]||"";if(!r){throw new Error(`Template ID is not available for event: ${data.event}`)}return r}async function createTemplate(e,t,n){const i=s(r.ab+"templates/"+e+"/template.html").toString();const o=s(r.ab+"templates/"+e+"/testData.json").toString();const[c]=await a.request({body:{name:t,generation:"dynamic"},method:"POST",url:"/v3/templates"});const{id:u}=c.body;await a.request({body:{name:t,subject:n,html_content:i,test_data:o,editor:"code"},method:"POST",url:`/v3/templates/${u}/versions`});return{event:e,id:u}}e.exports=async function handler(e,t){i(e.body,t.webhookSigningKey);const r=await t.merchant();const s=r.id;const n=await t.integration();const c={...e.body,merchant:r};const u=n.config.sendgrid.api_key||null;if(!u){throw new Error("SendGrid API key not available. Please check your configuration.")}o.setApiKey(u);let f={};switch(c.event){case"integrations.create":t.api.put(`/v1/merchants/${s}/notifications`,{customer:{login_token:false,orders:false,shipments:false}});a.setApiKey(u);const e=[];[{event:"customers.login.token",name:"Customers: login token",subject:"Log in to your account"},{event:"orders.create",name:"Orders: receipt",subject:"Your order: {{ payload.customer_reference }}"},{event:"orders.physical.shipment",name:"Orders: item shipped",subject:"Your order has shipped!"}].forEach((({event:t,name:r,subject:s})=>{e.push(createTemplate(t,r,s))}));const r=await Promise.all(e);const i={...n.config,templates:r.reduce(((e,t)=>(e[t.event]=t.id,e)),{})};f=await t.api.put(`/v1/integrations/${n.id}`,{config:i});break;case"orders.create":await o.send({to:c.payload.customer.email,from:c.merchant.support_email,subject:`Your order: ${c.payload.customer_reference}`,dynamic_template_data:c,template_id:getTemplateId(c.event,n)});f={sent:true};break;case"orders.physical.shipment":await o.send({to:c.payload.customer.email,from:c.merchant.support_email,subject:"Your order has a new shipment!",dynamic_template_data:c,template_id:getTemplateId(c.event,n)});f={sent:true};break;case"customers.login.token":await o.send({to:c.payload.email,from:c.merchant.support_email,subject:"Log in to your account",dynamic_template_data:c,template_id:getTemplateId(c.event,n)});f={sent:true};break;default:throw new Error("Invalid `event` type provided.")}return{statusCode:200,body:JSON.stringify(f)}}},2642:function(e,t){"use strict";var r=this&&this.__extends||function(){var extendStatics=function(e,t){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r))e[r]=t[r]};return extendStatics(e,t)};return function(e,t){if(typeof t!=="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");extendStatics(e,t);function __(){this.constructor=e}e.prototype=t===null?Object.create(t):(__.prototype=t.prototype,new __)}}();Object.defineProperty(t,"__esModule",{value:true});t.VerificationError=void 0;var s=function(e){r(VerificationError,e);function VerificationError(){return e!==null&&e.apply(this,arguments)||this}return VerificationError}(Error);t.VerificationError=s},8402:function(e,t,r){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){if(s===undefined)s=r;Object.defineProperty(e,s,{enumerable:true,get:function(){return t[r]}})}:function(e,t,r,s){if(s===undefined)s=r;e[s]=t[r]});var n=this&&this.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))s(t,e,r)};Object.defineProperty(t,"__esModule",{value:true});n(r(746),t)},746:function(e,t,r){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){if(s===undefined)s=r;Object.defineProperty(e,s,{enumerable:true,get:function(){return t[r]}})}:function(e,t,r,s){if(s===undefined)s=r;e[s]=t[r]});var n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(r!=="default"&&Object.prototype.hasOwnProperty.call(e,r))s(t,e,r);n(t,e);return t};Object.defineProperty(t,"__esModule",{value:true});t.verifyWebhook=void 0;var o=r(2642);var a=i(r(6417));function verifyWebhook(e,t,r){if(r===void 0){r=300}var s=e.signature;delete e.signature;if(!s||!s.length){throw new o.VerificationError("Signature was not found in payload.")}if(!t||!t.length){throw new o.VerificationError("Signing key was not provided.")}var n=a.createHmac("sha256",t).update(JSON.stringify(e)).digest("hex");if(n!==s){throw new o.VerificationError("Signature mismatch.")}var i=new Date(e.created*1e3);var c=new Date;if(+i<+c-r*1e3){throw new o.VerificationError("Request was made too far in the past.")}}t.verifyWebhook=verifyWebhook},2449:(e,t,r)=>{"use strict";const s=r(2769);const n=r(5843);e.exports=s;e.exports.Client=n},5843:(e,t,r)=>{"use strict";const s=r(6545);const n=r(4431);const{helpers:{mergeData:i},classes:{Response:o,ResponseError:a}}=r(2733);const c="SG.";const u="https://api.sendgrid.com/";const f="https://email.twilio.com/";class Client{constructor(){this.auth="";this.impersonateSubuser="";this.defaultHeaders={Accept:"application/json","Content-Type":"application/json","User-Agent":"sendgrid/"+n.version+";nodejs"};this.defaultRequest={baseUrl:u,url:"",method:"GET",headers:{},maxContentLength:Infinity,maxBodyLength:Infinity}}setApiKey(e){this.auth="Bearer "+e;this.setDefaultRequest("baseUrl",u);if(!this.isValidApiKey(e)){console.warn(`API key does not start with "${c}".`)}}setTwilioEmailAuth(e,t){const r=Buffer.from(e+":"+t).toString("base64");this.auth="Basic "+r;this.setDefaultRequest("baseUrl",f);if(!this.isValidTwilioAuth(e,t)){console.warn("Twilio Email credentials must be non-empty strings.")}}isValidApiKey(e){return this.isString(e)&&e.trim().startsWith(c)}isValidTwilioAuth(e,t){return this.isString(e)&&e&&this.isString(t)&&t}isString(e){return typeof e==="string"||e instanceof String}setImpersonateSubuser(e){this.impersonateSubuser=e}setDefaultHeader(e,t){if(e!==null&&typeof e==="object"){Object.assign(this.defaultHeaders,e);return this}this.defaultHeaders[e]=t;return this}setDefaultRequest(e,t){if(e!==null&&typeof e==="object"){Object.assign(this.defaultRequest,e);return this}this.defaultRequest[e]=t;return this}createHeaders(e){const t=i(this.defaultHeaders,e);if(typeof t.Authorization==="undefined"&&this.auth){t.Authorization=this.auth}if(this.impersonateSubuser){t["On-Behalf-Of"]=this.impersonateSubuser}return t}createRequest(e){let t={url:e.uri||e.url,baseUrl:e.baseUrl,method:e.method,data:e.body,params:e.qs,headers:e.headers};t=i(this.defaultRequest,t);t.headers=this.createHeaders(t.headers);t.baseURL=t.baseUrl;delete t.baseUrl;return t}request(e,t){e=this.createRequest(e);const r=new Promise(((t,r)=>{s(e).then((e=>t([new o(e.status,e.data,e.headers),e.data]))).catch((e=>{if(e.response){if(e.response.status>=400){return r(new a(e.response))}}return r(e)}))}));if(t&&typeof t!=="function"){throw new Error("Callback passed is not a function.")}if(t){return r.then((e=>t(null,e))).catch((e=>t(e,null)))}return r}}e.exports=Client},2769:(e,t,r)=>{"use strict";const s=r(5843);e.exports=new s},9232:(e,t,r)=>{"use strict";const s=r(3278);const n=r(7609);const i=r(4054);const o=r(5747);const a=r(5622);class Attachment{constructor(e){if(e){this.fromData(e)}}fromData(e){if(typeof e!=="object"){throw new Error("Expecting object for Mail data")}e=i(e);e=s(e);const{content:t,filename:r,type:n,disposition:o,contentId:a,filePath:c}=e;if(typeof t!=="undefined"&&typeof c!=="undefined"){throw new Error("The props 'content' and 'filePath' cannot be used together.")}this.setFilename(r);this.setType(n);this.setDisposition(o);this.setContentId(a);this.setContent(c?this.readFile(c):t)}readFile(e){return o.readFileSync(a.resolve(e))}setContent(e){if(typeof e==="string"){this.content=e;return}else if(e instanceof Buffer&&e.toString!==undefined){this.content=e.toString();if(this.disposition==="attachment"){this.content=e.toString("base64")}return}throw new Error("`content` expected to be either Buffer or string")}setFileContent(e){if(e instanceof Buffer&&e.toString!==undefined){this.content=e.toString("base64");return}throw new Error("`content` expected to be Buffer")}setFilename(e){if(typeof e==="undefined"){return}if(e&&typeof e!=="string"){throw new Error("String expected for `filename`")}this.filename=e}setType(e){if(typeof e==="undefined"){return}if(typeof e!=="string"){throw new Error("String expected for `type`")}this.type=e}setDisposition(e){if(typeof e==="undefined"){return}if(typeof e!=="string"){throw new Error("String expected for `disposition`")}this.disposition=e}setContentId(e){if(typeof e==="undefined"){return}if(typeof e!=="string"){throw new Error("String expected for `contentId`")}this.contentId=e}toJSON(){const{content:e,filename:t,type:r,disposition:s,contentId:i}=this;const o={content:e,filename:t};if(typeof r!=="undefined"){o.type=r}if(typeof s!=="undefined"){o.disposition=s}if(typeof i!=="undefined"){o.contentId=i}return n(o)}}e.exports=Attachment},9058:(e,t,r)=>{"use strict";const s=r(4194);class EmailAddress{constructor(e){if(e){this.fromData(e)}}fromData(e){if(typeof e==="string"){const[t,r]=s(e);e={name:t,email:r}}if(typeof e!=="object"){throw new Error("Expecting object or string for EmailAddress data")}const{name:t,email:r}=e;this.setEmail(r);this.setName(t)}setName(e){if(typeof e==="undefined"){return}if(typeof e!=="string"){throw new Error("String expected for `name`")}this.name=e}setEmail(e){if(typeof e==="undefined"){throw new Error("Must provide `email`")}if(typeof e!=="string"){throw new Error("String expected for `email`")}this.email=e}toJSON(){const{email:e,name:t}=this;const r={email:e};if(t!==""){r.name=t}return r}static create(e){if(Array.isArray(e)){return e.filter((e=>!!e)).map((e=>this.create(e)))}if(e instanceof EmailAddress){return e}return new EmailAddress(e)}}e.exports=EmailAddress},8480:(e,t,r)=>{"use strict";const s=r(9232);const n=r(9058);const i=r(806);const o=r(65);const a=r(4512);const c=r(2359);const u=r(374);e.exports={Attachment:s,EmailAddress:n,Mail:i,Personalization:o,Response:a,ResponseError:c,Statistics:u}},806:(e,t,r)=>{"use strict";const s=r(9058);const n=r(65);const i=r(3278);const o=r(7609);const a=r(4054);const c=r(3872);const{DYNAMIC_TEMPLATE_CHAR_WARNING:u}=r(2066);const{validateMailSettings:f,validateTrackingSettings:p}=r(7738);class Mail{constructor(e){this.isDynamic=false;this.hideWarnings=false;this.personalizations=[];this.attachments=[];this.content=[];this.categories=[];this.headers={};this.sections={};this.customArgs={};this.trackingSettings={};this.mailSettings={};this.asm={};this.substitutions=null;this.substitutionWrappers=null;this.dynamicTemplateData=null;if(e){this.fromData(e)}}fromData(e){if(typeof e!=="object"){throw new Error("Expecting object for Mail data")}e=a(e);e=i(e,["substitutions","dynamicTemplateData","customArgs","headers","sections"]);const{to:t,from:r,replyTo:s,cc:n,bcc:o,sendAt:c,subject:u,text:f,html:p,content:d,templateId:h,personalizations:l,attachments:m,ipPoolName:y,batchId:g,sections:b,headers:v,categories:w,category:_,customArgs:E,asm:x,mailSettings:A,trackingSettings:S,substitutions:T,substitutionWrappers:j,dynamicTemplateData:O,isMultiple:R,hideWarnings:k,replyToList:C}=e;this.setFrom(r);this.setReplyTo(s);this.setSubject(u);this.setSendAt(c);this.setTemplateId(h);this.setBatchId(g);this.setIpPoolName(y);this.setAttachments(m);this.setContent(d);this.setSections(b);this.setHeaders(v);this.setCategories(_);this.setCategories(w);this.setCustomArgs(E);this.setAsm(x);this.setMailSettings(A);this.setTrackingSettings(S);this.setHideWarnings(k);this.setReplyToList(C);if(this.isDynamic){this.setDynamicTemplateData(O)}else{this.setSubstitutions(T);this.setSubstitutionWrappers(j)}this.addTextContent(f);this.addHtmlContent(p);if(l){this.setPersonalizations(l)}else if(R&&Array.isArray(t)){t.forEach((e=>this.addTo(e,n,o)))}else{this.addTo(t,n,o)}}setFrom(e){if(this._checkProperty("from",e,[this._checkUndefined])){if(typeof e!=="string"&&typeof e.email!=="string"){throw new Error("String or address object expected for `from`")}this.from=s.create(e)}}setReplyTo(e){if(this._checkProperty("replyTo",e,[this._checkUndefined])){if(typeof e!=="string"&&typeof e.email!=="string"){throw new Error("String or address object expected for `replyTo`")}this.replyTo=s.create(e)}}setSubject(e){this._setProperty("subject",e,"string")}setSendAt(e){if(this._checkProperty("sendAt",e,[this._checkUndefined,this._createCheckThatThrows(Number.isInteger,"Integer expected for `sendAt`")])){this.sendAt=e}}setTemplateId(e){if(this._setProperty("templateId",e,"string")){if(e.indexOf("d-")===0){this.isDynamic=true}}}setBatchId(e){this._setProperty("batchId",e,"string")}setIpPoolName(e){this._setProperty("ipPoolName",e,"string")}setAsm(e){if(this._checkProperty("asm",e,[this._checkUndefined,this._createTypeCheck("object")])){if(typeof e.groupId!=="number"){throw new Error("Expected `asm` to include an integer in its `groupId` field")}if(e.groupsToDisplay&&(!Array.isArray(e.groupsToDisplay)||!e.groupsToDisplay.every((e=>typeof e==="number")))){throw new Error("Array of integers expected for `asm.groupsToDisplay`")}this.asm=e}}setPersonalizations(e){if(!this._doArrayCheck("personalizations",e)){return}if(!e.every((e=>typeof e==="object"))){throw new Error("Array of objects expected for `personalizations`")}this.personalizations=[];e.forEach((e=>this.addPersonalization(e)))}addPersonalization(e){if(this.isDynamic&&e.substitutions){delete e.substitutions}else if(!this.isDynamic&&e.dynamicTemplateData){delete e.dynamicTemplateData}if(!(e instanceof n)){e=new n(e)}if(this.isDynamic){this.applyDynamicTemplateData(e)}else{this.applySubstitutions(e)}this.personalizations.push(e)}addTo(e,t,r){if(typeof e==="undefined"&&typeof t==="undefined"&&typeof r==="undefined"){throw new Error("Provide at least one of to, cc or bcc")}this.addPersonalization(new n({to:e,cc:t,bcc:r}))}setSubstitutions(e){this._setProperty("substitutions",e,"object")}setSubstitutionWrappers(e){let lengthCheck=(e,t)=>{if(!Array.isArray(t)||t.length!==2){throw new Error("Array expected with two elements for `"+e+"`")}};if(this._checkProperty("substitutionWrappers",e,[this._checkUndefined,lengthCheck])){this.substitutionWrappers=e}}applySubstitutions(e){if(e instanceof n){e.reverseMergeSubstitutions(this.substitutions);e.setSubstitutionWrappers(this.substitutionWrappers)}}applyDynamicTemplateData(e){if(e instanceof n){e.deepMergeDynamicTemplateData(this.dynamicTemplateData)}}setDynamicTemplateData(e){if(typeof e==="undefined"){return}if(typeof e!=="object"){throw new Error("Object expected for `dynamicTemplateData`")}if(!this.hideWarnings){Object.values(e).forEach((e=>{if(/['"&]/.test(e)){console.warn(u)}}))}this.dynamicTemplateData=e}setContent(e){if(this._doArrayCheck("content",e)){if(!e.every((e=>typeof e==="object"))){throw new Error("Expected each entry in `content` to be an object")}if(!e.every((e=>typeof e.type==="string"))){throw new Error("Expected each `content` entry to contain a `type` string")}if(!e.every((e=>typeof e.value==="string"))){throw new Error("Expected each `content` entry to contain a `value` string")}this.content=e}}addContent(e){if(this._checkProperty("content",e,[this._createTypeCheck("object")])){this.content.push(e)}}addTextContent(e){if(this._checkProperty("text",e,[this._checkUndefined,this._createTypeCheck("string")])){this.addContent({value:e,type:"text/plain"})}}addHtmlContent(e){if(this._checkProperty("html",e,[this._checkUndefined,this._createTypeCheck("string")])){this.addContent({value:e,type:"text/html"})}}setAttachments(e){if(this._doArrayCheck("attachments",e)){if(!e.every((e=>typeof e.content==="string"))){throw new Error("Expected each attachment to contain a `content` string")}if(!e.every((e=>typeof e.filename==="string"))){throw new Error("Expected each attachment to contain a `filename` string")}if(!e.every((e=>!e.type||typeof e.type==="string"))){throw new Error("Expected the attachment's `type` field to be a string")}if(!e.every((e=>!e.disposition||typeof e.disposition==="string"))){throw new Error("Expected the attachment's `disposition` field to be a string")}this.attachments=e}}addAttachment(e){if(this._checkProperty("attachment",e,[this._checkUndefined,this._createTypeCheck("object")])){this.attachments.push(e)}}setCategories(e){let allElementsAreStrings=(e,t)=>{if(!Array.isArray(t)||!t.every((e=>typeof e==="string"))){throw new Error("Array of strings expected for `"+e+"`")}};if(typeof e==="string"){e=[e]}if(this._checkProperty("categories",e,[this._checkUndefined,allElementsAreStrings])){this.categories=e}}addCategory(e){if(this._checkProperty("category",e,[this._createTypeCheck("string")])){this.categories.push(e)}}setHeaders(e){this._setProperty("headers",e,"object")}addHeader(e,t){if(this._checkProperty("key",e,[this._createTypeCheck("string")])&&this._checkProperty("value",t,[this._createTypeCheck("string")])){this.headers[e]=t}}setSections(e){this._setProperty("sections",e,"object")}setCustomArgs(e){this._setProperty("customArgs",e,"object")}setTrackingSettings(e){if(typeof e==="undefined"){return}p(e);this.trackingSettings=e}setMailSettings(e){if(typeof e==="undefined"){return}f(e);this.mailSettings=e}setHideWarnings(e){if(typeof e==="undefined"){return}if(typeof e!=="boolean"){throw new Error("Boolean expected for `hideWarnings`")}this.hideWarnings=e}toJSON(){const{from:e,replyTo:t,sendAt:r,subject:s,content:n,templateId:i,personalizations:a,attachments:u,ipPoolName:f,batchId:p,asm:d,sections:h,headers:l,categories:m,customArgs:y,mailSettings:g,trackingSettings:b,replyToList:v}=this;const w={from:e,subject:s,personalizations:c(a)};if(Array.isArray(u)&&u.length>0){w.attachments=c(u)}if(Array.isArray(m)&&m.length>0){w.categories=m.filter((e=>e!==""))}if(Array.isArray(n)&&n.length>0){w.content=c(n)}if(Object.keys(l).length>0){w.headers=l}if(Object.keys(g).length>0){w.mailSettings=g}if(Object.keys(b).length>0){w.trackingSettings=b}if(Object.keys(y).length>0){w.customArgs=y}if(Object.keys(h).length>0){w.sections=h}if(Object.keys(d).length>0){w.asm=d}if(typeof t!=="undefined"){w.replyTo=t}if(typeof r!=="undefined"){w.sendAt=r}if(typeof p!=="undefined"){w.batchId=p}if(typeof i!=="undefined"){w.templateId=i}if(typeof f!=="undefined"){w.ipPoolName=f}if(typeof v!=="undefined"){w.replyToList=v}return o(w,["substitutions","dynamicTemplateData","customArgs","headers","sections"])}static create(e){if(Array.isArray(e)){return e.filter((e=>!!e)).map((e=>this.create(e)))}if(e instanceof Mail){return e}return new Mail(e)}_checkProperty(e,t,r){return!r.some((r=>r(e,t)))}_setProperty(e,t,r){let s=this._checkProperty(e,t,[this._checkUndefined,this._createTypeCheck(r)]);if(s){this[e]=t}return s}_checkUndefined(e,t){return typeof t==="undefined"}_createTypeCheck(e){return(t,r)=>{if(typeof r!==e){throw new Error(e+" expected for `"+t+"`")}}}_createCheckThatThrows(e,t){return(r,s)=>{if(!e(s)){throw new Error(t)}}}_setArrayProperty(e,t){if(this._doArrayCheck(e,t)){this[e]=t}}_doArrayCheck(e,t){return this._checkProperty(e,t,[this._checkUndefined,this._createCheckThatThrows(Array.isArray,"Array expected for`"+e+"`")])}setReplyToList(e){if(this._doArrayCheck("replyToList",e)&&e.length){if(!e.every((e=>e&&typeof e.email==="string"))){throw new Error("Expected each replyTo to contain an `email` string")}this.replyToList=e}}}e.exports=Mail},65:(e,t,r)=>{"use strict";const s=r(9058);const n=r(3278);const i=r(7609);const o=r(4054);const a=r(6323);const c=r(7174);class Personalization{constructor(e){this.to=[];this.cc=[];this.bcc=[];this.headers={};this.customArgs={};this.substitutions={};this.substitutionWrappers=["{{","}}"];this.dynamicTemplateData={};if(e){this.fromData(e)}}fromData(e){if(typeof e!=="object"){throw new Error("Expecting object for Mail data")}e=o(e);e=n(e,["substitutions","dynamicTemplateData","customArgs","headers"]);const{to:t,cc:r,bcc:s,subject:i,headers:a,customArgs:c,sendAt:u,substitutions:f,substitutionWrappers:p,dynamicTemplateData:d}=e;this.setTo(t);this.setCc(r);this.setBcc(s);this.setSubject(i);this.setHeaders(a);this.setSubstitutions(f);this.setSubstitutionWrappers(p);this.setCustomArgs(c);this.setDynamicTemplateData(d);this.setSendAt(u)}setSubject(e){if(typeof e==="undefined"){return}if(typeof e!=="string"){throw new Error("String expected for `subject`")}this.subject=e}setSendAt(e){if(typeof e==="undefined"){return}if(!Number.isInteger(e)){throw new Error("Integer expected for `sendAt`")}this.sendAt=e}setTo(e){if(typeof e==="undefined"){return}if(!Array.isArray(e)){e=[e]}this.to=s.create(e)}addTo(e){if(typeof e==="undefined"){return}this.to.push(s.create(e))}setCc(e){if(typeof e==="undefined"){return}if(!Array.isArray(e)){e=[e]}this.cc=s.create(e)}addCc(e){if(typeof e==="undefined"){return}this.cc.push(s.create(e))}setBcc(e){if(typeof e==="undefined"){return}if(!Array.isArray(e)){e=[e]}this.bcc=s.create(e)}addBcc(e){if(typeof e==="undefined"){return}this.bcc.push(s.create(e))}setHeaders(e){if(typeof e==="undefined"){return}if(typeof e!=="object"||e===null){throw new Error("Object expected for `headers`")}this.headers=e}addHeader(e,t){if(typeof e!=="string"){throw new Error("String expected for header key")}if(typeof t!=="string"){throw new Error("String expected for header value")}this.headers[e]=t}setCustomArgs(e){if(typeof e==="undefined"){return}if(typeof e!=="object"||e===null){throw new Error("Object expected for `customArgs`")}this.customArgs=e}addCustomArg(e,t){if(typeof e!=="string"){throw new Error("String expected for custom arg key")}if(typeof t!=="string"){throw new Error("String expected for custom arg value")}this.customArgs[e]=t}setSubstitutions(e){if(typeof e==="undefined"){return}if(typeof e!=="object"){throw new Error("Object expected for `substitutions`")}this.substitutions=e}addSubstitution(e,t){if(typeof e!=="string"){throw new Error("String expected for substitution key")}if(typeof t!=="string"&&typeof t!=="number"){throw new Error("String or Number expected for substitution value")}this.substitutions[e]=t}reverseMergeSubstitutions(e){if(typeof e==="undefined"||e===null){return}if(typeof e!=="object"){throw new Error("Object expected for `substitutions` in reverseMergeSubstitutions")}this.substitutions=Object.assign({},e,this.substitutions)}setSubstitutionWrappers(e){if(typeof e==="undefined"||e===null){return}if(!Array.isArray(e)||e.length!==2){throw new Error("Array expected with two elements for `substitutionWrappers`")}this.substitutionWrappers=e}deepMergeDynamicTemplateData(e){if(typeof e==="undefined"||e===null){return}if(typeof e!=="object"){throw new Error("Object expected for `dynamicTemplateData` in deepMergeDynamicTemplateData")}this.dynamicTemplateData=a(e,this.dynamicTemplateData)}setDynamicTemplateData(e){if(typeof e==="undefined"){return}if(typeof e!=="object"){throw new Error("Object expected for `dynamicTemplateData`")}this.dynamicTemplateData=e}toJSON(){const{to:e,cc:t,bcc:r,subject:s,headers:n,customArgs:o,sendAt:a,substitutions:u,substitutionWrappers:f,dynamicTemplateData:p}=this;const d={to:e};if(Array.isArray(t)&&t.length>0){d.cc=t}if(Array.isArray(r)&&r.length>0){d.bcc=r}if(Object.keys(n).length>0){d.headers=n}if(u&&Object.keys(u).length>0){const[e,t]=f;d.substitutions=c(u,e,t)}if(Object.keys(o).length>0){d.customArgs=o}if(p&&Object.keys(p).length>0){d.dynamicTemplateData=p}if(typeof s!=="undefined"){d.subject=s}if(typeof a!=="undefined"){d.sendAt=a}return i(d,["substitutions","dynamicTemplateData","customArgs","headers"])}}e.exports=Personalization},2359:e=>{"use strict";class ResponseError extends Error{constructor(e){super();const{headers:t,status:r,statusText:s,data:n}=e;this.code=r;this.message=s;this.response={headers:t,body:n};if(!this.stack){Error.captureStackTrace(this,this.constructor)}const i=new RegExp(process.cwd()+"/","gi");this.stack=this.stack.replace(i,"")}toString(){const{body:e}=this.response;let t=`${this.message} (${this.code})`;if(e&&Array.isArray(e.errors)){e.errors.forEach((e=>{const r=e.message;const s=e.field;const n=e.help;t+=`\n ${r}\n ${s}\n ${n}`}))}return t}toJSON(){const{message:e,code:t,response:r}=this;return{message:e,code:t,response:r}}}e.exports=ResponseError},4512:e=>{"use strict";class Response{constructor(e,t,r){this.statusCode=e;this.body=t;this.headers=r}toString(){return"HTTP "+this.statusCode+" "+this.body}}e.exports=Response},374:(e,t,r)=>{"use strict";const s=r(3278);const n=r(4054);const i=["day","week","month"];const o=["us","ca"];const a=["desc","asc"];class Statistics{constructor(e){this.startDate=null;this.endDate=null;this.aggregatedBy=null;if(e){this.fromData(e)}}fromData(e){if(typeof e!=="object"){throw new Error("Expecting object for Statistics data")}e=n(e);e=s(e,["substitutions","customArgs"]);const{startDate:t,endDate:r,aggregatedBy:i}=e;this.setStartDate(t);this.setEndDate(r);this.setAggregatedBy(i)}setStartDate(e){if(typeof e==="undefined"){throw new Error("Date expected for `startDate`")}if(new Date(e)==="Invalid Date"||isNaN(new Date(e))){throw new Error("Date expected for `startDate`")}console.log(e);this.startDate=new Date(e).toISOString().slice(0,10)}setEndDate(e){if(typeof e==="undefined"){this.endDate=(new Date).toISOString().slice(0,10);return}if(new Date(e)==="Invalid Date"||isNaN(new Date(e))){throw new Error("Date expected for `endDate`")}this.endDate=new Date(e).toISOString().slice(0,10)}setAggregatedBy(e){if(typeof e==="undefined"){return}if(typeof e==="string"&&i.includes(e.toLowerCase())){this.aggregatedBy=e}else{throw new Error("Incorrect value for `aggregatedBy`")}}getGlobal(){const{startDate:e,endDate:t,aggregatedBy:r}=this;return{startDate:e,endDate:t,aggregatedBy:r}}getAdvanced(e){const t=this.getGlobal();if(typeof e==="undefined"){return t}if(typeof e==="string"&&o.includes(e.toLowerCase())){t.country=e}return t}getAdvancedMailboxProviders(e){const t=this.getGlobal();if(typeof e==="undefined"){return t}if(Array.isArray(e)&&e.some((e=>typeof e!=="string"))){throw new Error("Array of strings expected for `mailboxProviders`")}t.mailBoxProviders=e;return t}getAdvancedBrowsers(e){const t=this.getGlobal();if(typeof e==="undefined"){return t}if(Array.isArray(e)&&e.some((e=>typeof e!=="string"))){throw new Error("Array of strings expected for `browsers`")}t.browsers=e;return t}getCategories(e){if(typeof e==="undefined"){throw new Error("Array of strings expected for `categories`")}if(!this._isValidArrayOfStrings(e)){throw new Error("Array of strings expected for `categories`")}const t=this.getGlobal();t.categories=e;return t}getSubuser(e){if(typeof e==="undefined"){throw new Error("Array of strings expected for `subusers`")}if(!this._isValidArrayOfStrings(e)){throw new Error("Array of strings expected for `subusers`")}const t=this.getGlobal();t.subusers=e;return t}getSubuserSum(e="delivered",t=a[0],r=5,s=0){if(typeof e!=="string"){throw new Error("string expected for `sortByMetric`")}if(!a.includes(t.toLowerCase())){throw new Error("desc or asc expected for `sortByDirection`")}if(typeof r!=="number"){throw new Error("number expected for `limit`")}if(typeof s!=="number"){throw new Error("number expected for `offset`")}const n=this.getGlobal();n.sortByMetric=e;n.sortByDirection=t;n.limit=r;n.offset=s;return n}getSubuserMonthly(e="delivered",t=a[0],r=5,s=0){if(typeof e!=="string"){throw new Error("string expected for `sortByMetric`")}if(!a.includes(t.toLowerCase())){throw new Error("desc or asc expected for `sortByDirection`")}if(typeof r!=="number"){throw new Error("number expected for `limit`")}if(typeof s!=="number"){throw new Error("number expected for `offset`")}const n=this.getGlobal();n.sortByMetric=e;n.sortByDirection=t;n.limit=r;n.offset=s;return n}_isValidArrayOfStrings(e){if(!Array.isArray(e)){return false}if(e.length<1||e.some((e=>typeof e!=="string"))){return false}return true}}e.exports=Statistics},2066:e=>{const t=`\nContent with characters ', " or & may need to be escaped with three brackets\n{{{ content }}}\nSee https://sendgrid.com/docs/for-developers/sending-email/using-handlebars/ for more information.`;e.exports={DYNAMIC_TEMPLATE_CHAR_WARNING:t}},3872:e=>{"use strict";e.exports=function arrayToJSON(e){return e.map((e=>{if(typeof e==="object"&&e!==null&&typeof e.toJSON==="function"){return e.toJSON()}return e}))}},8560:e=>{"use strict";e.exports=function convertKeys(e,t,r){if(typeof e!=="object"||e===null){throw new Error("Non object passed to convertKeys: "+e)}if(Array.isArray(e)){return e}if(!Array.isArray(r)){r=[]}for(const s in e){if(e.hasOwnProperty(s)){const n=t(s);if(typeof e[s]==="object"&&e[s]!==null){if(!r.includes(s)&&!r.includes(n)){e[s]=convertKeys(e[s],t,r)}}if(n!==s){e[n]=e[s];delete e[s]}}}return e}},4054:e=>{"use strict";e.exports=function deepClone(e){return JSON.parse(JSON.stringify(e))}},4741:(e,t,r)=>{"use strict";const s=r(3872);const n=r(8560);const i=r(4054);const o=r(1001);const a=r(4194);const c=r(3278);const u=r(7609);const f=r(7174);e.exports={arrayToJSON:s,convertKeys:n,deepClone:i,mergeData:o,splitNameEmail:a,toCamelCase:c,toSnakeCase:u,wrapSubstitutions:f}},1001:e=>{"use strict";e.exports=function mergeData(e,t){if(typeof e!=="object"||e===null){throw new Error("Not an object provided for base")}if(typeof t!=="object"||t===null){throw new Error("Not an object provided for data")}const r=Object.assign({},e);for(const e in t){if(t.hasOwnProperty(e)){if(t[e]&&Array.isArray(t[e])){r[e]=t[e]}else if(t[e]&&typeof t[e]==="object"){r[e]=Object.assign({},t[e])}else if(t[e]){r[e]=t[e]}}}return r}},4194:e=>{"use strict";e.exports=function splitNameEmail(e){if(e.indexOf("<")===-1){return["",e]}let[t,r]=e.split("<");t=t.trim();r=r.replace(">","").trim();return[t,r]}},9352:e=>{"use strict";e.exports=function strToCamelCase(e){if(typeof e!=="string"){throw new Error("String expected for conversion to snake case")}return e.trim().replace(/_+|\-+/g," ").replace(/(?:^\w|[A-Z]|\b\w|\s+)/g,(function(e,t){if(Number(e)===0){return""}return t===0?e.toLowerCase():e.toUpperCase()}))}},9014:e=>{"use strict";e.exports=function strToSnakeCase(e){if(typeof e!=="string"){throw new Error("String expected for conversion to snake case")}return e.trim().replace(/(\s*\-*\b\w|[A-Z])/g,(function(e){e=e.trim().toLowerCase().replace("-","");return(e[0]==="_"?"":"_")+e})).slice(1)}},3278:(e,t,r)=>{"use strict";const s=r(8560);const n=r(9352);e.exports=function toCamelCase(e,t){return s(e,n,t)}},7609:(e,t,r)=>{"use strict";const s=r(8560);const n=r(9014);e.exports=function toSnakeCase(e,t){return s(e,n,t)}},7738:e=>{"use strict";const validate=(e,t,r,s)=>{if(typeof e==="undefined"||typeof e[r]==="undefined"){return}if(typeof e[r]!==s){throw new Error(`${s} expected for \`${t}.${r}\``)}};e.exports={validateMailSettings(e){if(typeof e!=="object"){throw new Error("Object expected for `mailSettings`")}const{bcc:t,bypassListManagement:r,footer:s,sandboxMode:n,spamCheck:i}=e;validate(t,"bcc","enable","boolean");validate(t,"bcc","email","string");validate(r,"bypassListManagement","enable","boolean");validate(s,"footer","enable","boolean");validate(s,"footer","text","string");validate(s,"footer","html","string");validate(n,"sandboxMode","enable","boolean");validate(i,"spamCheck","enable","boolean");validate(i,"spamCheck","threshold","number");validate(i,"spamCheck","postToUrl","string")},validateTrackingSettings(e){if(typeof e!=="object"){throw new Error("Object expected for `trackingSettings`")}const{clickTracking:t,openTracking:r,subscriptionTracking:s,ganalytics:n}=e;validate(t,"clickTracking","enable","boolean");validate(t,"clickTracking","enableText","boolean");validate(r,"openTracking","enable","boolean");validate(r,"openTracking","substitutionTag","string");validate(s,"subscriptionTracking","enable","boolean");validate(s,"subscriptionTracking","text","string");validate(s,"subscriptionTracking","html","string");validate(s,"subscriptionTracking","substitutionTag","string");validate(n,"ganalytics","enable","boolean");validate(n,"ganalytics","utm_source","string");validate(n,"ganalytics","utm_medium","string");validate(n,"ganalytics","utm_term","string");validate(n,"ganalytics","utm_content","string");validate(n,"ganalytics","utm_campaign","string")}}},7174:e=>{"use strict";e.exports=function wrap(e,t="{{",r="}}"){if(Array.isArray(e)){return e.map((e=>wrap(e,t,r)))}const s={};for(const n in e){if(e.hasOwnProperty(n)){s[t+n+r]=String(e[n])}}return s}},2733:(e,t,r)=>{"use strict";const s=r(8480);const n=r(4741);e.exports={classes:s,helpers:n}},6686:(e,t,r)=>{"use strict";const s=r(4812);const n=r(6246);e.exports=s;e.exports.MailService=n},6246:(e,t,r)=>{"use strict";const{Client:s}=r(2449);const{classes:{Mail:n}}=r(2733);class MailService{constructor(){this.setClient(new s);this.setSubstitutionWrappers("{{","}}");this.secretRules=[]}setClient(e){this.client=e;return this}setApiKey(e){this.client.setApiKey(e);return this}setTwilioEmailAuth(e,t){this.client.setTwilioEmailAuth(e,t)}setTimeout(e){if(typeof e==="undefined"){return}this.client.setDefaultRequest("timeout",e)}setSubstitutionWrappers(e,t){if(typeof e==="undefined"||typeof t==="undefined"){throw new Error("Must provide both left and right side wrappers")}if(!Array.isArray(this.substitutionWrappers)){this.substitutionWrappers=[]}this.substitutionWrappers[0]=e;this.substitutionWrappers[1]=t;return this}setSecretRules(e){if(!(e instanceof Array)){e=[e]}const t=e.map((function(e){const t=typeof e;if(t==="string"){return{pattern:new RegExp(e)}}else if(t==="object"){if(e instanceof RegExp){e={pattern:e}}else if(e.hasOwnProperty("pattern")&&typeof e.pattern==="string"){e.pattern=new RegExp(e.pattern)}try{e.pattern.test("");return e}catch(e){}}}));this.secretRules=t.filter((function(e){return e}))}filterSecrets(e){if(typeof e==="object"&&!e.hasOwnProperty("content")){return}const t=this;e.content.forEach((function(e){t.secretRules.forEach((function(t){if(t.hasOwnProperty("pattern")&&!t.pattern.test(e.value)){return}let r=`The pattern '${t.pattern}'`;if(t.name){r+=`identified by '${t.name}'`}r+=" was found in the Mail content!";throw new Error(r)}))}))}send(e,t=false,r){if(typeof t==="function"){r=t;t=false}if(Array.isArray(e)){const s=Promise.all(e.map((e=>this.send(e,t))));if(r){s.then((e=>r(null,e))).catch((e=>r(e,null)))}return s}try{if(typeof e.isMultiple==="undefined"){e.isMultiple=t}if(typeof e.substitutionWrappers==="undefined"){e.substitutionWrappers=this.substitutionWrappers}const s=n.create(e);const i=s.toJSON();this.filterSecrets(i);const o={method:"POST",url:"/v3/mail/send",headers:s.headers,body:i};return this.client.request(o,r)}catch(e){if(r){r(e,null)}return Promise.reject(e)}}sendMultiple(e,t){return this.send(e,true,t)}}e.exports=MailService},4812:(e,t,r)=>{"use strict";const s=r(6246);e.exports=new s},6545:(e,t,r)=>{e.exports=r(2618)},8104:(e,t,r)=>{"use strict";var s=r(328);var n=r(3211);var i=r(1934);var o=r(646);var a=r(8605);var c=r(7211);var u=r(7707).http;var f=r(7707).https;var p=r(8835);var d=r(8761);var h=r(696);var l=r(5226);var m=r(1516);var y=/https:?/;function setProxy(e,t,r){e.hostname=t.host;e.host=t.host;e.port=t.port;e.path=r;if(t.auth){var s=Buffer.from(t.auth.username+":"+t.auth.password,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+s}e.beforeRedirect=function beforeRedirect(e){e.headers.host=e.host;setProxy(e,t,e.href)}}e.exports=function httpAdapter(e){return new Promise((function dispatchHttpRequest(t,r){var g=function resolve(e){t(e)};var b=function reject(e){r(e)};var v=e.data;var w=e.headers;if("User-Agent"in w||"user-agent"in w){if(!w["User-Agent"]&&!w["user-agent"]){delete w["User-Agent"];delete w["user-agent"]}}else{w["User-Agent"]="axios/"+h.version}if(v&&!s.isStream(v)){if(Buffer.isBuffer(v)){}else if(s.isArrayBuffer(v)){v=Buffer.from(new Uint8Array(v))}else if(s.isString(v)){v=Buffer.from(v,"utf-8")}else{return b(l("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",e))}w["Content-Length"]=v.length}var _=undefined;if(e.auth){var E=e.auth.username||"";var x=e.auth.password||"";_=E+":"+x}var A=i(e.baseURL,e.url);var S=p.parse(A);var T=S.protocol||"http:";if(!_&&S.auth){var j=S.auth.split(":");var O=j[0]||"";var R=j[1]||"";_=O+":"+R}if(_){delete w.Authorization}var k=y.test(T);var C=k?e.httpsAgent:e.httpAgent;var D={path:o(S.path,e.params,e.paramsSerializer).replace(/^\?/,""),method:e.method.toUpperCase(),headers:w,agent:C,agents:{http:e.httpAgent,https:e.httpsAgent},auth:_};if(e.socketPath){D.socketPath=e.socketPath}else{D.hostname=S.hostname;D.port=S.port}var P=e.proxy;if(!P&&P!==false){var q=T.slice(0,-1)+"_proxy";var B=process.env[q]||process.env[q.toUpperCase()];if(B){var N=p.parse(B);var M=process.env.no_proxy||process.env.NO_PROXY;var U=true;if(M){var I=M.split(",").map((function trim(e){return e.trim()}));U=!I.some((function proxyMatch(e){if(!e){return false}if(e==="*"){return true}if(e[0]==="."&&S.hostname.substr(S.hostname.length-e.length)===e){return true}return S.hostname===e}))}if(U){P={host:N.hostname,port:N.port,protocol:N.protocol};if(N.auth){var L=N.auth.split(":");P.auth={username:L[0],password:L[1]}}}}}if(P){D.headers.host=S.hostname+(S.port?":"+S.port:"");setProxy(D,P,T+"//"+S.hostname+(S.port?":"+S.port:"")+D.path)}var H;var W=k&&(P?y.test(P.protocol):true);if(e.transport){H=e.transport}else if(e.maxRedirects===0){H=W?c:a}else{if(e.maxRedirects){D.maxRedirects=e.maxRedirects}H=W?f:u}if(e.maxBodyLength>-1){D.maxBodyLength=e.maxBodyLength}var z=H.request(D,(function handleResponse(t){if(z.aborted)return;var r=t;var i=t.req||z;if(t.statusCode!==204&&i.method!=="HEAD"&&e.decompress!==false){switch(t.headers["content-encoding"]){case"gzip":case"compress":case"deflate":r=r.pipe(d.createUnzip());delete t.headers["content-encoding"];break}}var o={status:t.statusCode,statusText:t.statusMessage,headers:t.headers,config:e,request:i};if(e.responseType==="stream"){o.data=r;n(g,b,o)}else{var a=[];var c=0;r.on("data",(function handleStreamData(t){a.push(t);c+=t.length;if(e.maxContentLength>-1&&c>e.maxContentLength){r.destroy();b(l("maxContentLength size of "+e.maxContentLength+" exceeded",e,null,i))}}));r.on("error",(function handleStreamError(t){if(z.aborted)return;b(m(t,e,null,i))}));r.on("end",(function handleStreamEnd(){var t=Buffer.concat(a);if(e.responseType!=="arraybuffer"){t=t.toString(e.responseEncoding);if(!e.responseEncoding||e.responseEncoding==="utf8"){t=s.stripBOM(t)}}o.data=t;n(g,b,o)}))}}));z.on("error",(function handleRequestError(t){if(z.aborted&&t.code!=="ERR_FR_TOO_MANY_REDIRECTS")return;b(m(t,e,null,z))}));if(e.timeout){var V=parseInt(e.timeout,10);if(isNaN(V)){b(l("error trying to parse `config.timeout` to int",e,"ERR_PARSE_TIMEOUT",z));return}z.setTimeout(V,(function handleRequestTimeout(){z.abort();b(l("timeout of "+V+"ms exceeded",e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",z))}))}if(e.cancelToken){e.cancelToken.promise.then((function onCanceled(e){if(z.aborted)return;z.abort();b(e)}))}if(s.isStream(v)){v.on("error",(function handleStreamError(t){b(m(t,e,null,z))})).pipe(z)}else{z.end(v)}}))}},3454:(e,t,r)=>{"use strict";var s=r(328);var n=r(3211);var i=r(1545);var o=r(646);var a=r(1934);var c=r(6455);var u=r(3608);var f=r(5226);e.exports=function xhrAdapter(e){return new Promise((function dispatchXhrRequest(t,r){var p=e.data;var d=e.headers;var h=e.responseType;if(s.isFormData(p)){delete d["Content-Type"]}var l=new XMLHttpRequest;if(e.auth){var m=e.auth.username||"";var y=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";d.Authorization="Basic "+btoa(m+":"+y)}var g=a(e.baseURL,e.url);l.open(e.method.toUpperCase(),o(g,e.params,e.paramsSerializer),true);l.timeout=e.timeout;function onloadend(){if(!l){return}var s="getAllResponseHeaders"in l?c(l.getAllResponseHeaders()):null;var i=!h||h==="text"||h==="json"?l.responseText:l.response;var o={data:i,status:l.status,statusText:l.statusText,headers:s,config:e,request:l};n(t,r,o);l=null}if("onloadend"in l){l.onloadend=onloadend}else{l.onreadystatechange=function handleLoad(){if(!l||l.readyState!==4){return}if(l.status===0&&!(l.responseURL&&l.responseURL.indexOf("file:")===0)){return}setTimeout(onloadend)}}l.onabort=function handleAbort(){if(!l){return}r(f("Request aborted",e,"ECONNABORTED",l));l=null};l.onerror=function handleError(){r(f("Network Error",e,null,l));l=null};l.ontimeout=function handleTimeout(){var t="timeout of "+e.timeout+"ms exceeded";if(e.timeoutErrorMessage){t=e.timeoutErrorMessage}r(f(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",l));l=null};if(s.isStandardBrowserEnv()){var b=(e.withCredentials||u(g))&&e.xsrfCookieName?i.read(e.xsrfCookieName):undefined;if(b){d[e.xsrfHeaderName]=b}}if("setRequestHeader"in l){s.forEach(d,(function setRequestHeader(e,t){if(typeof p==="undefined"&&t.toLowerCase()==="content-type"){delete d[t]}else{l.setRequestHeader(t,e)}}))}if(!s.isUndefined(e.withCredentials)){l.withCredentials=!!e.withCredentials}if(h&&h!=="json"){l.responseType=e.responseType}if(typeof e.onDownloadProgress==="function"){l.addEventListener("progress",e.onDownloadProgress)}if(typeof e.onUploadProgress==="function"&&l.upload){l.upload.addEventListener("progress",e.onUploadProgress)}if(e.cancelToken){e.cancelToken.promise.then((function onCanceled(e){if(!l){return}l.abort();r(e);l=null}))}if(!p){p=null}l.send(p)}))}},2618:(e,t,r)=>{"use strict";var s=r(328);var n=r(7065);var i=r(8178);var o=r(4831);var a=r(8190);function createInstance(e){var t=new i(e);var r=n(i.prototype.request,t);s.extend(r,i.prototype,t);s.extend(r,t);return r}var c=createInstance(a);c.Axios=i;c.create=function create(e){return createInstance(o(c.defaults,e))};c.Cancel=r(8875);c.CancelToken=r(1587);c.isCancel=r(4057);c.all=function all(e){return Promise.all(e)};c.spread=r(4850);c.isAxiosError=r(650);e.exports=c;e.exports.default=c},8875:e=>{"use strict";function Cancel(e){this.message=e}Cancel.prototype.toString=function toString(){return"Cancel"+(this.message?": "+this.message:"")};Cancel.prototype.__CANCEL__=true;e.exports=Cancel},1587:(e,t,r)=>{"use strict";var s=r(8875);function CancelToken(e){if(typeof e!=="function"){throw new TypeError("executor must be a function.")}var t;this.promise=new Promise((function promiseExecutor(e){t=e}));var r=this;e((function cancel(e){if(r.reason){return}r.reason=new s(e);t(r.reason)}))}CancelToken.prototype.throwIfRequested=function throwIfRequested(){if(this.reason){throw this.reason}};CancelToken.source=function source(){var e;var t=new CancelToken((function executor(t){e=t}));return{token:t,cancel:e}};e.exports=CancelToken},4057:e=>{"use strict";e.exports=function isCancel(e){return!!(e&&e.__CANCEL__)}},8178:(e,t,r)=>{"use strict";var s=r(328);var n=r(646);var i=r(3214);var o=r(5062);var a=r(4831);var c=r(1632);var u=c.validators;function Axios(e){this.defaults=e;this.interceptors={request:new i,response:new i}}Axios.prototype.request=function request(e){if(typeof e==="string"){e=arguments[1]||{};e.url=arguments[0]}else{e=e||{}}e=a(this.defaults,e);if(e.method){e.method=e.method.toLowerCase()}else if(this.defaults.method){e.method=this.defaults.method.toLowerCase()}else{e.method="get"}var t=e.transitional;if(t!==undefined){c.assertOptions(t,{silentJSONParsing:u.transitional(u.boolean,"1.0.0"),forcedJSONParsing:u.transitional(u.boolean,"1.0.0"),clarifyTimeoutError:u.transitional(u.boolean,"1.0.0")},false)}var r=[];var s=true;this.interceptors.request.forEach((function unshiftRequestInterceptors(t){if(typeof t.runWhen==="function"&&t.runWhen(e)===false){return}s=s&&t.synchronous;r.unshift(t.fulfilled,t.rejected)}));var n=[];this.interceptors.response.forEach((function pushResponseInterceptors(e){n.push(e.fulfilled,e.rejected)}));var i;if(!s){var f=[o,undefined];Array.prototype.unshift.apply(f,r);f=f.concat(n);i=Promise.resolve(e);while(f.length){i=i.then(f.shift(),f.shift())}return i}var p=e;while(r.length){var d=r.shift();var h=r.shift();try{p=d(p)}catch(e){h(e);break}}try{i=o(p)}catch(e){return Promise.reject(e)}while(n.length){i=i.then(n.shift(),n.shift())}return i};Axios.prototype.getUri=function getUri(e){e=a(this.defaults,e);return n(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};s.forEach(["delete","get","head","options"],(function forEachMethodNoData(e){Axios.prototype[e]=function(t,r){return this.request(a(r||{},{method:e,url:t,data:(r||{}).data}))}}));s.forEach(["post","put","patch"],(function forEachMethodWithData(e){Axios.prototype[e]=function(t,r,s){return this.request(a(s||{},{method:e,url:t,data:r}))}}));e.exports=Axios},3214:(e,t,r)=>{"use strict";var s=r(328);function InterceptorManager(){this.handlers=[]}InterceptorManager.prototype.use=function use(e,t,r){this.handlers.push({fulfilled:e,rejected:t,synchronous:r?r.synchronous:false,runWhen:r?r.runWhen:null});return this.handlers.length-1};InterceptorManager.prototype.eject=function eject(e){if(this.handlers[e]){this.handlers[e]=null}};InterceptorManager.prototype.forEach=function forEach(e){s.forEach(this.handlers,(function forEachHandler(t){if(t!==null){e(t)}}))};e.exports=InterceptorManager},1934:(e,t,r)=>{"use strict";var s=r(1301);var n=r(7189);e.exports=function buildFullPath(e,t){if(e&&!s(t)){return n(e,t)}return t}},5226:(e,t,r)=>{"use strict";var s=r(1516);e.exports=function createError(e,t,r,n,i){var o=new Error(e);return s(o,t,r,n,i)}},5062:(e,t,r)=>{"use strict";var s=r(328);var n=r(9812);var i=r(4057);var o=r(8190);function throwIfCancellationRequested(e){if(e.cancelToken){e.cancelToken.throwIfRequested()}}e.exports=function dispatchRequest(e){throwIfCancellationRequested(e);e.headers=e.headers||{};e.data=n.call(e,e.data,e.headers,e.transformRequest);e.headers=s.merge(e.headers.common||{},e.headers[e.method]||{},e.headers);s.forEach(["delete","get","head","post","put","patch","common"],(function cleanHeaderConfig(t){delete e.headers[t]}));var t=e.adapter||o.adapter;return t(e).then((function onAdapterResolution(t){throwIfCancellationRequested(e);t.data=n.call(e,t.data,t.headers,e.transformResponse);return t}),(function onAdapterRejection(t){if(!i(t)){throwIfCancellationRequested(e);if(t&&t.response){t.response.data=n.call(e,t.response.data,t.response.headers,e.transformResponse)}}return Promise.reject(t)}))}},1516:e=>{"use strict";e.exports=function enhanceError(e,t,r,s,n){e.config=t;if(r){e.code=r}e.request=s;e.response=n;e.isAxiosError=true;e.toJSON=function toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}};return e}},4831:(e,t,r)=>{"use strict";var s=r(328);e.exports=function mergeConfig(e,t){t=t||{};var r={};var n=["url","method","data"];var i=["headers","auth","proxy","params"];var o=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"];var a=["validateStatus"];function getMergedValue(e,t){if(s.isPlainObject(e)&&s.isPlainObject(t)){return s.merge(e,t)}else if(s.isPlainObject(t)){return s.merge({},t)}else if(s.isArray(t)){return t.slice()}return t}function mergeDeepProperties(n){if(!s.isUndefined(t[n])){r[n]=getMergedValue(e[n],t[n])}else if(!s.isUndefined(e[n])){r[n]=getMergedValue(undefined,e[n])}}s.forEach(n,(function valueFromConfig2(e){if(!s.isUndefined(t[e])){r[e]=getMergedValue(undefined,t[e])}}));s.forEach(i,mergeDeepProperties);s.forEach(o,(function defaultToConfig2(n){if(!s.isUndefined(t[n])){r[n]=getMergedValue(undefined,t[n])}else if(!s.isUndefined(e[n])){r[n]=getMergedValue(undefined,e[n])}}));s.forEach(a,(function merge(s){if(s in t){r[s]=getMergedValue(e[s],t[s])}else if(s in e){r[s]=getMergedValue(undefined,e[s])}}));var c=n.concat(i).concat(o).concat(a);var u=Object.keys(e).concat(Object.keys(t)).filter((function filterAxiosKeys(e){return c.indexOf(e)===-1}));s.forEach(u,mergeDeepProperties);return r}},3211:(e,t,r)=>{"use strict";var s=r(5226);e.exports=function settle(e,t,r){var n=r.config.validateStatus;if(!r.status||!n||n(r.status)){e(r)}else{t(s("Request failed with status code "+r.status,r.config,null,r.request,r))}}},9812:(e,t,r)=>{"use strict";var s=r(328);var n=r(8190);e.exports=function transformData(e,t,r){var i=this||n;s.forEach(r,(function transform(r){e=r.call(i,e,t)}));return e}},8190:(e,t,r)=>{"use strict";var s=r(328);var n=r(6240);var i=r(1516);var o={"Content-Type":"application/x-www-form-urlencoded"};function setContentTypeIfUnset(e,t){if(!s.isUndefined(e)&&s.isUndefined(e["Content-Type"])){e["Content-Type"]=t}}function getDefaultAdapter(){var e;if(typeof XMLHttpRequest!=="undefined"){e=r(3454)}else if(typeof process!=="undefined"&&Object.prototype.toString.call(process)==="[object process]"){e=r(8104)}return e}function stringifySafely(e,t,r){if(s.isString(e)){try{(t||JSON.parse)(e);return s.trim(e)}catch(e){if(e.name!=="SyntaxError"){throw e}}}return(r||JSON.stringify)(e)}var a={transitional:{silentJSONParsing:true,forcedJSONParsing:true,clarifyTimeoutError:false},adapter:getDefaultAdapter(),transformRequest:[function transformRequest(e,t){n(t,"Accept");n(t,"Content-Type");if(s.isFormData(e)||s.isArrayBuffer(e)||s.isBuffer(e)||s.isStream(e)||s.isFile(e)||s.isBlob(e)){return e}if(s.isArrayBufferView(e)){return e.buffer}if(s.isURLSearchParams(e)){setContentTypeIfUnset(t,"application/x-www-form-urlencoded;charset=utf-8");return e.toString()}if(s.isObject(e)||t&&t["Content-Type"]==="application/json"){setContentTypeIfUnset(t,"application/json");return stringifySafely(e)}return e}],transformResponse:[function transformResponse(e){var t=this.transitional;var r=t&&t.silentJSONParsing;var n=t&&t.forcedJSONParsing;var o=!r&&this.responseType==="json";if(o||n&&s.isString(e)&&e.length){try{return JSON.parse(e)}catch(e){if(o){if(e.name==="SyntaxError"){throw i(e,this,"E_JSON_PARSE")}throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function validateStatus(e){return e>=200&&e<300}};a.headers={common:{Accept:"application/json, text/plain, */*"}};s.forEach(["delete","get","head"],(function forEachMethodNoData(e){a.headers[e]={}}));s.forEach(["post","put","patch"],(function forEachMethodWithData(e){a.headers[e]=s.merge(o)}));e.exports=a},7065:e=>{"use strict";e.exports=function bind(e,t){return function wrap(){var r=new Array(arguments.length);for(var s=0;s{"use strict";var s=r(328);function encode(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function buildURL(e,t,r){if(!t){return e}var n;if(r){n=r(t)}else if(s.isURLSearchParams(t)){n=t.toString()}else{var i=[];s.forEach(t,(function serialize(e,t){if(e===null||typeof e==="undefined"){return}if(s.isArray(e)){t=t+"[]"}else{e=[e]}s.forEach(e,(function parseValue(e){if(s.isDate(e)){e=e.toISOString()}else if(s.isObject(e)){e=JSON.stringify(e)}i.push(encode(t)+"="+encode(e))}))}));n=i.join("&")}if(n){var o=e.indexOf("#");if(o!==-1){e=e.slice(0,o)}e+=(e.indexOf("?")===-1?"?":"&")+n}return e}},7189:e=>{"use strict";e.exports=function combineURLs(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},1545:(e,t,r)=>{"use strict";var s=r(328);e.exports=s.isStandardBrowserEnv()?function standardBrowserEnv(){return{write:function write(e,t,r,n,i,o){var a=[];a.push(e+"="+encodeURIComponent(t));if(s.isNumber(r)){a.push("expires="+new Date(r).toGMTString())}if(s.isString(n)){a.push("path="+n)}if(s.isString(i)){a.push("domain="+i)}if(o===true){a.push("secure")}document.cookie=a.join("; ")},read:function read(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function remove(e){this.write(e,"",Date.now()-864e5)}}}():function nonStandardBrowserEnv(){return{write:function write(){},read:function read(){return null},remove:function remove(){}}}()},1301:e=>{"use strict";e.exports=function isAbsoluteURL(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},650:e=>{"use strict";e.exports=function isAxiosError(e){return typeof e==="object"&&e.isAxiosError===true}},3608:(e,t,r)=>{"use strict";var s=r(328);e.exports=s.isStandardBrowserEnv()?function standardBrowserEnv(){var e=/(msie|trident)/i.test(navigator.userAgent);var t=document.createElement("a");var r;function resolveURL(r){var s=r;if(e){t.setAttribute("href",s);s=t.href}t.setAttribute("href",s);return{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}r=resolveURL(window.location.href);return function isURLSameOrigin(e){var t=s.isString(e)?resolveURL(e):e;return t.protocol===r.protocol&&t.host===r.host}}():function nonStandardBrowserEnv(){return function isURLSameOrigin(){return true}}()},6240:(e,t,r)=>{"use strict";var s=r(328);e.exports=function normalizeHeaderName(e,t){s.forEach(e,(function processHeader(r,s){if(s!==t&&s.toUpperCase()===t.toUpperCase()){e[t]=r;delete e[s]}}))}},6455:(e,t,r)=>{"use strict";var s=r(328);var n=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function parseHeaders(e){var t={};var r;var i;var o;if(!e){return t}s.forEach(e.split("\n"),(function parser(e){o=e.indexOf(":");r=s.trim(e.substr(0,o)).toLowerCase();i=s.trim(e.substr(o+1));if(r){if(t[r]&&n.indexOf(r)>=0){return}if(r==="set-cookie"){t[r]=(t[r]?t[r]:[]).concat([i])}else{t[r]=t[r]?t[r]+", "+i:i}}}));return t}},4850:e=>{"use strict";e.exports=function spread(e){return function wrap(t){return e.apply(null,t)}}},1632:(e,t,r)=>{"use strict";var s=r(696);var n={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){n[e]=function validator(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var i={};var o=s.version.split(".");function isOlderVersion(e,t){var r=t?t.split("."):o;var s=e.split(".");for(var n=0;n<3;n++){if(r[n]>s[n]){return true}else if(r[n]0){var i=s[n];var o=t[i];if(o){var a=e[i];var c=a===undefined||o(a,i,e);if(c!==true){throw new TypeError("option "+i+" must be "+c)}continue}if(r!==true){throw Error("Unknown option "+i)}}}e.exports={isOlderVersion:isOlderVersion,assertOptions:assertOptions,validators:n}},328:(e,t,r)=>{"use strict";var s=r(7065);var n=Object.prototype.toString;function isArray(e){return n.call(e)==="[object Array]"}function isUndefined(e){return typeof e==="undefined"}function isBuffer(e){return e!==null&&!isUndefined(e)&&e.constructor!==null&&!isUndefined(e.constructor)&&typeof e.constructor.isBuffer==="function"&&e.constructor.isBuffer(e)}function isArrayBuffer(e){return n.call(e)==="[object ArrayBuffer]"}function isFormData(e){return typeof FormData!=="undefined"&&e instanceof FormData}function isArrayBufferView(e){var t;if(typeof ArrayBuffer!=="undefined"&&ArrayBuffer.isView){t=ArrayBuffer.isView(e)}else{t=e&&e.buffer&&e.buffer instanceof ArrayBuffer}return t}function isString(e){return typeof e==="string"}function isNumber(e){return typeof e==="number"}function isObject(e){return e!==null&&typeof e==="object"}function isPlainObject(e){if(n.call(e)!=="[object Object]"){return false}var t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function isDate(e){return n.call(e)==="[object Date]"}function isFile(e){return n.call(e)==="[object File]"}function isBlob(e){return n.call(e)==="[object Blob]"}function isFunction(e){return n.call(e)==="[object Function]"}function isStream(e){return isObject(e)&&isFunction(e.pipe)}function isURLSearchParams(e){return typeof URLSearchParams!=="undefined"&&e instanceof URLSearchParams}function trim(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function isStandardBrowserEnv(){if(typeof navigator!=="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")){return false}return typeof window!=="undefined"&&typeof document!=="undefined"}function forEach(e,t){if(e===null||typeof e==="undefined"){return}if(typeof e!=="object"){e=[e]}if(isArray(e)){for(var r=0,s=e.length;r{"use strict";var t=function isMergeableObject(e){return isNonNullObject(e)&&!isSpecial(e)};function isNonNullObject(e){return!!e&&typeof e==="object"}function isSpecial(e){var t=Object.prototype.toString.call(e);return t==="[object RegExp]"||t==="[object Date]"||isReactElement(e)}var r=typeof Symbol==="function"&&Symbol.for;var s=r?Symbol.for("react.element"):60103;function isReactElement(e){return e.$$typeof===s}function emptyTarget(e){return Array.isArray(e)?[]:{}}function cloneUnlessOtherwiseSpecified(e,t){return t.clone!==false&&t.isMergeableObject(e)?deepmerge(emptyTarget(e),e,t):e}function defaultArrayMerge(e,t,r){return e.concat(t).map((function(e){return cloneUnlessOtherwiseSpecified(e,r)}))}function getMergeFunction(e,t){if(!t.customMerge){return deepmerge}var r=t.customMerge(e);return typeof r==="function"?r:deepmerge}function getEnumerableOwnPropertySymbols(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return e.propertyIsEnumerable(t)})):[]}function getKeys(e){return Object.keys(e).concat(getEnumerableOwnPropertySymbols(e))}function propertyIsOnObject(e,t){try{return t in e}catch(e){return false}}function propertyIsUnsafe(e,t){return propertyIsOnObject(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function mergeObject(e,t,r){var s={};if(r.isMergeableObject(e)){getKeys(e).forEach((function(t){s[t]=cloneUnlessOtherwiseSpecified(e[t],r)}))}getKeys(t).forEach((function(n){if(propertyIsUnsafe(e,n)){return}if(propertyIsOnObject(e,n)&&r.isMergeableObject(t[n])){s[n]=getMergeFunction(n,r)(e[n],t[n],r)}else{s[n]=cloneUnlessOtherwiseSpecified(t[n],r)}}));return s}function deepmerge(e,r,s){s=s||{};s.arrayMerge=s.arrayMerge||defaultArrayMerge;s.isMergeableObject=s.isMergeableObject||t;s.cloneUnlessOtherwiseSpecified=cloneUnlessOtherwiseSpecified;var n=Array.isArray(r);var i=Array.isArray(e);var o=n===i;if(!o){return cloneUnlessOtherwiseSpecified(r,s)}else if(n){return s.arrayMerge(e,r,s)}else{return mergeObject(e,r,s)}}deepmerge.all=function deepmergeAll(e,t){if(!Array.isArray(e)){throw new Error("first argument should be an array")}return e.reduce((function(e,r){return deepmerge(e,r,t)}),{})};var n=deepmerge;e.exports=n},1133:(e,t,r)=>{var s;e.exports=function(){if(!s){try{s=r(9975)("follow-redirects")}catch(e){}if(typeof s!=="function"){s=function(){}}}s.apply(null,arguments)}},7707:(e,t,r)=>{var s=r(8835);var n=s.URL;var i=r(8605);var o=r(7211);var a=r(2413).Writable;var c=r(2357);var u=r(1133);var f=["abort","aborted","connect","error","socket","timeout"];var p=Object.create(null);f.forEach((function(e){p[e]=function(t,r,s){this._redirectable.emit(e,t,r,s)}}));var d=createErrorType("ERR_FR_REDIRECTION_FAILURE","");var h=createErrorType("ERR_FR_TOO_MANY_REDIRECTS","Maximum number of redirects exceeded");var l=createErrorType("ERR_FR_MAX_BODY_LENGTH_EXCEEDED","Request body larger than maxBodyLength limit");var m=createErrorType("ERR_STREAM_WRITE_AFTER_END","write after end");function RedirectableRequest(e,t){a.call(this);this._sanitizeOptions(e);this._options=e;this._ended=false;this._ending=false;this._redirectCount=0;this._redirects=[];this._requestBodyLength=0;this._requestBodyBuffers=[];if(t){this.on("response",t)}var r=this;this._onNativeResponse=function(e){r._processResponse(e)};this._performRequest()}RedirectableRequest.prototype=Object.create(a.prototype);RedirectableRequest.prototype.abort=function(){abortRequest(this._currentRequest);this.emit("abort")};RedirectableRequest.prototype.write=function(e,t,r){if(this._ending){throw new m}if(!(typeof e==="string"||typeof e==="object"&&"length"in e)){throw new TypeError("data should be a string, Buffer or Uint8Array")}if(typeof t==="function"){r=t;t=null}if(e.length===0){if(r){r()}return}if(this._requestBodyLength+e.length<=this._options.maxBodyLength){this._requestBodyLength+=e.length;this._requestBodyBuffers.push({data:e,encoding:t});this._currentRequest.write(e,t,r)}else{this.emit("error",new l);this.abort()}};RedirectableRequest.prototype.end=function(e,t,r){if(typeof e==="function"){r=e;e=t=null}else if(typeof t==="function"){r=t;t=null}if(!e){this._ended=this._ending=true;this._currentRequest.end(null,null,r)}else{var s=this;var n=this._currentRequest;this.write(e,t,(function(){s._ended=true;n.end(null,null,r)}));this._ending=true}};RedirectableRequest.prototype.setHeader=function(e,t){this._options.headers[e]=t;this._currentRequest.setHeader(e,t)};RedirectableRequest.prototype.removeHeader=function(e){delete this._options.headers[e];this._currentRequest.removeHeader(e)};RedirectableRequest.prototype.setTimeout=function(e,t){var r=this;function destroyOnTimeout(t){t.setTimeout(e);t.removeListener("timeout",t.destroy);t.addListener("timeout",t.destroy)}function startTimer(t){if(r._timeout){clearTimeout(r._timeout)}r._timeout=setTimeout((function(){r.emit("timeout");clearTimer()}),e);destroyOnTimeout(t)}function clearTimer(){if(r._timeout){clearTimeout(r._timeout);r._timeout=null}if(t){r.removeListener("timeout",t)}if(!r.socket){r._currentRequest.removeListener("socket",startTimer)}}if(t){this.on("timeout",t)}if(this.socket){startTimer(this.socket)}else{this._currentRequest.once("socket",startTimer)}this.on("socket",destroyOnTimeout);this.once("response",clearTimer);this.once("error",clearTimer);return this};["flushHeaders","getHeader","setNoDelay","setSocketKeepAlive"].forEach((function(e){RedirectableRequest.prototype[e]=function(t,r){return this._currentRequest[e](t,r)}}));["aborted","connection","socket"].forEach((function(e){Object.defineProperty(RedirectableRequest.prototype,e,{get:function(){return this._currentRequest[e]}})}));RedirectableRequest.prototype._sanitizeOptions=function(e){if(!e.headers){e.headers={}}if(e.host){if(!e.hostname){e.hostname=e.host}delete e.host}if(!e.pathname&&e.path){var t=e.path.indexOf("?");if(t<0){e.pathname=e.path}else{e.pathname=e.path.substring(0,t);e.search=e.path.substring(t)}}};RedirectableRequest.prototype._performRequest=function(){var e=this._options.protocol;var t=this._options.nativeProtocols[e];if(!t){this.emit("error",new TypeError("Unsupported protocol "+e));return}if(this._options.agents){var r=e.substr(0,e.length-1);this._options.agent=this._options.agents[r]}var n=this._currentRequest=t.request(this._options,this._onNativeResponse);this._currentUrl=s.format(this._options);n._redirectable=this;for(var i=0;i=300&&t<400){abortRequest(this._currentRequest);e.destroy();if(++this._redirectCount>this._options.maxRedirects){this.emit("error",new h);return}if((t===301||t===302)&&this._options.method==="POST"||t===303&&!/^(?:GET|HEAD)$/.test(this._options.method)){this._options.method="GET";this._requestBodyBuffers=[];removeMatchingHeaders(/^content-/i,this._options.headers)}var n=removeMatchingHeaders(/^host$/i,this._options.headers)||s.parse(this._currentUrl).hostname;var i=s.resolve(this._currentUrl,r);u("redirecting to",i);this._isRedirect=true;var o=s.parse(i);Object.assign(this._options,o);if(o.hostname!==n){removeMatchingHeaders(/^authorization$/i,this._options.headers)}if(typeof this._options.beforeRedirect==="function"){var a={headers:e.headers};try{this._options.beforeRedirect.call(null,this._options,a)}catch(e){this.emit("error",e);return}this._sanitizeOptions(this._options)}try{this._performRequest()}catch(e){var c=new d("Redirected request failed: "+e.message);c.cause=e;this.emit("error",c)}}else{e.responseUrl=this._currentUrl;e.redirects=this._redirects;this.emit("response",e);this._requestBodyBuffers=[]}};function wrap(e){var t={maxRedirects:21,maxBodyLength:10*1024*1024};var r={};Object.keys(e).forEach((function(i){var o=i+":";var a=r[o]=e[i];var f=t[i]=Object.create(a);function request(e,i,a){if(typeof e==="string"){var f=e;try{e=urlToOptions(new n(f))}catch(t){e=s.parse(f)}}else if(n&&e instanceof n){e=urlToOptions(e)}else{a=i;i=e;e={protocol:o}}if(typeof i==="function"){a=i;i=null}i=Object.assign({maxRedirects:t.maxRedirects,maxBodyLength:t.maxBodyLength},e,i);i.nativeProtocols=r;c.equal(i.protocol,o,"protocol mismatch");u("options",i);return new RedirectableRequest(i,a)}function get(e,t,r){var s=f.request(e,t,r);s.end();return s}Object.defineProperties(f,{request:{value:request,configurable:true,enumerable:true,writable:true},get:{value:get,configurable:true,enumerable:true,writable:true}})}));return t}function noop(){}function urlToOptions(e){var t={protocol:e.protocol,hostname:e.hostname.startsWith("[")?e.hostname.slice(1,-1):e.hostname,hash:e.hash,search:e.search,pathname:e.pathname,path:e.pathname+e.search,href:e.href};if(e.port!==""){t.port=Number(e.port)}return t}function removeMatchingHeaders(e,t){var r;for(var s in t){if(e.test(s)){r=t[s];delete t[s]}}return r}function createErrorType(e,t){function CustomError(e){Error.captureStackTrace(this,this.constructor);this.message=e||t}CustomError.prototype=new Error;CustomError.prototype.constructor=CustomError;CustomError.prototype.name="Error ["+e+"]";CustomError.prototype.code=e;return CustomError}function abortRequest(e){for(var t=0;t{module.exports=eval("require")("debug")},696:e=>{"use strict";e.exports=JSON.parse('{"name":"axios","version":"0.21.4","description":"Promise based HTTP client for the browser and node.js","main":"index.js","scripts":{"test":"grunt test","start":"node ./sandbox/server.js","build":"NODE_ENV=production grunt build","preversion":"npm test","version":"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json","postversion":"git push && git push --tags","examples":"node ./examples/server.js","coveralls":"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","fix":"eslint --fix lib/**/*.js"},"repository":{"type":"git","url":"https://github.com/axios/axios.git"},"keywords":["xhr","http","ajax","promise","node"],"author":"Matt Zabriskie","license":"MIT","bugs":{"url":"https://github.com/axios/axios/issues"},"homepage":"https://axios-http.com","devDependencies":{"coveralls":"^3.0.0","es6-promise":"^4.2.4","grunt":"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1","karma":"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2","minimist":"^1.2.0","mocha":"^8.2.1","sinon":"^4.5.0","terser-webpack-plugin":"^4.2.3","typescript":"^4.0.5","url-search-params":"^0.10.0","webpack":"^4.44.2","webpack-dev-server":"^3.11.0"},"browser":{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},"jsdelivr":"dist/axios.min.js","unpkg":"dist/axios.min.js","typings":"./index.d.ts","dependencies":{"follow-redirects":"^1.14.0"},"bundlesize":[{"path":"./dist/axios.min.js","threshold":"5kB"}]}')},2357:e=>{"use strict";e.exports=require("assert")},6417:e=>{"use strict";e.exports=require("crypto")},5747:e=>{"use strict";e.exports=require("fs")},8605:e=>{"use strict";e.exports=require("http")},7211:e=>{"use strict";e.exports=require("https")},5622:e=>{"use strict";e.exports=require("path")},2413:e=>{"use strict";e.exports=require("stream")},8835:e=>{"use strict";e.exports=require("url")},8761:e=>{"use strict";e.exports=require("zlib")}};var __webpack_module_cache__={};function __nccwpck_require__(e){var t=__webpack_module_cache__[e];if(t!==undefined){return t.exports}var r=__webpack_module_cache__[e]={exports:{}};var s=true;try{__webpack_modules__[e].call(r.exports,r,r.exports,__nccwpck_require__);s=false}finally{if(s)delete __webpack_module_cache__[e]}return r.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var __webpack_exports__=__nccwpck_require__(2932);module.exports=__webpack_exports__})(); \ No newline at end of file +(()=>{var __webpack_modules__={4431:e=>{"use strict";e.exports=JSON.parse('{"name":"@sendgrid/client","description":"Twilio SendGrid NodeJS API client","version":"7.5.0","author":"Twilio SendGrid (sendgrid.com)","contributors":["Kyle Partridge ","David Tomberlin ","Swift ","Brandon West ","Scott Motte ","Robert Acosta ","Elmer Thomas ","Adam Reis "],"license":"MIT","homepage":"https://sendgrid.com","repository":{"type":"git","url":"git://github.com/sendgrid/sendgrid-nodejs.git"},"publishConfig":{"access":"public"},"main":"index.js","engines":{"node":"6.* || 8.* || >=10.*"},"dependencies":{"@sendgrid/helpers":"^7.5.0","axios":"^0.21.4"},"devDependencies":{"chai":"4.2.0","nock":"^10.0.6"},"resolutions":{"chai":"4.2.0"},"tags":["http","rest","api","mail","sendgrid"],"gitHead":"a3307fda9318973ef9410f604a4d117ff7548e24"}')},2932:(e,t,r)=>{const{readFileSync:s}=r(5747);const{resolve:n}=r(5622);const{verifyWebhook:i}=r(8402);const o=r(6686);const a=r(2449);function getTemplateId(e,t){const r=t.config.templates[data.event]||"";if(!r){throw new Error(`Template ID is not available for event: ${data.event}`)}return r}async function createTemplate(e,t,n){const i=s(r.ab+"templates/"+e+"/template.html").toString();const o=s(r.ab+"templates/"+e+"/testData.json").toString();const[c]=await a.request({body:{name:t,generation:"dynamic"},method:"POST",url:"/v3/templates"});const{id:u}=c.body;await a.request({body:{name:t,subject:n,html_content:i,test_data:o,editor:"code"},method:"POST",url:`/v3/templates/${u}/versions`});return{event:e,id:u}}e.exports=async function handler(e,t){i(e.body,t.webhookSigningKey);if(e.body.event==="readiness.probe"){return{statusCode:204,body:""}}const r=await t.merchant();const s=r.id;const n=await t.integration();const c={...e.body,merchant:r};const u=n.config.sendgrid.api_key||null;if(!u){throw new Error("SendGrid API key not available. Please check your configuration.")}o.setApiKey(u);let f={};switch(c.event){case"integrations.ready":t.api.put(`/v1/merchants/${s}/notifications`,{customer:{login_token:false,orders:false,shipments:false}});a.setApiKey(u);const e=[];[{event:"customers.login.token",name:"Customers: login token",subject:"Log in to your account"},{event:"orders.create",name:"Orders: receipt",subject:"Your order: {{ payload.customer_reference }}"},{event:"orders.physical.shipment",name:"Orders: item shipped",subject:"Your order has shipped!"}].forEach((({event:t,name:r,subject:s})=>{e.push(createTemplate(t,r,s))}));const r=await Promise.all(e);const i={...n.config,templates:r.reduce(((e,t)=>(e[t.event]=t.id,e)),{})};f=await t.api.put(`/v1/integrations/${n.id}`,{config:i});break;case"orders.create":await o.send({to:c.payload.customer.email,from:c.merchant.support_email,subject:`Your order: ${c.payload.customer_reference}`,dynamic_template_data:c,template_id:getTemplateId(c.event,n)});f={sent:true};break;case"orders.physical.shipment":await o.send({to:c.payload.customer.email,from:c.merchant.support_email,subject:"Your order has a new shipment!",dynamic_template_data:c,template_id:getTemplateId(c.event,n)});f={sent:true};break;case"customers.login.token":await o.send({to:c.payload.email,from:c.merchant.support_email,subject:"Log in to your account",dynamic_template_data:c,template_id:getTemplateId(c.event,n)});f={sent:true};break;default:throw new Error("Invalid `event` type provided.")}return{statusCode:200,body:JSON.stringify(f)}}},2642:function(e,t){"use strict";var r=this&&this.__extends||function(){var extendStatics=function(e,t){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r))e[r]=t[r]};return extendStatics(e,t)};return function(e,t){if(typeof t!=="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");extendStatics(e,t);function __(){this.constructor=e}e.prototype=t===null?Object.create(t):(__.prototype=t.prototype,new __)}}();Object.defineProperty(t,"__esModule",{value:true});t.VerificationError=void 0;var s=function(e){r(VerificationError,e);function VerificationError(){return e!==null&&e.apply(this,arguments)||this}return VerificationError}(Error);t.VerificationError=s},8402:function(e,t,r){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){if(s===undefined)s=r;Object.defineProperty(e,s,{enumerable:true,get:function(){return t[r]}})}:function(e,t,r,s){if(s===undefined)s=r;e[s]=t[r]});var n=this&&this.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))s(t,e,r)};Object.defineProperty(t,"__esModule",{value:true});n(r(746),t)},746:function(e,t,r){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){if(s===undefined)s=r;Object.defineProperty(e,s,{enumerable:true,get:function(){return t[r]}})}:function(e,t,r,s){if(s===undefined)s=r;e[s]=t[r]});var n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(r!=="default"&&Object.prototype.hasOwnProperty.call(e,r))s(t,e,r);n(t,e);return t};Object.defineProperty(t,"__esModule",{value:true});t.verifyWebhook=void 0;var o=r(2642);var a=i(r(6417));function verifyWebhook(e,t,r){if(r===void 0){r=300}var s=e.signature;delete e.signature;if(!s||!s.length){throw new o.VerificationError("Signature was not found in payload.")}if(!t||!t.length){throw new o.VerificationError("Signing key was not provided.")}var n=a.createHmac("sha256",t).update(JSON.stringify(e)).digest("hex");if(n!==s){throw new o.VerificationError("Signature mismatch.")}var i=new Date(e.created*1e3);var c=new Date;if(+i<+c-r*1e3){throw new o.VerificationError("Request was made too far in the past.")}}t.verifyWebhook=verifyWebhook},2449:(e,t,r)=>{"use strict";const s=r(2769);const n=r(5843);e.exports=s;e.exports.Client=n},5843:(e,t,r)=>{"use strict";const s=r(6545);const n=r(4431);const{helpers:{mergeData:i},classes:{Response:o,ResponseError:a}}=r(2733);const c="SG.";const u="https://api.sendgrid.com/";const f="https://email.twilio.com/";class Client{constructor(){this.auth="";this.impersonateSubuser="";this.defaultHeaders={Accept:"application/json","Content-Type":"application/json","User-Agent":"sendgrid/"+n.version+";nodejs"};this.defaultRequest={baseUrl:u,url:"",method:"GET",headers:{},maxContentLength:Infinity,maxBodyLength:Infinity}}setApiKey(e){this.auth="Bearer "+e;this.setDefaultRequest("baseUrl",u);if(!this.isValidApiKey(e)){console.warn(`API key does not start with "${c}".`)}}setTwilioEmailAuth(e,t){const r=Buffer.from(e+":"+t).toString("base64");this.auth="Basic "+r;this.setDefaultRequest("baseUrl",f);if(!this.isValidTwilioAuth(e,t)){console.warn("Twilio Email credentials must be non-empty strings.")}}isValidApiKey(e){return this.isString(e)&&e.trim().startsWith(c)}isValidTwilioAuth(e,t){return this.isString(e)&&e&&this.isString(t)&&t}isString(e){return typeof e==="string"||e instanceof String}setImpersonateSubuser(e){this.impersonateSubuser=e}setDefaultHeader(e,t){if(e!==null&&typeof e==="object"){Object.assign(this.defaultHeaders,e);return this}this.defaultHeaders[e]=t;return this}setDefaultRequest(e,t){if(e!==null&&typeof e==="object"){Object.assign(this.defaultRequest,e);return this}this.defaultRequest[e]=t;return this}createHeaders(e){const t=i(this.defaultHeaders,e);if(typeof t.Authorization==="undefined"&&this.auth){t.Authorization=this.auth}if(this.impersonateSubuser){t["On-Behalf-Of"]=this.impersonateSubuser}return t}createRequest(e){let t={url:e.uri||e.url,baseUrl:e.baseUrl,method:e.method,data:e.body,params:e.qs,headers:e.headers};t=i(this.defaultRequest,t);t.headers=this.createHeaders(t.headers);t.baseURL=t.baseUrl;delete t.baseUrl;return t}request(e,t){e=this.createRequest(e);const r=new Promise(((t,r)=>{s(e).then((e=>t([new o(e.status,e.data,e.headers),e.data]))).catch((e=>{if(e.response){if(e.response.status>=400){return r(new a(e.response))}}return r(e)}))}));if(t&&typeof t!=="function"){throw new Error("Callback passed is not a function.")}if(t){return r.then((e=>t(null,e))).catch((e=>t(e,null)))}return r}}e.exports=Client},2769:(e,t,r)=>{"use strict";const s=r(5843);e.exports=new s},9232:(e,t,r)=>{"use strict";const s=r(3278);const n=r(7609);const i=r(4054);const o=r(5747);const a=r(5622);class Attachment{constructor(e){if(e){this.fromData(e)}}fromData(e){if(typeof e!=="object"){throw new Error("Expecting object for Mail data")}e=i(e);e=s(e);const{content:t,filename:r,type:n,disposition:o,contentId:a,filePath:c}=e;if(typeof t!=="undefined"&&typeof c!=="undefined"){throw new Error("The props 'content' and 'filePath' cannot be used together.")}this.setFilename(r);this.setType(n);this.setDisposition(o);this.setContentId(a);this.setContent(c?this.readFile(c):t)}readFile(e){return o.readFileSync(a.resolve(e))}setContent(e){if(typeof e==="string"){this.content=e;return}else if(e instanceof Buffer&&e.toString!==undefined){this.content=e.toString();if(this.disposition==="attachment"){this.content=e.toString("base64")}return}throw new Error("`content` expected to be either Buffer or string")}setFileContent(e){if(e instanceof Buffer&&e.toString!==undefined){this.content=e.toString("base64");return}throw new Error("`content` expected to be Buffer")}setFilename(e){if(typeof e==="undefined"){return}if(e&&typeof e!=="string"){throw new Error("String expected for `filename`")}this.filename=e}setType(e){if(typeof e==="undefined"){return}if(typeof e!=="string"){throw new Error("String expected for `type`")}this.type=e}setDisposition(e){if(typeof e==="undefined"){return}if(typeof e!=="string"){throw new Error("String expected for `disposition`")}this.disposition=e}setContentId(e){if(typeof e==="undefined"){return}if(typeof e!=="string"){throw new Error("String expected for `contentId`")}this.contentId=e}toJSON(){const{content:e,filename:t,type:r,disposition:s,contentId:i}=this;const o={content:e,filename:t};if(typeof r!=="undefined"){o.type=r}if(typeof s!=="undefined"){o.disposition=s}if(typeof i!=="undefined"){o.contentId=i}return n(o)}}e.exports=Attachment},9058:(e,t,r)=>{"use strict";const s=r(4194);class EmailAddress{constructor(e){if(e){this.fromData(e)}}fromData(e){if(typeof e==="string"){const[t,r]=s(e);e={name:t,email:r}}if(typeof e!=="object"){throw new Error("Expecting object or string for EmailAddress data")}const{name:t,email:r}=e;this.setEmail(r);this.setName(t)}setName(e){if(typeof e==="undefined"){return}if(typeof e!=="string"){throw new Error("String expected for `name`")}this.name=e}setEmail(e){if(typeof e==="undefined"){throw new Error("Must provide `email`")}if(typeof e!=="string"){throw new Error("String expected for `email`")}this.email=e}toJSON(){const{email:e,name:t}=this;const r={email:e};if(t!==""){r.name=t}return r}static create(e){if(Array.isArray(e)){return e.filter((e=>!!e)).map((e=>this.create(e)))}if(e instanceof EmailAddress){return e}return new EmailAddress(e)}}e.exports=EmailAddress},8480:(e,t,r)=>{"use strict";const s=r(9232);const n=r(9058);const i=r(806);const o=r(65);const a=r(4512);const c=r(2359);const u=r(374);e.exports={Attachment:s,EmailAddress:n,Mail:i,Personalization:o,Response:a,ResponseError:c,Statistics:u}},806:(e,t,r)=>{"use strict";const s=r(9058);const n=r(65);const i=r(3278);const o=r(7609);const a=r(4054);const c=r(3872);const{DYNAMIC_TEMPLATE_CHAR_WARNING:u}=r(2066);const{validateMailSettings:f,validateTrackingSettings:p}=r(7738);class Mail{constructor(e){this.isDynamic=false;this.hideWarnings=false;this.personalizations=[];this.attachments=[];this.content=[];this.categories=[];this.headers={};this.sections={};this.customArgs={};this.trackingSettings={};this.mailSettings={};this.asm={};this.substitutions=null;this.substitutionWrappers=null;this.dynamicTemplateData=null;if(e){this.fromData(e)}}fromData(e){if(typeof e!=="object"){throw new Error("Expecting object for Mail data")}e=a(e);e=i(e,["substitutions","dynamicTemplateData","customArgs","headers","sections"]);const{to:t,from:r,replyTo:s,cc:n,bcc:o,sendAt:c,subject:u,text:f,html:p,content:d,templateId:h,personalizations:l,attachments:m,ipPoolName:y,batchId:g,sections:b,headers:v,categories:w,category:_,customArgs:E,asm:x,mailSettings:A,trackingSettings:S,substitutions:T,substitutionWrappers:j,dynamicTemplateData:O,isMultiple:R,hideWarnings:k,replyToList:C}=e;this.setFrom(r);this.setReplyTo(s);this.setSubject(u);this.setSendAt(c);this.setTemplateId(h);this.setBatchId(g);this.setIpPoolName(y);this.setAttachments(m);this.setContent(d);this.setSections(b);this.setHeaders(v);this.setCategories(_);this.setCategories(w);this.setCustomArgs(E);this.setAsm(x);this.setMailSettings(A);this.setTrackingSettings(S);this.setHideWarnings(k);this.setReplyToList(C);if(this.isDynamic){this.setDynamicTemplateData(O)}else{this.setSubstitutions(T);this.setSubstitutionWrappers(j)}this.addTextContent(f);this.addHtmlContent(p);if(l){this.setPersonalizations(l)}else if(R&&Array.isArray(t)){t.forEach((e=>this.addTo(e,n,o)))}else{this.addTo(t,n,o)}}setFrom(e){if(this._checkProperty("from",e,[this._checkUndefined])){if(typeof e!=="string"&&typeof e.email!=="string"){throw new Error("String or address object expected for `from`")}this.from=s.create(e)}}setReplyTo(e){if(this._checkProperty("replyTo",e,[this._checkUndefined])){if(typeof e!=="string"&&typeof e.email!=="string"){throw new Error("String or address object expected for `replyTo`")}this.replyTo=s.create(e)}}setSubject(e){this._setProperty("subject",e,"string")}setSendAt(e){if(this._checkProperty("sendAt",e,[this._checkUndefined,this._createCheckThatThrows(Number.isInteger,"Integer expected for `sendAt`")])){this.sendAt=e}}setTemplateId(e){if(this._setProperty("templateId",e,"string")){if(e.indexOf("d-")===0){this.isDynamic=true}}}setBatchId(e){this._setProperty("batchId",e,"string")}setIpPoolName(e){this._setProperty("ipPoolName",e,"string")}setAsm(e){if(this._checkProperty("asm",e,[this._checkUndefined,this._createTypeCheck("object")])){if(typeof e.groupId!=="number"){throw new Error("Expected `asm` to include an integer in its `groupId` field")}if(e.groupsToDisplay&&(!Array.isArray(e.groupsToDisplay)||!e.groupsToDisplay.every((e=>typeof e==="number")))){throw new Error("Array of integers expected for `asm.groupsToDisplay`")}this.asm=e}}setPersonalizations(e){if(!this._doArrayCheck("personalizations",e)){return}if(!e.every((e=>typeof e==="object"))){throw new Error("Array of objects expected for `personalizations`")}this.personalizations=[];e.forEach((e=>this.addPersonalization(e)))}addPersonalization(e){if(this.isDynamic&&e.substitutions){delete e.substitutions}else if(!this.isDynamic&&e.dynamicTemplateData){delete e.dynamicTemplateData}if(!(e instanceof n)){e=new n(e)}if(this.isDynamic){this.applyDynamicTemplateData(e)}else{this.applySubstitutions(e)}this.personalizations.push(e)}addTo(e,t,r){if(typeof e==="undefined"&&typeof t==="undefined"&&typeof r==="undefined"){throw new Error("Provide at least one of to, cc or bcc")}this.addPersonalization(new n({to:e,cc:t,bcc:r}))}setSubstitutions(e){this._setProperty("substitutions",e,"object")}setSubstitutionWrappers(e){let lengthCheck=(e,t)=>{if(!Array.isArray(t)||t.length!==2){throw new Error("Array expected with two elements for `"+e+"`")}};if(this._checkProperty("substitutionWrappers",e,[this._checkUndefined,lengthCheck])){this.substitutionWrappers=e}}applySubstitutions(e){if(e instanceof n){e.reverseMergeSubstitutions(this.substitutions);e.setSubstitutionWrappers(this.substitutionWrappers)}}applyDynamicTemplateData(e){if(e instanceof n){e.deepMergeDynamicTemplateData(this.dynamicTemplateData)}}setDynamicTemplateData(e){if(typeof e==="undefined"){return}if(typeof e!=="object"){throw new Error("Object expected for `dynamicTemplateData`")}if(!this.hideWarnings){Object.values(e).forEach((e=>{if(/['"&]/.test(e)){console.warn(u)}}))}this.dynamicTemplateData=e}setContent(e){if(this._doArrayCheck("content",e)){if(!e.every((e=>typeof e==="object"))){throw new Error("Expected each entry in `content` to be an object")}if(!e.every((e=>typeof e.type==="string"))){throw new Error("Expected each `content` entry to contain a `type` string")}if(!e.every((e=>typeof e.value==="string"))){throw new Error("Expected each `content` entry to contain a `value` string")}this.content=e}}addContent(e){if(this._checkProperty("content",e,[this._createTypeCheck("object")])){this.content.push(e)}}addTextContent(e){if(this._checkProperty("text",e,[this._checkUndefined,this._createTypeCheck("string")])){this.addContent({value:e,type:"text/plain"})}}addHtmlContent(e){if(this._checkProperty("html",e,[this._checkUndefined,this._createTypeCheck("string")])){this.addContent({value:e,type:"text/html"})}}setAttachments(e){if(this._doArrayCheck("attachments",e)){if(!e.every((e=>typeof e.content==="string"))){throw new Error("Expected each attachment to contain a `content` string")}if(!e.every((e=>typeof e.filename==="string"))){throw new Error("Expected each attachment to contain a `filename` string")}if(!e.every((e=>!e.type||typeof e.type==="string"))){throw new Error("Expected the attachment's `type` field to be a string")}if(!e.every((e=>!e.disposition||typeof e.disposition==="string"))){throw new Error("Expected the attachment's `disposition` field to be a string")}this.attachments=e}}addAttachment(e){if(this._checkProperty("attachment",e,[this._checkUndefined,this._createTypeCheck("object")])){this.attachments.push(e)}}setCategories(e){let allElementsAreStrings=(e,t)=>{if(!Array.isArray(t)||!t.every((e=>typeof e==="string"))){throw new Error("Array of strings expected for `"+e+"`")}};if(typeof e==="string"){e=[e]}if(this._checkProperty("categories",e,[this._checkUndefined,allElementsAreStrings])){this.categories=e}}addCategory(e){if(this._checkProperty("category",e,[this._createTypeCheck("string")])){this.categories.push(e)}}setHeaders(e){this._setProperty("headers",e,"object")}addHeader(e,t){if(this._checkProperty("key",e,[this._createTypeCheck("string")])&&this._checkProperty("value",t,[this._createTypeCheck("string")])){this.headers[e]=t}}setSections(e){this._setProperty("sections",e,"object")}setCustomArgs(e){this._setProperty("customArgs",e,"object")}setTrackingSettings(e){if(typeof e==="undefined"){return}p(e);this.trackingSettings=e}setMailSettings(e){if(typeof e==="undefined"){return}f(e);this.mailSettings=e}setHideWarnings(e){if(typeof e==="undefined"){return}if(typeof e!=="boolean"){throw new Error("Boolean expected for `hideWarnings`")}this.hideWarnings=e}toJSON(){const{from:e,replyTo:t,sendAt:r,subject:s,content:n,templateId:i,personalizations:a,attachments:u,ipPoolName:f,batchId:p,asm:d,sections:h,headers:l,categories:m,customArgs:y,mailSettings:g,trackingSettings:b,replyToList:v}=this;const w={from:e,subject:s,personalizations:c(a)};if(Array.isArray(u)&&u.length>0){w.attachments=c(u)}if(Array.isArray(m)&&m.length>0){w.categories=m.filter((e=>e!==""))}if(Array.isArray(n)&&n.length>0){w.content=c(n)}if(Object.keys(l).length>0){w.headers=l}if(Object.keys(g).length>0){w.mailSettings=g}if(Object.keys(b).length>0){w.trackingSettings=b}if(Object.keys(y).length>0){w.customArgs=y}if(Object.keys(h).length>0){w.sections=h}if(Object.keys(d).length>0){w.asm=d}if(typeof t!=="undefined"){w.replyTo=t}if(typeof r!=="undefined"){w.sendAt=r}if(typeof p!=="undefined"){w.batchId=p}if(typeof i!=="undefined"){w.templateId=i}if(typeof f!=="undefined"){w.ipPoolName=f}if(typeof v!=="undefined"){w.replyToList=v}return o(w,["substitutions","dynamicTemplateData","customArgs","headers","sections"])}static create(e){if(Array.isArray(e)){return e.filter((e=>!!e)).map((e=>this.create(e)))}if(e instanceof Mail){return e}return new Mail(e)}_checkProperty(e,t,r){return!r.some((r=>r(e,t)))}_setProperty(e,t,r){let s=this._checkProperty(e,t,[this._checkUndefined,this._createTypeCheck(r)]);if(s){this[e]=t}return s}_checkUndefined(e,t){return typeof t==="undefined"}_createTypeCheck(e){return(t,r)=>{if(typeof r!==e){throw new Error(e+" expected for `"+t+"`")}}}_createCheckThatThrows(e,t){return(r,s)=>{if(!e(s)){throw new Error(t)}}}_setArrayProperty(e,t){if(this._doArrayCheck(e,t)){this[e]=t}}_doArrayCheck(e,t){return this._checkProperty(e,t,[this._checkUndefined,this._createCheckThatThrows(Array.isArray,"Array expected for`"+e+"`")])}setReplyToList(e){if(this._doArrayCheck("replyToList",e)&&e.length){if(!e.every((e=>e&&typeof e.email==="string"))){throw new Error("Expected each replyTo to contain an `email` string")}this.replyToList=e}}}e.exports=Mail},65:(e,t,r)=>{"use strict";const s=r(9058);const n=r(3278);const i=r(7609);const o=r(4054);const a=r(6323);const c=r(7174);class Personalization{constructor(e){this.to=[];this.cc=[];this.bcc=[];this.headers={};this.customArgs={};this.substitutions={};this.substitutionWrappers=["{{","}}"];this.dynamicTemplateData={};if(e){this.fromData(e)}}fromData(e){if(typeof e!=="object"){throw new Error("Expecting object for Mail data")}e=o(e);e=n(e,["substitutions","dynamicTemplateData","customArgs","headers"]);const{to:t,cc:r,bcc:s,subject:i,headers:a,customArgs:c,sendAt:u,substitutions:f,substitutionWrappers:p,dynamicTemplateData:d}=e;this.setTo(t);this.setCc(r);this.setBcc(s);this.setSubject(i);this.setHeaders(a);this.setSubstitutions(f);this.setSubstitutionWrappers(p);this.setCustomArgs(c);this.setDynamicTemplateData(d);this.setSendAt(u)}setSubject(e){if(typeof e==="undefined"){return}if(typeof e!=="string"){throw new Error("String expected for `subject`")}this.subject=e}setSendAt(e){if(typeof e==="undefined"){return}if(!Number.isInteger(e)){throw new Error("Integer expected for `sendAt`")}this.sendAt=e}setTo(e){if(typeof e==="undefined"){return}if(!Array.isArray(e)){e=[e]}this.to=s.create(e)}addTo(e){if(typeof e==="undefined"){return}this.to.push(s.create(e))}setCc(e){if(typeof e==="undefined"){return}if(!Array.isArray(e)){e=[e]}this.cc=s.create(e)}addCc(e){if(typeof e==="undefined"){return}this.cc.push(s.create(e))}setBcc(e){if(typeof e==="undefined"){return}if(!Array.isArray(e)){e=[e]}this.bcc=s.create(e)}addBcc(e){if(typeof e==="undefined"){return}this.bcc.push(s.create(e))}setHeaders(e){if(typeof e==="undefined"){return}if(typeof e!=="object"||e===null){throw new Error("Object expected for `headers`")}this.headers=e}addHeader(e,t){if(typeof e!=="string"){throw new Error("String expected for header key")}if(typeof t!=="string"){throw new Error("String expected for header value")}this.headers[e]=t}setCustomArgs(e){if(typeof e==="undefined"){return}if(typeof e!=="object"||e===null){throw new Error("Object expected for `customArgs`")}this.customArgs=e}addCustomArg(e,t){if(typeof e!=="string"){throw new Error("String expected for custom arg key")}if(typeof t!=="string"){throw new Error("String expected for custom arg value")}this.customArgs[e]=t}setSubstitutions(e){if(typeof e==="undefined"){return}if(typeof e!=="object"){throw new Error("Object expected for `substitutions`")}this.substitutions=e}addSubstitution(e,t){if(typeof e!=="string"){throw new Error("String expected for substitution key")}if(typeof t!=="string"&&typeof t!=="number"){throw new Error("String or Number expected for substitution value")}this.substitutions[e]=t}reverseMergeSubstitutions(e){if(typeof e==="undefined"||e===null){return}if(typeof e!=="object"){throw new Error("Object expected for `substitutions` in reverseMergeSubstitutions")}this.substitutions=Object.assign({},e,this.substitutions)}setSubstitutionWrappers(e){if(typeof e==="undefined"||e===null){return}if(!Array.isArray(e)||e.length!==2){throw new Error("Array expected with two elements for `substitutionWrappers`")}this.substitutionWrappers=e}deepMergeDynamicTemplateData(e){if(typeof e==="undefined"||e===null){return}if(typeof e!=="object"){throw new Error("Object expected for `dynamicTemplateData` in deepMergeDynamicTemplateData")}this.dynamicTemplateData=a(e,this.dynamicTemplateData)}setDynamicTemplateData(e){if(typeof e==="undefined"){return}if(typeof e!=="object"){throw new Error("Object expected for `dynamicTemplateData`")}this.dynamicTemplateData=e}toJSON(){const{to:e,cc:t,bcc:r,subject:s,headers:n,customArgs:o,sendAt:a,substitutions:u,substitutionWrappers:f,dynamicTemplateData:p}=this;const d={to:e};if(Array.isArray(t)&&t.length>0){d.cc=t}if(Array.isArray(r)&&r.length>0){d.bcc=r}if(Object.keys(n).length>0){d.headers=n}if(u&&Object.keys(u).length>0){const[e,t]=f;d.substitutions=c(u,e,t)}if(Object.keys(o).length>0){d.customArgs=o}if(p&&Object.keys(p).length>0){d.dynamicTemplateData=p}if(typeof s!=="undefined"){d.subject=s}if(typeof a!=="undefined"){d.sendAt=a}return i(d,["substitutions","dynamicTemplateData","customArgs","headers"])}}e.exports=Personalization},2359:e=>{"use strict";class ResponseError extends Error{constructor(e){super();const{headers:t,status:r,statusText:s,data:n}=e;this.code=r;this.message=s;this.response={headers:t,body:n};if(!this.stack){Error.captureStackTrace(this,this.constructor)}const i=new RegExp(process.cwd()+"/","gi");this.stack=this.stack.replace(i,"")}toString(){const{body:e}=this.response;let t=`${this.message} (${this.code})`;if(e&&Array.isArray(e.errors)){e.errors.forEach((e=>{const r=e.message;const s=e.field;const n=e.help;t+=`\n ${r}\n ${s}\n ${n}`}))}return t}toJSON(){const{message:e,code:t,response:r}=this;return{message:e,code:t,response:r}}}e.exports=ResponseError},4512:e=>{"use strict";class Response{constructor(e,t,r){this.statusCode=e;this.body=t;this.headers=r}toString(){return"HTTP "+this.statusCode+" "+this.body}}e.exports=Response},374:(e,t,r)=>{"use strict";const s=r(3278);const n=r(4054);const i=["day","week","month"];const o=["us","ca"];const a=["desc","asc"];class Statistics{constructor(e){this.startDate=null;this.endDate=null;this.aggregatedBy=null;if(e){this.fromData(e)}}fromData(e){if(typeof e!=="object"){throw new Error("Expecting object for Statistics data")}e=n(e);e=s(e,["substitutions","customArgs"]);const{startDate:t,endDate:r,aggregatedBy:i}=e;this.setStartDate(t);this.setEndDate(r);this.setAggregatedBy(i)}setStartDate(e){if(typeof e==="undefined"){throw new Error("Date expected for `startDate`")}if(new Date(e)==="Invalid Date"||isNaN(new Date(e))){throw new Error("Date expected for `startDate`")}console.log(e);this.startDate=new Date(e).toISOString().slice(0,10)}setEndDate(e){if(typeof e==="undefined"){this.endDate=(new Date).toISOString().slice(0,10);return}if(new Date(e)==="Invalid Date"||isNaN(new Date(e))){throw new Error("Date expected for `endDate`")}this.endDate=new Date(e).toISOString().slice(0,10)}setAggregatedBy(e){if(typeof e==="undefined"){return}if(typeof e==="string"&&i.includes(e.toLowerCase())){this.aggregatedBy=e}else{throw new Error("Incorrect value for `aggregatedBy`")}}getGlobal(){const{startDate:e,endDate:t,aggregatedBy:r}=this;return{startDate:e,endDate:t,aggregatedBy:r}}getAdvanced(e){const t=this.getGlobal();if(typeof e==="undefined"){return t}if(typeof e==="string"&&o.includes(e.toLowerCase())){t.country=e}return t}getAdvancedMailboxProviders(e){const t=this.getGlobal();if(typeof e==="undefined"){return t}if(Array.isArray(e)&&e.some((e=>typeof e!=="string"))){throw new Error("Array of strings expected for `mailboxProviders`")}t.mailBoxProviders=e;return t}getAdvancedBrowsers(e){const t=this.getGlobal();if(typeof e==="undefined"){return t}if(Array.isArray(e)&&e.some((e=>typeof e!=="string"))){throw new Error("Array of strings expected for `browsers`")}t.browsers=e;return t}getCategories(e){if(typeof e==="undefined"){throw new Error("Array of strings expected for `categories`")}if(!this._isValidArrayOfStrings(e)){throw new Error("Array of strings expected for `categories`")}const t=this.getGlobal();t.categories=e;return t}getSubuser(e){if(typeof e==="undefined"){throw new Error("Array of strings expected for `subusers`")}if(!this._isValidArrayOfStrings(e)){throw new Error("Array of strings expected for `subusers`")}const t=this.getGlobal();t.subusers=e;return t}getSubuserSum(e="delivered",t=a[0],r=5,s=0){if(typeof e!=="string"){throw new Error("string expected for `sortByMetric`")}if(!a.includes(t.toLowerCase())){throw new Error("desc or asc expected for `sortByDirection`")}if(typeof r!=="number"){throw new Error("number expected for `limit`")}if(typeof s!=="number"){throw new Error("number expected for `offset`")}const n=this.getGlobal();n.sortByMetric=e;n.sortByDirection=t;n.limit=r;n.offset=s;return n}getSubuserMonthly(e="delivered",t=a[0],r=5,s=0){if(typeof e!=="string"){throw new Error("string expected for `sortByMetric`")}if(!a.includes(t.toLowerCase())){throw new Error("desc or asc expected for `sortByDirection`")}if(typeof r!=="number"){throw new Error("number expected for `limit`")}if(typeof s!=="number"){throw new Error("number expected for `offset`")}const n=this.getGlobal();n.sortByMetric=e;n.sortByDirection=t;n.limit=r;n.offset=s;return n}_isValidArrayOfStrings(e){if(!Array.isArray(e)){return false}if(e.length<1||e.some((e=>typeof e!=="string"))){return false}return true}}e.exports=Statistics},2066:e=>{const t=`\nContent with characters ', " or & may need to be escaped with three brackets\n{{{ content }}}\nSee https://sendgrid.com/docs/for-developers/sending-email/using-handlebars/ for more information.`;e.exports={DYNAMIC_TEMPLATE_CHAR_WARNING:t}},3872:e=>{"use strict";e.exports=function arrayToJSON(e){return e.map((e=>{if(typeof e==="object"&&e!==null&&typeof e.toJSON==="function"){return e.toJSON()}return e}))}},8560:e=>{"use strict";e.exports=function convertKeys(e,t,r){if(typeof e!=="object"||e===null){throw new Error("Non object passed to convertKeys: "+e)}if(Array.isArray(e)){return e}if(!Array.isArray(r)){r=[]}for(const s in e){if(e.hasOwnProperty(s)){const n=t(s);if(typeof e[s]==="object"&&e[s]!==null){if(!r.includes(s)&&!r.includes(n)){e[s]=convertKeys(e[s],t,r)}}if(n!==s){e[n]=e[s];delete e[s]}}}return e}},4054:e=>{"use strict";e.exports=function deepClone(e){return JSON.parse(JSON.stringify(e))}},4741:(e,t,r)=>{"use strict";const s=r(3872);const n=r(8560);const i=r(4054);const o=r(1001);const a=r(4194);const c=r(3278);const u=r(7609);const f=r(7174);e.exports={arrayToJSON:s,convertKeys:n,deepClone:i,mergeData:o,splitNameEmail:a,toCamelCase:c,toSnakeCase:u,wrapSubstitutions:f}},1001:e=>{"use strict";e.exports=function mergeData(e,t){if(typeof e!=="object"||e===null){throw new Error("Not an object provided for base")}if(typeof t!=="object"||t===null){throw new Error("Not an object provided for data")}const r=Object.assign({},e);for(const e in t){if(t.hasOwnProperty(e)){if(t[e]&&Array.isArray(t[e])){r[e]=t[e]}else if(t[e]&&typeof t[e]==="object"){r[e]=Object.assign({},t[e])}else if(t[e]){r[e]=t[e]}}}return r}},4194:e=>{"use strict";e.exports=function splitNameEmail(e){if(e.indexOf("<")===-1){return["",e]}let[t,r]=e.split("<");t=t.trim();r=r.replace(">","").trim();return[t,r]}},9352:e=>{"use strict";e.exports=function strToCamelCase(e){if(typeof e!=="string"){throw new Error("String expected for conversion to snake case")}return e.trim().replace(/_+|\-+/g," ").replace(/(?:^\w|[A-Z]|\b\w|\s+)/g,(function(e,t){if(Number(e)===0){return""}return t===0?e.toLowerCase():e.toUpperCase()}))}},9014:e=>{"use strict";e.exports=function strToSnakeCase(e){if(typeof e!=="string"){throw new Error("String expected for conversion to snake case")}return e.trim().replace(/(\s*\-*\b\w|[A-Z])/g,(function(e){e=e.trim().toLowerCase().replace("-","");return(e[0]==="_"?"":"_")+e})).slice(1)}},3278:(e,t,r)=>{"use strict";const s=r(8560);const n=r(9352);e.exports=function toCamelCase(e,t){return s(e,n,t)}},7609:(e,t,r)=>{"use strict";const s=r(8560);const n=r(9014);e.exports=function toSnakeCase(e,t){return s(e,n,t)}},7738:e=>{"use strict";const validate=(e,t,r,s)=>{if(typeof e==="undefined"||typeof e[r]==="undefined"){return}if(typeof e[r]!==s){throw new Error(`${s} expected for \`${t}.${r}\``)}};e.exports={validateMailSettings(e){if(typeof e!=="object"){throw new Error("Object expected for `mailSettings`")}const{bcc:t,bypassListManagement:r,footer:s,sandboxMode:n,spamCheck:i}=e;validate(t,"bcc","enable","boolean");validate(t,"bcc","email","string");validate(r,"bypassListManagement","enable","boolean");validate(s,"footer","enable","boolean");validate(s,"footer","text","string");validate(s,"footer","html","string");validate(n,"sandboxMode","enable","boolean");validate(i,"spamCheck","enable","boolean");validate(i,"spamCheck","threshold","number");validate(i,"spamCheck","postToUrl","string")},validateTrackingSettings(e){if(typeof e!=="object"){throw new Error("Object expected for `trackingSettings`")}const{clickTracking:t,openTracking:r,subscriptionTracking:s,ganalytics:n}=e;validate(t,"clickTracking","enable","boolean");validate(t,"clickTracking","enableText","boolean");validate(r,"openTracking","enable","boolean");validate(r,"openTracking","substitutionTag","string");validate(s,"subscriptionTracking","enable","boolean");validate(s,"subscriptionTracking","text","string");validate(s,"subscriptionTracking","html","string");validate(s,"subscriptionTracking","substitutionTag","string");validate(n,"ganalytics","enable","boolean");validate(n,"ganalytics","utm_source","string");validate(n,"ganalytics","utm_medium","string");validate(n,"ganalytics","utm_term","string");validate(n,"ganalytics","utm_content","string");validate(n,"ganalytics","utm_campaign","string")}}},7174:e=>{"use strict";e.exports=function wrap(e,t="{{",r="}}"){if(Array.isArray(e)){return e.map((e=>wrap(e,t,r)))}const s={};for(const n in e){if(e.hasOwnProperty(n)){s[t+n+r]=String(e[n])}}return s}},2733:(e,t,r)=>{"use strict";const s=r(8480);const n=r(4741);e.exports={classes:s,helpers:n}},6686:(e,t,r)=>{"use strict";const s=r(4812);const n=r(6246);e.exports=s;e.exports.MailService=n},6246:(e,t,r)=>{"use strict";const{Client:s}=r(2449);const{classes:{Mail:n}}=r(2733);class MailService{constructor(){this.setClient(new s);this.setSubstitutionWrappers("{{","}}");this.secretRules=[]}setClient(e){this.client=e;return this}setApiKey(e){this.client.setApiKey(e);return this}setTwilioEmailAuth(e,t){this.client.setTwilioEmailAuth(e,t)}setTimeout(e){if(typeof e==="undefined"){return}this.client.setDefaultRequest("timeout",e)}setSubstitutionWrappers(e,t){if(typeof e==="undefined"||typeof t==="undefined"){throw new Error("Must provide both left and right side wrappers")}if(!Array.isArray(this.substitutionWrappers)){this.substitutionWrappers=[]}this.substitutionWrappers[0]=e;this.substitutionWrappers[1]=t;return this}setSecretRules(e){if(!(e instanceof Array)){e=[e]}const t=e.map((function(e){const t=typeof e;if(t==="string"){return{pattern:new RegExp(e)}}else if(t==="object"){if(e instanceof RegExp){e={pattern:e}}else if(e.hasOwnProperty("pattern")&&typeof e.pattern==="string"){e.pattern=new RegExp(e.pattern)}try{e.pattern.test("");return e}catch(e){}}}));this.secretRules=t.filter((function(e){return e}))}filterSecrets(e){if(typeof e==="object"&&!e.hasOwnProperty("content")){return}const t=this;e.content.forEach((function(e){t.secretRules.forEach((function(t){if(t.hasOwnProperty("pattern")&&!t.pattern.test(e.value)){return}let r=`The pattern '${t.pattern}'`;if(t.name){r+=`identified by '${t.name}'`}r+=" was found in the Mail content!";throw new Error(r)}))}))}send(e,t=false,r){if(typeof t==="function"){r=t;t=false}if(Array.isArray(e)){const s=Promise.all(e.map((e=>this.send(e,t))));if(r){s.then((e=>r(null,e))).catch((e=>r(e,null)))}return s}try{if(typeof e.isMultiple==="undefined"){e.isMultiple=t}if(typeof e.substitutionWrappers==="undefined"){e.substitutionWrappers=this.substitutionWrappers}const s=n.create(e);const i=s.toJSON();this.filterSecrets(i);const o={method:"POST",url:"/v3/mail/send",headers:s.headers,body:i};return this.client.request(o,r)}catch(e){if(r){r(e,null)}return Promise.reject(e)}}sendMultiple(e,t){return this.send(e,true,t)}}e.exports=MailService},4812:(e,t,r)=>{"use strict";const s=r(6246);e.exports=new s},6545:(e,t,r)=>{e.exports=r(2618)},8104:(e,t,r)=>{"use strict";var s=r(328);var n=r(3211);var i=r(1934);var o=r(646);var a=r(8605);var c=r(7211);var u=r(7707).http;var f=r(7707).https;var p=r(8835);var d=r(8761);var h=r(696);var l=r(5226);var m=r(1516);var y=/https:?/;function setProxy(e,t,r){e.hostname=t.host;e.host=t.host;e.port=t.port;e.path=r;if(t.auth){var s=Buffer.from(t.auth.username+":"+t.auth.password,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+s}e.beforeRedirect=function beforeRedirect(e){e.headers.host=e.host;setProxy(e,t,e.href)}}e.exports=function httpAdapter(e){return new Promise((function dispatchHttpRequest(t,r){var g=function resolve(e){t(e)};var b=function reject(e){r(e)};var v=e.data;var w=e.headers;if("User-Agent"in w||"user-agent"in w){if(!w["User-Agent"]&&!w["user-agent"]){delete w["User-Agent"];delete w["user-agent"]}}else{w["User-Agent"]="axios/"+h.version}if(v&&!s.isStream(v)){if(Buffer.isBuffer(v)){}else if(s.isArrayBuffer(v)){v=Buffer.from(new Uint8Array(v))}else if(s.isString(v)){v=Buffer.from(v,"utf-8")}else{return b(l("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",e))}w["Content-Length"]=v.length}var _=undefined;if(e.auth){var E=e.auth.username||"";var x=e.auth.password||"";_=E+":"+x}var A=i(e.baseURL,e.url);var S=p.parse(A);var T=S.protocol||"http:";if(!_&&S.auth){var j=S.auth.split(":");var O=j[0]||"";var R=j[1]||"";_=O+":"+R}if(_){delete w.Authorization}var k=y.test(T);var C=k?e.httpsAgent:e.httpAgent;var D={path:o(S.path,e.params,e.paramsSerializer).replace(/^\?/,""),method:e.method.toUpperCase(),headers:w,agent:C,agents:{http:e.httpAgent,https:e.httpsAgent},auth:_};if(e.socketPath){D.socketPath=e.socketPath}else{D.hostname=S.hostname;D.port=S.port}var P=e.proxy;if(!P&&P!==false){var q=T.slice(0,-1)+"_proxy";var B=process.env[q]||process.env[q.toUpperCase()];if(B){var N=p.parse(B);var M=process.env.no_proxy||process.env.NO_PROXY;var U=true;if(M){var I=M.split(",").map((function trim(e){return e.trim()}));U=!I.some((function proxyMatch(e){if(!e){return false}if(e==="*"){return true}if(e[0]==="."&&S.hostname.substr(S.hostname.length-e.length)===e){return true}return S.hostname===e}))}if(U){P={host:N.hostname,port:N.port,protocol:N.protocol};if(N.auth){var L=N.auth.split(":");P.auth={username:L[0],password:L[1]}}}}}if(P){D.headers.host=S.hostname+(S.port?":"+S.port:"");setProxy(D,P,T+"//"+S.hostname+(S.port?":"+S.port:"")+D.path)}var H;var W=k&&(P?y.test(P.protocol):true);if(e.transport){H=e.transport}else if(e.maxRedirects===0){H=W?c:a}else{if(e.maxRedirects){D.maxRedirects=e.maxRedirects}H=W?f:u}if(e.maxBodyLength>-1){D.maxBodyLength=e.maxBodyLength}var z=H.request(D,(function handleResponse(t){if(z.aborted)return;var r=t;var i=t.req||z;if(t.statusCode!==204&&i.method!=="HEAD"&&e.decompress!==false){switch(t.headers["content-encoding"]){case"gzip":case"compress":case"deflate":r=r.pipe(d.createUnzip());delete t.headers["content-encoding"];break}}var o={status:t.statusCode,statusText:t.statusMessage,headers:t.headers,config:e,request:i};if(e.responseType==="stream"){o.data=r;n(g,b,o)}else{var a=[];var c=0;r.on("data",(function handleStreamData(t){a.push(t);c+=t.length;if(e.maxContentLength>-1&&c>e.maxContentLength){r.destroy();b(l("maxContentLength size of "+e.maxContentLength+" exceeded",e,null,i))}}));r.on("error",(function handleStreamError(t){if(z.aborted)return;b(m(t,e,null,i))}));r.on("end",(function handleStreamEnd(){var t=Buffer.concat(a);if(e.responseType!=="arraybuffer"){t=t.toString(e.responseEncoding);if(!e.responseEncoding||e.responseEncoding==="utf8"){t=s.stripBOM(t)}}o.data=t;n(g,b,o)}))}}));z.on("error",(function handleRequestError(t){if(z.aborted&&t.code!=="ERR_FR_TOO_MANY_REDIRECTS")return;b(m(t,e,null,z))}));if(e.timeout){var V=parseInt(e.timeout,10);if(isNaN(V)){b(l("error trying to parse `config.timeout` to int",e,"ERR_PARSE_TIMEOUT",z));return}z.setTimeout(V,(function handleRequestTimeout(){z.abort();b(l("timeout of "+V+"ms exceeded",e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",z))}))}if(e.cancelToken){e.cancelToken.promise.then((function onCanceled(e){if(z.aborted)return;z.abort();b(e)}))}if(s.isStream(v)){v.on("error",(function handleStreamError(t){b(m(t,e,null,z))})).pipe(z)}else{z.end(v)}}))}},3454:(e,t,r)=>{"use strict";var s=r(328);var n=r(3211);var i=r(1545);var o=r(646);var a=r(1934);var c=r(6455);var u=r(3608);var f=r(5226);e.exports=function xhrAdapter(e){return new Promise((function dispatchXhrRequest(t,r){var p=e.data;var d=e.headers;var h=e.responseType;if(s.isFormData(p)){delete d["Content-Type"]}var l=new XMLHttpRequest;if(e.auth){var m=e.auth.username||"";var y=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";d.Authorization="Basic "+btoa(m+":"+y)}var g=a(e.baseURL,e.url);l.open(e.method.toUpperCase(),o(g,e.params,e.paramsSerializer),true);l.timeout=e.timeout;function onloadend(){if(!l){return}var s="getAllResponseHeaders"in l?c(l.getAllResponseHeaders()):null;var i=!h||h==="text"||h==="json"?l.responseText:l.response;var o={data:i,status:l.status,statusText:l.statusText,headers:s,config:e,request:l};n(t,r,o);l=null}if("onloadend"in l){l.onloadend=onloadend}else{l.onreadystatechange=function handleLoad(){if(!l||l.readyState!==4){return}if(l.status===0&&!(l.responseURL&&l.responseURL.indexOf("file:")===0)){return}setTimeout(onloadend)}}l.onabort=function handleAbort(){if(!l){return}r(f("Request aborted",e,"ECONNABORTED",l));l=null};l.onerror=function handleError(){r(f("Network Error",e,null,l));l=null};l.ontimeout=function handleTimeout(){var t="timeout of "+e.timeout+"ms exceeded";if(e.timeoutErrorMessage){t=e.timeoutErrorMessage}r(f(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",l));l=null};if(s.isStandardBrowserEnv()){var b=(e.withCredentials||u(g))&&e.xsrfCookieName?i.read(e.xsrfCookieName):undefined;if(b){d[e.xsrfHeaderName]=b}}if("setRequestHeader"in l){s.forEach(d,(function setRequestHeader(e,t){if(typeof p==="undefined"&&t.toLowerCase()==="content-type"){delete d[t]}else{l.setRequestHeader(t,e)}}))}if(!s.isUndefined(e.withCredentials)){l.withCredentials=!!e.withCredentials}if(h&&h!=="json"){l.responseType=e.responseType}if(typeof e.onDownloadProgress==="function"){l.addEventListener("progress",e.onDownloadProgress)}if(typeof e.onUploadProgress==="function"&&l.upload){l.upload.addEventListener("progress",e.onUploadProgress)}if(e.cancelToken){e.cancelToken.promise.then((function onCanceled(e){if(!l){return}l.abort();r(e);l=null}))}if(!p){p=null}l.send(p)}))}},2618:(e,t,r)=>{"use strict";var s=r(328);var n=r(7065);var i=r(8178);var o=r(4831);var a=r(8190);function createInstance(e){var t=new i(e);var r=n(i.prototype.request,t);s.extend(r,i.prototype,t);s.extend(r,t);return r}var c=createInstance(a);c.Axios=i;c.create=function create(e){return createInstance(o(c.defaults,e))};c.Cancel=r(8875);c.CancelToken=r(1587);c.isCancel=r(4057);c.all=function all(e){return Promise.all(e)};c.spread=r(4850);c.isAxiosError=r(650);e.exports=c;e.exports.default=c},8875:e=>{"use strict";function Cancel(e){this.message=e}Cancel.prototype.toString=function toString(){return"Cancel"+(this.message?": "+this.message:"")};Cancel.prototype.__CANCEL__=true;e.exports=Cancel},1587:(e,t,r)=>{"use strict";var s=r(8875);function CancelToken(e){if(typeof e!=="function"){throw new TypeError("executor must be a function.")}var t;this.promise=new Promise((function promiseExecutor(e){t=e}));var r=this;e((function cancel(e){if(r.reason){return}r.reason=new s(e);t(r.reason)}))}CancelToken.prototype.throwIfRequested=function throwIfRequested(){if(this.reason){throw this.reason}};CancelToken.source=function source(){var e;var t=new CancelToken((function executor(t){e=t}));return{token:t,cancel:e}};e.exports=CancelToken},4057:e=>{"use strict";e.exports=function isCancel(e){return!!(e&&e.__CANCEL__)}},8178:(e,t,r)=>{"use strict";var s=r(328);var n=r(646);var i=r(3214);var o=r(5062);var a=r(4831);var c=r(1632);var u=c.validators;function Axios(e){this.defaults=e;this.interceptors={request:new i,response:new i}}Axios.prototype.request=function request(e){if(typeof e==="string"){e=arguments[1]||{};e.url=arguments[0]}else{e=e||{}}e=a(this.defaults,e);if(e.method){e.method=e.method.toLowerCase()}else if(this.defaults.method){e.method=this.defaults.method.toLowerCase()}else{e.method="get"}var t=e.transitional;if(t!==undefined){c.assertOptions(t,{silentJSONParsing:u.transitional(u.boolean,"1.0.0"),forcedJSONParsing:u.transitional(u.boolean,"1.0.0"),clarifyTimeoutError:u.transitional(u.boolean,"1.0.0")},false)}var r=[];var s=true;this.interceptors.request.forEach((function unshiftRequestInterceptors(t){if(typeof t.runWhen==="function"&&t.runWhen(e)===false){return}s=s&&t.synchronous;r.unshift(t.fulfilled,t.rejected)}));var n=[];this.interceptors.response.forEach((function pushResponseInterceptors(e){n.push(e.fulfilled,e.rejected)}));var i;if(!s){var f=[o,undefined];Array.prototype.unshift.apply(f,r);f=f.concat(n);i=Promise.resolve(e);while(f.length){i=i.then(f.shift(),f.shift())}return i}var p=e;while(r.length){var d=r.shift();var h=r.shift();try{p=d(p)}catch(e){h(e);break}}try{i=o(p)}catch(e){return Promise.reject(e)}while(n.length){i=i.then(n.shift(),n.shift())}return i};Axios.prototype.getUri=function getUri(e){e=a(this.defaults,e);return n(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};s.forEach(["delete","get","head","options"],(function forEachMethodNoData(e){Axios.prototype[e]=function(t,r){return this.request(a(r||{},{method:e,url:t,data:(r||{}).data}))}}));s.forEach(["post","put","patch"],(function forEachMethodWithData(e){Axios.prototype[e]=function(t,r,s){return this.request(a(s||{},{method:e,url:t,data:r}))}}));e.exports=Axios},3214:(e,t,r)=>{"use strict";var s=r(328);function InterceptorManager(){this.handlers=[]}InterceptorManager.prototype.use=function use(e,t,r){this.handlers.push({fulfilled:e,rejected:t,synchronous:r?r.synchronous:false,runWhen:r?r.runWhen:null});return this.handlers.length-1};InterceptorManager.prototype.eject=function eject(e){if(this.handlers[e]){this.handlers[e]=null}};InterceptorManager.prototype.forEach=function forEach(e){s.forEach(this.handlers,(function forEachHandler(t){if(t!==null){e(t)}}))};e.exports=InterceptorManager},1934:(e,t,r)=>{"use strict";var s=r(1301);var n=r(7189);e.exports=function buildFullPath(e,t){if(e&&!s(t)){return n(e,t)}return t}},5226:(e,t,r)=>{"use strict";var s=r(1516);e.exports=function createError(e,t,r,n,i){var o=new Error(e);return s(o,t,r,n,i)}},5062:(e,t,r)=>{"use strict";var s=r(328);var n=r(9812);var i=r(4057);var o=r(8190);function throwIfCancellationRequested(e){if(e.cancelToken){e.cancelToken.throwIfRequested()}}e.exports=function dispatchRequest(e){throwIfCancellationRequested(e);e.headers=e.headers||{};e.data=n.call(e,e.data,e.headers,e.transformRequest);e.headers=s.merge(e.headers.common||{},e.headers[e.method]||{},e.headers);s.forEach(["delete","get","head","post","put","patch","common"],(function cleanHeaderConfig(t){delete e.headers[t]}));var t=e.adapter||o.adapter;return t(e).then((function onAdapterResolution(t){throwIfCancellationRequested(e);t.data=n.call(e,t.data,t.headers,e.transformResponse);return t}),(function onAdapterRejection(t){if(!i(t)){throwIfCancellationRequested(e);if(t&&t.response){t.response.data=n.call(e,t.response.data,t.response.headers,e.transformResponse)}}return Promise.reject(t)}))}},1516:e=>{"use strict";e.exports=function enhanceError(e,t,r,s,n){e.config=t;if(r){e.code=r}e.request=s;e.response=n;e.isAxiosError=true;e.toJSON=function toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}};return e}},4831:(e,t,r)=>{"use strict";var s=r(328);e.exports=function mergeConfig(e,t){t=t||{};var r={};var n=["url","method","data"];var i=["headers","auth","proxy","params"];var o=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"];var a=["validateStatus"];function getMergedValue(e,t){if(s.isPlainObject(e)&&s.isPlainObject(t)){return s.merge(e,t)}else if(s.isPlainObject(t)){return s.merge({},t)}else if(s.isArray(t)){return t.slice()}return t}function mergeDeepProperties(n){if(!s.isUndefined(t[n])){r[n]=getMergedValue(e[n],t[n])}else if(!s.isUndefined(e[n])){r[n]=getMergedValue(undefined,e[n])}}s.forEach(n,(function valueFromConfig2(e){if(!s.isUndefined(t[e])){r[e]=getMergedValue(undefined,t[e])}}));s.forEach(i,mergeDeepProperties);s.forEach(o,(function defaultToConfig2(n){if(!s.isUndefined(t[n])){r[n]=getMergedValue(undefined,t[n])}else if(!s.isUndefined(e[n])){r[n]=getMergedValue(undefined,e[n])}}));s.forEach(a,(function merge(s){if(s in t){r[s]=getMergedValue(e[s],t[s])}else if(s in e){r[s]=getMergedValue(undefined,e[s])}}));var c=n.concat(i).concat(o).concat(a);var u=Object.keys(e).concat(Object.keys(t)).filter((function filterAxiosKeys(e){return c.indexOf(e)===-1}));s.forEach(u,mergeDeepProperties);return r}},3211:(e,t,r)=>{"use strict";var s=r(5226);e.exports=function settle(e,t,r){var n=r.config.validateStatus;if(!r.status||!n||n(r.status)){e(r)}else{t(s("Request failed with status code "+r.status,r.config,null,r.request,r))}}},9812:(e,t,r)=>{"use strict";var s=r(328);var n=r(8190);e.exports=function transformData(e,t,r){var i=this||n;s.forEach(r,(function transform(r){e=r.call(i,e,t)}));return e}},8190:(e,t,r)=>{"use strict";var s=r(328);var n=r(6240);var i=r(1516);var o={"Content-Type":"application/x-www-form-urlencoded"};function setContentTypeIfUnset(e,t){if(!s.isUndefined(e)&&s.isUndefined(e["Content-Type"])){e["Content-Type"]=t}}function getDefaultAdapter(){var e;if(typeof XMLHttpRequest!=="undefined"){e=r(3454)}else if(typeof process!=="undefined"&&Object.prototype.toString.call(process)==="[object process]"){e=r(8104)}return e}function stringifySafely(e,t,r){if(s.isString(e)){try{(t||JSON.parse)(e);return s.trim(e)}catch(e){if(e.name!=="SyntaxError"){throw e}}}return(r||JSON.stringify)(e)}var a={transitional:{silentJSONParsing:true,forcedJSONParsing:true,clarifyTimeoutError:false},adapter:getDefaultAdapter(),transformRequest:[function transformRequest(e,t){n(t,"Accept");n(t,"Content-Type");if(s.isFormData(e)||s.isArrayBuffer(e)||s.isBuffer(e)||s.isStream(e)||s.isFile(e)||s.isBlob(e)){return e}if(s.isArrayBufferView(e)){return e.buffer}if(s.isURLSearchParams(e)){setContentTypeIfUnset(t,"application/x-www-form-urlencoded;charset=utf-8");return e.toString()}if(s.isObject(e)||t&&t["Content-Type"]==="application/json"){setContentTypeIfUnset(t,"application/json");return stringifySafely(e)}return e}],transformResponse:[function transformResponse(e){var t=this.transitional;var r=t&&t.silentJSONParsing;var n=t&&t.forcedJSONParsing;var o=!r&&this.responseType==="json";if(o||n&&s.isString(e)&&e.length){try{return JSON.parse(e)}catch(e){if(o){if(e.name==="SyntaxError"){throw i(e,this,"E_JSON_PARSE")}throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function validateStatus(e){return e>=200&&e<300}};a.headers={common:{Accept:"application/json, text/plain, */*"}};s.forEach(["delete","get","head"],(function forEachMethodNoData(e){a.headers[e]={}}));s.forEach(["post","put","patch"],(function forEachMethodWithData(e){a.headers[e]=s.merge(o)}));e.exports=a},7065:e=>{"use strict";e.exports=function bind(e,t){return function wrap(){var r=new Array(arguments.length);for(var s=0;s{"use strict";var s=r(328);function encode(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function buildURL(e,t,r){if(!t){return e}var n;if(r){n=r(t)}else if(s.isURLSearchParams(t)){n=t.toString()}else{var i=[];s.forEach(t,(function serialize(e,t){if(e===null||typeof e==="undefined"){return}if(s.isArray(e)){t=t+"[]"}else{e=[e]}s.forEach(e,(function parseValue(e){if(s.isDate(e)){e=e.toISOString()}else if(s.isObject(e)){e=JSON.stringify(e)}i.push(encode(t)+"="+encode(e))}))}));n=i.join("&")}if(n){var o=e.indexOf("#");if(o!==-1){e=e.slice(0,o)}e+=(e.indexOf("?")===-1?"?":"&")+n}return e}},7189:e=>{"use strict";e.exports=function combineURLs(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},1545:(e,t,r)=>{"use strict";var s=r(328);e.exports=s.isStandardBrowserEnv()?function standardBrowserEnv(){return{write:function write(e,t,r,n,i,o){var a=[];a.push(e+"="+encodeURIComponent(t));if(s.isNumber(r)){a.push("expires="+new Date(r).toGMTString())}if(s.isString(n)){a.push("path="+n)}if(s.isString(i)){a.push("domain="+i)}if(o===true){a.push("secure")}document.cookie=a.join("; ")},read:function read(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function remove(e){this.write(e,"",Date.now()-864e5)}}}():function nonStandardBrowserEnv(){return{write:function write(){},read:function read(){return null},remove:function remove(){}}}()},1301:e=>{"use strict";e.exports=function isAbsoluteURL(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},650:e=>{"use strict";e.exports=function isAxiosError(e){return typeof e==="object"&&e.isAxiosError===true}},3608:(e,t,r)=>{"use strict";var s=r(328);e.exports=s.isStandardBrowserEnv()?function standardBrowserEnv(){var e=/(msie|trident)/i.test(navigator.userAgent);var t=document.createElement("a");var r;function resolveURL(r){var s=r;if(e){t.setAttribute("href",s);s=t.href}t.setAttribute("href",s);return{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}r=resolveURL(window.location.href);return function isURLSameOrigin(e){var t=s.isString(e)?resolveURL(e):e;return t.protocol===r.protocol&&t.host===r.host}}():function nonStandardBrowserEnv(){return function isURLSameOrigin(){return true}}()},6240:(e,t,r)=>{"use strict";var s=r(328);e.exports=function normalizeHeaderName(e,t){s.forEach(e,(function processHeader(r,s){if(s!==t&&s.toUpperCase()===t.toUpperCase()){e[t]=r;delete e[s]}}))}},6455:(e,t,r)=>{"use strict";var s=r(328);var n=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function parseHeaders(e){var t={};var r;var i;var o;if(!e){return t}s.forEach(e.split("\n"),(function parser(e){o=e.indexOf(":");r=s.trim(e.substr(0,o)).toLowerCase();i=s.trim(e.substr(o+1));if(r){if(t[r]&&n.indexOf(r)>=0){return}if(r==="set-cookie"){t[r]=(t[r]?t[r]:[]).concat([i])}else{t[r]=t[r]?t[r]+", "+i:i}}}));return t}},4850:e=>{"use strict";e.exports=function spread(e){return function wrap(t){return e.apply(null,t)}}},1632:(e,t,r)=>{"use strict";var s=r(696);var n={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){n[e]=function validator(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var i={};var o=s.version.split(".");function isOlderVersion(e,t){var r=t?t.split("."):o;var s=e.split(".");for(var n=0;n<3;n++){if(r[n]>s[n]){return true}else if(r[n]0){var i=s[n];var o=t[i];if(o){var a=e[i];var c=a===undefined||o(a,i,e);if(c!==true){throw new TypeError("option "+i+" must be "+c)}continue}if(r!==true){throw Error("Unknown option "+i)}}}e.exports={isOlderVersion:isOlderVersion,assertOptions:assertOptions,validators:n}},328:(e,t,r)=>{"use strict";var s=r(7065);var n=Object.prototype.toString;function isArray(e){return n.call(e)==="[object Array]"}function isUndefined(e){return typeof e==="undefined"}function isBuffer(e){return e!==null&&!isUndefined(e)&&e.constructor!==null&&!isUndefined(e.constructor)&&typeof e.constructor.isBuffer==="function"&&e.constructor.isBuffer(e)}function isArrayBuffer(e){return n.call(e)==="[object ArrayBuffer]"}function isFormData(e){return typeof FormData!=="undefined"&&e instanceof FormData}function isArrayBufferView(e){var t;if(typeof ArrayBuffer!=="undefined"&&ArrayBuffer.isView){t=ArrayBuffer.isView(e)}else{t=e&&e.buffer&&e.buffer instanceof ArrayBuffer}return t}function isString(e){return typeof e==="string"}function isNumber(e){return typeof e==="number"}function isObject(e){return e!==null&&typeof e==="object"}function isPlainObject(e){if(n.call(e)!=="[object Object]"){return false}var t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function isDate(e){return n.call(e)==="[object Date]"}function isFile(e){return n.call(e)==="[object File]"}function isBlob(e){return n.call(e)==="[object Blob]"}function isFunction(e){return n.call(e)==="[object Function]"}function isStream(e){return isObject(e)&&isFunction(e.pipe)}function isURLSearchParams(e){return typeof URLSearchParams!=="undefined"&&e instanceof URLSearchParams}function trim(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function isStandardBrowserEnv(){if(typeof navigator!=="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")){return false}return typeof window!=="undefined"&&typeof document!=="undefined"}function forEach(e,t){if(e===null||typeof e==="undefined"){return}if(typeof e!=="object"){e=[e]}if(isArray(e)){for(var r=0,s=e.length;r{"use strict";var t=function isMergeableObject(e){return isNonNullObject(e)&&!isSpecial(e)};function isNonNullObject(e){return!!e&&typeof e==="object"}function isSpecial(e){var t=Object.prototype.toString.call(e);return t==="[object RegExp]"||t==="[object Date]"||isReactElement(e)}var r=typeof Symbol==="function"&&Symbol.for;var s=r?Symbol.for("react.element"):60103;function isReactElement(e){return e.$$typeof===s}function emptyTarget(e){return Array.isArray(e)?[]:{}}function cloneUnlessOtherwiseSpecified(e,t){return t.clone!==false&&t.isMergeableObject(e)?deepmerge(emptyTarget(e),e,t):e}function defaultArrayMerge(e,t,r){return e.concat(t).map((function(e){return cloneUnlessOtherwiseSpecified(e,r)}))}function getMergeFunction(e,t){if(!t.customMerge){return deepmerge}var r=t.customMerge(e);return typeof r==="function"?r:deepmerge}function getEnumerableOwnPropertySymbols(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return e.propertyIsEnumerable(t)})):[]}function getKeys(e){return Object.keys(e).concat(getEnumerableOwnPropertySymbols(e))}function propertyIsOnObject(e,t){try{return t in e}catch(e){return false}}function propertyIsUnsafe(e,t){return propertyIsOnObject(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function mergeObject(e,t,r){var s={};if(r.isMergeableObject(e)){getKeys(e).forEach((function(t){s[t]=cloneUnlessOtherwiseSpecified(e[t],r)}))}getKeys(t).forEach((function(n){if(propertyIsUnsafe(e,n)){return}if(propertyIsOnObject(e,n)&&r.isMergeableObject(t[n])){s[n]=getMergeFunction(n,r)(e[n],t[n],r)}else{s[n]=cloneUnlessOtherwiseSpecified(t[n],r)}}));return s}function deepmerge(e,r,s){s=s||{};s.arrayMerge=s.arrayMerge||defaultArrayMerge;s.isMergeableObject=s.isMergeableObject||t;s.cloneUnlessOtherwiseSpecified=cloneUnlessOtherwiseSpecified;var n=Array.isArray(r);var i=Array.isArray(e);var o=n===i;if(!o){return cloneUnlessOtherwiseSpecified(r,s)}else if(n){return s.arrayMerge(e,r,s)}else{return mergeObject(e,r,s)}}deepmerge.all=function deepmergeAll(e,t){if(!Array.isArray(e)){throw new Error("first argument should be an array")}return e.reduce((function(e,r){return deepmerge(e,r,t)}),{})};var n=deepmerge;e.exports=n},1133:(e,t,r)=>{var s;e.exports=function(){if(!s){try{s=r(9975)("follow-redirects")}catch(e){}if(typeof s!=="function"){s=function(){}}}s.apply(null,arguments)}},7707:(e,t,r)=>{var s=r(8835);var n=s.URL;var i=r(8605);var o=r(7211);var a=r(2413).Writable;var c=r(2357);var u=r(1133);var f=["abort","aborted","connect","error","socket","timeout"];var p=Object.create(null);f.forEach((function(e){p[e]=function(t,r,s){this._redirectable.emit(e,t,r,s)}}));var d=createErrorType("ERR_FR_REDIRECTION_FAILURE","");var h=createErrorType("ERR_FR_TOO_MANY_REDIRECTS","Maximum number of redirects exceeded");var l=createErrorType("ERR_FR_MAX_BODY_LENGTH_EXCEEDED","Request body larger than maxBodyLength limit");var m=createErrorType("ERR_STREAM_WRITE_AFTER_END","write after end");function RedirectableRequest(e,t){a.call(this);this._sanitizeOptions(e);this._options=e;this._ended=false;this._ending=false;this._redirectCount=0;this._redirects=[];this._requestBodyLength=0;this._requestBodyBuffers=[];if(t){this.on("response",t)}var r=this;this._onNativeResponse=function(e){r._processResponse(e)};this._performRequest()}RedirectableRequest.prototype=Object.create(a.prototype);RedirectableRequest.prototype.abort=function(){abortRequest(this._currentRequest);this.emit("abort")};RedirectableRequest.prototype.write=function(e,t,r){if(this._ending){throw new m}if(!(typeof e==="string"||typeof e==="object"&&"length"in e)){throw new TypeError("data should be a string, Buffer or Uint8Array")}if(typeof t==="function"){r=t;t=null}if(e.length===0){if(r){r()}return}if(this._requestBodyLength+e.length<=this._options.maxBodyLength){this._requestBodyLength+=e.length;this._requestBodyBuffers.push({data:e,encoding:t});this._currentRequest.write(e,t,r)}else{this.emit("error",new l);this.abort()}};RedirectableRequest.prototype.end=function(e,t,r){if(typeof e==="function"){r=e;e=t=null}else if(typeof t==="function"){r=t;t=null}if(!e){this._ended=this._ending=true;this._currentRequest.end(null,null,r)}else{var s=this;var n=this._currentRequest;this.write(e,t,(function(){s._ended=true;n.end(null,null,r)}));this._ending=true}};RedirectableRequest.prototype.setHeader=function(e,t){this._options.headers[e]=t;this._currentRequest.setHeader(e,t)};RedirectableRequest.prototype.removeHeader=function(e){delete this._options.headers[e];this._currentRequest.removeHeader(e)};RedirectableRequest.prototype.setTimeout=function(e,t){var r=this;function destroyOnTimeout(t){t.setTimeout(e);t.removeListener("timeout",t.destroy);t.addListener("timeout",t.destroy)}function startTimer(t){if(r._timeout){clearTimeout(r._timeout)}r._timeout=setTimeout((function(){r.emit("timeout");clearTimer()}),e);destroyOnTimeout(t)}function clearTimer(){if(r._timeout){clearTimeout(r._timeout);r._timeout=null}if(t){r.removeListener("timeout",t)}if(!r.socket){r._currentRequest.removeListener("socket",startTimer)}}if(t){this.on("timeout",t)}if(this.socket){startTimer(this.socket)}else{this._currentRequest.once("socket",startTimer)}this.on("socket",destroyOnTimeout);this.once("response",clearTimer);this.once("error",clearTimer);return this};["flushHeaders","getHeader","setNoDelay","setSocketKeepAlive"].forEach((function(e){RedirectableRequest.prototype[e]=function(t,r){return this._currentRequest[e](t,r)}}));["aborted","connection","socket"].forEach((function(e){Object.defineProperty(RedirectableRequest.prototype,e,{get:function(){return this._currentRequest[e]}})}));RedirectableRequest.prototype._sanitizeOptions=function(e){if(!e.headers){e.headers={}}if(e.host){if(!e.hostname){e.hostname=e.host}delete e.host}if(!e.pathname&&e.path){var t=e.path.indexOf("?");if(t<0){e.pathname=e.path}else{e.pathname=e.path.substring(0,t);e.search=e.path.substring(t)}}};RedirectableRequest.prototype._performRequest=function(){var e=this._options.protocol;var t=this._options.nativeProtocols[e];if(!t){this.emit("error",new TypeError("Unsupported protocol "+e));return}if(this._options.agents){var r=e.substr(0,e.length-1);this._options.agent=this._options.agents[r]}var n=this._currentRequest=t.request(this._options,this._onNativeResponse);this._currentUrl=s.format(this._options);n._redirectable=this;for(var i=0;i=300&&t<400){abortRequest(this._currentRequest);e.destroy();if(++this._redirectCount>this._options.maxRedirects){this.emit("error",new h);return}if((t===301||t===302)&&this._options.method==="POST"||t===303&&!/^(?:GET|HEAD)$/.test(this._options.method)){this._options.method="GET";this._requestBodyBuffers=[];removeMatchingHeaders(/^content-/i,this._options.headers)}var n=removeMatchingHeaders(/^host$/i,this._options.headers)||s.parse(this._currentUrl).hostname;var i=s.resolve(this._currentUrl,r);u("redirecting to",i);this._isRedirect=true;var o=s.parse(i);Object.assign(this._options,o);if(o.hostname!==n){removeMatchingHeaders(/^authorization$/i,this._options.headers)}if(typeof this._options.beforeRedirect==="function"){var a={headers:e.headers};try{this._options.beforeRedirect.call(null,this._options,a)}catch(e){this.emit("error",e);return}this._sanitizeOptions(this._options)}try{this._performRequest()}catch(e){var c=new d("Redirected request failed: "+e.message);c.cause=e;this.emit("error",c)}}else{e.responseUrl=this._currentUrl;e.redirects=this._redirects;this.emit("response",e);this._requestBodyBuffers=[]}};function wrap(e){var t={maxRedirects:21,maxBodyLength:10*1024*1024};var r={};Object.keys(e).forEach((function(i){var o=i+":";var a=r[o]=e[i];var f=t[i]=Object.create(a);function request(e,i,a){if(typeof e==="string"){var f=e;try{e=urlToOptions(new n(f))}catch(t){e=s.parse(f)}}else if(n&&e instanceof n){e=urlToOptions(e)}else{a=i;i=e;e={protocol:o}}if(typeof i==="function"){a=i;i=null}i=Object.assign({maxRedirects:t.maxRedirects,maxBodyLength:t.maxBodyLength},e,i);i.nativeProtocols=r;c.equal(i.protocol,o,"protocol mismatch");u("options",i);return new RedirectableRequest(i,a)}function get(e,t,r){var s=f.request(e,t,r);s.end();return s}Object.defineProperties(f,{request:{value:request,configurable:true,enumerable:true,writable:true},get:{value:get,configurable:true,enumerable:true,writable:true}})}));return t}function noop(){}function urlToOptions(e){var t={protocol:e.protocol,hostname:e.hostname.startsWith("[")?e.hostname.slice(1,-1):e.hostname,hash:e.hash,search:e.search,pathname:e.pathname,path:e.pathname+e.search,href:e.href};if(e.port!==""){t.port=Number(e.port)}return t}function removeMatchingHeaders(e,t){var r;for(var s in t){if(e.test(s)){r=t[s];delete t[s]}}return r}function createErrorType(e,t){function CustomError(e){Error.captureStackTrace(this,this.constructor);this.message=e||t}CustomError.prototype=new Error;CustomError.prototype.constructor=CustomError;CustomError.prototype.name="Error ["+e+"]";CustomError.prototype.code=e;return CustomError}function abortRequest(e){for(var t=0;t{module.exports=eval("require")("debug")},696:e=>{"use strict";e.exports=JSON.parse('{"name":"axios","version":"0.21.4","description":"Promise based HTTP client for the browser and node.js","main":"index.js","scripts":{"test":"grunt test","start":"node ./sandbox/server.js","build":"NODE_ENV=production grunt build","preversion":"npm test","version":"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json","postversion":"git push && git push --tags","examples":"node ./examples/server.js","coveralls":"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","fix":"eslint --fix lib/**/*.js"},"repository":{"type":"git","url":"https://github.com/axios/axios.git"},"keywords":["xhr","http","ajax","promise","node"],"author":"Matt Zabriskie","license":"MIT","bugs":{"url":"https://github.com/axios/axios/issues"},"homepage":"https://axios-http.com","devDependencies":{"coveralls":"^3.0.0","es6-promise":"^4.2.4","grunt":"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1","karma":"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2","minimist":"^1.2.0","mocha":"^8.2.1","sinon":"^4.5.0","terser-webpack-plugin":"^4.2.3","typescript":"^4.0.5","url-search-params":"^0.10.0","webpack":"^4.44.2","webpack-dev-server":"^3.11.0"},"browser":{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},"jsdelivr":"dist/axios.min.js","unpkg":"dist/axios.min.js","typings":"./index.d.ts","dependencies":{"follow-redirects":"^1.14.0"},"bundlesize":[{"path":"./dist/axios.min.js","threshold":"5kB"}]}')},2357:e=>{"use strict";e.exports=require("assert")},6417:e=>{"use strict";e.exports=require("crypto")},5747:e=>{"use strict";e.exports=require("fs")},8605:e=>{"use strict";e.exports=require("http")},7211:e=>{"use strict";e.exports=require("https")},5622:e=>{"use strict";e.exports=require("path")},2413:e=>{"use strict";e.exports=require("stream")},8835:e=>{"use strict";e.exports=require("url")},8761:e=>{"use strict";e.exports=require("zlib")}};var __webpack_module_cache__={};function __nccwpck_require__(e){var t=__webpack_module_cache__[e];if(t!==undefined){return t.exports}var r=__webpack_module_cache__[e]={exports:{}};var s=true;try{__webpack_modules__[e].call(r.exports,r,r.exports,__nccwpck_require__);s=false}finally{if(s)delete __webpack_module_cache__[e]}return r.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var __webpack_exports__=__nccwpck_require__(2932);module.exports=__webpack_exports__})(); \ No newline at end of file diff --git a/index.js b/index.js index a2a5ddb..766bc89 100644 --- a/index.js +++ b/index.js @@ -99,7 +99,7 @@ module.exports = async function handler(request, context) { switch (data.event) { // Runs once when an integration is first installed. Use this to control initial setup steps such as disabling // default emails in the Chec API, etc. - case 'integrations.create': + case 'integrations.ready': // Disable default emails in Chec context.api.put(`/v1/merchants/${merchantId}/notifications`, { customer: {