import React from "react";
import { Content } from "./components/Content";
import { LocalContentProvider } from "./context";
import { schema } from "./schema";
import { TrackingProvider, initializeAnalytics } from "~/tracking";
// TODO Move this import to sdks/sdks-app/src/App.tsx once all SDKs are migrated
import "~/assets/styles/globals.css";
import { ValidateOptions } from "~/components/ValidateOptions";
import { LocalLogicProvider } from "~/context/LocalLogicProvider";
import { useStateManagerContext } from "~/context/stateManager";
import { useResponsiveBreakpoints } from "~/hooks/useResponsiveBreakpoints";
import { ProductNames } from "~/types";
import { ANALYTICS_SETTINGS } from "~/constants/analytics";
initializeAnalytics(ANALYTICS_SETTINGS.localContent.key);
const LocalContent = () => {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
    const { sdkState } = useStateManagerContext();
    const breakpoints = useResponsiveBreakpoints();
    const locale = ((_a = sdkState.globalOptions) === null || _a === void 0 ? void 0 : _a.locale) || "en";
    if (Object.hasOwnProperty.call(((_c = (_b = sdkState === null || sdkState === void 0 ? void 0 : sdkState.options) === null || _b === void 0 ? void 0 : _b.scoresMenu) === null || _c === void 0 ? void 0 : _c.categories) || {}, "wellness")) {
        try {
            // Remove wellness category if it exists in the options
            sdkState.options.scoresMenu.categories.health = Object.assign(Object.assign({}, sdkState.options.scoresMenu.categories.health), (_f = (_e = (_d = sdkState.options) === null || _d === void 0 ? void 0 : _d.scoresMenu) === null || _e === void 0 ? void 0 : _e.categories) === null || _f === void 0 ? void 0 : _f.wellness);
            // @ts-expect-error -- We renamed the category, so TS gets confused here
            delete sdkState.options.scoresMenu.categories.wellness;
            console.warn("[Local Content SDK] The 'wellness' scores category has been renamed to 'health'. Please update your SDK options accordingly.");
        }
        catch (_error) {
            // Do nothing
        }
    }
    return (React.createElement(ValidateOptions, { sdk: "Local Content", schema: schema, options: sdkState.options },
        React.createElement(LocalLogicProvider, { environment: (_h = (_g = sdkState.globalOptions) === null || _g === void 0 ? void 0 : _g.environment) === null || _h === void 0 ? void 0 : _h.api, apiKey: sdkState.apiKey, appearance: (_j = sdkState.globalOptions) === null || _j === void 0 ? void 0 : _j.appearance, locale: (_k = sdkState.globalOptions) === null || _k === void 0 ? void 0 : _k.locale, product: ProductNames.LOCAL_CONTENT },
            React.createElement(TrackingProvider, { trackingPipelineSettings: {
                    apiKey: sdkState.apiKey || "",
                }, analyticsSettings: ANALYTICS_SETTINGS.localContent, meta: {
                    clientId: sdkState.clientId,
                    productName: ProductNames.LOCAL_CONTENT,
                    productVersion: FULL_APP_VERSION,
                }, attributes: {
                    location: {
                        lat: (_l = sdkState.options) === null || _l === void 0 ? void 0 : _l.lat,
                        lng: (_m = sdkState.options) === null || _m === void 0 ? void 0 : _m.lng,
                    },
                    host: sdkState.location,
                    host_url: document.referrer,
                    locale,
                    // The mobile experience is enabled from below the sm breakpoint
                    isMobile: !breakpoints.sm,
                    mapProvider: (_p = (_o = sdkState.options) === null || _o === void 0 ? void 0 : _o.mapProvider) === null || _p === void 0 ? void 0 : _p.name,
                }, flags: {
                    isDebugMode: import.meta.env.VITE_TRACKING_PIPELINE_DEBUG === "true",
                } },
                React.createElement(LocalContentProvider, null,
                    React.createElement(Content, null))))));
};
export default LocalContent;
//# sourceMappingURL=index.js.map