"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
module.exports = DynamicPricingUnavailable;
var _jsxRuntime = require("react/jsx-runtime");
var _material = require("@mui/material");
var _iconsMaterial = require("@mui/icons-material");
var _context = require("@arcblock/ux/lib/Locale/context");
var _react = require("react");
function DynamicPricingUnavailable({
  error = void 0,
  onRetry = void 0,
  showRetry = true,
  sx = void 0
}) {
  const {
    t
  } = (0, _context.useLocaleContext)();
  const [retrying, setRetrying] = (0, _react.useState)(false);
  if (error) {
    console.error("[Dynamic Pricing Error]", error);
  }
  const handleRetry = async () => {
    if (!onRetry || retrying) return;
    setRetrying(true);
    try {
      await onRetry();
    } finally {
      setRetrying(false);
    }
  };
  return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Alert, {
    severity: "warning",
    icon: /* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.ErrorOutline, {}),
    sx: {
      borderRadius: 2,
      "& .MuiAlert-message": {
        width: "100%"
      },
      ...sx
    },
    children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
      sx: {
        display: "flex",
        justifyContent: "space-between",
        alignItems: "flex-start",
        width: "100%"
      },
      children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
        children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.AlertTitle, {
          sx: {
            fontWeight: 600
          },
          children: t("payment.dynamicPricing.unavailable.title")
        }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
          variant: "body2",
          sx: {
            color: "text.secondary",
            mt: 0.5
          },
          children: t("payment.dynamicPricing.unavailable.message")
        })]
      }), showRetry && onRetry && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
        size: "small",
        variant: "outlined",
        onClick: handleRetry,
        disabled: retrying,
        startIcon: retrying ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.CircularProgress, {
          size: 16
        }) : /* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.Refresh, {}),
        sx: {
          ml: 2,
          flexShrink: 0
        },
        children: t("payment.dynamicPricing.unavailable.retry")
      })]
    })
  });
}