import { jsx as _jsx } from "react/jsx-runtime";
import { createContext, useContext, useEffect } from 'react';
import { CreatorTrackerBuilder, createCreatorEventTracker as createTracker } from '../trackers/creator.js';
export const CreatorTrackingContext = createContext({
    createTracker: () => () => { }
});
export const useCreatorTracking = () => useContext(CreatorTrackingContext);
function useCreatorTrackingProvider({ context, children }) {
    useEffect(() => {
        if (context) {
            CreatorTrackerBuilder.context = context;
        }
    }, [context]);
    return {
        children,
        createTracker
    };
}
const CreatorTrackingProviderView = ({ children, createTracker }) => (_jsx(CreatorTrackingContext.Provider, { value: { createTracker }, children: children }));
export const CreatorTrackingProvider = props => CreatorTrackingProviderView(useCreatorTrackingProvider(props));
export default CreatorTrackingProvider;
