import { globalProps } from '@bigbinary/neeto-commons-frontend/initializers';
import Button from '@bigbinary/neetoui/Button';
import Modal from '@bigbinary/neetoui/Modal';
import Typography from '@bigbinary/neetoui/Typography';
import { useTranslation, Trans } from 'react-i18next';
import { useMutation } from '@tanstack/react-query';
import axios from 'axios';
import { jsxs, jsx } from 'react/jsx-runtime';

var create = function create() {
  return axios.post("/neeto_sso/api/v1/subscription_request");
};
var subscriptionRequestApi = {
  create: create
};

var useCreateSubscriptionRequest = function useCreateSubscriptionRequest() {
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
    onSuccess = _ref.onSuccess;
  return useMutation({
    mutationFn: subscriptionRequestApi.create,
    onSuccess: onSuccess
  });
};

var SubscriptionUpgradeRequestModal = function SubscriptionUpgradeRequestModal(_ref) {
  var _globalProps$appName;
  var isOpen = _ref.isOpen,
    onClose = _ref.onClose;
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  var pricingPageUrl = "https://neeto.com/".concat((_globalProps$appName = globalProps.appName) === null || _globalProps$appName === void 0 ? void 0 : _globalProps$appName.toLowerCase(), "/pricing");
  var _useCreateSubscriptio = useCreateSubscriptionRequest({
      onSuccess: onClose
    }),
    sendRequest = _useCreateSubscriptio.mutate,
    isPending = _useCreateSubscriptio.isPending;
  return /*#__PURE__*/jsxs(Modal, {
    isOpen: isOpen,
    onClose: onClose,
    closeOnEsc: !isPending,
    closeOnOutsideClick: !isPending,
    children: [/*#__PURE__*/jsx(Modal.Header, {
      children: /*#__PURE__*/jsx(Typography, {
        style: "h3",
        weight: "semibold",
        children: t("neetoMolecules.subscriptionRequest.title")
      })
    }), /*#__PURE__*/jsxs(Modal.Body, {
      children: [/*#__PURE__*/jsx(Typography, {
        style: "body2",
        children: /*#__PURE__*/jsx(Trans, {
          components: {
            strong: /*#__PURE__*/jsx("strong", {})
          },
          i18nKey: "neetoMolecules.subscriptionRequest.description"
        })
      }), /*#__PURE__*/jsx(Typography, {
        className: "mt-3",
        style: "body2",
        children: /*#__PURE__*/jsx(Trans, {
          i18nKey: "neetoMolecules.subscriptionRequest.pricingInfo",
          components: {
            pricingLink: /*#__PURE__*/jsx("a", {
              className: "neeto-ui-text-primary-500",
              href: pricingPageUrl,
              rel: "noopener noreferrer",
              target: "_blank"
            })
          }
        })
      })]
    }), /*#__PURE__*/jsxs(Modal.Footer, {
      className: "flex gap-x-2",
      children: [/*#__PURE__*/jsx(Button, {
        disabled: isPending,
        label: t("neetoMolecules.subscriptionRequest.cancel"),
        style: "secondary",
        onClick: onClose
      }), /*#__PURE__*/jsx(Button, {
        disabled: isPending,
        label: t("neetoMolecules.subscriptionRequest.sendRequest"),
        loading: isPending,
        style: "primary",
        onClick: sendRequest
      })]
    })]
  });
};

export { SubscriptionUpgradeRequestModal as default };
//# sourceMappingURL=SubscriptionUpgradeRequestModal.js.map
