import React, { useState, useEffect } from "react";
import EmptyState from "../EmptyState/EmptyState";
import IconProp from "../../../Types/Icon/IconProp";
const OfflineIndicator = ({ onOnlineOfflineChange, }) => {
    const [isOnline, setIsOnline] = useState(navigator.onLine);
    useEffect(() => {
        const handleOnline = () => {
            setIsOnline(true);
            onOnlineOfflineChange === null || onOnlineOfflineChange === void 0 ? void 0 : onOnlineOfflineChange(true);
        };
        const handleOffline = () => {
            setIsOnline(false);
            onOnlineOfflineChange === null || onOnlineOfflineChange === void 0 ? void 0 : onOnlineOfflineChange(false);
        };
        window.addEventListener("online", handleOnline);
        window.addEventListener("offline", handleOffline);
        // Call with initial state
        onOnlineOfflineChange === null || onOnlineOfflineChange === void 0 ? void 0 : onOnlineOfflineChange(navigator.onLine);
        return () => {
            window.removeEventListener("online", handleOnline);
            window.removeEventListener("offline", handleOffline);
        };
    }, [onOnlineOfflineChange]);
    return (React.createElement("div", null, !isOnline && (React.createElement(EmptyState, { id: "offline-indicator", title: "You are offline", description: "Please check your internet connection.", icon: IconProp.NoSignal }))));
};
export default OfflineIndicator;
//# sourceMappingURL=OfflineIndicator.js.map