import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { UserStake } from "./UserWidget";
import { useActions } from "../overmind";
import { useCurrentUserStakeEligibility } from "../hooks/useBlockchainInfo";
const DefaultPrivateContentView = ({ stakeInfo, onClick }) => (_jsx("div", { ...(onClick ? { onClick } : {}), style: {
        position: "absolute",
        left: 0,
        width: "100%",
        padding: 15,
        borderRadius: 30,
        textAlign: "center",
        ...(onClick ? { cursor: "pointer" } : {}),
    }, children: _jsxs("div", { onClick: (e) => onClick && e.stopPropagation(), 
        // we can stake from the list of folders directly
        style: {
            background: "rgba(0,0,0,.3)",
            padding: "20px",
            borderRadius: "8px",
            width: "auto",
            maxWidth: "min(100vw,600px)",
            marginLeft: "auto",
            marginRight: "auto",
        }, children: ["Premium content: stake ", stakeInfo.currentUserNeeds, " $", stakeInfo.currency, " to access.", _jsx("br", {}), _jsx("br", {}), _jsx(UserStake, { onDone: () => { }, user: stakeInfo.owner })] }) }));
export const PremiumContent = ({ stakeToAccess, owner, children, className, style, privateContentView, link, ...rest }) => {
    const actions = useActions();
    const stakeInfo = useCurrentUserStakeEligibility(owner, stakeToAccess);
    const blur = !stakeInfo.currentUserEligible;
    className += "iosdk-premium-content";
    style = {
        ...style,
        ...(blur
            ? {
                filter: "blur(7px)",
            }
            : {}),
    };
    const PrivateContentView = privateContentView || DefaultPrivateContentView;
    const onClick = () => link && actions.routing.historyPush({ location: link });
    return (_jsxs(_Fragment, { children: [_jsx("div", { ...(blur
                    ? {
                        onClickCapture: (e) => {
                            e.preventDefault();
                            onClick();
                        },
                    }
                    : {}), ...rest, style: style, children: children }), blur ? _jsx(PrivateContentView, { stakeInfo: stakeInfo, onClick: onClick }) : _jsx(_Fragment, {})] }));
};
//# sourceMappingURL=PremiumContent.js.map