"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _selectableTilesItem = require("./selectable-tiles-item");
var _types = require("./types");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/** SelectableTiles let user choose on of the options represented in the form of tiles
 * [CAPITALIZATION] Sentence case (capitalize proper nouns i.e., Holdout).
 * @midnight-gray-supported
 * @alpine-light-supported
 */
function SelectableTiles({
  options,
  selectedKey,
  onItemSelect,
  containerClassName,
  itemClassName,
  optionId = 'id',
  isDisabled,
  labelledBy,
  size = _types.SELECTABLE_TILES_SIZES.MD
}) {
  const onSelect = key => {
    if (key === selectedKey) {
      return;
    }
    onItemSelect?.(key);
  };
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    className: (0, _classnames.default)('selectable-tiles-container', containerClassName),
    "test-id": "selectable-tiles-container",
    role: "radiogroup",
    "aria-labelledby": labelledBy,
    children: options.map(optionItem => {
      const {
        id,
        label,
        icon,
        isDisabled: itemDisabled,
        imgSrc,
        itemTestId,
        customContent,
        tooltipText,
        tooltipPlacement,
        className,
        itemAriaLabel
      } = optionItem;
      const tileId = optionId ? optionItem[optionId] : id;
      return /*#__PURE__*/(0, _jsxRuntime.jsx)(_selectableTilesItem.SelectableTilesItem, {
        id: tileId,
        label: label,
        imgSrc: imgSrc,
        itemTestId: itemTestId,
        icon: icon,
        isDisabled: itemDisabled || isDisabled,
        selectedKey: selectedKey,
        onItemSelect: onSelect,
        itemClassName: (0, _classnames.default)(itemClassName, className),
        customContent: customContent,
        tooltipText: tooltipText,
        tooltipPlacement: tooltipPlacement,
        itemAriaLabel: itemAriaLabel,
        size: size
      }, tileId);
    })
  });
}
var _default = exports.default = SelectableTiles;