import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Button } from "antd";
import { ProgressButton } from "../../Components/ProgressButton";
import { useActions, useAppState } from "../../overmind";
import { useEffect, useState } from "react";
import Paragraph from "antd/lib/typography/Paragraph";
import SupportBox from "../../Components/SupportBox";
const InitSteps = () => {
    return {
        HASH_VERIFY: {
            link: "/",
            action: "flows.user.create.verifyHash",
        },
        AUTHENTICATE: {
            link: "/signup/auth",
            action: "",
        },
        SELECT_DOMAIN: {
            link: "/signup/domain",
            action: "",
        },
        SUBSCRIBE: {
            title: "",
            action: "payments.pay",
            link: "/signup/subscribe",
        },
        CREATE_USER: {
            title: "",
            action: "api.user.create",
            link: "/",
        },
    };
};
export const NextButton = ({ isErrorSubmit = false, nextProps, visible = true, contentDescription }) => {
    const actions = useActions();
    const state = useAppState();
    const [_next, setNext] = useState(nextProps);
    const [steps] = useState(InitSteps());
    const wizard = state.flows.user.create.wizard;
    const next = _next;
    const currentSlide = steps[wizard.current];
    useEffect(() => {
        !nextProps && wizard.hasNext && setNext(undefined);
    }, [wizard.hasNext, wizard.current]); // wizard.hasNext,
    const isMember = (state.newcoin.pools || {})["CGY"] > 1087;
    useEffect(() => {
        if (isMember)
            actions.routing.historyPush({ location: "/explore" });
    }, [isMember]);
    if (isMember ||
        (state.indicators.isWorking &&
            !state.flows.user.create.form.username &&
            !state.api.auth.authorized &&
            !state.api.auth.attempted &&
            state.firebase.token))
        return _jsx(_Fragment, {});
    return (_jsxs("div", { className: "nl-onboarding-footer", children: [_jsx("div", { className: "app-control-surface", children: visible ? (next || wizard.hasNext ? (currentSlide.action ? (_jsx(ProgressButton, { type: "primary", progressText: "Processing...", actionName: currentSlide.action, onClick: () => {
                        return next ? next.command() : actions.flows.user.create.wizardStepNext();
                    }, isErrorSubmit: isErrorSubmit, children: next ? next.text : "Next" })) : (_jsx(Button, { type: "primary", disabled: isErrorSubmit, onClick: () => {
                        return next ? next.command() : actions.flows.user.create.wizardStepNext();
                    }, className: isErrorSubmit ? "disabled-submit-button" : "", children: next ? next.text : "Next" }))) : null) : null }), _jsxs("div", { className: "nl-domain-presale__info-text__wrapper", children: [_jsx(Paragraph, { className: "paragraph-2r nl-domain-presale__footer-paragraph", children: contentDescription }), _jsx(SupportBox, {})] })] }));
};
//# sourceMappingURL=NextButton.js.map