"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.ValueWrapper = exports.DynamicPropWrapper = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _excluded = ["__designMode", "value", "defaultValue"],
  _excluded2 = ["__designMode"];
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var createElement = React.createElement;
var ValueWrapper = exports.ValueWrapper = function ValueWrapper(NextFormComponent, displayName) {
  var WrappedComponent = function WrappedComponent(props) {
    var __designMode = props.__designMode,
      value = props.value,
      defaultValue = props.defaultValue,
      otherProps = (0, _objectWithoutPropertiesLoose2["default"])(props, _excluded);
    var finalValue = __designMode === 'design' ? defaultValue : value;
    if (typeof finalValue !== 'undefined') {
      otherProps.value = finalValue;
    }
    return createElement(NextFormComponent, (0, _extends2["default"])({}, otherProps));
  };
  WrappedComponent.displayName = displayName;
  return WrappedComponent;
};
var DynamicPropWrapper = exports.DynamicPropWrapper = function DynamicPropWrapper(prop, NextFormComponent, displayName) {
  var WrappedComponent = function WrappedComponent(props) {
    var dynamicProp = prop;
    var defaultDynamicProp = "default" + prop.slice(0, 1).toUpperCase() + prop.slice(1);
    var __designMode = props.__designMode,
      otherProps = (0, _objectWithoutPropertiesLoose2["default"])(props, _excluded2);
    var dynamicPropValueValue = props[dynamicProp];
    var defaultDynamicPropValue = props[defaultDynamicProp];
    var finalValue = __designMode === 'design' ? defaultDynamicPropValue : dynamicPropValueValue;
    if (typeof finalValue !== 'undefined') {
      otherProps[dynamicProp] = finalValue;
    }
    return createElement(NextFormComponent, (0, _extends2["default"])({}, otherProps));
  };
  WrappedComponent.displayName = displayName;
  return WrappedComponent;
};