"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.SqsEventSource=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),core_1=require("../../core");class SqsEventSource{constructor(queue,props={}){if(this.queue=queue,this.props=props,this._eventSourceMappingId=void 0,jsiiDeprecationWarnings.aws_cdk_lib_aws_sqs_IQueue(queue),jsiiDeprecationWarnings.aws_cdk_lib_aws_lambda_event_sources_SqsEventSourceProps(props),this.props.maxBatchingWindow!==void 0){if(queue.fifo)throw new Error("Batching window is not supported for FIFO queues");if(!this.props.maxBatchingWindow.isUnresolved()&&this.props.maxBatchingWindow.toSeconds()>300)throw new Error(`Maximum batching window must be 300 seconds or less (given ${this.props.maxBatchingWindow.toHumanString()})`)}if(this.props.batchSize!==void 0&&!core_1.Token.isUnresolved(this.props.batchSize)){if(this.props.maxBatchingWindow!==void 0&&(this.props.batchSize<1||this.props.batchSize>1e4))throw new Error(`Maximum batch size must be between 1 and 10000 inclusive (given ${this.props.batchSize}) when batching window is specified.`);if(this.props.maxBatchingWindow===void 0&&(this.props.batchSize<1||this.props.batchSize>10))throw new Error(`Maximum batch size must be between 1 and 10 inclusive (given ${this.props.batchSize}) when batching window is not specified.`)}}bind(target){jsiiDeprecationWarnings.aws_cdk_lib_aws_lambda_IFunction(target);const eventSourceMapping=target.addEventSourceMapping(`SqsEventSource:${core_1.Names.nodeUniqueId(this.queue.node)}`,{batchSize:this.props.batchSize,maxBatchingWindow:this.props.maxBatchingWindow,reportBatchItemFailures:this.props.reportBatchItemFailures,enabled:this.props.enabled,eventSourceArn:this.queue.queueArn});this._eventSourceMappingId=eventSourceMapping.eventSourceMappingId,this.queue.grantConsumeMessages(target)}get eventSourceMappingId(){if(!this._eventSourceMappingId)throw new Error("SqsEventSource is not yet bound to an event source mapping");return this._eventSourceMappingId}}exports.SqsEventSource=SqsEventSource,_a=JSII_RTTI_SYMBOL_1,SqsEventSource[_a]={fqn:"aws-cdk-lib.aws_lambda_event_sources.SqsEventSource",version:"2.13.0"};
//# sourceMappingURL=sqs.js.map
