#!/usr/bin/env node
import {
  ENTER,
  ESCAPE,
  RENDER_DELAY_MS,
  delay
} from "../../chunk-YZTWZVGX.js";
import {
  render
} from "../../chunk-66UDJBF6.js";
import {
  afterEach,
  beforeEach,
  describe,
  globalExpect,
  it,
  vi
} from "../../chunk-XY3XDVMI.js";
import {
  StepConfirm
} from "../../chunk-M3AGB4TR.js";
import "../../chunk-YRVTXSXP.js";
import "../../chunk-KWWLPPHF.js";
import {
  useWizardStore
} from "../../chunk-FYNMNY4P.js";
import "../../chunk-KZNPPUQG.js";
import "../../chunk-ZECXM7LP.js";
import "../../chunk-T4EXUIBY.js";
import "../../chunk-473YHDYQ.js";
import "../../chunk-FVN5PFFY.js";
import {
  init_esm_shims
} from "../../chunk-DHET7RCE.js";

// src/cli/components/wizard/step-confirm.test.tsx
init_esm_shims();
import { jsx } from "react/jsx-runtime";
describe("StepConfirm component", () => {
  let cleanup;
  beforeEach(() => {
    useWizardStore.getState().reset();
  });
  afterEach(() => {
    cleanup?.();
    cleanup = void 0;
  });
  describe("stack path", () => {
    it("should render stack name in title", () => {
      const onComplete = vi.fn();
      const onBack = vi.fn();
      const { lastFrame, unmount } = render(
        /* @__PURE__ */ jsx(
          StepConfirm,
          {
            onComplete,
            stackName: "nextjs-fullstack",
            technologyCount: 12,
            skillCount: 12,
            installMode: "plugin",
            onBack
          }
        )
      );
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Ready to install nextjs-fullstack");
    });
    it("should show technology count", () => {
      const onComplete = vi.fn();
      const onBack = vi.fn();
      const { lastFrame, unmount } = render(
        /* @__PURE__ */ jsx(
          StepConfirm,
          {
            onComplete,
            stackName: "nextjs-fullstack",
            technologyCount: 12,
            skillCount: 12,
            installMode: "plugin",
            onBack
          }
        )
      );
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Technologies:");
      globalExpect(output).toContain("12");
    });
    it("should show skill count with verified label", () => {
      const onComplete = vi.fn();
      const onBack = vi.fn();
      const { lastFrame, unmount } = render(
        /* @__PURE__ */ jsx(
          StepConfirm,
          {
            onComplete,
            stackName: "nextjs-fullstack",
            technologyCount: 12,
            skillCount: 12,
            installMode: "plugin",
            onBack
          }
        )
      );
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Skills:");
      globalExpect(output).toContain("(all verified)");
    });
    it("should show install mode as Plugin", () => {
      const onComplete = vi.fn();
      const onBack = vi.fn();
      const { lastFrame, unmount } = render(
        /* @__PURE__ */ jsx(
          StepConfirm,
          {
            onComplete,
            stackName: "nextjs-fullstack",
            technologyCount: 12,
            skillCount: 12,
            installMode: "plugin",
            onBack
          }
        )
      );
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Install mode:");
      globalExpect(output).toContain("Plugin");
    });
    it("should show install mode as Local", () => {
      const onComplete = vi.fn();
      const onBack = vi.fn();
      const { lastFrame, unmount } = render(
        /* @__PURE__ */ jsx(
          StepConfirm,
          {
            onComplete,
            stackName: "nextjs-fullstack",
            technologyCount: 12,
            skillCount: 12,
            installMode: "local",
            onBack
          }
        )
      );
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Install mode:");
      globalExpect(output).toContain("Local");
    });
    it("should render confirm step content", () => {
      const onComplete = vi.fn();
      const onBack = vi.fn();
      const { lastFrame, unmount } = render(
        /* @__PURE__ */ jsx(
          StepConfirm,
          {
            onComplete,
            stackName: "nextjs-fullstack",
            technologyCount: 12,
            skillCount: 12,
            installMode: "plugin",
            onBack
          }
        )
      );
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Ready to install");
    });
  });
  describe("scratch path", () => {
    it("should render custom stack title with domain names", () => {
      const onComplete = vi.fn();
      const onBack = vi.fn();
      const { lastFrame, unmount } = render(
        /* @__PURE__ */ jsx(
          StepConfirm,
          {
            onComplete,
            selectedDomains: ["web", "api"],
            domainSelections: {
              web: {
                "web-framework": ["web-framework-react"],
                "web-styling": ["web-styling-scss-modules"]
              },
              api: { "api-api": ["api-framework-hono"] }
            },
            technologyCount: 3,
            skillCount: 3,
            installMode: "local",
            onBack
          }
        )
      );
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Ready to install your custom stack");
      globalExpect(output).toContain("Web + API");
    });
    it("should show domain breakdown with technologies", () => {
      const onComplete = vi.fn();
      const onBack = vi.fn();
      const { lastFrame, unmount } = render(
        /* @__PURE__ */ jsx(
          StepConfirm,
          {
            onComplete,
            selectedDomains: ["web", "api"],
            domainSelections: {
              web: {
                "web-framework": ["web-framework-react"],
                "web-styling": ["web-styling-scss-modules"]
              },
              api: { "api-api": ["api-framework-hono"] }
            },
            technologyCount: 3,
            skillCount: 3,
            installMode: "local",
            onBack
          }
        )
      );
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Web:");
      globalExpect(output).toContain("react");
      globalExpect(output).toContain("scss-modules");
      globalExpect(output).toContain("API:");
      globalExpect(output).toContain("hono");
    });
    it("should handle single domain without plus sign", () => {
      const onComplete = vi.fn();
      const onBack = vi.fn();
      const { lastFrame, unmount } = render(
        /* @__PURE__ */ jsx(
          StepConfirm,
          {
            onComplete,
            selectedDomains: ["web"],
            domainSelections: {
              web: { "web-framework": ["web-framework-react"] }
            },
            technologyCount: 1,
            skillCount: 1,
            installMode: "local",
            onBack
          }
        )
      );
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("(Web)");
      globalExpect(output).not.toContain("+");
    });
    it("should skip domains with no selections", () => {
      const onComplete = vi.fn();
      const onBack = vi.fn();
      const { lastFrame, unmount } = render(
        /* @__PURE__ */ jsx(
          StepConfirm,
          {
            onComplete,
            selectedDomains: ["web", "api"],
            domainSelections: {
              web: { "web-framework": ["web-framework-react"] },
              api: {}
              // Empty selections
            },
            technologyCount: 1,
            skillCount: 1,
            installMode: "local",
            onBack
          }
        )
      );
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Web:");
      globalExpect(output).toContain("react");
      const lines = output?.split("\n") || [];
      const apiLine = lines.find((line) => line.includes("API:") && line.includes("hono"));
      globalExpect(apiLine).toBeUndefined();
    });
  });
  describe("keyboard navigation", () => {
    it("should call onComplete when Enter is pressed", async () => {
      const onComplete = vi.fn();
      const onBack = vi.fn();
      const { stdin, unmount } = render(
        /* @__PURE__ */ jsx(
          StepConfirm,
          {
            onComplete,
            stackName: "nextjs-fullstack",
            technologyCount: 12,
            skillCount: 12,
            installMode: "plugin",
            onBack
          }
        )
      );
      cleanup = unmount;
      await delay(RENDER_DELAY_MS);
      await stdin.write(ENTER);
      await delay(RENDER_DELAY_MS);
      globalExpect(onComplete).toHaveBeenCalled();
    });
    it("should call onBack when Escape is pressed", async () => {
      const onComplete = vi.fn();
      const onBack = vi.fn();
      const { stdin, unmount } = render(
        /* @__PURE__ */ jsx(
          StepConfirm,
          {
            onComplete,
            stackName: "nextjs-fullstack",
            technologyCount: 12,
            skillCount: 12,
            installMode: "plugin",
            onBack
          }
        )
      );
      cleanup = unmount;
      await delay(RENDER_DELAY_MS);
      await stdin.write(ESCAPE);
      await delay(RENDER_DELAY_MS);
      globalExpect(onBack).toHaveBeenCalled();
      globalExpect(onComplete).not.toHaveBeenCalled();
    });
    it("should not call onBack when Escape is pressed but onBack is not provided", async () => {
      const onComplete = vi.fn();
      const { stdin, unmount } = render(
        /* @__PURE__ */ jsx(
          StepConfirm,
          {
            onComplete,
            stackName: "nextjs-fullstack",
            technologyCount: 12,
            skillCount: 12,
            installMode: "plugin"
          }
        )
      );
      cleanup = unmount;
      await delay(RENDER_DELAY_MS);
      await stdin.write(ESCAPE);
      await delay(RENDER_DELAY_MS);
      globalExpect(onComplete).not.toHaveBeenCalled();
    });
  });
  describe("default props", () => {
    it("should render custom stack title when no stack name provided", () => {
      const onComplete = vi.fn();
      const { lastFrame, unmount } = render(/* @__PURE__ */ jsx(StepConfirm, { onComplete }));
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).toContain("Ready to install your custom stack");
    });
    it("should not show stats when not provided", () => {
      const onComplete = vi.fn();
      const { lastFrame, unmount } = render(/* @__PURE__ */ jsx(StepConfirm, { onComplete }));
      cleanup = unmount;
      const output = lastFrame();
      globalExpect(output).not.toContain("Technologies:");
      globalExpect(output).not.toContain("Skills:");
      globalExpect(output).not.toContain("Install mode:");
    });
  });
});
//# sourceMappingURL=step-confirm.test.js.map