import { ESourceAuthorization } from "@/api/resources/User";
import { ELocalesPlacement } from "@/locales";
import { anonymousPrefix, chatsPrefix, compatibilityV2Prefix, compatibilityV3Prefix, compatibilityV4Prefix, palmistryV1Prefix } from "@/routes";

export const getSourceByPathname = (): ESourceAuthorization => {
    if (location.pathname.includes(anonymousPrefix)) {
        return ESourceAuthorization["aura.test.payment"];
    }

    if (location.pathname.includes(palmistryV1Prefix)) {
        return ESourceAuthorization["aura.palmistry.new"];
    }

    if (location.pathname.includes("/palmistry")) {
        return ESourceAuthorization["aura.palmistry"];
    }

    if (location.pathname.includes(chatsPrefix)) {
        return ESourceAuthorization["aura.chats"];
    }

    if (location.pathname.includes(compatibilityV2Prefix)) {
        return ESourceAuthorization["aura.compatibility.v2"];
    }

    if (location.pathname.includes(compatibilityV3Prefix)) {
        return ESourceAuthorization["aura.compatibility.v3"];
    }

    if (location.pathname.includes(compatibilityV4Prefix)) {
        return ESourceAuthorization["aura.compatibility.v4"];
    }

    return ESourceAuthorization["aura.main.new"];
}

// TODO: add all paths
export const getLocalesPlacementByPathname = (): ELocalesPlacement => {
    if (location.pathname.includes(palmistryV1Prefix)) {
        return ELocalesPlacement.PalmistryV1;
    }

    if (location.pathname.includes("/palmistry")) {
        return ELocalesPlacement.PalmistryV0;
    }

    if (location.pathname.includes(chatsPrefix)) {
        return ELocalesPlacement.Chats;
    }

    if (location.pathname.includes(compatibilityV2Prefix)) {
        return ELocalesPlacement.CompatibilityV2;
    }

    if (location.pathname.includes(compatibilityV3Prefix)) {
        return ELocalesPlacement.CompatibilityV3;
    }

    if (location.pathname.includes(compatibilityV4Prefix)) {
        return ELocalesPlacement.CompatibilityV4;
    }

    return ELocalesPlacement.V0;
}