import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
import { Box, Button, Typography } from '@mui/material';
import PropTypes from 'prop-types';
import { joinURL } from 'ufo';
import getSafeUrlWithToast from '../../../util/get-safe-url';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
function UploadedToast({
  storeUrl,
  storeName,
  published,
  did = '',
  version = ''
}) {
  const {
    t
  } = useLocaleContext();
  const handleOpenUrl = () => {
    window.open(getSafeUrlWithToast(`${joinURL(storeUrl, did && version ? `/blocklets/${did}/${version}` : '/search?menu=my-blocklets')}`, {
      allowDomains: null
    }));
  };
  return /*#__PURE__*/_jsxs(Box, {
    children: [/*#__PURE__*/_jsx(Typography, {
      variant: "subtitle2",
      children: t(published ? 'blocklet.publish.publishToStoreSuccess' : 'blocklet.publish.uploadToStoreSuccess', {
        name: storeName
      })
    }), /*#__PURE__*/_jsx(Button, {
      size: "small",
      sx: {
        mt: 1
      },
      onClick: handleOpenUrl,
      variant: "contained",
      color: "success",
      children: t('common.visitTarget', {
        name: storeName
      })
    })]
  });
}
UploadedToast.propTypes = {
  storeName: PropTypes.string.isRequired,
  storeUrl: PropTypes.string.isRequired,
  published: PropTypes.bool.isRequired,
  did: PropTypes.string,
  version: PropTypes.string
};
export default UploadedToast;