<script lang="ts">
  import type { Snippet } from 'svelte';
  import { notifications } from './store';
  import EventNotification from './Notification.svelte';

  let { zIndex = 5000, children }: { zIndex?: number; children?: Snippet } = $props();

  const handleRemove = (id: string) => {
    notifications.remove(id);
  };
</script>

<div class="notifications-container" style="z-index: {zIndex};">
  {#each $notifications as notification (notification.id)}
    <EventNotification {notification} onRemove={() => handleRemove(notification.id)} />
  {/each}
</div>

{@render children?.()}

<style>
  .notifications-container {
    position: fixed;
    top: 0;
    right: 0;
    pointer-events: none;
  }

  .notifications-container :global(#notification-container) {
    pointer-events: auto;
  }
</style>
