function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

/*
Copyright (c) 2018 Uber Technologies, Inc.

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
import { styled } from '../styles/index.js';

/**
 * Main component container element
 */
export var StyledRoot = styled('div', function (props) {
  var _props$$theme = props.$theme,
      typography = _props$$theme.typography,
      colors = _props$$theme.colors,
      borders = _props$$theme.borders;
  return _objectSpread({}, typography.font400, {
    color: props.$theme.colors.datepickerDayFont,
    backgroundColor: colors.datepickerBackground,
    textAlign: 'center',
    borderRadius: borders.useRoundedCorners ? borders.radius200 : '0px',
    display: 'inline-block'
  });
});
StyledRoot.displayName = "StyledRoot";
export var StyledCalendarContainer = styled('div', function (props) {
  var sizing = props.$theme.sizing;
  return {
    paddingTop: sizing.scale400,
    paddingBottom: sizing.scale500,
    paddingLeft: sizing.scale600,
    paddingRight: sizing.scale600
  };
});
StyledCalendarContainer.displayName = "StyledCalendarContainer";
export var StyledQuickSelectContainer = styled('div', function (props) {
  return {
    maxWidth: '296px',
    marginLeft: 'auto',
    marginRight: 'auto',
    marginBottom: props.$theme.sizing.scale600
  };
});
StyledQuickSelectContainer.displayName = "StyledQuickSelectContainer";
export var StyledQuickSelectLabel = styled('div', function (props) {
  return _objectSpread({}, props.$theme.typography.font300, {
    color: props.$theme.colors.colorPrimary,
    marginBottom: props.$theme.sizing.scale600,
    textAlign: 'left'
  });
});
StyledQuickSelectLabel.displayName = "StyledQuickSelectLabel";
export var StyledQuickSelectButtons = styled('div', {
  display: 'flex',
  flexWrap: 'wrap'
});
StyledQuickSelectButtons.displayName = "StyledQuickSelectButtons";
export var StyledCalendarHeader = styled('div', function (props) {
  var _props$$theme2 = props.$theme,
      colors = _props$$theme2.colors,
      sizing = _props$$theme2.sizing,
      borders = _props$$theme2.borders;
  var borderRadius = borders.useRoundedCorners ? borders.radius200 : '0px';
  return {
    color: colors.white,
    display: 'flex',
    justifyContent: 'space-between',
    alignItems: 'center',
    paddingTop: sizing.scale500,
    paddingBottom: sizing.scale500,
    paddingLeft: sizing.scale600,
    paddingRight: sizing.scale600,
    backgroundColor: colors.primary,
    borderRadius: "".concat(borderRadius, " ").concat(borderRadius, " 0 0")
  };
});
StyledCalendarHeader.displayName = "StyledCalendarHeader";
export var StyledMonthHeader = styled('div', function (props) {
  return {
    whiteSpace: 'no-wrap'
  };
});
StyledMonthHeader.displayName = "StyledMonthHeader";

function getArrowBtnStyle(_ref) {
  var $theme = _ref.$theme;
  return {
    boxSizing: 'border-box',
    height: '22px',
    color: $theme.colors.white,
    backgroundColor: 'transparent',
    borderWidth: '0',
    paddingTop: '3px',
    paddingBottom: '3px',
    paddingLeft: '3px',
    paddingRight: '3px',
    outline: 'none',
    ':focus': {
      backgroundColor: $theme.colors.primary500,
      borderRadius: $theme.borders.useRoundedCorners ? $theme.sizing.scale100 : 0
    }
  };
}

export var StyledPrevButton = styled('button', getArrowBtnStyle);
StyledPrevButton.displayName = "StyledPrevButton";
export var StyledNextButton = styled('button', getArrowBtnStyle);
StyledNextButton.displayName = "StyledNextButton";
export var StyledMonth = styled('div', function (props) {
  return {
    display: 'inline-block'
  };
});
StyledMonth.displayName = "StyledMonth";
export var StyledWeek = styled('div', function (props) {
  var sizing = props.$theme.sizing;
  return {
    whiteSpace: 'no-wrap',
    display: 'flex',
    marginBottom: sizing.scale100
  };
});
StyledWeek.displayName = "StyledWeek";

function getBorderRadius(left, right) {
  return {
    borderTopLeftRadius: left,
    borderBottomLeftRadius: left,
    borderTopRightRadius: right,
    borderBottomRightRadius: right
  };
}

export function calculateBorderRadius(props) {
  var $isHighlighted = props.$isHighlighted,
      $pseudoHighlighted = props.$pseudoHighlighted,
      $pseudoSelected = props.$pseudoSelected,
      $selected = props.$selected,
      $startDate = props.$startDate,
      $range = props.$range,
      $hasRangeHighlighted = props.$hasRangeHighlighted,
      $hasRangeOnRight = props.$hasRangeOnRight,
      $hasRangeSelected = props.$hasRangeSelected,
      borders = props.$theme.borders;

  if (borders.useRoundedCorners) {
    if ($selected) {
      if (!$range) {
        return getBorderRadius(borders.radius200, borders.radius200);
      } else {
        if ($hasRangeSelected) {
          return $startDate ? getBorderRadius(borders.radius200, 0) : getBorderRadius(0, borders.radius200);
        } else {
          if ($hasRangeHighlighted) {
            return $hasRangeOnRight ? getBorderRadius(borders.radius200, 0) : getBorderRadius(0, borders.radius200);
          } else {
            return getBorderRadius(borders.radius200, borders.radius200);
          }
        }
      }
    } else {
      if (!$isHighlighted && ($pseudoHighlighted || $pseudoSelected)) {
        return getBorderRadius(0, 0);
      } else {
        if ($isHighlighted) {
          if (!$range) {
            return getBorderRadius(borders.radius200, borders.radius200);
          } else if ($hasRangeHighlighted) {
            return $hasRangeOnRight ? getBorderRadius(0, borders.radius200) : getBorderRadius(borders.radius200, 0);
          } else {
            return $pseudoSelected ? getBorderRadius(0, 0) : getBorderRadius(borders.radius200, borders.radius200);
          }
        } else {
          return !$pseudoSelected ? getBorderRadius(borders.radius200, borders.radius200) : null;
        }
      }
    }
  } else {
    return getBorderRadius(0, 0);
  }
}
export var StyledDay = styled('div', function (props) {
  var $disabled = props.$disabled,
      $isHovered = props.$isHovered,
      $isHighlighted = props.$isHighlighted,
      $outsideMonth = props.$outsideMonth,
      $pseudoHighlighted = props.$pseudoHighlighted,
      $pseudoSelected = props.$pseudoSelected,
      $selected = props.$selected,
      _props$$theme3 = props.$theme,
      colors = _props$$theme3.colors,
      sizing = _props$$theme3.sizing,
      borders = _props$$theme3.borders;
  return _objectSpread({
    boxSizing: 'border-box',
    position: 'relative',
    cursor: $disabled ? 'default' : 'pointer',
    display: 'inline-block',
    width: sizing.scale1000,
    height: sizing.scale1000,
    lineHeight: sizing.scale800,
    textAlign: 'center',
    paddingTop: sizing.scale300,
    paddingBottom: sizing.scale300,
    paddingLeft: sizing.scale200,
    paddingRight: sizing.scale200,
    marginTop: '0',
    marginBottom: '0',
    marginLeft: '0',
    marginRight: '0',
    color: $selected ? colors.white : $outsideMonth || $disabled ? colors.datepickerDayFontDisabled : 'inherit',
    backgroundColor: $selected ? $isHighlighted ? colors.primary500 : colors.primary : $pseudoSelected ? $isHighlighted ? colors.datepickerDayPseudoHighlighted : colors.datepickerDayPseudoSelected : $isHovered || $isHighlighted || $pseudoHighlighted ? colors.datepickerDayPseudoSelected : 'transparent'
  }, calculateBorderRadius(props), {
    ':first-child': _objectSpread({}, borders.useRoundedCorners ? {
      borderTopLeftRadius: borders.radius200,
      borderBottomLeftRadius: borders.radius200
    } : {}),
    ':last-child': _objectSpread({}, borders.useRoundedCorners ? {
      borderTopRightRadius: borders.radius200,
      borderBottomRightRadius: borders.radius200
    } : {})
  });
});
StyledDay.displayName = "StyledDay";