"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.UnauthenticatedAction=exports.ListenerAction=void 0;const jsiiDeprecationWarnings=require("../../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),core_1=require("../../../core");class ListenerAction{constructor(actionJson,next){this.actionJson=actionJson,this.next=next,jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_CfnListener_ActionProperty(actionJson),jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_ListenerAction(next)}static authenticateOidc(options){var _b;return jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_AuthenticateOidcOptions(options),new ListenerAction({type:"authenticate-oidc",authenticateOidcConfig:{authorizationEndpoint:options.authorizationEndpoint,clientId:options.clientId,clientSecret:options.clientSecret.toString(),issuer:options.issuer,tokenEndpoint:options.tokenEndpoint,userInfoEndpoint:options.userInfoEndpoint,authenticationRequestExtraParams:options.authenticationRequestExtraParams,onUnauthenticatedRequest:options.onUnauthenticatedRequest,scope:options.scope,sessionCookieName:options.sessionCookieName,sessionTimeout:(_b=options.sessionTimeout)===null||_b===void 0?void 0:_b.toSeconds().toString()}},options.next)}static forward(targetGroups,options={}){if(jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_ForwardOptions(options),targetGroups.length===0)throw new Error("Need at least one targetGroup in a ListenerAction.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={}){if(jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_ForwardOptions(options),targetGroups.length===0)throw new Error("Need at least one targetGroup in a ListenerAction.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}})}static fixedResponse(statusCode,options={}){return jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_FixedResponseOptions(options),new ListenerAction({type:"fixed-response",fixedResponseConfig:{statusCode:core_1.Tokenization.stringifyNumber(statusCode),contentType:options.contentType,messageBody:options.messageBody}})}static redirect(options){if(jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_RedirectOptions(options),[options.host,options.path,options.port,options.protocol,options.query].findIndex(x=>x!==void 0)===-1)throw new Error("To prevent redirect loops, set at least one of 'protocol', 'host', 'port', 'path', or 'query'.");return new ListenerAction({type:"redirect",redirectConfig:{statusCode:options.permanent?"HTTP_301":"HTTP_302",host:options.host,path:options.path,port:options.port,protocol:options.protocol,query:options.query}})}renderActions(){var _b,_c;return this.renumber([this.actionJson,...(_c=(_b=this.next)===null||_b===void 0?void 0:_b.renderActions())!==null&&_c!==void 0?_c:[]])}bind(scope,listener,associatingConstruct){jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_IApplicationListener(listener),Array.isArray(scope),Array.isArray(listener),Array.isArray(associatingConstruct)}renumber(actions){return actions.length<2?actions:actions.map((action,i)=>({...action,order:i+1}))}}exports.ListenerAction=ListenerAction,_a=JSII_RTTI_SYMBOL_1,ListenerAction[_a]={fqn:"aws-cdk-lib.aws_elasticloadbalancingv2.ListenerAction",version:"2.13.0"};var UnauthenticatedAction;(function(UnauthenticatedAction2){UnauthenticatedAction2.DENY="deny",UnauthenticatedAction2.ALLOW="allow",UnauthenticatedAction2.AUTHENTICATE="authenticate"})(UnauthenticatedAction=exports.UnauthenticatedAction||(exports.UnauthenticatedAction={}));class TargetGroupListenerAction extends ListenerAction{constructor(targetGroups,actionJson){super(actionJson);this.targetGroups=targetGroups}bind(_scope,listener,associatingConstruct){for(const tg of this.targetGroups)tg.registerListener(listener,associatingConstruct)}}
//# sourceMappingURL=application-listener-action.js.map
