var _excluded = ["children"];
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
import React from "react";
import Flex from "../templates/flex";
import { Button } from "../button";
import { ModalCloseButton } from "../modal";
import { Text } from "../typography";
import { Actions, Body, Content, Dialog, Header, Title, TitleIcon } from "./styled";
var BodyMessage = function BodyMessage(_ref) {
  var children = _ref.children,
    rest = _objectWithoutPropertiesLoose(_ref, _excluded);
  return typeof children === "object" ? children : /*#__PURE__*/React.createElement(Text, rest, children);
};
var ConfirmationDialog = function ConfirmationDialog(_ref2) {
  var _ref2$confirmLabel = _ref2.confirmLabel,
    confirmLabel = _ref2$confirmLabel === void 0 ? "Yes, remove" : _ref2$confirmLabel,
    _ref2$confirmWidth = _ref2.confirmWidth,
    confirmWidth = _ref2$confirmWidth === void 0 ? "128px" : _ref2$confirmWidth,
    _ref2$dataGa = _ref2["data-ga"],
    dataGA = _ref2$dataGa === void 0 ? "confirmation-dialog" : _ref2$dataGa,
    _ref2$dataTestid = _ref2["data-testid"],
    dataTestId = _ref2$dataTestid === void 0 ? "confirmationDialog" : _ref2$dataTestid,
    _ref2$declineLabel = _ref2.declineLabel,
    declineLabel = _ref2$declineLabel === void 0 ? "Cancel" : _ref2$declineLabel,
    _ref2$declineWidth = _ref2.declineWidth,
    declineWidth = _ref2$declineWidth === void 0 ? "128px" : _ref2$declineWidth,
    handleConfirm = _ref2.handleConfirm,
    handleDecline = _ref2.handleDecline,
    hideIcon = _ref2.hideIcon,
    _ref2$iconName = _ref2.iconName,
    iconName = _ref2$iconName === void 0 ? "warning_triangle_hollow" : _ref2$iconName,
    isConfirmDisabled = _ref2.isConfirmDisabled,
    isConfirmLoading = _ref2.isConfirmLoading,
    isDeclineDisabled = _ref2.isDeclineDisabled,
    isConfirmPositive = _ref2.isConfirmPositive,
    message = _ref2.message,
    title = _ref2.title,
    backdropContainerProps = _ref2.backdropContainerProps;
  return /*#__PURE__*/React.createElement(Dialog, {
    onEsc: handleDecline,
    backdropContainerProps: backdropContainerProps
  }, /*#__PURE__*/React.createElement(Content, {
    "data-testid": dataTestId
  }, /*#__PURE__*/React.createElement(Header, {
    "data-testid": dataTestId + "-headerContainer"
  }, /*#__PURE__*/React.createElement(Flex, {
    "data-testid": dataTestId + "-header",
    gap: 2
  }, !hideIcon && /*#__PURE__*/React.createElement(TitleIcon, {
    "data-testid": dataTestId + "-headerIcon",
    name: iconName
  }), /*#__PURE__*/React.createElement(Title, {
    "data-testid": dataTestId + "-headerText"
  }, title)), handleDecline && /*#__PURE__*/React.createElement(ModalCloseButton, {
    "data-testid": dataTestId + "-headerClose",
    onClose: handleDecline
  })), /*#__PURE__*/React.createElement(Body, {
    "data-testid": dataTestId + "-body"
  }, /*#__PURE__*/React.createElement(BodyMessage, {
    "data-testid": dataTestId + "-bodyMessage"
  }, message)), /*#__PURE__*/React.createElement(Actions, {
    "data-testid": dataTestId + "-actions"
  }, handleDecline && /*#__PURE__*/React.createElement(Button, {
    "data-ga": dataGA + "-::click-cancel::global-view",
    "data-testid": dataTestId + "-cancelAction",
    flavour: "hollow",
    disabled: isDeclineDisabled,
    label: declineLabel,
    onClick: handleDecline,
    width: declineWidth
  }), /*#__PURE__*/React.createElement(Button, {
    "data-ga": dataGA + "-::click-confirm::global-view",
    "data-testid": dataTestId + "-confirmAction",
    danger: !isConfirmPositive && true,
    disabled: isConfirmDisabled,
    label: confirmLabel,
    onClick: handleConfirm,
    width: confirmWidth,
    isLoading: isConfirmLoading
  }))));
};
export default ConfirmationDialog;