import { Meta, StoryObj } from "@storybook/nextjs-vite";
import { InfoTemplate } from "./InfoTemplate";
import { fn } from "storybook/test";
import { buildInfoDefaults } from "@/lib/admin/builder/state/defaults/info";
import type { InfoScreenDefinition } from "@/lib/funnel/types";

// Получаем дефолтные значения из builder
const defaultScreen = buildInfoDefaults("info-screen-story") as InfoScreenDefinition;

/** InfoTemplate - информационные экраны с иконкой и описанием */
const meta: Meta<typeof InfoTemplate> = {
  title: "Funnel Templates/InfoTemplate",
  component: InfoTemplate,
  tags: ["autodocs"],
  parameters: {
    layout: "fullscreen",
  },
  args: {
    screen: defaultScreen,
    onContinue: fn(),
    canGoBack: true,
    onBack: fn(),
    screenProgress: { current: 3, total: 10 },
    defaultTexts: {
      nextButton: "Next"
    },
  },
  argTypes: {
    screen: {
      control: { type: "object" },
    },
    screenProgress: {
      control: { type: "object" },
    },
    onContinue: { action: "continue" },
    onBack: { action: "back" },
  },
};

export default meta;
type Story = StoryObj<typeof meta>;

/** Дефолтный информационный экран */
export const Default: Story = {};

/** Экран без иконки */
export const WithoutIcon: Story = {
  args: {
    screen: {
      ...defaultScreen,
      icon: undefined,
    },
  },
};

/** Экран с кастомной иконкой */
export const WithCustomIcon: Story = {
  args: {
    screen: {
      ...defaultScreen,
      icon: {
        type: "emoji",
        value: "🎯",
        size: "lg",
      },
    },
  },
};

/** Экран без header */
export const WithoutHeader: Story = {
  args: {
    screen: {
      ...defaultScreen,
      header: {
        show: false,
      },
    },
  },
};

/** Экран с скрытым прогрессом */
export const WithoutProgress: Story = {
  args: {
    screen: {
      ...defaultScreen,
      header: {
        show: true,
        showBackButton: true,
        showProgress: false,
      },
    },
  },
};
