import React, { useEffect, useState } from "react";
export var HelpCenterHintType;
(function (HelpCenterHintType) {
    HelpCenterHintType["HelpCenter"] = "help-center";
    HelpCenterHintType["Onboarding"] = "onboarding";
})(HelpCenterHintType || (HelpCenterHintType = {}));
export const C3HelpCenterContext = React.createContext({
    openHelpCenter: () => undefined,
    setIsHelpCenterOpen: () => undefined,
    isHelpCenterOpen: false,
    showHint: false,
    setShowHint: () => undefined,
    setShowHintOnClose: () => undefined,
    hintType: HelpCenterHintType.Onboarding,
    setHintType: () => undefined,
});
export const C3HelpCenterProvider = ({ children }) => {
    const [isHelpCenterOpen, setIsHelpCenterOpen] = useState(false);
    const [activeTabId, setActiveTabId] = useState(null);
    const [showHint, setShowHint] = useState(false);
    const [showHintOnClose, setShowHintOnClose] = useState(false);
    const [hintType, setHintType] = useState(HelpCenterHintType.Onboarding);
    const openHelpCenter = (showTabId) => {
        if (!isHelpCenterOpen) {
            setIsHelpCenterOpen(true);
            setShowHint(false);
        }
        if (showTabId)
            setActiveTabId(showTabId);
    };
    useEffect(() => {
        if (!isHelpCenterOpen) {
            setActiveTabId(null);
            if (showHintOnClose) {
                setShowHintOnClose(false);
                setTimeout(() => setShowHint(true), 240);
            }
        }
    }, [isHelpCenterOpen]);
    return (React.createElement(C3HelpCenterContext.Provider, { value: {
            openHelpCenter,
            setIsHelpCenterOpen,
            isHelpCenterOpen,
            showTabId: activeTabId,
            showHint,
            setShowHint,
            setShowHintOnClose,
            hintType,
            setHintType,
        } }, children));
};
export const useC3HelpCenter = () => React.useContext(C3HelpCenterContext);
