"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Stage=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),cxapi=require("../../cx-api"),constructs_1=require("constructs"),synthesis_1=require("./private/synthesis"),STAGE_SYMBOL=Symbol.for("@aws-cdk/core.Stage");class Stage extends constructs_1.Construct{constructor(scope,id,props={}){var _b,_c,_d,_e,_f,_g,_h;super(scope,id);if(jsiiDeprecationWarnings.aws_cdk_lib_StageProps(props),id!==""&&!/^[a-z][a-z0-9\-\_\.]+$/i.test(id))throw new Error(`invalid stage name "${id}". Stage name must start with a letter and contain only alphanumeric characters, hypens ('-'), underscores ('_') and periods ('.')`);Object.defineProperty(this,STAGE_SYMBOL,{value:!0}),this.parentStage=Stage.of(this),this.region=(_c=(_b=props.env)===null||_b===void 0?void 0:_b.region)!==null&&_c!==void 0?_c:(_d=this.parentStage)===null||_d===void 0?void 0:_d.region,this.account=(_f=(_e=props.env)===null||_e===void 0?void 0:_e.account)!==null&&_f!==void 0?_f:(_g=this.parentStage)===null||_g===void 0?void 0:_g.account,this._assemblyBuilder=this.createBuilder(props.outdir),this.stageName=[(_h=this.parentStage)===null||_h===void 0?void 0:_h.stageName,id].filter(x=>x).join("-")}static of(construct){return constructs_1.Node.of(construct).scopes.reverse().slice(1).find(Stage.isStage)}static isStage(x){return x!==null&&typeof x=="object"&&STAGE_SYMBOL in x}get outdir(){return this._assemblyBuilder.outdir}get assetOutdir(){return this._assemblyBuilder.assetOutdir}get artifactId(){return this.node.path?`assembly-${this.node.path.replace(/\//g,"-").replace(/^-+|-+$/g,"")}`:""}synth(options={}){return jsiiDeprecationWarnings.aws_cdk_lib_StageSynthesisOptions(options),(!this.assembly||options.force)&&(this.assembly=synthesis_1.synthesize(this,{skipValidation:options.skipValidation,validateOnSynthesis:options.validateOnSynthesis})),this.assembly}createBuilder(outdir){if(this.parentStage&&outdir)throw new Error('"outdir" cannot be specified for nested stages');return this.parentStage?this.parentStage._assemblyBuilder.createNestedAssembly(this.artifactId,this.node.path):new cxapi.CloudAssemblyBuilder(outdir)}}exports.Stage=Stage,_a=JSII_RTTI_SYMBOL_1,Stage[_a]={fqn:"aws-cdk-lib.Stage",version:"2.13.0"};
//# sourceMappingURL=stage.js.map
