"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _react2 = require("@emotion/react");
var _checkMark = _interopRequireDefault(require("@atlaskit/icon/core/check-mark"));
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
var _styles = require("./styles");
/**
 * @jsxRuntime classic
 * @jsx jsx
 */

// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports -- Ignored via go/DSP-18766; jsx required at runtime for @jsxRuntime classic

var Color = function Color(props) {
  var autoFocus = props.autoFocus,
    tabIndex = props.tabIndex,
    value = props.value,
    label = props.label,
    isSelected = props.isSelected,
    borderColor = props.borderColor,
    hexToPaletteColor = props.hexToPaletteColor,
    decorator = props.decorator;
  var colorStyle = hexToPaletteColor ? hexToPaletteColor(value) : value;
  var onMouseDown = function onMouseDown(e) {
    e.preventDefault();
  };
  var onClick = function onClick(e) {
    var onClick = props.onClick,
      value = props.value,
      label = props.label;
    e.preventDefault();
    onClick(value, label);
  };
  var onKeyDown = function onKeyDown(e) {
    var onKeyDown = props.onKeyDown,
      value = props.value,
      label = props.label;
    if (!onKeyDown) {
      return undefined;
    }
    e.preventDefault();
    onKeyDown(value, label, e);
  };
  return (0, _react2.jsx)(_tooltip.default, {
    content: label
  }, (0, _react2.jsx)("span", {
    css: _styles.buttonWrapperStyle
  }, (0, _react2.jsx)("button", {
    type: "button"
    // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
    ,
    css: _styles.buttonStyle,
    "aria-label": label,
    role: "radio",
    "aria-checked": isSelected,
    onClick: onClick,
    onKeyDown: onKeyDown,
    onMouseDown: onMouseDown,
    tabIndex: tabIndex
    // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
    ,
    className: "".concat(isSelected ? 'selected' : ''),
    style: {
      backgroundColor: colorStyle || "var(--ds-background-input, #FFFFFF)",
      border: "var(--ds-border-width, 1px)".concat(" solid ", borderColor)
    },
    autoFocus: autoFocus
  }, !decorator && isSelected && (0, _react2.jsx)(_checkMark.default, {
    label: ""
  }), decorator)));
};
var _default = exports.default = Color;