import { __read } from "tslib";
import React, { createContext, useContext, useMemo, useState, useEffect } from "react";
var TabContext = createContext(null);
TabContext.displayName = "TabContext";
export var TabProvider = function (_a) {
    var children = _a.children, value = _a.value, isLazy = _a.isLazy;
    var _b = __read(useState(value), 2), selectedValue = _b[0], setSelectedValue = _b[1];
    var handleChange = function (currentValue) {
        setSelectedValue(currentValue);
    };
    var context = useMemo(function () { return ({
        value: selectedValue,
        onChange: handleChange,
        isLazy: isLazy
    }); }, [selectedValue]);
    useEffect(function () {
        setSelectedValue(value);
    }, []);
    return React.createElement(TabContext.Provider, { value: context }, children);
};
export var useTabContext = function () {
    return useContext(TabContext);
};
