"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.StageDeployment=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var stack_deployment_1=()=>{var tmp=require("./stack-deployment");return stack_deployment_1=()=>tmp,tmp},cloud_assembly_internals_1=()=>{var tmp=require("../private/cloud-assembly-internals");return cloud_assembly_internals_1=()=>tmp,tmp},construct_internals_1=()=>{var tmp=require("../private/construct-internals");return construct_internals_1=()=>tmp,tmp};class StageDeployment{static fromStage(stage,props={}){try{jsiiDeprecationWarnings().aws_cdk_lib_Stage(stage),jsiiDeprecationWarnings().aws_cdk_lib_pipelines_StageDeploymentProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromStage),error}const assembly=(0,construct_internals_1().pipelineSynth)(stage);if(assembly.stacks.length===0)throw new Error(`The given Stage construct ('${stage.node.path}') should contain at least one Stack`);const stepFromArtifact=new Map;for(const artifact of assembly.stacks){const step=stack_deployment_1().StackDeployment.fromArtifact(artifact);stepFromArtifact.set(artifact,step)}if(props.stackSteps)for(const stackstep of props.stackSteps){const stackArtifact=assembly.getStackArtifact(stackstep.stack.artifactId),thisStep=stepFromArtifact.get(stackArtifact);if(!thisStep)throw new Error("Logic error: we just added a step for this artifact but it disappeared.");thisStep.addStackSteps(stackstep.pre??[],stackstep.changeSet??[],stackstep.post??[])}for(const artifact of assembly.stacks){const thisStep=stepFromArtifact.get(artifact);if(!thisStep)throw new Error("Logic error: we just added a step for this artifact but it disappeared.");const stackDependencies=artifact.dependencies.filter(cloud_assembly_internals_1().isStackArtifact);for(const dep of stackDependencies){const depStep=stepFromArtifact.get(dep);if(!depStep)throw new Error(`Stack '${artifact.id}' depends on stack not found in same Stage: '${dep.id}'`);thisStep.addStackDependency(depStep)}}return new StageDeployment(Array.from(stepFromArtifact.values()),{stageName:stage.stageName,...props})}constructor(stacks,props={}){this.stacks=stacks,this.stageName=props.stageName??"",this.pre=props.pre??[],this.post=props.post??[],this.stackSteps=props.stackSteps??[]}addPre(...steps){try{jsiiDeprecationWarnings().aws_cdk_lib_pipelines_Step(steps)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addPre),error}this.pre.push(...steps)}addPost(...steps){try{jsiiDeprecationWarnings().aws_cdk_lib_pipelines_Step(steps)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addPost),error}this.post.push(...steps)}}exports.StageDeployment=StageDeployment,_a=JSII_RTTI_SYMBOL_1,StageDeployment[_a]={fqn:"aws-cdk-lib.pipelines.StageDeployment",version:"2.148.1"};
