function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
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); }
import React from 'react';
/**
 * @title: RecordListWrapper 只读态
 * @description: 低代码详情模式下展示每个 option 对应的 record 数据。
 *   值结构: { optionValue: { field1: v1, field2: v2 } }
 */
var RecordListWrapperReadPretty = function RecordListWrapperReadPretty(props) {
  var value = props.value,
    _props$options = props.options,
    options = _props$options === void 0 ? [] : _props$options;

  /** 安全获取 Map 值 */
  var safeValue = value && _typeof(value) === 'object' && !Array.isArray(value) ? value : {};
  var entries = Object.entries(safeValue);
  if (!entries.length) {
    return /*#__PURE__*/React.createElement("span", null, "-");
  }
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
    style: {
      marginBottom: 8
    }
  }, "Records: ", entries.length), entries.map(function (_ref) {
    var _ref2 = _slicedToArray(_ref, 2),
      key = _ref2[0],
      record = _ref2[1];
    var option = options.find(function (o) {
      return String(o.value) === key;
    });
    var label = (option === null || option === void 0 ? void 0 : option.label) || key;
    var displayLabel = _typeof(label) === 'object' ? JSON.stringify(label) : label;
    return /*#__PURE__*/React.createElement("div", {
      key: key,
      style: {
        marginBottom: 8
      }
    }, /*#__PURE__*/React.createElement("div", {
      style: {
        fontWeight: 500,
        marginBottom: 4
      }
    }, displayLabel), /*#__PURE__*/React.createElement("pre", {
      style: {
        margin: 0,
        padding: 8,
        background: '#f7f8fa',
        borderRadius: 4,
        fontSize: 12,
        maxHeight: 200,
        overflow: 'auto'
      }
    }, JSON.stringify(record, null, 2)));
  }));
};
export default RecordListWrapperReadPretty;