{ "version": 3, "sources": ["../../assets/scripts/store/features/alerts/index.tsx", "../../assets/scripts/store/features/alerts/Alert.tsx"], "sourcesContent": ["import { emitter, EmitterEvent } from '@app/store/events';\r\nimport type { IAlert } from '@store/types';\r\nimport React, { useCallback, useEffect, useRef, useState } from 'react';\r\n\r\nimport Alert from './Alert';\r\n\r\nexport interface StoreAlertsProps {\r\n alerts: IAlert[];\r\n}\r\n\r\nexport default function StoreAlerts(props: StoreAlertsProps) {\r\n const [alerts, setAlerts] = useState(props.alerts ?? []);\r\n\r\n const hasRun = useRef(false);\r\n\r\n const onClose = useCallback(\r\n (id: string) => setAlerts(state => state.filter(r => r.id !== id)),\r\n []\r\n );\r\n\r\n useEffect(() => {\r\n if (hasRun.current) return;\r\n hasRun.current = true;\r\n\r\n const add = (alert: IAlert) => {\r\n if (!alert) return;\r\n setAlerts(state => [alert, ...state]);\r\n };\r\n\r\n emitter.on(EmitterEvent.Alert, add);\r\n\r\n return () => {\r\n if (hasRun.current) return;\r\n\r\n emitter.off(EmitterEvent.Alert, add);\r\n };\r\n }, []);\r\n\r\n if (alerts.length === 0) return <>;\r\n\r\n return (\r\n
\r\n {alerts.map(alert => (\r\n \r\n ))}\r\n
\r\n );\r\n}\r\n", "import type { IAlert } from '@store/types';\r\nimport { AlertLevel } from '@store/types';\r\nimport React, { useEffect } from 'react';\r\n\r\ninterface IProps extends IAlert {\r\n onClose: (id: string) => void;\r\n timeout?: number;\r\n}\r\n\r\nexport default function Alert({ onClose, timeout = 3000, ...alert }: IProps) {\r\n useEffect(() => {\r\n let timer: NodeJS.Timeout;\r\n if (timeout !== undefined && !isNaN(timeout)) {\r\n timer = setTimeout(() => onClose(alert.id), timeout);\r\n }\r\n\r\n return () => {\r\n if (timer) clearTimeout(timer);\r\n };\r\n }, [alert.id, onClose, timeout]);\r\n\r\n return (\r\n \r\n
{alert.message}
\r\n
\r\n \r\n
\r\n \r\n );\r\n}\r\n"], "mappings": ";;;;;;;;;;;;AAEA,IAAAA,gB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