import a from './index5.mjs';
import { r as readConfigSnapshot, l as listConfigSnapshots } from '../shared/ccjk.BzPbSEP2.mjs';
import '../shared/ccjk.BAGoDD49.mjs';
import 'node:fs';
import './constants.mjs';
import 'node:os';
import './index2.mjs';
import 'node:process';
import 'node:url';
import '../shared/ccjk.bQ7Dh1g4.mjs';
import './fs-operations.mjs';
import 'node:crypto';
import 'node:fs/promises';

async function snapshotCommand(action = "list", id, options = {}) {
  if (action === "show") {
    if (!id) {
      console.error(a.red("Snapshot id is required."));
      return;
    }
    const snapshot = readConfigSnapshot(id);
    if (!snapshot) {
      console.error(a.red(`Snapshot not found: ${id}`));
      return;
    }
    if (options.json) {
      console.log(JSON.stringify(snapshot.manifest, null, 2));
      return;
    }
    console.log(a.bold.cyan("Snapshot"));
    console.log(`ID: ${snapshot.manifest.id}`);
    console.log(`Created: ${snapshot.manifest.createdAt}`);
    console.log(`Plan: ${snapshot.manifest.title}`);
    console.log(`Risk: ${snapshot.manifest.risk}`);
    console.log(`Files: ${snapshot.manifest.files.length}`);
    for (const file of snapshot.manifest.files) {
      console.log(`  - ${file.sourcePath}`);
      console.log(a.dim(`    ${file.operation}; ${file.reason}`));
    }
    return;
  }
  const snapshots = listConfigSnapshots();
  if (options.json) {
    console.log(JSON.stringify(snapshots, null, 2));
    return;
  }
  if (snapshots.length === 0) {
    console.log(a.yellow("No snapshots found."));
    return;
  }
  console.log(a.bold.cyan("Snapshots"));
  for (const snapshot of snapshots) {
    console.log(`${a.green(snapshot.id)}  ${snapshot.createdAt}`);
    console.log(a.dim(`  ${snapshot.title} (${snapshot.files.length} file${snapshot.files.length === 1 ? "" : "s"})`));
  }
}

export { snapshotCommand };
