cdktn-cli 0.25.0-pre.42 → 0.25.0-pre.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -71,7 +71,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
71
71
  ${i.join(`
72
72
  `)}`);let s={...n.context,...n.targetVersions?{[E9.TARGET_VERSIONS_CONTEXT_KEY]:n.targetVersions}:{}};return Object.keys(s).length>0&&(Nwt.env[kwt]=JSON.stringify(s)),n};nr.parseConfig=Gwt;function Zwt(t=Xye.join(process.cwd(),Kye)){let e;return qye.existsSync(t)&&(e=qye.readFileSync(t).toString()),(0,nr.parseConfig)(e)}function Owt(t){return eD(t.terraformModules)||eD(t.terraformProviders)}function Uwt(t){Jye.logger.debug(`Start timer for ${t}...`);let e=Date.now();return function(){let i=Date.now()-e;Jye.logger.debug(`${t} took ${i}ms`)}}});var rCe=p((mCr,tCe)=>{"use strict";tCe.exports=({onlyFirst:t=!1}={})=>{let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(e,t?void 0:"g")}});var Df=p((ICr,nCe)=>{"use strict";var Mwt=rCe();nCe.exports=t=>typeof t=="string"?t.replace(Mwt(),""):t});var V0=p(wr=>{"use strict";var Lwt=wr&&wr.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),Wwt=wr&&wr.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),oD=wr&&wr.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&Lwt(r,e,n[i]);return Wwt(r,e),r}})(),Vwt=wr&&wr.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(wr,"__esModule",{value:!0});wr.HttpError=wr.exec=void 0;wr.shell=jwt;wr.withTempDir=zwt;wr.mkdtemp=qwt;wr.readCDKTFVersion=Xwt;wr.readCDKTFManifest=Kwt;wr.downcaseFirst=e_t;wr.downloadFile=t_t;wr.ensureAllSettledBeforeThrowing=r_t;wr.hasNoColorFlagOrEnv=oCe;var Hwt=eV(),La=oD(Cr()),iCe=npe(),sCe=oD(require("os")),vB=oD(require("path")),iD=kg(),Pwt=require("cdktn"),Ywt=oD(nD()),BB=Vwt(Df());function $wt(t,e,r){t.stderr=e,t.stdout=r;let n=[e,r].filter(Boolean).join(`
73
73
  `);if(n){let i=t.message;t.toString=()=>`Error: ${i}
74
- ${n}`}}async function jwt(t,e=[],r={}){return(0,wr.exec)(t,e,r,n=>{let i=r.noColor?(0,BB.default)(n.toLocaleString()):n.toLocaleString();console.log(i)},()=>{})}async function zwt(t,e){let r=process.cwd(),n=await La.mkdtemp(vB.join(sCe.tmpdir(),"cdktf.")),i=vB.join(n,t);await La.mkdirp(i);try{process.chdir(i),await e()}finally{process.chdir(r),await La.remove(n)}}async function qwt(t){let e=await La.mkdtemp(vB.join(sCe.tmpdir(),"cdktf."));try{await t(e)}finally{await La.remove(e)}}var Jwt=async(t,e,r,n,i,s=!0)=>{typeof r.noColor!="boolean"&&oCe()&&(r.noColor=!0);let{signal:o,logStderrAsDebug:a,...c}=r,u=a?iD.processLoggerDebug:iD.processLoggerError;return new Promise((l,d)=>{var f,A,g,h;let m=(0,Hwt.spawn)(t,e,c),I=new Array,C=new Array;n!==void 0?(f=m.stdout)===null||f===void 0||f.on("data",b=>{let S=r.noColor?(0,BB.default)(b.toLocaleString()):b.toLocaleString();(0,iD.processLoggerDebug)(S),I.push(S),n(S)}):(A=m.stdout)===null||A===void 0||A.on("data",b=>{let S=r.noColor?(0,BB.default)(b.toLocaleString()):b.toLocaleString();(0,iD.processLoggerDebug)(S),I.push(S)}),i!==void 0?(g=m.stderr)===null||g===void 0||g.on("data",b=>{let S=r.noColor?(0,BB.default)(b.toLocaleString()):b.toLocaleString();u(S),s&&i(S),C.push(S)}):(h=m.stderr)===null||h===void 0||h.on("data",b=>{let S=r.noColor?(0,BB.default)(b.toLocaleString()):b.toLocaleString();u(S),s&&process.stderr.write(S),C.push(S)}),m.once("error",b=>d(b)),m.once("close",b=>{if(b!==0){let S=new Error(`${t} ${e.join(" ")} exited with code ${b}`);return $wt(S,C.join(""),I.join("")),d(S)}return l(I.join(""))})})};wr.exec=Jwt;async function Xwt(t){let e=vB.join(t,"cdk.tf.json");if(La.existsSync(e)){let r=La.readFileSync(e,"utf8");return JSON.parse(r)["//"].metadata.version}return""}async function Kwt(){let{output:t}=Ywt.readConfigSync(),e=await La.readFile(vB.join(t,Pwt.Manifest.fileName));return JSON.parse(e.toString())}function e_t(t){return t===""?t:`${t[0].toLocaleLowerCase()}${t.slice(1)}`}var sD=class extends Error{constructor(e,r){super(e),this.statusCode=r,Object.setPrototypeOf(this,new.target.prototype)}};wr.HttpError=sD;async function t_t(t,e){let r=t.startsWith("http://")?iCe.http:iCe.https,n=La.createWriteStream(e);return new Promise((i,s)=>{let o=r.get(t,a=>{if(a.statusCode!==200){s(new sD(`Failed to get '${t}' (${a.statusCode})`,a.statusCode));return}a.pipe(n)});n.on("finish",()=>i()),o.on("error",a=>{La.unlink(e,()=>s(a))}),n.on("error",a=>{La.unlink(e,()=>s(a))}),o.end()})}async function r_t(t,e){try{await t}catch(r){throw await Promise.allSettled(e),r}}function oCe(){return n_t("no-color")||process.env.FORCE_COLOR==="0"}function n_t(t){let e=t.startsWith("-")?"":t.length===1?"-":"--",r=process.argv.indexOf(e+t),n=process.argv.indexOf("--");return r!==-1&&(n===-1||r<n)}});var kg=p(gi=>{"use strict";var i_t=gi&&gi.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),s_t=gi&&gi.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),v9=gi&&gi.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&i_t(r,e,n[i]);return s_t(r,e),r}})();Object.defineProperty(gi,"__esModule",{value:!0});gi.logFileName=gi.processLoggerError=gi.processLoggerDebug=gi.logger=void 0;var B9=Yoe(),aCe=v9(Cr()),o_t=v9(require("path")),H0=v9(vR()),a_t=V0(),Jl=(0,B9.getLogger)(),S9={trace(t,...e){Jl.trace(t,...e),H0.addBreadcrumb({message:t,level:"debug"})},debug(t,...e){Jl.debug(t,...e),H0.addBreadcrumb({message:t,level:"debug"})},info(t,...e){Jl.info(t,...e),H0.addBreadcrumb({message:t,level:"info"})},warn(t,...e){Jl.warn(t,...e),H0.addBreadcrumb({message:t,level:"warning"})},error(t,...e){Jl.error(t,...e),H0.addBreadcrumb({message:t,level:"error"})},fatal(t,...e){Jl.fatal(t,...e),H0.addBreadcrumb({message:t,level:"fatal"})},setLevel(t){Jl.level=t},useDefaultLevel(){Jl.level=process.env.CDKTF_LOG_LEVEL||"INFO"}};gi.logger=S9;Jl.level=process.env.CDKTF_LOG_LEVEL||"INFO";var cCe="cdktf.log";gi.logFileName=cCe;if(process.env.CDKTF_LOG_FILE_DIRECTORY&&aCe.existsSync(process.env.CDKTF_LOG_FILE_DIRECTORY)&&aCe.statSync(process.env.CDKTF_LOG_FILE_DIRECTORY).isDirectory())(0,B9.configure)({appenders:{cdktf:{type:"file",filename:o_t.join(process.env.CDKTF_LOG_FILE_DIRECTORY,cCe)}},categories:{default:{appenders:["cdktf"],level:"debug"}}});else{let t=(0,a_t.hasNoColorFlagOrEnv)()?"basic":"colored";(0,B9.configure)({appenders:{out:{type:"stdout",layout:{type:t}}},categories:{default:{appenders:["out"],level:"info"}}})}var c_t=t=>{S9.debug(t.toString())};gi.processLoggerDebug=c_t;var u_t=t=>{S9.error(t.toString())};gi.processLoggerError=u_t});var uCe=p((bCr,l_t)=>{l_t.exports={name:"@cdktn/commons",version:"0.25.0-pre.42",publishConfig:{access:"public"},description:"CDK Terrain Common utilities",scripts:{build:"tsc",watch:"tsc -w","watch-preserve-output":"tsc -w --preserveWatchOutput","test:update":"jest -u",package:"bash package.sh","dist-clean":"rm -rf dist","package:js":"bash package.sh"},main:"build/index.js",types:"build/index.d.ts",nx:{tags:["unit-test"]},repository:{type:"git",url:"git://github.com/open-constructs/cdk-terrain.git",directory:"packages/@cdktn/commons"},author:{name:"OpenConstructs",url:"https://github.com/open-constructs"},keywords:["cdk","cdktf","cdktn","terraform"],license:"MPL-2.0",dependencies:{"@sentry/node":"7.120.4",cdktn:"workspace:*","ci-info":"4.4.0",codemaker:"1.140.0","cross-spawn":"7.0.6","follow-redirects":"1.16.0","fs-extra":"11.3.6",log4js:"6.9.1",semver:"7.8.5","strip-ansi":"6.0.1",validator:"13.15.35"},devDependencies:{"@types/node":"22.20.1","@types/cross-spawn":"6.0.6","@types/follow-redirects":"1.14.4","@types/fs-extra":"11.0.4","@types/semver":"7.7.1","@types/validator":"13.15.10","tsc-files":"1.1.4",typescript:"~6.0.0"},"lint-staged":{"src/**/*.{ts,tsx}":"tsc-files ambient.d.ts --noEmit"}}});var SB=p(aD=>{"use strict";Object.defineProperty(aD,"__esModule",{value:!0});aD.DISPLAY_VERSION=void 0;aD.DISPLAY_VERSION=`${d_t()}`;function d_t(){return uCe().version.replace(/\+[0-9a-f]+$/,"")}});var _9=p(Es=>{"use strict";var f_t=Es&&Es.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),A_t=Es&&Es.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),lD=Es&&Es.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&f_t(r,e,n[i]);return A_t(r,e),r}})(),g_t=Es&&Es.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Es,"__esModule",{value:!0});Es.sendTelemetry=E_t;Es.getProjectId=gCe;Es.getUserId=hCe;Es.ReportRequest=pCe;var h_t=lD(require("https")),p_t=require("url"),fCe=require("node:crypto"),uD=lD(require("os")),lCe=g_t(n_()),w9=kg(),wB=lD(require("path")),cD=lD(Cr()),m_t=SB(),I_t="https://checkpoint-api.hashicorp.com/v1/",y_t=[200,201],dCe=8192;function C_t(){var t;return process.env.CDKTF_HOME?wB.resolve(process.env.CDKTF_HOME):wB.join(((t=uD.userInfo().homedir)!==null&&t!==void 0?t:uD.homedir()).trim()||"/",".cdktf")}async function b_t(t,e){return new Promise((r,n)=>{let i=h_t.request((0,p_t.format)(t),{headers:{Accept:"application/json","Content-Length":e.length,"User-Agent":"OpenConstructs/cdktn-cli"},method:"POST"},s=>{if(s.statusCode){let a=s.statusCode;if(!y_t.includes(a))return n(new Error(s.statusMessage))}let o=new Array;s.on("data",a=>o.push(a)),s.on("error",a=>n(a)),s.on("end",()=>r())});i.setTimeout(1e3,()=>n(new Error("request timeout"))),i.write(e),i.end(),i.on("error",s=>n(s))})}async function E_t(t,e){let r={command:t,product:"cdktn",version:`${m_t.DISPLAY_VERSION}`,dateTime:new Date,language:e.language,payload:e};try{await pCe(r)}catch(n){w9.logger.error(`Could not send telemetry data: ${n}`)}}function ACe(t,e,r=!1,n){let i=(0,fCe.randomUUID)(),s;try{s=JSON.parse(cD.readFileSync(t,"utf-8"))}catch{if(r){let a={};n&&(a["//"]=n.replace(/\n/g," ")),a[e]=i,cD.ensureDirSync(wB.dirname(t)),cD.writeFileSync(t,JSON.stringify(a,null,2))}return i}return s[e]?s[e]:(cD.writeFileSync(t,JSON.stringify({...s,[e]:i},null,2)),i)}function gCe(t=process.cwd()){return ACe(wB.resolve(t,"cdktf.json"),"projectId")}function hCe(){return ACe(wB.resolve(C_t(),"config.json"),"userId",!0,`This signature is a randomly generated UUID used to anonymously differentiate users in telemetry data order to inform product direction.
74
+ ${n}`}}async function jwt(t,e=[],r={}){return(0,wr.exec)(t,e,r,n=>{let i=r.noColor?(0,BB.default)(n.toLocaleString()):n.toLocaleString();console.log(i)},()=>{})}async function zwt(t,e){let r=process.cwd(),n=await La.mkdtemp(vB.join(sCe.tmpdir(),"cdktf.")),i=vB.join(n,t);await La.mkdirp(i);try{process.chdir(i),await e()}finally{process.chdir(r),await La.remove(n)}}async function qwt(t){let e=await La.mkdtemp(vB.join(sCe.tmpdir(),"cdktf."));try{await t(e)}finally{await La.remove(e)}}var Jwt=async(t,e,r,n,i,s=!0)=>{typeof r.noColor!="boolean"&&oCe()&&(r.noColor=!0);let{signal:o,logStderrAsDebug:a,...c}=r,u=a?iD.processLoggerDebug:iD.processLoggerError;return new Promise((l,d)=>{var f,A,g,h;let m=(0,Hwt.spawn)(t,e,c),I=new Array,C=new Array;n!==void 0?(f=m.stdout)===null||f===void 0||f.on("data",b=>{let S=r.noColor?(0,BB.default)(b.toLocaleString()):b.toLocaleString();(0,iD.processLoggerDebug)(S),I.push(S),n(S)}):(A=m.stdout)===null||A===void 0||A.on("data",b=>{let S=r.noColor?(0,BB.default)(b.toLocaleString()):b.toLocaleString();(0,iD.processLoggerDebug)(S),I.push(S)}),i!==void 0?(g=m.stderr)===null||g===void 0||g.on("data",b=>{let S=r.noColor?(0,BB.default)(b.toLocaleString()):b.toLocaleString();u(S),s&&i(S),C.push(S)}):(h=m.stderr)===null||h===void 0||h.on("data",b=>{let S=r.noColor?(0,BB.default)(b.toLocaleString()):b.toLocaleString();u(S),s&&process.stderr.write(S),C.push(S)}),m.once("error",b=>d(b)),m.once("close",b=>{if(b!==0){let S=new Error(`${t} ${e.join(" ")} exited with code ${b}`);return $wt(S,C.join(""),I.join("")),d(S)}return l(I.join(""))})})};wr.exec=Jwt;async function Xwt(t){let e=vB.join(t,"cdk.tf.json");if(La.existsSync(e)){let r=La.readFileSync(e,"utf8");return JSON.parse(r)["//"].metadata.version}return""}async function Kwt(){let{output:t}=Ywt.readConfigSync(),e=await La.readFile(vB.join(t,Pwt.Manifest.fileName));return JSON.parse(e.toString())}function e_t(t){return t===""?t:`${t[0].toLocaleLowerCase()}${t.slice(1)}`}var sD=class extends Error{constructor(e,r){super(e),this.statusCode=r,Object.setPrototypeOf(this,new.target.prototype)}};wr.HttpError=sD;async function t_t(t,e){let r=t.startsWith("http://")?iCe.http:iCe.https,n=La.createWriteStream(e);return new Promise((i,s)=>{let o=r.get(t,a=>{if(a.statusCode!==200){s(new sD(`Failed to get '${t}' (${a.statusCode})`,a.statusCode));return}a.pipe(n)});n.on("finish",()=>i()),o.on("error",a=>{La.unlink(e,()=>s(a))}),n.on("error",a=>{La.unlink(e,()=>s(a))}),o.end()})}async function r_t(t,e){try{await t}catch(r){throw await Promise.allSettled(e),r}}function oCe(){return n_t("no-color")||process.env.FORCE_COLOR==="0"}function n_t(t){let e=t.startsWith("-")?"":t.length===1?"-":"--",r=process.argv.indexOf(e+t),n=process.argv.indexOf("--");return r!==-1&&(n===-1||r<n)}});var kg=p(gi=>{"use strict";var i_t=gi&&gi.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),s_t=gi&&gi.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),v9=gi&&gi.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&i_t(r,e,n[i]);return s_t(r,e),r}})();Object.defineProperty(gi,"__esModule",{value:!0});gi.logFileName=gi.processLoggerError=gi.processLoggerDebug=gi.logger=void 0;var B9=Yoe(),aCe=v9(Cr()),o_t=v9(require("path")),H0=v9(vR()),a_t=V0(),Jl=(0,B9.getLogger)(),S9={trace(t,...e){Jl.trace(t,...e),H0.addBreadcrumb({message:t,level:"debug"})},debug(t,...e){Jl.debug(t,...e),H0.addBreadcrumb({message:t,level:"debug"})},info(t,...e){Jl.info(t,...e),H0.addBreadcrumb({message:t,level:"info"})},warn(t,...e){Jl.warn(t,...e),H0.addBreadcrumb({message:t,level:"warning"})},error(t,...e){Jl.error(t,...e),H0.addBreadcrumb({message:t,level:"error"})},fatal(t,...e){Jl.fatal(t,...e),H0.addBreadcrumb({message:t,level:"fatal"})},setLevel(t){Jl.level=t},useDefaultLevel(){Jl.level=process.env.CDKTF_LOG_LEVEL||"INFO"}};gi.logger=S9;Jl.level=process.env.CDKTF_LOG_LEVEL||"INFO";var cCe="cdktf.log";gi.logFileName=cCe;if(process.env.CDKTF_LOG_FILE_DIRECTORY&&aCe.existsSync(process.env.CDKTF_LOG_FILE_DIRECTORY)&&aCe.statSync(process.env.CDKTF_LOG_FILE_DIRECTORY).isDirectory())(0,B9.configure)({appenders:{cdktf:{type:"file",filename:o_t.join(process.env.CDKTF_LOG_FILE_DIRECTORY,cCe)}},categories:{default:{appenders:["cdktf"],level:"debug"}}});else{let t=(0,a_t.hasNoColorFlagOrEnv)()?"basic":"colored";(0,B9.configure)({appenders:{out:{type:"stdout",layout:{type:t}}},categories:{default:{appenders:["out"],level:"info"}}})}var c_t=t=>{S9.debug(t.toString())};gi.processLoggerDebug=c_t;var u_t=t=>{S9.error(t.toString())};gi.processLoggerError=u_t});var uCe=p((bCr,l_t)=>{l_t.exports={name:"@cdktn/commons",version:"0.25.0-pre.43",publishConfig:{access:"public"},description:"CDK Terrain Common utilities",scripts:{build:"tsc",watch:"tsc -w","watch-preserve-output":"tsc -w --preserveWatchOutput","test:update":"jest -u",package:"bash package.sh","dist-clean":"rm -rf dist","package:js":"bash package.sh"},main:"build/index.js",types:"build/index.d.ts",nx:{tags:["unit-test"]},repository:{type:"git",url:"git://github.com/open-constructs/cdk-terrain.git",directory:"packages/@cdktn/commons"},author:{name:"OpenConstructs",url:"https://github.com/open-constructs"},keywords:["cdk","cdktf","cdktn","terraform"],license:"MPL-2.0",dependencies:{"@sentry/node":"7.120.4",cdktn:"workspace:*","ci-info":"4.4.0",codemaker:"1.140.0","cross-spawn":"7.0.6","follow-redirects":"1.16.0","fs-extra":"11.3.6",log4js:"6.9.1",semver:"7.8.5","strip-ansi":"6.0.1",validator:"13.15.35"},devDependencies:{"@types/node":"22.20.1","@types/cross-spawn":"6.0.6","@types/follow-redirects":"1.14.4","@types/fs-extra":"11.0.4","@types/semver":"7.7.1","@types/validator":"13.15.10","tsc-files":"1.1.4",typescript:"~6.0.0"},"lint-staged":{"src/**/*.{ts,tsx}":"tsc-files ambient.d.ts --noEmit"}}});var SB=p(aD=>{"use strict";Object.defineProperty(aD,"__esModule",{value:!0});aD.DISPLAY_VERSION=void 0;aD.DISPLAY_VERSION=`${d_t()}`;function d_t(){return uCe().version.replace(/\+[0-9a-f]+$/,"")}});var _9=p(Es=>{"use strict";var f_t=Es&&Es.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),A_t=Es&&Es.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),lD=Es&&Es.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&f_t(r,e,n[i]);return A_t(r,e),r}})(),g_t=Es&&Es.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Es,"__esModule",{value:!0});Es.sendTelemetry=E_t;Es.getProjectId=gCe;Es.getUserId=hCe;Es.ReportRequest=pCe;var h_t=lD(require("https")),p_t=require("url"),fCe=require("node:crypto"),uD=lD(require("os")),lCe=g_t(n_()),w9=kg(),wB=lD(require("path")),cD=lD(Cr()),m_t=SB(),I_t="https://checkpoint-api.hashicorp.com/v1/",y_t=[200,201],dCe=8192;function C_t(){var t;return process.env.CDKTF_HOME?wB.resolve(process.env.CDKTF_HOME):wB.join(((t=uD.userInfo().homedir)!==null&&t!==void 0?t:uD.homedir()).trim()||"/",".cdktf")}async function b_t(t,e){return new Promise((r,n)=>{let i=h_t.request((0,p_t.format)(t),{headers:{Accept:"application/json","Content-Length":e.length,"User-Agent":"OpenConstructs/cdktn-cli"},method:"POST"},s=>{if(s.statusCode){let a=s.statusCode;if(!y_t.includes(a))return n(new Error(s.statusMessage))}let o=new Array;s.on("data",a=>o.push(a)),s.on("error",a=>n(a)),s.on("end",()=>r())});i.setTimeout(1e3,()=>n(new Error("request timeout"))),i.write(e),i.end(),i.on("error",s=>n(s))})}async function E_t(t,e){let r={command:t,product:"cdktn",version:`${m_t.DISPLAY_VERSION}`,dateTime:new Date,language:e.language,payload:e};try{await pCe(r)}catch(n){w9.logger.error(`Could not send telemetry data: ${n}`)}}function ACe(t,e,r=!1,n){let i=(0,fCe.randomUUID)(),s;try{s=JSON.parse(cD.readFileSync(t,"utf-8"))}catch{if(r){let a={};n&&(a["//"]=n.replace(/\n/g," ")),a[e]=i,cD.ensureDirSync(wB.dirname(t)),cD.writeFileSync(t,JSON.stringify(a,null,2))}return i}return s[e]?s[e]:(cD.writeFileSync(t,JSON.stringify({...s,[e]:i},null,2)),i)}function gCe(t=process.cwd()){return ACe(wB.resolve(t,"cdktf.json"),"projectId")}function hCe(){return ACe(wB.resolve(C_t(),"config.json"),"userId",!0,`This signature is a randomly generated UUID used to anonymously differentiate users in telemetry data order to inform product direction.
75
75
  This signature is random, it is not based on any personally identifiable information.
76
76
  To create a new signature, you can simply delete this file at any time.
77
77
  See https://cdktn.io/docs/telemetry for more
@@ -326,7 +326,7 @@ ${e}${r?`~=${r}`:""}`;await ll.writeFile(i,a,"utf8"),await(0,Pe.exec)("pip",["in
326
326
  ${s.message}`)}else throw new Error(`Invalid target: "${r}" is not a valid target from the root node. Did you mean ".${r}"?`)})}function VZe(t){let e=_Ze(t.config.target);return e?{target:e.map(r=>typeof r=="string"?RS(t.parent,r):r)}:t.parent.type==="parallel"?{target:[t.parent]}:t.parent.initial}function jh(t){return t.type==="history"}function CZe(t){let e=HZe(t);for(let r of e)for(let n of Xh(r,t))e.add(n);return e}function HZe(t){let e=new Set;function r(n){if(!e.has(n)){if(e.add(n),n.type==="compound")r(n.initial.target[0]);else if(n.type==="parallel")for(let i of EI(n))r(i)}}return r(t),e}function BI(t,e){if(SI(e))return t.machine.getStateNodeById(e);if(!t.states)throw new Error(`Unable to retrieve child state '${e}' from '${t.id}'; no child states exist.`);let r=t.states[e];if(!r)throw new Error(`Child state '${e}' does not exist on '${t.id}'`);return r}function RS(t,e){if(typeof e=="string"&&SI(e))try{return t.machine.getStateNodeById(e)}catch{}let r=Fk(e).slice(),n=t;for(;r.length;){let i=r.shift();if(!i.length)break;n=BI(n,i)}return n}function Kh(t,e){if(typeof e=="string"){let i=t.states[e];if(!i)throw new Error(`State '${e}' does not exist on '${t.id}'`);return[t,i]}let r=Object.keys(e),n=r.map(i=>BI(t,i)).filter(Boolean);return[t.machine.root,t].concat(n,r.reduce((i,s)=>{let o=BI(t,s);if(!o)return i;let a=Kh(o,e[s]);return i.concat(a)},[]))}function otr(t,e,r,n){let s=BI(t,e).next(r,n);return!s||!s.length?t.next(r,n):s}function atr(t,e,r,n){let i=Object.keys(e),s=BI(t,i[0]),o=Ok(s,e[i[0]],r,n);return!o||!o.length?t.next(r,n):o}function ctr(t,e,r,n){let i=[];for(let s of Object.keys(e)){let o=e[s];if(!o)continue;let a=BI(t,s),c=Ok(a,o,r,n);c&&i.push(...c)}return i.length?i:t.next(r,n)}function Ok(t,e,r,n){return typeof e=="string"?otr(t,e,r,n):Object.keys(e).length===1?atr(t,e,r,n):ctr(t,e,r,n)}function utr(t){return Object.keys(t.states).map(e=>t.states[e]).filter(e=>e.type==="history")}function xA(t,e){let r=t;for(;r.parent&&r.parent!==e;)r=r.parent;return r.parent===e}function ltr(t,e){let r=new Set(t),n=new Set(e);for(let i of r)if(n.has(i))return!0;for(let i of n)if(r.has(i))return!0;return!1}function PZe(t,e,r){let n=new Set;for(let i of t){let s=!1,o=new Set;for(let a of n)if(ltr(Vq([i],e,r),Vq([a],e,r)))if(xA(i.source,a.source))o.add(a);else{s=!0;break}if(!s){for(let a of o)n.delete(a);n.add(i)}}return Array.from(n)}function dtr(t){let[e,...r]=t;for(let n of Xh(e,void 0))if(r.every(i=>xA(i,n)))return n}function eJ(t,e){if(!t.target)return[];let r=new Set;for(let n of t.target)if(jh(n))if(e[n.id])for(let i of e[n.id])r.add(i);else for(let i of eJ(VZe(n),e))r.add(i);else r.add(n);return[...r]}function YZe(t,e){let r=eJ(t,e);if(!r)return;if(!t.reenter&&r.every(i=>i===t.source||xA(i,t.source)))return t.source;let n=dtr(r.concat(t.source));if(n)return n;if(!t.reenter)return t.source.machine.root}function Vq(t,e,r){let n=new Set;for(let i of t)if(i.target?.length){let s=YZe(i,r);i.reenter&&i.source===s&&n.add(s);for(let o of e)xA(o,s)&&n.add(o)}return[...n]}function ftr(t,e){if(t.length!==e.size)return!1;for(let r of t)if(!e.has(r))return!1;return!0}function Uk(t,e,r,n,i){return Hq([{target:[...HZe(t)],source:t,reenter:!0,actions:[],eventType:null,toJSON:null}],e,r,n,!0,i)}function Hq(t,e,r,n,i,s){let o=[];if(!t.length)return[e,o];let a=r.actionExecutor;r.actionExecutor=c=>{o.push(c),a(c)};try{let c=new Set(e._nodes),u=e.historyValue,l=PZe(t,c,u),d=e;i||([d,u]=ptr(d,n,r,l,c,u,s,r.actionExecutor)),d=zh(d,n,r,l.flatMap(A=>A.actions),s,void 0),d=gtr(d,n,r,l,c,s,u,i);let f=[...c];d.status==="done"&&(d=zh(d,n,r,f.sort((A,g)=>g.order-A.order).flatMap(A=>A.exit),s,void 0));try{return u===e.historyValue&&ftr(e._nodes,c)?[d,o]:[RA(d,{_nodes:f,historyValue:u}),o]}catch(A){throw A}}finally{r.actionExecutor=a}}function Atr(t,e,r,n,i){if(n.output===void 0)return;let s=Lq(i.id,i.output!==void 0&&i.parent?Wq(i.output,t.context,e,r.self):void 0);return Wq(n.output,t.context,s,r.self)}function gtr(t,e,r,n,i,s,o,a){let c=t,u=new Set,l=new Set;htr(n,o,l,u),a&&l.add(t.machine.root);let d=new Set;for(let f of[...u].sort((A,g)=>A.order-g.order)){i.add(f);let A=[];A.push(...f.entry);for(let g of f.invoke)A.push(Jh(g.src,{...g,syncSnapshot:!!g.onSnapshot}));if(l.has(f)){let g=f.initial.actions;A.push(...g)}if(c=zh(c,e,r,A,s,f.invoke.map(g=>g.id)),f.type==="final"){let g=f.parent,h=g?.type==="parallel"?g:g?.parent,m=h||f;for(g?.type==="compound"&&s.push(Lq(g.id,f.output!==void 0?Wq(f.output,c.context,e,r.self):void 0));h?.type==="parallel"&&!d.has(h)&&Zk(i,h);)d.add(h),s.push(Lq(h.id)),m=h,h=h.parent;if(h)continue;c=RA(c,{status:"done",output:Atr(c,e,r,c.machine.root,m)})}}return c}function htr(t,e,r,n){for(let i of t){let s=YZe(i,e);for(let a of i.target||[])!jh(a)&&(i.source!==a||i.source!==s||i.reenter)&&(n.add(a),r.add(a)),CI(a,e,r,n);let o=eJ(i,e);for(let a of o){let c=Xh(a,s);s?.type==="parallel"&&c.push(s),$Ze(n,e,r,c,!i.source.parent&&i.reenter?void 0:s)}}}function CI(t,e,r,n){if(jh(t))if(e[t.id]){let i=e[t.id];for(let s of i)n.add(s),CI(s,e,r,n);for(let s of i)Mq(s,t.parent,n,e,r)}else{let i=VZe(t);for(let s of i.target)n.add(s),i===t.parent?.initial&&r.add(t.parent),CI(s,e,r,n);for(let s of i.target)Mq(s,t.parent,n,e,r)}else if(t.type==="compound"){let[i]=t.initial.target;jh(i)||(n.add(i),r.add(i)),CI(i,e,r,n),Mq(i,t,n,e,r)}else if(t.type==="parallel")for(let i of EI(t).filter(s=>!jh(s)))[...n].some(s=>xA(s,i))||(jh(i)||(n.add(i),r.add(i)),CI(i,e,r,n))}function $Ze(t,e,r,n,i){for(let s of n)if((!i||xA(s,i))&&t.add(s),s.type==="parallel")for(let o of EI(s).filter(a=>!jh(a)))[...t].some(a=>xA(a,o))||(t.add(o),CI(o,e,r,t))}function Mq(t,e,r,n,i){$Ze(r,n,i,Xh(t,e))}function ptr(t,e,r,n,i,s,o,a){let c=t,u=Vq(n,i,s);u.sort((d,f)=>f.order-d.order);let l;for(let d of u)for(let f of utr(d)){let A;f.history==="deep"?A=g=>vI(g)&&xA(g,d):A=g=>g.parent===d,l??={...s},l[f.id]=Array.from(i).filter(A)}for(let d of u)c=zh(c,e,r,[...d.exit,...d.invoke.map(f=>vd(f.id))],o,void 0),i.delete(d);return[c,l||s]}function mtr(t,e){return t.implementations.actions[e]}function jZe(t,e,r,n,i,s){let{machine:o}=t,a=t;for(let c of n){let u=typeof c=="function",l=u?c:mtr(o,typeof c=="string"?c:c.type),d={context:a.context,event:e,self:r.self,system:r.system},f=u||typeof c=="string"?void 0:"params"in c?typeof c.params=="function"?c.params({context:a.context,event:e}):c.params:void 0;if(!l||!("resolve"in l)){r.actionExecutor({type:typeof c=="string"?c:typeof c=="object"?c.type:c.name||"(anonymous)",info:d,params:f,exec:l});continue}let A=l,[g,h,m]=A.resolve(r,a,d,f,l,i);a=g,"retryResolve"in A&&s?.push([A,h]),"execute"in A&&r.actionExecutor({type:A.type,info:d,params:h,exec:A.execute.bind(null,r,h)}),m&&(a=jZe(a,e,r,m,i,s))}return a}function zh(t,e,r,n,i,s){let o=s?[]:void 0,a=jZe(t,e,r,n,{internalQueue:i,deferredActorIds:s},o);return o?.forEach(([c,u])=>{c.retryResolve(r,a,u)}),a}function ep(t,e,r,n){let i=t,s=[];function o(d,f,A){r.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:r.self,event:f,snapshot:d[0],_transitions:A}),s.push(d)}if(e.type===_A)return i=RA(bZe(i,e,r),{status:"stopped"}),o([i,[]],e,[]),{snapshot:i,microsteps:s};let a=e;if(a.type!==BZe){let d=a,f=Yer(d),A=EZe(d,i);if(f&&!A.length)return i=RA(t,{status:"error",error:d.error}),o([i,[]],d,[]),{snapshot:i,microsteps:s};let g=Hq(A,t,r,a,!1,n);i=g[0],o(g,d,A)}let c=!0,u=t.machine.options?.maxIterations??1/0,l=0;for(;i.status==="active";){if(l++,l>u)throw new Error(`Infinite loop detected: the machine has processed more than ${u} microsteps without reaching a stable state. This usually happens when there's a cycle of transitions (e.g., eventless transitions or raised events causing state A -> B -> C -> A).`);let d=c?Itr(i,a):[],f=d.length?i:void 0;if(!d.length){if(!n.length)break;a=n.shift(),d=EZe(a,i)}let A=Hq(d,i,r,a,!1,n);i=A[0],c=i!==f,o(A,a,d)}return i.status!=="active"&&bZe(i,a,r),{snapshot:i,microsteps:s}}function bZe(t,e,r){return zh(t,e,r,Object.values(t.children).map(n=>vd(n)),[],void 0)}function EZe(t,e){return e.machine.getTransitionData(e,t)}function Itr(t,e){let r=new Set,n=t._nodes.filter(vI);for(let i of n)e:for(let s of[i].concat(Xh(i,void 0)))if(s.always){for(let o of s.always)if(o.guard===void 0||Sd(o.guard,t.context,e,t)){r.add(o);break e}}return PZe(Array.from(r),new Set(t._nodes),t.historyValue)}function zZe(t,e){let r=NS(Kh(t,e));return ZZe(t,[...r])}function tJ(t){return!!t&&typeof t=="object"&&"machine"in t&&"value"in t}function TS(t,e){return{status:t.status,output:t.output,error:t.error,machine:e,context:t.context,_nodes:t._nodes,value:ZZe(e.root,t._nodes),tags:new Set(t._nodes.flatMap(r=>r.tags)),children:t.children,historyValue:t.historyValue||{},matches:ytr,hasTag:Ctr,can:btr,getMeta:Btr,toJSON:Etr}}function RA(t,e={}){return TS({...t,...e},t.machine)}function vtr(t){if(typeof t!="object"||t===null)return{};let e={};for(let r in t){let n=t[r];Array.isArray(n)&&(e[r]=n.map(i=>({id:i.id})))}return e}function qZe(t,e){let{_nodes:r,tags:n,machine:i,children:s,context:o,can:a,hasTag:c,matches:u,getMeta:l,toJSON:d,...f}=t,A={};for(let h in s){let m=s[h];A[h]={snapshot:m.getPersistedSnapshot(e),src:m.src,systemId:m.systemId,syncSnapshot:m._syncSnapshot}}return{...f,context:JZe(o),children:A,historyValue:vtr(f.historyValue)}}function JZe(t){let e;for(let r in t){let n=t[r];if(n&&typeof n=="object")if("sessionId"in n&&"send"in n&&"ref"in n)e??=Array.isArray(t)?t.slice():{...t},e[r]={xstate$$type:Gk,id:n.id};else{let i=JZe(n);i!==n&&(e??=Array.isArray(t)?t.slice():{...t},e[r]=i)}}return e??t}function Str(t,e,r,n,{event:i,id:s,delay:o},{internalQueue:a}){let c=e.machine.implementations.delays;if(typeof i=="string")throw new Error(`Only event objects may be used with raise; use raise({ type: "${i}" }) instead`);let u=typeof i=="function"?i(r,n):i,l;if(typeof o=="string"){let d=c&&c[o];l=typeof d=="function"?d(r,n):d}else l=typeof o=="function"?o(r,n):o;return typeof l!="number"&&a.push(u),[e,{event:u,id:s,delay:l},void 0]}function wtr(t,e){let{event:r,delay:n,id:i}=e;if(typeof n=="number"){t.defer(()=>{let s=t.self;t.system.scheduler.schedule(s,s,r,n,i)});return}}function tp(t,e){function r(n,i){}return r.type="xstate.raise",r.event=t,r.id=e?.id,r.delay=e?.delay,r.resolve=Str,r.execute=wtr,r}var Tk,Pq,Mer,Yq,Ler,Wer,BZe,vZe,_A,Per,$er,Uq,Gk,es,jer,xS,RZe,QZe,SI,ytr,Ctr,btr,Etr,Btr,rp=GA(()=>{"use strict";mZe();Tk=class{constructor(e){this._process=e,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(e){let r={value:e,next:null};if(this._current){this._last.next=r,this._last=r;return}this._current=r,this._last=r,this._active&&this.flush()}flush(){for(;this._current;){let e=this._current;this._process(e.value),this._current=e.next}this._last=null}},Pq=".",Mer="",Yq="",Ler="#",Wer="*",BZe="xstate.init",vZe="xstate.error",_A="xstate.stop";Per=typeof Symbol=="function"&&Symbol.observable||"@@observable";$er=0;Uq=!1,Gk=1,es=(function(t){return t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped",t})({}),jer={clock:{setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t)},logger:console.log.bind(console),devTools:!1},xS=class{constructor(e,r){this.logic=e,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new Tk(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=es.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this.systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];let n={...jer,...r},{clock:i,logger:s,parent:o,syncSnapshot:a,id:c,systemId:u,inspect:l}=n;this.system=o?o.system:Xq(this,{clock:i,logger:s}),l&&!o&&this.system.inspect(bI(l)),this.sessionId=this.system._bookId(),this.id=c??this.sessionId,this.logger=r?.logger??this.system._logger,this.clock=r?.clock??this.system._clock,this._parent=o,this._syncSnapshot=a,this.options=n,this.src=n.src??e,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:d=>{this._deferred.push(d)},system:this.system,stopChild:d=>{if(d._parent!==this)throw new Error(`Cannot stop child actor ${d.id} of ${this.id} because it is not a child`);d._stop()},emit:d=>{let f=this.eventListeners.get(d.type),A=this.eventListeners.get("*");if(!f&&!A)return;let g=[...f?f.values():[],...A?A.values():[]];for(let h of g)try{h(d)}catch(m){Al(m)}},actionExecutor:d=>{let f=()=>{if(this._actorScope.system._sendInspectionEvent({type:"@xstate.action",actorRef:this,action:{type:d.type,params:d.params}}),!d.exec)return;let A=Uq;try{Uq=!0,d.exec(d.info,d.params)}finally{Uq=A}};this._processingStatus===es.Running?f():this._deferred.push(f)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),u&&(this.systemId=u,this.system._set(u,this)),this._initState(r?.snapshot??r?.state),u&&this._snapshot.status!=="active"&&this.system._unregister(this)}_initState(e){try{this._snapshot=e?this.logic.restoreSnapshot?this.logic.restoreSnapshot(e,this._actorScope):e:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(r){this._snapshot={status:"error",output:void 0,error:r}}}update(e,r){this._snapshot=e;let n;for(;n=this._deferred.shift();)try{n()}catch(i){this._deferred.length=0,this._snapshot={...e,status:"error",error:i}}switch(this._snapshot.status){case"active":for(let i of this.observers)try{i.next?.(e)}catch(s){Al(s)}break;case"done":for(let i of this.observers)try{i.next?.(e)}catch(s){Al(s)}this._stopProcedure(),this._complete(),this._doneEvent=Her(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._error(this._snapshot.error);break}this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:r,snapshot:e})}subscribe(e,r,n){let i=bI(e,r,n);if(this._processingStatus!==es.Stopped)this.observers.add(i);else switch(this._snapshot.status){case"done":try{i.complete?.()}catch(s){Al(s)}break;case"error":{let s=this._snapshot.error;if(!i.error)Al(s);else try{i.error(s)}catch(o){Al(o)}break}}return{unsubscribe:()=>{this.observers.delete(i)}}}on(e,r){let n=this.eventListeners.get(e);n||(n=new Set,this.eventListeners.set(e,n));let i=r.bind(void 0);return n.add(i),{unsubscribe:()=>{n.delete(i)}}}select(e,r=Object.is){return{subscribe:n=>{let i=bI(n),s=this.getSnapshot(),o=e(s);return this.subscribe(a=>{let c=e(a);r(o,c)||(o=c,i.next?.(c))})},get:()=>e(this.getSnapshot())}}start(){if(this._processingStatus===es.Running)return this;this._syncSnapshot&&this.subscribe({next:n=>{n.status==="active"&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:n})},error:()=>{}}),this.system._register(this.sessionId,this),this.systemId&&this.system._set(this.systemId,this),this._processingStatus=es.Running;let e=DS(this.options.input);switch(this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:e}),this._snapshot.status){case"done":return this.update(this._snapshot,e),this;case"error":return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(n){return this._snapshot={...this._snapshot,status:"error",error:n},this._error(n),this}return this.update(this._snapshot,e),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(e){let r,n;try{r=this.logic.transition(this._snapshot,e,this._actorScope)}catch(i){n={err:i}}if(n){let{err:i}=n;this._snapshot={...this._snapshot,status:"error",error:i},this._error(i);return}this.update(r,e),e.type===_A&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===es.Stopped?this:(this.mailbox.clear(),this._processingStatus===es.NotStarted?(this._processingStatus=es.Stopped,this):(this.mailbox.enqueue({type:_A}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){for(let e of this.observers)try{e.complete?.()}catch(r){Al(r)}this.observers.clear(),this.eventListeners.clear()}_reportError(e){if(!this.observers.size){this._parent||Al(e),this.eventListeners.clear();return}let r=!1;for(let n of this.observers){let i=n.error;r||=!i;try{i?.(e)}catch(s){Al(s)}}this.observers.clear(),this.eventListeners.clear(),r&&Al(e)}_error(e){this._stopProcedure(),this._reportError(e),this._parent&&this.system._relay(this,this._parent,$q(this.id,e))}_stopProcedure(){return this._processingStatus!==es.Running?this:(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new Tk(this._process.bind(this)),this._processingStatus=es.Stopped,this.system._unregister(this),this)}_send(e){this._processingStatus!==es.Stopped&&this.mailbox.enqueue(e)}send(e){this.system._relay(void 0,this,e)}attachDevTools(){let{devTools:e}=this.options;e&&(typeof e=="function"?e:pZe)(this)}toJSON(){return{xstate$$type:Gk,id:this.id}}getPersistedSnapshot(e){return this.logic.getPersistedSnapshot(this._snapshot,e)}[Per](){return this}getSnapshot(){return this._snapshot}};RZe=yo;QZe=vd;SI=t=>t[0]===Ler;ytr=function(e){return kk(e,this.value)},Ctr=function(e){return this.tags.has(e)},btr=function(e){let r=this.machine.getTransitionData(this,e);return!!r?.length&&r.some(n=>n.target!==void 0||n.actions.length)},Etr=function(){let{_nodes:e,tags:r,machine:n,getMeta:i,toJSON:s,can:o,hasTag:a,matches:c,...u}=this;return{...u,tags:Array.from(r)}},Btr=function(){return this._nodes.reduce((e,r)=>(r.meta!==void 0&&(e[r.id]=r.meta),e),{})}});function nJ(t,e){return{config:t,transition:(r,n,i)=>({...r,context:t(r.context,n,i)}),getInitialSnapshot:(r,n)=>({status:"active",output:void 0,error:void 0,context:typeof e=="function"?e({input:n}):e}),getPersistedSnapshot:r=>r,restoreSnapshot:r=>r}}function tOe(t){return{config:t,start:(r,n)=>{let{self:i,system:s,emit:o}=n,a={receivers:void 0,dispose:void 0};rJ.set(i,a),a.dispose=t({input:r.input,system:s,self:i,sendBack:c=>{i.getSnapshot().status!=="stopped"&&i._parent&&s._relay(i,i._parent,c)},receive:c=>{a.receivers??=new Set,a.receivers.add(c)},emit:o})},transition:(r,n,i)=>{let s=rJ.get(i.self);return n.type===_A?(r={...r,status:"stopped",error:void 0},rJ.delete(i.self),s.receivers?.clear(),s.dispose?.(),r):(s.receivers?.forEach(o=>o(n)),r)},getInitialSnapshot:(r,n)=>({status:"active",output:void 0,error:void 0,input:n}),getPersistedSnapshot:r=>r,restoreSnapshot:r=>r}}function rOe(t){return{config:t,transition:(r,n)=>{if(r.status!=="active")return r;switch(n.type){case XZe:return{...r,context:n.data};case Mk:return{...r,status:"error",error:n.data,input:void 0,_subscription:void 0};case Lk:return{...r,status:"done",input:void 0,_subscription:void 0};case _A:return r._subscription.unsubscribe(),{...r,status:"stopped",input:void 0,_subscription:void 0};default:return r}},getInitialSnapshot:(r,n)=>({status:"active",output:void 0,error:void 0,context:void 0,input:n,_subscription:void 0}),start:(r,{self:n,system:i,emit:s})=>{r.status!=="done"&&(r._subscription=t({input:r.input,system:i,self:n,emit:s}).subscribe({next:o=>{i._relay(n,n,{type:XZe,data:o})},error:o=>{i._relay(n,n,{type:Mk,data:o})},complete:()=>{i._relay(n,n,{type:Lk})}}))},getPersistedSnapshot:({_subscription:r,...n})=>n,restoreSnapshot:r=>({...r,_subscription:void 0})}}function nOe(t){return{config:t,transition:(r,n)=>{if(r.status!=="active")return r;switch(n.type){case Mk:return{...r,status:"error",error:n.data,input:void 0,_subscription:void 0};case Lk:return{...r,status:"done",input:void 0,_subscription:void 0};case _A:return r._subscription.unsubscribe(),{...r,status:"stopped",input:void 0,_subscription:void 0};default:return r}},getInitialSnapshot:(r,n)=>({status:"active",output:void 0,error:void 0,context:void 0,input:n,_subscription:void 0}),start:(r,{self:n,system:i,emit:s})=>{r.status!=="done"&&(r._subscription=t({input:r.input,system:i,self:n,emit:s}).subscribe({next:o=>{n._parent&&i._relay(n,n._parent,o)},error:o=>{i._relay(n,n,{type:Mk,data:o})},complete:()=>{i._relay(n,n,{type:Lk})}}))},getPersistedSnapshot:({_subscription:r,...n})=>n,restoreSnapshot:r=>({...r,_subscription:void 0})}}function iOe(t){return{config:t,transition:(r,n,i)=>{if(r.status!=="active")return r;switch(n.type){case KZe:{let s=n.data;return{...r,status:"done",output:s,input:void 0}}case eOe:return{...r,status:"error",error:n.data,input:void 0};case _A:return kS.get(i.self)?.abort(),kS.delete(i.self),{...r,status:"stopped",input:void 0};default:return r}},start:(r,{self:n,system:i,emit:s})=>{if(r.status!=="active")return;let o=new AbortController;kS.set(n,o),Promise.resolve(t({input:r.input,system:i,self:n,signal:o.signal,emit:s})).then(c=>{n.getSnapshot().status==="active"&&(kS.delete(n),i._relay(n,n,{type:KZe,data:c}))},c=>{n.getSnapshot().status==="active"&&(kS.delete(n),i._relay(n,n,{type:eOe,data:c}))})},getInitialSnapshot:(r,n)=>({status:"active",output:void 0,error:void 0,input:n}),getPersistedSnapshot:r=>r,restoreSnapshot:r=>r}}function sOe(){return yo(_tr)}var rJ,XZe,Mk,Lk,KZe,eOe,kS,_tr,oOe=GA(()=>{"use strict";rp();rJ=new WeakMap;XZe="xstate.observable.next",Mk="xstate.observable.error",Lk="xstate.observable.complete";KZe="xstate.promise.resolve",eOe="xstate.promise.reject",kS=new WeakMap;_tr=nJ(t=>{},void 0)});function xtr(t,{machine:e,context:r},n,i){let s=(o,a)=>{if(typeof o=="string"){let c=QS(e,o);if(!c)throw new Error(`Actor logic '${o}' not implemented in machine '${e.id}'`);let u=yo(c,{id:a?.id,parent:t.self,syncSnapshot:a?.syncSnapshot,input:typeof a?.input=="function"?a.input({context:r,event:n,self:t.self}):a?.input,src:o,systemId:a?.systemId});return i[u.id]=u,u}else return yo(o,{id:a?.id,parent:t.self,syncSnapshot:a?.syncSnapshot,input:a?.input,src:o,systemId:a?.systemId})};return(o,a)=>{let c=s(o,a);return i[c.id]=c,t.defer(()=>{c._processingStatus!==es.Stopped&&c.start()}),c}}function Rtr(t,e,r,n,{assignment:i}){if(!e.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");let s={},o={context:e.context,event:r.event,spawn:xtr(t,e,r.event,s),self:t.self,system:t.system},a={};if(typeof i=="function")a=i(o,n);else for(let u of Object.keys(i)){let l=i[u];a[u]=typeof l=="function"?l(o,n):l}let c=Object.assign({},e.context,a);return[RA(e,{context:c,children:Object.keys(s).length?{...e.children,...s}:e.children}),void 0,void 0]}function DA(t){function e(r,n){}return e.type="xstate.assign",e.assignment=t,e.resolve=Rtr,e}var FS=GA(()=>{"use strict";rp()});function wI(t,e,r){let n=aOe.get(t);return n?e in n||(n[e]=r()):(n={[e]:r()},aOe.set(t,n)),n[e]}var aOe,Dtr,GS,_I,Qtr,xI,iJ=GA(()=>{"use strict";rp();FS();aOe=new WeakMap;Dtr={},GS=t=>typeof t=="string"?{type:t}:typeof t=="function"?"resolve"in t?{type:t.type}:{type:t.name}:t,_I=class t{constructor(e,r){if(this.config=e,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=r._parent,this.key=r._key,this.machine=r._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(Pq),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?zq(this.config.states,(n,i)=>new t(n,{_parent:this,_key:i,_machine:this.machine})):Dtr,this.type==="compound"&&!this.config.initial)throw new Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=this.config.history===!0?"shallow":this.config.history||!1,this.entry=tc(this.config.entry).slice(),this.exit=tc(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type==="final"||!this.parent?this.config.output:void 0,this.tags=tc(e.tags).slice()}_initialize(){this.transitions=MZe(this),this.config.always&&(this.always=$h(this.config.always).map(e=>Bd(this,Yq,e))),Object.keys(this.states).forEach(e=>{this.states[e]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(GS),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(e=>`#${e.id}`),source:`#${this.id}`,actions:this.initial.actions.map(GS),eventType:null})}:void 0,history:this.history,states:zq(this.states,e=>e.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(e=>({...e,actions:e.actions.map(GS)})),entry:this.entry.map(GS),exit:this.exit.map(GS),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return wI(this,"invoke",()=>tc(this.config.invoke).map((e,r)=>{let{src:n,systemId:i}=e,s=e.id??qq(this.id,r),o=typeof n=="string"?n:`xstate.invoke.${qq(this.id,r)}`;return{...e,src:o,id:s,systemId:i,toJSON(){let{onDone:a,onError:c,...u}=e;return{...u,type:"xstate.invoke",src:o,id:s}}}}))}get on(){return wI(this,"on",()=>[...this.transitions].flatMap(([r,n])=>n.map(i=>[r,i])).reduce((r,[n,i])=>(r[n]=r[n]||[],r[n].push(i),r),{}))}get after(){return wI(this,"delayedTransitions",()=>UZe(this))}get initial(){return wI(this,"initial",()=>WZe(this,this.config.initial))}next(e,r){let n=r.type,i=[],s,o=wI(this,`candidates-${n}`,()=>OZe(this,n));for(let a of o){let{guard:c}=a,u=e.context,l=!1;try{l=!c||Sd(c,u,r,e)}catch(d){let f=typeof c=="string"?c:typeof c=="object"?c.type:void 0;throw new Error(`Unable to evaluate guard ${f?`'${f}' `:""}in transition for event '${n}' in state node '${this.id}':
327
327
  ${d.message}`)}if(l){i.push(...a.actions),s=a;break}}return s?[s]:void 0}get events(){return wI(this,"events",()=>{let{states:e}=this,r=new Set(this.ownEvents);if(e)for(let n of Object.keys(e)){let i=e[n];if(i.states)for(let s of i.events)r.add(`${s}`)}return Array.from(r)})}get ownEvents(){let e=Object.keys(Object.fromEntries(this.transitions)),r=new Set(e.filter(n=>this.transitions.get(n).some(i=>!(!i.target&&!i.actions.length&&!i.reenter))));return Array.from(r)}},Qtr="#",xI=class t{constructor(e,r){this.config=e,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.options=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.id=e.id||"(machine)",this.implementations={actors:r?.actors??{},actions:r?.actions??{},delays:r?.delays??{},guards:r?.guards??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.options={maxIterations:1/0,...this.config.options},this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new _I(e,{_key:this.id,_machine:this}),this.root._initialize(),LZe(this.root),this.states=this.root.states,this.events=this.root.events}provide(e){let{actions:r,guards:n,actors:i,delays:s}=this.implementations;return new t(this.config,{actions:{...r,...e.actions},guards:{...n,...e.guards},actors:{...i,...e.actors},delays:{...s,...e.delays}})}resolveState(e){let r=zZe(this.root,e.value),n=NS(Kh(this.root,r));return TS({_nodes:[...n],context:e.context||{},children:{},status:Zk(n,this.root)?"done":e.status||"active",output:e.output,error:e.error,historyValue:e.historyValue},this)}transition(e,r,n){return ep(e,r,n,[]).snapshot}microstep(e,r,n){return ep(e,r,n,[]).microsteps.map(([i])=>i)}getTransitionData(e,r){return Ok(this.root,e.value,e,r)||[]}_getPreInitialState(e,r,n){let{context:i}=this.config,s=TS({context:typeof i!="function"&&i?i:{},_nodes:[this.root],children:{},status:"active"},this);return typeof i=="function"?zh(s,r,e,[DA(({spawn:a,event:c,self:u})=>i({spawn:a,input:c.input,self:u}))],n,void 0):s}getInitialSnapshot(e,r){let n=DS(r),i=[],s=this._getPreInitialState(e,n,i),[o]=Uk(this.root,s,e,n,i),{snapshot:a}=ep(o,n,e,i);return a}start(e){Object.values(e.children).forEach(r=>{r.getSnapshot().status==="active"&&r.start()})}getStateNodeById(e){let r=Fk(e),n=r.slice(1),i=SI(r[0])?r[0].slice(Qtr.length):r[0],s=this.idMap.get(i);if(!s)throw new Error(`Child state node '#${i}' does not exist on machine '${this.id}'`);return RS(s,n)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(e,r){return qZe(e,r)}restoreSnapshot(e,r){let n={},i=e.children;Object.keys(i).forEach(d=>{let f=i[d],A=f.snapshot,g=f.src,h=typeof g=="string"?QS(this,g):g;if(!h)return;let m=yo(h,{id:d,parent:r.self,syncSnapshot:f.syncSnapshot,snapshot:A,src:g,systemId:f.systemId});n[d]=m});function s(d,f){if(f instanceof _I)return f;try{return d.machine.getStateNodeById(f.id)}catch{}}function o(d,f){if(!f||typeof f!="object")return{};let A={};for(let g in f){let h=f[g];for(let m of h){let I=s(d,m);I&&(A[g]??=[],A[g].push(I))}}return A}let a=o(this.root,e.historyValue),c=TS({...e,children:n,_nodes:Array.from(NS(Kh(this.root,e.value))),historyValue:a},this),u=new Set;function l(d,f){if(!u.has(d)){u.add(d);for(let A in d){let g=d[A];if(g&&typeof g=="object"){if("xstate$$type"in g&&g.xstate$$type===Gk){d[A]=f[g.id];continue}l(g,f)}}}}return l(c.context,n),c}}});function Ntr(t,e,r,n,{event:i}){let s=typeof i=="function"?i(r,n):i;return[e,{event:s},void 0]}function Ttr(t,{event:e}){t.defer(()=>t.emit(e))}function OS(t){function e(r,n){}return e.type="xstate.emit",e.event=t,e.resolve=Ntr,e.execute=Ttr,e}function ktr(t,e,r,n,{to:i,event:s,id:o,delay:a},c){let u=e.machine.implementations.delays;if(typeof s=="string")throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${s}" }) instead`);let l=typeof s=="function"?s(r,n):s,d;if(typeof a=="string"){let g=u&&u[a];d=typeof g=="function"?g(r,n):g}else d=typeof a=="function"?a(r,n):a;let f=typeof i=="function"?i(r,n):i,A;if(typeof f=="string"){if(f===ZS.Parent?A=t.self._parent:f===ZS.Internal?A=t.self:f.startsWith("#_")?A=e.children[f.slice(2)]:A=c.deferredActorIds?.includes(f)?f:e.children[f],!A)throw new Error(`Unable to send event to actor '${f}' from machine '${e.machine.id}'.`)}else A=f||t.self;return[e,{to:A,targetId:typeof f=="string"?f:void 0,event:l,id:o,delay:d},void 0]}function Ftr(t,e,r){typeof r.to=="string"&&(r.to=e.children[r.to])}function Gtr(t,e){t.defer(()=>{let{to:r,event:n,delay:i,id:s}=e;if(typeof i=="number"){t.system.scheduler.schedule(t.self,r,n,i,s);return}t.system._relay(t.self,r,n.type===vZe?$q(t.self.id,n.data):n)})}function np(t,e,r){function n(i,s){}return n.type="xstate.sendTo",n.to=t,n.event=e,n.id=r?.id,n.delay=r?.delay,n.resolve=ktr,n.retryResolve=Ftr,n.execute=Gtr,n}function sJ(t,e){return np(ZS.Parent,t,e)}function cOe(t,e){return np(t,({event:r})=>r,e)}function Ztr(t,e,r,n,{collect:i}){let s=[],o=function(c){s.push(c)};return o.assign=(...a)=>{s.push(DA(...a))},o.cancel=(...a)=>{s.push(qh(...a))},o.raise=(...a)=>{s.push(tp(...a))},o.sendTo=(...a)=>{s.push(np(...a))},o.sendParent=(...a)=>{s.push(sJ(...a))},o.spawnChild=(...a)=>{s.push(Jh(...a))},o.stopChild=(...a)=>{s.push(vd(...a))},o.emit=(...a)=>{s.push(OS(...a))},i({context:r.context,event:r.event,enqueue:o,check:a=>Sd(a,e.context,r.event,e),self:t.self,system:t.system},n),[e,void 0,s]}function Wk(t){function e(r,n){}return e.type="xstate.enqueueActions",e.collect=t,e.resolve=Ztr,e}function Otr(t,e,r,n,{value:i,label:s}){return[e,{value:typeof i=="function"?i(r,n):i,label:s},void 0]}function Utr({logger:t},{value:e,label:r}){r?t(r,e):t(e)}function Vk(t=({context:r,event:n})=>({context:r,event:n}),e){function r(n,i){}return r.type="xstate.log",r.value=t,r.label=e,r.resolve=Otr,r.execute=Utr,r}var ZS,oJ=GA(()=>{"use strict";rp();FS();ZS=(function(t){return t.Parent="#_parent",t.Internal="#_internal",t})({})});var cJ={};X8(cJ,{Actor:()=>xS,SimulatedClock:()=>aJ,SpecialTargets:()=>ZS,StateMachine:()=>xI,StateNode:()=>_I,__unsafe_getAllOwnEventDescriptors:()=>xZe,and:()=>Kq,assertEvent:()=>Mtr,assign:()=>DA,cancel:()=>qh,createActor:()=>yo,createEmptyActor:()=>sOe,createMachine:()=>uOe,emit:()=>OS,enqueueActions:()=>Wk,forwardTo:()=>cOe,fromCallback:()=>tOe,fromEventObservable:()=>nOe,fromObservable:()=>rOe,fromPromise:()=>iOe,fromTransition:()=>nJ,getInitialMicrosteps:()=>jtr,getInitialSnapshot:()=>Wtr,getMicrosteps:()=>$tr,getNextSnapshot:()=>Vtr,getNextTransitions:()=>ztr,getStateNodes:()=>Kh,initialTransition:()=>Ytr,interpret:()=>RZe,isMachineSnapshot:()=>tJ,log:()=>Vk,mapState:()=>Ltr,matchesState:()=>kk,not:()=>TZe,or:()=>kZe,pathToStateValue:()=>jq,raise:()=>tp,sendParent:()=>sJ,sendTo:()=>np,setup:()=>lOe,spawnChild:()=>Jh,stateIn:()=>NZe,stop:()=>QZe,stopChild:()=>vd,toObserver:()=>bI,toPromise:()=>Htr,transition:()=>Ptr,waitFor:()=>Jtr});function Mtr(t,e){let r=tc(e);if(!r.some(i=>Jq(t.type,i))){let i=r.length===1?`type matching "${r[0]}"`:`one of types matching "${r.join('", "')}"`;throw new Error(`Expected event ${JSON.stringify(t)} to have ${i}`)}}function uOe(t,e){return new xI(t,e)}function Ltr(t,e){let r=[],n=(s,o)=>{let a=s;for(let c of o){if(!a?.states)return;let u=a.states;if(!(c in u))return;a=u[c]}return a},i=new Set;for(let s of t._nodes.filter(vI)){let o=s;for(;o&&!i.has(o);){i.add(o);let a=n(e,o.path);a?.map&&r.push({stateNode:o,result:a.map(t)}),o=o.parent}}return r}function RI(t){let e=yo(t),r=Xq(e,{clock:e.system._clock,logger:e.system._logger});return e.system=r,{self:e,defer:()=>{},id:"",logger:()=>{},sessionId:"",stopChild:()=>{},system:r,emit:()=>{},actionExecutor:()=>{}}}function Wtr(t,...[e]){let r=RI(t);return t.getInitialSnapshot(r,e)}function Vtr(t,e,r){let n=RI(t);return n.self._snapshot=e,t.transition(e,r,n)}function lOe({schemas:t,actors:e,actions:r,guards:n,delays:i}){return{assign:DA,sendTo:np,raise:tp,log:Vk,cancel:qh,stopChild:vd,enqueueActions:Wk,emit:OS,spawnChild:Jh,createStateConfig:s=>s,createAction:s=>s,createMachine:s=>uOe({...s,schemas:t},{actors:e,actions:r,guards:n,delays:i}),extend:s=>lOe({schemas:t,actors:e,actions:{...r,...s.actions},guards:{...n,...s.guards},delays:{...i,...s.delays}})}}function Htr(t){return new Promise((e,r)=>{t.subscribe({complete:()=>{e(t.getSnapshot().output)},error:r})})}function Ptr(t,e,r){let n=[],i=RI(t);return i.actionExecutor=o=>{n.push(o)},[t.transition(e,r,i),n]}function Ytr(t,...[e]){let r=[],n=RI(t);return n.actionExecutor=s=>{r.push(s)},[t.getInitialSnapshot(n,e),r]}function $tr(t,e,r){let n=RI(t),{microsteps:i}=ep(e,r,n,[]);return i}function jtr(t,...[e]){let r=RI(t),n=DS(e),i=[],s=t._getPreInitialState(r,n,i),o=Uk(t.root,s,r,n,i),{microsteps:a}=ep(o[0],n,r,i);return[o,...a]}function ztr(t){let e=[],r=t._nodes.filter(vI),n=new Set;for(let i of r)for(let s of[i].concat(Xh(i,void 0)))if(!n.has(s.id)){n.add(s.id);for(let[,o]of s.transitions)e.push(...o);s.always&&e.push(...s.always)}return e}function Jtr(t,e,r){let n={...qtr,...r};return new Promise((i,s)=>{let{signal:o}=n;if(o?.aborted){s(o.reason);return}let a=!1,c=n.timeout===1/0?void 0:setTimeout(()=>{u(),s(new Error(`Timeout of ${n.timeout} ms exceeded`))},n.timeout),u=()=>{clearTimeout(c),a=!0,f?.unsubscribe(),d&&o.removeEventListener("abort",d)};function l(A){e(A)&&(u(),i(A))}let d,f;l(t.getSnapshot()),!a&&(o&&(d=()=>{u(),s(o.reason)},o.addEventListener("abort",d)),f=t.subscribe({next:l,error:A=>{u(),s(A)},complete:()=>{u(),s(new Error("Actor terminated without satisfying predicate"))}}),a&&f.unsubscribe())})}var aJ,qtr,uJ=GA(()=>{"use strict";oOe();rp();rp();iJ();iJ();FS();FS();oJ();oJ();aJ=class{constructor(){this.timeouts=new Map,this._now=0,this._id=0,this._flushing=!1,this._flushingInvalidated=!1}now(){return this._now}getId(){return this._id++}setTimeout(e,r){this._flushingInvalidated=this._flushing;let n=this.getId();return this.timeouts.set(n,{start:this.now(),timeout:r,fn:e}),n}clearTimeout(e){this._flushingInvalidated=this._flushing,this.timeouts.delete(e)}set(e){if(this._now>e)throw new Error("Unable to travel back in time");this._now=e,this.flushTimeouts()}flushTimeouts(){if(this._flushing){this._flushingInvalidated=!0;return}this._flushing=!0;let e=[...this.timeouts].sort(([r,n],[i,s])=>{let o=n.start+n.timeout;return s.start+s.timeout>o?-1:1});for(let[r,n]of e){if(this._flushingInvalidated){this._flushingInvalidated=!1,this._flushing=!1,this.flushTimeouts();return}this.now()-n.start>=n.timeout&&(this.timeouts.delete(r),n.fn.call(null))}this._flushing=!1}increment(e){this._now+=e,this.flushTimeouts()}};qtr={timeout:1/0}});var lJ=p(Hk=>{"use strict";Object.defineProperty(Hk,"__esModule",{value:!0});Hk.missingVariable=void 0;var Xtr=t=>`Missing variable: '${t}'. You can provide it using the 'TF_VAR_${t}' environment variable.`;Hk.missingVariable=Xtr});var dJ=p(MS=>{"use strict";var Ktr=MS&&MS.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(MS,"__esModule",{value:!0});MS.spawnInteractive=rrr;var err=eV(),US=tt(),trr=Ktr(require("os"));function rrr(t,e){var r,n;let{args:i,options:s}=t,o=t.file;s.stdio="pipe",US.logger.trace(`Spawning process with file=${o}, args=${Array.isArray(i)?`[${i.join(", ")}]`:`"${i}"`}, options=${JSON.stringify(s)}`);let a=(0,err.spawn)(o,i,s),c={write:l=>{var d;US.logger.trace(`Sending response to process (file=${o}, args=${Array.isArray(i)?`[${i.join(", ")}]`:`"${i}"`}): ${l}`),(d=a.stdin)===null||d===void 0||d.write(l)},writeLine:l=>{var d;US.logger.trace(`Sending response (with newline) to process (file=${o}, args=${Array.isArray(i)?`[${i.join(", ")}]`:`"${i}"`}): ${l}`),(d=a.stdin)===null||d===void 0||d.write(`${l}${trr.default.EOL}`)},stop:()=>{US.logger.trace(`Aborting process (file=${o}, args=${Array.isArray(i)?`[${i.join(", ")}]`:`"${i}"`})`),a.kill()}};(r=a.stdout)===null||r===void 0||r.on("data",l=>{e(l.toLocaleString())}),(n=a.stderr)===null||n===void 0||n.on("data",l=>{e(l.toLocaleString())});let u=new Promise(l=>{a.once("close",d=>{d!==0&&US.logger.debug(`Process (file=${o}, args=${Array.isArray(i)?`[${i.join(", ")}]`:`"${i}"`}) exited with code ${u}`),l(d)})});return{exitCode:u,actions:c}}});var yOe=p(Rn=>{"use strict";var nrr=Rn&&Rn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Rn,"__esModule",{value:!0});Rn.deployMachine=Rn.terraformPtyService=void 0;Rn.isDeployEvent=orr;Rn.isMissingVariablePrompt=gOe;Rn.extractVariableNameFromPrompt=hOe;Rn.bufferUnterminatedLines=pOe;Rn.handleLineReceived=mOe;Rn.makeTerraformPtyService=IOe;Rn.createAndStartDeployService=arr;Rn.createAndStartDestroyService=crr;var ni=(uJ(),xG(cJ)),DI=tt(),irr=lJ(),fOe=nrr(Df()),dOe=require("os"),srr=dJ();function orr(t,e){return t.type===e}var AOe=/^\s*var\.([A-Za-z_][A-Za-z0-9_-]*)\s*$/;function gOe(t){return t.split(`
328
328
  `).some(e=>AOe.test(e))}function hOe(t){let n=(0,fOe.default)(t).split(`
329
- `).map(i=>i.match(AOe)).find(i=>i!==null);if(!n)throw DI.Errors.Internal(`Could not find variable name in prompt: ${t}. This is most likely a bug in cdktn. Please report it at http://cdktn.io/issues`);return n[1]}function pOe(t){let e="";function r(n){e+=n;let i=e.split(/[\n\r]+/);e=i.pop()||"",i.length>0&&t(i.join(dOe.EOL)+dOe.EOL)}return r.getBuffer=()=>e,r}function mOe(t){return e=>{let r=!1,n=(0,fOe.default)(e);if(n.includes("approved using the UI or API"))t({type:"APPROVED_EXTERNALLY"});else if(n.includes("discarded using the UI or API"))t({type:"REJECTED_EXTERNALLY"});else if(n.includes("Do you want to perform these actions")||n.includes("Do you really want to destroy all resources?")||n.includes("Do you really want to destroy all resources in workspace"))r=!0,t({type:"OUTPUT_RECEIVED",output:e}),t({type:"REQUEST_APPROVAL"});else if(gOe(n)){r=!0;let i=hOe(e);t({type:"OUTPUT_RECEIVED",output:(0,irr.missingVariable)(i)}),t({type:"VARIABLE_MISSING",variableName:i})}else n.includes("Enter a value:")?r=!0:n.includes("Do you want to override the soft failed policy check?")?(r=!0,t({type:"OUTPUT_RECEIVED",output:e}),t({type:"REQUEST_SENTINEL_OVERRIDE"})):n.includes("overridden using the UI or API")&&t({type:"OVERRIDDEN_EXTERNALLY"});r||t({type:"OUTPUT_RECEIVED",output:e})}}function IOe(t=srr.spawnInteractive){return(0,ni.fromCallback)(({sendBack:e,receive:r,input:n})=>{let{pty:i}=n,s=pOe(mOe(e)),{exitCode:o,actions:a}=t(i,c=>{s(c)});return r(c=>{c.type==="SEND_LINE"&&a.writeLine(c.input)}),o.then(c=>{let u=s.getBuffer();u.length>0&&DI.logger.debug(`Terraform CLI exited but the last outputted line was not terminated with a newline and hence is still in the buffer and wasn't printed: "${u}"`),e({type:"EXITED",exitCode:c})}),()=>{DI.logger.trace("Terraform CLI state machine: cleaning up pty"),a.stop()}})}Rn.terraformPtyService=IOe();Rn.deployMachine=(0,ni.setup)({types:{context:{},events:{},output:{}},actors:{runTerraformInPty:Rn.terraformPtyService}}).createMachine({context:{},initial:"idle",id:"root",states:{idle:{on:{START:{target:"running"}}},running:{invoke:{id:"pty",src:"runTerraformInPty",input:({event:t})=>{if(t.type!=="START")throw DI.Errors.Internal(`Terraform CLI invocation state machine: Unexpected event caused transition to the running state: ${t.type}`);return{pty:t.pty}}},on:{EXITED:{target:"exited",actions:(0,ni.assign)(({event:t})=>({exitCode:t.exitCode}))},STOP:".stopping"},initial:"processing",states:{processing:{on:{REQUEST_APPROVAL:"awaiting_approval",REQUEST_SENTINEL_OVERRIDE:"awaiting_sentinel_override",VARIABLE_MISSING:{actions:(0,ni.sendTo)(({self:t})=>t,{type:"EXITED",exitCode:1})}}},awaiting_approval:{on:{APPROVED_EXTERNALLY:"processing",REJECTED_EXTERNALLY:{target:"#root.exited",actions:(0,ni.assign)({cancelled:!0})},APPROVE:{target:"processing",actions:(0,ni.sendTo)("pty",{type:"SEND_LINE",input:"yes"})},REJECT:{target:"processing",actions:[(0,ni.sendTo)("pty",{type:"SEND_LINE",input:"no"}),(0,ni.assign)({cancelled:!0})]}}},awaiting_sentinel_override:{on:{OVERRIDDEN_EXTERNALLY:"processing",OVERRIDE_REJECTED_EXTERNALLY:{target:"#root.exited",actions:(0,ni.assign)({cancelled:!0})},REJECTED_EXTERNALLY:{actions:(0,ni.sendTo)(({self:t})=>t,{type:"OVERRIDE_REJECTED_EXTERNALLY"})},OVERRIDE:{target:"processing",actions:(0,ni.sendTo)("pty",{type:"SEND_LINE",input:"override"})},REJECT_OVERRIDE:{target:"processing",actions:[(0,ni.sendTo)("pty",{type:"SEND_LINE",input:"no"}),(0,ni.assign)({cancelled:!0})]}}},stopping:{entry:(0,ni.assign)({cancelled:!0}),on:{EXITED:{target:"#root.stopped",actions:(0,ni.assign)(({event:t})=>({exitCode:t.exitCode}))}}}}},exited:{type:"final"},stopped:{type:"final"}},output:({context:t})=>({exitCode:t.exitCode})});function arr(t,e){var r,n;let i=(0,ni.createActor)(Rn.deployMachine,{inspect:e}),s=["apply",...t.autoApprove?["-auto-approve"]:[],...t.extraOptions,...t.refreshOnly?["-refresh-only"]:[],...t.noColor?["-no-color"]:[],...t.parallelism>-1?[`-parallelism=${t.parallelism}`]:[]];(r=t.vars)===null||r===void 0||r.forEach(a=>{s.push(`-var=${a}`)}),(n=t.varFiles)===null||n===void 0||n.forEach(a=>{s.push(`-var-file=${a}`)}),DI.logger.debug(`Executing ${t.terraformBinaryName} ${s.join(" ")} in ${t.workdir}`);let o={file:t.terraformBinaryName,args:s,options:{cwd:t.workdir,env:process.env}};return i.start(),i.send({type:"START",pty:o}),i}function crr(t,e){var r,n;let i=(0,ni.createActor)(Rn.deployMachine,{inspect:e}),s=["destroy",...t.autoApprove?["-auto-approve"]:[],...t.extraOptions,...t.noColor?["-no-color"]:[],...t.parallelism>-1?[`-parallelism=${t.parallelism}`]:[]];(r=t.vars)===null||r===void 0||r.forEach(a=>{s.push(`-var=${a}`)}),(n=t.varFiles)===null||n===void 0||n.forEach(a=>{s.push(`-var-file=${a}`)}),DI.logger.debug(`Executing ${t.terraformBinaryName} ${s.join(" ")} in ${t.workdir}`);let o={file:t.terraformBinaryName,args:s,options:{cwd:t.workdir,env:process.env}};return i.start(),i.send({type:"START",pty:o}),i}});var fJ=p(gl=>{"use strict";var urr=gl&&gl.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),lrr=gl&&gl.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),drr=gl&&gl.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&urr(r,e,n[i]);return lrr(r,e),r}})();Object.defineProperty(gl,"__esModule",{value:!0});gl.terraformJsonSchema=void 0;var pt=drr(mI()),frr=pt.object({organization:pt.string(),hostname:pt.string().optional(),token:pt.string().optional(),workspaces:pt.object({name:pt.string().optional(),prefix:pt.string().optional()}).partial()}).partial();gl.terraformJsonSchema=pt.object({"//":pt.object({metadata:pt.object({version:pt.string(),stackName:pt.string(),backend:pt.string()}).partial().loose(),outputs:pt.record(pt.string(),pt.any())}).partial().loose(),terraform:pt.object({backend:pt.object({remote:frr}).partial().loose(),cloud:pt.object({organization:pt.string(),hostname:pt.string().optional(),token:pt.string().optional(),workspaces:pt.union([pt.object({name:pt.string()}),pt.object({tags:pt.array(pt.string())})])}).partial().loose(),required_providers:pt.record(pt.string(),pt.object({source:pt.string(),version:pt.string()}).loose()),required_version:pt.string()}).partial(),data:pt.record(pt.string(),pt.any()),provider:pt.record(pt.string(),pt.any()),resource:pt.record(pt.string(),pt.any())}).partial().loose()});var mJ=p(vi=>{"use strict";var Arr=vi&&vi.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),grr=vi&&vi.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),hrr=vi&&vi.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&Arr(r,e,n[i]);return grr(r,e),r}})(),bOe=vi&&vi.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(vi,"__esModule",{value:!0});vi.TerraformCli=vi.TerraformCliPlan=void 0;vi.tryReadGeneratedConfigurationFile=brr;vi.tryRemoveGeneratedConfigurationFile=Err;var prr=bOe(Df()),On=tt(),mrr=Nk(),ip=yOe(),Irr=(uJ(),xG(cJ)),yrr=lJ(),COe=fJ(),Crr=dJ(),pJ=bOe(require("path")),QI=hrr(Cr()),Pk="generated_resources.tf",AJ=class extends mrr.AbstractTerraformPlan{constructor(e,r){super(e,r?.resource_changes,r?.output_changes),this.planFile=e,this.plan=r}};vi.TerraformCliPlan=AJ;var gJ=class{},Yk=class extends gJ{static condition(e){let r=(0,prr.default)(e);return r.includes("Error: No value for required variable")&&r.includes("The root module input variable")}static transform(e){let r='The root module input variable "',n=e.substring(e.indexOf(r)+r.length,e.indexOf('" is not set'));return(0,yrr.missingVariable)(n)}},hJ=class{constructor(e,r,n=(i,s)=>(o,a=!1)=>{}){this.abortSignal=e,this.stack=r,this.workdir=r.workingDirectory,this.onStdout=(i,s)=>o=>n(i,s)(Buffer.isBuffer(o)?o.toString():o),this.onStderr=(i,s)=>o=>n(i,s)(o.toString(),!0)}async init(e){await this.setUserAgent();let r=["init"];e.needsUpgrade&&r.push("-upgrade"),e.noColor&&r.push("-no-color"),e.migrateState&&r.push("-migrate-state");let n=u=>{},i=new Promise((u,l)=>{n=l}),s=this.onStdout("init"),{actions:o,exitCode:a}=(0,Crr.spawnInteractive)({file:On.terraformBinaryName,args:r,options:{cwd:this.workdir,env:process.env}},u=>{s(u),(u.includes("Should Terraform migrate your existing state?")||u.includes("Do you want to copy existing state to the new backend"))&&(e.migrateState?o.writeLine("yes"):(o.stop(),n("Please pass the --migrate-state flag to migrate your state")))});this.abortSignal.addEventListener("abort",()=>{o.stop()});let c=a.then(u=>{if(u!==0)throw new Error(`terraform init failed with exit code ${u}`)});await Promise.race([c,i]),e.needsLockfileUpdate&&await(0,On.exec)(On.terraformBinaryName,["providers","lock","-platform=linux_amd64",...e.noColor?["-no-color"]:[]],{cwd:this.workdir,env:process.env,signal:this.abortSignal,noColor:e.noColor},this.onStdout("init"),this.onStderr("init"))}get isCloudStack(){var e,r,n;let i=COe.terraformJsonSchema.parse(JSON.parse(this.stack.content));return!!(!((r=(e=i.terraform)===null||e===void 0?void 0:e.backend)===null||r===void 0)&&r.remote||!((n=i.terraform)===null||n===void 0)&&n.cloud)}get hasImports(){return!!COe.terraformJsonSchema.parse(JSON.parse(this.stack.content)).import}async plan(e){let{destroy:r=!1,refreshOnly:n=!1,parallelism:i=-1,vars:s=[],varFiles:o=[],noColor:a=!1}=e,c=["plan","-input=false"],u=pJ.default.join(this.workdir,Pk);QI.existsSync(u)&&QI.remove(u),this.hasImports&&c.push(`-generate-config-out=${Pk}`),this.isCloudStack||c.push("-out","plan"),r&&c.push("-destroy"),n&&c.push("-refresh-only"),i>-1&&c.push(`-parallelism=${i}`),a&&c.push("-no-color"),s.forEach(l=>c.push(`-var=${l}`)),o.forEach(l=>c.push(`-var-file=${l}`)),On.logger.debug(`Executing ${On.terraformBinaryName} ${c.join(" ")} in ${this.workdir}`),await this.setUserAgent(),await(0,On.exec)(On.terraformBinaryName,c,{cwd:this.workdir,env:process.env,signal:this.abortSignal,noColor:a},this.onStdout("plan",[Yk]),this.onStderr("plan",[Yk]))}async deploy({autoApprove:e=!1,refreshOnly:r=!1,noColor:n=!1,parallelism:i=-1,extraOptions:s=[],vars:o=[],varFiles:a=[]},c){return await this.setUserAgent(),this.handleService("deploy",c,u=>(0,ip.createAndStartDeployService)({terraformBinaryName:On.terraformBinaryName,workdir:this.workdir,refreshOnly:r,noColor:n,autoApprove:e,parallelism:i,extraOptions:s,vars:o,varFiles:a},u))}async destroy({autoApprove:e=!1,parallelism:r=-1,noColor:n=!1,extraOptions:i=[],vars:s=[],varFiles:o=[]},a){return await this.setUserAgent(),this.handleService("destroy",a,c=>(0,ip.createAndStartDestroyService)({terraformBinaryName:On.terraformBinaryName,workdir:this.workdir,autoApprove:e,parallelism:r,noColor:n,extraOptions:i,vars:s,varFiles:o},c))}async handleService(e,r,n){var i;let o=n(d=>{if(d.type!=="@xstate.event"||d.actorRef.sessionId!==d.rootId)return;let f=d.event;On.logger.trace(`Terraform CLI state machine event: ${JSON.stringify(f)}`),(0,ip.isDeployEvent)(f,"OUTPUT_RECEIVED")?this.onStdout(e)(f.output):(0,ip.isDeployEvent)(f,"APPROVED_EXTERNALLY")?r({type:"external approval reply",approved:!0}):(0,ip.isDeployEvent)(f,"REJECTED_EXTERNALLY")?r({type:"external approval reply",approved:!1}):(0,ip.isDeployEvent)(f,"OVERRIDDEN_EXTERNALLY")?r({type:"external sentinel override reply",overridden:!0}):(0,ip.isDeployEvent)(f,"OVERRIDE_REJECTED_EXTERNALLY")&&r({type:"external sentinel override reply",overridden:!1})}),a="idle",c=d=>{d.matches(a)||(On.logger.trace(`Terraform CLI state machine state transition: ${JSON.stringify(a)} => ${JSON.stringify(d.value)}`),d.matches({running:"awaiting_approval"})?r({type:"waiting for approval",approve:()=>o.send({type:"APPROVE"}),reject:()=>o.send({type:"REJECT"})}):d.matches({running:"awaiting_sentinel_override"})?r({type:"waiting for sentinel override",override:()=>o.send({type:"OVERRIDE"}),reject:()=>o.send({type:"REJECT_OVERRIDE"})}):d.matches({running:"processing"})&&r({type:"running",cancelled:!!d.context.cancelled}),a=d.value)};o.subscribe(c),c(o.getSnapshot()),this.abortSignal.addEventListener("abort",()=>{o.send({type:"STOP"})},{once:!0});let u=await(0,Irr.waitFor)(o,d=>d.status==="done",{timeout:1/0}),l=(i=u.output)===null||i===void 0?void 0:i.exitCode;if(On.logger.trace(`Invoking Terraform CLI for ${e} done (state machine reached final state). Last exit code: ${JSON.stringify(l)}. Context: ${JSON.stringify(u.context)}`),l!==void 0&&l!==0&&!u.context.cancelled)throw`Invoking Terraform CLI failed with exit code ${l}`;return{cancelled:!!u.context.cancelled}}async version(){try{return await(0,On.exec)(On.terraformBinaryName,["-v"],{cwd:this.workdir,env:process.env,signal:this.abortSignal,noColor:!0},this.onStdout("version"),this.onStderr("version"))}catch{throw new Error("Terraform CLI not present - Please install a current version https://learn.hashicorp.com/terraform/getting-started/install.html")}}async output(){let e=await(0,On.exec)(On.terraformBinaryName,["output","-json"],{cwd:this.workdir,env:process.env,signal:this.abortSignal,noColor:!0},()=>{},this.onStderr("output"));try{return JSON.parse(e)}catch(r){throw On.Errors.External(`Failed to parse terraform output: ${r}. The output was '${e}'`)}}async setUserAgent(){let e=await(0,On.readCDKTFVersion)(this.workdir);e!=""&&(process.env.TF_APPEND_USER_AGENT="cdktn/"+e+" (+https://github.com/open-constructs/cdk-terrain)")}async abort(){}};vi.TerraformCli=hJ;async function brr(t){let e=pJ.default.join(t,Pk);return QI.existsSync(e)?QI.readFileSync(e,"utf-8"):null}async function Err(t){let e=pJ.default.join(t,Pk);QI.existsSync(e)&&QI.unlinkSync(e)}});var vOe=p(Os=>{"use strict";var Brr=Os&&Os.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),vrr=Os&&Os.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),CJ=Os&&Os.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&Brr(r,e,n[i]);return vrr(r,e),r}})(),Srr=Os&&Os.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Os,"__esModule",{value:!0});Os.shouldReportCrash=bJ;Os.persistReportCrashReportDecision=BOe;Os.initializErrorReporting=_rr;Os.captureException=xrr;var jk=CJ(vR()),$k=tt(),zk=tt(),IJ=CJ(require("path")),yJ=CJ(Cr()),EOe=Srr(n_());function bJ(t=process.cwd()){try{let e=JSON.parse(yJ.readFileSync(IJ.resolve(t,"cdktf.json"),"utf8"));return typeof e.sendCrashReports=="boolean"?e.sendCrashReports:e.sendCrashReports==="true"}catch(e){return zk.logger.debug(`Error determining if crash reporting should be enabled, defaulting to false: ${e}`),!1}}function BOe(t,e=process.cwd()){let r=JSON.parse(yJ.readFileSync(IJ.resolve(e,"cdktf.json"),"utf8"));r.sendCrashReports=t,yJ.writeFileSync(IJ.resolve(e,"cdktf.json"),JSON.stringify(r,null,2))}function wrr(t){return typeof t=="object"&&typeof t.then=="function"&&typeof t.catch=="function"}async function _rr(t){let e=bJ(),r=EOe.default.isCI?EOe.default.name||"unknown":!1;if(e===void 0&&t){if(r)return;e=await t(),BOe(e)}if(!e){zk.logger.debug("Error reporting disabled");return}zk.logger.debug("Initializing error reporting"),jk.init({autoSessionTracking:!0,dsn:"https://5a76d29d61ea79fd3ee038f276a6be21@o4510735861743616.ingest.de.sentry.io/4510735863840848",release:`cdktn-cli-${$k.DISPLAY_VERSION}`,async beforeSend(n,i){if(!i)return n;let s=i.originalException,o;return wrr(s)?(s.catch(c=>o=c),await Promise.allSettled([s])):o=s,(o?.toString()||"").includes("Usage Error")?null:n}}),jk.configureScope(function(n){n.setUser({id:(0,$k.getUserId)()}),n.setTag("projectId",(0,$k.getProjectId)())}),zk.logger.debug("Collecting environment information for error reporting"),(0,$k.collectDebugInformation)().then(n=>{jk.setContext("environment",n)})}function xrr({message:t,type:e,command:r,context:n}){bJ()&&jk.captureException(new Error(t),{tags:{context:JSON.stringify(n),type:e,command:r}})}});var wOe=p(hl=>{"use strict";var Rrr=hl&&hl.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),Drr=hl&&hl.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),Qrr=hl&&hl.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&Rrr(r,e,n[i]);return Drr(r,e),r}})();Object.defineProperty(hl,"__esModule",{value:!0});hl.schema=void 0;var Te=Qrr(mI()),rc=Te.object({addr:Te.string(),module:Te.string(),resource:Te.string(),implied_provider:Te.string(),resource_type:Te.string(),resource_name:Te.string(),resource_key:Te.string().optional().nullable()}),ts=Te.object({"@level":Te.enum(["info","error","warn"]),"@message":Te.string(),"@module":Te.string(),"@timestamp":Te.string()}).loose(),LS=Te.enum(["noop","create","read","update","delete"]),SOe=Te.object({resource:rc,action:LS}),Nrr=SOe.extend({action:Te.literal("replace"),reason:Te.enum(["tainted","requested","cannot_update"])}),Trr=ts.extend({type:Te.literal("planned_change"),change:Te.union([Nrr,SOe])}),krr=ts.extend({type:Te.literal("version")}),Frr=ts.extend({type:Te.literal("change_summary"),changes:Te.object({add:Te.number(),change:Te.number(),remove:Te.number(),operation:Te.enum(["plan","apply","deploy"])})}),Grr=ts.extend({type:Te.literal("outputs"),outputs:Te.record(Te.string(),Te.object({sensitive:Te.boolean(),type:Te.string(),value:Te.string()}))}),Zrr=ts.extend({type:Te.literal("apply_start"),hook:Te.object({resource:rc,action:LS,id_key:Te.string().optional(),id_value:Te.string().optional()})}),Orr=ts.extend({type:Te.literal("apply_progress"),hook:Te.object({resource:rc,action:LS,elapsed_seconds:Te.number()})}),Urr=ts.extend({type:Te.literal("apply_complete"),hook:Te.object({resource:rc,action:LS,id_key:Te.string().optional(),id_value:Te.string().optional(),elapsed_seconds:Te.number()})}),Mrr=ts.extend({type:Te.literal("apply_errored"),hook:Te.object({resource:rc,action:LS,elapsed_seconds:Te.number()})}),Lrr=ts.extend({type:Te.literal("provision_start"),hook:Te.object({resource:rc,provisioner:Te.string()})}),Wrr=ts.extend({type:Te.literal("provision_progress"),hook:Te.object({resource:rc,provisioner:Te.string(),output:Te.string()})}),Vrr=ts.extend({type:Te.literal("provision_complete"),hook:Te.object({resource:rc,provisioner:Te.string()})}),Hrr=ts.extend({type:Te.literal("provision_errored"),hook:Te.object({resource:rc,provisioner:Te.string()})}),Prr=ts.extend({type:Te.literal("refresh_start"),hook:Te.object({resource:rc,id_key:Te.string().optional(),id_value:Te.string().optional()})}),Yrr=ts.extend({type:Te.literal("refresh_complete"),hook:Te.object({resource:rc,id_key:Te.string().optional(),id_value:Te.string().optional()})}),$rr=ts.extend({type:Te.literal("log")});hl.schema=Te.union([krr,Trr,Frr,Grr,Zrr,Orr,Urr,Mrr,Lrr,Wrr,Vrr,Hrr,Prr,Yrr,$rr])});var BJ=p(Si=>{"use strict";var jrr=Si&&Si.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),zrr=Si&&Si.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),EJ=Si&&Si.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&jrr(r,e,n[i]);return zrr(r,e),r}})(),qrr=Si&&Si.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Si,"__esModule",{value:!0});Si.getConstructIdsForOutputs=Si.parseOutput=void 0;Si.saveOutputs=tnr;Si.normalizeOutputPath=rnr;var Jrr=EJ(mI()),Xrr=EJ(require("fs")),_Oe=EJ(require("path")),Krr=qrr(Df()),xOe=tt(),enr=wOe(),Co=Nk();function DOe(t,e){return Object.entries(t).reduce((r,[n,i])=>({...r,[n]:(0,Co.isTerraformOutput)(i)?!i.sensitive||e?i.value:void 0:DOe(i,e)}),{})}async function tnr(t,e,r){Xrr.writeFileSync(t,JSON.stringify(DOe(e,r),null,2))}function rnr(t){return _Oe.isAbsolute(t)?t:_Oe.join(process.cwd(),t)}var ROe=(t,e)=>{switch(t){case"create":case"update":return e?Co.DeployingResourceApplyState.CREATED:Co.DeployingResourceApplyState.CREATING;case"delete":return e?Co.DeployingResourceApplyState.DESTROYED:Co.DeployingResourceApplyState.DESTROYING;default:return Co.DeployingResourceApplyState.WAITING}},nnr=t=>{let e,r;try{e=JSON.parse(t)}catch{xOe.logger.trace(`Could not parse line as JSON: ${t}`);return}try{r=enr.schema.parse(e)}catch(n){n instanceof Jrr.ZodError&&xOe.logger.trace(`Error parsing line into schema: ${JSON.stringify(n.issues)} => ${t}`);return}switch(r.type){case"apply_start":case"apply_progress":return{id:r.hook.resource.resource,applyState:ROe(r.hook.action,!1)};case"apply_complete":return{id:r.hook.resource.resource,applyState:ROe(r.hook.action,!0)};default:return}},inr=t=>{if(/^Outputs:/.test(t)||/^Plan:/.test(t)||/^data\..*/.test(t))return;let e=t.match(/^([a-zA-Z_][a-zA-Z\d_\-.]*):/),r;switch(!0){case/Creating.../.test(t):case/Still creating.../.test(t):r=Co.DeployingResourceApplyState.CREATING;break;case/Creation complete/.test(t):r=Co.DeployingResourceApplyState.CREATED;break;case/Modifying.../.test(t):r=Co.DeployingResourceApplyState.UPDATING;break;case/Modifications complete/.test(t):r=Co.DeployingResourceApplyState.UPDATED;break;case/Destroying.../.test(t):case/Still destroying.../.test(t):r=Co.DeployingResourceApplyState.DESTROYING;break;case/Destruction complete/.test(t):r=Co.DeployingResourceApplyState.DESTROYED;break;default:return}if(e&&e.length>=0&&e[1]!="Warning")return{id:e[1],applyState:r}},snr=t=>(0,Krr.default)(t.toString()).split(`
329
+ `).map(i=>i.match(AOe)).find(i=>i!==null);if(!n)throw DI.Errors.Internal(`Could not find variable name in prompt: ${t}. This is most likely a bug in cdktn. Please report it at http://cdktn.io/issues`);return n[1]}function pOe(t){let e="";function r(n){e+=n;let i=e.split(/[\n\r]+/);e=i.pop()||"",i.length>0&&t(i.join(dOe.EOL)+dOe.EOL)}return r.getBuffer=()=>e,r}function mOe(t){return e=>{let r=!1,n=(0,fOe.default)(e);if(n.includes("approved using the UI or API"))t({type:"APPROVED_EXTERNALLY"});else if(n.includes("discarded using the UI or API"))t({type:"REJECTED_EXTERNALLY"});else if(n.includes("Do you want to perform these actions")||n.includes("Do you really want to destroy all resources?")||n.includes("Do you really want to destroy all resources in workspace"))r=!0,t({type:"OUTPUT_RECEIVED",output:e}),t({type:"REQUEST_APPROVAL"});else if(gOe(n)){r=!0;let i=hOe(e);t({type:"OUTPUT_RECEIVED",output:(0,irr.missingVariable)(i)}),t({type:"VARIABLE_MISSING",variableName:i})}else n.includes("Enter a value:")?r=!0:n.includes("Do you want to override the soft failed policy check?")?(r=!0,t({type:"OUTPUT_RECEIVED",output:e}),t({type:"REQUEST_SENTINEL_OVERRIDE"})):n.includes("overridden using the UI or API")&&t({type:"OVERRIDDEN_EXTERNALLY"});r||t({type:"OUTPUT_RECEIVED",output:e})}}function IOe(t=srr.spawnInteractive){return(0,ni.fromCallback)(({sendBack:e,receive:r,input:n})=>{let{pty:i}=n,s=pOe(mOe(e)),{exitCode:o,actions:a}=t(i,c=>{s(c)});return r(c=>{c.type==="SEND_LINE"&&a.writeLine(c.input)}),o.then(c=>{let u=s.getBuffer();u.length>0&&DI.logger.debug(`Terraform CLI exited but the last outputted line was not terminated with a newline and hence is still in the buffer and wasn't printed: "${u}"`),e({type:"EXITED",exitCode:c})}),()=>{DI.logger.trace("Terraform CLI state machine: cleaning up pty"),a.stop()}})}Rn.terraformPtyService=IOe();Rn.deployMachine=(0,ni.setup)({types:{context:{},events:{},output:{}},actors:{runTerraformInPty:Rn.terraformPtyService}}).createMachine({context:{},initial:"idle",id:"root",states:{idle:{on:{START:{target:"running"}}},running:{invoke:{id:"pty",src:"runTerraformInPty",input:({event:t})=>{if(t.type!=="START")throw DI.Errors.Internal(`Terraform CLI invocation state machine: Unexpected event caused transition to the running state: ${t.type}`);return{pty:t.pty}}},on:{EXITED:{target:"exited",actions:(0,ni.assign)(({event:t})=>({exitCode:t.exitCode}))},STOP:".stopping"},initial:"processing",states:{processing:{on:{REQUEST_APPROVAL:"awaiting_approval",REQUEST_SENTINEL_OVERRIDE:"awaiting_sentinel_override",VARIABLE_MISSING:{actions:(0,ni.sendTo)(({self:t})=>t,{type:"EXITED",exitCode:1})}}},awaiting_approval:{on:{APPROVED_EXTERNALLY:"processing",REJECTED_EXTERNALLY:{target:"#root.exited",actions:(0,ni.assign)({cancelled:!0})},APPROVE:{target:"processing",actions:(0,ni.sendTo)("pty",{type:"SEND_LINE",input:"yes"})},REJECT:{target:"processing",actions:[(0,ni.sendTo)("pty",{type:"SEND_LINE",input:"no"}),(0,ni.assign)({cancelled:!0})]}}},awaiting_sentinel_override:{on:{OVERRIDDEN_EXTERNALLY:"processing",OVERRIDE_REJECTED_EXTERNALLY:{target:"#root.exited",actions:(0,ni.assign)({cancelled:!0})},REJECTED_EXTERNALLY:{actions:(0,ni.sendTo)(({self:t})=>t,{type:"OVERRIDE_REJECTED_EXTERNALLY"})},OVERRIDE:{target:"processing",actions:(0,ni.sendTo)("pty",{type:"SEND_LINE",input:"override"})},REJECT_OVERRIDE:{target:"processing",actions:[(0,ni.sendTo)("pty",{type:"SEND_LINE",input:"no"}),(0,ni.assign)({cancelled:!0})]}}},stopping:{entry:(0,ni.assign)({cancelled:!0}),on:{EXITED:{target:"#root.stopped",actions:(0,ni.assign)(({event:t})=>({exitCode:t.exitCode}))}}}}},exited:{type:"final"},stopped:{type:"final"}},output:({context:t})=>({exitCode:t.exitCode})});function arr(t,e){var r,n;let i=(0,ni.createActor)(Rn.deployMachine,{inspect:e}),s=["apply",...t.autoApprove?["-auto-approve"]:[],...t.extraOptions,...t.refreshOnly?["-refresh-only"]:[],...t.noColor?["-no-color"]:[],...t.parallelism>-1?[`-parallelism=${t.parallelism}`]:[]];(r=t.vars)===null||r===void 0||r.forEach(a=>{s.push(`-var=${a}`)}),(n=t.varFiles)===null||n===void 0||n.forEach(a=>{s.push(`-var-file=${a}`)}),DI.logger.debug(`Executing ${t.terraformBinaryName} ${s.join(" ")} in ${t.workdir}`);let o={file:t.terraformBinaryName,args:s,options:{cwd:t.workdir,env:process.env}};return i.start(),i.send({type:"START",pty:o}),i}function crr(t,e){var r,n;let i=(0,ni.createActor)(Rn.deployMachine,{inspect:e}),s=["destroy",...t.autoApprove?["-auto-approve"]:[],...t.extraOptions,...t.noColor?["-no-color"]:[],...t.parallelism>-1?[`-parallelism=${t.parallelism}`]:[]];(r=t.vars)===null||r===void 0||r.forEach(a=>{s.push(`-var=${a}`)}),(n=t.varFiles)===null||n===void 0||n.forEach(a=>{s.push(`-var-file=${a}`)}),DI.logger.debug(`Executing ${t.terraformBinaryName} ${s.join(" ")} in ${t.workdir}`);let o={file:t.terraformBinaryName,args:s,options:{cwd:t.workdir,env:process.env}};return i.start(),i.send({type:"START",pty:o}),i}});var fJ=p(gl=>{"use strict";var urr=gl&&gl.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),lrr=gl&&gl.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),drr=gl&&gl.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&urr(r,e,n[i]);return lrr(r,e),r}})();Object.defineProperty(gl,"__esModule",{value:!0});gl.terraformJsonSchema=void 0;var pt=drr(mI()),frr=pt.object({organization:pt.string(),hostname:pt.string().optional(),token:pt.string().optional(),workspaces:pt.object({name:pt.string().optional(),prefix:pt.string().optional()}).partial()}).partial();gl.terraformJsonSchema=pt.object({"//":pt.object({metadata:pt.object({version:pt.string(),stackName:pt.string(),backend:pt.string()}).partial().loose(),outputs:pt.record(pt.string(),pt.any())}).partial().loose(),terraform:pt.object({backend:pt.object({remote:frr}).partial().loose(),cloud:pt.object({organization:pt.string(),hostname:pt.string().optional(),token:pt.string().optional(),workspaces:pt.union([pt.object({name:pt.string()}),pt.object({tags:pt.array(pt.string())})])}).partial().loose(),required_providers:pt.record(pt.string(),pt.object({source:pt.string(),version:pt.string()}).loose()),required_version:pt.string()}).partial(),data:pt.record(pt.string(),pt.any()),provider:pt.record(pt.string(),pt.any()),resource:pt.record(pt.string(),pt.any())}).partial().loose()});var mJ=p(vi=>{"use strict";var Arr=vi&&vi.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),grr=vi&&vi.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),hrr=vi&&vi.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&Arr(r,e,n[i]);return grr(r,e),r}})(),bOe=vi&&vi.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(vi,"__esModule",{value:!0});vi.TerraformCli=vi.TerraformCliPlan=void 0;vi.tryReadGeneratedConfigurationFile=brr;vi.tryRemoveGeneratedConfigurationFile=Err;var prr=bOe(Df()),On=tt(),mrr=Nk(),ip=yOe(),Irr=(uJ(),xG(cJ)),yrr=lJ(),COe=fJ(),Crr=dJ(),pJ=bOe(require("path")),QI=hrr(Cr()),Pk="generated_resources.tf",AJ=class extends mrr.AbstractTerraformPlan{constructor(e,r){super(e,r?.resource_changes,r?.output_changes),this.planFile=e,this.plan=r}};vi.TerraformCliPlan=AJ;var gJ=class{},Yk=class extends gJ{static condition(e){let r=(0,prr.default)(e);return r.includes("Error: No value for required variable")&&r.includes("The root module input variable")}static transform(e){let r='The root module input variable "',n=e.substring(e.indexOf(r)+r.length,e.indexOf('" is not set'));return(0,yrr.missingVariable)(n)}},hJ=class{constructor(e,r,n=(i,s)=>(o,a=!1)=>{}){this.abortSignal=e,this.stack=r,this.workdir=r.workingDirectory,this.onStdout=(i,s)=>o=>n(i,s)(Buffer.isBuffer(o)?o.toString():o),this.onStderr=(i,s)=>o=>n(i,s)(o.toString(),!0)}async init(e){await this.setUserAgent();let r=["init"];e.needsUpgrade&&r.push("-upgrade"),e.noColor&&r.push("-no-color"),e.migrateState&&r.push("-migrate-state");let n=u=>{},i=new Promise((u,l)=>{n=l}),s=this.onStdout("init"),{actions:o,exitCode:a}=(0,Crr.spawnInteractive)({file:On.terraformBinaryName,args:r,options:{cwd:this.workdir,env:process.env}},u=>{s(u),(u.includes("Should Terraform migrate your existing state?")||u.includes("Do you want to copy existing state to the new backend"))&&(e.migrateState?o.writeLine("yes"):(o.stop(),n("Please pass the --migrate-state flag to migrate your state")))});this.abortSignal.addEventListener("abort",()=>{o.stop()});let c=a.then(u=>{if(u!==0)throw new Error(`terraform init failed with exit code ${u}`)});await Promise.race([c,i]),e.needsLockfileUpdate&&await(0,On.exec)(On.terraformBinaryName,["providers","lock","-platform=linux_amd64",...e.noColor?["-no-color"]:[]],{cwd:this.workdir,env:process.env,signal:this.abortSignal,noColor:e.noColor},this.onStdout("init"),this.onStderr("init"))}get isCloudStack(){var e,r,n;let i=COe.terraformJsonSchema.parse(JSON.parse(this.stack.content));return!!(!((r=(e=i.terraform)===null||e===void 0?void 0:e.backend)===null||r===void 0)&&r.remote||!((n=i.terraform)===null||n===void 0)&&n.cloud)}get hasImports(){return!!COe.terraformJsonSchema.parse(JSON.parse(this.stack.content)).import}async plan(e){let{destroy:r=!1,refreshOnly:n=!1,parallelism:i=-1,vars:s=[],varFiles:o=[],noColor:a=!1}=e,c=["plan","-input=false"],u=pJ.default.join(this.workdir,Pk);QI.existsSync(u)&&QI.remove(u),this.hasImports&&c.push(`-generate-config-out=${Pk}`),this.isCloudStack||c.push("-out","plan"),r&&c.push("-destroy"),n&&c.push("-refresh-only"),i>-1&&c.push(`-parallelism=${i}`),a&&c.push("-no-color"),s.forEach(l=>c.push(`-var=${l}`)),o.forEach(l=>c.push(`-var-file=${l}`)),On.logger.debug(`Executing ${On.terraformBinaryName} ${c.join(" ")} in ${this.workdir}`),await this.setUserAgent(),await(0,On.exec)(On.terraformBinaryName,c,{cwd:this.workdir,env:process.env,signal:this.abortSignal,noColor:a},this.onStdout("plan",[Yk]),this.onStderr("plan",[Yk]))}async deploy({autoApprove:e=!1,refreshOnly:r=!1,noColor:n=!1,parallelism:i=-1,extraOptions:s=[],vars:o=[],varFiles:a=[]},c){return await this.setUserAgent(),this.handleService("deploy",c,u=>(0,ip.createAndStartDeployService)({terraformBinaryName:On.terraformBinaryName,workdir:this.workdir,refreshOnly:r,noColor:n,autoApprove:e,parallelism:i,extraOptions:s,vars:o,varFiles:a},u))}async destroy({autoApprove:e=!1,parallelism:r=-1,noColor:n=!1,extraOptions:i=[],vars:s=[],varFiles:o=[]},a){return await this.setUserAgent(),this.handleService("destroy",a,c=>(0,ip.createAndStartDestroyService)({terraformBinaryName:On.terraformBinaryName,workdir:this.workdir,autoApprove:e,parallelism:r,noColor:n,extraOptions:i,vars:s,varFiles:o},c))}async handleService(e,r,n){var i;let o=n(d=>{if(d.type!=="@xstate.event"||d.actorRef.sessionId!==d.rootId)return;let f=d.event;On.logger.trace(`Terraform CLI state machine event: ${JSON.stringify(f)}`),(0,ip.isDeployEvent)(f,"OUTPUT_RECEIVED")?this.onStdout(e)(f.output):(0,ip.isDeployEvent)(f,"APPROVED_EXTERNALLY")?r({type:"external approval reply",approved:!0}):(0,ip.isDeployEvent)(f,"REJECTED_EXTERNALLY")?r({type:"external approval reply",approved:!1}):(0,ip.isDeployEvent)(f,"OVERRIDDEN_EXTERNALLY")?r({type:"external sentinel override reply",overridden:!0}):(0,ip.isDeployEvent)(f,"OVERRIDE_REJECTED_EXTERNALLY")&&r({type:"external sentinel override reply",overridden:!1})}),a="idle",c=d=>{d.matches(a)||(On.logger.trace(`Terraform CLI state machine state transition: ${JSON.stringify(a)} => ${JSON.stringify(d.value)}`),d.matches({running:"awaiting_approval"})?r({type:"waiting for approval",approve:()=>o.send({type:"APPROVE"}),reject:()=>o.send({type:"REJECT"})}):d.matches({running:"awaiting_sentinel_override"})?r({type:"waiting for sentinel override",override:()=>o.send({type:"OVERRIDE"}),reject:()=>o.send({type:"REJECT_OVERRIDE"})}):d.matches({running:"processing"})&&r({type:"running",cancelled:!!d.context.cancelled}),a=d.value)};o.subscribe(c),c(o.getSnapshot()),this.abortSignal.addEventListener("abort",()=>{o.send({type:"STOP"})},{once:!0});let u=await(0,Irr.waitFor)(o,d=>d.status==="done",{timeout:1/0}),l=(i=u.output)===null||i===void 0?void 0:i.exitCode;if(On.logger.trace(`Invoking Terraform CLI for ${e} done (state machine reached final state). Last exit code: ${JSON.stringify(l)}. Context: ${JSON.stringify(u.context)}`),l!==void 0&&l!==0&&!u.context.cancelled)throw`Invoking Terraform CLI failed with exit code ${l}`;return{cancelled:!!u.context.cancelled}}async version(){try{return await(0,On.exec)(On.terraformBinaryName,["version"],{cwd:this.workdir,env:process.env,signal:this.abortSignal,noColor:!0},this.onStdout("version"),this.onStderr("version"))}catch{throw new Error("Terraform CLI not present - Please install a current version https://learn.hashicorp.com/terraform/getting-started/install.html")}}async output(){let e=await(0,On.exec)(On.terraformBinaryName,["output","-json"],{cwd:this.workdir,env:process.env,signal:this.abortSignal,noColor:!0},()=>{},this.onStderr("output"));try{return JSON.parse(e)}catch(r){throw On.Errors.External(`Failed to parse terraform output: ${r}. The output was '${e}'`)}}async setUserAgent(){let e=await(0,On.readCDKTFVersion)(this.workdir);e!=""&&(process.env.TF_APPEND_USER_AGENT="cdktn/"+e+" (+https://github.com/open-constructs/cdk-terrain)")}async abort(){}};vi.TerraformCli=hJ;async function brr(t){let e=pJ.default.join(t,Pk);return QI.existsSync(e)?QI.readFileSync(e,"utf-8"):null}async function Err(t){let e=pJ.default.join(t,Pk);QI.existsSync(e)&&QI.unlinkSync(e)}});var vOe=p(Os=>{"use strict";var Brr=Os&&Os.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),vrr=Os&&Os.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),CJ=Os&&Os.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&Brr(r,e,n[i]);return vrr(r,e),r}})(),Srr=Os&&Os.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Os,"__esModule",{value:!0});Os.shouldReportCrash=bJ;Os.persistReportCrashReportDecision=BOe;Os.initializErrorReporting=_rr;Os.captureException=xrr;var jk=CJ(vR()),$k=tt(),zk=tt(),IJ=CJ(require("path")),yJ=CJ(Cr()),EOe=Srr(n_());function bJ(t=process.cwd()){try{let e=JSON.parse(yJ.readFileSync(IJ.resolve(t,"cdktf.json"),"utf8"));return typeof e.sendCrashReports=="boolean"?e.sendCrashReports:e.sendCrashReports==="true"}catch(e){return zk.logger.debug(`Error determining if crash reporting should be enabled, defaulting to false: ${e}`),!1}}function BOe(t,e=process.cwd()){let r=JSON.parse(yJ.readFileSync(IJ.resolve(e,"cdktf.json"),"utf8"));r.sendCrashReports=t,yJ.writeFileSync(IJ.resolve(e,"cdktf.json"),JSON.stringify(r,null,2))}function wrr(t){return typeof t=="object"&&typeof t.then=="function"&&typeof t.catch=="function"}async function _rr(t){let e=bJ(),r=EOe.default.isCI?EOe.default.name||"unknown":!1;if(e===void 0&&t){if(r)return;e=await t(),BOe(e)}if(!e){zk.logger.debug("Error reporting disabled");return}zk.logger.debug("Initializing error reporting"),jk.init({autoSessionTracking:!0,dsn:"https://5a76d29d61ea79fd3ee038f276a6be21@o4510735861743616.ingest.de.sentry.io/4510735863840848",release:`cdktn-cli-${$k.DISPLAY_VERSION}`,async beforeSend(n,i){if(!i)return n;let s=i.originalException,o;return wrr(s)?(s.catch(c=>o=c),await Promise.allSettled([s])):o=s,(o?.toString()||"").includes("Usage Error")?null:n}}),jk.configureScope(function(n){n.setUser({id:(0,$k.getUserId)()}),n.setTag("projectId",(0,$k.getProjectId)())}),zk.logger.debug("Collecting environment information for error reporting"),(0,$k.collectDebugInformation)().then(n=>{jk.setContext("environment",n)})}function xrr({message:t,type:e,command:r,context:n}){bJ()&&jk.captureException(new Error(t),{tags:{context:JSON.stringify(n),type:e,command:r}})}});var wOe=p(hl=>{"use strict";var Rrr=hl&&hl.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),Drr=hl&&hl.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),Qrr=hl&&hl.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&Rrr(r,e,n[i]);return Drr(r,e),r}})();Object.defineProperty(hl,"__esModule",{value:!0});hl.schema=void 0;var Te=Qrr(mI()),rc=Te.object({addr:Te.string(),module:Te.string(),resource:Te.string(),implied_provider:Te.string(),resource_type:Te.string(),resource_name:Te.string(),resource_key:Te.string().optional().nullable()}),ts=Te.object({"@level":Te.enum(["info","error","warn"]),"@message":Te.string(),"@module":Te.string(),"@timestamp":Te.string()}).loose(),LS=Te.enum(["noop","create","read","update","delete"]),SOe=Te.object({resource:rc,action:LS}),Nrr=SOe.extend({action:Te.literal("replace"),reason:Te.enum(["tainted","requested","cannot_update"])}),Trr=ts.extend({type:Te.literal("planned_change"),change:Te.union([Nrr,SOe])}),krr=ts.extend({type:Te.literal("version")}),Frr=ts.extend({type:Te.literal("change_summary"),changes:Te.object({add:Te.number(),change:Te.number(),remove:Te.number(),operation:Te.enum(["plan","apply","deploy"])})}),Grr=ts.extend({type:Te.literal("outputs"),outputs:Te.record(Te.string(),Te.object({sensitive:Te.boolean(),type:Te.string(),value:Te.string()}))}),Zrr=ts.extend({type:Te.literal("apply_start"),hook:Te.object({resource:rc,action:LS,id_key:Te.string().optional(),id_value:Te.string().optional()})}),Orr=ts.extend({type:Te.literal("apply_progress"),hook:Te.object({resource:rc,action:LS,elapsed_seconds:Te.number()})}),Urr=ts.extend({type:Te.literal("apply_complete"),hook:Te.object({resource:rc,action:LS,id_key:Te.string().optional(),id_value:Te.string().optional(),elapsed_seconds:Te.number()})}),Mrr=ts.extend({type:Te.literal("apply_errored"),hook:Te.object({resource:rc,action:LS,elapsed_seconds:Te.number()})}),Lrr=ts.extend({type:Te.literal("provision_start"),hook:Te.object({resource:rc,provisioner:Te.string()})}),Wrr=ts.extend({type:Te.literal("provision_progress"),hook:Te.object({resource:rc,provisioner:Te.string(),output:Te.string()})}),Vrr=ts.extend({type:Te.literal("provision_complete"),hook:Te.object({resource:rc,provisioner:Te.string()})}),Hrr=ts.extend({type:Te.literal("provision_errored"),hook:Te.object({resource:rc,provisioner:Te.string()})}),Prr=ts.extend({type:Te.literal("refresh_start"),hook:Te.object({resource:rc,id_key:Te.string().optional(),id_value:Te.string().optional()})}),Yrr=ts.extend({type:Te.literal("refresh_complete"),hook:Te.object({resource:rc,id_key:Te.string().optional(),id_value:Te.string().optional()})}),$rr=ts.extend({type:Te.literal("log")});hl.schema=Te.union([krr,Trr,Frr,Grr,Zrr,Orr,Urr,Mrr,Lrr,Wrr,Vrr,Hrr,Prr,Yrr,$rr])});var BJ=p(Si=>{"use strict";var jrr=Si&&Si.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),zrr=Si&&Si.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),EJ=Si&&Si.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&jrr(r,e,n[i]);return zrr(r,e),r}})(),qrr=Si&&Si.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Si,"__esModule",{value:!0});Si.getConstructIdsForOutputs=Si.parseOutput=void 0;Si.saveOutputs=tnr;Si.normalizeOutputPath=rnr;var Jrr=EJ(mI()),Xrr=EJ(require("fs")),_Oe=EJ(require("path")),Krr=qrr(Df()),xOe=tt(),enr=wOe(),Co=Nk();function DOe(t,e){return Object.entries(t).reduce((r,[n,i])=>({...r,[n]:(0,Co.isTerraformOutput)(i)?!i.sensitive||e?i.value:void 0:DOe(i,e)}),{})}async function tnr(t,e,r){Xrr.writeFileSync(t,JSON.stringify(DOe(e,r),null,2))}function rnr(t){return _Oe.isAbsolute(t)?t:_Oe.join(process.cwd(),t)}var ROe=(t,e)=>{switch(t){case"create":case"update":return e?Co.DeployingResourceApplyState.CREATED:Co.DeployingResourceApplyState.CREATING;case"delete":return e?Co.DeployingResourceApplyState.DESTROYED:Co.DeployingResourceApplyState.DESTROYING;default:return Co.DeployingResourceApplyState.WAITING}},nnr=t=>{let e,r;try{e=JSON.parse(t)}catch{xOe.logger.trace(`Could not parse line as JSON: ${t}`);return}try{r=enr.schema.parse(e)}catch(n){n instanceof Jrr.ZodError&&xOe.logger.trace(`Error parsing line into schema: ${JSON.stringify(n.issues)} => ${t}`);return}switch(r.type){case"apply_start":case"apply_progress":return{id:r.hook.resource.resource,applyState:ROe(r.hook.action,!1)};case"apply_complete":return{id:r.hook.resource.resource,applyState:ROe(r.hook.action,!0)};default:return}},inr=t=>{if(/^Outputs:/.test(t)||/^Plan:/.test(t)||/^data\..*/.test(t))return;let e=t.match(/^([a-zA-Z_][a-zA-Z\d_\-.]*):/),r;switch(!0){case/Creating.../.test(t):case/Still creating.../.test(t):r=Co.DeployingResourceApplyState.CREATING;break;case/Creation complete/.test(t):r=Co.DeployingResourceApplyState.CREATED;break;case/Modifying.../.test(t):r=Co.DeployingResourceApplyState.UPDATING;break;case/Modifications complete/.test(t):r=Co.DeployingResourceApplyState.UPDATED;break;case/Destroying.../.test(t):case/Still destroying.../.test(t):r=Co.DeployingResourceApplyState.DESTROYING;break;case/Destruction complete/.test(t):r=Co.DeployingResourceApplyState.DESTROYED;break;default:return}if(e&&e.length>=0&&e[1]!="Warning")return{id:e[1],applyState:r}},snr=t=>(0,Krr.default)(t.toString()).split(`
330
330
  `).map(n=>{let i=nnr(n)||inr(n);if(i===void 0)return;let{id:s,applyState:o}=i;return{id:s,applyState:o,action:Co.PlannedResourceAction.CREATE}}).reduce((n,i)=>(i&&n.push(i),n),new Array);Si.parseOutput=snr;var QOe=t=>typeof t!="object"?!1:Object.keys(t).length===0||Object.values(t).every(e=>e==null||QOe(e)),onr=(t,e)=>{if(!("//"in t)||!("outputs"in t["//"]))return e;let r=t["//"].outputs,n=i=>Object.entries(i).reduce((s,[o,a])=>{if(typeof a=="string")return{...s,[o]:e[a]};let c=n(a);return QOe(c)?s:{...s,[o]:c}},{});return n(r)};Si.getConstructIdsForOutputs=onr});var TOe=p(wd=>{"use strict";var anr=wd&&wd.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),cnr=wd&&wd.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),unr=wd&&wd.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&anr(r,e,n[i]);return cnr(r,e),r}})();Object.defineProperty(wd,"__esModule",{value:!0});wd.checkInstalledBinaryAgainstTargets=dnr;var lnr=unr(eo()),NOe=tt();function dnr(t,e,r){let n=e??NOe.DEFAULT_TARGET_VERSIONS,i=(0,NOe.parseTerraformCliVersion)(t);if(i.name==="unknown"||!i.version)return[`Could not determine whether ${r} is Terraform or OpenTofu from its version output, unable to verify it against the declared targetVersions`];let s=n[i.name];return s?lnr.satisfies(i.version,s)?[]:[`The installed binary "${r}" is ${i.name} ${i.version}, which is outside the project's declared targetVersions.${i.name} range "${s}"`]:[`The installed binary "${r}" is ${i.name} ${i.version}, but the project's targetVersions does not declare ${i.name} (declared: ${JSON.stringify(n)})`]}});var kOe=p(vJ=>{"use strict";Object.defineProperty(vJ,"__esModule",{value:!0});vJ.extractJsonLogIfPresent=Anr;function fnr(t){try{let e=JSON.parse(t)["@message"];return e?e.trim():t}catch{return t}}function Anr(t){return t.split(`
331
331
  `).map(fnr).join(`
332
332
  `)}});var OOe=p(NI=>{"use strict";var ZOe=NI&&NI.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(NI,"__esModule",{value:!0});NI.TerraformProviderLock=void 0;var gnr=ZOe(require("path")),FOe=ZOe(require("fs/promises")),GOe=Pf(),hnr=tt(),pnr=".terraform.lock.hcl",SJ=class{constructor(e){this.stackWorkingDirectory=e,this._providerLockData=null}get lockFilePath(){return gnr.default.join(this.stackWorkingDirectory,pnr)}async hasProviderLockFile(){try{return await FOe.default.stat(this.lockFilePath),!0}catch{return!1}}async readProviderLockFile(){try{return(await FOe.default.readFile(this.lockFilePath)).toString()}catch(e){hnr.logger.debug("Unable to read provider lock file",e)}return""}parseProviderLockFile(e){let r={providers:{}},n;return e.split(/\r\n|\r|\n/).forEach(i=>{if(n){let o=i.match(/^\s*constraints\s+=\s+"(.*)"/);if(o){r.providers[n].constraints=new GOe.ProviderConstraint(n,o[1]);return}let a=i.match(/^\s*version\s+=\s+"(.*)"/);if(a){r.providers[n].version=a[1];return}i.match(/^\s*}/)&&(n=void 0);return}let s=i.match(/provider "(.*)"/);s&&(n=s[1],r.providers[n]={name:new GOe.ProviderConstraint(n,">=0").simplifiedName})}),r}async providers(e=!1){if(!this._providerLockData||e){let r=await this.readProviderLockFile();this._providerLockData=this.parseProviderLockFile(r)}return this._providerLockData.providers}async hasMatchingProvider(e){var r,n;let s=(await this.providers())[e.source];return s?(r=s.constraints)===null||r===void 0?void 0:r.matchesVersion((n=e.version)!==null&&n!==void 0?n:">0"):!1}};NI.TerraformProviderLock=SJ});var UOe=p(_d=>{"use strict";var mnr=_d&&_d.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),Inr=_d&&_d.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),ynr=_d&&_d.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&mnr(r,e,n[i]);return Inr(r,e),r}})();Object.defineProperty(_d,"__esModule",{value:!0});_d.convertConfigurationFile=vnr;var Cnr=ynr(require("@cdktn/hcl2cdk")),bnr=qc(),Enr=ZB(),Bnr=Gf(),wJ=tt();async function vnr(t,e){let r=bnr.CdktfConfig.read(e),n=r.terraformProviders.map(o=>wJ.ConstructsMakerProviderTarget.from(new Enr.TerraformProviderConstraint(o),wJ.LANGUAGES[0])),{providerSchema:i}=await(0,Bnr.readSchema)(n);if(!i)throw wJ.Errors.Internal("Could not fetch provider schema");let{all:s}=await Cnr.convert(t,{providerSchema:i,language:r.language,codeContainer:"constructs.Construct"});return s}});var RJ=p(qk=>{"use strict";Object.defineProperty(qk,"__esModule",{value:!0});qk.CdktfStack=void 0;var MOe=BJ(),nc=tt(),Snr=TOe(),wnr=kOe(),_J=mJ(),_nr=Pf(),xnr=fJ(),LOe=OOe(),Rnr=UOe();async function Dnr(t,e,r){return new _J.TerraformCli(t,e,r)}var xJ=class{constructor(e){this.options=e,this.stopped=!1,this.currentState="idle",this.stack=e.stack,this.parsedContent=xnr.terraformJsonSchema.parse(JSON.parse(this.stack.content))}get isPending(){return this.currentState==="idle"&&!this.stopped}get isDone(){return this.currentState==="done"||this.currentState==="errored"||this.stopped}get isRunning(){return!this.isPending&&!this.isDone}updateState(e){switch(nc.logger.debug(`[${this.stack.name}]: ${e.type}`),this.currentState=e.type,e.type){case"idle":case"done":break;case"errored":this.error=e.error,this.options.onUpdate(e);break;case"outputs fetched":case"deployed":nc.logger.debug(`Outputs: ${JSON.stringify(e.outputs)}`),nc.logger.debug(`OutputsByConstructId: ${JSON.stringify(e.outputsByConstructId)}`),this.outputs=e.outputs,this.outputsByConstructId=e.outputsByConstructId,this.options.onUpdate(e);break;default:this.options.onUpdate(e);break}}createTerraformLogHandler(e,r){nc.logger.debug("Creating terraform log handler",e);let n=this.options.onLog;return(i,s=!1)=>{let o=(0,wnr.extractJsonLogIfPresent)(i);nc.logger.debug(`[${this.options.stack.name}](${e}): ${i}`);let a=r?.find(u=>u.condition(o)),c=a?a.transform(o):o;c&&nc.logger.debug(`Filter ${a} applied on line '${o}' with result '${c}'`),n&&n({message:c,isError:s})}}async terraformClient(){return await Dnr(this.options.abortSignal,this.options.stack,this.createTerraformLogHandler.bind(this))}async validateInstalledBinaryIfConfigured(e){let r=(0,nc.readConfigSync)();if(!r.validateInstalledBinary)return;let n=(0,Snr.checkInstalledBinaryAgainstTargets)(await e.version(),r.targetVersions,nc.terraformBinaryName);if(n.length>0)throw nc.Errors.Usage(n.join(`