"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _react = _interopRequireWildcard(require("react"));
var _BaseModalLayoutSt = require("./BaseModalLayout.st.css.js");
var _constants = require("./constants");
var _CloseButton = _interopRequireDefault(require("../CloseButton"));
var _system = require("@wix/wix-ui-icons-common/system");
var _ThemeProviderConsumerBackwardCompatible = require("../ThemeProvider/ThemeProviderConsumerBackwardCompatible");
var _BaseModalLayoutContext = require("./BaseModalLayoutContext");
var _LayoutBlocks = require("./LayoutBlocks");
var _Box = _interopRequireDefault(require("../Box"));
var _deprecationLog = _interopRequireDefault(require("../utils/deprecationLog"));
var _excluded = ["dataHook", "className", "children", "style", "onCloseButtonClick", "onHelpButtonClick", "closeButtonProps", "helpButtonProps", "skin"];
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/BaseModalLayout/BaseModalLayout.tsx";
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var classNames = {
  headerClassName: _BaseModalLayoutSt.classes.header,
  contentClassName: _BaseModalLayoutSt.classes.content,
  footerClassName: _BaseModalLayoutSt.classes.footer,
  footnoteClassName: _BaseModalLayoutSt.classes.footnote,
  illustrationClassName: _BaseModalLayoutSt.classes.illustration
};
var BaseModalLayout = _ref => {
  var _helpButtonProps, _helpButtonProps2, _helpButtonProps3, _closeButtonProps, _closeButtonProps2, _closeButtonProps3, _helpButtonProps4, _closeButtonProps4;
  var {
      dataHook,
      className,
      children,
      style,
      onCloseButtonClick,
      // deprecated
      onHelpButtonClick,
      // deprecated
      closeButtonProps,
      helpButtonProps,
      skin = 'standard'
    } = _ref,
    restProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
  (0, _react.useEffect)(() => {
    if (onCloseButtonClick) {
      (0, _deprecationLog.default)('<BaseModalLayout /> - prop "onCloseButtonClick" is deprecated and will be removed in next major release, please use "closeButtonProps" property instead.');
    }
    if (onHelpButtonClick) {
      (0, _deprecationLog.default)('<BaseModalLayout /> - prop "onHelpButtonClick" is deprecated and will be removed in next major release, please use "helpButtonProps" property instead.');
    }
  }, [onCloseButtonClick, onHelpButtonClick]);
  helpButtonProps = _objectSpread(_objectSpread({}, helpButtonProps), {}, {
    onClick: ((_helpButtonProps = helpButtonProps) == null ? void 0 : _helpButtonProps.onClick) || onHelpButtonClick,
    skin: ((_helpButtonProps2 = helpButtonProps) == null ? void 0 : _helpButtonProps2.skin) || 'dark',
    size: ((_helpButtonProps3 = helpButtonProps) == null ? void 0 : _helpButtonProps3.size) || 'large'
  });
  closeButtonProps = _objectSpread(_objectSpread({}, closeButtonProps), {}, {
    onClick: ((_closeButtonProps = closeButtonProps) == null ? void 0 : _closeButtonProps.onClick) || onCloseButtonClick,
    skin: ((_closeButtonProps2 = closeButtonProps) == null ? void 0 : _closeButtonProps2.skin) || 'dark',
    size: ((_closeButtonProps3 = closeButtonProps) == null ? void 0 : _closeButtonProps3.size) || 'large'
  });
  var controlButtonAmount = [(_helpButtonProps4 = helpButtonProps) == null ? void 0 : _helpButtonProps4.onClick, (_closeButtonProps4 = closeButtonProps) == null ? void 0 : _closeButtonProps4.onClick].filter(Boolean).length;
  return /*#__PURE__*/_react.default.createElement("div", {
    "data-hook": dataHook,
    "data-skin": skin,
    style: style,
    className: (0, _BaseModalLayoutSt.st)(_BaseModalLayoutSt.classes.root, {
      skin,
      controlButtonAmount
    }, className),
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 73,
      columnNumber: 5
    }
  }, controlButtonAmount > 0 && /*#__PURE__*/_react.default.createElement(_ThemeProviderConsumerBackwardCompatible.ThemeProviderConsumerBackwardCompatible, {
    defaultIcons: {
      BaseModalLayout: {
        HelpIcon: _system.Help24
      }
    },
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 80,
      columnNumber: 9
    }
  }, _ref2 => {
    var {
      icons: {
        BaseModalLayout: {
          HelpIcon
        }
      }
    } = _ref2;
    return /*#__PURE__*/_react.default.createElement(_Box.default, {
      direction: "horizontal",
      className: _BaseModalLayoutSt.classes.controlButtons,
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 92,
        columnNumber: 13
      }
    }, helpButtonProps.onClick && /*#__PURE__*/_react.default.createElement(_CloseButton.default, {
      dataHook: _constants.dataHooks.helpButton,
      className: _BaseModalLayoutSt.classes.helpButton,
      onClick: helpButtonProps.onClick,
      onMouseDown: helpButtonProps.onMouseDown,
      size: helpButtonProps.size,
      skin: helpButtonProps.skin,
      "aria-label": _constants.labels.help,
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 94,
        columnNumber: 17
      }
    }, /*#__PURE__*/_react.default.createElement(HelpIcon, {
      className: _BaseModalLayoutSt.classes.helpIcon,
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 103,
        columnNumber: 19
      }
    })), closeButtonProps.onClick && /*#__PURE__*/_react.default.createElement(_CloseButton.default, {
      dataHook: _constants.dataHooks.closeButton,
      className: _BaseModalLayoutSt.classes.closeButton,
      onClick: closeButtonProps.onClick,
      onMouseDown: closeButtonProps.onMouseDown,
      size: closeButtonProps.size,
      skin: closeButtonProps.skin,
      autoFocus: closeButtonProps.autoFocus,
      "aria-label": _constants.labels.close,
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 107,
        columnNumber: 17
      }
    }));
  }), /*#__PURE__*/_react.default.createElement(_BaseModalLayoutContext.BaseModalLayoutContext.Provider, {
    value: _objectSpread(_objectSpread({}, restProps), {}, {
      skin
    }, classNames),
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 123,
      columnNumber: 7
    }
  }, children));
};

/** Private component to be used by all public modals. Represents the common internals of all modals */
BaseModalLayout.Header = _LayoutBlocks.Header;
BaseModalLayout.Content = _LayoutBlocks.Content;
BaseModalLayout.Footer = _LayoutBlocks.Footer;
BaseModalLayout.Footnote = _LayoutBlocks.Footnote;
BaseModalLayout.Illustration = _LayoutBlocks.Illustration;
BaseModalLayout.displayName = 'BaseModalLayout';
var _default = exports.default = BaseModalLayout;
//# sourceMappingURL=BaseModalLayout.js.map