'use strict';

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
var React = require('react');
var formik = require('formik');
var neetoCist = require('@bigbinary/neeto-cist');
var ramda = require('ramda');
var Editor = require('./Editor.cjs.js');
var jsxRuntime = require('react/jsx-runtime');
require('@babel/runtime/helpers/toConsumableArray');
require('@babel/runtime/helpers/slicedToArray');
require('./chunk-C0jA8m8h.cjs.js');
require('./chunk-vQvjPR2x.cjs.js');
require('i18next');
require('@bigbinary/neeto-icons/TextH1');
require('@bigbinary/neeto-icons/TextH2');
require('@bigbinary/neeto-icons/TextH3');
require('@bigbinary/neeto-icons/TextH4');
require('@bigbinary/neeto-icons/TextH5');
require('@bigbinary/neeto-icons/TextP');
require('./chunk-Cf2e86Di.cjs.js');
require('./chunk-B9Evf49b.cjs.js');
require('./chunk-D_e3pQI3.cjs.js');
require('yup');
require('tippy.js');
require('react-dom');
require('classnames');
require('tippy.js/dist/svg-arrow.css');
require('@bigbinary/neeto-icons/Link');
require('@bigbinary/neeto-icons/Column');
require('@bigbinary/neeto-icons/Down');
require('@bigbinary/neetoui/Dropdown');
require('react-i18next');
require('@bigbinary/neeto-icons/Close');
require('@bigbinary/neetoui/Button');
require('@bigbinary/neeto-commons-frontend/utils');
require('@bigbinary/neeto-icons/Check');
require('@bigbinary/neetoui/Label');
require('@bigbinary/neeto-icons/Quote');
require('@bigbinary/neeto-icons/Attachment');
require('@bigbinary/neeto-icons/CodeBlock');
require('@bigbinary/neeto-icons/Code');
require('@bigbinary/neeto-icons/Highlight');
require('@bigbinary/neeto-icons/TextBold');
require('@bigbinary/neeto-icons/TextCross');
require('@bigbinary/neeto-icons/TextItalic');
require('@bigbinary/neeto-icons/Underline');
require('@bigbinary/neeto-icons/ListDot');
require('@bigbinary/neeto-icons/ListNumber');
require('@bigbinary/neeto-icons/ImageUpload');
require('@bigbinary/neeto-icons/Video');
require('@bigbinary/neeto-icons/MediaVideo');
require('@bigbinary/neeto-icons/Undo');
require('@bigbinary/neeto-icons/Redo');
require('@bigbinary/neeto-icons/Email');
require('@bigbinary/neetoui/Avatar');
require('@bigbinary/neetoui/Typography');
require('@bigbinary/neeto-icons/Smiley');
require('@babel/runtime/helpers/asyncToGenerator');
require('@babel/runtime/helpers/classCallCheck');
require('@babel/runtime/helpers/createClass');
require('@babel/runtime/helpers/possibleConstructorReturn');
require('@babel/runtime/helpers/getPrototypeOf');
require('@babel/runtime/helpers/inherits');
require('@babel/runtime/regenerator');
require('emoji-mart');
require('axios');
require('@bigbinary/neeto-commons-frontend/react-utils');
require('@bigbinary/neeto-icons/Customize');
require('@bigbinary/neeto-icons/Refresh');
require('@bigbinary/neetoui/Input');
require('react-colorful');
require('@bigbinary/neeto-molecules/DynamicVariables');
require('@bigbinary/neetoui/Modal');
require('@bigbinary/neetoui/Tab');
require('./chunk-_-ayC5lT.cjs.js');
require('zustand/shallow');
require('@bigbinary/neetoui/Toastr');
require('zustand');
require('./chunk-B83fTs8d.cjs.js');
require('@bigbinary/neeto-icons/LeftAlign');
require('@bigbinary/neeto-icons/CenterAlign');
require('@bigbinary/neeto-icons/RightAlign');
require('@bigbinary/neeto-icons/Delete');
require('@bigbinary/neeto-commons-frontend/initializers');
require('@bigbinary/neetoui/Tooltip');
require('@bigbinary/neetoui/Spinner');
require('@bigbinary/neetoui/Checkbox');
require('@bigbinary/neeto-icons/MenuHorizontal');
require('@tippyjs/react');
require('@bigbinary/neeto-icons/File');
require('react-dom/server');
require('./chunk-Bi1rI-2R.cjs.js');
require('yjs');
require('@bigbinary/neeto-molecules/CopyToClipboardButton');
require('@bigbinary/neeto-icons/Blockquote');
require('@bigbinary/neeto-icons/Minus');
require('@bigbinary/neeto-icons/Notes');
require('@bigbinary/neeto-icons/DeleteRow');
require('@bigbinary/neeto-icons/DeleteColumn');
require('@bigbinary/neeto-icons/DeleteTable');
require('@bigbinary/neeto-icons/InsertRow');
require('@bigbinary/neeto-icons/InsertColumn');
require('@bigbinary/neeto-icons/MergeSplit');
require('@bigbinary/neeto-icons/ToggleHeaderRow');
require('@bigbinary/neetoui/formik/Form');
require('@bigbinary/neetoui/formik/Input');
require('./chunk-CzYfyrKT.cjs.js');
require('@bigbinary/neeto-icons/MenuVertical');
require('@bigbinary/neetoui/Alert');

var _excluded = ["name", "onChange", "shouldUpdate", "attachments", "mentions", "variables"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var FormikEditor = function FormikEditor(_ref, ref) {
  var name = _ref.name,
    _ref$onChange = _ref.onChange,
    _onChange = _ref$onChange === void 0 ? neetoCist.noop : _ref$onChange,
    shouldUpdate = _ref.shouldUpdate,
    _ref$attachments = _ref.attachments,
    attachments = _ref$attachments === void 0 ? [] : _ref$attachments,
    _ref$mentions = _ref.mentions,
    mentions = _ref$mentions === void 0 ? [] : _ref$mentions,
    _ref$variables = _ref.variables,
    variables = _ref$variables === void 0 ? [] : _ref$variables,
    otherProps = _objectWithoutProperties(_ref, _excluded);
  // Similar to the `shouldComponentUpdate` logic of FastField component.
  // https://github.com/jaredpalmer/formik/blob/main/packages/formik/src/FastField.tsx#L75-L93
  // Additionally calls the shouldUpdate function passed from the host application and compares to
  // the rest of the values.
  var internalShouldUpdate = function internalShouldUpdate(prevProps, nextProps) {
    var prevFormikProps = prevProps.formik;
    var nextFormikProps = nextProps.formik;
    var pathParts = name.split(".");
    var prevError = ramda.path(pathParts, prevFormikProps.errors);
    var nextError = ramda.path(pathParts, nextFormikProps.errors);
    var prevTouched = ramda.path(pathParts, prevFormikProps.touched);
    var nextTouched = ramda.path(pathParts, nextFormikProps.touched);
    return prevError !== nextError || prevTouched !== nextTouched || Object.keys(nextProps).length !== Object.keys(prevProps).length || prevFormikProps.isSubmitting !== nextFormikProps.isSubmitting || Boolean(shouldUpdate === null || shouldUpdate === void 0 ? void 0 : shouldUpdate(prevProps, nextProps));
  };
  return /*#__PURE__*/jsxRuntime.jsx(formik.FastField, {
    attachments: attachments,
    mentions: mentions,
    name: name,
    variables: variables,
    shouldUpdate: internalShouldUpdate,
    children: function children(_ref2) {
      var field = _ref2.field,
        form = _ref2.form,
        meta = _ref2.meta;
      return /*#__PURE__*/jsxRuntime.jsx(Editor, _objectSpread({
        attachments: attachments,
        mentions: mentions,
        name: name,
        ref: ref,
        variables: variables,
        error: meta.touched ? meta.error : "",
        initialValue: field.value,
        onBlur: function onBlur() {
          form.setFieldTouched(name, true);
        },
        onChange: function onChange(value) {
          form.setFieldValue(name, value);
          _onChange === null || _onChange === void 0 || _onChange(value);
        }
      }, otherProps));
    }
  });
};
FormikEditor.displayName = "FormikNeetoEditor";
var FormikEditor$1 = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(FormikEditor));

module.exports = FormikEditor$1;
//# sourceMappingURL=FormikEditor.cjs.js.map
