import D from "react";
import q from "react-dom";
import { __require as x } from "./index.es99.js";
import { __require as A } from "./index.es100.js";
var d, m;
function L() {
  if (m) return d;
  m = 1;
  var C = d && d.__extends || /* @__PURE__ */ function() {
    var r = function(i, t) {
      return r = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, o) {
        e.__proto__ = o;
      } || function(e, o) {
        for (var n in o) o.hasOwnProperty(n) && (e[n] = o[n]);
      }, r(i, t);
    };
    return function(i, t) {
      r(i, t);
      function e() {
        this.constructor = i;
      }
      i.prototype = t === null ? Object.create(t) : (e.prototype = t.prototype, new e());
    };
  }(), v = d && d.__assign || function() {
    return v = Object.assign || function(r) {
      for (var i, t = 1, e = arguments.length; t < e; t++) {
        i = arguments[t];
        for (var o in i) Object.prototype.hasOwnProperty.call(i, o) && (r[o] = i[o]);
      }
      return r;
    }, v.apply(this, arguments);
  }, b = d && d.__spreadArrays || function() {
    for (var r = 0, i = 0, t = arguments.length; i < t; i++) r += arguments[i].length;
    for (var e = Array(r), o = 0, i = 0; i < t; i++)
      for (var n = arguments[i], s = 0, a = n.length; s < a; s++, o++)
        e[o] = n[s];
    return e;
  }, y = d && d.__importDefault || function(r) {
    return r && r.__esModule ? r : { default: r };
  }, u = y(D), w = y(q), f = y(x()), E = y(A()), S = (
    /** @class */
    function(r) {
      C(i, r);
      function i(t) {
        var e = r.call(this, t) || this;
        e.dirtyProps = [
          "modules",
          "formats",
          "bounds",
          "theme",
          "children"
        ], e.cleanProps = [
          "id",
          "className",
          "style",
          "placeholder",
          "tabIndex",
          "onChange",
          "onChangeSelection",
          "onFocus",
          "onBlur",
          "onKeyPress",
          "onKeyDown",
          "onKeyUp"
        ], e.state = {
          generation: 0
        }, e.selection = null, e.onEditorChange = function(n, s, a, l) {
          var h, p, c, g;
          n === "text-change" ? (p = (h = e).onEditorChangeText) === null || p === void 0 || p.call(h, e.editor.root.innerHTML, s, l, e.unprivilegedEditor) : n === "selection-change" && ((g = (c = e).onEditorChangeSelection) === null || g === void 0 || g.call(c, s, l, e.unprivilegedEditor));
        };
        var o = e.isControlled() ? t.value : t.defaultValue;
        return e.value = o ?? "", e;
      }
      return i.prototype.validateProps = function(t) {
        var e;
        if (u.default.Children.count(t.children) > 1)
          throw new Error("The Quill editing area can only be composed of a single React element.");
        if (u.default.Children.count(t.children)) {
          var o = u.default.Children.only(t.children);
          if (((e = o) === null || e === void 0 ? void 0 : e.type) === "textarea")
            throw new Error("Quill does not support editing on a <textarea>. Use a <div> instead.");
        }
        if (this.lastDeltaChangeSet && t.value === this.lastDeltaChangeSet)
          throw new Error("You are passing the `delta` object from the `onChange` event back as `value`. You most probably want `editor.getContents()` instead. See: https://github.com/zenoamaro/react-quill#using-deltas");
      }, i.prototype.shouldComponentUpdate = function(t, e) {
        var o = this, n;
        if (this.validateProps(t), !this.editor || this.state.generation !== e.generation)
          return !0;
        if ("value" in t) {
          var s = this.getEditorContents(), a = (n = t.value, n ?? "");
          this.isEqualValue(a, s) || this.setEditorContents(this.editor, a);
        }
        return t.readOnly !== this.props.readOnly && this.setEditorReadOnly(this.editor, t.readOnly), b(this.cleanProps, this.dirtyProps).some(function(l) {
          return !f.default(t[l], o.props[l]);
        });
      }, i.prototype.shouldComponentRegenerate = function(t) {
        var e = this;
        return this.dirtyProps.some(function(o) {
          return !f.default(t[o], e.props[o]);
        });
      }, i.prototype.componentDidMount = function() {
        this.instantiateEditor(), this.setEditorContents(this.editor, this.getEditorContents());
      }, i.prototype.componentWillUnmount = function() {
        this.destroyEditor();
      }, i.prototype.componentDidUpdate = function(t, e) {
        var o = this;
        if (this.editor && this.shouldComponentRegenerate(t)) {
          var n = this.editor.getContents(), s = this.editor.getSelection();
          this.regenerationSnapshot = { delta: n, selection: s }, this.setState({ generation: this.state.generation + 1 }), this.destroyEditor();
        }
        if (this.state.generation !== e.generation) {
          var a = this.regenerationSnapshot, n = a.delta, l = a.selection;
          delete this.regenerationSnapshot, this.instantiateEditor();
          var h = this.editor;
          h.setContents(n), _(function() {
            return o.setEditorSelection(h, l);
          });
        }
      }, i.prototype.instantiateEditor = function() {
        this.editor ? this.hookEditor(this.editor) : this.editor = this.createEditor(this.getEditingArea(), this.getEditorConfig());
      }, i.prototype.destroyEditor = function() {
        this.editor && this.unhookEditor(this.editor);
      }, i.prototype.isControlled = function() {
        return "value" in this.props;
      }, i.prototype.getEditorConfig = function() {
        return {
          bounds: this.props.bounds,
          formats: this.props.formats,
          modules: this.props.modules,
          placeholder: this.props.placeholder,
          readOnly: this.props.readOnly,
          scrollingContainer: this.props.scrollingContainer,
          tabIndex: this.props.tabIndex,
          theme: this.props.theme
        };
      }, i.prototype.getEditor = function() {
        if (!this.editor)
          throw new Error("Accessing non-instantiated editor");
        return this.editor;
      }, i.prototype.createEditor = function(t, e) {
        var o = new E.default(t, e);
        return e.tabIndex != null && this.setEditorTabIndex(o, e.tabIndex), this.hookEditor(o), o;
      }, i.prototype.hookEditor = function(t) {
        this.unprivilegedEditor = this.makeUnprivilegedEditor(t), t.on("editor-change", this.onEditorChange);
      }, i.prototype.unhookEditor = function(t) {
        t.off("editor-change", this.onEditorChange);
      }, i.prototype.getEditorContents = function() {
        return this.value;
      }, i.prototype.getEditorSelection = function() {
        return this.selection;
      }, i.prototype.isDelta = function(t) {
        return t && t.ops;
      }, i.prototype.isEqualValue = function(t, e) {
        return this.isDelta(t) && this.isDelta(e) ? f.default(t.ops, e.ops) : f.default(t, e);
      }, i.prototype.setEditorContents = function(t, e) {
        var o = this;
        this.value = e;
        var n = this.getEditorSelection();
        typeof e == "string" ? t.setContents(t.clipboard.convert(e)) : t.setContents(e), _(function() {
          return o.setEditorSelection(t, n);
        });
      }, i.prototype.setEditorSelection = function(t, e) {
        if (this.selection = e, e) {
          var o = t.getLength();
          e.index = Math.max(0, Math.min(e.index, o - 1)), e.length = Math.max(0, Math.min(e.length, o - 1 - e.index)), t.setSelection(e);
        }
      }, i.prototype.setEditorTabIndex = function(t, e) {
        var o, n;
        !((n = (o = t) === null || o === void 0 ? void 0 : o.scroll) === null || n === void 0) && n.domNode && (t.scroll.domNode.tabIndex = e);
      }, i.prototype.setEditorReadOnly = function(t, e) {
        e ? t.disable() : t.enable();
      }, i.prototype.makeUnprivilegedEditor = function(t) {
        var e = t;
        return {
          getHTML: function() {
            return e.root.innerHTML;
          },
          getLength: e.getLength.bind(e),
          getText: e.getText.bind(e),
          getContents: e.getContents.bind(e),
          getSelection: e.getSelection.bind(e),
          getBounds: e.getBounds.bind(e)
        };
      }, i.prototype.getEditingArea = function() {
        if (!this.editingArea)
          throw new Error("Instantiating on missing editing area");
        var t = w.default.findDOMNode(this.editingArea);
        if (!t)
          throw new Error("Cannot find element for editing area");
        if (t.nodeType === 3)
          throw new Error("Editing area cannot be a text node");
        return t;
      }, i.prototype.renderEditingArea = function() {
        var t = this, e = this.props, o = e.children, n = e.preserveWhitespace, s = this.state.generation, a = {
          key: s,
          ref: function(l) {
            t.editingArea = l;
          }
        };
        return u.default.Children.count(o) ? u.default.cloneElement(u.default.Children.only(o), a) : n ? u.default.createElement("pre", v({}, a)) : u.default.createElement("div", v({}, a));
      }, i.prototype.render = function() {
        var t;
        return u.default.createElement("div", { id: this.props.id, style: this.props.style, key: this.state.generation, className: "quill " + (t = this.props.className, t ?? ""), onKeyPress: this.props.onKeyPress, onKeyDown: this.props.onKeyDown, onKeyUp: this.props.onKeyUp }, this.renderEditingArea());
      }, i.prototype.onEditorChangeText = function(t, e, o, n) {
        var s, a;
        if (this.editor) {
          var l = this.isDelta(this.value) ? n.getContents() : n.getHTML();
          l !== this.getEditorContents() && (this.lastDeltaChangeSet = e, this.value = l, (a = (s = this.props).onChange) === null || a === void 0 || a.call(s, t, e, o, n));
        }
      }, i.prototype.onEditorChangeSelection = function(t, e, o) {
        var n, s, a, l, h, p;
        if (this.editor) {
          var c = this.getEditorSelection(), g = !c && t, O = c && !t;
          f.default(t, c) || (this.selection = t, (s = (n = this.props).onChangeSelection) === null || s === void 0 || s.call(n, t, e, o), g ? (l = (a = this.props).onFocus) === null || l === void 0 || l.call(a, t, e, o) : O && ((p = (h = this.props).onBlur) === null || p === void 0 || p.call(h, c, e, o)));
        }
      }, i.prototype.focus = function() {
        this.editor && this.editor.focus();
      }, i.prototype.blur = function() {
        this.editor && (this.selection = null, this.editor.blur());
      }, i.displayName = "React Quill", i.Quill = E.default, i.defaultProps = {
        theme: "snow",
        modules: {},
        readOnly: !1
      }, i;
    }(u.default.Component)
  );
  function _(r) {
    Promise.resolve().then(r);
  }
  return d = S, d;
}
export {
  L as __require
};
//# sourceMappingURL=index.es98.js.map
