"use strict";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},core_1=()=>{var tmp=require("../../../core");return core_1=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp};class RunEcsEc2Task extends run_ecs_task_base_1().EcsRunTaskBase{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_stepfunctions_tasks.RunEcsEc2Task",version:"2.256.1"};constructor(props){if(!props.taskDefinition.isEc2Compatible)throw new(core_1()).UnscopedValidationError((0,literal_string_1().lit)`SuppliedTaskdefinitionConfiguredCompatibility`,"Supplied TaskDefinition is not configured for compatibility with EC2");if(!props.cluster.hasEc2Capacity)throw new(core_1()).UnscopedValidationError((0,literal_string_1().lit)`ClusterServiceNeedsCapacity`,"Cluster for this service needs Ec2 capacity. Call addXxxCapacity() on the cluster.");if(!props.taskDefinition.defaultContainer)throw new(core_1()).UnscopedValidationError((0,literal_string_1().lit)`TaskdefinitionLeastEssentialContainer`,"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;function validateNoNetworkingProps(props){if(props.subnets!==void 0||props.securityGroup!==void 0)throw new(core_1()).UnscopedValidationError((0,literal_string_1().lit)`VpcplacementSecuritygroupOnlyUsed`,"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}
