'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-DQoBksKy.cjs.js');
require('axios');
require('./chunk-NqciyXN3.cjs.js');
require('react-dom');
require('@bigbinary/neeto-commons-frontend/react-utils');
require('zustand');
require('classnames');
require('./chunk-2HrSPdAV.cjs.js');
require('@bigbinary/neetoui/Label');
require('./chunk-Ch4y-VZi.cjs.js');
require('./chunk-BKvkHB8E.cjs.js');
require('./chunk-BJu3ubxk.cjs.js');
require('@bigbinary/neeto-commons-frontend/initializers');
require('@babel/runtime/helpers/asyncToGenerator');
require('@babel/runtime/regenerator');
require('@tanstack/react-query');
require('yjs');
require('./chunk-B6qYtOJe.cjs.js');
require('./chunk-B_7qxIrt.cjs.js');
require('./chunk-BGy3NmZC.cjs.js');
require('i18next');
require('yup');
require('react-dom/server');
require('@bigbinary/neeto-icons/misc/Megaphone');
require('./chunk-Zpn4p-0s.cjs.js');
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('@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/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/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/classCallCheck');
require('@babel/runtime/helpers/createClass');
require('@babel/runtime/helpers/possibleConstructorReturn');
require('@babel/runtime/helpers/getPrototypeOf');
require('@babel/runtime/helpers/inherits');
require('emoji-mart');
require('@bigbinary/neeto-icons/Customize');
require('@bigbinary/neeto-icons/Refresh');
require('@bigbinary/neetoui/Input');
require('react-colorful');
require('@bigbinary/neeto-image-uploader-frontend/ImageUploader');
require('@bigbinary/neetoui/Modal');
require('@bigbinary/neetoui/Tab');
require('@bigbinary/neetoui/Toastr');
require('./chunk-D3Unocnm.cjs.js');
require('./chunk-yX0BlnxV.cjs.js');
require('zustand/shallow');
require('@bigbinary/neeto-icons/LeftAlign');
require('@bigbinary/neeto-icons/CenterAlign');
require('@bigbinary/neeto-icons/RightAlign');
require('@bigbinary/neeto-icons/Delete');
require('@bigbinary/neeto-icons/CustomSize');
require('@bigbinary/neeto-icons/BorderDisable');
require('@bigbinary/neeto-icons/BorderEnable');
require('@bigbinary/neeto-icons/AspectRatio11');
require('@bigbinary/neeto-icons/AspectRatio169');
require('@bigbinary/neeto-icons/AspectRatio916');
require('@bigbinary/neeto-icons/AspectRatio43');
require('@bigbinary/neeto-icons/AspectRatio32');
require('@bigbinary/neetoui/Tooltip');
require('@bigbinary/neetoui/formik/Form');
require('@bigbinary/neetoui/formik/Input');
require('@bigbinary/neetoui/formik/ActionBlock');
require('@bigbinary/neetoui/Checkbox');
require('@bigbinary/neeto-icons/Checkbox');
require('@bigbinary/neeto-icons/File');
require('@bigbinary/neeto-icons/Flag');
require('@bigbinary/neeto-icons/misc/Info');
require('@bigbinary/neeto-icons/misc/Warning');
require('@bigbinary/neeto-icons/misc/Danger');
require('@bigbinary/neeto-icons/misc/Success');
require('@bigbinary/neeto-icons/MenuHorizontal');
require('@bigbinary/neeto-molecules/DynamicVariables');
require('@tippyjs/react');
require('@bigbinary/neeto-molecules/CopyToClipboardButton');
require('tippy.js');
require('@bigbinary/neetoui/Spinner');
require('@bigbinary/neeto-icons/AspectRatio');
require('@bigbinary/neeto-icons/Blockquote');
require('@bigbinary/neeto-icons/Minus');
require('@bigbinary/neeto-icons/Notes');
require('@bigbinary/neeto-icons/MessageSquare');
require('@bigbinary/neeto-molecules/Search');
require('@bigbinary/neetoui/Select');
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/neeto-icons/Edit');
require('@bigbinary/neeto-icons/Articles');
require('./chunk-D8Uup1eh.cjs.js');
require('@bigbinary/neeto-commons-frontend/react-utils/useOnClickOutside');
require('@bigbinary/neeto-icons/MenuVertical');
require('@bigbinary/neetoui/Alert');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefault(_defineProperty);
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefault(_objectWithoutProperties);

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), true).forEach(function (r) { _defineProperty__default.default(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__default.default(_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);
    var prevAttachments = ramda.pluck("signedId", prevProps.attachments).join("|");
    var nextAttachments = ramda.pluck("signedId", nextProps.attachments).join("|");
    return prevError !== nextError || prevTouched !== nextTouched || Object.keys(nextProps).length !== Object.keys(prevProps).length || prevFormikProps.isSubmitting !== nextFormikProps.isSubmitting || prevAttachments !== nextAttachments || 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_default = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(FormikEditor));

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