import type { Meta, StoryObj } from '@storybook/angular';
import { LetterBlock } from '@brief/domain/brief';
import { LetterBlockComponent } from './letter-block.component';

const passageBlock: LetterBlock = {
  type: 'passage',
  blockId: 'local-1',
  sourcePassageId: 'p1',
  sourceVersion: 1,
  edited: false,
  content: { paragraphs: [{ nodes: [{ type: 'text', text: 'Geachte heer/mevrouw,' }] }] },
};

const freeTextBlock: LetterBlock = {
  type: 'freeText',
  blockId: 'local-2',
  content: {
    paragraphs: [
      {
        nodes: [
          { type: 'text', text: 'Wij hebben besloten om reden ' },
          { type: 'placeholder', key: 'reden_besluit' },
          { type: 'text', text: '.' },
        ],
      },
    ],
  },
};

const placeholders = [{ key: 'reden_besluit', label: 'Reden besluit' }];

const meta: Meta<LetterBlockComponent> = {
  title: 'Domein/Brief/Letter Block',
  component: LetterBlockComponent,
  args: {
    block: passageBlock,
    placeholders,
    contentChanged: () => {},
    removed: () => {},
    moved: () => {},
  },
};
export default meta;
type Story = StoryObj<LetterBlockComponent>;

export const ReadOnlyPassage: Story = { args: { editable: false } };
export const EditableFreeText: Story = { args: { block: freeTextBlock, editable: true } };
