"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.FormSelect = void 0;

var _styledComponents = _interopRequireDefault(require("styled-components"));

var _branding = require("../../../mixins/branding");

var _typography = require("../../../mixins/typography");

var _chevronDown = require("../../icon/chevrons/chevron-down/chevron-down.css-rules");

var _focus = require("../../../mixins/focus");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var getForegroundFont = function getForegroundFont(_ref) {
  var theme = _ref.theme;
  return (0, _typography.getFontFamily)({
    theme: theme
  });
};

var getForegroundColor = function getForegroundColor(_ref2) {
  var theme = _ref2.theme,
      error = _ref2.error,
      disabled = _ref2.disabled,
      isPlaceholderValue = _ref2.isPlaceholderValue;
  if (disabled) return (0, _branding.getPaletteColor)('greyscale-light')({
    theme: theme
  });
  if (error) return (0, _branding.getPaletteColor)('error-fg')({
    theme: theme
  });

  if (isPlaceholderValue) {
    return (0, _branding.getPaletteColor)('greyscale-dark')({
      theme: theme
    });
  }

  return (0, _branding.getPaletteColor)(theme.defaultTextColor || 'greyscale-black')({
    theme: theme
  });
};

var getFormSelectFontWeight = function getFormSelectFontWeight(_ref3) {
  var large = _ref3.large;
  return (0, _typography.getFontWeight)({
    bold: large
  });
};

var getFormSelectFontStyle = function getFormSelectFontStyle(_ref4) {
  var isPlaceholderValue = _ref4.isPlaceholderValue;
  return isPlaceholderValue ? 'italic' : undefined;
};

var getFormSelectFontSize = function getFormSelectFontSize(_ref5) {
  var theme = _ref5.theme,
      large = _ref5.large;
  return (0, _typography.getFontSize)({
    theme: theme,
    fontSize: large ? 'f2' : 'f1'
  });
};

var getHeight = function getHeight(_ref6) {
  var large = _ref6.large;
  return large ? '60px' : '40px';
};

var FormSelect = _styledComponents["default"].select.withConfig({
  displayName: "FormSelect",
  componentId: "sc-1itsrf-0"
})(["&&{appearance:none;background-color:", ";background-image:url(", ");background-position:right center;background-repeat:no-repeat;border-radius:6px;border:1px solid ", ";color:", ";font-family:", ";font-size:", ";font-weight:", ";font-style:", ";height:", ";padding:0 40px 0 20px;width:100%;", "}", "{border:1px solid ", ";}&:-webkit-autofill{-webkit-box-shadow:0 0 0 50px transparent inset;-webkit-text-fill-color:", ";}&:-webkit-autofill:focus{-webkit-box-shadow:0 0 0 50px transparent inset;-webkit-text-fill-color:", ";}&:not([disabled]):hover{border:1px solid ", ";}option{font-weight:100;font-style:normal;}"], (0, _branding.getPaletteColor)('white'), _chevronDown.getChevronDownDataUri, (0, _branding.getPaletteColor)('greyscale-light'), getForegroundColor, getForegroundFont, getFormSelectFontSize, getFormSelectFontWeight, getFormSelectFontStyle, getHeight, (0, _focus.getBaseFocusState)({
  hoverTransition: false,
  activeTransition: false
}), _focus.FOCUS_VISIBLE_SELECTOR, (0, _branding.getPaletteColor)('greyscale-dark'), getForegroundColor, getForegroundColor, (0, _branding.getPaletteColor)('greyscale-medium'));

exports.FormSelect = FormSelect;