import e from 'react';
import { _ as __rest, a as __assign } from './_tslib-5c49bd3f.js';
import { jsx } from '@emotion/react/jsx-runtime';

var TabProvider = function (_a) {
    var children = _a.children, props = __rest(_a, ["children"]);
    var _b = e.useState(props.activeTabId || ''), activeTabId = _b[0], setActiveTabId = _b[1];
    var handleChange = e.useCallback(function (id) {
        setActiveTabId(id);
        if (props.onChange) {
            props.onChange(id);
        }
    }, [props.onChange]);
    var derivedActiveTabId = props.activeTabId !== undefined ? props.activeTabId : activeTabId;
    var contextValue = e.useMemo(function () { return ({
        activeTabId: derivedActiveTabId,
        onChange: handleChange,
    }); }, [derivedActiveTabId, handleChange]);
    return (jsx(TabContext.Provider, __assign({ value: contextValue }, { children: children }), void 0));
};
var TabContext = e.createContext(null);

export { TabContext, TabProvider };
//# sourceMappingURL=TabProvider.js.map
