import type { Meta, StoryObj } from '@storybook/angular';
import { SourceBlock } from './source-block';
import { ChatbotSource } from '../../services/conversations.service';
import { moduleMetadata } from '@storybook/angular';
import { CommonModule } from '@angular/common';

const meta: Meta<SourceBlock> = {
  title: 'Chatbot/Sources/SourceBlock',
  component: SourceBlock,
  tags: ['autodocs'],
  decorators: [
    moduleMetadata({
      imports: [CommonModule],
      providers: []
    })
  ],
  argTypes: {
    source: {
      control: 'object',
      description: 'Objet contenant les informations de la source'
    }
  },
};

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

export const Default: Story = {
  args: {
    source: new ChatbotSource({
      title: 'Document technique.pdf',
      url: 'https://example.com/document-technique.pdf',
      description: 'Ce document contient des informations techniques sur les avions de ligne modernes et leur maintenance.'
    })
  },
};

export const ShortDescription: Story = {
  args: {
    source: new ChatbotSource({
      title: 'Rapport d\'accident.pdf',
      url: 'https://example.com/rapport-accident.pdf',
      description: 'Rapport concernant l\'incident de vol 123.'
    })
  },
};

export const LongDescription: Story = {
  args: {
    source: new ChatbotSource({
      title: 'Documentation complète.pdf',
      url: 'https://example.com/documentation-complete.pdf',
      description: 'DE GAGNE DATE: JANUARY 18, 2008 VEN #: V6-CAW-M2700-10 APPROVED BY: MARTIN SWAN DATE: FEBRUARY 5, 2008 -TITLE- DHC-6 ELEVATOR CONTROL CABLE WEAR SURVEY RESULTS ISSUE: 2 PAGE 2 respondents, representing 16 aircraft, operate outside the tropics and have a cycle/hour ratio of 1.6 to 2.8. Most respondents have reported that carbon steel elevator control cables are more wear resistant than stainless steel cables. Two operators in the tropics, representing 39 aircraft, use.'
    })
  },
};

export const WithoutUrl: Story = {
  args: {
    source: new ChatbotSource({
      title: 'Document interne.pdf',
      description: 'Document à usage interne uniquement, sans lien externe.'
    })
  },
};
