"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.NetworkListenerAction=void 0;const jsiiDeprecationWarnings=require("../../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");class NetworkListenerAction{constructor(actionJson,next){this.actionJson=actionJson,this.next=next;try{jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_CfnListener_ActionProperty(actionJson),jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_NetworkListenerAction(next)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,NetworkListenerAction),error}}static forward(targetGroups,options={}){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_NetworkForwardOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.forward),error}if(targetGroups.length===0)throw new Error("Need at least one targetGroup in a NetworkListenerAction.forward()");return targetGroups.length===1&&options.stickinessDuration===void 0?new TargetGroupListenerAction(targetGroups,{type:"forward",targetGroupArn:targetGroups[0].targetGroupArn}):new TargetGroupListenerAction(targetGroups,{type:"forward",forwardConfig:{targetGroups:targetGroups.map(g=>({targetGroupArn:g.targetGroupArn})),targetGroupStickinessConfig:options.stickinessDuration?{durationSeconds:options.stickinessDuration.toSeconds(),enabled:!0}:void 0}})}static weightedForward(targetGroups,options={}){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_NetworkForwardOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.weightedForward),error}if(targetGroups.length===0)throw new Error("Need at least one targetGroup in a NetworkListenerAction.weightedForward()");return new TargetGroupListenerAction(targetGroups.map(g=>g.targetGroup),{type:"forward",forwardConfig:{targetGroups:targetGroups.map(g=>({targetGroupArn:g.targetGroup.targetGroupArn,weight:g.weight})),targetGroupStickinessConfig:options.stickinessDuration?{durationSeconds:options.stickinessDuration.toSeconds(),enabled:!0}:void 0}})}renderActions(){return this.renumber([this.actionJson,...this.next?.renderActions()??[]])}bind(scope,listener){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_INetworkListener(listener)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}Array.isArray(scope),Array.isArray(listener)}renumber(actions){return actions.length<2?actions:actions.map((action,i)=>({...action,order:i+1}))}}exports.NetworkListenerAction=NetworkListenerAction,_a=JSII_RTTI_SYMBOL_1,NetworkListenerAction[_a]={fqn:"aws-cdk-lib.aws_elasticloadbalancingv2.NetworkListenerAction",version:"2.29.0"};class TargetGroupListenerAction extends NetworkListenerAction{constructor(targetGroups,actionJson){super(actionJson),this.targetGroups=targetGroups}bind(_scope,listener){for(const tg of this.targetGroups)tg.registerListener(listener)}}
//# sourceMappingURL=network-listener-action.js.map
