"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.LambdaDestination=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var event_bridge_1=()=>{var tmp=require("./event-bridge");return event_bridge_1=()=>tmp,tmp},events=()=>{var tmp=require("../../aws-events");return events=()=>tmp,tmp},targets=()=>{var tmp=require("../../aws-events-targets");return targets=()=>tmp,tmp};class LambdaDestination{constructor(fn,options={}){this.fn=fn,this.options=options;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_IFunction(fn),jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_destinations_LambdaDestinationOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,LambdaDestination),error}}bind(scope,fn,options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_IFunction(fn),jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_DestinationOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}if(!this.options.responseOnly)return this.fn.grantInvoke(fn),{destination:this.fn.functionArn};if(!options)throw new Error("Options must be defined when using `responseOnly`.");return new(events()).Rule(scope,options.type,{eventPattern:{detailType:[`Lambda Function Invocation Result - ${options.type}`],resources:[`${fn.functionArn}:$LATEST`],source:["lambda"]},targets:[new(targets()).LambdaFunction(this.fn,{event:events().RuleTargetInput.fromEventPath("$.detail.responsePayload")})]}),new(event_bridge_1()).EventBridgeDestination().bind(scope,fn)}}exports.LambdaDestination=LambdaDestination,_a=JSII_RTTI_SYMBOL_1,LambdaDestination[_a]={fqn:"aws-cdk-lib.aws_lambda_destinations.LambdaDestination",version:"2.159.0"};
