import { Meta, StoryObj } from '@storybook/react';

import StudioEditCard from './EditCard';

const meta: Meta<typeof StudioEditCard> = {
  title: 'Create/StudioEditCard',
  component: StudioEditCard,
  parameters: {
    layout: 'padded',
  },
  argTypes: {
    selectionStartSeconds: {
      control: { type: 'number', min: 0, step: 0.1 },
      description: 'Start time of the selection in seconds',
    },
    selectionEndSeconds: {
      control: { type: 'number', min: 0, step: 0.1 },
      description: 'End time of the selection in seconds',
    },
    setSelectionStartSeconds: {
      action: 'selection start changed',
      description: 'Callback when selection start time changes',
    },
    setSelectionEndSeconds: {
      action: 'selection end changed',
      description: 'Callback when selection end time changes',
    },
    sampleAudio: {
      description:
        'Function that returns a value between 0 and 1 (indicating audio amplitude at a point in time) given a value between 0 and 1 (indicating progress through the range to be rendered)',
    },
  },
};
export default meta;

type Story = StoryObj<typeof StudioEditCard>;

export const Default: Story = {
  args: {
    sampleAudio: (progress) =>
      (Math.cos((0.125 + progress) * 2 * Math.PI * 4) * 0.5 + 0.5) *
      10 *
      (0.1 - (progress % 0.1)),
    selectionStartSeconds: 0,
    selectionEndSeconds: 1,
    setSelectionStartSeconds: () => {},
    setSelectionEndSeconds: () => {},
  },
  render: (args) => <StudioEditCard {...args} />,
};
