"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.EndpointGroup=exports.HealthCheckProtocol=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),cdk=require("../../core"),_accelerator_security_group_1=require("./_accelerator-security-group"),ga=require("./globalaccelerator.generated");var HealthCheckProtocol;(function(HealthCheckProtocol2){HealthCheckProtocol2.TCP="TCP",HealthCheckProtocol2.HTTP="HTTP",HealthCheckProtocol2.HTTPS="HTTPS"})(HealthCheckProtocol=exports.HealthCheckProtocol||(exports.HealthCheckProtocol={}));class EndpointGroup extends cdk.Resource{constructor(scope,id,props){var _b,_c,_d,_e,_f;super(scope,id),this.endpoints=new Array;try{jsiiDeprecationWarnings.aws_cdk_lib_aws_globalaccelerator_EndpointGroupProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.constructor),error}const resource=new ga.CfnEndpointGroup(this,"Resource",{listenerArn:props.listener.listenerArn,endpointGroupRegion:(_b=props.region)!==null&&_b!==void 0?_b:cdk.Lazy.string({produce:()=>this.firstEndpointRegion()}),endpointConfigurations:cdk.Lazy.any({produce:()=>this.renderEndpoints()},{omitEmptyArray:!0}),healthCheckIntervalSeconds:(_c=props.healthCheckInterval)===null||_c===void 0?void 0:_c.toSeconds({integral:!0}),healthCheckPath:props.healthCheckPath,healthCheckPort:props.healthCheckPort,healthCheckProtocol:props.healthCheckProtocol,thresholdCount:props.healthCheckThreshold,trafficDialPercentage:props.trafficDialPercentage,portOverrides:(_d=props.portOverrides)===null||_d===void 0?void 0:_d.map(o=>({endpointPort:o.endpointPort,listenerPort:o.listenerPort}))});this.endpointGroupArn=resource.attrEndpointGroupArn,this.endpointGroupName=(_e=props.endpointGroupName)!==null&&_e!==void 0?_e:resource.logicalId;for(const endpoint of(_f=props.endpoints)!==null&&_f!==void 0?_f:[])this.addEndpoint(endpoint)}static fromEndpointGroupArn(scope,id,endpointGroupArn){class Import extends cdk.Resource{constructor(){super(...arguments),this.endpointGroupArn=endpointGroupArn}}return new Import(scope,id)}addEndpoint(endpoint){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_globalaccelerator_IEndpoint(endpoint)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addEndpoint),error}this.endpoints.push(endpoint)}connectionsPeer(id,vpc){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_ec2_IVpc(vpc)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.connectionsPeer),error}return _accelerator_security_group_1.AcceleratorSecurityGroupPeer.fromVpc(this,id,vpc,this)}renderEndpoints(){return this.endpoints.map(e=>e.renderEndpointConfiguration())}firstEndpointRegion(){for(const endpoint of this.endpoints)if(endpoint.region)return endpoint.region;return cdk.Stack.of(this).region}}exports.EndpointGroup=EndpointGroup,_a=JSII_RTTI_SYMBOL_1,EndpointGroup[_a]={fqn:"aws-cdk-lib.aws_globalaccelerator.EndpointGroup",version:"2.24.1"};
//# sourceMappingURL=endpoint-group.js.map
