"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VpcOrigin=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var cloudfront=()=>{var tmp=require("../../aws-cloudfront");return cloudfront=()=>tmp,tmp},cdk=()=>{var tmp=require("../../core");return cdk=()=>tmp,tmp},utils_1=()=>{var tmp=require("./private/utils");return utils_1=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp};class VpcOrigin extends cloudfront().OriginBase{props;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_cloudfront_origins.VpcOrigin",version:"2.256.1"};static withVpcOrigin(origin,props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudfront_IVpcOrigin(origin),jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudfront_origins_VpcOriginProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.withVpcOrigin),error}return new VpcOriginWithVpcOrigin(origin,props)}static withEc2Instance(instance,props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_IInstance(instance),jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudfront_origins_VpcOriginWithEndpointProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.withEc2Instance),error}return new VpcOriginWithEndpoint(cloudfront().VpcOriginEndpoint.ec2Instance(instance),props)}static withApplicationLoadBalancer(alb,props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_elasticloadbalancingv2_IApplicationLoadBalancer(alb),jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudfront_origins_VpcOriginWithEndpointProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.withApplicationLoadBalancer),error}return new VpcOriginWithEndpoint(cloudfront().VpcOriginEndpoint.applicationLoadBalancer(alb),props)}static withNetworkLoadBalancer(nlb,props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_elasticloadbalancingv2_INetworkLoadBalancer(nlb),jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudfront_origins_VpcOriginWithEndpointProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.withNetworkLoadBalancer),error}return new VpcOriginWithEndpoint(cloudfront().VpcOriginEndpoint.networkLoadBalancer(nlb),props)}vpcOrigin;constructor(domainName,props){super(domainName,props),this.props=props;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudfront_origins_VpcOriginProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,VpcOrigin),error}(0,utils_1().validateSecondsInRangeOrUndefined)("readTimeout",1,180,props.readTimeout),(0,utils_1().validateSecondsInRangeOrUndefined)("keepaliveTimeout",1,180,props.keepaliveTimeout)}renderVpcOriginConfig(){if(!this.vpcOrigin)throw new(cdk()).UnscopedValidationError((0,literal_string_1().lit)`VpcOriginCannotBeUndefined`,"VPC origin cannot be undefined.");return{vpcOriginId:this.vpcOrigin.vpcOriginId,originReadTimeout:this.props.readTimeout?.toSeconds(),originKeepaliveTimeout:this.props.keepaliveTimeout?.toSeconds()}}}exports.VpcOrigin=VpcOrigin;class VpcOriginWithVpcOrigin extends VpcOrigin{vpcOrigin;constructor(vpcOrigin,props={}){const domainName=props.domainName??vpcOrigin.domainName;if(!domainName)throw new(cdk()).UnscopedValidationError((0,literal_string_1().lit)`DomainNameMustBeSpecified`,"'domainName' must be specified when no default domain name is defined.");super(domainName,props),this.vpcOrigin=vpcOrigin}}class VpcOriginWithEndpoint extends VpcOrigin{vpcOriginEndpoint;props;constructor(vpcOriginEndpoint,props={}){const domainName=props.domainName??vpcOriginEndpoint.domainName;if(!domainName)throw new(cdk()).UnscopedValidationError((0,literal_string_1().lit)`DomainNameMustBeSpecifiedForEndpoint`,"'domainName' must be specified when no default domain name is defined.");super(domainName,props),this.vpcOriginEndpoint=vpcOriginEndpoint,this.props=props}bind(_scope,options){return this.vpcOrigin??=new(cloudfront()).VpcOrigin(_scope,"VpcOrigin",{endpoint:this.vpcOriginEndpoint,vpcOriginName:this.props.vpcOriginName,httpPort:this.props.httpPort,httpsPort:this.props.httpsPort,protocolPolicy:this.props.protocolPolicy,originSslProtocols:this.props.originSslProtocols}),super.bind(_scope,options)}}
