"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.SlackChannelConfiguration=exports.LoggingLevel=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var chatbot_generated_1=()=>{var tmp=require("./chatbot.generated");return chatbot_generated_1=()=>tmp,tmp},cloudwatch=()=>{var tmp=require("../../aws-cloudwatch");return cloudwatch=()=>tmp,tmp},iam=()=>{var tmp=require("../../aws-iam");return iam=()=>tmp,tmp},logs=()=>{var tmp=require("../../aws-logs");return logs=()=>tmp,tmp},cdk=()=>{var tmp=require("../../core");return cdk=()=>tmp,tmp},LoggingLevel;(function(LoggingLevel2){LoggingLevel2.ERROR="ERROR",LoggingLevel2.INFO="INFO",LoggingLevel2.NONE="NONE"})(LoggingLevel||(exports.LoggingLevel=LoggingLevel={}));class SlackChannelConfigurationBase extends cdk().Resource{addToRolePolicy(statement){this.role&&this.role.addToPrincipalPolicy(statement)}metric(metricName,props){return new(cloudwatch()).Metric({namespace:"AWS/Chatbot",region:"us-east-1",dimensionsMap:{ConfigurationName:this.slackChannelConfigurationName},metricName,...props})}bindAsNotificationRuleTarget(_scope){return{targetType:"AWSChatbotSlack",targetAddress:this.slackChannelConfigurationArn}}}class SlackChannelConfiguration extends SlackChannelConfigurationBase{static fromSlackChannelConfigurationArn(scope,id,slackChannelConfigurationArn){const re=/^slack-channel\//,resourceName=cdk().Arn.extractResourceName(slackChannelConfigurationArn,"chat-configuration");if(!cdk().Token.isUnresolved(slackChannelConfigurationArn)&&!re.test(resourceName))throw new Error("The ARN of a Slack integration must be in the form: arn:<partition>:chatbot:<region>:<account>:chat-configuration/slack-channel/<slackChannelName>");class Import extends SlackChannelConfigurationBase{constructor(s,i){super(s,i),this.slackChannelConfigurationArn=slackChannelConfigurationArn,this.role=void 0,this.grantPrincipal=new(iam()).UnknownPrincipal({resource:this}),cdk().Token.isUnresolved(slackChannelConfigurationArn)?this.slackChannelConfigurationName=cdk().Fn.select(1,cdk().Fn.split("slack-channel/",resourceName)):this.slackChannelConfigurationName=resourceName.substring(14)}}return new Import(scope,id)}static metricAll(metricName,props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricAll),error}return new(cloudwatch()).Metric({namespace:"AWS/Chatbot",region:"us-east-1",metricName,...props})}constructor(scope,id,props){super(scope,id,{physicalName:props.slackChannelConfigurationName});try{jsiiDeprecationWarnings().aws_cdk_lib_aws_chatbot_SlackChannelConfigurationProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,SlackChannelConfiguration),error}this.role=props.role||new(iam()).Role(this,"ConfigurationRole",{assumedBy:new(iam()).ServicePrincipal("chatbot.amazonaws.com")}),this.grantPrincipal=this.role,this.notificationTopics=props.notificationTopics??[];const configuration=new(chatbot_generated_1()).CfnSlackChannelConfiguration(this,"Resource",{configurationName:props.slackChannelConfigurationName,iamRoleArn:this.role.roleArn,slackWorkspaceId:props.slackWorkspaceId,slackChannelId:props.slackChannelId,snsTopicArns:cdk().Lazy.list({produce:()=>this.notificationTopics.map(topic=>topic.topicArn)},{omitEmpty:!0}),loggingLevel:props.loggingLevel?.toString(),guardrailPolicies:cdk().Lazy.list({produce:()=>props.guardrailPolicies?.map(policy=>policy.managedPolicyArn)},{omitEmpty:!0}),userRoleRequired:props.userRoleRequired});props.logRetention&&new(logs()).LogRetention(this,"LogRetention",{logGroupName:`/aws/chatbot/${props.slackChannelConfigurationName}`,retention:props.logRetention,role:props.logRetentionRole,logGroupRegion:"us-east-1",logRetentionRetryOptions:props.logRetentionRetryOptions}),this.slackChannelConfigurationArn=configuration.ref,this.slackChannelConfigurationName=props.slackChannelConfigurationName}addNotificationTopic(notificationTopic){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_sns_ITopic(notificationTopic)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addNotificationTopic),error}this.notificationTopics.push(notificationTopic)}}exports.SlackChannelConfiguration=SlackChannelConfiguration,_a=JSII_RTTI_SYMBOL_1,SlackChannelConfiguration[_a]={fqn:"aws-cdk-lib.aws_chatbot.SlackChannelConfiguration",version:"2.159.0"};
