{"version":3,"sources":["../src/core/config.ts","../src/core/soundRegistry.ts","../src/core/manager.ts"],"sourcesContent":["import type { NotifyConfig, ThemeName } from \"./types.js\";\n\nconst DEFAULT_CONFIG: NotifyConfig = {\n  volume: 0.7,\n  enabled: true,\n  duration: 3000,\n  position: \"top-right\",\n  soundEnabled: true,\n  queue: false,\n  maxVisible: 5,\n  theme: \"minimal\",\n};\n\nlet currentConfig: NotifyConfig = { ...DEFAULT_CONFIG };\n\nexport function getConfig(): NotifyConfig {\n  return { ...currentConfig };\n}\n\nexport function setConfig(partial: Partial<NotifyConfig>): void {\n  currentConfig = { ...currentConfig, ...partial };\n}\n\nexport function setTheme(theme: ThemeName): void {\n  currentConfig.theme = theme;\n}\n\nexport function resetConfig(): void {\n  currentConfig = { ...DEFAULT_CONFIG };\n}\n","import type { SoundName } from \"./types.js\";\n\n// Default built-in sound mappings\n// Maps logical names → file names in the sounds/ directory\nconst defaultSoundMap: Record<SoundName, string> = {\n  success: \"success.wav\",\n  error: \"error.wav\",\n  warning: \"warning.wav\",\n  message: \"message.wav\",\n  click: \"click.wav\",\n  ringtone: \"ringtone.wav\",\n};\n\nconst customSounds: Record<string, string> = {};\n\nexport function getSoundKey(sound: SoundName | string): string {\n  if (sound in defaultSoundMap) {\n    return defaultSoundMap[sound as SoundName];\n  }\n  if (sound in customSounds) {\n    return customSounds[sound];\n  }\n  // Treat as a direct path/URL\n  return sound;\n}\n\nexport function isBuiltInSound(sound: string): boolean {\n  return sound in defaultSoundMap;\n}\n\nexport function registerSound(name: string, path: string): void {\n  customSounds[name] = path;\n}\n\nexport function getRegisteredSounds(): Record<string, string> {\n  return { ...defaultSoundMap, ...customSounds };\n}\n","import type {\n  Notification,\n  NotifyPayload,\n  NotifyEvent,\n  NotifyEventListener,\n  NotifyEventType,\n  SoundEngine,\n  CustomRenderer,\n} from \"./types.js\";\nimport { getConfig } from \"./config.js\";\n\n// ─── ID Generator ──────────────────────────────────────────────\nlet idCounter = 0;\nfunction generateId(): string {\n  return `notify-${Date.now()}-${++idCounter}`;\n}\n\n// ─── State ─────────────────────────────────────────────────────\nlet notifications: Notification[] = [];\nlet soundEngine: SoundEngine | null = null;\nlet customRenderer: CustomRenderer | null = null;\nconst listeners: Set<NotifyEventListener> = new Set();\n\n// ─── Event System ──────────────────────────────────────────────\nexport function subscribe(listener: NotifyEventListener): () => void {\n  listeners.add(listener);\n  return () => listeners.delete(listener);\n}\n\nfunction emit(event: NotifyEvent): void {\n  listeners.forEach((fn) => fn(event));\n}\n\n// ─── Sound Engine ──────────────────────────────────────────────\nexport function setSoundEngine(engine: SoundEngine): void {\n  soundEngine = engine;\n}\n\nexport function getSoundEngine(): SoundEngine | null {\n  return soundEngine;\n}\n\n// ─── Custom Renderer ──────────────────────────────────────────\nexport function setRenderer(renderer: CustomRenderer | null): void {\n  customRenderer = renderer;\n}\n\nexport function getRenderer(): CustomRenderer | null {\n  return customRenderer;\n}\n\n// ─── Notifications State ───────────────────────────────────────\nexport function getNotifications(): Notification[] {\n  return [...notifications];\n}\n\n// ─── Show Notification ─────────────────────────────────────────\nexport function show(payload: NotifyPayload): string {\n  const config = getConfig();\n\n  if (!config.enabled) return \"\";\n\n  const notification: Notification = {\n    id: generateId(),\n    title: payload.title ?? \"\",\n    message: payload.message,\n    type: payload.type ?? \"info\",\n    variant: payload.variant ?? \"toast\",\n    sound: payload.sound ?? \"\",\n    volume: payload.volume ?? config.volume,\n    duration: payload.duration ?? config.duration,\n    position: payload.position ?? config.position,\n    dismissible: payload.dismissible ?? true,\n    vibration: payload.vibration ?? false,\n    createdAt: Date.now(),\n    actions: payload.actions ?? [],\n  };\n\n  // Handle queue vs replace behavior\n  if (config.queue) {\n    notifications.push(notification);\n  } else {\n    // Cap at maxVisible\n    if (notifications.length >= config.maxVisible) {\n      notifications.shift();\n    }\n    notifications.push(notification);\n  }\n\n  // Play sound\n  if (config.soundEnabled && notification.sound && soundEngine) {\n    soundEngine.play(notification.sound, notification.volume).catch(() => {\n      // Silently fail on sound errors\n    });\n  }\n\n  // Emit event\n  emit({ type: \"show\", notification });\n\n  // Auto-dismiss for toasts and alerts\n  if (notification.variant !== \"modal\" && notification.duration > 0) {\n    setTimeout(() => {\n      dismiss(notification.id);\n    }, notification.duration);\n  }\n\n  return notification.id;\n}\n\n// ─── Dismiss ───────────────────────────────────────────────────\nexport function dismiss(id: string): void {\n  const notification = notifications.find((n) => n.id === id);\n  if (!notification) return;\n\n  notifications = notifications.filter((n) => n.id !== id);\n  emit({ type: \"dismiss\", notification });\n}\n\nexport function dismissAll(): void {\n  notifications = [];\n  emit({ type: \"dismiss-all\" });\n}\n"],"mappings":";AAEA,IAAM,iBAA+B;AAAA,EACnC,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAAA,EACd,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,OAAO;AACT;AAEA,IAAI,gBAA8B,EAAE,GAAG,eAAe;AAE/C,SAAS,YAA0B;AACxC,SAAO,EAAE,GAAG,cAAc;AAC5B;AAEO,SAAS,UAAU,SAAsC;AAC9D,kBAAgB,EAAE,GAAG,eAAe,GAAG,QAAQ;AACjD;AAEO,SAAS,SAAS,OAAwB;AAC/C,gBAAc,QAAQ;AACxB;AAEO,SAAS,cAAoB;AAClC,kBAAgB,EAAE,GAAG,eAAe;AACtC;;;ACzBA,IAAM,kBAA6C;AAAA,EACjD,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AAAA,EACP,UAAU;AACZ;AAEA,IAAM,eAAuC,CAAC;AAEvC,SAAS,YAAY,OAAmC;AAC7D,MAAI,SAAS,iBAAiB;AAC5B,WAAO,gBAAgB,KAAkB;AAAA,EAC3C;AACA,MAAI,SAAS,cAAc;AACzB,WAAO,aAAa,KAAK;AAAA,EAC3B;AAEA,SAAO;AACT;AAEO,SAAS,eAAe,OAAwB;AACrD,SAAO,SAAS;AAClB;AAEO,SAAS,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