import type { NotificationSoundId } from "@workspace/api-client-react";

const BASE = (import.meta.env.BASE_URL || "/").replace(/\/$/, "");

export type NotificationSoundEntry = {
  id: NotificationSoundId;
  labelKey: string;
  url: string;
};

/**
 * Manifest of bundled short notification sounds. The actual audio files
 * live under `public/sounds/<id>.wav` in the tx-os artifact and are
 * served from the artifact base path. The matching i18n labels live in
 * `notifSettings.sounds.<id>` for both languages.
 */
export const NOTIFICATION_SOUND_MANIFEST: ReadonlyArray<NotificationSoundEntry> =
  [
    { id: "ding", labelKey: "notifSettings.sounds.ding", url: `${BASE}/sounds/ding.wav` },
    { id: "chime", labelKey: "notifSettings.sounds.chime", url: `${BASE}/sounds/chime.wav` },
    { id: "bell", labelKey: "notifSettings.sounds.bell", url: `${BASE}/sounds/bell.wav` },
    { id: "knock", labelKey: "notifSettings.sounds.knock", url: `${BASE}/sounds/knock.wav` },
    { id: "pop", labelKey: "notifSettings.sounds.pop", url: `${BASE}/sounds/pop.wav` },
    { id: "alert", labelKey: "notifSettings.sounds.alert", url: `${BASE}/sounds/alert.wav` },
    { id: "beep", labelKey: "notifSettings.sounds.beep", url: `${BASE}/sounds/beep.wav` },
    { id: "soft", labelKey: "notifSettings.sounds.soft", url: `${BASE}/sounds/soft.wav` },
  ];

export const SOUND_BY_ID = new Map(
  NOTIFICATION_SOUND_MANIFEST.map((s) => [s.id, s]),
);
