import React from "react";
//@ts-ignore
import BrowserOnly from "@docusaurus/BrowserOnly";
import { useEndpoint } from "@strata-foundation/react";
import { WalletAdapterNetwork } from "@solana/wallet-adapter-base";
import { useWallet } from "@solana/wallet-adapter-react";
import { WalletModalProvider, WalletMultiButton, } from "@solana/wallet-adapter-react-ui";
import { Swap } from "@strata-foundation/react";
import { SplTokenCollective } from "@strata-foundation/spl-token-collective";
//@ts-ignore
import styles from "./styles.module.css";
const MainnetGuard = ({ children = null }) => {
    const { endpoint, setClusterOrEndpoint } = useEndpoint();
    if (endpoint.includes("devnet")) {
        return (React.createElement("div", { className: styles.container },
            React.createElement("button", { onClick: () => {
                    setClusterOrEndpoint(WalletAdapterNetwork.Mainnet);
                }, className: "white button button--primary" }, "Switch to Mainnet")));
    }
    return children;
};
export const Buy = () => {
    const mintKey = SplTokenCollective.OPEN_COLLECTIVE_MINT_ID;
    const { connected, publicKey } = useWallet();
    return (React.createElement("div", { className: styles.container },
        !connected && (React.createElement(WalletModalProvider, null,
            React.createElement(WalletMultiButton, null))),
        connected && React.createElement(Swap, { id: mintKey })));
};
export const BuyOpen = () => (React.createElement(BrowserOnly, { fallback: React.createElement("div", null, "...") }, () => (React.createElement(MainnetGuard, null,
    React.createElement(Buy, null)))));
//# sourceMappingURL=index.js.map