import type { Meta } from '@storybook/react'

import {
  Template,
  type TemplateProps,
} from '../../stories/customMessageStoryTemplate'
import {
  currentUserArgType,
  storyUsers,
} from '../../stories/decorators/storyUser'

const meta: Meta = {
  title: 'CustomMessage/Locked Attachment',
  argTypes: currentUserArgType,
  args: { currentUser: storyUsers.creator },
  parameters: {
    layout: 'fullscreen',
  },
}
export default meta

export const LockedAttachment = Template.bind({})
LockedAttachment.args = {
  messages: [
    {
      id: 'msg-1',
      text: 'Can I have your workout plan?',
      user: storyUsers.visitor,
    },
    {
      id: 'msg-2',
      text: 'Yes, of course!',
      user: storyUsers.creator,
    },
    {
      id: 'msg-3',
      text: 'let me know if you have any questions!',
      user: storyUsers.creator,
      metadata: {
        custom_type: 'MESSAGE_ATTACHMENT',
        amount_text: 'AU$9.99',
        attachment_title: "Alicia's Workout Plan",
        attachment_mime_type: 'video/mp4',
        attachment_thumbnail: '/video-thumbnail-blurred.jpg',
        attachment_detail: '1:20',
      },
    },
    {
      id: 'msg-4',
      text: 'Looks amazing, unlocking now!',
      user: storyUsers.visitor,
    },
  ],
} satisfies TemplateProps

export const LockedTextAttachment = Template.bind({})
LockedTextAttachment.args = {
  messages: [
    {
      id: 'msg-1',
      text: 'Can you send me the details privately?',
      user: storyUsers.visitor,
    },
    {
      id: 'msg-2',
      // Empty text: the real content is redacted server-side until purchase,
      // so the bubble renders the blurred placeholder instead.
      text: '',
      user: storyUsers.creator,
      metadata: {
        custom_type: 'MESSAGE_ATTACHMENT',
        amount_text: 'AU$4.99',
        attachment_content_type: 'text',
      },
    },
    {
      id: 'msg-3',
      text: '',
      user: storyUsers.creator,
      metadata: {
        custom_type: 'MESSAGE_ATTACHMENT',
        amount_text: 'AU$4.99',
        payment_status: 'paid',
        attachment_content_type: 'text',
      },
    },
    {
      id: 'msg-4',
      // Buyer reveal: backend writes the real text back onto the message.
      text: "Here's the address — see you Thursday at 7!",
      user: storyUsers.creator,
      metadata: {
        custom_type: 'MESSAGE_ATTACHMENT',
        amount_text: 'AU$4.99',
        payment_status: 'paid',
        attachment_content_type: 'text',
      },
    },
  ],
} satisfies TemplateProps
LockedTextAttachment.parameters = {
  docs: {
    description: {
      story:
        'A paid text-only message renders as a regular bubble with blurred placeholder copy (msg-2: pending, msg-3: purchased-but-not-yet-revealed) until the real text is revealed (msg-4).',
    },
  },
}
