"use strict";var _a,_b;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConfigurationSetEventDestination=exports.CloudWatchDimensionSource=exports.EmailSendingEvent=exports.EventDestination=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),ses_generated_1=require("./ses.generated"),iam=require("../../aws-iam"),core_1=require("../../core");class EventDestination{static snsTopic(topic){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_sns_ITopic(topic)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.snsTopic),error}return{topic}}static cloudWatchDimensions(dimensions){return{dimensions}}}exports.EventDestination=EventDestination,_a=JSII_RTTI_SYMBOL_1,EventDestination[_a]={fqn:"aws-cdk-lib.aws_ses.EventDestination",version:"2.96.1"};var EmailSendingEvent;(function(EmailSendingEvent2){EmailSendingEvent2.SEND="send",EmailSendingEvent2.REJECT="reject",EmailSendingEvent2.BOUNCE="bounce",EmailSendingEvent2.COMPLAINT="complaint",EmailSendingEvent2.DELIVERY="delivery",EmailSendingEvent2.OPEN="open",EmailSendingEvent2.CLICK="click",EmailSendingEvent2.RENDERING_FAILURE="renderingFailure",EmailSendingEvent2.DELIVERY_DELAY="deliveryDelay",EmailSendingEvent2.SUBSCRIPTION="subscription"})(EmailSendingEvent||(exports.EmailSendingEvent=EmailSendingEvent={}));var CloudWatchDimensionSource;(function(CloudWatchDimensionSource2){CloudWatchDimensionSource2.EMAIL_HEADER="emailHeader",CloudWatchDimensionSource2.LINK_TAG="linkTag",CloudWatchDimensionSource2.MESSAGE_TAG="messageTag"})(CloudWatchDimensionSource||(exports.CloudWatchDimensionSource=CloudWatchDimensionSource={}));class ConfigurationSetEventDestination extends core_1.Resource{static fromConfigurationSetEventDestinationId(scope,id,configurationSetEventDestinationId){class Import extends core_1.Resource{constructor(){super(...arguments),this.configurationSetEventDestinationId=configurationSetEventDestinationId}}return new Import(scope,id)}constructor(scope,id,props){super(scope,id,{physicalName:props.configurationSetEventDestinationName});try{jsiiDeprecationWarnings.aws_cdk_lib_aws_ses_ConfigurationSetEventDestinationProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,ConfigurationSetEventDestination),error}const configurationSet=new ses_generated_1.CfnConfigurationSetEventDestination(this,"Resource",{configurationSetName:props.configurationSet.configurationSetName,eventDestination:{name:this.physicalName,enabled:props.enabled??!0,matchingEventTypes:props.events??Object.values(EmailSendingEvent),snsDestination:props.destination.topic?{topicArn:props.destination.topic.topicArn}:void 0,cloudWatchDestination:props.destination.dimensions?{dimensionConfigurations:props.destination.dimensions.map(dimension=>({dimensionValueSource:dimension.source,dimensionName:dimension.name,defaultDimensionValue:dimension.defaultValue}))}:void 0}});if(this.configurationSetEventDestinationId=configurationSet.attrId,props.destination.topic){const result=props.destination.topic.addToResourcePolicy(new iam.PolicyStatement({actions:["sns:Publish"],resources:[props.destination.topic.topicArn],principals:[new iam.ServicePrincipal("ses.amazonaws.com")],conditions:{StringEquals:{"AWS:SourceAccount":this.env.account,"AWS:SourceArn":`arn:${core_1.Aws.PARTITION}:ses:${this.env.region}:${this.env.account}:configuration-set/${props.configurationSet.configurationSetName}`}}}));result.policyDependable&&this.node.addDependency(result.policyDependable)}}}exports.ConfigurationSetEventDestination=ConfigurationSetEventDestination,_b=JSII_RTTI_SYMBOL_1,ConfigurationSetEventDestination[_b]={fqn:"aws-cdk-lib.aws_ses.ConfigurationSetEventDestination",version:"2.96.1"};
