"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.VirtualRouter=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),appmesh_generated_1=require("./appmesh.generated"),mesh_1=require("./mesh"),utils_1=require("./private/utils"),route_1=require("./route"),virtual_router_listener_1=require("./virtual-router-listener"),cdk=require("../../core");class VirtualRouterBase extends cdk.Resource{addRoute(id,props){return new route_1.Route(this,id,{...props,routeName:id,mesh:this.mesh,virtualRouter:this})}}class VirtualRouter extends VirtualRouterBase{static fromVirtualRouterArn(scope,id,virtualRouterArn){return new class extends VirtualRouterBase{constructor(){super(...arguments),this.virtualRouterArn=virtualRouterArn,this.parsedArn=cdk.Fn.split("/",cdk.Stack.of(scope).splitArn(virtualRouterArn,cdk.ArnFormat.SLASH_RESOURCE_NAME).resourceName),this.virtualRouterName=cdk.Fn.select(2,this.parsedArn),this.mesh=mesh_1.Mesh.fromMeshName(this,"Mesh",cdk.Fn.select(0,this.parsedArn))}}(scope,id)}static fromVirtualRouterAttributes(scope,id,attrs){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_appmesh_VirtualRouterAttributes(attrs)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromVirtualRouterAttributes),error}return new class extends VirtualRouterBase{constructor(){super(...arguments),this.virtualRouterName=attrs.virtualRouterName,this.mesh=attrs.mesh,this.virtualRouterArn=cdk.Stack.of(this).formatArn({service:"appmesh",resource:`mesh/${attrs.mesh.meshName}/virtualRouter`,resourceName:this.virtualRouterName})}}(scope,id)}constructor(scope,id,props){super(scope,id,{physicalName:props.virtualRouterName||cdk.Lazy.string({produce:()=>cdk.Names.uniqueId(this)})}),this.listeners=new Array;try{jsiiDeprecationWarnings.aws_cdk_lib_aws_appmesh_VirtualRouterProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,VirtualRouter),error}this.mesh=props.mesh,props.listeners&&props.listeners.length?props.listeners.forEach(listener=>this.addListener(listener)):this.addListener(virtual_router_listener_1.VirtualRouterListener.http());const router=new appmesh_generated_1.CfnVirtualRouter(this,"Resource",{virtualRouterName:this.physicalName,meshName:this.mesh.meshName,meshOwner:(0,utils_1.renderMeshOwner)(this.env.account,this.mesh.env.account),spec:{listeners:this.listeners}});this.virtualRouterName=this.getResourceNameAttribute(router.attrVirtualRouterName),this.virtualRouterArn=this.getResourceArnAttribute(router.ref,{service:"appmesh",resource:`mesh/${props.mesh.meshName}/virtualRouter`,resourceName:this.physicalName})}addListener(listener){this.listeners.push(listener.bind(this).listener)}}exports.VirtualRouter=VirtualRouter,_a=JSII_RTTI_SYMBOL_1,VirtualRouter[_a]={fqn:"aws-cdk-lib.aws_appmesh.VirtualRouter",version:"2.96.1"};
