#!/usr/bin/env node
import {
  WIZARD_STEPS,
  WizardTabs
} from "./chunk-MVEYK55V.js";
import {
  HelpModal
} from "./chunk-KQ27IDYL.js";
import {
  useWizardStore
} from "./chunk-SPSGZWTZ.js";
import {
  CLI_COLORS,
  DEFAULT_PLUGIN_NAME
} from "./chunk-FTD5Z6QD.js";
import {
  init_esm_shims
} from "./chunk-DHET7RCE.js";

// src/cli/components/wizard/wizard-layout.tsx
init_esm_shims();
import { Box, Text } from "ink";
import { Fragment } from "react";

// src/cli/components/hooks/use-terminal-dimensions.ts
init_esm_shims();
import { useState, useEffect } from "react";
import { useStdout } from "ink";
var DEFAULT_COLUMNS = 80;
var DEFAULT_ROWS = 24;
function useTerminalDimensions() {
  const { stdout } = useStdout();
  const [dimensions, setDimensions] = useState(() => ({
    columns: stdout.columns || DEFAULT_COLUMNS,
    rows: stdout.rows || DEFAULT_ROWS
  }));
  useEffect(() => {
    const handleResize = () => {
      setDimensions({
        columns: stdout.columns || DEFAULT_COLUMNS,
        rows: stdout.rows || DEFAULT_ROWS
      });
    };
    stdout.on("resize", handleResize);
    return () => {
      stdout.off("resize", handleResize);
    };
  }, [stdout]);
  return dimensions;
}

// src/cli/components/wizard/wizard-layout.tsx
import { Fragment as Fragment2, jsx, jsxs } from "react/jsx-runtime";
import { createElement } from "react";
var DefinitionItem = ({
  isVisible = true,
  isActive = false,
  label,
  values
}) => {
  if (!isVisible) {
    return null;
  }
  return /* @__PURE__ */ jsxs(Text, { children: [
    values.map((value) => /* @__PURE__ */ jsxs(Fragment, { children: [
      /* @__PURE__ */ jsxs(
        Text,
        {
          backgroundColor: "black",
          color: isActive ? CLI_COLORS.PRIMARY : CLI_COLORS.UNFOCUSED,
          children: [
            " ",
            value,
            " "
          ]
        }
      ),
      " "
    ] }, value)),
    /* @__PURE__ */ jsx(Text, { color: isActive ? CLI_COLORS.PRIMARY : void 0, children: label })
  ] });
};
var HOT_KEYS = [
  { label: "navigate", values: ["\u2190/\u2192", "\u2191/\u2193"] },
  { label: "select", values: ["SPACE"] },
  { label: "continue", values: ["ENTER"] },
  { label: "back", values: ["ESC"] }
];
var WizardFooter = () => {
  const store = useWizardStore();
  return /* @__PURE__ */ jsxs(
    Box,
    {
      columnGap: 2,
      borderTop: true,
      borderRight: false,
      borderBottom: true,
      borderLeft: false,
      borderColor: "blackBright",
      borderStyle: "single",
      paddingLeft: 1,
      paddingRight: 1,
      children: [
        /* @__PURE__ */ jsx(
          DefinitionItem,
          {
            label: "Accept defaults",
            values: ["A"],
            isVisible: store.step === "build" && !!store.selectedStackId
          }
        ),
        HOT_KEYS.map((hotkey) => /* @__PURE__ */ createElement(DefinitionItem, { ...hotkey, key: hotkey.label }))
      ]
    }
  );
};
var WizardLayout = ({
  version,
  marketplaceLabel,
  logo,
  children
}) => {
  const store = useWizardStore();
  const { completedSteps, skippedSteps } = store.getStepProgress();
  const { rows: terminalHeight } = useTerminalDimensions();
  return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", paddingX: 1, height: terminalHeight, children: [
    logo && /* @__PURE__ */ jsx(Box, { flexDirection: "row", marginTop: 1, columnGap: 1, children: /* @__PURE__ */ jsx(Text, { children: logo }) }),
    /* @__PURE__ */ jsxs(Box, { children: [
      /* @__PURE__ */ jsx(Text, { dimColor: true, children: "Marketplace: " }),
      /* @__PURE__ */ jsx(Text, { bold: true, children: marketplaceLabel || `${DEFAULT_PLUGIN_NAME} (public)` })
    ] }),
    /* @__PURE__ */ jsx(
      WizardTabs,
      {
        steps: WIZARD_STEPS,
        currentStep: store.step,
        completedSteps,
        skippedSteps,
        version
      }
    ),
    store.showHelp ? /* @__PURE__ */ jsx(HelpModal, { currentStep: store.step }) : /* @__PURE__ */ jsxs(Fragment2, { children: [
      /* @__PURE__ */ jsx(Box, { flexDirection: "column", flexGrow: 1, flexBasis: 0, marginTop: 1, children }),
      /* @__PURE__ */ jsxs(Box, { paddingX: 1, columnGap: 2, marginTop: 2, children: [
        /* @__PURE__ */ jsx(DefinitionItem, { label: "Expert mode", values: ["E"], isActive: store.expertMode }),
        /* @__PURE__ */ jsx(
          DefinitionItem,
          {
            label: "Labels",
            values: ["D"],
            isVisible: store.step === "build",
            isActive: store.showLabels
          }
        ),
        /* @__PURE__ */ jsx(
          DefinitionItem,
          {
            label: "Plugin mode",
            values: ["P"],
            isActive: store.installMode === "plugin"
          }
        ),
        /* @__PURE__ */ jsx(
          DefinitionItem,
          {
            label: "Settings",
            values: ["G"],
            isVisible: store.step === "sources",
            isActive: store.showSettings
          }
        ),
        /* @__PURE__ */ jsx(DefinitionItem, { label: "Help", values: ["?"] })
      ] }),
      /* @__PURE__ */ jsx(WizardFooter, {})
    ] })
  ] });
};

export {
  WizardLayout
};
//# sourceMappingURL=chunk-OEJDFGAF.js.map