import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import { Input } from "./Input";
import { SOCIAL_MEDIA } from "../UserWidget";
import { SocialLink } from "../../Components/SocialLink";
import { Success } from "../Icons/Success";
import { stage } from "../../config";
import { useAppState } from "../../overmind";
import Button from "antd/lib/button";
import Form from "antd/lib/form";
export const SocialMediaInputs = ({ enableVerify }) => {
    const state = useAppState();
    const onVerifySocial = (provider) => {
        window.open(`https://api-${stage}.newlife.io/creator/auth/provider/${provider}?token=${state.firebase.token}&redirect_url=${window.location.href}`, "_self");
    };
    const verify = (provider) => {
        if (provider === "soundcloud" || !enableVerify) {
            return false;
        }
        const sanitizedProvider = provider.replace(/[0-9]/g, "");
        return !isSocialVerified(sanitizedProvider) ? (_jsx(Button, { className: "secondary-button nl-social-media-verify", onClick: () => onVerifySocial(provider), children: _jsx("span", { className: "paragraph-2b", children: "Verify" }) })) : (_jsx(Success, {}));
    };
    const getSocialIcon = (social) => {
        return _jsx(SocialLink, { user: state.api.auth.user, platform: social, disableLink: true });
    };
    const isSocialVerified = (social) => {
        return state.api.auth.user.verifiedSocialIds?.includes(social);
    };
    const getSocialMediaInputs = () => {
        return SOCIAL_MEDIA.map((social) => {
            const isVerified = isSocialVerified(social) && enableVerify;
            let cls = `nl-userUpdate-social-input nl-social-input-${social} ${isVerified ? "nl-social-input-verified" : ""} ${!enableVerify ? "nl-social-input-invite" : ""}`;
            return (_jsx(Form.Item, { name: social, rules: social === "instagram" && enableVerify
                    ? [
                        {
                            // required: true,
                            message: "Your instagram please",
                        },
                    ]
                    : undefined, children: _jsx(Input, { placeholder: social, suffix: verify(social === "twitter" || social === "tumblr" ? `${social}2` : social), prefix: getSocialIcon(social), disabled: isVerified, className: cls }) }, social));
        });
    };
    return _jsx(_Fragment, { children: getSocialMediaInputs() });
};
//# sourceMappingURL=SocialMediaInputs.js.map