import { useMemo } from "react";
export function useReplacedURI(uri, id) {
    return useMemo(() => {
        return uri && id ? uri.replace(/protect-(simu|local-dev|staging)/, id) : undefined;
    }, [id, uri]);
}
function usePath(servicesConfig, uri) {
    return useMemo(() => {
        return servicesConfig?.enabled ? uri?.replace("ledgerlive://", "/") : undefined;
    }, [servicesConfig?.enabled, uri]);
}
export function usePostOnboardingURI(servicesConfig) {
    const uri = servicesConfig?.params?.onboardingRestore?.postOnboardingURI;
    const id = servicesConfig?.params?.protectId;
    return useReplacedURI(uri, id);
}
export function useQuickAccessURI(servicesConfig) {
    const uri = servicesConfig?.params?.managerStatesData?.NEW?.quickAccessURI;
    const id = servicesConfig?.params?.protectId;
    return useReplacedURI(uri, id);
}
export function useAlreadyOnboardedURI(servicesConfig) {
    const uri = servicesConfig?.params?.managerStatesData?.NEW?.alreadyOnboardedURI;
    const id = servicesConfig?.params?.protectId;
    return useReplacedURI(uri, id);
}
export function useHomeURI(servicesConfig) {
    const uri = servicesConfig?.params?.account?.homeURI;
    const id = servicesConfig?.params?.protectId;
    return useReplacedURI(uri, id);
}
export function useUpsellURI(servicesConfig) {
    const uri = servicesConfig?.params?.onboardingCompleted?.upsellURI;
    const id = servicesConfig?.params?.protectId;
    return useReplacedURI(uri, id);
}
export function useUpsellPath(servicesConfig) {
    const uri = useUpsellURI(servicesConfig);
    return usePath(servicesConfig, uri);
}
export function useRestore24URI(servicesConfig) {
    const uri = servicesConfig?.params?.onboardingCompleted?.restore24URI;
    const id = servicesConfig?.params?.protectId;
    return useReplacedURI(uri, id);
}
export function useRestore24Path(servicesConfig) {
    const uri = useRestore24URI(servicesConfig);
    return usePath(servicesConfig, uri);
}
export function useAccountURI(servicesConfig) {
    const uri = servicesConfig?.params?.account?.homeURI;
    const id = servicesConfig?.params?.protectId;
    return useReplacedURI(uri, id);
}
export function useAccountPath(servicesConfig) {
    const uri = useAccountURI(servicesConfig);
    return usePath(servicesConfig, uri);
}
export function useAlreadySeededDeviceURI(servicesConfig) {
    const uri = servicesConfig?.params?.onboardingCompleted?.alreadyDeviceSeededURI;
    const id = servicesConfig?.params?.protectId;
    return useReplacedURI(uri, id);
}
export function useAlreadySeededDevicePath(servicesConfig) {
    const uri = useAlreadySeededDeviceURI(servicesConfig);
    return usePath(servicesConfig, uri);
}
export function useCustomURI(servicesConfig, page, source, deeplinkCampaign) {
    const customUri = 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();
}
export function useCustomPath(servicesConfig, page, source, deeplinkCampaign) {
    const uri = useCustomURI(servicesConfig, page, source, deeplinkCampaign);
    return usePath(servicesConfig, uri);
}
export var Source;
(function (Source) {
    Source["LLM_ONBOARDING_24"] = "llm-onboarding-24";
    Source["LLD_ONBOARDING_24"] = "lld-onboarding-24";
})(Source || (Source = {}));
export function useTouchScreenOnboardingUpsellURI(servicesConfig, source) {
    const campaign = "touchscreen-onboarding";
    return useCustomURI(servicesConfig, "upsell", source, campaign);
}
export function useTouchScreenOnboardingUpsellPath(servicesConfig, source) {
    const uri = useTouchScreenOnboardingUpsellURI(servicesConfig, source);
    return usePath(servicesConfig, uri);
}
//# sourceMappingURL=recoverFeatureFlag.js.map