import { jsx as _jsx } from "react/jsx-runtime";
import { createContext, useContext, useEffect } from 'react';
import { ConsumerTrackerBuilder, createConsumerEventTracker as createTracker } from '../trackers/consumer.js';
export const ConsumerTrackingContext = createContext({
    createTracker: () => () => { }
});
export const useConsumerTracking = () => useContext(ConsumerTrackingContext);
function useConsumerTrackingProvider({ context, children }) {
    useEffect(() => {
        if (context) {
            ConsumerTrackerBuilder.context = context;
        }
    }, [context]);
    return {
        children,
        createTracker
    };
}
const ConsumerTrackingProviderView = ({ children, createTracker }) => (_jsx(ConsumerTrackingContext.Provider, { value: { createTracker }, children: children }));
export const ConsumerTrackingProvider = props => ConsumerTrackingProviderView(useConsumerTrackingProvider(props));
export default ConsumerTrackingProvider;
