import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { getNetworkIconId } from "../utils";
import Image from "./Image";
function AddNetwork(props) {
    const { chainConfig, appOrigin, onAddNetwork, onCancelNetwork } = props;
    const [showModal, setShowModal] = useState(true);
    const [networkIconId, setNetworkIconId] = useState("network-default");
    const [t] = useTranslation();
    useEffect(() => {
        getNetworkIconId(chainConfig.ticker)
            .then((id) => {
            return setNetworkIconId(id);
        })
            .catch(() => { });
    }, [chainConfig.ticker]);
    return (showModal && (_jsx("div", Object.assign({ id: "w3a-modal-network" }, { children: _jsxs("div", Object.assign({ className: "w3a-switch-network" }, { children: [_jsx("div", Object.assign({ className: "w3a-switch-network__title" }, { children: t("modal.network.add-request") })), _jsx("div", { children: _jsx("a", Object.assign({ className: "w3a-switch-network__link", href: appOrigin }, { children: appOrigin })) }), _jsx("div", Object.assign({ className: "w3a-switch-network__connect" }, { children: _jsxs("div", { children: [_jsx("div", Object.assign({ className: "w3a-switch-network__logo" }, { children: _jsx(Image, { imageId: networkIconId }) })), _jsx("div", { children: _jsx("div", { children: chainConfig.displayName }) })] }) })), _jsxs("div", Object.assign({ className: "w3a-switch-network__buttons" }, { children: [_jsx("button", Object.assign({ type: "button", className: "w3a-button", onClick: () => {
                                setShowModal(false);
                                onCancelNetwork();
                            } }, { children: t("modal.network.cancel") })), _jsx("button", Object.assign({ type: "button", className: "w3a-button w3a-button--primary", onClick: () => {
                                setShowModal(false);
                                onAddNetwork(chainConfig.chainId);
                            } }, { children: t("modal.network.proceed") }))] }))] })) }))));
}
export default AddNetwork;
//# sourceMappingURL=AddNetwork.js.map