import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import { createContext, useMemo } from 'react';
import { SeamQueryProvider, } from '../../lib/seam/SeamQueryProvider.js';
import { useSeamFont } from '../../lib/seam/use-seam-font.js';
import { useSeamStyles } from '../../lib/seam/use-seam-styles.js';
import { TelemetryProvider, useUserTelemetry, } from '../../lib/telemetry/index.js';
export const seamComponentsClassName = 'seam-components';
export function SeamProvider({ children, disableTelemetry = false, disableCssInjection = false, disableFontInjection = false, unminifiyCss = false, telemetryClient, queryClient, ...props }) {
    useSeamStyles({ disabled: disableCssInjection, unminified: unminifiyCss });
    useSeamFont({ disabled: disableFontInjection });
    const { Provider } = seamContext;
    const endpoint = 'endpoint' in props ? props.endpoint : undefined;
    const value = useMemo(() => {
        const context = createSeamContextValue(props);
        return context;
    }, [props]);
    return (_jsx("div", { className: seamComponentsClassName, children: _jsx(TelemetryProvider, { client: telemetryClient ?? globalThis.seamTelemetryClient, disabled: disableTelemetry, endpoint: endpoint, children: _jsx(SeamQueryProvider, { queryClient: queryClient ?? globalThis.seamQueryClient, ...props, children: _jsx(Provider, { value: value, children: _jsx(Telemetry, { children: children }) }) }) }) }));
}
function Telemetry({ children }) {
    useUserTelemetry();
    return _jsx(_Fragment, { children: children });
}
const createDefaultSeamContextValue = () => {
    try {
        if (globalThis.seam == null) {
            return {};
        }
        return createSeamContextValue(globalThis.seam);
    }
    catch (err) {
        // eslint-disable-next-line no-console
        console.warn(err);
        return {};
    }
};
const createSeamContextValue = (_options) => {
    return {};
};
const defaultSeamContextValue = createDefaultSeamContextValue();
const seamContext = createContext(defaultSeamContextValue);
//# sourceMappingURL=SeamProvider.js.map