import React from "react";
import { useRouter } from "@tanstack/react-location";
import { LDProvider, useFlags, useLDClient, basicLogger, } from "launchdarkly-react-client-sdk";
import { useStateManagerContext } from "../stateManager";
const FeatureFlagProvider = ({ children }) => {
    var _a;
    const { sdkState } = useStateManagerContext();
    const router = useRouter();
    return (React.createElement(LDProvider, { clientSideID: import.meta.env.VITE_LAUNCH_DARKLY_KEY, context: {
            kind: "organization",
            // Switching to clientId instead of sending the complete apiKey
            key: sdkState.clientId,
            custom: {
                locale: ((_a = sdkState.globalOptions) === null || _a === void 0 ? void 0 : _a.locale) || "en",
                /**
                 * Set the 'sdk' value to the current SDK, which can be found in the
                 * location pathname.
                 */
                sdk: router.state.location.pathname.split("/")[3],
            },
        }, reactOptions: {
            sendEventsOnFlagRead: true,
        }, options: {
            streaming: true,
            logger: basicLogger({ level: "none" }),
        } }, children));
};
export { FeatureFlagProvider, useFlags, useLDClient };
//# sourceMappingURL=index.js.map