"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.RunEcsEc2Task=void 0;const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var run_ecs_task_base_1=()=>{var tmp=require("./run-ecs-task-base");return run_ecs_task_base_1=()=>tmp,tmp},ecs=()=>{var tmp=require("../../../aws-ecs");return ecs=()=>tmp,tmp};class RunEcsEc2Task extends run_ecs_task_base_1().EcsRunTaskBase{constructor(props){if(!props.taskDefinition.isEc2Compatible)throw new Error("Supplied TaskDefinition is not configured for compatibility with EC2");if(!props.cluster.hasEc2Capacity)throw new Error("Cluster for this service needs Ec2 capacity. Call addXxxCapacity() on the cluster.");if(!props.taskDefinition.defaultContainer)throw new Error("A TaskDefinition must have at least one essential container");super({...props,parameters:{LaunchType:"EC2",PlacementConstraints:noEmpty(flatten((props.placementConstraints||[]).map(c=>c.toJson().map(uppercaseKeys)))),PlacementStrategy:noEmpty(flatten((props.placementStrategies||[]).map(c=>c.toJson().map(uppercaseKeys))))}}),props.taskDefinition.networkMode===ecs().NetworkMode.AWS_VPC?this.configureAwsVpcNetworking(props.cluster.vpc,void 0,props.subnets,props.securityGroup):(validateNoNetworkingProps(props),this.connections.addSecurityGroup(...props.cluster.connections.securityGroups))}}exports.RunEcsEc2Task=RunEcsEc2Task,_a=JSII_RTTI_SYMBOL_1,RunEcsEc2Task[_a]={fqn:"aws-cdk-lib.aws_stepfunctions_tasks.RunEcsEc2Task",version:"2.148.1"};function validateNoNetworkingProps(props){if(props.subnets!==void 0||props.securityGroup!==void 0)throw new Error("vpcPlacement and securityGroup can only be used in AwsVpc networking mode")}function uppercaseKeys(obj){const ret={};for(const key of Object.keys(obj))ret[key.slice(0,1).toUpperCase()+key.slice(1)]=obj[key];return ret}function flatten(xs){return Array.prototype.concat([],...xs)}function noEmpty(xs){if(xs.length!==0)return xs}
