"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _Text = _interopRequireDefault(require("../Text"));
var _TableToolbar = _interopRequireDefault(require("../TableToolbar"));
var _Calendar = _interopRequireDefault(require("../Calendar"));
var _Button = _interopRequireDefault(require("../Button"));
var _Box = _interopRequireDefault(require("../Box"));
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/CalendarPanelFooter/CalendarPanelFooter.tsx";
var isSelectedDaysRange = selectedDays => {
  return !(selectedDays instanceof Date);
};
var getSelectedDaysString = (selectedDaysRaw, dateToString) => {
  if (!selectedDaysRaw) {
    return '';
  }
  var selectedDays = _Calendar.default.parseValue(selectedDaysRaw);
  if (isSelectedDaysRange(selectedDays)) {
    var toSuffix = selectedDays.to ? " ".concat(dateToString(selectedDays.to)) : '';
    return "".concat(dateToString(selectedDays.from), " -").concat(toSuffix);
  }
  return dateToString(selectedDays);
};
var CalendarPanelFooter = _ref => {
  var {
    dataHook,
    dateToString,
    secondaryActionLabel,
    primaryActionLabel,
    selectedDays,
    primaryActionDisabled,
    primaryActionOnClick,
    secondaryActionOnClick
  } = _ref;
  return /*#__PURE__*/_react.default.createElement("div", {
    "data-hook": dataHook,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 47,
      columnNumber: 5
    }
  }, /*#__PURE__*/_react.default.createElement(_TableToolbar.default, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 48,
      columnNumber: 7
    }
  }, /*#__PURE__*/_react.default.createElement(_TableToolbar.default.ItemGroup, {
    position: "start",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 49,
      columnNumber: 9
    }
  }, /*#__PURE__*/_react.default.createElement(_TableToolbar.default.Item, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 50,
      columnNumber: 11
    }
  }, /*#__PURE__*/_react.default.createElement(_Text.default, {
    size: "small",
    weight: "thin",
    secondary: true,
    dataHook: "selected-days-text",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 51,
      columnNumber: 13
    }
  }, getSelectedDaysString(selectedDays, dateToString)))), /*#__PURE__*/_react.default.createElement(_TableToolbar.default.ItemGroup, {
    position: "end",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 61,
      columnNumber: 9
    }
  }, /*#__PURE__*/_react.default.createElement(_Box.default, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 62,
      columnNumber: 11
    }
  }, /*#__PURE__*/_react.default.createElement(_Button.default, {
    size: "small",
    priority: "secondary",
    dataHook: "secondary-action-button",
    onClick: secondaryActionOnClick,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 63,
      columnNumber: 13
    }
  }, secondaryActionLabel), /*#__PURE__*/_react.default.createElement(_Box.default, {
    margin: "0 6px",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 71,
      columnNumber: 13
    }
  }), /*#__PURE__*/_react.default.createElement(_Button.default, {
    size: "small",
    disabled: primaryActionDisabled,
    dataHook: "primary-action-button",
    onClick: primaryActionOnClick,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 72,
      columnNumber: 13
    }
  }, primaryActionLabel)))));
};
CalendarPanelFooter.displayName = 'CalendarPanelFooter';
CalendarPanelFooter.propTypes = {
  dataHook: _propTypes.default.string,
  primaryActionLabel: _propTypes.default.string.isRequired,
  secondaryActionLabel: _propTypes.default.string.isRequired,
  primaryActionDisabled: _propTypes.default.bool.isRequired,
  primaryActionOnClick: _propTypes.default.func.isRequired,
  secondaryActionOnClick: _propTypes.default.func.isRequired,
  selectedDays: _propTypes.default.any,
  dateToString: _propTypes.default.func.isRequired
};
var _default = exports.default = CalendarPanelFooter;
//# sourceMappingURL=CalendarPanelFooter.js.map