import { useMount } from "react-use";
import { useDispatch } from "../../../store/redux-separate-context";
import { getHashParams } from "../../../utils/hash-utils";
import { setAlarmAction, setGlobalPanAndZoomAction } from "../../global/actions";
import { alarmStatuses } from "../../global/constants";
export default () => {
    const dispatch = useDispatch();
    useMount(() => {
        const params = getHashParams();
        const alarmWhen = params["alarm_when"];
        if (alarmWhen) {
            const alarmTime = Number(alarmWhen);
            const alarmStatus = params["alarm_status"];
            const alarmChart = params["alarm_chart"];
            const alarmValue = params["alarm_value"];
            if (!alarmStatuses.includes(alarmStatus) || !alarmChart || !alarmValue) {
                return;
            }
            dispatch(setAlarmAction({
                alarm: {
                    chartId: alarmChart,
                    status: alarmStatus,
                    value: alarmValue,
                    when: alarmTime,
                },
            }));
            const PADDING = 1000 * 60 * 5;
            dispatch(setGlobalPanAndZoomAction({
                after: alarmTime * 1000 - PADDING,
                before: alarmTime * 1000 + PADDING,
            }));
        }
    });
};
//# sourceMappingURL=useAlarmFromUrl.js.map