import type { FC } from 'react'
import { RiErrorWarningFill } from '@remixicon/react'
import * as React from 'react'
import { cn } from '@/utils/classnames'

type ErrorMessageProps = {
  message: string
} & React.HTMLAttributes<HTMLDivElement>

const ErrorMessage: FC<ErrorMessageProps> = ({
  message,
  className,
}) => {
  return (
    <div className={cn('mt-1 flex gap-x-1 rounded-lg border-[0.5px] border-components-panel-border bg-toast-error-bg p-2', className)}>
      <RiErrorWarningFill className="h-4 w-4 shrink-0 text-text-destructive" />
      <div className="max-h-12 grow overflow-y-auto whitespace-pre-line break-words text-text-primary system-xs-medium">
        {message}
      </div>
    </div>
  )
}

export default React.memo(ErrorMessage)
