function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import React from 'react';
import classNames from 'classnames';
import { Divider } from 'antd';
import TimeRange from "../timeRange";
import Resources from "../resources";
import "./index.less";
var PREFIX = 'pisell-cart-sku-card-booking-item';
var getSelectedResourceNames = function getSelectedResourceNames(dataSource) {
  var _ref = dataSource || {},
    multiResources = _ref.multiResources,
    isMultipleResource = _ref.isMultipleResource;
  if (!isMultipleResource || !(multiResources !== null && multiResources !== void 0 && multiResources.length)) return [];
  return multiResources.flatMap(function (resourceGroup) {
    var _ref2 = resourceGroup || {},
      ids = _ref2.id,
      _ref2$lists = _ref2.lists,
      lists = _ref2$lists === void 0 ? [] : _ref2$lists;
    if (!Array.isArray(ids)) return [];
    return ids.map(function (id) {
      var targetRes = lists.find(function (resource) {
        return resource.id === id;
      });
      return (targetRes === null || targetRes === void 0 ? void 0 : targetRes.label) || null;
    }).filter(Boolean);
  }).filter(Boolean).filter(function (name, index, names) {
    return names.indexOf(name) === index;
  });
};
var BookingItem = function BookingItem(props) {
  var children = props.children,
    _props$isShowRelatedP = props.isShowRelatedProduct,
    isShowRelatedProduct = _props$isShowRelatedP === void 0 ? true : _props$isShowRelatedP,
    _props$isShowDelete = props.isShowDelete,
    isShowDelete = _props$isShowDelete === void 0 ? false : _props$isShowDelete,
    dataSource = props.dataSource;
  // const resourceTitle = getSelectedResourceNames(dataSource).join(' · ');

  return /*#__PURE__*/React.createElement("div", {
    className: PREFIX
  }, /*#__PURE__*/React.createElement("div", {
    className: classNames("".concat(PREFIX, "__info"), _defineProperty({}, "".concat(PREFIX, "__info--with-delete"), isShowDelete))
  }, /*#__PURE__*/React.createElement(TimeRange, {
    dataSource: dataSource
  }), /*#__PURE__*/React.createElement(Resources, {
    dataSource: dataSource
  })), isShowRelatedProduct && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Divider, {
    style: {
      margin: 0
    }
  }), /*#__PURE__*/React.createElement("div", {
    className: "".concat(PREFIX, "__related-product")
  }, children)));
};
export default BookingItem;