{"version":3,"file":"vendors-638dd808.f584a1446b2fc034d810.bundle.js","mappings":"AAEA","sources":["webpack://lernplattform-admin-frontend/../common/node_modules/prosemirror-history/dist/index.cjs","webpack://lernplattform-admin-frontend/../common/node_modules/prosemirror-keymap/dist/index.cjs","webpack://lernplattform-admin-frontend/../common/node_modules/prosemirror-model/dist/index.cjs","webpack://lernplattform-admin-frontend/../common/node_modules/prosemirror-schema-list/dist/index.cjs"],"sourcesContent":["'use strict';\n\nfunction _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); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar RopeSequence = require('rope-sequence');\nvar prosemirrorTransform = require('prosemirror-transform');\nvar prosemirrorState = require('prosemirror-state');\nvar max_empty_items = 500;\nvar Branch = function () {\n  function Branch(items, eventCount) {\n    _classCallCheck(this, Branch);\n    this.items = items;\n    this.eventCount = eventCount;\n  }\n  _createClass(Branch, [{\n    key: \"popEvent\",\n    value: function popEvent(state, preserveItems) {\n      var _this = this;\n      if (this.eventCount == 0) return null;\n      var end = this.items.length;\n      for (;; end--) {\n        var next = this.items.get(end - 1);\n        if (next.selection) {\n          --end;\n          break;\n        }\n      }\n      var remap, mapFrom;\n      if (preserveItems) {\n        remap = this.remapping(end, this.items.length);\n        mapFrom = remap.maps.length;\n      }\n      var transform = state.tr;\n      var selection, remaining;\n      var addAfter = [],\n        addBefore = [];\n      this.items.forEach(function (item, i) {\n        if (!item.step) {\n          if (!remap) {\n            remap = _this.remapping(end, i + 1);\n            mapFrom = remap.maps.length;\n          }\n          mapFrom--;\n          addBefore.push(item);\n          return;\n        }\n        if (remap) {\n          addBefore.push(new Item(item.map));\n          var step = item.step.map(remap.slice(mapFrom)),\n            map;\n          if (step && transform.maybeStep(step).doc) {\n            map = transform.mapping.maps[transform.mapping.maps.length - 1];\n            addAfter.push(new Item(map, undefined, undefined, addAfter.length + addBefore.length));\n          }\n          mapFrom--;\n          if (map) remap.appendMap(map, mapFrom);\n        } else {\n          transform.maybeStep(item.step);\n        }\n        if (item.selection) {\n          selection = remap ? item.selection.map(remap.slice(mapFrom)) : item.selection;\n          remaining = new Branch(_this.items.slice(0, end).append(addBefore.reverse().concat(addAfter)), _this.eventCount - 1);\n          return false;\n        }\n      }, this.items.length, 0);\n      return {\n        remaining: remaining,\n        transform: transform,\n        selection: selection\n      };\n    }\n  }, {\n    key: \"addTransform\",\n    value: function addTransform(transform, selection, histOptions, preserveItems) {\n      var newItems = [],\n        eventCount = this.eventCount;\n      var oldItems = this.items,\n        lastItem = !preserveItems && oldItems.length ? oldItems.get(oldItems.length - 1) : null;\n      for (var i = 0; i < transform.steps.length; i++) {\n        var step = transform.steps[i].invert(transform.docs[i]);\n        var item = new Item(transform.mapping.maps[i], step, selection),\n          merged = void 0;\n        if (merged = lastItem && lastItem.merge(item)) {\n          item = merged;\n          if (i) newItems.pop();else oldItems = oldItems.slice(0, oldItems.length - 1);\n        }\n        newItems.push(item);\n        if (selection) {\n          eventCount++;\n          selection = undefined;\n        }\n        if (!preserveItems) lastItem = item;\n      }\n      var overflow = eventCount - histOptions.depth;\n      if (overflow > DEPTH_OVERFLOW) {\n        oldItems = cutOffEvents(oldItems, overflow);\n        eventCount -= overflow;\n      }\n      return new Branch(oldItems.append(newItems), eventCount);\n    }\n  }, {\n    key: \"remapping\",\n    value: function remapping(from, to) {\n      var maps = new prosemirrorTransform.Mapping();\n      this.items.forEach(function (item, i) {\n        var mirrorPos = item.mirrorOffset != null && i - item.mirrorOffset >= from ? maps.maps.length - item.mirrorOffset : undefined;\n        maps.appendMap(item.map, mirrorPos);\n      }, from, to);\n      return maps;\n    }\n  }, {\n    key: \"addMaps\",\n    value: function addMaps(array) {\n      if (this.eventCount == 0) return this;\n      return new Branch(this.items.append(array.map(function (map) {\n        return new Item(map);\n      })), this.eventCount);\n    }\n  }, {\n    key: \"rebased\",\n    value: function rebased(rebasedTransform, rebasedCount) {\n      if (!this.eventCount) return this;\n      var rebasedItems = [],\n        start = Math.max(0, this.items.length - rebasedCount);\n      var mapping = rebasedTransform.mapping;\n      var newUntil = rebasedTransform.steps.length;\n      var eventCount = this.eventCount;\n      this.items.forEach(function (item) {\n        if (item.selection) eventCount--;\n      }, start);\n      var iRebased = rebasedCount;\n      this.items.forEach(function (item) {\n        var pos = mapping.getMirror(--iRebased);\n        if (pos == null) return;\n        newUntil = Math.min(newUntil, pos);\n        var map = mapping.maps[pos];\n        if (item.step) {\n          var step = rebasedTransform.steps[pos].invert(rebasedTransform.docs[pos]);\n          var selection = item.selection && item.selection.map(mapping.slice(iRebased + 1, pos));\n          if (selection) eventCount++;\n          rebasedItems.push(new Item(map, step, selection));\n        } else {\n          rebasedItems.push(new Item(map));\n        }\n      }, start);\n      var newMaps = [];\n      for (var i = rebasedCount; i < newUntil; i++) newMaps.push(new Item(mapping.maps[i]));\n      var items = this.items.slice(0, start).append(newMaps).append(rebasedItems);\n      var branch = new Branch(items, eventCount);\n      if (branch.emptyItemCount() > max_empty_items) branch = branch.compress(this.items.length - rebasedItems.length);\n      return branch;\n    }\n  }, {\n    key: \"emptyItemCount\",\n    value: function emptyItemCount() {\n      var count = 0;\n      this.items.forEach(function (item) {\n        if (!item.step) count++;\n      });\n      return count;\n    }\n  }, {\n    key: \"compress\",\n    value: function compress() {\n      var upto = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.items.length;\n      var remap = this.remapping(0, upto),\n        mapFrom = remap.maps.length;\n      var items = [],\n        events = 0;\n      this.items.forEach(function (item, i) {\n        if (i >= upto) {\n          items.push(item);\n          if (item.selection) events++;\n        } else if (item.step) {\n          var step = item.step.map(remap.slice(mapFrom)),\n            map = step && step.getMap();\n          mapFrom--;\n          if (map) remap.appendMap(map, mapFrom);\n          if (step) {\n            var selection = item.selection && item.selection.map(remap.slice(mapFrom));\n            if (selection) events++;\n            var newItem = new Item(map.invert(), step, selection),\n              merged,\n              last = items.length - 1;\n            if (merged = items.length && items[last].merge(newItem)) items[last] = merged;else items.push(newItem);\n          }\n        } else if (item.map) {\n          mapFrom--;\n        }\n      }, this.items.length, 0);\n      return new Branch(RopeSequence.from(items.reverse()), events);\n    }\n  }]);\n  return Branch;\n}();\nBranch.empty = new Branch(RopeSequence.empty, 0);\nfunction cutOffEvents(items, n) {\n  var cutPoint;\n  items.forEach(function (item, i) {\n    if (item.selection && n-- == 0) {\n      cutPoint = i;\n      return false;\n    }\n  });\n  return items.slice(cutPoint);\n}\nvar Item = function () {\n  function Item(map, step, selection, mirrorOffset) {\n    _classCallCheck(this, Item);\n    this.map = map;\n    this.step = step;\n    this.selection = selection;\n    this.mirrorOffset = mirrorOffset;\n  }\n  _createClass(Item, [{\n    key: \"merge\",\n    value: function merge(other) {\n      if (this.step && other.step && !other.selection) {\n        var step = other.step.merge(this.step);\n        if (step) return new Item(step.getMap().invert(), step, this.selection);\n      }\n    }\n  }]);\n  return Item;\n}();\nvar HistoryState = _createClass(function HistoryState(done, undone, prevRanges, prevTime, prevComposition) {\n  _classCallCheck(this, HistoryState);\n  this.done = done;\n  this.undone = undone;\n  this.prevRanges = prevRanges;\n  this.prevTime = prevTime;\n  this.prevComposition = prevComposition;\n});\nvar DEPTH_OVERFLOW = 20;\nfunction applyTransaction(history, state, tr, options) {\n  var historyTr = tr.getMeta(historyKey),\n    rebased;\n  if (historyTr) return historyTr.historyState;\n  if (tr.getMeta(closeHistoryKey)) history = new HistoryState(history.done, history.undone, null, 0, -1);\n  var appended = tr.getMeta(\"appendedTransaction\");\n  if (tr.steps.length == 0) {\n    return history;\n  } else if (appended && appended.getMeta(historyKey)) {\n    if (appended.getMeta(historyKey).redo) return new HistoryState(history.done.addTransform(tr, undefined, options, mustPreserveItems(state)), history.undone, rangesFor(tr.mapping.maps), history.prevTime, history.prevComposition);else return new HistoryState(history.done, history.undone.addTransform(tr, undefined, options, mustPreserveItems(state)), null, history.prevTime, history.prevComposition);\n  } else if (tr.getMeta(\"addToHistory\") !== false && !(appended && appended.getMeta(\"addToHistory\") === false)) {\n    var composition = tr.getMeta(\"composition\");\n    var newGroup = history.prevTime == 0 || !appended && history.prevComposition != composition && (history.prevTime < (tr.time || 0) - options.newGroupDelay || !isAdjacentTo(tr, history.prevRanges));\n    var prevRanges = appended ? mapRanges(history.prevRanges, tr.mapping) : rangesFor(tr.mapping.maps);\n    return new HistoryState(history.done.addTransform(tr, newGroup ? state.selection.getBookmark() : undefined, options, mustPreserveItems(state)), Branch.empty, prevRanges, tr.time, composition == null ? history.prevComposition : composition);\n  } else if (rebased = tr.getMeta(\"rebased\")) {\n    return new HistoryState(history.done.rebased(tr, rebased), history.undone.rebased(tr, rebased), mapRanges(history.prevRanges, tr.mapping), history.prevTime, history.prevComposition);\n  } else {\n    return new HistoryState(history.done.addMaps(tr.mapping.maps), history.undone.addMaps(tr.mapping.maps), mapRanges(history.prevRanges, tr.mapping), history.prevTime, history.prevComposition);\n  }\n}\nfunction isAdjacentTo(transform, prevRanges) {\n  if (!prevRanges) return false;\n  if (!transform.docChanged) return true;\n  var adjacent = false;\n  transform.mapping.maps[0].forEach(function (start, end) {\n    for (var i = 0; i < prevRanges.length; i += 2) if (start <= prevRanges[i + 1] && end >= prevRanges[i]) adjacent = true;\n  });\n  return adjacent;\n}\nfunction rangesFor(maps) {\n  var result = [];\n  for (var i = maps.length - 1; i >= 0 && result.length == 0; i--) maps[i].forEach(function (_from, _to, from, to) {\n    return result.push(from, to);\n  });\n  return result;\n}\nfunction mapRanges(ranges, mapping) {\n  if (!ranges) return null;\n  var result = [];\n  for (var i = 0; i < ranges.length; i += 2) {\n    var from = mapping.map(ranges[i], 1),\n      to = mapping.map(ranges[i + 1], -1);\n    if (from <= to) result.push(from, to);\n  }\n  return result;\n}\nfunction histTransaction(history, state, redo) {\n  var preserveItems = mustPreserveItems(state);\n  var histOptions = historyKey.get(state).spec.config;\n  var pop = (redo ? history.undone : history.done).popEvent(state, preserveItems);\n  if (!pop) return null;\n  var selection = pop.selection.resolve(pop.transform.doc);\n  var added = (redo ? history.done : history.undone).addTransform(pop.transform, state.selection.getBookmark(), histOptions, preserveItems);\n  var newHist = new HistoryState(redo ? added : pop.remaining, redo ? pop.remaining : added, null, 0, -1);\n  return pop.transform.setSelection(selection).setMeta(historyKey, {\n    redo: redo,\n    historyState: newHist\n  });\n}\nvar cachedPreserveItems = false,\n  cachedPreserveItemsPlugins = null;\nfunction mustPreserveItems(state) {\n  var plugins = state.plugins;\n  if (cachedPreserveItemsPlugins != plugins) {\n    cachedPreserveItems = false;\n    cachedPreserveItemsPlugins = plugins;\n    for (var i = 0; i < plugins.length; i++) if (plugins[i].spec.historyPreserveItems) {\n      cachedPreserveItems = true;\n      break;\n    }\n  }\n  return cachedPreserveItems;\n}\nfunction closeHistory(tr) {\n  return tr.setMeta(closeHistoryKey, true);\n}\nvar historyKey = new prosemirrorState.PluginKey(\"history\");\nvar closeHistoryKey = new prosemirrorState.PluginKey(\"closeHistory\");\nfunction history() {\n  var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n  config = {\n    depth: config.depth || 100,\n    newGroupDelay: config.newGroupDelay || 500\n  };\n  return new prosemirrorState.Plugin({\n    key: historyKey,\n    state: {\n      init: function init() {\n        return new HistoryState(Branch.empty, Branch.empty, null, 0, -1);\n      },\n      apply: function apply(tr, hist, state) {\n        return applyTransaction(hist, state, tr, config);\n      }\n    },\n    config: config,\n    props: {\n      handleDOMEvents: {\n        beforeinput: function beforeinput(view, e) {\n          var inputType = e.inputType;\n          var command = inputType == \"historyUndo\" ? undo : inputType == \"historyRedo\" ? redo : null;\n          if (!command || !view.editable) return false;\n          e.preventDefault();\n          return command(view.state, view.dispatch);\n        }\n      }\n    }\n  });\n}\nfunction buildCommand(redo, scroll) {\n  return function (state, dispatch) {\n    var hist = historyKey.getState(state);\n    if (!hist || (redo ? hist.undone : hist.done).eventCount == 0) return false;\n    if (dispatch) {\n      var tr = histTransaction(hist, state, redo);\n      if (tr) dispatch(scroll ? tr.scrollIntoView() : tr);\n    }\n    return true;\n  };\n}\nvar undo = buildCommand(false, true);\nvar redo = buildCommand(true, true);\nvar undoNoScroll = buildCommand(false, false);\nvar redoNoScroll = buildCommand(true, false);\nfunction undoDepth(state) {\n  var hist = historyKey.getState(state);\n  return hist ? hist.done.eventCount : 0;\n}\nfunction redoDepth(state) {\n  var hist = historyKey.getState(state);\n  return hist ? hist.undone.eventCount : 0;\n}\nfunction isHistoryTransaction(tr) {\n  return tr.getMeta(historyKey) != null;\n}\nexports.closeHistory = closeHistory;\nexports.history = history;\nexports.isHistoryTransaction = isHistoryTransaction;\nexports.redo = redo;\nexports.redoDepth = redoDepth;\nexports.redoNoScroll = redoNoScroll;\nexports.undo = undo;\nexports.undoDepth = undoDepth;\nexports.undoNoScroll = undoNoScroll;\n","'use strict';\n\nvar w3cKeyname = require('w3c-keyname');\nvar prosemirrorState = require('prosemirror-state');\nvar mac = typeof navigator != \"undefined\" && /Mac|iP(hone|[oa]d)/.test(navigator.platform);\nvar windows = typeof navigator != \"undefined\" && /Win/.test(navigator.platform);\nfunction normalizeKeyName(name) {\n  var parts = name.split(/-(?!$)/),\n    result = parts[parts.length - 1];\n  if (result == \"Space\") result = \" \";\n  var alt, ctrl, shift, meta;\n  for (var i = 0; i < parts.length - 1; i++) {\n    var mod = parts[i];\n    if (/^(cmd|meta|m)$/i.test(mod)) meta = true;else if (/^a(lt)?$/i.test(mod)) alt = true;else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true;else if (/^s(hift)?$/i.test(mod)) shift = true;else if (/^mod$/i.test(mod)) {\n      if (mac) meta = true;else ctrl = true;\n    } else throw new Error(\"Unrecognized modifier name: \" + mod);\n  }\n  if (alt) result = \"Alt-\" + result;\n  if (ctrl) result = \"Ctrl-\" + result;\n  if (meta) result = \"Meta-\" + result;\n  if (shift) result = \"Shift-\" + result;\n  return result;\n}\nfunction normalize(map) {\n  var copy = Object.create(null);\n  for (var prop in map) copy[normalizeKeyName(prop)] = map[prop];\n  return copy;\n}\nfunction modifiers(name, event) {\n  var shift = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;\n  if (event.altKey) name = \"Alt-\" + name;\n  if (event.ctrlKey) name = \"Ctrl-\" + name;\n  if (event.metaKey) name = \"Meta-\" + name;\n  if (shift && event.shiftKey) name = \"Shift-\" + name;\n  return name;\n}\nfunction keymap(bindings) {\n  return new prosemirrorState.Plugin({\n    props: {\n      handleKeyDown: keydownHandler(bindings)\n    }\n  });\n}\nfunction keydownHandler(bindings) {\n  var map = normalize(bindings);\n  return function (view, event) {\n    var name = w3cKeyname.keyName(event),\n      baseName,\n      direct = map[modifiers(name, event)];\n    if (direct && direct(view.state, view.dispatch, view)) return true;\n    if (name.length == 1 && name != \" \") {\n      if (event.shiftKey) {\n        var noShift = map[modifiers(name, event, false)];\n        if (noShift && noShift(view.state, view.dispatch, view)) return true;\n      }\n      if ((event.altKey || event.metaKey || event.ctrlKey) && !(windows && event.ctrlKey && event.altKey) && (baseName = w3cKeyname.base[event.keyCode]) && baseName != name) {\n        var fromCode = map[modifiers(baseName, event)];\n        if (fromCode && fromCode(view.state, view.dispatch, view)) return true;\n      }\n    }\n    return false;\n  };\n}\nexports.keydownHandler = keydownHandler;\nexports.keymap = keymap;\n","'use strict';\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _get() { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \"function\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \"function\") { throw new TypeError(\"Super expression must either be null or a function\"); } if (typeof _cache !== \"undefined\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\nfunction _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf(\"[native code]\") !== -1; } catch (e) { return typeof fn === \"function\"; } }\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\nfunction _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); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar OrderedMap = require('orderedmap');\nfunction _findDiffStart(a, b, pos) {\n  for (var i = 0;; i++) {\n    if (i == a.childCount || i == b.childCount) return a.childCount == b.childCount ? null : pos;\n    var childA = a.child(i),\n      childB = b.child(i);\n    if (childA == childB) {\n      pos += childA.nodeSize;\n      continue;\n    }\n    if (!childA.sameMarkup(childB)) return pos;\n    if (childA.isText && childA.text != childB.text) {\n      var tA = childA.text,\n        tB = childB.text,\n        j = 0;\n      for (; tA[j] == tB[j]; j++) pos++;\n      if (j && j < tA.length && j < tB.length && surrogateHigh(tA.charCodeAt(j - 1)) && surrogateLow(tA.charCodeAt(j))) pos--;\n      return pos;\n    }\n    if (childA.content.size || childB.content.size) {\n      var inner = _findDiffStart(childA.content, childB.content, pos + 1);\n      if (inner != null) return inner;\n    }\n    pos += childA.nodeSize;\n  }\n}\nfunction _findDiffEnd(a, b, posA, posB) {\n  for (var iA = a.childCount, iB = b.childCount;;) {\n    if (iA == 0 || iB == 0) return iA == iB ? null : {\n      a: posA,\n      b: posB\n    };\n    var childA = a.child(--iA),\n      childB = b.child(--iB),\n      size = childA.nodeSize;\n    if (childA == childB) {\n      posA -= size;\n      posB -= size;\n      continue;\n    }\n    if (!childA.sameMarkup(childB)) return {\n      a: posA,\n      b: posB\n    };\n    if (childA.isText && childA.text != childB.text) {\n      var tA = childA.text,\n        tB = childB.text,\n        _iA = tA.length,\n        _iB = tB.length;\n      while (_iA > 0 && _iB > 0 && tA[_iA - 1] == tB[_iB - 1]) {\n        _iA--;\n        _iB--;\n        posA--;\n        posB--;\n      }\n      if (_iA && _iB && _iA < tA.length && surrogateHigh(tA.charCodeAt(_iA - 1)) && surrogateLow(tA.charCodeAt(_iA))) {\n        posA++;\n        posB++;\n      }\n      return {\n        a: posA,\n        b: posB\n      };\n    }\n    if (childA.content.size || childB.content.size) {\n      var inner = _findDiffEnd(childA.content, childB.content, posA - 1, posB - 1);\n      if (inner) return inner;\n    }\n    posA -= size;\n    posB -= size;\n  }\n}\nfunction surrogateLow(ch) {\n  return ch >= 0xDC00 && ch < 0xE000;\n}\nfunction surrogateHigh(ch) {\n  return ch >= 0xD800 && ch < 0xDC00;\n}\nvar Fragment = function () {\n  function Fragment(content, size) {\n    _classCallCheck(this, Fragment);\n    this.content = content;\n    this.size = size || 0;\n    if (size == null) for (var i = 0; i < content.length; i++) this.size += content[i].nodeSize;\n  }\n  _createClass(Fragment, [{\n    key: \"nodesBetween\",\n    value: function nodesBetween(from, to, f) {\n      var nodeStart = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;\n      var parent = arguments.length > 4 ? arguments[4] : undefined;\n      for (var i = 0, pos = 0; pos < to; i++) {\n        var child = this.content[i],\n          end = pos + child.nodeSize;\n        if (end > from && f(child, nodeStart + pos, parent || null, i) !== false && child.content.size) {\n          var start = pos + 1;\n          child.nodesBetween(Math.max(0, from - start), Math.min(child.content.size, to - start), f, nodeStart + start);\n        }\n        pos = end;\n      }\n    }\n  }, {\n    key: \"descendants\",\n    value: function descendants(f) {\n      this.nodesBetween(0, this.size, f);\n    }\n  }, {\n    key: \"textBetween\",\n    value: function textBetween(from, to, blockSeparator, leafText) {\n      var text = \"\",\n        first = true;\n      this.nodesBetween(from, to, function (node, pos) {\n        var nodeText = node.isText ? node.text.slice(Math.max(from, pos) - pos, to - pos) : !node.isLeaf ? \"\" : leafText ? typeof leafText === \"function\" ? leafText(node) : leafText : node.type.spec.leafText ? node.type.spec.leafText(node) : \"\";\n        if (node.isBlock && (node.isLeaf && nodeText || node.isTextblock) && blockSeparator) {\n          if (first) first = false;else text += blockSeparator;\n        }\n        text += nodeText;\n      }, 0);\n      return text;\n    }\n  }, {\n    key: \"append\",\n    value: function append(other) {\n      if (!other.size) return this;\n      if (!this.size) return other;\n      var last = this.lastChild,\n        first = other.firstChild,\n        content = this.content.slice(),\n        i = 0;\n      if (last.isText && last.sameMarkup(first)) {\n        content[content.length - 1] = last.withText(last.text + first.text);\n        i = 1;\n      }\n      for (; i < other.content.length; i++) content.push(other.content[i]);\n      return new Fragment(content, this.size + other.size);\n    }\n  }, {\n    key: \"cut\",\n    value: function cut(from) {\n      var to = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.size;\n      if (from == 0 && to == this.size) return this;\n      var result = [],\n        size = 0;\n      if (to > from) for (var i = 0, pos = 0; pos < to; i++) {\n        var child = this.content[i],\n          end = pos + child.nodeSize;\n        if (end > from) {\n          if (pos < from || end > to) {\n            if (child.isText) child = child.cut(Math.max(0, from - pos), Math.min(child.text.length, to - pos));else child = child.cut(Math.max(0, from - pos - 1), Math.min(child.content.size, to - pos - 1));\n          }\n          result.push(child);\n          size += child.nodeSize;\n        }\n        pos = end;\n      }\n      return new Fragment(result, size);\n    }\n  }, {\n    key: \"cutByIndex\",\n    value: function cutByIndex(from, to) {\n      if (from == to) return Fragment.empty;\n      if (from == 0 && to == this.content.length) return this;\n      return new Fragment(this.content.slice(from, to));\n    }\n  }, {\n    key: \"replaceChild\",\n    value: function replaceChild(index, node) {\n      var current = this.content[index];\n      if (current == node) return this;\n      var copy = this.content.slice();\n      var size = this.size + node.nodeSize - current.nodeSize;\n      copy[index] = node;\n      return new Fragment(copy, size);\n    }\n  }, {\n    key: \"addToStart\",\n    value: function addToStart(node) {\n      return new Fragment([node].concat(this.content), this.size + node.nodeSize);\n    }\n  }, {\n    key: \"addToEnd\",\n    value: function addToEnd(node) {\n      return new Fragment(this.content.concat(node), this.size + node.nodeSize);\n    }\n  }, {\n    key: \"eq\",\n    value: function eq(other) {\n      if (this.content.length != other.content.length) return false;\n      for (var i = 0; i < this.content.length; i++) if (!this.content[i].eq(other.content[i])) return false;\n      return true;\n    }\n  }, {\n    key: \"firstChild\",\n    get: function get() {\n      return this.content.length ? this.content[0] : null;\n    }\n  }, {\n    key: \"lastChild\",\n    get: function get() {\n      return this.content.length ? this.content[this.content.length - 1] : null;\n    }\n  }, {\n    key: \"childCount\",\n    get: function get() {\n      return this.content.length;\n    }\n  }, {\n    key: \"child\",\n    value: function child(index) {\n      var found = this.content[index];\n      if (!found) throw new RangeError(\"Index \" + index + \" out of range for \" + this);\n      return found;\n    }\n  }, {\n    key: \"maybeChild\",\n    value: function maybeChild(index) {\n      return this.content[index] || null;\n    }\n  }, {\n    key: \"forEach\",\n    value: function forEach(f) {\n      for (var i = 0, p = 0; i < this.content.length; i++) {\n        var child = this.content[i];\n        f(child, p, i);\n        p += child.nodeSize;\n      }\n    }\n  }, {\n    key: \"findDiffStart\",\n    value: function findDiffStart(other) {\n      var pos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n      return _findDiffStart(this, other, pos);\n    }\n  }, {\n    key: \"findDiffEnd\",\n    value: function findDiffEnd(other) {\n      var pos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.size;\n      var otherPos = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : other.size;\n      return _findDiffEnd(this, other, pos, otherPos);\n    }\n  }, {\n    key: \"findIndex\",\n    value: function findIndex(pos) {\n      if (pos == 0) return retIndex(0, pos);\n      if (pos == this.size) return retIndex(this.content.length, pos);\n      if (pos > this.size || pos < 0) throw new RangeError(\"Position \".concat(pos, \" outside of fragment (\").concat(this, \")\"));\n      for (var i = 0, curPos = 0;; i++) {\n        var cur = this.child(i),\n          end = curPos + cur.nodeSize;\n        if (end >= pos) {\n          if (end == pos) return retIndex(i + 1, end);\n          return retIndex(i, curPos);\n        }\n        curPos = end;\n      }\n    }\n  }, {\n    key: \"toString\",\n    value: function toString() {\n      return \"<\" + this.toStringInner() + \">\";\n    }\n  }, {\n    key: \"toStringInner\",\n    value: function toStringInner() {\n      return this.content.join(\", \");\n    }\n  }, {\n    key: \"toJSON\",\n    value: function toJSON() {\n      return this.content.length ? this.content.map(function (n) {\n        return n.toJSON();\n      }) : null;\n    }\n  }], [{\n    key: \"fromJSON\",\n    value: function fromJSON(schema, value) {\n      if (!value) return Fragment.empty;\n      if (!Array.isArray(value)) throw new RangeError(\"Invalid input for Fragment.fromJSON\");\n      return Fragment.fromArray(value.map(schema.nodeFromJSON));\n    }\n  }, {\n    key: \"fromArray\",\n    value: function fromArray(array) {\n      if (!array.length) return Fragment.empty;\n      var joined,\n        size = 0;\n      for (var i = 0; i < array.length; i++) {\n        var node = array[i];\n        size += node.nodeSize;\n        if (i && node.isText && array[i - 1].sameMarkup(node)) {\n          if (!joined) joined = array.slice(0, i);\n          joined[joined.length - 1] = node.withText(joined[joined.length - 1].text + node.text);\n        } else if (joined) {\n          joined.push(node);\n        }\n      }\n      return new Fragment(joined || array, size);\n    }\n  }, {\n    key: \"from\",\n    value: function from(nodes) {\n      if (!nodes) return Fragment.empty;\n      if (nodes instanceof Fragment) return nodes;\n      if (Array.isArray(nodes)) return this.fromArray(nodes);\n      if (nodes.attrs) return new Fragment([nodes], nodes.nodeSize);\n      throw new RangeError(\"Can not convert \" + nodes + \" to a Fragment\" + (nodes.nodesBetween ? \" (looks like multiple versions of prosemirror-model were loaded)\" : \"\"));\n    }\n  }]);\n  return Fragment;\n}();\nFragment.empty = new Fragment([], 0);\nvar found = {\n  index: 0,\n  offset: 0\n};\nfunction retIndex(index, offset) {\n  found.index = index;\n  found.offset = offset;\n  return found;\n}\nfunction compareDeep(a, b) {\n  if (a === b) return true;\n  if (!(a && _typeof(a) == \"object\") || !(b && _typeof(b) == \"object\")) return false;\n  var array = Array.isArray(a);\n  if (Array.isArray(b) != array) return false;\n  if (array) {\n    if (a.length != b.length) return false;\n    for (var i = 0; i < a.length; i++) if (!compareDeep(a[i], b[i])) return false;\n  } else {\n    for (var p in a) if (!(p in b) || !compareDeep(a[p], b[p])) return false;\n    for (var _p in b) if (!(_p in a)) return false;\n  }\n  return true;\n}\nvar Mark = function () {\n  function Mark(type, attrs) {\n    _classCallCheck(this, Mark);\n    this.type = type;\n    this.attrs = attrs;\n  }\n  _createClass(Mark, [{\n    key: \"addToSet\",\n    value: function addToSet(set) {\n      var copy,\n        placed = false;\n      for (var i = 0; i < set.length; i++) {\n        var other = set[i];\n        if (this.eq(other)) return set;\n        if (this.type.excludes(other.type)) {\n          if (!copy) copy = set.slice(0, i);\n        } else if (other.type.excludes(this.type)) {\n          return set;\n        } else {\n          if (!placed && other.type.rank > this.type.rank) {\n            if (!copy) copy = set.slice(0, i);\n            copy.push(this);\n            placed = true;\n          }\n          if (copy) copy.push(other);\n        }\n      }\n      if (!copy) copy = set.slice();\n      if (!placed) copy.push(this);\n      return copy;\n    }\n  }, {\n    key: \"removeFromSet\",\n    value: function removeFromSet(set) {\n      for (var i = 0; i < set.length; i++) if (this.eq(set[i])) return set.slice(0, i).concat(set.slice(i + 1));\n      return set;\n    }\n  }, {\n    key: \"isInSet\",\n    value: function isInSet(set) {\n      for (var i = 0; i < set.length; i++) if (this.eq(set[i])) return true;\n      return false;\n    }\n  }, {\n    key: \"eq\",\n    value: function eq(other) {\n      return this == other || this.type == other.type && compareDeep(this.attrs, other.attrs);\n    }\n  }, {\n    key: \"toJSON\",\n    value: function toJSON() {\n      var obj = {\n        type: this.type.name\n      };\n      for (var _ in this.attrs) {\n        obj.attrs = this.attrs;\n        break;\n      }\n      return obj;\n    }\n  }], [{\n    key: \"fromJSON\",\n    value: function fromJSON(schema, json) {\n      if (!json) throw new RangeError(\"Invalid input for Mark.fromJSON\");\n      var type = schema.marks[json.type];\n      if (!type) throw new RangeError(\"There is no mark type \".concat(json.type, \" in this schema\"));\n      var mark = type.create(json.attrs);\n      return mark;\n    }\n  }, {\n    key: \"sameSet\",\n    value: function sameSet(a, b) {\n      if (a == b) return true;\n      if (a.length != b.length) return false;\n      for (var i = 0; i < a.length; i++) if (!a[i].eq(b[i])) return false;\n      return true;\n    }\n  }, {\n    key: \"setFrom\",\n    value: function setFrom(marks) {\n      if (!marks || Array.isArray(marks) && marks.length == 0) return Mark.none;\n      if (marks instanceof Mark) return [marks];\n      var copy = marks.slice();\n      copy.sort(function (a, b) {\n        return a.type.rank - b.type.rank;\n      });\n      return copy;\n    }\n  }]);\n  return Mark;\n}();\nMark.none = [];\nvar ReplaceError = function (_Error) {\n  _inherits(ReplaceError, _Error);\n  var _super = _createSuper(ReplaceError);\n  function ReplaceError() {\n    _classCallCheck(this, ReplaceError);\n    return _super.apply(this, arguments);\n  }\n  return _createClass(ReplaceError);\n}(_wrapNativeSuper(Error));\nvar Slice = function () {\n  function Slice(content, openStart, openEnd) {\n    _classCallCheck(this, Slice);\n    this.content = content;\n    this.openStart = openStart;\n    this.openEnd = openEnd;\n  }\n  _createClass(Slice, [{\n    key: \"size\",\n    get: function get() {\n      return this.content.size - this.openStart - this.openEnd;\n    }\n  }, {\n    key: \"insertAt\",\n    value: function insertAt(pos, fragment) {\n      var content = insertInto(this.content, pos + this.openStart, fragment, this.openStart + 1, this.openEnd + 1);\n      return content && new Slice(content, this.openStart, this.openEnd);\n    }\n  }, {\n    key: \"removeBetween\",\n    value: function removeBetween(from, to) {\n      return new Slice(removeRange(this.content, from + this.openStart, to + this.openStart), this.openStart, this.openEnd);\n    }\n  }, {\n    key: \"eq\",\n    value: function eq(other) {\n      return this.content.eq(other.content) && this.openStart == other.openStart && this.openEnd == other.openEnd;\n    }\n  }, {\n    key: \"toString\",\n    value: function toString() {\n      return this.content + \"(\" + this.openStart + \",\" + this.openEnd + \")\";\n    }\n  }, {\n    key: \"toJSON\",\n    value: function toJSON() {\n      if (!this.content.size) return null;\n      var json = {\n        content: this.content.toJSON()\n      };\n      if (this.openStart > 0) json.openStart = this.openStart;\n      if (this.openEnd > 0) json.openEnd = this.openEnd;\n      return json;\n    }\n  }], [{\n    key: \"fromJSON\",\n    value: function fromJSON(schema, json) {\n      if (!json) return Slice.empty;\n      var openStart = json.openStart || 0,\n        openEnd = json.openEnd || 0;\n      if (typeof openStart != \"number\" || typeof openEnd != \"number\") throw new RangeError(\"Invalid input for Slice.fromJSON\");\n      return new Slice(Fragment.fromJSON(schema, json.content), openStart, openEnd);\n    }\n  }, {\n    key: \"maxOpen\",\n    value: function maxOpen(fragment) {\n      var openIsolating = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;\n      var openStart = 0,\n        openEnd = 0;\n      for (var n = fragment.firstChild; n && !n.isLeaf && (openIsolating || !n.type.spec.isolating); n = n.firstChild) openStart++;\n      for (var _n = fragment.lastChild; _n && !_n.isLeaf && (openIsolating || !_n.type.spec.isolating); _n = _n.lastChild) openEnd++;\n      return new Slice(fragment, openStart, openEnd);\n    }\n  }]);\n  return Slice;\n}();\nSlice.empty = new Slice(Fragment.empty, 0, 0);\nfunction removeRange(content, from, to) {\n  var _content$findIndex = content.findIndex(from),\n    index = _content$findIndex.index,\n    offset = _content$findIndex.offset,\n    child = content.maybeChild(index);\n  var _content$findIndex2 = content.findIndex(to),\n    indexTo = _content$findIndex2.index,\n    offsetTo = _content$findIndex2.offset;\n  if (offset == from || child.isText) {\n    if (offsetTo != to && !content.child(indexTo).isText) throw new RangeError(\"Removing non-flat range\");\n    return content.cut(0, from).append(content.cut(to));\n  }\n  if (index != indexTo) throw new RangeError(\"Removing non-flat range\");\n  return content.replaceChild(index, child.copy(removeRange(child.content, from - offset - 1, to - offset - 1)));\n}\nfunction insertInto(content, dist, insert, openStart, openEnd, parent) {\n  var _content$findIndex3 = content.findIndex(dist),\n    index = _content$findIndex3.index,\n    offset = _content$findIndex3.offset,\n    child = content.maybeChild(index);\n  if (offset == dist || child.isText) {\n    if (parent && openStart <= 0 && openEnd <= 0 && !parent.canReplace(index, index, insert)) return null;\n    return content.cut(0, dist).append(insert).append(content.cut(dist));\n  }\n  var inner = insertInto(child.content, dist - offset - 1, insert, index == 0 ? openStart - 1 : 0, index == content.childCount - 1 ? openEnd - 1 : 0, child);\n  return inner && content.replaceChild(index, child.copy(inner));\n}\nfunction _replace($from, $to, slice) {\n  if (slice.openStart > $from.depth) throw new ReplaceError(\"Inserted content deeper than insertion position\");\n  if ($from.depth - slice.openStart != $to.depth - slice.openEnd) throw new ReplaceError(\"Inconsistent open depths\");\n  return replaceOuter($from, $to, slice, 0);\n}\nfunction replaceOuter($from, $to, slice, depth) {\n  var index = $from.index(depth),\n    node = $from.node(depth);\n  if (index == $to.index(depth) && depth < $from.depth - slice.openStart) {\n    var inner = replaceOuter($from, $to, slice, depth + 1);\n    return node.copy(node.content.replaceChild(index, inner));\n  } else if (!slice.content.size) {\n    return close(node, replaceTwoWay($from, $to, depth));\n  } else if (!slice.openStart && !slice.openEnd && $from.depth == depth && $to.depth == depth) {\n    var parent = $from.parent,\n      content = parent.content;\n    return close(parent, content.cut(0, $from.parentOffset).append(slice.content).append(content.cut($to.parentOffset)));\n  } else {\n    var _prepareSliceForRepla = prepareSliceForReplace(slice, $from),\n      start = _prepareSliceForRepla.start,\n      end = _prepareSliceForRepla.end;\n    return close(node, replaceThreeWay($from, start, end, $to, depth));\n  }\n}\nfunction checkJoin(main, sub) {\n  if (!sub.type.compatibleContent(main.type)) throw new ReplaceError(\"Cannot join \" + sub.type.name + \" onto \" + main.type.name);\n}\nfunction joinable($before, $after, depth) {\n  var node = $before.node(depth);\n  checkJoin(node, $after.node(depth));\n  return node;\n}\nfunction addNode(child, target) {\n  var last = target.length - 1;\n  if (last >= 0 && child.isText && child.sameMarkup(target[last])) target[last] = child.withText(target[last].text + child.text);else target.push(child);\n}\nfunction addRange($start, $end, depth, target) {\n  var node = ($end || $start).node(depth);\n  var startIndex = 0,\n    endIndex = $end ? $end.index(depth) : node.childCount;\n  if ($start) {\n    startIndex = $start.index(depth);\n    if ($start.depth > depth) {\n      startIndex++;\n    } else if ($start.textOffset) {\n      addNode($start.nodeAfter, target);\n      startIndex++;\n    }\n  }\n  for (var i = startIndex; i < endIndex; i++) addNode(node.child(i), target);\n  if ($end && $end.depth == depth && $end.textOffset) addNode($end.nodeBefore, target);\n}\nfunction close(node, content) {\n  if (!node.type.validContent(content)) throw new ReplaceError(\"Invalid content for node \" + node.type.name);\n  return node.copy(content);\n}\nfunction replaceThreeWay($from, $start, $end, $to, depth) {\n  var openStart = $from.depth > depth && joinable($from, $start, depth + 1);\n  var openEnd = $to.depth > depth && joinable($end, $to, depth + 1);\n  var content = [];\n  addRange(null, $from, depth, content);\n  if (openStart && openEnd && $start.index(depth) == $end.index(depth)) {\n    checkJoin(openStart, openEnd);\n    addNode(close(openStart, replaceThreeWay($from, $start, $end, $to, depth + 1)), content);\n  } else {\n    if (openStart) addNode(close(openStart, replaceTwoWay($from, $start, depth + 1)), content);\n    addRange($start, $end, depth, content);\n    if (openEnd) addNode(close(openEnd, replaceTwoWay($end, $to, depth + 1)), content);\n  }\n  addRange($to, null, depth, content);\n  return new Fragment(content);\n}\nfunction replaceTwoWay($from, $to, depth) {\n  var content = [];\n  addRange(null, $from, depth, content);\n  if ($from.depth > depth) {\n    var type = joinable($from, $to, depth + 1);\n    addNode(close(type, replaceTwoWay($from, $to, depth + 1)), content);\n  }\n  addRange($to, null, depth, content);\n  return new Fragment(content);\n}\nfunction prepareSliceForReplace(slice, $along) {\n  var extra = $along.depth - slice.openStart,\n    parent = $along.node(extra);\n  var node = parent.copy(slice.content);\n  for (var i = extra - 1; i >= 0; i--) node = $along.node(i).copy(Fragment.from(node));\n  return {\n    start: node.resolveNoCache(slice.openStart + extra),\n    end: node.resolveNoCache(node.content.size - slice.openEnd - extra)\n  };\n}\nvar ResolvedPos = function () {\n  function ResolvedPos(pos, path, parentOffset) {\n    _classCallCheck(this, ResolvedPos);\n    this.pos = pos;\n    this.path = path;\n    this.parentOffset = parentOffset;\n    this.depth = path.length / 3 - 1;\n  }\n  _createClass(ResolvedPos, [{\n    key: \"resolveDepth\",\n    value: function resolveDepth(val) {\n      if (val == null) return this.depth;\n      if (val < 0) return this.depth + val;\n      return val;\n    }\n  }, {\n    key: \"parent\",\n    get: function get() {\n      return this.node(this.depth);\n    }\n  }, {\n    key: \"doc\",\n    get: function get() {\n      return this.node(0);\n    }\n  }, {\n    key: \"node\",\n    value: function node(depth) {\n      return this.path[this.resolveDepth(depth) * 3];\n    }\n  }, {\n    key: \"index\",\n    value: function index(depth) {\n      return this.path[this.resolveDepth(depth) * 3 + 1];\n    }\n  }, {\n    key: \"indexAfter\",\n    value: function indexAfter(depth) {\n      depth = this.resolveDepth(depth);\n      return this.index(depth) + (depth == this.depth && !this.textOffset ? 0 : 1);\n    }\n  }, {\n    key: \"start\",\n    value: function start(depth) {\n      depth = this.resolveDepth(depth);\n      return depth == 0 ? 0 : this.path[depth * 3 - 1] + 1;\n    }\n  }, {\n    key: \"end\",\n    value: function end(depth) {\n      depth = this.resolveDepth(depth);\n      return this.start(depth) + this.node(depth).content.size;\n    }\n  }, {\n    key: \"before\",\n    value: function before(depth) {\n      depth = this.resolveDepth(depth);\n      if (!depth) throw new RangeError(\"There is no position before the top-level node\");\n      return depth == this.depth + 1 ? this.pos : this.path[depth * 3 - 1];\n    }\n  }, {\n    key: \"after\",\n    value: function after(depth) {\n      depth = this.resolveDepth(depth);\n      if (!depth) throw new RangeError(\"There is no position after the top-level node\");\n      return depth == this.depth + 1 ? this.pos : this.path[depth * 3 - 1] + this.path[depth * 3].nodeSize;\n    }\n  }, {\n    key: \"textOffset\",\n    get: function get() {\n      return this.pos - this.path[this.path.length - 1];\n    }\n  }, {\n    key: \"nodeAfter\",\n    get: function get() {\n      var parent = this.parent,\n        index = this.index(this.depth);\n      if (index == parent.childCount) return null;\n      var dOff = this.pos - this.path[this.path.length - 1],\n        child = parent.child(index);\n      return dOff ? parent.child(index).cut(dOff) : child;\n    }\n  }, {\n    key: \"nodeBefore\",\n    get: function get() {\n      var index = this.index(this.depth);\n      var dOff = this.pos - this.path[this.path.length - 1];\n      if (dOff) return this.parent.child(index).cut(0, dOff);\n      return index == 0 ? null : this.parent.child(index - 1);\n    }\n  }, {\n    key: \"posAtIndex\",\n    value: function posAtIndex(index, depth) {\n      depth = this.resolveDepth(depth);\n      var node = this.path[depth * 3],\n        pos = depth == 0 ? 0 : this.path[depth * 3 - 1] + 1;\n      for (var i = 0; i < index; i++) pos += node.child(i).nodeSize;\n      return pos;\n    }\n  }, {\n    key: \"marks\",\n    value: function marks() {\n      var parent = this.parent,\n        index = this.index();\n      if (parent.content.size == 0) return Mark.none;\n      if (this.textOffset) return parent.child(index).marks;\n      var main = parent.maybeChild(index - 1),\n        other = parent.maybeChild(index);\n      if (!main) {\n        var tmp = main;\n        main = other;\n        other = tmp;\n      }\n      var marks = main.marks;\n      for (var i = 0; i < marks.length; i++) if (marks[i].type.spec.inclusive === false && (!other || !marks[i].isInSet(other.marks))) marks = marks[i--].removeFromSet(marks);\n      return marks;\n    }\n  }, {\n    key: \"marksAcross\",\n    value: function marksAcross($end) {\n      var after = this.parent.maybeChild(this.index());\n      if (!after || !after.isInline) return null;\n      var marks = after.marks,\n        next = $end.parent.maybeChild($end.index());\n      for (var i = 0; i < marks.length; i++) if (marks[i].type.spec.inclusive === false && (!next || !marks[i].isInSet(next.marks))) marks = marks[i--].removeFromSet(marks);\n      return marks;\n    }\n  }, {\n    key: \"sharedDepth\",\n    value: function sharedDepth(pos) {\n      for (var depth = this.depth; depth > 0; depth--) if (this.start(depth) <= pos && this.end(depth) >= pos) return depth;\n      return 0;\n    }\n  }, {\n    key: \"blockRange\",\n    value: function blockRange() {\n      var other = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this;\n      var pred = arguments.length > 1 ? arguments[1] : undefined;\n      if (other.pos < this.pos) return other.blockRange(this);\n      for (var d = this.depth - (this.parent.inlineContent || this.pos == other.pos ? 1 : 0); d >= 0; d--) if (other.pos <= this.end(d) && (!pred || pred(this.node(d)))) return new NodeRange(this, other, d);\n      return null;\n    }\n  }, {\n    key: \"sameParent\",\n    value: function sameParent(other) {\n      return this.pos - this.parentOffset == other.pos - other.parentOffset;\n    }\n  }, {\n    key: \"max\",\n    value: function max(other) {\n      return other.pos > this.pos ? other : this;\n    }\n  }, {\n    key: \"min\",\n    value: function min(other) {\n      return other.pos < this.pos ? other : this;\n    }\n  }, {\n    key: \"toString\",\n    value: function toString() {\n      var str = \"\";\n      for (var i = 1; i <= this.depth; i++) str += (str ? \"/\" : \"\") + this.node(i).type.name + \"_\" + this.index(i - 1);\n      return str + \":\" + this.parentOffset;\n    }\n  }], [{\n    key: \"resolve\",\n    value: function resolve(doc, pos) {\n      if (!(pos >= 0 && pos <= doc.content.size)) throw new RangeError(\"Position \" + pos + \" out of range\");\n      var path = [];\n      var start = 0,\n        parentOffset = pos;\n      for (var node = doc;;) {\n        var _node$content$findInd = node.content.findIndex(parentOffset),\n          index = _node$content$findInd.index,\n          offset = _node$content$findInd.offset;\n        var rem = parentOffset - offset;\n        path.push(node, index, start + offset);\n        if (!rem) break;\n        node = node.child(index);\n        if (node.isText) break;\n        parentOffset = rem - 1;\n        start += offset + 1;\n      }\n      return new ResolvedPos(pos, path, parentOffset);\n    }\n  }, {\n    key: \"resolveCached\",\n    value: function resolveCached(doc, pos) {\n      var cache = resolveCache.get(doc);\n      if (cache) {\n        for (var i = 0; i < cache.elts.length; i++) {\n          var elt = cache.elts[i];\n          if (elt.pos == pos) return elt;\n        }\n      } else {\n        resolveCache.set(doc, cache = new ResolveCache());\n      }\n      var result = cache.elts[cache.i] = ResolvedPos.resolve(doc, pos);\n      cache.i = (cache.i + 1) % resolveCacheSize;\n      return result;\n    }\n  }]);\n  return ResolvedPos;\n}();\nvar ResolveCache = _createClass(function ResolveCache() {\n  _classCallCheck(this, ResolveCache);\n  this.elts = [];\n  this.i = 0;\n});\nvar resolveCacheSize = 12,\n  resolveCache = new WeakMap();\nvar NodeRange = function () {\n  function NodeRange($from, $to, depth) {\n    _classCallCheck(this, NodeRange);\n    this.$from = $from;\n    this.$to = $to;\n    this.depth = depth;\n  }\n  _createClass(NodeRange, [{\n    key: \"start\",\n    get: function get() {\n      return this.$from.before(this.depth + 1);\n    }\n  }, {\n    key: \"end\",\n    get: function get() {\n      return this.$to.after(this.depth + 1);\n    }\n  }, {\n    key: \"parent\",\n    get: function get() {\n      return this.$from.node(this.depth);\n    }\n  }, {\n    key: \"startIndex\",\n    get: function get() {\n      return this.$from.index(this.depth);\n    }\n  }, {\n    key: \"endIndex\",\n    get: function get() {\n      return this.$to.indexAfter(this.depth);\n    }\n  }]);\n  return NodeRange;\n}();\nvar emptyAttrs = Object.create(null);\nvar Node = function () {\n  function Node(type, attrs, content) {\n    var marks = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Mark.none;\n    _classCallCheck(this, Node);\n    this.type = type;\n    this.attrs = attrs;\n    this.marks = marks;\n    this.content = content || Fragment.empty;\n  }\n  _createClass(Node, [{\n    key: \"children\",\n    get: function get() {\n      return this.content.content;\n    }\n  }, {\n    key: \"nodeSize\",\n    get: function get() {\n      return this.isLeaf ? 1 : 2 + this.content.size;\n    }\n  }, {\n    key: \"childCount\",\n    get: function get() {\n      return this.content.childCount;\n    }\n  }, {\n    key: \"child\",\n    value: function child(index) {\n      return this.content.child(index);\n    }\n  }, {\n    key: \"maybeChild\",\n    value: function maybeChild(index) {\n      return this.content.maybeChild(index);\n    }\n  }, {\n    key: \"forEach\",\n    value: function forEach(f) {\n      this.content.forEach(f);\n    }\n  }, {\n    key: \"nodesBetween\",\n    value: function nodesBetween(from, to, f) {\n      var startPos = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;\n      this.content.nodesBetween(from, to, f, startPos, this);\n    }\n  }, {\n    key: \"descendants\",\n    value: function descendants(f) {\n      this.nodesBetween(0, this.content.size, f);\n    }\n  }, {\n    key: \"textContent\",\n    get: function get() {\n      return this.isLeaf && this.type.spec.leafText ? this.type.spec.leafText(this) : this.textBetween(0, this.content.size, \"\");\n    }\n  }, {\n    key: \"textBetween\",\n    value: function textBetween(from, to, blockSeparator, leafText) {\n      return this.content.textBetween(from, to, blockSeparator, leafText);\n    }\n  }, {\n    key: \"firstChild\",\n    get: function get() {\n      return this.content.firstChild;\n    }\n  }, {\n    key: \"lastChild\",\n    get: function get() {\n      return this.content.lastChild;\n    }\n  }, {\n    key: \"eq\",\n    value: function eq(other) {\n      return this == other || this.sameMarkup(other) && this.content.eq(other.content);\n    }\n  }, {\n    key: \"sameMarkup\",\n    value: function sameMarkup(other) {\n      return this.hasMarkup(other.type, other.attrs, other.marks);\n    }\n  }, {\n    key: \"hasMarkup\",\n    value: function hasMarkup(type, attrs, marks) {\n      return this.type == type && compareDeep(this.attrs, attrs || type.defaultAttrs || emptyAttrs) && Mark.sameSet(this.marks, marks || Mark.none);\n    }\n  }, {\n    key: \"copy\",\n    value: function copy() {\n      var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n      if (content == this.content) return this;\n      return new Node(this.type, this.attrs, content, this.marks);\n    }\n  }, {\n    key: \"mark\",\n    value: function mark(marks) {\n      return marks == this.marks ? this : new Node(this.type, this.attrs, this.content, marks);\n    }\n  }, {\n    key: \"cut\",\n    value: function cut(from) {\n      var to = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.content.size;\n      if (from == 0 && to == this.content.size) return this;\n      return this.copy(this.content.cut(from, to));\n    }\n  }, {\n    key: \"slice\",\n    value: function slice(from) {\n      var to = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.content.size;\n      var includeParents = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n      if (from == to) return Slice.empty;\n      var $from = this.resolve(from),\n        $to = this.resolve(to);\n      var depth = includeParents ? 0 : $from.sharedDepth(to);\n      var start = $from.start(depth),\n        node = $from.node(depth);\n      var content = node.content.cut($from.pos - start, $to.pos - start);\n      return new Slice(content, $from.depth - depth, $to.depth - depth);\n    }\n  }, {\n    key: \"replace\",\n    value: function replace(from, to, slice) {\n      return _replace(this.resolve(from), this.resolve(to), slice);\n    }\n  }, {\n    key: \"nodeAt\",\n    value: function nodeAt(pos) {\n      for (var node = this;;) {\n        var _node$content$findInd2 = node.content.findIndex(pos),\n          index = _node$content$findInd2.index,\n          offset = _node$content$findInd2.offset;\n        node = node.maybeChild(index);\n        if (!node) return null;\n        if (offset == pos || node.isText) return node;\n        pos -= offset + 1;\n      }\n    }\n  }, {\n    key: \"childAfter\",\n    value: function childAfter(pos) {\n      var _this$content$findInd = this.content.findIndex(pos),\n        index = _this$content$findInd.index,\n        offset = _this$content$findInd.offset;\n      return {\n        node: this.content.maybeChild(index),\n        index: index,\n        offset: offset\n      };\n    }\n  }, {\n    key: \"childBefore\",\n    value: function childBefore(pos) {\n      if (pos == 0) return {\n        node: null,\n        index: 0,\n        offset: 0\n      };\n      var _this$content$findInd2 = this.content.findIndex(pos),\n        index = _this$content$findInd2.index,\n        offset = _this$content$findInd2.offset;\n      if (offset < pos) return {\n        node: this.content.child(index),\n        index: index,\n        offset: offset\n      };\n      var node = this.content.child(index - 1);\n      return {\n        node: node,\n        index: index - 1,\n        offset: offset - node.nodeSize\n      };\n    }\n  }, {\n    key: \"resolve\",\n    value: function resolve(pos) {\n      return ResolvedPos.resolveCached(this, pos);\n    }\n  }, {\n    key: \"resolveNoCache\",\n    value: function resolveNoCache(pos) {\n      return ResolvedPos.resolve(this, pos);\n    }\n  }, {\n    key: \"rangeHasMark\",\n    value: function rangeHasMark(from, to, type) {\n      var found = false;\n      if (to > from) this.nodesBetween(from, to, function (node) {\n        if (type.isInSet(node.marks)) found = true;\n        return !found;\n      });\n      return found;\n    }\n  }, {\n    key: \"isBlock\",\n    get: function get() {\n      return this.type.isBlock;\n    }\n  }, {\n    key: \"isTextblock\",\n    get: function get() {\n      return this.type.isTextblock;\n    }\n  }, {\n    key: \"inlineContent\",\n    get: function get() {\n      return this.type.inlineContent;\n    }\n  }, {\n    key: \"isInline\",\n    get: function get() {\n      return this.type.isInline;\n    }\n  }, {\n    key: \"isText\",\n    get: function get() {\n      return this.type.isText;\n    }\n  }, {\n    key: \"isLeaf\",\n    get: function get() {\n      return this.type.isLeaf;\n    }\n  }, {\n    key: \"isAtom\",\n    get: function get() {\n      return this.type.isAtom;\n    }\n  }, {\n    key: \"toString\",\n    value: function toString() {\n      if (this.type.spec.toDebugString) return this.type.spec.toDebugString(this);\n      var name = this.type.name;\n      if (this.content.size) name += \"(\" + this.content.toStringInner() + \")\";\n      return wrapMarks(this.marks, name);\n    }\n  }, {\n    key: \"contentMatchAt\",\n    value: function contentMatchAt(index) {\n      var match = this.type.contentMatch.matchFragment(this.content, 0, index);\n      if (!match) throw new Error(\"Called contentMatchAt on a node with invalid content\");\n      return match;\n    }\n  }, {\n    key: \"canReplace\",\n    value: function canReplace(from, to) {\n      var replacement = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Fragment.empty;\n      var start = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;\n      var end = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : replacement.childCount;\n      var one = this.contentMatchAt(from).matchFragment(replacement, start, end);\n      var two = one && one.matchFragment(this.content, to);\n      if (!two || !two.validEnd) return false;\n      for (var i = start; i < end; i++) if (!this.type.allowsMarks(replacement.child(i).marks)) return false;\n      return true;\n    }\n  }, {\n    key: \"canReplaceWith\",\n    value: function canReplaceWith(from, to, type, marks) {\n      if (marks && !this.type.allowsMarks(marks)) return false;\n      var start = this.contentMatchAt(from).matchType(type);\n      var end = start && start.matchFragment(this.content, to);\n      return end ? end.validEnd : false;\n    }\n  }, {\n    key: \"canAppend\",\n    value: function canAppend(other) {\n      if (other.content.size) return this.canReplace(this.childCount, this.childCount, other.content);else return this.type.compatibleContent(other.type);\n    }\n  }, {\n    key: \"check\",\n    value: function check() {\n      this.type.checkContent(this.content);\n      checkAttrs(this.type.attrs, this.attrs, \"node\", this.type.name);\n      var copy = Mark.none;\n      for (var i = 0; i < this.marks.length; i++) {\n        var mark = this.marks[i];\n        checkAttrs(mark.type.attrs, mark.attrs, \"mark\", mark.type.name);\n        copy = mark.addToSet(copy);\n      }\n      if (!Mark.sameSet(copy, this.marks)) throw new RangeError(\"Invalid collection of marks for node \".concat(this.type.name, \": \").concat(this.marks.map(function (m) {\n        return m.type.name;\n      })));\n      this.content.forEach(function (node) {\n        return node.check();\n      });\n    }\n  }, {\n    key: \"toJSON\",\n    value: function toJSON() {\n      var obj = {\n        type: this.type.name\n      };\n      for (var _ in this.attrs) {\n        obj.attrs = this.attrs;\n        break;\n      }\n      if (this.content.size) obj.content = this.content.toJSON();\n      if (this.marks.length) obj.marks = this.marks.map(function (n) {\n        return n.toJSON();\n      });\n      return obj;\n    }\n  }], [{\n    key: \"fromJSON\",\n    value: function fromJSON(schema, json) {\n      if (!json) throw new RangeError(\"Invalid input for Node.fromJSON\");\n      var marks = undefined;\n      if (json.marks) {\n        if (!Array.isArray(json.marks)) throw new RangeError(\"Invalid mark data for Node.fromJSON\");\n        marks = json.marks.map(schema.markFromJSON);\n      }\n      if (json.type == \"text\") {\n        if (typeof json.text != \"string\") throw new RangeError(\"Invalid text node in JSON\");\n        return schema.text(json.text, marks);\n      }\n      var content = Fragment.fromJSON(schema, json.content);\n      var node = schema.nodeType(json.type).create(json.attrs, content, marks);\n      return node;\n    }\n  }]);\n  return Node;\n}();\nNode.prototype.text = undefined;\nvar TextNode = function (_Node) {\n  _inherits(TextNode, _Node);\n  var _super2 = _createSuper(TextNode);\n  function TextNode(type, attrs, content, marks) {\n    var _this;\n    _classCallCheck(this, TextNode);\n    _this = _super2.call(this, type, attrs, null, marks);\n    if (!content) throw new RangeError(\"Empty text nodes are not allowed\");\n    _this.text = content;\n    return _this;\n  }\n  _createClass(TextNode, [{\n    key: \"toString\",\n    value: function toString() {\n      if (this.type.spec.toDebugString) return this.type.spec.toDebugString(this);\n      return wrapMarks(this.marks, JSON.stringify(this.text));\n    }\n  }, {\n    key: \"textContent\",\n    get: function get() {\n      return this.text;\n    }\n  }, {\n    key: \"textBetween\",\n    value: function textBetween(from, to) {\n      return this.text.slice(from, to);\n    }\n  }, {\n    key: \"nodeSize\",\n    get: function get() {\n      return this.text.length;\n    }\n  }, {\n    key: \"mark\",\n    value: function mark(marks) {\n      return marks == this.marks ? this : new TextNode(this.type, this.attrs, this.text, marks);\n    }\n  }, {\n    key: \"withText\",\n    value: function withText(text) {\n      if (text == this.text) return this;\n      return new TextNode(this.type, this.attrs, text, this.marks);\n    }\n  }, {\n    key: \"cut\",\n    value: function cut() {\n      var from = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;\n      var to = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.text.length;\n      if (from == 0 && to == this.text.length) return this;\n      return this.withText(this.text.slice(from, to));\n    }\n  }, {\n    key: \"eq\",\n    value: function eq(other) {\n      return this.sameMarkup(other) && this.text == other.text;\n    }\n  }, {\n    key: \"toJSON\",\n    value: function toJSON() {\n      var base = _get(_getPrototypeOf(TextNode.prototype), \"toJSON\", this).call(this);\n      base.text = this.text;\n      return base;\n    }\n  }]);\n  return TextNode;\n}(Node);\nfunction wrapMarks(marks, str) {\n  for (var i = marks.length - 1; i >= 0; i--) str = marks[i].type.name + \"(\" + str + \")\";\n  return str;\n}\nfunction checkAttrs(attrs, values, type, name) {\n  for (var attr in values) if (!(attr in attrs)) throw new RangeError(\"Unsupported attribute \".concat(attr, \" for \").concat(type, \" of type \").concat(name));\n  for (var _attr in attrs) {\n    if (attrs[_attr].validate) attrs[_attr].validate(values[_attr]);\n  }\n}\nvar ContentMatch = function () {\n  function ContentMatch(validEnd) {\n    _classCallCheck(this, ContentMatch);\n    this.validEnd = validEnd;\n    this.next = [];\n    this.wrapCache = [];\n  }\n  _createClass(ContentMatch, [{\n    key: \"matchType\",\n    value: function matchType(type) {\n      for (var i = 0; i < this.next.length; i++) if (this.next[i].type == type) return this.next[i].next;\n      return null;\n    }\n  }, {\n    key: \"matchFragment\",\n    value: function matchFragment(frag) {\n      var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n      var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : frag.childCount;\n      var cur = this;\n      for (var i = start; cur && i < end; i++) cur = cur.matchType(frag.child(i).type);\n      return cur;\n    }\n  }, {\n    key: \"inlineContent\",\n    get: function get() {\n      return this.next.length != 0 && this.next[0].type.isInline;\n    }\n  }, {\n    key: \"defaultType\",\n    get: function get() {\n      for (var i = 0; i < this.next.length; i++) {\n        var type = this.next[i].type;\n        if (!(type.isText || type.hasRequiredAttrs())) return type;\n      }\n      return null;\n    }\n  }, {\n    key: \"compatible\",\n    value: function compatible(other) {\n      for (var i = 0; i < this.next.length; i++) for (var j = 0; j < other.next.length; j++) if (this.next[i].type == other.next[j].type) return true;\n      return false;\n    }\n  }, {\n    key: \"fillBefore\",\n    value: function fillBefore(after) {\n      var toEnd = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n      var startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;\n      var seen = [this];\n      function search(match, types) {\n        var finished = match.matchFragment(after, startIndex);\n        if (finished && (!toEnd || finished.validEnd)) return Fragment.from(types.map(function (tp) {\n          return tp.createAndFill();\n        }));\n        for (var i = 0; i < match.next.length; i++) {\n          var _match$next$i = match.next[i],\n            type = _match$next$i.type,\n            next = _match$next$i.next;\n          if (!(type.isText || type.hasRequiredAttrs()) && seen.indexOf(next) == -1) {\n            seen.push(next);\n            var _found = search(next, types.concat(type));\n            if (_found) return _found;\n          }\n        }\n        return null;\n      }\n      return search(this, []);\n    }\n  }, {\n    key: \"findWrapping\",\n    value: function findWrapping(target) {\n      for (var i = 0; i < this.wrapCache.length; i += 2) if (this.wrapCache[i] == target) return this.wrapCache[i + 1];\n      var computed = this.computeWrapping(target);\n      this.wrapCache.push(target, computed);\n      return computed;\n    }\n  }, {\n    key: \"computeWrapping\",\n    value: function computeWrapping(target) {\n      var seen = Object.create(null),\n        active = [{\n          match: this,\n          type: null,\n          via: null\n        }];\n      while (active.length) {\n        var current = active.shift(),\n          match = current.match;\n        if (match.matchType(target)) {\n          var result = [];\n          for (var obj = current; obj.type; obj = obj.via) result.push(obj.type);\n          return result.reverse();\n        }\n        for (var i = 0; i < match.next.length; i++) {\n          var _match$next$i2 = match.next[i],\n            type = _match$next$i2.type,\n            next = _match$next$i2.next;\n          if (!type.isLeaf && !type.hasRequiredAttrs() && !(type.name in seen) && (!current.type || next.validEnd)) {\n            active.push({\n              match: type.contentMatch,\n              type: type,\n              via: current\n            });\n            seen[type.name] = true;\n          }\n        }\n      }\n      return null;\n    }\n  }, {\n    key: \"edgeCount\",\n    get: function get() {\n      return this.next.length;\n    }\n  }, {\n    key: \"edge\",\n    value: function edge(n) {\n      if (n >= this.next.length) throw new RangeError(\"There's no \".concat(n, \"th edge in this content match\"));\n      return this.next[n];\n    }\n  }, {\n    key: \"toString\",\n    value: function toString() {\n      var seen = [];\n      function scan(m) {\n        seen.push(m);\n        for (var i = 0; i < m.next.length; i++) if (seen.indexOf(m.next[i].next) == -1) scan(m.next[i].next);\n      }\n      scan(this);\n      return seen.map(function (m, i) {\n        var out = i + (m.validEnd ? \"*\" : \" \") + \" \";\n        for (var _i = 0; _i < m.next.length; _i++) out += (_i ? \", \" : \"\") + m.next[_i].type.name + \"->\" + seen.indexOf(m.next[_i].next);\n        return out;\n      }).join(\"\\n\");\n    }\n  }], [{\n    key: \"parse\",\n    value: function parse(string, nodeTypes) {\n      var stream = new TokenStream(string, nodeTypes);\n      if (stream.next == null) return ContentMatch.empty;\n      var expr = parseExpr(stream);\n      if (stream.next) stream.err(\"Unexpected trailing text\");\n      var match = dfa(nfa(expr));\n      checkForDeadEnds(match, stream);\n      return match;\n    }\n  }]);\n  return ContentMatch;\n}();\nContentMatch.empty = new ContentMatch(true);\nvar TokenStream = function () {\n  function TokenStream(string, nodeTypes) {\n    _classCallCheck(this, TokenStream);\n    this.string = string;\n    this.nodeTypes = nodeTypes;\n    this.inline = null;\n    this.pos = 0;\n    this.tokens = string.split(/\\s*(?=\\b|\\W|$)/);\n    if (this.tokens[this.tokens.length - 1] == \"\") this.tokens.pop();\n    if (this.tokens[0] == \"\") this.tokens.shift();\n  }\n  _createClass(TokenStream, [{\n    key: \"next\",\n    get: function get() {\n      return this.tokens[this.pos];\n    }\n  }, {\n    key: \"eat\",\n    value: function eat(tok) {\n      return this.next == tok && (this.pos++ || true);\n    }\n  }, {\n    key: \"err\",\n    value: function err(str) {\n      throw new SyntaxError(str + \" (in content expression '\" + this.string + \"')\");\n    }\n  }]);\n  return TokenStream;\n}();\nfunction parseExpr(stream) {\n  var exprs = [];\n  do {\n    exprs.push(parseExprSeq(stream));\n  } while (stream.eat(\"|\"));\n  return exprs.length == 1 ? exprs[0] : {\n    type: \"choice\",\n    exprs: exprs\n  };\n}\nfunction parseExprSeq(stream) {\n  var exprs = [];\n  do {\n    exprs.push(parseExprSubscript(stream));\n  } while (stream.next && stream.next != \")\" && stream.next != \"|\");\n  return exprs.length == 1 ? exprs[0] : {\n    type: \"seq\",\n    exprs: exprs\n  };\n}\nfunction parseExprSubscript(stream) {\n  var expr = parseExprAtom(stream);\n  for (;;) {\n    if (stream.eat(\"+\")) expr = {\n      type: \"plus\",\n      expr: expr\n    };else if (stream.eat(\"*\")) expr = {\n      type: \"star\",\n      expr: expr\n    };else if (stream.eat(\"?\")) expr = {\n      type: \"opt\",\n      expr: expr\n    };else if (stream.eat(\"{\")) expr = parseExprRange(stream, expr);else break;\n  }\n  return expr;\n}\nfunction parseNum(stream) {\n  if (/\\D/.test(stream.next)) stream.err(\"Expected number, got '\" + stream.next + \"'\");\n  var result = Number(stream.next);\n  stream.pos++;\n  return result;\n}\nfunction parseExprRange(stream, expr) {\n  var min = parseNum(stream),\n    max = min;\n  if (stream.eat(\",\")) {\n    if (stream.next != \"}\") max = parseNum(stream);else max = -1;\n  }\n  if (!stream.eat(\"}\")) stream.err(\"Unclosed braced range\");\n  return {\n    type: \"range\",\n    min: min,\n    max: max,\n    expr: expr\n  };\n}\nfunction resolveName(stream, name) {\n  var types = stream.nodeTypes,\n    type = types[name];\n  if (type) return [type];\n  var result = [];\n  for (var typeName in types) {\n    var _type = types[typeName];\n    if (_type.isInGroup(name)) result.push(_type);\n  }\n  if (result.length == 0) stream.err(\"No node type or group '\" + name + \"' found\");\n  return result;\n}\nfunction parseExprAtom(stream) {\n  if (stream.eat(\"(\")) {\n    var expr = parseExpr(stream);\n    if (!stream.eat(\")\")) stream.err(\"Missing closing paren\");\n    return expr;\n  } else if (!/\\W/.test(stream.next)) {\n    var exprs = resolveName(stream, stream.next).map(function (type) {\n      if (stream.inline == null) stream.inline = type.isInline;else if (stream.inline != type.isInline) stream.err(\"Mixing inline and block content\");\n      return {\n        type: \"name\",\n        value: type\n      };\n    });\n    stream.pos++;\n    return exprs.length == 1 ? exprs[0] : {\n      type: \"choice\",\n      exprs: exprs\n    };\n  } else {\n    stream.err(\"Unexpected token '\" + stream.next + \"'\");\n  }\n}\nfunction nfa(expr) {\n  var nfa = [[]];\n  connect(compile(expr, 0), node());\n  return nfa;\n  function node() {\n    return nfa.push([]) - 1;\n  }\n  function edge(from, to, term) {\n    var edge = {\n      term: term,\n      to: to\n    };\n    nfa[from].push(edge);\n    return edge;\n  }\n  function connect(edges, to) {\n    edges.forEach(function (edge) {\n      return edge.to = to;\n    });\n  }\n  function compile(expr, from) {\n    if (expr.type == \"choice\") {\n      return expr.exprs.reduce(function (out, expr) {\n        return out.concat(compile(expr, from));\n      }, []);\n    } else if (expr.type == \"seq\") {\n      for (var i = 0;; i++) {\n        var next = compile(expr.exprs[i], from);\n        if (i == expr.exprs.length - 1) return next;\n        connect(next, from = node());\n      }\n    } else if (expr.type == \"star\") {\n      var loop = node();\n      edge(from, loop);\n      connect(compile(expr.expr, loop), loop);\n      return [edge(loop)];\n    } else if (expr.type == \"plus\") {\n      var _loop = node();\n      connect(compile(expr.expr, from), _loop);\n      connect(compile(expr.expr, _loop), _loop);\n      return [edge(_loop)];\n    } else if (expr.type == \"opt\") {\n      return [edge(from)].concat(compile(expr.expr, from));\n    } else if (expr.type == \"range\") {\n      var cur = from;\n      for (var _i2 = 0; _i2 < expr.min; _i2++) {\n        var _next = node();\n        connect(compile(expr.expr, cur), _next);\n        cur = _next;\n      }\n      if (expr.max == -1) {\n        connect(compile(expr.expr, cur), cur);\n      } else {\n        for (var _i3 = expr.min; _i3 < expr.max; _i3++) {\n          var _next2 = node();\n          edge(cur, _next2);\n          connect(compile(expr.expr, cur), _next2);\n          cur = _next2;\n        }\n      }\n      return [edge(cur)];\n    } else if (expr.type == \"name\") {\n      return [edge(from, undefined, expr.value)];\n    } else {\n      throw new Error(\"Unknown expr type\");\n    }\n  }\n}\nfunction cmp(a, b) {\n  return b - a;\n}\nfunction nullFrom(nfa, node) {\n  var result = [];\n  scan(node);\n  return result.sort(cmp);\n  function scan(node) {\n    var edges = nfa[node];\n    if (edges.length == 1 && !edges[0].term) return scan(edges[0].to);\n    result.push(node);\n    for (var i = 0; i < edges.length; i++) {\n      var _edges$i = edges[i],\n        term = _edges$i.term,\n        to = _edges$i.to;\n      if (!term && result.indexOf(to) == -1) scan(to);\n    }\n  }\n}\nfunction dfa(nfa) {\n  var labeled = Object.create(null);\n  return explore(nullFrom(nfa, 0));\n  function explore(states) {\n    var out = [];\n    states.forEach(function (node) {\n      nfa[node].forEach(function (_ref) {\n        var term = _ref.term,\n          to = _ref.to;\n        if (!term) return;\n        var set;\n        for (var i = 0; i < out.length; i++) if (out[i][0] == term) set = out[i][1];\n        nullFrom(nfa, to).forEach(function (node) {\n          if (!set) out.push([term, set = []]);\n          if (set.indexOf(node) == -1) set.push(node);\n        });\n      });\n    });\n    var state = labeled[states.join(\",\")] = new ContentMatch(states.indexOf(nfa.length - 1) > -1);\n    for (var i = 0; i < out.length; i++) {\n      var _states = out[i][1].sort(cmp);\n      state.next.push({\n        type: out[i][0],\n        next: labeled[_states.join(\",\")] || explore(_states)\n      });\n    }\n    return state;\n  }\n}\nfunction checkForDeadEnds(match, stream) {\n  for (var i = 0, work = [match]; i < work.length; i++) {\n    var state = work[i],\n      dead = !state.validEnd,\n      nodes = [];\n    for (var j = 0; j < state.next.length; j++) {\n      var _state$next$j = state.next[j],\n        type = _state$next$j.type,\n        next = _state$next$j.next;\n      nodes.push(type.name);\n      if (dead && !(type.isText || type.hasRequiredAttrs())) dead = false;\n      if (work.indexOf(next) == -1) work.push(next);\n    }\n    if (dead) stream.err(\"Only non-generatable nodes (\" + nodes.join(\", \") + \") in a required position (see https://prosemirror.net/docs/guide/#generatable)\");\n  }\n}\nfunction defaultAttrs(attrs) {\n  var defaults = Object.create(null);\n  for (var attrName in attrs) {\n    var attr = attrs[attrName];\n    if (!attr.hasDefault) return null;\n    defaults[attrName] = attr[\"default\"];\n  }\n  return defaults;\n}\nfunction _computeAttrs(attrs, value) {\n  var built = Object.create(null);\n  for (var name in attrs) {\n    var attr = attrs[name];\n    var given = value && value[name];\n    if (given === undefined) {\n      if (attr.hasDefault) given = attr[\"default\"];else throw new RangeError(\"No value supplied for attribute \" + name);\n    } else if (attr.validate) {\n      attr.validate(given);\n    }\n    built[name] = given;\n  }\n  return built;\n}\nfunction initAttrs(typeName, attrs) {\n  var result = Object.create(null);\n  if (attrs) for (var name in attrs) result[name] = new Attribute(typeName, name, attrs[name]);\n  return result;\n}\nvar NodeType = function () {\n  function NodeType(name, schema, spec) {\n    _classCallCheck(this, NodeType);\n    this.name = name;\n    this.schema = schema;\n    this.spec = spec;\n    this.markSet = null;\n    this.groups = spec.group ? spec.group.split(\" \") : [];\n    this.attrs = initAttrs(name, spec.attrs);\n    this.defaultAttrs = defaultAttrs(this.attrs);\n    this.contentMatch = null;\n    this.inlineContent = null;\n    this.isBlock = !(spec.inline || name == \"text\");\n    this.isText = name == \"text\";\n  }\n  _createClass(NodeType, [{\n    key: \"isInline\",\n    get: function get() {\n      return !this.isBlock;\n    }\n  }, {\n    key: \"isTextblock\",\n    get: function get() {\n      return this.isBlock && this.inlineContent;\n    }\n  }, {\n    key: \"isLeaf\",\n    get: function get() {\n      return this.contentMatch == ContentMatch.empty;\n    }\n  }, {\n    key: \"isAtom\",\n    get: function get() {\n      return this.isLeaf || !!this.spec.atom;\n    }\n  }, {\n    key: \"isInGroup\",\n    value: function isInGroup(group) {\n      return this.groups.indexOf(group) > -1;\n    }\n  }, {\n    key: \"whitespace\",\n    get: function get() {\n      return this.spec.whitespace || (this.spec.code ? \"pre\" : \"normal\");\n    }\n  }, {\n    key: \"hasRequiredAttrs\",\n    value: function hasRequiredAttrs() {\n      for (var n in this.attrs) if (this.attrs[n].isRequired) return true;\n      return false;\n    }\n  }, {\n    key: \"compatibleContent\",\n    value: function compatibleContent(other) {\n      return this == other || this.contentMatch.compatible(other.contentMatch);\n    }\n  }, {\n    key: \"computeAttrs\",\n    value: function computeAttrs(attrs) {\n      if (!attrs && this.defaultAttrs) return this.defaultAttrs;else return _computeAttrs(this.attrs, attrs);\n    }\n  }, {\n    key: \"create\",\n    value: function create() {\n      var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n      var content = arguments.length > 1 ? arguments[1] : undefined;\n      var marks = arguments.length > 2 ? arguments[2] : undefined;\n      if (this.isText) throw new Error(\"NodeType.create can't construct text nodes\");\n      return new Node(this, this.computeAttrs(attrs), Fragment.from(content), Mark.setFrom(marks));\n    }\n  }, {\n    key: \"createChecked\",\n    value: function createChecked() {\n      var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n      var content = arguments.length > 1 ? arguments[1] : undefined;\n      var marks = arguments.length > 2 ? arguments[2] : undefined;\n      content = Fragment.from(content);\n      this.checkContent(content);\n      return new Node(this, this.computeAttrs(attrs), content, Mark.setFrom(marks));\n    }\n  }, {\n    key: \"createAndFill\",\n    value: function createAndFill() {\n      var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n      var content = arguments.length > 1 ? arguments[1] : undefined;\n      var marks = arguments.length > 2 ? arguments[2] : undefined;\n      attrs = this.computeAttrs(attrs);\n      content = Fragment.from(content);\n      if (content.size) {\n        var before = this.contentMatch.fillBefore(content);\n        if (!before) return null;\n        content = before.append(content);\n      }\n      var matched = this.contentMatch.matchFragment(content);\n      var after = matched && matched.fillBefore(Fragment.empty, true);\n      if (!after) return null;\n      return new Node(this, attrs, content.append(after), Mark.setFrom(marks));\n    }\n  }, {\n    key: \"validContent\",\n    value: function validContent(content) {\n      var result = this.contentMatch.matchFragment(content);\n      if (!result || !result.validEnd) return false;\n      for (var i = 0; i < content.childCount; i++) if (!this.allowsMarks(content.child(i).marks)) return false;\n      return true;\n    }\n  }, {\n    key: \"checkContent\",\n    value: function checkContent(content) {\n      if (!this.validContent(content)) throw new RangeError(\"Invalid content for node \".concat(this.name, \": \").concat(content.toString().slice(0, 50)));\n    }\n  }, {\n    key: \"checkAttrs\",\n    value: function checkAttrs(attrs) {}\n  }, {\n    key: \"allowsMarkType\",\n    value: function allowsMarkType(markType) {\n      return this.markSet == null || this.markSet.indexOf(markType) > -1;\n    }\n  }, {\n    key: \"allowsMarks\",\n    value: function allowsMarks(marks) {\n      if (this.markSet == null) return true;\n      for (var i = 0; i < marks.length; i++) if (!this.allowsMarkType(marks[i].type)) return false;\n      return true;\n    }\n  }, {\n    key: \"allowedMarks\",\n    value: function allowedMarks(marks) {\n      if (this.markSet == null) return marks;\n      var copy;\n      for (var i = 0; i < marks.length; i++) {\n        if (!this.allowsMarkType(marks[i].type)) {\n          if (!copy) copy = marks.slice(0, i);\n        } else if (copy) {\n          copy.push(marks[i]);\n        }\n      }\n      return !copy ? marks : copy.length ? copy : Mark.none;\n    }\n  }], [{\n    key: \"compile\",\n    value: function compile(nodes, schema) {\n      var result = Object.create(null);\n      nodes.forEach(function (name, spec) {\n        return result[name] = new NodeType(name, schema, spec);\n      });\n      var topType = schema.spec.topNode || \"doc\";\n      if (!result[topType]) throw new RangeError(\"Schema is missing its top node type ('\" + topType + \"')\");\n      if (!result.text) throw new RangeError(\"Every schema needs a 'text' type\");\n      for (var _ in result.text.attrs) throw new RangeError(\"The text node type should not have attributes\");\n      return result;\n    }\n  }]);\n  return NodeType;\n}();\nfunction validateType(typeName, attrName, type) {\n  var types = type.split(\"|\");\n  return function (value) {\n    var name = value === null ? \"null\" : _typeof(value);\n    if (types.indexOf(name) < 0) throw new RangeError(\"Expected value of type \".concat(types, \" for attribute \").concat(attrName, \" on type \").concat(typeName, \", got \").concat(name));\n  };\n}\nvar Attribute = function () {\n  function Attribute(typeName, attrName, options) {\n    _classCallCheck(this, Attribute);\n    this.hasDefault = Object.prototype.hasOwnProperty.call(options, \"default\");\n    this[\"default\"] = options[\"default\"];\n    this.validate = typeof options.validate == \"string\" ? validateType(typeName, attrName, options.validate) : options.validate;\n  }\n  _createClass(Attribute, [{\n    key: \"isRequired\",\n    get: function get() {\n      return !this.hasDefault;\n    }\n  }]);\n  return Attribute;\n}();\nvar MarkType = function () {\n  function MarkType(name, rank, schema, spec) {\n    _classCallCheck(this, MarkType);\n    this.name = name;\n    this.rank = rank;\n    this.schema = schema;\n    this.spec = spec;\n    this.attrs = initAttrs(name, spec.attrs);\n    this.excluded = null;\n    var defaults = defaultAttrs(this.attrs);\n    this.instance = defaults ? new Mark(this, defaults) : null;\n  }\n  _createClass(MarkType, [{\n    key: \"create\",\n    value: function create() {\n      var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n      if (!attrs && this.instance) return this.instance;\n      return new Mark(this, _computeAttrs(this.attrs, attrs));\n    }\n  }, {\n    key: \"removeFromSet\",\n    value: function removeFromSet(set) {\n      for (var i = 0; i < set.length; i++) if (set[i].type == this) {\n        set = set.slice(0, i).concat(set.slice(i + 1));\n        i--;\n      }\n      return set;\n    }\n  }, {\n    key: \"isInSet\",\n    value: function isInSet(set) {\n      for (var i = 0; i < set.length; i++) if (set[i].type == this) return set[i];\n    }\n  }, {\n    key: \"excludes\",\n    value: function excludes(other) {\n      return this.excluded.indexOf(other) > -1;\n    }\n  }], [{\n    key: \"compile\",\n    value: function compile(marks, schema) {\n      var result = Object.create(null),\n        rank = 0;\n      marks.forEach(function (name, spec) {\n        return result[name] = new MarkType(name, rank++, schema, spec);\n      });\n      return result;\n    }\n  }]);\n  return MarkType;\n}();\nvar Schema = function () {\n  function Schema(spec) {\n    var _this2 = this;\n    _classCallCheck(this, Schema);\n    this.linebreakReplacement = null;\n    this.cached = Object.create(null);\n    var instanceSpec = this.spec = {};\n    for (var prop in spec) instanceSpec[prop] = spec[prop];\n    instanceSpec.nodes = OrderedMap.from(spec.nodes), instanceSpec.marks = OrderedMap.from(spec.marks || {}), this.nodes = NodeType.compile(this.spec.nodes, this);\n    this.marks = MarkType.compile(this.spec.marks, this);\n    var contentExprCache = Object.create(null);\n    for (var _prop in this.nodes) {\n      if (_prop in this.marks) throw new RangeError(_prop + \" can not be both a node and a mark\");\n      var type = this.nodes[_prop],\n        contentExpr = type.spec.content || \"\",\n        markExpr = type.spec.marks;\n      type.contentMatch = contentExprCache[contentExpr] || (contentExprCache[contentExpr] = ContentMatch.parse(contentExpr, this.nodes));\n      type.inlineContent = type.contentMatch.inlineContent;\n      if (type.spec.linebreakReplacement) {\n        if (this.linebreakReplacement) throw new RangeError(\"Multiple linebreak nodes defined\");\n        if (!type.isInline || !type.isLeaf) throw new RangeError(\"Linebreak replacement nodes must be inline leaf nodes\");\n        this.linebreakReplacement = type;\n      }\n      type.markSet = markExpr == \"_\" ? null : markExpr ? gatherMarks(this, markExpr.split(\" \")) : markExpr == \"\" || !type.inlineContent ? [] : null;\n    }\n    for (var _prop2 in this.marks) {\n      var _type2 = this.marks[_prop2],\n        excl = _type2.spec.excludes;\n      _type2.excluded = excl == null ? [_type2] : excl == \"\" ? [] : gatherMarks(this, excl.split(\" \"));\n    }\n    this.nodeFromJSON = function (json) {\n      return Node.fromJSON(_this2, json);\n    };\n    this.markFromJSON = function (json) {\n      return Mark.fromJSON(_this2, json);\n    };\n    this.topNodeType = this.nodes[this.spec.topNode || \"doc\"];\n    this.cached.wrappings = Object.create(null);\n  }\n  _createClass(Schema, [{\n    key: \"node\",\n    value: function node(type) {\n      var attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n      var content = arguments.length > 2 ? arguments[2] : undefined;\n      var marks = arguments.length > 3 ? arguments[3] : undefined;\n      if (typeof type == \"string\") type = this.nodeType(type);else if (!(type instanceof NodeType)) throw new RangeError(\"Invalid node type: \" + type);else if (type.schema != this) throw new RangeError(\"Node type from different schema used (\" + type.name + \")\");\n      return type.createChecked(attrs, content, marks);\n    }\n  }, {\n    key: \"text\",\n    value: function text(_text, marks) {\n      var type = this.nodes.text;\n      return new TextNode(type, type.defaultAttrs, _text, Mark.setFrom(marks));\n    }\n  }, {\n    key: \"mark\",\n    value: function mark(type, attrs) {\n      if (typeof type == \"string\") type = this.marks[type];\n      return type.create(attrs);\n    }\n  }, {\n    key: \"nodeType\",\n    value: function nodeType(name) {\n      var found = this.nodes[name];\n      if (!found) throw new RangeError(\"Unknown node type: \" + name);\n      return found;\n    }\n  }]);\n  return Schema;\n}();\nfunction gatherMarks(schema, marks) {\n  var found = [];\n  for (var i = 0; i < marks.length; i++) {\n    var name = marks[i],\n      mark = schema.marks[name],\n      ok = mark;\n    if (mark) {\n      found.push(mark);\n    } else {\n      for (var prop in schema.marks) {\n        var _mark = schema.marks[prop];\n        if (name == \"_\" || _mark.spec.group && _mark.spec.group.split(\" \").indexOf(name) > -1) found.push(ok = _mark);\n      }\n    }\n    if (!ok) throw new SyntaxError(\"Unknown mark type: '\" + marks[i] + \"'\");\n  }\n  return found;\n}\nfunction isTagRule(rule) {\n  return rule.tag != null;\n}\nfunction isStyleRule(rule) {\n  return rule.style != null;\n}\nvar DOMParser = function () {\n  function DOMParser(schema, rules) {\n    var _this3 = this;\n    _classCallCheck(this, DOMParser);\n    this.schema = schema;\n    this.rules = rules;\n    this.tags = [];\n    this.styles = [];\n    var matchedStyles = this.matchedStyles = [];\n    rules.forEach(function (rule) {\n      if (isTagRule(rule)) {\n        _this3.tags.push(rule);\n      } else if (isStyleRule(rule)) {\n        var prop = /[^=]*/.exec(rule.style)[0];\n        if (matchedStyles.indexOf(prop) < 0) matchedStyles.push(prop);\n        _this3.styles.push(rule);\n      }\n    });\n    this.normalizeLists = !this.tags.some(function (r) {\n      if (!/^(ul|ol)\\b/.test(r.tag) || !r.node) return false;\n      var node = schema.nodes[r.node];\n      return node.contentMatch.matchType(node);\n    });\n  }\n  _createClass(DOMParser, [{\n    key: \"parse\",\n    value: function parse(dom) {\n      var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n      var context = new ParseContext(this, options, false);\n      context.addAll(dom, Mark.none, options.from, options.to);\n      return context.finish();\n    }\n  }, {\n    key: \"parseSlice\",\n    value: function parseSlice(dom) {\n      var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n      var context = new ParseContext(this, options, true);\n      context.addAll(dom, Mark.none, options.from, options.to);\n      return Slice.maxOpen(context.finish());\n    }\n  }, {\n    key: \"matchTag\",\n    value: function matchTag(dom, context, after) {\n      for (var i = after ? this.tags.indexOf(after) + 1 : 0; i < this.tags.length; i++) {\n        var rule = this.tags[i];\n        if (matches(dom, rule.tag) && (rule.namespace === undefined || dom.namespaceURI == rule.namespace) && (!rule.context || context.matchesContext(rule.context))) {\n          if (rule.getAttrs) {\n            var result = rule.getAttrs(dom);\n            if (result === false) continue;\n            rule.attrs = result || undefined;\n          }\n          return rule;\n        }\n      }\n    }\n  }, {\n    key: \"matchStyle\",\n    value: function matchStyle(prop, value, context, after) {\n      for (var i = after ? this.styles.indexOf(after) + 1 : 0; i < this.styles.length; i++) {\n        var rule = this.styles[i],\n          style = rule.style;\n        if (style.indexOf(prop) != 0 || rule.context && !context.matchesContext(rule.context) || style.length > prop.length && (style.charCodeAt(prop.length) != 61 || style.slice(prop.length + 1) != value)) continue;\n        if (rule.getAttrs) {\n          var result = rule.getAttrs(value);\n          if (result === false) continue;\n          rule.attrs = result || undefined;\n        }\n        return rule;\n      }\n    }\n  }], [{\n    key: \"schemaRules\",\n    value: function schemaRules(schema) {\n      var result = [];\n      function insert(rule) {\n        var priority = rule.priority == null ? 50 : rule.priority,\n          i = 0;\n        for (; i < result.length; i++) {\n          var next = result[i],\n            nextPriority = next.priority == null ? 50 : next.priority;\n          if (nextPriority < priority) break;\n        }\n        result.splice(i, 0, rule);\n      }\n      var _loop2 = function _loop2(name) {\n        var rules = schema.marks[name].spec.parseDOM;\n        if (rules) rules.forEach(function (rule) {\n          insert(rule = copy(rule));\n          if (!(rule.mark || rule.ignore || rule.clearMark)) rule.mark = name;\n        });\n      };\n      for (var name in schema.marks) {\n        _loop2(name);\n      }\n      var _loop3 = function _loop3(_name) {\n        var rules = schema.nodes[_name].spec.parseDOM;\n        if (rules) rules.forEach(function (rule) {\n          insert(rule = copy(rule));\n          if (!(rule.node || rule.ignore || rule.mark)) rule.node = _name;\n        });\n      };\n      for (var _name in schema.nodes) {\n        _loop3(_name);\n      }\n      return result;\n    }\n  }, {\n    key: \"fromSchema\",\n    value: function fromSchema(schema) {\n      return schema.cached.domParser || (schema.cached.domParser = new DOMParser(schema, DOMParser.schemaRules(schema)));\n    }\n  }]);\n  return DOMParser;\n}();\nvar blockTags = {\n  address: true,\n  article: true,\n  aside: true,\n  blockquote: true,\n  body: true,\n  canvas: true,\n  dd: true,\n  div: true,\n  dl: true,\n  fieldset: true,\n  figcaption: true,\n  figure: true,\n  footer: true,\n  form: true,\n  h1: true,\n  h2: true,\n  h3: true,\n  h4: true,\n  h5: true,\n  h6: true,\n  header: true,\n  hgroup: true,\n  hr: true,\n  li: true,\n  noscript: true,\n  ol: true,\n  output: true,\n  p: true,\n  pre: true,\n  section: true,\n  table: true,\n  tfoot: true,\n  ul: true\n};\nvar ignoreTags = {\n  head: true,\n  noscript: true,\n  object: true,\n  script: true,\n  style: true,\n  title: true\n};\nvar listTags = {\n  ol: true,\n  ul: true\n};\nvar OPT_PRESERVE_WS = 1,\n  OPT_PRESERVE_WS_FULL = 2,\n  OPT_OPEN_LEFT = 4;\nfunction wsOptionsFor(type, preserveWhitespace, base) {\n  if (preserveWhitespace != null) return (preserveWhitespace ? OPT_PRESERVE_WS : 0) | (preserveWhitespace === \"full\" ? OPT_PRESERVE_WS_FULL : 0);\n  return type && type.whitespace == \"pre\" ? OPT_PRESERVE_WS | OPT_PRESERVE_WS_FULL : base & ~OPT_OPEN_LEFT;\n}\nvar NodeContext = function () {\n  function NodeContext(type, attrs, marks, solid, match, options) {\n    _classCallCheck(this, NodeContext);\n    this.type = type;\n    this.attrs = attrs;\n    this.marks = marks;\n    this.solid = solid;\n    this.options = options;\n    this.content = [];\n    this.activeMarks = Mark.none;\n    this.match = match || (options & OPT_OPEN_LEFT ? null : type.contentMatch);\n  }\n  _createClass(NodeContext, [{\n    key: \"findWrapping\",\n    value: function findWrapping(node) {\n      if (!this.match) {\n        if (!this.type) return [];\n        var fill = this.type.contentMatch.fillBefore(Fragment.from(node));\n        if (fill) {\n          this.match = this.type.contentMatch.matchFragment(fill);\n        } else {\n          var start = this.type.contentMatch,\n            wrap;\n          if (wrap = start.findWrapping(node.type)) {\n            this.match = start;\n            return wrap;\n          } else {\n            return null;\n          }\n        }\n      }\n      return this.match.findWrapping(node.type);\n    }\n  }, {\n    key: \"finish\",\n    value: function finish(openEnd) {\n      if (!(this.options & OPT_PRESERVE_WS)) {\n        var last = this.content[this.content.length - 1],\n          m;\n        if (last && last.isText && (m = /[ \\t\\r\\n\\u000c]+$/.exec(last.text))) {\n          var text = last;\n          if (last.text.length == m[0].length) this.content.pop();else this.content[this.content.length - 1] = text.withText(text.text.slice(0, text.text.length - m[0].length));\n        }\n      }\n      var content = Fragment.from(this.content);\n      if (!openEnd && this.match) content = content.append(this.match.fillBefore(Fragment.empty, true));\n      return this.type ? this.type.create(this.attrs, content, this.marks) : content;\n    }\n  }, {\n    key: \"inlineContext\",\n    value: function inlineContext(node) {\n      if (this.type) return this.type.inlineContent;\n      if (this.content.length) return this.content[0].isInline;\n      return node.parentNode && !blockTags.hasOwnProperty(node.parentNode.nodeName.toLowerCase());\n    }\n  }]);\n  return NodeContext;\n}();\nvar ParseContext = function () {\n  function ParseContext(parser, options, isOpen) {\n    _classCallCheck(this, ParseContext);\n    this.parser = parser;\n    this.options = options;\n    this.isOpen = isOpen;\n    this.open = 0;\n    this.localPreserveWS = false;\n    var topNode = options.topNode,\n      topContext;\n    var topOptions = wsOptionsFor(null, options.preserveWhitespace, 0) | (isOpen ? OPT_OPEN_LEFT : 0);\n    if (topNode) topContext = new NodeContext(topNode.type, topNode.attrs, Mark.none, true, options.topMatch || topNode.type.contentMatch, topOptions);else if (isOpen) topContext = new NodeContext(null, null, Mark.none, true, null, topOptions);else topContext = new NodeContext(parser.schema.topNodeType, null, Mark.none, true, null, topOptions);\n    this.nodes = [topContext];\n    this.find = options.findPositions;\n    this.needsBlock = false;\n  }\n  _createClass(ParseContext, [{\n    key: \"top\",\n    get: function get() {\n      return this.nodes[this.open];\n    }\n  }, {\n    key: \"addDOM\",\n    value: function addDOM(dom, marks) {\n      if (dom.nodeType == 3) this.addTextNode(dom, marks);else if (dom.nodeType == 1) this.addElement(dom, marks);\n    }\n  }, {\n    key: \"addTextNode\",\n    value: function addTextNode(dom, marks) {\n      var value = dom.nodeValue;\n      var top = this.top,\n        preserveWS = top.options & OPT_PRESERVE_WS_FULL ? \"full\" : this.localPreserveWS || (top.options & OPT_PRESERVE_WS) > 0;\n      var schema = this.parser.schema;\n      if (preserveWS === \"full\" || top.inlineContext(dom) || /[^ \\t\\r\\n\\u000c]/.test(value)) {\n        if (!preserveWS) {\n          value = value.replace(/[ \\t\\r\\n\\u000c]+/g, \" \");\n          if (/^[ \\t\\r\\n\\u000c]/.test(value) && this.open == this.nodes.length - 1) {\n            var nodeBefore = top.content[top.content.length - 1];\n            var domNodeBefore = dom.previousSibling;\n            if (!nodeBefore || domNodeBefore && domNodeBefore.nodeName == 'BR' || nodeBefore.isText && /[ \\t\\r\\n\\u000c]$/.test(nodeBefore.text)) value = value.slice(1);\n          }\n        } else if (preserveWS === \"full\") {\n          value = value.replace(/\\r\\n?/g, \"\\n\");\n        } else if (schema.linebreakReplacement && /[\\r\\n]/.test(value) && this.top.findWrapping(schema.linebreakReplacement.create())) {\n          var lines = value.split(/\\r?\\n|\\r/);\n          for (var i = 0; i < lines.length; i++) {\n            if (i) this.insertNode(schema.linebreakReplacement.create(), marks, true);\n            if (lines[i]) this.insertNode(schema.text(lines[i]), marks, !/\\S/.test(lines[i]));\n          }\n          value = \"\";\n        } else {\n          value = value.replace(/\\r?\\n|\\r/g, \" \");\n        }\n        if (value) this.insertNode(schema.text(value), marks, !/\\S/.test(value));\n        this.findInText(dom);\n      } else {\n        this.findInside(dom);\n      }\n    }\n  }, {\n    key: \"addElement\",\n    value: function addElement(dom, marks, matchAfter) {\n      var outerWS = this.localPreserveWS,\n        top = this.top;\n      if (dom.tagName == \"PRE\" || /pre/.test(dom.style && dom.style.whiteSpace)) this.localPreserveWS = true;\n      var name = dom.nodeName.toLowerCase(),\n        ruleID;\n      if (listTags.hasOwnProperty(name) && this.parser.normalizeLists) normalizeList(dom);\n      var rule = this.options.ruleFromNode && this.options.ruleFromNode(dom) || (ruleID = this.parser.matchTag(dom, this, matchAfter));\n      out: if (rule ? rule.ignore : ignoreTags.hasOwnProperty(name)) {\n        this.findInside(dom);\n        this.ignoreFallback(dom, marks);\n      } else if (!rule || rule.skip || rule.closeParent) {\n        if (rule && rule.closeParent) this.open = Math.max(0, this.open - 1);else if (rule && rule.skip.nodeType) dom = rule.skip;\n        var sync,\n          oldNeedsBlock = this.needsBlock;\n        if (blockTags.hasOwnProperty(name)) {\n          if (top.content.length && top.content[0].isInline && this.open) {\n            this.open--;\n            top = this.top;\n          }\n          sync = true;\n          if (!top.type) this.needsBlock = true;\n        } else if (!dom.firstChild) {\n          this.leafFallback(dom, marks);\n          break out;\n        }\n        var innerMarks = rule && rule.skip ? marks : this.readStyles(dom, marks);\n        if (innerMarks) this.addAll(dom, innerMarks);\n        if (sync) this.sync(top);\n        this.needsBlock = oldNeedsBlock;\n      } else {\n        var _innerMarks = this.readStyles(dom, marks);\n        if (_innerMarks) this.addElementByRule(dom, rule, _innerMarks, rule.consuming === false ? ruleID : undefined);\n      }\n      this.localPreserveWS = outerWS;\n    }\n  }, {\n    key: \"leafFallback\",\n    value: function leafFallback(dom, marks) {\n      if (dom.nodeName == \"BR\" && this.top.type && this.top.type.inlineContent) this.addTextNode(dom.ownerDocument.createTextNode(\"\\n\"), marks);\n    }\n  }, {\n    key: \"ignoreFallback\",\n    value: function ignoreFallback(dom, marks) {\n      if (dom.nodeName == \"BR\" && (!this.top.type || !this.top.type.inlineContent)) this.findPlace(this.parser.schema.text(\"-\"), marks, true);\n    }\n  }, {\n    key: \"readStyles\",\n    value: function readStyles(dom, marks) {\n      var _this4 = this;\n      var styles = dom.style;\n      if (styles && styles.length) for (var i = 0; i < this.parser.matchedStyles.length; i++) {\n        var name = this.parser.matchedStyles[i],\n          value = styles.getPropertyValue(name);\n        if (value) {\n          var _loop4 = function _loop4(_after) {\n              var rule = _this4.parser.matchStyle(name, value, _this4, _after);\n              if (!rule) {\n                after = _after;\n                return 0;\n              }\n              if (rule.ignore) return {\n                v: null\n              };\n              if (rule.clearMark) marks = marks.filter(function (m) {\n                return !rule.clearMark(m);\n              });else marks = marks.concat(_this4.parser.schema.marks[rule.mark].create(rule.attrs));\n              if (rule.consuming === false) _after = rule;else {\n                after = _after;\n                return 0;\n              }\n              after = _after;\n            },\n            _ret;\n          for (var after = undefined;;) {\n            _ret = _loop4(after);\n            if (_ret === 0) break;\n            if (_ret) return _ret.v;\n          }\n        }\n      }\n      return marks;\n    }\n  }, {\n    key: \"addElementByRule\",\n    value: function addElementByRule(dom, rule, marks, continueAfter) {\n      var _this5 = this;\n      var sync, nodeType;\n      if (rule.node) {\n        nodeType = this.parser.schema.nodes[rule.node];\n        if (!nodeType.isLeaf) {\n          var inner = this.enter(nodeType, rule.attrs || null, marks, rule.preserveWhitespace);\n          if (inner) {\n            sync = true;\n            marks = inner;\n          }\n        } else if (!this.insertNode(nodeType.create(rule.attrs), marks, dom.nodeName == \"BR\")) {\n          this.leafFallback(dom, marks);\n        }\n      } else {\n        var markType = this.parser.schema.marks[rule.mark];\n        marks = marks.concat(markType.create(rule.attrs));\n      }\n      var startIn = this.top;\n      if (nodeType && nodeType.isLeaf) {\n        this.findInside(dom);\n      } else if (continueAfter) {\n        this.addElement(dom, marks, continueAfter);\n      } else if (rule.getContent) {\n        this.findInside(dom);\n        rule.getContent(dom, this.parser.schema).forEach(function (node) {\n          return _this5.insertNode(node, marks, false);\n        });\n      } else {\n        var contentDOM = dom;\n        if (typeof rule.contentElement == \"string\") contentDOM = dom.querySelector(rule.contentElement);else if (typeof rule.contentElement == \"function\") contentDOM = rule.contentElement(dom);else if (rule.contentElement) contentDOM = rule.contentElement;\n        this.findAround(dom, contentDOM, true);\n        this.addAll(contentDOM, marks);\n        this.findAround(dom, contentDOM, false);\n      }\n      if (sync && this.sync(startIn)) this.open--;\n    }\n  }, {\n    key: \"addAll\",\n    value: function addAll(parent, marks, startIndex, endIndex) {\n      var index = startIndex || 0;\n      for (var dom = startIndex ? parent.childNodes[startIndex] : parent.firstChild, end = endIndex == null ? null : parent.childNodes[endIndex]; dom != end; dom = dom.nextSibling, ++index) {\n        this.findAtPoint(parent, index);\n        this.addDOM(dom, marks);\n      }\n      this.findAtPoint(parent, index);\n    }\n  }, {\n    key: \"findPlace\",\n    value: function findPlace(node, marks, cautious) {\n      var route, sync;\n      for (var depth = this.open, penalty = 0; depth >= 0; depth--) {\n        var cx = this.nodes[depth];\n        var _found2 = cx.findWrapping(node);\n        if (_found2 && (!route || route.length > _found2.length + penalty)) {\n          route = _found2;\n          sync = cx;\n          if (!_found2.length) break;\n        }\n        if (cx.solid) {\n          if (cautious) break;\n          penalty += 2;\n        }\n      }\n      if (!route) return null;\n      this.sync(sync);\n      for (var i = 0; i < route.length; i++) marks = this.enterInner(route[i], null, marks, false);\n      return marks;\n    }\n  }, {\n    key: \"insertNode\",\n    value: function insertNode(node, marks, cautious) {\n      if (node.isInline && this.needsBlock && !this.top.type) {\n        var block = this.textblockFromContext();\n        if (block) marks = this.enterInner(block, null, marks);\n      }\n      var innerMarks = this.findPlace(node, marks, cautious);\n      if (innerMarks) {\n        this.closeExtra();\n        var top = this.top;\n        if (top.match) top.match = top.match.matchType(node.type);\n        var nodeMarks = Mark.none;\n        var _iterator = _createForOfIteratorHelper(innerMarks.concat(node.marks)),\n          _step;\n        try {\n          for (_iterator.s(); !(_step = _iterator.n()).done;) {\n            var m = _step.value;\n            if (top.type ? top.type.allowsMarkType(m.type) : markMayApply(m.type, node.type)) nodeMarks = m.addToSet(nodeMarks);\n          }\n        } catch (err) {\n          _iterator.e(err);\n        } finally {\n          _iterator.f();\n        }\n        top.content.push(node.mark(nodeMarks));\n        return true;\n      }\n      return false;\n    }\n  }, {\n    key: \"enter\",\n    value: function enter(type, attrs, marks, preserveWS) {\n      var innerMarks = this.findPlace(type.create(attrs), marks, false);\n      if (innerMarks) innerMarks = this.enterInner(type, attrs, marks, true, preserveWS);\n      return innerMarks;\n    }\n  }, {\n    key: \"enterInner\",\n    value: function enterInner(type, attrs, marks) {\n      var solid = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;\n      var preserveWS = arguments.length > 4 ? arguments[4] : undefined;\n      this.closeExtra();\n      var top = this.top;\n      top.match = top.match && top.match.matchType(type);\n      var options = wsOptionsFor(type, preserveWS, top.options);\n      if (top.options & OPT_OPEN_LEFT && top.content.length == 0) options |= OPT_OPEN_LEFT;\n      var applyMarks = Mark.none;\n      marks = marks.filter(function (m) {\n        if (top.type ? top.type.allowsMarkType(m.type) : markMayApply(m.type, type)) {\n          applyMarks = m.addToSet(applyMarks);\n          return false;\n        }\n        return true;\n      });\n      this.nodes.push(new NodeContext(type, attrs, applyMarks, solid, null, options));\n      this.open++;\n      return marks;\n    }\n  }, {\n    key: \"closeExtra\",\n    value: function closeExtra() {\n      var openEnd = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n      var i = this.nodes.length - 1;\n      if (i > this.open) {\n        for (; i > this.open; i--) this.nodes[i - 1].content.push(this.nodes[i].finish(openEnd));\n        this.nodes.length = this.open + 1;\n      }\n    }\n  }, {\n    key: \"finish\",\n    value: function finish() {\n      this.open = 0;\n      this.closeExtra(this.isOpen);\n      return this.nodes[0].finish(!!(this.isOpen || this.options.topOpen));\n    }\n  }, {\n    key: \"sync\",\n    value: function sync(to) {\n      for (var i = this.open; i >= 0; i--) {\n        if (this.nodes[i] == to) {\n          this.open = i;\n          return true;\n        } else if (this.localPreserveWS) {\n          this.nodes[i].options |= OPT_PRESERVE_WS;\n        }\n      }\n      return false;\n    }\n  }, {\n    key: \"currentPos\",\n    get: function get() {\n      this.closeExtra();\n      var pos = 0;\n      for (var i = this.open; i >= 0; i--) {\n        var content = this.nodes[i].content;\n        for (var j = content.length - 1; j >= 0; j--) pos += content[j].nodeSize;\n        if (i) pos++;\n      }\n      return pos;\n    }\n  }, {\n    key: \"findAtPoint\",\n    value: function findAtPoint(parent, offset) {\n      if (this.find) for (var i = 0; i < this.find.length; i++) {\n        if (this.find[i].node == parent && this.find[i].offset == offset) this.find[i].pos = this.currentPos;\n      }\n    }\n  }, {\n    key: \"findInside\",\n    value: function findInside(parent) {\n      if (this.find) for (var i = 0; i < this.find.length; i++) {\n        if (this.find[i].pos == null && parent.nodeType == 1 && parent.contains(this.find[i].node)) this.find[i].pos = this.currentPos;\n      }\n    }\n  }, {\n    key: \"findAround\",\n    value: function findAround(parent, content, before) {\n      if (parent != content && this.find) for (var i = 0; i < this.find.length; i++) {\n        if (this.find[i].pos == null && parent.nodeType == 1 && parent.contains(this.find[i].node)) {\n          var pos = content.compareDocumentPosition(this.find[i].node);\n          if (pos & (before ? 2 : 4)) this.find[i].pos = this.currentPos;\n        }\n      }\n    }\n  }, {\n    key: \"findInText\",\n    value: function findInText(textNode) {\n      if (this.find) for (var i = 0; i < this.find.length; i++) {\n        if (this.find[i].node == textNode) this.find[i].pos = this.currentPos - (textNode.nodeValue.length - this.find[i].offset);\n      }\n    }\n  }, {\n    key: \"matchesContext\",\n    value: function matchesContext(context) {\n      var _this6 = this;\n      if (context.indexOf(\"|\") > -1) return context.split(/\\s*\\|\\s*/).some(this.matchesContext, this);\n      var parts = context.split(\"/\");\n      var option = this.options.context;\n      var useRoot = !this.isOpen && (!option || option.parent.type == this.nodes[0].type);\n      var minDepth = -(option ? option.depth + 1 : 0) + (useRoot ? 0 : 1);\n      var match = function match(i, depth) {\n        for (; i >= 0; i--) {\n          var part = parts[i];\n          if (part == \"\") {\n            if (i == parts.length - 1 || i == 0) continue;\n            for (; depth >= minDepth; depth--) if (match(i - 1, depth)) return true;\n            return false;\n          } else {\n            var next = depth > 0 || depth == 0 && useRoot ? _this6.nodes[depth].type : option && depth >= minDepth ? option.node(depth - minDepth).type : null;\n            if (!next || next.name != part && !next.isInGroup(part)) return false;\n            depth--;\n          }\n        }\n        return true;\n      };\n      return match(parts.length - 1, this.open);\n    }\n  }, {\n    key: \"textblockFromContext\",\n    value: function textblockFromContext() {\n      var $context = this.options.context;\n      if ($context) for (var d = $context.depth; d >= 0; d--) {\n        var deflt = $context.node(d).contentMatchAt($context.indexAfter(d)).defaultType;\n        if (deflt && deflt.isTextblock && deflt.defaultAttrs) return deflt;\n      }\n      for (var name in this.parser.schema.nodes) {\n        var type = this.parser.schema.nodes[name];\n        if (type.isTextblock && type.defaultAttrs) return type;\n      }\n    }\n  }]);\n  return ParseContext;\n}();\nfunction normalizeList(dom) {\n  for (var child = dom.firstChild, prevItem = null; child; child = child.nextSibling) {\n    var name = child.nodeType == 1 ? child.nodeName.toLowerCase() : null;\n    if (name && listTags.hasOwnProperty(name) && prevItem) {\n      prevItem.appendChild(child);\n      child = prevItem;\n    } else if (name == \"li\") {\n      prevItem = child;\n    } else if (name) {\n      prevItem = null;\n    }\n  }\n}\nfunction matches(dom, selector) {\n  return (dom.matches || dom.msMatchesSelector || dom.webkitMatchesSelector || dom.mozMatchesSelector).call(dom, selector);\n}\nfunction copy(obj) {\n  var copy = {};\n  for (var prop in obj) copy[prop] = obj[prop];\n  return copy;\n}\nfunction markMayApply(markType, nodeType) {\n  var nodes = nodeType.schema.nodes;\n  var _loop5 = function _loop5() {\n      var parent = nodes[name];\n      if (!parent.allowsMarkType(markType)) return 0;\n      var seen = [],\n        scan = function scan(match) {\n          seen.push(match);\n          for (var i = 0; i < match.edgeCount; i++) {\n            var _match$edge = match.edge(i),\n              type = _match$edge.type,\n              next = _match$edge.next;\n            if (type == nodeType) return true;\n            if (seen.indexOf(next) < 0 && scan(next)) return true;\n          }\n        };\n      if (scan(parent.contentMatch)) return {\n        v: true\n      };\n    },\n    _ret2;\n  for (var name in nodes) {\n    _ret2 = _loop5();\n    if (_ret2 === 0) continue;\n    if (_ret2) return _ret2.v;\n  }\n}\nvar DOMSerializer = function () {\n  function DOMSerializer(nodes, marks) {\n    _classCallCheck(this, DOMSerializer);\n    this.nodes = nodes;\n    this.marks = marks;\n  }\n  _createClass(DOMSerializer, [{\n    key: \"serializeFragment\",\n    value: function serializeFragment(fragment) {\n      var _this7 = this;\n      var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n      var target = arguments.length > 2 ? arguments[2] : undefined;\n      if (!target) target = doc(options).createDocumentFragment();\n      var top = target,\n        active = [];\n      fragment.forEach(function (node) {\n        if (active.length || node.marks.length) {\n          var keep = 0,\n            rendered = 0;\n          while (keep < active.length && rendered < node.marks.length) {\n            var next = node.marks[rendered];\n            if (!_this7.marks[next.type.name]) {\n              rendered++;\n              continue;\n            }\n            if (!next.eq(active[keep][0]) || next.type.spec.spanning === false) break;\n            keep++;\n            rendered++;\n          }\n          while (keep < active.length) top = active.pop()[1];\n          while (rendered < node.marks.length) {\n            var add = node.marks[rendered++];\n            var markDOM = _this7.serializeMark(add, node.isInline, options);\n            if (markDOM) {\n              active.push([add, top]);\n              top.appendChild(markDOM.dom);\n              top = markDOM.contentDOM || markDOM.dom;\n            }\n          }\n        }\n        top.appendChild(_this7.serializeNodeInner(node, options));\n      });\n      return target;\n    }\n  }, {\n    key: \"serializeNodeInner\",\n    value: function serializeNodeInner(node, options) {\n      if (node.isText) return doc(options).createTextNode(node.text);\n      var _renderSpec2 = _renderSpec(doc(options), this.nodes[node.type.name](node), null, node.attrs),\n        dom = _renderSpec2.dom,\n        contentDOM = _renderSpec2.contentDOM;\n      if (contentDOM) {\n        if (node.isLeaf) throw new RangeError(\"Content hole not allowed in a leaf node spec\");\n        this.serializeFragment(node.content, options, contentDOM);\n      }\n      return dom;\n    }\n  }, {\n    key: \"serializeNode\",\n    value: function serializeNode(node) {\n      var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n      var dom = this.serializeNodeInner(node, options);\n      for (var i = node.marks.length - 1; i >= 0; i--) {\n        var wrap = this.serializeMark(node.marks[i], node.isInline, options);\n        if (wrap) {\n          (wrap.contentDOM || wrap.dom).appendChild(dom);\n          dom = wrap.dom;\n        }\n      }\n      return dom;\n    }\n  }, {\n    key: \"serializeMark\",\n    value: function serializeMark(mark, inline) {\n      var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n      var toDOM = this.marks[mark.type.name];\n      return toDOM && _renderSpec(doc(options), toDOM(mark, inline), null, mark.attrs);\n    }\n  }], [{\n    key: \"renderSpec\",\n    value: function renderSpec(doc, structure) {\n      var xmlNS = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;\n      var blockArraysIn = arguments.length > 3 ? arguments[3] : undefined;\n      if (typeof structure == \"string\") return {\n        dom: doc.createTextNode(structure)\n      };\n      return _renderSpec(doc, structure, xmlNS, blockArraysIn);\n    }\n  }, {\n    key: \"fromSchema\",\n    value: function fromSchema(schema) {\n      return schema.cached.domSerializer || (schema.cached.domSerializer = new DOMSerializer(this.nodesFromSchema(schema), this.marksFromSchema(schema)));\n    }\n  }, {\n    key: \"nodesFromSchema\",\n    value: function nodesFromSchema(schema) {\n      var result = gatherToDOM(schema.nodes);\n      if (!result.text) result.text = function (node) {\n        return node.text;\n      };\n      return result;\n    }\n  }, {\n    key: \"marksFromSchema\",\n    value: function marksFromSchema(schema) {\n      return gatherToDOM(schema.marks);\n    }\n  }]);\n  return DOMSerializer;\n}();\nfunction gatherToDOM(obj) {\n  var result = {};\n  for (var name in obj) {\n    var toDOM = obj[name].spec.toDOM;\n    if (toDOM) result[name] = toDOM;\n  }\n  return result;\n}\nfunction doc(options) {\n  return options.document || window.document;\n}\nvar suspiciousAttributeCache = new WeakMap();\nfunction suspiciousAttributes(attrs) {\n  var value = suspiciousAttributeCache.get(attrs);\n  if (value === undefined) suspiciousAttributeCache.set(attrs, value = suspiciousAttributesInner(attrs));\n  return value;\n}\nfunction suspiciousAttributesInner(attrs) {\n  var result = null;\n  function scan(value) {\n    if (value && _typeof(value) == \"object\") {\n      if (Array.isArray(value)) {\n        if (typeof value[0] == \"string\") {\n          if (!result) result = [];\n          result.push(value);\n        } else {\n          for (var i = 0; i < value.length; i++) scan(value[i]);\n        }\n      } else {\n        for (var prop in value) scan(value[prop]);\n      }\n    }\n  }\n  scan(attrs);\n  return result;\n}\nfunction _renderSpec(doc, structure, xmlNS, blockArraysIn) {\n  if (structure.nodeType == 1) return {\n    dom: structure\n  };\n  if (structure.dom && structure.dom.nodeType == 1) return structure;\n  var tagName = structure[0],\n    suspicious;\n  if (typeof tagName != \"string\") throw new RangeError(\"Invalid array passed to renderSpec\");\n  if (blockArraysIn && (suspicious = suspiciousAttributes(blockArraysIn)) && suspicious.indexOf(structure) > -1) throw new RangeError(\"Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.\");\n  var space = tagName.indexOf(\" \");\n  if (space > 0) {\n    xmlNS = tagName.slice(0, space);\n    tagName = tagName.slice(space + 1);\n  }\n  var contentDOM;\n  var dom = xmlNS ? doc.createElementNS(xmlNS, tagName) : doc.createElement(tagName);\n  var attrs = structure[1],\n    start = 1;\n  if (attrs && _typeof(attrs) == \"object\" && attrs.nodeType == null && !Array.isArray(attrs)) {\n    start = 2;\n    for (var name in attrs) if (attrs[name] != null) {\n      var _space = name.indexOf(\" \");\n      if (_space > 0) dom.setAttributeNS(name.slice(0, _space), name.slice(_space + 1), attrs[name]);else if (name == \"style\" && dom.style) dom.style.cssText = attrs[name];else dom.setAttribute(name, attrs[name]);\n    }\n  }\n  for (var i = start; i < structure.length; i++) {\n    var child = structure[i];\n    if (child === 0) {\n      if (i < structure.length - 1 || i > start) throw new RangeError(\"Content hole must be the only child of its parent node\");\n      return {\n        dom: dom,\n        contentDOM: dom\n      };\n    } else if (typeof child == \"string\") {\n      dom.appendChild(doc.createTextNode(child));\n    } else {\n      var _renderSpec3 = _renderSpec(doc, child, xmlNS, blockArraysIn),\n        inner = _renderSpec3.dom,\n        innerContent = _renderSpec3.contentDOM;\n      dom.appendChild(inner);\n      if (innerContent) {\n        if (contentDOM) throw new RangeError(\"Multiple content holes\");\n        contentDOM = innerContent;\n      }\n    }\n  }\n  return {\n    dom: dom,\n    contentDOM: contentDOM\n  };\n}\nexports.ContentMatch = ContentMatch;\nexports.DOMParser = DOMParser;\nexports.DOMSerializer = DOMSerializer;\nexports.Fragment = Fragment;\nexports.Mark = Mark;\nexports.MarkType = MarkType;\nexports.Node = Node;\nexports.NodeRange = NodeRange;\nexports.NodeType = NodeType;\nexports.ReplaceError = ReplaceError;\nexports.ResolvedPos = ResolvedPos;\nexports.Schema = Schema;\nexports.Slice = Slice;\n","'use strict';\n\nvar prosemirrorTransform = require('prosemirror-transform');\nvar prosemirrorModel = require('prosemirror-model');\nvar prosemirrorState = require('prosemirror-state');\nvar olDOM = [\"ol\", 0],\n  ulDOM = [\"ul\", 0],\n  liDOM = [\"li\", 0];\nvar orderedList = {\n  attrs: {\n    order: {\n      \"default\": 1,\n      validate: \"number\"\n    }\n  },\n  parseDOM: [{\n    tag: \"ol\",\n    getAttrs: function getAttrs(dom) {\n      return {\n        order: dom.hasAttribute(\"start\") ? +dom.getAttribute(\"start\") : 1\n      };\n    }\n  }],\n  toDOM: function toDOM(node) {\n    return node.attrs.order == 1 ? olDOM : [\"ol\", {\n      start: node.attrs.order\n    }, 0];\n  }\n};\nvar bulletList = {\n  parseDOM: [{\n    tag: \"ul\"\n  }],\n  toDOM: function toDOM() {\n    return ulDOM;\n  }\n};\nvar listItem = {\n  parseDOM: [{\n    tag: \"li\"\n  }],\n  toDOM: function toDOM() {\n    return liDOM;\n  },\n  defining: true\n};\nfunction add(obj, props) {\n  var copy = {};\n  for (var prop in obj) copy[prop] = obj[prop];\n  for (var _prop in props) copy[_prop] = props[_prop];\n  return copy;\n}\nfunction addListNodes(nodes, itemContent, listGroup) {\n  return nodes.append({\n    ordered_list: add(orderedList, {\n      content: \"list_item+\",\n      group: listGroup\n    }),\n    bullet_list: add(bulletList, {\n      content: \"list_item+\",\n      group: listGroup\n    }),\n    list_item: add(listItem, {\n      content: itemContent\n    })\n  });\n}\nfunction wrapInList(listType) {\n  var attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n  return function (state, dispatch) {\n    var _state$selection = state.selection,\n      $from = _state$selection.$from,\n      $to = _state$selection.$to;\n    var range = $from.blockRange($to);\n    if (!range) return false;\n    var tr = dispatch ? state.tr : null;\n    if (!wrapRangeInList(tr, range, listType, attrs)) return false;\n    if (dispatch) dispatch(tr.scrollIntoView());\n    return true;\n  };\n}\nfunction wrapRangeInList(tr, range, listType) {\n  var attrs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;\n  var doJoin = false,\n    outerRange = range,\n    doc = range.$from.doc;\n  if (range.depth >= 2 && range.$from.node(range.depth - 1).type.compatibleContent(listType) && range.startIndex == 0) {\n    if (range.$from.index(range.depth - 1) == 0) return false;\n    var $insert = doc.resolve(range.start - 2);\n    outerRange = new prosemirrorModel.NodeRange($insert, $insert, range.depth);\n    if (range.endIndex < range.parent.childCount) range = new prosemirrorModel.NodeRange(range.$from, doc.resolve(range.$to.end(range.depth)), range.depth);\n    doJoin = true;\n  }\n  var wrap = prosemirrorTransform.findWrapping(outerRange, listType, attrs, range);\n  if (!wrap) return false;\n  if (tr) doWrapInList(tr, range, wrap, doJoin, listType);\n  return true;\n}\nfunction doWrapInList(tr, range, wrappers, joinBefore, listType) {\n  var content = prosemirrorModel.Fragment.empty;\n  for (var i = wrappers.length - 1; i >= 0; i--) content = prosemirrorModel.Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));\n  tr.step(new prosemirrorTransform.ReplaceAroundStep(range.start - (joinBefore ? 2 : 0), range.end, range.start, range.end, new prosemirrorModel.Slice(content, 0, 0), wrappers.length, true));\n  var found = 0;\n  for (var _i = 0; _i < wrappers.length; _i++) if (wrappers[_i].type == listType) found = _i + 1;\n  var splitDepth = wrappers.length - found;\n  var splitPos = range.start + wrappers.length - (joinBefore ? 2 : 0),\n    parent = range.parent;\n  for (var _i2 = range.startIndex, e = range.endIndex, first = true; _i2 < e; _i2++, first = false) {\n    if (!first && prosemirrorTransform.canSplit(tr.doc, splitPos, splitDepth)) {\n      tr.split(splitPos, splitDepth);\n      splitPos += 2 * splitDepth;\n    }\n    splitPos += parent.child(_i2).nodeSize;\n  }\n  return tr;\n}\nfunction splitListItem(itemType, itemAttrs) {\n  return function (state, dispatch) {\n    var _state$selection2 = state.selection,\n      $from = _state$selection2.$from,\n      $to = _state$selection2.$to,\n      node = _state$selection2.node;\n    if (node && node.isBlock || $from.depth < 2 || !$from.sameParent($to)) return false;\n    var grandParent = $from.node(-1);\n    if (grandParent.type != itemType) return false;\n    if ($from.parent.content.size == 0 && $from.node(-1).childCount == $from.indexAfter(-1)) {\n      if ($from.depth == 3 || $from.node(-3).type != itemType || $from.index(-2) != $from.node(-2).childCount - 1) return false;\n      if (dispatch) {\n        var wrap = prosemirrorModel.Fragment.empty;\n        var depthBefore = $from.index(-1) ? 1 : $from.index(-2) ? 2 : 3;\n        for (var d = $from.depth - depthBefore; d >= $from.depth - 3; d--) wrap = prosemirrorModel.Fragment.from($from.node(d).copy(wrap));\n        var depthAfter = $from.indexAfter(-1) < $from.node(-2).childCount ? 1 : $from.indexAfter(-2) < $from.node(-3).childCount ? 2 : 3;\n        wrap = wrap.append(prosemirrorModel.Fragment.from(itemType.createAndFill()));\n        var start = $from.before($from.depth - (depthBefore - 1));\n        var _tr = state.tr.replace(start, $from.after(-depthAfter), new prosemirrorModel.Slice(wrap, 4 - depthBefore, 0));\n        var sel = -1;\n        _tr.doc.nodesBetween(start, _tr.doc.content.size, function (node, pos) {\n          if (sel > -1) return false;\n          if (node.isTextblock && node.content.size == 0) sel = pos + 1;\n        });\n        if (sel > -1) _tr.setSelection(prosemirrorState.Selection.near(_tr.doc.resolve(sel)));\n        dispatch(_tr.scrollIntoView());\n      }\n      return true;\n    }\n    var nextType = $to.pos == $from.end() ? grandParent.contentMatchAt(0).defaultType : null;\n    var tr = state.tr[\"delete\"]($from.pos, $to.pos);\n    var types = nextType ? [itemAttrs ? {\n      type: itemType,\n      attrs: itemAttrs\n    } : null, {\n      type: nextType\n    }] : undefined;\n    if (!prosemirrorTransform.canSplit(tr.doc, $from.pos, 2, types)) return false;\n    if (dispatch) dispatch(tr.split($from.pos, 2, types).scrollIntoView());\n    return true;\n  };\n}\nfunction splitListItemKeepMarks(itemType, itemAttrs) {\n  var split = splitListItem(itemType, itemAttrs);\n  return function (state, dispatch) {\n    return split(state, dispatch && function (tr) {\n      var marks = state.storedMarks || state.selection.$to.parentOffset && state.selection.$from.marks();\n      if (marks) tr.ensureMarks(marks);\n      dispatch(tr);\n    });\n  };\n}\nfunction liftListItem(itemType) {\n  return function (state, dispatch) {\n    var _state$selection3 = state.selection,\n      $from = _state$selection3.$from,\n      $to = _state$selection3.$to;\n    var range = $from.blockRange($to, function (node) {\n      return node.childCount > 0 && node.firstChild.type == itemType;\n    });\n    if (!range) return false;\n    if (!dispatch) return true;\n    if ($from.node(range.depth - 1).type == itemType) return liftToOuterList(state, dispatch, itemType, range);else return liftOutOfList(state, dispatch, range);\n  };\n}\nfunction liftToOuterList(state, dispatch, itemType, range) {\n  var tr = state.tr,\n    end = range.end,\n    endOfList = range.$to.end(range.depth);\n  if (end < endOfList) {\n    tr.step(new prosemirrorTransform.ReplaceAroundStep(end - 1, endOfList, end, endOfList, new prosemirrorModel.Slice(prosemirrorModel.Fragment.from(itemType.create(null, range.parent.copy())), 1, 0), 1, true));\n    range = new prosemirrorModel.NodeRange(tr.doc.resolve(range.$from.pos), tr.doc.resolve(endOfList), range.depth);\n  }\n  var target = prosemirrorTransform.liftTarget(range);\n  if (target == null) return false;\n  tr.lift(range, target);\n  var $after = tr.doc.resolve(tr.mapping.map(end, -1) - 1);\n  if (prosemirrorTransform.canJoin(tr.doc, $after.pos) && $after.nodeBefore.type == $after.nodeAfter.type) tr.join($after.pos);\n  dispatch(tr.scrollIntoView());\n  return true;\n}\nfunction liftOutOfList(state, dispatch, range) {\n  var tr = state.tr,\n    list = range.parent;\n  for (var pos = range.end, i = range.endIndex - 1, e = range.startIndex; i > e; i--) {\n    pos -= list.child(i).nodeSize;\n    tr[\"delete\"](pos - 1, pos + 1);\n  }\n  var $start = tr.doc.resolve(range.start),\n    item = $start.nodeAfter;\n  if (tr.mapping.map(range.end) != range.start + $start.nodeAfter.nodeSize) return false;\n  var atStart = range.startIndex == 0,\n    atEnd = range.endIndex == list.childCount;\n  var parent = $start.node(-1),\n    indexBefore = $start.index(-1);\n  if (!parent.canReplace(indexBefore + (atStart ? 0 : 1), indexBefore + 1, item.content.append(atEnd ? prosemirrorModel.Fragment.empty : prosemirrorModel.Fragment.from(list)))) return false;\n  var start = $start.pos,\n    end = start + item.nodeSize;\n  tr.step(new prosemirrorTransform.ReplaceAroundStep(start - (atStart ? 1 : 0), end + (atEnd ? 1 : 0), start + 1, end - 1, new prosemirrorModel.Slice((atStart ? prosemirrorModel.Fragment.empty : prosemirrorModel.Fragment.from(list.copy(prosemirrorModel.Fragment.empty))).append(atEnd ? prosemirrorModel.Fragment.empty : prosemirrorModel.Fragment.from(list.copy(prosemirrorModel.Fragment.empty))), atStart ? 0 : 1, atEnd ? 0 : 1), atStart ? 0 : 1));\n  dispatch(tr.scrollIntoView());\n  return true;\n}\nfunction sinkListItem(itemType) {\n  return function (state, dispatch) {\n    var _state$selection4 = state.selection,\n      $from = _state$selection4.$from,\n      $to = _state$selection4.$to;\n    var range = $from.blockRange($to, function (node) {\n      return node.childCount > 0 && node.firstChild.type == itemType;\n    });\n    if (!range) return false;\n    var startIndex = range.startIndex;\n    if (startIndex == 0) return false;\n    var parent = range.parent,\n      nodeBefore = parent.child(startIndex - 1);\n    if (nodeBefore.type != itemType) return false;\n    if (dispatch) {\n      var nestedBefore = nodeBefore.lastChild && nodeBefore.lastChild.type == parent.type;\n      var inner = prosemirrorModel.Fragment.from(nestedBefore ? itemType.create() : null);\n      var slice = new prosemirrorModel.Slice(prosemirrorModel.Fragment.from(itemType.create(null, prosemirrorModel.Fragment.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);\n      var before = range.start,\n        after = range.end;\n      dispatch(state.tr.step(new prosemirrorTransform.ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice, 1, true)).scrollIntoView());\n    }\n    return true;\n  };\n}\nexports.addListNodes = addListNodes;\nexports.bulletList = bulletList;\nexports.liftListItem = liftListItem;\nexports.listItem = listItem;\nexports.orderedList = orderedList;\nexports.sinkListItem = sinkListItem;\nexports.splitListItem = splitListItem;\nexports.splitListItemKeepMarks = splitListItemKeepMarks;\nexports.wrapInList = wrapInList;\nexports.wrapRangeInList = wrapRangeInList;\n"],"names":[],"sourceRoot":""}