"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Template=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var path=()=>{var tmp=require("path");return path=()=>tmp,tmp},fs=()=>{var tmp=require("fs-extra");return fs=()=>tmp,tmp},match_1=()=>{var tmp=require("./match");return match_1=()=>tmp,tmp},matcher_1=()=>{var tmp=require("./matcher");return matcher_1=()=>tmp,tmp},conditions_1=()=>{var tmp=require("./private/conditions");return conditions_1=()=>tmp,tmp},cyclic_1=()=>{var tmp=require("./private/cyclic");return cyclic_1=()=>tmp,tmp},mappings_1=()=>{var tmp=require("./private/mappings");return mappings_1=()=>tmp,tmp},outputs_1=()=>{var tmp=require("./private/outputs");return outputs_1=()=>tmp,tmp},parameters_1=()=>{var tmp=require("./private/parameters");return parameters_1=()=>tmp,tmp},resources_1=()=>{var tmp=require("./private/resources");return resources_1=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp};class Template{static fromStack(stack,templateParsingOptions){try{jsiiDeprecationWarnings().aws_cdk_lib_Stack(stack),jsiiDeprecationWarnings().aws_cdk_lib_assertions_TemplateParsingOptions(templateParsingOptions)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromStack),error}return new Template(toTemplate(stack),templateParsingOptions)}static fromJSON(template,templateParsingOptions){try{jsiiDeprecationWarnings().aws_cdk_lib_assertions_TemplateParsingOptions(templateParsingOptions)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromJSON),error}return new Template(template,templateParsingOptions)}static fromString(template,templateParsingOptions){try{jsiiDeprecationWarnings().aws_cdk_lib_assertions_TemplateParsingOptions(templateParsingOptions)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromString),error}return new Template(JSON.parse(template),templateParsingOptions)}constructor(template,templateParsingOptions={}){this.template=template,templateParsingOptions?.skipCyclicalDependenciesCheck||(0,cyclic_1().checkTemplateForCyclicDependencies)(this.template)}toJSON(){return this.template}resourceCountIs(type,count){const counted=(0,resources_1().countResources)(this.template,type);if(counted!==count)throw new Error(`Expected ${count} resources of type ${type} but found ${counted}`)}resourcePropertiesCountIs(type,props,count){const counted=(0,resources_1().countResourcesProperties)(this.template,type,props);if(counted!==count)throw new Error(`Expected ${count} resources of type ${type} but found ${counted}`)}hasResourceProperties(type,props){const matchError=(0,resources_1().hasResourceProperties)(this.template,type,props);if(matchError)throw new Error(matchError)}hasResource(type,props){const matchError=(0,resources_1().hasResource)(this.template,type,props);if(matchError)throw new Error(matchError)}findResources(type,props={}){return(0,resources_1().findResources)(this.template,type,props)}allResources(type,props){const matchError=(0,resources_1().allResources)(this.template,type,props);if(matchError)throw new Error(matchError)}allResourcesProperties(type,props){const matchError=(0,resources_1().allResourcesProperties)(this.template,type,props);if(matchError)throw new Error(matchError)}hasParameter(logicalId,props){const matchError=(0,parameters_1().hasParameter)(this.template,logicalId,props);if(matchError)throw new Error(matchError)}findParameters(logicalId,props={}){return(0,parameters_1().findParameters)(this.template,logicalId,props)}hasOutput(logicalId,props){const matchError=(0,outputs_1().hasOutput)(this.template,logicalId,props);if(matchError)throw new Error(matchError)}findOutputs(logicalId,props={}){return(0,outputs_1().findOutputs)(this.template,logicalId,props)}hasMapping(logicalId,props){const matchError=(0,mappings_1().hasMapping)(this.template,logicalId,props);if(matchError)throw new Error(matchError)}findMappings(logicalId,props={}){return(0,mappings_1().findMappings)(this.template,logicalId,props)}hasCondition(logicalId,props){const matchError=(0,conditions_1().hasCondition)(this.template,logicalId,props);if(matchError)throw new Error(matchError)}findConditions(logicalId,props={}){return(0,conditions_1().findConditions)(this.template,logicalId,props)}templateMatches(expected){const result=(matcher_1().Matcher.isMatcher(expected)?expected:match_1().Match.objectLike(expected)).test(this.template);if(result.hasFailed())throw new Error(["Template did not match as expected. The following mismatches were found:",...result.toHumanStrings().map(s=>`	${s}`)].join(`
`))}}exports.Template=Template,_a=JSII_RTTI_SYMBOL_1,Template[_a]={fqn:"aws-cdk-lib.assertions.Template",version:"2.148.1"};function toTemplate(stack){const stage=core_1().Stage.of(stack);if(!core_1().Stage.isStage(stage))throw new Error("unexpected: all stacks must be part of a Stage or an App");const assembly=stage.synth();return stack.nestedStackParent?JSON.parse(fs().readFileSync(path().join(assembly.directory,stack.templateFile)).toString("utf-8")):assembly.getStackArtifact(stack.artifactId).template}
