"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useTouchScreenOnboardingUpsellPath = exports.useTouchScreenOnboardingUpsellURI = exports.Source = exports.useCustomPath = exports.useCustomURI = exports.useAlreadySeededDevicePath = exports.useAlreadySeededDeviceURI = exports.useAccountPath = exports.useAccountURI = exports.useRestore24Path = exports.useRestore24URI = exports.useUpsellPath = exports.useUpsellURI = exports.useHomeURI = exports.useAlreadyOnboardedURI = exports.useQuickAccessURI = exports.usePostOnboardingURI = exports.useReplacedURI = void 0;
const react_1 = require("react");
function useReplacedURI(uri, id) {
    return (0, react_1.useMemo)(() => {
        return uri && id ? uri.replace(/protect-(simu|local-dev|staging)/, id) : undefined;
    }, [id, uri]);
}
exports.useReplacedURI = useReplacedURI;
function usePath(servicesConfig, uri) {
    return (0, react_1.useMemo)(() => {
        return servicesConfig?.enabled ? uri?.replace("ledgerlive://", "/") : undefined;
    }, [servicesConfig?.enabled, uri]);
}
function usePostOnboardingURI(servicesConfig) {
    const uri = servicesConfig?.params?.onboardingRestore?.postOnboardingURI;
    const id = servicesConfig?.params?.protectId;
    return useReplacedURI(uri, id);
}
exports.usePostOnboardingURI = usePostOnboardingURI;
function useQuickAccessURI(servicesConfig) {
    const uri = servicesConfig?.params?.managerStatesData?.NEW?.quickAccessURI;
    const id = servicesConfig?.params?.protectId;
    return useReplacedURI(uri, id);
}
exports.useQuickAccessURI = useQuickAccessURI;
function useAlreadyOnboardedURI(servicesConfig) {
    const uri = servicesConfig?.params?.managerStatesData?.NEW?.alreadyOnboardedURI;
    const id = servicesConfig?.params?.protectId;
    return useReplacedURI(uri, id);
}
exports.useAlreadyOnboardedURI = useAlreadyOnboardedURI;
function useHomeURI(servicesConfig) {
    const uri = servicesConfig?.params?.account?.homeURI;
    const id = servicesConfig?.params?.protectId;
    return useReplacedURI(uri, id);
}
exports.useHomeURI = useHomeURI;
function useUpsellURI(servicesConfig) {
    const uri = servicesConfig?.params?.onboardingCompleted?.upsellURI;
    const id = servicesConfig?.params?.protectId;
    return useReplacedURI(uri, id);
}
exports.useUpsellURI = useUpsellURI;
function useUpsellPath(servicesConfig) {
    const uri = useUpsellURI(servicesConfig);
    return usePath(servicesConfig, uri);
}
exports.useUpsellPath = useUpsellPath;
function useRestore24URI(servicesConfig) {
    const uri = servicesConfig?.params?.onboardingCompleted?.restore24URI;
    const id = servicesConfig?.params?.protectId;
    return useReplacedURI(uri, id);
}
exports.useRestore24URI = useRestore24URI;
function useRestore24Path(servicesConfig) {
    const uri = useRestore24URI(servicesConfig);
    return usePath(servicesConfig, uri);
}
exports.useRestore24Path = useRestore24Path;
function useAccountURI(servicesConfig) {
    const uri = servicesConfig?.params?.account?.homeURI;
    const id = servicesConfig?.params?.protectId;
    return useReplacedURI(uri, id);
}
exports.useAccountURI = useAccountURI;
function useAccountPath(servicesConfig) {
    const uri = useAccountURI(servicesConfig);
    return usePath(servicesConfig, uri);
}
exports.useAccountPath = useAccountPath;
function useAlreadySeededDeviceURI(servicesConfig) {
    const uri = servicesConfig?.params?.onboardingCompleted?.alreadyDeviceSeededURI;
    const id = servicesConfig?.params?.protectId;
    return useReplacedURI(uri, id);
}
exports.useAlreadySeededDeviceURI = useAlreadySeededDeviceURI;
function useAlreadySeededDevicePath(servicesConfig) {
    const uri = useAlreadySeededDeviceURI(servicesConfig);
    return usePath(servicesConfig, uri);
}
exports.useAlreadySeededDevicePath = useAlreadySeededDevicePath;
function useCustomURI(servicesConfig, page, source, deeplinkCampaign) {
    const customUri = (0, react_1.useMemo)(() => {
        const id = servicesConfig?.params?.protectId;
        const basicUri = id ? `ledgerlive://recover/${id}` : "ledgerlive://recover/protect-prod";
        const uri = new URL(basicUri);
        if (page)
            uri.searchParams.append("redirectTo", page);
        if (source)
            uri.searchParams.append("source", source);
        if (source && deeplinkCampaign) {
            uri.searchParams.append("ajs_recover_source", source);
            uri.searchParams.append("ajs_recover_campaign", deeplinkCampaign);
            uri.searchParams.append("ajs_prop_source", source);
            uri.searchParams.append("ajs_prop_campaign", deeplinkCampaign);
        }
        return uri;
    }, [deeplinkCampaign, page, servicesConfig?.params?.protectId, source]);
    return customUri.toString();
}
exports.useCustomURI = useCustomURI;
function useCustomPath(servicesConfig, page, source, deeplinkCampaign) {
    const uri = useCustomURI(servicesConfig, page, source, deeplinkCampaign);
    return usePath(servicesConfig, uri);
}
exports.useCustomPath = useCustomPath;
var Source;
(function (Source) {
    Source["LLM_ONBOARDING_24"] = "llm-onboarding-24";
    Source["LLD_ONBOARDING_24"] = "lld-onboarding-24";
})(Source || (exports.Source = Source = {}));
function useTouchScreenOnboardingUpsellURI(servicesConfig, source) {
    const campaign = "touchscreen-onboarding";
    return useCustomURI(servicesConfig, "upsell", source, campaign);
}
exports.useTouchScreenOnboardingUpsellURI = useTouchScreenOnboardingUpsellURI;
function useTouchScreenOnboardingUpsellPath(servicesConfig, source) {
    const uri = useTouchScreenOnboardingUpsellURI(servicesConfig, source);
    return usePath(servicesConfig, uri);
}
exports.useTouchScreenOnboardingUpsellPath = useTouchScreenOnboardingUpsellPath;
//# sourceMappingURL=recoverFeatureFlag.js.map