"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.EnvironmentPlaceholders=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");class EnvironmentPlaceholders{static replace(object,values){try{jsiiDeprecationWarnings().aws_cdk_lib_cx_api_EnvironmentPlaceholderValues(values)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.replace),error}return this.recurse(object,value=>(value=replaceAll(value,EnvironmentPlaceholders.CURRENT_REGION,values.region),value=replaceAll(value,EnvironmentPlaceholders.CURRENT_ACCOUNT,values.accountId),value=replaceAll(value,EnvironmentPlaceholders.CURRENT_PARTITION,values.partition),value))}static async replaceAsync(object,provider){try{jsiiDeprecationWarnings().aws_cdk_lib_cx_api_IEnvironmentPlaceholderProvider(provider)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.replaceAsync),error}let needRegion=!1,needAccountId=!1,needPartition=!1;this.recurse(object,value=>(value.indexOf(EnvironmentPlaceholders.CURRENT_REGION)>1&&(needRegion=!0),value.indexOf(EnvironmentPlaceholders.CURRENT_ACCOUNT)>1&&(needAccountId=!0),value.indexOf(EnvironmentPlaceholders.CURRENT_PARTITION)>1&&(needPartition=!0),value));const region=needRegion?await provider.region():void 0,accountId=needAccountId?await provider.accountId():void 0,partition=needPartition?await provider.partition():void 0;return this.recurse(object,value=>(value=replaceAll(value,EnvironmentPlaceholders.CURRENT_REGION,region??"WONTHAPPEN"),value=replaceAll(value,EnvironmentPlaceholders.CURRENT_ACCOUNT,accountId??"WONTHAPPEN"),value=replaceAll(value,EnvironmentPlaceholders.CURRENT_PARTITION,partition??"WONTHAPPEN"),value))}static recurse(value,cb){if(typeof value=="string")return cb(value);if(typeof value!="object"||value===null)return value;if(Array.isArray(value))return value.map(x=>this.recurse(x,cb));const ret={};for(const[key,inner]of Object.entries(value))ret[key]=this.recurse(inner,cb);return ret}}exports.EnvironmentPlaceholders=EnvironmentPlaceholders,_a=JSII_RTTI_SYMBOL_1,EnvironmentPlaceholders[_a]={fqn:"aws-cdk-lib.cx_api.EnvironmentPlaceholders",version:"2.148.1"},EnvironmentPlaceholders.CURRENT_REGION="${AWS::Region}",EnvironmentPlaceholders.CURRENT_ACCOUNT="${AWS::AccountId}",EnvironmentPlaceholders.CURRENT_PARTITION="${AWS::Partition}";function replaceAll(s,search,replace){return s.split(search).join(replace)}
