import React from 'react';
import Iconfont from "../../../../iconfont";
import { PREFIX } from "../../index";
import "./index.less";
import { locales } from '@pisell/utils';
var holderIconMap = {
  'form': 'pisell2-file-05',
  'minors': 'pisell2-user-check-01',
  'waiver': 'pisell2-file-lock-03'
};
var Holders = function Holders(props) {
  var _props$dataSource = props.dataSource,
    dataSource = _props$dataSource === void 0 ? {} : _props$dataSource;
  var holders = dataSource.holders,
    holder_id = dataSource.holder_id;
  if (!holder_id || (holder_id === null || holder_id === void 0 ? void 0 : holder_id.length) === 0) {
    // 如果是Booking Holder为表单的，未选择则显示Unassigned
    if (dataSource.isFormSubject) {
      return /*#__PURE__*/React.createElement("div", {
        className: "holder-item unassigned"
      }, dataSource.holderMaxCount > 1 ? /*#__PURE__*/React.createElement("span", null, dataSource.holderMaxCount, "/", dataSource.holderMaxCount, " ") : null, /*#__PURE__*/React.createElement("span", {
        className: "holder-label"
      }, locales.getText('pisell2.cart.sku-card.unassigned')));
    }
    return null;
  }
  ;
  var renderHolder = function renderHolder(id) {
    if (!id) return null;
    var holder = (holders || []).find(function (item) {
      return item.id === id;
    });
    return /*#__PURE__*/React.createElement("div", {
      className: "holder-item",
      key: id
    }, /*#__PURE__*/React.createElement(Iconfont, {
      className: "holder-icon",
      type: holderIconMap[(dataSource === null || dataSource === void 0 ? void 0 : dataSource.holderType) || 'minors']
    }), /*#__PURE__*/React.createElement("span", {
      className: "holder-label"
    }, (holder === null || holder === void 0 ? void 0 : holder.label) || id));
  };
  return /*#__PURE__*/React.createElement("div", {
    className: "".concat(PREFIX, "__holders")
  }, Array.isArray(holder_id) ? holder_id === null || holder_id === void 0 ? void 0 : holder_id.map(function (id) {
    return renderHolder(id);
  }) : renderHolder(holder_id));
};
export default Holders;