//#region src/deploy/CachedStateProvider.ts
/**
* Cached state provider that wraps a remote provider with local cache.
*/
var CachedStateProvider = class {
	constructor(remote, local) {
		this.remote = remote;
		this.local = local;
	}
	async read(stage) {
		const localState = await this.local.read(stage);
		if (localState) return localState;
		const remoteState = await this.remote.read(stage);
		if (remoteState) await this.local.write(stage, remoteState);
		return remoteState;
	}
	async write(stage, state) {
		await this.remote.write(stage, state);
		await this.local.write(stage, state);
	}
	/**
	* Force pull from remote to local.
	* Used by `gkm state pull` command.
	*/
	async pull(stage) {
		const remoteState = await this.remote.read(stage);
		if (remoteState) await this.local.write(stage, remoteState);
		return remoteState;
	}
	/**
	* Force push from local to remote.
	* Used by `gkm state push` command.
	*/
	async push(stage) {
		const localState = await this.local.read(stage);
		if (localState) await this.remote.write(stage, localState);
		return localState;
	}
	/**
	* Get both local and remote state for comparison.
	* Used by `gkm state diff` command.
	*/
	async diff(stage) {
		const [local, remote] = await Promise.all([this.local.read(stage), this.remote.read(stage)]);
		return {
			local,
			remote
		};
	}
};

//#endregion
export { CachedStateProvider };
//# sourceMappingURL=CachedStateProvider-BDq5WqSy.mjs.map