"use strict";

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); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _ConfigContext = require("../../ConfigContext");
var _excluded = ["type", "extendType"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
var ExtensionField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
  var InitFanContext = (0, _react.useContext)(_ConfigContext.FanContext);
  var providerConfig = InitFanContext['Field'] || {}; // 使用上下文（全局配置）设置扩展的配置项
  var type = props.type,
    extendType = props.extendType,
    fieldProps = _objectWithoutProperties(props, _excluded);
  var MatchType = ((providerConfig === null || providerConfig === void 0 ? void 0 : providerConfig.extendComponents) || []).find(function (tItem) {
    return tItem.extendType === extendType;
  });
  var MatchTypeComponent = (MatchType === null || MatchType === void 0 ? void 0 : MatchType.component) || null;
  return typeof MatchTypeComponent === 'function' ? /*#__PURE__*/_react.default.createElement(MatchTypeComponent, fieldProps) : MatchTypeComponent;
});
var _default = exports.default = /*#__PURE__*/_react.default.memo(ExtensionField);