"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.LambdaDestination=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),events=require("../../aws-events"),targets=require("../../aws-events-targets"),event_bridge_1=require("./event-bridge");class LambdaDestination{constructor(fn,options={}){this.fn=fn,this.options=options,jsiiDeprecationWarnings.aws_cdk_lib_aws_lambda_IFunction(fn),jsiiDeprecationWarnings.aws_cdk_lib_aws_lambda_destinations_LambdaDestinationOptions(options)}bind(scope,fn,options){if(jsiiDeprecationWarnings.aws_cdk_lib_aws_lambda_IFunction(fn),jsiiDeprecationWarnings.aws_cdk_lib_aws_lambda_DestinationOptions(options),!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.13.0"};
//# sourceMappingURL=lambda.js.map
