<script lang="ts" setup>
import type { ToasterProps } from 'vue-sonner';
import { Toaster as Sonner } from 'vue-sonner';
import { UiIcon } from '@/components/UiIcon';
import { cn } from '@/lib/utils';

const props = defineProps<ToasterProps>();
</script>

<template>
  <Sonner
    v-bind="props"
    :class="cn('toaster group', props.class)"
    :style="{
      '--normal-bg': 'oklch(var(--background-surface-inverse))',
      '--normal-text': 'oklch(var(--content-on-surface-inverse))',
      '--normal-border': 'transparent',
      '--border-radius': 'var(--radius)',
      ...((typeof props.style === 'object' && props.style) || {}),
    }"
  >
    <template #success-icon>
      <UiIcon name="circle-check" size="s" />
    </template>
    <template #info-icon>
      <UiIcon name="info" size="s" />
    </template>
    <template #warning-icon>
      <UiIcon name="triangle-alert" size="s" />
    </template>
    <template #error-icon>
      <UiIcon name="octagon-x" size="s" />
    </template>
    <template #loading-icon>
      <div>
        <UiIcon name="loader-2" size="s" class="animate-spin" />
      </div>
    </template>
    <template #close-icon>
      <UiIcon name="x" size="s" />
    </template>
  </Sonner>
</template>
