"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Deployment=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var apigateway_generated_1=()=>{var tmp=require("./apigateway.generated");return apigateway_generated_1=()=>tmp,tmp},restapi_1=()=>{var tmp=require("./restapi");return restapi_1=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp},helpers_internal_1=()=>{var tmp=require("../../core/lib/helpers-internal");return helpers_internal_1=()=>tmp,tmp};class Deployment extends core_1().Resource{constructor(scope,id,props){super(scope,id);try{jsiiDeprecationWarnings().aws_cdk_lib_aws_apigateway_DeploymentProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,Deployment),error}this.resource=new LatestDeploymentResource(this,"Resource",{description:props.description,restApi:props.api,stageName:props.stageName}),props.retainDeployments&&this.resource.applyRemovalPolicy(core_1().RemovalPolicy.RETAIN),this.api=props.api,this.deploymentId=core_1().Lazy.string({produce:()=>this.resource.ref}),props.api instanceof restapi_1().RestApiBase&&props.api._attachDeployment(this)}addToLogicalId(data){this.resource.addToLogicalId(data)}_addMethodDependency(method){this.node.addDependency(method.node.defaultChild)}}exports.Deployment=Deployment,_a=JSII_RTTI_SYMBOL_1,Deployment[_a]={fqn:"aws-cdk-lib.aws_apigateway.Deployment",version:"2.159.0"};class LatestDeploymentResource extends apigateway_generated_1().CfnDeployment{constructor(scope,id,props){super(scope,id,{description:props.description,restApiId:props.restApi.restApiId,stageName:props.stageName}),this.hashComponents=new Array,this.api=props.restApi,this.originalLogicalId=this.stack.getLogicalId(this),this.overrideLogicalId(core_1().Lazy.uncachedString({produce:()=>this.calculateLogicalId()}))}addToLogicalId(data){if(this.node.locked)throw new Error("Cannot modify the logical ID when the construct is locked");this.hashComponents.push(data)}calculateLogicalId(){const hash=[...this.hashComponents];if(this.api instanceof restapi_1().RestApi||this.api instanceof restapi_1().SpecRestApi){const cfnRestApiCF=this.api.node.defaultChild._toCloudFormation();hash.push(this.stack.resolve(cfnRestApiCF))}let lid=this.originalLogicalId;return hash.length>0&&(lid+=(0,helpers_internal_1().md5hash)(hash.map(x=>this.stack.resolve(x)).map(c=>JSON.stringify(c)).join(""))),lid}}
