import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import React, { useCallback } from "react";
import styled, { useTheme } from "styled-components";
import Link from "../link";
import { Box } from "../../../grid";
import { t } from "ttag";
const Divider = styled.div `
  margin: 10px 16px;
  width: calc(100% - 32px);
  height: 1px;
  background: #ccdae9;
`;
const EQ_WEBSITE_URL_PROD = "https://equilibrium.io";
const EQ_APP_GATEWAY_PROD = "https://app.equilibrium.io";
const EOSDT_WEBSITE_URL_PROD = "https://eosdt.com";
const EQLAB_WEBSITE_URL_PROD = "https://eqlab.io";
const EQ_APP_PLO_PROD = "https://plo.equilibrium.io/";
const EQ_WEBSITE_URL_STAGE = "https://equilibrium.stage.eq";
const EQ_APP_GATEWAY_STAGE = "https://equilibrium.stage.eq";
const EOSDT_WEBSITE_URL_STAGE = "https://eosdt.stage.eq";
const EQLAB_WEBSITE_URL_STAGE = "https://eqlab.stage.eq";
const EQ_APP_PLO_STAGE = "https://plo-web.stage.eq";
const EQ_WEBSITE_URL_DEV = "https://equilibrium.dev.eq";
const EQ_APP_GATEWAY_DEV = "https://equilibrium.dev.eq";
const EOSDT_WEBSITE_URL_DEV = "https://eosdt.dev.eq";
const EQLAB_WEBSITE_URL_DEV = "https://eqlab.dev.eq";
const EQ_APP_PLO_DEV = "https://plo-web.dev.eq";
const URL_LOCAL = "http://localhost:3000";
const GENSHIRO_WEBSITE_STAGE = "https://genshiro.stage.eq";
const GENSHIRO_WEBSITE_PROD = "https://genshiro.equilibrium.io";
const getSubPageName = () => {
    if (!globalThis.location)
        return "";
    return globalThis.location.pathname.split("/")[2];
};
const containsSubPage = (page) => {
    if (!globalThis.location)
        return false;
    const path = globalThis.location.pathname;
    return path.indexOf(page) !== -1;
};
const getEnvironment = () => {
    if (!globalThis.location)
        return "prod";
    if (globalThis.location.href.includes("dev"))
        return "dev";
    if (globalThis.location.href.includes("stage"))
        return "stage";
    if (globalThis.location.href.includes("localhost"))
        return "local";
    return "prod";
};
/** @deprecated */
const getBaseUrl = (site) => {
    const env = getEnvironment();
    if (env === "local")
        return URL_LOCAL;
    if (site === "eq-website") {
        if (env === "dev") {
            return EQ_WEBSITE_URL_DEV;
        }
        if (env === "stage") {
            return EQ_WEBSITE_URL_STAGE;
        }
        return EQ_WEBSITE_URL_PROD;
    }
    if (site === "eq-eqlab-website") {
        if (env === "dev") {
            return EQLAB_WEBSITE_URL_DEV;
        }
        if (env === "stage") {
            return EQLAB_WEBSITE_URL_STAGE;
        }
        return EQLAB_WEBSITE_URL_PROD;
    }
    if (site === "eq-gateway") {
        if (env === "dev") {
            return EQ_APP_GATEWAY_DEV;
        }
        if (env === "stage") {
            return EQ_APP_GATEWAY_STAGE;
        }
        return EQ_APP_GATEWAY_PROD;
    }
    if (site === "eosdt-website") {
        if (env === "dev") {
            return EOSDT_WEBSITE_URL_DEV;
        }
        if (env === "stage") {
            return EOSDT_WEBSITE_URL_STAGE;
        }
        return EOSDT_WEBSITE_URL_PROD;
    }
    if (site === "plo") {
        if (env === "dev") {
            return EQ_APP_PLO_DEV;
        }
        if (env === "stage") {
            return EQ_APP_PLO_STAGE;
        }
        return EQ_APP_PLO_PROD;
    }
    if (site === "genshiro") {
        if (env === "dev") {
            return GENSHIRO_WEBSITE_STAGE;
        }
        if (env === "stage") {
            return GENSHIRO_WEBSITE_STAGE;
        }
        return GENSHIRO_WEBSITE_PROD;
    }
};
const SocMedia = () => (_jsxs(_Fragment, { children: [_jsx(Link, { href: "https://twitter.com/EquilibriumDeFi", secondary: true, children: t `Twitter` }), _jsx(Link, { href: "https://t.me/equilibrium_eosdt_official", secondary: true, children: t `Telegram` }), _jsx(Link, { href: "https://medium.com/equilibrium-eosdt", secondary: true, children: t `Medium` }), _jsx(Link, { href: "https://github.com/equilibrium-eosdt", secondary: true, children: t `Github` }), _jsx(Link, { href: "https://blog.eosdt.com/", secondary: true, children: t `Blog` })] }));
const disabled = (v) => null;
export const MenuLinks = ({ lang, isLanding }) => {
    const { flags } = useTheme();
    const isGenshiro = React.useMemo(() => flags?.isGenshiro, [flags?.isGenshiro]);
    const baseUrl = getBaseUrl(isGenshiro ? "genshiro" : "eq-website");
    const baseEQWebsiteUrl = getBaseUrl("eq-website");
    const isClient = typeof window !== "undefined";
    const location = isClient ? window.location : undefined;
    const isActive = useCallback((route) => {
        if (!location)
            return false;
        return Array.isArray(route)
            ? route.some((e) => e === location.pathname.split("/")?.slice(-1)?.[0])
            : location.pathname.split("/")?.slice(-1)?.[0] === route;
    }, [location?.pathname]);
    return (_jsx(_Fragment, { children: isGenshiro ? (_jsxs(_Fragment, { children: [isLanding && (_jsxs(_Fragment, { children: [_jsx(Link, { href: `${baseEQWebsiteUrl}/${lang}/`, children: t `Equilibrium` }), _jsx(Link, { href: `${baseUrl}/docs/genshiro-tokenomics.pdf`, children: t `GENS tokenomy` }), _jsx(Link, { href: `${baseUrl}/${lang}/plo`, active: isActive("plo"), extraBold: true, children: t `Crowdloan` }), _jsx(Link, { href: `${baseUrl}/${lang}/referral`, active: isActive("referral"), extraBold: true, children: t `Referral program` }), _jsx(Link, { href: `${baseUrl}/${lang}/opt-out`, active: isActive("opt-out"), extraBold: true, children: t `GENS opt-out` })] })), !isLanding && (_jsxs(_Fragment, { children: [_jsx(Link, { href: `/${lang}/market`, active: isActive("market"), smart: true, children: t `Market` }), _jsx(Link, { href: `/${lang}/portfolio/earn`, active: isActive("earn"), smart: true, children: t `Earn` }), _jsx(Link, { href: `/${lang}/portfolio/borrow`, active: isActive("borrow"), smart: true, children: t `Borrow` }), _jsx(Link, { href: `/${lang}/farming`, active: isActive("farming") || isActive("farming-prev"), smart: true, children: t `Farming` }), _jsx(Link, { href: `/${lang}/portfolio/dashboard`, active: isActive("dashboard"), smart: true, children: t `Portfolio` }), _jsx(Link, { href: `/${lang}/trading`, active: isActive("trading"), smart: true, children: t `Trade` }), _jsx(Link, { className: "genshiro-navigation-swap-tokens", href: `/${lang}/curve/buy-and-sell`, active: isActive("buy-and-sell"), smart: true, children: t `Swap tokens` }), _jsx(Link, { href: `/${lang}/allocation`, active: isActive(["allocation", "vesting", "lockdrop-gens"]), smart: true, children: t `Allocation` })] })), false && (_jsxs(_Fragment, { children: [_jsx(Link, { href: `/${lang}/curve/buy-and-sell`, active: isActive("buy-and-sell"), smart: true, children: t `Buy & Sell` }), _jsx(Link, { href: `/${lang}/curve/deposit`, active: isActive(["deposit", "withdraw"]), smart: true, children: t `Deposit/Withdraw` }), _jsx(Link, { href: `/${lang}/curve/dashboard`, active: isActive("dashboard"), smart: true, children: t `Dashboard` })] })), disabled(_jsx(Link, { href: `${baseUrl}/${lang}/nftcats`, active: getSubPageName() === "nftcats", extraBold: true, children: t `NFT Cats` }))] })) : (_jsxs(_Fragment, { children: [_jsx(Link, { href: `${baseUrl}/${lang}/eq-token`, active: getSubPageName() === "eq-token", children: t `EQ Token` }), _jsx(Link, { href: `${baseUrl}/${lang}/careers`, active: getSubPageName() === "careers", children: t `Careers` }), _jsx(Link, { href: `${baseUrl}/${lang}/about`, active: getSubPageName() === "about", children: t `About us` })] })) }));
};
export const EQlabMenuLinks = ({ lang }) => {
    const baseUrl = getBaseUrl("eq-eqlab-website");
    return (_jsxs(_Fragment, { children: [_jsx(Link, { href: `${baseUrl}/${lang}`, active: getSubPageName() !== "about" && getSubPageName() !== "contact-us", children: t `Main` }), _jsx(Link, { href: `${baseUrl}/${lang}/about`, active: getSubPageName() === "about", children: t `About us` }), _jsx(Link, { href: `${baseUrl}/${lang}/contact-us`, active: getSubPageName() === "contact-us", children: t `Contact us` }), _jsx(Link, { href: `https://meetup.eqlab.io/${lang}`, children: t `Meetup` })] }));
};
export const SpecialLinks = ({ lang, isApp, showCurve, list: listFinal /* TODO rename back */ }) => {
    const { flags } = useTheme();
    const isGenshiro = React.useMemo(() => flags?.isGenshiro, [flags?.isGenshiro]);
    const isCurve = React.useMemo(() => flags?.isGenshiro, [flags?.isCurve]);
    const gatewayBaseUrl = getBaseUrl("eq-gateway");
    const genshiroBaseUrl = getBaseUrl("genshiro");
    const ploBaseUrl = getBaseUrl("plo");
    const isPLO = containsSubPage("plo");
    /**
     * @deprecated
     */
    const listTemp = React.useMemo(() => {
        const list = [];
        if (listFinal) {
            return listFinal;
        }
        if (showCurve) {
            list.push({
                url: `${gatewayBaseUrl}/gateway/${lang}/curve`,
                active: isCurve,
                title: t `Curve`,
            });
        }
        if (!isGenshiro) {
            list.push({
                url: `https://xdot.equilibrium.io/${lang}`,
                title: t `Fluid xDOT`,
                active: flags?.isFluidXDot,
            });
            list.push({
                url: `${ploBaseUrl}/${lang}`,
                title: t `Crowdloan`,
                active: isPLO,
            });
        }
        list.push({
            url: isApp ? "/" : `${genshiroBaseUrl}/gateway/${lang}/portfolio/`,
            title: t `Genshiro`,
            active: !isCurve && isApp,
        });
        return list;
    }, [
        listFinal,
        isGenshiro,
        isApp,
        isPLO,
        isCurve,
        showCurve,
        lang,
        gatewayBaseUrl,
        genshiroBaseUrl,
    ]);
    return (_jsx(_Fragment, { children: listTemp.map(({ url, title, active, onClick }) => (_jsx(Link, { href: url, active: active, onClick: onClick, children: title }, title))) }));
};
export const BurgerLinks = ({ lang, onMenuClick }) => {
    const baseUrl = getBaseUrl("eq-website");
    return (_jsxs(_Fragment, { children: [_jsx(Link, { href: `${baseUrl}/${lang}/token-swap`, children: t `NUT/ EQ token swap` }), _jsx(Link, { href: `${baseUrl}/docs/${lang}/EQ_token_economy.pdf`, children: t `Tokenomy` }), _jsx(Link, { href: "", onClick: (e) => {
                    e.preventDefault();
                    if (onMenuClick) {
                        onMenuClick();
                    }
                }, children: t `Whitepaper` }), _jsx(Link, { href: "https://docs.equilibrium.io/", target: "_blank", children: t `Knowledge base` }), _jsx(Divider, {}), _jsx(SocMedia, {})] }));
};
export const MobileLinks = ({ lang, onMenuClick, isApp }) => {
    const baseUrl = getBaseUrl("eq-website");
    const ploBaseUrl = getBaseUrl("plo");
    const genshiroBaseUrl = getBaseUrl("genshiro");
    const baseEQWebsiteUrl = getBaseUrl("eq-website");
    const isGenshiro = process.env.REACT_APP_THEME === "Genshiro";
    const isCurve = containsSubPage("curve");
    return (_jsxs(_Fragment, { children: [isGenshiro ? (_jsxs(_Fragment, { children: [_jsx(Link, { href: `${genshiroBaseUrl}/${lang}/lockdrop`, 
                        // TODO: active state for genshiro menu link
                        active: getSubPageName() === "lockdrop", children: t `Lockdrop` }), _jsx(Link, { href: `${genshiroBaseUrl}/${lang}/nftcats`, active: getSubPageName() === "nftcats", extraBold: true, children: t `NFT Cats` }), _jsx(Link, { href: `${genshiroBaseUrl}/${lang}/plo`, active: getSubPageName() === "plo", extraBold: true, children: t `Crowdloan` }), _jsx(Link, { href: `${genshiroBaseUrl}/${lang}/referral`, active: getSubPageName() === "referral", extraBold: true, children: t `Referral program` }), _jsx(Link, { href: `${genshiroBaseUrl}/${lang}/opt-out`, active: getSubPageName() === "opt-out", extraBold: true, children: t `GENS opt-out` }), _jsx(Link, { href: `${genshiroBaseUrl}/docs/genshiro-tokenomics.pdf`, children: t `GENS tokenomy` }), _jsx(Link, { href: `${baseEQWebsiteUrl}/${lang}/`, children: t `Equilibrium` })] })) : (_jsxs(_Fragment, { children: [_jsx(Link, { href: `${baseUrl}/${lang}/eq-token`, active: getSubPageName() === "eq-token", children: t `EQ Token` }), _jsx(Link, { href: `${baseUrl}/${lang}/careers`, active: getSubPageName() === "careers", children: t `Careers` }), _jsx(Link, { href: `${baseUrl}/${lang}/about`, active: getSubPageName() === "about", children: t `About us` })] })), _jsx(Box, { mt: "20px" }), isGenshiro ? (_jsx(_Fragment, { children: _jsx(Link, { href: `https://genshiro.equilibrium.io/gateway/${lang}/portfolio/`, active: isApp, mobile: true, children: t `Application` }) })) : (_jsxs(_Fragment, { children: [_jsx(Link, { href: `${baseUrl}/docs/${lang}/EQ_token_economy.pdf`, children: t `Tokenomy` }), _jsx(Link, { href: `${baseUrl}/${lang}/token-swap`, active: getSubPageName() === "token-swap", children: t `NUT/ EQ token swap` }), _jsx(Link, { href: "https://docs.equilibrium.io/", target: "_blank", children: t `Knowledge base` }), _jsx(Link, { href: "", onClick: (e) => {
                            e.preventDefault();
                            if (onMenuClick) {
                                onMenuClick();
                            }
                        }, children: t `Whitepaper` }), _jsx(Link, { href: `https://xdot.equilibrium.io/${lang}`, mobile: true, children: t `Fluid xDOT` }), _jsx(Link, { href: `${ploBaseUrl}/${lang}`, active: window.location.hostname.indexOf("plo") !== -1, mobile: true, children: t `Crowdloan` }), _jsx(Link, { href: `${process.env.REACT_APP_GATEWAY}/gateway/${lang}/portfolio/`, active: isCurve ? false : isApp, mobile: true, children: t `Genshiro` })] }))] }));
};
export const EqLabMobileLinks = ({ lang }) => {
    const baseUrl = getBaseUrl("eq-eqlab-website");
    return (_jsxs(_Fragment, { children: [_jsx(Link, { href: `${baseUrl}/${lang}`, active: getSubPageName() !== "about" && getSubPageName() !== "contact-us", children: t `Main` }), _jsx(Link, { href: `${baseUrl}/${lang}/about`, active: getSubPageName() === "about", children: t `About us` }), _jsx(Link, { href: `${baseUrl}/${lang}/contact-us`, active: getSubPageName() === "contact-us", children: t `Contact us` }), _jsx(Link, { href: `https://meetup.eqlab.io/${lang}`, children: t `Meetup` })] }));
};
//# sourceMappingURL=index.js.map