/*
 * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
 * This devtool is neither made for production nor for readable output files.
 * It uses "eval()" calls to create a separate source file in the browser devtools.
 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
 * or disable the default devtool with "devtool: false".
 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
 */
(self["webpackChunkkd_libs"] = self["webpackChunkkd_libs"] || []).push([[636],{

/***/ "../../node_modules/tinymce/tinymce.js":
/*!*********************************************!*\
  !*** ../../node_modules/tinymce/tinymce.js ***!
  \*********************************************/
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

eval("/**\n * Copyright (c) Tiny Technologies, Inc. All rights reserved.\n * Licensed under the LGPL or a commercial license.\n * For LGPL see License.txt in the project root for license information.\n * For commercial licenses see https://www.tiny.cloud/\n *\n * Version: 5.10.9 (2023-11-15)\n */\n(function () {\n    'use strict';\n\n    var typeOf$1 = function (x) {\n      if (x === null) {\n        return 'null';\n      }\n      if (x === undefined) {\n        return 'undefined';\n      }\n      var t = typeof x;\n      if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {\n        return 'array';\n      }\n      if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {\n        return 'string';\n      }\n      return t;\n    };\n    var isEquatableType = function (x) {\n      return [\n        'undefined',\n        'boolean',\n        'number',\n        'string',\n        'function',\n        'xml',\n        'null'\n      ].indexOf(x) !== -1;\n    };\n\n    var sort$1 = function (xs, compareFn) {\n      var clone = Array.prototype.slice.call(xs);\n      return clone.sort(compareFn);\n    };\n\n    var contramap = function (eqa, f) {\n      return eq$2(function (x, y) {\n        return eqa.eq(f(x), f(y));\n      });\n    };\n    var eq$2 = function (f) {\n      return { eq: f };\n    };\n    var tripleEq = eq$2(function (x, y) {\n      return x === y;\n    });\n    var eqString = tripleEq;\n    var eqArray = function (eqa) {\n      return eq$2(function (x, y) {\n        if (x.length !== y.length) {\n          return false;\n        }\n        var len = x.length;\n        for (var i = 0; i < len; i++) {\n          if (!eqa.eq(x[i], y[i])) {\n            return false;\n          }\n        }\n        return true;\n      });\n    };\n    var eqSortedArray = function (eqa, compareFn) {\n      return contramap(eqArray(eqa), function (xs) {\n        return sort$1(xs, compareFn);\n      });\n    };\n    var eqRecord = function (eqa) {\n      return eq$2(function (x, y) {\n        var kx = Object.keys(x);\n        var ky = Object.keys(y);\n        if (!eqSortedArray(eqString).eq(kx, ky)) {\n          return false;\n        }\n        var len = kx.length;\n        for (var i = 0; i < len; i++) {\n          var q = kx[i];\n          if (!eqa.eq(x[q], y[q])) {\n            return false;\n          }\n        }\n        return true;\n      });\n    };\n    var eqAny = eq$2(function (x, y) {\n      if (x === y) {\n        return true;\n      }\n      var tx = typeOf$1(x);\n      var ty = typeOf$1(y);\n      if (tx !== ty) {\n        return false;\n      }\n      if (isEquatableType(tx)) {\n        return x === y;\n      } else if (tx === 'array') {\n        return eqArray(eqAny).eq(x, y);\n      } else if (tx === 'object') {\n        return eqRecord(eqAny).eq(x, y);\n      }\n      return false;\n    });\n\n    var typeOf = function (x) {\n      var t = typeof x;\n      if (x === null) {\n        return 'null';\n      } else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {\n        return 'array';\n      } else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {\n        return 'string';\n      } else {\n        return t;\n      }\n    };\n    var isType$1 = function (type) {\n      return function (value) {\n        return typeOf(value) === type;\n      };\n    };\n    var isSimpleType = function (type) {\n      return function (value) {\n        return typeof value === type;\n      };\n    };\n    var eq$1 = function (t) {\n      return function (a) {\n        return t === a;\n      };\n    };\n    var isString$1 = isType$1('string');\n    var isObject = isType$1('object');\n    var isArray$1 = isType$1('array');\n    var isNull = eq$1(null);\n    var isBoolean = isSimpleType('boolean');\n    var isUndefined = eq$1(undefined);\n    var isNullable = function (a) {\n      return a === null || a === undefined;\n    };\n    var isNonNullable = function (a) {\n      return !isNullable(a);\n    };\n    var isFunction = isSimpleType('function');\n    var isNumber = isSimpleType('number');\n\n    var noop = function () {\n    };\n    var compose = function (fa, fb) {\n      return function () {\n        var args = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n          args[_i] = arguments[_i];\n        }\n        return fa(fb.apply(null, args));\n      };\n    };\n    var compose1 = function (fbc, fab) {\n      return function (a) {\n        return fbc(fab(a));\n      };\n    };\n    var constant = function (value) {\n      return function () {\n        return value;\n      };\n    };\n    var identity = function (x) {\n      return x;\n    };\n    var tripleEquals = function (a, b) {\n      return a === b;\n    };\n    function curry(fn) {\n      var initialArgs = [];\n      for (var _i = 1; _i < arguments.length; _i++) {\n        initialArgs[_i - 1] = arguments[_i];\n      }\n      return function () {\n        var restArgs = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n          restArgs[_i] = arguments[_i];\n        }\n        var all = initialArgs.concat(restArgs);\n        return fn.apply(null, all);\n      };\n    }\n    var not = function (f) {\n      return function (t) {\n        return !f(t);\n      };\n    };\n    var die = function (msg) {\n      return function () {\n        throw new Error(msg);\n      };\n    };\n    var apply = function (f) {\n      return f();\n    };\n    var call = function (f) {\n      f();\n    };\n    var never = constant(false);\n    var always = constant(true);\n\n    var none = function () {\n      return NONE;\n    };\n    var NONE = function () {\n      var call = function (thunk) {\n        return thunk();\n      };\n      var id = identity;\n      var me = {\n        fold: function (n, _s) {\n          return n();\n        },\n        isSome: never,\n        isNone: always,\n        getOr: id,\n        getOrThunk: call,\n        getOrDie: function (msg) {\n          throw new Error(msg || 'error: getOrDie called on none.');\n        },\n        getOrNull: constant(null),\n        getOrUndefined: constant(undefined),\n        or: id,\n        orThunk: call,\n        map: none,\n        each: noop,\n        bind: none,\n        exists: never,\n        forall: always,\n        filter: function () {\n          return none();\n        },\n        toArray: function () {\n          return [];\n        },\n        toString: constant('none()')\n      };\n      return me;\n    }();\n    var some = function (a) {\n      var constant_a = constant(a);\n      var self = function () {\n        return me;\n      };\n      var bind = function (f) {\n        return f(a);\n      };\n      var me = {\n        fold: function (n, s) {\n          return s(a);\n        },\n        isSome: always,\n        isNone: never,\n        getOr: constant_a,\n        getOrThunk: constant_a,\n        getOrDie: constant_a,\n        getOrNull: constant_a,\n        getOrUndefined: constant_a,\n        or: self,\n        orThunk: self,\n        map: function (f) {\n          return some(f(a));\n        },\n        each: function (f) {\n          f(a);\n        },\n        bind: bind,\n        exists: bind,\n        forall: bind,\n        filter: function (f) {\n          return f(a) ? me : NONE;\n        },\n        toArray: function () {\n          return [a];\n        },\n        toString: function () {\n          return 'some(' + a + ')';\n        }\n      };\n      return me;\n    };\n    var from$1 = function (value) {\n      return value === null || value === undefined ? NONE : some(value);\n    };\n    var Optional = {\n      some: some,\n      none: none,\n      from: from$1\n    };\n\n    var nativeSlice = Array.prototype.slice;\n    var nativeIndexOf = Array.prototype.indexOf;\n    var nativePush = Array.prototype.push;\n    var rawIndexOf = function (ts, t) {\n      return nativeIndexOf.call(ts, t);\n    };\n    var indexOf$2 = function (xs, x) {\n      var r = rawIndexOf(xs, x);\n      return r === -1 ? Optional.none() : Optional.some(r);\n    };\n    var contains$3 = function (xs, x) {\n      return rawIndexOf(xs, x) > -1;\n    };\n    var exists = function (xs, pred) {\n      for (var i = 0, len = xs.length; i < len; i++) {\n        var x = xs[i];\n        if (pred(x, i)) {\n          return true;\n        }\n      }\n      return false;\n    };\n    var map$3 = function (xs, f) {\n      var len = xs.length;\n      var r = new Array(len);\n      for (var i = 0; i < len; i++) {\n        var x = xs[i];\n        r[i] = f(x, i);\n      }\n      return r;\n    };\n    var each$k = function (xs, f) {\n      for (var i = 0, len = xs.length; i < len; i++) {\n        var x = xs[i];\n        f(x, i);\n      }\n    };\n    var eachr = function (xs, f) {\n      for (var i = xs.length - 1; i >= 0; i--) {\n        var x = xs[i];\n        f(x, i);\n      }\n    };\n    var partition = function (xs, pred) {\n      var pass = [];\n      var fail = [];\n      for (var i = 0, len = xs.length; i < len; i++) {\n        var x = xs[i];\n        var arr = pred(x, i) ? pass : fail;\n        arr.push(x);\n      }\n      return {\n        pass: pass,\n        fail: fail\n      };\n    };\n    var filter$4 = function (xs, pred) {\n      var r = [];\n      for (var i = 0, len = xs.length; i < len; i++) {\n        var x = xs[i];\n        if (pred(x, i)) {\n          r.push(x);\n        }\n      }\n      return r;\n    };\n    var foldr = function (xs, f, acc) {\n      eachr(xs, function (x, i) {\n        acc = f(acc, x, i);\n      });\n      return acc;\n    };\n    var foldl = function (xs, f, acc) {\n      each$k(xs, function (x, i) {\n        acc = f(acc, x, i);\n      });\n      return acc;\n    };\n    var findUntil$1 = function (xs, pred, until) {\n      for (var i = 0, len = xs.length; i < len; i++) {\n        var x = xs[i];\n        if (pred(x, i)) {\n          return Optional.some(x);\n        } else if (until(x, i)) {\n          break;\n        }\n      }\n      return Optional.none();\n    };\n    var find$3 = function (xs, pred) {\n      return findUntil$1(xs, pred, never);\n    };\n    var findIndex$2 = function (xs, pred) {\n      for (var i = 0, len = xs.length; i < len; i++) {\n        var x = xs[i];\n        if (pred(x, i)) {\n          return Optional.some(i);\n        }\n      }\n      return Optional.none();\n    };\n    var flatten = function (xs) {\n      var r = [];\n      for (var i = 0, len = xs.length; i < len; ++i) {\n        if (!isArray$1(xs[i])) {\n          throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);\n        }\n        nativePush.apply(r, xs[i]);\n      }\n      return r;\n    };\n    var bind = function (xs, f) {\n      return flatten(map$3(xs, f));\n    };\n    var forall = function (xs, pred) {\n      for (var i = 0, len = xs.length; i < len; ++i) {\n        var x = xs[i];\n        if (pred(x, i) !== true) {\n          return false;\n        }\n      }\n      return true;\n    };\n    var reverse = function (xs) {\n      var r = nativeSlice.call(xs, 0);\n      r.reverse();\n      return r;\n    };\n    var difference = function (a1, a2) {\n      return filter$4(a1, function (x) {\n        return !contains$3(a2, x);\n      });\n    };\n    var mapToObject = function (xs, f) {\n      var r = {};\n      for (var i = 0, len = xs.length; i < len; i++) {\n        var x = xs[i];\n        r[String(x)] = f(x, i);\n      }\n      return r;\n    };\n    var sort = function (xs, comparator) {\n      var copy = nativeSlice.call(xs, 0);\n      copy.sort(comparator);\n      return copy;\n    };\n    var get$a = function (xs, i) {\n      return i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();\n    };\n    var head = function (xs) {\n      return get$a(xs, 0);\n    };\n    var last$2 = function (xs) {\n      return get$a(xs, xs.length - 1);\n    };\n    var from = isFunction(Array.from) ? Array.from : function (x) {\n      return nativeSlice.call(x);\n    };\n    var findMap = function (arr, f) {\n      for (var i = 0; i < arr.length; i++) {\n        var r = f(arr[i], i);\n        if (r.isSome()) {\n          return r;\n        }\n      }\n      return Optional.none();\n    };\n\n    var keys = Object.keys;\n    var hasOwnProperty$1 = Object.hasOwnProperty;\n    var each$j = function (obj, f) {\n      var props = keys(obj);\n      for (var k = 0, len = props.length; k < len; k++) {\n        var i = props[k];\n        var x = obj[i];\n        f(x, i);\n      }\n    };\n    var map$2 = function (obj, f) {\n      return tupleMap(obj, function (x, i) {\n        return {\n          k: i,\n          v: f(x, i)\n        };\n      });\n    };\n    var tupleMap = function (obj, f) {\n      var r = {};\n      each$j(obj, function (x, i) {\n        var tuple = f(x, i);\n        r[tuple.k] = tuple.v;\n      });\n      return r;\n    };\n    var objAcc = function (r) {\n      return function (x, i) {\n        r[i] = x;\n      };\n    };\n    var internalFilter = function (obj, pred, onTrue, onFalse) {\n      var r = {};\n      each$j(obj, function (x, i) {\n        (pred(x, i) ? onTrue : onFalse)(x, i);\n      });\n      return r;\n    };\n    var bifilter = function (obj, pred) {\n      var t = {};\n      var f = {};\n      internalFilter(obj, pred, objAcc(t), objAcc(f));\n      return {\n        t: t,\n        f: f\n      };\n    };\n    var filter$3 = function (obj, pred) {\n      var t = {};\n      internalFilter(obj, pred, objAcc(t), noop);\n      return t;\n    };\n    var mapToArray = function (obj, f) {\n      var r = [];\n      each$j(obj, function (value, name) {\n        r.push(f(value, name));\n      });\n      return r;\n    };\n    var values = function (obj) {\n      return mapToArray(obj, identity);\n    };\n    var get$9 = function (obj, key) {\n      return has$2(obj, key) ? Optional.from(obj[key]) : Optional.none();\n    };\n    var has$2 = function (obj, key) {\n      return hasOwnProperty$1.call(obj, key);\n    };\n    var hasNonNullableKey = function (obj, key) {\n      return has$2(obj, key) && obj[key] !== undefined && obj[key] !== null;\n    };\n    var equal$1 = function (a1, a2, eq) {\n      if (eq === void 0) {\n        eq = eqAny;\n      }\n      return eqRecord(eq).eq(a1, a2);\n    };\n\n    var isArray = Array.isArray;\n    var toArray$1 = function (obj) {\n      if (!isArray(obj)) {\n        var array = [];\n        for (var i = 0, l = obj.length; i < l; i++) {\n          array[i] = obj[i];\n        }\n        return array;\n      } else {\n        return obj;\n      }\n    };\n    var each$i = function (o, cb, s) {\n      var n, l;\n      if (!o) {\n        return false;\n      }\n      s = s || o;\n      if (o.length !== undefined) {\n        for (n = 0, l = o.length; n < l; n++) {\n          if (cb.call(s, o[n], n, o) === false) {\n            return false;\n          }\n        }\n      } else {\n        for (n in o) {\n          if (has$2(o, n)) {\n            if (cb.call(s, o[n], n, o) === false) {\n              return false;\n            }\n          }\n        }\n      }\n      return true;\n    };\n    var map$1 = function (array, callback) {\n      var out = [];\n      each$i(array, function (item, index) {\n        out.push(callback(item, index, array));\n      });\n      return out;\n    };\n    var filter$2 = function (a, f) {\n      var o = [];\n      each$i(a, function (v, index) {\n        if (!f || f(v, index, a)) {\n          o.push(v);\n        }\n      });\n      return o;\n    };\n    var indexOf$1 = function (a, v) {\n      if (a) {\n        for (var i = 0, l = a.length; i < l; i++) {\n          if (a[i] === v) {\n            return i;\n          }\n        }\n      }\n      return -1;\n    };\n    var reduce = function (collection, iteratee, accumulator, thisArg) {\n      var acc = isUndefined(accumulator) ? collection[0] : accumulator;\n      for (var i = 0; i < collection.length; i++) {\n        acc = iteratee.call(thisArg, acc, collection[i], i);\n      }\n      return acc;\n    };\n    var findIndex$1 = function (array, predicate, thisArg) {\n      var i, l;\n      for (i = 0, l = array.length; i < l; i++) {\n        if (predicate.call(thisArg, array[i], i, array)) {\n          return i;\n        }\n      }\n      return -1;\n    };\n    var last$1 = function (collection) {\n      return collection[collection.length - 1];\n    };\n\n    var __assign = function () {\n      __assign = Object.assign || function __assign(t) {\n        for (var s, i = 1, n = arguments.length; i < n; i++) {\n          s = arguments[i];\n          for (var p in s)\n            if (Object.prototype.hasOwnProperty.call(s, p))\n              t[p] = s[p];\n        }\n        return t;\n      };\n      return __assign.apply(this, arguments);\n    };\n    function __rest(s, e) {\n      var t = {};\n      for (var p in s)\n        if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n          t[p] = s[p];\n      if (s != null && typeof Object.getOwnPropertySymbols === 'function')\n        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n          if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n            t[p[i]] = s[p[i]];\n        }\n      return t;\n    }\n    function __spreadArray(to, from, pack) {\n      if (pack || arguments.length === 2)\n        for (var i = 0, l = from.length, ar; i < l; i++) {\n          if (ar || !(i in from)) {\n            if (!ar)\n              ar = Array.prototype.slice.call(from, 0, i);\n            ar[i] = from[i];\n          }\n        }\n      return to.concat(ar || Array.prototype.slice.call(from));\n    }\n\n    var cached = function (f) {\n      var called = false;\n      var r;\n      return function () {\n        var args = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n          args[_i] = arguments[_i];\n        }\n        if (!called) {\n          called = true;\n          r = f.apply(null, args);\n        }\n        return r;\n      };\n    };\n\n    var DeviceType = function (os, browser, userAgent, mediaMatch) {\n      var isiPad = os.isiOS() && /ipad/i.test(userAgent) === true;\n      var isiPhone = os.isiOS() && !isiPad;\n      var isMobile = os.isiOS() || os.isAndroid();\n      var isTouch = isMobile || mediaMatch('(pointer:coarse)');\n      var isTablet = isiPad || !isiPhone && isMobile && mediaMatch('(min-device-width:768px)');\n      var isPhone = isiPhone || isMobile && !isTablet;\n      var iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false;\n      var isDesktop = !isPhone && !isTablet && !iOSwebview;\n      return {\n        isiPad: constant(isiPad),\n        isiPhone: constant(isiPhone),\n        isTablet: constant(isTablet),\n        isPhone: constant(isPhone),\n        isTouch: constant(isTouch),\n        isAndroid: os.isAndroid,\n        isiOS: os.isiOS,\n        isWebView: constant(iOSwebview),\n        isDesktop: constant(isDesktop)\n      };\n    };\n\n    var firstMatch = function (regexes, s) {\n      for (var i = 0; i < regexes.length; i++) {\n        var x = regexes[i];\n        if (x.test(s)) {\n          return x;\n        }\n      }\n      return undefined;\n    };\n    var find$2 = function (regexes, agent) {\n      var r = firstMatch(regexes, agent);\n      if (!r) {\n        return {\n          major: 0,\n          minor: 0\n        };\n      }\n      var group = function (i) {\n        return Number(agent.replace(r, '$' + i));\n      };\n      return nu$4(group(1), group(2));\n    };\n    var detect$3 = function (versionRegexes, agent) {\n      var cleanedAgent = String(agent).toLowerCase();\n      if (versionRegexes.length === 0) {\n        return unknown$2();\n      }\n      return find$2(versionRegexes, cleanedAgent);\n    };\n    var unknown$2 = function () {\n      return nu$4(0, 0);\n    };\n    var nu$4 = function (major, minor) {\n      return {\n        major: major,\n        minor: minor\n      };\n    };\n    var Version = {\n      nu: nu$4,\n      detect: detect$3,\n      unknown: unknown$2\n    };\n\n    var detectBrowser$1 = function (browsers, userAgentData) {\n      return findMap(userAgentData.brands, function (uaBrand) {\n        var lcBrand = uaBrand.brand.toLowerCase();\n        return find$3(browsers, function (browser) {\n          var _a;\n          return lcBrand === ((_a = browser.brand) === null || _a === void 0 ? void 0 : _a.toLowerCase());\n        }).map(function (info) {\n          return {\n            current: info.name,\n            version: Version.nu(parseInt(uaBrand.version, 10), 0)\n          };\n        });\n      });\n    };\n\n    var detect$2 = function (candidates, userAgent) {\n      var agent = String(userAgent).toLowerCase();\n      return find$3(candidates, function (candidate) {\n        return candidate.search(agent);\n      });\n    };\n    var detectBrowser = function (browsers, userAgent) {\n      return detect$2(browsers, userAgent).map(function (browser) {\n        var version = Version.detect(browser.versionRegexes, userAgent);\n        return {\n          current: browser.name,\n          version: version\n        };\n      });\n    };\n    var detectOs = function (oses, userAgent) {\n      return detect$2(oses, userAgent).map(function (os) {\n        var version = Version.detect(os.versionRegexes, userAgent);\n        return {\n          current: os.name,\n          version: version\n        };\n      });\n    };\n\n    var removeFromStart = function (str, numChars) {\n      return str.substring(numChars);\n    };\n\n    var checkRange = function (str, substr, start) {\n      return substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;\n    };\n    var removeLeading = function (str, prefix) {\n      return startsWith(str, prefix) ? removeFromStart(str, prefix.length) : str;\n    };\n    var contains$2 = function (str, substr) {\n      return str.indexOf(substr) !== -1;\n    };\n    var startsWith = function (str, prefix) {\n      return checkRange(str, prefix, 0);\n    };\n    var blank = function (r) {\n      return function (s) {\n        return s.replace(r, '');\n      };\n    };\n    var trim$5 = blank(/^\\s+|\\s+$/g);\n    var lTrim = blank(/^\\s+/g);\n    var rTrim = blank(/\\s+$/g);\n    var isNotEmpty = function (s) {\n      return s.length > 0;\n    };\n    var isEmpty$3 = function (s) {\n      return !isNotEmpty(s);\n    };\n\n    var normalVersionRegex = /.*?version\\/\\ ?([0-9]+)\\.([0-9]+).*/;\n    var checkContains = function (target) {\n      return function (uastring) {\n        return contains$2(uastring, target);\n      };\n    };\n    var browsers = [\n      {\n        name: 'Edge',\n        versionRegexes: [/.*?edge\\/ ?([0-9]+)\\.([0-9]+)$/],\n        search: function (uastring) {\n          return contains$2(uastring, 'edge/') && contains$2(uastring, 'chrome') && contains$2(uastring, 'safari') && contains$2(uastring, 'applewebkit');\n        }\n      },\n      {\n        name: 'Chrome',\n        brand: 'Chromium',\n        versionRegexes: [\n          /.*?chrome\\/([0-9]+)\\.([0-9]+).*/,\n          normalVersionRegex\n        ],\n        search: function (uastring) {\n          return contains$2(uastring, 'chrome') && !contains$2(uastring, 'chromeframe');\n        }\n      },\n      {\n        name: 'IE',\n        versionRegexes: [\n          /.*?msie\\ ?([0-9]+)\\.([0-9]+).*/,\n          /.*?rv:([0-9]+)\\.([0-9]+).*/\n        ],\n        search: function (uastring) {\n          return contains$2(uastring, 'msie') || contains$2(uastring, 'trident');\n        }\n      },\n      {\n        name: 'Opera',\n        versionRegexes: [\n          normalVersionRegex,\n          /.*?opera\\/([0-9]+)\\.([0-9]+).*/\n        ],\n        search: checkContains('opera')\n      },\n      {\n        name: 'Firefox',\n        versionRegexes: [/.*?firefox\\/\\ ?([0-9]+)\\.([0-9]+).*/],\n        search: checkContains('firefox')\n      },\n      {\n        name: 'Safari',\n        versionRegexes: [\n          normalVersionRegex,\n          /.*?cpu os ([0-9]+)_([0-9]+).*/\n        ],\n        search: function (uastring) {\n          return (contains$2(uastring, 'safari') || contains$2(uastring, 'mobile/')) && contains$2(uastring, 'applewebkit');\n        }\n      }\n    ];\n    var oses = [\n      {\n        name: 'Windows',\n        search: checkContains('win'),\n        versionRegexes: [/.*?windows\\ nt\\ ?([0-9]+)\\.([0-9]+).*/]\n      },\n      {\n        name: 'iOS',\n        search: function (uastring) {\n          return contains$2(uastring, 'iphone') || contains$2(uastring, 'ipad');\n        },\n        versionRegexes: [\n          /.*?version\\/\\ ?([0-9]+)\\.([0-9]+).*/,\n          /.*cpu os ([0-9]+)_([0-9]+).*/,\n          /.*cpu iphone os ([0-9]+)_([0-9]+).*/\n        ]\n      },\n      {\n        name: 'Android',\n        search: checkContains('android'),\n        versionRegexes: [/.*?android\\ ?([0-9]+)\\.([0-9]+).*/]\n      },\n      {\n        name: 'OSX',\n        search: checkContains('mac os x'),\n        versionRegexes: [/.*?mac\\ os\\ x\\ ?([0-9]+)_([0-9]+).*/]\n      },\n      {\n        name: 'Linux',\n        search: checkContains('linux'),\n        versionRegexes: []\n      },\n      {\n        name: 'Solaris',\n        search: checkContains('sunos'),\n        versionRegexes: []\n      },\n      {\n        name: 'FreeBSD',\n        search: checkContains('freebsd'),\n        versionRegexes: []\n      },\n      {\n        name: 'ChromeOS',\n        search: checkContains('cros'),\n        versionRegexes: [/.*?chrome\\/([0-9]+)\\.([0-9]+).*/]\n      }\n    ];\n    var PlatformInfo = {\n      browsers: constant(browsers),\n      oses: constant(oses)\n    };\n\n    var edge = 'Edge';\n    var chrome = 'Chrome';\n    var ie$1 = 'IE';\n    var opera = 'Opera';\n    var firefox = 'Firefox';\n    var safari = 'Safari';\n    var unknown$1 = function () {\n      return nu$3({\n        current: undefined,\n        version: Version.unknown()\n      });\n    };\n    var nu$3 = function (info) {\n      var current = info.current;\n      var version = info.version;\n      var isBrowser = function (name) {\n        return function () {\n          return current === name;\n        };\n      };\n      return {\n        current: current,\n        version: version,\n        isEdge: isBrowser(edge),\n        isChrome: isBrowser(chrome),\n        isIE: isBrowser(ie$1),\n        isOpera: isBrowser(opera),\n        isFirefox: isBrowser(firefox),\n        isSafari: isBrowser(safari)\n      };\n    };\n    var Browser = {\n      unknown: unknown$1,\n      nu: nu$3,\n      edge: constant(edge),\n      chrome: constant(chrome),\n      ie: constant(ie$1),\n      opera: constant(opera),\n      firefox: constant(firefox),\n      safari: constant(safari)\n    };\n\n    var windows = 'Windows';\n    var ios = 'iOS';\n    var android = 'Android';\n    var linux = 'Linux';\n    var osx = 'OSX';\n    var solaris = 'Solaris';\n    var freebsd = 'FreeBSD';\n    var chromeos = 'ChromeOS';\n    var unknown = function () {\n      return nu$2({\n        current: undefined,\n        version: Version.unknown()\n      });\n    };\n    var nu$2 = function (info) {\n      var current = info.current;\n      var version = info.version;\n      var isOS = function (name) {\n        return function () {\n          return current === name;\n        };\n      };\n      return {\n        current: current,\n        version: version,\n        isWindows: isOS(windows),\n        isiOS: isOS(ios),\n        isAndroid: isOS(android),\n        isOSX: isOS(osx),\n        isLinux: isOS(linux),\n        isSolaris: isOS(solaris),\n        isFreeBSD: isOS(freebsd),\n        isChromeOS: isOS(chromeos)\n      };\n    };\n    var OperatingSystem = {\n      unknown: unknown,\n      nu: nu$2,\n      windows: constant(windows),\n      ios: constant(ios),\n      android: constant(android),\n      linux: constant(linux),\n      osx: constant(osx),\n      solaris: constant(solaris),\n      freebsd: constant(freebsd),\n      chromeos: constant(chromeos)\n    };\n\n    var detect$1 = function (userAgent, userAgentDataOpt, mediaMatch) {\n      var browsers = PlatformInfo.browsers();\n      var oses = PlatformInfo.oses();\n      var browser = userAgentDataOpt.bind(function (userAgentData) {\n        return detectBrowser$1(browsers, userAgentData);\n      }).orThunk(function () {\n        return detectBrowser(browsers, userAgent);\n      }).fold(Browser.unknown, Browser.nu);\n      var os = detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu);\n      var deviceType = DeviceType(os, browser, userAgent, mediaMatch);\n      return {\n        browser: browser,\n        os: os,\n        deviceType: deviceType\n      };\n    };\n    var PlatformDetection = { detect: detect$1 };\n\n    var mediaMatch = function (query) {\n      return window.matchMedia(query).matches;\n    };\n    var platform$2 = cached(function () {\n      return PlatformDetection.detect(navigator.userAgent, Optional.from(navigator.userAgentData), mediaMatch);\n    });\n    var detect = function () {\n      return platform$2();\n    };\n\n    var userAgent = navigator.userAgent;\n    var platform$1 = detect();\n    var browser$4 = platform$1.browser;\n    var os = platform$1.os;\n    var deviceType = platform$1.deviceType;\n    var webkit = /WebKit/.test(userAgent) && !browser$4.isEdge();\n    var fileApi = 'FormData' in window && 'FileReader' in window && 'URL' in window && !!URL.createObjectURL;\n    var windowsPhone = userAgent.indexOf('Windows Phone') !== -1;\n    var Env = {\n      opera: browser$4.isOpera(),\n      webkit: webkit,\n      ie: browser$4.isIE() || browser$4.isEdge() ? browser$4.version.major : false,\n      gecko: browser$4.isFirefox(),\n      mac: os.isOSX() || os.isiOS(),\n      iOS: deviceType.isiPad() || deviceType.isiPhone(),\n      android: os.isAndroid(),\n      contentEditable: true,\n      transparentSrc: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',\n      caretAfter: true,\n      range: window.getSelection && 'Range' in window,\n      documentMode: browser$4.isIE() ? document.documentMode || 7 : 10,\n      fileApi: fileApi,\n      ceFalse: true,\n      cacheSuffix: null,\n      container: null,\n      experimentalShadowDom: false,\n      canHaveCSP: !browser$4.isIE(),\n      desktop: deviceType.isDesktop(),\n      windowsPhone: windowsPhone,\n      browser: {\n        current: browser$4.current,\n        version: browser$4.version,\n        isChrome: browser$4.isChrome,\n        isEdge: browser$4.isEdge,\n        isFirefox: browser$4.isFirefox,\n        isIE: browser$4.isIE,\n        isOpera: browser$4.isOpera,\n        isSafari: browser$4.isSafari\n      },\n      os: {\n        current: os.current,\n        version: os.version,\n        isAndroid: os.isAndroid,\n        isChromeOS: os.isChromeOS,\n        isFreeBSD: os.isFreeBSD,\n        isiOS: os.isiOS,\n        isLinux: os.isLinux,\n        isOSX: os.isOSX,\n        isSolaris: os.isSolaris,\n        isWindows: os.isWindows\n      },\n      deviceType: {\n        isDesktop: deviceType.isDesktop,\n        isiPad: deviceType.isiPad,\n        isiPhone: deviceType.isiPhone,\n        isPhone: deviceType.isPhone,\n        isTablet: deviceType.isTablet,\n        isTouch: deviceType.isTouch,\n        isWebView: deviceType.isWebView\n      }\n    };\n\n    var whiteSpaceRegExp$2 = /^\\s*|\\s*$/g;\n    var trim$4 = function (str) {\n      return str === null || str === undefined ? '' : ('' + str).replace(whiteSpaceRegExp$2, '');\n    };\n    var is$3 = function (obj, type) {\n      if (!type) {\n        return obj !== undefined;\n      }\n      if (type === 'array' && isArray(obj)) {\n        return true;\n      }\n      return typeof obj === type;\n    };\n    var makeMap$4 = function (items, delim, map) {\n      var i;\n      items = items || [];\n      delim = delim || ',';\n      if (typeof items === 'string') {\n        items = items.split(delim);\n      }\n      map = map || {};\n      i = items.length;\n      while (i--) {\n        map[items[i]] = {};\n      }\n      return map;\n    };\n    var hasOwnProperty = has$2;\n    var create$9 = function (s, p, root) {\n      var self = this;\n      var sp, scn, c, de = 0;\n      s = /^((static) )?([\\w.]+)(:([\\w.]+))?/.exec(s);\n      var cn = s[3].match(/(^|\\.)(\\w+)$/i)[2];\n      var ns = self.createNS(s[3].replace(/\\.\\w+$/, ''), root);\n      if (ns[cn]) {\n        return;\n      }\n      if (s[2] === 'static') {\n        ns[cn] = p;\n        if (this.onCreate) {\n          this.onCreate(s[2], s[3], ns[cn]);\n        }\n        return;\n      }\n      if (!p[cn]) {\n        p[cn] = function () {\n        };\n        de = 1;\n      }\n      ns[cn] = p[cn];\n      self.extend(ns[cn].prototype, p);\n      if (s[5]) {\n        sp = self.resolve(s[5]).prototype;\n        scn = s[5].match(/\\.(\\w+)$/i)[1];\n        c = ns[cn];\n        if (de) {\n          ns[cn] = function () {\n            return sp[scn].apply(this, arguments);\n          };\n        } else {\n          ns[cn] = function () {\n            this.parent = sp[scn];\n            return c.apply(this, arguments);\n          };\n        }\n        ns[cn].prototype[cn] = ns[cn];\n        self.each(sp, function (f, n) {\n          ns[cn].prototype[n] = sp[n];\n        });\n        self.each(p, function (f, n) {\n          if (sp[n]) {\n            ns[cn].prototype[n] = function () {\n              this.parent = sp[n];\n              return f.apply(this, arguments);\n            };\n          } else {\n            if (n !== cn) {\n              ns[cn].prototype[n] = f;\n            }\n          }\n        });\n      }\n      self.each(p.static, function (f, n) {\n        ns[cn][n] = f;\n      });\n    };\n    var extend$6 = function (obj) {\n      var exts = [];\n      for (var _i = 1; _i < arguments.length; _i++) {\n        exts[_i - 1] = arguments[_i];\n      }\n      for (var i = 0; i < exts.length; i++) {\n        var ext = exts[i];\n        for (var name_1 in ext) {\n          if (has$2(ext, name_1)) {\n            var value = ext[name_1];\n            if (value !== undefined) {\n              obj[name_1] = value;\n            }\n          }\n        }\n      }\n      return obj;\n    };\n    var walk$3 = function (o, f, n, s) {\n      s = s || this;\n      if (o) {\n        if (n) {\n          o = o[n];\n        }\n        each$i(o, function (o, i) {\n          if (f.call(s, o, i, n) === false) {\n            return false;\n          }\n          walk$3(o, f, n, s);\n        });\n      }\n    };\n    var createNS = function (n, o) {\n      var i, v;\n      o = o || window;\n      n = n.split('.');\n      for (i = 0; i < n.length; i++) {\n        v = n[i];\n        if (!o[v]) {\n          o[v] = {};\n        }\n        o = o[v];\n      }\n      return o;\n    };\n    var resolve$3 = function (n, o) {\n      var i, l;\n      o = o || window;\n      n = n.split('.');\n      for (i = 0, l = n.length; i < l; i++) {\n        o = o[n[i]];\n        if (!o) {\n          break;\n        }\n      }\n      return o;\n    };\n    var explode$4 = function (s, d) {\n      if (!s || is$3(s, 'array')) {\n        return s;\n      }\n      return map$1(s.split(d || ','), trim$4);\n    };\n    var _addCacheSuffix = function (url) {\n      var cacheSuffix = Env.cacheSuffix;\n      if (cacheSuffix) {\n        url += (url.indexOf('?') === -1 ? '?' : '&') + cacheSuffix;\n      }\n      return url;\n    };\n    var Tools = {\n      trim: trim$4,\n      isArray: isArray,\n      is: is$3,\n      toArray: toArray$1,\n      makeMap: makeMap$4,\n      each: each$i,\n      map: map$1,\n      grep: filter$2,\n      inArray: indexOf$1,\n      hasOwn: hasOwnProperty,\n      extend: extend$6,\n      create: create$9,\n      walk: walk$3,\n      createNS: createNS,\n      resolve: resolve$3,\n      explode: explode$4,\n      _addCacheSuffix: _addCacheSuffix\n    };\n\n    var fromHtml$1 = function (html, scope) {\n      var doc = scope || document;\n      var div = doc.createElement('div');\n      div.innerHTML = html;\n      if (!div.hasChildNodes() || div.childNodes.length > 1) {\n        console.error('HTML does not have a single root node', html);\n        throw new Error('HTML must have a single root node');\n      }\n      return fromDom$2(div.childNodes[0]);\n    };\n    var fromTag = function (tag, scope) {\n      var doc = scope || document;\n      var node = doc.createElement(tag);\n      return fromDom$2(node);\n    };\n    var fromText = function (text, scope) {\n      var doc = scope || document;\n      var node = doc.createTextNode(text);\n      return fromDom$2(node);\n    };\n    var fromDom$2 = function (node) {\n      if (node === null || node === undefined) {\n        throw new Error('Node cannot be null or undefined');\n      }\n      return { dom: node };\n    };\n    var fromPoint$1 = function (docElm, x, y) {\n      return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom$2);\n    };\n    var SugarElement = {\n      fromHtml: fromHtml$1,\n      fromTag: fromTag,\n      fromText: fromText,\n      fromDom: fromDom$2,\n      fromPoint: fromPoint$1\n    };\n\n    var toArray = function (target, f) {\n      var r = [];\n      var recurse = function (e) {\n        r.push(e);\n        return f(e);\n      };\n      var cur = f(target);\n      do {\n        cur = cur.bind(recurse);\n      } while (cur.isSome());\n      return r;\n    };\n\n    var compareDocumentPosition = function (a, b, match) {\n      return (a.compareDocumentPosition(b) & match) !== 0;\n    };\n    var documentPositionContainedBy = function (a, b) {\n      return compareDocumentPosition(a, b, Node.DOCUMENT_POSITION_CONTAINED_BY);\n    };\n\n    var COMMENT = 8;\n    var DOCUMENT = 9;\n    var DOCUMENT_FRAGMENT = 11;\n    var ELEMENT = 1;\n    var TEXT = 3;\n\n    var is$2 = function (element, selector) {\n      var dom = element.dom;\n      if (dom.nodeType !== ELEMENT) {\n        return false;\n      } else {\n        var elem = dom;\n        if (elem.matches !== undefined) {\n          return elem.matches(selector);\n        } else if (elem.msMatchesSelector !== undefined) {\n          return elem.msMatchesSelector(selector);\n        } else if (elem.webkitMatchesSelector !== undefined) {\n          return elem.webkitMatchesSelector(selector);\n        } else if (elem.mozMatchesSelector !== undefined) {\n          return elem.mozMatchesSelector(selector);\n        } else {\n          throw new Error('Browser lacks native selectors');\n        }\n      }\n    };\n    var bypassSelector = function (dom) {\n      return dom.nodeType !== ELEMENT && dom.nodeType !== DOCUMENT && dom.nodeType !== DOCUMENT_FRAGMENT || dom.childElementCount === 0;\n    };\n    var all = function (selector, scope) {\n      var base = scope === undefined ? document : scope.dom;\n      return bypassSelector(base) ? [] : map$3(base.querySelectorAll(selector), SugarElement.fromDom);\n    };\n    var one = function (selector, scope) {\n      var base = scope === undefined ? document : scope.dom;\n      return bypassSelector(base) ? Optional.none() : Optional.from(base.querySelector(selector)).map(SugarElement.fromDom);\n    };\n\n    var eq = function (e1, e2) {\n      return e1.dom === e2.dom;\n    };\n    var regularContains = function (e1, e2) {\n      var d1 = e1.dom;\n      var d2 = e2.dom;\n      return d1 === d2 ? false : d1.contains(d2);\n    };\n    var ieContains = function (e1, e2) {\n      return documentPositionContainedBy(e1.dom, e2.dom);\n    };\n    var contains$1 = function (e1, e2) {\n      return detect().browser.isIE() ? ieContains(e1, e2) : regularContains(e1, e2);\n    };\n\n    typeof window !== 'undefined' ? window : Function('return this;')();\n\n    var name = function (element) {\n      var r = element.dom.nodeName;\n      return r.toLowerCase();\n    };\n    var type = function (element) {\n      return element.dom.nodeType;\n    };\n    var isType = function (t) {\n      return function (element) {\n        return type(element) === t;\n      };\n    };\n    var isComment$1 = function (element) {\n      return type(element) === COMMENT || name(element) === '#comment';\n    };\n    var isElement$6 = isType(ELEMENT);\n    var isText$8 = isType(TEXT);\n    var isDocument$2 = isType(DOCUMENT);\n    var isDocumentFragment$1 = isType(DOCUMENT_FRAGMENT);\n    var isTag = function (tag) {\n      return function (e) {\n        return isElement$6(e) && name(e) === tag;\n      };\n    };\n\n    var owner$1 = function (element) {\n      return SugarElement.fromDom(element.dom.ownerDocument);\n    };\n    var documentOrOwner = function (dos) {\n      return isDocument$2(dos) ? dos : owner$1(dos);\n    };\n    var documentElement = function (element) {\n      return SugarElement.fromDom(documentOrOwner(element).dom.documentElement);\n    };\n    var defaultView = function (element) {\n      return SugarElement.fromDom(documentOrOwner(element).dom.defaultView);\n    };\n    var parent = function (element) {\n      return Optional.from(element.dom.parentNode).map(SugarElement.fromDom);\n    };\n    var parents$1 = function (element, isRoot) {\n      var stop = isFunction(isRoot) ? isRoot : never;\n      var dom = element.dom;\n      var ret = [];\n      while (dom.parentNode !== null && dom.parentNode !== undefined) {\n        var rawParent = dom.parentNode;\n        var p = SugarElement.fromDom(rawParent);\n        ret.push(p);\n        if (stop(p) === true) {\n          break;\n        } else {\n          dom = rawParent;\n        }\n      }\n      return ret;\n    };\n    var siblings = function (element) {\n      var filterSelf = function (elements) {\n        return filter$4(elements, function (x) {\n          return !eq(element, x);\n        });\n      };\n      return parent(element).map(children).map(filterSelf).getOr([]);\n    };\n    var prevSibling = function (element) {\n      return Optional.from(element.dom.previousSibling).map(SugarElement.fromDom);\n    };\n    var nextSibling = function (element) {\n      return Optional.from(element.dom.nextSibling).map(SugarElement.fromDom);\n    };\n    var prevSiblings = function (element) {\n      return reverse(toArray(element, prevSibling));\n    };\n    var nextSiblings = function (element) {\n      return toArray(element, nextSibling);\n    };\n    var children = function (element) {\n      return map$3(element.dom.childNodes, SugarElement.fromDom);\n    };\n    var child$1 = function (element, index) {\n      var cs = element.dom.childNodes;\n      return Optional.from(cs[index]).map(SugarElement.fromDom);\n    };\n    var firstChild = function (element) {\n      return child$1(element, 0);\n    };\n    var lastChild = function (element) {\n      return child$1(element, element.dom.childNodes.length - 1);\n    };\n    var childNodesCount = function (element) {\n      return element.dom.childNodes.length;\n    };\n\n    var getHead = function (doc) {\n      var b = doc.dom.head;\n      if (b === null || b === undefined) {\n        throw new Error('Head is not available yet');\n      }\n      return SugarElement.fromDom(b);\n    };\n\n    var isShadowRoot = function (dos) {\n      return isDocumentFragment$1(dos) && isNonNullable(dos.dom.host);\n    };\n    var supported = isFunction(Element.prototype.attachShadow) && isFunction(Node.prototype.getRootNode);\n    var isSupported$1 = constant(supported);\n    var getRootNode = supported ? function (e) {\n      return SugarElement.fromDom(e.dom.getRootNode());\n    } : documentOrOwner;\n    var getStyleContainer = function (dos) {\n      return isShadowRoot(dos) ? dos : getHead(documentOrOwner(dos));\n    };\n    var getShadowRoot = function (e) {\n      var r = getRootNode(e);\n      return isShadowRoot(r) ? Optional.some(r) : Optional.none();\n    };\n    var getShadowHost = function (e) {\n      return SugarElement.fromDom(e.dom.host);\n    };\n    var getOriginalEventTarget = function (event) {\n      if (isSupported$1() && isNonNullable(event.target)) {\n        var el = SugarElement.fromDom(event.target);\n        if (isElement$6(el) && isOpenShadowHost(el)) {\n          if (event.composed && event.composedPath) {\n            var composedPath = event.composedPath();\n            if (composedPath) {\n              return head(composedPath);\n            }\n          }\n        }\n      }\n      return Optional.from(event.target);\n    };\n    var isOpenShadowHost = function (element) {\n      return isNonNullable(element.dom.shadowRoot);\n    };\n\n    var before$4 = function (marker, element) {\n      var parent$1 = parent(marker);\n      parent$1.each(function (v) {\n        v.dom.insertBefore(element.dom, marker.dom);\n      });\n    };\n    var after$3 = function (marker, element) {\n      var sibling = nextSibling(marker);\n      sibling.fold(function () {\n        var parent$1 = parent(marker);\n        parent$1.each(function (v) {\n          append$1(v, element);\n        });\n      }, function (v) {\n        before$4(v, element);\n      });\n    };\n    var prepend = function (parent, element) {\n      var firstChild$1 = firstChild(parent);\n      firstChild$1.fold(function () {\n        append$1(parent, element);\n      }, function (v) {\n        parent.dom.insertBefore(element.dom, v.dom);\n      });\n    };\n    var append$1 = function (parent, element) {\n      parent.dom.appendChild(element.dom);\n    };\n    var wrap$3 = function (element, wrapper) {\n      before$4(element, wrapper);\n      append$1(wrapper, element);\n    };\n\n    var before$3 = function (marker, elements) {\n      each$k(elements, function (x) {\n        before$4(marker, x);\n      });\n    };\n    var append = function (parent, elements) {\n      each$k(elements, function (x) {\n        append$1(parent, x);\n      });\n    };\n\n    var empty = function (element) {\n      element.dom.textContent = '';\n      each$k(children(element), function (rogue) {\n        remove$7(rogue);\n      });\n    };\n    var remove$7 = function (element) {\n      var dom = element.dom;\n      if (dom.parentNode !== null) {\n        dom.parentNode.removeChild(dom);\n      }\n    };\n    var unwrap = function (wrapper) {\n      var children$1 = children(wrapper);\n      if (children$1.length > 0) {\n        before$3(wrapper, children$1);\n      }\n      remove$7(wrapper);\n    };\n\n    var inBody = function (element) {\n      var dom = isText$8(element) ? element.dom.parentNode : element.dom;\n      if (dom === undefined || dom === null || dom.ownerDocument === null) {\n        return false;\n      }\n      var doc = dom.ownerDocument;\n      return getShadowRoot(SugarElement.fromDom(dom)).fold(function () {\n        return doc.body.contains(dom);\n      }, compose1(inBody, getShadowHost));\n    };\n\n    var r = function (left, top) {\n      var translate = function (x, y) {\n        return r(left + x, top + y);\n      };\n      return {\n        left: left,\n        top: top,\n        translate: translate\n      };\n    };\n    var SugarPosition = r;\n\n    var boxPosition = function (dom) {\n      var box = dom.getBoundingClientRect();\n      return SugarPosition(box.left, box.top);\n    };\n    var firstDefinedOrZero = function (a, b) {\n      if (a !== undefined) {\n        return a;\n      } else {\n        return b !== undefined ? b : 0;\n      }\n    };\n    var absolute = function (element) {\n      var doc = element.dom.ownerDocument;\n      var body = doc.body;\n      var win = doc.defaultView;\n      var html = doc.documentElement;\n      if (body === element.dom) {\n        return SugarPosition(body.offsetLeft, body.offsetTop);\n      }\n      var scrollTop = firstDefinedOrZero(win === null || win === void 0 ? void 0 : win.pageYOffset, html.scrollTop);\n      var scrollLeft = firstDefinedOrZero(win === null || win === void 0 ? void 0 : win.pageXOffset, html.scrollLeft);\n      var clientTop = firstDefinedOrZero(html.clientTop, body.clientTop);\n      var clientLeft = firstDefinedOrZero(html.clientLeft, body.clientLeft);\n      return viewport(element).translate(scrollLeft - clientLeft, scrollTop - clientTop);\n    };\n    var viewport = function (element) {\n      var dom = element.dom;\n      var doc = dom.ownerDocument;\n      var body = doc.body;\n      if (body === dom) {\n        return SugarPosition(body.offsetLeft, body.offsetTop);\n      }\n      if (!inBody(element)) {\n        return SugarPosition(0, 0);\n      }\n      return boxPosition(dom);\n    };\n\n    var get$8 = function (_DOC) {\n      var doc = _DOC !== undefined ? _DOC.dom : document;\n      var x = doc.body.scrollLeft || doc.documentElement.scrollLeft;\n      var y = doc.body.scrollTop || doc.documentElement.scrollTop;\n      return SugarPosition(x, y);\n    };\n    var to = function (x, y, _DOC) {\n      var doc = _DOC !== undefined ? _DOC.dom : document;\n      var win = doc.defaultView;\n      if (win) {\n        win.scrollTo(x, y);\n      }\n    };\n    var intoView = function (element, alignToTop) {\n      var isSafari = detect().browser.isSafari();\n      if (isSafari && isFunction(element.dom.scrollIntoViewIfNeeded)) {\n        element.dom.scrollIntoViewIfNeeded(false);\n      } else {\n        element.dom.scrollIntoView(alignToTop);\n      }\n    };\n\n    var get$7 = function (_win) {\n      var win = _win === undefined ? window : _win;\n      if (detect().browser.isFirefox()) {\n        return Optional.none();\n      } else {\n        return Optional.from(win['visualViewport']);\n      }\n    };\n    var bounds = function (x, y, width, height) {\n      return {\n        x: x,\n        y: y,\n        width: width,\n        height: height,\n        right: x + width,\n        bottom: y + height\n      };\n    };\n    var getBounds = function (_win) {\n      var win = _win === undefined ? window : _win;\n      var doc = win.document;\n      var scroll = get$8(SugarElement.fromDom(doc));\n      return get$7(win).fold(function () {\n        var html = win.document.documentElement;\n        var width = html.clientWidth;\n        var height = html.clientHeight;\n        return bounds(scroll.left, scroll.top, width, height);\n      }, function (visualViewport) {\n        return bounds(Math.max(visualViewport.pageLeft, scroll.left), Math.max(visualViewport.pageTop, scroll.top), visualViewport.width, visualViewport.height);\n      });\n    };\n\n    var isNodeType = function (type) {\n      return function (node) {\n        return !!node && node.nodeType === type;\n      };\n    };\n    var isRestrictedNode = function (node) {\n      return !!node && !Object.getPrototypeOf(node);\n    };\n    var isElement$5 = isNodeType(1);\n    var matchNodeNames = function (names) {\n      var lowercasedNames = names.map(function (s) {\n        return s.toLowerCase();\n      });\n      return function (node) {\n        if (node && node.nodeName) {\n          var nodeName = node.nodeName.toLowerCase();\n          return contains$3(lowercasedNames, nodeName);\n        }\n        return false;\n      };\n    };\n    var matchStyleValues = function (name, values) {\n      var items = values.toLowerCase().split(' ');\n      return function (node) {\n        if (isElement$5(node)) {\n          for (var i = 0; i < items.length; i++) {\n            var computed = node.ownerDocument.defaultView.getComputedStyle(node, null);\n            var cssValue = computed ? computed.getPropertyValue(name) : null;\n            if (cssValue === items[i]) {\n              return true;\n            }\n          }\n        }\n        return false;\n      };\n    };\n    var hasAttribute = function (attrName) {\n      return function (node) {\n        return isElement$5(node) && node.hasAttribute(attrName);\n      };\n    };\n    var hasAttributeValue = function (attrName, attrValue) {\n      return function (node) {\n        return isElement$5(node) && node.getAttribute(attrName) === attrValue;\n      };\n    };\n    var isBogus$2 = function (node) {\n      return isElement$5(node) && node.hasAttribute('data-mce-bogus');\n    };\n    var isBogusAll$1 = function (node) {\n      return isElement$5(node) && node.getAttribute('data-mce-bogus') === 'all';\n    };\n    var isTable$3 = function (node) {\n      return isElement$5(node) && node.tagName === 'TABLE';\n    };\n    var hasContentEditableState = function (value) {\n      return function (node) {\n        if (isElement$5(node)) {\n          if (node.contentEditable === value) {\n            return true;\n          }\n          if (node.getAttribute('data-mce-contenteditable') === value) {\n            return true;\n          }\n        }\n        return false;\n      };\n    };\n    var isTextareaOrInput = matchNodeNames([\n      'textarea',\n      'input'\n    ]);\n    var isText$7 = isNodeType(3);\n    var isComment = isNodeType(8);\n    var isDocument$1 = isNodeType(9);\n    var isDocumentFragment = isNodeType(11);\n    var isBr$5 = matchNodeNames(['br']);\n    var isImg = matchNodeNames(['img']);\n    var isContentEditableTrue$4 = hasContentEditableState('true');\n    var isContentEditableFalse$b = hasContentEditableState('false');\n    var isTableCell$5 = matchNodeNames([\n      'td',\n      'th'\n    ]);\n    var isMedia$2 = matchNodeNames([\n      'video',\n      'audio',\n      'object',\n      'embed'\n    ]);\n\n    var is$1 = function (lhs, rhs, comparator) {\n      if (comparator === void 0) {\n        comparator = tripleEquals;\n      }\n      return lhs.exists(function (left) {\n        return comparator(left, rhs);\n      });\n    };\n    var cat = function (arr) {\n      var r = [];\n      var push = function (x) {\n        r.push(x);\n      };\n      for (var i = 0; i < arr.length; i++) {\n        arr[i].each(push);\n      }\n      return r;\n    };\n    var lift2 = function (oa, ob, f) {\n      return oa.isSome() && ob.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie())) : Optional.none();\n    };\n    var lift3 = function (oa, ob, oc, f) {\n      return oa.isSome() && ob.isSome() && oc.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie(), oc.getOrDie())) : Optional.none();\n    };\n    var someIf = function (b, a) {\n      return b ? Optional.some(a) : Optional.none();\n    };\n\n    var isSupported = function (dom) {\n      return dom.style !== undefined && isFunction(dom.style.getPropertyValue);\n    };\n\n    var rawSet = function (dom, key, value) {\n      if (isString$1(value) || isBoolean(value) || isNumber(value)) {\n        dom.setAttribute(key, value + '');\n      } else {\n        console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);\n        throw new Error('Attribute value was not simple');\n      }\n    };\n    var set$1 = function (element, key, value) {\n      rawSet(element.dom, key, value);\n    };\n    var setAll$1 = function (element, attrs) {\n      var dom = element.dom;\n      each$j(attrs, function (v, k) {\n        rawSet(dom, k, v);\n      });\n    };\n    var get$6 = function (element, key) {\n      var v = element.dom.getAttribute(key);\n      return v === null ? undefined : v;\n    };\n    var getOpt = function (element, key) {\n      return Optional.from(get$6(element, key));\n    };\n    var has$1 = function (element, key) {\n      var dom = element.dom;\n      return dom && dom.hasAttribute ? dom.hasAttribute(key) : false;\n    };\n    var remove$6 = function (element, key) {\n      element.dom.removeAttribute(key);\n    };\n    var clone$3 = function (element) {\n      return foldl(element.dom.attributes, function (acc, attr) {\n        acc[attr.name] = attr.value;\n        return acc;\n      }, {});\n    };\n\n    var internalSet = function (dom, property, value) {\n      if (!isString$1(value)) {\n        console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom);\n        throw new Error('CSS value must be a string: ' + value);\n      }\n      if (isSupported(dom)) {\n        dom.style.setProperty(property, value);\n      }\n    };\n    var setAll = function (element, css) {\n      var dom = element.dom;\n      each$j(css, function (v, k) {\n        internalSet(dom, k, v);\n      });\n    };\n    var get$5 = function (element, property) {\n      var dom = element.dom;\n      var styles = window.getComputedStyle(dom);\n      var r = styles.getPropertyValue(property);\n      return r === '' && !inBody(element) ? getUnsafeProperty(dom, property) : r;\n    };\n    var getUnsafeProperty = function (dom, property) {\n      return isSupported(dom) ? dom.style.getPropertyValue(property) : '';\n    };\n    var getRaw = function (element, property) {\n      var dom = element.dom;\n      var raw = getUnsafeProperty(dom, property);\n      return Optional.from(raw).filter(function (r) {\n        return r.length > 0;\n      });\n    };\n    var getAllRaw = function (element) {\n      var css = {};\n      var dom = element.dom;\n      if (isSupported(dom)) {\n        for (var i = 0; i < dom.style.length; i++) {\n          var ruleName = dom.style.item(i);\n          css[ruleName] = dom.style[ruleName];\n        }\n      }\n      return css;\n    };\n    var reflow = function (e) {\n      return e.dom.offsetWidth;\n    };\n\n    var browser$3 = detect().browser;\n    var firstElement = function (nodes) {\n      return find$3(nodes, isElement$6);\n    };\n    var getTableCaptionDeltaY = function (elm) {\n      if (browser$3.isFirefox() && name(elm) === 'table') {\n        return firstElement(children(elm)).filter(function (elm) {\n          return name(elm) === 'caption';\n        }).bind(function (caption) {\n          return firstElement(nextSiblings(caption)).map(function (body) {\n            var bodyTop = body.dom.offsetTop;\n            var captionTop = caption.dom.offsetTop;\n            var captionHeight = caption.dom.offsetHeight;\n            return bodyTop <= captionTop ? -captionHeight : 0;\n          });\n        }).getOr(0);\n      } else {\n        return 0;\n      }\n    };\n    var hasChild = function (elm, child) {\n      return elm.children && contains$3(elm.children, child);\n    };\n    var getPos = function (body, elm, rootElm) {\n      var x = 0, y = 0;\n      var doc = body.ownerDocument;\n      rootElm = rootElm ? rootElm : body;\n      if (elm) {\n        if (rootElm === body && elm.getBoundingClientRect && get$5(SugarElement.fromDom(body), 'position') === 'static') {\n          var pos = elm.getBoundingClientRect();\n          x = pos.left + (doc.documentElement.scrollLeft || body.scrollLeft) - doc.documentElement.clientLeft;\n          y = pos.top + (doc.documentElement.scrollTop || body.scrollTop) - doc.documentElement.clientTop;\n          return {\n            x: x,\n            y: y\n          };\n        }\n        var offsetParent = elm;\n        while (offsetParent && offsetParent !== rootElm && offsetParent.nodeType && !hasChild(offsetParent, rootElm)) {\n          var castOffsetParent = offsetParent;\n          x += castOffsetParent.offsetLeft || 0;\n          y += castOffsetParent.offsetTop || 0;\n          offsetParent = castOffsetParent.offsetParent;\n        }\n        offsetParent = elm.parentNode;\n        while (offsetParent && offsetParent !== rootElm && offsetParent.nodeType && !hasChild(offsetParent, rootElm)) {\n          x -= offsetParent.scrollLeft || 0;\n          y -= offsetParent.scrollTop || 0;\n          offsetParent = offsetParent.parentNode;\n        }\n        y += getTableCaptionDeltaY(SugarElement.fromDom(elm));\n      }\n      return {\n        x: x,\n        y: y\n      };\n    };\n\n    var exports$1 = {}, module$1 = { exports: exports$1 };\n    (function (define, exports, module, require) {\n      (function (global, factory) {\n        typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.EphoxContactWrapper = factory());\n      }(this, function () {\n        var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof __webpack_require__.g !== 'undefined' ? __webpack_require__.g : typeof self !== 'undefined' ? self : {};\n        var promise = { exports: {} };\n        (function (module) {\n          (function (root) {\n            var setTimeoutFunc = setTimeout;\n            function noop() {\n            }\n            function bind(fn, thisArg) {\n              return function () {\n                fn.apply(thisArg, arguments);\n              };\n            }\n            function Promise(fn) {\n              if (typeof this !== 'object')\n                throw new TypeError('Promises must be constructed via new');\n              if (typeof fn !== 'function')\n                throw new TypeError('not a function');\n              this._state = 0;\n              this._handled = false;\n              this._value = undefined;\n              this._deferreds = [];\n              doResolve(fn, this);\n            }\n            function handle(self, deferred) {\n              while (self._state === 3) {\n                self = self._value;\n              }\n              if (self._state === 0) {\n                self._deferreds.push(deferred);\n                return;\n              }\n              self._handled = true;\n              Promise._immediateFn(function () {\n                var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;\n                if (cb === null) {\n                  (self._state === 1 ? resolve : reject)(deferred.promise, self._value);\n                  return;\n                }\n                var ret;\n                try {\n                  ret = cb(self._value);\n                } catch (e) {\n                  reject(deferred.promise, e);\n                  return;\n                }\n                resolve(deferred.promise, ret);\n              });\n            }\n            function resolve(self, newValue) {\n              try {\n                if (newValue === self)\n                  throw new TypeError('A promise cannot be resolved with itself.');\n                if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) {\n                  var then = newValue.then;\n                  if (newValue instanceof Promise) {\n                    self._state = 3;\n                    self._value = newValue;\n                    finale(self);\n                    return;\n                  } else if (typeof then === 'function') {\n                    doResolve(bind(then, newValue), self);\n                    return;\n                  }\n                }\n                self._state = 1;\n                self._value = newValue;\n                finale(self);\n              } catch (e) {\n                reject(self, e);\n              }\n            }\n            function reject(self, newValue) {\n              self._state = 2;\n              self._value = newValue;\n              finale(self);\n            }\n            function finale(self) {\n              if (self._state === 2 && self._deferreds.length === 0) {\n                Promise._immediateFn(function () {\n                  if (!self._handled) {\n                    Promise._unhandledRejectionFn(self._value);\n                  }\n                });\n              }\n              for (var i = 0, len = self._deferreds.length; i < len; i++) {\n                handle(self, self._deferreds[i]);\n              }\n              self._deferreds = null;\n            }\n            function Handler(onFulfilled, onRejected, promise) {\n              this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;\n              this.onRejected = typeof onRejected === 'function' ? onRejected : null;\n              this.promise = promise;\n            }\n            function doResolve(fn, self) {\n              var done = false;\n              try {\n                fn(function (value) {\n                  if (done)\n                    return;\n                  done = true;\n                  resolve(self, value);\n                }, function (reason) {\n                  if (done)\n                    return;\n                  done = true;\n                  reject(self, reason);\n                });\n              } catch (ex) {\n                if (done)\n                  return;\n                done = true;\n                reject(self, ex);\n              }\n            }\n            Promise.prototype['catch'] = function (onRejected) {\n              return this.then(null, onRejected);\n            };\n            Promise.prototype.then = function (onFulfilled, onRejected) {\n              var prom = new this.constructor(noop);\n              handle(this, new Handler(onFulfilled, onRejected, prom));\n              return prom;\n            };\n            Promise.all = function (arr) {\n              var args = Array.prototype.slice.call(arr);\n              return new Promise(function (resolve, reject) {\n                if (args.length === 0)\n                  return resolve([]);\n                var remaining = args.length;\n                function res(i, val) {\n                  try {\n                    if (val && (typeof val === 'object' || typeof val === 'function')) {\n                      var then = val.then;\n                      if (typeof then === 'function') {\n                        then.call(val, function (val) {\n                          res(i, val);\n                        }, reject);\n                        return;\n                      }\n                    }\n                    args[i] = val;\n                    if (--remaining === 0) {\n                      resolve(args);\n                    }\n                  } catch (ex) {\n                    reject(ex);\n                  }\n                }\n                for (var i = 0; i < args.length; i++) {\n                  res(i, args[i]);\n                }\n              });\n            };\n            Promise.resolve = function (value) {\n              if (value && typeof value === 'object' && value.constructor === Promise) {\n                return value;\n              }\n              return new Promise(function (resolve) {\n                resolve(value);\n              });\n            };\n            Promise.reject = function (value) {\n              return new Promise(function (resolve, reject) {\n                reject(value);\n              });\n            };\n            Promise.race = function (values) {\n              return new Promise(function (resolve, reject) {\n                for (var i = 0, len = values.length; i < len; i++) {\n                  values[i].then(resolve, reject);\n                }\n              });\n            };\n            Promise._immediateFn = typeof setImmediate === 'function' ? function (fn) {\n              setImmediate(fn);\n            } : function (fn) {\n              setTimeoutFunc(fn, 0);\n            };\n            Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) {\n              if (typeof console !== 'undefined' && console) {\n                console.warn('Possible Unhandled Promise Rejection:', err);\n              }\n            };\n            Promise._setImmediateFn = function _setImmediateFn(fn) {\n              Promise._immediateFn = fn;\n            };\n            Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) {\n              Promise._unhandledRejectionFn = fn;\n            };\n            if (module.exports) {\n              module.exports = Promise;\n            } else if (!root.Promise) {\n              root.Promise = Promise;\n            }\n          }(commonjsGlobal));\n        }(promise));\n        var promisePolyfill = promise.exports;\n        var Global = function () {\n          if (typeof window !== 'undefined') {\n            return window;\n          } else {\n            return Function('return this;')();\n          }\n        }();\n        var promisePolyfill_1 = { boltExport: Global.Promise || promisePolyfill };\n        return promisePolyfill_1;\n      }));\n    }(undefined, exports$1, module$1));\n    var Promise$1 = module$1.exports.boltExport;\n\n    var nu$1 = function (baseFn) {\n      var data = Optional.none();\n      var callbacks = [];\n      var map = function (f) {\n        return nu$1(function (nCallback) {\n          get(function (data) {\n            nCallback(f(data));\n          });\n        });\n      };\n      var get = function (nCallback) {\n        if (isReady()) {\n          call(nCallback);\n        } else {\n          callbacks.push(nCallback);\n        }\n      };\n      var set = function (x) {\n        if (!isReady()) {\n          data = Optional.some(x);\n          run(callbacks);\n          callbacks = [];\n        }\n      };\n      var isReady = function () {\n        return data.isSome();\n      };\n      var run = function (cbs) {\n        each$k(cbs, call);\n      };\n      var call = function (cb) {\n        data.each(function (x) {\n          setTimeout(function () {\n            cb(x);\n          }, 0);\n        });\n      };\n      baseFn(set);\n      return {\n        get: get,\n        map: map,\n        isReady: isReady\n      };\n    };\n    var pure$1 = function (a) {\n      return nu$1(function (callback) {\n        callback(a);\n      });\n    };\n    var LazyValue = {\n      nu: nu$1,\n      pure: pure$1\n    };\n\n    var errorReporter = function (err) {\n      setTimeout(function () {\n        throw err;\n      }, 0);\n    };\n    var make = function (run) {\n      var get = function (callback) {\n        run().then(callback, errorReporter);\n      };\n      var map = function (fab) {\n        return make(function () {\n          return run().then(fab);\n        });\n      };\n      var bind = function (aFutureB) {\n        return make(function () {\n          return run().then(function (v) {\n            return aFutureB(v).toPromise();\n          });\n        });\n      };\n      var anonBind = function (futureB) {\n        return make(function () {\n          return run().then(function () {\n            return futureB.toPromise();\n          });\n        });\n      };\n      var toLazy = function () {\n        return LazyValue.nu(get);\n      };\n      var toCached = function () {\n        var cache = null;\n        return make(function () {\n          if (cache === null) {\n            cache = run();\n          }\n          return cache;\n        });\n      };\n      var toPromise = run;\n      return {\n        map: map,\n        bind: bind,\n        anonBind: anonBind,\n        toLazy: toLazy,\n        toCached: toCached,\n        toPromise: toPromise,\n        get: get\n      };\n    };\n    var nu = function (baseFn) {\n      return make(function () {\n        return new Promise$1(baseFn);\n      });\n    };\n    var pure = function (a) {\n      return make(function () {\n        return Promise$1.resolve(a);\n      });\n    };\n    var Future = {\n      nu: nu,\n      pure: pure\n    };\n\n    var par$1 = function (asyncValues, nu) {\n      return nu(function (callback) {\n        var r = [];\n        var count = 0;\n        var cb = function (i) {\n          return function (value) {\n            r[i] = value;\n            count++;\n            if (count >= asyncValues.length) {\n              callback(r);\n            }\n          };\n        };\n        if (asyncValues.length === 0) {\n          callback([]);\n        } else {\n          each$k(asyncValues, function (asyncValue, i) {\n            asyncValue.get(cb(i));\n          });\n        }\n      });\n    };\n\n    var par = function (futures) {\n      return par$1(futures, Future.nu);\n    };\n\n    var value$1 = function (o) {\n      var or = function (_opt) {\n        return value$1(o);\n      };\n      var orThunk = function (_f) {\n        return value$1(o);\n      };\n      var map = function (f) {\n        return value$1(f(o));\n      };\n      var mapError = function (_f) {\n        return value$1(o);\n      };\n      var each = function (f) {\n        f(o);\n      };\n      var bind = function (f) {\n        return f(o);\n      };\n      var fold = function (_, onValue) {\n        return onValue(o);\n      };\n      var exists = function (f) {\n        return f(o);\n      };\n      var forall = function (f) {\n        return f(o);\n      };\n      var toOptional = function () {\n        return Optional.some(o);\n      };\n      return {\n        isValue: always,\n        isError: never,\n        getOr: constant(o),\n        getOrThunk: constant(o),\n        getOrDie: constant(o),\n        or: or,\n        orThunk: orThunk,\n        fold: fold,\n        map: map,\n        mapError: mapError,\n        each: each,\n        bind: bind,\n        exists: exists,\n        forall: forall,\n        toOptional: toOptional\n      };\n    };\n    var error = function (message) {\n      var getOrThunk = function (f) {\n        return f();\n      };\n      var getOrDie = function () {\n        return die(String(message))();\n      };\n      var or = identity;\n      var orThunk = function (f) {\n        return f();\n      };\n      var map = function (_f) {\n        return error(message);\n      };\n      var mapError = function (f) {\n        return error(f(message));\n      };\n      var bind = function (_f) {\n        return error(message);\n      };\n      var fold = function (onError, _) {\n        return onError(message);\n      };\n      return {\n        isValue: never,\n        isError: always,\n        getOr: identity,\n        getOrThunk: getOrThunk,\n        getOrDie: getOrDie,\n        or: or,\n        orThunk: orThunk,\n        fold: fold,\n        map: map,\n        mapError: mapError,\n        each: noop,\n        bind: bind,\n        exists: never,\n        forall: always,\n        toOptional: Optional.none\n      };\n    };\n    var fromOption = function (opt, err) {\n      return opt.fold(function () {\n        return error(err);\n      }, value$1);\n    };\n    var Result = {\n      value: value$1,\n      error: error,\n      fromOption: fromOption\n    };\n\n    var generate$1 = function (cases) {\n      if (!isArray$1(cases)) {\n        throw new Error('cases must be an array');\n      }\n      if (cases.length === 0) {\n        throw new Error('there must be at least one case');\n      }\n      var constructors = [];\n      var adt = {};\n      each$k(cases, function (acase, count) {\n        var keys$1 = keys(acase);\n        if (keys$1.length !== 1) {\n          throw new Error('one and only one name per case');\n        }\n        var key = keys$1[0];\n        var value = acase[key];\n        if (adt[key] !== undefined) {\n          throw new Error('duplicate key detected:' + key);\n        } else if (key === 'cata') {\n          throw new Error('cannot have a case named cata (sorry)');\n        } else if (!isArray$1(value)) {\n          throw new Error('case arguments must be an array');\n        }\n        constructors.push(key);\n        adt[key] = function () {\n          var args = [];\n          for (var _i = 0; _i < arguments.length; _i++) {\n            args[_i] = arguments[_i];\n          }\n          var argLength = args.length;\n          if (argLength !== value.length) {\n            throw new Error('Wrong number of arguments to case ' + key + '. Expected ' + value.length + ' (' + value + '), got ' + argLength);\n          }\n          var match = function (branches) {\n            var branchKeys = keys(branches);\n            if (constructors.length !== branchKeys.length) {\n              throw new Error('Wrong number of arguments to match. Expected: ' + constructors.join(',') + '\\nActual: ' + branchKeys.join(','));\n            }\n            var allReqd = forall(constructors, function (reqKey) {\n              return contains$3(branchKeys, reqKey);\n            });\n            if (!allReqd) {\n              throw new Error('Not all branches were specified when using match. Specified: ' + branchKeys.join(', ') + '\\nRequired: ' + constructors.join(', '));\n            }\n            return branches[key].apply(null, args);\n          };\n          return {\n            fold: function () {\n              var foldArgs = [];\n              for (var _i = 0; _i < arguments.length; _i++) {\n                foldArgs[_i] = arguments[_i];\n              }\n              if (foldArgs.length !== cases.length) {\n                throw new Error('Wrong number of arguments to fold. Expected ' + cases.length + ', got ' + foldArgs.length);\n              }\n              var target = foldArgs[count];\n              return target.apply(null, args);\n            },\n            match: match,\n            log: function (label) {\n              console.log(label, {\n                constructors: constructors,\n                constructor: key,\n                params: args\n              });\n            }\n          };\n        };\n      });\n      return adt;\n    };\n    var Adt = { generate: generate$1 };\n\n    Adt.generate([\n      {\n        bothErrors: [\n          'error1',\n          'error2'\n        ]\n      },\n      {\n        firstError: [\n          'error1',\n          'value2'\n        ]\n      },\n      {\n        secondError: [\n          'value1',\n          'error2'\n        ]\n      },\n      {\n        bothValues: [\n          'value1',\n          'value2'\n        ]\n      }\n    ]);\n    var unite = function (result) {\n      return result.fold(identity, identity);\n    };\n\n    function ClosestOrAncestor (is, ancestor, scope, a, isRoot) {\n      if (is(scope, a)) {\n        return Optional.some(scope);\n      } else if (isFunction(isRoot) && isRoot(scope)) {\n        return Optional.none();\n      } else {\n        return ancestor(scope, a, isRoot);\n      }\n    }\n\n    var ancestor$3 = function (scope, predicate, isRoot) {\n      var element = scope.dom;\n      var stop = isFunction(isRoot) ? isRoot : never;\n      while (element.parentNode) {\n        element = element.parentNode;\n        var el = SugarElement.fromDom(element);\n        if (predicate(el)) {\n          return Optional.some(el);\n        } else if (stop(el)) {\n          break;\n        }\n      }\n      return Optional.none();\n    };\n    var closest$3 = function (scope, predicate, isRoot) {\n      var is = function (s, test) {\n        return test(s);\n      };\n      return ClosestOrAncestor(is, ancestor$3, scope, predicate, isRoot);\n    };\n    var sibling$2 = function (scope, predicate) {\n      var element = scope.dom;\n      if (!element.parentNode) {\n        return Optional.none();\n      }\n      return child(SugarElement.fromDom(element.parentNode), function (x) {\n        return !eq(scope, x) && predicate(x);\n      });\n    };\n    var child = function (scope, predicate) {\n      var pred = function (node) {\n        return predicate(SugarElement.fromDom(node));\n      };\n      var result = find$3(scope.dom.childNodes, pred);\n      return result.map(SugarElement.fromDom);\n    };\n\n    var ancestor$2 = function (scope, selector, isRoot) {\n      return ancestor$3(scope, function (e) {\n        return is$2(e, selector);\n      }, isRoot);\n    };\n    var descendant = function (scope, selector) {\n      return one(selector, scope);\n    };\n    var closest$2 = function (scope, selector, isRoot) {\n      var is = function (element, selector) {\n        return is$2(element, selector);\n      };\n      return ClosestOrAncestor(is, ancestor$2, scope, selector, isRoot);\n    };\n\n    var promiseObj = window.Promise ? window.Promise : Promise$1;\n\n    var requestAnimationFramePromise;\n    var requestAnimationFrame = function (callback, element) {\n      var requestAnimationFrameFunc = window.requestAnimationFrame;\n      var vendors = [\n        'ms',\n        'moz',\n        'webkit'\n      ];\n      var featurefill = function (cb) {\n        window.setTimeout(cb, 0);\n      };\n      for (var i = 0; i < vendors.length && !requestAnimationFrameFunc; i++) {\n        requestAnimationFrameFunc = window[vendors[i] + 'RequestAnimationFrame'];\n      }\n      if (!requestAnimationFrameFunc) {\n        requestAnimationFrameFunc = featurefill;\n      }\n      requestAnimationFrameFunc(callback, element);\n    };\n    var wrappedSetTimeout = function (callback, time) {\n      if (typeof time !== 'number') {\n        time = 0;\n      }\n      return setTimeout(callback, time);\n    };\n    var wrappedSetInterval = function (callback, time) {\n      if (typeof time !== 'number') {\n        time = 1;\n      }\n      return setInterval(callback, time);\n    };\n    var wrappedClearTimeout = function (id) {\n      return clearTimeout(id);\n    };\n    var wrappedClearInterval = function (id) {\n      return clearInterval(id);\n    };\n    var debounce = function (callback, time) {\n      var timer;\n      var func = function () {\n        var args = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n          args[_i] = arguments[_i];\n        }\n        clearTimeout(timer);\n        timer = wrappedSetTimeout(function () {\n          callback.apply(this, args);\n        }, time);\n      };\n      func.stop = function () {\n        clearTimeout(timer);\n      };\n      return func;\n    };\n    var Delay = {\n      requestAnimationFrame: function (callback, element) {\n        if (requestAnimationFramePromise) {\n          requestAnimationFramePromise.then(callback);\n          return;\n        }\n        requestAnimationFramePromise = new promiseObj(function (resolve) {\n          if (!element) {\n            element = document.body;\n          }\n          requestAnimationFrame(resolve, element);\n        }).then(callback);\n      },\n      setTimeout: wrappedSetTimeout,\n      setInterval: wrappedSetInterval,\n      setEditorTimeout: function (editor, callback, time) {\n        return wrappedSetTimeout(function () {\n          if (!editor.removed) {\n            callback();\n          }\n        }, time);\n      },\n      setEditorInterval: function (editor, callback, time) {\n        var timer = wrappedSetInterval(function () {\n          if (!editor.removed) {\n            callback();\n          } else {\n            clearInterval(timer);\n          }\n        }, time);\n        return timer;\n      },\n      debounce: debounce,\n      throttle: debounce,\n      clearInterval: wrappedClearInterval,\n      clearTimeout: wrappedClearTimeout\n    };\n\n    var StyleSheetLoader = function (documentOrShadowRoot, settings) {\n      if (settings === void 0) {\n        settings = {};\n      }\n      var idCount = 0;\n      var loadedStates = {};\n      var edos = SugarElement.fromDom(documentOrShadowRoot);\n      var doc = documentOrOwner(edos);\n      var maxLoadTime = settings.maxLoadTime || 5000;\n      var _setReferrerPolicy = function (referrerPolicy) {\n        settings.referrerPolicy = referrerPolicy;\n      };\n      var addStyle = function (element) {\n        append$1(getStyleContainer(edos), element);\n      };\n      var removeStyle = function (id) {\n        var styleContainer = getStyleContainer(edos);\n        descendant(styleContainer, '#' + id).each(remove$7);\n      };\n      var getOrCreateState = function (url) {\n        return get$9(loadedStates, url).getOrThunk(function () {\n          return {\n            id: 'mce-u' + idCount++,\n            passed: [],\n            failed: [],\n            count: 0\n          };\n        });\n      };\n      var load = function (url, success, failure) {\n        var link;\n        var urlWithSuffix = Tools._addCacheSuffix(url);\n        var state = getOrCreateState(urlWithSuffix);\n        loadedStates[urlWithSuffix] = state;\n        state.count++;\n        var resolve = function (callbacks, status) {\n          var i = callbacks.length;\n          while (i--) {\n            callbacks[i]();\n          }\n          state.status = status;\n          state.passed = [];\n          state.failed = [];\n          if (link) {\n            link.onload = null;\n            link.onerror = null;\n            link = null;\n          }\n        };\n        var passed = function () {\n          return resolve(state.passed, 2);\n        };\n        var failed = function () {\n          return resolve(state.failed, 3);\n        };\n        var wait = function (testCallback, waitCallback) {\n          if (!testCallback()) {\n            if (Date.now() - startTime < maxLoadTime) {\n              Delay.setTimeout(waitCallback);\n            } else {\n              failed();\n            }\n          }\n        };\n        var waitForWebKitLinkLoaded = function () {\n          wait(function () {\n            var styleSheets = documentOrShadowRoot.styleSheets;\n            var i = styleSheets.length;\n            while (i--) {\n              var styleSheet = styleSheets[i];\n              var owner = styleSheet.ownerNode;\n              if (owner && owner.id === link.id) {\n                passed();\n                return true;\n              }\n            }\n            return false;\n          }, waitForWebKitLinkLoaded);\n        };\n        if (success) {\n          state.passed.push(success);\n        }\n        if (failure) {\n          state.failed.push(failure);\n        }\n        if (state.status === 1) {\n          return;\n        }\n        if (state.status === 2) {\n          passed();\n          return;\n        }\n        if (state.status === 3) {\n          failed();\n          return;\n        }\n        state.status = 1;\n        var linkElem = SugarElement.fromTag('link', doc.dom);\n        setAll$1(linkElem, {\n          rel: 'stylesheet',\n          type: 'text/css',\n          id: state.id\n        });\n        var startTime = Date.now();\n        if (settings.contentCssCors) {\n          set$1(linkElem, 'crossOrigin', 'anonymous');\n        }\n        if (settings.referrerPolicy) {\n          set$1(linkElem, 'referrerpolicy', settings.referrerPolicy);\n        }\n        link = linkElem.dom;\n        link.onload = waitForWebKitLinkLoaded;\n        link.onerror = failed;\n        addStyle(linkElem);\n        set$1(linkElem, 'href', urlWithSuffix);\n      };\n      var loadF = function (url) {\n        return Future.nu(function (resolve) {\n          load(url, compose(resolve, constant(Result.value(url))), compose(resolve, constant(Result.error(url))));\n        });\n      };\n      var loadAll = function (urls, success, failure) {\n        par(map$3(urls, loadF)).get(function (result) {\n          var parts = partition(result, function (r) {\n            return r.isValue();\n          });\n          if (parts.fail.length > 0) {\n            failure(parts.fail.map(unite));\n          } else {\n            success(parts.pass.map(unite));\n          }\n        });\n      };\n      var unload = function (url) {\n        var urlWithSuffix = Tools._addCacheSuffix(url);\n        get$9(loadedStates, urlWithSuffix).each(function (state) {\n          var count = --state.count;\n          if (count === 0) {\n            delete loadedStates[urlWithSuffix];\n            removeStyle(state.id);\n          }\n        });\n      };\n      var unloadAll = function (urls) {\n        each$k(urls, function (url) {\n          unload(url);\n        });\n      };\n      return {\n        load: load,\n        loadAll: loadAll,\n        unload: unload,\n        unloadAll: unloadAll,\n        _setReferrerPolicy: _setReferrerPolicy\n      };\n    };\n\n    var create$8 = function () {\n      var map = new WeakMap();\n      var forElement = function (referenceElement, settings) {\n        var root = getRootNode(referenceElement);\n        var rootDom = root.dom;\n        return Optional.from(map.get(rootDom)).getOrThunk(function () {\n          var sl = StyleSheetLoader(rootDom, settings);\n          map.set(rootDom, sl);\n          return sl;\n        });\n      };\n      return { forElement: forElement };\n    };\n    var instance = create$8();\n\n    var DomTreeWalker = function () {\n      function DomTreeWalker(startNode, rootNode) {\n        this.node = startNode;\n        this.rootNode = rootNode;\n        this.current = this.current.bind(this);\n        this.next = this.next.bind(this);\n        this.prev = this.prev.bind(this);\n        this.prev2 = this.prev2.bind(this);\n      }\n      DomTreeWalker.prototype.current = function () {\n        return this.node;\n      };\n      DomTreeWalker.prototype.next = function (shallow) {\n        this.node = this.findSibling(this.node, 'firstChild', 'nextSibling', shallow);\n        return this.node;\n      };\n      DomTreeWalker.prototype.prev = function (shallow) {\n        this.node = this.findSibling(this.node, 'lastChild', 'previousSibling', shallow);\n        return this.node;\n      };\n      DomTreeWalker.prototype.prev2 = function (shallow) {\n        this.node = this.findPreviousNode(this.node, 'lastChild', 'previousSibling', shallow);\n        return this.node;\n      };\n      DomTreeWalker.prototype.findSibling = function (node, startName, siblingName, shallow) {\n        var sibling, parent;\n        if (node) {\n          if (!shallow && node[startName]) {\n            return node[startName];\n          }\n          if (node !== this.rootNode) {\n            sibling = node[siblingName];\n            if (sibling) {\n              return sibling;\n            }\n            for (parent = node.parentNode; parent && parent !== this.rootNode; parent = parent.parentNode) {\n              sibling = parent[siblingName];\n              if (sibling) {\n                return sibling;\n              }\n            }\n          }\n        }\n      };\n      DomTreeWalker.prototype.findPreviousNode = function (node, startName, siblingName, shallow) {\n        var sibling, parent, child;\n        if (node) {\n          sibling = node[siblingName];\n          if (this.rootNode && sibling === this.rootNode) {\n            return;\n          }\n          if (sibling) {\n            if (!shallow) {\n              for (child = sibling[startName]; child; child = child[startName]) {\n                if (!child[startName]) {\n                  return child;\n                }\n              }\n            }\n            return sibling;\n          }\n          parent = node.parentNode;\n          if (parent && parent !== this.rootNode) {\n            return parent;\n          }\n        }\n      };\n      return DomTreeWalker;\n    }();\n\n    var blocks = [\n      'article',\n      'aside',\n      'details',\n      'div',\n      'dt',\n      'figcaption',\n      'footer',\n      'form',\n      'fieldset',\n      'header',\n      'hgroup',\n      'html',\n      'main',\n      'nav',\n      'section',\n      'summary',\n      'body',\n      'p',\n      'dl',\n      'multicol',\n      'dd',\n      'figure',\n      'address',\n      'center',\n      'blockquote',\n      'h1',\n      'h2',\n      'h3',\n      'h4',\n      'h5',\n      'h6',\n      'listing',\n      'xmp',\n      'pre',\n      'plaintext',\n      'menu',\n      'dir',\n      'ul',\n      'ol',\n      'li',\n      'hr',\n      'table',\n      'tbody',\n      'thead',\n      'tfoot',\n      'th',\n      'tr',\n      'td',\n      'caption'\n    ];\n    var tableCells = [\n      'td',\n      'th'\n    ];\n    var tableSections = [\n      'thead',\n      'tbody',\n      'tfoot'\n    ];\n    var textBlocks = [\n      'h1',\n      'h2',\n      'h3',\n      'h4',\n      'h5',\n      'h6',\n      'p',\n      'div',\n      'address',\n      'pre',\n      'form',\n      'blockquote',\n      'center',\n      'dir',\n      'fieldset',\n      'header',\n      'footer',\n      'article',\n      'section',\n      'hgroup',\n      'aside',\n      'nav',\n      'figure'\n    ];\n    var headings = [\n      'h1',\n      'h2',\n      'h3',\n      'h4',\n      'h5',\n      'h6'\n    ];\n    var listItems$1 = [\n      'li',\n      'dd',\n      'dt'\n    ];\n    var lists = [\n      'ul',\n      'ol',\n      'dl'\n    ];\n    var wsElements = [\n      'pre',\n      'script',\n      'textarea',\n      'style'\n    ];\n    var lazyLookup = function (items) {\n      var lookup;\n      return function (node) {\n        lookup = lookup ? lookup : mapToObject(items, always);\n        return has$2(lookup, name(node));\n      };\n    };\n    var isHeading = lazyLookup(headings);\n    var isBlock$2 = lazyLookup(blocks);\n    var isTable$2 = function (node) {\n      return name(node) === 'table';\n    };\n    var isInline$1 = function (node) {\n      return isElement$6(node) && !isBlock$2(node);\n    };\n    var isBr$4 = function (node) {\n      return isElement$6(node) && name(node) === 'br';\n    };\n    var isTextBlock$2 = lazyLookup(textBlocks);\n    var isList = lazyLookup(lists);\n    var isListItem = lazyLookup(listItems$1);\n    var isTableSection = lazyLookup(tableSections);\n    var isTableCell$4 = lazyLookup(tableCells);\n    var isWsPreserveElement = lazyLookup(wsElements);\n\n    var ancestor$1 = function (scope, selector, isRoot) {\n      return ancestor$2(scope, selector, isRoot).isSome();\n    };\n\n    var zeroWidth = '\\uFEFF';\n    var nbsp = '\\xA0';\n    var isZwsp$1 = function (char) {\n      return char === zeroWidth;\n    };\n    var removeZwsp = function (s) {\n      return s.replace(/\\uFEFF/g, '');\n    };\n\n    var ZWSP$1 = zeroWidth;\n    var isZwsp = isZwsp$1;\n    var trim$3 = removeZwsp;\n\n    var isElement$4 = isElement$5;\n    var isText$6 = isText$7;\n    var isCaretContainerBlock$1 = function (node) {\n      if (isText$6(node)) {\n        node = node.parentNode;\n      }\n      return isElement$4(node) && node.hasAttribute('data-mce-caret');\n    };\n    var isCaretContainerInline = function (node) {\n      return isText$6(node) && isZwsp(node.data);\n    };\n    var isCaretContainer$2 = function (node) {\n      return isCaretContainerBlock$1(node) || isCaretContainerInline(node);\n    };\n    var hasContent = function (node) {\n      return node.firstChild !== node.lastChild || !isBr$5(node.firstChild);\n    };\n    var insertInline$1 = function (node, before) {\n      var doc = node.ownerDocument;\n      var textNode = doc.createTextNode(ZWSP$1);\n      var parentNode = node.parentNode;\n      if (!before) {\n        var sibling = node.nextSibling;\n        if (isText$6(sibling)) {\n          if (isCaretContainer$2(sibling)) {\n            return sibling;\n          }\n          if (startsWithCaretContainer$1(sibling)) {\n            sibling.splitText(1);\n            return sibling;\n          }\n        }\n        if (node.nextSibling) {\n          parentNode.insertBefore(textNode, node.nextSibling);\n        } else {\n          parentNode.appendChild(textNode);\n        }\n      } else {\n        var sibling = node.previousSibling;\n        if (isText$6(sibling)) {\n          if (isCaretContainer$2(sibling)) {\n            return sibling;\n          }\n          if (endsWithCaretContainer$1(sibling)) {\n            return sibling.splitText(sibling.data.length - 1);\n          }\n        }\n        parentNode.insertBefore(textNode, node);\n      }\n      return textNode;\n    };\n    var isBeforeInline = function (pos) {\n      var container = pos.container();\n      if (!isText$7(container)) {\n        return false;\n      }\n      return container.data.charAt(pos.offset()) === ZWSP$1 || pos.isAtStart() && isCaretContainerInline(container.previousSibling);\n    };\n    var isAfterInline = function (pos) {\n      var container = pos.container();\n      if (!isText$7(container)) {\n        return false;\n      }\n      return container.data.charAt(pos.offset() - 1) === ZWSP$1 || pos.isAtEnd() && isCaretContainerInline(container.nextSibling);\n    };\n    var createBogusBr = function () {\n      var br = document.createElement('br');\n      br.setAttribute('data-mce-bogus', '1');\n      return br;\n    };\n    var insertBlock$1 = function (blockName, node, before) {\n      var doc = node.ownerDocument;\n      var blockNode = doc.createElement(blockName);\n      blockNode.setAttribute('data-mce-caret', before ? 'before' : 'after');\n      blockNode.setAttribute('data-mce-bogus', 'all');\n      blockNode.appendChild(createBogusBr());\n      var parentNode = node.parentNode;\n      if (!before) {\n        if (node.nextSibling) {\n          parentNode.insertBefore(blockNode, node.nextSibling);\n        } else {\n          parentNode.appendChild(blockNode);\n        }\n      } else {\n        parentNode.insertBefore(blockNode, node);\n      }\n      return blockNode;\n    };\n    var startsWithCaretContainer$1 = function (node) {\n      return isText$6(node) && node.data[0] === ZWSP$1;\n    };\n    var endsWithCaretContainer$1 = function (node) {\n      return isText$6(node) && node.data[node.data.length - 1] === ZWSP$1;\n    };\n    var trimBogusBr = function (elm) {\n      var brs = elm.getElementsByTagName('br');\n      var lastBr = brs[brs.length - 1];\n      if (isBogus$2(lastBr)) {\n        lastBr.parentNode.removeChild(lastBr);\n      }\n    };\n    var showCaretContainerBlock = function (caretContainer) {\n      if (caretContainer && caretContainer.hasAttribute('data-mce-caret')) {\n        trimBogusBr(caretContainer);\n        caretContainer.removeAttribute('data-mce-caret');\n        caretContainer.removeAttribute('data-mce-bogus');\n        caretContainer.removeAttribute('style');\n        caretContainer.removeAttribute('_moz_abspos');\n        return caretContainer;\n      }\n      return null;\n    };\n    var isRangeInCaretContainerBlock = function (range) {\n      return isCaretContainerBlock$1(range.startContainer);\n    };\n\n    var isContentEditableTrue$3 = isContentEditableTrue$4;\n    var isContentEditableFalse$a = isContentEditableFalse$b;\n    var isBr$3 = isBr$5;\n    var isText$5 = isText$7;\n    var isInvalidTextElement = matchNodeNames([\n      'script',\n      'style',\n      'textarea'\n    ]);\n    var isAtomicInline = matchNodeNames([\n      'img',\n      'input',\n      'textarea',\n      'hr',\n      'iframe',\n      'video',\n      'audio',\n      'object',\n      'embed'\n    ]);\n    var isTable$1 = matchNodeNames(['table']);\n    var isCaretContainer$1 = isCaretContainer$2;\n    var isCaretCandidate$3 = function (node) {\n      if (isCaretContainer$1(node)) {\n        return false;\n      }\n      if (isText$5(node)) {\n        return !isInvalidTextElement(node.parentNode);\n      }\n      return isAtomicInline(node) || isBr$3(node) || isTable$1(node) || isNonUiContentEditableFalse(node);\n    };\n    var isUnselectable = function (node) {\n      return isElement$5(node) && node.getAttribute('unselectable') === 'true';\n    };\n    var isNonUiContentEditableFalse = function (node) {\n      return isUnselectable(node) === false && isContentEditableFalse$a(node);\n    };\n    var isInEditable = function (node, root) {\n      for (node = node.parentNode; node && node !== root; node = node.parentNode) {\n        if (isNonUiContentEditableFalse(node)) {\n          return false;\n        }\n        if (isContentEditableTrue$3(node)) {\n          return true;\n        }\n      }\n      return true;\n    };\n    var isAtomicContentEditableFalse = function (node) {\n      if (!isNonUiContentEditableFalse(node)) {\n        return false;\n      }\n      return foldl(from(node.getElementsByTagName('*')), function (result, elm) {\n        return result || isContentEditableTrue$3(elm);\n      }, false) !== true;\n    };\n    var isAtomic$1 = function (node) {\n      return isAtomicInline(node) || isAtomicContentEditableFalse(node);\n    };\n    var isEditableCaretCandidate$1 = function (node, root) {\n      return isCaretCandidate$3(node) && isInEditable(node, root);\n    };\n\n    var whiteSpaceRegExp$1 = /^[ \\t\\r\\n]*$/;\n    var isWhitespaceText = function (text) {\n      return whiteSpaceRegExp$1.test(text);\n    };\n\n    var hasWhitespacePreserveParent = function (node, rootNode) {\n      var rootElement = SugarElement.fromDom(rootNode);\n      var startNode = SugarElement.fromDom(node);\n      return ancestor$1(startNode, 'pre,code', curry(eq, rootElement));\n    };\n    var isWhitespace = function (node, rootNode) {\n      return isText$7(node) && isWhitespaceText(node.data) && hasWhitespacePreserveParent(node, rootNode) === false;\n    };\n    var isNamedAnchor = function (node) {\n      return isElement$5(node) && node.nodeName === 'A' && !node.hasAttribute('href') && (node.hasAttribute('name') || node.hasAttribute('id'));\n    };\n    var isContent$1 = function (node, rootNode) {\n      return isCaretCandidate$3(node) && isWhitespace(node, rootNode) === false || isNamedAnchor(node) || isBookmark(node);\n    };\n    var isBookmark = hasAttribute('data-mce-bookmark');\n    var isBogus$1 = hasAttribute('data-mce-bogus');\n    var isBogusAll = hasAttributeValue('data-mce-bogus', 'all');\n    var isEmptyNode = function (targetNode, skipBogus) {\n      var brCount = 0;\n      if (isContent$1(targetNode, targetNode)) {\n        return false;\n      } else {\n        var node = targetNode.firstChild;\n        if (!node) {\n          return true;\n        }\n        var walker = new DomTreeWalker(node, targetNode);\n        do {\n          if (skipBogus) {\n            if (isBogusAll(node)) {\n              node = walker.next(true);\n              continue;\n            }\n            if (isBogus$1(node)) {\n              node = walker.next();\n              continue;\n            }\n          }\n          if (isBr$5(node)) {\n            brCount++;\n            node = walker.next();\n            continue;\n          }\n          if (isContent$1(node, targetNode)) {\n            return false;\n          }\n          node = walker.next();\n        } while (node);\n        return brCount <= 1;\n      }\n    };\n    var isEmpty$2 = function (elm, skipBogus) {\n      if (skipBogus === void 0) {\n        skipBogus = true;\n      }\n      return isEmptyNode(elm.dom, skipBogus);\n    };\n\n    var isSpan = function (node) {\n      return node.nodeName.toLowerCase() === 'span';\n    };\n    var isInlineContent = function (node, root) {\n      return isNonNullable(node) && (isContent$1(node, root) || isInline$1(SugarElement.fromDom(node)));\n    };\n    var surroundedByInlineContent = function (node, root) {\n      var prev = new DomTreeWalker(node, root).prev(false);\n      var next = new DomTreeWalker(node, root).next(false);\n      var prevIsInline = isUndefined(prev) || isInlineContent(prev, root);\n      var nextIsInline = isUndefined(next) || isInlineContent(next, root);\n      return prevIsInline && nextIsInline;\n    };\n    var isBookmarkNode$2 = function (node) {\n      return isSpan(node) && node.getAttribute('data-mce-type') === 'bookmark';\n    };\n    var isKeepTextNode = function (node, root) {\n      return isText$7(node) && node.data.length > 0 && surroundedByInlineContent(node, root);\n    };\n    var isKeepElement = function (node) {\n      return isElement$5(node) ? node.childNodes.length > 0 : false;\n    };\n    var isDocument = function (node) {\n      return isDocumentFragment(node) || isDocument$1(node);\n    };\n    var trimNode = function (dom, node, root) {\n      var rootNode = root || node;\n      if (isElement$5(node) && isBookmarkNode$2(node)) {\n        return node;\n      }\n      var children = node.childNodes;\n      for (var i = children.length - 1; i >= 0; i--) {\n        trimNode(dom, children[i], rootNode);\n      }\n      if (isElement$5(node)) {\n        var currentChildren = node.childNodes;\n        if (currentChildren.length === 1 && isBookmarkNode$2(currentChildren[0])) {\n          node.parentNode.insertBefore(currentChildren[0], node);\n        }\n      }\n      if (!isDocument(node) && !isContent$1(node, rootNode) && !isKeepElement(node) && !isKeepTextNode(node, rootNode)) {\n        dom.remove(node);\n      }\n      return node;\n    };\n\n    var makeMap$3 = Tools.makeMap;\n    var attrsCharsRegExp = /[&<>\\\"\\u0060\\u007E-\\uD7FF\\uE000-\\uFFEF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g;\n    var textCharsRegExp = /[<>&\\u007E-\\uD7FF\\uE000-\\uFFEF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g;\n    var rawCharsRegExp = /[<>&\\\"\\']/g;\n    var entityRegExp = /&#([a-z0-9]+);?|&([a-z0-9]+);/gi;\n    var asciiMap = {\n      128: '\\u20AC',\n      130: '\\u201A',\n      131: '\\u0192',\n      132: '\\u201E',\n      133: '\\u2026',\n      134: '\\u2020',\n      135: '\\u2021',\n      136: '\\u02c6',\n      137: '\\u2030',\n      138: '\\u0160',\n      139: '\\u2039',\n      140: '\\u0152',\n      142: '\\u017d',\n      145: '\\u2018',\n      146: '\\u2019',\n      147: '\\u201C',\n      148: '\\u201D',\n      149: '\\u2022',\n      150: '\\u2013',\n      151: '\\u2014',\n      152: '\\u02DC',\n      153: '\\u2122',\n      154: '\\u0161',\n      155: '\\u203A',\n      156: '\\u0153',\n      158: '\\u017e',\n      159: '\\u0178'\n    };\n    var baseEntities = {\n      '\"': '&quot;',\n      '\\'': '&#39;',\n      '<': '&lt;',\n      '>': '&gt;',\n      '&': '&amp;',\n      '`': '&#96;'\n    };\n    var reverseEntities = {\n      '&lt;': '<',\n      '&gt;': '>',\n      '&amp;': '&',\n      '&quot;': '\"',\n      '&apos;': '\\''\n    };\n    var nativeDecode = function (text) {\n      var elm = SugarElement.fromTag('div').dom;\n      elm.innerHTML = text;\n      return elm.textContent || elm.innerText || text;\n    };\n    var buildEntitiesLookup = function (items, radix) {\n      var i, chr, entity;\n      var lookup = {};\n      if (items) {\n        items = items.split(',');\n        radix = radix || 10;\n        for (i = 0; i < items.length; i += 2) {\n          chr = String.fromCharCode(parseInt(items[i], radix));\n          if (!baseEntities[chr]) {\n            entity = '&' + items[i + 1] + ';';\n            lookup[chr] = entity;\n            lookup[entity] = chr;\n          }\n        }\n        return lookup;\n      }\n    };\n    var namedEntities = buildEntitiesLookup('50,nbsp,51,iexcl,52,cent,53,pound,54,curren,55,yen,56,brvbar,57,sect,58,uml,59,copy,' + '5a,ordf,5b,laquo,5c,not,5d,shy,5e,reg,5f,macr,5g,deg,5h,plusmn,5i,sup2,5j,sup3,5k,acute,' + '5l,micro,5m,para,5n,middot,5o,cedil,5p,sup1,5q,ordm,5r,raquo,5s,frac14,5t,frac12,5u,frac34,' + '5v,iquest,60,Agrave,61,Aacute,62,Acirc,63,Atilde,64,Auml,65,Aring,66,AElig,67,Ccedil,' + '68,Egrave,69,Eacute,6a,Ecirc,6b,Euml,6c,Igrave,6d,Iacute,6e,Icirc,6f,Iuml,6g,ETH,6h,Ntilde,' + '6i,Ograve,6j,Oacute,6k,Ocirc,6l,Otilde,6m,Ouml,6n,times,6o,Oslash,6p,Ugrave,6q,Uacute,' + '6r,Ucirc,6s,Uuml,6t,Yacute,6u,THORN,6v,szlig,70,agrave,71,aacute,72,acirc,73,atilde,74,auml,' + '75,aring,76,aelig,77,ccedil,78,egrave,79,eacute,7a,ecirc,7b,euml,7c,igrave,7d,iacute,7e,icirc,' + '7f,iuml,7g,eth,7h,ntilde,7i,ograve,7j,oacute,7k,ocirc,7l,otilde,7m,ouml,7n,divide,7o,oslash,' + '7p,ugrave,7q,uacute,7r,ucirc,7s,uuml,7t,yacute,7u,thorn,7v,yuml,ci,fnof,sh,Alpha,si,Beta,' + 'sj,Gamma,sk,Delta,sl,Epsilon,sm,Zeta,sn,Eta,so,Theta,sp,Iota,sq,Kappa,sr,Lambda,ss,Mu,' + 'st,Nu,su,Xi,sv,Omicron,t0,Pi,t1,Rho,t3,Sigma,t4,Tau,t5,Upsilon,t6,Phi,t7,Chi,t8,Psi,' + 't9,Omega,th,alpha,ti,beta,tj,gamma,tk,delta,tl,epsilon,tm,zeta,tn,eta,to,theta,tp,iota,' + 'tq,kappa,tr,lambda,ts,mu,tt,nu,tu,xi,tv,omicron,u0,pi,u1,rho,u2,sigmaf,u3,sigma,u4,tau,' + 'u5,upsilon,u6,phi,u7,chi,u8,psi,u9,omega,uh,thetasym,ui,upsih,um,piv,812,bull,816,hellip,' + '81i,prime,81j,Prime,81u,oline,824,frasl,88o,weierp,88h,image,88s,real,892,trade,89l,alefsym,' + '8cg,larr,8ch,uarr,8ci,rarr,8cj,darr,8ck,harr,8dl,crarr,8eg,lArr,8eh,uArr,8ei,rArr,8ej,dArr,' + '8ek,hArr,8g0,forall,8g2,part,8g3,exist,8g5,empty,8g7,nabla,8g8,isin,8g9,notin,8gb,ni,8gf,prod,' + '8gh,sum,8gi,minus,8gn,lowast,8gq,radic,8gt,prop,8gu,infin,8h0,ang,8h7,and,8h8,or,8h9,cap,8ha,cup,' + '8hb,int,8hk,there4,8hs,sim,8i5,cong,8i8,asymp,8j0,ne,8j1,equiv,8j4,le,8j5,ge,8k2,sub,8k3,sup,8k4,' + 'nsub,8k6,sube,8k7,supe,8kl,oplus,8kn,otimes,8l5,perp,8m5,sdot,8o8,lceil,8o9,rceil,8oa,lfloor,8ob,' + 'rfloor,8p9,lang,8pa,rang,9ea,loz,9j0,spades,9j3,clubs,9j5,hearts,9j6,diams,ai,OElig,aj,oelig,b0,' + 'Scaron,b1,scaron,bo,Yuml,m6,circ,ms,tilde,802,ensp,803,emsp,809,thinsp,80c,zwnj,80d,zwj,80e,lrm,' + '80f,rlm,80j,ndash,80k,mdash,80o,lsquo,80p,rsquo,80q,sbquo,80s,ldquo,80t,rdquo,80u,bdquo,810,dagger,' + '811,Dagger,81g,permil,81p,lsaquo,81q,rsaquo,85c,euro', 32);\n    var encodeRaw = function (text, attr) {\n      return text.replace(attr ? attrsCharsRegExp : textCharsRegExp, function (chr) {\n        return baseEntities[chr] || chr;\n      });\n    };\n    var encodeAllRaw = function (text) {\n      return ('' + text).replace(rawCharsRegExp, function (chr) {\n        return baseEntities[chr] || chr;\n      });\n    };\n    var encodeNumeric = function (text, attr) {\n      return text.replace(attr ? attrsCharsRegExp : textCharsRegExp, function (chr) {\n        if (chr.length > 1) {\n          return '&#' + ((chr.charCodeAt(0) - 55296) * 1024 + (chr.charCodeAt(1) - 56320) + 65536) + ';';\n        }\n        return baseEntities[chr] || '&#' + chr.charCodeAt(0) + ';';\n      });\n    };\n    var encodeNamed = function (text, attr, entities) {\n      entities = entities || namedEntities;\n      return text.replace(attr ? attrsCharsRegExp : textCharsRegExp, function (chr) {\n        return baseEntities[chr] || entities[chr] || chr;\n      });\n    };\n    var getEncodeFunc = function (name, entities) {\n      var entitiesMap = buildEntitiesLookup(entities) || namedEntities;\n      var encodeNamedAndNumeric = function (text, attr) {\n        return text.replace(attr ? attrsCharsRegExp : textCharsRegExp, function (chr) {\n          if (baseEntities[chr] !== undefined) {\n            return baseEntities[chr];\n          }\n          if (entitiesMap[chr] !== undefined) {\n            return entitiesMap[chr];\n          }\n          if (chr.length > 1) {\n            return '&#' + ((chr.charCodeAt(0) - 55296) * 1024 + (chr.charCodeAt(1) - 56320) + 65536) + ';';\n          }\n          return '&#' + chr.charCodeAt(0) + ';';\n        });\n      };\n      var encodeCustomNamed = function (text, attr) {\n        return encodeNamed(text, attr, entitiesMap);\n      };\n      var nameMap = makeMap$3(name.replace(/\\+/g, ','));\n      if (nameMap.named && nameMap.numeric) {\n        return encodeNamedAndNumeric;\n      }\n      if (nameMap.named) {\n        if (entities) {\n          return encodeCustomNamed;\n        }\n        return encodeNamed;\n      }\n      if (nameMap.numeric) {\n        return encodeNumeric;\n      }\n      return encodeRaw;\n    };\n    var decode = function (text) {\n      return text.replace(entityRegExp, function (all, numeric) {\n        if (numeric) {\n          if (numeric.charAt(0).toLowerCase() === 'x') {\n            numeric = parseInt(numeric.substr(1), 16);\n          } else {\n            numeric = parseInt(numeric, 10);\n          }\n          if (numeric > 65535) {\n            numeric -= 65536;\n            return String.fromCharCode(55296 + (numeric >> 10), 56320 + (numeric & 1023));\n          }\n          return asciiMap[numeric] || String.fromCharCode(numeric);\n        }\n        return reverseEntities[all] || namedEntities[all] || nativeDecode(all);\n      });\n    };\n    var Entities = {\n      encodeRaw: encodeRaw,\n      encodeAllRaw: encodeAllRaw,\n      encodeNumeric: encodeNumeric,\n      encodeNamed: encodeNamed,\n      getEncodeFunc: getEncodeFunc,\n      decode: decode\n    };\n\n    var mapCache = {}, dummyObj = {};\n    var makeMap$2 = Tools.makeMap, each$h = Tools.each, extend$5 = Tools.extend, explode$3 = Tools.explode, inArray$2 = Tools.inArray;\n    var split$1 = function (items, delim) {\n      items = Tools.trim(items);\n      return items ? items.split(delim || ' ') : [];\n    };\n    var createMap = function (defaultValue, extendWith) {\n      var value = makeMap$2(defaultValue, ' ', makeMap$2(defaultValue.toUpperCase(), ' '));\n      return extend$5(value, extendWith);\n    };\n    var getTextRootBlockElements = function (schema) {\n      return createMap('td th li dt dd figcaption caption details summary', schema.getTextBlockElements());\n    };\n    var compileSchema = function (type) {\n      var schema = {};\n      var globalAttributes, blockContent;\n      var phrasingContent, flowContent, html4BlockContent, html4PhrasingContent;\n      var add = function (name, attributes, children) {\n        var ni, attributesOrder, element;\n        var arrayToMap = function (array, obj) {\n          var map = {};\n          var i, l;\n          for (i = 0, l = array.length; i < l; i++) {\n            map[array[i]] = obj || {};\n          }\n          return map;\n        };\n        children = children || [];\n        attributes = attributes || '';\n        if (typeof children === 'string') {\n          children = split$1(children);\n        }\n        var names = split$1(name);\n        ni = names.length;\n        while (ni--) {\n          attributesOrder = split$1([\n            globalAttributes,\n            attributes\n          ].join(' '));\n          element = {\n            attributes: arrayToMap(attributesOrder),\n            attributesOrder: attributesOrder,\n            children: arrayToMap(children, dummyObj)\n          };\n          schema[names[ni]] = element;\n        }\n      };\n      var addAttrs = function (name, attributes) {\n        var ni, schemaItem, i, l;\n        var names = split$1(name);\n        ni = names.length;\n        var attrs = split$1(attributes);\n        while (ni--) {\n          schemaItem = schema[names[ni]];\n          for (i = 0, l = attrs.length; i < l; i++) {\n            schemaItem.attributes[attrs[i]] = {};\n            schemaItem.attributesOrder.push(attrs[i]);\n          }\n        }\n      };\n      if (mapCache[type]) {\n        return mapCache[type];\n      }\n      globalAttributes = 'id accesskey class dir lang style tabindex title role';\n      blockContent = 'address blockquote div dl fieldset form h1 h2 h3 h4 h5 h6 hr menu ol p pre table ul';\n      phrasingContent = 'a abbr b bdo br button cite code del dfn em embed i iframe img input ins kbd ' + 'label map noscript object q s samp script select small span strong sub sup ' + 'textarea u var #text #comment';\n      if (type !== 'html4') {\n        globalAttributes += ' contenteditable contextmenu draggable dropzone ' + 'hidden spellcheck translate';\n        blockContent += ' article aside details dialog figure main header footer hgroup section nav';\n        phrasingContent += ' audio canvas command datalist mark meter output picture ' + 'progress time wbr video ruby bdi keygen';\n      }\n      if (type !== 'html5-strict') {\n        globalAttributes += ' xml:lang';\n        html4PhrasingContent = 'acronym applet basefont big font strike tt';\n        phrasingContent = [\n          phrasingContent,\n          html4PhrasingContent\n        ].join(' ');\n        each$h(split$1(html4PhrasingContent), function (name) {\n          add(name, '', phrasingContent);\n        });\n        html4BlockContent = 'center dir isindex noframes';\n        blockContent = [\n          blockContent,\n          html4BlockContent\n        ].join(' ');\n        flowContent = [\n          blockContent,\n          phrasingContent\n        ].join(' ');\n        each$h(split$1(html4BlockContent), function (name) {\n          add(name, '', flowContent);\n        });\n      }\n      flowContent = flowContent || [\n        blockContent,\n        phrasingContent\n      ].join(' ');\n      add('html', 'manifest', 'head body');\n      add('head', '', 'base command link meta noscript script style title');\n      add('title hr noscript br');\n      add('base', 'href target');\n      add('link', 'href rel media hreflang type sizes hreflang');\n      add('meta', 'name http-equiv content charset');\n      add('style', 'media type scoped');\n      add('script', 'src async defer type charset');\n      add('body', 'onafterprint onbeforeprint onbeforeunload onblur onerror onfocus ' + 'onhashchange onload onmessage onoffline ononline onpagehide onpageshow ' + 'onpopstate onresize onscroll onstorage onunload', flowContent);\n      add('address dt dd div caption', '', flowContent);\n      add('h1 h2 h3 h4 h5 h6 pre p abbr code var samp kbd sub sup i b u bdo span legend em strong small s cite dfn', '', phrasingContent);\n      add('blockquote', 'cite', flowContent);\n      add('ol', 'reversed start type', 'li');\n      add('ul', '', 'li');\n      add('li', 'value', flowContent);\n      add('dl', '', 'dt dd');\n      add('a', 'href target rel media hreflang type', phrasingContent);\n      add('q', 'cite', phrasingContent);\n      add('ins del', 'cite datetime', flowContent);\n      add('img', 'src sizes srcset alt usemap ismap width height');\n      add('iframe', 'src name width height', flowContent);\n      add('embed', 'src type width height');\n      add('object', 'data type typemustmatch name usemap form width height', [\n        flowContent,\n        'param'\n      ].join(' '));\n      add('param', 'name value');\n      add('map', 'name', [\n        flowContent,\n        'area'\n      ].join(' '));\n      add('area', 'alt coords shape href target rel media hreflang type');\n      add('table', 'border', 'caption colgroup thead tfoot tbody tr' + (type === 'html4' ? ' col' : ''));\n      add('colgroup', 'span', 'col');\n      add('col', 'span');\n      add('tbody thead tfoot', '', 'tr');\n      add('tr', '', 'td th');\n      add('td', 'colspan rowspan headers', flowContent);\n      add('th', 'colspan rowspan headers scope abbr', flowContent);\n      add('form', 'accept-charset action autocomplete enctype method name novalidate target', flowContent);\n      add('fieldset', 'disabled form name', [\n        flowContent,\n        'legend'\n      ].join(' '));\n      add('label', 'form for', phrasingContent);\n      add('input', 'accept alt autocomplete checked dirname disabled form formaction formenctype formmethod formnovalidate ' + 'formtarget height list max maxlength min multiple name pattern readonly required size src step type value width');\n      add('button', 'disabled form formaction formenctype formmethod formnovalidate formtarget name type value', type === 'html4' ? flowContent : phrasingContent);\n      add('select', 'disabled form multiple name required size', 'option optgroup');\n      add('optgroup', 'disabled label', 'option');\n      add('option', 'disabled label selected value');\n      add('textarea', 'cols dirname disabled form maxlength name readonly required rows wrap');\n      add('menu', 'type label', [\n        flowContent,\n        'li'\n      ].join(' '));\n      add('noscript', '', flowContent);\n      if (type !== 'html4') {\n        add('wbr');\n        add('ruby', '', [\n          phrasingContent,\n          'rt rp'\n        ].join(' '));\n        add('figcaption', '', flowContent);\n        add('mark rt rp summary bdi', '', phrasingContent);\n        add('canvas', 'width height', flowContent);\n        add('video', 'src crossorigin poster preload autoplay mediagroup loop ' + 'muted controls width height buffered', [\n          flowContent,\n          'track source'\n        ].join(' '));\n        add('audio', 'src crossorigin preload autoplay mediagroup loop muted controls ' + 'buffered volume', [\n          flowContent,\n          'track source'\n        ].join(' '));\n        add('picture', '', 'img source');\n        add('source', 'src srcset type media sizes');\n        add('track', 'kind src srclang label default');\n        add('datalist', '', [\n          phrasingContent,\n          'option'\n        ].join(' '));\n        add('article section nav aside main header footer', '', flowContent);\n        add('hgroup', '', 'h1 h2 h3 h4 h5 h6');\n        add('figure', '', [\n          flowContent,\n          'figcaption'\n        ].join(' '));\n        add('time', 'datetime', phrasingContent);\n        add('dialog', 'open', flowContent);\n        add('command', 'type label icon disabled checked radiogroup command');\n        add('output', 'for form name', phrasingContent);\n        add('progress', 'value max', phrasingContent);\n        add('meter', 'value min max low high optimum', phrasingContent);\n        add('details', 'open', [\n          flowContent,\n          'summary'\n        ].join(' '));\n        add('keygen', 'autofocus challenge disabled form keytype name');\n      }\n      if (type !== 'html5-strict') {\n        addAttrs('script', 'language xml:space');\n        addAttrs('style', 'xml:space');\n        addAttrs('object', 'declare classid code codebase codetype archive standby align border hspace vspace');\n        addAttrs('embed', 'align name hspace vspace');\n        addAttrs('param', 'valuetype type');\n        addAttrs('a', 'charset name rev shape coords');\n        addAttrs('br', 'clear');\n        addAttrs('applet', 'codebase archive code object alt name width height align hspace vspace');\n        addAttrs('img', 'name longdesc align border hspace vspace');\n        addAttrs('iframe', 'longdesc frameborder marginwidth marginheight scrolling align');\n        addAttrs('font basefont', 'size color face');\n        addAttrs('input', 'usemap align');\n        addAttrs('select');\n        addAttrs('textarea');\n        addAttrs('h1 h2 h3 h4 h5 h6 div p legend caption', 'align');\n        addAttrs('ul', 'type compact');\n        addAttrs('li', 'type');\n        addAttrs('ol dl menu dir', 'compact');\n        addAttrs('pre', 'width xml:space');\n        addAttrs('hr', 'align noshade size width');\n        addAttrs('isindex', 'prompt');\n        addAttrs('table', 'summary width frame rules cellspacing cellpadding align bgcolor');\n        addAttrs('col', 'width align char charoff valign');\n        addAttrs('colgroup', 'width align char charoff valign');\n        addAttrs('thead', 'align char charoff valign');\n        addAttrs('tr', 'align char charoff valign bgcolor');\n        addAttrs('th', 'axis align char charoff valign nowrap bgcolor width height');\n        addAttrs('form', 'accept');\n        addAttrs('td', 'abbr axis scope align char charoff valign nowrap bgcolor width height');\n        addAttrs('tfoot', 'align char charoff valign');\n        addAttrs('tbody', 'align char charoff valign');\n        addAttrs('area', 'nohref');\n        addAttrs('body', 'background bgcolor text link vlink alink');\n      }\n      if (type !== 'html4') {\n        addAttrs('input button select textarea', 'autofocus');\n        addAttrs('input textarea', 'placeholder');\n        addAttrs('a', 'download');\n        addAttrs('link script img', 'crossorigin');\n        addAttrs('img', 'loading');\n        addAttrs('iframe', 'sandbox seamless allowfullscreen loading');\n      }\n      each$h(split$1('a form meter progress dfn'), function (name) {\n        if (schema[name]) {\n          delete schema[name].children[name];\n        }\n      });\n      delete schema.caption.children.table;\n      delete schema.script;\n      mapCache[type] = schema;\n      return schema;\n    };\n    var compileElementMap = function (value, mode) {\n      var styles;\n      if (value) {\n        styles = {};\n        if (typeof value === 'string') {\n          value = { '*': value };\n        }\n        each$h(value, function (value, key) {\n          styles[key] = styles[key.toUpperCase()] = mode === 'map' ? makeMap$2(value, /[, ]/) : explode$3(value, /[, ]/);\n        });\n      }\n      return styles;\n    };\n    var Schema = function (settings) {\n      var elements = {};\n      var children = {};\n      var patternElements = [];\n      var customElementsMap = {}, specialElements = {};\n      var createLookupTable = function (option, defaultValue, extendWith) {\n        var value = settings[option];\n        if (!value) {\n          value = mapCache[option];\n          if (!value) {\n            value = createMap(defaultValue, extendWith);\n            mapCache[option] = value;\n          }\n        } else {\n          value = makeMap$2(value, /[, ]/, makeMap$2(value.toUpperCase(), /[, ]/));\n        }\n        return value;\n      };\n      settings = settings || {};\n      var schemaItems = compileSchema(settings.schema);\n      if (settings.verify_html === false) {\n        settings.valid_elements = '*[*]';\n      }\n      var validStyles = compileElementMap(settings.valid_styles);\n      var invalidStyles = compileElementMap(settings.invalid_styles, 'map');\n      var validClasses = compileElementMap(settings.valid_classes, 'map');\n      var whiteSpaceElementsMap = createLookupTable('whitespace_elements', 'pre script noscript style textarea video audio iframe object code');\n      var selfClosingElementsMap = createLookupTable('self_closing_elements', 'colgroup dd dt li option p td tfoot th thead tr');\n      var shortEndedElementsMap = createLookupTable('short_ended_elements', 'area base basefont br col frame hr img input isindex link ' + 'meta param embed source wbr track');\n      var boolAttrMap = createLookupTable('boolean_attributes', 'checked compact declare defer disabled ismap multiple nohref noresize ' + 'noshade nowrap readonly selected autoplay loop controls');\n      var nonEmptyOrMoveCaretBeforeOnEnter = 'td th iframe video audio object script code';\n      var nonEmptyElementsMap = createLookupTable('non_empty_elements', nonEmptyOrMoveCaretBeforeOnEnter + ' pre', shortEndedElementsMap);\n      var moveCaretBeforeOnEnterElementsMap = createLookupTable('move_caret_before_on_enter_elements', nonEmptyOrMoveCaretBeforeOnEnter + ' table', shortEndedElementsMap);\n      var textBlockElementsMap = createLookupTable('text_block_elements', 'h1 h2 h3 h4 h5 h6 p div address pre form ' + 'blockquote center dir fieldset header footer article section hgroup aside main nav figure');\n      var blockElementsMap = createLookupTable('block_elements', 'hr table tbody thead tfoot ' + 'th tr td li ol ul caption dl dt dd noscript menu isindex option ' + 'datalist select optgroup figcaption details summary', textBlockElementsMap);\n      var textInlineElementsMap = createLookupTable('text_inline_elements', 'span strong b em i font s strike u var cite ' + 'dfn code mark q sup sub samp');\n      each$h((settings.special || 'script noscript iframe noframes noembed title style textarea xmp').split(' '), function (name) {\n        specialElements[name] = new RegExp('</' + name + '[^>]*>', 'gi');\n      });\n      var patternToRegExp = function (str) {\n        return new RegExp('^' + str.replace(/([?+*])/g, '.$1') + '$');\n      };\n      var addValidElements = function (validElements) {\n        var ei, el, ai, al, matches, element, attr, attrData, elementName, attrName, attrType, attributes, attributesOrder, prefix, outputName, globalAttributes, globalAttributesOrder, value;\n        var elementRuleRegExp = /^([#+\\-])?([^\\[!\\/]+)(?:\\/([^\\[!]+))?(?:(!?)\\[([^\\]]+)])?$/, attrRuleRegExp = /^([!\\-])?(\\w+[\\\\:]:\\w+|[^=:<]+)?(?:([=:<])(.*))?$/, hasPatternsRegExp = /[*?+]/;\n        if (validElements) {\n          var validElementsArr = split$1(validElements, ',');\n          if (elements['@']) {\n            globalAttributes = elements['@'].attributes;\n            globalAttributesOrder = elements['@'].attributesOrder;\n          }\n          for (ei = 0, el = validElementsArr.length; ei < el; ei++) {\n            matches = elementRuleRegExp.exec(validElementsArr[ei]);\n            if (matches) {\n              prefix = matches[1];\n              elementName = matches[2];\n              outputName = matches[3];\n              attrData = matches[5];\n              attributes = {};\n              attributesOrder = [];\n              element = {\n                attributes: attributes,\n                attributesOrder: attributesOrder\n              };\n              if (prefix === '#') {\n                element.paddEmpty = true;\n              }\n              if (prefix === '-') {\n                element.removeEmpty = true;\n              }\n              if (matches[4] === '!') {\n                element.removeEmptyAttrs = true;\n              }\n              if (globalAttributes) {\n                each$j(globalAttributes, function (value, key) {\n                  attributes[key] = value;\n                });\n                attributesOrder.push.apply(attributesOrder, globalAttributesOrder);\n              }\n              if (attrData) {\n                attrData = split$1(attrData, '|');\n                for (ai = 0, al = attrData.length; ai < al; ai++) {\n                  matches = attrRuleRegExp.exec(attrData[ai]);\n                  if (matches) {\n                    attr = {};\n                    attrType = matches[1];\n                    attrName = matches[2].replace(/[\\\\:]:/g, ':');\n                    prefix = matches[3];\n                    value = matches[4];\n                    if (attrType === '!') {\n                      element.attributesRequired = element.attributesRequired || [];\n                      element.attributesRequired.push(attrName);\n                      attr.required = true;\n                    }\n                    if (attrType === '-') {\n                      delete attributes[attrName];\n                      attributesOrder.splice(inArray$2(attributesOrder, attrName), 1);\n                      continue;\n                    }\n                    if (prefix) {\n                      if (prefix === '=') {\n                        element.attributesDefault = element.attributesDefault || [];\n                        element.attributesDefault.push({\n                          name: attrName,\n                          value: value\n                        });\n                        attr.defaultValue = value;\n                      }\n                      if (prefix === ':') {\n                        element.attributesForced = element.attributesForced || [];\n                        element.attributesForced.push({\n                          name: attrName,\n                          value: value\n                        });\n                        attr.forcedValue = value;\n                      }\n                      if (prefix === '<') {\n                        attr.validValues = makeMap$2(value, '?');\n                      }\n                    }\n                    if (hasPatternsRegExp.test(attrName)) {\n                      element.attributePatterns = element.attributePatterns || [];\n                      attr.pattern = patternToRegExp(attrName);\n                      element.attributePatterns.push(attr);\n                    } else {\n                      if (!attributes[attrName]) {\n                        attributesOrder.push(attrName);\n                      }\n                      attributes[attrName] = attr;\n                    }\n                  }\n                }\n              }\n              if (!globalAttributes && elementName === '@') {\n                globalAttributes = attributes;\n                globalAttributesOrder = attributesOrder;\n              }\n              if (outputName) {\n                element.outputName = elementName;\n                elements[outputName] = element;\n              }\n              if (hasPatternsRegExp.test(elementName)) {\n                element.pattern = patternToRegExp(elementName);\n                patternElements.push(element);\n              } else {\n                elements[elementName] = element;\n              }\n            }\n          }\n        }\n      };\n      var setValidElements = function (validElements) {\n        elements = {};\n        patternElements = [];\n        addValidElements(validElements);\n        each$h(schemaItems, function (element, name) {\n          children[name] = element.children;\n        });\n      };\n      var addCustomElements = function (customElements) {\n        var customElementRegExp = /^(~)?(.+)$/;\n        if (customElements) {\n          mapCache.text_block_elements = mapCache.block_elements = null;\n          each$h(split$1(customElements, ','), function (rule) {\n            var matches = customElementRegExp.exec(rule), inline = matches[1] === '~', cloneName = inline ? 'span' : 'div', name = matches[2];\n            children[name] = children[cloneName];\n            customElementsMap[name] = cloneName;\n            if (!inline) {\n              blockElementsMap[name.toUpperCase()] = {};\n              blockElementsMap[name] = {};\n            }\n            if (!elements[name]) {\n              var customRule = elements[cloneName];\n              customRule = extend$5({}, customRule);\n              delete customRule.removeEmptyAttrs;\n              delete customRule.removeEmpty;\n              elements[name] = customRule;\n            }\n            each$h(children, function (element, elmName) {\n              if (element[cloneName]) {\n                children[elmName] = element = extend$5({}, children[elmName]);\n                element[name] = element[cloneName];\n              }\n            });\n          });\n        }\n      };\n      var addValidChildren = function (validChildren) {\n        var childRuleRegExp = /^([+\\-]?)([A-Za-z0-9_\\-.\\u00b7\\u00c0-\\u00d6\\u00d8-\\u00f6\\u00f8-\\u037d\\u037f-\\u1fff\\u200c-\\u200d\\u203f-\\u2040\\u2070-\\u218f\\u2c00-\\u2fef\\u3001-\\ud7ff\\uf900-\\ufdcf\\ufdf0-\\ufffd]+)\\[([^\\]]+)]$/;\n        mapCache[settings.schema] = null;\n        if (validChildren) {\n          each$h(split$1(validChildren, ','), function (rule) {\n            var matches = childRuleRegExp.exec(rule);\n            var parent, prefix;\n            if (matches) {\n              prefix = matches[1];\n              if (prefix) {\n                parent = children[matches[2]];\n              } else {\n                parent = children[matches[2]] = { '#comment': {} };\n              }\n              parent = children[matches[2]];\n              each$h(split$1(matches[3], '|'), function (child) {\n                if (prefix === '-') {\n                  delete parent[child];\n                } else {\n                  parent[child] = {};\n                }\n              });\n            }\n          });\n        }\n      };\n      var getElementRule = function (name) {\n        var element = elements[name], i;\n        if (element) {\n          return element;\n        }\n        i = patternElements.length;\n        while (i--) {\n          element = patternElements[i];\n          if (element.pattern.test(name)) {\n            return element;\n          }\n        }\n      };\n      if (!settings.valid_elements) {\n        each$h(schemaItems, function (element, name) {\n          elements[name] = {\n            attributes: element.attributes,\n            attributesOrder: element.attributesOrder\n          };\n          children[name] = element.children;\n        });\n        if (settings.schema !== 'html5') {\n          each$h(split$1('strong/b em/i'), function (item) {\n            var items = split$1(item, '/');\n            elements[items[1]].outputName = items[0];\n          });\n        }\n        each$h(textInlineElementsMap, function (_val, name) {\n          if (elements[name]) {\n            if (settings.padd_empty_block_inline_children) {\n              elements[name].paddInEmptyBlock = true;\n            }\n            elements[name].removeEmpty = true;\n          }\n        });\n        each$h(split$1('ol ul blockquote a table tbody'), function (name) {\n          if (elements[name]) {\n            elements[name].removeEmpty = true;\n          }\n        });\n        each$h(split$1('p h1 h2 h3 h4 h5 h6 th td pre div address caption li'), function (name) {\n          elements[name].paddEmpty = true;\n        });\n        each$h(split$1('span'), function (name) {\n          elements[name].removeEmptyAttrs = true;\n        });\n      } else {\n        setValidElements(settings.valid_elements);\n      }\n      addCustomElements(settings.custom_elements);\n      addValidChildren(settings.valid_children);\n      addValidElements(settings.extended_valid_elements);\n      addValidChildren('+ol[ul|ol],+ul[ul|ol]');\n      each$h({\n        dd: 'dl',\n        dt: 'dl',\n        li: 'ul ol',\n        td: 'tr',\n        th: 'tr',\n        tr: 'tbody thead tfoot',\n        tbody: 'table',\n        thead: 'table',\n        tfoot: 'table',\n        legend: 'fieldset',\n        area: 'map',\n        param: 'video audio object'\n      }, function (parents, item) {\n        if (elements[item]) {\n          elements[item].parentsRequired = split$1(parents);\n        }\n      });\n      if (settings.invalid_elements) {\n        each$h(explode$3(settings.invalid_elements), function (item) {\n          if (elements[item]) {\n            delete elements[item];\n          }\n        });\n      }\n      if (!getElementRule('span')) {\n        addValidElements('span[!data-mce-type|*]');\n      }\n      var getValidStyles = constant(validStyles);\n      var getInvalidStyles = constant(invalidStyles);\n      var getValidClasses = constant(validClasses);\n      var getBoolAttrs = constant(boolAttrMap);\n      var getBlockElements = constant(blockElementsMap);\n      var getTextBlockElements = constant(textBlockElementsMap);\n      var getTextInlineElements = constant(textInlineElementsMap);\n      var getShortEndedElements = constant(shortEndedElementsMap);\n      var getSelfClosingElements = constant(selfClosingElementsMap);\n      var getNonEmptyElements = constant(nonEmptyElementsMap);\n      var getMoveCaretBeforeOnEnterElements = constant(moveCaretBeforeOnEnterElementsMap);\n      var getWhiteSpaceElements = constant(whiteSpaceElementsMap);\n      var getSpecialElements = constant(specialElements);\n      var isValidChild = function (name, child) {\n        var parent = children[name.toLowerCase()];\n        return !!(parent && parent[child.toLowerCase()]);\n      };\n      var isValid = function (name, attr) {\n        var attrPatterns, i;\n        var rule = getElementRule(name);\n        if (rule) {\n          if (attr) {\n            if (rule.attributes[attr]) {\n              return true;\n            }\n            attrPatterns = rule.attributePatterns;\n            if (attrPatterns) {\n              i = attrPatterns.length;\n              while (i--) {\n                if (attrPatterns[i].pattern.test(name)) {\n                  return true;\n                }\n              }\n            }\n          } else {\n            return true;\n          }\n        }\n        return false;\n      };\n      var getCustomElements = constant(customElementsMap);\n      return {\n        children: children,\n        elements: elements,\n        getValidStyles: getValidStyles,\n        getValidClasses: getValidClasses,\n        getBlockElements: getBlockElements,\n        getInvalidStyles: getInvalidStyles,\n        getShortEndedElements: getShortEndedElements,\n        getTextBlockElements: getTextBlockElements,\n        getTextInlineElements: getTextInlineElements,\n        getBoolAttrs: getBoolAttrs,\n        getElementRule: getElementRule,\n        getSelfClosingElements: getSelfClosingElements,\n        getNonEmptyElements: getNonEmptyElements,\n        getMoveCaretBeforeOnEnterElements: getMoveCaretBeforeOnEnterElements,\n        getWhiteSpaceElements: getWhiteSpaceElements,\n        getSpecialElements: getSpecialElements,\n        isValidChild: isValidChild,\n        isValid: isValid,\n        getCustomElements: getCustomElements,\n        addValidElements: addValidElements,\n        setValidElements: setValidElements,\n        addCustomElements: addCustomElements,\n        addValidChildren: addValidChildren\n      };\n    };\n\n    var toHex = function (match, r, g, b) {\n      var hex = function (val) {\n        val = parseInt(val, 10).toString(16);\n        return val.length > 1 ? val : '0' + val;\n      };\n      return '#' + hex(r) + hex(g) + hex(b);\n    };\n    var Styles = function (settings, schema) {\n      var _this = this;\n      var rgbRegExp = /rgb\\s*\\(\\s*([0-9]+)\\s*,\\s*([0-9]+)\\s*,\\s*([0-9]+)\\s*\\)/gi;\n      var urlOrStrRegExp = /(?:url(?:(?:\\(\\s*\\\"([^\\\"]+)\\\"\\s*\\))|(?:\\(\\s*\\'([^\\']+)\\'\\s*\\))|(?:\\(\\s*([^)\\s]+)\\s*\\))))|(?:\\'([^\\']+)\\')|(?:\\\"([^\\\"]+)\\\")/gi;\n      var styleRegExp = /\\s*([^:]+):\\s*([^;]+);?/g;\n      var trimRightRegExp = /\\s+$/;\n      var i;\n      var encodingLookup = {};\n      var validStyles;\n      var invalidStyles;\n      var invisibleChar = zeroWidth;\n      settings = settings || {};\n      if (schema) {\n        validStyles = schema.getValidStyles();\n        invalidStyles = schema.getInvalidStyles();\n      }\n      var encodingItems = ('\\\\\" \\\\\\' \\\\; \\\\: ; : ' + invisibleChar).split(' ');\n      for (i = 0; i < encodingItems.length; i++) {\n        encodingLookup[encodingItems[i]] = invisibleChar + i;\n        encodingLookup[invisibleChar + i] = encodingItems[i];\n      }\n      return {\n        toHex: function (color) {\n          return color.replace(rgbRegExp, toHex);\n        },\n        parse: function (css) {\n          var styles = {};\n          var matches, name, value, isEncoded;\n          var urlConverter = settings.url_converter;\n          var urlConverterScope = settings.url_converter_scope || _this;\n          var compress = function (prefix, suffix, noJoin) {\n            var top = styles[prefix + '-top' + suffix];\n            if (!top) {\n              return;\n            }\n            var right = styles[prefix + '-right' + suffix];\n            if (!right) {\n              return;\n            }\n            var bottom = styles[prefix + '-bottom' + suffix];\n            if (!bottom) {\n              return;\n            }\n            var left = styles[prefix + '-left' + suffix];\n            if (!left) {\n              return;\n            }\n            var box = [\n              top,\n              right,\n              bottom,\n              left\n            ];\n            i = box.length - 1;\n            while (i--) {\n              if (box[i] !== box[i + 1]) {\n                break;\n              }\n            }\n            if (i > -1 && noJoin) {\n              return;\n            }\n            styles[prefix + suffix] = i === -1 ? box[0] : box.join(' ');\n            delete styles[prefix + '-top' + suffix];\n            delete styles[prefix + '-right' + suffix];\n            delete styles[prefix + '-bottom' + suffix];\n            delete styles[prefix + '-left' + suffix];\n          };\n          var canCompress = function (key) {\n            var value = styles[key], i;\n            if (!value) {\n              return;\n            }\n            value = value.split(' ');\n            i = value.length;\n            while (i--) {\n              if (value[i] !== value[0]) {\n                return false;\n              }\n            }\n            styles[key] = value[0];\n            return true;\n          };\n          var compress2 = function (target, a, b, c) {\n            if (!canCompress(a)) {\n              return;\n            }\n            if (!canCompress(b)) {\n              return;\n            }\n            if (!canCompress(c)) {\n              return;\n            }\n            styles[target] = styles[a] + ' ' + styles[b] + ' ' + styles[c];\n            delete styles[a];\n            delete styles[b];\n            delete styles[c];\n          };\n          var encode = function (str) {\n            isEncoded = true;\n            return encodingLookup[str];\n          };\n          var decode = function (str, keepSlashes) {\n            if (isEncoded) {\n              str = str.replace(/\\uFEFF[0-9]/g, function (str) {\n                return encodingLookup[str];\n              });\n            }\n            if (!keepSlashes) {\n              str = str.replace(/\\\\([\\'\\\";:])/g, '$1');\n            }\n            return str;\n          };\n          var decodeSingleHexSequence = function (escSeq) {\n            return String.fromCharCode(parseInt(escSeq.slice(1), 16));\n          };\n          var decodeHexSequences = function (value) {\n            return value.replace(/\\\\[0-9a-f]+/gi, decodeSingleHexSequence);\n          };\n          var processUrl = function (match, url, url2, url3, str, str2) {\n            str = str || str2;\n            if (str) {\n              str = decode(str);\n              return '\\'' + str.replace(/\\'/g, '\\\\\\'') + '\\'';\n            }\n            url = decode(url || url2 || url3);\n            if (!settings.allow_script_urls) {\n              var scriptUrl = url.replace(/[\\s\\r\\n]+/g, '');\n              if (/(java|vb)script:/i.test(scriptUrl)) {\n                return '';\n              }\n              if (!settings.allow_svg_data_urls && /^data:image\\/svg/i.test(scriptUrl)) {\n                return '';\n              }\n            }\n            if (urlConverter) {\n              url = urlConverter.call(urlConverterScope, url, 'style');\n            }\n            return 'url(\\'' + url.replace(/\\'/g, '\\\\\\'') + '\\')';\n          };\n          if (css) {\n            css = css.replace(/[\\u0000-\\u001F]/g, '');\n            css = css.replace(/\\\\[\\\"\\';:\\uFEFF]/g, encode).replace(/\\\"[^\\\"]+\\\"|\\'[^\\']+\\'/g, function (str) {\n              return str.replace(/[;:]/g, encode);\n            });\n            while (matches = styleRegExp.exec(css)) {\n              styleRegExp.lastIndex = matches.index + matches[0].length;\n              name = matches[1].replace(trimRightRegExp, '').toLowerCase();\n              value = matches[2].replace(trimRightRegExp, '');\n              if (name && value) {\n                name = decodeHexSequences(name);\n                value = decodeHexSequences(value);\n                if (name.indexOf(invisibleChar) !== -1 || name.indexOf('\"') !== -1) {\n                  continue;\n                }\n                if (!settings.allow_script_urls && (name === 'behavior' || /expression\\s*\\(|\\/\\*|\\*\\//.test(value))) {\n                  continue;\n                }\n                if (name === 'font-weight' && value === '700') {\n                  value = 'bold';\n                } else if (name === 'color' || name === 'background-color') {\n                  value = value.toLowerCase();\n                }\n                value = value.replace(rgbRegExp, toHex);\n                value = value.replace(urlOrStrRegExp, processUrl);\n                styles[name] = isEncoded ? decode(value, true) : value;\n              }\n            }\n            compress('border', '', true);\n            compress('border', '-width');\n            compress('border', '-color');\n            compress('border', '-style');\n            compress('padding', '');\n            compress('margin', '');\n            compress2('border', 'border-width', 'border-style', 'border-color');\n            if (styles.border === 'medium none') {\n              delete styles.border;\n            }\n            if (styles['border-image'] === 'none') {\n              delete styles['border-image'];\n            }\n          }\n          return styles;\n        },\n        serialize: function (styles, elementName) {\n          var css = '';\n          var serializeStyles = function (name) {\n            var value;\n            var styleList = validStyles[name];\n            if (styleList) {\n              for (var i_1 = 0, l = styleList.length; i_1 < l; i_1++) {\n                name = styleList[i_1];\n                value = styles[name];\n                if (value) {\n                  css += (css.length > 0 ? ' ' : '') + name + ': ' + value + ';';\n                }\n              }\n            }\n          };\n          var isValid = function (name, elementName) {\n            var styleMap = invalidStyles['*'];\n            if (styleMap && styleMap[name]) {\n              return false;\n            }\n            styleMap = invalidStyles[elementName];\n            return !(styleMap && styleMap[name]);\n          };\n          if (elementName && validStyles) {\n            serializeStyles('*');\n            serializeStyles(elementName);\n          } else {\n            each$j(styles, function (value, name) {\n              if (value && (!invalidStyles || isValid(name, elementName))) {\n                css += (css.length > 0 ? ' ' : '') + name + ': ' + value + ';';\n              }\n            });\n          }\n          return css;\n        }\n      };\n    };\n\n    var deprecated = {\n      keyLocation: true,\n      layerX: true,\n      layerY: true,\n      returnValue: true,\n      webkitMovementX: true,\n      webkitMovementY: true,\n      keyIdentifier: true,\n      mozPressure: true\n    };\n    var isNativeEvent = function (event) {\n      return event instanceof Event || isFunction(event.initEvent);\n    };\n    var hasIsDefaultPrevented = function (event) {\n      return event.isDefaultPrevented === always || event.isDefaultPrevented === never;\n    };\n    var needsNormalizing = function (event) {\n      return isNullable(event.preventDefault) || isNativeEvent(event);\n    };\n    var clone$2 = function (originalEvent, data) {\n      var event = data !== null && data !== void 0 ? data : {};\n      for (var name_1 in originalEvent) {\n        if (!has$2(deprecated, name_1)) {\n          event[name_1] = originalEvent[name_1];\n        }\n      }\n      if (isNonNullable(event.composedPath)) {\n        event.composedPath = function () {\n          return originalEvent.composedPath();\n        };\n      }\n      return event;\n    };\n    var normalize$3 = function (type, originalEvent, fallbackTarget, data) {\n      var _a;\n      var event = clone$2(originalEvent, data);\n      event.type = type;\n      if (isNullable(event.target)) {\n        event.target = (_a = event.srcElement) !== null && _a !== void 0 ? _a : fallbackTarget;\n      }\n      if (needsNormalizing(originalEvent)) {\n        event.preventDefault = function () {\n          event.defaultPrevented = true;\n          event.isDefaultPrevented = always;\n          if (isFunction(originalEvent.preventDefault)) {\n            originalEvent.preventDefault();\n          } else if (isNativeEvent(originalEvent)) {\n            originalEvent.returnValue = false;\n          }\n        };\n        event.stopPropagation = function () {\n          event.cancelBubble = true;\n          event.isPropagationStopped = always;\n          if (isFunction(originalEvent.stopPropagation)) {\n            originalEvent.stopPropagation();\n          } else if (isNativeEvent(originalEvent)) {\n            originalEvent.cancelBubble = true;\n          }\n        };\n        event.stopImmediatePropagation = function () {\n          event.isImmediatePropagationStopped = always;\n          event.stopPropagation();\n        };\n        if (!hasIsDefaultPrevented(event)) {\n          event.isDefaultPrevented = event.defaultPrevented === true ? always : never;\n          event.isPropagationStopped = event.cancelBubble === true ? always : never;\n          event.isImmediatePropagationStopped = never;\n        }\n      }\n      return event;\n    };\n\n    var eventExpandoPrefix = 'mce-data-';\n    var mouseEventRe = /^(?:mouse|contextmenu)|click/;\n    var addEvent = function (target, name, callback, capture) {\n      if (target.addEventListener) {\n        target.addEventListener(name, callback, capture || false);\n      } else if (target.attachEvent) {\n        target.attachEvent('on' + name, callback);\n      }\n    };\n    var removeEvent = function (target, name, callback, capture) {\n      if (target.removeEventListener) {\n        target.removeEventListener(name, callback, capture || false);\n      } else if (target.detachEvent) {\n        target.detachEvent('on' + name, callback);\n      }\n    };\n    var isMouseEvent = function (event) {\n      return isNonNullable(event) && mouseEventRe.test(event.type);\n    };\n    var fix = function (originalEvent, data) {\n      var event = normalize$3(originalEvent.type, originalEvent, document, data);\n      if (isMouseEvent(originalEvent) && isUndefined(originalEvent.pageX) && !isUndefined(originalEvent.clientX)) {\n        var eventDoc = event.target.ownerDocument || document;\n        var doc = eventDoc.documentElement;\n        var body = eventDoc.body;\n        var mouseEvent = event;\n        mouseEvent.pageX = originalEvent.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);\n        mouseEvent.pageY = originalEvent.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);\n      }\n      if (isUndefined(event.metaKey)) {\n        event.metaKey = false;\n      }\n      return event;\n    };\n    var bindOnReady = function (win, callback, eventUtils) {\n      var doc = win.document, event = { type: 'ready' };\n      if (eventUtils.domLoaded) {\n        callback(event);\n        return;\n      }\n      var isDocReady = function () {\n        return doc.readyState === 'complete' || doc.readyState === 'interactive' && doc.body;\n      };\n      var readyHandler = function () {\n        removeEvent(win, 'DOMContentLoaded', readyHandler);\n        removeEvent(win, 'load', readyHandler);\n        if (!eventUtils.domLoaded) {\n          eventUtils.domLoaded = true;\n          callback(event);\n        }\n        win = null;\n      };\n      if (isDocReady()) {\n        readyHandler();\n      } else {\n        addEvent(win, 'DOMContentLoaded', readyHandler);\n      }\n      if (!eventUtils.domLoaded) {\n        addEvent(win, 'load', readyHandler);\n      }\n    };\n    var EventUtils = function () {\n      function EventUtils() {\n        this.domLoaded = false;\n        this.events = {};\n        this.count = 1;\n        this.expando = eventExpandoPrefix + (+new Date()).toString(32);\n        this.hasMouseEnterLeave = 'onmouseenter' in document.documentElement;\n        this.hasFocusIn = 'onfocusin' in document.documentElement;\n        this.count = 1;\n      }\n      EventUtils.prototype.bind = function (target, names, callback, scope) {\n        var self = this;\n        var id, callbackList, i, name, fakeName, nativeHandler, capture;\n        var win = window;\n        var defaultNativeHandler = function (evt) {\n          self.executeHandlers(fix(evt || win.event), id);\n        };\n        if (!target || target.nodeType === 3 || target.nodeType === 8) {\n          return;\n        }\n        if (!target[self.expando]) {\n          id = self.count++;\n          target[self.expando] = id;\n          self.events[id] = {};\n        } else {\n          id = target[self.expando];\n        }\n        scope = scope || target;\n        var namesList = names.split(' ');\n        i = namesList.length;\n        while (i--) {\n          name = namesList[i];\n          nativeHandler = defaultNativeHandler;\n          fakeName = capture = false;\n          if (name === 'DOMContentLoaded') {\n            name = 'ready';\n          }\n          if (self.domLoaded && name === 'ready' && target.readyState === 'complete') {\n            callback.call(scope, fix({ type: name }));\n            continue;\n          }\n          if (!self.hasMouseEnterLeave) {\n            fakeName = self.mouseEnterLeave[name];\n            if (fakeName) {\n              nativeHandler = function (evt) {\n                var current = evt.currentTarget;\n                var related = evt.relatedTarget;\n                if (related && current.contains) {\n                  related = current.contains(related);\n                } else {\n                  while (related && related !== current) {\n                    related = related.parentNode;\n                  }\n                }\n                if (!related) {\n                  evt = fix(evt || win.event);\n                  evt.type = evt.type === 'mouseout' ? 'mouseleave' : 'mouseenter';\n                  evt.target = current;\n                  self.executeHandlers(evt, id);\n                }\n              };\n            }\n          }\n          if (!self.hasFocusIn && (name === 'focusin' || name === 'focusout')) {\n            capture = true;\n            fakeName = name === 'focusin' ? 'focus' : 'blur';\n            nativeHandler = function (evt) {\n              evt = fix(evt || win.event);\n              evt.type = evt.type === 'focus' ? 'focusin' : 'focusout';\n              self.executeHandlers(evt, id);\n            };\n          }\n          callbackList = self.events[id][name];\n          if (!callbackList) {\n            self.events[id][name] = callbackList = [{\n                func: callback,\n                scope: scope\n              }];\n            callbackList.fakeName = fakeName;\n            callbackList.capture = capture;\n            callbackList.nativeHandler = nativeHandler;\n            if (name === 'ready') {\n              bindOnReady(target, nativeHandler, self);\n            } else {\n              addEvent(target, fakeName || name, nativeHandler, capture);\n            }\n          } else {\n            if (name === 'ready' && self.domLoaded) {\n              callback(fix({ type: name }));\n            } else {\n              callbackList.push({\n                func: callback,\n                scope: scope\n              });\n            }\n          }\n        }\n        target = callbackList = null;\n        return callback;\n      };\n      EventUtils.prototype.unbind = function (target, names, callback) {\n        var callbackList, i, ci, name, eventMap;\n        if (!target || target.nodeType === 3 || target.nodeType === 8) {\n          return this;\n        }\n        var id = target[this.expando];\n        if (id) {\n          eventMap = this.events[id];\n          if (names) {\n            var namesList = names.split(' ');\n            i = namesList.length;\n            while (i--) {\n              name = namesList[i];\n              callbackList = eventMap[name];\n              if (callbackList) {\n                if (callback) {\n                  ci = callbackList.length;\n                  while (ci--) {\n                    if (callbackList[ci].func === callback) {\n                      var nativeHandler = callbackList.nativeHandler;\n                      var fakeName = callbackList.fakeName, capture = callbackList.capture;\n                      callbackList = callbackList.slice(0, ci).concat(callbackList.slice(ci + 1));\n                      callbackList.nativeHandler = nativeHandler;\n                      callbackList.fakeName = fakeName;\n                      callbackList.capture = capture;\n                      eventMap[name] = callbackList;\n                    }\n                  }\n                }\n                if (!callback || callbackList.length === 0) {\n                  delete eventMap[name];\n                  removeEvent(target, callbackList.fakeName || name, callbackList.nativeHandler, callbackList.capture);\n                }\n              }\n            }\n          } else {\n            each$j(eventMap, function (callbackList, name) {\n              removeEvent(target, callbackList.fakeName || name, callbackList.nativeHandler, callbackList.capture);\n            });\n            eventMap = {};\n          }\n          for (name in eventMap) {\n            if (has$2(eventMap, name)) {\n              return this;\n            }\n          }\n          delete this.events[id];\n          try {\n            delete target[this.expando];\n          } catch (ex) {\n            target[this.expando] = null;\n          }\n        }\n        return this;\n      };\n      EventUtils.prototype.fire = function (target, name, args) {\n        var id;\n        if (!target || target.nodeType === 3 || target.nodeType === 8) {\n          return this;\n        }\n        var event = fix({\n          type: name,\n          target: target\n        }, args);\n        do {\n          id = target[this.expando];\n          if (id) {\n            this.executeHandlers(event, id);\n          }\n          target = target.parentNode || target.ownerDocument || target.defaultView || target.parentWindow;\n        } while (target && !event.isPropagationStopped());\n        return this;\n      };\n      EventUtils.prototype.clean = function (target) {\n        var i, children;\n        if (!target || target.nodeType === 3 || target.nodeType === 8) {\n          return this;\n        }\n        if (target[this.expando]) {\n          this.unbind(target);\n        }\n        if (!target.getElementsByTagName) {\n          target = target.document;\n        }\n        if (target && target.getElementsByTagName) {\n          this.unbind(target);\n          children = target.getElementsByTagName('*');\n          i = children.length;\n          while (i--) {\n            target = children[i];\n            if (target[this.expando]) {\n              this.unbind(target);\n            }\n          }\n        }\n        return this;\n      };\n      EventUtils.prototype.destroy = function () {\n        this.events = {};\n      };\n      EventUtils.prototype.cancel = function (e) {\n        if (e) {\n          e.preventDefault();\n          e.stopImmediatePropagation();\n        }\n        return false;\n      };\n      EventUtils.prototype.executeHandlers = function (evt, id) {\n        var container = this.events[id];\n        var callbackList = container && container[evt.type];\n        if (callbackList) {\n          for (var i = 0, l = callbackList.length; i < l; i++) {\n            var callback = callbackList[i];\n            if (callback && callback.func.call(callback.scope, evt) === false) {\n              evt.preventDefault();\n            }\n            if (evt.isImmediatePropagationStopped()) {\n              return;\n            }\n          }\n        }\n      };\n      EventUtils.Event = new EventUtils();\n      return EventUtils;\n    }();\n\n    var support, Expr, getText, isXML, tokenize, compile, select$1, outermostContext, sortInput, hasDuplicate, setDocument, document$1, docElem, documentIsHTML, rbuggyQSA, rbuggyMatches, matches, contains, expando = 'sizzle' + -new Date(), preferredDoc = window.document, dirruns = 0, done = 0, classCache = createCache(), tokenCache = createCache(), compilerCache = createCache(), sortOrder = function (a, b) {\n        if (a === b) {\n          hasDuplicate = true;\n        }\n        return 0;\n      }, strundefined = typeof undefined, MAX_NEGATIVE = 1 << 31, hasOwn = {}.hasOwnProperty, arr = [], pop = arr.pop, push_native = arr.push, push$1 = arr.push, slice$1 = arr.slice, indexOf = arr.indexOf || function (elem) {\n        var i = 0, len = this.length;\n        for (; i < len; i++) {\n          if (this[i] === elem) {\n            return i;\n          }\n        }\n        return -1;\n      }, booleans = 'checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped', whitespace = '[\\\\x20\\\\t\\\\r\\\\n\\\\f]', identifier = '(?:\\\\\\\\.|[\\\\w-]|[^\\\\x00-\\\\xa0])+', attributes = '\\\\[' + whitespace + '*(' + identifier + ')(?:' + whitespace + '*([*^$|!~]?=)' + whitespace + '*(?:\\'((?:\\\\\\\\.|[^\\\\\\\\\\'])*)\\'|\"((?:\\\\\\\\.|[^\\\\\\\\\"])*)\"|(' + identifier + '))|)' + whitespace + '*\\\\]', pseudos = ':(' + identifier + ')(?:\\\\((' + '(\\'((?:\\\\\\\\.|[^\\\\\\\\\\'])*)\\'|\"((?:\\\\\\\\.|[^\\\\\\\\\"])*)\")|' + '((?:\\\\\\\\.|[^\\\\\\\\()[\\\\]]|' + attributes + ')*)|' + '.*' + ')\\\\)|)', rtrim = new RegExp('^' + whitespace + '+|((?:^|[^\\\\\\\\])(?:\\\\\\\\.)*)' + whitespace + '+$', 'g'), rcomma = new RegExp('^' + whitespace + '*,' + whitespace + '*'), rcombinators = new RegExp('^' + whitespace + '*([>+~]|' + whitespace + ')' + whitespace + '*'), rattributeQuotes = new RegExp('=' + whitespace + '*([^\\\\]\\'\"]*?)' + whitespace + '*\\\\]', 'g'), rpseudo = new RegExp(pseudos), ridentifier = new RegExp('^' + identifier + '$'), matchExpr = {\n        ID: new RegExp('^#(' + identifier + ')'),\n        CLASS: new RegExp('^\\\\.(' + identifier + ')'),\n        TAG: new RegExp('^(' + identifier + '|[*])'),\n        ATTR: new RegExp('^' + attributes),\n        PSEUDO: new RegExp('^' + pseudos),\n        CHILD: new RegExp('^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\\\(' + whitespace + '*(even|odd|(([+-]|)(\\\\d*)n|)' + whitespace + '*(?:([+-]|)' + whitespace + '*(\\\\d+)|))' + whitespace + '*\\\\)|)', 'i'),\n        bool: new RegExp('^(?:' + booleans + ')$', 'i'),\n        needsContext: new RegExp('^' + whitespace + '*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\\\(' + whitespace + '*((?:-\\\\d)?\\\\d*)' + whitespace + '*\\\\)|)(?=[^-]|$)', 'i')\n      }, rinputs = /^(?:input|select|textarea|button)$/i, rheader = /^h\\d$/i, rnative = /^[^{]+\\{\\s*\\[native \\w/, rquickExpr$1 = /^(?:#([\\w-]+)|(\\w+)|\\.([\\w-]+))$/, rsibling = /[+~]/, rescape = /'|\\\\/g, runescape = new RegExp('\\\\\\\\([\\\\da-f]{1,6}' + whitespace + '?|(' + whitespace + ')|.)', 'ig'), funescape = function (_, escaped, escapedWhitespace) {\n        var high = '0x' + escaped - 65536;\n        return high !== high || escapedWhitespace ? escaped : high < 0 ? String.fromCharCode(high + 65536) : String.fromCharCode(high >> 10 | 55296, high & 1023 | 56320);\n      };\n    try {\n      push$1.apply(arr = slice$1.call(preferredDoc.childNodes), preferredDoc.childNodes);\n      arr[preferredDoc.childNodes.length].nodeType;\n    } catch (e) {\n      push$1 = {\n        apply: arr.length ? function (target, els) {\n          push_native.apply(target, slice$1.call(els));\n        } : function (target, els) {\n          var j = target.length, i = 0;\n          while (target[j++] = els[i++]) {\n          }\n          target.length = j - 1;\n        }\n      };\n    }\n    var Sizzle = function (selector, context, results, seed) {\n      var match, elem, m, nodeType, i, groups, old, nid, newContext, newSelector;\n      if ((context ? context.ownerDocument || context : preferredDoc) !== document$1) {\n        setDocument(context);\n      }\n      context = context || document$1;\n      results = results || [];\n      if (!selector || typeof selector !== 'string') {\n        return results;\n      }\n      if ((nodeType = context.nodeType) !== 1 && nodeType !== 9) {\n        return [];\n      }\n      if (documentIsHTML && !seed) {\n        if (match = rquickExpr$1.exec(selector)) {\n          if (m = match[1]) {\n            if (nodeType === 9) {\n              elem = context.getElementById(m);\n              if (elem && elem.parentNode) {\n                if (elem.id === m) {\n                  results.push(elem);\n                  return results;\n                }\n              } else {\n                return results;\n              }\n            } else {\n              if (context.ownerDocument && (elem = context.ownerDocument.getElementById(m)) && contains(context, elem) && elem.id === m) {\n                results.push(elem);\n                return results;\n              }\n            }\n          } else if (match[2]) {\n            push$1.apply(results, context.getElementsByTagName(selector));\n            return results;\n          } else if ((m = match[3]) && support.getElementsByClassName) {\n            push$1.apply(results, context.getElementsByClassName(m));\n            return results;\n          }\n        }\n        if (support.qsa && (!rbuggyQSA || !rbuggyQSA.test(selector))) {\n          nid = old = expando;\n          newContext = context;\n          newSelector = nodeType === 9 && selector;\n          if (nodeType === 1 && context.nodeName.toLowerCase() !== 'object') {\n            groups = tokenize(selector);\n            if (old = context.getAttribute('id')) {\n              nid = old.replace(rescape, '\\\\$&');\n            } else {\n              context.setAttribute('id', nid);\n            }\n            nid = '[id=\\'' + nid + '\\'] ';\n            i = groups.length;\n            while (i--) {\n              groups[i] = nid + toSelector(groups[i]);\n            }\n            newContext = rsibling.test(selector) && testContext(context.parentNode) || context;\n            newSelector = groups.join(',');\n          }\n          if (newSelector) {\n            try {\n              push$1.apply(results, newContext.querySelectorAll(newSelector));\n              return results;\n            } catch (qsaError) {\n            } finally {\n              if (!old) {\n                context.removeAttribute('id');\n              }\n            }\n          }\n        }\n      }\n      return select$1(selector.replace(rtrim, '$1'), context, results, seed);\n    };\n    function createCache() {\n      var keys = [];\n      function cache(key, value) {\n        if (keys.push(key + ' ') > Expr.cacheLength) {\n          delete cache[keys.shift()];\n        }\n        return cache[key + ' '] = value;\n      }\n      return cache;\n    }\n    function markFunction(fn) {\n      fn[expando] = true;\n      return fn;\n    }\n    function siblingCheck(a, b) {\n      var cur = b && a, diff = cur && a.nodeType === 1 && b.nodeType === 1 && (~b.sourceIndex || MAX_NEGATIVE) - (~a.sourceIndex || MAX_NEGATIVE);\n      if (diff) {\n        return diff;\n      }\n      if (cur) {\n        while (cur = cur.nextSibling) {\n          if (cur === b) {\n            return -1;\n          }\n        }\n      }\n      return a ? 1 : -1;\n    }\n    function createInputPseudo(type) {\n      return function (elem) {\n        var name = elem.nodeName.toLowerCase();\n        return name === 'input' && elem.type === type;\n      };\n    }\n    function createButtonPseudo(type) {\n      return function (elem) {\n        var name = elem.nodeName.toLowerCase();\n        return (name === 'input' || name === 'button') && elem.type === type;\n      };\n    }\n    function createPositionalPseudo(fn) {\n      return markFunction(function (argument) {\n        argument = +argument;\n        return markFunction(function (seed, matches) {\n          var j, matchIndexes = fn([], seed.length, argument), i = matchIndexes.length;\n          while (i--) {\n            if (seed[j = matchIndexes[i]]) {\n              seed[j] = !(matches[j] = seed[j]);\n            }\n          }\n        });\n      });\n    }\n    function testContext(context) {\n      return context && typeof context.getElementsByTagName !== strundefined && context;\n    }\n    support = Sizzle.support = {};\n    isXML = Sizzle.isXML = function (elem) {\n      var documentElement = elem && (elem.ownerDocument || elem).documentElement;\n      return documentElement ? documentElement.nodeName !== 'HTML' : false;\n    };\n    setDocument = Sizzle.setDocument = function (node) {\n      var hasCompare, doc = node ? node.ownerDocument || node : preferredDoc, parent = doc.defaultView;\n      function getTop(win) {\n        try {\n          return win.top;\n        } catch (ex) {\n        }\n        return null;\n      }\n      if (doc === document$1 || doc.nodeType !== 9 || !doc.documentElement) {\n        return document$1;\n      }\n      document$1 = doc;\n      docElem = doc.documentElement;\n      documentIsHTML = !isXML(doc);\n      if (parent && parent !== getTop(parent)) {\n        if (parent.addEventListener) {\n          parent.addEventListener('unload', function () {\n            setDocument();\n          }, false);\n        } else if (parent.attachEvent) {\n          parent.attachEvent('onunload', function () {\n            setDocument();\n          });\n        }\n      }\n      support.attributes = true;\n      support.getElementsByTagName = true;\n      support.getElementsByClassName = rnative.test(doc.getElementsByClassName);\n      support.getById = true;\n      Expr.find.ID = function (id, context) {\n        if (typeof context.getElementById !== strundefined && documentIsHTML) {\n          var m = context.getElementById(id);\n          return m && m.parentNode ? [m] : [];\n        }\n      };\n      Expr.filter.ID = function (id) {\n        var attrId = id.replace(runescape, funescape);\n        return function (elem) {\n          return elem.getAttribute('id') === attrId;\n        };\n      };\n      Expr.find.TAG = support.getElementsByTagName ? function (tag, context) {\n        if (typeof context.getElementsByTagName !== strundefined) {\n          return context.getElementsByTagName(tag);\n        }\n      } : function (tag, context) {\n        var elem, tmp = [], i = 0, results = context.getElementsByTagName(tag);\n        if (tag === '*') {\n          while (elem = results[i++]) {\n            if (elem.nodeType === 1) {\n              tmp.push(elem);\n            }\n          }\n          return tmp;\n        }\n        return results;\n      };\n      Expr.find.CLASS = support.getElementsByClassName && function (className, context) {\n        if (documentIsHTML) {\n          return context.getElementsByClassName(className);\n        }\n      };\n      rbuggyMatches = [];\n      rbuggyQSA = [];\n      support.disconnectedMatch = true;\n      rbuggyQSA = rbuggyQSA.length && new RegExp(rbuggyQSA.join('|'));\n      rbuggyMatches = rbuggyMatches.length && new RegExp(rbuggyMatches.join('|'));\n      hasCompare = rnative.test(docElem.compareDocumentPosition);\n      contains = hasCompare || rnative.test(docElem.contains) ? function (a, b) {\n        var adown = a.nodeType === 9 ? a.documentElement : a, bup = b && b.parentNode;\n        return a === bup || !!(bup && bup.nodeType === 1 && (adown.contains ? adown.contains(bup) : a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16));\n      } : function (a, b) {\n        if (b) {\n          while (b = b.parentNode) {\n            if (b === a) {\n              return true;\n            }\n          }\n        }\n        return false;\n      };\n      sortOrder = hasCompare ? function (a, b) {\n        if (a === b) {\n          hasDuplicate = true;\n          return 0;\n        }\n        var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;\n        if (compare) {\n          return compare;\n        }\n        compare = (a.ownerDocument || a) === (b.ownerDocument || b) ? a.compareDocumentPosition(b) : 1;\n        if (compare & 1 || !support.sortDetached && b.compareDocumentPosition(a) === compare) {\n          if (a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a)) {\n            return -1;\n          }\n          if (b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b)) {\n            return 1;\n          }\n          return sortInput ? indexOf.call(sortInput, a) - indexOf.call(sortInput, b) : 0;\n        }\n        return compare & 4 ? -1 : 1;\n      } : function (a, b) {\n        if (a === b) {\n          hasDuplicate = true;\n          return 0;\n        }\n        var cur, i = 0, aup = a.parentNode, bup = b.parentNode, ap = [a], bp = [b];\n        if (!aup || !bup) {\n          return a === doc ? -1 : b === doc ? 1 : aup ? -1 : bup ? 1 : sortInput ? indexOf.call(sortInput, a) - indexOf.call(sortInput, b) : 0;\n        } else if (aup === bup) {\n          return siblingCheck(a, b);\n        }\n        cur = a;\n        while (cur = cur.parentNode) {\n          ap.unshift(cur);\n        }\n        cur = b;\n        while (cur = cur.parentNode) {\n          bp.unshift(cur);\n        }\n        while (ap[i] === bp[i]) {\n          i++;\n        }\n        return i ? siblingCheck(ap[i], bp[i]) : ap[i] === preferredDoc ? -1 : bp[i] === preferredDoc ? 1 : 0;\n      };\n      return doc;\n    };\n    Sizzle.matches = function (expr, elements) {\n      return Sizzle(expr, null, null, elements);\n    };\n    Sizzle.matchesSelector = function (elem, expr) {\n      if ((elem.ownerDocument || elem) !== document$1) {\n        setDocument(elem);\n      }\n      expr = expr.replace(rattributeQuotes, '=\\'$1\\']');\n      if (support.matchesSelector && documentIsHTML && (!rbuggyMatches || !rbuggyMatches.test(expr)) && (!rbuggyQSA || !rbuggyQSA.test(expr))) {\n        try {\n          var ret = matches.call(elem, expr);\n          if (ret || support.disconnectedMatch || elem.document && elem.document.nodeType !== 11) {\n            return ret;\n          }\n        } catch (e) {\n        }\n      }\n      return Sizzle(expr, document$1, null, [elem]).length > 0;\n    };\n    Sizzle.contains = function (context, elem) {\n      if ((context.ownerDocument || context) !== document$1) {\n        setDocument(context);\n      }\n      return contains(context, elem);\n    };\n    Sizzle.attr = function (elem, name) {\n      if ((elem.ownerDocument || elem) !== document$1) {\n        setDocument(elem);\n      }\n      var fn = Expr.attrHandle[name.toLowerCase()], val = fn && hasOwn.call(Expr.attrHandle, name.toLowerCase()) ? fn(elem, name, !documentIsHTML) : undefined;\n      return val !== undefined ? val : support.attributes || !documentIsHTML ? elem.getAttribute(name) : (val = elem.getAttributeNode(name)) && val.specified ? val.value : null;\n    };\n    Sizzle.error = function (msg) {\n      throw new Error('Syntax error, unrecognized expression: ' + msg);\n    };\n    Sizzle.uniqueSort = function (results) {\n      var elem, duplicates = [], j = 0, i = 0;\n      hasDuplicate = !support.detectDuplicates;\n      sortInput = !support.sortStable && results.slice(0);\n      results.sort(sortOrder);\n      if (hasDuplicate) {\n        while (elem = results[i++]) {\n          if (elem === results[i]) {\n            j = duplicates.push(i);\n          }\n        }\n        while (j--) {\n          results.splice(duplicates[j], 1);\n        }\n      }\n      sortInput = null;\n      return results;\n    };\n    getText = Sizzle.getText = function (elem) {\n      var node, ret = '', i = 0, nodeType = elem.nodeType;\n      if (!nodeType) {\n        while (node = elem[i++]) {\n          ret += getText(node);\n        }\n      } else if (nodeType === 1 || nodeType === 9 || nodeType === 11) {\n        if (typeof elem.textContent === 'string') {\n          return elem.textContent;\n        } else {\n          for (elem = elem.firstChild; elem; elem = elem.nextSibling) {\n            ret += getText(elem);\n          }\n        }\n      } else if (nodeType === 3 || nodeType === 4) {\n        return elem.nodeValue;\n      }\n      return ret;\n    };\n    Expr = Sizzle.selectors = {\n      cacheLength: 50,\n      createPseudo: markFunction,\n      match: matchExpr,\n      attrHandle: {},\n      find: {},\n      relative: {\n        '>': {\n          dir: 'parentNode',\n          first: true\n        },\n        ' ': { dir: 'parentNode' },\n        '+': {\n          dir: 'previousSibling',\n          first: true\n        },\n        '~': { dir: 'previousSibling' }\n      },\n      preFilter: {\n        ATTR: function (match) {\n          match[1] = match[1].replace(runescape, funescape);\n          match[3] = (match[3] || match[4] || match[5] || '').replace(runescape, funescape);\n          if (match[2] === '~=') {\n            match[3] = ' ' + match[3] + ' ';\n          }\n          return match.slice(0, 4);\n        },\n        CHILD: function (match) {\n          match[1] = match[1].toLowerCase();\n          if (match[1].slice(0, 3) === 'nth') {\n            if (!match[3]) {\n              Sizzle.error(match[0]);\n            }\n            match[4] = +(match[4] ? match[5] + (match[6] || 1) : 2 * (match[3] === 'even' || match[3] === 'odd'));\n            match[5] = +(match[7] + match[8] || match[3] === 'odd');\n          } else if (match[3]) {\n            Sizzle.error(match[0]);\n          }\n          return match;\n        },\n        PSEUDO: function (match) {\n          var excess, unquoted = !match[6] && match[2];\n          if (matchExpr.CHILD.test(match[0])) {\n            return null;\n          }\n          if (match[3]) {\n            match[2] = match[4] || match[5] || '';\n          } else if (unquoted && rpseudo.test(unquoted) && (excess = tokenize(unquoted, true)) && (excess = unquoted.indexOf(')', unquoted.length - excess) - unquoted.length)) {\n            match[0] = match[0].slice(0, excess);\n            match[2] = unquoted.slice(0, excess);\n          }\n          return match.slice(0, 3);\n        }\n      },\n      filter: {\n        TAG: function (nodeNameSelector) {\n          var nodeName = nodeNameSelector.replace(runescape, funescape).toLowerCase();\n          return nodeNameSelector === '*' ? function () {\n            return true;\n          } : function (elem) {\n            return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;\n          };\n        },\n        CLASS: function (className) {\n          var pattern = classCache[className + ' '];\n          return pattern || (pattern = new RegExp('(^|' + whitespace + ')' + className + '(' + whitespace + '|$)')) && classCache(className, function (elem) {\n            return pattern.test(typeof elem.className === 'string' && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute('class') || '');\n          });\n        },\n        ATTR: function (name, operator, check) {\n          return function (elem) {\n            var result = Sizzle.attr(elem, name);\n            if (result == null) {\n              return operator === '!=';\n            }\n            if (!operator) {\n              return true;\n            }\n            result += '';\n            return operator === '=' ? result === check : operator === '!=' ? result !== check : operator === '^=' ? check && result.indexOf(check) === 0 : operator === '*=' ? check && result.indexOf(check) > -1 : operator === '$=' ? check && result.slice(-check.length) === check : operator === '~=' ? (' ' + result + ' ').indexOf(check) > -1 : operator === '|=' ? result === check || result.slice(0, check.length + 1) === check + '-' : false;\n          };\n        },\n        CHILD: function (type, what, argument, first, last) {\n          var simple = type.slice(0, 3) !== 'nth', forward = type.slice(-4) !== 'last', ofType = what === 'of-type';\n          return first === 1 && last === 0 ? function (elem) {\n            return !!elem.parentNode;\n          } : function (elem, context, xml) {\n            var cache, outerCache, node, diff, nodeIndex, start, dir = simple !== forward ? 'nextSibling' : 'previousSibling', parent = elem.parentNode, name = ofType && elem.nodeName.toLowerCase(), useCache = !xml && !ofType;\n            if (parent) {\n              if (simple) {\n                while (dir) {\n                  node = elem;\n                  while (node = node[dir]) {\n                    if (ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) {\n                      return false;\n                    }\n                  }\n                  start = dir = type === 'only' && !start && 'nextSibling';\n                }\n                return true;\n              }\n              start = [forward ? parent.firstChild : parent.lastChild];\n              if (forward && useCache) {\n                outerCache = parent[expando] || (parent[expando] = {});\n                cache = outerCache[type] || [];\n                nodeIndex = cache[0] === dirruns && cache[1];\n                diff = cache[0] === dirruns && cache[2];\n                node = nodeIndex && parent.childNodes[nodeIndex];\n                while (node = ++nodeIndex && node && node[dir] || (diff = nodeIndex = 0) || start.pop()) {\n                  if (node.nodeType === 1 && ++diff && node === elem) {\n                    outerCache[type] = [\n                      dirruns,\n                      nodeIndex,\n                      diff\n                    ];\n                    break;\n                  }\n                }\n              } else if (useCache && (cache = (elem[expando] || (elem[expando] = {}))[type]) && cache[0] === dirruns) {\n                diff = cache[1];\n              } else {\n                while (node = ++nodeIndex && node && node[dir] || (diff = nodeIndex = 0) || start.pop()) {\n                  if ((ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) && ++diff) {\n                    if (useCache) {\n                      (node[expando] || (node[expando] = {}))[type] = [\n                        dirruns,\n                        diff\n                      ];\n                    }\n                    if (node === elem) {\n                      break;\n                    }\n                  }\n                }\n              }\n              diff -= last;\n              return diff === first || diff % first === 0 && diff / first >= 0;\n            }\n          };\n        },\n        PSEUDO: function (pseudo, argument) {\n          var args, fn = Expr.pseudos[pseudo] || Expr.setFilters[pseudo.toLowerCase()] || Sizzle.error('unsupported pseudo: ' + pseudo);\n          if (fn[expando]) {\n            return fn(argument);\n          }\n          if (fn.length > 1) {\n            args = [\n              pseudo,\n              pseudo,\n              '',\n              argument\n            ];\n            return Expr.setFilters.hasOwnProperty(pseudo.toLowerCase()) ? markFunction(function (seed, matches) {\n              var idx, matched = fn(seed, argument), i = matched.length;\n              while (i--) {\n                idx = indexOf.call(seed, matched[i]);\n                seed[idx] = !(matches[idx] = matched[i]);\n              }\n            }) : function (elem) {\n              return fn(elem, 0, args);\n            };\n          }\n          return fn;\n        }\n      },\n      pseudos: {\n        not: markFunction(function (selector) {\n          var input = [], results = [], matcher = compile(selector.replace(rtrim, '$1'));\n          return matcher[expando] ? markFunction(function (seed, matches, context, xml) {\n            var elem, unmatched = matcher(seed, null, xml, []), i = seed.length;\n            while (i--) {\n              if (elem = unmatched[i]) {\n                seed[i] = !(matches[i] = elem);\n              }\n            }\n          }) : function (elem, context, xml) {\n            input[0] = elem;\n            matcher(input, null, xml, results);\n            input[0] = null;\n            return !results.pop();\n          };\n        }),\n        has: markFunction(function (selector) {\n          return function (elem) {\n            return Sizzle(selector, elem).length > 0;\n          };\n        }),\n        contains: markFunction(function (text) {\n          text = text.replace(runescape, funescape);\n          return function (elem) {\n            return (elem.textContent || elem.innerText || getText(elem)).indexOf(text) > -1;\n          };\n        }),\n        lang: markFunction(function (lang) {\n          if (!ridentifier.test(lang || '')) {\n            Sizzle.error('unsupported lang: ' + lang);\n          }\n          lang = lang.replace(runescape, funescape).toLowerCase();\n          return function (elem) {\n            var elemLang;\n            do {\n              if (elemLang = documentIsHTML ? elem.lang : elem.getAttribute('xml:lang') || elem.getAttribute('lang')) {\n                elemLang = elemLang.toLowerCase();\n                return elemLang === lang || elemLang.indexOf(lang + '-') === 0;\n              }\n            } while ((elem = elem.parentNode) && elem.nodeType === 1);\n            return false;\n          };\n        }),\n        target: function (elem) {\n          var hash = window.location && window.location.hash;\n          return hash && hash.slice(1) === elem.id;\n        },\n        root: function (elem) {\n          return elem === docElem;\n        },\n        focus: function (elem) {\n          return elem === document$1.activeElement && (!document$1.hasFocus || document$1.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);\n        },\n        enabled: function (elem) {\n          return elem.disabled === false;\n        },\n        disabled: function (elem) {\n          return elem.disabled === true;\n        },\n        checked: function (elem) {\n          var nodeName = elem.nodeName.toLowerCase();\n          return nodeName === 'input' && !!elem.checked || nodeName === 'option' && !!elem.selected;\n        },\n        selected: function (elem) {\n          if (elem.parentNode) {\n            elem.parentNode.selectedIndex;\n          }\n          return elem.selected === true;\n        },\n        empty: function (elem) {\n          for (elem = elem.firstChild; elem; elem = elem.nextSibling) {\n            if (elem.nodeType < 6) {\n              return false;\n            }\n          }\n          return true;\n        },\n        parent: function (elem) {\n          return !Expr.pseudos.empty(elem);\n        },\n        header: function (elem) {\n          return rheader.test(elem.nodeName);\n        },\n        input: function (elem) {\n          return rinputs.test(elem.nodeName);\n        },\n        button: function (elem) {\n          var name = elem.nodeName.toLowerCase();\n          return name === 'input' && elem.type === 'button' || name === 'button';\n        },\n        text: function (elem) {\n          var attr;\n          return elem.nodeName.toLowerCase() === 'input' && elem.type === 'text' && ((attr = elem.getAttribute('type')) == null || attr.toLowerCase() === 'text');\n        },\n        first: createPositionalPseudo(function () {\n          return [0];\n        }),\n        last: createPositionalPseudo(function (matchIndexes, length) {\n          return [length - 1];\n        }),\n        eq: createPositionalPseudo(function (matchIndexes, length, argument) {\n          return [argument < 0 ? argument + length : argument];\n        }),\n        even: createPositionalPseudo(function (matchIndexes, length) {\n          var i = 0;\n          for (; i < length; i += 2) {\n            matchIndexes.push(i);\n          }\n          return matchIndexes;\n        }),\n        odd: createPositionalPseudo(function (matchIndexes, length) {\n          var i = 1;\n          for (; i < length; i += 2) {\n            matchIndexes.push(i);\n          }\n          return matchIndexes;\n        }),\n        lt: createPositionalPseudo(function (matchIndexes, length, argument) {\n          var i = argument < 0 ? argument + length : argument;\n          for (; --i >= 0;) {\n            matchIndexes.push(i);\n          }\n          return matchIndexes;\n        }),\n        gt: createPositionalPseudo(function (matchIndexes, length, argument) {\n          var i = argument < 0 ? argument + length : argument;\n          for (; ++i < length;) {\n            matchIndexes.push(i);\n          }\n          return matchIndexes;\n        })\n      }\n    };\n    Expr.pseudos.nth = Expr.pseudos.eq;\n    each$k([\n      'radio',\n      'checkbox',\n      'file',\n      'password',\n      'image'\n    ], function (i) {\n      Expr.pseudos[i] = createInputPseudo(i);\n    });\n    each$k([\n      'submit',\n      'reset'\n    ], function (i) {\n      Expr.pseudos[i] = createButtonPseudo(i);\n    });\n    function setFilters() {\n    }\n    setFilters.prototype = Expr.filters = Expr.pseudos;\n    Expr.setFilters = new setFilters();\n    tokenize = Sizzle.tokenize = function (selector, parseOnly) {\n      var matched, match, tokens, type, soFar, groups, preFilters, cached = tokenCache[selector + ' '];\n      if (cached) {\n        return parseOnly ? 0 : cached.slice(0);\n      }\n      soFar = selector;\n      groups = [];\n      preFilters = Expr.preFilter;\n      while (soFar) {\n        if (!matched || (match = rcomma.exec(soFar))) {\n          if (match) {\n            soFar = soFar.slice(match[0].length) || soFar;\n          }\n          groups.push(tokens = []);\n        }\n        matched = false;\n        if (match = rcombinators.exec(soFar)) {\n          matched = match.shift();\n          tokens.push({\n            value: matched,\n            type: match[0].replace(rtrim, ' ')\n          });\n          soFar = soFar.slice(matched.length);\n        }\n        for (type in Expr.filter) {\n          if (!Expr.filter.hasOwnProperty(type)) {\n            continue;\n          }\n          if ((match = matchExpr[type].exec(soFar)) && (!preFilters[type] || (match = preFilters[type](match)))) {\n            matched = match.shift();\n            tokens.push({\n              value: matched,\n              type: type,\n              matches: match\n            });\n            soFar = soFar.slice(matched.length);\n          }\n        }\n        if (!matched) {\n          break;\n        }\n      }\n      return parseOnly ? soFar.length : soFar ? Sizzle.error(selector) : tokenCache(selector, groups).slice(0);\n    };\n    function toSelector(tokens) {\n      var i = 0, len = tokens.length, selector = '';\n      for (; i < len; i++) {\n        selector += tokens[i].value;\n      }\n      return selector;\n    }\n    function addCombinator(matcher, combinator, base) {\n      var dir = combinator.dir, checkNonElements = base && dir === 'parentNode', doneName = done++;\n      return combinator.first ? function (elem, context, xml) {\n        while (elem = elem[dir]) {\n          if (elem.nodeType === 1 || checkNonElements) {\n            return matcher(elem, context, xml);\n          }\n        }\n      } : function (elem, context, xml) {\n        var oldCache, outerCache, newCache = [\n            dirruns,\n            doneName\n          ];\n        if (xml) {\n          while (elem = elem[dir]) {\n            if (elem.nodeType === 1 || checkNonElements) {\n              if (matcher(elem, context, xml)) {\n                return true;\n              }\n            }\n          }\n        } else {\n          while (elem = elem[dir]) {\n            if (elem.nodeType === 1 || checkNonElements) {\n              outerCache = elem[expando] || (elem[expando] = {});\n              if ((oldCache = outerCache[dir]) && oldCache[0] === dirruns && oldCache[1] === doneName) {\n                return newCache[2] = oldCache[2];\n              } else {\n                outerCache[dir] = newCache;\n                if (newCache[2] = matcher(elem, context, xml)) {\n                  return true;\n                }\n              }\n            }\n          }\n        }\n      };\n    }\n    function elementMatcher(matchers) {\n      return matchers.length > 1 ? function (elem, context, xml) {\n        var i = matchers.length;\n        while (i--) {\n          if (!matchers[i](elem, context, xml)) {\n            return false;\n          }\n        }\n        return true;\n      } : matchers[0];\n    }\n    function multipleContexts(selector, contexts, results) {\n      var i = 0, len = contexts.length;\n      for (; i < len; i++) {\n        Sizzle(selector, contexts[i], results);\n      }\n      return results;\n    }\n    function condense(unmatched, map, filter, context, xml) {\n      var elem, newUnmatched = [], i = 0, len = unmatched.length, mapped = map != null;\n      for (; i < len; i++) {\n        if (elem = unmatched[i]) {\n          if (!filter || filter(elem, context, xml)) {\n            newUnmatched.push(elem);\n            if (mapped) {\n              map.push(i);\n            }\n          }\n        }\n      }\n      return newUnmatched;\n    }\n    function setMatcher(preFilter, selector, matcher, postFilter, postFinder, postSelector) {\n      if (postFilter && !postFilter[expando]) {\n        postFilter = setMatcher(postFilter);\n      }\n      if (postFinder && !postFinder[expando]) {\n        postFinder = setMatcher(postFinder, postSelector);\n      }\n      return markFunction(function (seed, results, context, xml) {\n        var temp, i, elem, preMap = [], postMap = [], preexisting = results.length, elems = seed || multipleContexts(selector || '*', context.nodeType ? [context] : context, []), matcherIn = preFilter && (seed || !selector) ? condense(elems, preMap, preFilter, context, xml) : elems, matcherOut = matcher ? postFinder || (seed ? preFilter : preexisting || postFilter) ? [] : results : matcherIn;\n        if (matcher) {\n          matcher(matcherIn, matcherOut, context, xml);\n        }\n        if (postFilter) {\n          temp = condense(matcherOut, postMap);\n          postFilter(temp, [], context, xml);\n          i = temp.length;\n          while (i--) {\n            if (elem = temp[i]) {\n              matcherOut[postMap[i]] = !(matcherIn[postMap[i]] = elem);\n            }\n          }\n        }\n        if (seed) {\n          if (postFinder || preFilter) {\n            if (postFinder) {\n              temp = [];\n              i = matcherOut.length;\n              while (i--) {\n                if (elem = matcherOut[i]) {\n                  temp.push(matcherIn[i] = elem);\n                }\n              }\n              postFinder(null, matcherOut = [], temp, xml);\n            }\n            i = matcherOut.length;\n            while (i--) {\n              if ((elem = matcherOut[i]) && (temp = postFinder ? indexOf.call(seed, elem) : preMap[i]) > -1) {\n                seed[temp] = !(results[temp] = elem);\n              }\n            }\n          }\n        } else {\n          matcherOut = condense(matcherOut === results ? matcherOut.splice(preexisting, matcherOut.length) : matcherOut);\n          if (postFinder) {\n            postFinder(null, results, matcherOut, xml);\n          } else {\n            push$1.apply(results, matcherOut);\n          }\n        }\n      });\n    }\n    function matcherFromTokens(tokens) {\n      var checkContext, matcher, j, len = tokens.length, leadingRelative = Expr.relative[tokens[0].type], implicitRelative = leadingRelative || Expr.relative[' '], i = leadingRelative ? 1 : 0, matchContext = addCombinator(function (elem) {\n          return elem === checkContext;\n        }, implicitRelative, true), matchAnyContext = addCombinator(function (elem) {\n          return indexOf.call(checkContext, elem) > -1;\n        }, implicitRelative, true), matchers = [function (elem, context, xml) {\n            var ret = !leadingRelative && (xml || context !== outermostContext) || ((checkContext = context).nodeType ? matchContext(elem, context, xml) : matchAnyContext(elem, context, xml));\n            checkContext = null;\n            return ret;\n          }];\n      for (; i < len; i++) {\n        if (matcher = Expr.relative[tokens[i].type]) {\n          matchers = [addCombinator(elementMatcher(matchers), matcher)];\n        } else {\n          matcher = Expr.filter[tokens[i].type].apply(null, tokens[i].matches);\n          if (matcher[expando]) {\n            j = ++i;\n            for (; j < len; j++) {\n              if (Expr.relative[tokens[j].type]) {\n                break;\n              }\n            }\n            return setMatcher(i > 1 && elementMatcher(matchers), i > 1 && toSelector(tokens.slice(0, i - 1).concat({ value: tokens[i - 2].type === ' ' ? '*' : '' })).replace(rtrim, '$1'), matcher, i < j && matcherFromTokens(tokens.slice(i, j)), j < len && matcherFromTokens(tokens = tokens.slice(j)), j < len && toSelector(tokens));\n          }\n          matchers.push(matcher);\n        }\n      }\n      return elementMatcher(matchers);\n    }\n    function matcherFromGroupMatchers(elementMatchers, setMatchers) {\n      var bySet = setMatchers.length > 0, byElement = elementMatchers.length > 0, superMatcher = function (seed, context, xml, results, outermost) {\n          var elem, j, matcher, matchedCount = 0, i = '0', unmatched = seed && [], setMatched = [], contextBackup = outermostContext, elems = seed || byElement && Expr.find.TAG('*', outermost), dirrunsUnique = dirruns += contextBackup == null ? 1 : Math.random() || 0.1, len = elems.length;\n          if (outermost) {\n            outermostContext = context !== document$1 && context;\n          }\n          for (; i !== len && (elem = elems[i]) != null; i++) {\n            if (byElement && elem) {\n              j = 0;\n              while (matcher = elementMatchers[j++]) {\n                if (matcher(elem, context, xml)) {\n                  results.push(elem);\n                  break;\n                }\n              }\n              if (outermost) {\n                dirruns = dirrunsUnique;\n              }\n            }\n            if (bySet) {\n              if (elem = !matcher && elem) {\n                matchedCount--;\n              }\n              if (seed) {\n                unmatched.push(elem);\n              }\n            }\n          }\n          matchedCount += i;\n          if (bySet && i !== matchedCount) {\n            j = 0;\n            while (matcher = setMatchers[j++]) {\n              matcher(unmatched, setMatched, context, xml);\n            }\n            if (seed) {\n              if (matchedCount > 0) {\n                while (i--) {\n                  if (!(unmatched[i] || setMatched[i])) {\n                    setMatched[i] = pop.call(results);\n                  }\n                }\n              }\n              setMatched = condense(setMatched);\n            }\n            push$1.apply(results, setMatched);\n            if (outermost && !seed && setMatched.length > 0 && matchedCount + setMatchers.length > 1) {\n              Sizzle.uniqueSort(results);\n            }\n          }\n          if (outermost) {\n            dirruns = dirrunsUnique;\n            outermostContext = contextBackup;\n          }\n          return unmatched;\n        };\n      return bySet ? markFunction(superMatcher) : superMatcher;\n    }\n    compile = Sizzle.compile = function (selector, match) {\n      var i, setMatchers = [], elementMatchers = [], cached = compilerCache[selector + ' '];\n      if (!cached) {\n        if (!match) {\n          match = tokenize(selector);\n        }\n        i = match.length;\n        while (i--) {\n          cached = matcherFromTokens(match[i]);\n          if (cached[expando]) {\n            setMatchers.push(cached);\n          } else {\n            elementMatchers.push(cached);\n          }\n        }\n        cached = compilerCache(selector, matcherFromGroupMatchers(elementMatchers, setMatchers));\n        cached.selector = selector;\n      }\n      return cached;\n    };\n    select$1 = Sizzle.select = function (selector, context, results, seed) {\n      var i, tokens, token, type, find, compiled = typeof selector === 'function' && selector, match = !seed && tokenize(selector = compiled.selector || selector);\n      results = results || [];\n      if (match.length === 1) {\n        tokens = match[0] = match[0].slice(0);\n        if (tokens.length > 2 && (token = tokens[0]).type === 'ID' && support.getById && context.nodeType === 9 && documentIsHTML && Expr.relative[tokens[1].type]) {\n          context = (Expr.find.ID(token.matches[0].replace(runescape, funescape), context) || [])[0];\n          if (!context) {\n            return results;\n          } else if (compiled) {\n            context = context.parentNode;\n          }\n          selector = selector.slice(tokens.shift().value.length);\n        }\n        i = matchExpr.needsContext.test(selector) ? 0 : tokens.length;\n        while (i--) {\n          token = tokens[i];\n          if (Expr.relative[type = token.type]) {\n            break;\n          }\n          if (find = Expr.find[type]) {\n            if (seed = find(token.matches[0].replace(runescape, funescape), rsibling.test(tokens[0].type) && testContext(context.parentNode) || context)) {\n              tokens.splice(i, 1);\n              selector = seed.length && toSelector(tokens);\n              if (!selector) {\n                push$1.apply(results, seed);\n                return results;\n              }\n              break;\n            }\n          }\n        }\n      }\n      (compiled || compile(selector, match))(seed, context, !documentIsHTML, results, rsibling.test(selector) && testContext(context.parentNode) || context);\n      return results;\n    };\n    support.sortStable = expando.split('').sort(sortOrder).join('') === expando;\n    support.detectDuplicates = !!hasDuplicate;\n    setDocument();\n    support.sortDetached = true;\n\n    var doc = document;\n    var push = Array.prototype.push;\n    var slice = Array.prototype.slice;\n    var rquickExpr = /^(?:[^#<]*(<[\\w\\W]+>)[^>]*$|#([\\w\\-]*)$)/;\n    var Event$1 = EventUtils.Event;\n    var skipUniques = Tools.makeMap('children,contents,next,prev');\n    var isDefined = function (obj) {\n      return typeof obj !== 'undefined';\n    };\n    var isString = function (obj) {\n      return typeof obj === 'string';\n    };\n    var isWindow = function (obj) {\n      return obj && obj === obj.window;\n    };\n    var createFragment$1 = function (html, fragDoc) {\n      fragDoc = fragDoc || doc;\n      var container = fragDoc.createElement('div');\n      var frag = fragDoc.createDocumentFragment();\n      container.innerHTML = html;\n      var node;\n      while (node = container.firstChild) {\n        frag.appendChild(node);\n      }\n      return frag;\n    };\n    var domManipulate = function (targetNodes, sourceItem, callback, reverse) {\n      var i;\n      if (isString(sourceItem)) {\n        sourceItem = createFragment$1(sourceItem, getElementDocument(targetNodes[0]));\n      } else if (sourceItem.length && !sourceItem.nodeType) {\n        sourceItem = DomQuery.makeArray(sourceItem);\n        if (reverse) {\n          for (i = sourceItem.length - 1; i >= 0; i--) {\n            domManipulate(targetNodes, sourceItem[i], callback, reverse);\n          }\n        } else {\n          for (i = 0; i < sourceItem.length; i++) {\n            domManipulate(targetNodes, sourceItem[i], callback, reverse);\n          }\n        }\n        return targetNodes;\n      }\n      if (sourceItem.nodeType) {\n        i = targetNodes.length;\n        while (i--) {\n          callback.call(targetNodes[i], sourceItem);\n        }\n      }\n      return targetNodes;\n    };\n    var hasClass = function (node, className) {\n      return node && className && (' ' + node.className + ' ').indexOf(' ' + className + ' ') !== -1;\n    };\n    var wrap$2 = function (elements, wrapper, all) {\n      var lastParent, newWrapper;\n      wrapper = DomQuery(wrapper)[0];\n      elements.each(function () {\n        var self = this;\n        if (!all || lastParent !== self.parentNode) {\n          lastParent = self.parentNode;\n          newWrapper = wrapper.cloneNode(false);\n          self.parentNode.insertBefore(newWrapper, self);\n          newWrapper.appendChild(self);\n        } else {\n          newWrapper.appendChild(self);\n        }\n      });\n      return elements;\n    };\n    var numericCssMap = Tools.makeMap('fillOpacity fontWeight lineHeight opacity orphans widows zIndex zoom', ' ');\n    var booleanMap = Tools.makeMap('checked compact declare defer disabled ismap multiple nohref noshade nowrap readonly selected', ' ');\n    var propFix = {\n      for: 'htmlFor',\n      class: 'className',\n      readonly: 'readOnly'\n    };\n    var cssFix = { float: 'cssFloat' };\n    var attrHooks = {}, cssHooks = {};\n    var DomQueryConstructor = function (selector, context) {\n      return new DomQuery.fn.init(selector, context);\n    };\n    var inArray$1 = function (item, array) {\n      var i;\n      if (array.indexOf) {\n        return array.indexOf(item);\n      }\n      i = array.length;\n      while (i--) {\n        if (array[i] === item) {\n          return i;\n        }\n      }\n      return -1;\n    };\n    var whiteSpaceRegExp = /^\\s*|\\s*$/g;\n    var trim$2 = function (str) {\n      return str === null || str === undefined ? '' : ('' + str).replace(whiteSpaceRegExp, '');\n    };\n    var each$g = function (obj, callback) {\n      var length, key, i, value;\n      if (obj) {\n        length = obj.length;\n        if (length === undefined) {\n          for (key in obj) {\n            if (obj.hasOwnProperty(key)) {\n              value = obj[key];\n              if (callback.call(value, key, value) === false) {\n                break;\n              }\n            }\n          }\n        } else {\n          for (i = 0; i < length; i++) {\n            value = obj[i];\n            if (callback.call(value, i, value) === false) {\n              break;\n            }\n          }\n        }\n      }\n      return obj;\n    };\n    var grep$2 = function (array, callback) {\n      var out = [];\n      each$g(array, function (i, item) {\n        if (callback(item, i)) {\n          out.push(item);\n        }\n      });\n      return out;\n    };\n    var getElementDocument = function (element) {\n      if (!element) {\n        return doc;\n      }\n      if (element.nodeType === 9) {\n        return element;\n      }\n      return element.ownerDocument;\n    };\n    DomQueryConstructor.fn = DomQueryConstructor.prototype = {\n      constructor: DomQueryConstructor,\n      selector: '',\n      context: null,\n      length: 0,\n      init: function (selector, context) {\n        var self = this;\n        var match, node;\n        if (!selector) {\n          return self;\n        }\n        if (selector.nodeType) {\n          self.context = self[0] = selector;\n          self.length = 1;\n          return self;\n        }\n        if (context && context.nodeType) {\n          self.context = context;\n        } else {\n          if (context) {\n            return DomQuery(selector).attr(context);\n          }\n          self.context = context = document;\n        }\n        if (isString(selector)) {\n          self.selector = selector;\n          if (selector.charAt(0) === '<' && selector.charAt(selector.length - 1) === '>' && selector.length >= 3) {\n            match = [\n              null,\n              selector,\n              null\n            ];\n          } else {\n            match = rquickExpr.exec(selector);\n          }\n          if (match) {\n            if (match[1]) {\n              node = createFragment$1(selector, getElementDocument(context)).firstChild;\n              while (node) {\n                push.call(self, node);\n                node = node.nextSibling;\n              }\n            } else {\n              node = getElementDocument(context).getElementById(match[2]);\n              if (!node) {\n                return self;\n              }\n              if (node.id !== match[2]) {\n                return self.find(selector);\n              }\n              self.length = 1;\n              self[0] = node;\n            }\n          } else {\n            return DomQuery(context).find(selector);\n          }\n        } else {\n          this.add(selector, false);\n        }\n        return self;\n      },\n      toArray: function () {\n        return Tools.toArray(this);\n      },\n      add: function (items, sort) {\n        var self = this;\n        var nodes, i;\n        if (isString(items)) {\n          return self.add(DomQuery(items));\n        }\n        if (sort !== false) {\n          nodes = DomQuery.unique(self.toArray().concat(DomQuery.makeArray(items)));\n          self.length = nodes.length;\n          for (i = 0; i < nodes.length; i++) {\n            self[i] = nodes[i];\n          }\n        } else {\n          push.apply(self, DomQuery.makeArray(items));\n        }\n        return self;\n      },\n      attr: function (name, value) {\n        var self = this;\n        var hook;\n        if (typeof name === 'object') {\n          each$g(name, function (name, value) {\n            self.attr(name, value);\n          });\n        } else if (isDefined(value)) {\n          this.each(function () {\n            var hook;\n            if (this.nodeType === 1) {\n              hook = attrHooks[name];\n              if (hook && hook.set) {\n                hook.set(this, value);\n                return;\n              }\n              if (value === null) {\n                this.removeAttribute(name, 2);\n              } else {\n                this.setAttribute(name, value, 2);\n              }\n            }\n          });\n        } else {\n          if (self[0] && self[0].nodeType === 1) {\n            hook = attrHooks[name];\n            if (hook && hook.get) {\n              return hook.get(self[0], name);\n            }\n            if (booleanMap[name]) {\n              return self.prop(name) ? name : undefined;\n            }\n            value = self[0].getAttribute(name, 2);\n            if (value === null) {\n              value = undefined;\n            }\n          }\n          return value;\n        }\n        return self;\n      },\n      removeAttr: function (name) {\n        return this.attr(name, null);\n      },\n      prop: function (name, value) {\n        var self = this;\n        name = propFix[name] || name;\n        if (typeof name === 'object') {\n          each$g(name, function (name, value) {\n            self.prop(name, value);\n          });\n        } else if (isDefined(value)) {\n          this.each(function () {\n            if (this.nodeType === 1) {\n              this[name] = value;\n            }\n          });\n        } else {\n          if (self[0] && self[0].nodeType && name in self[0]) {\n            return self[0][name];\n          }\n          return value;\n        }\n        return self;\n      },\n      css: function (name, value) {\n        var self = this;\n        var elm, hook;\n        var camel = function (name) {\n          return name.replace(/-(\\D)/g, function (a, b) {\n            return b.toUpperCase();\n          });\n        };\n        var dashed = function (name) {\n          return name.replace(/[A-Z]/g, function (a) {\n            return '-' + a;\n          });\n        };\n        if (typeof name === 'object') {\n          each$g(name, function (name, value) {\n            self.css(name, value);\n          });\n        } else {\n          if (isDefined(value)) {\n            name = camel(name);\n            if (typeof value === 'number' && !numericCssMap[name]) {\n              value = value.toString() + 'px';\n            }\n            self.each(function () {\n              var style = this.style;\n              hook = cssHooks[name];\n              if (hook && hook.set) {\n                hook.set(this, value);\n                return;\n              }\n              try {\n                this.style[cssFix[name] || name] = value;\n              } catch (ex) {\n              }\n              if (value === null || value === '') {\n                if (style.removeProperty) {\n                  style.removeProperty(dashed(name));\n                } else {\n                  style.removeAttribute(name);\n                }\n              }\n            });\n          } else {\n            elm = self[0];\n            hook = cssHooks[name];\n            if (hook && hook.get) {\n              return hook.get(elm);\n            }\n            if (elm.ownerDocument.defaultView) {\n              try {\n                return elm.ownerDocument.defaultView.getComputedStyle(elm, null).getPropertyValue(dashed(name));\n              } catch (ex) {\n                return undefined;\n              }\n            } else if (elm.currentStyle) {\n              return elm.currentStyle[camel(name)];\n            } else {\n              return '';\n            }\n          }\n        }\n        return self;\n      },\n      remove: function () {\n        var self = this;\n        var node, i = this.length;\n        while (i--) {\n          node = self[i];\n          Event$1.clean(node);\n          if (node.parentNode) {\n            node.parentNode.removeChild(node);\n          }\n        }\n        return this;\n      },\n      empty: function () {\n        var self = this;\n        var node, i = this.length;\n        while (i--) {\n          node = self[i];\n          while (node.firstChild) {\n            node.removeChild(node.firstChild);\n          }\n        }\n        return this;\n      },\n      html: function (value) {\n        var self = this;\n        var i;\n        if (isDefined(value)) {\n          i = self.length;\n          try {\n            while (i--) {\n              self[i].innerHTML = value;\n            }\n          } catch (ex) {\n            DomQuery(self[i]).empty().append(value);\n          }\n          return self;\n        }\n        return self[0] ? self[0].innerHTML : '';\n      },\n      text: function (value) {\n        var self = this;\n        var i;\n        if (isDefined(value)) {\n          i = self.length;\n          while (i--) {\n            if ('innerText' in self[i]) {\n              self[i].innerText = value;\n            } else {\n              self[0].textContent = value;\n            }\n          }\n          return self;\n        }\n        return self[0] ? self[0].innerText || self[0].textContent : '';\n      },\n      append: function () {\n        return domManipulate(this, arguments, function (node) {\n          if (this.nodeType === 1 || this.host && this.host.nodeType === 1) {\n            this.appendChild(node);\n          }\n        });\n      },\n      prepend: function () {\n        return domManipulate(this, arguments, function (node) {\n          if (this.nodeType === 1 || this.host && this.host.nodeType === 1) {\n            this.insertBefore(node, this.firstChild);\n          }\n        }, true);\n      },\n      before: function () {\n        var self = this;\n        if (self[0] && self[0].parentNode) {\n          return domManipulate(self, arguments, function (node) {\n            this.parentNode.insertBefore(node, this);\n          });\n        }\n        return self;\n      },\n      after: function () {\n        var self = this;\n        if (self[0] && self[0].parentNode) {\n          return domManipulate(self, arguments, function (node) {\n            this.parentNode.insertBefore(node, this.nextSibling);\n          }, true);\n        }\n        return self;\n      },\n      appendTo: function (val) {\n        DomQuery(val).append(this);\n        return this;\n      },\n      prependTo: function (val) {\n        DomQuery(val).prepend(this);\n        return this;\n      },\n      replaceWith: function (content) {\n        return this.before(content).remove();\n      },\n      wrap: function (content) {\n        return wrap$2(this, content);\n      },\n      wrapAll: function (content) {\n        return wrap$2(this, content, true);\n      },\n      wrapInner: function (content) {\n        this.each(function () {\n          DomQuery(this).contents().wrapAll(content);\n        });\n        return this;\n      },\n      unwrap: function () {\n        return this.parent().each(function () {\n          DomQuery(this).replaceWith(this.childNodes);\n        });\n      },\n      clone: function () {\n        var result = [];\n        this.each(function () {\n          result.push(this.cloneNode(true));\n        });\n        return DomQuery(result);\n      },\n      addClass: function (className) {\n        return this.toggleClass(className, true);\n      },\n      removeClass: function (className) {\n        return this.toggleClass(className, false);\n      },\n      toggleClass: function (className, state) {\n        var self = this;\n        if (typeof className !== 'string') {\n          return self;\n        }\n        if (className.indexOf(' ') !== -1) {\n          each$g(className.split(' '), function () {\n            self.toggleClass(this, state);\n          });\n        } else {\n          self.each(function (index, node) {\n            var classState = hasClass(node, className);\n            if (classState !== state) {\n              var existingClassName = node.className;\n              if (classState) {\n                node.className = trim$2((' ' + existingClassName + ' ').replace(' ' + className + ' ', ' '));\n              } else {\n                node.className += existingClassName ? ' ' + className : className;\n              }\n            }\n          });\n        }\n        return self;\n      },\n      hasClass: function (className) {\n        return hasClass(this[0], className);\n      },\n      each: function (callback) {\n        return each$g(this, callback);\n      },\n      on: function (name, callback) {\n        return this.each(function () {\n          Event$1.bind(this, name, callback);\n        });\n      },\n      off: function (name, callback) {\n        return this.each(function () {\n          Event$1.unbind(this, name, callback);\n        });\n      },\n      trigger: function (name) {\n        return this.each(function () {\n          if (typeof name === 'object') {\n            Event$1.fire(this, name.type, name);\n          } else {\n            Event$1.fire(this, name);\n          }\n        });\n      },\n      show: function () {\n        return this.css('display', '');\n      },\n      hide: function () {\n        return this.css('display', 'none');\n      },\n      slice: function () {\n        return DomQuery(slice.apply(this, arguments));\n      },\n      eq: function (index) {\n        return index === -1 ? this.slice(index) : this.slice(index, +index + 1);\n      },\n      first: function () {\n        return this.eq(0);\n      },\n      last: function () {\n        return this.eq(-1);\n      },\n      find: function (selector) {\n        var i, l;\n        var ret = [];\n        for (i = 0, l = this.length; i < l; i++) {\n          DomQuery.find(selector, this[i], ret);\n        }\n        return DomQuery(ret);\n      },\n      filter: function (selector) {\n        if (typeof selector === 'function') {\n          return DomQuery(grep$2(this.toArray(), function (item, i) {\n            return selector(i, item);\n          }));\n        }\n        return DomQuery(DomQuery.filter(selector, this.toArray()));\n      },\n      closest: function (selector) {\n        var result = [];\n        if (selector instanceof DomQuery) {\n          selector = selector[0];\n        }\n        this.each(function (i, node) {\n          while (node) {\n            if (typeof selector === 'string' && DomQuery(node).is(selector)) {\n              result.push(node);\n              break;\n            } else if (node === selector) {\n              result.push(node);\n              break;\n            }\n            node = node.parentNode;\n          }\n        });\n        return DomQuery(result);\n      },\n      offset: function (offset) {\n        var elm, doc, docElm;\n        var x = 0, y = 0, pos;\n        if (!offset) {\n          elm = this[0];\n          if (elm) {\n            doc = elm.ownerDocument;\n            docElm = doc.documentElement;\n            if (elm.getBoundingClientRect) {\n              pos = elm.getBoundingClientRect();\n              x = pos.left + (docElm.scrollLeft || doc.body.scrollLeft) - docElm.clientLeft;\n              y = pos.top + (docElm.scrollTop || doc.body.scrollTop) - docElm.clientTop;\n            }\n          }\n          return {\n            left: x,\n            top: y\n          };\n        }\n        return this.css(offset);\n      },\n      push: push,\n      sort: Array.prototype.sort,\n      splice: Array.prototype.splice\n    };\n    Tools.extend(DomQueryConstructor, {\n      extend: Tools.extend,\n      makeArray: function (object) {\n        if (isWindow(object) || object.nodeType) {\n          return [object];\n        }\n        return Tools.toArray(object);\n      },\n      inArray: inArray$1,\n      isArray: Tools.isArray,\n      each: each$g,\n      trim: trim$2,\n      grep: grep$2,\n      find: Sizzle,\n      expr: Sizzle.selectors,\n      unique: Sizzle.uniqueSort,\n      text: Sizzle.getText,\n      contains: Sizzle.contains,\n      filter: function (expr, elems, not) {\n        var i = elems.length;\n        if (not) {\n          expr = ':not(' + expr + ')';\n        }\n        while (i--) {\n          if (elems[i].nodeType !== 1) {\n            elems.splice(i, 1);\n          }\n        }\n        if (elems.length === 1) {\n          elems = DomQuery.find.matchesSelector(elems[0], expr) ? [elems[0]] : [];\n        } else {\n          elems = DomQuery.find.matches(expr, elems);\n        }\n        return elems;\n      }\n    });\n    var dir = function (el, prop, until) {\n      var matched = [];\n      var cur = el[prop];\n      if (typeof until !== 'string' && until instanceof DomQuery) {\n        until = until[0];\n      }\n      while (cur && cur.nodeType !== 9) {\n        if (until !== undefined) {\n          if (cur === until) {\n            break;\n          }\n          if (typeof until === 'string' && DomQuery(cur).is(until)) {\n            break;\n          }\n        }\n        if (cur.nodeType === 1) {\n          matched.push(cur);\n        }\n        cur = cur[prop];\n      }\n      return matched;\n    };\n    var sibling$1 = function (node, siblingName, nodeType, until) {\n      var result = [];\n      if (until instanceof DomQuery) {\n        until = until[0];\n      }\n      for (; node; node = node[siblingName]) {\n        if (nodeType && node.nodeType !== nodeType) {\n          continue;\n        }\n        if (until !== undefined) {\n          if (node === until) {\n            break;\n          }\n          if (typeof until === 'string' && DomQuery(node).is(until)) {\n            break;\n          }\n        }\n        result.push(node);\n      }\n      return result;\n    };\n    var firstSibling = function (node, siblingName, nodeType) {\n      for (node = node[siblingName]; node; node = node[siblingName]) {\n        if (node.nodeType === nodeType) {\n          return node;\n        }\n      }\n      return null;\n    };\n    each$g({\n      parent: function (node) {\n        var parent = node.parentNode;\n        return parent && parent.nodeType !== 11 ? parent : null;\n      },\n      parents: function (node) {\n        return dir(node, 'parentNode');\n      },\n      next: function (node) {\n        return firstSibling(node, 'nextSibling', 1);\n      },\n      prev: function (node) {\n        return firstSibling(node, 'previousSibling', 1);\n      },\n      children: function (node) {\n        return sibling$1(node.firstChild, 'nextSibling', 1);\n      },\n      contents: function (node) {\n        return Tools.toArray((node.nodeName === 'iframe' ? node.contentDocument || node.contentWindow.document : node).childNodes);\n      }\n    }, function (name, fn) {\n      DomQueryConstructor.fn[name] = function (selector) {\n        var self = this;\n        var result = [];\n        self.each(function () {\n          var nodes = fn.call(result, this, selector, result);\n          if (nodes) {\n            if (DomQuery.isArray(nodes)) {\n              result.push.apply(result, nodes);\n            } else {\n              result.push(nodes);\n            }\n          }\n        });\n        if (this.length > 1) {\n          if (!skipUniques[name]) {\n            result = DomQuery.unique(result);\n          }\n          if (name.indexOf('parents') === 0) {\n            result = result.reverse();\n          }\n        }\n        var wrappedResult = DomQuery(result);\n        if (selector) {\n          return wrappedResult.filter(selector);\n        }\n        return wrappedResult;\n      };\n    });\n    each$g({\n      parentsUntil: function (node, until) {\n        return dir(node, 'parentNode', until);\n      },\n      nextUntil: function (node, until) {\n        return sibling$1(node, 'nextSibling', 1, until).slice(1);\n      },\n      prevUntil: function (node, until) {\n        return sibling$1(node, 'previousSibling', 1, until).slice(1);\n      }\n    }, function (name, fn) {\n      DomQueryConstructor.fn[name] = function (selector, filter) {\n        var self = this;\n        var result = [];\n        self.each(function () {\n          var nodes = fn.call(result, this, selector, result);\n          if (nodes) {\n            if (DomQuery.isArray(nodes)) {\n              result.push.apply(result, nodes);\n            } else {\n              result.push(nodes);\n            }\n          }\n        });\n        if (this.length > 1) {\n          result = DomQuery.unique(result);\n          if (name.indexOf('parents') === 0 || name === 'prevUntil') {\n            result = result.reverse();\n          }\n        }\n        var wrappedResult = DomQuery(result);\n        if (filter) {\n          return wrappedResult.filter(filter);\n        }\n        return wrappedResult;\n      };\n    });\n    DomQueryConstructor.fn.is = function (selector) {\n      return !!selector && this.filter(selector).length > 0;\n    };\n    DomQueryConstructor.fn.init.prototype = DomQueryConstructor.fn;\n    DomQueryConstructor.overrideDefaults = function (callback) {\n      var defaults;\n      var sub = function (selector, context) {\n        defaults = defaults || callback();\n        if (arguments.length === 0) {\n          selector = defaults.element;\n        }\n        if (!context) {\n          context = defaults.context;\n        }\n        return new sub.fn.init(selector, context);\n      };\n      DomQuery.extend(sub, this);\n      return sub;\n    };\n    DomQueryConstructor.attrHooks = attrHooks;\n    DomQueryConstructor.cssHooks = cssHooks;\n    var DomQuery = DomQueryConstructor;\n\n    var each$f = Tools.each;\n    var grep$1 = Tools.grep;\n    var isIE = Env.ie;\n    var simpleSelectorRe = /^([a-z0-9],?)+$/i;\n    var setupAttrHooks = function (styles, settings, getContext) {\n      var keepValues = settings.keep_values;\n      var keepUrlHook = {\n        set: function ($elm, value, name) {\n          if (settings.url_converter && value !== null) {\n            value = settings.url_converter.call(settings.url_converter_scope || getContext(), value, name, $elm[0]);\n          }\n          $elm.attr('data-mce-' + name, value).attr(name, value);\n        },\n        get: function ($elm, name) {\n          return $elm.attr('data-mce-' + name) || $elm.attr(name);\n        }\n      };\n      var attrHooks = {\n        style: {\n          set: function ($elm, value) {\n            if (value !== null && typeof value === 'object') {\n              $elm.css(value);\n              return;\n            }\n            if (keepValues) {\n              $elm.attr('data-mce-style', value);\n            }\n            if (value !== null && typeof value === 'string') {\n              $elm.removeAttr('style');\n              $elm.css(styles.parse(value));\n            } else {\n              $elm.attr('style', value);\n            }\n          },\n          get: function ($elm) {\n            var value = $elm.attr('data-mce-style') || $elm.attr('style');\n            value = styles.serialize(styles.parse(value), $elm[0].nodeName);\n            return value;\n          }\n        }\n      };\n      if (keepValues) {\n        attrHooks.href = attrHooks.src = keepUrlHook;\n      }\n      return attrHooks;\n    };\n    var updateInternalStyleAttr = function (styles, $elm) {\n      var rawValue = $elm.attr('style');\n      var value = styles.serialize(styles.parse(rawValue), $elm[0].nodeName);\n      if (!value) {\n        value = null;\n      }\n      $elm.attr('data-mce-style', value);\n    };\n    var findNodeIndex = function (node, normalized) {\n      var idx = 0, lastNodeType, nodeType;\n      if (node) {\n        for (lastNodeType = node.nodeType, node = node.previousSibling; node; node = node.previousSibling) {\n          nodeType = node.nodeType;\n          if (normalized && nodeType === 3) {\n            if (nodeType === lastNodeType || !node.nodeValue.length) {\n              continue;\n            }\n          }\n          idx++;\n          lastNodeType = nodeType;\n        }\n      }\n      return idx;\n    };\n    var DOMUtils = function (doc, settings) {\n      if (settings === void 0) {\n        settings = {};\n      }\n      var addedStyles = {};\n      var win = window;\n      var files = {};\n      var counter = 0;\n      var stdMode = true;\n      var boxModel = true;\n      var styleSheetLoader = instance.forElement(SugarElement.fromDom(doc), {\n        contentCssCors: settings.contentCssCors,\n        referrerPolicy: settings.referrerPolicy\n      });\n      var boundEvents = [];\n      var schema = settings.schema ? settings.schema : Schema({});\n      var styles = Styles({\n        url_converter: settings.url_converter,\n        url_converter_scope: settings.url_converter_scope\n      }, settings.schema);\n      var events = settings.ownEvents ? new EventUtils() : EventUtils.Event;\n      var blockElementsMap = schema.getBlockElements();\n      var $ = DomQuery.overrideDefaults(function () {\n        return {\n          context: doc,\n          element: self.getRoot()\n        };\n      });\n      var isBlock = function (node) {\n        if (typeof node === 'string') {\n          return !!blockElementsMap[node];\n        } else if (node) {\n          var type = node.nodeType;\n          if (type) {\n            return !!(type === 1 && blockElementsMap[node.nodeName]);\n          }\n        }\n        return false;\n      };\n      var get = function (elm) {\n        return elm && doc && isString$1(elm) ? doc.getElementById(elm) : elm;\n      };\n      var $$ = function (elm) {\n        return $(typeof elm === 'string' ? get(elm) : elm);\n      };\n      var getAttrib = function (elm, name, defaultVal) {\n        var hook, value;\n        var $elm = $$(elm);\n        if ($elm.length) {\n          hook = attrHooks[name];\n          if (hook && hook.get) {\n            value = hook.get($elm, name);\n          } else {\n            value = $elm.attr(name);\n          }\n        }\n        if (typeof value === 'undefined') {\n          value = defaultVal || '';\n        }\n        return value;\n      };\n      var getAttribs = function (elm) {\n        var node = get(elm);\n        if (!node) {\n          return [];\n        }\n        return node.attributes;\n      };\n      var setAttrib = function (elm, name, value) {\n        if (value === '') {\n          value = null;\n        }\n        var $elm = $$(elm);\n        var originalValue = $elm.attr(name);\n        if (!$elm.length) {\n          return;\n        }\n        var hook = attrHooks[name];\n        if (hook && hook.set) {\n          hook.set($elm, value, name);\n        } else {\n          $elm.attr(name, value);\n        }\n        if (originalValue !== value && settings.onSetAttrib) {\n          settings.onSetAttrib({\n            attrElm: $elm,\n            attrName: name,\n            attrValue: value\n          });\n        }\n      };\n      var clone = function (node, deep) {\n        if (!isIE || node.nodeType !== 1 || deep) {\n          return node.cloneNode(deep);\n        } else {\n          var clone_1 = doc.createElement(node.nodeName);\n          each$f(getAttribs(node), function (attr) {\n            setAttrib(clone_1, attr.nodeName, getAttrib(node, attr.nodeName));\n          });\n          return clone_1;\n        }\n      };\n      var getRoot = function () {\n        return settings.root_element || doc.body;\n      };\n      var getViewPort = function (argWin) {\n        var vp = getBounds(argWin);\n        return {\n          x: vp.x,\n          y: vp.y,\n          w: vp.width,\n          h: vp.height\n        };\n      };\n      var getPos$1 = function (elm, rootElm) {\n        return getPos(doc.body, get(elm), rootElm);\n      };\n      var setStyle = function (elm, name, value) {\n        var $elm = isString$1(name) ? $$(elm).css(name, value) : $$(elm).css(name);\n        if (settings.update_styles) {\n          updateInternalStyleAttr(styles, $elm);\n        }\n      };\n      var setStyles = function (elm, stylesArg) {\n        var $elm = $$(elm).css(stylesArg);\n        if (settings.update_styles) {\n          updateInternalStyleAttr(styles, $elm);\n        }\n      };\n      var getStyle = function (elm, name, computed) {\n        var $elm = $$(elm);\n        if (computed) {\n          return $elm.css(name);\n        }\n        name = name.replace(/-(\\D)/g, function (a, b) {\n          return b.toUpperCase();\n        });\n        if (name === 'float') {\n          name = Env.browser.isIE() ? 'styleFloat' : 'cssFloat';\n        }\n        return $elm[0] && $elm[0].style ? $elm[0].style[name] : undefined;\n      };\n      var getSize = function (elm) {\n        var w, h;\n        elm = get(elm);\n        w = getStyle(elm, 'width');\n        h = getStyle(elm, 'height');\n        if (w.indexOf('px') === -1) {\n          w = 0;\n        }\n        if (h.indexOf('px') === -1) {\n          h = 0;\n        }\n        return {\n          w: parseInt(w, 10) || elm.offsetWidth || elm.clientWidth,\n          h: parseInt(h, 10) || elm.offsetHeight || elm.clientHeight\n        };\n      };\n      var getRect = function (elm) {\n        elm = get(elm);\n        var pos = getPos$1(elm);\n        var size = getSize(elm);\n        return {\n          x: pos.x,\n          y: pos.y,\n          w: size.w,\n          h: size.h\n        };\n      };\n      var is = function (elm, selector) {\n        var i;\n        if (!elm) {\n          return false;\n        }\n        if (!Array.isArray(elm)) {\n          if (selector === '*') {\n            return elm.nodeType === 1;\n          }\n          if (simpleSelectorRe.test(selector)) {\n            var selectors = selector.toLowerCase().split(/,/);\n            var elmName = elm.nodeName.toLowerCase();\n            for (i = selectors.length - 1; i >= 0; i--) {\n              if (selectors[i] === elmName) {\n                return true;\n              }\n            }\n            return false;\n          }\n          if (elm.nodeType && elm.nodeType !== 1) {\n            return false;\n          }\n        }\n        var elms = !Array.isArray(elm) ? [elm] : elm;\n        return Sizzle(selector, elms[0].ownerDocument || elms[0], null, elms).length > 0;\n      };\n      var getParents = function (elm, selector, root, collect) {\n        var result = [];\n        var selectorVal;\n        var node = get(elm);\n        collect = collect === undefined;\n        root = root || (getRoot().nodeName !== 'BODY' ? getRoot().parentNode : null);\n        if (Tools.is(selector, 'string')) {\n          selectorVal = selector;\n          if (selector === '*') {\n            selector = function (node) {\n              return node.nodeType === 1;\n            };\n          } else {\n            selector = function (node) {\n              return is(node, selectorVal);\n            };\n          }\n        }\n        while (node) {\n          if (node === root || isNullable(node.nodeType) || isDocument$1(node) || isDocumentFragment(node)) {\n            break;\n          }\n          if (!selector || typeof selector === 'function' && selector(node)) {\n            if (collect) {\n              result.push(node);\n            } else {\n              return [node];\n            }\n          }\n          node = node.parentNode;\n        }\n        return collect ? result : null;\n      };\n      var getParent = function (node, selector, root) {\n        var parents = getParents(node, selector, root, false);\n        return parents && parents.length > 0 ? parents[0] : null;\n      };\n      var _findSib = function (node, selector, name) {\n        var func = selector;\n        if (node) {\n          if (typeof selector === 'string') {\n            func = function (node) {\n              return is(node, selector);\n            };\n          }\n          for (node = node[name]; node; node = node[name]) {\n            if (typeof func === 'function' && func(node)) {\n              return node;\n            }\n          }\n        }\n        return null;\n      };\n      var getNext = function (node, selector) {\n        return _findSib(node, selector, 'nextSibling');\n      };\n      var getPrev = function (node, selector) {\n        return _findSib(node, selector, 'previousSibling');\n      };\n      var select = function (selector, scope) {\n        return Sizzle(selector, get(scope) || settings.root_element || doc, []);\n      };\n      var run = function (elm, func, scope) {\n        var result;\n        var node = typeof elm === 'string' ? get(elm) : elm;\n        if (!node) {\n          return false;\n        }\n        if (Tools.isArray(node) && (node.length || node.length === 0)) {\n          result = [];\n          each$f(node, function (elm, i) {\n            if (elm) {\n              result.push(func.call(scope, typeof elm === 'string' ? get(elm) : elm, i));\n            }\n          });\n          return result;\n        }\n        var context = scope ? scope : this;\n        return func.call(context, node);\n      };\n      var setAttribs = function (elm, attrs) {\n        $$(elm).each(function (i, node) {\n          each$f(attrs, function (value, name) {\n            setAttrib(node, name, value);\n          });\n        });\n      };\n      var setHTML = function (elm, html) {\n        var $elm = $$(elm);\n        if (isIE) {\n          $elm.each(function (i, target) {\n            if (target.canHaveHTML === false) {\n              return;\n            }\n            while (target.firstChild) {\n              target.removeChild(target.firstChild);\n            }\n            try {\n              target.innerHTML = '<br>' + html;\n              target.removeChild(target.firstChild);\n            } catch (ex) {\n              DomQuery('<div></div>').html('<br>' + html).contents().slice(1).appendTo(target);\n            }\n            return html;\n          });\n        } else {\n          $elm.html(html);\n        }\n      };\n      var add = function (parentElm, name, attrs, html, create) {\n        return run(parentElm, function (parentElm) {\n          var newElm = typeof name === 'string' ? doc.createElement(name) : name;\n          setAttribs(newElm, attrs);\n          if (html) {\n            if (typeof html !== 'string' && html.nodeType) {\n              newElm.appendChild(html);\n            } else if (typeof html === 'string') {\n              setHTML(newElm, html);\n            }\n          }\n          return !create ? parentElm.appendChild(newElm) : newElm;\n        });\n      };\n      var create = function (name, attrs, html) {\n        return add(doc.createElement(name), name, attrs, html, true);\n      };\n      var decode = Entities.decode;\n      var encode = Entities.encodeAllRaw;\n      var createHTML = function (name, attrs, html) {\n        var outHtml = '', key;\n        outHtml += '<' + name;\n        for (key in attrs) {\n          if (hasNonNullableKey(attrs, key)) {\n            outHtml += ' ' + key + '=\"' + encode(attrs[key]) + '\"';\n          }\n        }\n        if (typeof html !== 'undefined') {\n          return outHtml + '>' + html + '</' + name + '>';\n        }\n        return outHtml + ' />';\n      };\n      var createFragment = function (html) {\n        var node;\n        var container = doc.createElement('div');\n        var frag = doc.createDocumentFragment();\n        frag.appendChild(container);\n        if (html) {\n          container.innerHTML = html;\n        }\n        while (node = container.firstChild) {\n          frag.appendChild(node);\n        }\n        frag.removeChild(container);\n        return frag;\n      };\n      var remove = function (node, keepChildren) {\n        var $node = $$(node);\n        if (keepChildren) {\n          $node.each(function () {\n            var child;\n            while (child = this.firstChild) {\n              if (child.nodeType === 3 && child.data.length === 0) {\n                this.removeChild(child);\n              } else {\n                this.parentNode.insertBefore(child, this);\n              }\n            }\n          }).remove();\n        } else {\n          $node.remove();\n        }\n        return $node.length > 1 ? $node.toArray() : $node[0];\n      };\n      var removeAllAttribs = function (e) {\n        return run(e, function (e) {\n          var i;\n          var attrs = e.attributes;\n          for (i = attrs.length - 1; i >= 0; i--) {\n            e.removeAttributeNode(attrs.item(i));\n          }\n        });\n      };\n      var parseStyle = function (cssText) {\n        return styles.parse(cssText);\n      };\n      var serializeStyle = function (stylesArg, name) {\n        return styles.serialize(stylesArg, name);\n      };\n      var addStyle = function (cssText) {\n        var head, styleElm;\n        if (self !== DOMUtils.DOM && doc === document) {\n          if (addedStyles[cssText]) {\n            return;\n          }\n          addedStyles[cssText] = true;\n        }\n        styleElm = doc.getElementById('mceDefaultStyles');\n        if (!styleElm) {\n          styleElm = doc.createElement('style');\n          styleElm.id = 'mceDefaultStyles';\n          styleElm.type = 'text/css';\n          head = doc.getElementsByTagName('head')[0];\n          if (head.firstChild) {\n            head.insertBefore(styleElm, head.firstChild);\n          } else {\n            head.appendChild(styleElm);\n          }\n        }\n        if (styleElm.styleSheet) {\n          styleElm.styleSheet.cssText += cssText;\n        } else {\n          styleElm.appendChild(doc.createTextNode(cssText));\n        }\n      };\n      var loadCSS = function (urls) {\n        if (!urls) {\n          urls = '';\n        }\n        each$k(urls.split(','), function (url) {\n          files[url] = true;\n          styleSheetLoader.load(url, noop);\n        });\n      };\n      var toggleClass = function (elm, cls, state) {\n        $$(elm).toggleClass(cls, state).each(function () {\n          if (this.className === '') {\n            DomQuery(this).attr('class', null);\n          }\n        });\n      };\n      var addClass = function (elm, cls) {\n        $$(elm).addClass(cls);\n      };\n      var removeClass = function (elm, cls) {\n        toggleClass(elm, cls, false);\n      };\n      var hasClass = function (elm, cls) {\n        return $$(elm).hasClass(cls);\n      };\n      var show = function (elm) {\n        $$(elm).show();\n      };\n      var hide = function (elm) {\n        $$(elm).hide();\n      };\n      var isHidden = function (elm) {\n        return $$(elm).css('display') === 'none';\n      };\n      var uniqueId = function (prefix) {\n        return (!prefix ? 'mce_' : prefix) + counter++;\n      };\n      var getOuterHTML = function (elm) {\n        var node = typeof elm === 'string' ? get(elm) : elm;\n        return isElement$5(node) ? node.outerHTML : DomQuery('<div></div>').append(DomQuery(node).clone()).html();\n      };\n      var setOuterHTML = function (elm, html) {\n        $$(elm).each(function () {\n          try {\n            if ('outerHTML' in this) {\n              this.outerHTML = html;\n              return;\n            }\n          } catch (ex) {\n          }\n          remove(DomQuery(this).html(html), true);\n        });\n      };\n      var insertAfter = function (node, reference) {\n        var referenceNode = get(reference);\n        return run(node, function (node) {\n          var parent = referenceNode.parentNode;\n          var nextSibling = referenceNode.nextSibling;\n          if (nextSibling) {\n            parent.insertBefore(node, nextSibling);\n          } else {\n            parent.appendChild(node);\n          }\n          return node;\n        });\n      };\n      var replace = function (newElm, oldElm, keepChildren) {\n        return run(oldElm, function (oldElm) {\n          if (Tools.is(oldElm, 'array')) {\n            newElm = newElm.cloneNode(true);\n          }\n          if (keepChildren) {\n            each$f(grep$1(oldElm.childNodes), function (node) {\n              newElm.appendChild(node);\n            });\n          }\n          return oldElm.parentNode.replaceChild(newElm, oldElm);\n        });\n      };\n      var rename = function (elm, name) {\n        var newElm;\n        if (elm.nodeName !== name.toUpperCase()) {\n          newElm = create(name);\n          each$f(getAttribs(elm), function (attrNode) {\n            setAttrib(newElm, attrNode.nodeName, getAttrib(elm, attrNode.nodeName));\n          });\n          replace(newElm, elm, true);\n        }\n        return newElm || elm;\n      };\n      var findCommonAncestor = function (a, b) {\n        var ps = a, pe;\n        while (ps) {\n          pe = b;\n          while (pe && ps !== pe) {\n            pe = pe.parentNode;\n          }\n          if (ps === pe) {\n            break;\n          }\n          ps = ps.parentNode;\n        }\n        if (!ps && a.ownerDocument) {\n          return a.ownerDocument.documentElement;\n        }\n        return ps;\n      };\n      var toHex = function (rgbVal) {\n        return styles.toHex(Tools.trim(rgbVal));\n      };\n      var isNonEmptyElement = function (node) {\n        if (isElement$5(node)) {\n          var isNamedAnchor = node.nodeName.toLowerCase() === 'a' && !getAttrib(node, 'href') && getAttrib(node, 'id');\n          if (getAttrib(node, 'name') || getAttrib(node, 'data-mce-bookmark') || isNamedAnchor) {\n            return true;\n          }\n        }\n        return false;\n      };\n      var isEmpty = function (node, elements) {\n        var type, name, brCount = 0;\n        if (isNonEmptyElement(node)) {\n          return false;\n        }\n        node = node.firstChild;\n        if (node) {\n          var walker = new DomTreeWalker(node, node.parentNode);\n          var whitespace = schema ? schema.getWhiteSpaceElements() : {};\n          elements = elements || (schema ? schema.getNonEmptyElements() : null);\n          do {\n            type = node.nodeType;\n            if (isElement$5(node)) {\n              var bogusVal = node.getAttribute('data-mce-bogus');\n              if (bogusVal) {\n                node = walker.next(bogusVal === 'all');\n                continue;\n              }\n              name = node.nodeName.toLowerCase();\n              if (elements && elements[name]) {\n                if (name === 'br') {\n                  brCount++;\n                  node = walker.next();\n                  continue;\n                }\n                return false;\n              }\n              if (isNonEmptyElement(node)) {\n                return false;\n              }\n            }\n            if (type === 8) {\n              return false;\n            }\n            if (type === 3 && !isWhitespaceText(node.nodeValue)) {\n              return false;\n            }\n            if (type === 3 && node.parentNode && whitespace[node.parentNode.nodeName] && isWhitespaceText(node.nodeValue)) {\n              return false;\n            }\n            node = walker.next();\n          } while (node);\n        }\n        return brCount <= 1;\n      };\n      var createRng = function () {\n        return doc.createRange();\n      };\n      var split = function (parentElm, splitElm, replacementElm) {\n        var range = createRng();\n        var beforeFragment;\n        var afterFragment;\n        var parentNode;\n        if (parentElm && splitElm) {\n          range.setStart(parentElm.parentNode, findNodeIndex(parentElm));\n          range.setEnd(splitElm.parentNode, findNodeIndex(splitElm));\n          beforeFragment = range.extractContents();\n          range = createRng();\n          range.setStart(splitElm.parentNode, findNodeIndex(splitElm) + 1);\n          range.setEnd(parentElm.parentNode, findNodeIndex(parentElm) + 1);\n          afterFragment = range.extractContents();\n          parentNode = parentElm.parentNode;\n          parentNode.insertBefore(trimNode(self, beforeFragment), parentElm);\n          if (replacementElm) {\n            parentNode.insertBefore(replacementElm, parentElm);\n          } else {\n            parentNode.insertBefore(splitElm, parentElm);\n          }\n          parentNode.insertBefore(trimNode(self, afterFragment), parentElm);\n          remove(parentElm);\n          return replacementElm || splitElm;\n        }\n      };\n      var bind = function (target, name, func, scope) {\n        if (Tools.isArray(target)) {\n          var i = target.length;\n          var rv = [];\n          while (i--) {\n            rv[i] = bind(target[i], name, func, scope);\n          }\n          return rv;\n        }\n        if (settings.collect && (target === doc || target === win)) {\n          boundEvents.push([\n            target,\n            name,\n            func,\n            scope\n          ]);\n        }\n        var output = events.bind(target, name, func, scope || self);\n        return output;\n      };\n      var unbind = function (target, name, func) {\n        if (Tools.isArray(target)) {\n          var i = target.length;\n          var rv = [];\n          while (i--) {\n            rv[i] = unbind(target[i], name, func);\n          }\n          return rv;\n        } else {\n          if (boundEvents.length > 0 && (target === doc || target === win)) {\n            var i = boundEvents.length;\n            while (i--) {\n              var item = boundEvents[i];\n              if (target === item[0] && (!name || name === item[1]) && (!func || func === item[2])) {\n                events.unbind(item[0], item[1], item[2]);\n              }\n            }\n          }\n          return events.unbind(target, name, func);\n        }\n      };\n      var fire = function (target, name, evt) {\n        return events.fire(target, name, evt);\n      };\n      var getContentEditable = function (node) {\n        if (node && isElement$5(node)) {\n          var contentEditable = node.getAttribute('data-mce-contenteditable');\n          if (contentEditable && contentEditable !== 'inherit') {\n            return contentEditable;\n          }\n          return node.contentEditable !== 'inherit' ? node.contentEditable : null;\n        } else {\n          return null;\n        }\n      };\n      var getContentEditableParent = function (node) {\n        var root = getRoot();\n        var state = null;\n        for (; node && node !== root; node = node.parentNode) {\n          state = getContentEditable(node);\n          if (state !== null) {\n            break;\n          }\n        }\n        return state;\n      };\n      var destroy = function () {\n        if (boundEvents.length > 0) {\n          var i = boundEvents.length;\n          while (i--) {\n            var item = boundEvents[i];\n            events.unbind(item[0], item[1], item[2]);\n          }\n        }\n        each$j(files, function (_, url) {\n          styleSheetLoader.unload(url);\n          delete files[url];\n        });\n        if (Sizzle.setDocument) {\n          Sizzle.setDocument();\n        }\n      };\n      var isChildOf = function (node, parent) {\n        if (!isIE) {\n          return node === parent || parent.contains(node);\n        } else {\n          while (node) {\n            if (parent === node) {\n              return true;\n            }\n            node = node.parentNode;\n          }\n          return false;\n        }\n      };\n      var dumpRng = function (r) {\n        return 'startContainer: ' + r.startContainer.nodeName + ', startOffset: ' + r.startOffset + ', endContainer: ' + r.endContainer.nodeName + ', endOffset: ' + r.endOffset;\n      };\n      var self = {\n        doc: doc,\n        settings: settings,\n        win: win,\n        files: files,\n        stdMode: stdMode,\n        boxModel: boxModel,\n        styleSheetLoader: styleSheetLoader,\n        boundEvents: boundEvents,\n        styles: styles,\n        schema: schema,\n        events: events,\n        isBlock: isBlock,\n        $: $,\n        $$: $$,\n        root: null,\n        clone: clone,\n        getRoot: getRoot,\n        getViewPort: getViewPort,\n        getRect: getRect,\n        getSize: getSize,\n        getParent: getParent,\n        getParents: getParents,\n        get: get,\n        getNext: getNext,\n        getPrev: getPrev,\n        select: select,\n        is: is,\n        add: add,\n        create: create,\n        createHTML: createHTML,\n        createFragment: createFragment,\n        remove: remove,\n        setStyle: setStyle,\n        getStyle: getStyle,\n        setStyles: setStyles,\n        removeAllAttribs: removeAllAttribs,\n        setAttrib: setAttrib,\n        setAttribs: setAttribs,\n        getAttrib: getAttrib,\n        getPos: getPos$1,\n        parseStyle: parseStyle,\n        serializeStyle: serializeStyle,\n        addStyle: addStyle,\n        loadCSS: loadCSS,\n        addClass: addClass,\n        removeClass: removeClass,\n        hasClass: hasClass,\n        toggleClass: toggleClass,\n        show: show,\n        hide: hide,\n        isHidden: isHidden,\n        uniqueId: uniqueId,\n        setHTML: setHTML,\n        getOuterHTML: getOuterHTML,\n        setOuterHTML: setOuterHTML,\n        decode: decode,\n        encode: encode,\n        insertAfter: insertAfter,\n        replace: replace,\n        rename: rename,\n        findCommonAncestor: findCommonAncestor,\n        toHex: toHex,\n        run: run,\n        getAttribs: getAttribs,\n        isEmpty: isEmpty,\n        createRng: createRng,\n        nodeIndex: findNodeIndex,\n        split: split,\n        bind: bind,\n        unbind: unbind,\n        fire: fire,\n        getContentEditable: getContentEditable,\n        getContentEditableParent: getContentEditableParent,\n        destroy: destroy,\n        isChildOf: isChildOf,\n        dumpRng: dumpRng\n      };\n      var attrHooks = setupAttrHooks(styles, settings, constant(self));\n      return self;\n    };\n    DOMUtils.DOM = DOMUtils(document);\n    DOMUtils.nodeIndex = findNodeIndex;\n\n    var DOM$a = DOMUtils.DOM;\n    var each$e = Tools.each, grep = Tools.grep;\n    var QUEUED = 0;\n    var LOADING = 1;\n    var LOADED = 2;\n    var FAILED = 3;\n    var ScriptLoader = function () {\n      function ScriptLoader(settings) {\n        if (settings === void 0) {\n          settings = {};\n        }\n        this.states = {};\n        this.queue = [];\n        this.scriptLoadedCallbacks = {};\n        this.queueLoadedCallbacks = [];\n        this.loading = 0;\n        this.settings = settings;\n      }\n      ScriptLoader.prototype._setReferrerPolicy = function (referrerPolicy) {\n        this.settings.referrerPolicy = referrerPolicy;\n      };\n      ScriptLoader.prototype.loadScript = function (url, success, failure) {\n        var dom = DOM$a;\n        var elm;\n        var cleanup = function () {\n          dom.remove(id);\n          if (elm) {\n            elm.onerror = elm.onload = elm = null;\n          }\n        };\n        var done = function () {\n          cleanup();\n          success();\n        };\n        var error = function () {\n          cleanup();\n          if (isFunction(failure)) {\n            failure();\n          } else {\n            if (typeof console !== 'undefined' && console.log) {\n              console.log('Failed to load script: ' + url);\n            }\n          }\n        };\n        var id = dom.uniqueId();\n        elm = document.createElement('script');\n        elm.id = id;\n        elm.type = 'text/javascript';\n        elm.src = Tools._addCacheSuffix(url);\n        if (this.settings.referrerPolicy) {\n          dom.setAttrib(elm, 'referrerpolicy', this.settings.referrerPolicy);\n        }\n        elm.onload = done;\n        elm.onerror = error;\n        (document.getElementsByTagName('head')[0] || document.body).appendChild(elm);\n      };\n      ScriptLoader.prototype.isDone = function (url) {\n        return this.states[url] === LOADED;\n      };\n      ScriptLoader.prototype.markDone = function (url) {\n        this.states[url] = LOADED;\n      };\n      ScriptLoader.prototype.add = function (url, success, scope, failure) {\n        var state = this.states[url];\n        this.queue.push(url);\n        if (state === undefined) {\n          this.states[url] = QUEUED;\n        }\n        if (success) {\n          if (!this.scriptLoadedCallbacks[url]) {\n            this.scriptLoadedCallbacks[url] = [];\n          }\n          this.scriptLoadedCallbacks[url].push({\n            success: success,\n            failure: failure,\n            scope: scope || this\n          });\n        }\n      };\n      ScriptLoader.prototype.load = function (url, success, scope, failure) {\n        return this.add(url, success, scope, failure);\n      };\n      ScriptLoader.prototype.remove = function (url) {\n        delete this.states[url];\n        delete this.scriptLoadedCallbacks[url];\n      };\n      ScriptLoader.prototype.loadQueue = function (success, scope, failure) {\n        this.loadScripts(this.queue, success, scope, failure);\n      };\n      ScriptLoader.prototype.loadScripts = function (scripts, success, scope, failure) {\n        var self = this;\n        var failures = [];\n        var execCallbacks = function (name, url) {\n          each$e(self.scriptLoadedCallbacks[url], function (callback) {\n            if (isFunction(callback[name])) {\n              callback[name].call(callback.scope);\n            }\n          });\n          self.scriptLoadedCallbacks[url] = undefined;\n        };\n        self.queueLoadedCallbacks.push({\n          success: success,\n          failure: failure,\n          scope: scope || this\n        });\n        var loadScripts = function () {\n          var loadingScripts = grep(scripts);\n          scripts.length = 0;\n          each$e(loadingScripts, function (url) {\n            if (self.states[url] === LOADED) {\n              execCallbacks('success', url);\n              return;\n            }\n            if (self.states[url] === FAILED) {\n              execCallbacks('failure', url);\n              return;\n            }\n            if (self.states[url] !== LOADING) {\n              self.states[url] = LOADING;\n              self.loading++;\n              self.loadScript(url, function () {\n                self.states[url] = LOADED;\n                self.loading--;\n                execCallbacks('success', url);\n                loadScripts();\n              }, function () {\n                self.states[url] = FAILED;\n                self.loading--;\n                failures.push(url);\n                execCallbacks('failure', url);\n                loadScripts();\n              });\n            }\n          });\n          if (!self.loading) {\n            var notifyCallbacks = self.queueLoadedCallbacks.slice(0);\n            self.queueLoadedCallbacks.length = 0;\n            each$e(notifyCallbacks, function (callback) {\n              if (failures.length === 0) {\n                if (isFunction(callback.success)) {\n                  callback.success.call(callback.scope);\n                }\n              } else {\n                if (isFunction(callback.failure)) {\n                  callback.failure.call(callback.scope, failures);\n                }\n              }\n            });\n          }\n        };\n        loadScripts();\n      };\n      ScriptLoader.ScriptLoader = new ScriptLoader();\n      return ScriptLoader;\n    }();\n\n    var Cell = function (initial) {\n      var value = initial;\n      var get = function () {\n        return value;\n      };\n      var set = function (v) {\n        value = v;\n      };\n      return {\n        get: get,\n        set: set\n      };\n    };\n\n    var isRaw = function (str) {\n      return isObject(str) && has$2(str, 'raw');\n    };\n    var isTokenised = function (str) {\n      return isArray$1(str) && str.length > 1;\n    };\n    var data = {};\n    var currentCode = Cell('en');\n    var getLanguageData = function () {\n      return get$9(data, currentCode.get());\n    };\n    var getData = function () {\n      return map$2(data, function (value) {\n        return __assign({}, value);\n      });\n    };\n    var setCode = function (newCode) {\n      if (newCode) {\n        currentCode.set(newCode);\n      }\n    };\n    var getCode = function () {\n      return currentCode.get();\n    };\n    var add$4 = function (code, items) {\n      var langData = data[code];\n      if (!langData) {\n        data[code] = langData = {};\n      }\n      each$j(items, function (translation, name) {\n        langData[name.toLowerCase()] = translation;\n      });\n    };\n    var translate = function (text) {\n      var langData = getLanguageData().getOr({});\n      var toString = function (obj) {\n        if (isFunction(obj)) {\n          return Object.prototype.toString.call(obj);\n        }\n        return !isEmpty(obj) ? '' + obj : '';\n      };\n      var isEmpty = function (text) {\n        return text === '' || text === null || text === undefined;\n      };\n      var getLangData = function (text) {\n        var textstr = toString(text);\n        return get$9(langData, textstr.toLowerCase()).map(toString).getOr(textstr);\n      };\n      var removeContext = function (str) {\n        return str.replace(/{context:\\w+}$/, '');\n      };\n      if (isEmpty(text)) {\n        return '';\n      }\n      if (isRaw(text)) {\n        return toString(text.raw);\n      }\n      if (isTokenised(text)) {\n        var values_1 = text.slice(1);\n        var substitued = getLangData(text[0]).replace(/\\{([0-9]+)\\}/g, function ($1, $2) {\n          return has$2(values_1, $2) ? toString(values_1[$2]) : $1;\n        });\n        return removeContext(substitued);\n      }\n      return removeContext(getLangData(text));\n    };\n    var isRtl$1 = function () {\n      return getLanguageData().bind(function (items) {\n        return get$9(items, '_dir');\n      }).exists(function (dir) {\n        return dir === 'rtl';\n      });\n    };\n    var hasCode = function (code) {\n      return has$2(data, code);\n    };\n    var I18n = {\n      getData: getData,\n      setCode: setCode,\n      getCode: getCode,\n      add: add$4,\n      translate: translate,\n      isRtl: isRtl$1,\n      hasCode: hasCode\n    };\n\n    var AddOnManager = function () {\n      var items = [];\n      var urls = {};\n      var lookup = {};\n      var _listeners = [];\n      var runListeners = function (name, state) {\n        var matchedListeners = filter$4(_listeners, function (listener) {\n          return listener.name === name && listener.state === state;\n        });\n        each$k(matchedListeners, function (listener) {\n          return listener.callback();\n        });\n      };\n      var get = function (name) {\n        if (lookup[name]) {\n          return lookup[name].instance;\n        }\n        return undefined;\n      };\n      var dependencies = function (name) {\n        var result;\n        if (lookup[name]) {\n          result = lookup[name].dependencies;\n        }\n        return result || [];\n      };\n      var requireLangPack = function (name, languages) {\n        if (AddOnManager.languageLoad !== false) {\n          waitFor(name, function () {\n            var language = I18n.getCode();\n            var wrappedLanguages = ',' + (languages || '') + ',';\n            if (!language || languages && wrappedLanguages.indexOf(',' + language + ',') === -1) {\n              return;\n            }\n            ScriptLoader.ScriptLoader.add(urls[name] + '/langs/' + language + '.js');\n          }, 'loaded');\n        }\n      };\n      var add = function (id, addOn, dependencies) {\n        var addOnConstructor = addOn;\n        items.push(addOnConstructor);\n        lookup[id] = {\n          instance: addOnConstructor,\n          dependencies: dependencies\n        };\n        runListeners(id, 'added');\n        return addOnConstructor;\n      };\n      var remove = function (name) {\n        delete urls[name];\n        delete lookup[name];\n      };\n      var createUrl = function (baseUrl, dep) {\n        if (typeof dep === 'object') {\n          return dep;\n        }\n        return typeof baseUrl === 'string' ? {\n          prefix: '',\n          resource: dep,\n          suffix: ''\n        } : {\n          prefix: baseUrl.prefix,\n          resource: dep,\n          suffix: baseUrl.suffix\n        };\n      };\n      var addComponents = function (pluginName, scripts) {\n        var pluginUrl = urls[pluginName];\n        each$k(scripts, function (script) {\n          ScriptLoader.ScriptLoader.add(pluginUrl + '/' + script);\n        });\n      };\n      var loadDependencies = function (name, addOnUrl, success, scope) {\n        var deps = dependencies(name);\n        each$k(deps, function (dep) {\n          var newUrl = createUrl(addOnUrl, dep);\n          load(newUrl.resource, newUrl, undefined, undefined);\n        });\n        if (success) {\n          if (scope) {\n            success.call(scope);\n          } else {\n            success.call(ScriptLoader);\n          }\n        }\n      };\n      var load = function (name, addOnUrl, success, scope, failure) {\n        if (urls[name]) {\n          return;\n        }\n        var urlString = typeof addOnUrl === 'string' ? addOnUrl : addOnUrl.prefix + addOnUrl.resource + addOnUrl.suffix;\n        if (urlString.indexOf('/') !== 0 && urlString.indexOf('://') === -1) {\n          urlString = AddOnManager.baseURL + '/' + urlString;\n        }\n        urls[name] = urlString.substring(0, urlString.lastIndexOf('/'));\n        var done = function () {\n          runListeners(name, 'loaded');\n          loadDependencies(name, addOnUrl, success, scope);\n        };\n        if (lookup[name]) {\n          done();\n        } else {\n          ScriptLoader.ScriptLoader.add(urlString, done, scope, failure);\n        }\n      };\n      var waitFor = function (name, callback, state) {\n        if (state === void 0) {\n          state = 'added';\n        }\n        if (has$2(lookup, name) && state === 'added') {\n          callback();\n        } else if (has$2(urls, name) && state === 'loaded') {\n          callback();\n        } else {\n          _listeners.push({\n            name: name,\n            state: state,\n            callback: callback\n          });\n        }\n      };\n      return {\n        items: items,\n        urls: urls,\n        lookup: lookup,\n        _listeners: _listeners,\n        get: get,\n        dependencies: dependencies,\n        requireLangPack: requireLangPack,\n        add: add,\n        remove: remove,\n        createUrl: createUrl,\n        addComponents: addComponents,\n        load: load,\n        waitFor: waitFor\n      };\n    };\n    AddOnManager.languageLoad = true;\n    AddOnManager.baseURL = '';\n    AddOnManager.PluginManager = AddOnManager();\n    AddOnManager.ThemeManager = AddOnManager();\n\n    var singleton = function (doRevoke) {\n      var subject = Cell(Optional.none());\n      var revoke = function () {\n        return subject.get().each(doRevoke);\n      };\n      var clear = function () {\n        revoke();\n        subject.set(Optional.none());\n      };\n      var isSet = function () {\n        return subject.get().isSome();\n      };\n      var get = function () {\n        return subject.get();\n      };\n      var set = function (s) {\n        revoke();\n        subject.set(Optional.some(s));\n      };\n      return {\n        clear: clear,\n        isSet: isSet,\n        get: get,\n        set: set\n      };\n    };\n    var value = function () {\n      var subject = singleton(noop);\n      var on = function (f) {\n        return subject.get().each(f);\n      };\n      return __assign(__assign({}, subject), { on: on });\n    };\n\n    var first = function (fn, rate) {\n      var timer = null;\n      var cancel = function () {\n        if (!isNull(timer)) {\n          clearTimeout(timer);\n          timer = null;\n        }\n      };\n      var throttle = function () {\n        var args = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n          args[_i] = arguments[_i];\n        }\n        if (isNull(timer)) {\n          timer = setTimeout(function () {\n            timer = null;\n            fn.apply(null, args);\n          }, rate);\n        }\n      };\n      return {\n        cancel: cancel,\n        throttle: throttle\n      };\n    };\n    var last = function (fn, rate) {\n      var timer = null;\n      var cancel = function () {\n        if (!isNull(timer)) {\n          clearTimeout(timer);\n          timer = null;\n        }\n      };\n      var throttle = function () {\n        var args = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n          args[_i] = arguments[_i];\n        }\n        cancel();\n        timer = setTimeout(function () {\n          timer = null;\n          fn.apply(null, args);\n        }, rate);\n      };\n      return {\n        cancel: cancel,\n        throttle: throttle\n      };\n    };\n\n    var read$4 = function (element, attr) {\n      var value = get$6(element, attr);\n      return value === undefined || value === '' ? [] : value.split(' ');\n    };\n    var add$3 = function (element, attr, id) {\n      var old = read$4(element, attr);\n      var nu = old.concat([id]);\n      set$1(element, attr, nu.join(' '));\n      return true;\n    };\n    var remove$5 = function (element, attr, id) {\n      var nu = filter$4(read$4(element, attr), function (v) {\n        return v !== id;\n      });\n      if (nu.length > 0) {\n        set$1(element, attr, nu.join(' '));\n      } else {\n        remove$6(element, attr);\n      }\n      return false;\n    };\n\n    var supports = function (element) {\n      return element.dom.classList !== undefined;\n    };\n    var get$4 = function (element) {\n      return read$4(element, 'class');\n    };\n    var add$2 = function (element, clazz) {\n      return add$3(element, 'class', clazz);\n    };\n    var remove$4 = function (element, clazz) {\n      return remove$5(element, 'class', clazz);\n    };\n\n    var add$1 = function (element, clazz) {\n      if (supports(element)) {\n        element.dom.classList.add(clazz);\n      } else {\n        add$2(element, clazz);\n      }\n    };\n    var cleanClass = function (element) {\n      var classList = supports(element) ? element.dom.classList : get$4(element);\n      if (classList.length === 0) {\n        remove$6(element, 'class');\n      }\n    };\n    var remove$3 = function (element, clazz) {\n      if (supports(element)) {\n        var classList = element.dom.classList;\n        classList.remove(clazz);\n      } else {\n        remove$4(element, clazz);\n      }\n      cleanClass(element);\n    };\n    var has = function (element, clazz) {\n      return supports(element) && element.dom.classList.contains(clazz);\n    };\n\n    var descendants$1 = function (scope, predicate) {\n      var result = [];\n      each$k(children(scope), function (x) {\n        if (predicate(x)) {\n          result = result.concat([x]);\n        }\n        result = result.concat(descendants$1(x, predicate));\n      });\n      return result;\n    };\n\n    var descendants = function (scope, selector) {\n      return all(selector, scope);\n    };\n\n    var annotation = constant('mce-annotation');\n    var dataAnnotation = constant('data-mce-annotation');\n    var dataAnnotationId = constant('data-mce-annotation-uid');\n\n    var identify = function (editor, annotationName) {\n      var rng = editor.selection.getRng();\n      var start = SugarElement.fromDom(rng.startContainer);\n      var root = SugarElement.fromDom(editor.getBody());\n      var selector = annotationName.fold(function () {\n        return '.' + annotation();\n      }, function (an) {\n        return '[' + dataAnnotation() + '=\"' + an + '\"]';\n      });\n      var newStart = child$1(start, rng.startOffset).getOr(start);\n      var closest = closest$2(newStart, selector, function (n) {\n        return eq(n, root);\n      });\n      var getAttr = function (c, property) {\n        if (has$1(c, property)) {\n          return Optional.some(get$6(c, property));\n        } else {\n          return Optional.none();\n        }\n      };\n      return closest.bind(function (c) {\n        return getAttr(c, '' + dataAnnotationId()).bind(function (uid) {\n          return getAttr(c, '' + dataAnnotation()).map(function (name) {\n            var elements = findMarkers(editor, uid);\n            return {\n              uid: uid,\n              name: name,\n              elements: elements\n            };\n          });\n        });\n      });\n    };\n    var isAnnotation = function (elem) {\n      return isElement$6(elem) && has(elem, annotation());\n    };\n    var findMarkers = function (editor, uid) {\n      var body = SugarElement.fromDom(editor.getBody());\n      return descendants(body, '[' + dataAnnotationId() + '=\"' + uid + '\"]');\n    };\n    var findAll = function (editor, name) {\n      var body = SugarElement.fromDom(editor.getBody());\n      var markers = descendants(body, '[' + dataAnnotation() + '=\"' + name + '\"]');\n      var directory = {};\n      each$k(markers, function (m) {\n        var uid = get$6(m, dataAnnotationId());\n        var nodesAlready = get$9(directory, uid).getOr([]);\n        directory[uid] = nodesAlready.concat([m]);\n      });\n      return directory;\n    };\n\n    var setup$n = function (editor, _registry) {\n      var changeCallbacks = Cell({});\n      var initData = function () {\n        return {\n          listeners: [],\n          previous: value()\n        };\n      };\n      var withCallbacks = function (name, f) {\n        updateCallbacks(name, function (data) {\n          f(data);\n          return data;\n        });\n      };\n      var updateCallbacks = function (name, f) {\n        var callbackMap = changeCallbacks.get();\n        var data = get$9(callbackMap, name).getOrThunk(initData);\n        var outputData = f(data);\n        callbackMap[name] = outputData;\n        changeCallbacks.set(callbackMap);\n      };\n      var fireCallbacks = function (name, uid, elements) {\n        withCallbacks(name, function (data) {\n          each$k(data.listeners, function (f) {\n            return f(true, name, {\n              uid: uid,\n              nodes: map$3(elements, function (elem) {\n                return elem.dom;\n              })\n            });\n          });\n        });\n      };\n      var fireNoAnnotation = function (name) {\n        withCallbacks(name, function (data) {\n          each$k(data.listeners, function (f) {\n            return f(false, name);\n          });\n        });\n      };\n      var onNodeChange = last(function () {\n        var callbackMap = changeCallbacks.get();\n        var annotations = sort(keys(callbackMap));\n        each$k(annotations, function (name) {\n          updateCallbacks(name, function (data) {\n            var prev = data.previous.get();\n            identify(editor, Optional.some(name)).fold(function () {\n              if (prev.isSome()) {\n                fireNoAnnotation(name);\n                data.previous.clear();\n              }\n            }, function (_a) {\n              var uid = _a.uid, name = _a.name, elements = _a.elements;\n              if (!is$1(prev, uid)) {\n                fireCallbacks(name, uid, elements);\n                data.previous.set(uid);\n              }\n            });\n            return {\n              previous: data.previous,\n              listeners: data.listeners\n            };\n          });\n        });\n      }, 30);\n      editor.on('remove', function () {\n        onNodeChange.cancel();\n      });\n      editor.on('NodeChange', function () {\n        onNodeChange.throttle();\n      });\n      var addListener = function (name, f) {\n        updateCallbacks(name, function (data) {\n          return {\n            previous: data.previous,\n            listeners: data.listeners.concat([f])\n          };\n        });\n      };\n      return { addListener: addListener };\n    };\n\n    var setup$m = function (editor, registry) {\n      var identifyParserNode = function (span) {\n        return Optional.from(span.attr(dataAnnotation())).bind(registry.lookup);\n      };\n      editor.on('init', function () {\n        editor.serializer.addNodeFilter('span', function (spans) {\n          each$k(spans, function (span) {\n            identifyParserNode(span).each(function (settings) {\n              if (settings.persistent === false) {\n                span.unwrap();\n              }\n            });\n          });\n        });\n      });\n    };\n\n    var create$7 = function () {\n      var annotations = {};\n      var register = function (name, settings) {\n        annotations[name] = {\n          name: name,\n          settings: settings\n        };\n      };\n      var lookup = function (name) {\n        return get$9(annotations, name).map(function (a) {\n          return a.settings;\n        });\n      };\n      return {\n        register: register,\n        lookup: lookup\n      };\n    };\n\n    var unique = 0;\n    var generate = function (prefix) {\n      var date = new Date();\n      var time = date.getTime();\n      var random = Math.floor(Math.random() * 1000000000);\n      unique++;\n      return prefix + '_' + random + unique + String(time);\n    };\n\n    var add = function (element, classes) {\n      each$k(classes, function (x) {\n        add$1(element, x);\n      });\n    };\n\n    var fromHtml = function (html, scope) {\n      var doc = scope || document;\n      var div = doc.createElement('div');\n      div.innerHTML = html;\n      return children(SugarElement.fromDom(div));\n    };\n    var fromDom$1 = function (nodes) {\n      return map$3(nodes, SugarElement.fromDom);\n    };\n\n    var get$3 = function (element) {\n      return element.dom.innerHTML;\n    };\n    var set = function (element, content) {\n      var owner = owner$1(element);\n      var docDom = owner.dom;\n      var fragment = SugarElement.fromDom(docDom.createDocumentFragment());\n      var contentElements = fromHtml(content, docDom);\n      append(fragment, contentElements);\n      empty(element);\n      append$1(element, fragment);\n    };\n\n    var clone$1 = function (original, isDeep) {\n      return SugarElement.fromDom(original.dom.cloneNode(isDeep));\n    };\n    var shallow = function (original) {\n      return clone$1(original, false);\n    };\n    var deep$1 = function (original) {\n      return clone$1(original, true);\n    };\n\n    var TextWalker = function (startNode, rootNode, isBoundary) {\n      if (isBoundary === void 0) {\n        isBoundary = never;\n      }\n      var walker = new DomTreeWalker(startNode, rootNode);\n      var walk = function (direction) {\n        var next;\n        do {\n          next = walker[direction]();\n        } while (next && !isText$7(next) && !isBoundary(next));\n        return Optional.from(next).filter(isText$7);\n      };\n      return {\n        current: function () {\n          return Optional.from(walker.current()).filter(isText$7);\n        },\n        next: function () {\n          return walk('next');\n        },\n        prev: function () {\n          return walk('prev');\n        },\n        prev2: function () {\n          return walk('prev2');\n        }\n      };\n    };\n\n    var TextSeeker = function (dom, isBoundary) {\n      var isBlockBoundary = isBoundary ? isBoundary : function (node) {\n        return dom.isBlock(node) || isBr$5(node) || isContentEditableFalse$b(node);\n      };\n      var walk = function (node, offset, walker, process) {\n        if (isText$7(node)) {\n          var newOffset = process(node, offset, node.data);\n          if (newOffset !== -1) {\n            return Optional.some({\n              container: node,\n              offset: newOffset\n            });\n          }\n        }\n        return walker().bind(function (next) {\n          return walk(next.container, next.offset, walker, process);\n        });\n      };\n      var backwards = function (node, offset, process, root) {\n        var walker = TextWalker(node, root, isBlockBoundary);\n        return walk(node, offset, function () {\n          return walker.prev().map(function (prev) {\n            return {\n              container: prev,\n              offset: prev.length\n            };\n          });\n        }, process).getOrNull();\n      };\n      var forwards = function (node, offset, process, root) {\n        var walker = TextWalker(node, root, isBlockBoundary);\n        return walk(node, offset, function () {\n          return walker.next().map(function (next) {\n            return {\n              container: next,\n              offset: 0\n            };\n          });\n        }, process).getOrNull();\n      };\n      return {\n        backwards: backwards,\n        forwards: forwards\n      };\n    };\n\n    var round$2 = Math.round;\n    var clone = function (rect) {\n      if (!rect) {\n        return {\n          left: 0,\n          top: 0,\n          bottom: 0,\n          right: 0,\n          width: 0,\n          height: 0\n        };\n      }\n      return {\n        left: round$2(rect.left),\n        top: round$2(rect.top),\n        bottom: round$2(rect.bottom),\n        right: round$2(rect.right),\n        width: round$2(rect.width),\n        height: round$2(rect.height)\n      };\n    };\n    var collapse = function (rect, toStart) {\n      rect = clone(rect);\n      if (toStart) {\n        rect.right = rect.left;\n      } else {\n        rect.left = rect.left + rect.width;\n        rect.right = rect.left;\n      }\n      rect.width = 0;\n      return rect;\n    };\n    var isEqual = function (rect1, rect2) {\n      return rect1.left === rect2.left && rect1.top === rect2.top && rect1.bottom === rect2.bottom && rect1.right === rect2.right;\n    };\n    var isValidOverflow = function (overflowY, rect1, rect2) {\n      return overflowY >= 0 && overflowY <= Math.min(rect1.height, rect2.height) / 2;\n    };\n    var isAbove$1 = function (rect1, rect2) {\n      var halfHeight = Math.min(rect2.height / 2, rect1.height / 2);\n      if (rect1.bottom - halfHeight < rect2.top) {\n        return true;\n      }\n      if (rect1.top > rect2.bottom) {\n        return false;\n      }\n      return isValidOverflow(rect2.top - rect1.bottom, rect1, rect2);\n    };\n    var isBelow$1 = function (rect1, rect2) {\n      if (rect1.top > rect2.bottom) {\n        return true;\n      }\n      if (rect1.bottom < rect2.top) {\n        return false;\n      }\n      return isValidOverflow(rect2.bottom - rect1.top, rect1, rect2);\n    };\n    var containsXY = function (rect, clientX, clientY) {\n      return clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom;\n    };\n\n    var clamp$2 = function (value, min, max) {\n      return Math.min(Math.max(value, min), max);\n    };\n\n    var getSelectedNode = function (range) {\n      var startContainer = range.startContainer, startOffset = range.startOffset;\n      if (startContainer.hasChildNodes() && range.endOffset === startOffset + 1) {\n        return startContainer.childNodes[startOffset];\n      }\n      return null;\n    };\n    var getNode$1 = function (container, offset) {\n      if (isElement$5(container) && container.hasChildNodes()) {\n        var childNodes = container.childNodes;\n        var safeOffset = clamp$2(offset, 0, childNodes.length - 1);\n        return childNodes[safeOffset];\n      } else {\n        return container;\n      }\n    };\n    var getNodeUnsafe = function (container, offset) {\n      if (offset < 0 && isElement$5(container) && container.hasChildNodes()) {\n        return undefined;\n      } else {\n        return getNode$1(container, offset);\n      }\n    };\n\n    var extendingChars = new RegExp('[\\u0300-\\u036f\\u0483-\\u0487\\u0488-\\u0489\\u0591-\\u05bd\\u05bf\\u05c1-\\u05c2\\u05c4-\\u05c5\\u05c7\\u0610-\\u061a' + '\\u064b-\\u065f\\u0670\\u06d6-\\u06dc\\u06df-\\u06e4\\u06e7-\\u06e8\\u06ea-\\u06ed\\u0711\\u0730-\\u074a\\u07a6-\\u07b0' + '\\u07eb-\\u07f3\\u0816-\\u0819\\u081b-\\u0823\\u0825-\\u0827\\u0829-\\u082d\\u0859-\\u085b\\u08e3-\\u0902\\u093a\\u093c' + '\\u0941-\\u0948\\u094d\\u0951-\\u0957\\u0962-\\u0963\\u0981\\u09bc\\u09be\\u09c1-\\u09c4\\u09cd\\u09d7\\u09e2-\\u09e3' + '\\u0a01-\\u0a02\\u0a3c\\u0a41-\\u0a42\\u0a47-\\u0a48\\u0a4b-\\u0a4d\\u0a51\\u0a70-\\u0a71\\u0a75\\u0a81-\\u0a82\\u0abc' + '\\u0ac1-\\u0ac5\\u0ac7-\\u0ac8\\u0acd\\u0ae2-\\u0ae3\\u0b01\\u0b3c\\u0b3e\\u0b3f\\u0b41-\\u0b44\\u0b4d\\u0b56\\u0b57' + '\\u0b62-\\u0b63\\u0b82\\u0bbe\\u0bc0\\u0bcd\\u0bd7\\u0c00\\u0c3e-\\u0c40\\u0c46-\\u0c48\\u0c4a-\\u0c4d\\u0c55-\\u0c56' + '\\u0c62-\\u0c63\\u0c81\\u0cbc\\u0cbf\\u0cc2\\u0cc6\\u0ccc-\\u0ccd\\u0cd5-\\u0cd6\\u0ce2-\\u0ce3\\u0d01\\u0d3e\\u0d41-\\u0d44' + '\\u0d4d\\u0d57\\u0d62-\\u0d63\\u0dca\\u0dcf\\u0dd2-\\u0dd4\\u0dd6\\u0ddf\\u0e31\\u0e34-\\u0e3a\\u0e47-\\u0e4e\\u0eb1\\u0eb4-\\u0eb9' + '\\u0ebb-\\u0ebc\\u0ec8-\\u0ecd\\u0f18-\\u0f19\\u0f35\\u0f37\\u0f39\\u0f71-\\u0f7e\\u0f80-\\u0f84\\u0f86-\\u0f87\\u0f8d-\\u0f97' + '\\u0f99-\\u0fbc\\u0fc6\\u102d-\\u1030\\u1032-\\u1037\\u1039-\\u103a\\u103d-\\u103e\\u1058-\\u1059\\u105e-\\u1060\\u1071-\\u1074' + '\\u1082\\u1085-\\u1086\\u108d\\u109d\\u135d-\\u135f\\u1712-\\u1714\\u1732-\\u1734\\u1752-\\u1753\\u1772-\\u1773\\u17b4-\\u17b5' + '\\u17b7-\\u17bd\\u17c6\\u17c9-\\u17d3\\u17dd\\u180b-\\u180d\\u18a9\\u1920-\\u1922\\u1927-\\u1928\\u1932\\u1939-\\u193b\\u1a17-\\u1a18' + '\\u1a1b\\u1a56\\u1a58-\\u1a5e\\u1a60\\u1a62\\u1a65-\\u1a6c\\u1a73-\\u1a7c\\u1a7f\\u1ab0-\\u1abd\\u1ABE\\u1b00-\\u1b03\\u1b34' + '\\u1b36-\\u1b3a\\u1b3c\\u1b42\\u1b6b-\\u1b73\\u1b80-\\u1b81\\u1ba2-\\u1ba5\\u1ba8-\\u1ba9\\u1bab-\\u1bad\\u1be6\\u1be8-\\u1be9' + '\\u1bed\\u1bef-\\u1bf1\\u1c2c-\\u1c33\\u1c36-\\u1c37\\u1cd0-\\u1cd2\\u1cd4-\\u1ce0\\u1ce2-\\u1ce8\\u1ced\\u1cf4\\u1cf8-\\u1cf9' + '\\u1dc0-\\u1df5\\u1dfc-\\u1dff\\u200c-\\u200d\\u20d0-\\u20dc\\u20DD-\\u20E0\\u20e1\\u20E2-\\u20E4\\u20e5-\\u20f0\\u2cef-\\u2cf1' + '\\u2d7f\\u2de0-\\u2dff\\u302a-\\u302d\\u302e-\\u302f\\u3099-\\u309a\\ua66f\\uA670-\\uA672\\ua674-\\ua67d\\ua69e-\\ua69f\\ua6f0-\\ua6f1' + '\\ua802\\ua806\\ua80b\\ua825-\\ua826\\ua8c4\\ua8e0-\\ua8f1\\ua926-\\ua92d\\ua947-\\ua951\\ua980-\\ua982\\ua9b3\\ua9b6-\\ua9b9\\ua9bc' + '\\ua9e5\\uaa29-\\uaa2e\\uaa31-\\uaa32\\uaa35-\\uaa36\\uaa43\\uaa4c\\uaa7c\\uaab0\\uaab2-\\uaab4\\uaab7-\\uaab8\\uaabe-\\uaabf\\uaac1' + '\\uaaec-\\uaaed\\uaaf6\\uabe5\\uabe8\\uabed\\ufb1e\\ufe00-\\ufe0f\\ufe20-\\ufe2f\\uff9e-\\uff9f]');\n    var isExtendingChar = function (ch) {\n      return typeof ch === 'string' && ch.charCodeAt(0) >= 768 && extendingChars.test(ch);\n    };\n\n    var or = function () {\n      var args = [];\n      for (var _i = 0; _i < arguments.length; _i++) {\n        args[_i] = arguments[_i];\n      }\n      return function (x) {\n        for (var i = 0; i < args.length; i++) {\n          if (args[i](x)) {\n            return true;\n          }\n        }\n        return false;\n      };\n    };\n    var and = function () {\n      var args = [];\n      for (var _i = 0; _i < arguments.length; _i++) {\n        args[_i] = arguments[_i];\n      }\n      return function (x) {\n        for (var i = 0; i < args.length; i++) {\n          if (!args[i](x)) {\n            return false;\n          }\n        }\n        return true;\n      };\n    };\n\n    var isElement$3 = isElement$5;\n    var isCaretCandidate$2 = isCaretCandidate$3;\n    var isBlock$1 = matchStyleValues('display', 'block table');\n    var isFloated = matchStyleValues('float', 'left right');\n    var isValidElementCaretCandidate = and(isElement$3, isCaretCandidate$2, not(isFloated));\n    var isNotPre = not(matchStyleValues('white-space', 'pre pre-line pre-wrap'));\n    var isText$4 = isText$7;\n    var isBr$2 = isBr$5;\n    var nodeIndex$1 = DOMUtils.nodeIndex;\n    var resolveIndex$1 = getNodeUnsafe;\n    var createRange$1 = function (doc) {\n      return 'createRange' in doc ? doc.createRange() : DOMUtils.DOM.createRng();\n    };\n    var isWhiteSpace$1 = function (chr) {\n      return chr && /[\\r\\n\\t ]/.test(chr);\n    };\n    var isRange = function (rng) {\n      return !!rng.setStart && !!rng.setEnd;\n    };\n    var isHiddenWhiteSpaceRange = function (range) {\n      var container = range.startContainer;\n      var offset = range.startOffset;\n      if (isWhiteSpace$1(range.toString()) && isNotPre(container.parentNode) && isText$7(container)) {\n        var text = container.data;\n        if (isWhiteSpace$1(text[offset - 1]) || isWhiteSpace$1(text[offset + 1])) {\n          return true;\n        }\n      }\n      return false;\n    };\n    var getBrClientRect = function (brNode) {\n      var doc = brNode.ownerDocument;\n      var rng = createRange$1(doc);\n      var nbsp$1 = doc.createTextNode(nbsp);\n      var parentNode = brNode.parentNode;\n      parentNode.insertBefore(nbsp$1, brNode);\n      rng.setStart(nbsp$1, 0);\n      rng.setEnd(nbsp$1, 1);\n      var clientRect = clone(rng.getBoundingClientRect());\n      parentNode.removeChild(nbsp$1);\n      return clientRect;\n    };\n    var getBoundingClientRectWebKitText = function (rng) {\n      var sc = rng.startContainer;\n      var ec = rng.endContainer;\n      var so = rng.startOffset;\n      var eo = rng.endOffset;\n      if (sc === ec && isText$7(ec) && so === 0 && eo === 1) {\n        var newRng = rng.cloneRange();\n        newRng.setEndAfter(ec);\n        return getBoundingClientRect$1(newRng);\n      } else {\n        return null;\n      }\n    };\n    var isZeroRect = function (r) {\n      return r.left === 0 && r.right === 0 && r.top === 0 && r.bottom === 0;\n    };\n    var getBoundingClientRect$1 = function (item) {\n      var clientRect;\n      var clientRects = item.getClientRects();\n      if (clientRects.length > 0) {\n        clientRect = clone(clientRects[0]);\n      } else {\n        clientRect = clone(item.getBoundingClientRect());\n      }\n      if (!isRange(item) && isBr$2(item) && isZeroRect(clientRect)) {\n        return getBrClientRect(item);\n      }\n      if (isZeroRect(clientRect) && isRange(item)) {\n        return getBoundingClientRectWebKitText(item);\n      }\n      return clientRect;\n    };\n    var collapseAndInflateWidth = function (clientRect, toStart) {\n      var newClientRect = collapse(clientRect, toStart);\n      newClientRect.width = 1;\n      newClientRect.right = newClientRect.left + 1;\n      return newClientRect;\n    };\n    var getCaretPositionClientRects = function (caretPosition) {\n      var clientRects = [];\n      var addUniqueAndValidRect = function (clientRect) {\n        if (clientRect.height === 0) {\n          return;\n        }\n        if (clientRects.length > 0) {\n          if (isEqual(clientRect, clientRects[clientRects.length - 1])) {\n            return;\n          }\n        }\n        clientRects.push(clientRect);\n      };\n      var addCharacterOffset = function (container, offset) {\n        var range = createRange$1(container.ownerDocument);\n        if (offset < container.data.length) {\n          if (isExtendingChar(container.data[offset])) {\n            return clientRects;\n          }\n          if (isExtendingChar(container.data[offset - 1])) {\n            range.setStart(container, offset);\n            range.setEnd(container, offset + 1);\n            if (!isHiddenWhiteSpaceRange(range)) {\n              addUniqueAndValidRect(collapseAndInflateWidth(getBoundingClientRect$1(range), false));\n              return clientRects;\n            }\n          }\n        }\n        if (offset > 0) {\n          range.setStart(container, offset - 1);\n          range.setEnd(container, offset);\n          if (!isHiddenWhiteSpaceRange(range)) {\n            addUniqueAndValidRect(collapseAndInflateWidth(getBoundingClientRect$1(range), false));\n          }\n        }\n        if (offset < container.data.length) {\n          range.setStart(container, offset);\n          range.setEnd(container, offset + 1);\n          if (!isHiddenWhiteSpaceRange(range)) {\n            addUniqueAndValidRect(collapseAndInflateWidth(getBoundingClientRect$1(range), true));\n          }\n        }\n      };\n      var container = caretPosition.container();\n      var offset = caretPosition.offset();\n      if (isText$4(container)) {\n        addCharacterOffset(container, offset);\n        return clientRects;\n      }\n      if (isElement$3(container)) {\n        if (caretPosition.isAtEnd()) {\n          var node = resolveIndex$1(container, offset);\n          if (isText$4(node)) {\n            addCharacterOffset(node, node.data.length);\n          }\n          if (isValidElementCaretCandidate(node) && !isBr$2(node)) {\n            addUniqueAndValidRect(collapseAndInflateWidth(getBoundingClientRect$1(node), false));\n          }\n        } else {\n          var node = resolveIndex$1(container, offset);\n          if (isText$4(node)) {\n            addCharacterOffset(node, 0);\n          }\n          if (isValidElementCaretCandidate(node) && caretPosition.isAtEnd()) {\n            addUniqueAndValidRect(collapseAndInflateWidth(getBoundingClientRect$1(node), false));\n            return clientRects;\n          }\n          var beforeNode = resolveIndex$1(caretPosition.container(), caretPosition.offset() - 1);\n          if (isValidElementCaretCandidate(beforeNode) && !isBr$2(beforeNode)) {\n            if (isBlock$1(beforeNode) || isBlock$1(node) || !isValidElementCaretCandidate(node)) {\n              addUniqueAndValidRect(collapseAndInflateWidth(getBoundingClientRect$1(beforeNode), false));\n            }\n          }\n          if (isValidElementCaretCandidate(node)) {\n            addUniqueAndValidRect(collapseAndInflateWidth(getBoundingClientRect$1(node), true));\n          }\n        }\n      }\n      return clientRects;\n    };\n    var CaretPosition = function (container, offset, clientRects) {\n      var isAtStart = function () {\n        if (isText$4(container)) {\n          return offset === 0;\n        }\n        return offset === 0;\n      };\n      var isAtEnd = function () {\n        if (isText$4(container)) {\n          return offset >= container.data.length;\n        }\n        return offset >= container.childNodes.length;\n      };\n      var toRange = function () {\n        var range = createRange$1(container.ownerDocument);\n        range.setStart(container, offset);\n        range.setEnd(container, offset);\n        return range;\n      };\n      var getClientRects = function () {\n        if (!clientRects) {\n          clientRects = getCaretPositionClientRects(CaretPosition(container, offset));\n        }\n        return clientRects;\n      };\n      var isVisible = function () {\n        return getClientRects().length > 0;\n      };\n      var isEqual = function (caretPosition) {\n        return caretPosition && container === caretPosition.container() && offset === caretPosition.offset();\n      };\n      var getNode = function (before) {\n        return resolveIndex$1(container, before ? offset - 1 : offset);\n      };\n      return {\n        container: constant(container),\n        offset: constant(offset),\n        toRange: toRange,\n        getClientRects: getClientRects,\n        isVisible: isVisible,\n        isAtStart: isAtStart,\n        isAtEnd: isAtEnd,\n        isEqual: isEqual,\n        getNode: getNode\n      };\n    };\n    CaretPosition.fromRangeStart = function (range) {\n      return CaretPosition(range.startContainer, range.startOffset);\n    };\n    CaretPosition.fromRangeEnd = function (range) {\n      return CaretPosition(range.endContainer, range.endOffset);\n    };\n    CaretPosition.after = function (node) {\n      return CaretPosition(node.parentNode, nodeIndex$1(node) + 1);\n    };\n    CaretPosition.before = function (node) {\n      return CaretPosition(node.parentNode, nodeIndex$1(node));\n    };\n    CaretPosition.isAbove = function (pos1, pos2) {\n      return lift2(head(pos2.getClientRects()), last$2(pos1.getClientRects()), isAbove$1).getOr(false);\n    };\n    CaretPosition.isBelow = function (pos1, pos2) {\n      return lift2(last$2(pos2.getClientRects()), head(pos1.getClientRects()), isBelow$1).getOr(false);\n    };\n    CaretPosition.isAtStart = function (pos) {\n      return pos ? pos.isAtStart() : false;\n    };\n    CaretPosition.isAtEnd = function (pos) {\n      return pos ? pos.isAtEnd() : false;\n    };\n    CaretPosition.isTextPosition = function (pos) {\n      return pos ? isText$7(pos.container()) : false;\n    };\n    CaretPosition.isElementPosition = function (pos) {\n      return CaretPosition.isTextPosition(pos) === false;\n    };\n\n    var trimEmptyTextNode$1 = function (dom, node) {\n      if (isText$7(node) && node.data.length === 0) {\n        dom.remove(node);\n      }\n    };\n    var insertNode = function (dom, rng, node) {\n      rng.insertNode(node);\n      trimEmptyTextNode$1(dom, node.previousSibling);\n      trimEmptyTextNode$1(dom, node.nextSibling);\n    };\n    var insertFragment = function (dom, rng, frag) {\n      var firstChild = Optional.from(frag.firstChild);\n      var lastChild = Optional.from(frag.lastChild);\n      rng.insertNode(frag);\n      firstChild.each(function (child) {\n        return trimEmptyTextNode$1(dom, child.previousSibling);\n      });\n      lastChild.each(function (child) {\n        return trimEmptyTextNode$1(dom, child.nextSibling);\n      });\n    };\n    var rangeInsertNode = function (dom, rng, node) {\n      if (isDocumentFragment(node)) {\n        insertFragment(dom, rng, node);\n      } else {\n        insertNode(dom, rng, node);\n      }\n    };\n\n    var isText$3 = isText$7;\n    var isBogus = isBogus$2;\n    var nodeIndex = DOMUtils.nodeIndex;\n    var normalizedParent = function (node) {\n      var parentNode = node.parentNode;\n      if (isBogus(parentNode)) {\n        return normalizedParent(parentNode);\n      }\n      return parentNode;\n    };\n    var getChildNodes = function (node) {\n      if (!node) {\n        return [];\n      }\n      return reduce(node.childNodes, function (result, node) {\n        if (isBogus(node) && node.nodeName !== 'BR') {\n          result = result.concat(getChildNodes(node));\n        } else {\n          result.push(node);\n        }\n        return result;\n      }, []);\n    };\n    var normalizedTextOffset = function (node, offset) {\n      while (node = node.previousSibling) {\n        if (!isText$3(node)) {\n          break;\n        }\n        offset += node.data.length;\n      }\n      return offset;\n    };\n    var equal = function (a) {\n      return function (b) {\n        return a === b;\n      };\n    };\n    var normalizedNodeIndex = function (node) {\n      var nodes, index;\n      nodes = getChildNodes(normalizedParent(node));\n      index = findIndex$1(nodes, equal(node), node);\n      nodes = nodes.slice(0, index + 1);\n      var numTextFragments = reduce(nodes, function (result, node, i) {\n        if (isText$3(node) && isText$3(nodes[i - 1])) {\n          result++;\n        }\n        return result;\n      }, 0);\n      nodes = filter$2(nodes, matchNodeNames([node.nodeName]));\n      index = findIndex$1(nodes, equal(node), node);\n      return index - numTextFragments;\n    };\n    var createPathItem = function (node) {\n      var name;\n      if (isText$3(node)) {\n        name = 'text()';\n      } else {\n        name = node.nodeName.toLowerCase();\n      }\n      return name + '[' + normalizedNodeIndex(node) + ']';\n    };\n    var parentsUntil$1 = function (root, node, predicate) {\n      var parents = [];\n      for (node = node.parentNode; node !== root; node = node.parentNode) {\n        if (predicate && predicate(node)) {\n          break;\n        }\n        parents.push(node);\n      }\n      return parents;\n    };\n    var create$6 = function (root, caretPosition) {\n      var container, offset, path = [], outputOffset, childNodes, parents;\n      container = caretPosition.container();\n      offset = caretPosition.offset();\n      if (isText$3(container)) {\n        outputOffset = normalizedTextOffset(container, offset);\n      } else {\n        childNodes = container.childNodes;\n        if (offset >= childNodes.length) {\n          outputOffset = 'after';\n          offset = childNodes.length - 1;\n        } else {\n          outputOffset = 'before';\n        }\n        container = childNodes[offset];\n      }\n      path.push(createPathItem(container));\n      parents = parentsUntil$1(root, container);\n      parents = filter$2(parents, not(isBogus$2));\n      path = path.concat(map$1(parents, function (node) {\n        return createPathItem(node);\n      }));\n      return path.reverse().join('/') + ',' + outputOffset;\n    };\n    var resolvePathItem = function (node, name, index) {\n      var nodes = getChildNodes(node);\n      nodes = filter$2(nodes, function (node, index) {\n        return !isText$3(node) || !isText$3(nodes[index - 1]);\n      });\n      nodes = filter$2(nodes, matchNodeNames([name]));\n      return nodes[index];\n    };\n    var findTextPosition = function (container, offset) {\n      var node = container, targetOffset = 0, dataLen;\n      while (isText$3(node)) {\n        dataLen = node.data.length;\n        if (offset >= targetOffset && offset <= targetOffset + dataLen) {\n          container = node;\n          offset = offset - targetOffset;\n          break;\n        }\n        if (!isText$3(node.nextSibling)) {\n          container = node;\n          offset = dataLen;\n          break;\n        }\n        targetOffset += dataLen;\n        node = node.nextSibling;\n      }\n      if (isText$3(container) && offset > container.data.length) {\n        offset = container.data.length;\n      }\n      return CaretPosition(container, offset);\n    };\n    var resolve$2 = function (root, path) {\n      var offset;\n      if (!path) {\n        return null;\n      }\n      var parts = path.split(',');\n      var paths = parts[0].split('/');\n      offset = parts.length > 1 ? parts[1] : 'before';\n      var container = reduce(paths, function (result, value) {\n        var match = /([\\w\\-\\(\\)]+)\\[([0-9]+)\\]/.exec(value);\n        if (!match) {\n          return null;\n        }\n        if (match[1] === 'text()') {\n          match[1] = '#text';\n        }\n        return resolvePathItem(result, match[1], parseInt(match[2], 10));\n      }, root);\n      if (!container) {\n        return null;\n      }\n      if (!isText$3(container)) {\n        if (offset === 'after') {\n          offset = nodeIndex(container) + 1;\n        } else {\n          offset = nodeIndex(container);\n        }\n        return CaretPosition(container.parentNode, offset);\n      }\n      return findTextPosition(container, parseInt(offset, 10));\n    };\n\n    var isContentEditableFalse$9 = isContentEditableFalse$b;\n    var getNormalizedTextOffset = function (trim, container, offset) {\n      var node, trimmedOffset;\n      trimmedOffset = trim(container.data.slice(0, offset)).length;\n      for (node = container.previousSibling; node && isText$7(node); node = node.previousSibling) {\n        trimmedOffset += trim(node.data).length;\n      }\n      return trimmedOffset;\n    };\n    var getPoint = function (dom, trim, normalized, rng, start) {\n      var container = rng[start ? 'startContainer' : 'endContainer'];\n      var offset = rng[start ? 'startOffset' : 'endOffset'];\n      var point = [];\n      var childNodes, after = 0;\n      var root = dom.getRoot();\n      if (isText$7(container)) {\n        point.push(normalized ? getNormalizedTextOffset(trim, container, offset) : offset);\n      } else {\n        childNodes = container.childNodes;\n        if (offset >= childNodes.length && childNodes.length) {\n          after = 1;\n          offset = Math.max(0, childNodes.length - 1);\n        }\n        point.push(dom.nodeIndex(childNodes[offset], normalized) + after);\n      }\n      for (; container && container !== root; container = container.parentNode) {\n        point.push(dom.nodeIndex(container, normalized));\n      }\n      return point;\n    };\n    var getLocation = function (trim, selection, normalized, rng) {\n      var dom = selection.dom, bookmark = {};\n      bookmark.start = getPoint(dom, trim, normalized, rng, true);\n      if (!selection.isCollapsed()) {\n        bookmark.end = getPoint(dom, trim, normalized, rng, false);\n      }\n      if (isRangeInCaretContainerBlock(rng)) {\n        bookmark.isFakeCaret = true;\n      }\n      return bookmark;\n    };\n    var findIndex = function (dom, name, element) {\n      var count = 0;\n      Tools.each(dom.select(name), function (node) {\n        if (node.getAttribute('data-mce-bogus') === 'all') {\n          return;\n        }\n        if (node === element) {\n          return false;\n        }\n        count++;\n      });\n      return count;\n    };\n    var moveEndPoint$1 = function (rng, start) {\n      var container, offset, childNodes;\n      var prefix = start ? 'start' : 'end';\n      container = rng[prefix + 'Container'];\n      offset = rng[prefix + 'Offset'];\n      if (isElement$5(container) && container.nodeName === 'TR') {\n        childNodes = container.childNodes;\n        container = childNodes[Math.min(start ? offset : offset - 1, childNodes.length - 1)];\n        if (container) {\n          offset = start ? 0 : container.childNodes.length;\n          rng['set' + (start ? 'Start' : 'End')](container, offset);\n        }\n      }\n    };\n    var normalizeTableCellSelection = function (rng) {\n      moveEndPoint$1(rng, true);\n      moveEndPoint$1(rng, false);\n      return rng;\n    };\n    var findSibling = function (node, offset) {\n      var sibling;\n      if (isElement$5(node)) {\n        node = getNode$1(node, offset);\n        if (isContentEditableFalse$9(node)) {\n          return node;\n        }\n      }\n      if (isCaretContainer$2(node)) {\n        if (isText$7(node) && isCaretContainerBlock$1(node)) {\n          node = node.parentNode;\n        }\n        sibling = node.previousSibling;\n        if (isContentEditableFalse$9(sibling)) {\n          return sibling;\n        }\n        sibling = node.nextSibling;\n        if (isContentEditableFalse$9(sibling)) {\n          return sibling;\n        }\n      }\n    };\n    var findAdjacentContentEditableFalseElm = function (rng) {\n      return findSibling(rng.startContainer, rng.startOffset) || findSibling(rng.endContainer, rng.endOffset);\n    };\n    var getOffsetBookmark = function (trim, normalized, selection) {\n      var element = selection.getNode();\n      var name = element ? element.nodeName : null;\n      var rng = selection.getRng();\n      if (isContentEditableFalse$9(element) || name === 'IMG') {\n        return {\n          name: name,\n          index: findIndex(selection.dom, name, element)\n        };\n      }\n      var sibling = findAdjacentContentEditableFalseElm(rng);\n      if (sibling) {\n        name = sibling.tagName;\n        return {\n          name: name,\n          index: findIndex(selection.dom, name, sibling)\n        };\n      }\n      return getLocation(trim, selection, normalized, rng);\n    };\n    var getCaretBookmark = function (selection) {\n      var rng = selection.getRng();\n      return {\n        start: create$6(selection.dom.getRoot(), CaretPosition.fromRangeStart(rng)),\n        end: create$6(selection.dom.getRoot(), CaretPosition.fromRangeEnd(rng))\n      };\n    };\n    var getRangeBookmark = function (selection) {\n      return { rng: selection.getRng() };\n    };\n    var createBookmarkSpan = function (dom, id, filled) {\n      var args = {\n        'data-mce-type': 'bookmark',\n        id: id,\n        'style': 'overflow:hidden;line-height:0px'\n      };\n      return filled ? dom.create('span', args, '&#xFEFF;') : dom.create('span', args);\n    };\n    var getPersistentBookmark = function (selection, filled) {\n      var dom = selection.dom;\n      var rng = selection.getRng();\n      var id = dom.uniqueId();\n      var collapsed = selection.isCollapsed();\n      var element = selection.getNode();\n      var name = element.nodeName;\n      if (name === 'IMG') {\n        return {\n          name: name,\n          index: findIndex(dom, name, element)\n        };\n      }\n      var rng2 = normalizeTableCellSelection(rng.cloneRange());\n      if (!collapsed) {\n        rng2.collapse(false);\n        var endBookmarkNode = createBookmarkSpan(dom, id + '_end', filled);\n        rangeInsertNode(dom, rng2, endBookmarkNode);\n      }\n      rng = normalizeTableCellSelection(rng);\n      rng.collapse(true);\n      var startBookmarkNode = createBookmarkSpan(dom, id + '_start', filled);\n      rangeInsertNode(dom, rng, startBookmarkNode);\n      selection.moveToBookmark({\n        id: id,\n        keep: true\n      });\n      return { id: id };\n    };\n    var getBookmark$2 = function (selection, type, normalized) {\n      if (type === 2) {\n        return getOffsetBookmark(trim$3, normalized, selection);\n      } else if (type === 3) {\n        return getCaretBookmark(selection);\n      } else if (type) {\n        return getRangeBookmark(selection);\n      } else {\n        return getPersistentBookmark(selection, false);\n      }\n    };\n    var getUndoBookmark = curry(getOffsetBookmark, identity, true);\n\n    var DOM$9 = DOMUtils.DOM;\n    var defaultPreviewStyles = 'font-family font-size font-weight font-style text-decoration text-transform color background-color border border-radius outline text-shadow';\n    var getBodySetting = function (editor, name, defaultValue) {\n      var value = editor.getParam(name, defaultValue);\n      if (value.indexOf('=') !== -1) {\n        var bodyObj = editor.getParam(name, '', 'hash');\n        return get$9(bodyObj, editor.id).getOr(defaultValue);\n      } else {\n        return value;\n      }\n    };\n    var getIframeAttrs = function (editor) {\n      return editor.getParam('iframe_attrs', {});\n    };\n    var getDocType = function (editor) {\n      return editor.getParam('doctype', '<!DOCTYPE html>');\n    };\n    var getDocumentBaseUrl = function (editor) {\n      return editor.getParam('document_base_url', '');\n    };\n    var getBodyId = function (editor) {\n      return getBodySetting(editor, 'body_id', 'tinymce');\n    };\n    var getBodyClass = function (editor) {\n      return getBodySetting(editor, 'body_class', '');\n    };\n    var getContentSecurityPolicy = function (editor) {\n      return editor.getParam('content_security_policy', '');\n    };\n    var shouldPutBrInPre$1 = function (editor) {\n      return editor.getParam('br_in_pre', true);\n    };\n    var getForcedRootBlock = function (editor) {\n      if (editor.getParam('force_p_newlines', false)) {\n        return 'p';\n      }\n      var block = editor.getParam('forced_root_block', 'p');\n      if (block === false) {\n        return '';\n      } else if (block === true) {\n        return 'p';\n      } else {\n        return block;\n      }\n    };\n    var getForcedRootBlockAttrs = function (editor) {\n      return editor.getParam('forced_root_block_attrs', {});\n    };\n    var getBrNewLineSelector = function (editor) {\n      return editor.getParam('br_newline_selector', '.mce-toc h2,figcaption,caption');\n    };\n    var getNoNewLineSelector = function (editor) {\n      return editor.getParam('no_newline_selector', '');\n    };\n    var shouldKeepStyles = function (editor) {\n      return editor.getParam('keep_styles', true);\n    };\n    var shouldEndContainerOnEmptyBlock = function (editor) {\n      return editor.getParam('end_container_on_empty_block', false);\n    };\n    var getFontStyleValues = function (editor) {\n      return Tools.explode(editor.getParam('font_size_style_values', 'xx-small,x-small,small,medium,large,x-large,xx-large'));\n    };\n    var getFontSizeClasses = function (editor) {\n      return Tools.explode(editor.getParam('font_size_classes', ''));\n    };\n    var getImagesDataImgFilter = function (editor) {\n      return editor.getParam('images_dataimg_filter', always, 'function');\n    };\n    var isAutomaticUploadsEnabled = function (editor) {\n      return editor.getParam('automatic_uploads', true, 'boolean');\n    };\n    var shouldReuseFileName = function (editor) {\n      return editor.getParam('images_reuse_filename', false, 'boolean');\n    };\n    var shouldReplaceBlobUris = function (editor) {\n      return editor.getParam('images_replace_blob_uris', true, 'boolean');\n    };\n    var getIconPackName = function (editor) {\n      return editor.getParam('icons', '', 'string');\n    };\n    var getIconsUrl = function (editor) {\n      return editor.getParam('icons_url', '', 'string');\n    };\n    var getImageUploadUrl = function (editor) {\n      return editor.getParam('images_upload_url', '', 'string');\n    };\n    var getImageUploadBasePath = function (editor) {\n      return editor.getParam('images_upload_base_path', '', 'string');\n    };\n    var getImagesUploadCredentials = function (editor) {\n      return editor.getParam('images_upload_credentials', false, 'boolean');\n    };\n    var getImagesUploadHandler = function (editor) {\n      return editor.getParam('images_upload_handler', null, 'function');\n    };\n    var shouldUseContentCssCors = function (editor) {\n      return editor.getParam('content_css_cors', false, 'boolean');\n    };\n    var getReferrerPolicy = function (editor) {\n      return editor.getParam('referrer_policy', '', 'string');\n    };\n    var getLanguageCode = function (editor) {\n      return editor.getParam('language', 'en', 'string');\n    };\n    var getLanguageUrl = function (editor) {\n      return editor.getParam('language_url', '', 'string');\n    };\n    var shouldIndentUseMargin = function (editor) {\n      return editor.getParam('indent_use_margin', false);\n    };\n    var getIndentation = function (editor) {\n      return editor.getParam('indentation', '40px', 'string');\n    };\n    var getContentCss = function (editor) {\n      var contentCss = editor.getParam('content_css');\n      if (isString$1(contentCss)) {\n        return map$3(contentCss.split(','), trim$5);\n      } else if (isArray$1(contentCss)) {\n        return contentCss;\n      } else if (contentCss === false || editor.inline) {\n        return [];\n      } else {\n        return ['default'];\n      }\n    };\n    var getFontCss = function (editor) {\n      var fontCss = editor.getParam('font_css', []);\n      return isArray$1(fontCss) ? fontCss : map$3(fontCss.split(','), trim$5);\n    };\n    var getDirectionality = function (editor) {\n      return editor.getParam('directionality', I18n.isRtl() ? 'rtl' : undefined);\n    };\n    var getInlineBoundarySelector = function (editor) {\n      return editor.getParam('inline_boundaries_selector', 'a[href],code,.mce-annotation', 'string');\n    };\n    var getObjectResizing = function (editor) {\n      var selector = editor.getParam('object_resizing');\n      if (selector === false || Env.iOS) {\n        return false;\n      } else {\n        return isString$1(selector) ? selector : 'table,img,figure.image,div,video,iframe';\n      }\n    };\n    var getResizeImgProportional = function (editor) {\n      return editor.getParam('resize_img_proportional', true, 'boolean');\n    };\n    var getPlaceholder = function (editor) {\n      return editor.getParam('placeholder', DOM$9.getAttrib(editor.getElement(), 'placeholder'), 'string');\n    };\n    var getEventRoot = function (editor) {\n      return editor.getParam('event_root');\n    };\n    var getServiceMessage = function (editor) {\n      return editor.getParam('service_message');\n    };\n    var getTheme = function (editor) {\n      return editor.getParam('theme');\n    };\n    var shouldValidate = function (editor) {\n      return editor.getParam('validate');\n    };\n    var isInlineBoundariesEnabled = function (editor) {\n      return editor.getParam('inline_boundaries') !== false;\n    };\n    var getFormats = function (editor) {\n      return editor.getParam('formats');\n    };\n    var getPreviewStyles = function (editor) {\n      var style = editor.getParam('preview_styles', defaultPreviewStyles);\n      if (isString$1(style)) {\n        return style;\n      } else {\n        return '';\n      }\n    };\n    var canFormatEmptyLines = function (editor) {\n      return editor.getParam('format_empty_lines', false, 'boolean');\n    };\n    var getCustomUiSelector = function (editor) {\n      return editor.getParam('custom_ui_selector', '', 'string');\n    };\n    var getThemeUrl = function (editor) {\n      return editor.getParam('theme_url');\n    };\n    var isInline = function (editor) {\n      return editor.getParam('inline');\n    };\n    var hasHiddenInput = function (editor) {\n      return editor.getParam('hidden_input');\n    };\n    var shouldPatchSubmit = function (editor) {\n      return editor.getParam('submit_patch');\n    };\n    var isEncodingXml = function (editor) {\n      return editor.getParam('encoding') === 'xml';\n    };\n    var shouldAddFormSubmitTrigger = function (editor) {\n      return editor.getParam('add_form_submit_trigger');\n    };\n    var shouldAddUnloadTrigger = function (editor) {\n      return editor.getParam('add_unload_trigger');\n    };\n    var hasForcedRootBlock = function (editor) {\n      return getForcedRootBlock(editor) !== '';\n    };\n    var getCustomUndoRedoLevels = function (editor) {\n      return editor.getParam('custom_undo_redo_levels', 0, 'number');\n    };\n    var shouldDisableNodeChange = function (editor) {\n      return editor.getParam('disable_nodechange');\n    };\n    var isReadOnly$1 = function (editor) {\n      return editor.getParam('readonly');\n    };\n    var hasContentCssCors = function (editor) {\n      return editor.getParam('content_css_cors');\n    };\n    var getPlugins = function (editor) {\n      return editor.getParam('plugins', '', 'string');\n    };\n    var getExternalPlugins$1 = function (editor) {\n      return editor.getParam('external_plugins');\n    };\n    var shouldBlockUnsupportedDrop = function (editor) {\n      return editor.getParam('block_unsupported_drop', true, 'boolean');\n    };\n    var isVisualAidsEnabled = function (editor) {\n      return editor.getParam('visual', true, 'boolean');\n    };\n    var getVisualAidsTableClass = function (editor) {\n      return editor.getParam('visual_table_class', 'mce-item-table', 'string');\n    };\n    var getVisualAidsAnchorClass = function (editor) {\n      return editor.getParam('visual_anchor_class', 'mce-item-anchor', 'string');\n    };\n    var getIframeAriaText = function (editor) {\n      return editor.getParam('iframe_aria_text', 'Rich Text Area. Press ALT-0 for help.', 'string');\n    };\n\n    var isElement$2 = isElement$5;\n    var isText$2 = isText$7;\n    var removeNode$1 = function (node) {\n      var parentNode = node.parentNode;\n      if (parentNode) {\n        parentNode.removeChild(node);\n      }\n    };\n    var trimCount = function (text) {\n      var trimmedText = trim$3(text);\n      return {\n        count: text.length - trimmedText.length,\n        text: trimmedText\n      };\n    };\n    var deleteZwspChars = function (caretContainer) {\n      var idx;\n      while ((idx = caretContainer.data.lastIndexOf(ZWSP$1)) !== -1) {\n        caretContainer.deleteData(idx, 1);\n      }\n    };\n    var removeUnchanged = function (caretContainer, pos) {\n      remove$2(caretContainer);\n      return pos;\n    };\n    var removeTextAndReposition = function (caretContainer, pos) {\n      var before = trimCount(caretContainer.data.substr(0, pos.offset()));\n      var after = trimCount(caretContainer.data.substr(pos.offset()));\n      var text = before.text + after.text;\n      if (text.length > 0) {\n        deleteZwspChars(caretContainer);\n        return CaretPosition(caretContainer, pos.offset() - before.count);\n      } else {\n        return pos;\n      }\n    };\n    var removeElementAndReposition = function (caretContainer, pos) {\n      var parentNode = pos.container();\n      var newPosition = indexOf$2(from(parentNode.childNodes), caretContainer).map(function (index) {\n        return index < pos.offset() ? CaretPosition(parentNode, pos.offset() - 1) : pos;\n      }).getOr(pos);\n      remove$2(caretContainer);\n      return newPosition;\n    };\n    var removeTextCaretContainer = function (caretContainer, pos) {\n      return isText$2(caretContainer) && pos.container() === caretContainer ? removeTextAndReposition(caretContainer, pos) : removeUnchanged(caretContainer, pos);\n    };\n    var removeElementCaretContainer = function (caretContainer, pos) {\n      return pos.container() === caretContainer.parentNode ? removeElementAndReposition(caretContainer, pos) : removeUnchanged(caretContainer, pos);\n    };\n    var removeAndReposition = function (container, pos) {\n      return CaretPosition.isTextPosition(pos) ? removeTextCaretContainer(container, pos) : removeElementCaretContainer(container, pos);\n    };\n    var remove$2 = function (caretContainerNode) {\n      if (isElement$2(caretContainerNode) && isCaretContainer$2(caretContainerNode)) {\n        if (hasContent(caretContainerNode)) {\n          caretContainerNode.removeAttribute('data-mce-caret');\n        } else {\n          removeNode$1(caretContainerNode);\n        }\n      }\n      if (isText$2(caretContainerNode)) {\n        deleteZwspChars(caretContainerNode);\n        if (caretContainerNode.data.length === 0) {\n          removeNode$1(caretContainerNode);\n        }\n      }\n    };\n\n    var browser$2 = detect().browser;\n    var isContentEditableFalse$8 = isContentEditableFalse$b;\n    var isMedia$1 = isMedia$2;\n    var isTableCell$3 = isTableCell$5;\n    var inlineFakeCaretSelector = '*[contentEditable=false],video,audio,embed,object';\n    var getAbsoluteClientRect = function (root, element, before) {\n      var clientRect = collapse(element.getBoundingClientRect(), before);\n      var scrollX;\n      var scrollY;\n      if (root.tagName === 'BODY') {\n        var docElm = root.ownerDocument.documentElement;\n        scrollX = root.scrollLeft || docElm.scrollLeft;\n        scrollY = root.scrollTop || docElm.scrollTop;\n      } else {\n        var rootRect = root.getBoundingClientRect();\n        scrollX = root.scrollLeft - rootRect.left;\n        scrollY = root.scrollTop - rootRect.top;\n      }\n      clientRect.left += scrollX;\n      clientRect.right += scrollX;\n      clientRect.top += scrollY;\n      clientRect.bottom += scrollY;\n      clientRect.width = 1;\n      var margin = element.offsetWidth - element.clientWidth;\n      if (margin > 0) {\n        if (before) {\n          margin *= -1;\n        }\n        clientRect.left += margin;\n        clientRect.right += margin;\n      }\n      return clientRect;\n    };\n    var trimInlineCaretContainers = function (root) {\n      var fakeCaretTargetNodes = descendants(SugarElement.fromDom(root), inlineFakeCaretSelector);\n      for (var i = 0; i < fakeCaretTargetNodes.length; i++) {\n        var node = fakeCaretTargetNodes[i].dom;\n        var sibling = node.previousSibling;\n        if (endsWithCaretContainer$1(sibling)) {\n          var data = sibling.data;\n          if (data.length === 1) {\n            sibling.parentNode.removeChild(sibling);\n          } else {\n            sibling.deleteData(data.length - 1, 1);\n          }\n        }\n        sibling = node.nextSibling;\n        if (startsWithCaretContainer$1(sibling)) {\n          var data = sibling.data;\n          if (data.length === 1) {\n            sibling.parentNode.removeChild(sibling);\n          } else {\n            sibling.deleteData(0, 1);\n          }\n        }\n      }\n    };\n    var FakeCaret = function (editor, root, isBlock, hasFocus) {\n      var lastVisualCaret = value();\n      var cursorInterval;\n      var caretContainerNode;\n      var rootBlock = getForcedRootBlock(editor);\n      var caretBlock = rootBlock.length > 0 ? rootBlock : 'p';\n      var show = function (before, element) {\n        var rng;\n        hide();\n        if (isTableCell$3(element)) {\n          return null;\n        }\n        if (isBlock(element)) {\n          caretContainerNode = insertBlock$1(caretBlock, element, before);\n          var clientRect = getAbsoluteClientRect(root, element, before);\n          DomQuery(caretContainerNode).css('top', clientRect.top);\n          var caret = DomQuery('<div class=\"mce-visual-caret\" data-mce-bogus=\"all\"></div>').css(__assign({}, clientRect)).appendTo(root)[0];\n          lastVisualCaret.set({\n            caret: caret,\n            element: element,\n            before: before\n          });\n          if (before) {\n            DomQuery(caret).addClass('mce-visual-caret-before');\n          }\n          startBlink();\n          rng = element.ownerDocument.createRange();\n          rng.setStart(caretContainerNode, 0);\n          rng.setEnd(caretContainerNode, 0);\n        } else {\n          caretContainerNode = insertInline$1(element, before);\n          rng = element.ownerDocument.createRange();\n          if (isInlineFakeCaretTarget(caretContainerNode.nextSibling)) {\n            rng.setStart(caretContainerNode, 0);\n            rng.setEnd(caretContainerNode, 0);\n          } else {\n            rng.setStart(caretContainerNode, 1);\n            rng.setEnd(caretContainerNode, 1);\n          }\n          return rng;\n        }\n        return rng;\n      };\n      var hide = function () {\n        trimInlineCaretContainers(root);\n        if (caretContainerNode) {\n          remove$2(caretContainerNode);\n          caretContainerNode = null;\n        }\n        lastVisualCaret.on(function (caretState) {\n          DomQuery(caretState.caret).remove();\n          lastVisualCaret.clear();\n        });\n        if (cursorInterval) {\n          Delay.clearInterval(cursorInterval);\n          cursorInterval = undefined;\n        }\n      };\n      var startBlink = function () {\n        cursorInterval = Delay.setInterval(function () {\n          if (hasFocus()) {\n            DomQuery('div.mce-visual-caret', root).toggleClass('mce-visual-caret-hidden');\n          } else {\n            DomQuery('div.mce-visual-caret', root).addClass('mce-visual-caret-hidden');\n          }\n        }, 500);\n      };\n      var reposition = function () {\n        lastVisualCaret.on(function (caretState) {\n          var clientRect = getAbsoluteClientRect(root, caretState.element, caretState.before);\n          DomQuery(caretState.caret).css(__assign({}, clientRect));\n        });\n      };\n      var destroy = function () {\n        return Delay.clearInterval(cursorInterval);\n      };\n      var getCss = function () {\n        return '.mce-visual-caret {' + 'position: absolute;' + 'background-color: black;' + 'background-color: currentcolor;' + '}' + '.mce-visual-caret-hidden {' + 'display: none;' + '}' + '*[data-mce-caret] {' + 'position: absolute;' + 'left: -1000px;' + 'right: auto;' + 'top: 0;' + 'margin: 0;' + 'padding: 0;' + '}';\n      };\n      return {\n        show: show,\n        hide: hide,\n        getCss: getCss,\n        reposition: reposition,\n        destroy: destroy\n      };\n    };\n    var isFakeCaretTableBrowser = function () {\n      return browser$2.isIE() || browser$2.isEdge() || browser$2.isFirefox();\n    };\n    var isInlineFakeCaretTarget = function (node) {\n      return isContentEditableFalse$8(node) || isMedia$1(node);\n    };\n    var isFakeCaretTarget = function (node) {\n      return isInlineFakeCaretTarget(node) || isTable$3(node) && isFakeCaretTableBrowser();\n    };\n\n    var isContentEditableFalse$7 = isContentEditableFalse$b;\n    var isMedia = isMedia$2;\n    var isBlockLike = matchStyleValues('display', 'block table table-cell table-caption list-item');\n    var isCaretContainer = isCaretContainer$2;\n    var isCaretContainerBlock = isCaretContainerBlock$1;\n    var isElement$1 = isElement$5;\n    var isCaretCandidate$1 = isCaretCandidate$3;\n    var isForwards = function (direction) {\n      return direction > 0;\n    };\n    var isBackwards = function (direction) {\n      return direction < 0;\n    };\n    var skipCaretContainers = function (walk, shallow) {\n      var node;\n      while (node = walk(shallow)) {\n        if (!isCaretContainerBlock(node)) {\n          return node;\n        }\n      }\n      return null;\n    };\n    var findNode$1 = function (node, direction, predicateFn, rootNode, shallow) {\n      var walker = new DomTreeWalker(node, rootNode);\n      var isCefOrCaretContainer = isContentEditableFalse$7(node) || isCaretContainerBlock(node);\n      if (isBackwards(direction)) {\n        if (isCefOrCaretContainer) {\n          node = skipCaretContainers(walker.prev.bind(walker), true);\n          if (predicateFn(node)) {\n            return node;\n          }\n        }\n        while (node = skipCaretContainers(walker.prev.bind(walker), shallow)) {\n          if (predicateFn(node)) {\n            return node;\n          }\n        }\n      }\n      if (isForwards(direction)) {\n        if (isCefOrCaretContainer) {\n          node = skipCaretContainers(walker.next.bind(walker), true);\n          if (predicateFn(node)) {\n            return node;\n          }\n        }\n        while (node = skipCaretContainers(walker.next.bind(walker), shallow)) {\n          if (predicateFn(node)) {\n            return node;\n          }\n        }\n      }\n      return null;\n    };\n    var getParentBlock$2 = function (node, rootNode) {\n      while (node && node !== rootNode) {\n        if (isBlockLike(node)) {\n          return node;\n        }\n        node = node.parentNode;\n      }\n      return null;\n    };\n    var isInSameBlock = function (caretPosition1, caretPosition2, rootNode) {\n      return getParentBlock$2(caretPosition1.container(), rootNode) === getParentBlock$2(caretPosition2.container(), rootNode);\n    };\n    var getChildNodeAtRelativeOffset = function (relativeOffset, caretPosition) {\n      if (!caretPosition) {\n        return null;\n      }\n      var container = caretPosition.container();\n      var offset = caretPosition.offset();\n      if (!isElement$1(container)) {\n        return null;\n      }\n      return container.childNodes[offset + relativeOffset];\n    };\n    var beforeAfter = function (before, node) {\n      var range = node.ownerDocument.createRange();\n      if (before) {\n        range.setStartBefore(node);\n        range.setEndBefore(node);\n      } else {\n        range.setStartAfter(node);\n        range.setEndAfter(node);\n      }\n      return range;\n    };\n    var isNodesInSameBlock = function (root, node1, node2) {\n      return getParentBlock$2(node1, root) === getParentBlock$2(node2, root);\n    };\n    var lean = function (left, root, node) {\n      var siblingName = left ? 'previousSibling' : 'nextSibling';\n      while (node && node !== root) {\n        var sibling = node[siblingName];\n        if (isCaretContainer(sibling)) {\n          sibling = sibling[siblingName];\n        }\n        if (isContentEditableFalse$7(sibling) || isMedia(sibling)) {\n          if (isNodesInSameBlock(root, sibling, node)) {\n            return sibling;\n          }\n          break;\n        }\n        if (isCaretCandidate$1(sibling)) {\n          break;\n        }\n        node = node.parentNode;\n      }\n      return null;\n    };\n    var before$2 = curry(beforeAfter, true);\n    var after$2 = curry(beforeAfter, false);\n    var normalizeRange = function (direction, root, range) {\n      var node;\n      var leanLeft = curry(lean, true, root);\n      var leanRight = curry(lean, false, root);\n      var container = range.startContainer;\n      var offset = range.startOffset;\n      if (isCaretContainerBlock$1(container)) {\n        if (!isElement$1(container)) {\n          container = container.parentNode;\n        }\n        var location_1 = container.getAttribute('data-mce-caret');\n        if (location_1 === 'before') {\n          node = container.nextSibling;\n          if (isFakeCaretTarget(node)) {\n            return before$2(node);\n          }\n        }\n        if (location_1 === 'after') {\n          node = container.previousSibling;\n          if (isFakeCaretTarget(node)) {\n            return after$2(node);\n          }\n        }\n      }\n      if (!range.collapsed) {\n        return range;\n      }\n      if (isText$7(container)) {\n        if (isCaretContainer(container)) {\n          if (direction === 1) {\n            node = leanRight(container);\n            if (node) {\n              return before$2(node);\n            }\n            node = leanLeft(container);\n            if (node) {\n              return after$2(node);\n            }\n          }\n          if (direction === -1) {\n            node = leanLeft(container);\n            if (node) {\n              return after$2(node);\n            }\n            node = leanRight(container);\n            if (node) {\n              return before$2(node);\n            }\n          }\n          return range;\n        }\n        if (endsWithCaretContainer$1(container) && offset >= container.data.length - 1) {\n          if (direction === 1) {\n            node = leanRight(container);\n            if (node) {\n              return before$2(node);\n            }\n          }\n          return range;\n        }\n        if (startsWithCaretContainer$1(container) && offset <= 1) {\n          if (direction === -1) {\n            node = leanLeft(container);\n            if (node) {\n              return after$2(node);\n            }\n          }\n          return range;\n        }\n        if (offset === container.data.length) {\n          node = leanRight(container);\n          if (node) {\n            return before$2(node);\n          }\n          return range;\n        }\n        if (offset === 0) {\n          node = leanLeft(container);\n          if (node) {\n            return after$2(node);\n          }\n          return range;\n        }\n      }\n      return range;\n    };\n    var getRelativeCefElm = function (forward, caretPosition) {\n      return Optional.from(getChildNodeAtRelativeOffset(forward ? 0 : -1, caretPosition)).filter(isContentEditableFalse$7);\n    };\n    var getNormalizedRangeEndPoint = function (direction, root, range) {\n      var normalizedRange = normalizeRange(direction, root, range);\n      if (direction === -1) {\n        return CaretPosition.fromRangeStart(normalizedRange);\n      }\n      return CaretPosition.fromRangeEnd(normalizedRange);\n    };\n    var getElementFromPosition = function (pos) {\n      return Optional.from(pos.getNode()).map(SugarElement.fromDom);\n    };\n    var getElementFromPrevPosition = function (pos) {\n      return Optional.from(pos.getNode(true)).map(SugarElement.fromDom);\n    };\n    var getVisualCaretPosition = function (walkFn, caretPosition) {\n      while (caretPosition = walkFn(caretPosition)) {\n        if (caretPosition.isVisible()) {\n          return caretPosition;\n        }\n      }\n      return caretPosition;\n    };\n    var isMoveInsideSameBlock = function (from, to) {\n      var inSameBlock = isInSameBlock(from, to);\n      if (!inSameBlock && isBr$5(from.getNode())) {\n        return true;\n      }\n      return inSameBlock;\n    };\n\n    var HDirection;\n    (function (HDirection) {\n      HDirection[HDirection['Backwards'] = -1] = 'Backwards';\n      HDirection[HDirection['Forwards'] = 1] = 'Forwards';\n    }(HDirection || (HDirection = {})));\n    var isContentEditableFalse$6 = isContentEditableFalse$b;\n    var isText$1 = isText$7;\n    var isElement = isElement$5;\n    var isBr$1 = isBr$5;\n    var isCaretCandidate = isCaretCandidate$3;\n    var isAtomic = isAtomic$1;\n    var isEditableCaretCandidate = isEditableCaretCandidate$1;\n    var getParents$3 = function (node, root) {\n      var parents = [];\n      while (node && node !== root) {\n        parents.push(node);\n        node = node.parentNode;\n      }\n      return parents;\n    };\n    var nodeAtIndex = function (container, offset) {\n      if (container.hasChildNodes() && offset < container.childNodes.length) {\n        return container.childNodes[offset];\n      }\n      return null;\n    };\n    var getCaretCandidatePosition = function (direction, node) {\n      if (isForwards(direction)) {\n        if (isCaretCandidate(node.previousSibling) && !isText$1(node.previousSibling)) {\n          return CaretPosition.before(node);\n        }\n        if (isText$1(node)) {\n          return CaretPosition(node, 0);\n        }\n      }\n      if (isBackwards(direction)) {\n        if (isCaretCandidate(node.nextSibling) && !isText$1(node.nextSibling)) {\n          return CaretPosition.after(node);\n        }\n        if (isText$1(node)) {\n          return CaretPosition(node, node.data.length);\n        }\n      }\n      if (isBackwards(direction)) {\n        if (isBr$1(node)) {\n          return CaretPosition.before(node);\n        }\n        return CaretPosition.after(node);\n      }\n      return CaretPosition.before(node);\n    };\n    var moveForwardFromBr = function (root, nextNode) {\n      var nextSibling = nextNode.nextSibling;\n      if (nextSibling && isCaretCandidate(nextSibling)) {\n        if (isText$1(nextSibling)) {\n          return CaretPosition(nextSibling, 0);\n        } else {\n          return CaretPosition.before(nextSibling);\n        }\n      } else {\n        return findCaretPosition$1(HDirection.Forwards, CaretPosition.after(nextNode), root);\n      }\n    };\n    var findCaretPosition$1 = function (direction, startPos, root) {\n      var node;\n      var nextNode;\n      var innerNode;\n      var caretPosition;\n      if (!isElement(root) || !startPos) {\n        return null;\n      }\n      if (startPos.isEqual(CaretPosition.after(root)) && root.lastChild) {\n        caretPosition = CaretPosition.after(root.lastChild);\n        if (isBackwards(direction) && isCaretCandidate(root.lastChild) && isElement(root.lastChild)) {\n          return isBr$1(root.lastChild) ? CaretPosition.before(root.lastChild) : caretPosition;\n        }\n      } else {\n        caretPosition = startPos;\n      }\n      var container = caretPosition.container();\n      var offset = caretPosition.offset();\n      if (isText$1(container)) {\n        if (isBackwards(direction) && offset > 0) {\n          return CaretPosition(container, --offset);\n        }\n        if (isForwards(direction) && offset < container.length) {\n          return CaretPosition(container, ++offset);\n        }\n        node = container;\n      } else {\n        if (isBackwards(direction) && offset > 0) {\n          nextNode = nodeAtIndex(container, offset - 1);\n          if (isCaretCandidate(nextNode)) {\n            if (!isAtomic(nextNode)) {\n              innerNode = findNode$1(nextNode, direction, isEditableCaretCandidate, nextNode);\n              if (innerNode) {\n                if (isText$1(innerNode)) {\n                  return CaretPosition(innerNode, innerNode.data.length);\n                }\n                return CaretPosition.after(innerNode);\n              }\n            }\n            if (isText$1(nextNode)) {\n              return CaretPosition(nextNode, nextNode.data.length);\n            }\n            return CaretPosition.before(nextNode);\n          }\n        }\n        if (isForwards(direction) && offset < container.childNodes.length) {\n          nextNode = nodeAtIndex(container, offset);\n          if (isCaretCandidate(nextNode)) {\n            if (isBr$1(nextNode)) {\n              return moveForwardFromBr(root, nextNode);\n            }\n            if (!isAtomic(nextNode)) {\n              innerNode = findNode$1(nextNode, direction, isEditableCaretCandidate, nextNode);\n              if (innerNode) {\n                if (isText$1(innerNode)) {\n                  return CaretPosition(innerNode, 0);\n                }\n                return CaretPosition.before(innerNode);\n              }\n            }\n            if (isText$1(nextNode)) {\n              return CaretPosition(nextNode, 0);\n            }\n            return CaretPosition.after(nextNode);\n          }\n        }\n        node = nextNode ? nextNode : caretPosition.getNode();\n      }\n      if (isForwards(direction) && caretPosition.isAtEnd() || isBackwards(direction) && caretPosition.isAtStart()) {\n        node = findNode$1(node, direction, always, root, true);\n        if (isEditableCaretCandidate(node, root)) {\n          return getCaretCandidatePosition(direction, node);\n        }\n      }\n      nextNode = findNode$1(node, direction, isEditableCaretCandidate, root);\n      var rootContentEditableFalseElm = last$1(filter$4(getParents$3(container, root), isContentEditableFalse$6));\n      if (rootContentEditableFalseElm && (!nextNode || !rootContentEditableFalseElm.contains(nextNode))) {\n        if (isForwards(direction)) {\n          caretPosition = CaretPosition.after(rootContentEditableFalseElm);\n        } else {\n          caretPosition = CaretPosition.before(rootContentEditableFalseElm);\n        }\n        return caretPosition;\n      }\n      if (nextNode) {\n        return getCaretCandidatePosition(direction, nextNode);\n      }\n      return null;\n    };\n    var CaretWalker = function (root) {\n      return {\n        next: function (caretPosition) {\n          return findCaretPosition$1(HDirection.Forwards, caretPosition, root);\n        },\n        prev: function (caretPosition) {\n          return findCaretPosition$1(HDirection.Backwards, caretPosition, root);\n        }\n      };\n    };\n\n    var walkToPositionIn = function (forward, root, start) {\n      var position = forward ? CaretPosition.before(start) : CaretPosition.after(start);\n      return fromPosition(forward, root, position);\n    };\n    var afterElement = function (node) {\n      return isBr$5(node) ? CaretPosition.before(node) : CaretPosition.after(node);\n    };\n    var isBeforeOrStart = function (position) {\n      if (CaretPosition.isTextPosition(position)) {\n        return position.offset() === 0;\n      } else {\n        return isCaretCandidate$3(position.getNode());\n      }\n    };\n    var isAfterOrEnd = function (position) {\n      if (CaretPosition.isTextPosition(position)) {\n        var container = position.container();\n        return position.offset() === container.data.length;\n      } else {\n        return isCaretCandidate$3(position.getNode(true));\n      }\n    };\n    var isBeforeAfterSameElement = function (from, to) {\n      return !CaretPosition.isTextPosition(from) && !CaretPosition.isTextPosition(to) && from.getNode() === to.getNode(true);\n    };\n    var isAtBr = function (position) {\n      return !CaretPosition.isTextPosition(position) && isBr$5(position.getNode());\n    };\n    var shouldSkipPosition = function (forward, from, to) {\n      if (forward) {\n        return !isBeforeAfterSameElement(from, to) && !isAtBr(from) && isAfterOrEnd(from) && isBeforeOrStart(to);\n      } else {\n        return !isBeforeAfterSameElement(to, from) && isBeforeOrStart(from) && isAfterOrEnd(to);\n      }\n    };\n    var fromPosition = function (forward, root, pos) {\n      var walker = CaretWalker(root);\n      return Optional.from(forward ? walker.next(pos) : walker.prev(pos));\n    };\n    var navigate = function (forward, root, from) {\n      return fromPosition(forward, root, from).bind(function (to) {\n        if (isInSameBlock(from, to, root) && shouldSkipPosition(forward, from, to)) {\n          return fromPosition(forward, root, to);\n        } else {\n          return Optional.some(to);\n        }\n      });\n    };\n    var navigateIgnore = function (forward, root, from, ignoreFilter) {\n      return navigate(forward, root, from).bind(function (pos) {\n        return ignoreFilter(pos) ? navigateIgnore(forward, root, pos, ignoreFilter) : Optional.some(pos);\n      });\n    };\n    var positionIn = function (forward, element) {\n      var startNode = forward ? element.firstChild : element.lastChild;\n      if (isText$7(startNode)) {\n        return Optional.some(CaretPosition(startNode, forward ? 0 : startNode.data.length));\n      } else if (startNode) {\n        if (isCaretCandidate$3(startNode)) {\n          return Optional.some(forward ? CaretPosition.before(startNode) : afterElement(startNode));\n        } else {\n          return walkToPositionIn(forward, element, startNode);\n        }\n      } else {\n        return Optional.none();\n      }\n    };\n    var nextPosition = curry(fromPosition, true);\n    var prevPosition = curry(fromPosition, false);\n    var firstPositionIn = curry(positionIn, true);\n    var lastPositionIn = curry(positionIn, false);\n\n    var CARET_ID$1 = '_mce_caret';\n    var isCaretNode = function (node) {\n      return isElement$5(node) && node.id === CARET_ID$1;\n    };\n    var getParentCaretContainer = function (body, node) {\n      while (node && node !== body) {\n        if (node.id === CARET_ID$1) {\n          return node;\n        }\n        node = node.parentNode;\n      }\n      return null;\n    };\n\n    var isStringPathBookmark = function (bookmark) {\n      return isString$1(bookmark.start);\n    };\n    var isRangeBookmark = function (bookmark) {\n      return has$2(bookmark, 'rng');\n    };\n    var isIdBookmark = function (bookmark) {\n      return has$2(bookmark, 'id');\n    };\n    var isIndexBookmark = function (bookmark) {\n      return has$2(bookmark, 'name');\n    };\n    var isPathBookmark = function (bookmark) {\n      return Tools.isArray(bookmark.start);\n    };\n\n    var addBogus = function (dom, node) {\n      if (isElement$5(node) && dom.isBlock(node) && !node.innerHTML && !Env.ie) {\n        node.innerHTML = '<br data-mce-bogus=\"1\" />';\n      }\n      return node;\n    };\n    var resolveCaretPositionBookmark = function (dom, bookmark) {\n      var pos;\n      var rng = dom.createRng();\n      pos = resolve$2(dom.getRoot(), bookmark.start);\n      rng.setStart(pos.container(), pos.offset());\n      pos = resolve$2(dom.getRoot(), bookmark.end);\n      rng.setEnd(pos.container(), pos.offset());\n      return rng;\n    };\n    var insertZwsp = function (node, rng) {\n      var textNode = node.ownerDocument.createTextNode(ZWSP$1);\n      node.appendChild(textNode);\n      rng.setStart(textNode, 0);\n      rng.setEnd(textNode, 0);\n    };\n    var isEmpty$1 = function (node) {\n      return node.hasChildNodes() === false;\n    };\n    var tryFindRangePosition = function (node, rng) {\n      return lastPositionIn(node).fold(never, function (pos) {\n        rng.setStart(pos.container(), pos.offset());\n        rng.setEnd(pos.container(), pos.offset());\n        return true;\n      });\n    };\n    var padEmptyCaretContainer = function (root, node, rng) {\n      if (isEmpty$1(node) && getParentCaretContainer(root, node)) {\n        insertZwsp(node, rng);\n        return true;\n      } else {\n        return false;\n      }\n    };\n    var setEndPoint = function (dom, start, bookmark, rng) {\n      var point = bookmark[start ? 'start' : 'end'];\n      var i, node, offset, children;\n      var root = dom.getRoot();\n      if (point) {\n        offset = point[0];\n        for (node = root, i = point.length - 1; i >= 1; i--) {\n          children = node.childNodes;\n          if (padEmptyCaretContainer(root, node, rng)) {\n            return true;\n          }\n          if (point[i] > children.length - 1) {\n            if (padEmptyCaretContainer(root, node, rng)) {\n              return true;\n            }\n            return tryFindRangePosition(node, rng);\n          }\n          node = children[point[i]];\n        }\n        if (node.nodeType === 3) {\n          offset = Math.min(point[0], node.nodeValue.length);\n        }\n        if (node.nodeType === 1) {\n          offset = Math.min(point[0], node.childNodes.length);\n        }\n        if (start) {\n          rng.setStart(node, offset);\n        } else {\n          rng.setEnd(node, offset);\n        }\n      }\n      return true;\n    };\n    var isValidTextNode = function (node) {\n      return isText$7(node) && node.data.length > 0;\n    };\n    var restoreEndPoint = function (dom, suffix, bookmark) {\n      var marker = dom.get(bookmark.id + '_' + suffix), node, idx, next, prev;\n      var keep = bookmark.keep;\n      var container, offset;\n      if (marker) {\n        node = marker.parentNode;\n        if (suffix === 'start') {\n          if (!keep) {\n            idx = dom.nodeIndex(marker);\n          } else {\n            if (marker.hasChildNodes()) {\n              node = marker.firstChild;\n              idx = 1;\n            } else if (isValidTextNode(marker.nextSibling)) {\n              node = marker.nextSibling;\n              idx = 0;\n            } else if (isValidTextNode(marker.previousSibling)) {\n              node = marker.previousSibling;\n              idx = marker.previousSibling.data.length;\n            } else {\n              node = marker.parentNode;\n              idx = dom.nodeIndex(marker) + 1;\n            }\n          }\n          container = node;\n          offset = idx;\n        } else {\n          if (!keep) {\n            idx = dom.nodeIndex(marker);\n          } else {\n            if (marker.hasChildNodes()) {\n              node = marker.firstChild;\n              idx = 1;\n            } else if (isValidTextNode(marker.previousSibling)) {\n              node = marker.previousSibling;\n              idx = marker.previousSibling.data.length;\n            } else {\n              node = marker.parentNode;\n              idx = dom.nodeIndex(marker);\n            }\n          }\n          container = node;\n          offset = idx;\n        }\n        if (!keep) {\n          prev = marker.previousSibling;\n          next = marker.nextSibling;\n          Tools.each(Tools.grep(marker.childNodes), function (node) {\n            if (isText$7(node)) {\n              node.nodeValue = node.nodeValue.replace(/\\uFEFF/g, '');\n            }\n          });\n          while (marker = dom.get(bookmark.id + '_' + suffix)) {\n            dom.remove(marker, true);\n          }\n          if (prev && next && prev.nodeType === next.nodeType && isText$7(prev) && !Env.opera) {\n            idx = prev.nodeValue.length;\n            prev.appendData(next.nodeValue);\n            dom.remove(next);\n            container = prev;\n            offset = idx;\n          }\n        }\n        return Optional.some(CaretPosition(container, offset));\n      } else {\n        return Optional.none();\n      }\n    };\n    var resolvePaths = function (dom, bookmark) {\n      var rng = dom.createRng();\n      if (setEndPoint(dom, true, bookmark, rng) && setEndPoint(dom, false, bookmark, rng)) {\n        return Optional.some(rng);\n      } else {\n        return Optional.none();\n      }\n    };\n    var resolveId = function (dom, bookmark) {\n      var startPos = restoreEndPoint(dom, 'start', bookmark);\n      var endPos = restoreEndPoint(dom, 'end', bookmark);\n      return lift2(startPos, endPos.or(startPos), function (spos, epos) {\n        var rng = dom.createRng();\n        rng.setStart(addBogus(dom, spos.container()), spos.offset());\n        rng.setEnd(addBogus(dom, epos.container()), epos.offset());\n        return rng;\n      });\n    };\n    var resolveIndex = function (dom, bookmark) {\n      return Optional.from(dom.select(bookmark.name)[bookmark.index]).map(function (elm) {\n        var rng = dom.createRng();\n        rng.selectNode(elm);\n        return rng;\n      });\n    };\n    var resolve$1 = function (selection, bookmark) {\n      var dom = selection.dom;\n      if (bookmark) {\n        if (isPathBookmark(bookmark)) {\n          return resolvePaths(dom, bookmark);\n        } else if (isStringPathBookmark(bookmark)) {\n          return Optional.some(resolveCaretPositionBookmark(dom, bookmark));\n        } else if (isIdBookmark(bookmark)) {\n          return resolveId(dom, bookmark);\n        } else if (isIndexBookmark(bookmark)) {\n          return resolveIndex(dom, bookmark);\n        } else if (isRangeBookmark(bookmark)) {\n          return Optional.some(bookmark.rng);\n        }\n      }\n      return Optional.none();\n    };\n\n    var getBookmark$1 = function (selection, type, normalized) {\n      return getBookmark$2(selection, type, normalized);\n    };\n    var moveToBookmark = function (selection, bookmark) {\n      resolve$1(selection, bookmark).each(function (rng) {\n        selection.setRng(rng);\n      });\n    };\n    var isBookmarkNode$1 = function (node) {\n      return isElement$5(node) && node.tagName === 'SPAN' && node.getAttribute('data-mce-type') === 'bookmark';\n    };\n\n    var is = function (expected) {\n      return function (actual) {\n        return expected === actual;\n      };\n    };\n    var isNbsp = is(nbsp);\n    var isWhiteSpace = function (chr) {\n      return chr !== '' && ' \\f\\n\\r\\t\\x0B'.indexOf(chr) !== -1;\n    };\n    var isContent = function (chr) {\n      return !isWhiteSpace(chr) && !isNbsp(chr);\n    };\n\n    var isNode = function (node) {\n      return !!node.nodeType;\n    };\n    var isInlineBlock = function (node) {\n      return node && /^(IMG)$/.test(node.nodeName);\n    };\n    var moveStart = function (dom, selection, rng) {\n      var offset = rng.startOffset;\n      var container = rng.startContainer;\n      if (container === rng.endContainer) {\n        if (isInlineBlock(container.childNodes[offset])) {\n          return;\n        }\n      }\n      if (isElement$5(container)) {\n        var nodes = container.childNodes;\n        var walker = void 0;\n        if (offset < nodes.length) {\n          container = nodes[offset];\n          walker = new DomTreeWalker(container, dom.getParent(container, dom.isBlock));\n        } else {\n          container = nodes[nodes.length - 1];\n          walker = new DomTreeWalker(container, dom.getParent(container, dom.isBlock));\n          walker.next(true);\n        }\n        for (var node = walker.current(); node; node = walker.next()) {\n          if (isText$7(node) && !isWhiteSpaceNode$1(node)) {\n            rng.setStart(node, 0);\n            selection.setRng(rng);\n            return;\n          }\n        }\n      }\n    };\n    var getNonWhiteSpaceSibling = function (node, next, inc) {\n      if (node) {\n        var nextName = next ? 'nextSibling' : 'previousSibling';\n        for (node = inc ? node : node[nextName]; node; node = node[nextName]) {\n          if (isElement$5(node) || !isWhiteSpaceNode$1(node)) {\n            return node;\n          }\n        }\n      }\n    };\n    var isTextBlock$1 = function (editor, name) {\n      if (isNode(name)) {\n        name = name.nodeName;\n      }\n      return !!editor.schema.getTextBlockElements()[name.toLowerCase()];\n    };\n    var isValid = function (ed, parent, child) {\n      return ed.schema.isValidChild(parent, child);\n    };\n    var isWhiteSpaceNode$1 = function (node, allowSpaces) {\n      if (allowSpaces === void 0) {\n        allowSpaces = false;\n      }\n      if (isNonNullable(node) && isText$7(node)) {\n        var data = allowSpaces ? node.data.replace(/ /g, '\\xA0') : node.data;\n        return isWhitespaceText(data);\n      } else {\n        return false;\n      }\n    };\n    var isEmptyTextNode$1 = function (node) {\n      return isNonNullable(node) && isText$7(node) && node.length === 0;\n    };\n    var replaceVars = function (value, vars) {\n      if (isFunction(value)) {\n        value = value(vars);\n      } else if (isNonNullable(vars)) {\n        value = value.replace(/%(\\w+)/g, function (str, name) {\n          return vars[name] || str;\n        });\n      }\n      return value;\n    };\n    var isEq$5 = function (str1, str2) {\n      str1 = str1 || '';\n      str2 = str2 || '';\n      str1 = '' + (str1.nodeName || str1);\n      str2 = '' + (str2.nodeName || str2);\n      return str1.toLowerCase() === str2.toLowerCase();\n    };\n    var normalizeStyleValue = function (dom, value, name) {\n      if (name === 'color' || name === 'backgroundColor') {\n        value = dom.toHex(value);\n      }\n      if (name === 'fontWeight' && value === 700) {\n        value = 'bold';\n      }\n      if (name === 'fontFamily') {\n        value = value.replace(/[\\'\\\"]/g, '').replace(/,\\s+/g, ',');\n      }\n      return '' + value;\n    };\n    var getStyle = function (dom, node, name) {\n      return normalizeStyleValue(dom, dom.getStyle(node, name), name);\n    };\n    var getTextDecoration = function (dom, node) {\n      var decoration;\n      dom.getParent(node, function (n) {\n        decoration = dom.getStyle(n, 'text-decoration');\n        return decoration && decoration !== 'none';\n      });\n      return decoration;\n    };\n    var getParents$2 = function (dom, node, selector) {\n      return dom.getParents(node, selector, dom.getRoot());\n    };\n    var isVariableFormatName = function (editor, formatName) {\n      var hasVariableValues = function (format) {\n        var isVariableValue = function (val) {\n          return val.length > 1 && val.charAt(0) === '%';\n        };\n        return exists([\n          'styles',\n          'attributes'\n        ], function (key) {\n          return get$9(format, key).exists(function (field) {\n            var fieldValues = isArray$1(field) ? field : values(field);\n            return exists(fieldValues, isVariableValue);\n          });\n        });\n      };\n      return exists(editor.formatter.get(formatName), hasVariableValues);\n    };\n    var areSimilarFormats = function (editor, formatName, otherFormatName) {\n      var validKeys = [\n        'inline',\n        'block',\n        'selector',\n        'attributes',\n        'styles',\n        'classes'\n      ];\n      var filterObj = function (format) {\n        return filter$3(format, function (_, key) {\n          return exists(validKeys, function (validKey) {\n            return validKey === key;\n          });\n        });\n      };\n      return exists(editor.formatter.get(formatName), function (fmt1) {\n        var filteredFmt1 = filterObj(fmt1);\n        return exists(editor.formatter.get(otherFormatName), function (fmt2) {\n          var filteredFmt2 = filterObj(fmt2);\n          return equal$1(filteredFmt1, filteredFmt2);\n        });\n      });\n    };\n    var isBlockFormat = function (format) {\n      return hasNonNullableKey(format, 'block');\n    };\n    var isSelectorFormat = function (format) {\n      return hasNonNullableKey(format, 'selector');\n    };\n    var isInlineFormat = function (format) {\n      return hasNonNullableKey(format, 'inline');\n    };\n    var isMixedFormat = function (format) {\n      return isSelectorFormat(format) && isInlineFormat(format) && is$1(get$9(format, 'mixed'), true);\n    };\n    var shouldExpandToSelector = function (format) {\n      return isSelectorFormat(format) && format.expand !== false && !isInlineFormat(format);\n    };\n\n    var isBookmarkNode = isBookmarkNode$1;\n    var getParents$1 = getParents$2;\n    var isWhiteSpaceNode = isWhiteSpaceNode$1;\n    var isTextBlock = isTextBlock$1;\n    var isBogusBr = function (node) {\n      return isBr$5(node) && node.getAttribute('data-mce-bogus') && !node.nextSibling;\n    };\n    var findParentContentEditable = function (dom, node) {\n      var parent = node;\n      while (parent) {\n        if (isElement$5(parent) && dom.getContentEditable(parent)) {\n          return dom.getContentEditable(parent) === 'false' ? parent : node;\n        }\n        parent = parent.parentNode;\n      }\n      return node;\n    };\n    var walkText = function (start, node, offset, predicate) {\n      var str = node.data;\n      for (var i = offset; start ? i >= 0 : i < str.length; start ? i-- : i++) {\n        if (predicate(str.charAt(i))) {\n          return start ? i + 1 : i;\n        }\n      }\n      return -1;\n    };\n    var findSpace = function (start, node, offset) {\n      return walkText(start, node, offset, function (c) {\n        return isNbsp(c) || isWhiteSpace(c);\n      });\n    };\n    var findContent = function (start, node, offset) {\n      return walkText(start, node, offset, isContent);\n    };\n    var findWordEndPoint = function (dom, body, container, offset, start, includeTrailingSpaces) {\n      var lastTextNode;\n      var rootNode = dom.getParent(container, dom.isBlock) || body;\n      var walk = function (container, offset, pred) {\n        var textSeeker = TextSeeker(dom);\n        var walker = start ? textSeeker.backwards : textSeeker.forwards;\n        return Optional.from(walker(container, offset, function (text, textOffset) {\n          if (isBookmarkNode(text.parentNode)) {\n            return -1;\n          } else {\n            lastTextNode = text;\n            return pred(start, text, textOffset);\n          }\n        }, rootNode));\n      };\n      var spaceResult = walk(container, offset, findSpace);\n      return spaceResult.bind(function (result) {\n        return includeTrailingSpaces ? walk(result.container, result.offset + (start ? -1 : 0), findContent) : Optional.some(result);\n      }).orThunk(function () {\n        return lastTextNode ? Optional.some({\n          container: lastTextNode,\n          offset: start ? 0 : lastTextNode.length\n        }) : Optional.none();\n      });\n    };\n    var findSelectorEndPoint = function (dom, formatList, rng, container, siblingName) {\n      if (isText$7(container) && isEmpty$3(container.data) && container[siblingName]) {\n        container = container[siblingName];\n      }\n      var parents = getParents$1(dom, container);\n      for (var i = 0; i < parents.length; i++) {\n        for (var y = 0; y < formatList.length; y++) {\n          var curFormat = formatList[y];\n          if (isNonNullable(curFormat.collapsed) && curFormat.collapsed !== rng.collapsed) {\n            continue;\n          }\n          if (isSelectorFormat(curFormat) && dom.is(parents[i], curFormat.selector)) {\n            return parents[i];\n          }\n        }\n      }\n      return container;\n    };\n    var findBlockEndPoint = function (editor, formatList, container, siblingName) {\n      var node = container;\n      var dom = editor.dom;\n      var root = dom.getRoot();\n      var format = formatList[0];\n      if (isBlockFormat(format)) {\n        node = format.wrapper ? null : dom.getParent(container, format.block, root);\n      }\n      if (!node) {\n        var scopeRoot = dom.getParent(container, 'LI,TD,TH');\n        node = dom.getParent(isText$7(container) ? container.parentNode : container, function (node) {\n          return node !== root && isTextBlock(editor, node);\n        }, scopeRoot);\n      }\n      if (node && isBlockFormat(format) && format.wrapper) {\n        node = getParents$1(dom, node, 'ul,ol').reverse()[0] || node;\n      }\n      if (!node) {\n        node = container;\n        while (node[siblingName] && !dom.isBlock(node[siblingName])) {\n          node = node[siblingName];\n          if (isEq$5(node, 'br')) {\n            break;\n          }\n        }\n      }\n      return node || container;\n    };\n    var isAtBlockBoundary$1 = function (dom, root, container, siblingName) {\n      var parent = container.parentNode;\n      if (isNonNullable(container[siblingName])) {\n        return false;\n      } else if (parent === root || isNullable(parent) || dom.isBlock(parent)) {\n        return true;\n      } else {\n        return isAtBlockBoundary$1(dom, root, parent, siblingName);\n      }\n    };\n    var findParentContainer = function (dom, formatList, container, offset, start) {\n      var parent = container;\n      var siblingName = start ? 'previousSibling' : 'nextSibling';\n      var root = dom.getRoot();\n      if (isText$7(container) && !isWhiteSpaceNode(container)) {\n        if (start ? offset > 0 : offset < container.data.length) {\n          return container;\n        }\n      }\n      while (true) {\n        if (!formatList[0].block_expand && dom.isBlock(parent)) {\n          return parent;\n        }\n        for (var sibling = parent[siblingName]; sibling; sibling = sibling[siblingName]) {\n          var allowSpaces = isText$7(sibling) && !isAtBlockBoundary$1(dom, root, sibling, siblingName);\n          if (!isBookmarkNode(sibling) && !isBogusBr(sibling) && !isWhiteSpaceNode(sibling, allowSpaces)) {\n            return parent;\n          }\n        }\n        if (parent === root || parent.parentNode === root) {\n          container = parent;\n          break;\n        }\n        parent = parent.parentNode;\n      }\n      return container;\n    };\n    var isSelfOrParentBookmark = function (container) {\n      return isBookmarkNode(container.parentNode) || isBookmarkNode(container);\n    };\n    var expandRng = function (editor, rng, formatList, includeTrailingSpace) {\n      if (includeTrailingSpace === void 0) {\n        includeTrailingSpace = false;\n      }\n      var startContainer = rng.startContainer, startOffset = rng.startOffset, endContainer = rng.endContainer, endOffset = rng.endOffset;\n      var dom = editor.dom;\n      var format = formatList[0];\n      if (isElement$5(startContainer) && startContainer.hasChildNodes()) {\n        startContainer = getNode$1(startContainer, startOffset);\n        if (isText$7(startContainer)) {\n          startOffset = 0;\n        }\n      }\n      if (isElement$5(endContainer) && endContainer.hasChildNodes()) {\n        endContainer = getNode$1(endContainer, rng.collapsed ? endOffset : endOffset - 1);\n        if (isText$7(endContainer)) {\n          endOffset = endContainer.nodeValue.length;\n        }\n      }\n      startContainer = findParentContentEditable(dom, startContainer);\n      endContainer = findParentContentEditable(dom, endContainer);\n      if (isSelfOrParentBookmark(startContainer)) {\n        startContainer = isBookmarkNode(startContainer) ? startContainer : startContainer.parentNode;\n        if (rng.collapsed) {\n          startContainer = startContainer.previousSibling || startContainer;\n        } else {\n          startContainer = startContainer.nextSibling || startContainer;\n        }\n        if (isText$7(startContainer)) {\n          startOffset = rng.collapsed ? startContainer.length : 0;\n        }\n      }\n      if (isSelfOrParentBookmark(endContainer)) {\n        endContainer = isBookmarkNode(endContainer) ? endContainer : endContainer.parentNode;\n        if (rng.collapsed) {\n          endContainer = endContainer.nextSibling || endContainer;\n        } else {\n          endContainer = endContainer.previousSibling || endContainer;\n        }\n        if (isText$7(endContainer)) {\n          endOffset = rng.collapsed ? 0 : endContainer.length;\n        }\n      }\n      if (rng.collapsed) {\n        var startPoint = findWordEndPoint(dom, editor.getBody(), startContainer, startOffset, true, includeTrailingSpace);\n        startPoint.each(function (_a) {\n          var container = _a.container, offset = _a.offset;\n          startContainer = container;\n          startOffset = offset;\n        });\n        var endPoint = findWordEndPoint(dom, editor.getBody(), endContainer, endOffset, false, includeTrailingSpace);\n        endPoint.each(function (_a) {\n          var container = _a.container, offset = _a.offset;\n          endContainer = container;\n          endOffset = offset;\n        });\n      }\n      if (isInlineFormat(format) || format.block_expand) {\n        if (!isInlineFormat(format) || (!isText$7(startContainer) || startOffset === 0)) {\n          startContainer = findParentContainer(dom, formatList, startContainer, startOffset, true);\n        }\n        if (!isInlineFormat(format) || (!isText$7(endContainer) || endOffset === endContainer.nodeValue.length)) {\n          endContainer = findParentContainer(dom, formatList, endContainer, endOffset, false);\n        }\n      }\n      if (shouldExpandToSelector(format)) {\n        startContainer = findSelectorEndPoint(dom, formatList, rng, startContainer, 'previousSibling');\n        endContainer = findSelectorEndPoint(dom, formatList, rng, endContainer, 'nextSibling');\n      }\n      if (isBlockFormat(format) || isSelectorFormat(format)) {\n        startContainer = findBlockEndPoint(editor, formatList, startContainer, 'previousSibling');\n        endContainer = findBlockEndPoint(editor, formatList, endContainer, 'nextSibling');\n        if (isBlockFormat(format)) {\n          if (!dom.isBlock(startContainer)) {\n            startContainer = findParentContainer(dom, formatList, startContainer, startOffset, true);\n          }\n          if (!dom.isBlock(endContainer)) {\n            endContainer = findParentContainer(dom, formatList, endContainer, endOffset, false);\n          }\n        }\n      }\n      if (isElement$5(startContainer)) {\n        startOffset = dom.nodeIndex(startContainer);\n        startContainer = startContainer.parentNode;\n      }\n      if (isElement$5(endContainer)) {\n        endOffset = dom.nodeIndex(endContainer) + 1;\n        endContainer = endContainer.parentNode;\n      }\n      return {\n        startContainer: startContainer,\n        startOffset: startOffset,\n        endContainer: endContainer,\n        endOffset: endOffset\n      };\n    };\n\n    var walk$2 = function (dom, rng, callback) {\n      var startOffset = rng.startOffset;\n      var startContainer = getNode$1(rng.startContainer, startOffset);\n      var endOffset = rng.endOffset;\n      var endContainer = getNode$1(rng.endContainer, endOffset - 1);\n      var exclude = function (nodes) {\n        var firstNode = nodes[0];\n        if (isText$7(firstNode) && firstNode === startContainer && startOffset >= firstNode.data.length) {\n          nodes.splice(0, 1);\n        }\n        var lastNode = nodes[nodes.length - 1];\n        if (endOffset === 0 && nodes.length > 0 && lastNode === endContainer && isText$7(lastNode)) {\n          nodes.splice(nodes.length - 1, 1);\n        }\n        return nodes;\n      };\n      var collectSiblings = function (node, name, endNode) {\n        var siblings = [];\n        for (; node && node !== endNode; node = node[name]) {\n          siblings.push(node);\n        }\n        return siblings;\n      };\n      var findEndPoint = function (node, root) {\n        return dom.getParent(node, function (node) {\n          return node.parentNode === root;\n        }, root);\n      };\n      var walkBoundary = function (startNode, endNode, next) {\n        var siblingName = next ? 'nextSibling' : 'previousSibling';\n        for (var node = startNode, parent_1 = node.parentNode; node && node !== endNode; node = parent_1) {\n          parent_1 = node.parentNode;\n          var siblings_1 = collectSiblings(node === startNode ? node : node[siblingName], siblingName);\n          if (siblings_1.length) {\n            if (!next) {\n              siblings_1.reverse();\n            }\n            callback(exclude(siblings_1));\n          }\n        }\n      };\n      if (startContainer === endContainer) {\n        return callback(exclude([startContainer]));\n      }\n      var ancestor = dom.findCommonAncestor(startContainer, endContainer);\n      if (dom.isChildOf(startContainer, endContainer)) {\n        return walkBoundary(startContainer, ancestor, true);\n      }\n      if (dom.isChildOf(endContainer, startContainer)) {\n        return walkBoundary(endContainer, ancestor);\n      }\n      var startPoint = findEndPoint(startContainer, ancestor) || startContainer;\n      var endPoint = findEndPoint(endContainer, ancestor) || endContainer;\n      walkBoundary(startContainer, startPoint, true);\n      var siblings = collectSiblings(startPoint === startContainer ? startPoint : startPoint.nextSibling, 'nextSibling', endPoint === endContainer ? endPoint.nextSibling : endPoint);\n      if (siblings.length) {\n        callback(exclude(siblings));\n      }\n      walkBoundary(endContainer, endPoint);\n    };\n\n    var getRanges = function (selection) {\n      var ranges = [];\n      if (selection) {\n        for (var i = 0; i < selection.rangeCount; i++) {\n          ranges.push(selection.getRangeAt(i));\n        }\n      }\n      return ranges;\n    };\n    var getSelectedNodes = function (ranges) {\n      return bind(ranges, function (range) {\n        var node = getSelectedNode(range);\n        return node ? [SugarElement.fromDom(node)] : [];\n      });\n    };\n    var hasMultipleRanges = function (selection) {\n      return getRanges(selection).length > 1;\n    };\n\n    var getCellsFromRanges = function (ranges) {\n      return filter$4(getSelectedNodes(ranges), isTableCell$4);\n    };\n    var getCellsFromElement = function (elm) {\n      return descendants(elm, 'td[data-mce-selected],th[data-mce-selected]');\n    };\n    var getCellsFromElementOrRanges = function (ranges, element) {\n      var selectedCells = getCellsFromElement(element);\n      return selectedCells.length > 0 ? selectedCells : getCellsFromRanges(ranges);\n    };\n    var getCellsFromEditor = function (editor) {\n      return getCellsFromElementOrRanges(getRanges(editor.selection.getSel()), SugarElement.fromDom(editor.getBody()));\n    };\n    var getClosestTable = function (cell, isRoot) {\n      return ancestor$2(cell, 'table', isRoot);\n    };\n\n    var getStartNode = function (rng) {\n      var sc = rng.startContainer, so = rng.startOffset;\n      if (isText$7(sc)) {\n        return so === 0 ? Optional.some(SugarElement.fromDom(sc)) : Optional.none();\n      } else {\n        return Optional.from(sc.childNodes[so]).map(SugarElement.fromDom);\n      }\n    };\n    var getEndNode = function (rng) {\n      var ec = rng.endContainer, eo = rng.endOffset;\n      if (isText$7(ec)) {\n        return eo === ec.data.length ? Optional.some(SugarElement.fromDom(ec)) : Optional.none();\n      } else {\n        return Optional.from(ec.childNodes[eo - 1]).map(SugarElement.fromDom);\n      }\n    };\n    var getFirstChildren = function (node) {\n      return firstChild(node).fold(constant([node]), function (child) {\n        return [node].concat(getFirstChildren(child));\n      });\n    };\n    var getLastChildren$1 = function (node) {\n      return lastChild(node).fold(constant([node]), function (child) {\n        if (name(child) === 'br') {\n          return prevSibling(child).map(function (sibling) {\n            return [node].concat(getLastChildren$1(sibling));\n          }).getOr([]);\n        } else {\n          return [node].concat(getLastChildren$1(child));\n        }\n      });\n    };\n    var hasAllContentsSelected = function (elm, rng) {\n      return lift2(getStartNode(rng), getEndNode(rng), function (startNode, endNode) {\n        var start = find$3(getFirstChildren(elm), curry(eq, startNode));\n        var end = find$3(getLastChildren$1(elm), curry(eq, endNode));\n        return start.isSome() && end.isSome();\n      }).getOr(false);\n    };\n    var moveEndPoint = function (dom, rng, node, start) {\n      var root = node, walker = new DomTreeWalker(node, root);\n      var moveCaretBeforeOnEnterElementsMap = filter$3(dom.schema.getMoveCaretBeforeOnEnterElements(), function (_, name) {\n        return !contains$3([\n          'td',\n          'th',\n          'table'\n        ], name.toLowerCase());\n      });\n      do {\n        if (isText$7(node) && Tools.trim(node.nodeValue).length !== 0) {\n          if (start) {\n            rng.setStart(node, 0);\n          } else {\n            rng.setEnd(node, node.nodeValue.length);\n          }\n          return;\n        }\n        if (moveCaretBeforeOnEnterElementsMap[node.nodeName]) {\n          if (start) {\n            rng.setStartBefore(node);\n          } else {\n            if (node.nodeName === 'BR') {\n              rng.setEndBefore(node);\n            } else {\n              rng.setEndAfter(node);\n            }\n          }\n          return;\n        }\n      } while (node = start ? walker.next() : walker.prev());\n      if (root.nodeName === 'BODY') {\n        if (start) {\n          rng.setStart(root, 0);\n        } else {\n          rng.setEnd(root, root.childNodes.length);\n        }\n      }\n    };\n    var hasAnyRanges = function (editor) {\n      var sel = editor.selection.getSel();\n      return sel && sel.rangeCount > 0;\n    };\n    var runOnRanges = function (editor, executor) {\n      var fakeSelectionNodes = getCellsFromEditor(editor);\n      if (fakeSelectionNodes.length > 0) {\n        each$k(fakeSelectionNodes, function (elem) {\n          var node = elem.dom;\n          var fakeNodeRng = editor.dom.createRng();\n          fakeNodeRng.setStartBefore(node);\n          fakeNodeRng.setEndAfter(node);\n          executor(fakeNodeRng, true);\n        });\n      } else {\n        executor(editor.selection.getRng(), false);\n      }\n    };\n    var preserve = function (selection, fillBookmark, executor) {\n      var bookmark = getPersistentBookmark(selection, fillBookmark);\n      executor(bookmark);\n      selection.moveToBookmark(bookmark);\n    };\n\n    var NodeValue = function (is, name) {\n      var get = function (element) {\n        if (!is(element)) {\n          throw new Error('Can only get ' + name + ' value of a ' + name + ' node');\n        }\n        return getOption(element).getOr('');\n      };\n      var getOption = function (element) {\n        return is(element) ? Optional.from(element.dom.nodeValue) : Optional.none();\n      };\n      var set = function (element, value) {\n        if (!is(element)) {\n          throw new Error('Can only set raw ' + name + ' value of a ' + name + ' node');\n        }\n        element.dom.nodeValue = value;\n      };\n      return {\n        get: get,\n        getOption: getOption,\n        set: set\n      };\n    };\n\n    var api$1 = NodeValue(isText$8, 'text');\n    var get$2 = function (element) {\n      return api$1.get(element);\n    };\n\n    var isZeroWidth = function (elem) {\n      return isText$8(elem) && get$2(elem) === ZWSP$1;\n    };\n    var context = function (editor, elem, wrapName, nodeName) {\n      return parent(elem).fold(function () {\n        return 'skipping';\n      }, function (parent) {\n        if (nodeName === 'br' || isZeroWidth(elem)) {\n          return 'valid';\n        } else if (isAnnotation(elem)) {\n          return 'existing';\n        } else if (isCaretNode(elem.dom)) {\n          return 'caret';\n        } else if (!isValid(editor, wrapName, nodeName) || !isValid(editor, name(parent), wrapName)) {\n          return 'invalid-child';\n        } else {\n          return 'valid';\n        }\n      });\n    };\n\n    var applyWordGrab = function (editor, rng) {\n      var r = expandRng(editor, rng, [{ inline: 'span' }]);\n      rng.setStart(r.startContainer, r.startOffset);\n      rng.setEnd(r.endContainer, r.endOffset);\n      editor.selection.setRng(rng);\n    };\n    var makeAnnotation = function (eDoc, _a, annotationName, decorate) {\n      var _b = _a.uid, uid = _b === void 0 ? generate('mce-annotation') : _b, data = __rest(_a, ['uid']);\n      var master = SugarElement.fromTag('span', eDoc);\n      add$1(master, annotation());\n      set$1(master, '' + dataAnnotationId(), uid);\n      set$1(master, '' + dataAnnotation(), annotationName);\n      var _c = decorate(uid, data), _d = _c.attributes, attributes = _d === void 0 ? {} : _d, _e = _c.classes, classes = _e === void 0 ? [] : _e;\n      setAll$1(master, attributes);\n      add(master, classes);\n      return master;\n    };\n    var annotate = function (editor, rng, annotationName, decorate, data) {\n      var newWrappers = [];\n      var master = makeAnnotation(editor.getDoc(), data, annotationName, decorate);\n      var wrapper = value();\n      var finishWrapper = function () {\n        wrapper.clear();\n      };\n      var getOrOpenWrapper = function () {\n        return wrapper.get().getOrThunk(function () {\n          var nu = shallow(master);\n          newWrappers.push(nu);\n          wrapper.set(nu);\n          return nu;\n        });\n      };\n      var processElements = function (elems) {\n        each$k(elems, processElement);\n      };\n      var processElement = function (elem) {\n        var ctx = context(editor, elem, 'span', name(elem));\n        switch (ctx) {\n        case 'invalid-child': {\n            finishWrapper();\n            var children$1 = children(elem);\n            processElements(children$1);\n            finishWrapper();\n            break;\n          }\n        case 'valid': {\n            var w = getOrOpenWrapper();\n            wrap$3(elem, w);\n            break;\n          }\n        }\n      };\n      var processNodes = function (nodes) {\n        var elems = map$3(nodes, SugarElement.fromDom);\n        processElements(elems);\n      };\n      walk$2(editor.dom, rng, function (nodes) {\n        finishWrapper();\n        processNodes(nodes);\n      });\n      return newWrappers;\n    };\n    var annotateWithBookmark = function (editor, name, settings, data) {\n      editor.undoManager.transact(function () {\n        var selection = editor.selection;\n        var initialRng = selection.getRng();\n        var hasFakeSelection = getCellsFromEditor(editor).length > 0;\n        if (initialRng.collapsed && !hasFakeSelection) {\n          applyWordGrab(editor, initialRng);\n        }\n        if (selection.getRng().collapsed && !hasFakeSelection) {\n          var wrapper = makeAnnotation(editor.getDoc(), data, name, settings.decorate);\n          set(wrapper, nbsp);\n          selection.getRng().insertNode(wrapper.dom);\n          selection.select(wrapper.dom);\n        } else {\n          preserve(selection, false, function () {\n            runOnRanges(editor, function (selectionRng) {\n              annotate(editor, selectionRng, name, settings.decorate, data);\n            });\n          });\n        }\n      });\n    };\n\n    var Annotator = function (editor) {\n      var registry = create$7();\n      setup$m(editor, registry);\n      var changes = setup$n(editor);\n      return {\n        register: function (name, settings) {\n          registry.register(name, settings);\n        },\n        annotate: function (name, data) {\n          registry.lookup(name).each(function (settings) {\n            annotateWithBookmark(editor, name, settings, data);\n          });\n        },\n        annotationChanged: function (name, callback) {\n          changes.addListener(name, callback);\n        },\n        remove: function (name) {\n          identify(editor, Optional.some(name)).each(function (_a) {\n            var elements = _a.elements;\n            each$k(elements, unwrap);\n          });\n        },\n        getAll: function (name) {\n          var directory = findAll(editor, name);\n          return map$2(directory, function (elems) {\n            return map$3(elems, function (elem) {\n              return elem.dom;\n            });\n          });\n        }\n      };\n    };\n\n    var BookmarkManager = function (selection) {\n      return {\n        getBookmark: curry(getBookmark$1, selection),\n        moveToBookmark: curry(moveToBookmark, selection)\n      };\n    };\n    BookmarkManager.isBookmarkNode = isBookmarkNode$1;\n\n    var getContentEditableRoot$1 = function (root, node) {\n      while (node && node !== root) {\n        if (isContentEditableTrue$4(node) || isContentEditableFalse$b(node)) {\n          return node;\n        }\n        node = node.parentNode;\n      }\n      return null;\n    };\n\n    var isXYWithinRange = function (clientX, clientY, range) {\n      if (range.collapsed) {\n        return false;\n      }\n      if (Env.browser.isIE() && range.startOffset === range.endOffset - 1 && range.startContainer === range.endContainer) {\n        var elm = range.startContainer.childNodes[range.startOffset];\n        if (isElement$5(elm)) {\n          return exists(elm.getClientRects(), function (rect) {\n            return containsXY(rect, clientX, clientY);\n          });\n        }\n      }\n      return exists(range.getClientRects(), function (rect) {\n        return containsXY(rect, clientX, clientY);\n      });\n    };\n\n    var firePreProcess = function (editor, args) {\n      return editor.fire('PreProcess', args);\n    };\n    var firePostProcess = function (editor, args) {\n      return editor.fire('PostProcess', args);\n    };\n    var fireRemove = function (editor) {\n      return editor.fire('remove');\n    };\n    var fireDetach = function (editor) {\n      return editor.fire('detach');\n    };\n    var fireSwitchMode = function (editor, mode) {\n      return editor.fire('SwitchMode', { mode: mode });\n    };\n    var fireObjectResizeStart = function (editor, target, width, height, origin) {\n      editor.fire('ObjectResizeStart', {\n        target: target,\n        width: width,\n        height: height,\n        origin: origin\n      });\n    };\n    var fireObjectResized = function (editor, target, width, height, origin) {\n      editor.fire('ObjectResized', {\n        target: target,\n        width: width,\n        height: height,\n        origin: origin\n      });\n    };\n    var firePreInit = function (editor) {\n      return editor.fire('PreInit');\n    };\n    var firePostRender = function (editor) {\n      return editor.fire('PostRender');\n    };\n    var fireInit = function (editor) {\n      return editor.fire('Init');\n    };\n    var firePlaceholderToggle = function (editor, state) {\n      return editor.fire('PlaceholderToggle', { state: state });\n    };\n    var fireError = function (editor, errorType, error) {\n      return editor.fire(errorType, error);\n    };\n    var fireFormatApply = function (editor, format, node, vars) {\n      return editor.fire('FormatApply', {\n        format: format,\n        node: node,\n        vars: vars\n      });\n    };\n    var fireFormatRemove = function (editor, format, node, vars) {\n      return editor.fire('FormatRemove', {\n        format: format,\n        node: node,\n        vars: vars\n      });\n    };\n\n    var VK = {\n      BACKSPACE: 8,\n      DELETE: 46,\n      DOWN: 40,\n      ENTER: 13,\n      ESC: 27,\n      LEFT: 37,\n      RIGHT: 39,\n      SPACEBAR: 32,\n      TAB: 9,\n      UP: 38,\n      PAGE_UP: 33,\n      PAGE_DOWN: 34,\n      END: 35,\n      HOME: 36,\n      modifierPressed: function (e) {\n        return e.shiftKey || e.ctrlKey || e.altKey || VK.metaKeyPressed(e);\n      },\n      metaKeyPressed: function (e) {\n        return Env.mac ? e.metaKey : e.ctrlKey && !e.altKey;\n      }\n    };\n\n    var isContentEditableFalse$5 = isContentEditableFalse$b;\n    var ControlSelection = function (selection, editor) {\n      var elementSelectionAttr = 'data-mce-selected';\n      var dom = editor.dom, each = Tools.each;\n      var selectedElm, selectedElmGhost, resizeHelper, selectedHandle, resizeBackdrop;\n      var startX, startY, selectedElmX, selectedElmY, startW, startH, ratio, resizeStarted;\n      var width, height;\n      var editableDoc = editor.getDoc(), rootDocument = document;\n      var abs = Math.abs, round = Math.round, rootElement = editor.getBody();\n      var startScrollWidth, startScrollHeight;\n      var resizeHandles = {\n        nw: [\n          0,\n          0,\n          -1,\n          -1\n        ],\n        ne: [\n          1,\n          0,\n          1,\n          -1\n        ],\n        se: [\n          1,\n          1,\n          1,\n          1\n        ],\n        sw: [\n          0,\n          1,\n          -1,\n          1\n        ]\n      };\n      var isImage = function (elm) {\n        return elm && (elm.nodeName === 'IMG' || editor.dom.is(elm, 'figure.image'));\n      };\n      var isMedia = function (elm) {\n        return isMedia$2(elm) || dom.hasClass(elm, 'mce-preview-object');\n      };\n      var isEventOnImageOutsideRange = function (evt, range) {\n        if (evt.type === 'longpress' || evt.type.indexOf('touch') === 0) {\n          var touch = evt.touches[0];\n          return isImage(evt.target) && !isXYWithinRange(touch.clientX, touch.clientY, range);\n        } else {\n          return isImage(evt.target) && !isXYWithinRange(evt.clientX, evt.clientY, range);\n        }\n      };\n      var contextMenuSelectImage = function (evt) {\n        var target = evt.target;\n        if (isEventOnImageOutsideRange(evt, editor.selection.getRng()) && !evt.isDefaultPrevented()) {\n          editor.selection.select(target);\n        }\n      };\n      var getResizeTargets = function (elm) {\n        if (dom.is(elm, 'figure.image')) {\n          return [elm.querySelector('img')];\n        } else if (dom.hasClass(elm, 'mce-preview-object') && isNonNullable(elm.firstElementChild)) {\n          return [\n            elm,\n            elm.firstElementChild\n          ];\n        } else {\n          return [elm];\n        }\n      };\n      var isResizable = function (elm) {\n        var selector = getObjectResizing(editor);\n        if (!selector) {\n          return false;\n        }\n        if (elm.getAttribute('data-mce-resize') === 'false') {\n          return false;\n        }\n        if (elm === editor.getBody()) {\n          return false;\n        }\n        if (dom.hasClass(elm, 'mce-preview-object')) {\n          return is$2(SugarElement.fromDom(elm.firstElementChild), selector);\n        } else {\n          return is$2(SugarElement.fromDom(elm), selector);\n        }\n      };\n      var createGhostElement = function (elm) {\n        if (isMedia(elm)) {\n          return dom.create('img', { src: Env.transparentSrc });\n        } else {\n          return elm.cloneNode(true);\n        }\n      };\n      var setSizeProp = function (element, name, value) {\n        if (isNonNullable(value)) {\n          var targets = getResizeTargets(element);\n          each$k(targets, function (target) {\n            if (target.style[name] || !editor.schema.isValid(target.nodeName.toLowerCase(), name)) {\n              dom.setStyle(target, name, value);\n            } else {\n              dom.setAttrib(target, name, '' + value);\n            }\n          });\n        }\n      };\n      var setGhostElmSize = function (ghostElm, width, height) {\n        setSizeProp(ghostElm, 'width', width);\n        setSizeProp(ghostElm, 'height', height);\n      };\n      var resizeGhostElement = function (e) {\n        var deltaX, deltaY, proportional;\n        var resizeHelperX, resizeHelperY;\n        deltaX = e.screenX - startX;\n        deltaY = e.screenY - startY;\n        width = deltaX * selectedHandle[2] + startW;\n        height = deltaY * selectedHandle[3] + startH;\n        width = width < 5 ? 5 : width;\n        height = height < 5 ? 5 : height;\n        if ((isImage(selectedElm) || isMedia(selectedElm)) && getResizeImgProportional(editor) !== false) {\n          proportional = !VK.modifierPressed(e);\n        } else {\n          proportional = VK.modifierPressed(e);\n        }\n        if (proportional) {\n          if (abs(deltaX) > abs(deltaY)) {\n            height = round(width * ratio);\n            width = round(height / ratio);\n          } else {\n            width = round(height / ratio);\n            height = round(width * ratio);\n          }\n        }\n        setGhostElmSize(selectedElmGhost, width, height);\n        resizeHelperX = selectedHandle.startPos.x + deltaX;\n        resizeHelperY = selectedHandle.startPos.y + deltaY;\n        resizeHelperX = resizeHelperX > 0 ? resizeHelperX : 0;\n        resizeHelperY = resizeHelperY > 0 ? resizeHelperY : 0;\n        dom.setStyles(resizeHelper, {\n          left: resizeHelperX,\n          top: resizeHelperY,\n          display: 'block'\n        });\n        resizeHelper.innerHTML = width + ' &times; ' + height;\n        if (selectedHandle[2] < 0 && selectedElmGhost.clientWidth <= width) {\n          dom.setStyle(selectedElmGhost, 'left', selectedElmX + (startW - width));\n        }\n        if (selectedHandle[3] < 0 && selectedElmGhost.clientHeight <= height) {\n          dom.setStyle(selectedElmGhost, 'top', selectedElmY + (startH - height));\n        }\n        deltaX = rootElement.scrollWidth - startScrollWidth;\n        deltaY = rootElement.scrollHeight - startScrollHeight;\n        if (deltaX + deltaY !== 0) {\n          dom.setStyles(resizeHelper, {\n            left: resizeHelperX - deltaX,\n            top: resizeHelperY - deltaY\n          });\n        }\n        if (!resizeStarted) {\n          fireObjectResizeStart(editor, selectedElm, startW, startH, 'corner-' + selectedHandle.name);\n          resizeStarted = true;\n        }\n      };\n      var endGhostResize = function () {\n        var wasResizeStarted = resizeStarted;\n        resizeStarted = false;\n        if (wasResizeStarted) {\n          setSizeProp(selectedElm, 'width', width);\n          setSizeProp(selectedElm, 'height', height);\n        }\n        dom.unbind(editableDoc, 'mousemove', resizeGhostElement);\n        dom.unbind(editableDoc, 'mouseup', endGhostResize);\n        if (rootDocument !== editableDoc) {\n          dom.unbind(rootDocument, 'mousemove', resizeGhostElement);\n          dom.unbind(rootDocument, 'mouseup', endGhostResize);\n        }\n        dom.remove(selectedElmGhost);\n        dom.remove(resizeHelper);\n        dom.remove(resizeBackdrop);\n        showResizeRect(selectedElm);\n        if (wasResizeStarted) {\n          fireObjectResized(editor, selectedElm, width, height, 'corner-' + selectedHandle.name);\n          dom.setAttrib(selectedElm, 'style', dom.getAttrib(selectedElm, 'style'));\n        }\n        editor.nodeChanged();\n      };\n      var showResizeRect = function (targetElm) {\n        unbindResizeHandleEvents();\n        var position = dom.getPos(targetElm, rootElement);\n        var selectedElmX = position.x;\n        var selectedElmY = position.y;\n        var rect = targetElm.getBoundingClientRect();\n        var targetWidth = rect.width || rect.right - rect.left;\n        var targetHeight = rect.height || rect.bottom - rect.top;\n        if (selectedElm !== targetElm) {\n          hideResizeRect();\n          selectedElm = targetElm;\n          width = height = 0;\n        }\n        var e = editor.fire('ObjectSelected', { target: targetElm });\n        var selectedValue = dom.getAttrib(selectedElm, elementSelectionAttr, '1');\n        if (isResizable(targetElm) && !e.isDefaultPrevented()) {\n          each(resizeHandles, function (handle, name) {\n            var handleElm;\n            var startDrag = function (e) {\n              var target = getResizeTargets(selectedElm)[0];\n              startX = e.screenX;\n              startY = e.screenY;\n              startW = target.clientWidth;\n              startH = target.clientHeight;\n              ratio = startH / startW;\n              selectedHandle = handle;\n              selectedHandle.name = name;\n              selectedHandle.startPos = {\n                x: targetWidth * handle[0] + selectedElmX,\n                y: targetHeight * handle[1] + selectedElmY\n              };\n              startScrollWidth = rootElement.scrollWidth;\n              startScrollHeight = rootElement.scrollHeight;\n              resizeBackdrop = dom.add(rootElement, 'div', {\n                'class': 'mce-resize-backdrop',\n                'data-mce-bogus': 'all'\n              });\n              dom.setStyles(resizeBackdrop, {\n                position: 'fixed',\n                left: '0',\n                top: '0',\n                width: '100%',\n                height: '100%'\n              });\n              selectedElmGhost = createGhostElement(selectedElm);\n              dom.addClass(selectedElmGhost, 'mce-clonedresizable');\n              dom.setAttrib(selectedElmGhost, 'data-mce-bogus', 'all');\n              selectedElmGhost.contentEditable = 'false';\n              dom.setStyles(selectedElmGhost, {\n                left: selectedElmX,\n                top: selectedElmY,\n                margin: 0\n              });\n              setGhostElmSize(selectedElmGhost, targetWidth, targetHeight);\n              selectedElmGhost.removeAttribute(elementSelectionAttr);\n              rootElement.appendChild(selectedElmGhost);\n              dom.bind(editableDoc, 'mousemove', resizeGhostElement);\n              dom.bind(editableDoc, 'mouseup', endGhostResize);\n              if (rootDocument !== editableDoc) {\n                dom.bind(rootDocument, 'mousemove', resizeGhostElement);\n                dom.bind(rootDocument, 'mouseup', endGhostResize);\n              }\n              resizeHelper = dom.add(rootElement, 'div', {\n                'class': 'mce-resize-helper',\n                'data-mce-bogus': 'all'\n              }, startW + ' &times; ' + startH);\n            };\n            handleElm = dom.get('mceResizeHandle' + name);\n            if (handleElm) {\n              dom.remove(handleElm);\n            }\n            handleElm = dom.add(rootElement, 'div', {\n              'id': 'mceResizeHandle' + name,\n              'data-mce-bogus': 'all',\n              'class': 'mce-resizehandle',\n              'unselectable': true,\n              'style': 'cursor:' + name + '-resize; margin:0; padding:0'\n            });\n            if (Env.ie === 11) {\n              handleElm.contentEditable = false;\n            }\n            dom.bind(handleElm, 'mousedown', function (e) {\n              e.stopImmediatePropagation();\n              e.preventDefault();\n              startDrag(e);\n            });\n            handle.elm = handleElm;\n            dom.setStyles(handleElm, {\n              left: targetWidth * handle[0] + selectedElmX - handleElm.offsetWidth / 2,\n              top: targetHeight * handle[1] + selectedElmY - handleElm.offsetHeight / 2\n            });\n          });\n        } else {\n          hideResizeRect();\n        }\n        if (!dom.getAttrib(selectedElm, elementSelectionAttr)) {\n          selectedElm.setAttribute(elementSelectionAttr, selectedValue);\n        }\n      };\n      var hideResizeRect = function () {\n        unbindResizeHandleEvents();\n        if (selectedElm) {\n          selectedElm.removeAttribute(elementSelectionAttr);\n        }\n        each$j(resizeHandles, function (value, name) {\n          var handleElm = dom.get('mceResizeHandle' + name);\n          if (handleElm) {\n            dom.unbind(handleElm);\n            dom.remove(handleElm);\n          }\n        });\n      };\n      var updateResizeRect = function (e) {\n        var startElm, controlElm;\n        var isChildOrEqual = function (node, parent) {\n          if (node) {\n            do {\n              if (node === parent) {\n                return true;\n              }\n            } while (node = node.parentNode);\n          }\n        };\n        if (resizeStarted || editor.removed) {\n          return;\n        }\n        each(dom.select('img[data-mce-selected],hr[data-mce-selected]'), function (img) {\n          img.removeAttribute(elementSelectionAttr);\n        });\n        controlElm = e.type === 'mousedown' ? e.target : selection.getNode();\n        controlElm = dom.$(controlElm).closest('table,img,figure.image,hr,video,span.mce-preview-object')[0];\n        if (isChildOrEqual(controlElm, rootElement)) {\n          disableGeckoResize();\n          startElm = selection.getStart(true);\n          if (isChildOrEqual(startElm, controlElm) && isChildOrEqual(selection.getEnd(true), controlElm)) {\n            showResizeRect(controlElm);\n            return;\n          }\n        }\n        hideResizeRect();\n      };\n      var isWithinContentEditableFalse = function (elm) {\n        return isContentEditableFalse$5(getContentEditableRoot$1(editor.getBody(), elm));\n      };\n      var unbindResizeHandleEvents = function () {\n        each$j(resizeHandles, function (handle) {\n          if (handle.elm) {\n            dom.unbind(handle.elm);\n            delete handle.elm;\n          }\n        });\n      };\n      var disableGeckoResize = function () {\n        try {\n          editor.getDoc().execCommand('enableObjectResizing', false, 'false');\n        } catch (ex) {\n        }\n      };\n      editor.on('init', function () {\n        disableGeckoResize();\n        if (Env.browser.isIE() || Env.browser.isEdge()) {\n          editor.on('mousedown click', function (e) {\n            var target = e.target, nodeName = target.nodeName;\n            if (!resizeStarted && /^(TABLE|IMG|HR)$/.test(nodeName) && !isWithinContentEditableFalse(target)) {\n              if (e.button !== 2) {\n                editor.selection.select(target, nodeName === 'TABLE');\n              }\n              if (e.type === 'mousedown') {\n                editor.nodeChanged();\n              }\n            }\n          });\n          var handleMSControlSelect_1 = function (e) {\n            var delayedSelect = function (node) {\n              Delay.setEditorTimeout(editor, function () {\n                return editor.selection.select(node);\n              });\n            };\n            if (isWithinContentEditableFalse(e.target) || isMedia$2(e.target)) {\n              e.preventDefault();\n              delayedSelect(e.target);\n              return;\n            }\n            if (/^(TABLE|IMG|HR)$/.test(e.target.nodeName)) {\n              e.preventDefault();\n              if (e.target.tagName === 'IMG') {\n                delayedSelect(e.target);\n              }\n            }\n          };\n          dom.bind(rootElement, 'mscontrolselect', handleMSControlSelect_1);\n          editor.on('remove', function () {\n            return dom.unbind(rootElement, 'mscontrolselect', handleMSControlSelect_1);\n          });\n        }\n        var throttledUpdateResizeRect = Delay.throttle(function (e) {\n          if (!editor.composing) {\n            updateResizeRect(e);\n          }\n        });\n        editor.on('NodeChange ResizeEditor ResizeWindow ResizeContent drop', throttledUpdateResizeRect);\n        editor.on('keyup compositionend', function (e) {\n          if (selectedElm && selectedElm.nodeName === 'TABLE') {\n            throttledUpdateResizeRect(e);\n          }\n        });\n        editor.on('hide blur', hideResizeRect);\n        editor.on('contextmenu longpress', contextMenuSelectImage, true);\n      });\n      editor.on('remove', unbindResizeHandleEvents);\n      var destroy = function () {\n        selectedElm = selectedElmGhost = resizeBackdrop = null;\n      };\n      return {\n        isResizable: isResizable,\n        showResizeRect: showResizeRect,\n        hideResizeRect: hideResizeRect,\n        updateResizeRect: updateResizeRect,\n        destroy: destroy\n      };\n    };\n\n    var hasCeProperty = function (node) {\n      return isContentEditableTrue$4(node) || isContentEditableFalse$b(node);\n    };\n    var findParent$1 = function (node, rootNode, predicate) {\n      while (node && node !== rootNode) {\n        if (predicate(node)) {\n          return node;\n        }\n        node = node.parentNode;\n      }\n      return null;\n    };\n    var findClosestIeRange = function (clientX, clientY, doc) {\n      var rects;\n      var element = doc.elementFromPoint(clientX, clientY);\n      var rng = doc.body.createTextRange();\n      if (!element || element.tagName === 'HTML') {\n        element = doc.body;\n      }\n      rng.moveToElementText(element);\n      rects = Tools.toArray(rng.getClientRects());\n      rects = rects.sort(function (a, b) {\n        a = Math.abs(Math.max(a.top - clientY, a.bottom - clientY));\n        b = Math.abs(Math.max(b.top - clientY, b.bottom - clientY));\n        return a - b;\n      });\n      if (rects.length > 0) {\n        clientY = (rects[0].bottom + rects[0].top) / 2;\n        try {\n          rng.moveToPoint(clientX, clientY);\n          rng.collapse(true);\n          return rng;\n        } catch (ex) {\n        }\n      }\n      return null;\n    };\n    var moveOutOfContentEditableFalse = function (rng, rootNode) {\n      var parentElement = rng && rng.parentElement ? rng.parentElement() : null;\n      return isContentEditableFalse$b(findParent$1(parentElement, rootNode, hasCeProperty)) ? null : rng;\n    };\n    var fromPoint = function (clientX, clientY, doc) {\n      var rng, point;\n      var pointDoc = doc;\n      if (pointDoc.caretPositionFromPoint) {\n        point = pointDoc.caretPositionFromPoint(clientX, clientY);\n        if (point) {\n          rng = doc.createRange();\n          rng.setStart(point.offsetNode, point.offset);\n          rng.collapse(true);\n        }\n      } else if (pointDoc.caretRangeFromPoint) {\n        rng = pointDoc.caretRangeFromPoint(clientX, clientY);\n      } else if (pointDoc.body.createTextRange) {\n        rng = pointDoc.body.createTextRange();\n        try {\n          rng.moveToPoint(clientX, clientY);\n          rng.collapse(true);\n        } catch (ex) {\n          rng = findClosestIeRange(clientX, clientY, doc);\n        }\n        return moveOutOfContentEditableFalse(rng, doc.body);\n      }\n      return rng;\n    };\n\n    var isEq$4 = function (rng1, rng2) {\n      return rng1 && rng2 && (rng1.startContainer === rng2.startContainer && rng1.startOffset === rng2.startOffset) && (rng1.endContainer === rng2.endContainer && rng1.endOffset === rng2.endOffset);\n    };\n\n    var findParent = function (node, rootNode, predicate) {\n      while (node && node !== rootNode) {\n        if (predicate(node)) {\n          return node;\n        }\n        node = node.parentNode;\n      }\n      return null;\n    };\n    var hasParent$1 = function (node, rootNode, predicate) {\n      return findParent(node, rootNode, predicate) !== null;\n    };\n    var hasParentWithName = function (node, rootNode, name) {\n      return hasParent$1(node, rootNode, function (node) {\n        return node.nodeName === name;\n      });\n    };\n    var isTable = function (node) {\n      return node && node.nodeName === 'TABLE';\n    };\n    var isTableCell$2 = function (node) {\n      return node && /^(TD|TH|CAPTION)$/.test(node.nodeName);\n    };\n    var isCeFalseCaretContainer = function (node, rootNode) {\n      return isCaretContainer$2(node) && hasParent$1(node, rootNode, isCaretNode) === false;\n    };\n    var hasBrBeforeAfter = function (dom, node, left) {\n      var walker = new DomTreeWalker(node, dom.getParent(node.parentNode, dom.isBlock) || dom.getRoot());\n      while (node = walker[left ? 'prev' : 'next']()) {\n        if (isBr$5(node)) {\n          return true;\n        }\n      }\n    };\n    var isPrevNode = function (node, name) {\n      return node.previousSibling && node.previousSibling.nodeName === name;\n    };\n    var hasContentEditableFalseParent = function (body, node) {\n      while (node && node !== body) {\n        if (isContentEditableFalse$b(node)) {\n          return true;\n        }\n        node = node.parentNode;\n      }\n      return false;\n    };\n    var findTextNodeRelative = function (dom, isAfterNode, collapsed, left, startNode) {\n      var lastInlineElement;\n      var body = dom.getRoot();\n      var node;\n      var nonEmptyElementsMap = dom.schema.getNonEmptyElements();\n      var parentBlockContainer = dom.getParent(startNode.parentNode, dom.isBlock) || body;\n      if (left && isBr$5(startNode) && isAfterNode && dom.isEmpty(parentBlockContainer)) {\n        return Optional.some(CaretPosition(startNode.parentNode, dom.nodeIndex(startNode)));\n      }\n      var walker = new DomTreeWalker(startNode, parentBlockContainer);\n      while (node = walker[left ? 'prev' : 'next']()) {\n        if (dom.getContentEditableParent(node) === 'false' || isCeFalseCaretContainer(node, body)) {\n          return Optional.none();\n        }\n        if (isText$7(node) && node.nodeValue.length > 0) {\n          if (hasParentWithName(node, body, 'A') === false) {\n            return Optional.some(CaretPosition(node, left ? node.nodeValue.length : 0));\n          }\n          return Optional.none();\n        }\n        if (dom.isBlock(node) || nonEmptyElementsMap[node.nodeName.toLowerCase()]) {\n          return Optional.none();\n        }\n        lastInlineElement = node;\n      }\n      if (collapsed && lastInlineElement) {\n        return Optional.some(CaretPosition(lastInlineElement, 0));\n      }\n      return Optional.none();\n    };\n    var normalizeEndPoint = function (dom, collapsed, start, rng) {\n      var container, offset;\n      var body = dom.getRoot();\n      var node;\n      var directionLeft, normalized = false;\n      container = rng[(start ? 'start' : 'end') + 'Container'];\n      offset = rng[(start ? 'start' : 'end') + 'Offset'];\n      var isAfterNode = isElement$5(container) && offset === container.childNodes.length;\n      var nonEmptyElementsMap = dom.schema.getNonEmptyElements();\n      directionLeft = start;\n      if (isCaretContainer$2(container)) {\n        return Optional.none();\n      }\n      if (isElement$5(container) && offset > container.childNodes.length - 1) {\n        directionLeft = false;\n      }\n      if (isDocument$1(container)) {\n        container = body;\n        offset = 0;\n      }\n      if (container === body) {\n        if (directionLeft) {\n          node = container.childNodes[offset > 0 ? offset - 1 : 0];\n          if (node) {\n            if (isCaretContainer$2(node)) {\n              return Optional.none();\n            }\n            if (nonEmptyElementsMap[node.nodeName] || isTable(node)) {\n              return Optional.none();\n            }\n          }\n        }\n        if (container.hasChildNodes()) {\n          offset = Math.min(!directionLeft && offset > 0 ? offset - 1 : offset, container.childNodes.length - 1);\n          container = container.childNodes[offset];\n          offset = isText$7(container) && isAfterNode ? container.data.length : 0;\n          if (!collapsed && container === body.lastChild && isTable(container)) {\n            return Optional.none();\n          }\n          if (hasContentEditableFalseParent(body, container) || isCaretContainer$2(container)) {\n            return Optional.none();\n          }\n          if (container.hasChildNodes() && isTable(container) === false) {\n            node = container;\n            var walker = new DomTreeWalker(container, body);\n            do {\n              if (isContentEditableFalse$b(node) || isCaretContainer$2(node)) {\n                normalized = false;\n                break;\n              }\n              if (isText$7(node) && node.nodeValue.length > 0) {\n                offset = directionLeft ? 0 : node.nodeValue.length;\n                container = node;\n                normalized = true;\n                break;\n              }\n              if (nonEmptyElementsMap[node.nodeName.toLowerCase()] && !isTableCell$2(node)) {\n                offset = dom.nodeIndex(node);\n                container = node.parentNode;\n                if (!directionLeft) {\n                  offset++;\n                }\n                normalized = true;\n                break;\n              }\n            } while (node = directionLeft ? walker.next() : walker.prev());\n          }\n        }\n      }\n      if (collapsed) {\n        if (isText$7(container) && offset === 0) {\n          findTextNodeRelative(dom, isAfterNode, collapsed, true, container).each(function (pos) {\n            container = pos.container();\n            offset = pos.offset();\n            normalized = true;\n          });\n        }\n        if (isElement$5(container)) {\n          node = container.childNodes[offset];\n          if (!node) {\n            node = container.childNodes[offset - 1];\n          }\n          if (node && isBr$5(node) && !isPrevNode(node, 'A') && !hasBrBeforeAfter(dom, node, false) && !hasBrBeforeAfter(dom, node, true)) {\n            findTextNodeRelative(dom, isAfterNode, collapsed, true, node).each(function (pos) {\n              container = pos.container();\n              offset = pos.offset();\n              normalized = true;\n            });\n          }\n        }\n      }\n      if (directionLeft && !collapsed && isText$7(container) && offset === container.nodeValue.length) {\n        findTextNodeRelative(dom, isAfterNode, collapsed, false, container).each(function (pos) {\n          container = pos.container();\n          offset = pos.offset();\n          normalized = true;\n        });\n      }\n      return normalized ? Optional.some(CaretPosition(container, offset)) : Optional.none();\n    };\n    var normalize$2 = function (dom, rng) {\n      var collapsed = rng.collapsed, normRng = rng.cloneRange();\n      var startPos = CaretPosition.fromRangeStart(rng);\n      normalizeEndPoint(dom, collapsed, true, normRng).each(function (pos) {\n        if (!collapsed || !CaretPosition.isAbove(startPos, pos)) {\n          normRng.setStart(pos.container(), pos.offset());\n        }\n      });\n      if (!collapsed) {\n        normalizeEndPoint(dom, collapsed, false, normRng).each(function (pos) {\n          normRng.setEnd(pos.container(), pos.offset());\n        });\n      }\n      if (collapsed) {\n        normRng.collapse(true);\n      }\n      return isEq$4(rng, normRng) ? Optional.none() : Optional.some(normRng);\n    };\n\n    var splitText = function (node, offset) {\n      return node.splitText(offset);\n    };\n    var split = function (rng) {\n      var startContainer = rng.startContainer, startOffset = rng.startOffset, endContainer = rng.endContainer, endOffset = rng.endOffset;\n      if (startContainer === endContainer && isText$7(startContainer)) {\n        if (startOffset > 0 && startOffset < startContainer.nodeValue.length) {\n          endContainer = splitText(startContainer, startOffset);\n          startContainer = endContainer.previousSibling;\n          if (endOffset > startOffset) {\n            endOffset = endOffset - startOffset;\n            startContainer = endContainer = splitText(endContainer, endOffset).previousSibling;\n            endOffset = endContainer.nodeValue.length;\n            startOffset = 0;\n          } else {\n            endOffset = 0;\n          }\n        }\n      } else {\n        if (isText$7(startContainer) && startOffset > 0 && startOffset < startContainer.nodeValue.length) {\n          startContainer = splitText(startContainer, startOffset);\n          startOffset = 0;\n        }\n        if (isText$7(endContainer) && endOffset > 0 && endOffset < endContainer.nodeValue.length) {\n          endContainer = splitText(endContainer, endOffset).previousSibling;\n          endOffset = endContainer.nodeValue.length;\n        }\n      }\n      return {\n        startContainer: startContainer,\n        startOffset: startOffset,\n        endContainer: endContainer,\n        endOffset: endOffset\n      };\n    };\n\n    var RangeUtils = function (dom) {\n      var walk = function (rng, callback) {\n        return walk$2(dom, rng, callback);\n      };\n      var split$1 = split;\n      var normalize = function (rng) {\n        return normalize$2(dom, rng).fold(never, function (normalizedRng) {\n          rng.setStart(normalizedRng.startContainer, normalizedRng.startOffset);\n          rng.setEnd(normalizedRng.endContainer, normalizedRng.endOffset);\n          return true;\n        });\n      };\n      return {\n        walk: walk,\n        split: split$1,\n        normalize: normalize\n      };\n    };\n    RangeUtils.compareRanges = isEq$4;\n    RangeUtils.getCaretRangeFromPoint = fromPoint;\n    RangeUtils.getSelectedNode = getSelectedNode;\n    RangeUtils.getNode = getNode$1;\n\n    var Dimension = function (name, getOffset) {\n      var set = function (element, h) {\n        if (!isNumber(h) && !h.match(/^[0-9]+$/)) {\n          throw new Error(name + '.set accepts only positive integer values. Value was ' + h);\n        }\n        var dom = element.dom;\n        if (isSupported(dom)) {\n          dom.style[name] = h + 'px';\n        }\n      };\n      var get = function (element) {\n        var r = getOffset(element);\n        if (r <= 0 || r === null) {\n          var css = get$5(element, name);\n          return parseFloat(css) || 0;\n        }\n        return r;\n      };\n      var getOuter = get;\n      var aggregate = function (element, properties) {\n        return foldl(properties, function (acc, property) {\n          var val = get$5(element, property);\n          var value = val === undefined ? 0 : parseInt(val, 10);\n          return isNaN(value) ? acc : acc + value;\n        }, 0);\n      };\n      var max = function (element, value, properties) {\n        var cumulativeInclusions = aggregate(element, properties);\n        var absoluteMax = value > cumulativeInclusions ? value - cumulativeInclusions : 0;\n        return absoluteMax;\n      };\n      return {\n        set: set,\n        get: get,\n        getOuter: getOuter,\n        aggregate: aggregate,\n        max: max\n      };\n    };\n\n    var api = Dimension('height', function (element) {\n      var dom = element.dom;\n      return inBody(element) ? dom.getBoundingClientRect().height : dom.offsetHeight;\n    });\n    var get$1 = function (element) {\n      return api.get(element);\n    };\n\n    var walkUp = function (navigation, doc) {\n      var frame = navigation.view(doc);\n      return frame.fold(constant([]), function (f) {\n        var parent = navigation.owner(f);\n        var rest = walkUp(navigation, parent);\n        return [f].concat(rest);\n      });\n    };\n    var pathTo = function (element, navigation) {\n      var d = navigation.owner(element);\n      return walkUp(navigation, d);\n    };\n\n    var view = function (doc) {\n      var _a;\n      var element = doc.dom === document ? Optional.none() : Optional.from((_a = doc.dom.defaultView) === null || _a === void 0 ? void 0 : _a.frameElement);\n      return element.map(SugarElement.fromDom);\n    };\n    var owner = function (element) {\n      return documentOrOwner(element);\n    };\n\n    var Navigation = /*#__PURE__*/Object.freeze({\n        __proto__: null,\n        view: view,\n        owner: owner\n    });\n\n    var find$1 = function (element) {\n      var doc = SugarElement.fromDom(document);\n      var scroll = get$8(doc);\n      var frames = pathTo(element, Navigation);\n      var offset = viewport(element);\n      var r = foldr(frames, function (b, a) {\n        var loc = viewport(a);\n        return {\n          left: b.left + loc.left,\n          top: b.top + loc.top\n        };\n      }, {\n        left: 0,\n        top: 0\n      });\n      return SugarPosition(r.left + offset.left + scroll.left, r.top + offset.top + scroll.top);\n    };\n\n    var excludeFromDescend = function (element) {\n      return name(element) === 'textarea';\n    };\n    var fireScrollIntoViewEvent = function (editor, data) {\n      var scrollEvent = editor.fire('ScrollIntoView', data);\n      return scrollEvent.isDefaultPrevented();\n    };\n    var fireAfterScrollIntoViewEvent = function (editor, data) {\n      editor.fire('AfterScrollIntoView', data);\n    };\n    var descend = function (element, offset) {\n      var children$1 = children(element);\n      if (children$1.length === 0 || excludeFromDescend(element)) {\n        return {\n          element: element,\n          offset: offset\n        };\n      } else if (offset < children$1.length && !excludeFromDescend(children$1[offset])) {\n        return {\n          element: children$1[offset],\n          offset: 0\n        };\n      } else {\n        var last = children$1[children$1.length - 1];\n        if (excludeFromDescend(last)) {\n          return {\n            element: element,\n            offset: offset\n          };\n        } else {\n          if (name(last) === 'img') {\n            return {\n              element: last,\n              offset: 1\n            };\n          } else if (isText$8(last)) {\n            return {\n              element: last,\n              offset: get$2(last).length\n            };\n          } else {\n            return {\n              element: last,\n              offset: children(last).length\n            };\n          }\n        }\n      }\n    };\n    var markerInfo = function (element, cleanupFun) {\n      var pos = absolute(element);\n      var height = get$1(element);\n      return {\n        element: element,\n        bottom: pos.top + height,\n        height: height,\n        pos: pos,\n        cleanup: cleanupFun\n      };\n    };\n    var createMarker = function (element, offset) {\n      var startPoint = descend(element, offset);\n      var span = SugarElement.fromHtml('<span data-mce-bogus=\"all\" style=\"display: inline-block;\">' + ZWSP$1 + '</span>');\n      before$4(startPoint.element, span);\n      return markerInfo(span, function () {\n        return remove$7(span);\n      });\n    };\n    var elementMarker = function (element) {\n      return markerInfo(SugarElement.fromDom(element), noop);\n    };\n    var withMarker = function (editor, f, rng, alignToTop) {\n      preserveWith(editor, function (_s, _e) {\n        return applyWithMarker(editor, f, rng, alignToTop);\n      }, rng);\n    };\n    var withScrollEvents = function (editor, doc, f, marker, alignToTop) {\n      var data = {\n        elm: marker.element.dom,\n        alignToTop: alignToTop\n      };\n      if (fireScrollIntoViewEvent(editor, data)) {\n        return;\n      }\n      var scrollTop = get$8(doc).top;\n      f(doc, scrollTop, marker, alignToTop);\n      fireAfterScrollIntoViewEvent(editor, data);\n    };\n    var applyWithMarker = function (editor, f, rng, alignToTop) {\n      var body = SugarElement.fromDom(editor.getBody());\n      var doc = SugarElement.fromDom(editor.getDoc());\n      reflow(body);\n      var marker = createMarker(SugarElement.fromDom(rng.startContainer), rng.startOffset);\n      withScrollEvents(editor, doc, f, marker, alignToTop);\n      marker.cleanup();\n    };\n    var withElement = function (editor, element, f, alignToTop) {\n      var doc = SugarElement.fromDom(editor.getDoc());\n      withScrollEvents(editor, doc, f, elementMarker(element), alignToTop);\n    };\n    var preserveWith = function (editor, f, rng) {\n      var startElement = rng.startContainer;\n      var startOffset = rng.startOffset;\n      var endElement = rng.endContainer;\n      var endOffset = rng.endOffset;\n      f(SugarElement.fromDom(startElement), SugarElement.fromDom(endElement));\n      var newRng = editor.dom.createRng();\n      newRng.setStart(startElement, startOffset);\n      newRng.setEnd(endElement, endOffset);\n      editor.selection.setRng(rng);\n    };\n    var scrollToMarker = function (marker, viewHeight, alignToTop, doc) {\n      var pos = marker.pos;\n      if (alignToTop) {\n        to(pos.left, pos.top, doc);\n      } else {\n        var y = pos.top - viewHeight + marker.height;\n        to(pos.left, y, doc);\n      }\n    };\n    var intoWindowIfNeeded = function (doc, scrollTop, viewHeight, marker, alignToTop) {\n      var viewportBottom = viewHeight + scrollTop;\n      var markerTop = marker.pos.top;\n      var markerBottom = marker.bottom;\n      var largerThanViewport = markerBottom - markerTop >= viewHeight;\n      if (markerTop < scrollTop) {\n        scrollToMarker(marker, viewHeight, alignToTop !== false, doc);\n      } else if (markerTop > viewportBottom) {\n        var align = largerThanViewport ? alignToTop !== false : alignToTop === true;\n        scrollToMarker(marker, viewHeight, align, doc);\n      } else if (markerBottom > viewportBottom && !largerThanViewport) {\n        scrollToMarker(marker, viewHeight, alignToTop === true, doc);\n      }\n    };\n    var intoWindow = function (doc, scrollTop, marker, alignToTop) {\n      var viewHeight = doc.dom.defaultView.innerHeight;\n      intoWindowIfNeeded(doc, scrollTop, viewHeight, marker, alignToTop);\n    };\n    var intoFrame = function (doc, scrollTop, marker, alignToTop) {\n      var frameViewHeight = doc.dom.defaultView.innerHeight;\n      intoWindowIfNeeded(doc, scrollTop, frameViewHeight, marker, alignToTop);\n      var op = find$1(marker.element);\n      var viewportBounds = getBounds(window);\n      if (op.top < viewportBounds.y) {\n        intoView(marker.element, alignToTop !== false);\n      } else if (op.top > viewportBounds.bottom) {\n        intoView(marker.element, alignToTop === true);\n      }\n    };\n    var rangeIntoWindow = function (editor, rng, alignToTop) {\n      return withMarker(editor, intoWindow, rng, alignToTop);\n    };\n    var elementIntoWindow = function (editor, element, alignToTop) {\n      return withElement(editor, element, intoWindow, alignToTop);\n    };\n    var rangeIntoFrame = function (editor, rng, alignToTop) {\n      return withMarker(editor, intoFrame, rng, alignToTop);\n    };\n    var elementIntoFrame = function (editor, element, alignToTop) {\n      return withElement(editor, element, intoFrame, alignToTop);\n    };\n    var scrollElementIntoView = function (editor, element, alignToTop) {\n      var scroller = editor.inline ? elementIntoWindow : elementIntoFrame;\n      scroller(editor, element, alignToTop);\n    };\n    var scrollRangeIntoView = function (editor, rng, alignToTop) {\n      var scroller = editor.inline ? rangeIntoWindow : rangeIntoFrame;\n      scroller(editor, rng, alignToTop);\n    };\n\n    var getDocument = function () {\n      return SugarElement.fromDom(document);\n    };\n\n    var focus$1 = function (element) {\n      return element.dom.focus();\n    };\n    var hasFocus$1 = function (element) {\n      var root = getRootNode(element).dom;\n      return element.dom === root.activeElement;\n    };\n    var active = function (root) {\n      if (root === void 0) {\n        root = getDocument();\n      }\n      return Optional.from(root.dom.activeElement).map(SugarElement.fromDom);\n    };\n    var search = function (element) {\n      return active(getRootNode(element)).filter(function (e) {\n        return element.dom.contains(e.dom);\n      });\n    };\n\n    var create$5 = function (start, soffset, finish, foffset) {\n      return {\n        start: start,\n        soffset: soffset,\n        finish: finish,\n        foffset: foffset\n      };\n    };\n    var SimRange = { create: create$5 };\n\n    var adt$1 = Adt.generate([\n      { before: ['element'] },\n      {\n        on: [\n          'element',\n          'offset'\n        ]\n      },\n      { after: ['element'] }\n    ]);\n    var cata = function (subject, onBefore, onOn, onAfter) {\n      return subject.fold(onBefore, onOn, onAfter);\n    };\n    var getStart$2 = function (situ) {\n      return situ.fold(identity, identity, identity);\n    };\n    var before$1 = adt$1.before;\n    var on = adt$1.on;\n    var after$1 = adt$1.after;\n    var Situ = {\n      before: before$1,\n      on: on,\n      after: after$1,\n      cata: cata,\n      getStart: getStart$2\n    };\n\n    var adt = Adt.generate([\n      { domRange: ['rng'] },\n      {\n        relative: [\n          'startSitu',\n          'finishSitu'\n        ]\n      },\n      {\n        exact: [\n          'start',\n          'soffset',\n          'finish',\n          'foffset'\n        ]\n      }\n    ]);\n    var exactFromRange = function (simRange) {\n      return adt.exact(simRange.start, simRange.soffset, simRange.finish, simRange.foffset);\n    };\n    var getStart$1 = function (selection) {\n      return selection.match({\n        domRange: function (rng) {\n          return SugarElement.fromDom(rng.startContainer);\n        },\n        relative: function (startSitu, _finishSitu) {\n          return Situ.getStart(startSitu);\n        },\n        exact: function (start, _soffset, _finish, _foffset) {\n          return start;\n        }\n      });\n    };\n    var domRange = adt.domRange;\n    var relative = adt.relative;\n    var exact = adt.exact;\n    var getWin = function (selection) {\n      var start = getStart$1(selection);\n      return defaultView(start);\n    };\n    var range = SimRange.create;\n    var SimSelection = {\n      domRange: domRange,\n      relative: relative,\n      exact: exact,\n      exactFromRange: exactFromRange,\n      getWin: getWin,\n      range: range\n    };\n\n    var browser$1 = detect().browser;\n    var clamp$1 = function (offset, element) {\n      var max = isText$8(element) ? get$2(element).length : children(element).length + 1;\n      if (offset > max) {\n        return max;\n      } else if (offset < 0) {\n        return 0;\n      }\n      return offset;\n    };\n    var normalizeRng = function (rng) {\n      return SimSelection.range(rng.start, clamp$1(rng.soffset, rng.start), rng.finish, clamp$1(rng.foffset, rng.finish));\n    };\n    var isOrContains = function (root, elm) {\n      return !isRestrictedNode(elm.dom) && (contains$1(root, elm) || eq(root, elm));\n    };\n    var isRngInRoot = function (root) {\n      return function (rng) {\n        return isOrContains(root, rng.start) && isOrContains(root, rng.finish);\n      };\n    };\n    var shouldStore = function (editor) {\n      return editor.inline === true || browser$1.isIE();\n    };\n    var nativeRangeToSelectionRange = function (r) {\n      return SimSelection.range(SugarElement.fromDom(r.startContainer), r.startOffset, SugarElement.fromDom(r.endContainer), r.endOffset);\n    };\n    var readRange = function (win) {\n      var selection = win.getSelection();\n      var rng = !selection || selection.rangeCount === 0 ? Optional.none() : Optional.from(selection.getRangeAt(0));\n      return rng.map(nativeRangeToSelectionRange);\n    };\n    var getBookmark = function (root) {\n      var win = defaultView(root);\n      return readRange(win.dom).filter(isRngInRoot(root));\n    };\n    var validate = function (root, bookmark) {\n      return Optional.from(bookmark).filter(isRngInRoot(root)).map(normalizeRng);\n    };\n    var bookmarkToNativeRng = function (bookmark) {\n      var rng = document.createRange();\n      try {\n        rng.setStart(bookmark.start.dom, bookmark.soffset);\n        rng.setEnd(bookmark.finish.dom, bookmark.foffset);\n        return Optional.some(rng);\n      } catch (_) {\n        return Optional.none();\n      }\n    };\n    var store = function (editor) {\n      var newBookmark = shouldStore(editor) ? getBookmark(SugarElement.fromDom(editor.getBody())) : Optional.none();\n      editor.bookmark = newBookmark.isSome() ? newBookmark : editor.bookmark;\n    };\n    var storeNative = function (editor, rng) {\n      var root = SugarElement.fromDom(editor.getBody());\n      var range = shouldStore(editor) ? Optional.from(rng) : Optional.none();\n      var newBookmark = range.map(nativeRangeToSelectionRange).filter(isRngInRoot(root));\n      editor.bookmark = newBookmark.isSome() ? newBookmark : editor.bookmark;\n    };\n    var getRng = function (editor) {\n      var bookmark = editor.bookmark ? editor.bookmark : Optional.none();\n      return bookmark.bind(function (x) {\n        return validate(SugarElement.fromDom(editor.getBody()), x);\n      }).bind(bookmarkToNativeRng);\n    };\n    var restore = function (editor) {\n      getRng(editor).each(function (rng) {\n        return editor.selection.setRng(rng);\n      });\n    };\n\n    var isEditorUIElement$1 = function (elm) {\n      var className = elm.className.toString();\n      return className.indexOf('tox-') !== -1 || className.indexOf('mce-') !== -1;\n    };\n    var FocusManager = { isEditorUIElement: isEditorUIElement$1 };\n\n    var isManualNodeChange = function (e) {\n      return e.type === 'nodechange' && e.selectionChange;\n    };\n    var registerPageMouseUp = function (editor, throttledStore) {\n      var mouseUpPage = function () {\n        throttledStore.throttle();\n      };\n      DOMUtils.DOM.bind(document, 'mouseup', mouseUpPage);\n      editor.on('remove', function () {\n        DOMUtils.DOM.unbind(document, 'mouseup', mouseUpPage);\n      });\n    };\n    var registerFocusOut = function (editor) {\n      editor.on('focusout', function () {\n        store(editor);\n      });\n    };\n    var registerMouseUp = function (editor, throttledStore) {\n      editor.on('mouseup touchend', function (_e) {\n        throttledStore.throttle();\n      });\n    };\n    var registerEditorEvents = function (editor, throttledStore) {\n      var browser = detect().browser;\n      if (browser.isIE()) {\n        registerFocusOut(editor);\n      } else {\n        registerMouseUp(editor, throttledStore);\n      }\n      editor.on('keyup NodeChange', function (e) {\n        if (!isManualNodeChange(e)) {\n          store(editor);\n        }\n      });\n    };\n    var register$3 = function (editor) {\n      var throttledStore = first(function () {\n        store(editor);\n      }, 0);\n      editor.on('init', function () {\n        if (editor.inline) {\n          registerPageMouseUp(editor, throttledStore);\n        }\n        registerEditorEvents(editor, throttledStore);\n      });\n      editor.on('remove', function () {\n        throttledStore.cancel();\n      });\n    };\n\n    var documentFocusInHandler;\n    var DOM$8 = DOMUtils.DOM;\n    var isEditorUIElement = function (elm) {\n      return FocusManager.isEditorUIElement(elm);\n    };\n    var isEditorContentAreaElement = function (elm) {\n      var classList = elm.classList;\n      if (classList !== undefined) {\n        return classList.contains('tox-edit-area') || classList.contains('tox-edit-area__iframe') || classList.contains('mce-content-body');\n      } else {\n        return false;\n      }\n    };\n    var isUIElement = function (editor, elm) {\n      var customSelector = getCustomUiSelector(editor);\n      var parent = DOM$8.getParent(elm, function (elm) {\n        return isEditorUIElement(elm) || (customSelector ? editor.dom.is(elm, customSelector) : false);\n      });\n      return parent !== null;\n    };\n    var getActiveElement = function (editor) {\n      try {\n        var root = getRootNode(SugarElement.fromDom(editor.getElement()));\n        return active(root).fold(function () {\n          return document.body;\n        }, function (x) {\n          return x.dom;\n        });\n      } catch (ex) {\n        return document.body;\n      }\n    };\n    var registerEvents$1 = function (editorManager, e) {\n      var editor = e.editor;\n      register$3(editor);\n      editor.on('focusin', function () {\n        var focusedEditor = editorManager.focusedEditor;\n        if (focusedEditor !== editor) {\n          if (focusedEditor) {\n            focusedEditor.fire('blur', { focusedEditor: editor });\n          }\n          editorManager.setActive(editor);\n          editorManager.focusedEditor = editor;\n          editor.fire('focus', { blurredEditor: focusedEditor });\n          editor.focus(true);\n        }\n      });\n      editor.on('focusout', function () {\n        Delay.setEditorTimeout(editor, function () {\n          var focusedEditor = editorManager.focusedEditor;\n          if (!isUIElement(editor, getActiveElement(editor)) && focusedEditor === editor) {\n            editor.fire('blur', { focusedEditor: null });\n            editorManager.focusedEditor = null;\n          }\n        });\n      });\n      if (!documentFocusInHandler) {\n        documentFocusInHandler = function (e) {\n          var activeEditor = editorManager.activeEditor;\n          if (activeEditor) {\n            getOriginalEventTarget(e).each(function (target) {\n              if (target.ownerDocument === document) {\n                if (target !== document.body && !isUIElement(activeEditor, target) && editorManager.focusedEditor === activeEditor) {\n                  activeEditor.fire('blur', { focusedEditor: null });\n                  editorManager.focusedEditor = null;\n                }\n              }\n            });\n          }\n        };\n        DOM$8.bind(document, 'focusin', documentFocusInHandler);\n      }\n    };\n    var unregisterDocumentEvents = function (editorManager, e) {\n      if (editorManager.focusedEditor === e.editor) {\n        editorManager.focusedEditor = null;\n      }\n      if (!editorManager.activeEditor) {\n        DOM$8.unbind(document, 'focusin', documentFocusInHandler);\n        documentFocusInHandler = null;\n      }\n    };\n    var setup$l = function (editorManager) {\n      editorManager.on('AddEditor', curry(registerEvents$1, editorManager));\n      editorManager.on('RemoveEditor', curry(unregisterDocumentEvents, editorManager));\n    };\n\n    var getContentEditableHost = function (editor, node) {\n      return editor.dom.getParent(node, function (node) {\n        return editor.dom.getContentEditable(node) === 'true';\n      });\n    };\n    var getCollapsedNode = function (rng) {\n      return rng.collapsed ? Optional.from(getNode$1(rng.startContainer, rng.startOffset)).map(SugarElement.fromDom) : Optional.none();\n    };\n    var getFocusInElement = function (root, rng) {\n      return getCollapsedNode(rng).bind(function (node) {\n        if (isTableSection(node)) {\n          return Optional.some(node);\n        } else if (contains$1(root, node) === false) {\n          return Optional.some(root);\n        } else {\n          return Optional.none();\n        }\n      });\n    };\n    var normalizeSelection$1 = function (editor, rng) {\n      getFocusInElement(SugarElement.fromDom(editor.getBody()), rng).bind(function (elm) {\n        return firstPositionIn(elm.dom);\n      }).fold(function () {\n        editor.selection.normalize();\n        return;\n      }, function (caretPos) {\n        return editor.selection.setRng(caretPos.toRange());\n      });\n    };\n    var focusBody = function (body) {\n      if (body.setActive) {\n        try {\n          body.setActive();\n        } catch (ex) {\n          body.focus();\n        }\n      } else {\n        body.focus();\n      }\n    };\n    var hasElementFocus = function (elm) {\n      return hasFocus$1(elm) || search(elm).isSome();\n    };\n    var hasIframeFocus = function (editor) {\n      return editor.iframeElement && hasFocus$1(SugarElement.fromDom(editor.iframeElement));\n    };\n    var hasInlineFocus = function (editor) {\n      var rawBody = editor.getBody();\n      return rawBody && hasElementFocus(SugarElement.fromDom(rawBody));\n    };\n    var hasUiFocus = function (editor) {\n      var dos = getRootNode(SugarElement.fromDom(editor.getElement()));\n      return active(dos).filter(function (elem) {\n        return !isEditorContentAreaElement(elem.dom) && isUIElement(editor, elem.dom);\n      }).isSome();\n    };\n    var hasFocus = function (editor) {\n      return editor.inline ? hasInlineFocus(editor) : hasIframeFocus(editor);\n    };\n    var hasEditorOrUiFocus = function (editor) {\n      return hasFocus(editor) || hasUiFocus(editor);\n    };\n    var focusEditor = function (editor) {\n      var selection = editor.selection;\n      var body = editor.getBody();\n      var rng = selection.getRng();\n      editor.quirks.refreshContentEditable();\n      if (editor.bookmark !== undefined && hasFocus(editor) === false) {\n        getRng(editor).each(function (bookmarkRng) {\n          editor.selection.setRng(bookmarkRng);\n          rng = bookmarkRng;\n        });\n      }\n      var contentEditableHost = getContentEditableHost(editor, selection.getNode());\n      if (editor.$.contains(body, contentEditableHost)) {\n        focusBody(contentEditableHost);\n        normalizeSelection$1(editor, rng);\n        activateEditor(editor);\n        return;\n      }\n      if (!editor.inline) {\n        if (!Env.opera) {\n          focusBody(body);\n        }\n        editor.getWin().focus();\n      }\n      if (Env.gecko || editor.inline) {\n        focusBody(body);\n        normalizeSelection$1(editor, rng);\n      }\n      activateEditor(editor);\n    };\n    var activateEditor = function (editor) {\n      return editor.editorManager.setActive(editor);\n    };\n    var focus = function (editor, skipFocus) {\n      if (editor.removed) {\n        return;\n      }\n      if (skipFocus) {\n        activateEditor(editor);\n      } else {\n        focusEditor(editor);\n      }\n    };\n\n    var getEndpointElement = function (root, rng, start, real, resolve) {\n      var container = start ? rng.startContainer : rng.endContainer;\n      var offset = start ? rng.startOffset : rng.endOffset;\n      return Optional.from(container).map(SugarElement.fromDom).map(function (elm) {\n        return !real || !rng.collapsed ? child$1(elm, resolve(elm, offset)).getOr(elm) : elm;\n      }).bind(function (elm) {\n        return isElement$6(elm) ? Optional.some(elm) : parent(elm).filter(isElement$6);\n      }).map(function (elm) {\n        return elm.dom;\n      }).getOr(root);\n    };\n    var getStart = function (root, rng, real) {\n      return getEndpointElement(root, rng, true, real, function (elm, offset) {\n        return Math.min(childNodesCount(elm), offset);\n      });\n    };\n    var getEnd = function (root, rng, real) {\n      return getEndpointElement(root, rng, false, real, function (elm, offset) {\n        return offset > 0 ? offset - 1 : offset;\n      });\n    };\n    var skipEmptyTextNodes = function (node, forwards) {\n      var orig = node;\n      while (node && isText$7(node) && node.length === 0) {\n        node = forwards ? node.nextSibling : node.previousSibling;\n      }\n      return node || orig;\n    };\n    var getNode = function (root, rng) {\n      var elm, startContainer, endContainer;\n      if (!rng) {\n        return root;\n      }\n      startContainer = rng.startContainer;\n      endContainer = rng.endContainer;\n      var startOffset = rng.startOffset;\n      var endOffset = rng.endOffset;\n      elm = rng.commonAncestorContainer;\n      if (!rng.collapsed) {\n        if (startContainer === endContainer) {\n          if (endOffset - startOffset < 2) {\n            if (startContainer.hasChildNodes()) {\n              elm = startContainer.childNodes[startOffset];\n            }\n          }\n        }\n        if (startContainer.nodeType === 3 && endContainer.nodeType === 3) {\n          if (startContainer.length === startOffset) {\n            startContainer = skipEmptyTextNodes(startContainer.nextSibling, true);\n          } else {\n            startContainer = startContainer.parentNode;\n          }\n          if (endOffset === 0) {\n            endContainer = skipEmptyTextNodes(endContainer.previousSibling, false);\n          } else {\n            endContainer = endContainer.parentNode;\n          }\n          if (startContainer && startContainer === endContainer) {\n            return startContainer;\n          }\n        }\n      }\n      if (elm && elm.nodeType === 3) {\n        return elm.parentNode;\n      }\n      return elm;\n    };\n    var getSelectedBlocks = function (dom, rng, startElm, endElm) {\n      var node;\n      var selectedBlocks = [];\n      var root = dom.getRoot();\n      startElm = dom.getParent(startElm || getStart(root, rng, rng.collapsed), dom.isBlock);\n      endElm = dom.getParent(endElm || getEnd(root, rng, rng.collapsed), dom.isBlock);\n      if (startElm && startElm !== root) {\n        selectedBlocks.push(startElm);\n      }\n      if (startElm && endElm && startElm !== endElm) {\n        node = startElm;\n        var walker = new DomTreeWalker(startElm, root);\n        while ((node = walker.next()) && node !== endElm) {\n          if (dom.isBlock(node)) {\n            selectedBlocks.push(node);\n          }\n        }\n      }\n      if (endElm && startElm !== endElm && endElm !== root) {\n        selectedBlocks.push(endElm);\n      }\n      return selectedBlocks;\n    };\n    var select = function (dom, node, content) {\n      return Optional.from(node).map(function (node) {\n        var idx = dom.nodeIndex(node);\n        var rng = dom.createRng();\n        rng.setStart(node.parentNode, idx);\n        rng.setEnd(node.parentNode, idx + 1);\n        if (content) {\n          moveEndPoint(dom, rng, node, true);\n          moveEndPoint(dom, rng, node, false);\n        }\n        return rng;\n      });\n    };\n\n    var processRanges = function (editor, ranges) {\n      return map$3(ranges, function (range) {\n        var evt = editor.fire('GetSelectionRange', { range: range });\n        return evt.range !== range ? evt.range : range;\n      });\n    };\n\n    var typeLookup = {\n      '#text': 3,\n      '#comment': 8,\n      '#cdata': 4,\n      '#pi': 7,\n      '#doctype': 10,\n      '#document-fragment': 11\n    };\n    var walk$1 = function (node, root, prev) {\n      var startName = prev ? 'lastChild' : 'firstChild';\n      var siblingName = prev ? 'prev' : 'next';\n      if (node[startName]) {\n        return node[startName];\n      }\n      if (node !== root) {\n        var sibling = node[siblingName];\n        if (sibling) {\n          return sibling;\n        }\n        for (var parent_1 = node.parent; parent_1 && parent_1 !== root; parent_1 = parent_1.parent) {\n          sibling = parent_1[siblingName];\n          if (sibling) {\n            return sibling;\n          }\n        }\n      }\n    };\n    var isEmptyTextNode = function (node) {\n      if (!isWhitespaceText(node.value)) {\n        return false;\n      }\n      var parentNode = node.parent;\n      if (parentNode && (parentNode.name !== 'span' || parentNode.attr('style')) && /^[ ]+$/.test(node.value)) {\n        return false;\n      }\n      return true;\n    };\n    var isNonEmptyElement = function (node) {\n      var isNamedAnchor = node.name === 'a' && !node.attr('href') && node.attr('id');\n      return node.attr('name') || node.attr('id') && !node.firstChild || node.attr('data-mce-bookmark') || isNamedAnchor;\n    };\n    var AstNode = function () {\n      function AstNode(name, type) {\n        this.name = name;\n        this.type = type;\n        if (type === 1) {\n          this.attributes = [];\n          this.attributes.map = {};\n        }\n      }\n      AstNode.create = function (name, attrs) {\n        var node = new AstNode(name, typeLookup[name] || 1);\n        if (attrs) {\n          each$j(attrs, function (value, attrName) {\n            node.attr(attrName, value);\n          });\n        }\n        return node;\n      };\n      AstNode.prototype.replace = function (node) {\n        var self = this;\n        if (node.parent) {\n          node.remove();\n        }\n        self.insert(node, self);\n        self.remove();\n        return self;\n      };\n      AstNode.prototype.attr = function (name, value) {\n        var self = this;\n        var attrs;\n        if (typeof name !== 'string') {\n          if (name !== undefined && name !== null) {\n            each$j(name, function (value, key) {\n              self.attr(key, value);\n            });\n          }\n          return self;\n        }\n        if (attrs = self.attributes) {\n          if (value !== undefined) {\n            if (value === null) {\n              if (name in attrs.map) {\n                delete attrs.map[name];\n                var i = attrs.length;\n                while (i--) {\n                  if (attrs[i].name === name) {\n                    attrs.splice(i, 1);\n                    return self;\n                  }\n                }\n              }\n              return self;\n            }\n            if (name in attrs.map) {\n              var i = attrs.length;\n              while (i--) {\n                if (attrs[i].name === name) {\n                  attrs[i].value = value;\n                  break;\n                }\n              }\n            } else {\n              attrs.push({\n                name: name,\n                value: value\n              });\n            }\n            attrs.map[name] = value;\n            return self;\n          }\n          return attrs.map[name];\n        }\n      };\n      AstNode.prototype.clone = function () {\n        var self = this;\n        var clone = new AstNode(self.name, self.type);\n        var selfAttrs;\n        if (selfAttrs = self.attributes) {\n          var cloneAttrs = [];\n          cloneAttrs.map = {};\n          for (var i = 0, l = selfAttrs.length; i < l; i++) {\n            var selfAttr = selfAttrs[i];\n            if (selfAttr.name !== 'id') {\n              cloneAttrs[cloneAttrs.length] = {\n                name: selfAttr.name,\n                value: selfAttr.value\n              };\n              cloneAttrs.map[selfAttr.name] = selfAttr.value;\n            }\n          }\n          clone.attributes = cloneAttrs;\n        }\n        clone.value = self.value;\n        clone.shortEnded = self.shortEnded;\n        return clone;\n      };\n      AstNode.prototype.wrap = function (wrapper) {\n        var self = this;\n        self.parent.insert(wrapper, self);\n        wrapper.append(self);\n        return self;\n      };\n      AstNode.prototype.unwrap = function () {\n        var self = this;\n        for (var node = self.firstChild; node;) {\n          var next = node.next;\n          self.insert(node, self, true);\n          node = next;\n        }\n        self.remove();\n      };\n      AstNode.prototype.remove = function () {\n        var self = this, parent = self.parent, next = self.next, prev = self.prev;\n        if (parent) {\n          if (parent.firstChild === self) {\n            parent.firstChild = next;\n            if (next) {\n              next.prev = null;\n            }\n          } else {\n            prev.next = next;\n          }\n          if (parent.lastChild === self) {\n            parent.lastChild = prev;\n            if (prev) {\n              prev.next = null;\n            }\n          } else {\n            next.prev = prev;\n          }\n          self.parent = self.next = self.prev = null;\n        }\n        return self;\n      };\n      AstNode.prototype.append = function (node) {\n        var self = this;\n        if (node.parent) {\n          node.remove();\n        }\n        var last = self.lastChild;\n        if (last) {\n          last.next = node;\n          node.prev = last;\n          self.lastChild = node;\n        } else {\n          self.lastChild = self.firstChild = node;\n        }\n        node.parent = self;\n        return node;\n      };\n      AstNode.prototype.insert = function (node, refNode, before) {\n        if (node.parent) {\n          node.remove();\n        }\n        var parent = refNode.parent || this;\n        if (before) {\n          if (refNode === parent.firstChild) {\n            parent.firstChild = node;\n          } else {\n            refNode.prev.next = node;\n          }\n          node.prev = refNode.prev;\n          node.next = refNode;\n          refNode.prev = node;\n        } else {\n          if (refNode === parent.lastChild) {\n            parent.lastChild = node;\n          } else {\n            refNode.next.prev = node;\n          }\n          node.next = refNode.next;\n          node.prev = refNode;\n          refNode.next = node;\n        }\n        node.parent = parent;\n        return node;\n      };\n      AstNode.prototype.getAll = function (name) {\n        var self = this;\n        var collection = [];\n        for (var node = self.firstChild; node; node = walk$1(node, self)) {\n          if (node.name === name) {\n            collection.push(node);\n          }\n        }\n        return collection;\n      };\n      AstNode.prototype.children = function () {\n        var self = this;\n        var collection = [];\n        for (var node = self.firstChild; node; node = node.next) {\n          collection.push(node);\n        }\n        return collection;\n      };\n      AstNode.prototype.empty = function () {\n        var self = this;\n        if (self.firstChild) {\n          var nodes = [];\n          for (var node = self.firstChild; node; node = walk$1(node, self)) {\n            nodes.push(node);\n          }\n          var i = nodes.length;\n          while (i--) {\n            var node = nodes[i];\n            node.parent = node.firstChild = node.lastChild = node.next = node.prev = null;\n          }\n        }\n        self.firstChild = self.lastChild = null;\n        return self;\n      };\n      AstNode.prototype.isEmpty = function (elements, whitespace, predicate) {\n        if (whitespace === void 0) {\n          whitespace = {};\n        }\n        var self = this;\n        var node = self.firstChild;\n        if (isNonEmptyElement(self)) {\n          return false;\n        }\n        if (node) {\n          do {\n            if (node.type === 1) {\n              if (node.attr('data-mce-bogus')) {\n                continue;\n              }\n              if (elements[node.name]) {\n                return false;\n              }\n              if (isNonEmptyElement(node)) {\n                return false;\n              }\n            }\n            if (node.type === 8) {\n              return false;\n            }\n            if (node.type === 3 && !isEmptyTextNode(node)) {\n              return false;\n            }\n            if (node.type === 3 && node.parent && whitespace[node.parent.name] && isWhitespaceText(node.value)) {\n              return false;\n            }\n            if (predicate && predicate(node)) {\n              return false;\n            }\n          } while (node = walk$1(node, self));\n        }\n        return true;\n      };\n      AstNode.prototype.walk = function (prev) {\n        return walk$1(this, null, prev);\n      };\n      return AstNode;\n    }();\n\n    var unescapedTextParents = Tools.makeMap('NOSCRIPT STYLE SCRIPT XMP IFRAME NOEMBED NOFRAMES PLAINTEXT', ' ');\n    var containsZwsp = function (node) {\n      return isString$1(node.nodeValue) && contains$2(node.nodeValue, ZWSP$1);\n    };\n    var getTemporaryNodeSelector = function (tempAttrs) {\n      return (tempAttrs.length === 0 ? '' : map$3(tempAttrs, function (attr) {\n        return '[' + attr + ']';\n      }).join(',') + ',') + '[data-mce-bogus=\"all\"]';\n    };\n    var getTemporaryNodes = function (tempAttrs, body) {\n      return body.querySelectorAll(getTemporaryNodeSelector(tempAttrs));\n    };\n    var createWalker = function (body, whatToShow, filter) {\n      return document.createTreeWalker(body, whatToShow, filter, false);\n    };\n    var createZwspCommentWalker = function (body) {\n      return createWalker(body, NodeFilter.SHOW_COMMENT, function (node) {\n        return containsZwsp(node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;\n      });\n    };\n    var createUnescapedZwspTextWalker = function (body) {\n      return createWalker(body, NodeFilter.SHOW_TEXT, function (node) {\n        if (containsZwsp(node)) {\n          var parent_1 = node.parentNode;\n          return parent_1 && has$2(unescapedTextParents, parent_1.nodeName) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;\n        } else {\n          return NodeFilter.FILTER_SKIP;\n        }\n      });\n    };\n    var hasZwspComment = function (body) {\n      return createZwspCommentWalker(body).nextNode() !== null;\n    };\n    var hasUnescapedZwspText = function (body) {\n      return createUnescapedZwspTextWalker(body).nextNode() !== null;\n    };\n    var hasTemporaryNode = function (tempAttrs, body) {\n      return body.querySelector(getTemporaryNodeSelector(tempAttrs)) !== null;\n    };\n    var trimTemporaryNodes = function (tempAttrs, body) {\n      each$k(getTemporaryNodes(tempAttrs, body), function (elm) {\n        var element = SugarElement.fromDom(elm);\n        if (get$6(element, 'data-mce-bogus') === 'all') {\n          remove$7(element);\n        } else {\n          each$k(tempAttrs, function (attr) {\n            if (has$1(element, attr)) {\n              remove$6(element, attr);\n            }\n          });\n        }\n      });\n    };\n    var emptyAllNodeValuesInWalker = function (walker) {\n      var curr = walker.nextNode();\n      while (curr !== null) {\n        curr.nodeValue = null;\n        curr = walker.nextNode();\n      }\n    };\n    var emptyZwspComments = compose(emptyAllNodeValuesInWalker, createZwspCommentWalker);\n    var emptyUnescapedZwspTexts = compose(emptyAllNodeValuesInWalker, createUnescapedZwspTextWalker);\n    var trim$1 = function (body, tempAttrs) {\n      var conditionalTrims = [\n        {\n          condition: curry(hasTemporaryNode, tempAttrs),\n          action: curry(trimTemporaryNodes, tempAttrs)\n        },\n        {\n          condition: hasZwspComment,\n          action: emptyZwspComments\n        },\n        {\n          condition: hasUnescapedZwspText,\n          action: emptyUnescapedZwspTexts\n        }\n      ];\n      var trimmed = body;\n      var cloned = false;\n      each$k(conditionalTrims, function (_a) {\n        var condition = _a.condition, action = _a.action;\n        if (condition(trimmed)) {\n          if (!cloned) {\n            trimmed = body.cloneNode(true);\n            cloned = true;\n          }\n          action(trimmed);\n        }\n      });\n      return trimmed;\n    };\n\n    var trimEmptyContents = function (editor, html) {\n      var blockName = getForcedRootBlock(editor);\n      var emptyRegExp = new RegExp('^(<' + blockName + '[^>]*>(&nbsp;|&#160;|\\\\s|\\xA0|<br \\\\/>|)<\\\\/' + blockName + '>[\\r\\n]*|<br \\\\/>[\\r\\n]*)$');\n      return html.replace(emptyRegExp, '');\n    };\n    var setupArgs$3 = function (args, format) {\n      return __assign(__assign({}, args), {\n        format: format,\n        get: true,\n        getInner: true\n      });\n    };\n    var getContentFromBody = function (editor, args, format, body) {\n      var defaultedArgs = setupArgs$3(args, format);\n      var updatedArgs = args.no_events ? defaultedArgs : editor.fire('BeforeGetContent', defaultedArgs);\n      var content;\n      if (updatedArgs.format === 'raw') {\n        content = Tools.trim(trim$3(trim$1(body, editor.serializer.getTempAttrs()).innerHTML));\n      } else if (updatedArgs.format === 'text') {\n        content = editor.dom.isEmpty(body) ? '' : trim$3(body.innerText || body.textContent);\n      } else if (updatedArgs.format === 'tree') {\n        content = editor.serializer.serialize(body, updatedArgs);\n      } else {\n        content = trimEmptyContents(editor, editor.serializer.serialize(body, updatedArgs));\n      }\n      if (!contains$3([\n          'text',\n          'tree'\n        ], updatedArgs.format) && !isWsPreserveElement(SugarElement.fromDom(body))) {\n        updatedArgs.content = Tools.trim(content);\n      } else {\n        updatedArgs.content = content;\n      }\n      if (updatedArgs.no_events) {\n        return updatedArgs.content;\n      } else {\n        return editor.fire('GetContent', updatedArgs).content;\n      }\n    };\n    var getContentInternal = function (editor, args, format) {\n      return Optional.from(editor.getBody()).fold(constant(args.format === 'tree' ? new AstNode('body', 11) : ''), function (body) {\n        return getContentFromBody(editor, args, format, body);\n      });\n    };\n\n    var each$d = Tools.each;\n    var ElementUtils = function (dom) {\n      var compare = function (node1, node2) {\n        if (node1.nodeName !== node2.nodeName) {\n          return false;\n        }\n        var getAttribs = function (node) {\n          var attribs = {};\n          each$d(dom.getAttribs(node), function (attr) {\n            var name = attr.nodeName.toLowerCase();\n            if (name.indexOf('_') !== 0 && name !== 'style' && name.indexOf('data-') !== 0) {\n              attribs[name] = dom.getAttrib(node, name);\n            }\n          });\n          return attribs;\n        };\n        var compareObjects = function (obj1, obj2) {\n          var value, name;\n          for (name in obj1) {\n            if (has$2(obj1, name)) {\n              value = obj2[name];\n              if (typeof value === 'undefined') {\n                return false;\n              }\n              if (obj1[name] !== value) {\n                return false;\n              }\n              delete obj2[name];\n            }\n          }\n          for (name in obj2) {\n            if (has$2(obj2, name)) {\n              return false;\n            }\n          }\n          return true;\n        };\n        if (!compareObjects(getAttribs(node1), getAttribs(node2))) {\n          return false;\n        }\n        if (!compareObjects(dom.parseStyle(dom.getAttrib(node1, 'style')), dom.parseStyle(dom.getAttrib(node2, 'style')))) {\n          return false;\n        }\n        return !isBookmarkNode$1(node1) && !isBookmarkNode$1(node2);\n      };\n      return { compare: compare };\n    };\n\n    var makeMap$1 = Tools.makeMap;\n    var Writer = function (settings) {\n      var html = [];\n      settings = settings || {};\n      var indent = settings.indent;\n      var indentBefore = makeMap$1(settings.indent_before || '');\n      var indentAfter = makeMap$1(settings.indent_after || '');\n      var encode = Entities.getEncodeFunc(settings.entity_encoding || 'raw', settings.entities);\n      var htmlOutput = settings.element_format === 'html';\n      return {\n        start: function (name, attrs, empty) {\n          var i, l, attr, value;\n          if (indent && indentBefore[name] && html.length > 0) {\n            value = html[html.length - 1];\n            if (value.length > 0 && value !== '\\n') {\n              html.push('\\n');\n            }\n          }\n          html.push('<', name);\n          if (attrs) {\n            for (i = 0, l = attrs.length; i < l; i++) {\n              attr = attrs[i];\n              html.push(' ', attr.name, '=\"', encode(attr.value, true), '\"');\n            }\n          }\n          if (!empty || htmlOutput) {\n            html[html.length] = '>';\n          } else {\n            html[html.length] = ' />';\n          }\n          if (empty && indent && indentAfter[name] && html.length > 0) {\n            value = html[html.length - 1];\n            if (value.length > 0 && value !== '\\n') {\n              html.push('\\n');\n            }\n          }\n        },\n        end: function (name) {\n          var value;\n          html.push('</', name, '>');\n          if (indent && indentAfter[name] && html.length > 0) {\n            value = html[html.length - 1];\n            if (value.length > 0 && value !== '\\n') {\n              html.push('\\n');\n            }\n          }\n        },\n        text: function (text, raw) {\n          if (text.length > 0) {\n            html[html.length] = raw ? text : encode(text);\n          }\n        },\n        cdata: function (text) {\n          html.push('<![CDATA[', text, ']]>');\n        },\n        comment: function (text) {\n          html.push('<!--', text, '-->');\n        },\n        pi: function (name, text) {\n          if (text) {\n            html.push('<?', name, ' ', encode(text), '?>');\n          } else {\n            html.push('<?', name, '?>');\n          }\n          if (indent) {\n            html.push('\\n');\n          }\n        },\n        doctype: function (text) {\n          html.push('<!DOCTYPE', text, '>', indent ? '\\n' : '');\n        },\n        reset: function () {\n          html.length = 0;\n        },\n        getContent: function () {\n          return html.join('').replace(/\\n$/, '');\n        }\n      };\n    };\n\n    var HtmlSerializer = function (settings, schema) {\n      if (schema === void 0) {\n        schema = Schema();\n      }\n      var writer = Writer(settings);\n      settings = settings || {};\n      settings.validate = 'validate' in settings ? settings.validate : true;\n      var serialize = function (node) {\n        var validate = settings.validate;\n        var handlers = {\n          3: function (node) {\n            writer.text(node.value, node.raw);\n          },\n          8: function (node) {\n            writer.comment(node.value);\n          },\n          7: function (node) {\n            writer.pi(node.name, node.value);\n          },\n          10: function (node) {\n            writer.doctype(node.value);\n          },\n          4: function (node) {\n            writer.cdata(node.value);\n          },\n          11: function (node) {\n            if (node = node.firstChild) {\n              do {\n                walk(node);\n              } while (node = node.next);\n            }\n          }\n        };\n        writer.reset();\n        var walk = function (node) {\n          var handler = handlers[node.type];\n          if (!handler) {\n            var name_1 = node.name;\n            var isEmpty = node.shortEnded;\n            var attrs = node.attributes;\n            if (validate && attrs && attrs.length > 1) {\n              var sortedAttrs = [];\n              sortedAttrs.map = {};\n              var elementRule = schema.getElementRule(node.name);\n              if (elementRule) {\n                for (var i = 0, l = elementRule.attributesOrder.length; i < l; i++) {\n                  var attrName = elementRule.attributesOrder[i];\n                  if (attrName in attrs.map) {\n                    var attrValue = attrs.map[attrName];\n                    sortedAttrs.map[attrName] = attrValue;\n                    sortedAttrs.push({\n                      name: attrName,\n                      value: attrValue\n                    });\n                  }\n                }\n                for (var i = 0, l = attrs.length; i < l; i++) {\n                  var attrName = attrs[i].name;\n                  if (!(attrName in sortedAttrs.map)) {\n                    var attrValue = attrs.map[attrName];\n                    sortedAttrs.map[attrName] = attrValue;\n                    sortedAttrs.push({\n                      name: attrName,\n                      value: attrValue\n                    });\n                  }\n                }\n                attrs = sortedAttrs;\n              }\n            }\n            writer.start(node.name, attrs, isEmpty);\n            if (!isEmpty) {\n              if (node = node.firstChild) {\n                do {\n                  walk(node);\n                } while (node = node.next);\n              }\n              writer.end(name_1);\n            }\n          } else {\n            handler(node);\n          }\n        };\n        if (node.type === 1 && !settings.inner) {\n          walk(node);\n        } else {\n          handlers[11](node);\n        }\n        return writer.getContent();\n      };\n      return { serialize: serialize };\n    };\n\n    var nonInheritableStyles = new Set();\n    (function () {\n      var nonInheritableStylesArr = [\n        'margin',\n        'margin-left',\n        'margin-right',\n        'margin-top',\n        'margin-bottom',\n        'padding',\n        'padding-left',\n        'padding-right',\n        'padding-top',\n        'padding-bottom',\n        'border',\n        'border-width',\n        'border-style',\n        'border-color',\n        'background',\n        'background-attachment',\n        'background-clip',\n        'background-color',\n        'background-image',\n        'background-origin',\n        'background-position',\n        'background-repeat',\n        'background-size',\n        'float',\n        'position',\n        'left',\n        'right',\n        'top',\n        'bottom',\n        'z-index',\n        'display',\n        'transform',\n        'width',\n        'max-width',\n        'min-width',\n        'height',\n        'max-height',\n        'min-height',\n        'overflow',\n        'overflow-x',\n        'overflow-y',\n        'text-overflow',\n        'vertical-align',\n        'transition',\n        'transition-delay',\n        'transition-duration',\n        'transition-property',\n        'transition-timing-function'\n      ];\n      each$k(nonInheritableStylesArr, function (style) {\n        nonInheritableStyles.add(style);\n      });\n    }());\n    var shorthandStyleProps = [\n      'font',\n      'text-decoration',\n      'text-emphasis'\n    ];\n    var getStyleProps = function (dom, node) {\n      return keys(dom.parseStyle(dom.getAttrib(node, 'style')));\n    };\n    var isNonInheritableStyle = function (style) {\n      return nonInheritableStyles.has(style);\n    };\n    var hasInheritableStyles = function (dom, node) {\n      return forall(getStyleProps(dom, node), function (style) {\n        return !isNonInheritableStyle(style);\n      });\n    };\n    var getLonghandStyleProps = function (styles) {\n      return filter$4(styles, function (style) {\n        return exists(shorthandStyleProps, function (prop) {\n          return startsWith(style, prop);\n        });\n      });\n    };\n    var hasStyleConflict = function (dom, node, parentNode) {\n      var nodeStyleProps = getStyleProps(dom, node);\n      var parentNodeStyleProps = getStyleProps(dom, parentNode);\n      var valueMismatch = function (prop) {\n        var nodeValue = dom.getStyle(node, prop);\n        var parentValue = dom.getStyle(parentNode, prop);\n        return isNotEmpty(nodeValue) && isNotEmpty(parentValue) && nodeValue !== parentValue;\n      };\n      return exists(nodeStyleProps, function (nodeStyleProp) {\n        var propExists = function (props) {\n          return exists(props, function (prop) {\n            return prop === nodeStyleProp;\n          });\n        };\n        if (!propExists(parentNodeStyleProps) && propExists(shorthandStyleProps)) {\n          var longhandProps = getLonghandStyleProps(parentNodeStyleProps);\n          return exists(longhandProps, valueMismatch);\n        } else {\n          return valueMismatch(nodeStyleProp);\n        }\n      });\n    };\n\n    var isChar = function (forward, predicate, pos) {\n      return Optional.from(pos.container()).filter(isText$7).exists(function (text) {\n        var delta = forward ? 0 : -1;\n        return predicate(text.data.charAt(pos.offset() + delta));\n      });\n    };\n    var isBeforeSpace = curry(isChar, true, isWhiteSpace);\n    var isAfterSpace = curry(isChar, false, isWhiteSpace);\n    var isEmptyText = function (pos) {\n      var container = pos.container();\n      return isText$7(container) && (container.data.length === 0 || isZwsp(container.data) && BookmarkManager.isBookmarkNode(container.parentNode));\n    };\n    var matchesElementPosition = function (before, predicate) {\n      return function (pos) {\n        return Optional.from(getChildNodeAtRelativeOffset(before ? 0 : -1, pos)).filter(predicate).isSome();\n      };\n    };\n    var isImageBlock = function (node) {\n      return isImg(node) && get$5(SugarElement.fromDom(node), 'display') === 'block';\n    };\n    var isCefNode = function (node) {\n      return isContentEditableFalse$b(node) && !isBogusAll$1(node);\n    };\n    var isBeforeImageBlock = matchesElementPosition(true, isImageBlock);\n    var isAfterImageBlock = matchesElementPosition(false, isImageBlock);\n    var isBeforeMedia = matchesElementPosition(true, isMedia$2);\n    var isAfterMedia = matchesElementPosition(false, isMedia$2);\n    var isBeforeTable = matchesElementPosition(true, isTable$3);\n    var isAfterTable = matchesElementPosition(false, isTable$3);\n    var isBeforeContentEditableFalse = matchesElementPosition(true, isCefNode);\n    var isAfterContentEditableFalse = matchesElementPosition(false, isCefNode);\n\n    var getLastChildren = function (elm) {\n      var children = [];\n      var rawNode = elm.dom;\n      while (rawNode) {\n        children.push(SugarElement.fromDom(rawNode));\n        rawNode = rawNode.lastChild;\n      }\n      return children;\n    };\n    var removeTrailingBr = function (elm) {\n      var allBrs = descendants(elm, 'br');\n      var brs = filter$4(getLastChildren(elm).slice(-1), isBr$4);\n      if (allBrs.length === brs.length) {\n        each$k(brs, remove$7);\n      }\n    };\n    var fillWithPaddingBr = function (elm) {\n      empty(elm);\n      append$1(elm, SugarElement.fromHtml('<br data-mce-bogus=\"1\">'));\n    };\n    var trimBlockTrailingBr = function (elm) {\n      lastChild(elm).each(function (lastChild) {\n        prevSibling(lastChild).each(function (lastChildPrevSibling) {\n          if (isBlock$2(elm) && isBr$4(lastChild) && isBlock$2(lastChildPrevSibling)) {\n            remove$7(lastChild);\n          }\n        });\n      });\n    };\n\n    var dropLast = function (xs) {\n      return xs.slice(0, -1);\n    };\n    var parentsUntil = function (start, root, predicate) {\n      if (contains$1(root, start)) {\n        return dropLast(parents$1(start, function (elm) {\n          return predicate(elm) || eq(elm, root);\n        }));\n      } else {\n        return [];\n      }\n    };\n    var parents = function (start, root) {\n      return parentsUntil(start, root, never);\n    };\n    var parentsAndSelf = function (start, root) {\n      return [start].concat(parents(start, root));\n    };\n\n    var navigateIgnoreEmptyTextNodes = function (forward, root, from) {\n      return navigateIgnore(forward, root, from, isEmptyText);\n    };\n    var getClosestBlock$1 = function (root, pos) {\n      return find$3(parentsAndSelf(SugarElement.fromDom(pos.container()), root), isBlock$2);\n    };\n    var isAtBeforeAfterBlockBoundary = function (forward, root, pos) {\n      return navigateIgnoreEmptyTextNodes(forward, root.dom, pos).forall(function (newPos) {\n        return getClosestBlock$1(root, pos).fold(function () {\n          return isInSameBlock(newPos, pos, root.dom) === false;\n        }, function (fromBlock) {\n          return isInSameBlock(newPos, pos, root.dom) === false && contains$1(fromBlock, SugarElement.fromDom(newPos.container()));\n        });\n      });\n    };\n    var isAtBlockBoundary = function (forward, root, pos) {\n      return getClosestBlock$1(root, pos).fold(function () {\n        return navigateIgnoreEmptyTextNodes(forward, root.dom, pos).forall(function (newPos) {\n          return isInSameBlock(newPos, pos, root.dom) === false;\n        });\n      }, function (parent) {\n        return navigateIgnoreEmptyTextNodes(forward, parent.dom, pos).isNone();\n      });\n    };\n    var isAtStartOfBlock = curry(isAtBlockBoundary, false);\n    var isAtEndOfBlock = curry(isAtBlockBoundary, true);\n    var isBeforeBlock = curry(isAtBeforeAfterBlockBoundary, false);\n    var isAfterBlock = curry(isAtBeforeAfterBlockBoundary, true);\n\n    var isBr = function (pos) {\n      return getElementFromPosition(pos).exists(isBr$4);\n    };\n    var findBr = function (forward, root, pos) {\n      var parentBlocks = filter$4(parentsAndSelf(SugarElement.fromDom(pos.container()), root), isBlock$2);\n      var scope = head(parentBlocks).getOr(root);\n      return fromPosition(forward, scope.dom, pos).filter(isBr);\n    };\n    var isBeforeBr$1 = function (root, pos) {\n      return getElementFromPosition(pos).exists(isBr$4) || findBr(true, root, pos).isSome();\n    };\n    var isAfterBr = function (root, pos) {\n      return getElementFromPrevPosition(pos).exists(isBr$4) || findBr(false, root, pos).isSome();\n    };\n    var findPreviousBr = curry(findBr, false);\n    var findNextBr = curry(findBr, true);\n\n    var isInMiddleOfText = function (pos) {\n      return CaretPosition.isTextPosition(pos) && !pos.isAtStart() && !pos.isAtEnd();\n    };\n    var getClosestBlock = function (root, pos) {\n      var parentBlocks = filter$4(parentsAndSelf(SugarElement.fromDom(pos.container()), root), isBlock$2);\n      return head(parentBlocks).getOr(root);\n    };\n    var hasSpaceBefore = function (root, pos) {\n      if (isInMiddleOfText(pos)) {\n        return isAfterSpace(pos);\n      } else {\n        return isAfterSpace(pos) || prevPosition(getClosestBlock(root, pos).dom, pos).exists(isAfterSpace);\n      }\n    };\n    var hasSpaceAfter = function (root, pos) {\n      if (isInMiddleOfText(pos)) {\n        return isBeforeSpace(pos);\n      } else {\n        return isBeforeSpace(pos) || nextPosition(getClosestBlock(root, pos).dom, pos).exists(isBeforeSpace);\n      }\n    };\n    var isPreValue = function (value) {\n      return contains$3([\n        'pre',\n        'pre-wrap'\n      ], value);\n    };\n    var isInPre = function (pos) {\n      return getElementFromPosition(pos).bind(function (elm) {\n        return closest$3(elm, isElement$6);\n      }).exists(function (elm) {\n        return isPreValue(get$5(elm, 'white-space'));\n      });\n    };\n    var isAtBeginningOfBody = function (root, pos) {\n      return prevPosition(root.dom, pos).isNone();\n    };\n    var isAtEndOfBody = function (root, pos) {\n      return nextPosition(root.dom, pos).isNone();\n    };\n    var isAtLineBoundary = function (root, pos) {\n      return isAtBeginningOfBody(root, pos) || isAtEndOfBody(root, pos) || isAtStartOfBlock(root, pos) || isAtEndOfBlock(root, pos) || isAfterBr(root, pos) || isBeforeBr$1(root, pos);\n    };\n    var needsToHaveNbsp = function (root, pos) {\n      if (isInPre(pos)) {\n        return false;\n      } else {\n        return isAtLineBoundary(root, pos) || hasSpaceBefore(root, pos) || hasSpaceAfter(root, pos);\n      }\n    };\n    var needsToBeNbspLeft = function (root, pos) {\n      if (isInPre(pos)) {\n        return false;\n      } else {\n        return isAtStartOfBlock(root, pos) || isBeforeBlock(root, pos) || isAfterBr(root, pos) || hasSpaceBefore(root, pos);\n      }\n    };\n    var leanRight = function (pos) {\n      var container = pos.container();\n      var offset = pos.offset();\n      if (isText$7(container) && offset < container.data.length) {\n        return CaretPosition(container, offset + 1);\n      } else {\n        return pos;\n      }\n    };\n    var needsToBeNbspRight = function (root, pos) {\n      if (isInPre(pos)) {\n        return false;\n      } else {\n        return isAtEndOfBlock(root, pos) || isAfterBlock(root, pos) || isBeforeBr$1(root, pos) || hasSpaceAfter(root, pos);\n      }\n    };\n    var needsToBeNbsp = function (root, pos) {\n      return needsToBeNbspLeft(root, pos) || needsToBeNbspRight(root, leanRight(pos));\n    };\n    var isNbspAt = function (text, offset) {\n      return isNbsp(text.charAt(offset));\n    };\n    var hasNbsp = function (pos) {\n      var container = pos.container();\n      return isText$7(container) && contains$2(container.data, nbsp);\n    };\n    var normalizeNbspMiddle = function (text) {\n      var chars = text.split('');\n      return map$3(chars, function (chr, i) {\n        if (isNbsp(chr) && i > 0 && i < chars.length - 1 && isContent(chars[i - 1]) && isContent(chars[i + 1])) {\n          return ' ';\n        } else {\n          return chr;\n        }\n      }).join('');\n    };\n    var normalizeNbspAtStart = function (root, node) {\n      var text = node.data;\n      var firstPos = CaretPosition(node, 0);\n      if (isNbspAt(text, 0) && !needsToBeNbsp(root, firstPos)) {\n        node.data = ' ' + text.slice(1);\n        return true;\n      } else {\n        return false;\n      }\n    };\n    var normalizeNbspInMiddleOfTextNode = function (node) {\n      var text = node.data;\n      var newText = normalizeNbspMiddle(text);\n      if (newText !== text) {\n        node.data = newText;\n        return true;\n      } else {\n        return false;\n      }\n    };\n    var normalizeNbspAtEnd = function (root, node) {\n      var text = node.data;\n      var lastPos = CaretPosition(node, text.length - 1);\n      if (isNbspAt(text, text.length - 1) && !needsToBeNbsp(root, lastPos)) {\n        node.data = text.slice(0, -1) + ' ';\n        return true;\n      } else {\n        return false;\n      }\n    };\n    var normalizeNbsps = function (root, pos) {\n      return Optional.some(pos).filter(hasNbsp).bind(function (pos) {\n        var container = pos.container();\n        var normalized = normalizeNbspAtStart(root, container) || normalizeNbspInMiddleOfTextNode(container) || normalizeNbspAtEnd(root, container);\n        return normalized ? Optional.some(pos) : Optional.none();\n      });\n    };\n    var normalizeNbspsInEditor = function (editor) {\n      var root = SugarElement.fromDom(editor.getBody());\n      if (editor.selection.isCollapsed()) {\n        normalizeNbsps(root, CaretPosition.fromRangeStart(editor.selection.getRng())).each(function (pos) {\n          editor.selection.setRng(pos.toRange());\n        });\n      }\n    };\n\n    var normalizeContent = function (content, isStartOfContent, isEndOfContent) {\n      var result = foldl(content, function (acc, c) {\n        if (isWhiteSpace(c) || isNbsp(c)) {\n          if (acc.previousCharIsSpace || acc.str === '' && isStartOfContent || acc.str.length === content.length - 1 && isEndOfContent) {\n            return {\n              previousCharIsSpace: false,\n              str: acc.str + nbsp\n            };\n          } else {\n            return {\n              previousCharIsSpace: true,\n              str: acc.str + ' '\n            };\n          }\n        } else {\n          return {\n            previousCharIsSpace: false,\n            str: acc.str + c\n          };\n        }\n      }, {\n        previousCharIsSpace: false,\n        str: ''\n      });\n      return result.str;\n    };\n    var normalize$1 = function (node, offset, count) {\n      if (count === 0) {\n        return;\n      }\n      var elm = SugarElement.fromDom(node);\n      var root = ancestor$3(elm, isBlock$2).getOr(elm);\n      var whitespace = node.data.slice(offset, offset + count);\n      var isEndOfContent = offset + count >= node.data.length && needsToBeNbspRight(root, CaretPosition(node, node.data.length));\n      var isStartOfContent = offset === 0 && needsToBeNbspLeft(root, CaretPosition(node, 0));\n      node.replaceData(offset, count, normalizeContent(whitespace, isStartOfContent, isEndOfContent));\n    };\n    var normalizeWhitespaceAfter = function (node, offset) {\n      var content = node.data.slice(offset);\n      var whitespaceCount = content.length - lTrim(content).length;\n      normalize$1(node, offset, whitespaceCount);\n    };\n    var normalizeWhitespaceBefore = function (node, offset) {\n      var content = node.data.slice(0, offset);\n      var whitespaceCount = content.length - rTrim(content).length;\n      normalize$1(node, offset - whitespaceCount, whitespaceCount);\n    };\n    var mergeTextNodes = function (prevNode, nextNode, normalizeWhitespace, mergeToPrev) {\n      if (mergeToPrev === void 0) {\n        mergeToPrev = true;\n      }\n      var whitespaceOffset = rTrim(prevNode.data).length;\n      var newNode = mergeToPrev ? prevNode : nextNode;\n      var removeNode = mergeToPrev ? nextNode : prevNode;\n      if (mergeToPrev) {\n        newNode.appendData(removeNode.data);\n      } else {\n        newNode.insertData(0, removeNode.data);\n      }\n      remove$7(SugarElement.fromDom(removeNode));\n      if (normalizeWhitespace) {\n        normalizeWhitespaceAfter(newNode, whitespaceOffset);\n      }\n      return newNode;\n    };\n\n    var needsReposition = function (pos, elm) {\n      var container = pos.container();\n      var offset = pos.offset();\n      return CaretPosition.isTextPosition(pos) === false && container === elm.parentNode && offset > CaretPosition.before(elm).offset();\n    };\n    var reposition = function (elm, pos) {\n      return needsReposition(pos, elm) ? CaretPosition(pos.container(), pos.offset() - 1) : pos;\n    };\n    var beforeOrStartOf = function (node) {\n      return isText$7(node) ? CaretPosition(node, 0) : CaretPosition.before(node);\n    };\n    var afterOrEndOf = function (node) {\n      return isText$7(node) ? CaretPosition(node, node.data.length) : CaretPosition.after(node);\n    };\n    var getPreviousSiblingCaretPosition = function (elm) {\n      if (isCaretCandidate$3(elm.previousSibling)) {\n        return Optional.some(afterOrEndOf(elm.previousSibling));\n      } else {\n        return elm.previousSibling ? lastPositionIn(elm.previousSibling) : Optional.none();\n      }\n    };\n    var getNextSiblingCaretPosition = function (elm) {\n      if (isCaretCandidate$3(elm.nextSibling)) {\n        return Optional.some(beforeOrStartOf(elm.nextSibling));\n      } else {\n        return elm.nextSibling ? firstPositionIn(elm.nextSibling) : Optional.none();\n      }\n    };\n    var findCaretPositionBackwardsFromElm = function (rootElement, elm) {\n      var startPosition = CaretPosition.before(elm.previousSibling ? elm.previousSibling : elm.parentNode);\n      return prevPosition(rootElement, startPosition).fold(function () {\n        return nextPosition(rootElement, CaretPosition.after(elm));\n      }, Optional.some);\n    };\n    var findCaretPositionForwardsFromElm = function (rootElement, elm) {\n      return nextPosition(rootElement, CaretPosition.after(elm)).fold(function () {\n        return prevPosition(rootElement, CaretPosition.before(elm));\n      }, Optional.some);\n    };\n    var findCaretPositionBackwards = function (rootElement, elm) {\n      return getPreviousSiblingCaretPosition(elm).orThunk(function () {\n        return getNextSiblingCaretPosition(elm);\n      }).orThunk(function () {\n        return findCaretPositionBackwardsFromElm(rootElement, elm);\n      });\n    };\n    var findCaretPositionForward = function (rootElement, elm) {\n      return getNextSiblingCaretPosition(elm).orThunk(function () {\n        return getPreviousSiblingCaretPosition(elm);\n      }).orThunk(function () {\n        return findCaretPositionForwardsFromElm(rootElement, elm);\n      });\n    };\n    var findCaretPosition = function (forward, rootElement, elm) {\n      return forward ? findCaretPositionForward(rootElement, elm) : findCaretPositionBackwards(rootElement, elm);\n    };\n    var findCaretPosOutsideElmAfterDelete = function (forward, rootElement, elm) {\n      return findCaretPosition(forward, rootElement, elm).map(curry(reposition, elm));\n    };\n    var setSelection$1 = function (editor, forward, pos) {\n      pos.fold(function () {\n        editor.focus();\n      }, function (pos) {\n        editor.selection.setRng(pos.toRange(), forward);\n      });\n    };\n    var eqRawNode = function (rawNode) {\n      return function (elm) {\n        return elm.dom === rawNode;\n      };\n    };\n    var isBlock = function (editor, elm) {\n      return elm && has$2(editor.schema.getBlockElements(), name(elm));\n    };\n    var paddEmptyBlock = function (elm) {\n      if (isEmpty$2(elm)) {\n        var br = SugarElement.fromHtml('<br data-mce-bogus=\"1\">');\n        empty(elm);\n        append$1(elm, br);\n        return Optional.some(CaretPosition.before(br.dom));\n      } else {\n        return Optional.none();\n      }\n    };\n    var deleteNormalized = function (elm, afterDeletePosOpt, normalizeWhitespace) {\n      var prevTextOpt = prevSibling(elm).filter(isText$8);\n      var nextTextOpt = nextSibling(elm).filter(isText$8);\n      remove$7(elm);\n      return lift3(prevTextOpt, nextTextOpt, afterDeletePosOpt, function (prev, next, pos) {\n        var prevNode = prev.dom, nextNode = next.dom;\n        var offset = prevNode.data.length;\n        mergeTextNodes(prevNode, nextNode, normalizeWhitespace);\n        return pos.container() === nextNode ? CaretPosition(prevNode, offset) : pos;\n      }).orThunk(function () {\n        if (normalizeWhitespace) {\n          prevTextOpt.each(function (elm) {\n            return normalizeWhitespaceBefore(elm.dom, elm.dom.length);\n          });\n          nextTextOpt.each(function (elm) {\n            return normalizeWhitespaceAfter(elm.dom, 0);\n          });\n        }\n        return afterDeletePosOpt;\n      });\n    };\n    var isInlineElement = function (editor, element) {\n      return has$2(editor.schema.getTextInlineElements(), name(element));\n    };\n    var deleteElement$2 = function (editor, forward, elm, moveCaret) {\n      if (moveCaret === void 0) {\n        moveCaret = true;\n      }\n      var afterDeletePos = findCaretPosOutsideElmAfterDelete(forward, editor.getBody(), elm.dom);\n      var parentBlock = ancestor$3(elm, curry(isBlock, editor), eqRawNode(editor.getBody()));\n      var normalizedAfterDeletePos = deleteNormalized(elm, afterDeletePos, isInlineElement(editor, elm));\n      if (editor.dom.isEmpty(editor.getBody())) {\n        editor.setContent('');\n        editor.selection.setCursorLocation();\n      } else {\n        parentBlock.bind(paddEmptyBlock).fold(function () {\n          if (moveCaret) {\n            setSelection$1(editor, forward, normalizedAfterDeletePos);\n          }\n        }, function (paddPos) {\n          if (moveCaret) {\n            setSelection$1(editor, forward, Optional.some(paddPos));\n          }\n        });\n      }\n    };\n\n    var isRootFromElement = function (root) {\n      return function (cur) {\n        return eq(root, cur);\n      };\n    };\n    var getTableCells = function (table) {\n      return descendants(table, 'td,th');\n    };\n    var getTableDetailsFromRange = function (rng, isRoot) {\n      var getTable = function (node) {\n        return getClosestTable(SugarElement.fromDom(node), isRoot);\n      };\n      var startTable = getTable(rng.startContainer);\n      var endTable = getTable(rng.endContainer);\n      var isStartInTable = startTable.isSome();\n      var isEndInTable = endTable.isSome();\n      var isSameTable = lift2(startTable, endTable, eq).getOr(false);\n      var isMultiTable = !isSameTable && isStartInTable && isEndInTable;\n      return {\n        startTable: startTable,\n        endTable: endTable,\n        isStartInTable: isStartInTable,\n        isEndInTable: isEndInTable,\n        isSameTable: isSameTable,\n        isMultiTable: isMultiTable\n      };\n    };\n\n    var tableCellRng = function (start, end) {\n      return {\n        start: start,\n        end: end\n      };\n    };\n    var tableSelection = function (rng, table, cells) {\n      return {\n        rng: rng,\n        table: table,\n        cells: cells\n      };\n    };\n    var deleteAction = Adt.generate([\n      {\n        singleCellTable: [\n          'rng',\n          'cell'\n        ]\n      },\n      { fullTable: ['table'] },\n      {\n        partialTable: [\n          'cells',\n          'outsideDetails'\n        ]\n      },\n      {\n        multiTable: [\n          'startTableCells',\n          'endTableCells',\n          'betweenRng'\n        ]\n      }\n    ]);\n    var getClosestCell$1 = function (container, isRoot) {\n      return closest$2(SugarElement.fromDom(container), 'td,th', isRoot);\n    };\n    var isExpandedCellRng = function (cellRng) {\n      return !eq(cellRng.start, cellRng.end);\n    };\n    var getTableFromCellRng = function (cellRng, isRoot) {\n      return getClosestTable(cellRng.start, isRoot).bind(function (startParentTable) {\n        return getClosestTable(cellRng.end, isRoot).bind(function (endParentTable) {\n          return someIf(eq(startParentTable, endParentTable), startParentTable);\n        });\n      });\n    };\n    var isSingleCellTable = function (cellRng, isRoot) {\n      return !isExpandedCellRng(cellRng) && getTableFromCellRng(cellRng, isRoot).exists(function (table) {\n        var rows = table.dom.rows;\n        return rows.length === 1 && rows[0].cells.length === 1;\n      });\n    };\n    var getCellRng = function (rng, isRoot) {\n      var startCell = getClosestCell$1(rng.startContainer, isRoot);\n      var endCell = getClosestCell$1(rng.endContainer, isRoot);\n      return lift2(startCell, endCell, tableCellRng);\n    };\n    var getCellRangeFromStartTable = function (isRoot) {\n      return function (startCell) {\n        return getClosestTable(startCell, isRoot).bind(function (table) {\n          return last$2(getTableCells(table)).map(function (endCell) {\n            return tableCellRng(startCell, endCell);\n          });\n        });\n      };\n    };\n    var getCellRangeFromEndTable = function (isRoot) {\n      return function (endCell) {\n        return getClosestTable(endCell, isRoot).bind(function (table) {\n          return head(getTableCells(table)).map(function (startCell) {\n            return tableCellRng(startCell, endCell);\n          });\n        });\n      };\n    };\n    var getTableSelectionFromCellRng = function (isRoot) {\n      return function (cellRng) {\n        return getTableFromCellRng(cellRng, isRoot).map(function (table) {\n          return tableSelection(cellRng, table, getTableCells(table));\n        });\n      };\n    };\n    var getTableSelections = function (cellRng, selectionDetails, rng, isRoot) {\n      if (rng.collapsed || !cellRng.forall(isExpandedCellRng)) {\n        return Optional.none();\n      } else if (selectionDetails.isSameTable) {\n        var sameTableSelection = cellRng.bind(getTableSelectionFromCellRng(isRoot));\n        return Optional.some({\n          start: sameTableSelection,\n          end: sameTableSelection\n        });\n      } else {\n        var startCell = getClosestCell$1(rng.startContainer, isRoot);\n        var endCell = getClosestCell$1(rng.endContainer, isRoot);\n        var startTableSelection = startCell.bind(getCellRangeFromStartTable(isRoot)).bind(getTableSelectionFromCellRng(isRoot));\n        var endTableSelection = endCell.bind(getCellRangeFromEndTable(isRoot)).bind(getTableSelectionFromCellRng(isRoot));\n        return Optional.some({\n          start: startTableSelection,\n          end: endTableSelection\n        });\n      }\n    };\n    var getCellIndex = function (cells, cell) {\n      return findIndex$2(cells, function (x) {\n        return eq(x, cell);\n      });\n    };\n    var getSelectedCells = function (tableSelection) {\n      return lift2(getCellIndex(tableSelection.cells, tableSelection.rng.start), getCellIndex(tableSelection.cells, tableSelection.rng.end), function (startIndex, endIndex) {\n        return tableSelection.cells.slice(startIndex, endIndex + 1);\n      });\n    };\n    var isSingleCellTableContentSelected = function (optCellRng, rng, isRoot) {\n      return optCellRng.exists(function (cellRng) {\n        return isSingleCellTable(cellRng, isRoot) && hasAllContentsSelected(cellRng.start, rng);\n      });\n    };\n    var unselectCells = function (rng, selectionDetails) {\n      var startTable = selectionDetails.startTable, endTable = selectionDetails.endTable;\n      var otherContentRng = rng.cloneRange();\n      startTable.each(function (table) {\n        return otherContentRng.setStartAfter(table.dom);\n      });\n      endTable.each(function (table) {\n        return otherContentRng.setEndBefore(table.dom);\n      });\n      return otherContentRng;\n    };\n    var handleSingleTable = function (cellRng, selectionDetails, rng, isRoot) {\n      return getTableSelections(cellRng, selectionDetails, rng, isRoot).bind(function (_a) {\n        var start = _a.start, end = _a.end;\n        return start.or(end);\n      }).bind(function (tableSelection) {\n        var isSameTable = selectionDetails.isSameTable;\n        var selectedCells = getSelectedCells(tableSelection).getOr([]);\n        if (isSameTable && tableSelection.cells.length === selectedCells.length) {\n          return Optional.some(deleteAction.fullTable(tableSelection.table));\n        } else if (selectedCells.length > 0) {\n          if (isSameTable) {\n            return Optional.some(deleteAction.partialTable(selectedCells, Optional.none()));\n          } else {\n            var otherContentRng = unselectCells(rng, selectionDetails);\n            return Optional.some(deleteAction.partialTable(selectedCells, Optional.some(__assign(__assign({}, selectionDetails), { rng: otherContentRng }))));\n          }\n        } else {\n          return Optional.none();\n        }\n      });\n    };\n    var handleMultiTable = function (cellRng, selectionDetails, rng, isRoot) {\n      return getTableSelections(cellRng, selectionDetails, rng, isRoot).bind(function (_a) {\n        var start = _a.start, end = _a.end;\n        var startTableSelectedCells = start.bind(getSelectedCells).getOr([]);\n        var endTableSelectedCells = end.bind(getSelectedCells).getOr([]);\n        if (startTableSelectedCells.length > 0 && endTableSelectedCells.length > 0) {\n          var otherContentRng = unselectCells(rng, selectionDetails);\n          return Optional.some(deleteAction.multiTable(startTableSelectedCells, endTableSelectedCells, otherContentRng));\n        } else {\n          return Optional.none();\n        }\n      });\n    };\n    var getActionFromRange = function (root, rng) {\n      var isRoot = isRootFromElement(root);\n      var optCellRng = getCellRng(rng, isRoot);\n      var selectionDetails = getTableDetailsFromRange(rng, isRoot);\n      if (isSingleCellTableContentSelected(optCellRng, rng, isRoot)) {\n        return optCellRng.map(function (cellRng) {\n          return deleteAction.singleCellTable(rng, cellRng.start);\n        });\n      } else if (selectionDetails.isMultiTable) {\n        return handleMultiTable(optCellRng, selectionDetails, rng, isRoot);\n      } else {\n        return handleSingleTable(optCellRng, selectionDetails, rng, isRoot);\n      }\n    };\n\n    var freefallRtl = function (root) {\n      var child = isComment$1(root) ? prevSibling(root) : lastChild(root);\n      return child.bind(freefallRtl).orThunk(function () {\n        return Optional.some(root);\n      });\n    };\n    var cleanCells = function (cells) {\n      return each$k(cells, function (cell) {\n        remove$6(cell, 'contenteditable');\n        fillWithPaddingBr(cell);\n      });\n    };\n    var getOutsideBlock = function (editor, container) {\n      return Optional.from(editor.dom.getParent(container, editor.dom.isBlock)).map(SugarElement.fromDom);\n    };\n    var handleEmptyBlock = function (editor, startInTable, emptyBlock) {\n      emptyBlock.each(function (block) {\n        if (startInTable) {\n          remove$7(block);\n        } else {\n          fillWithPaddingBr(block);\n          editor.selection.setCursorLocation(block.dom, 0);\n        }\n      });\n    };\n    var deleteContentInsideCell = function (editor, cell, rng, isFirstCellInSelection) {\n      var insideTableRng = rng.cloneRange();\n      if (isFirstCellInSelection) {\n        insideTableRng.setStart(rng.startContainer, rng.startOffset);\n        insideTableRng.setEndAfter(cell.dom.lastChild);\n      } else {\n        insideTableRng.setStartBefore(cell.dom.firstChild);\n        insideTableRng.setEnd(rng.endContainer, rng.endOffset);\n      }\n      deleteCellContents(editor, insideTableRng, cell, false);\n    };\n    var collapseAndRestoreCellSelection = function (editor) {\n      var selectedCells = getCellsFromEditor(editor);\n      var selectedNode = SugarElement.fromDom(editor.selection.getNode());\n      if (isTableCell$5(selectedNode.dom) && isEmpty$2(selectedNode)) {\n        editor.selection.setCursorLocation(selectedNode.dom, 0);\n      } else {\n        editor.selection.collapse(true);\n      }\n      if (selectedCells.length > 1 && exists(selectedCells, function (cell) {\n          return eq(cell, selectedNode);\n        })) {\n        set$1(selectedNode, 'data-mce-selected', '1');\n      }\n    };\n    var emptySingleTableCells = function (editor, cells, outsideDetails) {\n      var editorRng = editor.selection.getRng();\n      var cellsToClean = outsideDetails.bind(function (_a) {\n        var rng = _a.rng, isStartInTable = _a.isStartInTable;\n        var outsideBlock = getOutsideBlock(editor, isStartInTable ? rng.endContainer : rng.startContainer);\n        rng.deleteContents();\n        handleEmptyBlock(editor, isStartInTable, outsideBlock.filter(isEmpty$2));\n        var endPointCell = isStartInTable ? cells[0] : cells[cells.length - 1];\n        deleteContentInsideCell(editor, endPointCell, editorRng, isStartInTable);\n        if (!isEmpty$2(endPointCell)) {\n          return Optional.some(isStartInTable ? cells.slice(1) : cells.slice(0, -1));\n        } else {\n          return Optional.none();\n        }\n      }).getOr(cells);\n      cleanCells(cellsToClean);\n      collapseAndRestoreCellSelection(editor);\n      return true;\n    };\n    var emptyMultiTableCells = function (editor, startTableCells, endTableCells, betweenRng) {\n      var rng = editor.selection.getRng();\n      var startCell = startTableCells[0];\n      var endCell = endTableCells[endTableCells.length - 1];\n      deleteContentInsideCell(editor, startCell, rng, true);\n      deleteContentInsideCell(editor, endCell, rng, false);\n      var startTableCellsToClean = isEmpty$2(startCell) ? startTableCells : startTableCells.slice(1);\n      var endTableCellsToClean = isEmpty$2(endCell) ? endTableCells : endTableCells.slice(0, -1);\n      cleanCells(startTableCellsToClean.concat(endTableCellsToClean));\n      betweenRng.deleteContents();\n      collapseAndRestoreCellSelection(editor);\n      return true;\n    };\n    var deleteCellContents = function (editor, rng, cell, moveSelection) {\n      if (moveSelection === void 0) {\n        moveSelection = true;\n      }\n      rng.deleteContents();\n      var lastNode = freefallRtl(cell).getOr(cell);\n      var lastBlock = SugarElement.fromDom(editor.dom.getParent(lastNode.dom, editor.dom.isBlock));\n      if (isEmpty$2(lastBlock)) {\n        fillWithPaddingBr(lastBlock);\n        if (moveSelection) {\n          editor.selection.setCursorLocation(lastBlock.dom, 0);\n        }\n      }\n      if (!eq(cell, lastBlock)) {\n        var additionalCleanupNodes = is$1(parent(lastBlock), cell) ? [] : siblings(lastBlock);\n        each$k(additionalCleanupNodes.concat(children(cell)), function (node) {\n          if (!eq(node, lastBlock) && !contains$1(node, lastBlock) && isEmpty$2(node)) {\n            remove$7(node);\n          }\n        });\n      }\n      return true;\n    };\n    var deleteTableElement = function (editor, table) {\n      deleteElement$2(editor, false, table);\n      return true;\n    };\n    var deleteCellRange = function (editor, rootElm, rng) {\n      return getActionFromRange(rootElm, rng).map(function (action) {\n        return action.fold(curry(deleteCellContents, editor), curry(deleteTableElement, editor), curry(emptySingleTableCells, editor), curry(emptyMultiTableCells, editor));\n      });\n    };\n    var deleteCaptionRange = function (editor, caption) {\n      return emptyElement(editor, caption);\n    };\n    var deleteTableRange = function (editor, rootElm, rng, startElm) {\n      return getParentCaption(rootElm, startElm).fold(function () {\n        return deleteCellRange(editor, rootElm, rng);\n      }, function (caption) {\n        return deleteCaptionRange(editor, caption);\n      }).getOr(false);\n    };\n    var deleteRange$2 = function (editor, startElm, selectedCells) {\n      var rootNode = SugarElement.fromDom(editor.getBody());\n      var rng = editor.selection.getRng();\n      return selectedCells.length !== 0 ? emptySingleTableCells(editor, selectedCells, Optional.none()) : deleteTableRange(editor, rootNode, rng, startElm);\n    };\n    var getParentCell = function (rootElm, elm) {\n      return find$3(parentsAndSelf(elm, rootElm), isTableCell$4);\n    };\n    var getParentCaption = function (rootElm, elm) {\n      return find$3(parentsAndSelf(elm, rootElm), isTag('caption'));\n    };\n    var deleteBetweenCells = function (editor, rootElm, forward, fromCell, from) {\n      return navigate(forward, editor.getBody(), from).bind(function (to) {\n        return getParentCell(rootElm, SugarElement.fromDom(to.getNode())).map(function (toCell) {\n          return eq(toCell, fromCell) === false;\n        });\n      });\n    };\n    var emptyElement = function (editor, elm) {\n      fillWithPaddingBr(elm);\n      editor.selection.setCursorLocation(elm.dom, 0);\n      return Optional.some(true);\n    };\n    var isDeleteOfLastCharPos = function (fromCaption, forward, from, to) {\n      return firstPositionIn(fromCaption.dom).bind(function (first) {\n        return lastPositionIn(fromCaption.dom).map(function (last) {\n          return forward ? from.isEqual(first) && to.isEqual(last) : from.isEqual(last) && to.isEqual(first);\n        });\n      }).getOr(true);\n    };\n    var emptyCaretCaption = function (editor, elm) {\n      return emptyElement(editor, elm);\n    };\n    var validateCaretCaption = function (rootElm, fromCaption, to) {\n      return getParentCaption(rootElm, SugarElement.fromDom(to.getNode())).map(function (toCaption) {\n        return eq(toCaption, fromCaption) === false;\n      });\n    };\n    var deleteCaretInsideCaption = function (editor, rootElm, forward, fromCaption, from) {\n      return navigate(forward, editor.getBody(), from).bind(function (to) {\n        return isDeleteOfLastCharPos(fromCaption, forward, from, to) ? emptyCaretCaption(editor, fromCaption) : validateCaretCaption(rootElm, fromCaption, to);\n      }).or(Optional.some(true));\n    };\n    var deleteCaretCells = function (editor, forward, rootElm, startElm) {\n      var from = CaretPosition.fromRangeStart(editor.selection.getRng());\n      return getParentCell(rootElm, startElm).bind(function (fromCell) {\n        return isEmpty$2(fromCell) ? emptyElement(editor, fromCell) : deleteBetweenCells(editor, rootElm, forward, fromCell, from);\n      }).getOr(false);\n    };\n    var deleteCaretCaption = function (editor, forward, rootElm, fromCaption) {\n      var from = CaretPosition.fromRangeStart(editor.selection.getRng());\n      return isEmpty$2(fromCaption) ? emptyElement(editor, fromCaption) : deleteCaretInsideCaption(editor, rootElm, forward, fromCaption, from);\n    };\n    var isNearTable = function (forward, pos) {\n      return forward ? isBeforeTable(pos) : isAfterTable(pos);\n    };\n    var isBeforeOrAfterTable = function (editor, forward) {\n      var fromPos = CaretPosition.fromRangeStart(editor.selection.getRng());\n      return isNearTable(forward, fromPos) || fromPosition(forward, editor.getBody(), fromPos).exists(function (pos) {\n        return isNearTable(forward, pos);\n      });\n    };\n    var deleteCaret$3 = function (editor, forward, startElm) {\n      var rootElm = SugarElement.fromDom(editor.getBody());\n      return getParentCaption(rootElm, startElm).fold(function () {\n        return deleteCaretCells(editor, forward, rootElm, startElm) || isBeforeOrAfterTable(editor, forward);\n      }, function (fromCaption) {\n        return deleteCaretCaption(editor, forward, rootElm, fromCaption).getOr(false);\n      });\n    };\n    var backspaceDelete$9 = function (editor, forward) {\n      var startElm = SugarElement.fromDom(editor.selection.getStart(true));\n      var cells = getCellsFromEditor(editor);\n      return editor.selection.isCollapsed() && cells.length === 0 ? deleteCaret$3(editor, forward, startElm) : deleteRange$2(editor, startElm, cells);\n    };\n\n    var createRange = function (sc, so, ec, eo) {\n      var rng = document.createRange();\n      rng.setStart(sc, so);\n      rng.setEnd(ec, eo);\n      return rng;\n    };\n    var normalizeBlockSelectionRange = function (rng) {\n      var startPos = CaretPosition.fromRangeStart(rng);\n      var endPos = CaretPosition.fromRangeEnd(rng);\n      var rootNode = rng.commonAncestorContainer;\n      return fromPosition(false, rootNode, endPos).map(function (newEndPos) {\n        if (!isInSameBlock(startPos, endPos, rootNode) && isInSameBlock(startPos, newEndPos, rootNode)) {\n          return createRange(startPos.container(), startPos.offset(), newEndPos.container(), newEndPos.offset());\n        } else {\n          return rng;\n        }\n      }).getOr(rng);\n    };\n    var normalize = function (rng) {\n      return rng.collapsed ? rng : normalizeBlockSelectionRange(rng);\n    };\n\n    var hasOnlyOneChild$1 = function (node) {\n      return node.firstChild && node.firstChild === node.lastChild;\n    };\n    var isPaddingNode = function (node) {\n      return node.name === 'br' || node.value === nbsp;\n    };\n    var isPaddedEmptyBlock = function (schema, node) {\n      var blockElements = schema.getBlockElements();\n      return blockElements[node.name] && hasOnlyOneChild$1(node) && isPaddingNode(node.firstChild);\n    };\n    var isEmptyFragmentElement = function (schema, node) {\n      var nonEmptyElements = schema.getNonEmptyElements();\n      return node && (node.isEmpty(nonEmptyElements) || isPaddedEmptyBlock(schema, node));\n    };\n    var isListFragment = function (schema, fragment) {\n      var firstChild = fragment.firstChild;\n      var lastChild = fragment.lastChild;\n      if (firstChild && firstChild.name === 'meta') {\n        firstChild = firstChild.next;\n      }\n      if (lastChild && lastChild.attr('id') === 'mce_marker') {\n        lastChild = lastChild.prev;\n      }\n      if (isEmptyFragmentElement(schema, lastChild)) {\n        lastChild = lastChild.prev;\n      }\n      if (!firstChild || firstChild !== lastChild) {\n        return false;\n      }\n      return firstChild.name === 'ul' || firstChild.name === 'ol';\n    };\n    var cleanupDomFragment = function (domFragment) {\n      var firstChild = domFragment.firstChild;\n      var lastChild = domFragment.lastChild;\n      if (firstChild && firstChild.nodeName === 'META') {\n        firstChild.parentNode.removeChild(firstChild);\n      }\n      if (lastChild && lastChild.id === 'mce_marker') {\n        lastChild.parentNode.removeChild(lastChild);\n      }\n      return domFragment;\n    };\n    var toDomFragment = function (dom, serializer, fragment) {\n      var html = serializer.serialize(fragment);\n      var domFragment = dom.createFragment(html);\n      return cleanupDomFragment(domFragment);\n    };\n    var listItems = function (elm) {\n      return filter$4(elm.childNodes, function (child) {\n        return child.nodeName === 'LI';\n      });\n    };\n    var isPadding = function (node) {\n      return node.data === nbsp || isBr$5(node);\n    };\n    var isListItemPadded = function (node) {\n      return node && node.firstChild && node.firstChild === node.lastChild && isPadding(node.firstChild);\n    };\n    var isEmptyOrPadded = function (elm) {\n      return !elm.firstChild || isListItemPadded(elm);\n    };\n    var trimListItems = function (elms) {\n      return elms.length > 0 && isEmptyOrPadded(elms[elms.length - 1]) ? elms.slice(0, -1) : elms;\n    };\n    var getParentLi = function (dom, node) {\n      var parentBlock = dom.getParent(node, dom.isBlock);\n      return parentBlock && parentBlock.nodeName === 'LI' ? parentBlock : null;\n    };\n    var isParentBlockLi = function (dom, node) {\n      return !!getParentLi(dom, node);\n    };\n    var getSplit = function (parentNode, rng) {\n      var beforeRng = rng.cloneRange();\n      var afterRng = rng.cloneRange();\n      beforeRng.setStartBefore(parentNode);\n      afterRng.setEndAfter(parentNode);\n      return [\n        beforeRng.cloneContents(),\n        afterRng.cloneContents()\n      ];\n    };\n    var findFirstIn = function (node, rootNode) {\n      var caretPos = CaretPosition.before(node);\n      var caretWalker = CaretWalker(rootNode);\n      var newCaretPos = caretWalker.next(caretPos);\n      return newCaretPos ? newCaretPos.toRange() : null;\n    };\n    var findLastOf = function (node, rootNode) {\n      var caretPos = CaretPosition.after(node);\n      var caretWalker = CaretWalker(rootNode);\n      var newCaretPos = caretWalker.prev(caretPos);\n      return newCaretPos ? newCaretPos.toRange() : null;\n    };\n    var insertMiddle = function (target, elms, rootNode, rng) {\n      var parts = getSplit(target, rng);\n      var parentElm = target.parentNode;\n      parentElm.insertBefore(parts[0], target);\n      Tools.each(elms, function (li) {\n        parentElm.insertBefore(li, target);\n      });\n      parentElm.insertBefore(parts[1], target);\n      parentElm.removeChild(target);\n      return findLastOf(elms[elms.length - 1], rootNode);\n    };\n    var insertBefore$1 = function (target, elms, rootNode) {\n      var parentElm = target.parentNode;\n      Tools.each(elms, function (elm) {\n        parentElm.insertBefore(elm, target);\n      });\n      return findFirstIn(target, rootNode);\n    };\n    var insertAfter$1 = function (target, elms, rootNode, dom) {\n      dom.insertAfter(elms.reverse(), target);\n      return findLastOf(elms[0], rootNode);\n    };\n    var insertAtCaret$1 = function (serializer, dom, rng, fragment) {\n      var domFragment = toDomFragment(dom, serializer, fragment);\n      var liTarget = getParentLi(dom, rng.startContainer);\n      var liElms = trimListItems(listItems(domFragment.firstChild));\n      var BEGINNING = 1, END = 2;\n      var rootNode = dom.getRoot();\n      var isAt = function (location) {\n        var caretPos = CaretPosition.fromRangeStart(rng);\n        var caretWalker = CaretWalker(dom.getRoot());\n        var newPos = location === BEGINNING ? caretWalker.prev(caretPos) : caretWalker.next(caretPos);\n        return newPos ? getParentLi(dom, newPos.getNode()) !== liTarget : true;\n      };\n      if (isAt(BEGINNING)) {\n        return insertBefore$1(liTarget, liElms, rootNode);\n      } else if (isAt(END)) {\n        return insertAfter$1(liTarget, liElms, rootNode, dom);\n      }\n      return insertMiddle(liTarget, liElms, rootNode, rng);\n    };\n\n    var trimOrPadLeftRight = function (dom, rng, html) {\n      var root = SugarElement.fromDom(dom.getRoot());\n      if (needsToBeNbspLeft(root, CaretPosition.fromRangeStart(rng))) {\n        html = html.replace(/^ /, '&nbsp;');\n      } else {\n        html = html.replace(/^&nbsp;/, ' ');\n      }\n      if (needsToBeNbspRight(root, CaretPosition.fromRangeEnd(rng))) {\n        html = html.replace(/(&nbsp;| )(<br( \\/)>)?$/, '&nbsp;');\n      } else {\n        html = html.replace(/&nbsp;(<br( \\/)?>)?$/, ' ');\n      }\n      return html;\n    };\n\n    var isTableCell$1 = isTableCell$5;\n    var isTableCellContentSelected = function (dom, rng, cell) {\n      if (cell !== null) {\n        var endCell = dom.getParent(rng.endContainer, isTableCell$1);\n        return cell === endCell && hasAllContentsSelected(SugarElement.fromDom(cell), rng);\n      } else {\n        return false;\n      }\n    };\n    var validInsertion = function (editor, value, parentNode) {\n      if (parentNode.getAttribute('data-mce-bogus') === 'all') {\n        parentNode.parentNode.insertBefore(editor.dom.createFragment(value), parentNode);\n      } else {\n        var node = parentNode.firstChild;\n        var node2 = parentNode.lastChild;\n        if (!node || node === node2 && node.nodeName === 'BR') {\n          editor.dom.setHTML(parentNode, value);\n        } else {\n          editor.selection.setContent(value);\n        }\n      }\n    };\n    var trimBrsFromTableCell = function (dom, elm) {\n      Optional.from(dom.getParent(elm, 'td,th')).map(SugarElement.fromDom).each(trimBlockTrailingBr);\n    };\n    var reduceInlineTextElements = function (editor, merge) {\n      var textInlineElements = editor.schema.getTextInlineElements();\n      var dom = editor.dom;\n      if (merge) {\n        var root_1 = editor.getBody();\n        var elementUtils_1 = ElementUtils(dom);\n        Tools.each(dom.select('*[data-mce-fragment]'), function (node) {\n          var isInline = isNonNullable(textInlineElements[node.nodeName.toLowerCase()]);\n          if (isInline && hasInheritableStyles(dom, node)) {\n            for (var parentNode = node.parentNode; isNonNullable(parentNode) && parentNode !== root_1; parentNode = parentNode.parentNode) {\n              var styleConflict = hasStyleConflict(dom, node, parentNode);\n              if (styleConflict) {\n                break;\n              }\n              if (elementUtils_1.compare(parentNode, node)) {\n                dom.remove(node, true);\n                break;\n              }\n            }\n          }\n        });\n      }\n    };\n    var markFragmentElements = function (fragment) {\n      var node = fragment;\n      while (node = node.walk()) {\n        if (node.type === 1) {\n          node.attr('data-mce-fragment', '1');\n        }\n      }\n    };\n    var unmarkFragmentElements = function (elm) {\n      Tools.each(elm.getElementsByTagName('*'), function (elm) {\n        elm.removeAttribute('data-mce-fragment');\n      });\n    };\n    var isPartOfFragment = function (node) {\n      return !!node.getAttribute('data-mce-fragment');\n    };\n    var canHaveChildren = function (editor, node) {\n      return node && !editor.schema.getShortEndedElements()[node.nodeName];\n    };\n    var moveSelectionToMarker = function (editor, marker) {\n      var nextRng;\n      var dom = editor.dom;\n      var selection = editor.selection;\n      if (!marker) {\n        return;\n      }\n      selection.scrollIntoView(marker);\n      var parentEditableElm = getContentEditableRoot$1(editor.getBody(), marker);\n      if (dom.getContentEditable(parentEditableElm) === 'false') {\n        dom.remove(marker);\n        selection.select(parentEditableElm);\n        return;\n      }\n      var rng = dom.createRng();\n      var node = marker.previousSibling;\n      if (isText$7(node)) {\n        rng.setStart(node, node.nodeValue.length);\n        if (!Env.ie) {\n          var node2 = marker.nextSibling;\n          if (isText$7(node2)) {\n            node.appendData(node2.data);\n            node2.parentNode.removeChild(node2);\n          }\n        }\n      } else {\n        rng.setStartBefore(marker);\n        rng.setEndBefore(marker);\n      }\n      var findNextCaretRng = function (rng) {\n        var caretPos = CaretPosition.fromRangeStart(rng);\n        var caretWalker = CaretWalker(editor.getBody());\n        caretPos = caretWalker.next(caretPos);\n        if (caretPos) {\n          return caretPos.toRange();\n        }\n      };\n      var parentBlock = dom.getParent(marker, dom.isBlock);\n      dom.remove(marker);\n      if (parentBlock && dom.isEmpty(parentBlock)) {\n        editor.$(parentBlock).empty();\n        rng.setStart(parentBlock, 0);\n        rng.setEnd(parentBlock, 0);\n        if (!isTableCell$1(parentBlock) && !isPartOfFragment(parentBlock) && (nextRng = findNextCaretRng(rng))) {\n          rng = nextRng;\n          dom.remove(parentBlock);\n        } else {\n          dom.add(parentBlock, dom.create('br', { 'data-mce-bogus': '1' }));\n        }\n      }\n      selection.setRng(rng);\n    };\n    var deleteSelectedContent = function (editor) {\n      var dom = editor.dom;\n      var rng = normalize(editor.selection.getRng());\n      editor.selection.setRng(rng);\n      var startCell = dom.getParent(rng.startContainer, isTableCell$1);\n      if (isTableCellContentSelected(dom, rng, startCell)) {\n        deleteCellContents(editor, rng, SugarElement.fromDom(startCell));\n      } else {\n        editor.getDoc().execCommand('Delete', false, null);\n      }\n    };\n    var insertHtmlAtCaret = function (editor, value, details) {\n      var parentNode;\n      var rng, node;\n      var selection = editor.selection;\n      var dom = editor.dom;\n      if (/^ | $/.test(value)) {\n        value = trimOrPadLeftRight(dom, selection.getRng(), value);\n      }\n      var parser = editor.parser;\n      var merge = details.merge;\n      var serializer = HtmlSerializer({ validate: shouldValidate(editor) }, editor.schema);\n      var bookmarkHtml = '<span id=\"mce_marker\" data-mce-type=\"bookmark\">&#xFEFF;</span>';\n      var args = editor.fire('BeforeSetContent', {\n        content: value,\n        format: 'html',\n        selection: true,\n        paste: details.paste\n      });\n      if (args.isDefaultPrevented()) {\n        editor.fire('SetContent', {\n          content: args.content,\n          format: 'html',\n          selection: true,\n          paste: details.paste\n        });\n        return;\n      }\n      value = args.content;\n      if (!details.preserve_zwsp) {\n        value = trim$3(value);\n      }\n      if (value.indexOf('{$caret}') === -1) {\n        value += '{$caret}';\n      }\n      value = value.replace(/\\{\\$caret\\}/, bookmarkHtml);\n      rng = selection.getRng();\n      var caretElement = rng.startContainer || (rng.parentElement ? rng.parentElement() : null);\n      var body = editor.getBody();\n      if (caretElement === body && selection.isCollapsed()) {\n        if (dom.isBlock(body.firstChild) && canHaveChildren(editor, body.firstChild) && dom.isEmpty(body.firstChild)) {\n          rng = dom.createRng();\n          rng.setStart(body.firstChild, 0);\n          rng.setEnd(body.firstChild, 0);\n          selection.setRng(rng);\n        }\n      }\n      if (!selection.isCollapsed()) {\n        deleteSelectedContent(editor);\n      }\n      parentNode = selection.getNode();\n      var parserArgs = {\n        context: parentNode.nodeName.toLowerCase(),\n        data: details.data,\n        insert: true\n      };\n      var fragment = parser.parse(value, parserArgs);\n      if (details.paste === true && isListFragment(editor.schema, fragment) && isParentBlockLi(dom, parentNode)) {\n        rng = insertAtCaret$1(serializer, dom, selection.getRng(), fragment);\n        selection.setRng(rng);\n        editor.fire('SetContent', args);\n        return;\n      }\n      markFragmentElements(fragment);\n      node = fragment.lastChild;\n      if (node.attr('id') === 'mce_marker') {\n        var marker = node;\n        for (node = node.prev; node; node = node.walk(true)) {\n          if (node.type === 3 || !dom.isBlock(node.name)) {\n            if (editor.schema.isValidChild(node.parent.name, 'span')) {\n              node.parent.insert(marker, node, node.name === 'br');\n            }\n            break;\n          }\n        }\n      }\n      editor._selectionOverrides.showBlockCaretContainer(parentNode);\n      if (!parserArgs.invalid) {\n        value = serializer.serialize(fragment);\n        validInsertion(editor, value, parentNode);\n      } else {\n        editor.selection.setContent(bookmarkHtml);\n        parentNode = selection.getNode();\n        var rootNode = editor.getBody();\n        if (parentNode.nodeType === 9) {\n          parentNode = node = rootNode;\n        } else {\n          node = parentNode;\n        }\n        while (node !== rootNode) {\n          parentNode = node;\n          node = node.parentNode;\n        }\n        value = parentNode === rootNode ? rootNode.innerHTML : dom.getOuterHTML(parentNode);\n        value = serializer.serialize(parser.parse(value.replace(/<span (id=\"mce_marker\"|id=mce_marker).+?<\\/span>/i, function () {\n          return serializer.serialize(fragment);\n        })));\n        if (parentNode === rootNode) {\n          dom.setHTML(rootNode, value);\n        } else {\n          dom.setOuterHTML(parentNode, value);\n        }\n      }\n      reduceInlineTextElements(editor, merge);\n      moveSelectionToMarker(editor, dom.get('mce_marker'));\n      unmarkFragmentElements(editor.getBody());\n      trimBrsFromTableCell(dom, selection.getStart());\n      editor.fire('SetContent', args);\n      editor.addVisual();\n    };\n\n    var traverse = function (node, fn) {\n      fn(node);\n      if (node.firstChild) {\n        traverse(node.firstChild, fn);\n      }\n      if (node.next) {\n        traverse(node.next, fn);\n      }\n    };\n    var findMatchingNodes = function (nodeFilters, attributeFilters, node) {\n      var nodeMatches = {};\n      var attrMatches = {};\n      var matches = [];\n      if (node.firstChild) {\n        traverse(node.firstChild, function (node) {\n          each$k(nodeFilters, function (filter) {\n            if (filter.name === node.name) {\n              if (nodeMatches[filter.name]) {\n                nodeMatches[filter.name].nodes.push(node);\n              } else {\n                nodeMatches[filter.name] = {\n                  filter: filter,\n                  nodes: [node]\n                };\n              }\n            }\n          });\n          each$k(attributeFilters, function (filter) {\n            if (typeof node.attr(filter.name) === 'string') {\n              if (attrMatches[filter.name]) {\n                attrMatches[filter.name].nodes.push(node);\n              } else {\n                attrMatches[filter.name] = {\n                  filter: filter,\n                  nodes: [node]\n                };\n              }\n            }\n          });\n        });\n      }\n      for (var name_1 in nodeMatches) {\n        if (has$2(nodeMatches, name_1)) {\n          matches.push(nodeMatches[name_1]);\n        }\n      }\n      for (var name_2 in attrMatches) {\n        if (has$2(attrMatches, name_2)) {\n          matches.push(attrMatches[name_2]);\n        }\n      }\n      return matches;\n    };\n    var filter$1 = function (nodeFilters, attributeFilters, node) {\n      var matches = findMatchingNodes(nodeFilters, attributeFilters, node);\n      each$k(matches, function (match) {\n        each$k(match.filter.callbacks, function (callback) {\n          callback(match.nodes, match.filter.name, {});\n        });\n      });\n    };\n\n    var defaultFormat$1 = 'html';\n    var isTreeNode = function (content) {\n      return content instanceof AstNode;\n    };\n    var moveSelection = function (editor) {\n      if (hasFocus(editor)) {\n        firstPositionIn(editor.getBody()).each(function (pos) {\n          var node = pos.getNode();\n          var caretPos = isTable$3(node) ? firstPositionIn(node).getOr(pos) : pos;\n          editor.selection.setRng(caretPos.toRange());\n        });\n      }\n    };\n    var setEditorHtml = function (editor, html, noSelection) {\n      editor.dom.setHTML(editor.getBody(), html);\n      if (noSelection !== true) {\n        moveSelection(editor);\n      }\n    };\n    var setContentString = function (editor, body, content, args) {\n      content = trim$3(content);\n      if (content.length === 0 || /^\\s+$/.test(content)) {\n        var padd = '<br data-mce-bogus=\"1\">';\n        if (body.nodeName === 'TABLE') {\n          content = '<tr><td>' + padd + '</td></tr>';\n        } else if (/^(UL|OL)$/.test(body.nodeName)) {\n          content = '<li>' + padd + '</li>';\n        }\n        var forcedRootBlockName = getForcedRootBlock(editor);\n        if (forcedRootBlockName && editor.schema.isValidChild(body.nodeName.toLowerCase(), forcedRootBlockName.toLowerCase())) {\n          content = padd;\n          content = editor.dom.createHTML(forcedRootBlockName, getForcedRootBlockAttrs(editor), content);\n        } else if (!content) {\n          content = '<br data-mce-bogus=\"1\">';\n        }\n        setEditorHtml(editor, content, args.no_selection);\n        editor.fire('SetContent', args);\n      } else {\n        if (args.format !== 'raw') {\n          content = HtmlSerializer({ validate: editor.validate }, editor.schema).serialize(editor.parser.parse(content, {\n            isRootContent: true,\n            insert: true\n          }));\n        }\n        args.content = isWsPreserveElement(SugarElement.fromDom(body)) ? content : Tools.trim(content);\n        setEditorHtml(editor, args.content, args.no_selection);\n        if (!args.no_events) {\n          editor.fire('SetContent', args);\n        }\n      }\n      return args.content;\n    };\n    var setContentTree = function (editor, body, content, args) {\n      filter$1(editor.parser.getNodeFilters(), editor.parser.getAttributeFilters(), content);\n      var html = HtmlSerializer({ validate: editor.validate }, editor.schema).serialize(content);\n      args.content = trim$3(isWsPreserveElement(SugarElement.fromDom(body)) ? html : Tools.trim(html));\n      setEditorHtml(editor, args.content, args.no_selection);\n      if (!args.no_events) {\n        editor.fire('SetContent', args);\n      }\n      return content;\n    };\n    var setupArgs$2 = function (args, content) {\n      return __assign(__assign({ format: defaultFormat$1 }, args), {\n        set: true,\n        content: isTreeNode(content) ? '' : content\n      });\n    };\n    var setContentInternal = function (editor, content, args) {\n      var defaultedArgs = setupArgs$2(args, content);\n      var updatedArgs = args.no_events ? defaultedArgs : editor.fire('BeforeSetContent', defaultedArgs);\n      if (!isTreeNode(content)) {\n        content = updatedArgs.content;\n      }\n      return Optional.from(editor.getBody()).fold(constant(content), function (body) {\n        return isTreeNode(content) ? setContentTree(editor, body, content, updatedArgs) : setContentString(editor, body, content, updatedArgs);\n      });\n    };\n\n    var sibling = function (scope, predicate) {\n      return sibling$2(scope, predicate).isSome();\n    };\n\n    var ensureIsRoot = function (isRoot) {\n      return isFunction(isRoot) ? isRoot : never;\n    };\n    var ancestor = function (scope, transform, isRoot) {\n      var element = scope.dom;\n      var stop = ensureIsRoot(isRoot);\n      while (element.parentNode) {\n        element = element.parentNode;\n        var el = SugarElement.fromDom(element);\n        var transformed = transform(el);\n        if (transformed.isSome()) {\n          return transformed;\n        } else if (stop(el)) {\n          break;\n        }\n      }\n      return Optional.none();\n    };\n    var closest$1 = function (scope, transform, isRoot) {\n      var current = transform(scope);\n      var stop = ensureIsRoot(isRoot);\n      return current.orThunk(function () {\n        return stop(scope) ? Optional.none() : ancestor(scope, transform, stop);\n      });\n    };\n\n    var isEq$3 = isEq$5;\n    var matchesUnInheritedFormatSelector = function (ed, node, name) {\n      var formatList = ed.formatter.get(name);\n      if (formatList) {\n        for (var i = 0; i < formatList.length; i++) {\n          var format = formatList[i];\n          if (isSelectorFormat(format) && format.inherit === false && ed.dom.is(node, format.selector)) {\n            return true;\n          }\n        }\n      }\n      return false;\n    };\n    var matchParents = function (editor, node, name, vars, similar) {\n      var root = editor.dom.getRoot();\n      if (node === root) {\n        return false;\n      }\n      node = editor.dom.getParent(node, function (node) {\n        if (matchesUnInheritedFormatSelector(editor, node, name)) {\n          return true;\n        }\n        return node.parentNode === root || !!matchNode(editor, node, name, vars, true);\n      });\n      return !!matchNode(editor, node, name, vars, similar);\n    };\n    var matchName$1 = function (dom, node, format) {\n      if (isEq$3(node, format.inline)) {\n        return true;\n      }\n      if (isEq$3(node, format.block)) {\n        return true;\n      }\n      if (format.selector) {\n        return node.nodeType === 1 && dom.is(node, format.selector);\n      }\n    };\n    var matchItems = function (dom, node, format, itemName, similar, vars) {\n      var items = format[itemName];\n      if (isFunction(format.onmatch)) {\n        return format.onmatch(node, format, itemName);\n      }\n      if (items) {\n        if (isUndefined(items.length)) {\n          for (var key in items) {\n            if (has$2(items, key)) {\n              var value = itemName === 'attributes' ? dom.getAttrib(node, key) : getStyle(dom, node, key);\n              var expectedValue = replaceVars(items[key], vars);\n              var isEmptyValue = isNullable(value) || isEmpty$3(value);\n              if (isEmptyValue && isNullable(expectedValue)) {\n                continue;\n              }\n              if (similar && isEmptyValue && !format.exact) {\n                return false;\n              }\n              if ((!similar || format.exact) && !isEq$3(value, normalizeStyleValue(dom, expectedValue, key))) {\n                return false;\n              }\n            }\n          }\n        } else {\n          for (var i = 0; i < items.length; i++) {\n            if (itemName === 'attributes' ? dom.getAttrib(node, items[i]) : getStyle(dom, node, items[i])) {\n              return true;\n            }\n          }\n        }\n      }\n      return true;\n    };\n    var matchNode = function (ed, node, name, vars, similar) {\n      var formatList = ed.formatter.get(name);\n      var dom = ed.dom;\n      if (formatList && node) {\n        for (var i = 0; i < formatList.length; i++) {\n          var format = formatList[i];\n          if (matchName$1(ed.dom, node, format) && matchItems(dom, node, format, 'attributes', similar, vars) && matchItems(dom, node, format, 'styles', similar, vars)) {\n            var classes = format.classes;\n            if (classes) {\n              for (var x = 0; x < classes.length; x++) {\n                if (!ed.dom.hasClass(node, replaceVars(classes[x], vars))) {\n                  return;\n                }\n              }\n            }\n            return format;\n          }\n        }\n      }\n    };\n    var match$2 = function (editor, name, vars, node, similar) {\n      if (node) {\n        return matchParents(editor, node, name, vars, similar);\n      }\n      node = editor.selection.getNode();\n      if (matchParents(editor, node, name, vars, similar)) {\n        return true;\n      }\n      var startNode = editor.selection.getStart();\n      if (startNode !== node) {\n        if (matchParents(editor, startNode, name, vars, similar)) {\n          return true;\n        }\n      }\n      return false;\n    };\n    var matchAll = function (editor, names, vars) {\n      var matchedFormatNames = [];\n      var checkedMap = {};\n      var startElement = editor.selection.getStart();\n      editor.dom.getParent(startElement, function (node) {\n        for (var i = 0; i < names.length; i++) {\n          var name_1 = names[i];\n          if (!checkedMap[name_1] && matchNode(editor, node, name_1, vars)) {\n            checkedMap[name_1] = true;\n            matchedFormatNames.push(name_1);\n          }\n        }\n      }, editor.dom.getRoot());\n      return matchedFormatNames;\n    };\n    var closest = function (editor, names) {\n      var isRoot = function (elm) {\n        return eq(elm, SugarElement.fromDom(editor.getBody()));\n      };\n      var match = function (elm, name) {\n        return matchNode(editor, elm.dom, name) ? Optional.some(name) : Optional.none();\n      };\n      return Optional.from(editor.selection.getStart(true)).bind(function (rawElm) {\n        return closest$1(SugarElement.fromDom(rawElm), function (elm) {\n          return findMap(names, function (name) {\n            return match(elm, name);\n          });\n        }, isRoot);\n      }).getOrNull();\n    };\n    var canApply = function (editor, name) {\n      var formatList = editor.formatter.get(name);\n      var dom = editor.dom;\n      if (formatList) {\n        var startNode = editor.selection.getStart();\n        var parents = getParents$2(dom, startNode);\n        for (var x = formatList.length - 1; x >= 0; x--) {\n          var format = formatList[x];\n          if (!isSelectorFormat(format) || isNonNullable(format.defaultBlock)) {\n            return true;\n          }\n          for (var i = parents.length - 1; i >= 0; i--) {\n            if (dom.is(parents[i], format.selector)) {\n              return true;\n            }\n          }\n        }\n      }\n      return false;\n    };\n    var matchAllOnNode = function (editor, node, formatNames) {\n      return foldl(formatNames, function (acc, name) {\n        var matchSimilar = isVariableFormatName(editor, name);\n        if (editor.formatter.matchNode(node, name, {}, matchSimilar)) {\n          return acc.concat([name]);\n        } else {\n          return acc;\n        }\n      }, []);\n    };\n\n    var ZWSP = ZWSP$1, CARET_ID = '_mce_caret';\n    var importNode = function (ownerDocument, node) {\n      return ownerDocument.importNode(node, true);\n    };\n    var getEmptyCaretContainers = function (node) {\n      var nodes = [];\n      while (node) {\n        if (node.nodeType === 3 && node.nodeValue !== ZWSP || node.childNodes.length > 1) {\n          return [];\n        }\n        if (node.nodeType === 1) {\n          nodes.push(node);\n        }\n        node = node.firstChild;\n      }\n      return nodes;\n    };\n    var isCaretContainerEmpty = function (node) {\n      return getEmptyCaretContainers(node).length > 0;\n    };\n    var findFirstTextNode = function (node) {\n      if (node) {\n        var walker = new DomTreeWalker(node, node);\n        for (node = walker.current(); node; node = walker.next()) {\n          if (isText$7(node)) {\n            return node;\n          }\n        }\n      }\n      return null;\n    };\n    var createCaretContainer = function (fill) {\n      var caretContainer = SugarElement.fromTag('span');\n      setAll$1(caretContainer, {\n        'id': CARET_ID,\n        'data-mce-bogus': '1',\n        'data-mce-type': 'format-caret'\n      });\n      if (fill) {\n        append$1(caretContainer, SugarElement.fromText(ZWSP));\n      }\n      return caretContainer;\n    };\n    var trimZwspFromCaretContainer = function (caretContainerNode) {\n      var textNode = findFirstTextNode(caretContainerNode);\n      if (textNode && textNode.nodeValue.charAt(0) === ZWSP) {\n        textNode.deleteData(0, 1);\n      }\n      return textNode;\n    };\n    var removeCaretContainerNode = function (editor, node, moveCaret) {\n      if (moveCaret === void 0) {\n        moveCaret = true;\n      }\n      var dom = editor.dom, selection = editor.selection;\n      if (isCaretContainerEmpty(node)) {\n        deleteElement$2(editor, false, SugarElement.fromDom(node), moveCaret);\n      } else {\n        var rng = selection.getRng();\n        var block = dom.getParent(node, dom.isBlock);\n        var startContainer = rng.startContainer;\n        var startOffset = rng.startOffset;\n        var endContainer = rng.endContainer;\n        var endOffset = rng.endOffset;\n        var textNode = trimZwspFromCaretContainer(node);\n        dom.remove(node, true);\n        if (startContainer === textNode && startOffset > 0) {\n          rng.setStart(textNode, startOffset - 1);\n        }\n        if (endContainer === textNode && endOffset > 0) {\n          rng.setEnd(textNode, endOffset - 1);\n        }\n        if (block && dom.isEmpty(block)) {\n          fillWithPaddingBr(SugarElement.fromDom(block));\n        }\n        selection.setRng(rng);\n      }\n    };\n    var removeCaretContainer = function (editor, node, moveCaret) {\n      if (moveCaret === void 0) {\n        moveCaret = true;\n      }\n      var dom = editor.dom, selection = editor.selection;\n      if (!node) {\n        node = getParentCaretContainer(editor.getBody(), selection.getStart());\n        if (!node) {\n          while (node = dom.get(CARET_ID)) {\n            removeCaretContainerNode(editor, node, false);\n          }\n        }\n      } else {\n        removeCaretContainerNode(editor, node, moveCaret);\n      }\n    };\n    var insertCaretContainerNode = function (editor, caretContainer, formatNode) {\n      var dom = editor.dom, block = dom.getParent(formatNode, curry(isTextBlock$1, editor));\n      if (block && dom.isEmpty(block)) {\n        formatNode.parentNode.replaceChild(caretContainer, formatNode);\n      } else {\n        removeTrailingBr(SugarElement.fromDom(formatNode));\n        if (dom.isEmpty(formatNode)) {\n          formatNode.parentNode.replaceChild(caretContainer, formatNode);\n        } else {\n          dom.insertAfter(caretContainer, formatNode);\n        }\n      }\n    };\n    var appendNode = function (parentNode, node) {\n      parentNode.appendChild(node);\n      return node;\n    };\n    var insertFormatNodesIntoCaretContainer = function (formatNodes, caretContainer) {\n      var innerMostFormatNode = foldr(formatNodes, function (parentNode, formatNode) {\n        return appendNode(parentNode, formatNode.cloneNode(false));\n      }, caretContainer);\n      return appendNode(innerMostFormatNode, innerMostFormatNode.ownerDocument.createTextNode(ZWSP));\n    };\n    var cleanFormatNode = function (editor, caretContainer, formatNode, name, vars, similar) {\n      var formatter = editor.formatter;\n      var dom = editor.dom;\n      var validFormats = filter$4(keys(formatter.get()), function (formatName) {\n        return formatName !== name && !contains$2(formatName, 'removeformat');\n      });\n      var matchedFormats = matchAllOnNode(editor, formatNode, validFormats);\n      var uniqueFormats = filter$4(matchedFormats, function (fmtName) {\n        return !areSimilarFormats(editor, fmtName, name);\n      });\n      if (uniqueFormats.length > 0) {\n        var clonedFormatNode = formatNode.cloneNode(false);\n        dom.add(caretContainer, clonedFormatNode);\n        formatter.remove(name, vars, clonedFormatNode, similar);\n        dom.remove(clonedFormatNode);\n        return Optional.some(clonedFormatNode);\n      } else {\n        return Optional.none();\n      }\n    };\n    var applyCaretFormat = function (editor, name, vars) {\n      var caretContainer, textNode;\n      var selection = editor.selection;\n      var selectionRng = selection.getRng();\n      var offset = selectionRng.startOffset;\n      var container = selectionRng.startContainer;\n      var text = container.nodeValue;\n      caretContainer = getParentCaretContainer(editor.getBody(), selection.getStart());\n      if (caretContainer) {\n        textNode = findFirstTextNode(caretContainer);\n      }\n      var wordcharRegex = /[^\\s\\u00a0\\u00ad\\u200b\\ufeff]/;\n      if (text && offset > 0 && offset < text.length && wordcharRegex.test(text.charAt(offset)) && wordcharRegex.test(text.charAt(offset - 1))) {\n        var bookmark = selection.getBookmark();\n        selectionRng.collapse(true);\n        var rng = expandRng(editor, selectionRng, editor.formatter.get(name));\n        rng = split(rng);\n        editor.formatter.apply(name, vars, rng);\n        selection.moveToBookmark(bookmark);\n      } else {\n        if (!caretContainer || textNode.nodeValue !== ZWSP) {\n          caretContainer = importNode(editor.getDoc(), createCaretContainer(true).dom);\n          textNode = caretContainer.firstChild;\n          selectionRng.insertNode(caretContainer);\n          offset = 1;\n          editor.formatter.apply(name, vars, caretContainer);\n        } else {\n          editor.formatter.apply(name, vars, caretContainer);\n        }\n        selection.setCursorLocation(textNode, offset);\n      }\n    };\n    var removeCaretFormat = function (editor, name, vars, similar) {\n      var dom = editor.dom;\n      var selection = editor.selection;\n      var hasContentAfter, node, formatNode;\n      var parents = [];\n      var rng = selection.getRng();\n      var container = rng.startContainer;\n      var offset = rng.startOffset;\n      node = container;\n      if (container.nodeType === 3) {\n        if (offset !== container.nodeValue.length) {\n          hasContentAfter = true;\n        }\n        node = node.parentNode;\n      }\n      while (node) {\n        if (matchNode(editor, node, name, vars, similar)) {\n          formatNode = node;\n          break;\n        }\n        if (node.nextSibling) {\n          hasContentAfter = true;\n        }\n        parents.push(node);\n        node = node.parentNode;\n      }\n      if (!formatNode) {\n        return;\n      }\n      if (hasContentAfter) {\n        var bookmark = selection.getBookmark();\n        rng.collapse(true);\n        var expandedRng = expandRng(editor, rng, editor.formatter.get(name), true);\n        expandedRng = split(expandedRng);\n        editor.formatter.remove(name, vars, expandedRng, similar);\n        selection.moveToBookmark(bookmark);\n      } else {\n        var caretContainer = getParentCaretContainer(editor.getBody(), formatNode);\n        var newCaretContainer = createCaretContainer(false).dom;\n        insertCaretContainerNode(editor, newCaretContainer, caretContainer !== null ? caretContainer : formatNode);\n        var cleanedFormatNode = cleanFormatNode(editor, newCaretContainer, formatNode, name, vars, similar);\n        var caretTextNode = insertFormatNodesIntoCaretContainer(parents.concat(cleanedFormatNode.toArray()), newCaretContainer);\n        removeCaretContainerNode(editor, caretContainer, false);\n        selection.setCursorLocation(caretTextNode, 1);\n        if (dom.isEmpty(formatNode)) {\n          dom.remove(formatNode);\n        }\n      }\n    };\n    var disableCaretContainer = function (editor, keyCode) {\n      var selection = editor.selection, body = editor.getBody();\n      removeCaretContainer(editor, null, false);\n      if ((keyCode === 8 || keyCode === 46) && selection.isCollapsed() && selection.getStart().innerHTML === ZWSP) {\n        removeCaretContainer(editor, getParentCaretContainer(body, selection.getStart()));\n      }\n      if (keyCode === 37 || keyCode === 39) {\n        removeCaretContainer(editor, getParentCaretContainer(body, selection.getStart()));\n      }\n    };\n    var setup$k = function (editor) {\n      editor.on('mouseup keydown', function (e) {\n        disableCaretContainer(editor, e.keyCode);\n      });\n    };\n    var replaceWithCaretFormat = function (targetNode, formatNodes) {\n      var caretContainer = createCaretContainer(false);\n      var innerMost = insertFormatNodesIntoCaretContainer(formatNodes, caretContainer.dom);\n      before$4(SugarElement.fromDom(targetNode), caretContainer);\n      remove$7(SugarElement.fromDom(targetNode));\n      return CaretPosition(innerMost, 0);\n    };\n    var isFormatElement = function (editor, element) {\n      var inlineElements = editor.schema.getTextInlineElements();\n      return has$2(inlineElements, name(element)) && !isCaretNode(element.dom) && !isBogus$2(element.dom);\n    };\n    var isEmptyCaretFormatElement = function (element) {\n      return isCaretNode(element.dom) && isCaretContainerEmpty(element.dom);\n    };\n\n    var postProcessHooks = {};\n    var filter = filter$2;\n    var each$c = each$i;\n    var addPostProcessHook = function (name, hook) {\n      var hooks = postProcessHooks[name];\n      if (!hooks) {\n        postProcessHooks[name] = [];\n      }\n      postProcessHooks[name].push(hook);\n    };\n    var postProcess$1 = function (name, editor) {\n      each$c(postProcessHooks[name], function (hook) {\n        hook(editor);\n      });\n    };\n    addPostProcessHook('pre', function (editor) {\n      var rng = editor.selection.getRng();\n      var blocks;\n      var hasPreSibling = function (pre) {\n        return isPre(pre.previousSibling) && indexOf$1(blocks, pre.previousSibling) !== -1;\n      };\n      var joinPre = function (pre1, pre2) {\n        DomQuery(pre2).remove();\n        DomQuery(pre1).append('<br><br>').append(pre2.childNodes);\n      };\n      var isPre = matchNodeNames(['pre']);\n      if (!rng.collapsed) {\n        blocks = editor.selection.getSelectedBlocks();\n        each$c(filter(filter(blocks, isPre), hasPreSibling), function (pre) {\n          joinPre(pre.previousSibling, pre);\n        });\n      }\n    });\n\n    var each$b = Tools.each;\n    var isElementNode$1 = function (node) {\n      return isElement$5(node) && !isBookmarkNode$1(node) && !isCaretNode(node) && !isBogus$2(node);\n    };\n    var findElementSibling = function (node, siblingName) {\n      for (var sibling = node; sibling; sibling = sibling[siblingName]) {\n        if (isText$7(sibling) && isNotEmpty(sibling.data)) {\n          return node;\n        }\n        if (isElement$5(sibling) && !isBookmarkNode$1(sibling)) {\n          return sibling;\n        }\n      }\n      return node;\n    };\n    var mergeSiblingsNodes = function (dom, prev, next) {\n      var elementUtils = ElementUtils(dom);\n      if (prev && next) {\n        prev = findElementSibling(prev, 'previousSibling');\n        next = findElementSibling(next, 'nextSibling');\n        if (elementUtils.compare(prev, next)) {\n          for (var sibling = prev.nextSibling; sibling && sibling !== next;) {\n            var tmpSibling = sibling;\n            sibling = sibling.nextSibling;\n            prev.appendChild(tmpSibling);\n          }\n          dom.remove(next);\n          Tools.each(Tools.grep(next.childNodes), function (node) {\n            prev.appendChild(node);\n          });\n          return prev;\n        }\n      }\n      return next;\n    };\n    var mergeSiblings = function (dom, format, vars, node) {\n      if (node && format.merge_siblings !== false) {\n        var newNode = mergeSiblingsNodes(dom, getNonWhiteSpaceSibling(node), node);\n        mergeSiblingsNodes(dom, newNode, getNonWhiteSpaceSibling(newNode, true));\n      }\n    };\n    var clearChildStyles = function (dom, format, node) {\n      if (format.clear_child_styles) {\n        var selector = format.links ? '*:not(a)' : '*';\n        each$b(dom.select(selector, node), function (node) {\n          if (isElementNode$1(node)) {\n            each$b(format.styles, function (value, name) {\n              dom.setStyle(node, name, '');\n            });\n          }\n        });\n      }\n    };\n    var processChildElements = function (node, filter, process) {\n      each$b(node.childNodes, function (node) {\n        if (isElementNode$1(node)) {\n          if (filter(node)) {\n            process(node);\n          }\n          if (node.hasChildNodes()) {\n            processChildElements(node, filter, process);\n          }\n        }\n      });\n    };\n    var unwrapEmptySpan = function (dom, node) {\n      if (node.nodeName === 'SPAN' && dom.getAttribs(node).length === 0) {\n        dom.remove(node, true);\n      }\n    };\n    var hasStyle = function (dom, name) {\n      return function (node) {\n        return !!(node && getStyle(dom, node, name));\n      };\n    };\n    var applyStyle = function (dom, name, value) {\n      return function (node) {\n        dom.setStyle(node, name, value);\n        if (node.getAttribute('style') === '') {\n          node.removeAttribute('style');\n        }\n        unwrapEmptySpan(dom, node);\n      };\n    };\n\n    var removeResult = Adt.generate([\n      { keep: [] },\n      { rename: ['name'] },\n      { removed: [] }\n    ]);\n    var MCE_ATTR_RE = /^(src|href|style)$/;\n    var each$a = Tools.each;\n    var isEq$2 = isEq$5;\n    var isTableCellOrRow = function (node) {\n      return /^(TR|TH|TD)$/.test(node.nodeName);\n    };\n    var isChildOfInlineParent = function (dom, node, parent) {\n      return dom.isChildOf(node, parent) && node !== parent && !dom.isBlock(parent);\n    };\n    var getContainer = function (ed, rng, start) {\n      var container = rng[start ? 'startContainer' : 'endContainer'];\n      var offset = rng[start ? 'startOffset' : 'endOffset'];\n      if (isElement$5(container)) {\n        var lastIdx = container.childNodes.length - 1;\n        if (!start && offset) {\n          offset--;\n        }\n        container = container.childNodes[offset > lastIdx ? lastIdx : offset];\n      }\n      if (isText$7(container) && start && offset >= container.nodeValue.length) {\n        container = new DomTreeWalker(container, ed.getBody()).next() || container;\n      }\n      if (isText$7(container) && !start && offset === 0) {\n        container = new DomTreeWalker(container, ed.getBody()).prev() || container;\n      }\n      return container;\n    };\n    var normalizeTableSelection = function (node, start) {\n      var prop = start ? 'firstChild' : 'lastChild';\n      if (isTableCellOrRow(node) && node[prop]) {\n        var childNode = node[prop];\n        if (node.nodeName === 'TR') {\n          return childNode[prop] || childNode;\n        } else {\n          return childNode;\n        }\n      }\n      return node;\n    };\n    var wrap$1 = function (dom, node, name, attrs) {\n      var wrapper = dom.create(name, attrs);\n      node.parentNode.insertBefore(wrapper, node);\n      wrapper.appendChild(node);\n      return wrapper;\n    };\n    var wrapWithSiblings = function (dom, node, next, name, attrs) {\n      var start = SugarElement.fromDom(node);\n      var wrapper = SugarElement.fromDom(dom.create(name, attrs));\n      var siblings = next ? nextSiblings(start) : prevSiblings(start);\n      append(wrapper, siblings);\n      if (next) {\n        before$4(start, wrapper);\n        prepend(wrapper, start);\n      } else {\n        after$3(start, wrapper);\n        append$1(wrapper, start);\n      }\n      return wrapper.dom;\n    };\n    var matchName = function (dom, node, format) {\n      if (isInlineFormat(format) && isEq$2(node, format.inline)) {\n        return true;\n      }\n      if (isBlockFormat(format) && isEq$2(node, format.block)) {\n        return true;\n      }\n      if (isSelectorFormat(format)) {\n        return isElement$5(node) && dom.is(node, format.selector);\n      }\n    };\n    var isColorFormatAndAnchor = function (node, format) {\n      return format.links && node.nodeName === 'A';\n    };\n    var find = function (dom, node, next, inc) {\n      var sibling = getNonWhiteSpaceSibling(node, next, inc);\n      return isNullable(sibling) || sibling.nodeName === 'BR' || dom.isBlock(sibling);\n    };\n    var removeNode = function (ed, node, format) {\n      var parentNode = node.parentNode;\n      var rootBlockElm;\n      var dom = ed.dom, forcedRootBlock = getForcedRootBlock(ed);\n      if (isBlockFormat(format)) {\n        if (!forcedRootBlock) {\n          if (dom.isBlock(node) && !dom.isBlock(parentNode)) {\n            if (!find(dom, node, false) && !find(dom, node.firstChild, true, true)) {\n              node.insertBefore(dom.create('br'), node.firstChild);\n            }\n            if (!find(dom, node, true) && !find(dom, node.lastChild, false, true)) {\n              node.appendChild(dom.create('br'));\n            }\n          }\n        } else {\n          if (parentNode === dom.getRoot()) {\n            if (!format.list_block || !isEq$2(node, format.list_block)) {\n              each$k(from(node.childNodes), function (node) {\n                if (isValid(ed, forcedRootBlock, node.nodeName.toLowerCase())) {\n                  if (!rootBlockElm) {\n                    rootBlockElm = wrap$1(dom, node, forcedRootBlock);\n                    dom.setAttribs(rootBlockElm, ed.settings.forced_root_block_attrs);\n                  } else {\n                    rootBlockElm.appendChild(node);\n                  }\n                } else {\n                  rootBlockElm = null;\n                }\n              });\n            }\n          }\n        }\n      }\n      if (isMixedFormat(format) && !isEq$2(format.inline, node)) {\n        return;\n      }\n      dom.remove(node, true);\n    };\n    var removeFormatInternal = function (ed, format, vars, node, compareNode) {\n      var stylesModified;\n      var dom = ed.dom;\n      if (!matchName(dom, node, format) && !isColorFormatAndAnchor(node, format)) {\n        return removeResult.keep();\n      }\n      var elm = node;\n      if (isInlineFormat(format) && format.remove === 'all' && isArray$1(format.preserve_attributes)) {\n        var attrsToPreserve = filter$4(dom.getAttribs(elm), function (attr) {\n          return contains$3(format.preserve_attributes, attr.name.toLowerCase());\n        });\n        dom.removeAllAttribs(elm);\n        each$k(attrsToPreserve, function (attr) {\n          return dom.setAttrib(elm, attr.name, attr.value);\n        });\n        if (attrsToPreserve.length > 0) {\n          return removeResult.rename('span');\n        }\n      }\n      if (format.remove !== 'all') {\n        each$a(format.styles, function (value, name) {\n          value = normalizeStyleValue(dom, replaceVars(value, vars), name + '');\n          if (isNumber(name)) {\n            name = value;\n            compareNode = null;\n          }\n          if (format.remove_similar || (!compareNode || isEq$2(getStyle(dom, compareNode, name), value))) {\n            dom.setStyle(elm, name, '');\n          }\n          stylesModified = true;\n        });\n        if (stylesModified && dom.getAttrib(elm, 'style') === '') {\n          elm.removeAttribute('style');\n          elm.removeAttribute('data-mce-style');\n        }\n        each$a(format.attributes, function (value, name) {\n          var valueOut;\n          value = replaceVars(value, vars);\n          if (isNumber(name)) {\n            name = value;\n            compareNode = null;\n          }\n          if (format.remove_similar || (!compareNode || isEq$2(dom.getAttrib(compareNode, name), value))) {\n            if (name === 'class') {\n              value = dom.getAttrib(elm, name);\n              if (value) {\n                valueOut = '';\n                each$k(value.split(/\\s+/), function (cls) {\n                  if (/mce\\-\\w+/.test(cls)) {\n                    valueOut += (valueOut ? ' ' : '') + cls;\n                  }\n                });\n                if (valueOut) {\n                  dom.setAttrib(elm, name, valueOut);\n                  return;\n                }\n              }\n            }\n            if (MCE_ATTR_RE.test(name)) {\n              elm.removeAttribute('data-mce-' + name);\n            }\n            if (name === 'style' && matchNodeNames(['li'])(elm) && dom.getStyle(elm, 'list-style-type') === 'none') {\n              elm.removeAttribute(name);\n              dom.setStyle(elm, 'list-style-type', 'none');\n              return;\n            }\n            if (name === 'class') {\n              elm.removeAttribute('className');\n            }\n            elm.removeAttribute(name);\n          }\n        });\n        each$a(format.classes, function (value) {\n          value = replaceVars(value, vars);\n          if (!compareNode || dom.hasClass(compareNode, value)) {\n            dom.removeClass(elm, value);\n          }\n        });\n        var attrs = dom.getAttribs(elm);\n        for (var i = 0; i < attrs.length; i++) {\n          var attrName = attrs[i].nodeName;\n          if (attrName.indexOf('_') !== 0 && attrName.indexOf('data-') !== 0) {\n            return removeResult.keep();\n          }\n        }\n      }\n      if (format.remove !== 'none') {\n        removeNode(ed, elm, format);\n        return removeResult.removed();\n      }\n      return removeResult.keep();\n    };\n    var removeFormat$1 = function (ed, format, vars, node, compareNode) {\n      return removeFormatInternal(ed, format, vars, node, compareNode).fold(never, function (newName) {\n        ed.dom.rename(node, newName);\n        return true;\n      }, always);\n    };\n    var findFormatRoot = function (editor, container, name, vars, similar) {\n      var formatRoot;\n      each$k(getParents$2(editor.dom, container.parentNode).reverse(), function (parent) {\n        if (!formatRoot && parent.id !== '_start' && parent.id !== '_end') {\n          var format = matchNode(editor, parent, name, vars, similar);\n          if (format && format.split !== false) {\n            formatRoot = parent;\n          }\n        }\n      });\n      return formatRoot;\n    };\n    var removeFormatFromClone = function (editor, format, vars, clone) {\n      return removeFormatInternal(editor, format, vars, clone, clone).fold(constant(clone), function (newName) {\n        var fragment = editor.dom.createFragment();\n        fragment.appendChild(clone);\n        return editor.dom.rename(clone, newName);\n      }, constant(null));\n    };\n    var wrapAndSplit = function (editor, formatList, formatRoot, container, target, split, format, vars) {\n      var clone, lastClone, firstClone;\n      var dom = editor.dom;\n      if (formatRoot) {\n        var formatRootParent = formatRoot.parentNode;\n        for (var parent_1 = container.parentNode; parent_1 && parent_1 !== formatRootParent; parent_1 = parent_1.parentNode) {\n          clone = dom.clone(parent_1, false);\n          for (var i = 0; i < formatList.length; i++) {\n            clone = removeFormatFromClone(editor, formatList[i], vars, clone);\n            if (clone === null) {\n              break;\n            }\n          }\n          if (clone) {\n            if (lastClone) {\n              clone.appendChild(lastClone);\n            }\n            if (!firstClone) {\n              firstClone = clone;\n            }\n            lastClone = clone;\n          }\n        }\n        if (split && (!format.mixed || !dom.isBlock(formatRoot))) {\n          container = dom.split(formatRoot, container);\n        }\n        if (lastClone) {\n          target.parentNode.insertBefore(lastClone, target);\n          firstClone.appendChild(target);\n          if (isInlineFormat(format)) {\n            mergeSiblings(dom, format, vars, lastClone);\n          }\n        }\n      }\n      return container;\n    };\n    var remove$1 = function (ed, name, vars, node, similar) {\n      var formatList = ed.formatter.get(name);\n      var format = formatList[0];\n      var contentEditable = true;\n      var dom = ed.dom;\n      var selection = ed.selection;\n      var splitToFormatRoot = function (container) {\n        var formatRoot = findFormatRoot(ed, container, name, vars, similar);\n        return wrapAndSplit(ed, formatList, formatRoot, container, container, true, format, vars);\n      };\n      var isRemoveBookmarkNode = function (node) {\n        return isBookmarkNode$1(node) && isElement$5(node) && (node.id === '_start' || node.id === '_end');\n      };\n      var removeNodeFormat = function (node) {\n        return exists(formatList, function (fmt) {\n          return removeFormat$1(ed, fmt, vars, node, node);\n        });\n      };\n      var process = function (node) {\n        var lastContentEditable = true;\n        var hasContentEditableState = false;\n        if (isElement$5(node) && dom.getContentEditable(node)) {\n          lastContentEditable = contentEditable;\n          contentEditable = dom.getContentEditable(node) === 'true';\n          hasContentEditableState = true;\n        }\n        var children = from(node.childNodes);\n        if (contentEditable && !hasContentEditableState) {\n          var removed = removeNodeFormat(node);\n          var currentNodeMatches = removed || exists(formatList, function (f) {\n            return matchName$1(dom, node, f);\n          });\n          var parentNode = node.parentNode;\n          if (!currentNodeMatches && isNonNullable(parentNode) && shouldExpandToSelector(format)) {\n            removeNodeFormat(parentNode);\n          }\n        }\n        if (format.deep) {\n          if (children.length) {\n            for (var i = 0; i < children.length; i++) {\n              process(children[i]);\n            }\n            if (hasContentEditableState) {\n              contentEditable = lastContentEditable;\n            }\n          }\n        }\n        var textDecorations = [\n          'underline',\n          'line-through',\n          'overline'\n        ];\n        each$k(textDecorations, function (decoration) {\n          if (isElement$5(node) && ed.dom.getStyle(node, 'text-decoration') === decoration && node.parentNode && getTextDecoration(dom, node.parentNode) === decoration) {\n            removeFormat$1(ed, {\n              deep: false,\n              exact: true,\n              inline: 'span',\n              styles: { textDecoration: decoration }\n            }, null, node);\n          }\n        });\n      };\n      var unwrap = function (start) {\n        var node = dom.get(start ? '_start' : '_end');\n        var out = node[start ? 'firstChild' : 'lastChild'];\n        if (isRemoveBookmarkNode(out)) {\n          out = out[start ? 'firstChild' : 'lastChild'];\n        }\n        if (isText$7(out) && out.data.length === 0) {\n          out = start ? node.previousSibling || node.nextSibling : node.nextSibling || node.previousSibling;\n        }\n        dom.remove(node, true);\n        return out;\n      };\n      var removeRngStyle = function (rng) {\n        var startContainer, endContainer;\n        var expandedRng = expandRng(ed, rng, formatList, rng.collapsed);\n        if (format.split) {\n          expandedRng = split(expandedRng);\n          startContainer = getContainer(ed, expandedRng, true);\n          endContainer = getContainer(ed, expandedRng);\n          if (startContainer !== endContainer) {\n            startContainer = normalizeTableSelection(startContainer, true);\n            endContainer = normalizeTableSelection(endContainer, false);\n            if (isChildOfInlineParent(dom, startContainer, endContainer)) {\n              var marker = Optional.from(startContainer.firstChild).getOr(startContainer);\n              splitToFormatRoot(wrapWithSiblings(dom, marker, true, 'span', {\n                'id': '_start',\n                'data-mce-type': 'bookmark'\n              }));\n              unwrap(true);\n              return;\n            }\n            if (isChildOfInlineParent(dom, endContainer, startContainer)) {\n              var marker = Optional.from(endContainer.lastChild).getOr(endContainer);\n              splitToFormatRoot(wrapWithSiblings(dom, marker, false, 'span', {\n                'id': '_end',\n                'data-mce-type': 'bookmark'\n              }));\n              unwrap(false);\n              return;\n            }\n            startContainer = wrap$1(dom, startContainer, 'span', {\n              'id': '_start',\n              'data-mce-type': 'bookmark'\n            });\n            endContainer = wrap$1(dom, endContainer, 'span', {\n              'id': '_end',\n              'data-mce-type': 'bookmark'\n            });\n            var newRng = dom.createRng();\n            newRng.setStartAfter(startContainer);\n            newRng.setEndBefore(endContainer);\n            walk$2(dom, newRng, function (nodes) {\n              each$k(nodes, function (n) {\n                if (!isBookmarkNode$1(n) && !isBookmarkNode$1(n.parentNode)) {\n                  splitToFormatRoot(n);\n                }\n              });\n            });\n            splitToFormatRoot(startContainer);\n            splitToFormatRoot(endContainer);\n            startContainer = unwrap(true);\n            endContainer = unwrap();\n          } else {\n            startContainer = endContainer = splitToFormatRoot(startContainer);\n          }\n          expandedRng.startContainer = startContainer.parentNode ? startContainer.parentNode : startContainer;\n          expandedRng.startOffset = dom.nodeIndex(startContainer);\n          expandedRng.endContainer = endContainer.parentNode ? endContainer.parentNode : endContainer;\n          expandedRng.endOffset = dom.nodeIndex(endContainer) + 1;\n        }\n        walk$2(dom, expandedRng, function (nodes) {\n          each$k(nodes, process);\n        });\n      };\n      if (node) {\n        if (isNode(node)) {\n          var rng = dom.createRng();\n          rng.setStartBefore(node);\n          rng.setEndAfter(node);\n          removeRngStyle(rng);\n        } else {\n          removeRngStyle(node);\n        }\n        fireFormatRemove(ed, name, node, vars);\n        return;\n      }\n      if (dom.getContentEditable(selection.getNode()) === 'false') {\n        node = selection.getNode();\n        for (var i = 0; i < formatList.length; i++) {\n          if (formatList[i].ceFalseOverride) {\n            if (removeFormat$1(ed, formatList[i], vars, node, node)) {\n              break;\n            }\n          }\n        }\n        fireFormatRemove(ed, name, node, vars);\n        return;\n      }\n      if (!selection.isCollapsed() || !isInlineFormat(format) || getCellsFromEditor(ed).length) {\n        preserve(selection, true, function () {\n          runOnRanges(ed, removeRngStyle);\n        });\n        if (isInlineFormat(format) && match$2(ed, name, vars, selection.getStart())) {\n          moveStart(dom, selection, selection.getRng());\n        }\n        ed.nodeChanged();\n      } else {\n        removeCaretFormat(ed, name, vars, similar);\n      }\n      fireFormatRemove(ed, name, node, vars);\n    };\n\n    var each$9 = Tools.each;\n    var mergeTextDecorationsAndColor = function (dom, format, vars, node) {\n      var processTextDecorationsAndColor = function (n) {\n        if (n.nodeType === 1 && n.parentNode && n.parentNode.nodeType === 1) {\n          var textDecoration = getTextDecoration(dom, n.parentNode);\n          if (dom.getStyle(n, 'color') && textDecoration) {\n            dom.setStyle(n, 'text-decoration', textDecoration);\n          } else if (dom.getStyle(n, 'text-decoration') === textDecoration) {\n            dom.setStyle(n, 'text-decoration', null);\n          }\n        }\n      };\n      if (format.styles && (format.styles.color || format.styles.textDecoration)) {\n        Tools.walk(node, processTextDecorationsAndColor, 'childNodes');\n        processTextDecorationsAndColor(node);\n      }\n    };\n    var mergeBackgroundColorAndFontSize = function (dom, format, vars, node) {\n      if (format.styles && format.styles.backgroundColor) {\n        processChildElements(node, hasStyle(dom, 'fontSize'), applyStyle(dom, 'backgroundColor', replaceVars(format.styles.backgroundColor, vars)));\n      }\n    };\n    var mergeSubSup = function (dom, format, vars, node) {\n      if (isInlineFormat(format) && (format.inline === 'sub' || format.inline === 'sup')) {\n        processChildElements(node, hasStyle(dom, 'fontSize'), applyStyle(dom, 'fontSize', ''));\n        dom.remove(dom.select(format.inline === 'sup' ? 'sub' : 'sup', node), true);\n      }\n    };\n    var mergeWithChildren = function (editor, formatList, vars, node) {\n      each$9(formatList, function (format) {\n        if (isInlineFormat(format)) {\n          each$9(editor.dom.select(format.inline, node), function (child) {\n            if (!isElementNode$1(child)) {\n              return;\n            }\n            removeFormat$1(editor, format, vars, child, format.exact ? child : null);\n          });\n        }\n        clearChildStyles(editor.dom, format, node);\n      });\n    };\n    var mergeWithParents = function (editor, format, name, vars, node) {\n      if (matchNode(editor, node.parentNode, name, vars)) {\n        if (removeFormat$1(editor, format, vars, node)) {\n          return;\n        }\n      }\n      if (format.merge_with_parents) {\n        editor.dom.getParent(node.parentNode, function (parent) {\n          if (matchNode(editor, parent, name, vars)) {\n            removeFormat$1(editor, format, vars, node);\n            return true;\n          }\n        });\n      }\n    };\n\n    var each$8 = Tools.each;\n    var isElementNode = function (node) {\n      return isElement$5(node) && !isBookmarkNode$1(node) && !isCaretNode(node) && !isBogus$2(node);\n    };\n    var canFormatBR = function (editor, format, node, parentName) {\n      if (canFormatEmptyLines(editor) && isInlineFormat(format)) {\n        var validBRParentElements = getTextRootBlockElements(editor.schema);\n        var hasCaretNodeSibling = sibling(SugarElement.fromDom(node), function (sibling) {\n          return isCaretNode(sibling.dom);\n        });\n        return hasNonNullableKey(validBRParentElements, parentName) && isEmpty$2(SugarElement.fromDom(node.parentNode), false) && !hasCaretNodeSibling;\n      } else {\n        return false;\n      }\n    };\n    var applyFormat$1 = function (ed, name, vars, node) {\n      var formatList = ed.formatter.get(name);\n      var format = formatList[0];\n      var isCollapsed = !node && ed.selection.isCollapsed();\n      var dom = ed.dom;\n      var selection = ed.selection;\n      var setElementFormat = function (elm, fmt) {\n        if (fmt === void 0) {\n          fmt = format;\n        }\n        if (isFunction(fmt.onformat)) {\n          fmt.onformat(elm, fmt, vars, node);\n        }\n        each$8(fmt.styles, function (value, name) {\n          dom.setStyle(elm, name, replaceVars(value, vars));\n        });\n        if (fmt.styles) {\n          var styleVal = dom.getAttrib(elm, 'style');\n          if (styleVal) {\n            dom.setAttrib(elm, 'data-mce-style', styleVal);\n          }\n        }\n        each$8(fmt.attributes, function (value, name) {\n          dom.setAttrib(elm, name, replaceVars(value, vars));\n        });\n        each$8(fmt.classes, function (value) {\n          value = replaceVars(value, vars);\n          if (!dom.hasClass(elm, value)) {\n            dom.addClass(elm, value);\n          }\n        });\n      };\n      var applyNodeStyle = function (formatList, node) {\n        var found = false;\n        each$8(formatList, function (format) {\n          if (!isSelectorFormat(format)) {\n            return false;\n          }\n          if (isNonNullable(format.collapsed) && format.collapsed !== isCollapsed) {\n            return;\n          }\n          if (dom.is(node, format.selector) && !isCaretNode(node)) {\n            setElementFormat(node, format);\n            found = true;\n            return false;\n          }\n        });\n        return found;\n      };\n      var createWrapElement = function (wrapName) {\n        if (isString$1(wrapName)) {\n          var wrapElm = dom.create(wrapName);\n          setElementFormat(wrapElm);\n          return wrapElm;\n        } else {\n          return null;\n        }\n      };\n      var applyRngStyle = function (dom, rng, nodeSpecific) {\n        var newWrappers = [];\n        var contentEditable = true;\n        var wrapName = format.inline || format.block;\n        var wrapElm = createWrapElement(wrapName);\n        walk$2(dom, rng, function (nodes) {\n          var currentWrapElm;\n          var process = function (node) {\n            var hasContentEditableState = false;\n            var lastContentEditable = contentEditable;\n            var nodeName = node.nodeName.toLowerCase();\n            var parentNode = node.parentNode;\n            var parentName = parentNode.nodeName.toLowerCase();\n            if (isElement$5(node) && dom.getContentEditable(node)) {\n              lastContentEditable = contentEditable;\n              contentEditable = dom.getContentEditable(node) === 'true';\n              hasContentEditableState = true;\n            }\n            if (isBr$5(node) && !canFormatBR(ed, format, node, parentName)) {\n              currentWrapElm = null;\n              if (isBlockFormat(format)) {\n                dom.remove(node);\n              }\n              return;\n            }\n            if (isBlockFormat(format) && format.wrapper && matchNode(ed, node, name, vars)) {\n              currentWrapElm = null;\n              return;\n            }\n            if (contentEditable && !hasContentEditableState && isBlockFormat(format) && !format.wrapper && isTextBlock$1(ed, nodeName) && isValid(ed, parentName, wrapName)) {\n              var elm = dom.rename(node, wrapName);\n              setElementFormat(elm);\n              newWrappers.push(elm);\n              currentWrapElm = null;\n              return;\n            }\n            if (isSelectorFormat(format)) {\n              var found = applyNodeStyle(formatList, node);\n              if (!found && isNonNullable(parentNode) && shouldExpandToSelector(format)) {\n                found = applyNodeStyle(formatList, parentNode);\n              }\n              if (!isInlineFormat(format) || found) {\n                currentWrapElm = null;\n                return;\n              }\n            }\n            if (contentEditable && !hasContentEditableState && isValid(ed, wrapName, nodeName) && isValid(ed, parentName, wrapName) && !(!nodeSpecific && isText$7(node) && isZwsp(node.data)) && !isCaretNode(node) && (!isInlineFormat(format) || !dom.isBlock(node))) {\n              if (!currentWrapElm) {\n                currentWrapElm = dom.clone(wrapElm, false);\n                node.parentNode.insertBefore(currentWrapElm, node);\n                newWrappers.push(currentWrapElm);\n              }\n              currentWrapElm.appendChild(node);\n            } else {\n              currentWrapElm = null;\n              each$k(from(node.childNodes), process);\n              if (hasContentEditableState) {\n                contentEditable = lastContentEditable;\n              }\n              currentWrapElm = null;\n            }\n          };\n          each$k(nodes, process);\n        });\n        if (format.links === true) {\n          each$k(newWrappers, function (node) {\n            var process = function (node) {\n              if (node.nodeName === 'A') {\n                setElementFormat(node, format);\n              }\n              each$k(from(node.childNodes), process);\n            };\n            process(node);\n          });\n        }\n        each$k(newWrappers, function (node) {\n          var getChildCount = function (node) {\n            var count = 0;\n            each$k(node.childNodes, function (node) {\n              if (!isEmptyTextNode$1(node) && !isBookmarkNode$1(node)) {\n                count++;\n              }\n            });\n            return count;\n          };\n          var mergeStyles = function (node) {\n            var childElement = find$3(node.childNodes, isElementNode).filter(function (child) {\n              return matchName$1(dom, child, format);\n            });\n            return childElement.map(function (child) {\n              var clone = dom.clone(child, false);\n              setElementFormat(clone);\n              dom.replace(clone, node, true);\n              dom.remove(child, true);\n              return clone;\n            }).getOr(node);\n          };\n          var childCount = getChildCount(node);\n          if ((newWrappers.length > 1 || !dom.isBlock(node)) && childCount === 0) {\n            dom.remove(node, true);\n            return;\n          }\n          if (isInlineFormat(format) || isBlockFormat(format) && format.wrapper) {\n            if (!format.exact && childCount === 1) {\n              node = mergeStyles(node);\n            }\n            mergeWithChildren(ed, formatList, vars, node);\n            mergeWithParents(ed, format, name, vars, node);\n            mergeBackgroundColorAndFontSize(dom, format, vars, node);\n            mergeTextDecorationsAndColor(dom, format, vars, node);\n            mergeSubSup(dom, format, vars, node);\n            mergeSiblings(dom, format, vars, node);\n          }\n        });\n      };\n      if (dom.getContentEditable(selection.getNode()) === 'false') {\n        node = selection.getNode();\n        for (var i = 0, l = formatList.length; i < l; i++) {\n          var formatItem = formatList[i];\n          if (formatItem.ceFalseOverride && isSelectorFormat(formatItem) && dom.is(node, formatItem.selector)) {\n            setElementFormat(node, formatItem);\n            break;\n          }\n        }\n        fireFormatApply(ed, name, node, vars);\n        return;\n      }\n      if (format) {\n        if (node) {\n          if (isNode(node)) {\n            if (!applyNodeStyle(formatList, node)) {\n              var rng = dom.createRng();\n              rng.setStartBefore(node);\n              rng.setEndAfter(node);\n              applyRngStyle(dom, expandRng(ed, rng, formatList), true);\n            }\n          } else {\n            applyRngStyle(dom, node, true);\n          }\n        } else {\n          if (!isCollapsed || !isInlineFormat(format) || getCellsFromEditor(ed).length) {\n            var curSelNode = selection.getNode();\n            var firstFormat = formatList[0];\n            if (!ed.settings.forced_root_block && firstFormat.defaultBlock && !dom.getParent(curSelNode, dom.isBlock)) {\n              applyFormat$1(ed, firstFormat.defaultBlock);\n            }\n            selection.setRng(normalize(selection.getRng()));\n            preserve(selection, true, function () {\n              runOnRanges(ed, function (selectionRng, fake) {\n                var expandedRng = fake ? selectionRng : expandRng(ed, selectionRng, formatList);\n                applyRngStyle(dom, expandedRng, false);\n              });\n            });\n            moveStart(dom, selection, selection.getRng());\n            ed.nodeChanged();\n          } else {\n            applyCaretFormat(ed, name, vars);\n          }\n        }\n        postProcess$1(name, ed);\n      }\n      fireFormatApply(ed, name, node, vars);\n    };\n\n    var hasVars = function (value) {\n      return has$2(value, 'vars');\n    };\n    var setup$j = function (registeredFormatListeners, editor) {\n      registeredFormatListeners.set({});\n      editor.on('NodeChange', function (e) {\n        updateAndFireChangeCallbacks(editor, e.element, registeredFormatListeners.get());\n      });\n      editor.on('FormatApply FormatRemove', function (e) {\n        var element = Optional.from(e.node).map(function (nodeOrRange) {\n          return isNode(nodeOrRange) ? nodeOrRange : nodeOrRange.startContainer;\n        }).bind(function (node) {\n          return isElement$5(node) ? Optional.some(node) : Optional.from(node.parentElement);\n        }).getOrThunk(function () {\n          return fallbackElement(editor);\n        });\n        updateAndFireChangeCallbacks(editor, element, registeredFormatListeners.get());\n      });\n    };\n    var fallbackElement = function (editor) {\n      return editor.selection.getStart();\n    };\n    var matchingNode = function (editor, parents, format, similar, vars) {\n      var isMatchingNode = function (node) {\n        var matchingFormat = editor.formatter.matchNode(node, format, vars !== null && vars !== void 0 ? vars : {}, similar);\n        return !isUndefined(matchingFormat);\n      };\n      var isUnableToMatch = function (node) {\n        if (matchesUnInheritedFormatSelector(editor, node, format)) {\n          return true;\n        } else {\n          if (!similar) {\n            return isNonNullable(editor.formatter.matchNode(node, format, vars, true));\n          } else {\n            return false;\n          }\n        }\n      };\n      return findUntil$1(parents, isMatchingNode, isUnableToMatch);\n    };\n    var getParents = function (editor, elm) {\n      var element = elm !== null && elm !== void 0 ? elm : fallbackElement(editor);\n      return filter$4(getParents$2(editor.dom, element), function (node) {\n        return isElement$5(node) && !isBogus$2(node);\n      });\n    };\n    var updateAndFireChangeCallbacks = function (editor, elm, registeredCallbacks) {\n      var parents = getParents(editor, elm);\n      each$j(registeredCallbacks, function (data, format) {\n        var runIfChanged = function (spec) {\n          var match = matchingNode(editor, parents, format, spec.similar, hasVars(spec) ? spec.vars : undefined);\n          var isSet = match.isSome();\n          if (spec.state.get() !== isSet) {\n            spec.state.set(isSet);\n            var node_1 = match.getOr(elm);\n            if (hasVars(spec)) {\n              spec.callback(isSet, {\n                node: node_1,\n                format: format,\n                parents: parents\n              });\n            } else {\n              each$k(spec.callbacks, function (callback) {\n                return callback(isSet, {\n                  node: node_1,\n                  format: format,\n                  parents: parents\n                });\n              });\n            }\n          }\n        };\n        each$k([\n          data.withSimilar,\n          data.withoutSimilar\n        ], runIfChanged);\n        each$k(data.withVars, runIfChanged);\n      });\n    };\n    var addListeners = function (editor, registeredFormatListeners, formats, callback, similar, vars) {\n      var formatChangeItems = registeredFormatListeners.get();\n      each$k(formats.split(','), function (format) {\n        var group = get$9(formatChangeItems, format).getOrThunk(function () {\n          var base = {\n            withSimilar: {\n              state: Cell(false),\n              similar: true,\n              callbacks: []\n            },\n            withoutSimilar: {\n              state: Cell(false),\n              similar: false,\n              callbacks: []\n            },\n            withVars: []\n          };\n          formatChangeItems[format] = base;\n          return base;\n        });\n        var getCurrent = function () {\n          var parents = getParents(editor);\n          return matchingNode(editor, parents, format, similar, vars).isSome();\n        };\n        if (isUndefined(vars)) {\n          var toAppendTo = similar ? group.withSimilar : group.withoutSimilar;\n          toAppendTo.callbacks.push(callback);\n          if (toAppendTo.callbacks.length === 1) {\n            toAppendTo.state.set(getCurrent());\n          }\n        } else {\n          group.withVars.push({\n            state: Cell(getCurrent()),\n            similar: similar,\n            vars: vars,\n            callback: callback\n          });\n        }\n      });\n      registeredFormatListeners.set(formatChangeItems);\n    };\n    var removeListeners = function (registeredFormatListeners, formats, callback) {\n      var formatChangeItems = registeredFormatListeners.get();\n      each$k(formats.split(','), function (format) {\n        return get$9(formatChangeItems, format).each(function (group) {\n          formatChangeItems[format] = {\n            withSimilar: __assign(__assign({}, group.withSimilar), {\n              callbacks: filter$4(group.withSimilar.callbacks, function (cb) {\n                return cb !== callback;\n              })\n            }),\n            withoutSimilar: __assign(__assign({}, group.withoutSimilar), {\n              callbacks: filter$4(group.withoutSimilar.callbacks, function (cb) {\n                return cb !== callback;\n              })\n            }),\n            withVars: filter$4(group.withVars, function (item) {\n              return item.callback !== callback;\n            })\n          };\n        });\n      });\n      registeredFormatListeners.set(formatChangeItems);\n    };\n    var formatChangedInternal = function (editor, registeredFormatListeners, formats, callback, similar, vars) {\n      if (registeredFormatListeners.get() === null) {\n        setup$j(registeredFormatListeners, editor);\n      }\n      addListeners(editor, registeredFormatListeners, formats, callback, similar, vars);\n      return {\n        unbind: function () {\n          return removeListeners(registeredFormatListeners, formats, callback);\n        }\n      };\n    };\n\n    var toggle = function (editor, name, vars, node) {\n      var fmt = editor.formatter.get(name);\n      if (match$2(editor, name, vars, node) && (!('toggle' in fmt[0]) || fmt[0].toggle)) {\n        remove$1(editor, name, vars, node);\n      } else {\n        applyFormat$1(editor, name, vars, node);\n      }\n    };\n\n    var fromElements = function (elements, scope) {\n      var doc = scope || document;\n      var fragment = doc.createDocumentFragment();\n      each$k(elements, function (element) {\n        fragment.appendChild(element.dom);\n      });\n      return SugarElement.fromDom(fragment);\n    };\n\n    var tableModel = function (element, width, rows) {\n      return {\n        element: element,\n        width: width,\n        rows: rows\n      };\n    };\n    var tableRow = function (element, cells) {\n      return {\n        element: element,\n        cells: cells\n      };\n    };\n    var cellPosition = function (x, y) {\n      return {\n        x: x,\n        y: y\n      };\n    };\n    var getSpan = function (td, key) {\n      var value = parseInt(get$6(td, key), 10);\n      return isNaN(value) ? 1 : value;\n    };\n    var fillout = function (table, x, y, tr, td) {\n      var rowspan = getSpan(td, 'rowspan');\n      var colspan = getSpan(td, 'colspan');\n      var rows = table.rows;\n      for (var y2 = y; y2 < y + rowspan; y2++) {\n        if (!rows[y2]) {\n          rows[y2] = tableRow(deep$1(tr), []);\n        }\n        for (var x2 = x; x2 < x + colspan; x2++) {\n          var cells = rows[y2].cells;\n          cells[x2] = y2 === y && x2 === x ? td : shallow(td);\n        }\n      }\n    };\n    var cellExists = function (table, x, y) {\n      var rows = table.rows;\n      var cells = rows[y] ? rows[y].cells : [];\n      return !!cells[x];\n    };\n    var skipCellsX = function (table, x, y) {\n      while (cellExists(table, x, y)) {\n        x++;\n      }\n      return x;\n    };\n    var getWidth = function (rows) {\n      return foldl(rows, function (acc, row) {\n        return row.cells.length > acc ? row.cells.length : acc;\n      }, 0);\n    };\n    var findElementPos = function (table, element) {\n      var rows = table.rows;\n      for (var y = 0; y < rows.length; y++) {\n        var cells = rows[y].cells;\n        for (var x = 0; x < cells.length; x++) {\n          if (eq(cells[x], element)) {\n            return Optional.some(cellPosition(x, y));\n          }\n        }\n      }\n      return Optional.none();\n    };\n    var extractRows = function (table, sx, sy, ex, ey) {\n      var newRows = [];\n      var rows = table.rows;\n      for (var y = sy; y <= ey; y++) {\n        var cells = rows[y].cells;\n        var slice = sx < ex ? cells.slice(sx, ex + 1) : cells.slice(ex, sx + 1);\n        newRows.push(tableRow(rows[y].element, slice));\n      }\n      return newRows;\n    };\n    var subTable = function (table, startPos, endPos) {\n      var sx = startPos.x, sy = startPos.y;\n      var ex = endPos.x, ey = endPos.y;\n      var newRows = sy < ey ? extractRows(table, sx, sy, ex, ey) : extractRows(table, sx, ey, ex, sy);\n      return tableModel(table.element, getWidth(newRows), newRows);\n    };\n    var createDomTable = function (table, rows) {\n      var tableElement = shallow(table.element);\n      var tableBody = SugarElement.fromTag('tbody');\n      append(tableBody, rows);\n      append$1(tableElement, tableBody);\n      return tableElement;\n    };\n    var modelRowsToDomRows = function (table) {\n      return map$3(table.rows, function (row) {\n        var cells = map$3(row.cells, function (cell) {\n          var td = deep$1(cell);\n          remove$6(td, 'colspan');\n          remove$6(td, 'rowspan');\n          return td;\n        });\n        var tr = shallow(row.element);\n        append(tr, cells);\n        return tr;\n      });\n    };\n    var fromDom = function (tableElm) {\n      var table = tableModel(shallow(tableElm), 0, []);\n      each$k(descendants(tableElm, 'tr'), function (tr, y) {\n        each$k(descendants(tr, 'td,th'), function (td, x) {\n          fillout(table, skipCellsX(table, x, y), y, tr, td);\n        });\n      });\n      return tableModel(table.element, getWidth(table.rows), table.rows);\n    };\n    var toDom = function (table) {\n      return createDomTable(table, modelRowsToDomRows(table));\n    };\n    var subsection = function (table, startElement, endElement) {\n      return findElementPos(table, startElement).bind(function (startPos) {\n        return findElementPos(table, endElement).map(function (endPos) {\n          return subTable(table, startPos, endPos);\n        });\n      });\n    };\n\n    var findParentListContainer = function (parents) {\n      return find$3(parents, function (elm) {\n        return name(elm) === 'ul' || name(elm) === 'ol';\n      });\n    };\n    var getFullySelectedListWrappers = function (parents, rng) {\n      return find$3(parents, function (elm) {\n        return name(elm) === 'li' && hasAllContentsSelected(elm, rng);\n      }).fold(constant([]), function (_li) {\n        return findParentListContainer(parents).map(function (listCont) {\n          var listElm = SugarElement.fromTag(name(listCont));\n          var listStyles = filter$3(getAllRaw(listCont), function (_style, name) {\n            return startsWith(name, 'list-style');\n          });\n          setAll(listElm, listStyles);\n          return [\n            SugarElement.fromTag('li'),\n            listElm\n          ];\n        }).getOr([]);\n      });\n    };\n    var wrap = function (innerElm, elms) {\n      var wrapped = foldl(elms, function (acc, elm) {\n        append$1(elm, acc);\n        return elm;\n      }, innerElm);\n      return elms.length > 0 ? fromElements([wrapped]) : wrapped;\n    };\n    var directListWrappers = function (commonAnchorContainer) {\n      if (isListItem(commonAnchorContainer)) {\n        return parent(commonAnchorContainer).filter(isList).fold(constant([]), function (listElm) {\n          return [\n            commonAnchorContainer,\n            listElm\n          ];\n        });\n      } else {\n        return isList(commonAnchorContainer) ? [commonAnchorContainer] : [];\n      }\n    };\n    var getWrapElements = function (rootNode, rng) {\n      var commonAnchorContainer = SugarElement.fromDom(rng.commonAncestorContainer);\n      var parents = parentsAndSelf(commonAnchorContainer, rootNode);\n      var wrapElements = filter$4(parents, function (elm) {\n        return isInline$1(elm) || isHeading(elm);\n      });\n      var listWrappers = getFullySelectedListWrappers(parents, rng);\n      var allWrappers = wrapElements.concat(listWrappers.length ? listWrappers : directListWrappers(commonAnchorContainer));\n      return map$3(allWrappers, shallow);\n    };\n    var emptyFragment = function () {\n      return fromElements([]);\n    };\n    var getFragmentFromRange = function (rootNode, rng) {\n      return wrap(SugarElement.fromDom(rng.cloneContents()), getWrapElements(rootNode, rng));\n    };\n    var getParentTable = function (rootElm, cell) {\n      return ancestor$2(cell, 'table', curry(eq, rootElm));\n    };\n    var getTableFragment = function (rootNode, selectedTableCells) {\n      return getParentTable(rootNode, selectedTableCells[0]).bind(function (tableElm) {\n        var firstCell = selectedTableCells[0];\n        var lastCell = selectedTableCells[selectedTableCells.length - 1];\n        var fullTableModel = fromDom(tableElm);\n        return subsection(fullTableModel, firstCell, lastCell).map(function (sectionedTableModel) {\n          return fromElements([toDom(sectionedTableModel)]);\n        });\n      }).getOrThunk(emptyFragment);\n    };\n    var getSelectionFragment = function (rootNode, ranges) {\n      return ranges.length > 0 && ranges[0].collapsed ? emptyFragment() : getFragmentFromRange(rootNode, ranges[0]);\n    };\n    var read$3 = function (rootNode, ranges) {\n      var selectedCells = getCellsFromElementOrRanges(ranges, rootNode);\n      return selectedCells.length > 0 ? getTableFragment(rootNode, selectedCells) : getSelectionFragment(rootNode, ranges);\n    };\n\n    var trimLeadingCollapsibleText = function (text) {\n      return text.replace(/^[ \\f\\n\\r\\t\\v]+/, '');\n    };\n    var isCollapsibleWhitespace = function (text, index) {\n      return index >= 0 && index < text.length && isWhiteSpace(text.charAt(index));\n    };\n    var getInnerText = function (bin, shouldTrim) {\n      var text = trim$3(bin.innerText);\n      return shouldTrim ? trimLeadingCollapsibleText(text) : text;\n    };\n    var getContextNodeName = function (parentBlockOpt) {\n      return parentBlockOpt.map(function (block) {\n        return block.nodeName;\n      }).getOr('div').toLowerCase();\n    };\n    var getTextContent = function (editor) {\n      return Optional.from(editor.selection.getRng()).map(function (rng) {\n        var parentBlockOpt = Optional.from(editor.dom.getParent(rng.commonAncestorContainer, editor.dom.isBlock));\n        var body = editor.getBody();\n        var contextNodeName = getContextNodeName(parentBlockOpt);\n        var shouldTrimSpaces = Env.browser.isIE() && contextNodeName !== 'pre';\n        var bin = editor.dom.add(body, contextNodeName, {\n          'data-mce-bogus': 'all',\n          'style': 'overflow: hidden; opacity: 0;'\n        }, rng.cloneContents());\n        var text = getInnerText(bin, shouldTrimSpaces);\n        var nonRenderedText = trim$3(bin.textContent);\n        editor.dom.remove(bin);\n        if (isCollapsibleWhitespace(nonRenderedText, 0) || isCollapsibleWhitespace(nonRenderedText, nonRenderedText.length - 1)) {\n          var parentBlock = parentBlockOpt.getOr(body);\n          var parentBlockText = getInnerText(parentBlock, shouldTrimSpaces);\n          var textIndex = parentBlockText.indexOf(text);\n          if (textIndex === -1) {\n            return text;\n          } else {\n            var hasProceedingSpace = isCollapsibleWhitespace(parentBlockText, textIndex - 1);\n            var hasTrailingSpace = isCollapsibleWhitespace(parentBlockText, textIndex + text.length);\n            return (hasProceedingSpace ? ' ' : '') + text + (hasTrailingSpace ? ' ' : '');\n          }\n        } else {\n          return text;\n        }\n      }).getOr('');\n    };\n    var getSerializedContent = function (editor, args) {\n      var rng = editor.selection.getRng(), tmpElm = editor.dom.create('body');\n      var sel = editor.selection.getSel();\n      var ranges = processRanges(editor, getRanges(sel));\n      var fragment = args.contextual ? read$3(SugarElement.fromDom(editor.getBody()), ranges).dom : rng.cloneContents();\n      if (fragment) {\n        tmpElm.appendChild(fragment);\n      }\n      return editor.selection.serializer.serialize(tmpElm, args);\n    };\n    var setupArgs$1 = function (args, format) {\n      return __assign(__assign({}, args), {\n        format: format,\n        get: true,\n        selection: true\n      });\n    };\n    var getSelectedContentInternal = function (editor, format, args) {\n      if (args === void 0) {\n        args = {};\n      }\n      var defaultedArgs = setupArgs$1(args, format);\n      var updatedArgs = editor.fire('BeforeGetContent', defaultedArgs);\n      if (updatedArgs.isDefaultPrevented()) {\n        editor.fire('GetContent', updatedArgs);\n        return updatedArgs.content;\n      }\n      if (updatedArgs.format === 'text') {\n        return getTextContent(editor);\n      } else {\n        updatedArgs.getInner = true;\n        var content = getSerializedContent(editor, updatedArgs);\n        if (updatedArgs.format === 'tree') {\n          return content;\n        } else {\n          updatedArgs.content = editor.selection.isCollapsed() ? '' : content;\n          editor.fire('GetContent', updatedArgs);\n          return updatedArgs.content;\n        }\n      }\n    };\n\n    var KEEP = 0, INSERT = 1, DELETE = 2;\n    var diff = function (left, right) {\n      var size = left.length + right.length + 2;\n      var vDown = new Array(size);\n      var vUp = new Array(size);\n      var snake = function (start, end, diag) {\n        return {\n          start: start,\n          end: end,\n          diag: diag\n        };\n      };\n      var buildScript = function (start1, end1, start2, end2, script) {\n        var middle = getMiddleSnake(start1, end1, start2, end2);\n        if (middle === null || middle.start === end1 && middle.diag === end1 - end2 || middle.end === start1 && middle.diag === start1 - start2) {\n          var i = start1;\n          var j = start2;\n          while (i < end1 || j < end2) {\n            if (i < end1 && j < end2 && left[i] === right[j]) {\n              script.push([\n                KEEP,\n                left[i]\n              ]);\n              ++i;\n              ++j;\n            } else {\n              if (end1 - start1 > end2 - start2) {\n                script.push([\n                  DELETE,\n                  left[i]\n                ]);\n                ++i;\n              } else {\n                script.push([\n                  INSERT,\n                  right[j]\n                ]);\n                ++j;\n              }\n            }\n          }\n        } else {\n          buildScript(start1, middle.start, start2, middle.start - middle.diag, script);\n          for (var i2 = middle.start; i2 < middle.end; ++i2) {\n            script.push([\n              KEEP,\n              left[i2]\n            ]);\n          }\n          buildScript(middle.end, end1, middle.end - middle.diag, end2, script);\n        }\n      };\n      var buildSnake = function (start, diag, end1, end2) {\n        var end = start;\n        while (end - diag < end2 && end < end1 && left[end] === right[end - diag]) {\n          ++end;\n        }\n        return snake(start, end, diag);\n      };\n      var getMiddleSnake = function (start1, end1, start2, end2) {\n        var m = end1 - start1;\n        var n = end2 - start2;\n        if (m === 0 || n === 0) {\n          return null;\n        }\n        var delta = m - n;\n        var sum = n + m;\n        var offset = (sum % 2 === 0 ? sum : sum + 1) / 2;\n        vDown[1 + offset] = start1;\n        vUp[1 + offset] = end1 + 1;\n        var d, k, i, x, y;\n        for (d = 0; d <= offset; ++d) {\n          for (k = -d; k <= d; k += 2) {\n            i = k + offset;\n            if (k === -d || k !== d && vDown[i - 1] < vDown[i + 1]) {\n              vDown[i] = vDown[i + 1];\n            } else {\n              vDown[i] = vDown[i - 1] + 1;\n            }\n            x = vDown[i];\n            y = x - start1 + start2 - k;\n            while (x < end1 && y < end2 && left[x] === right[y]) {\n              vDown[i] = ++x;\n              ++y;\n            }\n            if (delta % 2 !== 0 && delta - d <= k && k <= delta + d) {\n              if (vUp[i - delta] <= vDown[i]) {\n                return buildSnake(vUp[i - delta], k + start1 - start2, end1, end2);\n              }\n            }\n          }\n          for (k = delta - d; k <= delta + d; k += 2) {\n            i = k + offset - delta;\n            if (k === delta - d || k !== delta + d && vUp[i + 1] <= vUp[i - 1]) {\n              vUp[i] = vUp[i + 1] - 1;\n            } else {\n              vUp[i] = vUp[i - 1];\n            }\n            x = vUp[i] - 1;\n            y = x - start1 + start2 - k;\n            while (x >= start1 && y >= start2 && left[x] === right[y]) {\n              vUp[i] = x--;\n              y--;\n            }\n            if (delta % 2 === 0 && -d <= k && k <= d) {\n              if (vUp[i] <= vDown[i + delta]) {\n                return buildSnake(vUp[i], k + start1 - start2, end1, end2);\n              }\n            }\n          }\n        }\n      };\n      var script = [];\n      buildScript(0, left.length, 0, right.length, script);\n      return script;\n    };\n\n    var getOuterHtml = function (elm) {\n      if (isElement$5(elm)) {\n        return elm.outerHTML;\n      } else if (isText$7(elm)) {\n        return Entities.encodeRaw(elm.data, false);\n      } else if (isComment(elm)) {\n        return '<!--' + elm.data + '-->';\n      }\n      return '';\n    };\n    var createFragment = function (html) {\n      var node;\n      var container = document.createElement('div');\n      var frag = document.createDocumentFragment();\n      if (html) {\n        container.innerHTML = html;\n      }\n      while (node = container.firstChild) {\n        frag.appendChild(node);\n      }\n      return frag;\n    };\n    var insertAt = function (elm, html, index) {\n      var fragment = createFragment(html);\n      if (elm.hasChildNodes() && index < elm.childNodes.length) {\n        var target = elm.childNodes[index];\n        target.parentNode.insertBefore(fragment, target);\n      } else {\n        elm.appendChild(fragment);\n      }\n    };\n    var removeAt = function (elm, index) {\n      if (elm.hasChildNodes() && index < elm.childNodes.length) {\n        var target = elm.childNodes[index];\n        target.parentNode.removeChild(target);\n      }\n    };\n    var applyDiff = function (diff, elm) {\n      var index = 0;\n      each$k(diff, function (action) {\n        if (action[0] === KEEP) {\n          index++;\n        } else if (action[0] === INSERT) {\n          insertAt(elm, action[1], index);\n          index++;\n        } else if (action[0] === DELETE) {\n          removeAt(elm, index);\n        }\n      });\n    };\n    var read$2 = function (elm, trimZwsp) {\n      return filter$4(map$3(from(elm.childNodes), trimZwsp ? compose(trim$3, getOuterHtml) : getOuterHtml), function (item) {\n        return item.length > 0;\n      });\n    };\n    var write = function (fragments, elm) {\n      var currentFragments = map$3(from(elm.childNodes), getOuterHtml);\n      applyDiff(diff(currentFragments, fragments), elm);\n      return elm;\n    };\n\n    var lazyTempDocument$1 = cached(function () {\n      return document.implementation.createHTMLDocument('undo');\n    });\n    var hasIframes = function (body) {\n      return body.querySelector('iframe') !== null;\n    };\n    var createFragmentedLevel = function (fragments) {\n      return {\n        type: 'fragmented',\n        fragments: fragments,\n        content: '',\n        bookmark: null,\n        beforeBookmark: null\n      };\n    };\n    var createCompleteLevel = function (content) {\n      return {\n        type: 'complete',\n        fragments: null,\n        content: content,\n        bookmark: null,\n        beforeBookmark: null\n      };\n    };\n    var createFromEditor = function (editor) {\n      var tempAttrs = editor.serializer.getTempAttrs();\n      var body = trim$1(editor.getBody(), tempAttrs);\n      return hasIframes(body) ? createFragmentedLevel(read$2(body, true)) : createCompleteLevel(trim$3(body.innerHTML));\n    };\n    var applyToEditor = function (editor, level, before) {\n      var bookmark = before ? level.beforeBookmark : level.bookmark;\n      if (level.type === 'fragmented') {\n        write(level.fragments, editor.getBody());\n      } else {\n        editor.setContent(level.content, {\n          format: 'raw',\n          no_selection: isNonNullable(bookmark) && isPathBookmark(bookmark) ? !bookmark.isFakeCaret : true\n        });\n      }\n      editor.selection.moveToBookmark(bookmark);\n    };\n    var getLevelContent = function (level) {\n      return level.type === 'fragmented' ? level.fragments.join('') : level.content;\n    };\n    var getCleanLevelContent = function (level) {\n      var elm = SugarElement.fromTag('body', lazyTempDocument$1());\n      set(elm, getLevelContent(level));\n      each$k(descendants(elm, '*[data-mce-bogus]'), unwrap);\n      return get$3(elm);\n    };\n    var hasEqualContent = function (level1, level2) {\n      return getLevelContent(level1) === getLevelContent(level2);\n    };\n    var hasEqualCleanedContent = function (level1, level2) {\n      return getCleanLevelContent(level1) === getCleanLevelContent(level2);\n    };\n    var isEq$1 = function (level1, level2) {\n      if (!level1 || !level2) {\n        return false;\n      } else if (hasEqualContent(level1, level2)) {\n        return true;\n      } else {\n        return hasEqualCleanedContent(level1, level2);\n      }\n    };\n\n    var isUnlocked = function (locks) {\n      return locks.get() === 0;\n    };\n\n    var setTyping = function (undoManager, typing, locks) {\n      if (isUnlocked(locks)) {\n        undoManager.typing = typing;\n      }\n    };\n    var endTyping = function (undoManager, locks) {\n      if (undoManager.typing) {\n        setTyping(undoManager, false, locks);\n        undoManager.add();\n      }\n    };\n    var endTypingLevelIgnoreLocks = function (undoManager) {\n      if (undoManager.typing) {\n        undoManager.typing = false;\n        undoManager.add();\n      }\n    };\n\n    var beforeChange$1 = function (editor, locks, beforeBookmark) {\n      if (isUnlocked(locks)) {\n        beforeBookmark.set(getUndoBookmark(editor.selection));\n      }\n    };\n    var addUndoLevel$1 = function (editor, undoManager, index, locks, beforeBookmark, level, event) {\n      var currentLevel = createFromEditor(editor);\n      level = level || {};\n      level = Tools.extend(level, currentLevel);\n      if (isUnlocked(locks) === false || editor.removed) {\n        return null;\n      }\n      var lastLevel = undoManager.data[index.get()];\n      if (editor.fire('BeforeAddUndo', {\n          level: level,\n          lastLevel: lastLevel,\n          originalEvent: event\n        }).isDefaultPrevented()) {\n        return null;\n      }\n      if (lastLevel && isEq$1(lastLevel, level)) {\n        return null;\n      }\n      if (undoManager.data[index.get()]) {\n        beforeBookmark.get().each(function (bm) {\n          undoManager.data[index.get()].beforeBookmark = bm;\n        });\n      }\n      var customUndoRedoLevels = getCustomUndoRedoLevels(editor);\n      if (customUndoRedoLevels) {\n        if (undoManager.data.length > customUndoRedoLevels) {\n          for (var i = 0; i < undoManager.data.length - 1; i++) {\n            undoManager.data[i] = undoManager.data[i + 1];\n          }\n          undoManager.data.length--;\n          index.set(undoManager.data.length);\n        }\n      }\n      level.bookmark = getUndoBookmark(editor.selection);\n      if (index.get() < undoManager.data.length - 1) {\n        undoManager.data.length = index.get() + 1;\n      }\n      undoManager.data.push(level);\n      index.set(undoManager.data.length - 1);\n      var args = {\n        level: level,\n        lastLevel: lastLevel,\n        originalEvent: event\n      };\n      if (index.get() > 0) {\n        editor.setDirty(true);\n        editor.fire('AddUndo', args);\n        editor.fire('change', args);\n      } else {\n        editor.fire('AddUndo', args);\n      }\n      return level;\n    };\n    var clear$1 = function (editor, undoManager, index) {\n      undoManager.data = [];\n      index.set(0);\n      undoManager.typing = false;\n      editor.fire('ClearUndos');\n    };\n    var extra$1 = function (editor, undoManager, index, callback1, callback2) {\n      if (undoManager.transact(callback1)) {\n        var bookmark = undoManager.data[index.get()].bookmark;\n        var lastLevel = undoManager.data[index.get() - 1];\n        applyToEditor(editor, lastLevel, true);\n        if (undoManager.transact(callback2)) {\n          undoManager.data[index.get() - 1].beforeBookmark = bookmark;\n        }\n      }\n    };\n    var redo$1 = function (editor, index, data) {\n      var level;\n      if (index.get() < data.length - 1) {\n        index.set(index.get() + 1);\n        level = data[index.get()];\n        applyToEditor(editor, level, false);\n        editor.setDirty(true);\n        editor.fire('Redo', { level: level });\n      }\n      return level;\n    };\n    var undo$1 = function (editor, undoManager, locks, index) {\n      var level;\n      if (undoManager.typing) {\n        undoManager.add();\n        undoManager.typing = false;\n        setTyping(undoManager, false, locks);\n      }\n      if (index.get() > 0) {\n        index.set(index.get() - 1);\n        level = undoManager.data[index.get()];\n        applyToEditor(editor, level, true);\n        editor.setDirty(true);\n        editor.fire('Undo', { level: level });\n      }\n      return level;\n    };\n    var reset$1 = function (undoManager) {\n      undoManager.clear();\n      undoManager.add();\n    };\n    var hasUndo$1 = function (editor, undoManager, index) {\n      return index.get() > 0 || undoManager.typing && undoManager.data[0] && !isEq$1(createFromEditor(editor), undoManager.data[0]);\n    };\n    var hasRedo$1 = function (undoManager, index) {\n      return index.get() < undoManager.data.length - 1 && !undoManager.typing;\n    };\n    var transact$1 = function (undoManager, locks, callback) {\n      endTyping(undoManager, locks);\n      undoManager.beforeChange();\n      undoManager.ignore(callback);\n      return undoManager.add();\n    };\n    var ignore$1 = function (locks, callback) {\n      try {\n        locks.set(locks.get() + 1);\n        callback();\n      } finally {\n        locks.set(locks.get() - 1);\n      }\n    };\n\n    var addVisualInternal = function (editor, elm) {\n      var dom = editor.dom;\n      var scope = isNonNullable(elm) ? elm : editor.getBody();\n      if (isUndefined(editor.hasVisual)) {\n        editor.hasVisual = isVisualAidsEnabled(editor);\n      }\n      each$k(dom.select('table,a', scope), function (matchedElm) {\n        switch (matchedElm.nodeName) {\n        case 'TABLE':\n          var cls = getVisualAidsTableClass(editor);\n          var value = dom.getAttrib(matchedElm, 'border');\n          if ((!value || value === '0') && editor.hasVisual) {\n            dom.addClass(matchedElm, cls);\n          } else {\n            dom.removeClass(matchedElm, cls);\n          }\n          break;\n        case 'A':\n          if (!dom.getAttrib(matchedElm, 'href')) {\n            var value_1 = dom.getAttrib(matchedElm, 'name') || matchedElm.id;\n            var cls_1 = getVisualAidsAnchorClass(editor);\n            if (value_1 && editor.hasVisual) {\n              dom.addClass(matchedElm, cls_1);\n            } else {\n              dom.removeClass(matchedElm, cls_1);\n            }\n          }\n          break;\n        }\n      });\n      editor.fire('VisualAid', {\n        element: elm,\n        hasVisual: editor.hasVisual\n      });\n    };\n\n    var makePlainAdaptor = function (editor) {\n      return {\n        undoManager: {\n          beforeChange: function (locks, beforeBookmark) {\n            return beforeChange$1(editor, locks, beforeBookmark);\n          },\n          add: function (undoManager, index, locks, beforeBookmark, level, event) {\n            return addUndoLevel$1(editor, undoManager, index, locks, beforeBookmark, level, event);\n          },\n          undo: function (undoManager, locks, index) {\n            return undo$1(editor, undoManager, locks, index);\n          },\n          redo: function (index, data) {\n            return redo$1(editor, index, data);\n          },\n          clear: function (undoManager, index) {\n            return clear$1(editor, undoManager, index);\n          },\n          reset: function (undoManager) {\n            return reset$1(undoManager);\n          },\n          hasUndo: function (undoManager, index) {\n            return hasUndo$1(editor, undoManager, index);\n          },\n          hasRedo: function (undoManager, index) {\n            return hasRedo$1(undoManager, index);\n          },\n          transact: function (undoManager, locks, callback) {\n            return transact$1(undoManager, locks, callback);\n          },\n          ignore: function (locks, callback) {\n            return ignore$1(locks, callback);\n          },\n          extra: function (undoManager, index, callback1, callback2) {\n            return extra$1(editor, undoManager, index, callback1, callback2);\n          }\n        },\n        formatter: {\n          match: function (name, vars, node, similar) {\n            return match$2(editor, name, vars, node, similar);\n          },\n          matchAll: function (names, vars) {\n            return matchAll(editor, names, vars);\n          },\n          matchNode: function (node, name, vars, similar) {\n            return matchNode(editor, node, name, vars, similar);\n          },\n          canApply: function (name) {\n            return canApply(editor, name);\n          },\n          closest: function (names) {\n            return closest(editor, names);\n          },\n          apply: function (name, vars, node) {\n            return applyFormat$1(editor, name, vars, node);\n          },\n          remove: function (name, vars, node, similar) {\n            return remove$1(editor, name, vars, node, similar);\n          },\n          toggle: function (name, vars, node) {\n            return toggle(editor, name, vars, node);\n          },\n          formatChanged: function (registeredFormatListeners, formats, callback, similar, vars) {\n            return formatChangedInternal(editor, registeredFormatListeners, formats, callback, similar, vars);\n          }\n        },\n        editor: {\n          getContent: function (args, format) {\n            return getContentInternal(editor, args, format);\n          },\n          setContent: function (content, args) {\n            return setContentInternal(editor, content, args);\n          },\n          insertContent: function (value, details) {\n            return insertHtmlAtCaret(editor, value, details);\n          },\n          addVisual: function (elm) {\n            return addVisualInternal(editor, elm);\n          }\n        },\n        selection: {\n          getContent: function (format, args) {\n            return getSelectedContentInternal(editor, format, args);\n          }\n        },\n        raw: {\n          getModel: function () {\n            return Optional.none();\n          }\n        }\n      };\n    };\n    var makeRtcAdaptor = function (rtcEditor) {\n      var defaultVars = function (vars) {\n        return isObject(vars) ? vars : {};\n      };\n      var undoManager = rtcEditor.undoManager, formatter = rtcEditor.formatter, editor = rtcEditor.editor, selection = rtcEditor.selection, raw = rtcEditor.raw;\n      return {\n        undoManager: {\n          beforeChange: undoManager.beforeChange,\n          add: undoManager.add,\n          undo: undoManager.undo,\n          redo: undoManager.redo,\n          clear: undoManager.clear,\n          reset: undoManager.reset,\n          hasUndo: undoManager.hasUndo,\n          hasRedo: undoManager.hasRedo,\n          transact: function (_undoManager, _locks, fn) {\n            return undoManager.transact(fn);\n          },\n          ignore: function (_locks, callback) {\n            return undoManager.ignore(callback);\n          },\n          extra: function (_undoManager, _index, callback1, callback2) {\n            return undoManager.extra(callback1, callback2);\n          }\n        },\n        formatter: {\n          match: function (name, vars, _node, similar) {\n            return formatter.match(name, defaultVars(vars), similar);\n          },\n          matchAll: formatter.matchAll,\n          matchNode: formatter.matchNode,\n          canApply: function (name) {\n            return formatter.canApply(name);\n          },\n          closest: function (names) {\n            return formatter.closest(names);\n          },\n          apply: function (name, vars, _node) {\n            return formatter.apply(name, defaultVars(vars));\n          },\n          remove: function (name, vars, _node, _similar) {\n            return formatter.remove(name, defaultVars(vars));\n          },\n          toggle: function (name, vars, _node) {\n            return formatter.toggle(name, defaultVars(vars));\n          },\n          formatChanged: function (_rfl, formats, callback, similar, vars) {\n            return formatter.formatChanged(formats, callback, similar, vars);\n          }\n        },\n        editor: {\n          getContent: function (args, _format) {\n            return editor.getContent(args);\n          },\n          setContent: function (content, args) {\n            return editor.setContent(content, args);\n          },\n          insertContent: function (content, _details) {\n            return editor.insertContent(content);\n          },\n          addVisual: editor.addVisual\n        },\n        selection: {\n          getContent: function (_format, args) {\n            return selection.getContent(args);\n          }\n        },\n        raw: {\n          getModel: function () {\n            return Optional.some(raw.getRawModel());\n          }\n        }\n      };\n    };\n    var makeNoopAdaptor = function () {\n      var nul = constant(null);\n      var empty = constant('');\n      return {\n        undoManager: {\n          beforeChange: noop,\n          add: nul,\n          undo: nul,\n          redo: nul,\n          clear: noop,\n          reset: noop,\n          hasUndo: never,\n          hasRedo: never,\n          transact: nul,\n          ignore: noop,\n          extra: noop\n        },\n        formatter: {\n          match: never,\n          matchAll: constant([]),\n          matchNode: constant(undefined),\n          canApply: never,\n          closest: empty,\n          apply: noop,\n          remove: noop,\n          toggle: noop,\n          formatChanged: constant({ unbind: noop })\n        },\n        editor: {\n          getContent: empty,\n          setContent: empty,\n          insertContent: noop,\n          addVisual: noop\n        },\n        selection: { getContent: empty },\n        raw: { getModel: constant(Optional.none()) }\n      };\n    };\n    var isRtc = function (editor) {\n      return has$2(editor.plugins, 'rtc');\n    };\n    var getRtcSetup = function (editor) {\n      return get$9(editor.plugins, 'rtc').bind(function (rtcPlugin) {\n        return Optional.from(rtcPlugin.setup);\n      });\n    };\n    var setup$i = function (editor) {\n      var editorCast = editor;\n      return getRtcSetup(editor).fold(function () {\n        editorCast.rtcInstance = makePlainAdaptor(editor);\n        return Optional.none();\n      }, function (setup) {\n        editorCast.rtcInstance = makeNoopAdaptor();\n        return Optional.some(function () {\n          return setup().then(function (rtcEditor) {\n            editorCast.rtcInstance = makeRtcAdaptor(rtcEditor);\n            return rtcEditor.rtc.isRemote;\n          });\n        });\n      });\n    };\n    var getRtcInstanceWithFallback = function (editor) {\n      return editor.rtcInstance ? editor.rtcInstance : makePlainAdaptor(editor);\n    };\n    var getRtcInstanceWithError = function (editor) {\n      var rtcInstance = editor.rtcInstance;\n      if (!rtcInstance) {\n        throw new Error('Failed to get RTC instance not yet initialized.');\n      } else {\n        return rtcInstance;\n      }\n    };\n    var beforeChange = function (editor, locks, beforeBookmark) {\n      getRtcInstanceWithError(editor).undoManager.beforeChange(locks, beforeBookmark);\n    };\n    var addUndoLevel = function (editor, undoManager, index, locks, beforeBookmark, level, event) {\n      return getRtcInstanceWithError(editor).undoManager.add(undoManager, index, locks, beforeBookmark, level, event);\n    };\n    var undo = function (editor, undoManager, locks, index) {\n      return getRtcInstanceWithError(editor).undoManager.undo(undoManager, locks, index);\n    };\n    var redo = function (editor, index, data) {\n      return getRtcInstanceWithError(editor).undoManager.redo(index, data);\n    };\n    var clear = function (editor, undoManager, index) {\n      getRtcInstanceWithError(editor).undoManager.clear(undoManager, index);\n    };\n    var reset = function (editor, undoManager) {\n      getRtcInstanceWithError(editor).undoManager.reset(undoManager);\n    };\n    var hasUndo = function (editor, undoManager, index) {\n      return getRtcInstanceWithError(editor).undoManager.hasUndo(undoManager, index);\n    };\n    var hasRedo = function (editor, undoManager, index) {\n      return getRtcInstanceWithError(editor).undoManager.hasRedo(undoManager, index);\n    };\n    var transact = function (editor, undoManager, locks, callback) {\n      return getRtcInstanceWithError(editor).undoManager.transact(undoManager, locks, callback);\n    };\n    var ignore = function (editor, locks, callback) {\n      getRtcInstanceWithError(editor).undoManager.ignore(locks, callback);\n    };\n    var extra = function (editor, undoManager, index, callback1, callback2) {\n      getRtcInstanceWithError(editor).undoManager.extra(undoManager, index, callback1, callback2);\n    };\n    var matchFormat = function (editor, name, vars, node, similar) {\n      return getRtcInstanceWithError(editor).formatter.match(name, vars, node, similar);\n    };\n    var matchAllFormats = function (editor, names, vars) {\n      return getRtcInstanceWithError(editor).formatter.matchAll(names, vars);\n    };\n    var matchNodeFormat = function (editor, node, name, vars, similar) {\n      return getRtcInstanceWithError(editor).formatter.matchNode(node, name, vars, similar);\n    };\n    var canApplyFormat = function (editor, name) {\n      return getRtcInstanceWithError(editor).formatter.canApply(name);\n    };\n    var closestFormat = function (editor, names) {\n      return getRtcInstanceWithError(editor).formatter.closest(names);\n    };\n    var applyFormat = function (editor, name, vars, node) {\n      getRtcInstanceWithError(editor).formatter.apply(name, vars, node);\n    };\n    var removeFormat = function (editor, name, vars, node, similar) {\n      getRtcInstanceWithError(editor).formatter.remove(name, vars, node, similar);\n    };\n    var toggleFormat = function (editor, name, vars, node) {\n      getRtcInstanceWithError(editor).formatter.toggle(name, vars, node);\n    };\n    var formatChanged = function (editor, registeredFormatListeners, formats, callback, similar, vars) {\n      return getRtcInstanceWithError(editor).formatter.formatChanged(registeredFormatListeners, formats, callback, similar, vars);\n    };\n    var getContent$2 = function (editor, args, format) {\n      return getRtcInstanceWithFallback(editor).editor.getContent(args, format);\n    };\n    var setContent$2 = function (editor, content, args) {\n      return getRtcInstanceWithFallback(editor).editor.setContent(content, args);\n    };\n    var insertContent = function (editor, value, details) {\n      return getRtcInstanceWithFallback(editor).editor.insertContent(value, details);\n    };\n    var getSelectedContent = function (editor, format, args) {\n      return getRtcInstanceWithError(editor).selection.getContent(format, args);\n    };\n    var addVisual$1 = function (editor, elm) {\n      return getRtcInstanceWithError(editor).editor.addVisual(elm);\n    };\n\n    var getContent$1 = function (editor, args) {\n      if (args === void 0) {\n        args = {};\n      }\n      var format = args.format ? args.format : 'html';\n      return getSelectedContent(editor, format, args);\n    };\n\n    var removeEmpty = function (text) {\n      if (text.dom.length === 0) {\n        remove$7(text);\n        return Optional.none();\n      } else {\n        return Optional.some(text);\n      }\n    };\n    var walkPastBookmark = function (node, start) {\n      return node.filter(function (elm) {\n        return BookmarkManager.isBookmarkNode(elm.dom);\n      }).bind(start ? nextSibling : prevSibling);\n    };\n    var merge = function (outer, inner, rng, start) {\n      var outerElm = outer.dom;\n      var innerElm = inner.dom;\n      var oldLength = start ? outerElm.length : innerElm.length;\n      if (start) {\n        mergeTextNodes(outerElm, innerElm, false, !start);\n        rng.setStart(innerElm, oldLength);\n      } else {\n        mergeTextNodes(innerElm, outerElm, false, !start);\n        rng.setEnd(innerElm, oldLength);\n      }\n    };\n    var normalizeTextIfRequired = function (inner, start) {\n      parent(inner).each(function (root) {\n        var text = inner.dom;\n        if (start && needsToBeNbspLeft(root, CaretPosition(text, 0))) {\n          normalizeWhitespaceAfter(text, 0);\n        } else if (!start && needsToBeNbspRight(root, CaretPosition(text, text.length))) {\n          normalizeWhitespaceBefore(text, text.length);\n        }\n      });\n    };\n    var mergeAndNormalizeText = function (outerNode, innerNode, rng, start) {\n      outerNode.bind(function (outer) {\n        var normalizer = start ? normalizeWhitespaceBefore : normalizeWhitespaceAfter;\n        normalizer(outer.dom, start ? outer.dom.length : 0);\n        return innerNode.filter(isText$8).map(function (inner) {\n          return merge(outer, inner, rng, start);\n        });\n      }).orThunk(function () {\n        var innerTextNode = walkPastBookmark(innerNode, start).or(innerNode).filter(isText$8);\n        return innerTextNode.map(function (inner) {\n          return normalizeTextIfRequired(inner, start);\n        });\n      });\n    };\n    var rngSetContent = function (rng, fragment) {\n      var firstChild = Optional.from(fragment.firstChild).map(SugarElement.fromDom);\n      var lastChild = Optional.from(fragment.lastChild).map(SugarElement.fromDom);\n      rng.deleteContents();\n      rng.insertNode(fragment);\n      var prevText = firstChild.bind(prevSibling).filter(isText$8).bind(removeEmpty);\n      var nextText = lastChild.bind(nextSibling).filter(isText$8).bind(removeEmpty);\n      mergeAndNormalizeText(prevText, firstChild, rng, true);\n      mergeAndNormalizeText(nextText, lastChild, rng, false);\n      rng.collapse(false);\n    };\n    var setupArgs = function (args, content) {\n      return __assign(__assign({ format: 'html' }, args), {\n        set: true,\n        selection: true,\n        content: content\n      });\n    };\n    var cleanContent = function (editor, args) {\n      if (args.format !== 'raw') {\n        var rng = editor.selection.getRng();\n        var contextBlock = editor.dom.getParent(rng.commonAncestorContainer, editor.dom.isBlock);\n        var contextArgs = contextBlock ? { context: contextBlock.nodeName.toLowerCase() } : {};\n        var node = editor.parser.parse(args.content, __assign(__assign({\n          isRootContent: true,\n          forced_root_block: false\n        }, contextArgs), args));\n        return HtmlSerializer({ validate: editor.validate }, editor.schema).serialize(node);\n      } else {\n        return args.content;\n      }\n    };\n    var setContent$1 = function (editor, content, args) {\n      if (args === void 0) {\n        args = {};\n      }\n      var defaultedArgs = setupArgs(args, content);\n      var updatedArgs = defaultedArgs;\n      if (!defaultedArgs.no_events) {\n        var eventArgs = editor.fire('BeforeSetContent', defaultedArgs);\n        if (eventArgs.isDefaultPrevented()) {\n          editor.fire('SetContent', eventArgs);\n          return;\n        } else {\n          updatedArgs = eventArgs;\n        }\n      }\n      updatedArgs.content = cleanContent(editor, updatedArgs);\n      var rng = editor.selection.getRng();\n      rngSetContent(rng, rng.createContextualFragment(updatedArgs.content));\n      editor.selection.setRng(rng);\n      scrollRangeIntoView(editor, rng);\n      if (!updatedArgs.no_events) {\n        editor.fire('SetContent', updatedArgs);\n      }\n    };\n\n    var deleteFromCallbackMap = function (callbackMap, selector, callback) {\n      if (callbackMap && has$2(callbackMap, selector)) {\n        var newCallbacks = filter$4(callbackMap[selector], function (cb) {\n          return cb !== callback;\n        });\n        if (newCallbacks.length === 0) {\n          delete callbackMap[selector];\n        } else {\n          callbackMap[selector] = newCallbacks;\n        }\n      }\n    };\n    function SelectorChanged (dom, editor) {\n      var selectorChangedData;\n      var currentSelectors;\n      var findMatchingNode = function (selector, nodes) {\n        return find$3(nodes, function (node) {\n          return dom.is(node, selector);\n        });\n      };\n      var getParents = function (elem) {\n        return dom.getParents(elem, null, dom.getRoot());\n      };\n      return {\n        selectorChangedWithUnbind: function (selector, callback) {\n          if (!selectorChangedData) {\n            selectorChangedData = {};\n            currentSelectors = {};\n            editor.on('NodeChange', function (e) {\n              var node = e.element;\n              var parents = getParents(node);\n              var matchedSelectors = {};\n              Tools.each(selectorChangedData, function (callbacks, selector) {\n                findMatchingNode(selector, parents).each(function (node) {\n                  if (!currentSelectors[selector]) {\n                    each$k(callbacks, function (callback) {\n                      callback(true, {\n                        node: node,\n                        selector: selector,\n                        parents: parents\n                      });\n                    });\n                    currentSelectors[selector] = callbacks;\n                  }\n                  matchedSelectors[selector] = callbacks;\n                });\n              });\n              Tools.each(currentSelectors, function (callbacks, selector) {\n                if (!matchedSelectors[selector]) {\n                  delete currentSelectors[selector];\n                  Tools.each(callbacks, function (callback) {\n                    callback(false, {\n                      node: node,\n                      selector: selector,\n                      parents: parents\n                    });\n                  });\n                }\n              });\n            });\n          }\n          if (!selectorChangedData[selector]) {\n            selectorChangedData[selector] = [];\n          }\n          selectorChangedData[selector].push(callback);\n          findMatchingNode(selector, getParents(editor.selection.getStart())).each(function () {\n            currentSelectors[selector] = selectorChangedData[selector];\n          });\n          return {\n            unbind: function () {\n              deleteFromCallbackMap(selectorChangedData, selector, callback);\n              deleteFromCallbackMap(currentSelectors, selector, callback);\n            }\n          };\n        }\n      };\n    }\n\n    var isNativeIeSelection = function (rng) {\n      return !!rng.select;\n    };\n    var isAttachedToDom = function (node) {\n      return !!(node && node.ownerDocument) && contains$1(SugarElement.fromDom(node.ownerDocument), SugarElement.fromDom(node));\n    };\n    var isValidRange = function (rng) {\n      if (!rng) {\n        return false;\n      } else if (isNativeIeSelection(rng)) {\n        return true;\n      } else {\n        return isAttachedToDom(rng.startContainer) && isAttachedToDom(rng.endContainer);\n      }\n    };\n    var EditorSelection = function (dom, win, serializer, editor) {\n      var selectedRange;\n      var explicitRange;\n      var selectorChangedWithUnbind = SelectorChanged(dom, editor).selectorChangedWithUnbind;\n      var setCursorLocation = function (node, offset) {\n        var rng = dom.createRng();\n        if (isNonNullable(node) && isNonNullable(offset)) {\n          rng.setStart(node, offset);\n          rng.setEnd(node, offset);\n          setRng(rng);\n          collapse(false);\n        } else {\n          moveEndPoint(dom, rng, editor.getBody(), true);\n          setRng(rng);\n        }\n      };\n      var getContent = function (args) {\n        return getContent$1(editor, args);\n      };\n      var setContent = function (content, args) {\n        return setContent$1(editor, content, args);\n      };\n      var getStart$1 = function (real) {\n        return getStart(editor.getBody(), getRng$1(), real);\n      };\n      var getEnd$1 = function (real) {\n        return getEnd(editor.getBody(), getRng$1(), real);\n      };\n      var getBookmark = function (type, normalized) {\n        return bookmarkManager.getBookmark(type, normalized);\n      };\n      var moveToBookmark = function (bookmark) {\n        return bookmarkManager.moveToBookmark(bookmark);\n      };\n      var select$1 = function (node, content) {\n        select(dom, node, content).each(setRng);\n        return node;\n      };\n      var isCollapsed = function () {\n        var rng = getRng$1(), sel = getSel();\n        if (!rng || rng.item) {\n          return false;\n        }\n        if (rng.compareEndPoints) {\n          return rng.compareEndPoints('StartToEnd', rng) === 0;\n        }\n        return !sel || rng.collapsed;\n      };\n      var collapse = function (toStart) {\n        var rng = getRng$1();\n        rng.collapse(!!toStart);\n        setRng(rng);\n      };\n      var getSel = function () {\n        return win.getSelection ? win.getSelection() : win.document.selection;\n      };\n      var getRng$1 = function () {\n        var selection, rng, elm;\n        var tryCompareBoundaryPoints = function (how, sourceRange, destinationRange) {\n          try {\n            return sourceRange.compareBoundaryPoints(how, destinationRange);\n          } catch (ex) {\n            return -1;\n          }\n        };\n        var doc = win.document;\n        if (editor.bookmark !== undefined && hasFocus(editor) === false) {\n          var bookmark = getRng(editor);\n          if (bookmark.isSome()) {\n            return bookmark.map(function (r) {\n              return processRanges(editor, [r])[0];\n            }).getOr(doc.createRange());\n          }\n        }\n        try {\n          if ((selection = getSel()) && !isRestrictedNode(selection.anchorNode)) {\n            if (selection.rangeCount > 0) {\n              rng = selection.getRangeAt(0);\n            } else {\n              rng = selection.createRange ? selection.createRange() : doc.createRange();\n            }\n            rng = processRanges(editor, [rng])[0];\n          }\n        } catch (ex) {\n        }\n        if (!rng) {\n          rng = doc.createRange ? doc.createRange() : doc.body.createTextRange();\n        }\n        if (rng.setStart && rng.startContainer.nodeType === 9 && rng.collapsed) {\n          elm = dom.getRoot();\n          rng.setStart(elm, 0);\n          rng.setEnd(elm, 0);\n        }\n        if (selectedRange && explicitRange) {\n          if (tryCompareBoundaryPoints(rng.START_TO_START, rng, selectedRange) === 0 && tryCompareBoundaryPoints(rng.END_TO_END, rng, selectedRange) === 0) {\n            rng = explicitRange;\n          } else {\n            selectedRange = null;\n            explicitRange = null;\n          }\n        }\n        return rng;\n      };\n      var setRng = function (rng, forward) {\n        var node;\n        if (!isValidRange(rng)) {\n          return;\n        }\n        var ieRange = isNativeIeSelection(rng) ? rng : null;\n        if (ieRange) {\n          explicitRange = null;\n          try {\n            ieRange.select();\n          } catch (ex) {\n          }\n          return;\n        }\n        var sel = getSel();\n        var evt = editor.fire('SetSelectionRange', {\n          range: rng,\n          forward: forward\n        });\n        rng = evt.range;\n        if (sel) {\n          explicitRange = rng;\n          try {\n            sel.removeAllRanges();\n            sel.addRange(rng);\n          } catch (ex) {\n          }\n          if (forward === false && sel.extend) {\n            sel.collapse(rng.endContainer, rng.endOffset);\n            sel.extend(rng.startContainer, rng.startOffset);\n          }\n          selectedRange = sel.rangeCount > 0 ? sel.getRangeAt(0) : null;\n        }\n        if (!rng.collapsed && rng.startContainer === rng.endContainer && sel.setBaseAndExtent && !Env.ie) {\n          if (rng.endOffset - rng.startOffset < 2) {\n            if (rng.startContainer.hasChildNodes()) {\n              node = rng.startContainer.childNodes[rng.startOffset];\n              if (node && node.tagName === 'IMG') {\n                sel.setBaseAndExtent(rng.startContainer, rng.startOffset, rng.endContainer, rng.endOffset);\n                if (sel.anchorNode !== rng.startContainer || sel.focusNode !== rng.endContainer) {\n                  sel.setBaseAndExtent(node, 0, node, 1);\n                }\n              }\n            }\n          }\n        }\n        editor.fire('AfterSetSelectionRange', {\n          range: rng,\n          forward: forward\n        });\n      };\n      var setNode = function (elm) {\n        setContent(dom.getOuterHTML(elm));\n        return elm;\n      };\n      var getNode$1 = function () {\n        return getNode(editor.getBody(), getRng$1());\n      };\n      var getSelectedBlocks$1 = function (startElm, endElm) {\n        return getSelectedBlocks(dom, getRng$1(), startElm, endElm);\n      };\n      var isForward = function () {\n        var sel = getSel();\n        var anchorNode = sel === null || sel === void 0 ? void 0 : sel.anchorNode;\n        var focusNode = sel === null || sel === void 0 ? void 0 : sel.focusNode;\n        if (!sel || !anchorNode || !focusNode || isRestrictedNode(anchorNode) || isRestrictedNode(focusNode)) {\n          return true;\n        }\n        var anchorRange = dom.createRng();\n        anchorRange.setStart(anchorNode, sel.anchorOffset);\n        anchorRange.collapse(true);\n        var focusRange = dom.createRng();\n        focusRange.setStart(focusNode, sel.focusOffset);\n        focusRange.collapse(true);\n        return anchorRange.compareBoundaryPoints(anchorRange.START_TO_START, focusRange) <= 0;\n      };\n      var normalize = function () {\n        var rng = getRng$1();\n        var sel = getSel();\n        if (!hasMultipleRanges(sel) && hasAnyRanges(editor)) {\n          var normRng = normalize$2(dom, rng);\n          normRng.each(function (normRng) {\n            setRng(normRng, isForward());\n          });\n          return normRng.getOr(rng);\n        }\n        return rng;\n      };\n      var selectorChanged = function (selector, callback) {\n        selectorChangedWithUnbind(selector, callback);\n        return exports;\n      };\n      var getScrollContainer = function () {\n        var scrollContainer;\n        var node = dom.getRoot();\n        while (node && node.nodeName !== 'BODY') {\n          if (node.scrollHeight > node.clientHeight) {\n            scrollContainer = node;\n            break;\n          }\n          node = node.parentNode;\n        }\n        return scrollContainer;\n      };\n      var scrollIntoView = function (elm, alignToTop) {\n        if (isNonNullable(elm)) {\n          scrollElementIntoView(editor, elm, alignToTop);\n        } else {\n          scrollRangeIntoView(editor, getRng$1(), alignToTop);\n        }\n      };\n      var placeCaretAt = function (clientX, clientY) {\n        return setRng(fromPoint(clientX, clientY, editor.getDoc()));\n      };\n      var getBoundingClientRect = function () {\n        var rng = getRng$1();\n        return rng.collapsed ? CaretPosition.fromRangeStart(rng).getClientRects()[0] : rng.getBoundingClientRect();\n      };\n      var destroy = function () {\n        win = selectedRange = explicitRange = null;\n        controlSelection.destroy();\n      };\n      var exports = {\n        bookmarkManager: null,\n        controlSelection: null,\n        dom: dom,\n        win: win,\n        serializer: serializer,\n        editor: editor,\n        collapse: collapse,\n        setCursorLocation: setCursorLocation,\n        getContent: getContent,\n        setContent: setContent,\n        getBookmark: getBookmark,\n        moveToBookmark: moveToBookmark,\n        select: select$1,\n        isCollapsed: isCollapsed,\n        isForward: isForward,\n        setNode: setNode,\n        getNode: getNode$1,\n        getSel: getSel,\n        setRng: setRng,\n        getRng: getRng$1,\n        getStart: getStart$1,\n        getEnd: getEnd$1,\n        getSelectedBlocks: getSelectedBlocks$1,\n        normalize: normalize,\n        selectorChanged: selectorChanged,\n        selectorChangedWithUnbind: selectorChangedWithUnbind,\n        getScrollContainer: getScrollContainer,\n        scrollIntoView: scrollIntoView,\n        placeCaretAt: placeCaretAt,\n        getBoundingClientRect: getBoundingClientRect,\n        destroy: destroy\n      };\n      var bookmarkManager = BookmarkManager(exports);\n      var controlSelection = ControlSelection(exports, editor);\n      exports.bookmarkManager = bookmarkManager;\n      exports.controlSelection = controlSelection;\n      return exports;\n    };\n\n    var removeAttrs = function (node, names) {\n      each$k(names, function (name) {\n        node.attr(name, null);\n      });\n    };\n    var addFontToSpansFilter = function (domParser, styles, fontSizes) {\n      domParser.addNodeFilter('font', function (nodes) {\n        each$k(nodes, function (node) {\n          var props = styles.parse(node.attr('style'));\n          var color = node.attr('color');\n          var face = node.attr('face');\n          var size = node.attr('size');\n          if (color) {\n            props.color = color;\n          }\n          if (face) {\n            props['font-family'] = face;\n          }\n          if (size) {\n            props['font-size'] = fontSizes[parseInt(node.attr('size'), 10) - 1];\n          }\n          node.name = 'span';\n          node.attr('style', styles.serialize(props));\n          removeAttrs(node, [\n            'color',\n            'face',\n            'size'\n          ]);\n        });\n      });\n    };\n    var addStrikeToSpanFilter = function (domParser, styles) {\n      domParser.addNodeFilter('strike', function (nodes) {\n        each$k(nodes, function (node) {\n          var props = styles.parse(node.attr('style'));\n          props['text-decoration'] = 'line-through';\n          node.name = 'span';\n          node.attr('style', styles.serialize(props));\n        });\n      });\n    };\n    var addFilters = function (domParser, settings) {\n      var styles = Styles();\n      if (settings.convert_fonts_to_spans) {\n        addFontToSpansFilter(domParser, styles, Tools.explode(settings.font_size_legacy_values));\n      }\n      addStrikeToSpanFilter(domParser, styles);\n    };\n    var register$2 = function (domParser, settings) {\n      if (settings.inline_styles) {\n        addFilters(domParser, settings);\n      }\n    };\n\n    var blobUriToBlob = function (url) {\n      return new promiseObj(function (resolve, reject) {\n        var rejectWithError = function () {\n          reject('Cannot convert ' + url + ' to Blob. Resource might not exist or is inaccessible.');\n        };\n        try {\n          var xhr_1 = new XMLHttpRequest();\n          xhr_1.open('GET', url, true);\n          xhr_1.responseType = 'blob';\n          xhr_1.onload = function () {\n            if (xhr_1.status === 200) {\n              resolve(xhr_1.response);\n            } else {\n              rejectWithError();\n            }\n          };\n          xhr_1.onerror = rejectWithError;\n          xhr_1.send();\n        } catch (ex) {\n          rejectWithError();\n        }\n      });\n    };\n    var parseDataUri$1 = function (uri) {\n      var type;\n      var uriParts = decodeURIComponent(uri).split(',');\n      var matches = /data:([^;]+)/.exec(uriParts[0]);\n      if (matches) {\n        type = matches[1];\n      }\n      return {\n        type: type,\n        data: uriParts[1]\n      };\n    };\n    var buildBlob = function (type, data) {\n      var str;\n      try {\n        str = atob(data);\n      } catch (e) {\n        return Optional.none();\n      }\n      var arr = new Uint8Array(str.length);\n      for (var i = 0; i < arr.length; i++) {\n        arr[i] = str.charCodeAt(i);\n      }\n      return Optional.some(new Blob([arr], { type: type }));\n    };\n    var dataUriToBlob = function (uri) {\n      return new promiseObj(function (resolve) {\n        var _a = parseDataUri$1(uri), type = _a.type, data = _a.data;\n        buildBlob(type, data).fold(function () {\n          return resolve(new Blob([]));\n        }, resolve);\n      });\n    };\n    var uriToBlob = function (url) {\n      if (url.indexOf('blob:') === 0) {\n        return blobUriToBlob(url);\n      }\n      if (url.indexOf('data:') === 0) {\n        return dataUriToBlob(url);\n      }\n      return null;\n    };\n    var blobToDataUri = function (blob) {\n      return new promiseObj(function (resolve) {\n        var reader = new FileReader();\n        reader.onloadend = function () {\n          resolve(reader.result);\n        };\n        reader.readAsDataURL(blob);\n      });\n    };\n\n    var count$1 = 0;\n    var uniqueId = function (prefix) {\n      return (prefix || 'blobid') + count$1++;\n    };\n    var imageToBlobInfo = function (blobCache, img, resolve, reject) {\n      var base64, blobInfo;\n      if (img.src.indexOf('blob:') === 0) {\n        blobInfo = blobCache.getByUri(img.src);\n        if (blobInfo) {\n          resolve({\n            image: img,\n            blobInfo: blobInfo\n          });\n        } else {\n          uriToBlob(img.src).then(function (blob) {\n            blobToDataUri(blob).then(function (dataUri) {\n              base64 = parseDataUri$1(dataUri).data;\n              blobInfo = blobCache.create(uniqueId(), blob, base64);\n              blobCache.add(blobInfo);\n              resolve({\n                image: img,\n                blobInfo: blobInfo\n              });\n            });\n          }, function (err) {\n            reject(err);\n          });\n        }\n        return;\n      }\n      var _a = parseDataUri$1(img.src), data = _a.data, type = _a.type;\n      base64 = data;\n      blobInfo = blobCache.getByData(base64, type);\n      if (blobInfo) {\n        resolve({\n          image: img,\n          blobInfo: blobInfo\n        });\n      } else {\n        uriToBlob(img.src).then(function (blob) {\n          blobInfo = blobCache.create(uniqueId(), blob, base64);\n          blobCache.add(blobInfo);\n          resolve({\n            image: img,\n            blobInfo: blobInfo\n          });\n        }, function (err) {\n          reject(err);\n        });\n      }\n    };\n    var getAllImages = function (elm) {\n      return elm ? from(elm.getElementsByTagName('img')) : [];\n    };\n    var ImageScanner = function (uploadStatus, blobCache) {\n      var cachedPromises = {};\n      var findAll = function (elm, predicate) {\n        if (!predicate) {\n          predicate = always;\n        }\n        var images = filter$4(getAllImages(elm), function (img) {\n          var src = img.src;\n          if (!Env.fileApi) {\n            return false;\n          }\n          if (img.hasAttribute('data-mce-bogus')) {\n            return false;\n          }\n          if (img.hasAttribute('data-mce-placeholder')) {\n            return false;\n          }\n          if (!src || src === Env.transparentSrc) {\n            return false;\n          }\n          if (src.indexOf('blob:') === 0) {\n            return !uploadStatus.isUploaded(src) && predicate(img);\n          }\n          if (src.indexOf('data:') === 0) {\n            return predicate(img);\n          }\n          return false;\n        });\n        var promises = map$3(images, function (img) {\n          if (cachedPromises[img.src] !== undefined) {\n            return new promiseObj(function (resolve) {\n              cachedPromises[img.src].then(function (imageInfo) {\n                if (typeof imageInfo === 'string') {\n                  return imageInfo;\n                }\n                resolve({\n                  image: img,\n                  blobInfo: imageInfo.blobInfo\n                });\n              });\n            });\n          }\n          var newPromise = new promiseObj(function (resolve, reject) {\n            imageToBlobInfo(blobCache, img, resolve, reject);\n          }).then(function (result) {\n            delete cachedPromises[result.image.src];\n            return result;\n          }).catch(function (error) {\n            delete cachedPromises[img.src];\n            return error;\n          });\n          cachedPromises[img.src] = newPromise;\n          return newPromise;\n        });\n        return promiseObj.all(promises);\n      };\n      return { findAll: findAll };\n    };\n\n    var extractBase64DataUris = function (html) {\n      var dataImageUri = /data:[^;<\"'\\s]+;base64,([a-z0-9\\+\\/=\\s]+)/gi;\n      var chunks = [];\n      var uris = {};\n      var prefix = generate('img');\n      var matches;\n      var index = 0;\n      var count = 0;\n      while (matches = dataImageUri.exec(html)) {\n        var uri = matches[0];\n        var imageId = prefix + '_' + count++;\n        uris[imageId] = uri;\n        if (index < matches.index) {\n          chunks.push(html.substr(index, matches.index - index));\n        }\n        chunks.push(imageId);\n        index = matches.index + uri.length;\n      }\n      var re = new RegExp(prefix + '_[0-9]+', 'g');\n      if (index === 0) {\n        return {\n          prefix: prefix,\n          uris: uris,\n          html: html,\n          re: re\n        };\n      } else {\n        if (index < html.length) {\n          chunks.push(html.substr(index));\n        }\n        return {\n          prefix: prefix,\n          uris: uris,\n          html: chunks.join(''),\n          re: re\n        };\n      }\n    };\n    var restoreDataUris = function (html, result) {\n      return html.replace(result.re, function (imageId) {\n        return get$9(result.uris, imageId).getOr(imageId);\n      });\n    };\n    var parseDataUri = function (uri) {\n      var matches = /data:([^;]+);base64,([a-z0-9\\+\\/=\\s]+)/i.exec(uri);\n      if (matches) {\n        return Optional.some({\n          type: matches[1],\n          data: decodeURIComponent(matches[2])\n        });\n      } else {\n        return Optional.none();\n      }\n    };\n\n    var paddEmptyNode = function (settings, args, blockElements, node) {\n      var brPreferred = settings.padd_empty_with_br || args.insert;\n      if (brPreferred && blockElements[node.name]) {\n        node.empty().append(new AstNode('br', 1)).shortEnded = true;\n      } else {\n        node.empty().append(new AstNode('#text', 3)).value = nbsp;\n      }\n    };\n    var isPaddedWithNbsp = function (node) {\n      return hasOnlyChild(node, '#text') && node.firstChild.value === nbsp;\n    };\n    var hasOnlyChild = function (node, name) {\n      return node && node.firstChild && node.firstChild === node.lastChild && node.firstChild.name === name;\n    };\n    var isPadded = function (schema, node) {\n      var rule = schema.getElementRule(node.name);\n      return rule && rule.paddEmpty;\n    };\n    var isEmpty = function (schema, nonEmptyElements, whitespaceElements, node) {\n      return node.isEmpty(nonEmptyElements, whitespaceElements, function (node) {\n        return isPadded(schema, node);\n      });\n    };\n    var isLineBreakNode = function (node, blockElements) {\n      return node && (has$2(blockElements, node.name) || node.name === 'br');\n    };\n\n    var isBogusImage = function (img) {\n      return isNonNullable(img.attr('data-mce-bogus'));\n    };\n    var isInternalImageSource = function (img) {\n      return img.attr('src') === Env.transparentSrc || isNonNullable(img.attr('data-mce-placeholder'));\n    };\n    var isValidDataImg = function (img, settings) {\n      if (settings.images_dataimg_filter) {\n        var imgElem_1 = new Image();\n        imgElem_1.src = img.attr('src');\n        each$j(img.attributes.map, function (value, key) {\n          imgElem_1.setAttribute(key, value);\n        });\n        return settings.images_dataimg_filter(imgElem_1);\n      } else {\n        return true;\n      }\n    };\n    var registerBase64ImageFilter = function (parser, settings) {\n      var blobCache = settings.blob_cache;\n      var processImage = function (img) {\n        var inputSrc = img.attr('src');\n        if (isInternalImageSource(img) || isBogusImage(img)) {\n          return;\n        }\n        parseDataUri(inputSrc).filter(function () {\n          return isValidDataImg(img, settings);\n        }).bind(function (_a) {\n          var type = _a.type, data = _a.data;\n          return Optional.from(blobCache.getByData(data, type)).orThunk(function () {\n            return buildBlob(type, data).map(function (blob) {\n              var blobInfo = blobCache.create(uniqueId(), blob, data);\n              blobCache.add(blobInfo);\n              return blobInfo;\n            });\n          });\n        }).each(function (blobInfo) {\n          img.attr('src', blobInfo.blobUri());\n        });\n      };\n      if (blobCache) {\n        parser.addAttributeFilter('src', function (nodes) {\n          return each$k(nodes, processImage);\n        });\n      }\n    };\n    var register$1 = function (parser, settings) {\n      var schema = parser.schema;\n      if (settings.remove_trailing_brs) {\n        parser.addNodeFilter('br', function (nodes, _, args) {\n          var i;\n          var l = nodes.length;\n          var node;\n          var blockElements = Tools.extend({}, schema.getBlockElements());\n          var nonEmptyElements = schema.getNonEmptyElements();\n          var parent, lastParent, prev, prevName;\n          var whiteSpaceElements = schema.getWhiteSpaceElements();\n          var elementRule, textNode;\n          blockElements.body = 1;\n          for (i = 0; i < l; i++) {\n            node = nodes[i];\n            parent = node.parent;\n            if (blockElements[node.parent.name] && node === parent.lastChild) {\n              prev = node.prev;\n              while (prev) {\n                prevName = prev.name;\n                if (prevName !== 'span' || prev.attr('data-mce-type') !== 'bookmark') {\n                  if (prevName === 'br') {\n                    node = null;\n                  }\n                  break;\n                }\n                prev = prev.prev;\n              }\n              if (node) {\n                node.remove();\n                if (isEmpty(schema, nonEmptyElements, whiteSpaceElements, parent)) {\n                  elementRule = schema.getElementRule(parent.name);\n                  if (elementRule) {\n                    if (elementRule.removeEmpty) {\n                      parent.remove();\n                    } else if (elementRule.paddEmpty) {\n                      paddEmptyNode(settings, args, blockElements, parent);\n                    }\n                  }\n                }\n              }\n            } else {\n              lastParent = node;\n              while (parent && parent.firstChild === lastParent && parent.lastChild === lastParent) {\n                lastParent = parent;\n                if (blockElements[parent.name]) {\n                  break;\n                }\n                parent = parent.parent;\n              }\n              if (lastParent === parent && settings.padd_empty_with_br !== true) {\n                textNode = new AstNode('#text', 3);\n                textNode.value = nbsp;\n                node.replace(textNode);\n              }\n            }\n          }\n        });\n      }\n      parser.addAttributeFilter('href', function (nodes) {\n        var i = nodes.length;\n        var appendRel = function (rel) {\n          var parts = rel.split(' ').filter(function (p) {\n            return p.length > 0;\n          });\n          return parts.concat(['noopener']).sort().join(' ');\n        };\n        var addNoOpener = function (rel) {\n          var newRel = rel ? Tools.trim(rel) : '';\n          if (!/\\b(noopener)\\b/g.test(newRel)) {\n            return appendRel(newRel);\n          } else {\n            return newRel;\n          }\n        };\n        if (!settings.allow_unsafe_link_target) {\n          while (i--) {\n            var node = nodes[i];\n            if (node.name === 'a' && node.attr('target') === '_blank') {\n              node.attr('rel', addNoOpener(node.attr('rel')));\n            }\n          }\n        }\n      });\n      if (!settings.allow_html_in_named_anchor) {\n        parser.addAttributeFilter('id,name', function (nodes) {\n          var i = nodes.length, sibling, prevSibling, parent, node;\n          while (i--) {\n            node = nodes[i];\n            if (node.name === 'a' && node.firstChild && !node.attr('href')) {\n              parent = node.parent;\n              sibling = node.lastChild;\n              do {\n                prevSibling = sibling.prev;\n                parent.insert(sibling, node);\n                sibling = prevSibling;\n              } while (sibling);\n            }\n          }\n        });\n      }\n      if (settings.fix_list_elements) {\n        parser.addNodeFilter('ul,ol', function (nodes) {\n          var i = nodes.length, node, parentNode;\n          while (i--) {\n            node = nodes[i];\n            parentNode = node.parent;\n            if (parentNode.name === 'ul' || parentNode.name === 'ol') {\n              if (node.prev && node.prev.name === 'li') {\n                node.prev.append(node);\n              } else {\n                var li = new AstNode('li', 1);\n                li.attr('style', 'list-style-type: none');\n                node.wrap(li);\n              }\n            }\n          }\n        });\n      }\n      if (settings.validate && schema.getValidClasses()) {\n        parser.addAttributeFilter('class', function (nodes) {\n          var validClasses = schema.getValidClasses();\n          var i = nodes.length;\n          while (i--) {\n            var node = nodes[i];\n            var classList = node.attr('class').split(' ');\n            var classValue = '';\n            for (var ci = 0; ci < classList.length; ci++) {\n              var className = classList[ci];\n              var valid = false;\n              var validClassesMap = validClasses['*'];\n              if (validClassesMap && validClassesMap[className]) {\n                valid = true;\n              }\n              validClassesMap = validClasses[node.name];\n              if (!valid && validClassesMap && validClassesMap[className]) {\n                valid = true;\n              }\n              if (valid) {\n                if (classValue) {\n                  classValue += ' ';\n                }\n                classValue += className;\n              }\n            }\n            if (!classValue.length) {\n              classValue = null;\n            }\n            node.attr('class', classValue);\n          }\n        });\n      }\n      registerBase64ImageFilter(parser, settings);\n    };\n\n    var each$7 = Tools.each, trim = Tools.trim;\n    var queryParts = 'source protocol authority userInfo user password host port relative path directory file query anchor'.split(' ');\n    var DEFAULT_PORTS = {\n      ftp: 21,\n      http: 80,\n      https: 443,\n      mailto: 25\n    };\n    var safeSvgDataUrlElements = [\n      'img',\n      'video'\n    ];\n    var blockSvgDataUris = function (allowSvgDataUrls, tagName) {\n      if (isNonNullable(allowSvgDataUrls)) {\n        return !allowSvgDataUrls;\n      } else {\n        return isNonNullable(tagName) ? !contains$3(safeSvgDataUrlElements, tagName) : true;\n      }\n    };\n    var isInvalidUri = function (settings, uri, tagName) {\n      if (settings.allow_html_data_urls) {\n        return false;\n      } else if (/^data:image\\//i.test(uri)) {\n        return blockSvgDataUris(settings.allow_svg_data_urls, tagName) && /^data:image\\/svg\\+xml/i.test(uri);\n      } else {\n        return /^data:/i.test(uri);\n      }\n    };\n    var URI = function () {\n      function URI(url, settings) {\n        url = trim(url);\n        this.settings = settings || {};\n        var baseUri = this.settings.base_uri;\n        var self = this;\n        if (/^([\\w\\-]+):([^\\/]{2})/i.test(url) || /^\\s*#/.test(url)) {\n          self.source = url;\n          return;\n        }\n        var isProtocolRelative = url.indexOf('//') === 0;\n        if (url.indexOf('/') === 0 && !isProtocolRelative) {\n          url = (baseUri ? baseUri.protocol || 'http' : 'http') + '://mce_host' + url;\n        }\n        if (!/^[\\w\\-]*:?\\/\\//.test(url)) {\n          var baseUrl = this.settings.base_uri ? this.settings.base_uri.path : new URI(document.location.href).directory;\n          if (this.settings.base_uri && this.settings.base_uri.protocol == '') {\n            url = '//mce_host' + self.toAbsPath(baseUrl, url);\n          } else {\n            var match = /([^#?]*)([#?]?.*)/.exec(url);\n            url = (baseUri && baseUri.protocol || 'http') + '://mce_host' + self.toAbsPath(baseUrl, match[1]) + match[2];\n          }\n        }\n        url = url.replace(/@@/g, '(mce_at)');\n        var urlMatch = /^(?:(?![^:@]+:[^:@\\/]*@)([^:\\/?#.]+):)?(?:\\/\\/)?((?:(([^:@\\/]*):?([^:@\\/]*))?@)?(\\[[a-zA-Z0-9:.%]+\\]|[^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/.exec(url);\n        each$7(queryParts, function (v, i) {\n          var part = urlMatch[i];\n          if (part) {\n            part = part.replace(/\\(mce_at\\)/g, '@@');\n          }\n          self[v] = part;\n        });\n        if (baseUri) {\n          if (!self.protocol) {\n            self.protocol = baseUri.protocol;\n          }\n          if (!self.userInfo) {\n            self.userInfo = baseUri.userInfo;\n          }\n          if (!self.port && self.host === 'mce_host') {\n            self.port = baseUri.port;\n          }\n          if (!self.host || self.host === 'mce_host') {\n            self.host = baseUri.host;\n          }\n          self.source = '';\n        }\n        if (isProtocolRelative) {\n          self.protocol = '';\n        }\n      }\n      URI.parseDataUri = function (uri) {\n        var type;\n        var uriComponents = decodeURIComponent(uri).split(',');\n        var matches = /data:([^;]+)/.exec(uriComponents[0]);\n        if (matches) {\n          type = matches[1];\n        }\n        return {\n          type: type,\n          data: uriComponents[1]\n        };\n      };\n      URI.isDomSafe = function (uri, context, options) {\n        if (options === void 0) {\n          options = {};\n        }\n        if (options.allow_script_urls) {\n          return true;\n        } else {\n          var decodedUri = Entities.decode(uri).replace(/[\\s\\u0000-\\u001F]+/g, '');\n          try {\n            decodedUri = decodeURIComponent(decodedUri);\n          } catch (ex) {\n            decodedUri = unescape(decodedUri);\n          }\n          if (/((java|vb)script|mhtml):/i.test(decodedUri)) {\n            return false;\n          }\n          return !isInvalidUri(options, decodedUri, context);\n        }\n      };\n      URI.getDocumentBaseUrl = function (loc) {\n        var baseUrl;\n        if (loc.protocol.indexOf('http') !== 0 && loc.protocol !== 'file:') {\n          baseUrl = loc.href;\n        } else {\n          baseUrl = loc.protocol + '//' + loc.host + loc.pathname;\n        }\n        if (/^[^:]+:\\/\\/\\/?[^\\/]+\\//.test(baseUrl)) {\n          baseUrl = baseUrl.replace(/[\\?#].*$/, '').replace(/[\\/\\\\][^\\/]+$/, '');\n          if (!/[\\/\\\\]$/.test(baseUrl)) {\n            baseUrl += '/';\n          }\n        }\n        return baseUrl;\n      };\n      URI.prototype.setPath = function (path) {\n        var pathMatch = /^(.*?)\\/?(\\w+)?$/.exec(path);\n        this.path = pathMatch[0];\n        this.directory = pathMatch[1];\n        this.file = pathMatch[2];\n        this.source = '';\n        this.getURI();\n      };\n      URI.prototype.toRelative = function (uri) {\n        var output;\n        if (uri === './') {\n          return uri;\n        }\n        var relativeUri = new URI(uri, { base_uri: this });\n        if (relativeUri.host !== 'mce_host' && this.host !== relativeUri.host && relativeUri.host || this.port !== relativeUri.port || this.protocol !== relativeUri.protocol && relativeUri.protocol !== '') {\n          return relativeUri.getURI();\n        }\n        var tu = this.getURI(), uu = relativeUri.getURI();\n        if (tu === uu || tu.charAt(tu.length - 1) === '/' && tu.substr(0, tu.length - 1) === uu) {\n          return tu;\n        }\n        output = this.toRelPath(this.path, relativeUri.path);\n        if (relativeUri.query) {\n          output += '?' + relativeUri.query;\n        }\n        if (relativeUri.anchor) {\n          output += '#' + relativeUri.anchor;\n        }\n        return output;\n      };\n      URI.prototype.toAbsolute = function (uri, noHost) {\n        var absoluteUri = new URI(uri, { base_uri: this });\n        return absoluteUri.getURI(noHost && this.isSameOrigin(absoluteUri));\n      };\n      URI.prototype.isSameOrigin = function (uri) {\n        if (this.host == uri.host && this.protocol == uri.protocol) {\n          if (this.port == uri.port) {\n            return true;\n          }\n          var defaultPort = DEFAULT_PORTS[this.protocol];\n          if (defaultPort && (this.port || defaultPort) == (uri.port || defaultPort)) {\n            return true;\n          }\n        }\n        return false;\n      };\n      URI.prototype.toRelPath = function (base, path) {\n        var breakPoint = 0, out = '', i, l;\n        var normalizedBase = base.substring(0, base.lastIndexOf('/')).split('/');\n        var items = path.split('/');\n        if (normalizedBase.length >= items.length) {\n          for (i = 0, l = normalizedBase.length; i < l; i++) {\n            if (i >= items.length || normalizedBase[i] !== items[i]) {\n              breakPoint = i + 1;\n              break;\n            }\n          }\n        }\n        if (normalizedBase.length < items.length) {\n          for (i = 0, l = items.length; i < l; i++) {\n            if (i >= normalizedBase.length || normalizedBase[i] !== items[i]) {\n              breakPoint = i + 1;\n              break;\n            }\n          }\n        }\n        if (breakPoint === 1) {\n          return path;\n        }\n        for (i = 0, l = normalizedBase.length - (breakPoint - 1); i < l; i++) {\n          out += '../';\n        }\n        for (i = breakPoint - 1, l = items.length; i < l; i++) {\n          if (i !== breakPoint - 1) {\n            out += '/' + items[i];\n          } else {\n            out += items[i];\n          }\n        }\n        return out;\n      };\n      URI.prototype.toAbsPath = function (base, path) {\n        var i, nb = 0, o = [], outPath;\n        var tr = /\\/$/.test(path) ? '/' : '';\n        var normalizedBase = base.split('/');\n        var normalizedPath = path.split('/');\n        each$7(normalizedBase, function (k) {\n          if (k) {\n            o.push(k);\n          }\n        });\n        normalizedBase = o;\n        for (i = normalizedPath.length - 1, o = []; i >= 0; i--) {\n          if (normalizedPath[i].length === 0 || normalizedPath[i] === '.') {\n            continue;\n          }\n          if (normalizedPath[i] === '..') {\n            nb++;\n            continue;\n          }\n          if (nb > 0) {\n            nb--;\n            continue;\n          }\n          o.push(normalizedPath[i]);\n        }\n        i = normalizedBase.length - nb;\n        if (i <= 0) {\n          outPath = reverse(o).join('/');\n        } else {\n          outPath = normalizedBase.slice(0, i).join('/') + '/' + reverse(o).join('/');\n        }\n        if (outPath.indexOf('/') !== 0) {\n          outPath = '/' + outPath;\n        }\n        if (tr && outPath.lastIndexOf('/') !== outPath.length - 1) {\n          outPath += tr;\n        }\n        return outPath;\n      };\n      URI.prototype.getURI = function (noProtoHost) {\n        if (noProtoHost === void 0) {\n          noProtoHost = false;\n        }\n        var s;\n        if (!this.source || noProtoHost) {\n          s = '';\n          if (!noProtoHost) {\n            if (this.protocol) {\n              s += this.protocol + '://';\n            } else {\n              s += '//';\n            }\n            if (this.userInfo) {\n              s += this.userInfo + '@';\n            }\n            if (this.host) {\n              s += this.host;\n            }\n            if (this.port) {\n              s += ':' + this.port;\n            }\n          }\n          if (this.path) {\n            s += this.path;\n          }\n          if (this.query) {\n            s += '?' + this.query;\n          }\n          if (this.anchor) {\n            s += '#' + this.anchor;\n          }\n          this.source = s;\n        }\n        return this.source;\n      };\n      return URI;\n    }();\n\n    var filteredClobberElements = Tools.makeMap('button,fieldset,form,iframe,img,image,input,object,output,select,textarea');\n    var isValidPrefixAttrName = function (name) {\n      return name.indexOf('data-') === 0 || name.indexOf('aria-') === 0;\n    };\n    var lazyTempDocument = cached(function () {\n      return document.implementation.createHTMLDocument('parser');\n    });\n    var findMatchingEndTagIndex = function (schema, html, startIndex) {\n      var startTagRegExp = /<([!?\\/])?([A-Za-z0-9\\-_:.]+)/g;\n      var endTagRegExp = /(?:\\s(?:[^'\">]+(?:\"[^\"]*\"|'[^']*'))*[^\"'>]*(?:\"[^\">]*|'[^'>]*)?|\\s*|\\/)>/g;\n      var shortEndedElements = schema.getShortEndedElements();\n      var count = 1, index = startIndex;\n      while (count !== 0) {\n        startTagRegExp.lastIndex = index;\n        while (true) {\n          var startMatch = startTagRegExp.exec(html);\n          if (startMatch === null) {\n            return index;\n          } else if (startMatch[1] === '!') {\n            if (startsWith(startMatch[2], '--')) {\n              index = findCommentEndIndex(html, false, startMatch.index + '!--'.length);\n            } else {\n              index = findCommentEndIndex(html, true, startMatch.index + 1);\n            }\n            break;\n          } else {\n            endTagRegExp.lastIndex = startTagRegExp.lastIndex;\n            var endMatch = endTagRegExp.exec(html);\n            if (isNull(endMatch) || endMatch.index !== startTagRegExp.lastIndex) {\n              continue;\n            }\n            if (startMatch[1] === '/') {\n              count -= 1;\n            } else if (!has$2(shortEndedElements, startMatch[2])) {\n              count += 1;\n            }\n            index = startTagRegExp.lastIndex + endMatch[0].length;\n            break;\n          }\n        }\n      }\n      return index;\n    };\n    var isConditionalComment = function (html, startIndex) {\n      return /^\\s*\\[if [\\w\\W]+\\]>.*<!\\[endif\\](--!?)?>/.test(html.substr(startIndex));\n    };\n    var findCommentEndIndex = function (html, isBogus, startIndex) {\n      if (startIndex === void 0) {\n        startIndex = 0;\n      }\n      var lcHtml = html.toLowerCase();\n      if (lcHtml.indexOf('[if ', startIndex) !== -1 && isConditionalComment(lcHtml, startIndex)) {\n        var endIfIndex = lcHtml.indexOf('[endif]', startIndex);\n        return lcHtml.indexOf('>', endIfIndex);\n      } else {\n        if (isBogus) {\n          var endIndex = lcHtml.indexOf('>', startIndex);\n          return endIndex !== -1 ? endIndex : lcHtml.length;\n        } else {\n          var endCommentRegexp = /--!?>/g;\n          endCommentRegexp.lastIndex = startIndex;\n          var match = endCommentRegexp.exec(html);\n          return match ? match.index + match[0].length : lcHtml.length;\n        }\n      }\n    };\n    var checkBogusAttribute = function (regExp, attrString) {\n      var matches = regExp.exec(attrString);\n      if (matches) {\n        var name_1 = matches[1];\n        var value = matches[2];\n        return typeof name_1 === 'string' && name_1.toLowerCase() === 'data-mce-bogus' ? value : null;\n      } else {\n        return null;\n      }\n    };\n    var SaxParser = function (settings, schema) {\n      if (schema === void 0) {\n        schema = Schema();\n      }\n      settings = settings || {};\n      var doc = lazyTempDocument();\n      var form = doc.createElement('form');\n      if (settings.fix_self_closing !== false) {\n        settings.fix_self_closing = true;\n      }\n      var comment = settings.comment ? settings.comment : noop;\n      var cdata = settings.cdata ? settings.cdata : noop;\n      var text = settings.text ? settings.text : noop;\n      var start = settings.start ? settings.start : noop;\n      var end = settings.end ? settings.end : noop;\n      var pi = settings.pi ? settings.pi : noop;\n      var doctype = settings.doctype ? settings.doctype : noop;\n      var parseInternal = function (base64Extract, format) {\n        if (format === void 0) {\n          format = 'html';\n        }\n        var html = base64Extract.html;\n        var matches, index = 0, value, endRegExp;\n        var stack = [];\n        var attrList, i, textData, name;\n        var isInternalElement, isShortEnded;\n        var elementRule, isValidElement, attr, attribsValue, validAttributesMap, validAttributePatterns;\n        var attributesRequired, attributesDefault, attributesForced;\n        var anyAttributesRequired, attrValue, idCount = 0;\n        var decode = Entities.decode;\n        var filteredUrlAttrs = Tools.makeMap('src,href,data,background,action,formaction,poster,xlink:href');\n        var parsingMode = format === 'html' ? 0 : 1;\n        var processEndTag = function (name) {\n          var pos, i;\n          pos = stack.length;\n          while (pos--) {\n            if (stack[pos].name === name) {\n              break;\n            }\n          }\n          if (pos >= 0) {\n            for (i = stack.length - 1; i >= pos; i--) {\n              name = stack[i];\n              if (name.valid) {\n                end(name.name);\n              }\n            }\n            stack.length = pos;\n          }\n        };\n        var processText = function (value, raw) {\n          return text(restoreDataUris(value, base64Extract), raw);\n        };\n        var processComment = function (value) {\n          if (value === '') {\n            return;\n          }\n          if (value.charAt(0) === '>') {\n            value = ' ' + value;\n          }\n          if (!settings.allow_conditional_comments && value.substr(0, 3).toLowerCase() === '[if') {\n            value = ' ' + value;\n          }\n          comment(restoreDataUris(value, base64Extract));\n        };\n        var processAttr = function (value) {\n          return restoreDataUris(value, base64Extract);\n        };\n        var processMalformedComment = function (value, startIndex) {\n          var startTag = value || '';\n          var isBogus = !startsWith(startTag, '--');\n          var endIndex = findCommentEndIndex(html, isBogus, startIndex);\n          value = html.substr(startIndex, endIndex - startIndex);\n          processComment(isBogus ? startTag + value : value);\n          return endIndex + 1;\n        };\n        var parseAttribute = function (tagName, name, value, val2, val3) {\n          name = name.toLowerCase();\n          value = processAttr(name in fillAttrsMap ? name : decode(value || val2 || val3 || ''));\n          if (validate && !isInternalElement && isValidPrefixAttrName(name) === false) {\n            var attrRule = validAttributesMap[name];\n            if (!attrRule && validAttributePatterns) {\n              var i_1 = validAttributePatterns.length;\n              while (i_1--) {\n                attrRule = validAttributePatterns[i_1];\n                if (attrRule.pattern.test(name)) {\n                  break;\n                }\n              }\n              if (i_1 === -1) {\n                attrRule = null;\n              }\n            }\n            if (!attrRule) {\n              return;\n            }\n            if (attrRule.validValues && !(value in attrRule.validValues)) {\n              return;\n            }\n          }\n          var isNameOrId = name === 'name' || name === 'id';\n          if (isNameOrId && tagName in filteredClobberElements && (value in doc || value in form)) {\n            return;\n          }\n          if (filteredUrlAttrs[name] && !URI.isDomSafe(value, tagName, settings)) {\n            return;\n          }\n          if (isInternalElement && (name in filteredUrlAttrs || name.indexOf('on') === 0)) {\n            return;\n          }\n          attrList.map[name] = value;\n          attrList.push({\n            name: name,\n            value: value\n          });\n        };\n        var tokenRegExp = new RegExp('<(?:' + '(?:!--([\\\\w\\\\W]*?)--!?>)|' + '(?:!\\\\[CDATA\\\\[([\\\\w\\\\W]*?)\\\\]\\\\]>)|' + '(?:![Dd][Oo][Cc][Tt][Yy][Pp][Ee]([\\\\w\\\\W]*?)>)|' + '(?:!(--)?)|' + '(?:\\\\?([^\\\\s\\\\/<>]+) ?([\\\\w\\\\W]*?)[?/]>)|' + '(?:\\\\/([A-Za-z][A-Za-z0-9\\\\-_\\\\:\\\\.]*)>)|' + '(?:([A-Za-z][A-Za-z0-9\\\\-_:.]*)(\\\\s(?:[^\\'\">]+(?:\"[^\"]*\"|\\'[^\\']*\\'))*[^\"\\'>]*(?:\"[^\">]*|\\'[^\\'>]*)?|\\\\s*|\\\\/)>)' + ')', 'g');\n        var attrRegExp = /([\\w:\\-]+)(?:\\s*=\\s*(?:(?:\\\"((?:[^\\\"])*)\\\")|(?:\\'((?:[^\\'])*)\\')|([^>\\s]+)))?/g;\n        var shortEndedElements = schema.getShortEndedElements();\n        var selfClosing = settings.self_closing_elements || schema.getSelfClosingElements();\n        var fillAttrsMap = schema.getBoolAttrs();\n        var validate = settings.validate;\n        var removeInternalElements = settings.remove_internals;\n        var fixSelfClosing = settings.fix_self_closing;\n        var specialElements = schema.getSpecialElements();\n        var processHtml = html + '>';\n        while (matches = tokenRegExp.exec(processHtml)) {\n          var matchText = matches[0];\n          if (index < matches.index) {\n            processText(decode(html.substr(index, matches.index - index)));\n          }\n          if (value = matches[7]) {\n            value = value.toLowerCase();\n            if (value.charAt(0) === ':') {\n              value = value.substr(1);\n            }\n            processEndTag(value);\n          } else if (value = matches[8]) {\n            if (matches.index + matchText.length > html.length) {\n              processText(decode(html.substr(matches.index)));\n              index = matches.index + matchText.length;\n              continue;\n            }\n            value = value.toLowerCase();\n            if (value.charAt(0) === ':') {\n              value = value.substr(1);\n            }\n            isShortEnded = value in shortEndedElements;\n            if (fixSelfClosing && selfClosing[value] && stack.length > 0 && stack[stack.length - 1].name === value) {\n              processEndTag(value);\n            }\n            var bogusValue = checkBogusAttribute(attrRegExp, matches[9]);\n            if (bogusValue !== null) {\n              if (bogusValue === 'all') {\n                index = findMatchingEndTagIndex(schema, html, tokenRegExp.lastIndex);\n                tokenRegExp.lastIndex = index;\n                continue;\n              }\n              isValidElement = false;\n            }\n            if (!validate || (elementRule = schema.getElementRule(value))) {\n              isValidElement = true;\n              if (validate) {\n                validAttributesMap = elementRule.attributes;\n                validAttributePatterns = elementRule.attributePatterns;\n              }\n              if (attribsValue = matches[9]) {\n                isInternalElement = attribsValue.indexOf('data-mce-type') !== -1;\n                if (isInternalElement && removeInternalElements) {\n                  isValidElement = false;\n                }\n                attrList = [];\n                attrList.map = {};\n                attribsValue.replace(attrRegExp, function (match, name, val, val2, val3) {\n                  parseAttribute(value, name, val, val2, val3);\n                  return '';\n                });\n              } else {\n                attrList = [];\n                attrList.map = {};\n              }\n              if (validate && !isInternalElement) {\n                attributesRequired = elementRule.attributesRequired;\n                attributesDefault = elementRule.attributesDefault;\n                attributesForced = elementRule.attributesForced;\n                anyAttributesRequired = elementRule.removeEmptyAttrs;\n                if (anyAttributesRequired && !attrList.length) {\n                  isValidElement = false;\n                }\n                if (attributesForced) {\n                  i = attributesForced.length;\n                  while (i--) {\n                    attr = attributesForced[i];\n                    name = attr.name;\n                    attrValue = attr.value;\n                    if (attrValue === '{$uid}') {\n                      attrValue = 'mce_' + idCount++;\n                    }\n                    attrList.map[name] = attrValue;\n                    attrList.push({\n                      name: name,\n                      value: attrValue\n                    });\n                  }\n                }\n                if (attributesDefault) {\n                  i = attributesDefault.length;\n                  while (i--) {\n                    attr = attributesDefault[i];\n                    name = attr.name;\n                    if (!(name in attrList.map)) {\n                      attrValue = attr.value;\n                      if (attrValue === '{$uid}') {\n                        attrValue = 'mce_' + idCount++;\n                      }\n                      attrList.map[name] = attrValue;\n                      attrList.push({\n                        name: name,\n                        value: attrValue\n                      });\n                    }\n                  }\n                }\n                if (attributesRequired) {\n                  i = attributesRequired.length;\n                  while (i--) {\n                    if (attributesRequired[i] in attrList.map) {\n                      break;\n                    }\n                  }\n                  if (i === -1) {\n                    isValidElement = false;\n                  }\n                }\n                if (attr = attrList.map['data-mce-bogus']) {\n                  if (attr === 'all') {\n                    index = findMatchingEndTagIndex(schema, html, tokenRegExp.lastIndex);\n                    tokenRegExp.lastIndex = index;\n                    continue;\n                  }\n                  isValidElement = false;\n                }\n              }\n              if (isValidElement) {\n                start(value, attrList, isShortEnded);\n              }\n            } else {\n              isValidElement = false;\n            }\n            if (endRegExp = specialElements[value]) {\n              endRegExp.lastIndex = index = matches.index + matchText.length;\n              if (matches = endRegExp.exec(html)) {\n                if (isValidElement) {\n                  textData = html.substr(index, matches.index - index);\n                }\n                index = matches.index + matches[0].length;\n              } else {\n                textData = html.substr(index);\n                index = html.length;\n              }\n              if (isValidElement) {\n                if (textData.length > 0) {\n                  processText(textData, true);\n                }\n                end(value);\n              }\n              tokenRegExp.lastIndex = index;\n              continue;\n            }\n            if (!isShortEnded) {\n              if (!attribsValue || attribsValue.indexOf('/') !== attribsValue.length - 1) {\n                stack.push({\n                  name: value,\n                  valid: isValidElement\n                });\n              } else if (isValidElement) {\n                end(value);\n              }\n            }\n          } else if (value = matches[1]) {\n            processComment(value);\n          } else if (value = matches[2]) {\n            var isValidCdataSection = parsingMode === 1 || settings.preserve_cdata || stack.length > 0 && schema.isValidChild(stack[stack.length - 1].name, '#cdata');\n            if (isValidCdataSection) {\n              cdata(value);\n            } else {\n              index = processMalformedComment('', matches.index + 2);\n              tokenRegExp.lastIndex = index;\n              continue;\n            }\n          } else if (value = matches[3]) {\n            doctype(value);\n          } else if ((value = matches[4]) || matchText === '<!') {\n            index = processMalformedComment(value, matches.index + matchText.length);\n            tokenRegExp.lastIndex = index;\n            continue;\n          } else if (value = matches[5]) {\n            if (parsingMode === 1) {\n              pi(value, matches[6]);\n            } else {\n              index = processMalformedComment('?', matches.index + 2);\n              tokenRegExp.lastIndex = index;\n              continue;\n            }\n          }\n          index = matches.index + matchText.length;\n        }\n        if (index < html.length) {\n          processText(decode(html.substr(index)));\n        }\n        for (i = stack.length - 1; i >= 0; i--) {\n          value = stack[i];\n          if (value.valid) {\n            end(value.name);\n          }\n        }\n      };\n      var parse = function (html, format) {\n        if (format === void 0) {\n          format = 'html';\n        }\n        parseInternal(extractBase64DataUris(html), format);\n      };\n      return { parse: parse };\n    };\n    SaxParser.findEndTag = findMatchingEndTagIndex;\n\n    var makeMap = Tools.makeMap, each$6 = Tools.each, explode$2 = Tools.explode, extend$4 = Tools.extend;\n    var DomParser = function (settings, schema) {\n      if (schema === void 0) {\n        schema = Schema();\n      }\n      var nodeFilters = {};\n      var attributeFilters = [];\n      var matchedNodes = {};\n      var matchedAttributes = {};\n      settings = settings || {};\n      settings.validate = 'validate' in settings ? settings.validate : true;\n      settings.root_name = settings.root_name || 'body';\n      var fixInvalidChildren = function (nodes) {\n        var nonSplitableElements = makeMap('tr,td,th,tbody,thead,tfoot,table');\n        var nonEmptyElements = schema.getNonEmptyElements();\n        var whitespaceElements = schema.getWhiteSpaceElements();\n        var textBlockElements = schema.getTextBlockElements();\n        var specialElements = schema.getSpecialElements();\n        var removeOrUnwrapInvalidNode = function (node, originalNodeParent) {\n          if (originalNodeParent === void 0) {\n            originalNodeParent = node.parent;\n          }\n          if (specialElements[node.name]) {\n            node.empty().remove();\n          } else {\n            var children = node.children();\n            for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {\n              var childNode = children_1[_i];\n              if (!schema.isValidChild(originalNodeParent.name, childNode.name)) {\n                removeOrUnwrapInvalidNode(childNode, originalNodeParent);\n              }\n            }\n            node.unwrap();\n          }\n        };\n        for (var ni = 0; ni < nodes.length; ni++) {\n          var node = nodes[ni];\n          var parent_1 = void 0, newParent = void 0, tempNode = void 0;\n          if (!node.parent || node.fixed) {\n            continue;\n          }\n          if (textBlockElements[node.name] && node.parent.name === 'li') {\n            var sibling = node.next;\n            while (sibling) {\n              if (textBlockElements[sibling.name]) {\n                sibling.name = 'li';\n                sibling.fixed = true;\n                node.parent.insert(sibling, node.parent);\n              } else {\n                break;\n              }\n              sibling = sibling.next;\n            }\n            node.unwrap();\n            continue;\n          }\n          var parents = [node];\n          for (parent_1 = node.parent; parent_1 && !schema.isValidChild(parent_1.name, node.name) && !nonSplitableElements[parent_1.name]; parent_1 = parent_1.parent) {\n            parents.push(parent_1);\n          }\n          if (parent_1 && parents.length > 1) {\n            if (schema.isValidChild(parent_1.name, node.name)) {\n              parents.reverse();\n              newParent = filterNode(parents[0].clone());\n              var currentNode = newParent;\n              for (var i = 0; i < parents.length - 1; i++) {\n                if (schema.isValidChild(currentNode.name, parents[i].name)) {\n                  tempNode = filterNode(parents[i].clone());\n                  currentNode.append(tempNode);\n                } else {\n                  tempNode = currentNode;\n                }\n                for (var childNode = parents[i].firstChild; childNode && childNode !== parents[i + 1];) {\n                  var nextNode = childNode.next;\n                  tempNode.append(childNode);\n                  childNode = nextNode;\n                }\n                currentNode = tempNode;\n              }\n              if (!isEmpty(schema, nonEmptyElements, whitespaceElements, newParent)) {\n                parent_1.insert(newParent, parents[0], true);\n                parent_1.insert(node, newParent);\n              } else {\n                parent_1.insert(node, parents[0], true);\n              }\n              parent_1 = parents[0];\n              if (isEmpty(schema, nonEmptyElements, whitespaceElements, parent_1) || hasOnlyChild(parent_1, 'br')) {\n                parent_1.empty().remove();\n              }\n            } else {\n              removeOrUnwrapInvalidNode(node);\n            }\n          } else if (node.parent) {\n            if (node.name === 'li') {\n              var sibling = node.prev;\n              if (sibling && (sibling.name === 'ul' || sibling.name === 'ol')) {\n                sibling.append(node);\n                continue;\n              }\n              sibling = node.next;\n              if (sibling && (sibling.name === 'ul' || sibling.name === 'ol')) {\n                sibling.insert(node, sibling.firstChild, true);\n                continue;\n              }\n              node.wrap(filterNode(new AstNode('ul', 1)));\n              continue;\n            }\n            if (schema.isValidChild(node.parent.name, 'div') && schema.isValidChild('div', node.name)) {\n              node.wrap(filterNode(new AstNode('div', 1)));\n            } else {\n              removeOrUnwrapInvalidNode(node);\n            }\n          }\n        }\n      };\n      var filterNode = function (node) {\n        var name = node.name;\n        if (name in nodeFilters) {\n          var list = matchedNodes[name];\n          if (list) {\n            list.push(node);\n          } else {\n            matchedNodes[name] = [node];\n          }\n        }\n        var i = attributeFilters.length;\n        while (i--) {\n          var attrName = attributeFilters[i].name;\n          if (attrName in node.attributes.map) {\n            var list = matchedAttributes[attrName];\n            if (list) {\n              list.push(node);\n            } else {\n              matchedAttributes[attrName] = [node];\n            }\n          }\n        }\n        return node;\n      };\n      var addNodeFilter = function (name, callback) {\n        each$6(explode$2(name), function (name) {\n          var list = nodeFilters[name];\n          if (!list) {\n            nodeFilters[name] = list = [];\n          }\n          list.push(callback);\n        });\n      };\n      var getNodeFilters = function () {\n        var out = [];\n        for (var name_1 in nodeFilters) {\n          if (has$2(nodeFilters, name_1)) {\n            out.push({\n              name: name_1,\n              callbacks: nodeFilters[name_1]\n            });\n          }\n        }\n        return out;\n      };\n      var addAttributeFilter = function (name, callback) {\n        each$6(explode$2(name), function (name) {\n          var i;\n          for (i = 0; i < attributeFilters.length; i++) {\n            if (attributeFilters[i].name === name) {\n              attributeFilters[i].callbacks.push(callback);\n              return;\n            }\n          }\n          attributeFilters.push({\n            name: name,\n            callbacks: [callback]\n          });\n        });\n      };\n      var getAttributeFilters = function () {\n        return [].concat(attributeFilters);\n      };\n      var parse = function (html, args) {\n        var nodes, i, l, fi, fl, list, name;\n        var invalidChildren = [];\n        var node;\n        var getRootBlockName = function (name) {\n          if (name === false) {\n            return '';\n          } else if (name === true) {\n            return 'p';\n          } else {\n            return name;\n          }\n        };\n        args = args || {};\n        matchedNodes = {};\n        matchedAttributes = {};\n        var blockElements = extend$4(makeMap('script,style,head,html,body,title,meta,param'), schema.getBlockElements());\n        var textRootBlockElements = getTextRootBlockElements(schema);\n        var nonEmptyElements = schema.getNonEmptyElements();\n        var children = schema.children;\n        var validate = settings.validate;\n        var forcedRootBlockName = 'forced_root_block' in args ? args.forced_root_block : settings.forced_root_block;\n        var rootBlockName = getRootBlockName(forcedRootBlockName);\n        var whiteSpaceElements = schema.getWhiteSpaceElements();\n        var startWhiteSpaceRegExp = /^[ \\t\\r\\n]+/;\n        var endWhiteSpaceRegExp = /[ \\t\\r\\n]+$/;\n        var allWhiteSpaceRegExp = /[ \\t\\r\\n]+/g;\n        var isAllWhiteSpaceRegExp = /^[ \\t\\r\\n]+$/;\n        var isInWhiteSpacePreservedElement = has$2(whiteSpaceElements, args.context) || has$2(whiteSpaceElements, settings.root_name);\n        var addRootBlocks = function () {\n          var node = rootNode.firstChild, rootBlockNode = null;\n          var trim = function (rootBlock) {\n            if (rootBlock) {\n              node = rootBlock.firstChild;\n              if (node && node.type === 3) {\n                node.value = node.value.replace(startWhiteSpaceRegExp, '');\n              }\n              node = rootBlock.lastChild;\n              if (node && node.type === 3) {\n                node.value = node.value.replace(endWhiteSpaceRegExp, '');\n              }\n            }\n          };\n          if (!schema.isValidChild(rootNode.name, rootBlockName.toLowerCase())) {\n            return;\n          }\n          while (node) {\n            var next = node.next;\n            if (node.type === 3 || node.type === 1 && node.name !== 'p' && !blockElements[node.name] && !node.attr('data-mce-type')) {\n              if (!rootBlockNode) {\n                rootBlockNode = createNode(rootBlockName, 1);\n                rootBlockNode.attr(settings.forced_root_block_attrs);\n                rootNode.insert(rootBlockNode, node);\n                rootBlockNode.append(node);\n              } else {\n                rootBlockNode.append(node);\n              }\n            } else {\n              trim(rootBlockNode);\n              rootBlockNode = null;\n            }\n            node = next;\n          }\n          trim(rootBlockNode);\n        };\n        var createNode = function (name, type) {\n          var node = new AstNode(name, type);\n          var list;\n          if (name in nodeFilters) {\n            list = matchedNodes[name];\n            if (list) {\n              list.push(node);\n            } else {\n              matchedNodes[name] = [node];\n            }\n          }\n          return node;\n        };\n        var removeWhitespaceBefore = function (node) {\n          var blockElements = schema.getBlockElements();\n          for (var textNode = node.prev; textNode && textNode.type === 3;) {\n            var textVal = textNode.value.replace(endWhiteSpaceRegExp, '');\n            if (textVal.length > 0) {\n              textNode.value = textVal;\n              return;\n            }\n            var textNodeNext = textNode.next;\n            if (textNodeNext) {\n              if (textNodeNext.type === 3 && textNodeNext.value.length) {\n                textNode = textNode.prev;\n                continue;\n              }\n              if (!blockElements[textNodeNext.name] && textNodeNext.name !== 'script' && textNodeNext.name !== 'style') {\n                textNode = textNode.prev;\n                continue;\n              }\n            }\n            var sibling = textNode.prev;\n            textNode.remove();\n            textNode = sibling;\n          }\n        };\n        var cloneAndExcludeBlocks = function (input) {\n          var output = {};\n          for (var name_2 in input) {\n            if (name_2 !== 'li' && name_2 !== 'p') {\n              output[name_2] = input[name_2];\n            }\n          }\n          return output;\n        };\n        var isTextRootBlockEmpty = function (node) {\n          var tempNode = node;\n          while (isNonNullable(tempNode)) {\n            if (tempNode.name in textRootBlockElements) {\n              return isEmpty(schema, nonEmptyElements, whiteSpaceElements, tempNode);\n            } else {\n              tempNode = tempNode.parent;\n            }\n          }\n          return false;\n        };\n        var parser = SaxParser({\n          validate: validate,\n          document: settings.document,\n          allow_html_data_urls: settings.allow_html_data_urls,\n          allow_svg_data_urls: settings.allow_svg_data_urls,\n          allow_script_urls: settings.allow_script_urls,\n          allow_conditional_comments: settings.allow_conditional_comments,\n          preserve_cdata: settings.preserve_cdata,\n          self_closing_elements: cloneAndExcludeBlocks(schema.getSelfClosingElements()),\n          cdata: function (text) {\n            node.append(createNode('#cdata', 4)).value = text;\n          },\n          text: function (text, raw) {\n            var textNode;\n            if (!isInWhiteSpacePreservedElement) {\n              text = text.replace(allWhiteSpaceRegExp, ' ');\n              if (isLineBreakNode(node.lastChild, blockElements)) {\n                text = text.replace(startWhiteSpaceRegExp, '');\n              }\n            }\n            if (text.length !== 0) {\n              textNode = createNode('#text', 3);\n              textNode.raw = !!raw;\n              node.append(textNode).value = text;\n            }\n          },\n          comment: function (text) {\n            node.append(createNode('#comment', 8)).value = text;\n          },\n          pi: function (name, text) {\n            node.append(createNode(name, 7)).value = text;\n            removeWhitespaceBefore(node);\n          },\n          doctype: function (text) {\n            var newNode = node.append(createNode('#doctype', 10));\n            newNode.value = text;\n            removeWhitespaceBefore(node);\n          },\n          start: function (name, attrs, empty) {\n            var elementRule = validate ? schema.getElementRule(name) : {};\n            if (elementRule) {\n              var newNode = createNode(elementRule.outputName || name, 1);\n              newNode.attributes = attrs;\n              newNode.shortEnded = empty;\n              node.append(newNode);\n              var parent_2 = children[node.name];\n              if (parent_2 && children[newNode.name] && !parent_2[newNode.name]) {\n                invalidChildren.push(newNode);\n              }\n              var attrFiltersLen = attributeFilters.length;\n              while (attrFiltersLen--) {\n                var attrName = attributeFilters[attrFiltersLen].name;\n                if (attrName in attrs.map) {\n                  list = matchedAttributes[attrName];\n                  if (list) {\n                    list.push(newNode);\n                  } else {\n                    matchedAttributes[attrName] = [newNode];\n                  }\n                }\n              }\n              if (blockElements[name]) {\n                removeWhitespaceBefore(newNode);\n              }\n              if (!empty) {\n                node = newNode;\n              }\n              if (!isInWhiteSpacePreservedElement && whiteSpaceElements[name]) {\n                isInWhiteSpacePreservedElement = true;\n              }\n            }\n          },\n          end: function (name) {\n            var textNode, text, sibling;\n            var elementRule = validate ? schema.getElementRule(name) : {};\n            if (elementRule) {\n              if (blockElements[name]) {\n                if (!isInWhiteSpacePreservedElement) {\n                  textNode = node.firstChild;\n                  if (textNode && textNode.type === 3) {\n                    text = textNode.value.replace(startWhiteSpaceRegExp, '');\n                    if (text.length > 0) {\n                      textNode.value = text;\n                      textNode = textNode.next;\n                    } else {\n                      sibling = textNode.next;\n                      textNode.remove();\n                      textNode = sibling;\n                      while (textNode && textNode.type === 3) {\n                        text = textNode.value;\n                        sibling = textNode.next;\n                        if (text.length === 0 || isAllWhiteSpaceRegExp.test(text)) {\n                          textNode.remove();\n                          textNode = sibling;\n                        }\n                        textNode = sibling;\n                      }\n                    }\n                  }\n                  textNode = node.lastChild;\n                  if (textNode && textNode.type === 3) {\n                    text = textNode.value.replace(endWhiteSpaceRegExp, '');\n                    if (text.length > 0) {\n                      textNode.value = text;\n                      textNode = textNode.prev;\n                    } else {\n                      sibling = textNode.prev;\n                      textNode.remove();\n                      textNode = sibling;\n                      while (textNode && textNode.type === 3) {\n                        text = textNode.value;\n                        sibling = textNode.prev;\n                        if (text.length === 0 || isAllWhiteSpaceRegExp.test(text)) {\n                          textNode.remove();\n                          textNode = sibling;\n                        }\n                        textNode = sibling;\n                      }\n                    }\n                  }\n                }\n              }\n              if (isInWhiteSpacePreservedElement && whiteSpaceElements[name]) {\n                isInWhiteSpacePreservedElement = false;\n              }\n              var isNodeEmpty = isEmpty(schema, nonEmptyElements, whiteSpaceElements, node);\n              var parentNode = node.parent;\n              if (elementRule.paddInEmptyBlock && isNodeEmpty && isTextRootBlockEmpty(node)) {\n                paddEmptyNode(settings, args, blockElements, node);\n              } else if (elementRule.removeEmpty && isNodeEmpty) {\n                if (blockElements[node.name]) {\n                  node.empty().remove();\n                } else {\n                  node.unwrap();\n                }\n              } else if (elementRule.paddEmpty && (isPaddedWithNbsp(node) || isNodeEmpty)) {\n                paddEmptyNode(settings, args, blockElements, node);\n              }\n              node = parentNode;\n            }\n          }\n        }, schema);\n        var rootNode = node = new AstNode(args.context || settings.root_name, 11);\n        parser.parse(html, args.format);\n        if (validate && invalidChildren.length) {\n          if (!args.context) {\n            fixInvalidChildren(invalidChildren);\n          } else {\n            args.invalid = true;\n          }\n        }\n        if (rootBlockName && (rootNode.name === 'body' || args.isRootContent)) {\n          addRootBlocks();\n        }\n        if (!args.invalid) {\n          for (name in matchedNodes) {\n            if (!has$2(matchedNodes, name)) {\n              continue;\n            }\n            list = nodeFilters[name];\n            nodes = matchedNodes[name];\n            fi = nodes.length;\n            while (fi--) {\n              if (!nodes[fi].parent) {\n                nodes.splice(fi, 1);\n              }\n            }\n            for (i = 0, l = list.length; i < l; i++) {\n              list[i](nodes, name, args);\n            }\n          }\n          for (i = 0, l = attributeFilters.length; i < l; i++) {\n            list = attributeFilters[i];\n            if (list.name in matchedAttributes) {\n              nodes = matchedAttributes[list.name];\n              fi = nodes.length;\n              while (fi--) {\n                if (!nodes[fi].parent) {\n                  nodes.splice(fi, 1);\n                }\n              }\n              for (fi = 0, fl = list.callbacks.length; fi < fl; fi++) {\n                list.callbacks[fi](nodes, list.name, args);\n              }\n            }\n          }\n        }\n        return rootNode;\n      };\n      var exports = {\n        schema: schema,\n        addAttributeFilter: addAttributeFilter,\n        getAttributeFilters: getAttributeFilters,\n        addNodeFilter: addNodeFilter,\n        getNodeFilters: getNodeFilters,\n        filterNode: filterNode,\n        parse: parse\n      };\n      register$1(exports, settings);\n      register$2(exports, settings);\n      return exports;\n    };\n\n    var register = function (htmlParser, settings, dom) {\n      htmlParser.addAttributeFilter('data-mce-tabindex', function (nodes, name) {\n        var i = nodes.length;\n        while (i--) {\n          var node = nodes[i];\n          node.attr('tabindex', node.attr('data-mce-tabindex'));\n          node.attr(name, null);\n        }\n      });\n      htmlParser.addAttributeFilter('src,href,style', function (nodes, name) {\n        var internalName = 'data-mce-' + name;\n        var urlConverter = settings.url_converter;\n        var urlConverterScope = settings.url_converter_scope;\n        var i = nodes.length;\n        while (i--) {\n          var node = nodes[i];\n          var value = node.attr(internalName);\n          if (value !== undefined) {\n            node.attr(name, value.length > 0 ? value : null);\n            node.attr(internalName, null);\n          } else {\n            value = node.attr(name);\n            if (name === 'style') {\n              value = dom.serializeStyle(dom.parseStyle(value), node.name);\n            } else if (urlConverter) {\n              value = urlConverter.call(urlConverterScope, value, name, node.name);\n            }\n            node.attr(name, value.length > 0 ? value : null);\n          }\n        }\n      });\n      htmlParser.addAttributeFilter('class', function (nodes) {\n        var i = nodes.length;\n        while (i--) {\n          var node = nodes[i];\n          var value = node.attr('class');\n          if (value) {\n            value = node.attr('class').replace(/(?:^|\\s)mce-item-\\w+(?!\\S)/g, '');\n            node.attr('class', value.length > 0 ? value : null);\n          }\n        }\n      });\n      htmlParser.addAttributeFilter('data-mce-type', function (nodes, name, args) {\n        var i = nodes.length;\n        while (i--) {\n          var node = nodes[i];\n          if (node.attr('data-mce-type') === 'bookmark' && !args.cleanup) {\n            var hasChildren = Optional.from(node.firstChild).exists(function (firstChild) {\n              return !isZwsp(firstChild.value);\n            });\n            if (hasChildren) {\n              node.unwrap();\n            } else {\n              node.remove();\n            }\n          }\n        }\n      });\n      htmlParser.addNodeFilter('noscript', function (nodes) {\n        var i = nodes.length;\n        while (i--) {\n          var node = nodes[i].firstChild;\n          if (node) {\n            node.value = Entities.decode(node.value);\n          }\n        }\n      });\n      htmlParser.addNodeFilter('script,style', function (nodes, name) {\n        var trim = function (value) {\n          return value.replace(/(<!--\\[CDATA\\[|\\]\\]-->)/g, '\\n').replace(/^[\\r\\n]*|[\\r\\n]*$/g, '').replace(/^\\s*((<!--)?(\\s*\\/\\/)?\\s*<!\\[CDATA\\[|(<!--\\s*)?\\/\\*\\s*<!\\[CDATA\\[\\s*\\*\\/|(\\/\\/)?\\s*<!--|\\/\\*\\s*<!--\\s*\\*\\/)\\s*[\\r\\n]*/gi, '').replace(/\\s*(\\/\\*\\s*\\]\\]>\\s*\\*\\/(-->)?|\\s*\\/\\/\\s*\\]\\]>(-->)?|\\/\\/\\s*(-->)?|\\]\\]>|\\/\\*\\s*-->\\s*\\*\\/|\\s*-->\\s*)\\s*$/g, '');\n        };\n        var i = nodes.length;\n        while (i--) {\n          var node = nodes[i];\n          var value = node.firstChild ? node.firstChild.value : '';\n          if (name === 'script') {\n            var type = node.attr('type');\n            if (type) {\n              node.attr('type', type === 'mce-no/type' ? null : type.replace(/^mce\\-/, ''));\n            }\n            if (settings.element_format === 'xhtml' && value.length > 0) {\n              node.firstChild.value = '// <![CDATA[\\n' + trim(value) + '\\n// ]]>';\n            }\n          } else {\n            if (settings.element_format === 'xhtml' && value.length > 0) {\n              node.firstChild.value = '<!--\\n' + trim(value) + '\\n-->';\n            }\n          }\n        }\n      });\n      htmlParser.addNodeFilter('#comment', function (nodes) {\n        var i = nodes.length;\n        while (i--) {\n          var node = nodes[i];\n          if (settings.preserve_cdata && node.value.indexOf('[CDATA[') === 0) {\n            node.name = '#cdata';\n            node.type = 4;\n            node.value = dom.decode(node.value.replace(/^\\[CDATA\\[|\\]\\]$/g, ''));\n          } else if (node.value.indexOf('mce:protected ') === 0) {\n            node.name = '#text';\n            node.type = 3;\n            node.raw = true;\n            node.value = unescape(node.value).substr(14);\n          }\n        }\n      });\n      htmlParser.addNodeFilter('xml:namespace,input', function (nodes, name) {\n        var i = nodes.length;\n        while (i--) {\n          var node = nodes[i];\n          if (node.type === 7) {\n            node.remove();\n          } else if (node.type === 1) {\n            if (name === 'input' && !node.attr('type')) {\n              node.attr('type', 'text');\n            }\n          }\n        }\n      });\n      htmlParser.addAttributeFilter('data-mce-type', function (nodes) {\n        each$k(nodes, function (node) {\n          if (node.attr('data-mce-type') === 'format-caret') {\n            if (node.isEmpty(htmlParser.schema.getNonEmptyElements())) {\n              node.remove();\n            } else {\n              node.unwrap();\n            }\n          }\n        });\n      });\n      htmlParser.addAttributeFilter('data-mce-src,data-mce-href,data-mce-style,' + 'data-mce-selected,data-mce-expando,' + 'data-mce-type,data-mce-resize,data-mce-placeholder', function (nodes, name) {\n        var i = nodes.length;\n        while (i--) {\n          nodes[i].attr(name, null);\n        }\n      });\n    };\n    var trimTrailingBr = function (rootNode) {\n      var isBr = function (node) {\n        return node && node.name === 'br';\n      };\n      var brNode1 = rootNode.lastChild;\n      if (isBr(brNode1)) {\n        var brNode2 = brNode1.prev;\n        if (isBr(brNode2)) {\n          brNode1.remove();\n          brNode2.remove();\n        }\n      }\n    };\n\n    var preProcess = function (editor, node, args) {\n      var oldDoc;\n      var dom = editor.dom;\n      var clonedNode = node.cloneNode(true);\n      var impl = document.implementation;\n      if (impl.createHTMLDocument) {\n        var doc_1 = impl.createHTMLDocument('');\n        Tools.each(clonedNode.nodeName === 'BODY' ? clonedNode.childNodes : [clonedNode], function (node) {\n          doc_1.body.appendChild(doc_1.importNode(node, true));\n        });\n        if (clonedNode.nodeName !== 'BODY') {\n          clonedNode = doc_1.body.firstChild;\n        } else {\n          clonedNode = doc_1.body;\n        }\n        oldDoc = dom.doc;\n        dom.doc = doc_1;\n      }\n      firePreProcess(editor, __assign(__assign({}, args), { node: clonedNode }));\n      if (oldDoc) {\n        dom.doc = oldDoc;\n      }\n      return clonedNode;\n    };\n    var shouldFireEvent = function (editor, args) {\n      return editor && editor.hasEventListeners('PreProcess') && !args.no_events;\n    };\n    var process = function (editor, node, args) {\n      return shouldFireEvent(editor, args) ? preProcess(editor, node, args) : node;\n    };\n\n    var addTempAttr = function (htmlParser, tempAttrs, name) {\n      if (Tools.inArray(tempAttrs, name) === -1) {\n        htmlParser.addAttributeFilter(name, function (nodes, name) {\n          var i = nodes.length;\n          while (i--) {\n            nodes[i].attr(name, null);\n          }\n        });\n        tempAttrs.push(name);\n      }\n    };\n    var postProcess = function (editor, args, content) {\n      if (!args.no_events && editor) {\n        var outArgs = firePostProcess(editor, __assign(__assign({}, args), { content: content }));\n        return outArgs.content;\n      } else {\n        return content;\n      }\n    };\n    var getHtmlFromNode = function (dom, node, args) {\n      var html = trim$3(args.getInner ? node.innerHTML : dom.getOuterHTML(node));\n      return args.selection || isWsPreserveElement(SugarElement.fromDom(node)) ? html : Tools.trim(html);\n    };\n    var parseHtml = function (htmlParser, html, args) {\n      var parserArgs = args.selection ? __assign({ forced_root_block: false }, args) : args;\n      var rootNode = htmlParser.parse(html, parserArgs);\n      trimTrailingBr(rootNode);\n      return rootNode;\n    };\n    var serializeNode = function (settings, schema, node) {\n      var htmlSerializer = HtmlSerializer(settings, schema);\n      return htmlSerializer.serialize(node);\n    };\n    var toHtml = function (editor, settings, schema, rootNode, args) {\n      var content = serializeNode(settings, schema, rootNode);\n      return postProcess(editor, args, content);\n    };\n    var DomSerializerImpl = function (settings, editor) {\n      var tempAttrs = ['data-mce-selected'];\n      var dom = editor && editor.dom ? editor.dom : DOMUtils.DOM;\n      var schema = editor && editor.schema ? editor.schema : Schema(settings);\n      settings.entity_encoding = settings.entity_encoding || 'named';\n      settings.remove_trailing_brs = 'remove_trailing_brs' in settings ? settings.remove_trailing_brs : true;\n      var htmlParser = DomParser(settings, schema);\n      register(htmlParser, settings, dom);\n      var serialize = function (node, parserArgs) {\n        if (parserArgs === void 0) {\n          parserArgs = {};\n        }\n        var args = __assign({ format: 'html' }, parserArgs);\n        var targetNode = process(editor, node, args);\n        var html = getHtmlFromNode(dom, targetNode, args);\n        var rootNode = parseHtml(htmlParser, html, args);\n        return args.format === 'tree' ? rootNode : toHtml(editor, settings, schema, rootNode, args);\n      };\n      return {\n        schema: schema,\n        addNodeFilter: htmlParser.addNodeFilter,\n        addAttributeFilter: htmlParser.addAttributeFilter,\n        serialize: serialize,\n        addRules: schema.addValidElements,\n        setRules: schema.setValidElements,\n        addTempAttr: curry(addTempAttr, htmlParser, tempAttrs),\n        getTempAttrs: constant(tempAttrs),\n        getNodeFilters: htmlParser.getNodeFilters,\n        getAttributeFilters: htmlParser.getAttributeFilters\n      };\n    };\n\n    var DomSerializer = function (settings, editor) {\n      var domSerializer = DomSerializerImpl(settings, editor);\n      return {\n        schema: domSerializer.schema,\n        addNodeFilter: domSerializer.addNodeFilter,\n        addAttributeFilter: domSerializer.addAttributeFilter,\n        serialize: domSerializer.serialize,\n        addRules: domSerializer.addRules,\n        setRules: domSerializer.setRules,\n        addTempAttr: domSerializer.addTempAttr,\n        getTempAttrs: domSerializer.getTempAttrs,\n        getNodeFilters: domSerializer.getNodeFilters,\n        getAttributeFilters: domSerializer.getAttributeFilters\n      };\n    };\n\n    var defaultFormat = 'html';\n    var getContent = function (editor, args) {\n      if (args === void 0) {\n        args = {};\n      }\n      var format = args.format ? args.format : defaultFormat;\n      return getContent$2(editor, args, format);\n    };\n\n    var setContent = function (editor, content, args) {\n      if (args === void 0) {\n        args = {};\n      }\n      return setContent$2(editor, content, args);\n    };\n\n    var DOM$7 = DOMUtils.DOM;\n    var restoreOriginalStyles = function (editor) {\n      DOM$7.setStyle(editor.id, 'display', editor.orgDisplay);\n    };\n    var safeDestroy = function (x) {\n      return Optional.from(x).each(function (x) {\n        return x.destroy();\n      });\n    };\n    var clearDomReferences = function (editor) {\n      editor.contentAreaContainer = editor.formElement = editor.container = editor.editorContainer = null;\n      editor.bodyElement = editor.contentDocument = editor.contentWindow = null;\n      editor.iframeElement = editor.targetElm = null;\n      if (editor.selection) {\n        editor.selection = editor.selection.win = editor.selection.dom = editor.selection.dom.doc = null;\n      }\n    };\n    var restoreForm = function (editor) {\n      var form = editor.formElement;\n      if (form) {\n        if (form._mceOldSubmit) {\n          form.submit = form._mceOldSubmit;\n          form._mceOldSubmit = null;\n        }\n        DOM$7.unbind(form, 'submit reset', editor.formEventDelegate);\n      }\n    };\n    var remove = function (editor) {\n      if (!editor.removed) {\n        var _selectionOverrides = editor._selectionOverrides, editorUpload = editor.editorUpload;\n        var body = editor.getBody();\n        var element = editor.getElement();\n        if (body) {\n          editor.save({ is_removing: true });\n        }\n        editor.removed = true;\n        editor.unbindAllNativeEvents();\n        if (editor.hasHiddenInput && element) {\n          DOM$7.remove(element.nextSibling);\n        }\n        fireRemove(editor);\n        editor.editorManager.remove(editor);\n        if (!editor.inline && body) {\n          restoreOriginalStyles(editor);\n        }\n        fireDetach(editor);\n        DOM$7.remove(editor.getContainer());\n        safeDestroy(_selectionOverrides);\n        safeDestroy(editorUpload);\n        editor.destroy();\n      }\n    };\n    var destroy = function (editor, automatic) {\n      var selection = editor.selection, dom = editor.dom;\n      if (editor.destroyed) {\n        return;\n      }\n      if (!automatic && !editor.removed) {\n        editor.remove();\n        return;\n      }\n      if (!automatic) {\n        editor.editorManager.off('beforeunload', editor._beforeUnload);\n        if (editor.theme && editor.theme.destroy) {\n          editor.theme.destroy();\n        }\n        safeDestroy(selection);\n        safeDestroy(dom);\n      }\n      restoreForm(editor);\n      clearDomReferences(editor);\n      editor.destroyed = true;\n    };\n\n    var deep = function (old, nu) {\n      var bothObjects = isObject(old) && isObject(nu);\n      return bothObjects ? deepMerge(old, nu) : nu;\n    };\n    var baseMerge = function (merger) {\n      return function () {\n        var objects = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n          objects[_i] = arguments[_i];\n        }\n        if (objects.length === 0) {\n          throw new Error('Can\\'t merge zero objects');\n        }\n        var ret = {};\n        for (var j = 0; j < objects.length; j++) {\n          var curObject = objects[j];\n          for (var key in curObject) {\n            if (has$2(curObject, key)) {\n              ret[key] = merger(ret[key], curObject[key]);\n            }\n          }\n        }\n        return ret;\n      };\n    };\n    var deepMerge = baseMerge(deep);\n\n    var deprecatedSettings = ('autoresize_on_init,content_editable_state,convert_fonts_to_spans,inline_styles,padd_empty_with_br,block_elements,' + 'boolean_attributes,editor_deselector,editor_selector,elements,file_browser_callback_types,filepicker_validator_handler,' + 'force_hex_style_colors,force_p_newlines,gecko_spellcheck,images_dataimg_filter,media_scripts,mode,move_caret_before_on_enter_elements,' + 'non_empty_elements,self_closing_elements,short_ended_elements,special,spellchecker_select_languages,spellchecker_whitelist,' + 'tab_focus,table_responsive_width,text_block_elements,text_inline_elements,toolbar_drawer,types,validate,whitespace_elements,' + 'paste_word_valid_elements,paste_retain_style_properties,paste_convert_word_fake_lists').split(',');\n    var deprecatedPlugins = 'bbcode,colorpicker,contextmenu,fullpage,legacyoutput,spellchecker,textcolor'.split(',');\n    var movedToPremiumPlugins = 'imagetools,toc'.split(',');\n    var getDeprecatedSettings = function (settings) {\n      var settingNames = filter$4(deprecatedSettings, function (setting) {\n        return has$2(settings, setting);\n      });\n      var forcedRootBlock = settings.forced_root_block;\n      if (forcedRootBlock === false || forcedRootBlock === '') {\n        settingNames.push('forced_root_block (false only)');\n      }\n      return sort(settingNames);\n    };\n    var getDeprecatedPlugins = function (settings) {\n      var plugins = Tools.makeMap(settings.plugins, ' ');\n      var hasPlugin = function (plugin) {\n        return has$2(plugins, plugin);\n      };\n      var pluginNames = __spreadArray(__spreadArray([], filter$4(deprecatedPlugins, hasPlugin), true), bind(movedToPremiumPlugins, function (plugin) {\n        return hasPlugin(plugin) ? [plugin + ' (moving to premium)'] : [];\n      }), true);\n      return sort(pluginNames);\n    };\n    var logDeprecationsWarning = function (rawSettings, finalSettings) {\n      var deprecatedSettings = getDeprecatedSettings(rawSettings);\n      var deprecatedPlugins = getDeprecatedPlugins(finalSettings);\n      var hasDeprecatedPlugins = deprecatedPlugins.length > 0;\n      var hasDeprecatedSettings = deprecatedSettings.length > 0;\n      var isLegacyMobileTheme = finalSettings.theme === 'mobile';\n      if (hasDeprecatedPlugins || hasDeprecatedSettings || isLegacyMobileTheme) {\n        var listJoiner = '\\n- ';\n        var themesMessage = isLegacyMobileTheme ? '\\n\\nThemes:' + listJoiner + 'mobile' : '';\n        var pluginsMessage = hasDeprecatedPlugins ? '\\n\\nPlugins:' + listJoiner + deprecatedPlugins.join(listJoiner) : '';\n        var settingsMessage = hasDeprecatedSettings ? '\\n\\nSettings:' + listJoiner + deprecatedSettings.join(listJoiner) : '';\n        console.warn('The following deprecated features are currently enabled, these will be removed in TinyMCE 6.0. ' + 'See https://www.tiny.cloud/docs/release-notes/6.0-upcoming-changes/ for more information.' + themesMessage + pluginsMessage + settingsMessage);\n      }\n    };\n\n    var sectionResult = function (sections, settings) {\n      return {\n        sections: constant(sections),\n        settings: constant(settings)\n      };\n    };\n    var deviceDetection = detect().deviceType;\n    var isTouch = deviceDetection.isTouch();\n    var isPhone = deviceDetection.isPhone();\n    var isTablet = deviceDetection.isTablet();\n    var legacyMobilePlugins = [\n      'lists',\n      'autolink',\n      'autosave'\n    ];\n    var defaultTouchSettings = {\n      table_grid: false,\n      object_resizing: false,\n      resize: false\n    };\n    var normalizePlugins = function (plugins) {\n      var pluginNames = isArray$1(plugins) ? plugins.join(' ') : plugins;\n      var trimmedPlugins = map$3(isString$1(pluginNames) ? pluginNames.split(' ') : [], trim$5);\n      return filter$4(trimmedPlugins, function (item) {\n        return item.length > 0;\n      });\n    };\n    var filterLegacyMobilePlugins = function (plugins) {\n      return filter$4(plugins, curry(contains$3, legacyMobilePlugins));\n    };\n    var extractSections = function (keys, settings) {\n      var result = bifilter(settings, function (value, key) {\n        return contains$3(keys, key);\n      });\n      return sectionResult(result.t, result.f);\n    };\n    var getSection = function (sectionResult, name, defaults) {\n      if (defaults === void 0) {\n        defaults = {};\n      }\n      var sections = sectionResult.sections();\n      var sectionSettings = get$9(sections, name).getOr({});\n      return Tools.extend({}, defaults, sectionSettings);\n    };\n    var hasSection = function (sectionResult, name) {\n      return has$2(sectionResult.sections(), name);\n    };\n    var isSectionTheme = function (sectionResult, name, theme) {\n      var section = sectionResult.sections();\n      return hasSection(sectionResult, name) && section[name].theme === theme;\n    };\n    var getSectionConfig = function (sectionResult, name) {\n      return hasSection(sectionResult, name) ? sectionResult.sections()[name] : {};\n    };\n    var getToolbarMode = function (settings, defaultVal) {\n      return get$9(settings, 'toolbar_mode').orThunk(function () {\n        return get$9(settings, 'toolbar_drawer').map(function (val) {\n          return val === false ? 'wrap' : val;\n        });\n      }).getOr(defaultVal);\n    };\n    var getDefaultSettings = function (settings, id, documentBaseUrl, isTouch, editor) {\n      var baseDefaults = {\n        id: id,\n        theme: 'silver',\n        toolbar_mode: getToolbarMode(settings, 'floating'),\n        plugins: '',\n        document_base_url: documentBaseUrl,\n        add_form_submit_trigger: true,\n        submit_patch: true,\n        add_unload_trigger: true,\n        convert_urls: true,\n        relative_urls: true,\n        remove_script_host: true,\n        object_resizing: true,\n        doctype: '<!DOCTYPE html>',\n        visual: true,\n        font_size_legacy_values: 'xx-small,small,medium,large,x-large,xx-large,300%',\n        forced_root_block: 'p',\n        hidden_input: true,\n        inline_styles: true,\n        convert_fonts_to_spans: true,\n        indent: true,\n        indent_before: 'p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,' + 'tfoot,tbody,tr,section,summary,article,hgroup,aside,figure,figcaption,option,optgroup,datalist',\n        indent_after: 'p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,' + 'tfoot,tbody,tr,section,summary,article,hgroup,aside,figure,figcaption,option,optgroup,datalist',\n        entity_encoding: 'named',\n        url_converter: editor.convertURL,\n        url_converter_scope: editor\n      };\n      return __assign(__assign({}, baseDefaults), isTouch ? defaultTouchSettings : {});\n    };\n    var getDefaultMobileSettings = function (mobileSettings, isPhone) {\n      var defaultMobileSettings = {\n        resize: false,\n        toolbar_mode: getToolbarMode(mobileSettings, 'scrolling'),\n        toolbar_sticky: false\n      };\n      var defaultPhoneSettings = { menubar: false };\n      return __assign(__assign(__assign({}, defaultTouchSettings), defaultMobileSettings), isPhone ? defaultPhoneSettings : {});\n    };\n    var getExternalPlugins = function (overrideSettings, settings) {\n      var userDefinedExternalPlugins = settings.external_plugins ? settings.external_plugins : {};\n      if (overrideSettings && overrideSettings.external_plugins) {\n        return Tools.extend({}, overrideSettings.external_plugins, userDefinedExternalPlugins);\n      } else {\n        return userDefinedExternalPlugins;\n      }\n    };\n    var combinePlugins = function (forcedPlugins, plugins) {\n      return [].concat(normalizePlugins(forcedPlugins)).concat(normalizePlugins(plugins));\n    };\n    var getPlatformPlugins = function (isMobileDevice, sectionResult, desktopPlugins, mobilePlugins) {\n      if (isMobileDevice && isSectionTheme(sectionResult, 'mobile', 'mobile')) {\n        return filterLegacyMobilePlugins(mobilePlugins);\n      } else if (isMobileDevice && hasSection(sectionResult, 'mobile')) {\n        return mobilePlugins;\n      } else {\n        return desktopPlugins;\n      }\n    };\n    var processPlugins = function (isMobileDevice, sectionResult, defaultOverrideSettings, settings) {\n      var forcedPlugins = normalizePlugins(defaultOverrideSettings.forced_plugins);\n      var desktopPlugins = normalizePlugins(settings.plugins);\n      var mobileConfig = getSectionConfig(sectionResult, 'mobile');\n      var mobilePlugins = mobileConfig.plugins ? normalizePlugins(mobileConfig.plugins) : desktopPlugins;\n      var platformPlugins = getPlatformPlugins(isMobileDevice, sectionResult, desktopPlugins, mobilePlugins);\n      var combinedPlugins = combinePlugins(forcedPlugins, platformPlugins);\n      if (Env.browser.isIE() && contains$3(combinedPlugins, 'rtc')) {\n        throw new Error('RTC plugin is not supported on IE 11.');\n      }\n      return Tools.extend(settings, { plugins: combinedPlugins.join(' ') });\n    };\n    var isOnMobile = function (isMobileDevice, sectionResult) {\n      return isMobileDevice && hasSection(sectionResult, 'mobile');\n    };\n    var combineSettings = function (isMobileDevice, isPhone, defaultSettings, defaultOverrideSettings, settings) {\n      var defaultDeviceSettings = isMobileDevice ? { mobile: getDefaultMobileSettings(settings.mobile || {}, isPhone) } : {};\n      var sectionResult = extractSections(['mobile'], deepMerge(defaultDeviceSettings, settings));\n      var extendedSettings = Tools.extend(defaultSettings, defaultOverrideSettings, sectionResult.settings(), isOnMobile(isMobileDevice, sectionResult) ? getSection(sectionResult, 'mobile') : {}, {\n        validate: true,\n        external_plugins: getExternalPlugins(defaultOverrideSettings, sectionResult.settings())\n      });\n      return processPlugins(isMobileDevice, sectionResult, defaultOverrideSettings, extendedSettings);\n    };\n    var getEditorSettings = function (editor, id, documentBaseUrl, defaultOverrideSettings, settings) {\n      var defaultSettings = getDefaultSettings(settings, id, documentBaseUrl, isTouch, editor);\n      var finalSettings = combineSettings(isPhone || isTablet, isPhone, defaultSettings, defaultOverrideSettings, settings);\n      if (finalSettings.deprecation_warnings !== false) {\n        logDeprecationsWarning(settings, finalSettings);\n      }\n      return finalSettings;\n    };\n    var getFiltered = function (predicate, editor, name) {\n      return Optional.from(editor.settings[name]).filter(predicate);\n    };\n    var getParamObject = function (value) {\n      var output = {};\n      if (typeof value === 'string') {\n        each$k(value.indexOf('=') > 0 ? value.split(/[;,](?![^=;,]*(?:[;,]|$))/) : value.split(','), function (val) {\n          var arr = val.split('=');\n          if (arr.length > 1) {\n            output[Tools.trim(arr[0])] = Tools.trim(arr[1]);\n          } else {\n            output[Tools.trim(arr[0])] = Tools.trim(arr[0]);\n          }\n        });\n      } else {\n        output = value;\n      }\n      return output;\n    };\n    var isArrayOf = function (p) {\n      return function (a) {\n        return isArray$1(a) && forall(a, p);\n      };\n    };\n    var getParam = function (editor, name, defaultVal, type) {\n      var value = name in editor.settings ? editor.settings[name] : defaultVal;\n      if (type === 'hash') {\n        return getParamObject(value);\n      } else if (type === 'string') {\n        return getFiltered(isString$1, editor, name).getOr(defaultVal);\n      } else if (type === 'number') {\n        return getFiltered(isNumber, editor, name).getOr(defaultVal);\n      } else if (type === 'boolean') {\n        return getFiltered(isBoolean, editor, name).getOr(defaultVal);\n      } else if (type === 'object') {\n        return getFiltered(isObject, editor, name).getOr(defaultVal);\n      } else if (type === 'array') {\n        return getFiltered(isArray$1, editor, name).getOr(defaultVal);\n      } else if (type === 'string[]') {\n        return getFiltered(isArrayOf(isString$1), editor, name).getOr(defaultVal);\n      } else if (type === 'function') {\n        return getFiltered(isFunction, editor, name).getOr(defaultVal);\n      } else {\n        return value;\n      }\n    };\n\n    var CreateIconManager = function () {\n      var lookup = {};\n      var add = function (id, iconPack) {\n        lookup[id] = iconPack;\n      };\n      var get = function (id) {\n        if (lookup[id]) {\n          return lookup[id];\n        }\n        return { icons: {} };\n      };\n      var has = function (id) {\n        return has$2(lookup, id);\n      };\n      return {\n        add: add,\n        get: get,\n        has: has\n      };\n    };\n    var IconManager = CreateIconManager();\n\n    var getProp = function (propName, elm) {\n      var rawElm = elm.dom;\n      return rawElm[propName];\n    };\n    var getComputedSizeProp = function (propName, elm) {\n      return parseInt(get$5(elm, propName), 10);\n    };\n    var getClientWidth = curry(getProp, 'clientWidth');\n    var getClientHeight = curry(getProp, 'clientHeight');\n    var getMarginTop = curry(getComputedSizeProp, 'margin-top');\n    var getMarginLeft = curry(getComputedSizeProp, 'margin-left');\n    var getBoundingClientRect = function (elm) {\n      return elm.dom.getBoundingClientRect();\n    };\n    var isInsideElementContentArea = function (bodyElm, clientX, clientY) {\n      var clientWidth = getClientWidth(bodyElm);\n      var clientHeight = getClientHeight(bodyElm);\n      return clientX >= 0 && clientY >= 0 && clientX <= clientWidth && clientY <= clientHeight;\n    };\n    var transpose = function (inline, elm, clientX, clientY) {\n      var clientRect = getBoundingClientRect(elm);\n      var deltaX = inline ? clientRect.left + elm.dom.clientLeft + getMarginLeft(elm) : 0;\n      var deltaY = inline ? clientRect.top + elm.dom.clientTop + getMarginTop(elm) : 0;\n      var x = clientX - deltaX;\n      var y = clientY - deltaY;\n      return {\n        x: x,\n        y: y\n      };\n    };\n    var isXYInContentArea = function (editor, clientX, clientY) {\n      var bodyElm = SugarElement.fromDom(editor.getBody());\n      var targetElm = editor.inline ? bodyElm : documentElement(bodyElm);\n      var transposedPoint = transpose(editor.inline, targetElm, clientX, clientY);\n      return isInsideElementContentArea(targetElm, transposedPoint.x, transposedPoint.y);\n    };\n    var fromDomSafe = function (node) {\n      return Optional.from(node).map(SugarElement.fromDom);\n    };\n    var isEditorAttachedToDom = function (editor) {\n      var rawContainer = editor.inline ? editor.getBody() : editor.getContentAreaContainer();\n      return fromDomSafe(rawContainer).map(inBody).getOr(false);\n    };\n\n    var NotificationManagerImpl = function () {\n      var unimplemented = function () {\n        throw new Error('Theme did not provide a NotificationManager implementation.');\n      };\n      return {\n        open: unimplemented,\n        close: unimplemented,\n        reposition: unimplemented,\n        getArgs: unimplemented\n      };\n    };\n\n    var NotificationManager = function (editor) {\n      var notifications = [];\n      var getImplementation = function () {\n        var theme = editor.theme;\n        return theme && theme.getNotificationManagerImpl ? theme.getNotificationManagerImpl() : NotificationManagerImpl();\n      };\n      var getTopNotification = function () {\n        return Optional.from(notifications[0]);\n      };\n      var isEqual = function (a, b) {\n        return a.type === b.type && a.text === b.text && !a.progressBar && !a.timeout && !b.progressBar && !b.timeout;\n      };\n      var reposition = function () {\n        if (notifications.length > 0) {\n          getImplementation().reposition(notifications);\n        }\n      };\n      var addNotification = function (notification) {\n        notifications.push(notification);\n      };\n      var closeNotification = function (notification) {\n        findIndex$2(notifications, function (otherNotification) {\n          return otherNotification === notification;\n        }).each(function (index) {\n          notifications.splice(index, 1);\n        });\n      };\n      var open = function (spec, fireEvent) {\n        if (fireEvent === void 0) {\n          fireEvent = true;\n        }\n        if (editor.removed || !isEditorAttachedToDom(editor)) {\n          return;\n        }\n        if (fireEvent) {\n          editor.fire('BeforeOpenNotification', { notification: spec });\n        }\n        return find$3(notifications, function (notification) {\n          return isEqual(getImplementation().getArgs(notification), spec);\n        }).getOrThunk(function () {\n          editor.editorManager.setActive(editor);\n          var notification = getImplementation().open(spec, function () {\n            closeNotification(notification);\n            reposition();\n            getTopNotification().fold(function () {\n              return editor.focus();\n            }, function (top) {\n              return focus$1(SugarElement.fromDom(top.getEl()));\n            });\n          });\n          addNotification(notification);\n          reposition();\n          editor.fire('OpenNotification', { notification: __assign({}, notification) });\n          return notification;\n        });\n      };\n      var close = function () {\n        getTopNotification().each(function (notification) {\n          getImplementation().close(notification);\n          closeNotification(notification);\n          reposition();\n        });\n      };\n      var getNotifications = constant(notifications);\n      var registerEvents = function (editor) {\n        editor.on('SkinLoaded', function () {\n          var serviceMessage = getServiceMessage(editor);\n          if (serviceMessage) {\n            open({\n              text: serviceMessage,\n              type: 'warning',\n              timeout: 0\n            }, false);\n          }\n          reposition();\n        });\n        editor.on('show ResizeEditor ResizeWindow NodeChange', function () {\n          Delay.requestAnimationFrame(reposition);\n        });\n        editor.on('remove', function () {\n          each$k(notifications.slice(), function (notification) {\n            getImplementation().close(notification);\n          });\n        });\n      };\n      registerEvents(editor);\n      return {\n        open: open,\n        close: close,\n        getNotifications: getNotifications\n      };\n    };\n\n    var PluginManager = AddOnManager.PluginManager;\n\n    var ThemeManager = AddOnManager.ThemeManager;\n\n    function WindowManagerImpl () {\n      var unimplemented = function () {\n        throw new Error('Theme did not provide a WindowManager implementation.');\n      };\n      return {\n        open: unimplemented,\n        openUrl: unimplemented,\n        alert: unimplemented,\n        confirm: unimplemented,\n        close: unimplemented,\n        getParams: unimplemented,\n        setParams: unimplemented\n      };\n    }\n\n    var WindowManager = function (editor) {\n      var dialogs = [];\n      var getImplementation = function () {\n        var theme = editor.theme;\n        return theme && theme.getWindowManagerImpl ? theme.getWindowManagerImpl() : WindowManagerImpl();\n      };\n      var funcBind = function (scope, f) {\n        return function () {\n          var args = [];\n          for (var _i = 0; _i < arguments.length; _i++) {\n            args[_i] = arguments[_i];\n          }\n          return f ? f.apply(scope, args) : undefined;\n        };\n      };\n      var fireOpenEvent = function (dialog) {\n        editor.fire('OpenWindow', { dialog: dialog });\n      };\n      var fireCloseEvent = function (dialog) {\n        editor.fire('CloseWindow', { dialog: dialog });\n      };\n      var addDialog = function (dialog) {\n        dialogs.push(dialog);\n        fireOpenEvent(dialog);\n      };\n      var closeDialog = function (dialog) {\n        fireCloseEvent(dialog);\n        dialogs = filter$4(dialogs, function (otherDialog) {\n          return otherDialog !== dialog;\n        });\n        if (dialogs.length === 0) {\n          editor.focus();\n        }\n      };\n      var getTopDialog = function () {\n        return Optional.from(dialogs[dialogs.length - 1]);\n      };\n      var storeSelectionAndOpenDialog = function (openDialog) {\n        editor.editorManager.setActive(editor);\n        store(editor);\n        var dialog = openDialog();\n        addDialog(dialog);\n        return dialog;\n      };\n      var open = function (args, params) {\n        return storeSelectionAndOpenDialog(function () {\n          return getImplementation().open(args, params, closeDialog);\n        });\n      };\n      var openUrl = function (args) {\n        return storeSelectionAndOpenDialog(function () {\n          return getImplementation().openUrl(args, closeDialog);\n        });\n      };\n      var alert = function (message, callback, scope) {\n        var windowManagerImpl = getImplementation();\n        windowManagerImpl.alert(message, funcBind(scope ? scope : windowManagerImpl, callback));\n      };\n      var confirm = function (message, callback, scope) {\n        var windowManagerImpl = getImplementation();\n        windowManagerImpl.confirm(message, funcBind(scope ? scope : windowManagerImpl, callback));\n      };\n      var close = function () {\n        getTopDialog().each(function (dialog) {\n          getImplementation().close(dialog);\n          closeDialog(dialog);\n        });\n      };\n      editor.on('remove', function () {\n        each$k(dialogs, function (dialog) {\n          getImplementation().close(dialog);\n        });\n      });\n      return {\n        open: open,\n        openUrl: openUrl,\n        alert: alert,\n        confirm: confirm,\n        close: close\n      };\n    };\n\n    var displayNotification = function (editor, message) {\n      editor.notificationManager.open({\n        type: 'error',\n        text: message\n      });\n    };\n    var displayError = function (editor, message) {\n      if (editor._skinLoaded) {\n        displayNotification(editor, message);\n      } else {\n        editor.on('SkinLoaded', function () {\n          displayNotification(editor, message);\n        });\n      }\n    };\n    var uploadError = function (editor, message) {\n      displayError(editor, I18n.translate([\n        'Failed to upload image: {0}',\n        message\n      ]));\n    };\n    var logError = function (editor, errorType, msg) {\n      fireError(editor, errorType, { message: msg });\n      console.error(msg);\n    };\n    var createLoadError = function (type, url, name) {\n      return name ? 'Failed to load ' + type + ': ' + name + ' from url ' + url : 'Failed to load ' + type + ' url: ' + url;\n    };\n    var pluginLoadError = function (editor, url, name) {\n      logError(editor, 'PluginLoadError', createLoadError('plugin', url, name));\n    };\n    var iconsLoadError = function (editor, url, name) {\n      logError(editor, 'IconsLoadError', createLoadError('icons', url, name));\n    };\n    var languageLoadError = function (editor, url, name) {\n      logError(editor, 'LanguageLoadError', createLoadError('language', url, name));\n    };\n    var pluginInitError = function (editor, name, err) {\n      var message = I18n.translate([\n        'Failed to initialize plugin: {0}',\n        name\n      ]);\n      fireError(editor, 'PluginLoadError', { message: message });\n      initError(message, err);\n      displayError(editor, message);\n    };\n    var initError = function (message) {\n      var x = [];\n      for (var _i = 1; _i < arguments.length; _i++) {\n        x[_i - 1] = arguments[_i];\n      }\n      var console = window.console;\n      if (console) {\n        if (console.error) {\n          console.error.apply(console, __spreadArray([message], x, false));\n        } else {\n          console.log.apply(console, __spreadArray([message], x, false));\n        }\n      }\n    };\n\n    var isContentCssSkinName = function (url) {\n      return /^[a-z0-9\\-]+$/i.test(url);\n    };\n    var getContentCssUrls = function (editor) {\n      return transformToUrls(editor, getContentCss(editor));\n    };\n    var getFontCssUrls = function (editor) {\n      return transformToUrls(editor, getFontCss(editor));\n    };\n    var transformToUrls = function (editor, cssLinks) {\n      var skinUrl = editor.editorManager.baseURL + '/skins/content';\n      var suffix = editor.editorManager.suffix;\n      var contentCssFile = 'content' + suffix + '.css';\n      var inline = editor.inline === true;\n      return map$3(cssLinks, function (url) {\n        if (isContentCssSkinName(url) && !inline) {\n          return skinUrl + '/' + url + '/' + contentCssFile;\n        } else {\n          return editor.documentBaseURI.toAbsolute(url);\n        }\n      });\n    };\n    var appendContentCssFromSettings = function (editor) {\n      editor.contentCSS = editor.contentCSS.concat(getContentCssUrls(editor), getFontCssUrls(editor));\n    };\n\n    var UploadStatus = function () {\n      var PENDING = 1, UPLOADED = 2;\n      var blobUriStatuses = {};\n      var createStatus = function (status, resultUri) {\n        return {\n          status: status,\n          resultUri: resultUri\n        };\n      };\n      var hasBlobUri = function (blobUri) {\n        return blobUri in blobUriStatuses;\n      };\n      var getResultUri = function (blobUri) {\n        var result = blobUriStatuses[blobUri];\n        return result ? result.resultUri : null;\n      };\n      var isPending = function (blobUri) {\n        return hasBlobUri(blobUri) ? blobUriStatuses[blobUri].status === PENDING : false;\n      };\n      var isUploaded = function (blobUri) {\n        return hasBlobUri(blobUri) ? blobUriStatuses[blobUri].status === UPLOADED : false;\n      };\n      var markPending = function (blobUri) {\n        blobUriStatuses[blobUri] = createStatus(PENDING, null);\n      };\n      var markUploaded = function (blobUri, resultUri) {\n        blobUriStatuses[blobUri] = createStatus(UPLOADED, resultUri);\n      };\n      var removeFailed = function (blobUri) {\n        delete blobUriStatuses[blobUri];\n      };\n      var destroy = function () {\n        blobUriStatuses = {};\n      };\n      return {\n        hasBlobUri: hasBlobUri,\n        getResultUri: getResultUri,\n        isPending: isPending,\n        isUploaded: isUploaded,\n        markPending: markPending,\n        markUploaded: markUploaded,\n        removeFailed: removeFailed,\n        destroy: destroy\n      };\n    };\n\n    var count = 0;\n    var seed = function () {\n      var rnd = function () {\n        return Math.round(Math.random() * 4294967295).toString(36);\n      };\n      var now = new Date().getTime();\n      return 's' + now.toString(36) + rnd() + rnd() + rnd();\n    };\n    var uuid = function (prefix) {\n      return prefix + count++ + seed();\n    };\n\n    var BlobCache = function () {\n      var cache = [];\n      var mimeToExt = function (mime) {\n        var mimes = {\n          'image/jpeg': 'jpg',\n          'image/jpg': 'jpg',\n          'image/gif': 'gif',\n          'image/png': 'png',\n          'image/apng': 'apng',\n          'image/avif': 'avif',\n          'image/svg+xml': 'svg',\n          'image/webp': 'webp',\n          'image/bmp': 'bmp',\n          'image/tiff': 'tiff'\n        };\n        return mimes[mime.toLowerCase()] || 'dat';\n      };\n      var create = function (o, blob, base64, name, filename) {\n        if (isString$1(o)) {\n          var id = o;\n          return toBlobInfo({\n            id: id,\n            name: name,\n            filename: filename,\n            blob: blob,\n            base64: base64\n          });\n        } else if (isObject(o)) {\n          return toBlobInfo(o);\n        } else {\n          throw new Error('Unknown input type');\n        }\n      };\n      var toBlobInfo = function (o) {\n        if (!o.blob || !o.base64) {\n          throw new Error('blob and base64 representations of the image are required for BlobInfo to be created');\n        }\n        var id = o.id || uuid('blobid');\n        var name = o.name || id;\n        var blob = o.blob;\n        return {\n          id: constant(id),\n          name: constant(name),\n          filename: constant(o.filename || name + '.' + mimeToExt(blob.type)),\n          blob: constant(blob),\n          base64: constant(o.base64),\n          blobUri: constant(o.blobUri || URL.createObjectURL(blob)),\n          uri: constant(o.uri)\n        };\n      };\n      var add = function (blobInfo) {\n        if (!get(blobInfo.id())) {\n          cache.push(blobInfo);\n        }\n      };\n      var findFirst = function (predicate) {\n        return find$3(cache, predicate).getOrUndefined();\n      };\n      var get = function (id) {\n        return findFirst(function (cachedBlobInfo) {\n          return cachedBlobInfo.id() === id;\n        });\n      };\n      var getByUri = function (blobUri) {\n        return findFirst(function (blobInfo) {\n          return blobInfo.blobUri() === blobUri;\n        });\n      };\n      var getByData = function (base64, type) {\n        return findFirst(function (blobInfo) {\n          return blobInfo.base64() === base64 && blobInfo.blob().type === type;\n        });\n      };\n      var removeByUri = function (blobUri) {\n        cache = filter$4(cache, function (blobInfo) {\n          if (blobInfo.blobUri() === blobUri) {\n            URL.revokeObjectURL(blobInfo.blobUri());\n            return false;\n          }\n          return true;\n        });\n      };\n      var destroy = function () {\n        each$k(cache, function (cachedBlobInfo) {\n          URL.revokeObjectURL(cachedBlobInfo.blobUri());\n        });\n        cache = [];\n      };\n      return {\n        create: create,\n        add: add,\n        get: get,\n        getByUri: getByUri,\n        getByData: getByData,\n        findFirst: findFirst,\n        removeByUri: removeByUri,\n        destroy: destroy\n      };\n    };\n\n    var Uploader = function (uploadStatus, settings) {\n      var pendingPromises = {};\n      var pathJoin = function (path1, path2) {\n        if (path1) {\n          return path1.replace(/\\/$/, '') + '/' + path2.replace(/^\\//, '');\n        }\n        return path2;\n      };\n      var defaultHandler = function (blobInfo, success, failure, progress) {\n        var xhr = new XMLHttpRequest();\n        xhr.open('POST', settings.url);\n        xhr.withCredentials = settings.credentials;\n        xhr.upload.onprogress = function (e) {\n          progress(e.loaded / e.total * 100);\n        };\n        xhr.onerror = function () {\n          failure('Image upload failed due to a XHR Transport error. Code: ' + xhr.status);\n        };\n        xhr.onload = function () {\n          if (xhr.status < 200 || xhr.status >= 300) {\n            failure('HTTP Error: ' + xhr.status);\n            return;\n          }\n          var json = JSON.parse(xhr.responseText);\n          if (!json || typeof json.location !== 'string') {\n            failure('Invalid JSON: ' + xhr.responseText);\n            return;\n          }\n          success(pathJoin(settings.basePath, json.location));\n        };\n        var formData = new FormData();\n        formData.append('file', blobInfo.blob(), blobInfo.filename());\n        xhr.send(formData);\n      };\n      var noUpload = function () {\n        return new promiseObj(function (resolve) {\n          resolve([]);\n        });\n      };\n      var handlerSuccess = function (blobInfo, url) {\n        return {\n          url: url,\n          blobInfo: blobInfo,\n          status: true\n        };\n      };\n      var handlerFailure = function (blobInfo, message, options) {\n        return {\n          url: '',\n          blobInfo: blobInfo,\n          status: false,\n          error: {\n            message: message,\n            options: options\n          }\n        };\n      };\n      var resolvePending = function (blobUri, result) {\n        Tools.each(pendingPromises[blobUri], function (resolve) {\n          resolve(result);\n        });\n        delete pendingPromises[blobUri];\n      };\n      var uploadBlobInfo = function (blobInfo, handler, openNotification) {\n        uploadStatus.markPending(blobInfo.blobUri());\n        return new promiseObj(function (resolve) {\n          var notification, progress;\n          try {\n            var closeNotification_1 = function () {\n              if (notification) {\n                notification.close();\n                progress = noop;\n              }\n            };\n            var success = function (url) {\n              closeNotification_1();\n              uploadStatus.markUploaded(blobInfo.blobUri(), url);\n              resolvePending(blobInfo.blobUri(), handlerSuccess(blobInfo, url));\n              resolve(handlerSuccess(blobInfo, url));\n            };\n            var failure = function (error, options) {\n              var failureOptions = options ? options : {};\n              closeNotification_1();\n              uploadStatus.removeFailed(blobInfo.blobUri());\n              resolvePending(blobInfo.blobUri(), handlerFailure(blobInfo, error, failureOptions));\n              resolve(handlerFailure(blobInfo, error, failureOptions));\n            };\n            progress = function (percent) {\n              if (percent < 0 || percent > 100) {\n                return;\n              }\n              Optional.from(notification).orThunk(function () {\n                return Optional.from(openNotification).map(apply);\n              }).each(function (n) {\n                notification = n;\n                n.progressBar.value(percent);\n              });\n            };\n            handler(blobInfo, success, failure, progress);\n          } catch (ex) {\n            resolve(handlerFailure(blobInfo, ex.message, {}));\n          }\n        });\n      };\n      var isDefaultHandler = function (handler) {\n        return handler === defaultHandler;\n      };\n      var pendingUploadBlobInfo = function (blobInfo) {\n        var blobUri = blobInfo.blobUri();\n        return new promiseObj(function (resolve) {\n          pendingPromises[blobUri] = pendingPromises[blobUri] || [];\n          pendingPromises[blobUri].push(resolve);\n        });\n      };\n      var uploadBlobs = function (blobInfos, openNotification) {\n        blobInfos = Tools.grep(blobInfos, function (blobInfo) {\n          return !uploadStatus.isUploaded(blobInfo.blobUri());\n        });\n        return promiseObj.all(Tools.map(blobInfos, function (blobInfo) {\n          return uploadStatus.isPending(blobInfo.blobUri()) ? pendingUploadBlobInfo(blobInfo) : uploadBlobInfo(blobInfo, settings.handler, openNotification);\n        }));\n      };\n      var upload = function (blobInfos, openNotification) {\n        return !settings.url && isDefaultHandler(settings.handler) ? noUpload() : uploadBlobs(blobInfos, openNotification);\n      };\n      if (isFunction(settings.handler) === false) {\n        settings.handler = defaultHandler;\n      }\n      return { upload: upload };\n    };\n\n    var openNotification = function (editor) {\n      return function () {\n        return editor.notificationManager.open({\n          text: editor.translate('Image uploading...'),\n          type: 'info',\n          timeout: -1,\n          progressBar: true\n        });\n      };\n    };\n    var createUploader = function (editor, uploadStatus) {\n      return Uploader(uploadStatus, {\n        url: getImageUploadUrl(editor),\n        basePath: getImageUploadBasePath(editor),\n        credentials: getImagesUploadCredentials(editor),\n        handler: getImagesUploadHandler(editor)\n      });\n    };\n    var ImageUploader = function (editor) {\n      var uploadStatus = UploadStatus();\n      var uploader = createUploader(editor, uploadStatus);\n      return {\n        upload: function (blobInfos, showNotification) {\n          if (showNotification === void 0) {\n            showNotification = true;\n          }\n          return uploader.upload(blobInfos, showNotification ? openNotification(editor) : undefined);\n        }\n      };\n    };\n\n    var UploadChangeHandler = function (editor) {\n      var lastChangedLevel = Cell(null);\n      editor.on('change AddUndo', function (e) {\n        lastChangedLevel.set(__assign({}, e.level));\n      });\n      var fireIfChanged = function () {\n        var data = editor.undoManager.data;\n        last$2(data).filter(function (level) {\n          return !isEq$1(lastChangedLevel.get(), level);\n        }).each(function (level) {\n          editor.setDirty(true);\n          editor.fire('change', {\n            level: level,\n            lastLevel: get$a(data, data.length - 2).getOrNull()\n          });\n        });\n      };\n      return { fireIfChanged: fireIfChanged };\n    };\n    var EditorUpload = function (editor) {\n      var blobCache = BlobCache();\n      var uploader, imageScanner;\n      var uploadStatus = UploadStatus();\n      var urlFilters = [];\n      var changeHandler = UploadChangeHandler(editor);\n      var aliveGuard = function (callback) {\n        return function (result) {\n          if (editor.selection) {\n            return callback(result);\n          }\n          return [];\n        };\n      };\n      var cacheInvalidator = function (url) {\n        return url + (url.indexOf('?') === -1 ? '?' : '&') + new Date().getTime();\n      };\n      var replaceString = function (content, search, replace) {\n        var index = 0;\n        do {\n          index = content.indexOf(search, index);\n          if (index !== -1) {\n            content = content.substring(0, index) + replace + content.substr(index + search.length);\n            index += replace.length - search.length + 1;\n          }\n        } while (index !== -1);\n        return content;\n      };\n      var replaceImageUrl = function (content, targetUrl, replacementUrl) {\n        var replacementString = 'src=\"' + replacementUrl + '\"' + (replacementUrl === Env.transparentSrc ? ' data-mce-placeholder=\"1\"' : '');\n        content = replaceString(content, 'src=\"' + targetUrl + '\"', replacementString);\n        content = replaceString(content, 'data-mce-src=\"' + targetUrl + '\"', 'data-mce-src=\"' + replacementUrl + '\"');\n        return content;\n      };\n      var replaceUrlInUndoStack = function (targetUrl, replacementUrl) {\n        each$k(editor.undoManager.data, function (level) {\n          if (level.type === 'fragmented') {\n            level.fragments = map$3(level.fragments, function (fragment) {\n              return replaceImageUrl(fragment, targetUrl, replacementUrl);\n            });\n          } else {\n            level.content = replaceImageUrl(level.content, targetUrl, replacementUrl);\n          }\n        });\n      };\n      var replaceImageUriInView = function (image, resultUri) {\n        var src = editor.convertURL(resultUri, 'src');\n        replaceUrlInUndoStack(image.src, resultUri);\n        editor.$(image).attr({\n          'src': shouldReuseFileName(editor) ? cacheInvalidator(resultUri) : resultUri,\n          'data-mce-src': src\n        });\n      };\n      var uploadImages = function (callback) {\n        if (!uploader) {\n          uploader = createUploader(editor, uploadStatus);\n        }\n        return scanForImages().then(aliveGuard(function (imageInfos) {\n          var blobInfos = map$3(imageInfos, function (imageInfo) {\n            return imageInfo.blobInfo;\n          });\n          return uploader.upload(blobInfos, openNotification(editor)).then(aliveGuard(function (result) {\n            var imagesToRemove = [];\n            var filteredResult = map$3(result, function (uploadInfo, index) {\n              var blobInfo = imageInfos[index].blobInfo;\n              var image = imageInfos[index].image;\n              if (uploadInfo.status && shouldReplaceBlobUris(editor)) {\n                blobCache.removeByUri(image.src);\n                if (isRtc(editor)) ; else {\n                  replaceImageUriInView(image, uploadInfo.url);\n                }\n              } else if (uploadInfo.error) {\n                if (uploadInfo.error.options.remove) {\n                  replaceUrlInUndoStack(image.getAttribute('src'), Env.transparentSrc);\n                  imagesToRemove.push(image);\n                }\n                uploadError(editor, uploadInfo.error.message);\n              }\n              return {\n                element: image,\n                status: uploadInfo.status,\n                uploadUri: uploadInfo.url,\n                blobInfo: blobInfo\n              };\n            });\n            if (filteredResult.length > 0) {\n              changeHandler.fireIfChanged();\n            }\n            if (imagesToRemove.length > 0) {\n              if (isRtc(editor)) {\n                console.error('Removing images on failed uploads is currently unsupported for RTC');\n              } else {\n                editor.undoManager.transact(function () {\n                  each$k(imagesToRemove, function (element) {\n                    editor.dom.remove(element);\n                    blobCache.removeByUri(element.src);\n                  });\n                });\n              }\n            }\n            if (callback) {\n              callback(filteredResult);\n            }\n            return filteredResult;\n          }));\n        }));\n      };\n      var uploadImagesAuto = function (callback) {\n        if (isAutomaticUploadsEnabled(editor)) {\n          return uploadImages(callback);\n        }\n      };\n      var isValidDataUriImage = function (imgElm) {\n        if (forall(urlFilters, function (filter) {\n            return filter(imgElm);\n          }) === false) {\n          return false;\n        }\n        if (imgElm.getAttribute('src').indexOf('data:') === 0) {\n          var dataImgFilter = getImagesDataImgFilter(editor);\n          return dataImgFilter(imgElm);\n        }\n        return true;\n      };\n      var addFilter = function (filter) {\n        urlFilters.push(filter);\n      };\n      var scanForImages = function () {\n        if (!imageScanner) {\n          imageScanner = ImageScanner(uploadStatus, blobCache);\n        }\n        return imageScanner.findAll(editor.getBody(), isValidDataUriImage).then(aliveGuard(function (result) {\n          result = filter$4(result, function (resultItem) {\n            if (typeof resultItem === 'string') {\n              displayError(editor, resultItem);\n              return false;\n            }\n            return true;\n          });\n          if (isRtc(editor)) ; else {\n            each$k(result, function (resultItem) {\n              replaceUrlInUndoStack(resultItem.image.src, resultItem.blobInfo.blobUri());\n              resultItem.image.src = resultItem.blobInfo.blobUri();\n              resultItem.image.removeAttribute('data-mce-src');\n            });\n          }\n          return result;\n        }));\n      };\n      var destroy = function () {\n        blobCache.destroy();\n        uploadStatus.destroy();\n        imageScanner = uploader = null;\n      };\n      var replaceBlobUris = function (content) {\n        return content.replace(/src=\"(blob:[^\"]+)\"/g, function (match, blobUri) {\n          var resultUri = uploadStatus.getResultUri(blobUri);\n          if (resultUri) {\n            return 'src=\"' + resultUri + '\"';\n          }\n          var blobInfo = blobCache.getByUri(blobUri);\n          if (!blobInfo) {\n            blobInfo = foldl(editor.editorManager.get(), function (result, editor) {\n              return result || editor.editorUpload && editor.editorUpload.blobCache.getByUri(blobUri);\n            }, null);\n          }\n          if (blobInfo) {\n            var blob = blobInfo.blob();\n            return 'src=\"data:' + blob.type + ';base64,' + blobInfo.base64() + '\"';\n          }\n          return match;\n        });\n      };\n      editor.on('SetContent', function () {\n        if (isAutomaticUploadsEnabled(editor)) {\n          uploadImagesAuto();\n        } else {\n          scanForImages();\n        }\n      });\n      editor.on('RawSaveContent', function (e) {\n        e.content = replaceBlobUris(e.content);\n      });\n      editor.on('GetContent', function (e) {\n        if (e.source_view || e.format === 'raw' || e.format === 'tree') {\n          return;\n        }\n        e.content = replaceBlobUris(e.content);\n      });\n      editor.on('PostRender', function () {\n        editor.parser.addNodeFilter('img', function (images) {\n          each$k(images, function (img) {\n            var src = img.attr('src');\n            if (blobCache.getByUri(src)) {\n              return;\n            }\n            var resultUri = uploadStatus.getResultUri(src);\n            if (resultUri) {\n              img.attr('src', resultUri);\n            }\n          });\n        });\n      });\n      return {\n        blobCache: blobCache,\n        addFilter: addFilter,\n        uploadImages: uploadImages,\n        uploadImagesAuto: uploadImagesAuto,\n        scanForImages: scanForImages,\n        destroy: destroy\n      };\n    };\n\n    var get = function (dom) {\n      var formats = {\n        valigntop: [{\n            selector: 'td,th',\n            styles: { verticalAlign: 'top' }\n          }],\n        valignmiddle: [{\n            selector: 'td,th',\n            styles: { verticalAlign: 'middle' }\n          }],\n        valignbottom: [{\n            selector: 'td,th',\n            styles: { verticalAlign: 'bottom' }\n          }],\n        alignleft: [\n          {\n            selector: 'figure.image',\n            collapsed: false,\n            classes: 'align-left',\n            ceFalseOverride: true,\n            preview: 'font-family font-size'\n          },\n          {\n            selector: 'figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li',\n            styles: { textAlign: 'left' },\n            inherit: false,\n            preview: false,\n            defaultBlock: 'div'\n          },\n          {\n            selector: 'img,table,audio,video',\n            collapsed: false,\n            styles: { float: 'left' },\n            preview: 'font-family font-size'\n          }\n        ],\n        aligncenter: [\n          {\n            selector: 'figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li',\n            styles: { textAlign: 'center' },\n            inherit: false,\n            preview: 'font-family font-size',\n            defaultBlock: 'div'\n          },\n          {\n            selector: 'figure.image',\n            collapsed: false,\n            classes: 'align-center',\n            ceFalseOverride: true,\n            preview: 'font-family font-size'\n          },\n          {\n            selector: 'img,audio,video',\n            collapsed: false,\n            styles: {\n              display: 'block',\n              marginLeft: 'auto',\n              marginRight: 'auto'\n            },\n            preview: false\n          },\n          {\n            selector: 'table',\n            collapsed: false,\n            styles: {\n              marginLeft: 'auto',\n              marginRight: 'auto'\n            },\n            preview: 'font-family font-size'\n          }\n        ],\n        alignright: [\n          {\n            selector: 'figure.image',\n            collapsed: false,\n            classes: 'align-right',\n            ceFalseOverride: true,\n            preview: 'font-family font-size'\n          },\n          {\n            selector: 'figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li',\n            styles: { textAlign: 'right' },\n            inherit: false,\n            preview: 'font-family font-size',\n            defaultBlock: 'div'\n          },\n          {\n            selector: 'img,table,audio,video',\n            collapsed: false,\n            styles: { float: 'right' },\n            preview: 'font-family font-size'\n          }\n        ],\n        alignjustify: [{\n            selector: 'figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li',\n            styles: { textAlign: 'justify' },\n            inherit: false,\n            defaultBlock: 'div',\n            preview: 'font-family font-size'\n          }],\n        bold: [\n          {\n            inline: 'strong',\n            remove: 'all',\n            preserve_attributes: [\n              'class',\n              'style'\n            ]\n          },\n          {\n            inline: 'span',\n            styles: { fontWeight: 'bold' }\n          },\n          {\n            inline: 'b',\n            remove: 'all',\n            preserve_attributes: [\n              'class',\n              'style'\n            ]\n          }\n        ],\n        italic: [\n          {\n            inline: 'em',\n            remove: 'all',\n            preserve_attributes: [\n              'class',\n              'style'\n            ]\n          },\n          {\n            inline: 'span',\n            styles: { fontStyle: 'italic' }\n          },\n          {\n            inline: 'i',\n            remove: 'all',\n            preserve_attributes: [\n              'class',\n              'style'\n            ]\n          }\n        ],\n        underline: [\n          {\n            inline: 'span',\n            styles: { textDecoration: 'underline' },\n            exact: true\n          },\n          {\n            inline: 'u',\n            remove: 'all',\n            preserve_attributes: [\n              'class',\n              'style'\n            ]\n          }\n        ],\n        strikethrough: [\n          {\n            inline: 'span',\n            styles: { textDecoration: 'line-through' },\n            exact: true\n          },\n          {\n            inline: 'strike',\n            remove: 'all',\n            preserve_attributes: [\n              'class',\n              'style'\n            ]\n          },\n          {\n            inline: 's',\n            remove: 'all',\n            preserve_attributes: [\n              'class',\n              'style'\n            ]\n          }\n        ],\n        forecolor: {\n          inline: 'span',\n          styles: { color: '%value' },\n          links: true,\n          remove_similar: true,\n          clear_child_styles: true\n        },\n        hilitecolor: {\n          inline: 'span',\n          styles: { backgroundColor: '%value' },\n          links: true,\n          remove_similar: true,\n          clear_child_styles: true\n        },\n        fontname: {\n          inline: 'span',\n          toggle: false,\n          styles: { fontFamily: '%value' },\n          clear_child_styles: true\n        },\n        fontsize: {\n          inline: 'span',\n          toggle: false,\n          styles: { fontSize: '%value' },\n          clear_child_styles: true\n        },\n        lineheight: {\n          selector: 'h1,h2,h3,h4,h5,h6,p,li,td,th,div',\n          defaultBlock: 'p',\n          styles: { lineHeight: '%value' }\n        },\n        fontsize_class: {\n          inline: 'span',\n          attributes: { class: '%value' }\n        },\n        blockquote: {\n          block: 'blockquote',\n          wrapper: true,\n          remove: 'all'\n        },\n        subscript: { inline: 'sub' },\n        superscript: { inline: 'sup' },\n        code: { inline: 'code' },\n        link: {\n          inline: 'a',\n          selector: 'a',\n          remove: 'all',\n          split: true,\n          deep: true,\n          onmatch: function (node, _fmt, _itemName) {\n            return isElement$5(node) && node.hasAttribute('href');\n          },\n          onformat: function (elm, _fmt, vars) {\n            Tools.each(vars, function (value, key) {\n              dom.setAttrib(elm, key, value);\n            });\n          }\n        },\n        lang: {\n          inline: 'span',\n          clear_child_styles: true,\n          remove_similar: true,\n          attributes: {\n            'lang': '%value',\n            'data-mce-lang': function (vars) {\n              var _a;\n              return (_a = vars === null || vars === void 0 ? void 0 : vars.customValue) !== null && _a !== void 0 ? _a : null;\n            }\n          }\n        },\n        removeformat: [\n          {\n            selector: 'b,strong,em,i,font,u,strike,s,sub,sup,dfn,code,samp,kbd,var,cite,mark,q,del,ins,small',\n            remove: 'all',\n            split: true,\n            expand: false,\n            block_expand: true,\n            deep: true\n          },\n          {\n            selector: 'span',\n            attributes: [\n              'style',\n              'class'\n            ],\n            remove: 'empty',\n            split: true,\n            expand: false,\n            deep: true\n          },\n          {\n            selector: '*',\n            attributes: [\n              'style',\n              'class'\n            ],\n            split: false,\n            expand: false,\n            deep: true\n          }\n        ]\n      };\n      Tools.each('p h1 h2 h3 h4 h5 h6 div address pre dt dd samp'.split(/\\s/), function (name) {\n        formats[name] = {\n          block: name,\n          remove: 'all'\n        };\n      });\n      return formats;\n    };\n\n    var FormatRegistry = function (editor) {\n      var formats = {};\n      var get$1 = function (name) {\n        return isNonNullable(name) ? formats[name] : formats;\n      };\n      var has = function (name) {\n        return has$2(formats, name);\n      };\n      var register = function (name, format) {\n        if (name) {\n          if (!isString$1(name)) {\n            each$j(name, function (format, name) {\n              register(name, format);\n            });\n          } else {\n            if (!isArray$1(format)) {\n              format = [format];\n            }\n            each$k(format, function (format) {\n              if (isUndefined(format.deep)) {\n                format.deep = !isSelectorFormat(format);\n              }\n              if (isUndefined(format.split)) {\n                format.split = !isSelectorFormat(format) || isInlineFormat(format);\n              }\n              if (isUndefined(format.remove) && isSelectorFormat(format) && !isInlineFormat(format)) {\n                format.remove = 'none';\n              }\n              if (isSelectorFormat(format) && isInlineFormat(format)) {\n                format.mixed = true;\n                format.block_expand = true;\n              }\n              if (isString$1(format.classes)) {\n                format.classes = format.classes.split(/\\s+/);\n              }\n            });\n            formats[name] = format;\n          }\n        }\n      };\n      var unregister = function (name) {\n        if (name && formats[name]) {\n          delete formats[name];\n        }\n        return formats;\n      };\n      register(get(editor.dom));\n      register(getFormats(editor));\n      return {\n        get: get$1,\n        has: has,\n        register: register,\n        unregister: unregister\n      };\n    };\n\n    var each$5 = Tools.each;\n    var dom = DOMUtils.DOM;\n    var parsedSelectorToHtml = function (ancestry, editor) {\n      var elm, item, fragment;\n      var schema = editor && editor.schema || Schema({});\n      var decorate = function (elm, item) {\n        if (item.classes.length) {\n          dom.addClass(elm, item.classes.join(' '));\n        }\n        dom.setAttribs(elm, item.attrs);\n      };\n      var createElement = function (sItem) {\n        item = typeof sItem === 'string' ? {\n          name: sItem,\n          classes: [],\n          attrs: {}\n        } : sItem;\n        var elm = dom.create(item.name);\n        decorate(elm, item);\n        return elm;\n      };\n      var getRequiredParent = function (elm, candidate) {\n        var name = typeof elm !== 'string' ? elm.nodeName.toLowerCase() : elm;\n        var elmRule = schema.getElementRule(name);\n        var parentsRequired = elmRule && elmRule.parentsRequired;\n        if (parentsRequired && parentsRequired.length) {\n          return candidate && Tools.inArray(parentsRequired, candidate) !== -1 ? candidate : parentsRequired[0];\n        } else {\n          return false;\n        }\n      };\n      var wrapInHtml = function (elm, ancestry, siblings) {\n        var parent, parentCandidate;\n        var ancestor = ancestry.length > 0 && ancestry[0];\n        var ancestorName = ancestor && ancestor.name;\n        var parentRequired = getRequiredParent(elm, ancestorName);\n        if (parentRequired) {\n          if (ancestorName === parentRequired) {\n            parentCandidate = ancestry[0];\n            ancestry = ancestry.slice(1);\n          } else {\n            parentCandidate = parentRequired;\n          }\n        } else if (ancestor) {\n          parentCandidate = ancestry[0];\n          ancestry = ancestry.slice(1);\n        } else if (!siblings) {\n          return elm;\n        }\n        if (parentCandidate) {\n          parent = createElement(parentCandidate);\n          parent.appendChild(elm);\n        }\n        if (siblings) {\n          if (!parent) {\n            parent = dom.create('div');\n            parent.appendChild(elm);\n          }\n          Tools.each(siblings, function (sibling) {\n            var siblingElm = createElement(sibling);\n            parent.insertBefore(siblingElm, elm);\n          });\n        }\n        return wrapInHtml(parent, ancestry, parentCandidate && parentCandidate.siblings);\n      };\n      if (ancestry && ancestry.length) {\n        item = ancestry[0];\n        elm = createElement(item);\n        fragment = dom.create('div');\n        fragment.appendChild(wrapInHtml(elm, ancestry.slice(1), item.siblings));\n        return fragment;\n      } else {\n        return '';\n      }\n    };\n    var parseSelectorItem = function (item) {\n      var tagName;\n      var obj = {\n        classes: [],\n        attrs: {}\n      };\n      item = obj.selector = Tools.trim(item);\n      if (item !== '*') {\n        tagName = item.replace(/(?:([#\\.]|::?)([\\w\\-]+)|(\\[)([^\\]]+)\\]?)/g, function ($0, $1, $2, $3, $4) {\n          switch ($1) {\n          case '#':\n            obj.attrs.id = $2;\n            break;\n          case '.':\n            obj.classes.push($2);\n            break;\n          case ':':\n            if (Tools.inArray('checked disabled enabled read-only required'.split(' '), $2) !== -1) {\n              obj.attrs[$2] = $2;\n            }\n            break;\n          }\n          if ($3 === '[') {\n            var m = $4.match(/([\\w\\-]+)(?:\\=\\\"([^\\\"]+))?/);\n            if (m) {\n              obj.attrs[m[1]] = m[2];\n            }\n          }\n          return '';\n        });\n      }\n      obj.name = tagName || 'div';\n      return obj;\n    };\n    var parseSelector = function (selector) {\n      if (!selector || typeof selector !== 'string') {\n        return [];\n      }\n      selector = selector.split(/\\s*,\\s*/)[0];\n      selector = selector.replace(/\\s*(~\\+|~|\\+|>)\\s*/g, '$1');\n      return Tools.map(selector.split(/(?:>|\\s+(?![^\\[\\]]+\\]))/), function (item) {\n        var siblings = Tools.map(item.split(/(?:~\\+|~|\\+)/), parseSelectorItem);\n        var obj = siblings.pop();\n        if (siblings.length) {\n          obj.siblings = siblings;\n        }\n        return obj;\n      }).reverse();\n    };\n    var getCssText = function (editor, format) {\n      var name, previewFrag;\n      var previewCss = '', parentFontSize;\n      var previewStyles = getPreviewStyles(editor);\n      if (previewStyles === '') {\n        return '';\n      }\n      var removeVars = function (val) {\n        return val.replace(/%(\\w+)/g, '');\n      };\n      if (typeof format === 'string') {\n        format = editor.formatter.get(format);\n        if (!format) {\n          return;\n        }\n        format = format[0];\n      }\n      if ('preview' in format) {\n        var previewOpt = get$9(format, 'preview');\n        if (is$1(previewOpt, false)) {\n          return '';\n        } else {\n          previewStyles = previewOpt.getOr(previewStyles);\n        }\n      }\n      name = format.block || format.inline || 'span';\n      var items = parseSelector(format.selector);\n      if (items.length) {\n        if (!items[0].name) {\n          items[0].name = name;\n        }\n        name = format.selector;\n        previewFrag = parsedSelectorToHtml(items, editor);\n      } else {\n        previewFrag = parsedSelectorToHtml([name], editor);\n      }\n      var previewElm = dom.select(name, previewFrag)[0] || previewFrag.firstChild;\n      each$5(format.styles, function (value, name) {\n        var newValue = removeVars(value);\n        if (newValue) {\n          dom.setStyle(previewElm, name, newValue);\n        }\n      });\n      each$5(format.attributes, function (value, name) {\n        var newValue = removeVars(value);\n        if (newValue) {\n          dom.setAttrib(previewElm, name, newValue);\n        }\n      });\n      each$5(format.classes, function (value) {\n        var newValue = removeVars(value);\n        if (!dom.hasClass(previewElm, newValue)) {\n          dom.addClass(previewElm, newValue);\n        }\n      });\n      editor.fire('PreviewFormats');\n      dom.setStyles(previewFrag, {\n        position: 'absolute',\n        left: -65535\n      });\n      editor.getBody().appendChild(previewFrag);\n      parentFontSize = dom.getStyle(editor.getBody(), 'fontSize', true);\n      parentFontSize = /px$/.test(parentFontSize) ? parseInt(parentFontSize, 10) : 0;\n      each$5(previewStyles.split(' '), function (name) {\n        var value = dom.getStyle(previewElm, name, true);\n        if (name === 'background-color' && /transparent|rgba\\s*\\([^)]+,\\s*0\\)/.test(value)) {\n          value = dom.getStyle(editor.getBody(), name, true);\n          if (dom.toHex(value).toLowerCase() === '#ffffff') {\n            return;\n          }\n        }\n        if (name === 'color') {\n          if (dom.toHex(value).toLowerCase() === '#000000') {\n            return;\n          }\n        }\n        if (name === 'font-size') {\n          if (/em|%$/.test(value)) {\n            if (parentFontSize === 0) {\n              return;\n            }\n            var numValue = parseFloat(value) / (/%$/.test(value) ? 100 : 1);\n            value = numValue * parentFontSize + 'px';\n          }\n        }\n        if (name === 'border' && value) {\n          previewCss += 'padding:0 2px;';\n        }\n        previewCss += name + ':' + value + ';';\n      });\n      editor.fire('AfterPreviewFormats');\n      dom.remove(previewFrag);\n      return previewCss;\n    };\n\n    var setup$h = function (editor) {\n      editor.addShortcut('meta+b', '', 'Bold');\n      editor.addShortcut('meta+i', '', 'Italic');\n      editor.addShortcut('meta+u', '', 'Underline');\n      for (var i = 1; i <= 6; i++) {\n        editor.addShortcut('access+' + i, '', [\n          'FormatBlock',\n          false,\n          'h' + i\n        ]);\n      }\n      editor.addShortcut('access+7', '', [\n        'FormatBlock',\n        false,\n        'p'\n      ]);\n      editor.addShortcut('access+8', '', [\n        'FormatBlock',\n        false,\n        'div'\n      ]);\n      editor.addShortcut('access+9', '', [\n        'FormatBlock',\n        false,\n        'address'\n      ]);\n    };\n\n    var Formatter = function (editor) {\n      var formats = FormatRegistry(editor);\n      var formatChangeState = Cell(null);\n      setup$h(editor);\n      setup$k(editor);\n      return {\n        get: formats.get,\n        has: formats.has,\n        register: formats.register,\n        unregister: formats.unregister,\n        apply: function (name, vars, node) {\n          applyFormat(editor, name, vars, node);\n        },\n        remove: function (name, vars, node, similar) {\n          removeFormat(editor, name, vars, node, similar);\n        },\n        toggle: function (name, vars, node) {\n          toggleFormat(editor, name, vars, node);\n        },\n        match: function (name, vars, node, similar) {\n          return matchFormat(editor, name, vars, node, similar);\n        },\n        closest: function (names) {\n          return closestFormat(editor, names);\n        },\n        matchAll: function (names, vars) {\n          return matchAllFormats(editor, names, vars);\n        },\n        matchNode: function (node, name, vars, similar) {\n          return matchNodeFormat(editor, node, name, vars, similar);\n        },\n        canApply: function (name) {\n          return canApplyFormat(editor, name);\n        },\n        formatChanged: function (formats, callback, similar, vars) {\n          return formatChanged(editor, formatChangeState, formats, callback, similar, vars);\n        },\n        getCssText: curry(getCssText, editor)\n      };\n    };\n\n    var shouldIgnoreCommand = function (cmd) {\n      switch (cmd.toLowerCase()) {\n      case 'undo':\n      case 'redo':\n      case 'mcerepaint':\n      case 'mcefocus':\n        return true;\n      default:\n        return false;\n      }\n    };\n    var registerEvents = function (editor, undoManager, locks) {\n      var isFirstTypedCharacter = Cell(false);\n      var addNonTypingUndoLevel = function (e) {\n        setTyping(undoManager, false, locks);\n        undoManager.add({}, e);\n      };\n      editor.on('init', function () {\n        undoManager.add();\n      });\n      editor.on('BeforeExecCommand', function (e) {\n        var cmd = e.command;\n        if (!shouldIgnoreCommand(cmd)) {\n          endTyping(undoManager, locks);\n          undoManager.beforeChange();\n        }\n      });\n      editor.on('ExecCommand', function (e) {\n        var cmd = e.command;\n        if (!shouldIgnoreCommand(cmd)) {\n          addNonTypingUndoLevel(e);\n        }\n      });\n      editor.on('ObjectResizeStart cut', function () {\n        undoManager.beforeChange();\n      });\n      editor.on('SaveContent ObjectResized blur', addNonTypingUndoLevel);\n      editor.on('dragend', addNonTypingUndoLevel);\n      editor.on('keyup', function (e) {\n        var keyCode = e.keyCode;\n        if (e.isDefaultPrevented()) {\n          return;\n        }\n        if (keyCode >= 33 && keyCode <= 36 || keyCode >= 37 && keyCode <= 40 || keyCode === 45 || e.ctrlKey) {\n          addNonTypingUndoLevel();\n          editor.nodeChanged();\n        }\n        if (keyCode === 46 || keyCode === 8) {\n          editor.nodeChanged();\n        }\n        if (isFirstTypedCharacter.get() && undoManager.typing && isEq$1(createFromEditor(editor), undoManager.data[0]) === false) {\n          if (editor.isDirty() === false) {\n            editor.setDirty(true);\n            editor.fire('change', {\n              level: undoManager.data[0],\n              lastLevel: null\n            });\n          }\n          editor.fire('TypingUndo');\n          isFirstTypedCharacter.set(false);\n          editor.nodeChanged();\n        }\n      });\n      editor.on('keydown', function (e) {\n        var keyCode = e.keyCode;\n        if (e.isDefaultPrevented()) {\n          return;\n        }\n        if (keyCode >= 33 && keyCode <= 36 || keyCode >= 37 && keyCode <= 40 || keyCode === 45) {\n          if (undoManager.typing) {\n            addNonTypingUndoLevel(e);\n          }\n          return;\n        }\n        var modKey = e.ctrlKey && !e.altKey || e.metaKey;\n        if ((keyCode < 16 || keyCode > 20) && keyCode !== 224 && keyCode !== 91 && !undoManager.typing && !modKey) {\n          undoManager.beforeChange();\n          setTyping(undoManager, true, locks);\n          undoManager.add({}, e);\n          isFirstTypedCharacter.set(true);\n        }\n      });\n      editor.on('mousedown', function (e) {\n        if (undoManager.typing) {\n          addNonTypingUndoLevel(e);\n        }\n      });\n      var isInsertReplacementText = function (event) {\n        return event.inputType === 'insertReplacementText';\n      };\n      var isInsertTextDataNull = function (event) {\n        return event.inputType === 'insertText' && event.data === null;\n      };\n      var isInsertFromPasteOrDrop = function (event) {\n        return event.inputType === 'insertFromPaste' || event.inputType === 'insertFromDrop';\n      };\n      editor.on('input', function (e) {\n        if (e.inputType && (isInsertReplacementText(e) || isInsertTextDataNull(e) || isInsertFromPasteOrDrop(e))) {\n          addNonTypingUndoLevel(e);\n        }\n      });\n      editor.on('AddUndo Undo Redo ClearUndos', function (e) {\n        if (!e.isDefaultPrevented()) {\n          editor.nodeChanged();\n        }\n      });\n    };\n    var addKeyboardShortcuts = function (editor) {\n      editor.addShortcut('meta+z', '', 'Undo');\n      editor.addShortcut('meta+y,meta+shift+z', '', 'Redo');\n    };\n\n    var UndoManager = function (editor) {\n      var beforeBookmark = value();\n      var locks = Cell(0);\n      var index = Cell(0);\n      var undoManager = {\n        data: [],\n        typing: false,\n        beforeChange: function () {\n          beforeChange(editor, locks, beforeBookmark);\n        },\n        add: function (level, event) {\n          return addUndoLevel(editor, undoManager, index, locks, beforeBookmark, level, event);\n        },\n        undo: function () {\n          return undo(editor, undoManager, locks, index);\n        },\n        redo: function () {\n          return redo(editor, index, undoManager.data);\n        },\n        clear: function () {\n          clear(editor, undoManager, index);\n        },\n        reset: function () {\n          reset(editor, undoManager);\n        },\n        hasUndo: function () {\n          return hasUndo(editor, undoManager, index);\n        },\n        hasRedo: function () {\n          return hasRedo(editor, undoManager, index);\n        },\n        transact: function (callback) {\n          return transact(editor, undoManager, locks, callback);\n        },\n        ignore: function (callback) {\n          ignore(editor, locks, callback);\n        },\n        extra: function (callback1, callback2) {\n          extra(editor, undoManager, index, callback1, callback2);\n        }\n      };\n      if (!isRtc(editor)) {\n        registerEvents(editor, undoManager, locks);\n      }\n      addKeyboardShortcuts(editor);\n      return undoManager;\n    };\n\n    var nonTypingKeycodes = [\n      9,\n      27,\n      VK.HOME,\n      VK.END,\n      19,\n      20,\n      44,\n      144,\n      145,\n      33,\n      34,\n      45,\n      16,\n      17,\n      18,\n      91,\n      92,\n      93,\n      VK.DOWN,\n      VK.UP,\n      VK.LEFT,\n      VK.RIGHT\n    ].concat(Env.browser.isFirefox() ? [224] : []);\n    var placeholderAttr = 'data-mce-placeholder';\n    var isKeyboardEvent = function (e) {\n      return e.type === 'keydown' || e.type === 'keyup';\n    };\n    var isDeleteEvent = function (e) {\n      var keyCode = e.keyCode;\n      return keyCode === VK.BACKSPACE || keyCode === VK.DELETE;\n    };\n    var isNonTypingKeyboardEvent = function (e) {\n      if (isKeyboardEvent(e)) {\n        var keyCode = e.keyCode;\n        return !isDeleteEvent(e) && (VK.metaKeyPressed(e) || e.altKey || keyCode >= 112 && keyCode <= 123 || contains$3(nonTypingKeycodes, keyCode));\n      } else {\n        return false;\n      }\n    };\n    var isTypingKeyboardEvent = function (e) {\n      return isKeyboardEvent(e) && !(isDeleteEvent(e) || e.type === 'keyup' && e.keyCode === 229);\n    };\n    var isVisuallyEmpty = function (dom, rootElm, forcedRootBlock) {\n      if (isEmpty$2(SugarElement.fromDom(rootElm), false)) {\n        var isForcedRootBlockFalse = forcedRootBlock === '';\n        var firstElement = rootElm.firstElementChild;\n        if (!firstElement) {\n          return true;\n        } else if (dom.getStyle(rootElm.firstElementChild, 'padding-left') || dom.getStyle(rootElm.firstElementChild, 'padding-right')) {\n          return false;\n        } else {\n          return isForcedRootBlockFalse ? !dom.isBlock(firstElement) : forcedRootBlock === firstElement.nodeName.toLowerCase();\n        }\n      } else {\n        return false;\n      }\n    };\n    var setup$g = function (editor) {\n      var dom = editor.dom;\n      var rootBlock = getForcedRootBlock(editor);\n      var placeholder = getPlaceholder(editor);\n      var updatePlaceholder = function (e, initial) {\n        if (isNonTypingKeyboardEvent(e)) {\n          return;\n        }\n        var body = editor.getBody();\n        var showPlaceholder = isTypingKeyboardEvent(e) ? false : isVisuallyEmpty(dom, body, rootBlock);\n        var isPlaceholderShown = dom.getAttrib(body, placeholderAttr) !== '';\n        if (isPlaceholderShown !== showPlaceholder || initial) {\n          dom.setAttrib(body, placeholderAttr, showPlaceholder ? placeholder : null);\n          dom.setAttrib(body, 'aria-placeholder', showPlaceholder ? placeholder : null);\n          firePlaceholderToggle(editor, showPlaceholder);\n          editor.on(showPlaceholder ? 'keydown' : 'keyup', updatePlaceholder);\n          editor.off(showPlaceholder ? 'keyup' : 'keydown', updatePlaceholder);\n        }\n      };\n      if (placeholder) {\n        editor.on('init', function (e) {\n          updatePlaceholder(e, true);\n          editor.on('change SetContent ExecCommand', updatePlaceholder);\n          editor.on('paste', function (e) {\n            return Delay.setEditorTimeout(editor, function () {\n              return updatePlaceholder(e);\n            });\n          });\n        });\n      }\n    };\n\n    var strongRtl = /[\\u0591-\\u07FF\\uFB1D-\\uFDFF\\uFE70-\\uFEFC]/;\n    var hasStrongRtl = function (text) {\n      return strongRtl.test(text);\n    };\n\n    var isInlineTarget = function (editor, elm) {\n      return is$2(SugarElement.fromDom(elm), getInlineBoundarySelector(editor));\n    };\n    var isRtl = function (element) {\n      return DOMUtils.DOM.getStyle(element, 'direction', true) === 'rtl' || hasStrongRtl(element.textContent);\n    };\n    var findInlineParents = function (isInlineTarget, rootNode, pos) {\n      return filter$4(DOMUtils.DOM.getParents(pos.container(), '*', rootNode), isInlineTarget);\n    };\n    var findRootInline = function (isInlineTarget, rootNode, pos) {\n      var parents = findInlineParents(isInlineTarget, rootNode, pos);\n      return Optional.from(parents[parents.length - 1]);\n    };\n    var hasSameParentBlock = function (rootNode, node1, node2) {\n      var block1 = getParentBlock$2(node1, rootNode);\n      var block2 = getParentBlock$2(node2, rootNode);\n      return block1 && block1 === block2;\n    };\n    var isAtZwsp = function (pos) {\n      return isBeforeInline(pos) || isAfterInline(pos);\n    };\n    var normalizePosition = function (forward, pos) {\n      if (!pos) {\n        return pos;\n      }\n      var container = pos.container(), offset = pos.offset();\n      if (forward) {\n        if (isCaretContainerInline(container)) {\n          if (isText$7(container.nextSibling)) {\n            return CaretPosition(container.nextSibling, 0);\n          } else {\n            return CaretPosition.after(container);\n          }\n        } else {\n          return isBeforeInline(pos) ? CaretPosition(container, offset + 1) : pos;\n        }\n      } else {\n        if (isCaretContainerInline(container)) {\n          if (isText$7(container.previousSibling)) {\n            return CaretPosition(container.previousSibling, container.previousSibling.data.length);\n          } else {\n            return CaretPosition.before(container);\n          }\n        } else {\n          return isAfterInline(pos) ? CaretPosition(container, offset - 1) : pos;\n        }\n      }\n    };\n    var normalizeForwards = curry(normalizePosition, true);\n    var normalizeBackwards = curry(normalizePosition, false);\n\n    var isBeforeRoot = function (rootNode) {\n      return function (elm) {\n        return eq(rootNode, SugarElement.fromDom(elm.dom.parentNode));\n      };\n    };\n    var isTextBlockOrListItem = function (element) {\n      return isTextBlock$2(element) || isListItem(element);\n    };\n    var getParentBlock$1 = function (rootNode, elm) {\n      if (contains$1(rootNode, elm)) {\n        return closest$3(elm, isTextBlockOrListItem, isBeforeRoot(rootNode));\n      } else {\n        return Optional.none();\n      }\n    };\n    var placeCaretInEmptyBody = function (editor) {\n      var body = editor.getBody();\n      var node = body.firstChild && editor.dom.isBlock(body.firstChild) ? body.firstChild : body;\n      editor.selection.setCursorLocation(node, 0);\n    };\n    var paddEmptyBody = function (editor) {\n      if (editor.dom.isEmpty(editor.getBody())) {\n        editor.setContent('');\n        placeCaretInEmptyBody(editor);\n      }\n    };\n    var willDeleteLastPositionInElement = function (forward, fromPos, elm) {\n      return lift2(firstPositionIn(elm), lastPositionIn(elm), function (firstPos, lastPos) {\n        var normalizedFirstPos = normalizePosition(true, firstPos);\n        var normalizedLastPos = normalizePosition(false, lastPos);\n        var normalizedFromPos = normalizePosition(false, fromPos);\n        if (forward) {\n          return nextPosition(elm, normalizedFromPos).exists(function (nextPos) {\n            return nextPos.isEqual(normalizedLastPos) && fromPos.isEqual(normalizedFirstPos);\n          });\n        } else {\n          return prevPosition(elm, normalizedFromPos).exists(function (prevPos) {\n            return prevPos.isEqual(normalizedFirstPos) && fromPos.isEqual(normalizedLastPos);\n          });\n        }\n      }).getOr(true);\n    };\n\n    var blockPosition = function (block, position) {\n      return {\n        block: block,\n        position: position\n      };\n    };\n    var blockBoundary = function (from, to) {\n      return {\n        from: from,\n        to: to\n      };\n    };\n    var getBlockPosition = function (rootNode, pos) {\n      var rootElm = SugarElement.fromDom(rootNode);\n      var containerElm = SugarElement.fromDom(pos.container());\n      return getParentBlock$1(rootElm, containerElm).map(function (block) {\n        return blockPosition(block, pos);\n      });\n    };\n    var isDifferentBlocks = function (blockBoundary) {\n      return eq(blockBoundary.from.block, blockBoundary.to.block) === false;\n    };\n    var hasSameParent = function (blockBoundary) {\n      return parent(blockBoundary.from.block).bind(function (parent1) {\n        return parent(blockBoundary.to.block).filter(function (parent2) {\n          return eq(parent1, parent2);\n        });\n      }).isSome();\n    };\n    var isEditable$1 = function (blockBoundary) {\n      return isContentEditableFalse$b(blockBoundary.from.block.dom) === false && isContentEditableFalse$b(blockBoundary.to.block.dom) === false;\n    };\n    var skipLastBr = function (rootNode, forward, blockPosition) {\n      if (isBr$5(blockPosition.position.getNode()) && isEmpty$2(blockPosition.block) === false) {\n        return positionIn(false, blockPosition.block.dom).bind(function (lastPositionInBlock) {\n          if (lastPositionInBlock.isEqual(blockPosition.position)) {\n            return fromPosition(forward, rootNode, lastPositionInBlock).bind(function (to) {\n              return getBlockPosition(rootNode, to);\n            });\n          } else {\n            return Optional.some(blockPosition);\n          }\n        }).getOr(blockPosition);\n      } else {\n        return blockPosition;\n      }\n    };\n    var readFromRange = function (rootNode, forward, rng) {\n      var fromBlockPos = getBlockPosition(rootNode, CaretPosition.fromRangeStart(rng));\n      var toBlockPos = fromBlockPos.bind(function (blockPos) {\n        return fromPosition(forward, rootNode, blockPos.position).bind(function (to) {\n          return getBlockPosition(rootNode, to).map(function (blockPos) {\n            return skipLastBr(rootNode, forward, blockPos);\n          });\n        });\n      });\n      return lift2(fromBlockPos, toBlockPos, blockBoundary).filter(function (blockBoundary) {\n        return isDifferentBlocks(blockBoundary) && hasSameParent(blockBoundary) && isEditable$1(blockBoundary);\n      });\n    };\n    var read$1 = function (rootNode, forward, rng) {\n      return rng.collapsed ? readFromRange(rootNode, forward, rng) : Optional.none();\n    };\n\n    var getChildrenUntilBlockBoundary = function (block) {\n      var children$1 = children(block);\n      return findIndex$2(children$1, isBlock$2).fold(constant(children$1), function (index) {\n        return children$1.slice(0, index);\n      });\n    };\n    var extractChildren = function (block) {\n      var children = getChildrenUntilBlockBoundary(block);\n      each$k(children, remove$7);\n      return children;\n    };\n    var removeEmptyRoot = function (rootNode, block) {\n      var parents = parentsAndSelf(block, rootNode);\n      return find$3(parents.reverse(), function (element) {\n        return isEmpty$2(element);\n      }).each(remove$7);\n    };\n    var isEmptyBefore = function (el) {\n      return filter$4(prevSiblings(el), function (el) {\n        return !isEmpty$2(el);\n      }).length === 0;\n    };\n    var nestedBlockMerge = function (rootNode, fromBlock, toBlock, insertionPoint) {\n      if (isEmpty$2(toBlock)) {\n        fillWithPaddingBr(toBlock);\n        return firstPositionIn(toBlock.dom);\n      }\n      if (isEmptyBefore(insertionPoint) && isEmpty$2(fromBlock)) {\n        before$4(insertionPoint, SugarElement.fromTag('br'));\n      }\n      var position = prevPosition(toBlock.dom, CaretPosition.before(insertionPoint.dom));\n      each$k(extractChildren(fromBlock), function (child) {\n        before$4(insertionPoint, child);\n      });\n      removeEmptyRoot(rootNode, fromBlock);\n      return position;\n    };\n    var sidelongBlockMerge = function (rootNode, fromBlock, toBlock) {\n      if (isEmpty$2(toBlock)) {\n        remove$7(toBlock);\n        if (isEmpty$2(fromBlock)) {\n          fillWithPaddingBr(fromBlock);\n        }\n        return firstPositionIn(fromBlock.dom);\n      }\n      var position = lastPositionIn(toBlock.dom);\n      each$k(extractChildren(fromBlock), function (child) {\n        append$1(toBlock, child);\n      });\n      removeEmptyRoot(rootNode, fromBlock);\n      return position;\n    };\n    var findInsertionPoint = function (toBlock, block) {\n      var parentsAndSelf$1 = parentsAndSelf(block, toBlock);\n      return Optional.from(parentsAndSelf$1[parentsAndSelf$1.length - 1]);\n    };\n    var getInsertionPoint = function (fromBlock, toBlock) {\n      return contains$1(toBlock, fromBlock) ? findInsertionPoint(toBlock, fromBlock) : Optional.none();\n    };\n    var trimBr = function (first, block) {\n      positionIn(first, block.dom).map(function (position) {\n        return position.getNode();\n      }).map(SugarElement.fromDom).filter(isBr$4).each(remove$7);\n    };\n    var mergeBlockInto = function (rootNode, fromBlock, toBlock) {\n      trimBr(true, fromBlock);\n      trimBr(false, toBlock);\n      return getInsertionPoint(fromBlock, toBlock).fold(curry(sidelongBlockMerge, rootNode, fromBlock, toBlock), curry(nestedBlockMerge, rootNode, fromBlock, toBlock));\n    };\n    var mergeBlocks = function (rootNode, forward, block1, block2) {\n      return forward ? mergeBlockInto(rootNode, block2, block1) : mergeBlockInto(rootNode, block1, block2);\n    };\n\n    var backspaceDelete$8 = function (editor, forward) {\n      var rootNode = SugarElement.fromDom(editor.getBody());\n      var position = read$1(rootNode.dom, forward, editor.selection.getRng()).bind(function (blockBoundary) {\n        return mergeBlocks(rootNode, forward, blockBoundary.from.block, blockBoundary.to.block);\n      });\n      position.each(function (pos) {\n        editor.selection.setRng(pos.toRange());\n      });\n      return position.isSome();\n    };\n\n    var deleteRangeMergeBlocks = function (rootNode, selection) {\n      var rng = selection.getRng();\n      return lift2(getParentBlock$1(rootNode, SugarElement.fromDom(rng.startContainer)), getParentBlock$1(rootNode, SugarElement.fromDom(rng.endContainer)), function (block1, block2) {\n        if (eq(block1, block2) === false) {\n          rng.deleteContents();\n          mergeBlocks(rootNode, true, block1, block2).each(function (pos) {\n            selection.setRng(pos.toRange());\n          });\n          return true;\n        } else {\n          return false;\n        }\n      }).getOr(false);\n    };\n    var isRawNodeInTable = function (root, rawNode) {\n      var node = SugarElement.fromDom(rawNode);\n      var isRoot = curry(eq, root);\n      return ancestor$3(node, isTableCell$4, isRoot).isSome();\n    };\n    var isSelectionInTable = function (root, rng) {\n      return isRawNodeInTable(root, rng.startContainer) || isRawNodeInTable(root, rng.endContainer);\n    };\n    var isEverythingSelected = function (root, rng) {\n      var noPrevious = prevPosition(root.dom, CaretPosition.fromRangeStart(rng)).isNone();\n      var noNext = nextPosition(root.dom, CaretPosition.fromRangeEnd(rng)).isNone();\n      return !isSelectionInTable(root, rng) && noPrevious && noNext;\n    };\n    var emptyEditor = function (editor) {\n      editor.setContent('');\n      editor.selection.setCursorLocation();\n      return true;\n    };\n    var deleteRange$1 = function (editor) {\n      var rootNode = SugarElement.fromDom(editor.getBody());\n      var rng = editor.selection.getRng();\n      return isEverythingSelected(rootNode, rng) ? emptyEditor(editor) : deleteRangeMergeBlocks(rootNode, editor.selection);\n    };\n    var backspaceDelete$7 = function (editor, _forward) {\n      return editor.selection.isCollapsed() ? false : deleteRange$1(editor);\n    };\n\n    var isContentEditableTrue$2 = isContentEditableTrue$4;\n    var isContentEditableFalse$4 = isContentEditableFalse$b;\n    var showCaret = function (direction, editor, node, before, scrollIntoView) {\n      return Optional.from(editor._selectionOverrides.showCaret(direction, node, before, scrollIntoView));\n    };\n    var getNodeRange = function (node) {\n      var rng = node.ownerDocument.createRange();\n      rng.selectNode(node);\n      return rng;\n    };\n    var selectNode = function (editor, node) {\n      var e = editor.fire('BeforeObjectSelected', { target: node });\n      if (e.isDefaultPrevented()) {\n        return Optional.none();\n      }\n      return Optional.some(getNodeRange(node));\n    };\n    var renderCaretAtRange = function (editor, range, scrollIntoView) {\n      var normalizedRange = normalizeRange(1, editor.getBody(), range);\n      var caretPosition = CaretPosition.fromRangeStart(normalizedRange);\n      var caretPositionNode = caretPosition.getNode();\n      if (isInlineFakeCaretTarget(caretPositionNode)) {\n        return showCaret(1, editor, caretPositionNode, !caretPosition.isAtEnd(), false);\n      }\n      var caretPositionBeforeNode = caretPosition.getNode(true);\n      if (isInlineFakeCaretTarget(caretPositionBeforeNode)) {\n        return showCaret(1, editor, caretPositionBeforeNode, false, false);\n      }\n      var ceRoot = editor.dom.getParent(caretPosition.getNode(), function (node) {\n        return isContentEditableFalse$4(node) || isContentEditableTrue$2(node);\n      });\n      if (isInlineFakeCaretTarget(ceRoot)) {\n        return showCaret(1, editor, ceRoot, false, scrollIntoView);\n      }\n      return Optional.none();\n    };\n    var renderRangeCaret = function (editor, range, scrollIntoView) {\n      return range.collapsed ? renderCaretAtRange(editor, range, scrollIntoView).getOr(range) : range;\n    };\n\n    var isBeforeBoundary = function (pos) {\n      return isBeforeContentEditableFalse(pos) || isBeforeMedia(pos);\n    };\n    var isAfterBoundary = function (pos) {\n      return isAfterContentEditableFalse(pos) || isAfterMedia(pos);\n    };\n    var trimEmptyTextNode = function (dom, node) {\n      if (isText$7(node) && node.data.length === 0) {\n        dom.remove(node);\n      }\n    };\n    var deleteContentAndShowCaret = function (editor, range, node, direction, forward, peekCaretPosition) {\n      showCaret(direction, editor, peekCaretPosition.getNode(!forward), forward, true).each(function (caretRange) {\n        if (range.collapsed) {\n          var deleteRange = range.cloneRange();\n          if (forward) {\n            deleteRange.setEnd(caretRange.startContainer, caretRange.startOffset);\n          } else {\n            deleteRange.setStart(caretRange.endContainer, caretRange.endOffset);\n          }\n          deleteRange.deleteContents();\n        } else {\n          range.deleteContents();\n        }\n        editor.selection.setRng(caretRange);\n      });\n      trimEmptyTextNode(editor.dom, node);\n      return true;\n    };\n    var deleteBoundaryText = function (editor, forward) {\n      var range = editor.selection.getRng();\n      if (!isText$7(range.commonAncestorContainer)) {\n        return false;\n      }\n      var direction = forward ? HDirection.Forwards : HDirection.Backwards;\n      var caretWalker = CaretWalker(editor.getBody());\n      var getNextPosFn = curry(getVisualCaretPosition, forward ? caretWalker.next : caretWalker.prev);\n      var isBeforeFn = forward ? isBeforeBoundary : isAfterBoundary;\n      var caretPosition = getNormalizedRangeEndPoint(direction, editor.getBody(), range);\n      var nextCaretPosition = normalizePosition(forward, getNextPosFn(caretPosition));\n      if (!nextCaretPosition || !isMoveInsideSameBlock(caretPosition, nextCaretPosition)) {\n        return false;\n      } else if (isBeforeFn(nextCaretPosition)) {\n        return deleteContentAndShowCaret(editor, range, caretPosition.getNode(), direction, forward, nextCaretPosition);\n      }\n      var peekCaretPosition = getNextPosFn(nextCaretPosition);\n      if (peekCaretPosition && isBeforeFn(peekCaretPosition)) {\n        if (isMoveInsideSameBlock(nextCaretPosition, peekCaretPosition)) {\n          return deleteContentAndShowCaret(editor, range, caretPosition.getNode(), direction, forward, peekCaretPosition);\n        }\n      }\n      return false;\n    };\n    var backspaceDelete$6 = function (editor, forward) {\n      return deleteBoundaryText(editor, forward);\n    };\n\n    var isCompoundElement = function (node) {\n      return isTableCell$4(SugarElement.fromDom(node)) || isListItem(SugarElement.fromDom(node));\n    };\n    var DeleteAction = Adt.generate([\n      { remove: ['element'] },\n      { moveToElement: ['element'] },\n      { moveToPosition: ['position'] }\n    ]);\n    var isAtContentEditableBlockCaret = function (forward, from) {\n      var elm = from.getNode(forward === false);\n      var caretLocation = forward ? 'after' : 'before';\n      return isElement$5(elm) && elm.getAttribute('data-mce-caret') === caretLocation;\n    };\n    var isDeleteFromCefDifferentBlocks = function (root, forward, from, to) {\n      var inSameBlock = function (elm) {\n        return isInline$1(SugarElement.fromDom(elm)) && !isInSameBlock(from, to, root);\n      };\n      return getRelativeCefElm(!forward, from).fold(function () {\n        return getRelativeCefElm(forward, to).fold(never, inSameBlock);\n      }, inSameBlock);\n    };\n    var deleteEmptyBlockOrMoveToCef = function (root, forward, from, to) {\n      var toCefElm = to.getNode(forward === false);\n      return getParentBlock$1(SugarElement.fromDom(root), SugarElement.fromDom(from.getNode())).map(function (blockElm) {\n        return isEmpty$2(blockElm) ? DeleteAction.remove(blockElm.dom) : DeleteAction.moveToElement(toCefElm);\n      }).orThunk(function () {\n        return Optional.some(DeleteAction.moveToElement(toCefElm));\n      });\n    };\n    var findCefPosition = function (root, forward, from) {\n      return fromPosition(forward, root, from).bind(function (to) {\n        if (isCompoundElement(to.getNode())) {\n          return Optional.none();\n        } else if (isDeleteFromCefDifferentBlocks(root, forward, from, to)) {\n          return Optional.none();\n        } else if (forward && isContentEditableFalse$b(to.getNode())) {\n          return deleteEmptyBlockOrMoveToCef(root, forward, from, to);\n        } else if (forward === false && isContentEditableFalse$b(to.getNode(true))) {\n          return deleteEmptyBlockOrMoveToCef(root, forward, from, to);\n        } else if (forward && isAfterContentEditableFalse(from)) {\n          return Optional.some(DeleteAction.moveToPosition(to));\n        } else if (forward === false && isBeforeContentEditableFalse(from)) {\n          return Optional.some(DeleteAction.moveToPosition(to));\n        } else {\n          return Optional.none();\n        }\n      });\n    };\n    var getContentEditableBlockAction = function (forward, elm) {\n      if (forward && isContentEditableFalse$b(elm.nextSibling)) {\n        return Optional.some(DeleteAction.moveToElement(elm.nextSibling));\n      } else if (forward === false && isContentEditableFalse$b(elm.previousSibling)) {\n        return Optional.some(DeleteAction.moveToElement(elm.previousSibling));\n      } else {\n        return Optional.none();\n      }\n    };\n    var skipMoveToActionFromInlineCefToContent = function (root, from, deleteAction) {\n      return deleteAction.fold(function (elm) {\n        return Optional.some(DeleteAction.remove(elm));\n      }, function (elm) {\n        return Optional.some(DeleteAction.moveToElement(elm));\n      }, function (to) {\n        if (isInSameBlock(from, to, root)) {\n          return Optional.none();\n        } else {\n          return Optional.some(DeleteAction.moveToPosition(to));\n        }\n      });\n    };\n    var getContentEditableAction = function (root, forward, from) {\n      if (isAtContentEditableBlockCaret(forward, from)) {\n        return getContentEditableBlockAction(forward, from.getNode(forward === false)).fold(function () {\n          return findCefPosition(root, forward, from);\n        }, Optional.some);\n      } else {\n        return findCefPosition(root, forward, from).bind(function (deleteAction) {\n          return skipMoveToActionFromInlineCefToContent(root, from, deleteAction);\n        });\n      }\n    };\n    var read = function (root, forward, rng) {\n      var normalizedRange = normalizeRange(forward ? 1 : -1, root, rng);\n      var from = CaretPosition.fromRangeStart(normalizedRange);\n      var rootElement = SugarElement.fromDom(root);\n      if (forward === false && isAfterContentEditableFalse(from)) {\n        return Optional.some(DeleteAction.remove(from.getNode(true)));\n      } else if (forward && isBeforeContentEditableFalse(from)) {\n        return Optional.some(DeleteAction.remove(from.getNode()));\n      } else if (forward === false && isBeforeContentEditableFalse(from) && isAfterBr(rootElement, from)) {\n        return findPreviousBr(rootElement, from).map(function (br) {\n          return DeleteAction.remove(br.getNode());\n        });\n      } else if (forward && isAfterContentEditableFalse(from) && isBeforeBr$1(rootElement, from)) {\n        return findNextBr(rootElement, from).map(function (br) {\n          return DeleteAction.remove(br.getNode());\n        });\n      } else {\n        return getContentEditableAction(root, forward, from);\n      }\n    };\n\n    var deleteElement$1 = function (editor, forward) {\n      return function (element) {\n        editor._selectionOverrides.hideFakeCaret();\n        deleteElement$2(editor, forward, SugarElement.fromDom(element));\n        return true;\n      };\n    };\n    var moveToElement = function (editor, forward) {\n      return function (element) {\n        var pos = forward ? CaretPosition.before(element) : CaretPosition.after(element);\n        editor.selection.setRng(pos.toRange());\n        return true;\n      };\n    };\n    var moveToPosition = function (editor) {\n      return function (pos) {\n        editor.selection.setRng(pos.toRange());\n        return true;\n      };\n    };\n    var getAncestorCe = function (editor, node) {\n      return Optional.from(getContentEditableRoot$1(editor.getBody(), node));\n    };\n    var backspaceDeleteCaret = function (editor, forward) {\n      var selectedNode = editor.selection.getNode();\n      return getAncestorCe(editor, selectedNode).filter(isContentEditableFalse$b).fold(function () {\n        return read(editor.getBody(), forward, editor.selection.getRng()).exists(function (deleteAction) {\n          return deleteAction.fold(deleteElement$1(editor, forward), moveToElement(editor, forward), moveToPosition(editor));\n        });\n      }, always);\n    };\n    var deleteOffscreenSelection = function (rootElement) {\n      each$k(descendants(rootElement, '.mce-offscreen-selection'), remove$7);\n    };\n    var backspaceDeleteRange = function (editor, forward) {\n      var selectedNode = editor.selection.getNode();\n      if (isContentEditableFalse$b(selectedNode) && !isTableCell$5(selectedNode)) {\n        var hasCefAncestor = getAncestorCe(editor, selectedNode.parentNode).filter(isContentEditableFalse$b);\n        return hasCefAncestor.fold(function () {\n          deleteOffscreenSelection(SugarElement.fromDom(editor.getBody()));\n          deleteElement$2(editor, forward, SugarElement.fromDom(editor.selection.getNode()));\n          paddEmptyBody(editor);\n          return true;\n        }, always);\n      }\n      return false;\n    };\n    var paddEmptyElement = function (editor) {\n      var dom = editor.dom, selection = editor.selection;\n      var ceRoot = getContentEditableRoot$1(editor.getBody(), selection.getNode());\n      if (isContentEditableTrue$4(ceRoot) && dom.isBlock(ceRoot) && dom.isEmpty(ceRoot)) {\n        var br = dom.create('br', { 'data-mce-bogus': '1' });\n        dom.setHTML(ceRoot, '');\n        ceRoot.appendChild(br);\n        selection.setRng(CaretPosition.before(br).toRange());\n      }\n      return true;\n    };\n    var backspaceDelete$5 = function (editor, forward) {\n      if (editor.selection.isCollapsed()) {\n        return backspaceDeleteCaret(editor, forward);\n      } else {\n        return backspaceDeleteRange(editor, forward);\n      }\n    };\n\n    var deleteCaret$2 = function (editor, forward) {\n      var fromPos = CaretPosition.fromRangeStart(editor.selection.getRng());\n      return fromPosition(forward, editor.getBody(), fromPos).filter(function (pos) {\n        return forward ? isBeforeImageBlock(pos) : isAfterImageBlock(pos);\n      }).bind(function (pos) {\n        return Optional.from(getChildNodeAtRelativeOffset(forward ? 0 : -1, pos));\n      }).exists(function (elm) {\n        editor.selection.select(elm);\n        return true;\n      });\n    };\n    var backspaceDelete$4 = function (editor, forward) {\n      return editor.selection.isCollapsed() ? deleteCaret$2(editor, forward) : false;\n    };\n\n    var isText = isText$7;\n    var startsWithCaretContainer = function (node) {\n      return isText(node) && node.data[0] === ZWSP$1;\n    };\n    var endsWithCaretContainer = function (node) {\n      return isText(node) && node.data[node.data.length - 1] === ZWSP$1;\n    };\n    var createZwsp = function (node) {\n      return node.ownerDocument.createTextNode(ZWSP$1);\n    };\n    var insertBefore = function (node) {\n      if (isText(node.previousSibling)) {\n        if (endsWithCaretContainer(node.previousSibling)) {\n          return node.previousSibling;\n        } else {\n          node.previousSibling.appendData(ZWSP$1);\n          return node.previousSibling;\n        }\n      } else if (isText(node)) {\n        if (startsWithCaretContainer(node)) {\n          return node;\n        } else {\n          node.insertData(0, ZWSP$1);\n          return node;\n        }\n      } else {\n        var newNode = createZwsp(node);\n        node.parentNode.insertBefore(newNode, node);\n        return newNode;\n      }\n    };\n    var insertAfter = function (node) {\n      if (isText(node.nextSibling)) {\n        if (startsWithCaretContainer(node.nextSibling)) {\n          return node.nextSibling;\n        } else {\n          node.nextSibling.insertData(0, ZWSP$1);\n          return node.nextSibling;\n        }\n      } else if (isText(node)) {\n        if (endsWithCaretContainer(node)) {\n          return node;\n        } else {\n          node.appendData(ZWSP$1);\n          return node;\n        }\n      } else {\n        var newNode = createZwsp(node);\n        if (node.nextSibling) {\n          node.parentNode.insertBefore(newNode, node.nextSibling);\n        } else {\n          node.parentNode.appendChild(newNode);\n        }\n        return newNode;\n      }\n    };\n    var insertInline = function (before, node) {\n      return before ? insertBefore(node) : insertAfter(node);\n    };\n    var insertInlineBefore = curry(insertInline, true);\n    var insertInlineAfter = curry(insertInline, false);\n\n    var insertInlinePos = function (pos, before) {\n      if (isText$7(pos.container())) {\n        return insertInline(before, pos.container());\n      } else {\n        return insertInline(before, pos.getNode());\n      }\n    };\n    var isPosCaretContainer = function (pos, caret) {\n      var caretNode = caret.get();\n      return caretNode && pos.container() === caretNode && isCaretContainerInline(caretNode);\n    };\n    var renderCaret = function (caret, location) {\n      return location.fold(function (element) {\n        remove$2(caret.get());\n        var text = insertInlineBefore(element);\n        caret.set(text);\n        return Optional.some(CaretPosition(text, text.length - 1));\n      }, function (element) {\n        return firstPositionIn(element).map(function (pos) {\n          if (!isPosCaretContainer(pos, caret)) {\n            remove$2(caret.get());\n            var text = insertInlinePos(pos, true);\n            caret.set(text);\n            return CaretPosition(text, 1);\n          } else {\n            return CaretPosition(caret.get(), 1);\n          }\n        });\n      }, function (element) {\n        return lastPositionIn(element).map(function (pos) {\n          if (!isPosCaretContainer(pos, caret)) {\n            remove$2(caret.get());\n            var text = insertInlinePos(pos, false);\n            caret.set(text);\n            return CaretPosition(text, text.length - 1);\n          } else {\n            return CaretPosition(caret.get(), caret.get().length - 1);\n          }\n        });\n      }, function (element) {\n        remove$2(caret.get());\n        var text = insertInlineAfter(element);\n        caret.set(text);\n        return Optional.some(CaretPosition(text, 1));\n      });\n    };\n\n    var evaluateUntil = function (fns, args) {\n      for (var i = 0; i < fns.length; i++) {\n        var result = fns[i].apply(null, args);\n        if (result.isSome()) {\n          return result;\n        }\n      }\n      return Optional.none();\n    };\n\n    var Location = Adt.generate([\n      { before: ['element'] },\n      { start: ['element'] },\n      { end: ['element'] },\n      { after: ['element'] }\n    ]);\n    var rescope$1 = function (rootNode, node) {\n      var parentBlock = getParentBlock$2(node, rootNode);\n      return parentBlock ? parentBlock : rootNode;\n    };\n    var before = function (isInlineTarget, rootNode, pos) {\n      var nPos = normalizeForwards(pos);\n      var scope = rescope$1(rootNode, nPos.container());\n      return findRootInline(isInlineTarget, scope, nPos).fold(function () {\n        return nextPosition(scope, nPos).bind(curry(findRootInline, isInlineTarget, scope)).map(function (inline) {\n          return Location.before(inline);\n        });\n      }, Optional.none);\n    };\n    var isNotInsideFormatCaretContainer = function (rootNode, elm) {\n      return getParentCaretContainer(rootNode, elm) === null;\n    };\n    var findInsideRootInline = function (isInlineTarget, rootNode, pos) {\n      return findRootInline(isInlineTarget, rootNode, pos).filter(curry(isNotInsideFormatCaretContainer, rootNode));\n    };\n    var start$1 = function (isInlineTarget, rootNode, pos) {\n      var nPos = normalizeBackwards(pos);\n      return findInsideRootInline(isInlineTarget, rootNode, nPos).bind(function (inline) {\n        var prevPos = prevPosition(inline, nPos);\n        return prevPos.isNone() ? Optional.some(Location.start(inline)) : Optional.none();\n      });\n    };\n    var end = function (isInlineTarget, rootNode, pos) {\n      var nPos = normalizeForwards(pos);\n      return findInsideRootInline(isInlineTarget, rootNode, nPos).bind(function (inline) {\n        var nextPos = nextPosition(inline, nPos);\n        return nextPos.isNone() ? Optional.some(Location.end(inline)) : Optional.none();\n      });\n    };\n    var after = function (isInlineTarget, rootNode, pos) {\n      var nPos = normalizeBackwards(pos);\n      var scope = rescope$1(rootNode, nPos.container());\n      return findRootInline(isInlineTarget, scope, nPos).fold(function () {\n        return prevPosition(scope, nPos).bind(curry(findRootInline, isInlineTarget, scope)).map(function (inline) {\n          return Location.after(inline);\n        });\n      }, Optional.none);\n    };\n    var isValidLocation = function (location) {\n      return isRtl(getElement(location)) === false;\n    };\n    var readLocation = function (isInlineTarget, rootNode, pos) {\n      var location = evaluateUntil([\n        before,\n        start$1,\n        end,\n        after\n      ], [\n        isInlineTarget,\n        rootNode,\n        pos\n      ]);\n      return location.filter(isValidLocation);\n    };\n    var getElement = function (location) {\n      return location.fold(identity, identity, identity, identity);\n    };\n    var getName = function (location) {\n      return location.fold(constant('before'), constant('start'), constant('end'), constant('after'));\n    };\n    var outside = function (location) {\n      return location.fold(Location.before, Location.before, Location.after, Location.after);\n    };\n    var inside = function (location) {\n      return location.fold(Location.start, Location.start, Location.end, Location.end);\n    };\n    var isEq = function (location1, location2) {\n      return getName(location1) === getName(location2) && getElement(location1) === getElement(location2);\n    };\n    var betweenInlines = function (forward, isInlineTarget, rootNode, from, to, location) {\n      return lift2(findRootInline(isInlineTarget, rootNode, from), findRootInline(isInlineTarget, rootNode, to), function (fromInline, toInline) {\n        if (fromInline !== toInline && hasSameParentBlock(rootNode, fromInline, toInline)) {\n          return Location.after(forward ? fromInline : toInline);\n        } else {\n          return location;\n        }\n      }).getOr(location);\n    };\n    var skipNoMovement = function (fromLocation, toLocation) {\n      return fromLocation.fold(always, function (fromLocation) {\n        return !isEq(fromLocation, toLocation);\n      });\n    };\n    var findLocationTraverse = function (forward, isInlineTarget, rootNode, fromLocation, pos) {\n      var from = normalizePosition(forward, pos);\n      var to = fromPosition(forward, rootNode, from).map(curry(normalizePosition, forward));\n      var location = to.fold(function () {\n        return fromLocation.map(outside);\n      }, function (to) {\n        return readLocation(isInlineTarget, rootNode, to).map(curry(betweenInlines, forward, isInlineTarget, rootNode, from, to)).filter(curry(skipNoMovement, fromLocation));\n      });\n      return location.filter(isValidLocation);\n    };\n    var findLocationSimple = function (forward, location) {\n      if (forward) {\n        return location.fold(compose(Optional.some, Location.start), Optional.none, compose(Optional.some, Location.after), Optional.none);\n      } else {\n        return location.fold(Optional.none, compose(Optional.some, Location.before), Optional.none, compose(Optional.some, Location.end));\n      }\n    };\n    var findLocation$1 = function (forward, isInlineTarget, rootNode, pos) {\n      var from = normalizePosition(forward, pos);\n      var fromLocation = readLocation(isInlineTarget, rootNode, from);\n      return readLocation(isInlineTarget, rootNode, from).bind(curry(findLocationSimple, forward)).orThunk(function () {\n        return findLocationTraverse(forward, isInlineTarget, rootNode, fromLocation, pos);\n      });\n    };\n    curry(findLocation$1, false);\n    curry(findLocation$1, true);\n\n    var hasSelectionModifyApi = function (editor) {\n      return isFunction(editor.selection.getSel().modify);\n    };\n    var moveRel = function (forward, selection, pos) {\n      var delta = forward ? 1 : -1;\n      selection.setRng(CaretPosition(pos.container(), pos.offset() + delta).toRange());\n      selection.getSel().modify('move', forward ? 'forward' : 'backward', 'word');\n      return true;\n    };\n    var moveByWord = function (forward, editor) {\n      var rng = editor.selection.getRng();\n      var pos = forward ? CaretPosition.fromRangeEnd(rng) : CaretPosition.fromRangeStart(rng);\n      if (!hasSelectionModifyApi(editor)) {\n        return false;\n      } else if (forward && isBeforeInline(pos)) {\n        return moveRel(true, editor.selection, pos);\n      } else if (!forward && isAfterInline(pos)) {\n        return moveRel(false, editor.selection, pos);\n      } else {\n        return false;\n      }\n    };\n\n    var BreakType;\n    (function (BreakType) {\n      BreakType[BreakType['Br'] = 0] = 'Br';\n      BreakType[BreakType['Block'] = 1] = 'Block';\n      BreakType[BreakType['Wrap'] = 2] = 'Wrap';\n      BreakType[BreakType['Eol'] = 3] = 'Eol';\n    }(BreakType || (BreakType = {})));\n    var flip = function (direction, positions) {\n      return direction === HDirection.Backwards ? reverse(positions) : positions;\n    };\n    var walk = function (direction, caretWalker, pos) {\n      return direction === HDirection.Forwards ? caretWalker.next(pos) : caretWalker.prev(pos);\n    };\n    var getBreakType = function (scope, direction, currentPos, nextPos) {\n      if (isBr$5(nextPos.getNode(direction === HDirection.Forwards))) {\n        return BreakType.Br;\n      } else if (isInSameBlock(currentPos, nextPos) === false) {\n        return BreakType.Block;\n      } else {\n        return BreakType.Wrap;\n      }\n    };\n    var getPositionsUntil = function (predicate, direction, scope, start) {\n      var caretWalker = CaretWalker(scope);\n      var currentPos = start;\n      var positions = [];\n      while (currentPos) {\n        var nextPos = walk(direction, caretWalker, currentPos);\n        if (!nextPos) {\n          break;\n        }\n        if (isBr$5(nextPos.getNode(false))) {\n          if (direction === HDirection.Forwards) {\n            return {\n              positions: flip(direction, positions).concat([nextPos]),\n              breakType: BreakType.Br,\n              breakAt: Optional.some(nextPos)\n            };\n          } else {\n            return {\n              positions: flip(direction, positions),\n              breakType: BreakType.Br,\n              breakAt: Optional.some(nextPos)\n            };\n          }\n        }\n        if (!nextPos.isVisible()) {\n          currentPos = nextPos;\n          continue;\n        }\n        if (predicate(currentPos, nextPos)) {\n          var breakType = getBreakType(scope, direction, currentPos, nextPos);\n          return {\n            positions: flip(direction, positions),\n            breakType: breakType,\n            breakAt: Optional.some(nextPos)\n          };\n        }\n        positions.push(nextPos);\n        currentPos = nextPos;\n      }\n      return {\n        positions: flip(direction, positions),\n        breakType: BreakType.Eol,\n        breakAt: Optional.none()\n      };\n    };\n    var getAdjacentLinePositions = function (direction, getPositionsUntilBreak, scope, start) {\n      return getPositionsUntilBreak(scope, start).breakAt.map(function (pos) {\n        var positions = getPositionsUntilBreak(scope, pos).positions;\n        return direction === HDirection.Backwards ? positions.concat(pos) : [pos].concat(positions);\n      }).getOr([]);\n    };\n    var findClosestHorizontalPositionFromPoint = function (positions, x) {\n      return foldl(positions, function (acc, newPos) {\n        return acc.fold(function () {\n          return Optional.some(newPos);\n        }, function (lastPos) {\n          return lift2(head(lastPos.getClientRects()), head(newPos.getClientRects()), function (lastRect, newRect) {\n            var lastDist = Math.abs(x - lastRect.left);\n            var newDist = Math.abs(x - newRect.left);\n            return newDist <= lastDist ? newPos : lastPos;\n          }).or(acc);\n        });\n      }, Optional.none());\n    };\n    var findClosestHorizontalPosition = function (positions, pos) {\n      return head(pos.getClientRects()).bind(function (targetRect) {\n        return findClosestHorizontalPositionFromPoint(positions, targetRect.left);\n      });\n    };\n    var getPositionsUntilPreviousLine = curry(getPositionsUntil, CaretPosition.isAbove, -1);\n    var getPositionsUntilNextLine = curry(getPositionsUntil, CaretPosition.isBelow, 1);\n    var getPositionsAbove = curry(getAdjacentLinePositions, -1, getPositionsUntilPreviousLine);\n    var getPositionsBelow = curry(getAdjacentLinePositions, 1, getPositionsUntilNextLine);\n    var isAtFirstLine = function (scope, pos) {\n      return getPositionsUntilPreviousLine(scope, pos).breakAt.isNone();\n    };\n    var isAtLastLine = function (scope, pos) {\n      return getPositionsUntilNextLine(scope, pos).breakAt.isNone();\n    };\n    var getFirstLinePositions = function (scope) {\n      return firstPositionIn(scope).map(function (pos) {\n        return [pos].concat(getPositionsUntilNextLine(scope, pos).positions);\n      }).getOr([]);\n    };\n    var getLastLinePositions = function (scope) {\n      return lastPositionIn(scope).map(function (pos) {\n        return getPositionsUntilPreviousLine(scope, pos).positions.concat(pos);\n      }).getOr([]);\n    };\n\n    var getNodeClientRects = function (node) {\n      var toArrayWithNode = function (clientRects) {\n        return map$3(clientRects, function (rect) {\n          var clientRect = clone(rect);\n          clientRect.node = node;\n          return clientRect;\n        });\n      };\n      if (isElement$5(node)) {\n        return toArrayWithNode(node.getClientRects());\n      }\n      if (isText$7(node)) {\n        var rng = node.ownerDocument.createRange();\n        rng.setStart(node, 0);\n        rng.setEnd(node, node.data.length);\n        return toArrayWithNode(rng.getClientRects());\n      }\n    };\n    var getClientRects = function (nodes) {\n      return bind(nodes, getNodeClientRects);\n    };\n\n    var VDirection;\n    (function (VDirection) {\n      VDirection[VDirection['Up'] = -1] = 'Up';\n      VDirection[VDirection['Down'] = 1] = 'Down';\n    }(VDirection || (VDirection = {})));\n    var findUntil = function (direction, root, predicateFn, node) {\n      while (node = findNode$1(node, direction, isEditableCaretCandidate$1, root)) {\n        if (predicateFn(node)) {\n          return;\n        }\n      }\n    };\n    var walkUntil$1 = function (direction, isAboveFn, isBeflowFn, root, predicateFn, caretPosition) {\n      var line = 0;\n      var result = [];\n      var add = function (node) {\n        var clientRects = getClientRects([node]);\n        if (direction === -1) {\n          clientRects = clientRects.reverse();\n        }\n        for (var i = 0; i < clientRects.length; i++) {\n          var clientRect = clientRects[i];\n          if (isBeflowFn(clientRect, targetClientRect)) {\n            continue;\n          }\n          if (result.length > 0 && isAboveFn(clientRect, last$1(result))) {\n            line++;\n          }\n          clientRect.line = line;\n          if (predicateFn(clientRect)) {\n            return true;\n          }\n          result.push(clientRect);\n        }\n      };\n      var targetClientRect = last$1(caretPosition.getClientRects());\n      if (!targetClientRect) {\n        return result;\n      }\n      var node = caretPosition.getNode();\n      add(node);\n      findUntil(direction, root, add, node);\n      return result;\n    };\n    var aboveLineNumber = function (lineNumber, clientRect) {\n      return clientRect.line > lineNumber;\n    };\n    var isLineNumber = function (lineNumber, clientRect) {\n      return clientRect.line === lineNumber;\n    };\n    var upUntil = curry(walkUntil$1, VDirection.Up, isAbove$1, isBelow$1);\n    var downUntil = curry(walkUntil$1, VDirection.Down, isBelow$1, isAbove$1);\n    var positionsUntil = function (direction, root, predicateFn, node) {\n      var caretWalker = CaretWalker(root);\n      var walkFn;\n      var isBelowFn;\n      var isAboveFn;\n      var caretPosition;\n      var result = [];\n      var line = 0;\n      var getClientRect = function (caretPosition) {\n        if (direction === 1) {\n          return last$1(caretPosition.getClientRects());\n        }\n        return last$1(caretPosition.getClientRects());\n      };\n      if (direction === 1) {\n        walkFn = caretWalker.next;\n        isBelowFn = isBelow$1;\n        isAboveFn = isAbove$1;\n        caretPosition = CaretPosition.after(node);\n      } else {\n        walkFn = caretWalker.prev;\n        isBelowFn = isAbove$1;\n        isAboveFn = isBelow$1;\n        caretPosition = CaretPosition.before(node);\n      }\n      var targetClientRect = getClientRect(caretPosition);\n      do {\n        if (!caretPosition.isVisible()) {\n          continue;\n        }\n        var rect = getClientRect(caretPosition);\n        if (isAboveFn(rect, targetClientRect)) {\n          continue;\n        }\n        if (result.length > 0 && isBelowFn(rect, last$1(result))) {\n          line++;\n        }\n        var clientRect = clone(rect);\n        clientRect.position = caretPosition;\n        clientRect.line = line;\n        if (predicateFn(clientRect)) {\n          return result;\n        }\n        result.push(clientRect);\n      } while (caretPosition = walkFn(caretPosition));\n      return result;\n    };\n    var isAboveLine = function (lineNumber) {\n      return function (clientRect) {\n        return aboveLineNumber(lineNumber, clientRect);\n      };\n    };\n    var isLine = function (lineNumber) {\n      return function (clientRect) {\n        return isLineNumber(lineNumber, clientRect);\n      };\n    };\n\n    var isContentEditableFalse$3 = isContentEditableFalse$b;\n    var findNode = findNode$1;\n    var distanceToRectLeft = function (clientRect, clientX) {\n      return Math.abs(clientRect.left - clientX);\n    };\n    var distanceToRectRight = function (clientRect, clientX) {\n      return Math.abs(clientRect.right - clientX);\n    };\n    var isInsideX = function (clientX, clientRect) {\n      return clientX >= clientRect.left && clientX <= clientRect.right;\n    };\n    var isInsideY = function (clientY, clientRect) {\n      return clientY >= clientRect.top && clientY <= clientRect.bottom;\n    };\n    var isNodeClientRect = function (rect) {\n      return hasNonNullableKey(rect, 'node');\n    };\n    var findClosestClientRect = function (clientRects, clientX, allowInside) {\n      if (allowInside === void 0) {\n        allowInside = always;\n      }\n      return reduce(clientRects, function (oldClientRect, clientRect) {\n        if (isInsideX(clientX, clientRect)) {\n          return allowInside(clientRect) ? clientRect : oldClientRect;\n        }\n        if (isInsideX(clientX, oldClientRect)) {\n          return allowInside(oldClientRect) ? oldClientRect : clientRect;\n        }\n        var oldDistance = Math.min(distanceToRectLeft(oldClientRect, clientX), distanceToRectRight(oldClientRect, clientX));\n        var newDistance = Math.min(distanceToRectLeft(clientRect, clientX), distanceToRectRight(clientRect, clientX));\n        if (newDistance === oldDistance && isNodeClientRect(clientRect) && isContentEditableFalse$3(clientRect.node)) {\n          return clientRect;\n        }\n        if (newDistance < oldDistance) {\n          return clientRect;\n        }\n        return oldClientRect;\n      });\n    };\n    var walkUntil = function (direction, root, predicateFn, startNode, includeChildren) {\n      var node = findNode(startNode, direction, isEditableCaretCandidate$1, root, !includeChildren);\n      do {\n        if (!node || predicateFn(node)) {\n          return;\n        }\n      } while (node = findNode(node, direction, isEditableCaretCandidate$1, root));\n    };\n    var findLineNodeRects = function (root, targetNodeRect, includeChildren) {\n      if (includeChildren === void 0) {\n        includeChildren = true;\n      }\n      var clientRects = [];\n      var collect = function (checkPosFn, node) {\n        var lineRects = filter$4(getClientRects([node]), function (clientRect) {\n          return !checkPosFn(clientRect, targetNodeRect);\n        });\n        clientRects = clientRects.concat(lineRects);\n        return lineRects.length === 0;\n      };\n      clientRects.push(targetNodeRect);\n      walkUntil(VDirection.Up, root, curry(collect, isAbove$1), targetNodeRect.node, includeChildren);\n      walkUntil(VDirection.Down, root, curry(collect, isBelow$1), targetNodeRect.node, includeChildren);\n      return clientRects;\n    };\n    var getFakeCaretTargets = function (root) {\n      return filter$4(from(root.getElementsByTagName('*')), isFakeCaretTarget);\n    };\n    var caretInfo = function (clientRect, clientX) {\n      return {\n        node: clientRect.node,\n        before: distanceToRectLeft(clientRect, clientX) < distanceToRectRight(clientRect, clientX)\n      };\n    };\n    var closestFakeCaret = function (root, clientX, clientY) {\n      var fakeTargetNodeRects = getClientRects(getFakeCaretTargets(root));\n      var targetNodeRects = filter$4(fakeTargetNodeRects, curry(isInsideY, clientY));\n      var checkInside = function (clientRect) {\n        return !isTable$3(clientRect.node) && !isMedia$2(clientRect.node);\n      };\n      var closestNodeRect = findClosestClientRect(targetNodeRects, clientX, checkInside);\n      if (closestNodeRect) {\n        var includeChildren = checkInside(closestNodeRect);\n        closestNodeRect = findClosestClientRect(findLineNodeRects(root, closestNodeRect, includeChildren), clientX, checkInside);\n        if (closestNodeRect && isFakeCaretTarget(closestNodeRect.node)) {\n          return caretInfo(closestNodeRect, clientX);\n        }\n      }\n      return null;\n    };\n\n    var moveToRange = function (editor, rng) {\n      editor.selection.setRng(rng);\n      scrollRangeIntoView(editor, editor.selection.getRng());\n    };\n    var renderRangeCaretOpt = function (editor, range, scrollIntoView) {\n      return Optional.some(renderRangeCaret(editor, range, scrollIntoView));\n    };\n    var moveHorizontally = function (editor, direction, range, isBefore, isAfter, isElement) {\n      var forwards = direction === HDirection.Forwards;\n      var caretWalker = CaretWalker(editor.getBody());\n      var getNextPosFn = curry(getVisualCaretPosition, forwards ? caretWalker.next : caretWalker.prev);\n      var isBeforeFn = forwards ? isBefore : isAfter;\n      if (!range.collapsed) {\n        var node = getSelectedNode(range);\n        if (isElement(node)) {\n          return showCaret(direction, editor, node, direction === HDirection.Backwards, false);\n        }\n      }\n      var caretPosition = getNormalizedRangeEndPoint(direction, editor.getBody(), range);\n      if (isBeforeFn(caretPosition)) {\n        return selectNode(editor, caretPosition.getNode(!forwards));\n      }\n      var nextCaretPosition = normalizePosition(forwards, getNextPosFn(caretPosition));\n      var rangeIsInContainerBlock = isRangeInCaretContainerBlock(range);\n      if (!nextCaretPosition) {\n        return rangeIsInContainerBlock ? Optional.some(range) : Optional.none();\n      }\n      if (isBeforeFn(nextCaretPosition)) {\n        return showCaret(direction, editor, nextCaretPosition.getNode(!forwards), forwards, false);\n      }\n      var peekCaretPosition = getNextPosFn(nextCaretPosition);\n      if (peekCaretPosition && isBeforeFn(peekCaretPosition)) {\n        if (isMoveInsideSameBlock(nextCaretPosition, peekCaretPosition)) {\n          return showCaret(direction, editor, peekCaretPosition.getNode(!forwards), forwards, false);\n        }\n      }\n      if (rangeIsInContainerBlock) {\n        return renderRangeCaretOpt(editor, nextCaretPosition.toRange(), false);\n      }\n      return Optional.none();\n    };\n    var moveVertically = function (editor, direction, range, isBefore, isAfter, isElement) {\n      var caretPosition = getNormalizedRangeEndPoint(direction, editor.getBody(), range);\n      var caretClientRect = last$1(caretPosition.getClientRects());\n      var forwards = direction === VDirection.Down;\n      if (!caretClientRect) {\n        return Optional.none();\n      }\n      var walkerFn = forwards ? downUntil : upUntil;\n      var linePositions = walkerFn(editor.getBody(), isAboveLine(1), caretPosition);\n      var nextLinePositions = filter$4(linePositions, isLine(1));\n      var clientX = caretClientRect.left;\n      var nextLineRect = findClosestClientRect(nextLinePositions, clientX);\n      if (nextLineRect && isElement(nextLineRect.node)) {\n        var dist1 = Math.abs(clientX - nextLineRect.left);\n        var dist2 = Math.abs(clientX - nextLineRect.right);\n        return showCaret(direction, editor, nextLineRect.node, dist1 < dist2, false);\n      }\n      var currentNode;\n      if (isBefore(caretPosition)) {\n        currentNode = caretPosition.getNode();\n      } else if (isAfter(caretPosition)) {\n        currentNode = caretPosition.getNode(true);\n      } else {\n        currentNode = getSelectedNode(range);\n      }\n      if (currentNode) {\n        var caretPositions = positionsUntil(direction, editor.getBody(), isAboveLine(1), currentNode);\n        var closestNextLineRect = findClosestClientRect(filter$4(caretPositions, isLine(1)), clientX);\n        if (closestNextLineRect) {\n          return renderRangeCaretOpt(editor, closestNextLineRect.position.toRange(), false);\n        }\n        closestNextLineRect = last$1(filter$4(caretPositions, isLine(0)));\n        if (closestNextLineRect) {\n          return renderRangeCaretOpt(editor, closestNextLineRect.position.toRange(), false);\n        }\n      }\n      if (nextLinePositions.length === 0) {\n        return getLineEndPoint(editor, forwards).filter(forwards ? isAfter : isBefore).map(function (pos) {\n          return renderRangeCaret(editor, pos.toRange(), false);\n        });\n      }\n      return Optional.none();\n    };\n    var getLineEndPoint = function (editor, forward) {\n      var rng = editor.selection.getRng();\n      var body = editor.getBody();\n      if (forward) {\n        var from = CaretPosition.fromRangeEnd(rng);\n        var result = getPositionsUntilNextLine(body, from);\n        return last$2(result.positions);\n      } else {\n        var from = CaretPosition.fromRangeStart(rng);\n        var result = getPositionsUntilPreviousLine(body, from);\n        return head(result.positions);\n      }\n    };\n    var moveToLineEndPoint$3 = function (editor, forward, isElementPosition) {\n      return getLineEndPoint(editor, forward).filter(isElementPosition).exists(function (pos) {\n        editor.selection.setRng(pos.toRange());\n        return true;\n      });\n    };\n\n    var setCaretPosition = function (editor, pos) {\n      var rng = editor.dom.createRng();\n      rng.setStart(pos.container(), pos.offset());\n      rng.setEnd(pos.container(), pos.offset());\n      editor.selection.setRng(rng);\n    };\n    var setSelected = function (state, elm) {\n      if (state) {\n        elm.setAttribute('data-mce-selected', 'inline-boundary');\n      } else {\n        elm.removeAttribute('data-mce-selected');\n      }\n    };\n    var renderCaretLocation = function (editor, caret, location) {\n      return renderCaret(caret, location).map(function (pos) {\n        setCaretPosition(editor, pos);\n        return location;\n      });\n    };\n    var findLocation = function (editor, caret, forward) {\n      var rootNode = editor.getBody();\n      var from = CaretPosition.fromRangeStart(editor.selection.getRng());\n      var isInlineTarget$1 = curry(isInlineTarget, editor);\n      var location = findLocation$1(forward, isInlineTarget$1, rootNode, from);\n      return location.bind(function (location) {\n        return renderCaretLocation(editor, caret, location);\n      });\n    };\n    var toggleInlines = function (isInlineTarget, dom, elms) {\n      var inlineBoundaries = map$3(descendants(SugarElement.fromDom(dom.getRoot()), '*[data-mce-selected=\"inline-boundary\"]'), function (e) {\n        return e.dom;\n      });\n      var selectedInlines = filter$4(inlineBoundaries, isInlineTarget);\n      var targetInlines = filter$4(elms, isInlineTarget);\n      each$k(difference(selectedInlines, targetInlines), curry(setSelected, false));\n      each$k(difference(targetInlines, selectedInlines), curry(setSelected, true));\n    };\n    var safeRemoveCaretContainer = function (editor, caret) {\n      if (editor.selection.isCollapsed() && editor.composing !== true && caret.get()) {\n        var pos = CaretPosition.fromRangeStart(editor.selection.getRng());\n        if (CaretPosition.isTextPosition(pos) && isAtZwsp(pos) === false) {\n          setCaretPosition(editor, removeAndReposition(caret.get(), pos));\n          caret.set(null);\n        }\n      }\n    };\n    var renderInsideInlineCaret = function (isInlineTarget, editor, caret, elms) {\n      if (editor.selection.isCollapsed()) {\n        var inlines = filter$4(elms, isInlineTarget);\n        each$k(inlines, function (_inline) {\n          var pos = CaretPosition.fromRangeStart(editor.selection.getRng());\n          readLocation(isInlineTarget, editor.getBody(), pos).bind(function (location) {\n            return renderCaretLocation(editor, caret, location);\n          });\n        });\n      }\n    };\n    var move$2 = function (editor, caret, forward) {\n      return isInlineBoundariesEnabled(editor) ? findLocation(editor, caret, forward).isSome() : false;\n    };\n    var moveWord = function (forward, editor, _caret) {\n      return isInlineBoundariesEnabled(editor) ? moveByWord(forward, editor) : false;\n    };\n    var setupSelectedState = function (editor) {\n      var caret = Cell(null);\n      var isInlineTarget$1 = curry(isInlineTarget, editor);\n      editor.on('NodeChange', function (e) {\n        if (isInlineBoundariesEnabled(editor) && !(Env.browser.isIE() && e.initial)) {\n          toggleInlines(isInlineTarget$1, editor.dom, e.parents);\n          safeRemoveCaretContainer(editor, caret);\n          renderInsideInlineCaret(isInlineTarget$1, editor, caret, e.parents);\n        }\n      });\n      return caret;\n    };\n    var moveNextWord = curry(moveWord, true);\n    var movePrevWord = curry(moveWord, false);\n    var moveToLineEndPoint$2 = function (editor, forward, caret) {\n      if (isInlineBoundariesEnabled(editor)) {\n        var linePoint = getLineEndPoint(editor, forward).getOrThunk(function () {\n          var rng = editor.selection.getRng();\n          return forward ? CaretPosition.fromRangeEnd(rng) : CaretPosition.fromRangeStart(rng);\n        });\n        return readLocation(curry(isInlineTarget, editor), editor.getBody(), linePoint).exists(function (loc) {\n          var outsideLoc = outside(loc);\n          return renderCaret(caret, outsideLoc).exists(function (pos) {\n            setCaretPosition(editor, pos);\n            return true;\n          });\n        });\n      } else {\n        return false;\n      }\n    };\n\n    var rangeFromPositions = function (from, to) {\n      var range = document.createRange();\n      range.setStart(from.container(), from.offset());\n      range.setEnd(to.container(), to.offset());\n      return range;\n    };\n    var hasOnlyTwoOrLessPositionsLeft = function (elm) {\n      return lift2(firstPositionIn(elm), lastPositionIn(elm), function (firstPos, lastPos) {\n        var normalizedFirstPos = normalizePosition(true, firstPos);\n        var normalizedLastPos = normalizePosition(false, lastPos);\n        return nextPosition(elm, normalizedFirstPos).forall(function (pos) {\n          return pos.isEqual(normalizedLastPos);\n        });\n      }).getOr(true);\n    };\n    var setCaretLocation = function (editor, caret) {\n      return function (location) {\n        return renderCaret(caret, location).exists(function (pos) {\n          setCaretPosition(editor, pos);\n          return true;\n        });\n      };\n    };\n    var deleteFromTo = function (editor, caret, from, to) {\n      var rootNode = editor.getBody();\n      var isInlineTarget$1 = curry(isInlineTarget, editor);\n      editor.undoManager.ignore(function () {\n        editor.selection.setRng(rangeFromPositions(from, to));\n        editor.execCommand('Delete');\n        readLocation(isInlineTarget$1, rootNode, CaretPosition.fromRangeStart(editor.selection.getRng())).map(inside).map(setCaretLocation(editor, caret));\n      });\n      editor.nodeChanged();\n    };\n    var rescope = function (rootNode, node) {\n      var parentBlock = getParentBlock$2(node, rootNode);\n      return parentBlock ? parentBlock : rootNode;\n    };\n    var backspaceDeleteCollapsed = function (editor, caret, forward, from) {\n      var rootNode = rescope(editor.getBody(), from.container());\n      var isInlineTarget$1 = curry(isInlineTarget, editor);\n      var fromLocation = readLocation(isInlineTarget$1, rootNode, from);\n      return fromLocation.bind(function (location) {\n        if (forward) {\n          return location.fold(constant(Optional.some(inside(location))), Optional.none, constant(Optional.some(outside(location))), Optional.none);\n        } else {\n          return location.fold(Optional.none, constant(Optional.some(outside(location))), Optional.none, constant(Optional.some(inside(location))));\n        }\n      }).map(setCaretLocation(editor, caret)).getOrThunk(function () {\n        var toPosition = navigate(forward, rootNode, from);\n        var toLocation = toPosition.bind(function (pos) {\n          return readLocation(isInlineTarget$1, rootNode, pos);\n        });\n        return lift2(fromLocation, toLocation, function () {\n          return findRootInline(isInlineTarget$1, rootNode, from).exists(function (elm) {\n            if (hasOnlyTwoOrLessPositionsLeft(elm)) {\n              deleteElement$2(editor, forward, SugarElement.fromDom(elm));\n              return true;\n            } else {\n              return false;\n            }\n          });\n        }).orThunk(function () {\n          return toLocation.bind(function (_) {\n            return toPosition.map(function (to) {\n              if (forward) {\n                deleteFromTo(editor, caret, from, to);\n              } else {\n                deleteFromTo(editor, caret, to, from);\n              }\n              return true;\n            });\n          });\n        }).getOr(false);\n      });\n    };\n    var backspaceDelete$3 = function (editor, caret, forward) {\n      if (editor.selection.isCollapsed() && isInlineBoundariesEnabled(editor)) {\n        var from = CaretPosition.fromRangeStart(editor.selection.getRng());\n        return backspaceDeleteCollapsed(editor, caret, forward, from);\n      }\n      return false;\n    };\n\n    var getParentInlines = function (rootElm, startElm) {\n      var parents = parentsAndSelf(startElm, rootElm);\n      return findIndex$2(parents, isBlock$2).fold(constant(parents), function (index) {\n        return parents.slice(0, index);\n      });\n    };\n    var hasOnlyOneChild = function (elm) {\n      return childNodesCount(elm) === 1;\n    };\n    var deleteLastPosition = function (forward, editor, target, parentInlines) {\n      var isFormatElement$1 = curry(isFormatElement, editor);\n      var formatNodes = map$3(filter$4(parentInlines, isFormatElement$1), function (elm) {\n        return elm.dom;\n      });\n      if (formatNodes.length === 0) {\n        deleteElement$2(editor, forward, target);\n      } else {\n        var pos = replaceWithCaretFormat(target.dom, formatNodes);\n        editor.selection.setRng(pos.toRange());\n      }\n    };\n    var deleteCaret$1 = function (editor, forward) {\n      var rootElm = SugarElement.fromDom(editor.getBody());\n      var startElm = SugarElement.fromDom(editor.selection.getStart());\n      var parentInlines = filter$4(getParentInlines(rootElm, startElm), hasOnlyOneChild);\n      return last$2(parentInlines).exists(function (target) {\n        var fromPos = CaretPosition.fromRangeStart(editor.selection.getRng());\n        if (willDeleteLastPositionInElement(forward, fromPos, target.dom) && !isEmptyCaretFormatElement(target)) {\n          deleteLastPosition(forward, editor, target, parentInlines);\n          return true;\n        } else {\n          return false;\n        }\n      });\n    };\n    var backspaceDelete$2 = function (editor, forward) {\n      return editor.selection.isCollapsed() ? deleteCaret$1(editor, forward) : false;\n    };\n\n    var deleteElement = function (editor, forward, element) {\n      editor._selectionOverrides.hideFakeCaret();\n      deleteElement$2(editor, forward, SugarElement.fromDom(element));\n      return true;\n    };\n    var deleteCaret = function (editor, forward) {\n      var isNearMedia = forward ? isBeforeMedia : isAfterMedia;\n      var direction = forward ? HDirection.Forwards : HDirection.Backwards;\n      var fromPos = getNormalizedRangeEndPoint(direction, editor.getBody(), editor.selection.getRng());\n      if (isNearMedia(fromPos)) {\n        return deleteElement(editor, forward, fromPos.getNode(!forward));\n      } else {\n        return Optional.from(normalizePosition(forward, fromPos)).filter(function (pos) {\n          return isNearMedia(pos) && isMoveInsideSameBlock(fromPos, pos);\n        }).exists(function (pos) {\n          return deleteElement(editor, forward, pos.getNode(!forward));\n        });\n      }\n    };\n    var deleteRange = function (editor, forward) {\n      var selectedNode = editor.selection.getNode();\n      return isMedia$2(selectedNode) ? deleteElement(editor, forward, selectedNode) : false;\n    };\n    var backspaceDelete$1 = function (editor, forward) {\n      return editor.selection.isCollapsed() ? deleteCaret(editor, forward) : deleteRange(editor, forward);\n    };\n\n    var isEditable = function (target) {\n      return closest$3(target, function (elm) {\n        return isContentEditableTrue$4(elm.dom) || isContentEditableFalse$b(elm.dom);\n      }).exists(function (elm) {\n        return isContentEditableTrue$4(elm.dom);\n      });\n    };\n    var parseIndentValue = function (value) {\n      var number = parseInt(value, 10);\n      return isNaN(number) ? 0 : number;\n    };\n    var getIndentStyleName = function (useMargin, element) {\n      var indentStyleName = useMargin || isTable$2(element) ? 'margin' : 'padding';\n      var suffix = get$5(element, 'direction') === 'rtl' ? '-right' : '-left';\n      return indentStyleName + suffix;\n    };\n    var indentElement = function (dom, command, useMargin, value, unit, element) {\n      var indentStyleName = getIndentStyleName(useMargin, SugarElement.fromDom(element));\n      if (command === 'outdent') {\n        var styleValue = Math.max(0, parseIndentValue(element.style[indentStyleName]) - value);\n        dom.setStyle(element, indentStyleName, styleValue ? styleValue + unit : '');\n      } else {\n        var styleValue = parseIndentValue(element.style[indentStyleName]) + value + unit;\n        dom.setStyle(element, indentStyleName, styleValue);\n      }\n    };\n    var validateBlocks = function (editor, blocks) {\n      return forall(blocks, function (block) {\n        var indentStyleName = getIndentStyleName(shouldIndentUseMargin(editor), block);\n        var intentValue = getRaw(block, indentStyleName).map(parseIndentValue).getOr(0);\n        var contentEditable = editor.dom.getContentEditable(block.dom);\n        return contentEditable !== 'false' && intentValue > 0;\n      });\n    };\n    var canOutdent = function (editor) {\n      var blocks = getBlocksToIndent(editor);\n      return !editor.mode.isReadOnly() && (blocks.length > 1 || validateBlocks(editor, blocks));\n    };\n    var isListComponent = function (el) {\n      return isList(el) || isListItem(el);\n    };\n    var parentIsListComponent = function (el) {\n      return parent(el).exists(isListComponent);\n    };\n    var getBlocksToIndent = function (editor) {\n      return filter$4(fromDom$1(editor.selection.getSelectedBlocks()), function (el) {\n        return !isListComponent(el) && !parentIsListComponent(el) && isEditable(el);\n      });\n    };\n    var handle = function (editor, command) {\n      var dom = editor.dom, selection = editor.selection, formatter = editor.formatter;\n      var indentation = getIndentation(editor);\n      var indentUnit = /[a-z%]+$/i.exec(indentation)[0];\n      var indentValue = parseInt(indentation, 10);\n      var useMargin = shouldIndentUseMargin(editor);\n      var forcedRootBlock = getForcedRootBlock(editor);\n      if (!editor.queryCommandState('InsertUnorderedList') && !editor.queryCommandState('InsertOrderedList')) {\n        if (forcedRootBlock === '' && !dom.getParent(selection.getNode(), dom.isBlock)) {\n          formatter.apply('div');\n        }\n      }\n      each$k(getBlocksToIndent(editor), function (block) {\n        indentElement(dom, command, useMargin, indentValue, indentUnit, block.dom);\n      });\n    };\n\n    var backspaceDelete = function (editor, _forward) {\n      if (editor.selection.isCollapsed() && canOutdent(editor)) {\n        var dom = editor.dom;\n        var rng = editor.selection.getRng();\n        var pos = CaretPosition.fromRangeStart(rng);\n        var block = dom.getParent(rng.startContainer, dom.isBlock);\n        if (block !== null && isAtStartOfBlock(SugarElement.fromDom(block), pos)) {\n          handle(editor, 'outdent');\n          return true;\n        }\n      }\n      return false;\n    };\n\n    var nativeCommand = function (editor, command) {\n      editor.getDoc().execCommand(command, false, null);\n    };\n    var deleteCommand = function (editor, caret) {\n      if (backspaceDelete(editor)) {\n        return;\n      } else if (backspaceDelete$5(editor, false)) {\n        return;\n      } else if (backspaceDelete$6(editor, false)) {\n        return;\n      } else if (backspaceDelete$3(editor, caret, false)) {\n        return;\n      } else if (backspaceDelete$8(editor, false)) {\n        return;\n      } else if (backspaceDelete$9(editor)) {\n        return;\n      } else if (backspaceDelete$4(editor, false)) {\n        return;\n      } else if (backspaceDelete$1(editor, false)) {\n        return;\n      } else if (backspaceDelete$7(editor)) {\n        return;\n      } else if (backspaceDelete$2(editor, false)) {\n        return;\n      } else {\n        nativeCommand(editor, 'Delete');\n        paddEmptyBody(editor);\n      }\n    };\n    var forwardDeleteCommand = function (editor, caret) {\n      if (backspaceDelete$5(editor, true)) {\n        return;\n      } else if (backspaceDelete$6(editor, true)) {\n        return;\n      } else if (backspaceDelete$3(editor, caret, true)) {\n        return;\n      } else if (backspaceDelete$8(editor, true)) {\n        return;\n      } else if (backspaceDelete$9(editor)) {\n        return;\n      } else if (backspaceDelete$4(editor, true)) {\n        return;\n      } else if (backspaceDelete$1(editor, true)) {\n        return;\n      } else if (backspaceDelete$7(editor)) {\n        return;\n      } else if (backspaceDelete$2(editor, true)) {\n        return;\n      } else {\n        nativeCommand(editor, 'ForwardDelete');\n      }\n    };\n    var setup$f = function (editor, caret) {\n      editor.addCommand('delete', function () {\n        deleteCommand(editor, caret);\n      });\n      editor.addCommand('forwardDelete', function () {\n        forwardDeleteCommand(editor, caret);\n      });\n    };\n\n    var SIGNIFICANT_MOVE = 5;\n    var LONGPRESS_DELAY = 400;\n    var getTouch = function (event) {\n      if (event.touches === undefined || event.touches.length !== 1) {\n        return Optional.none();\n      }\n      return Optional.some(event.touches[0]);\n    };\n    var isFarEnough = function (touch, data) {\n      var distX = Math.abs(touch.clientX - data.x);\n      var distY = Math.abs(touch.clientY - data.y);\n      return distX > SIGNIFICANT_MOVE || distY > SIGNIFICANT_MOVE;\n    };\n    var setup$e = function (editor) {\n      var startData = value();\n      var longpressFired = Cell(false);\n      var debounceLongpress = last(function (e) {\n        editor.fire('longpress', __assign(__assign({}, e), { type: 'longpress' }));\n        longpressFired.set(true);\n      }, LONGPRESS_DELAY);\n      editor.on('touchstart', function (e) {\n        getTouch(e).each(function (touch) {\n          debounceLongpress.cancel();\n          var data = {\n            x: touch.clientX,\n            y: touch.clientY,\n            target: e.target\n          };\n          debounceLongpress.throttle(e);\n          longpressFired.set(false);\n          startData.set(data);\n        });\n      }, true);\n      editor.on('touchmove', function (e) {\n        debounceLongpress.cancel();\n        getTouch(e).each(function (touch) {\n          startData.on(function (data) {\n            if (isFarEnough(touch, data)) {\n              startData.clear();\n              longpressFired.set(false);\n              editor.fire('longpresscancel');\n            }\n          });\n        });\n      }, true);\n      editor.on('touchend touchcancel', function (e) {\n        debounceLongpress.cancel();\n        if (e.type === 'touchcancel') {\n          return;\n        }\n        startData.get().filter(function (data) {\n          return data.target.isEqualNode(e.target);\n        }).each(function () {\n          if (longpressFired.get()) {\n            e.preventDefault();\n          } else {\n            editor.fire('tap', __assign(__assign({}, e), { type: 'tap' }));\n          }\n        });\n      }, true);\n    };\n\n    var isBlockElement = function (blockElements, node) {\n      return has$2(blockElements, node.nodeName);\n    };\n    var isValidTarget = function (blockElements, node) {\n      if (isText$7(node)) {\n        return true;\n      } else if (isElement$5(node)) {\n        return !isBlockElement(blockElements, node) && !isBookmarkNode$1(node);\n      } else {\n        return false;\n      }\n    };\n    var hasBlockParent = function (blockElements, root, node) {\n      return exists(parents(SugarElement.fromDom(node), SugarElement.fromDom(root)), function (elm) {\n        return isBlockElement(blockElements, elm.dom);\n      });\n    };\n    var shouldRemoveTextNode = function (blockElements, node) {\n      if (isText$7(node)) {\n        if (node.nodeValue.length === 0) {\n          return true;\n        } else if (/^\\s+$/.test(node.nodeValue) && (!node.nextSibling || isBlockElement(blockElements, node.nextSibling))) {\n          return true;\n        }\n      }\n      return false;\n    };\n    var addRootBlocks = function (editor) {\n      var dom = editor.dom, selection = editor.selection;\n      var schema = editor.schema, blockElements = schema.getBlockElements();\n      var node = selection.getStart();\n      var rootNode = editor.getBody();\n      var rootBlockNode, tempNode, wrapped;\n      var forcedRootBlock = getForcedRootBlock(editor);\n      if (!node || !isElement$5(node) || !forcedRootBlock) {\n        return;\n      }\n      var rootNodeName = rootNode.nodeName.toLowerCase();\n      if (!schema.isValidChild(rootNodeName, forcedRootBlock.toLowerCase()) || hasBlockParent(blockElements, rootNode, node)) {\n        return;\n      }\n      var rng = selection.getRng();\n      var startContainer = rng.startContainer;\n      var startOffset = rng.startOffset;\n      var endContainer = rng.endContainer;\n      var endOffset = rng.endOffset;\n      var restoreSelection = hasFocus(editor);\n      node = rootNode.firstChild;\n      while (node) {\n        if (isValidTarget(blockElements, node)) {\n          if (shouldRemoveTextNode(blockElements, node)) {\n            tempNode = node;\n            node = node.nextSibling;\n            dom.remove(tempNode);\n            continue;\n          }\n          if (!rootBlockNode) {\n            rootBlockNode = dom.create(forcedRootBlock, getForcedRootBlockAttrs(editor));\n            node.parentNode.insertBefore(rootBlockNode, node);\n            wrapped = true;\n          }\n          tempNode = node;\n          node = node.nextSibling;\n          rootBlockNode.appendChild(tempNode);\n        } else {\n          rootBlockNode = null;\n          node = node.nextSibling;\n        }\n      }\n      if (wrapped && restoreSelection) {\n        rng.setStart(startContainer, startOffset);\n        rng.setEnd(endContainer, endOffset);\n        selection.setRng(rng);\n        editor.nodeChanged();\n      }\n    };\n    var setup$d = function (editor) {\n      if (getForcedRootBlock(editor)) {\n        editor.on('NodeChange', curry(addRootBlocks, editor));\n      }\n    };\n\n    var findBlockCaretContainer = function (editor) {\n      return descendant(SugarElement.fromDom(editor.getBody()), '*[data-mce-caret]').map(function (elm) {\n        return elm.dom;\n      }).getOrNull();\n    };\n    var removeIeControlRect = function (editor) {\n      editor.selection.setRng(editor.selection.getRng());\n    };\n    var showBlockCaretContainer = function (editor, blockCaretContainer) {\n      if (blockCaretContainer.hasAttribute('data-mce-caret')) {\n        showCaretContainerBlock(blockCaretContainer);\n        removeIeControlRect(editor);\n        editor.selection.scrollIntoView(blockCaretContainer);\n      }\n    };\n    var handleBlockContainer = function (editor, e) {\n      var blockCaretContainer = findBlockCaretContainer(editor);\n      if (!blockCaretContainer) {\n        return;\n      }\n      if (e.type === 'compositionstart') {\n        e.preventDefault();\n        e.stopPropagation();\n        showBlockCaretContainer(editor, blockCaretContainer);\n        return;\n      }\n      if (hasContent(blockCaretContainer)) {\n        showBlockCaretContainer(editor, blockCaretContainer);\n        editor.undoManager.add();\n      }\n    };\n    var setup$c = function (editor) {\n      editor.on('keyup compositionstart', curry(handleBlockContainer, editor));\n    };\n\n    var isContentEditableFalse$2 = isContentEditableFalse$b;\n    var moveToCeFalseHorizontally = function (direction, editor, range) {\n      return moveHorizontally(editor, direction, range, isBeforeContentEditableFalse, isAfterContentEditableFalse, isContentEditableFalse$2);\n    };\n    var moveToCeFalseVertically = function (direction, editor, range) {\n      var isBefore = function (caretPosition) {\n        return isBeforeContentEditableFalse(caretPosition) || isBeforeTable(caretPosition);\n      };\n      var isAfter = function (caretPosition) {\n        return isAfterContentEditableFalse(caretPosition) || isAfterTable(caretPosition);\n      };\n      return moveVertically(editor, direction, range, isBefore, isAfter, isContentEditableFalse$2);\n    };\n    var createTextBlock = function (editor) {\n      var textBlock = editor.dom.create(getForcedRootBlock(editor));\n      if (!Env.ie || Env.ie >= 11) {\n        textBlock.innerHTML = '<br data-mce-bogus=\"1\">';\n      }\n      return textBlock;\n    };\n    var exitPreBlock = function (editor, direction, range) {\n      var caretWalker = CaretWalker(editor.getBody());\n      var getVisualCaretPosition$1 = curry(getVisualCaretPosition, direction === 1 ? caretWalker.next : caretWalker.prev);\n      if (range.collapsed && hasForcedRootBlock(editor)) {\n        var pre = editor.dom.getParent(range.startContainer, 'PRE');\n        if (!pre) {\n          return;\n        }\n        var caretPos = getVisualCaretPosition$1(CaretPosition.fromRangeStart(range));\n        if (!caretPos) {\n          var newBlock = createTextBlock(editor);\n          if (direction === 1) {\n            editor.$(pre).after(newBlock);\n          } else {\n            editor.$(pre).before(newBlock);\n          }\n          editor.selection.select(newBlock, true);\n          editor.selection.collapse();\n        }\n      }\n    };\n    var getHorizontalRange = function (editor, forward) {\n      var direction = forward ? HDirection.Forwards : HDirection.Backwards;\n      var range = editor.selection.getRng();\n      return moveToCeFalseHorizontally(direction, editor, range).orThunk(function () {\n        exitPreBlock(editor, direction, range);\n        return Optional.none();\n      });\n    };\n    var getVerticalRange = function (editor, down) {\n      var direction = down ? 1 : -1;\n      var range = editor.selection.getRng();\n      return moveToCeFalseVertically(direction, editor, range).orThunk(function () {\n        exitPreBlock(editor, direction, range);\n        return Optional.none();\n      });\n    };\n    var moveH$2 = function (editor, forward) {\n      return getHorizontalRange(editor, forward).exists(function (newRange) {\n        moveToRange(editor, newRange);\n        return true;\n      });\n    };\n    var moveV$3 = function (editor, down) {\n      return getVerticalRange(editor, down).exists(function (newRange) {\n        moveToRange(editor, newRange);\n        return true;\n      });\n    };\n    var moveToLineEndPoint$1 = function (editor, forward) {\n      var isCefPosition = forward ? isAfterContentEditableFalse : isBeforeContentEditableFalse;\n      return moveToLineEndPoint$3(editor, forward, isCefPosition);\n    };\n\n    var isTarget = function (node) {\n      return contains$3(['figcaption'], name(node));\n    };\n    var rangeBefore = function (target) {\n      var rng = document.createRange();\n      rng.setStartBefore(target.dom);\n      rng.setEndBefore(target.dom);\n      return rng;\n    };\n    var insertElement = function (root, elm, forward) {\n      if (forward) {\n        append$1(root, elm);\n      } else {\n        prepend(root, elm);\n      }\n    };\n    var insertBr = function (root, forward) {\n      var br = SugarElement.fromTag('br');\n      insertElement(root, br, forward);\n      return rangeBefore(br);\n    };\n    var insertBlock = function (root, forward, blockName, attrs) {\n      var block = SugarElement.fromTag(blockName);\n      var br = SugarElement.fromTag('br');\n      setAll$1(block, attrs);\n      append$1(block, br);\n      insertElement(root, block, forward);\n      return rangeBefore(br);\n    };\n    var insertEmptyLine = function (root, rootBlockName, attrs, forward) {\n      if (rootBlockName === '') {\n        return insertBr(root, forward);\n      } else {\n        return insertBlock(root, forward, rootBlockName, attrs);\n      }\n    };\n    var getClosestTargetBlock = function (pos, root) {\n      var isRoot = curry(eq, root);\n      return closest$3(SugarElement.fromDom(pos.container()), isBlock$2, isRoot).filter(isTarget);\n    };\n    var isAtFirstOrLastLine = function (root, forward, pos) {\n      return forward ? isAtLastLine(root.dom, pos) : isAtFirstLine(root.dom, pos);\n    };\n    var moveCaretToNewEmptyLine = function (editor, forward) {\n      var root = SugarElement.fromDom(editor.getBody());\n      var pos = CaretPosition.fromRangeStart(editor.selection.getRng());\n      var rootBlock = getForcedRootBlock(editor);\n      var rootBlockAttrs = getForcedRootBlockAttrs(editor);\n      return getClosestTargetBlock(pos, root).exists(function () {\n        if (isAtFirstOrLastLine(root, forward, pos)) {\n          var rng = insertEmptyLine(root, rootBlock, rootBlockAttrs, forward);\n          editor.selection.setRng(rng);\n          return true;\n        } else {\n          return false;\n        }\n      });\n    };\n    var moveV$2 = function (editor, forward) {\n      if (editor.selection.isCollapsed()) {\n        return moveCaretToNewEmptyLine(editor, forward);\n      } else {\n        return false;\n      }\n    };\n\n    var defaultPatterns = function (patterns) {\n      return map$3(patterns, function (pattern) {\n        return __assign({\n          shiftKey: false,\n          altKey: false,\n          ctrlKey: false,\n          metaKey: false,\n          keyCode: 0,\n          action: noop\n        }, pattern);\n      });\n    };\n    var matchesEvent = function (pattern, evt) {\n      return evt.keyCode === pattern.keyCode && evt.shiftKey === pattern.shiftKey && evt.altKey === pattern.altKey && evt.ctrlKey === pattern.ctrlKey && evt.metaKey === pattern.metaKey;\n    };\n    var match$1 = function (patterns, evt) {\n      return bind(defaultPatterns(patterns), function (pattern) {\n        return matchesEvent(pattern, evt) ? [pattern] : [];\n      });\n    };\n    var action = function (f) {\n      var x = [];\n      for (var _i = 1; _i < arguments.length; _i++) {\n        x[_i - 1] = arguments[_i];\n      }\n      return function () {\n        return f.apply(null, x);\n      };\n    };\n    var execute = function (patterns, evt) {\n      return find$3(match$1(patterns, evt), function (pattern) {\n        return pattern.action();\n      });\n    };\n\n    var moveH$1 = function (editor, forward) {\n      var direction = forward ? HDirection.Forwards : HDirection.Backwards;\n      var range = editor.selection.getRng();\n      return moveHorizontally(editor, direction, range, isBeforeMedia, isAfterMedia, isMedia$2).exists(function (newRange) {\n        moveToRange(editor, newRange);\n        return true;\n      });\n    };\n    var moveV$1 = function (editor, down) {\n      var direction = down ? 1 : -1;\n      var range = editor.selection.getRng();\n      return moveVertically(editor, direction, range, isBeforeMedia, isAfterMedia, isMedia$2).exists(function (newRange) {\n        moveToRange(editor, newRange);\n        return true;\n      });\n    };\n    var moveToLineEndPoint = function (editor, forward) {\n      var isNearMedia = forward ? isAfterMedia : isBeforeMedia;\n      return moveToLineEndPoint$3(editor, forward, isNearMedia);\n    };\n\n    var deflate = function (rect, delta) {\n      return {\n        left: rect.left - delta,\n        top: rect.top - delta,\n        right: rect.right + delta * 2,\n        bottom: rect.bottom + delta * 2,\n        width: rect.width + delta,\n        height: rect.height + delta\n      };\n    };\n    var getCorners = function (getYAxisValue, tds) {\n      return bind(tds, function (td) {\n        var rect = deflate(clone(td.getBoundingClientRect()), -1);\n        return [\n          {\n            x: rect.left,\n            y: getYAxisValue(rect),\n            cell: td\n          },\n          {\n            x: rect.right,\n            y: getYAxisValue(rect),\n            cell: td\n          }\n        ];\n      });\n    };\n    var findClosestCorner = function (corners, x, y) {\n      return foldl(corners, function (acc, newCorner) {\n        return acc.fold(function () {\n          return Optional.some(newCorner);\n        }, function (oldCorner) {\n          var oldDist = Math.sqrt(Math.abs(oldCorner.x - x) + Math.abs(oldCorner.y - y));\n          var newDist = Math.sqrt(Math.abs(newCorner.x - x) + Math.abs(newCorner.y - y));\n          return Optional.some(newDist < oldDist ? newCorner : oldCorner);\n        });\n      }, Optional.none());\n    };\n    var getClosestCell = function (getYAxisValue, isTargetCorner, table, x, y) {\n      var cells = descendants(SugarElement.fromDom(table), 'td,th,caption').map(function (e) {\n        return e.dom;\n      });\n      var corners = filter$4(getCorners(getYAxisValue, cells), function (corner) {\n        return isTargetCorner(corner, y);\n      });\n      return findClosestCorner(corners, x, y).map(function (corner) {\n        return corner.cell;\n      });\n    };\n    var getBottomValue = function (rect) {\n      return rect.bottom;\n    };\n    var getTopValue = function (rect) {\n      return rect.top;\n    };\n    var isAbove = function (corner, y) {\n      return corner.y < y;\n    };\n    var isBelow = function (corner, y) {\n      return corner.y > y;\n    };\n    var getClosestCellAbove = curry(getClosestCell, getBottomValue, isAbove);\n    var getClosestCellBelow = curry(getClosestCell, getTopValue, isBelow);\n    var findClosestPositionInAboveCell = function (table, pos) {\n      return head(pos.getClientRects()).bind(function (rect) {\n        return getClosestCellAbove(table, rect.left, rect.top);\n      }).bind(function (cell) {\n        return findClosestHorizontalPosition(getLastLinePositions(cell), pos);\n      });\n    };\n    var findClosestPositionInBelowCell = function (table, pos) {\n      return last$2(pos.getClientRects()).bind(function (rect) {\n        return getClosestCellBelow(table, rect.left, rect.top);\n      }).bind(function (cell) {\n        return findClosestHorizontalPosition(getFirstLinePositions(cell), pos);\n      });\n    };\n\n    var hasNextBreak = function (getPositionsUntil, scope, lineInfo) {\n      return lineInfo.breakAt.exists(function (breakPos) {\n        return getPositionsUntil(scope, breakPos).breakAt.isSome();\n      });\n    };\n    var startsWithWrapBreak = function (lineInfo) {\n      return lineInfo.breakType === BreakType.Wrap && lineInfo.positions.length === 0;\n    };\n    var startsWithBrBreak = function (lineInfo) {\n      return lineInfo.breakType === BreakType.Br && lineInfo.positions.length === 1;\n    };\n    var isAtTableCellLine = function (getPositionsUntil, scope, pos) {\n      var lineInfo = getPositionsUntil(scope, pos);\n      if (startsWithWrapBreak(lineInfo) || !isBr$5(pos.getNode()) && startsWithBrBreak(lineInfo)) {\n        return !hasNextBreak(getPositionsUntil, scope, lineInfo);\n      } else {\n        return lineInfo.breakAt.isNone();\n      }\n    };\n    var isAtFirstTableCellLine = curry(isAtTableCellLine, getPositionsUntilPreviousLine);\n    var isAtLastTableCellLine = curry(isAtTableCellLine, getPositionsUntilNextLine);\n    var isCaretAtStartOrEndOfTable = function (forward, rng, table) {\n      var caretPos = CaretPosition.fromRangeStart(rng);\n      return positionIn(!forward, table).exists(function (pos) {\n        return pos.isEqual(caretPos);\n      });\n    };\n    var navigateHorizontally = function (editor, forward, table, _td) {\n      var rng = editor.selection.getRng();\n      var direction = forward ? 1 : -1;\n      if (isFakeCaretTableBrowser() && isCaretAtStartOrEndOfTable(forward, rng, table)) {\n        showCaret(direction, editor, table, !forward, false).each(function (newRng) {\n          moveToRange(editor, newRng);\n        });\n        return true;\n      }\n      return false;\n    };\n    var getClosestAbovePosition = function (root, table, start) {\n      return findClosestPositionInAboveCell(table, start).orThunk(function () {\n        return head(start.getClientRects()).bind(function (rect) {\n          return findClosestHorizontalPositionFromPoint(getPositionsAbove(root, CaretPosition.before(table)), rect.left);\n        });\n      }).getOr(CaretPosition.before(table));\n    };\n    var getClosestBelowPosition = function (root, table, start) {\n      return findClosestPositionInBelowCell(table, start).orThunk(function () {\n        return head(start.getClientRects()).bind(function (rect) {\n          return findClosestHorizontalPositionFromPoint(getPositionsBelow(root, CaretPosition.after(table)), rect.left);\n        });\n      }).getOr(CaretPosition.after(table));\n    };\n    var getTable = function (previous, pos) {\n      var node = pos.getNode(previous);\n      return isElement$5(node) && node.nodeName === 'TABLE' ? Optional.some(node) : Optional.none();\n    };\n    var renderBlock = function (down, editor, table, pos) {\n      var forcedRootBlock = getForcedRootBlock(editor);\n      if (forcedRootBlock) {\n        editor.undoManager.transact(function () {\n          var element = SugarElement.fromTag(forcedRootBlock);\n          setAll$1(element, getForcedRootBlockAttrs(editor));\n          append$1(element, SugarElement.fromTag('br'));\n          if (down) {\n            after$3(SugarElement.fromDom(table), element);\n          } else {\n            before$4(SugarElement.fromDom(table), element);\n          }\n          var rng = editor.dom.createRng();\n          rng.setStart(element.dom, 0);\n          rng.setEnd(element.dom, 0);\n          moveToRange(editor, rng);\n        });\n      } else {\n        moveToRange(editor, pos.toRange());\n      }\n    };\n    var moveCaret = function (editor, down, pos) {\n      var table = down ? getTable(true, pos) : getTable(false, pos);\n      var last = down === false;\n      table.fold(function () {\n        return moveToRange(editor, pos.toRange());\n      }, function (table) {\n        return positionIn(last, editor.getBody()).filter(function (lastPos) {\n          return lastPos.isEqual(pos);\n        }).fold(function () {\n          return moveToRange(editor, pos.toRange());\n        }, function (_) {\n          return renderBlock(down, editor, table, pos);\n        });\n      });\n    };\n    var navigateVertically = function (editor, down, table, td) {\n      var rng = editor.selection.getRng();\n      var pos = CaretPosition.fromRangeStart(rng);\n      var root = editor.getBody();\n      if (!down && isAtFirstTableCellLine(td, pos)) {\n        var newPos = getClosestAbovePosition(root, table, pos);\n        moveCaret(editor, down, newPos);\n        return true;\n      } else if (down && isAtLastTableCellLine(td, pos)) {\n        var newPos = getClosestBelowPosition(root, table, pos);\n        moveCaret(editor, down, newPos);\n        return true;\n      } else {\n        return false;\n      }\n    };\n    var move$1 = function (editor, forward, mover) {\n      return Optional.from(editor.dom.getParent(editor.selection.getNode(), 'td,th')).bind(function (td) {\n        return Optional.from(editor.dom.getParent(td, 'table')).map(function (table) {\n          return mover(editor, forward, table, td);\n        });\n      }).getOr(false);\n    };\n    var moveH = function (editor, forward) {\n      return move$1(editor, forward, navigateHorizontally);\n    };\n    var moveV = function (editor, forward) {\n      return move$1(editor, forward, navigateVertically);\n    };\n\n    var executeKeydownOverride$3 = function (editor, caret, evt) {\n      var os = detect().os;\n      execute([\n        {\n          keyCode: VK.RIGHT,\n          action: action(moveH$2, editor, true)\n        },\n        {\n          keyCode: VK.LEFT,\n          action: action(moveH$2, editor, false)\n        },\n        {\n          keyCode: VK.UP,\n          action: action(moveV$3, editor, false)\n        },\n        {\n          keyCode: VK.DOWN,\n          action: action(moveV$3, editor, true)\n        },\n        {\n          keyCode: VK.RIGHT,\n          action: action(moveH, editor, true)\n        },\n        {\n          keyCode: VK.LEFT,\n          action: action(moveH, editor, false)\n        },\n        {\n          keyCode: VK.UP,\n          action: action(moveV, editor, false)\n        },\n        {\n          keyCode: VK.DOWN,\n          action: action(moveV, editor, true)\n        },\n        {\n          keyCode: VK.RIGHT,\n          action: action(moveH$1, editor, true)\n        },\n        {\n          keyCode: VK.LEFT,\n          action: action(moveH$1, editor, false)\n        },\n        {\n          keyCode: VK.UP,\n          action: action(moveV$1, editor, false)\n        },\n        {\n          keyCode: VK.DOWN,\n          action: action(moveV$1, editor, true)\n        },\n        {\n          keyCode: VK.RIGHT,\n          action: action(move$2, editor, caret, true)\n        },\n        {\n          keyCode: VK.LEFT,\n          action: action(move$2, editor, caret, false)\n        },\n        {\n          keyCode: VK.RIGHT,\n          ctrlKey: !os.isOSX(),\n          altKey: os.isOSX(),\n          action: action(moveNextWord, editor, caret)\n        },\n        {\n          keyCode: VK.LEFT,\n          ctrlKey: !os.isOSX(),\n          altKey: os.isOSX(),\n          action: action(movePrevWord, editor, caret)\n        },\n        {\n          keyCode: VK.UP,\n          action: action(moveV$2, editor, false)\n        },\n        {\n          keyCode: VK.DOWN,\n          action: action(moveV$2, editor, true)\n        }\n      ], evt).each(function (_) {\n        evt.preventDefault();\n      });\n    };\n    var setup$b = function (editor, caret) {\n      editor.on('keydown', function (evt) {\n        if (evt.isDefaultPrevented() === false) {\n          executeKeydownOverride$3(editor, caret, evt);\n        }\n      });\n    };\n\n    var executeKeydownOverride$2 = function (editor, caret, evt) {\n      execute([\n        {\n          keyCode: VK.BACKSPACE,\n          action: action(backspaceDelete, editor, false)\n        },\n        {\n          keyCode: VK.BACKSPACE,\n          action: action(backspaceDelete$5, editor, false)\n        },\n        {\n          keyCode: VK.DELETE,\n          action: action(backspaceDelete$5, editor, true)\n        },\n        {\n          keyCode: VK.BACKSPACE,\n          action: action(backspaceDelete$6, editor, false)\n        },\n        {\n          keyCode: VK.DELETE,\n          action: action(backspaceDelete$6, editor, true)\n        },\n        {\n          keyCode: VK.BACKSPACE,\n          action: action(backspaceDelete$3, editor, caret, false)\n        },\n        {\n          keyCode: VK.DELETE,\n          action: action(backspaceDelete$3, editor, caret, true)\n        },\n        {\n          keyCode: VK.BACKSPACE,\n          action: action(backspaceDelete$9, editor, false)\n        },\n        {\n          keyCode: VK.DELETE,\n          action: action(backspaceDelete$9, editor, true)\n        },\n        {\n          keyCode: VK.BACKSPACE,\n          action: action(backspaceDelete$4, editor, false)\n        },\n        {\n          keyCode: VK.DELETE,\n          action: action(backspaceDelete$4, editor, true)\n        },\n        {\n          keyCode: VK.BACKSPACE,\n          action: action(backspaceDelete$1, editor, false)\n        },\n        {\n          keyCode: VK.DELETE,\n          action: action(backspaceDelete$1, editor, true)\n        },\n        {\n          keyCode: VK.BACKSPACE,\n          action: action(backspaceDelete$7, editor, false)\n        },\n        {\n          keyCode: VK.DELETE,\n          action: action(backspaceDelete$7, editor, true)\n        },\n        {\n          keyCode: VK.BACKSPACE,\n          action: action(backspaceDelete$8, editor, false)\n        },\n        {\n          keyCode: VK.DELETE,\n          action: action(backspaceDelete$8, editor, true)\n        },\n        {\n          keyCode: VK.BACKSPACE,\n          action: action(backspaceDelete$2, editor, false)\n        },\n        {\n          keyCode: VK.DELETE,\n          action: action(backspaceDelete$2, editor, true)\n        }\n      ], evt).each(function (_) {\n        evt.preventDefault();\n      });\n    };\n    var executeKeyupOverride = function (editor, evt) {\n      execute([\n        {\n          keyCode: VK.BACKSPACE,\n          action: action(paddEmptyElement, editor)\n        },\n        {\n          keyCode: VK.DELETE,\n          action: action(paddEmptyElement, editor)\n        }\n      ], evt);\n    };\n    var setup$a = function (editor, caret) {\n      editor.on('keydown', function (evt) {\n        if (evt.isDefaultPrevented() === false) {\n          executeKeydownOverride$2(editor, caret, evt);\n        }\n      });\n      editor.on('keyup', function (evt) {\n        if (evt.isDefaultPrevented() === false) {\n          executeKeyupOverride(editor, evt);\n        }\n      });\n    };\n\n    var firstNonWhiteSpaceNodeSibling = function (node) {\n      while (node) {\n        if (node.nodeType === 1 || node.nodeType === 3 && node.data && /[\\r\\n\\s]/.test(node.data)) {\n          return node;\n        }\n        node = node.nextSibling;\n      }\n    };\n    var moveToCaretPosition = function (editor, root) {\n      var node, lastNode = root;\n      var dom = editor.dom;\n      var moveCaretBeforeOnEnterElementsMap = editor.schema.getMoveCaretBeforeOnEnterElements();\n      if (!root) {\n        return;\n      }\n      if (/^(LI|DT|DD)$/.test(root.nodeName)) {\n        var firstChild = firstNonWhiteSpaceNodeSibling(root.firstChild);\n        if (firstChild && /^(UL|OL|DL)$/.test(firstChild.nodeName)) {\n          root.insertBefore(dom.doc.createTextNode(nbsp), root.firstChild);\n        }\n      }\n      var rng = dom.createRng();\n      root.normalize();\n      if (root.hasChildNodes()) {\n        var walker = new DomTreeWalker(root, root);\n        while (node = walker.current()) {\n          if (isText$7(node)) {\n            rng.setStart(node, 0);\n            rng.setEnd(node, 0);\n            break;\n          }\n          if (moveCaretBeforeOnEnterElementsMap[node.nodeName.toLowerCase()]) {\n            rng.setStartBefore(node);\n            rng.setEndBefore(node);\n            break;\n          }\n          lastNode = node;\n          node = walker.next();\n        }\n        if (!node) {\n          rng.setStart(lastNode, 0);\n          rng.setEnd(lastNode, 0);\n        }\n      } else {\n        if (isBr$5(root)) {\n          if (root.nextSibling && dom.isBlock(root.nextSibling)) {\n            rng.setStartBefore(root);\n            rng.setEndBefore(root);\n          } else {\n            rng.setStartAfter(root);\n            rng.setEndAfter(root);\n          }\n        } else {\n          rng.setStart(root, 0);\n          rng.setEnd(root, 0);\n        }\n      }\n      editor.selection.setRng(rng);\n      scrollRangeIntoView(editor, rng);\n    };\n    var getEditableRoot$1 = function (dom, node) {\n      var root = dom.getRoot();\n      var parent, editableRoot;\n      parent = node;\n      while (parent !== root && dom.getContentEditable(parent) !== 'false') {\n        if (dom.getContentEditable(parent) === 'true') {\n          editableRoot = parent;\n        }\n        parent = parent.parentNode;\n      }\n      return parent !== root ? editableRoot : root;\n    };\n    var getParentBlock = function (editor) {\n      return Optional.from(editor.dom.getParent(editor.selection.getStart(true), editor.dom.isBlock));\n    };\n    var getParentBlockName = function (editor) {\n      return getParentBlock(editor).fold(constant(''), function (parentBlock) {\n        return parentBlock.nodeName.toUpperCase();\n      });\n    };\n    var isListItemParentBlock = function (editor) {\n      return getParentBlock(editor).filter(function (elm) {\n        return isListItem(SugarElement.fromDom(elm));\n      }).isSome();\n    };\n\n    var hasFirstChild = function (elm, name) {\n      return elm.firstChild && elm.firstChild.nodeName === name;\n    };\n    var isFirstChild = function (elm) {\n      var _a;\n      return ((_a = elm.parentNode) === null || _a === void 0 ? void 0 : _a.firstChild) === elm;\n    };\n    var hasParent = function (elm, parentName) {\n      return elm && elm.parentNode && elm.parentNode.nodeName === parentName;\n    };\n    var isListBlock = function (elm) {\n      return elm && /^(OL|UL|LI)$/.test(elm.nodeName);\n    };\n    var isNestedList = function (elm) {\n      return isListBlock(elm) && isListBlock(elm.parentNode);\n    };\n    var getContainerBlock = function (containerBlock) {\n      var containerBlockParent = containerBlock.parentNode;\n      if (/^(LI|DT|DD)$/.test(containerBlockParent.nodeName)) {\n        return containerBlockParent;\n      }\n      return containerBlock;\n    };\n    var isFirstOrLastLi = function (containerBlock, parentBlock, first) {\n      var node = containerBlock[first ? 'firstChild' : 'lastChild'];\n      while (node) {\n        if (isElement$5(node)) {\n          break;\n        }\n        node = node[first ? 'nextSibling' : 'previousSibling'];\n      }\n      return node === parentBlock;\n    };\n    var insert$3 = function (editor, createNewBlock, containerBlock, parentBlock, newBlockName) {\n      var dom = editor.dom;\n      var rng = editor.selection.getRng();\n      if (containerBlock === editor.getBody()) {\n        return;\n      }\n      if (isNestedList(containerBlock)) {\n        newBlockName = 'LI';\n      }\n      var newBlock = newBlockName ? createNewBlock(newBlockName) : dom.create('BR');\n      if (isFirstOrLastLi(containerBlock, parentBlock, true) && isFirstOrLastLi(containerBlock, parentBlock, false)) {\n        if (hasParent(containerBlock, 'LI')) {\n          var containerBlockParent = getContainerBlock(containerBlock);\n          dom.insertAfter(newBlock, containerBlockParent);\n          if (isFirstChild(containerBlock)) {\n            dom.remove(containerBlockParent);\n          } else {\n            dom.remove(containerBlock);\n          }\n        } else {\n          dom.replace(newBlock, containerBlock);\n        }\n      } else if (isFirstOrLastLi(containerBlock, parentBlock, true)) {\n        if (hasParent(containerBlock, 'LI')) {\n          dom.insertAfter(newBlock, getContainerBlock(containerBlock));\n          newBlock.appendChild(dom.doc.createTextNode(' '));\n          newBlock.appendChild(containerBlock);\n        } else {\n          containerBlock.parentNode.insertBefore(newBlock, containerBlock);\n        }\n        dom.remove(parentBlock);\n      } else if (isFirstOrLastLi(containerBlock, parentBlock, false)) {\n        dom.insertAfter(newBlock, getContainerBlock(containerBlock));\n        dom.remove(parentBlock);\n      } else {\n        containerBlock = getContainerBlock(containerBlock);\n        var tmpRng = rng.cloneRange();\n        tmpRng.setStartAfter(parentBlock);\n        tmpRng.setEndAfter(containerBlock);\n        var fragment = tmpRng.extractContents();\n        if (newBlockName === 'LI' && hasFirstChild(fragment, 'LI')) {\n          newBlock = fragment.firstChild;\n          dom.insertAfter(fragment, containerBlock);\n        } else {\n          dom.insertAfter(fragment, containerBlock);\n          dom.insertAfter(newBlock, containerBlock);\n        }\n        dom.remove(parentBlock);\n      }\n      moveToCaretPosition(editor, newBlock);\n    };\n\n    var trimZwsp = function (fragment) {\n      each$k(descendants$1(SugarElement.fromDom(fragment), isText$8), function (text) {\n        var rawNode = text.dom;\n        rawNode.nodeValue = trim$3(rawNode.nodeValue);\n      });\n    };\n    var isEmptyAnchor = function (dom, elm) {\n      return elm && elm.nodeName === 'A' && dom.isEmpty(elm);\n    };\n    var isTableCell = function (node) {\n      return node && /^(TD|TH|CAPTION)$/.test(node.nodeName);\n    };\n    var emptyBlock = function (elm) {\n      elm.innerHTML = '<br data-mce-bogus=\"1\">';\n    };\n    var containerAndSiblingName = function (container, nodeName) {\n      return container.nodeName === nodeName || container.previousSibling && container.previousSibling.nodeName === nodeName;\n    };\n    var canSplitBlock = function (dom, node) {\n      return node && dom.isBlock(node) && !/^(TD|TH|CAPTION|FORM)$/.test(node.nodeName) && !/^(fixed|absolute)/i.test(node.style.position) && dom.getContentEditable(node) !== 'true';\n    };\n    var trimInlineElementsOnLeftSideOfBlock = function (dom, nonEmptyElementsMap, block) {\n      var node = block;\n      var firstChilds = [];\n      var i;\n      if (!node) {\n        return;\n      }\n      while (node = node.firstChild) {\n        if (dom.isBlock(node)) {\n          return;\n        }\n        if (isElement$5(node) && !nonEmptyElementsMap[node.nodeName.toLowerCase()]) {\n          firstChilds.push(node);\n        }\n      }\n      i = firstChilds.length;\n      while (i--) {\n        node = firstChilds[i];\n        if (!node.hasChildNodes() || node.firstChild === node.lastChild && node.firstChild.nodeValue === '') {\n          dom.remove(node);\n        } else {\n          if (isEmptyAnchor(dom, node)) {\n            dom.remove(node);\n          }\n        }\n      }\n    };\n    var normalizeZwspOffset = function (start, container, offset) {\n      if (isText$7(container) === false) {\n        return offset;\n      } else if (start) {\n        return offset === 1 && container.data.charAt(offset - 1) === ZWSP$1 ? 0 : offset;\n      } else {\n        return offset === container.data.length - 1 && container.data.charAt(offset) === ZWSP$1 ? container.data.length : offset;\n      }\n    };\n    var includeZwspInRange = function (rng) {\n      var newRng = rng.cloneRange();\n      newRng.setStart(rng.startContainer, normalizeZwspOffset(true, rng.startContainer, rng.startOffset));\n      newRng.setEnd(rng.endContainer, normalizeZwspOffset(false, rng.endContainer, rng.endOffset));\n      return newRng;\n    };\n    var trimLeadingLineBreaks = function (node) {\n      do {\n        if (isText$7(node)) {\n          node.nodeValue = node.nodeValue.replace(/^[\\r\\n]+/, '');\n        }\n        node = node.firstChild;\n      } while (node);\n    };\n    var getEditableRoot = function (dom, node) {\n      var root = dom.getRoot();\n      var parent, editableRoot;\n      parent = node;\n      while (parent !== root && dom.getContentEditable(parent) !== 'false') {\n        if (dom.getContentEditable(parent) === 'true') {\n          editableRoot = parent;\n        }\n        parent = parent.parentNode;\n      }\n      return parent !== root ? editableRoot : root;\n    };\n    var applyAttributes = function (editor, node, forcedRootBlockAttrs) {\n      var dom = editor.dom;\n      Optional.from(forcedRootBlockAttrs.style).map(dom.parseStyle).each(function (attrStyles) {\n        var currentStyles = getAllRaw(SugarElement.fromDom(node));\n        var newStyles = __assign(__assign({}, currentStyles), attrStyles);\n        dom.setStyles(node, newStyles);\n      });\n      var attrClassesOpt = Optional.from(forcedRootBlockAttrs.class).map(function (attrClasses) {\n        return attrClasses.split(/\\s+/);\n      });\n      var currentClassesOpt = Optional.from(node.className).map(function (currentClasses) {\n        return filter$4(currentClasses.split(/\\s+/), function (clazz) {\n          return clazz !== '';\n        });\n      });\n      lift2(attrClassesOpt, currentClassesOpt, function (attrClasses, currentClasses) {\n        var filteredClasses = filter$4(currentClasses, function (clazz) {\n          return !contains$3(attrClasses, clazz);\n        });\n        var newClasses = __spreadArray(__spreadArray([], attrClasses, true), filteredClasses, true);\n        dom.setAttrib(node, 'class', newClasses.join(' '));\n      });\n      var appliedAttrs = [\n        'style',\n        'class'\n      ];\n      var remainingAttrs = filter$3(forcedRootBlockAttrs, function (_, attrs) {\n        return !contains$3(appliedAttrs, attrs);\n      });\n      dom.setAttribs(node, remainingAttrs);\n    };\n    var setForcedBlockAttrs = function (editor, node) {\n      var forcedRootBlockName = getForcedRootBlock(editor);\n      if (forcedRootBlockName && forcedRootBlockName.toLowerCase() === node.tagName.toLowerCase()) {\n        var forcedRootBlockAttrs = getForcedRootBlockAttrs(editor);\n        applyAttributes(editor, node, forcedRootBlockAttrs);\n      }\n    };\n    var wrapSelfAndSiblingsInDefaultBlock = function (editor, newBlockName, rng, container, offset) {\n      var newBlock, parentBlock, startNode, node, next, rootBlockName;\n      var blockName = newBlockName || 'P';\n      var dom = editor.dom, editableRoot = getEditableRoot(dom, container);\n      parentBlock = dom.getParent(container, dom.isBlock);\n      if (!parentBlock || !canSplitBlock(dom, parentBlock)) {\n        parentBlock = parentBlock || editableRoot;\n        if (parentBlock === editor.getBody() || isTableCell(parentBlock)) {\n          rootBlockName = parentBlock.nodeName.toLowerCase();\n        } else {\n          rootBlockName = parentBlock.parentNode.nodeName.toLowerCase();\n        }\n        if (!parentBlock.hasChildNodes()) {\n          newBlock = dom.create(blockName);\n          setForcedBlockAttrs(editor, newBlock);\n          parentBlock.appendChild(newBlock);\n          rng.setStart(newBlock, 0);\n          rng.setEnd(newBlock, 0);\n          return newBlock;\n        }\n        node = container;\n        while (node.parentNode !== parentBlock) {\n          node = node.parentNode;\n        }\n        while (node && !dom.isBlock(node)) {\n          startNode = node;\n          node = node.previousSibling;\n        }\n        if (startNode && editor.schema.isValidChild(rootBlockName, blockName.toLowerCase())) {\n          newBlock = dom.create(blockName);\n          setForcedBlockAttrs(editor, newBlock);\n          startNode.parentNode.insertBefore(newBlock, startNode);\n          node = startNode;\n          while (node && !dom.isBlock(node)) {\n            next = node.nextSibling;\n            newBlock.appendChild(node);\n            node = next;\n          }\n          rng.setStart(container, offset);\n          rng.setEnd(container, offset);\n        }\n      }\n      return container;\n    };\n    var addBrToBlockIfNeeded = function (dom, block) {\n      block.normalize();\n      var lastChild = block.lastChild;\n      if (!lastChild || /^(left|right)$/gi.test(dom.getStyle(lastChild, 'float', true))) {\n        dom.add(block, 'br');\n      }\n    };\n    var insert$2 = function (editor, evt) {\n      var tmpRng, container, offset, parentBlock;\n      var newBlock, fragment, containerBlock, parentBlockName, newBlockName, isAfterLastNodeInContainer;\n      var dom = editor.dom;\n      var schema = editor.schema, nonEmptyElementsMap = schema.getNonEmptyElements();\n      var rng = editor.selection.getRng();\n      var createNewBlock = function (name) {\n        var node = container, block, clonedNode, caretNode;\n        var textInlineElements = schema.getTextInlineElements();\n        if (name || parentBlockName === 'TABLE' || parentBlockName === 'HR') {\n          block = dom.create(name || newBlockName);\n        } else {\n          block = parentBlock.cloneNode(false);\n        }\n        caretNode = block;\n        if (shouldKeepStyles(editor) === false) {\n          dom.setAttrib(block, 'style', null);\n          dom.setAttrib(block, 'class', null);\n        } else {\n          do {\n            if (textInlineElements[node.nodeName]) {\n              if (isCaretNode(node) || isBookmarkNode$1(node)) {\n                continue;\n              }\n              clonedNode = node.cloneNode(false);\n              dom.setAttrib(clonedNode, 'id', '');\n              if (block.hasChildNodes()) {\n                clonedNode.appendChild(block.firstChild);\n                block.appendChild(clonedNode);\n              } else {\n                caretNode = clonedNode;\n                block.appendChild(clonedNode);\n              }\n            }\n          } while ((node = node.parentNode) && node !== editableRoot);\n        }\n        setForcedBlockAttrs(editor, block);\n        emptyBlock(caretNode);\n        return block;\n      };\n      var isCaretAtStartOrEndOfBlock = function (start) {\n        var node, name;\n        var normalizedOffset = normalizeZwspOffset(start, container, offset);\n        if (isText$7(container) && (start ? normalizedOffset > 0 : normalizedOffset < container.nodeValue.length)) {\n          return false;\n        }\n        if (container.parentNode === parentBlock && isAfterLastNodeInContainer && !start) {\n          return true;\n        }\n        if (start && isElement$5(container) && container === parentBlock.firstChild) {\n          return true;\n        }\n        if (containerAndSiblingName(container, 'TABLE') || containerAndSiblingName(container, 'HR')) {\n          return isAfterLastNodeInContainer && !start || !isAfterLastNodeInContainer && start;\n        }\n        var walker = new DomTreeWalker(container, parentBlock);\n        if (isText$7(container)) {\n          if (start && normalizedOffset === 0) {\n            walker.prev();\n          } else if (!start && normalizedOffset === container.nodeValue.length) {\n            walker.next();\n          }\n        }\n        while (node = walker.current()) {\n          if (isElement$5(node)) {\n            if (!node.getAttribute('data-mce-bogus')) {\n              name = node.nodeName.toLowerCase();\n              if (nonEmptyElementsMap[name] && name !== 'br') {\n                return false;\n              }\n            }\n          } else if (isText$7(node) && !isWhitespaceText(node.nodeValue)) {\n            return false;\n          }\n          if (start) {\n            walker.prev();\n          } else {\n            walker.next();\n          }\n        }\n        return true;\n      };\n      var insertNewBlockAfter = function () {\n        if (/^(H[1-6]|PRE|FIGURE)$/.test(parentBlockName) && containerBlockName !== 'HGROUP') {\n          newBlock = createNewBlock(newBlockName);\n        } else {\n          newBlock = createNewBlock();\n        }\n        if (shouldEndContainerOnEmptyBlock(editor) && canSplitBlock(dom, containerBlock) && dom.isEmpty(parentBlock)) {\n          newBlock = dom.split(containerBlock, parentBlock);\n        } else {\n          dom.insertAfter(newBlock, parentBlock);\n        }\n        moveToCaretPosition(editor, newBlock);\n      };\n      normalize$2(dom, rng).each(function (normRng) {\n        rng.setStart(normRng.startContainer, normRng.startOffset);\n        rng.setEnd(normRng.endContainer, normRng.endOffset);\n      });\n      container = rng.startContainer;\n      offset = rng.startOffset;\n      newBlockName = getForcedRootBlock(editor);\n      var shiftKey = !!(evt && evt.shiftKey);\n      var ctrlKey = !!(evt && evt.ctrlKey);\n      if (isElement$5(container) && container.hasChildNodes()) {\n        isAfterLastNodeInContainer = offset > container.childNodes.length - 1;\n        container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container;\n        if (isAfterLastNodeInContainer && isText$7(container)) {\n          offset = container.nodeValue.length;\n        } else {\n          offset = 0;\n        }\n      }\n      var editableRoot = getEditableRoot(dom, container);\n      if (!editableRoot) {\n        return;\n      }\n      if (newBlockName && !shiftKey || !newBlockName && shiftKey) {\n        container = wrapSelfAndSiblingsInDefaultBlock(editor, newBlockName, rng, container, offset);\n      }\n      parentBlock = dom.getParent(container, dom.isBlock);\n      containerBlock = parentBlock ? dom.getParent(parentBlock.parentNode, dom.isBlock) : null;\n      parentBlockName = parentBlock ? parentBlock.nodeName.toUpperCase() : '';\n      var containerBlockName = containerBlock ? containerBlock.nodeName.toUpperCase() : '';\n      if (containerBlockName === 'LI' && !ctrlKey) {\n        parentBlock = containerBlock;\n        containerBlock = containerBlock.parentNode;\n        parentBlockName = containerBlockName;\n      }\n      if (/^(LI|DT|DD)$/.test(parentBlockName)) {\n        if (dom.isEmpty(parentBlock)) {\n          insert$3(editor, createNewBlock, containerBlock, parentBlock, newBlockName);\n          return;\n        }\n      }\n      if (newBlockName && parentBlock === editor.getBody()) {\n        return;\n      }\n      newBlockName = newBlockName || 'P';\n      if (isCaretContainerBlock$1(parentBlock)) {\n        newBlock = showCaretContainerBlock(parentBlock);\n        if (dom.isEmpty(parentBlock)) {\n          emptyBlock(parentBlock);\n        }\n        setForcedBlockAttrs(editor, newBlock);\n        moveToCaretPosition(editor, newBlock);\n      } else if (isCaretAtStartOrEndOfBlock()) {\n        insertNewBlockAfter();\n      } else if (isCaretAtStartOrEndOfBlock(true)) {\n        newBlock = parentBlock.parentNode.insertBefore(createNewBlock(), parentBlock);\n        moveToCaretPosition(editor, containerAndSiblingName(parentBlock, 'HR') ? newBlock : parentBlock);\n      } else {\n        tmpRng = includeZwspInRange(rng).cloneRange();\n        tmpRng.setEndAfter(parentBlock);\n        fragment = tmpRng.extractContents();\n        trimZwsp(fragment);\n        trimLeadingLineBreaks(fragment);\n        newBlock = fragment.firstChild;\n        dom.insertAfter(fragment, parentBlock);\n        trimInlineElementsOnLeftSideOfBlock(dom, nonEmptyElementsMap, newBlock);\n        addBrToBlockIfNeeded(dom, parentBlock);\n        if (dom.isEmpty(parentBlock)) {\n          emptyBlock(parentBlock);\n        }\n        newBlock.normalize();\n        if (dom.isEmpty(newBlock)) {\n          dom.remove(newBlock);\n          insertNewBlockAfter();\n        } else {\n          setForcedBlockAttrs(editor, newBlock);\n          moveToCaretPosition(editor, newBlock);\n        }\n      }\n      dom.setAttrib(newBlock, 'id', '');\n      editor.fire('NewBlock', { newBlock: newBlock });\n    };\n\n    var hasRightSideContent = function (schema, container, parentBlock) {\n      var walker = new DomTreeWalker(container, parentBlock);\n      var node;\n      var nonEmptyElementsMap = schema.getNonEmptyElements();\n      while (node = walker.next()) {\n        if (nonEmptyElementsMap[node.nodeName.toLowerCase()] || node.length > 0) {\n          return true;\n        }\n      }\n    };\n    var moveSelectionToBr = function (editor, brElm, extraBr) {\n      var rng = editor.dom.createRng();\n      if (!extraBr) {\n        rng.setStartAfter(brElm);\n        rng.setEndAfter(brElm);\n      } else {\n        rng.setStartBefore(brElm);\n        rng.setEndBefore(brElm);\n      }\n      editor.selection.setRng(rng);\n      scrollRangeIntoView(editor, rng);\n    };\n    var insertBrAtCaret = function (editor, evt) {\n      var selection = editor.selection;\n      var dom = editor.dom;\n      var rng = selection.getRng();\n      var brElm;\n      var extraBr;\n      normalize$2(dom, rng).each(function (normRng) {\n        rng.setStart(normRng.startContainer, normRng.startOffset);\n        rng.setEnd(normRng.endContainer, normRng.endOffset);\n      });\n      var offset = rng.startOffset;\n      var container = rng.startContainer;\n      if (container.nodeType === 1 && container.hasChildNodes()) {\n        var isAfterLastNodeInContainer = offset > container.childNodes.length - 1;\n        container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container;\n        if (isAfterLastNodeInContainer && container.nodeType === 3) {\n          offset = container.nodeValue.length;\n        } else {\n          offset = 0;\n        }\n      }\n      var parentBlock = dom.getParent(container, dom.isBlock);\n      var containerBlock = parentBlock ? dom.getParent(parentBlock.parentNode, dom.isBlock) : null;\n      var containerBlockName = containerBlock ? containerBlock.nodeName.toUpperCase() : '';\n      var isControlKey = !!(evt && evt.ctrlKey);\n      if (containerBlockName === 'LI' && !isControlKey) {\n        parentBlock = containerBlock;\n      }\n      if (container && container.nodeType === 3 && offset >= container.nodeValue.length) {\n        if (!hasRightSideContent(editor.schema, container, parentBlock)) {\n          brElm = dom.create('br');\n          rng.insertNode(brElm);\n          rng.setStartAfter(brElm);\n          rng.setEndAfter(brElm);\n          extraBr = true;\n        }\n      }\n      brElm = dom.create('br');\n      rangeInsertNode(dom, rng, brElm);\n      moveSelectionToBr(editor, brElm, extraBr);\n      editor.undoManager.add();\n    };\n    var insertBrBefore = function (editor, inline) {\n      var br = SugarElement.fromTag('br');\n      before$4(SugarElement.fromDom(inline), br);\n      editor.undoManager.add();\n    };\n    var insertBrAfter = function (editor, inline) {\n      if (!hasBrAfter(editor.getBody(), inline)) {\n        after$3(SugarElement.fromDom(inline), SugarElement.fromTag('br'));\n      }\n      var br = SugarElement.fromTag('br');\n      after$3(SugarElement.fromDom(inline), br);\n      moveSelectionToBr(editor, br.dom, false);\n      editor.undoManager.add();\n    };\n    var isBeforeBr = function (pos) {\n      return isBr$5(pos.getNode());\n    };\n    var hasBrAfter = function (rootNode, startNode) {\n      if (isBeforeBr(CaretPosition.after(startNode))) {\n        return true;\n      } else {\n        return nextPosition(rootNode, CaretPosition.after(startNode)).map(function (pos) {\n          return isBr$5(pos.getNode());\n        }).getOr(false);\n      }\n    };\n    var isAnchorLink = function (elm) {\n      return elm && elm.nodeName === 'A' && 'href' in elm;\n    };\n    var isInsideAnchor = function (location) {\n      return location.fold(never, isAnchorLink, isAnchorLink, never);\n    };\n    var readInlineAnchorLocation = function (editor) {\n      var isInlineTarget$1 = curry(isInlineTarget, editor);\n      var position = CaretPosition.fromRangeStart(editor.selection.getRng());\n      return readLocation(isInlineTarget$1, editor.getBody(), position).filter(isInsideAnchor);\n    };\n    var insertBrOutsideAnchor = function (editor, location) {\n      location.fold(noop, curry(insertBrBefore, editor), curry(insertBrAfter, editor), noop);\n    };\n    var insert$1 = function (editor, evt) {\n      var anchorLocation = readInlineAnchorLocation(editor);\n      if (anchorLocation.isSome()) {\n        anchorLocation.each(curry(insertBrOutsideAnchor, editor));\n      } else {\n        insertBrAtCaret(editor, evt);\n      }\n    };\n\n    var matchesSelector = function (editor, selector) {\n      return getParentBlock(editor).filter(function (parentBlock) {\n        return selector.length > 0 && is$2(SugarElement.fromDom(parentBlock), selector);\n      }).isSome();\n    };\n    var shouldInsertBr = function (editor) {\n      return matchesSelector(editor, getBrNewLineSelector(editor));\n    };\n    var shouldBlockNewLine$1 = function (editor) {\n      return matchesSelector(editor, getNoNewLineSelector(editor));\n    };\n\n    var newLineAction = Adt.generate([\n      { br: [] },\n      { block: [] },\n      { none: [] }\n    ]);\n    var shouldBlockNewLine = function (editor, _shiftKey) {\n      return shouldBlockNewLine$1(editor);\n    };\n    var isBrMode = function (requiredState) {\n      return function (editor, _shiftKey) {\n        var brMode = getForcedRootBlock(editor) === '';\n        return brMode === requiredState;\n      };\n    };\n    var inListBlock = function (requiredState) {\n      return function (editor, _shiftKey) {\n        return isListItemParentBlock(editor) === requiredState;\n      };\n    };\n    var inBlock = function (blockName, requiredState) {\n      return function (editor, _shiftKey) {\n        var state = getParentBlockName(editor) === blockName.toUpperCase();\n        return state === requiredState;\n      };\n    };\n    var inPreBlock = function (requiredState) {\n      return inBlock('pre', requiredState);\n    };\n    var inSummaryBlock = function () {\n      return inBlock('summary', true);\n    };\n    var shouldPutBrInPre = function (requiredState) {\n      return function (editor, _shiftKey) {\n        return shouldPutBrInPre$1(editor) === requiredState;\n      };\n    };\n    var inBrContext = function (editor, _shiftKey) {\n      return shouldInsertBr(editor);\n    };\n    var hasShiftKey = function (_editor, shiftKey) {\n      return shiftKey;\n    };\n    var canInsertIntoEditableRoot = function (editor) {\n      var forcedRootBlock = getForcedRootBlock(editor);\n      var rootEditable = getEditableRoot$1(editor.dom, editor.selection.getStart());\n      return rootEditable && editor.schema.isValidChild(rootEditable.nodeName, forcedRootBlock ? forcedRootBlock : 'P');\n    };\n    var match = function (predicates, action) {\n      return function (editor, shiftKey) {\n        var isMatch = foldl(predicates, function (res, p) {\n          return res && p(editor, shiftKey);\n        }, true);\n        return isMatch ? Optional.some(action) : Optional.none();\n      };\n    };\n    var getAction = function (editor, evt) {\n      return evaluateUntil([\n        match([shouldBlockNewLine], newLineAction.none()),\n        match([inSummaryBlock()], newLineAction.br()),\n        match([\n          inPreBlock(true),\n          shouldPutBrInPre(false),\n          hasShiftKey\n        ], newLineAction.br()),\n        match([\n          inPreBlock(true),\n          shouldPutBrInPre(false)\n        ], newLineAction.block()),\n        match([\n          inPreBlock(true),\n          shouldPutBrInPre(true),\n          hasShiftKey\n        ], newLineAction.block()),\n        match([\n          inPreBlock(true),\n          shouldPutBrInPre(true)\n        ], newLineAction.br()),\n        match([\n          inListBlock(true),\n          hasShiftKey\n        ], newLineAction.br()),\n        match([inListBlock(true)], newLineAction.block()),\n        match([\n          isBrMode(true),\n          hasShiftKey,\n          canInsertIntoEditableRoot\n        ], newLineAction.block()),\n        match([isBrMode(true)], newLineAction.br()),\n        match([inBrContext], newLineAction.br()),\n        match([\n          isBrMode(false),\n          hasShiftKey\n        ], newLineAction.br()),\n        match([canInsertIntoEditableRoot], newLineAction.block())\n      ], [\n        editor,\n        !!(evt && evt.shiftKey)\n      ]).getOr(newLineAction.none());\n    };\n\n    var insert = function (editor, evt) {\n      getAction(editor, evt).fold(function () {\n        insert$1(editor, evt);\n      }, function () {\n        insert$2(editor, evt);\n      }, noop);\n    };\n\n    var handleEnterKeyEvent = function (editor, event) {\n      if (event.isDefaultPrevented()) {\n        return;\n      }\n      event.preventDefault();\n      endTypingLevelIgnoreLocks(editor.undoManager);\n      editor.undoManager.transact(function () {\n        if (editor.selection.isCollapsed() === false) {\n          editor.execCommand('Delete');\n        }\n        insert(editor, event);\n      });\n    };\n    var setup$9 = function (editor) {\n      editor.on('keydown', function (event) {\n        if (event.keyCode === VK.ENTER) {\n          handleEnterKeyEvent(editor, event);\n        }\n      });\n    };\n\n    var executeKeydownOverride$1 = function (editor, caret, evt) {\n      execute([\n        {\n          keyCode: VK.END,\n          action: action(moveToLineEndPoint$1, editor, true)\n        },\n        {\n          keyCode: VK.HOME,\n          action: action(moveToLineEndPoint$1, editor, false)\n        },\n        {\n          keyCode: VK.END,\n          action: action(moveToLineEndPoint, editor, true)\n        },\n        {\n          keyCode: VK.HOME,\n          action: action(moveToLineEndPoint, editor, false)\n        },\n        {\n          keyCode: VK.END,\n          action: action(moveToLineEndPoint$2, editor, true, caret)\n        },\n        {\n          keyCode: VK.HOME,\n          action: action(moveToLineEndPoint$2, editor, false, caret)\n        }\n      ], evt).each(function (_) {\n        evt.preventDefault();\n      });\n    };\n    var setup$8 = function (editor, caret) {\n      editor.on('keydown', function (evt) {\n        if (evt.isDefaultPrevented() === false) {\n          executeKeydownOverride$1(editor, caret, evt);\n        }\n      });\n    };\n\n    var browser = detect().browser;\n    var setupIeInput = function (editor) {\n      var keypressThrotter = first(function () {\n        if (!editor.composing) {\n          normalizeNbspsInEditor(editor);\n        }\n      }, 0);\n      if (browser.isIE()) {\n        editor.on('keypress', function (_e) {\n          keypressThrotter.throttle();\n        });\n        editor.on('remove', function (_e) {\n          keypressThrotter.cancel();\n        });\n      }\n    };\n    var setup$7 = function (editor) {\n      setupIeInput(editor);\n      editor.on('input', function (e) {\n        if (e.isComposing === false) {\n          normalizeNbspsInEditor(editor);\n        }\n      });\n    };\n\n    var platform = detect();\n    var executeKeyupAction = function (editor, caret, evt) {\n      execute([\n        {\n          keyCode: VK.PAGE_UP,\n          action: action(moveToLineEndPoint$2, editor, false, caret)\n        },\n        {\n          keyCode: VK.PAGE_DOWN,\n          action: action(moveToLineEndPoint$2, editor, true, caret)\n        }\n      ], evt);\n    };\n    var stopImmediatePropagation = function (e) {\n      return e.stopImmediatePropagation();\n    };\n    var isPageUpDown = function (evt) {\n      return evt.keyCode === VK.PAGE_UP || evt.keyCode === VK.PAGE_DOWN;\n    };\n    var setNodeChangeBlocker = function (blocked, editor, block) {\n      if (block && !blocked.get()) {\n        editor.on('NodeChange', stopImmediatePropagation, true);\n      } else if (!block && blocked.get()) {\n        editor.off('NodeChange', stopImmediatePropagation);\n      }\n      blocked.set(block);\n    };\n    var setup$6 = function (editor, caret) {\n      if (platform.os.isOSX()) {\n        return;\n      }\n      var blocked = Cell(false);\n      editor.on('keydown', function (evt) {\n        if (isPageUpDown(evt)) {\n          setNodeChangeBlocker(blocked, editor, true);\n        }\n      });\n      editor.on('keyup', function (evt) {\n        if (evt.isDefaultPrevented() === false) {\n          executeKeyupAction(editor, caret, evt);\n        }\n        if (isPageUpDown(evt) && blocked.get()) {\n          setNodeChangeBlocker(blocked, editor, false);\n          editor.nodeChanged();\n        }\n      });\n    };\n\n    var insertTextAtPosition = function (text, pos) {\n      var container = pos.container();\n      var offset = pos.offset();\n      if (isText$7(container)) {\n        container.insertData(offset, text);\n        return Optional.some(CaretPosition(container, offset + text.length));\n      } else {\n        return getElementFromPosition(pos).map(function (elm) {\n          var textNode = SugarElement.fromText(text);\n          if (pos.isAtEnd()) {\n            after$3(elm, textNode);\n          } else {\n            before$4(elm, textNode);\n          }\n          return CaretPosition(textNode.dom, text.length);\n        });\n      }\n    };\n    var insertNbspAtPosition = curry(insertTextAtPosition, nbsp);\n    var insertSpaceAtPosition = curry(insertTextAtPosition, ' ');\n\n    var locationToCaretPosition = function (root) {\n      return function (location) {\n        return location.fold(function (element) {\n          return prevPosition(root.dom, CaretPosition.before(element));\n        }, function (element) {\n          return firstPositionIn(element);\n        }, function (element) {\n          return lastPositionIn(element);\n        }, function (element) {\n          return nextPosition(root.dom, CaretPosition.after(element));\n        });\n      };\n    };\n    var insertInlineBoundarySpaceOrNbsp = function (root, pos) {\n      return function (checkPos) {\n        return needsToHaveNbsp(root, checkPos) ? insertNbspAtPosition(pos) : insertSpaceAtPosition(pos);\n      };\n    };\n    var setSelection = function (editor) {\n      return function (pos) {\n        editor.selection.setRng(pos.toRange());\n        editor.nodeChanged();\n        return true;\n      };\n    };\n    var insertSpaceOrNbspAtSelection = function (editor) {\n      var pos = CaretPosition.fromRangeStart(editor.selection.getRng());\n      var root = SugarElement.fromDom(editor.getBody());\n      if (editor.selection.isCollapsed()) {\n        var isInlineTarget$1 = curry(isInlineTarget, editor);\n        var caretPosition = CaretPosition.fromRangeStart(editor.selection.getRng());\n        return readLocation(isInlineTarget$1, editor.getBody(), caretPosition).bind(locationToCaretPosition(root)).bind(insertInlineBoundarySpaceOrNbsp(root, pos)).exists(setSelection(editor));\n      } else {\n        return false;\n      }\n    };\n\n    var executeKeydownOverride = function (editor, evt) {\n      execute([{\n          keyCode: VK.SPACEBAR,\n          action: action(insertSpaceOrNbspAtSelection, editor)\n        }], evt).each(function (_) {\n        evt.preventDefault();\n      });\n    };\n    var setup$5 = function (editor) {\n      editor.on('keydown', function (evt) {\n        if (evt.isDefaultPrevented() === false) {\n          executeKeydownOverride(editor, evt);\n        }\n      });\n    };\n\n    var registerKeyboardOverrides = function (editor) {\n      var caret = setupSelectedState(editor);\n      setup$c(editor);\n      setup$b(editor, caret);\n      setup$a(editor, caret);\n      setup$9(editor);\n      setup$5(editor);\n      setup$7(editor);\n      setup$8(editor, caret);\n      setup$6(editor, caret);\n      return caret;\n    };\n    var setup$4 = function (editor) {\n      if (!isRtc(editor)) {\n        return registerKeyboardOverrides(editor);\n      } else {\n        return Cell(null);\n      }\n    };\n\n    var NodeChange = function () {\n      function NodeChange(editor) {\n        this.lastPath = [];\n        this.editor = editor;\n        var lastRng;\n        var self = this;\n        if (!('onselectionchange' in editor.getDoc())) {\n          editor.on('NodeChange click mouseup keyup focus', function (e) {\n            var nativeRng = editor.selection.getRng();\n            var fakeRng = {\n              startContainer: nativeRng.startContainer,\n              startOffset: nativeRng.startOffset,\n              endContainer: nativeRng.endContainer,\n              endOffset: nativeRng.endOffset\n            };\n            if (e.type === 'nodechange' || !isEq$4(fakeRng, lastRng)) {\n              editor.fire('SelectionChange');\n            }\n            lastRng = fakeRng;\n          });\n        }\n        editor.on('contextmenu', function () {\n          editor.fire('SelectionChange');\n        });\n        editor.on('SelectionChange', function () {\n          var startElm = editor.selection.getStart(true);\n          if (!startElm || !Env.range && editor.selection.isCollapsed()) {\n            return;\n          }\n          if (hasAnyRanges(editor) && !self.isSameElementPath(startElm) && editor.dom.isChildOf(startElm, editor.getBody())) {\n            editor.nodeChanged({ selectionChange: true });\n          }\n        });\n        editor.on('mouseup', function (e) {\n          if (!e.isDefaultPrevented() && hasAnyRanges(editor)) {\n            if (editor.selection.getNode().nodeName === 'IMG') {\n              Delay.setEditorTimeout(editor, function () {\n                editor.nodeChanged();\n              });\n            } else {\n              editor.nodeChanged();\n            }\n          }\n        });\n      }\n      NodeChange.prototype.nodeChanged = function (args) {\n        var selection = this.editor.selection;\n        var node, parents, root;\n        if (this.editor.initialized && selection && !shouldDisableNodeChange(this.editor) && !this.editor.mode.isReadOnly()) {\n          root = this.editor.getBody();\n          node = selection.getStart(true) || root;\n          if (node.ownerDocument !== this.editor.getDoc() || !this.editor.dom.isChildOf(node, root)) {\n            node = root;\n          }\n          parents = [];\n          this.editor.dom.getParent(node, function (node) {\n            if (node === root) {\n              return true;\n            }\n            parents.push(node);\n          });\n          args = args || {};\n          args.element = node;\n          args.parents = parents;\n          this.editor.fire('NodeChange', args);\n        }\n      };\n      NodeChange.prototype.isSameElementPath = function (startElm) {\n        var i;\n        var currentPath = this.editor.$(startElm).parentsUntil(this.editor.getBody()).add(startElm);\n        if (currentPath.length === this.lastPath.length) {\n          for (i = currentPath.length; i >= 0; i--) {\n            if (currentPath[i] !== this.lastPath[i]) {\n              break;\n            }\n          }\n          if (i === -1) {\n            this.lastPath = currentPath;\n            return true;\n          }\n        }\n        this.lastPath = currentPath;\n        return false;\n      };\n      return NodeChange;\n    }();\n\n    var preventSummaryToggle = function (editor) {\n      editor.on('click', function (e) {\n        if (editor.dom.getParent(e.target, 'details')) {\n          e.preventDefault();\n        }\n      });\n    };\n    var filterDetails = function (editor) {\n      editor.parser.addNodeFilter('details', function (elms) {\n        each$k(elms, function (details) {\n          details.attr('data-mce-open', details.attr('open'));\n          details.attr('open', 'open');\n        });\n      });\n      editor.serializer.addNodeFilter('details', function (elms) {\n        each$k(elms, function (details) {\n          var open = details.attr('data-mce-open');\n          details.attr('open', isString$1(open) ? open : null);\n          details.attr('data-mce-open', null);\n        });\n      });\n    };\n    var setup$3 = function (editor) {\n      preventSummaryToggle(editor);\n      filterDetails(editor);\n    };\n\n    var isTextBlockNode = function (node) {\n      return isElement$5(node) && isTextBlock$2(SugarElement.fromDom(node));\n    };\n    var normalizeSelection = function (editor) {\n      var rng = editor.selection.getRng();\n      var startPos = CaretPosition.fromRangeStart(rng);\n      var endPos = CaretPosition.fromRangeEnd(rng);\n      if (CaretPosition.isElementPosition(startPos)) {\n        var container = startPos.container();\n        if (isTextBlockNode(container)) {\n          firstPositionIn(container).each(function (pos) {\n            return rng.setStart(pos.container(), pos.offset());\n          });\n        }\n      }\n      if (CaretPosition.isElementPosition(endPos)) {\n        var container = startPos.container();\n        if (isTextBlockNode(container)) {\n          lastPositionIn(container).each(function (pos) {\n            return rng.setEnd(pos.container(), pos.offset());\n          });\n        }\n      }\n      editor.selection.setRng(normalize(rng));\n    };\n    var setup$2 = function (editor) {\n      editor.on('click', function (e) {\n        if (e.detail >= 3) {\n          normalizeSelection(editor);\n        }\n      });\n    };\n\n    var getAbsolutePosition = function (elm) {\n      var clientRect = elm.getBoundingClientRect();\n      var doc = elm.ownerDocument;\n      var docElem = doc.documentElement;\n      var win = doc.defaultView;\n      return {\n        top: clientRect.top + win.pageYOffset - docElem.clientTop,\n        left: clientRect.left + win.pageXOffset - docElem.clientLeft\n      };\n    };\n    var getBodyPosition = function (editor) {\n      return editor.inline ? getAbsolutePosition(editor.getBody()) : {\n        left: 0,\n        top: 0\n      };\n    };\n    var getScrollPosition = function (editor) {\n      var body = editor.getBody();\n      return editor.inline ? {\n        left: body.scrollLeft,\n        top: body.scrollTop\n      } : {\n        left: 0,\n        top: 0\n      };\n    };\n    var getBodyScroll = function (editor) {\n      var body = editor.getBody(), docElm = editor.getDoc().documentElement;\n      var inlineScroll = {\n        left: body.scrollLeft,\n        top: body.scrollTop\n      };\n      var iframeScroll = {\n        left: body.scrollLeft || docElm.scrollLeft,\n        top: body.scrollTop || docElm.scrollTop\n      };\n      return editor.inline ? inlineScroll : iframeScroll;\n    };\n    var getMousePosition = function (editor, event) {\n      if (event.target.ownerDocument !== editor.getDoc()) {\n        var iframePosition = getAbsolutePosition(editor.getContentAreaContainer());\n        var scrollPosition = getBodyScroll(editor);\n        return {\n          left: event.pageX - iframePosition.left + scrollPosition.left,\n          top: event.pageY - iframePosition.top + scrollPosition.top\n        };\n      }\n      return {\n        left: event.pageX,\n        top: event.pageY\n      };\n    };\n    var calculatePosition = function (bodyPosition, scrollPosition, mousePosition) {\n      return {\n        pageX: mousePosition.left - bodyPosition.left + scrollPosition.left,\n        pageY: mousePosition.top - bodyPosition.top + scrollPosition.top\n      };\n    };\n    var calc = function (editor, event) {\n      return calculatePosition(getBodyPosition(editor), getScrollPosition(editor), getMousePosition(editor, event));\n    };\n\n    var isContentEditableFalse$1 = isContentEditableFalse$b, isContentEditableTrue$1 = isContentEditableTrue$4;\n    var isDraggable = function (rootElm, elm) {\n      return isContentEditableFalse$1(elm) && elm !== rootElm;\n    };\n    var isValidDropTarget = function (editor, targetElement, dragElement) {\n      if (targetElement === dragElement || editor.dom.isChildOf(targetElement, dragElement)) {\n        return false;\n      }\n      return !isContentEditableFalse$1(targetElement);\n    };\n    var cloneElement = function (elm) {\n      var cloneElm = elm.cloneNode(true);\n      cloneElm.removeAttribute('data-mce-selected');\n      return cloneElm;\n    };\n    var createGhost = function (editor, elm, width, height) {\n      var dom = editor.dom;\n      var clonedElm = elm.cloneNode(true);\n      dom.setStyles(clonedElm, {\n        width: width,\n        height: height\n      });\n      dom.setAttrib(clonedElm, 'data-mce-selected', null);\n      var ghostElm = dom.create('div', {\n        'class': 'mce-drag-container',\n        'data-mce-bogus': 'all',\n        'unselectable': 'on',\n        'contenteditable': 'false'\n      });\n      dom.setStyles(ghostElm, {\n        position: 'absolute',\n        opacity: 0.5,\n        overflow: 'hidden',\n        border: 0,\n        padding: 0,\n        margin: 0,\n        width: width,\n        height: height\n      });\n      dom.setStyles(clonedElm, {\n        margin: 0,\n        boxSizing: 'border-box'\n      });\n      ghostElm.appendChild(clonedElm);\n      return ghostElm;\n    };\n    var appendGhostToBody = function (ghostElm, bodyElm) {\n      if (ghostElm.parentNode !== bodyElm) {\n        bodyElm.appendChild(ghostElm);\n      }\n    };\n    var moveGhost = function (ghostElm, position, width, height, maxX, maxY) {\n      var overflowX = 0, overflowY = 0;\n      ghostElm.style.left = position.pageX + 'px';\n      ghostElm.style.top = position.pageY + 'px';\n      if (position.pageX + width > maxX) {\n        overflowX = position.pageX + width - maxX;\n      }\n      if (position.pageY + height > maxY) {\n        overflowY = position.pageY + height - maxY;\n      }\n      ghostElm.style.width = width - overflowX + 'px';\n      ghostElm.style.height = height - overflowY + 'px';\n    };\n    var removeElement = function (elm) {\n      if (elm && elm.parentNode) {\n        elm.parentNode.removeChild(elm);\n      }\n    };\n    var isLeftMouseButtonPressed = function (e) {\n      return e.button === 0;\n    };\n    var applyRelPos = function (state, position) {\n      return {\n        pageX: position.pageX - state.relX,\n        pageY: position.pageY + 5\n      };\n    };\n    var start = function (state, editor) {\n      return function (e) {\n        if (isLeftMouseButtonPressed(e)) {\n          var ceElm = find$3(editor.dom.getParents(e.target), or(isContentEditableFalse$1, isContentEditableTrue$1)).getOr(null);\n          if (isDraggable(editor.getBody(), ceElm)) {\n            var elmPos = editor.dom.getPos(ceElm);\n            var bodyElm = editor.getBody();\n            var docElm = editor.getDoc().documentElement;\n            state.set({\n              element: ceElm,\n              dragging: false,\n              screenX: e.screenX,\n              screenY: e.screenY,\n              maxX: (editor.inline ? bodyElm.scrollWidth : docElm.offsetWidth) - 2,\n              maxY: (editor.inline ? bodyElm.scrollHeight : docElm.offsetHeight) - 2,\n              relX: e.pageX - elmPos.x,\n              relY: e.pageY - elmPos.y,\n              width: ceElm.offsetWidth,\n              height: ceElm.offsetHeight,\n              ghost: createGhost(editor, ceElm, ceElm.offsetWidth, ceElm.offsetHeight)\n            });\n          }\n        }\n      };\n    };\n    var move = function (state, editor) {\n      var throttledPlaceCaretAt = Delay.throttle(function (clientX, clientY) {\n        editor._selectionOverrides.hideFakeCaret();\n        editor.selection.placeCaretAt(clientX, clientY);\n      }, 0);\n      editor.on('remove', throttledPlaceCaretAt.stop);\n      return function (e) {\n        return state.on(function (state) {\n          var movement = Math.max(Math.abs(e.screenX - state.screenX), Math.abs(e.screenY - state.screenY));\n          if (!state.dragging && movement > 10) {\n            var args = editor.fire('dragstart', { target: state.element });\n            if (args.isDefaultPrevented()) {\n              return;\n            }\n            state.dragging = true;\n            editor.focus();\n          }\n          if (state.dragging) {\n            var targetPos = applyRelPos(state, calc(editor, e));\n            appendGhostToBody(state.ghost, editor.getBody());\n            moveGhost(state.ghost, targetPos, state.width, state.height, state.maxX, state.maxY);\n            throttledPlaceCaretAt(e.clientX, e.clientY);\n          }\n        });\n      };\n    };\n    var getRawTarget = function (selection) {\n      var rng = selection.getSel().getRangeAt(0);\n      var startContainer = rng.startContainer;\n      return startContainer.nodeType === 3 ? startContainer.parentNode : startContainer;\n    };\n    var drop = function (state, editor) {\n      return function (e) {\n        state.on(function (state) {\n          if (state.dragging) {\n            if (isValidDropTarget(editor, getRawTarget(editor.selection), state.element)) {\n              var targetClone_1 = cloneElement(state.element);\n              var args = editor.fire('drop', {\n                clientX: e.clientX,\n                clientY: e.clientY\n              });\n              if (!args.isDefaultPrevented()) {\n                editor.undoManager.transact(function () {\n                  removeElement(state.element);\n                  editor.insertContent(editor.dom.getOuterHTML(targetClone_1));\n                  editor._selectionOverrides.hideFakeCaret();\n                });\n              }\n            }\n            editor.fire('dragend');\n          }\n        });\n        removeDragState(state);\n      };\n    };\n    var stop = function (state, editor) {\n      return function () {\n        state.on(function (state) {\n          if (state.dragging) {\n            editor.fire('dragend');\n          }\n        });\n        removeDragState(state);\n      };\n    };\n    var removeDragState = function (state) {\n      state.on(function (state) {\n        removeElement(state.ghost);\n      });\n      state.clear();\n    };\n    var bindFakeDragEvents = function (editor) {\n      var state = value();\n      var pageDom = DOMUtils.DOM;\n      var rootDocument = document;\n      var dragStartHandler = start(state, editor);\n      var dragHandler = move(state, editor);\n      var dropHandler = drop(state, editor);\n      var dragEndHandler = stop(state, editor);\n      editor.on('mousedown', dragStartHandler);\n      editor.on('mousemove', dragHandler);\n      editor.on('mouseup', dropHandler);\n      pageDom.bind(rootDocument, 'mousemove', dragHandler);\n      pageDom.bind(rootDocument, 'mouseup', dragEndHandler);\n      editor.on('remove', function () {\n        pageDom.unbind(rootDocument, 'mousemove', dragHandler);\n        pageDom.unbind(rootDocument, 'mouseup', dragEndHandler);\n      });\n      editor.on('keydown', function (e) {\n        if (e.keyCode === VK.ESC) {\n          dragEndHandler();\n        }\n      });\n    };\n    var blockIeDrop = function (editor) {\n      editor.on('drop', function (e) {\n        var realTarget = typeof e.clientX !== 'undefined' ? editor.getDoc().elementFromPoint(e.clientX, e.clientY) : null;\n        if (isContentEditableFalse$1(realTarget) || editor.dom.getContentEditableParent(realTarget) === 'false') {\n          e.preventDefault();\n        }\n      });\n    };\n    var blockUnsupportedFileDrop = function (editor) {\n      var preventFileDrop = function (e) {\n        if (!e.isDefaultPrevented()) {\n          var dataTransfer = e.dataTransfer;\n          if (dataTransfer && (contains$3(dataTransfer.types, 'Files') || dataTransfer.files.length > 0)) {\n            e.preventDefault();\n            if (e.type === 'drop') {\n              displayError(editor, 'Dropped file type is not supported');\n            }\n          }\n        }\n      };\n      var preventFileDropIfUIElement = function (e) {\n        if (isUIElement(editor, e.target)) {\n          preventFileDrop(e);\n        }\n      };\n      var setup = function () {\n        var pageDom = DOMUtils.DOM;\n        var dom = editor.dom;\n        var doc = document;\n        var editorRoot = editor.inline ? editor.getBody() : editor.getDoc();\n        var eventNames = [\n          'drop',\n          'dragover'\n        ];\n        each$k(eventNames, function (name) {\n          pageDom.bind(doc, name, preventFileDropIfUIElement);\n          dom.bind(editorRoot, name, preventFileDrop);\n        });\n        editor.on('remove', function () {\n          each$k(eventNames, function (name) {\n            pageDom.unbind(doc, name, preventFileDropIfUIElement);\n            dom.unbind(editorRoot, name, preventFileDrop);\n          });\n        });\n      };\n      editor.on('init', function () {\n        Delay.setEditorTimeout(editor, setup, 0);\n      });\n    };\n    var init$2 = function (editor) {\n      bindFakeDragEvents(editor);\n      blockIeDrop(editor);\n      if (shouldBlockUnsupportedDrop(editor)) {\n        blockUnsupportedFileDrop(editor);\n      }\n    };\n\n    var setup$1 = function (editor) {\n      var renderFocusCaret = first(function () {\n        if (!editor.removed && editor.getBody().contains(document.activeElement)) {\n          var rng = editor.selection.getRng();\n          if (rng.collapsed) {\n            var caretRange = renderRangeCaret(editor, rng, false);\n            editor.selection.setRng(caretRange);\n          }\n        }\n      }, 0);\n      editor.on('focus', function () {\n        renderFocusCaret.throttle();\n      });\n      editor.on('blur', function () {\n        renderFocusCaret.cancel();\n      });\n    };\n\n    var setup = function (editor) {\n      editor.on('init', function () {\n        editor.on('focusin', function (e) {\n          var target = e.target;\n          if (isMedia$2(target)) {\n            var ceRoot = getContentEditableRoot$1(editor.getBody(), target);\n            var node = isContentEditableFalse$b(ceRoot) ? ceRoot : target;\n            if (editor.selection.getNode() !== node) {\n              selectNode(editor, node).each(function (rng) {\n                return editor.selection.setRng(rng);\n              });\n            }\n          }\n        });\n      });\n    };\n\n    var isContentEditableTrue = isContentEditableTrue$4;\n    var isContentEditableFalse = isContentEditableFalse$b;\n    var getContentEditableRoot = function (editor, node) {\n      return getContentEditableRoot$1(editor.getBody(), node);\n    };\n    var SelectionOverrides = function (editor) {\n      var selection = editor.selection, dom = editor.dom;\n      var isBlock = dom.isBlock;\n      var rootNode = editor.getBody();\n      var fakeCaret = FakeCaret(editor, rootNode, isBlock, function () {\n        return hasFocus(editor);\n      });\n      var realSelectionId = 'sel-' + dom.uniqueId();\n      var elementSelectionAttr = 'data-mce-selected';\n      var selectedElement;\n      var isFakeSelectionElement = function (node) {\n        return dom.hasClass(node, 'mce-offscreen-selection');\n      };\n      var isFakeSelectionTargetElement = function (node) {\n        return node !== rootNode && (isContentEditableFalse(node) || isMedia$2(node)) && dom.isChildOf(node, rootNode);\n      };\n      var isNearFakeSelectionElement = function (pos) {\n        return isBeforeContentEditableFalse(pos) || isAfterContentEditableFalse(pos) || isBeforeMedia(pos) || isAfterMedia(pos);\n      };\n      var getRealSelectionElement = function () {\n        var container = dom.get(realSelectionId);\n        return container ? container.getElementsByTagName('*')[0] : container;\n      };\n      var setRange = function (range) {\n        if (range) {\n          selection.setRng(range);\n        }\n      };\n      var getRange = selection.getRng;\n      var showCaret = function (direction, node, before, scrollIntoView) {\n        if (scrollIntoView === void 0) {\n          scrollIntoView = true;\n        }\n        var e = editor.fire('ShowCaret', {\n          target: node,\n          direction: direction,\n          before: before\n        });\n        if (e.isDefaultPrevented()) {\n          return null;\n        }\n        if (scrollIntoView) {\n          selection.scrollIntoView(node, direction === -1);\n        }\n        return fakeCaret.show(before, node);\n      };\n      var showBlockCaretContainer = function (blockCaretContainer) {\n        if (blockCaretContainer.hasAttribute('data-mce-caret')) {\n          showCaretContainerBlock(blockCaretContainer);\n          setRange(getRange());\n          selection.scrollIntoView(blockCaretContainer);\n        }\n      };\n      var registerEvents = function () {\n        editor.on('mouseup', function (e) {\n          var range = getRange();\n          if (range.collapsed && isXYInContentArea(editor, e.clientX, e.clientY)) {\n            renderCaretAtRange(editor, range, false).each(setRange);\n          }\n        });\n        editor.on('click', function (e) {\n          var contentEditableRoot = getContentEditableRoot(editor, e.target);\n          if (contentEditableRoot) {\n            if (isContentEditableFalse(contentEditableRoot)) {\n              e.preventDefault();\n              editor.focus();\n            }\n            if (isContentEditableTrue(contentEditableRoot)) {\n              if (dom.isChildOf(contentEditableRoot, selection.getNode())) {\n                removeElementSelection();\n              }\n            }\n          }\n        });\n        editor.on('blur NewBlock', removeElementSelection);\n        editor.on('ResizeWindow FullscreenStateChanged', fakeCaret.reposition);\n        var hasNormalCaretPosition = function (elm) {\n          var start = elm.firstChild;\n          if (isNullable(start)) {\n            return false;\n          }\n          var startPos = CaretPosition.before(start);\n          if (isBr$5(startPos.getNode()) && elm.childNodes.length === 1) {\n            return !isNearFakeSelectionElement(startPos);\n          } else {\n            var caretWalker = CaretWalker(elm);\n            var newPos = caretWalker.next(startPos);\n            return newPos && !isNearFakeSelectionElement(newPos);\n          }\n        };\n        var isInSameBlock = function (node1, node2) {\n          var block1 = dom.getParent(node1, isBlock);\n          var block2 = dom.getParent(node2, isBlock);\n          return block1 === block2;\n        };\n        var hasBetterMouseTarget = function (targetNode, caretNode) {\n          var targetBlock = dom.getParent(targetNode, isBlock);\n          var caretBlock = dom.getParent(caretNode, isBlock);\n          if (isNullable(targetBlock)) {\n            return false;\n          }\n          if (targetNode !== caretBlock && dom.isChildOf(targetBlock, caretBlock) && isContentEditableFalse(getContentEditableRoot(editor, targetBlock)) === false) {\n            return true;\n          }\n          return !dom.isChildOf(caretBlock, targetBlock) && !isInSameBlock(targetBlock, caretBlock) && hasNormalCaretPosition(targetBlock);\n        };\n        editor.on('tap', function (e) {\n          var targetElm = e.target;\n          var contentEditableRoot = getContentEditableRoot(editor, targetElm);\n          if (isContentEditableFalse(contentEditableRoot)) {\n            e.preventDefault();\n            selectNode(editor, contentEditableRoot).each(setElementSelection);\n          } else if (isFakeSelectionTargetElement(targetElm)) {\n            selectNode(editor, targetElm).each(setElementSelection);\n          }\n        }, true);\n        editor.on('mousedown', function (e) {\n          var targetElm = e.target;\n          if (targetElm !== rootNode && targetElm.nodeName !== 'HTML' && !dom.isChildOf(targetElm, rootNode)) {\n            return;\n          }\n          if (isXYInContentArea(editor, e.clientX, e.clientY) === false) {\n            return;\n          }\n          var contentEditableRoot = getContentEditableRoot(editor, targetElm);\n          if (contentEditableRoot) {\n            if (isContentEditableFalse(contentEditableRoot)) {\n              e.preventDefault();\n              selectNode(editor, contentEditableRoot).each(setElementSelection);\n            } else {\n              removeElementSelection();\n              if (!(isContentEditableTrue(contentEditableRoot) && e.shiftKey) && !isXYWithinRange(e.clientX, e.clientY, selection.getRng())) {\n                hideFakeCaret();\n                selection.placeCaretAt(e.clientX, e.clientY);\n              }\n            }\n          } else if (isFakeSelectionTargetElement(targetElm)) {\n            selectNode(editor, targetElm).each(setElementSelection);\n          } else if (isFakeCaretTarget(targetElm) === false) {\n            removeElementSelection();\n            hideFakeCaret();\n            var fakeCaretInfo = closestFakeCaret(rootNode, e.clientX, e.clientY);\n            if (fakeCaretInfo) {\n              if (!hasBetterMouseTarget(targetElm, fakeCaretInfo.node)) {\n                e.preventDefault();\n                var range = showCaret(1, fakeCaretInfo.node, fakeCaretInfo.before, false);\n                setRange(range);\n                editor.getBody().focus();\n              }\n            }\n          }\n        });\n        editor.on('keypress', function (e) {\n          if (VK.modifierPressed(e)) {\n            return;\n          }\n          if (isContentEditableFalse(selection.getNode())) {\n            e.preventDefault();\n          }\n        });\n        editor.on('GetSelectionRange', function (e) {\n          var rng = e.range;\n          if (selectedElement) {\n            if (!selectedElement.parentNode) {\n              selectedElement = null;\n              return;\n            }\n            rng = rng.cloneRange();\n            rng.selectNode(selectedElement);\n            e.range = rng;\n          }\n        });\n        editor.on('SetSelectionRange', function (e) {\n          e.range = normalizeShortEndedElementSelection(e.range);\n          var rng = setElementSelection(e.range, e.forward);\n          if (rng) {\n            e.range = rng;\n          }\n        });\n        var isPasteBin = function (node) {\n          return node.id === 'mcepastebin';\n        };\n        editor.on('AfterSetSelectionRange', function (e) {\n          var rng = e.range;\n          var parentNode = rng.startContainer.parentNode;\n          if (!isRangeInCaretContainer(rng) && !isPasteBin(parentNode)) {\n            hideFakeCaret();\n          }\n          if (!isFakeSelectionElement(parentNode)) {\n            removeElementSelection();\n          }\n        });\n        editor.on('copy', function (e) {\n          var clipboardData = e.clipboardData;\n          if (!e.isDefaultPrevented() && e.clipboardData && !Env.ie) {\n            var realSelectionElement = getRealSelectionElement();\n            if (realSelectionElement) {\n              e.preventDefault();\n              clipboardData.clearData();\n              clipboardData.setData('text/html', realSelectionElement.outerHTML);\n              clipboardData.setData('text/plain', realSelectionElement.outerText || realSelectionElement.innerText);\n            }\n          }\n        });\n        init$2(editor);\n        setup$1(editor);\n        setup(editor);\n      };\n      var isWithinCaretContainer = function (node) {\n        return isCaretContainer$2(node) || startsWithCaretContainer$1(node) || endsWithCaretContainer$1(node);\n      };\n      var isRangeInCaretContainer = function (rng) {\n        return isWithinCaretContainer(rng.startContainer) || isWithinCaretContainer(rng.endContainer);\n      };\n      var normalizeShortEndedElementSelection = function (rng) {\n        var shortEndedElements = editor.schema.getShortEndedElements();\n        var newRng = dom.createRng();\n        var startContainer = rng.startContainer;\n        var startOffset = rng.startOffset;\n        var endContainer = rng.endContainer;\n        var endOffset = rng.endOffset;\n        if (has$2(shortEndedElements, startContainer.nodeName.toLowerCase())) {\n          if (startOffset === 0) {\n            newRng.setStartBefore(startContainer);\n          } else {\n            newRng.setStartAfter(startContainer);\n          }\n        } else {\n          newRng.setStart(startContainer, startOffset);\n        }\n        if (has$2(shortEndedElements, endContainer.nodeName.toLowerCase())) {\n          if (endOffset === 0) {\n            newRng.setEndBefore(endContainer);\n          } else {\n            newRng.setEndAfter(endContainer);\n          }\n        } else {\n          newRng.setEnd(endContainer, endOffset);\n        }\n        return newRng;\n      };\n      var setupOffscreenSelection = function (node, targetClone, origTargetClone) {\n        var $ = editor.$;\n        var $realSelectionContainer = descendant(SugarElement.fromDom(editor.getBody()), '#' + realSelectionId).fold(function () {\n          return $([]);\n        }, function (elm) {\n          return $([elm.dom]);\n        });\n        if ($realSelectionContainer.length === 0) {\n          $realSelectionContainer = $('<div data-mce-bogus=\"all\" class=\"mce-offscreen-selection\"></div>').attr('id', realSelectionId);\n          $realSelectionContainer.appendTo(editor.getBody());\n        }\n        var newRange = dom.createRng();\n        if (targetClone === origTargetClone && Env.ie) {\n          $realSelectionContainer.empty().append('<p style=\"font-size: 0\" data-mce-bogus=\"all\">\\xA0</p>').append(targetClone);\n          newRange.setStartAfter($realSelectionContainer[0].firstChild.firstChild);\n          newRange.setEndAfter(targetClone);\n        } else {\n          $realSelectionContainer.empty().append(nbsp).append(targetClone).append(nbsp);\n          newRange.setStart($realSelectionContainer[0].firstChild, 1);\n          newRange.setEnd($realSelectionContainer[0].lastChild, 0);\n        }\n        $realSelectionContainer.css({ top: dom.getPos(node, editor.getBody()).y });\n        $realSelectionContainer[0].focus();\n        var sel = selection.getSel();\n        sel.removeAllRanges();\n        sel.addRange(newRange);\n        return newRange;\n      };\n      var selectElement = function (elm) {\n        var targetClone = elm.cloneNode(true);\n        var e = editor.fire('ObjectSelected', {\n          target: elm,\n          targetClone: targetClone\n        });\n        if (e.isDefaultPrevented()) {\n          return null;\n        }\n        var range = setupOffscreenSelection(elm, e.targetClone, targetClone);\n        var nodeElm = SugarElement.fromDom(elm);\n        each$k(descendants(SugarElement.fromDom(editor.getBody()), '*[data-mce-selected]'), function (elm) {\n          if (!eq(nodeElm, elm)) {\n            remove$6(elm, elementSelectionAttr);\n          }\n        });\n        if (!dom.getAttrib(elm, elementSelectionAttr)) {\n          elm.setAttribute(elementSelectionAttr, '1');\n        }\n        selectedElement = elm;\n        hideFakeCaret();\n        return range;\n      };\n      var setElementSelection = function (range, forward) {\n        if (!range) {\n          return null;\n        }\n        if (range.collapsed) {\n          if (!isRangeInCaretContainer(range)) {\n            var dir = forward ? 1 : -1;\n            var caretPosition = getNormalizedRangeEndPoint(dir, rootNode, range);\n            var beforeNode = caretPosition.getNode(!forward);\n            if (isFakeCaretTarget(beforeNode)) {\n              return showCaret(dir, beforeNode, forward ? !caretPosition.isAtEnd() : false, false);\n            }\n            var afterNode = caretPosition.getNode(forward);\n            if (isFakeCaretTarget(afterNode)) {\n              return showCaret(dir, afterNode, forward ? false : !caretPosition.isAtEnd(), false);\n            }\n          }\n          return null;\n        }\n        var startContainer = range.startContainer;\n        var startOffset = range.startOffset;\n        var endOffset = range.endOffset;\n        if (startContainer.nodeType === 3 && startOffset === 0 && isContentEditableFalse(startContainer.parentNode)) {\n          startContainer = startContainer.parentNode;\n          startOffset = dom.nodeIndex(startContainer);\n          startContainer = startContainer.parentNode;\n        }\n        if (startContainer.nodeType !== 1) {\n          return null;\n        }\n        if (endOffset === startOffset + 1 && startContainer === range.endContainer) {\n          var node = startContainer.childNodes[startOffset];\n          if (isFakeSelectionTargetElement(node)) {\n            return selectElement(node);\n          }\n        }\n        return null;\n      };\n      var removeElementSelection = function () {\n        if (selectedElement) {\n          selectedElement.removeAttribute(elementSelectionAttr);\n        }\n        descendant(SugarElement.fromDom(editor.getBody()), '#' + realSelectionId).each(remove$7);\n        selectedElement = null;\n      };\n      var destroy = function () {\n        fakeCaret.destroy();\n        selectedElement = null;\n      };\n      var hideFakeCaret = function () {\n        fakeCaret.hide();\n      };\n      if (Env.ceFalse && !isRtc(editor)) {\n        registerEvents();\n      }\n      return {\n        showCaret: showCaret,\n        showBlockCaretContainer: showBlockCaretContainer,\n        hideFakeCaret: hideFakeCaret,\n        destroy: destroy\n      };\n    };\n\n    var Quirks = function (editor) {\n      var each = Tools.each;\n      var BACKSPACE = VK.BACKSPACE, DELETE = VK.DELETE, dom = editor.dom, selection = editor.selection, parser = editor.parser;\n      var isGecko = Env.gecko, isIE = Env.ie, isWebKit = Env.webkit;\n      var mceInternalUrlPrefix = 'data:text/mce-internal,';\n      var mceInternalDataType = isIE ? 'Text' : 'URL';\n      var setEditorCommandState = function (cmd, state) {\n        try {\n          editor.getDoc().execCommand(cmd, false, state);\n        } catch (ex) {\n        }\n      };\n      var isDefaultPrevented = function (e) {\n        return e.isDefaultPrevented();\n      };\n      var setMceInternalContent = function (e) {\n        var selectionHtml, internalContent;\n        if (e.dataTransfer) {\n          if (editor.selection.isCollapsed() && e.target.tagName === 'IMG') {\n            selection.select(e.target);\n          }\n          selectionHtml = editor.selection.getContent();\n          if (selectionHtml.length > 0) {\n            internalContent = mceInternalUrlPrefix + escape(editor.id) + ',' + escape(selectionHtml);\n            e.dataTransfer.setData(mceInternalDataType, internalContent);\n          }\n        }\n      };\n      var getMceInternalContent = function (e) {\n        var internalContent;\n        if (e.dataTransfer) {\n          internalContent = e.dataTransfer.getData(mceInternalDataType);\n          if (internalContent && internalContent.indexOf(mceInternalUrlPrefix) >= 0) {\n            internalContent = internalContent.substr(mceInternalUrlPrefix.length).split(',');\n            return {\n              id: unescape(internalContent[0]),\n              html: unescape(internalContent[1])\n            };\n          }\n        }\n        return null;\n      };\n      var insertClipboardContents = function (content, internal) {\n        if (editor.queryCommandSupported('mceInsertClipboardContent')) {\n          editor.execCommand('mceInsertClipboardContent', false, {\n            content: content,\n            internal: internal\n          });\n        } else {\n          editor.execCommand('mceInsertContent', false, content);\n        }\n      };\n      var emptyEditorWhenDeleting = function () {\n        var serializeRng = function (rng) {\n          var body = dom.create('body');\n          var contents = rng.cloneContents();\n          body.appendChild(contents);\n          return selection.serializer.serialize(body, { format: 'html' });\n        };\n        var allContentsSelected = function (rng) {\n          var selection = serializeRng(rng);\n          var allRng = dom.createRng();\n          allRng.selectNode(editor.getBody());\n          var allSelection = serializeRng(allRng);\n          return selection === allSelection;\n        };\n        editor.on('keydown', function (e) {\n          var keyCode = e.keyCode;\n          var isCollapsed, body;\n          if (!isDefaultPrevented(e) && (keyCode === DELETE || keyCode === BACKSPACE)) {\n            isCollapsed = editor.selection.isCollapsed();\n            body = editor.getBody();\n            if (isCollapsed && !dom.isEmpty(body)) {\n              return;\n            }\n            if (!isCollapsed && !allContentsSelected(editor.selection.getRng())) {\n              return;\n            }\n            e.preventDefault();\n            editor.setContent('');\n            if (body.firstChild && dom.isBlock(body.firstChild)) {\n              editor.selection.setCursorLocation(body.firstChild, 0);\n            } else {\n              editor.selection.setCursorLocation(body, 0);\n            }\n            editor.nodeChanged();\n          }\n        });\n      };\n      var selectAll = function () {\n        editor.shortcuts.add('meta+a', null, 'SelectAll');\n      };\n      var documentElementEditingFocus = function () {\n        if (!editor.inline) {\n          dom.bind(editor.getDoc(), 'mousedown mouseup', function (e) {\n            var rng;\n            if (e.target === editor.getDoc().documentElement) {\n              rng = selection.getRng();\n              editor.getBody().focus();\n              if (e.type === 'mousedown') {\n                if (isCaretContainer$2(rng.startContainer)) {\n                  return;\n                }\n                selection.placeCaretAt(e.clientX, e.clientY);\n              } else {\n                selection.setRng(rng);\n              }\n            }\n          });\n        }\n      };\n      var removeHrOnBackspace = function () {\n        editor.on('keydown', function (e) {\n          if (!isDefaultPrevented(e) && e.keyCode === BACKSPACE) {\n            if (!editor.getBody().getElementsByTagName('hr').length) {\n              return;\n            }\n            if (selection.isCollapsed() && selection.getRng().startOffset === 0) {\n              var node = selection.getNode();\n              var previousSibling = node.previousSibling;\n              if (node.nodeName === 'HR') {\n                dom.remove(node);\n                e.preventDefault();\n                return;\n              }\n              if (previousSibling && previousSibling.nodeName && previousSibling.nodeName.toLowerCase() === 'hr') {\n                dom.remove(previousSibling);\n                e.preventDefault();\n              }\n            }\n          }\n        });\n      };\n      var focusBody = function () {\n        if (!Range.prototype.getClientRects) {\n          editor.on('mousedown', function (e) {\n            if (!isDefaultPrevented(e) && e.target.nodeName === 'HTML') {\n              var body_1 = editor.getBody();\n              body_1.blur();\n              Delay.setEditorTimeout(editor, function () {\n                body_1.focus();\n              });\n            }\n          });\n        }\n      };\n      var selectControlElements = function () {\n        editor.on('click', function (e) {\n          var target = e.target;\n          if (/^(IMG|HR)$/.test(target.nodeName) && dom.getContentEditableParent(target) !== 'false') {\n            e.preventDefault();\n            editor.selection.select(target);\n            editor.nodeChanged();\n          }\n          if (target.nodeName === 'A' && dom.hasClass(target, 'mce-item-anchor')) {\n            e.preventDefault();\n            selection.select(target);\n          }\n        });\n      };\n      var removeStylesWhenDeletingAcrossBlockElements = function () {\n        var getAttributeApplyFunction = function () {\n          var template = dom.getAttribs(selection.getStart().cloneNode(false));\n          return function () {\n            var target = selection.getStart();\n            if (target !== editor.getBody()) {\n              dom.setAttrib(target, 'style', null);\n              each(template, function (attr) {\n                target.setAttributeNode(attr.cloneNode(true));\n              });\n            }\n          };\n        };\n        var isSelectionAcrossElements = function () {\n          return !selection.isCollapsed() && dom.getParent(selection.getStart(), dom.isBlock) !== dom.getParent(selection.getEnd(), dom.isBlock);\n        };\n        editor.on('keypress', function (e) {\n          var applyAttributes;\n          if (!isDefaultPrevented(e) && (e.keyCode === 8 || e.keyCode === 46) && isSelectionAcrossElements()) {\n            applyAttributes = getAttributeApplyFunction();\n            editor.getDoc().execCommand('delete', false, null);\n            applyAttributes();\n            e.preventDefault();\n            return false;\n          }\n        });\n        dom.bind(editor.getDoc(), 'cut', function (e) {\n          var applyAttributes;\n          if (!isDefaultPrevented(e) && isSelectionAcrossElements()) {\n            applyAttributes = getAttributeApplyFunction();\n            Delay.setEditorTimeout(editor, function () {\n              applyAttributes();\n            });\n          }\n        });\n      };\n      var disableBackspaceIntoATable = function () {\n        editor.on('keydown', function (e) {\n          if (!isDefaultPrevented(e) && e.keyCode === BACKSPACE) {\n            if (selection.isCollapsed() && selection.getRng().startOffset === 0) {\n              var previousSibling = selection.getNode().previousSibling;\n              if (previousSibling && previousSibling.nodeName && previousSibling.nodeName.toLowerCase() === 'table') {\n                e.preventDefault();\n                return false;\n              }\n            }\n          }\n        });\n      };\n      var removeBlockQuoteOnBackSpace = function () {\n        editor.on('keydown', function (e) {\n          var rng, parent;\n          if (isDefaultPrevented(e) || e.keyCode !== VK.BACKSPACE) {\n            return;\n          }\n          rng = selection.getRng();\n          var container = rng.startContainer;\n          var offset = rng.startOffset;\n          var root = dom.getRoot();\n          parent = container;\n          if (!rng.collapsed || offset !== 0) {\n            return;\n          }\n          while (parent && parent.parentNode && parent.parentNode.firstChild === parent && parent.parentNode !== root) {\n            parent = parent.parentNode;\n          }\n          if (parent.tagName === 'BLOCKQUOTE') {\n            editor.formatter.toggle('blockquote', null, parent);\n            rng = dom.createRng();\n            rng.setStart(container, 0);\n            rng.setEnd(container, 0);\n            selection.setRng(rng);\n          }\n        });\n      };\n      var setGeckoEditingOptions = function () {\n        var setOpts = function () {\n          setEditorCommandState('StyleWithCSS', false);\n          setEditorCommandState('enableInlineTableEditing', false);\n          if (!getObjectResizing(editor)) {\n            setEditorCommandState('enableObjectResizing', false);\n          }\n        };\n        if (!isReadOnly$1(editor)) {\n          editor.on('BeforeExecCommand mousedown', setOpts);\n        }\n      };\n      var addBrAfterLastLinks = function () {\n        var fixLinks = function () {\n          each(dom.select('a'), function (node) {\n            var parentNode = node.parentNode;\n            var root = dom.getRoot();\n            if (parentNode.lastChild === node) {\n              while (parentNode && !dom.isBlock(parentNode)) {\n                if (parentNode.parentNode.lastChild !== parentNode || parentNode === root) {\n                  return;\n                }\n                parentNode = parentNode.parentNode;\n              }\n              dom.add(parentNode, 'br', { 'data-mce-bogus': 1 });\n            }\n          });\n        };\n        editor.on('SetContent ExecCommand', function (e) {\n          if (e.type === 'setcontent' || e.command === 'mceInsertLink') {\n            fixLinks();\n          }\n        });\n      };\n      var setDefaultBlockType = function () {\n        if (getForcedRootBlock(editor)) {\n          editor.on('init', function () {\n            setEditorCommandState('DefaultParagraphSeparator', getForcedRootBlock(editor));\n          });\n        }\n      };\n      var normalizeSelection = function () {\n        editor.on('keyup focusin mouseup', function (e) {\n          if (!VK.modifierPressed(e)) {\n            selection.normalize();\n          }\n        }, true);\n      };\n      var showBrokenImageIcon = function () {\n        editor.contentStyles.push('img:-moz-broken {' + '-moz-force-broken-image-icon:1;' + 'min-width:24px;' + 'min-height:24px' + '}');\n      };\n      var restoreFocusOnKeyDown = function () {\n        if (!editor.inline) {\n          editor.on('keydown', function () {\n            if (document.activeElement === document.body) {\n              editor.getWin().focus();\n            }\n          });\n        }\n      };\n      var bodyHeight = function () {\n        if (!editor.inline) {\n          editor.contentStyles.push('body {min-height: 150px}');\n          editor.on('click', function (e) {\n            var rng;\n            if (e.target.nodeName === 'HTML') {\n              if (Env.ie > 11) {\n                editor.getBody().focus();\n                return;\n              }\n              rng = editor.selection.getRng();\n              editor.getBody().focus();\n              editor.selection.setRng(rng);\n              editor.selection.normalize();\n              editor.nodeChanged();\n            }\n          });\n        }\n      };\n      var blockCmdArrowNavigation = function () {\n        if (Env.mac) {\n          editor.on('keydown', function (e) {\n            if (VK.metaKeyPressed(e) && !e.shiftKey && (e.keyCode === 37 || e.keyCode === 39)) {\n              e.preventDefault();\n              var selection_1 = editor.selection.getSel();\n              selection_1.modify('move', e.keyCode === 37 ? 'backward' : 'forward', 'lineboundary');\n            }\n          });\n        }\n      };\n      var disableAutoUrlDetect = function () {\n        setEditorCommandState('AutoUrlDetect', false);\n      };\n      var tapLinksAndImages = function () {\n        editor.on('click', function (e) {\n          var elm = e.target;\n          do {\n            if (elm.tagName === 'A') {\n              e.preventDefault();\n              return;\n            }\n          } while (elm = elm.parentNode);\n        });\n        editor.contentStyles.push('.mce-content-body {-webkit-touch-callout: none}');\n      };\n      var blockFormSubmitInsideEditor = function () {\n        editor.on('init', function () {\n          editor.dom.bind(editor.getBody(), 'submit', function (e) {\n            e.preventDefault();\n          });\n        });\n      };\n      var removeAppleInterchangeBrs = function () {\n        parser.addNodeFilter('br', function (nodes) {\n          var i = nodes.length;\n          while (i--) {\n            if (nodes[i].attr('class') === 'Apple-interchange-newline') {\n              nodes[i].remove();\n            }\n          }\n        });\n      };\n      var ieInternalDragAndDrop = function () {\n        editor.on('dragstart', function (e) {\n          setMceInternalContent(e);\n        });\n        editor.on('drop', function (e) {\n          if (!isDefaultPrevented(e)) {\n            var internalContent = getMceInternalContent(e);\n            if (internalContent && internalContent.id !== editor.id) {\n              e.preventDefault();\n              var rng = fromPoint(e.x, e.y, editor.getDoc());\n              selection.setRng(rng);\n              insertClipboardContents(internalContent.html, true);\n            }\n          }\n        });\n      };\n      var refreshContentEditable = noop;\n      var isHidden = function () {\n        if (!isGecko || editor.removed) {\n          return false;\n        }\n        var sel = editor.selection.getSel();\n        return !sel || !sel.rangeCount || sel.rangeCount === 0;\n      };\n      var setupRtc = function () {\n        if (isWebKit) {\n          documentElementEditingFocus();\n          selectControlElements();\n          blockFormSubmitInsideEditor();\n          selectAll();\n          if (Env.iOS) {\n            restoreFocusOnKeyDown();\n            bodyHeight();\n            tapLinksAndImages();\n          }\n        }\n        if (isGecko) {\n          focusBody();\n          setGeckoEditingOptions();\n          showBrokenImageIcon();\n          blockCmdArrowNavigation();\n        }\n      };\n      var setup = function () {\n        removeBlockQuoteOnBackSpace();\n        emptyEditorWhenDeleting();\n        if (!Env.windowsPhone) {\n          normalizeSelection();\n        }\n        if (isWebKit) {\n          documentElementEditingFocus();\n          selectControlElements();\n          setDefaultBlockType();\n          blockFormSubmitInsideEditor();\n          disableBackspaceIntoATable();\n          removeAppleInterchangeBrs();\n          if (Env.iOS) {\n            restoreFocusOnKeyDown();\n            bodyHeight();\n            tapLinksAndImages();\n          } else {\n            selectAll();\n          }\n        }\n        if (Env.ie >= 11) {\n          bodyHeight();\n          disableBackspaceIntoATable();\n        }\n        if (Env.ie) {\n          selectAll();\n          disableAutoUrlDetect();\n          ieInternalDragAndDrop();\n        }\n        if (isGecko) {\n          removeHrOnBackspace();\n          focusBody();\n          removeStylesWhenDeletingAcrossBlockElements();\n          setGeckoEditingOptions();\n          addBrAfterLastLinks();\n          showBrokenImageIcon();\n          blockCmdArrowNavigation();\n          disableBackspaceIntoATable();\n        }\n      };\n      if (isRtc(editor)) {\n        setupRtc();\n      } else {\n        setup();\n      }\n      return {\n        refreshContentEditable: refreshContentEditable,\n        isHidden: isHidden\n      };\n    };\n\n    var DOM$6 = DOMUtils.DOM;\n    var appendStyle = function (editor, text) {\n      var body = SugarElement.fromDom(editor.getBody());\n      var container = getStyleContainer(getRootNode(body));\n      var style = SugarElement.fromTag('style');\n      set$1(style, 'type', 'text/css');\n      append$1(style, SugarElement.fromText(text));\n      append$1(container, style);\n      editor.on('remove', function () {\n        remove$7(style);\n      });\n    };\n    var getRootName = function (editor) {\n      return editor.inline ? editor.getElement().nodeName.toLowerCase() : undefined;\n    };\n    var removeUndefined = function (obj) {\n      return filter$3(obj, function (v) {\n        return isUndefined(v) === false;\n      });\n    };\n    var mkSchemaSettings = function (editor) {\n      var settings = editor.settings;\n      return removeUndefined({\n        block_elements: settings.block_elements,\n        boolean_attributes: settings.boolean_attributes,\n        custom_elements: settings.custom_elements,\n        extended_valid_elements: settings.extended_valid_elements,\n        invalid_elements: settings.invalid_elements,\n        invalid_styles: settings.invalid_styles,\n        move_caret_before_on_enter_elements: settings.move_caret_before_on_enter_elements,\n        non_empty_elements: settings.non_empty_elements,\n        schema: settings.schema,\n        self_closing_elements: settings.self_closing_elements,\n        short_ended_elements: settings.short_ended_elements,\n        special: settings.special,\n        text_block_elements: settings.text_block_elements,\n        text_inline_elements: settings.text_inline_elements,\n        valid_children: settings.valid_children,\n        valid_classes: settings.valid_classes,\n        valid_elements: settings.valid_elements,\n        valid_styles: settings.valid_styles,\n        verify_html: settings.verify_html,\n        whitespace_elements: settings.whitespace_elements,\n        padd_empty_block_inline_children: settings.format_empty_lines\n      });\n    };\n    var mkParserSettings = function (editor) {\n      var settings = editor.settings;\n      var blobCache = editor.editorUpload.blobCache;\n      return removeUndefined({\n        allow_conditional_comments: settings.allow_conditional_comments,\n        allow_html_data_urls: settings.allow_html_data_urls,\n        allow_svg_data_urls: settings.allow_svg_data_urls,\n        allow_html_in_named_anchor: settings.allow_html_in_named_anchor,\n        allow_script_urls: settings.allow_script_urls,\n        allow_unsafe_link_target: settings.allow_unsafe_link_target,\n        convert_fonts_to_spans: settings.convert_fonts_to_spans,\n        fix_list_elements: settings.fix_list_elements,\n        font_size_legacy_values: settings.font_size_legacy_values,\n        forced_root_block: settings.forced_root_block,\n        forced_root_block_attrs: settings.forced_root_block_attrs,\n        padd_empty_with_br: settings.padd_empty_with_br,\n        preserve_cdata: settings.preserve_cdata,\n        remove_trailing_brs: settings.remove_trailing_brs,\n        inline_styles: settings.inline_styles,\n        root_name: getRootName(editor),\n        validate: true,\n        blob_cache: blobCache,\n        document: editor.getDoc(),\n        images_dataimg_filter: settings.images_dataimg_filter\n      });\n    };\n    var mkSerializerSettings = function (editor) {\n      var settings = editor.settings;\n      return __assign(__assign(__assign({}, mkParserSettings(editor)), mkSchemaSettings(editor)), removeUndefined({\n        url_converter: settings.url_converter,\n        url_converter_scope: settings.url_converter_scope,\n        element_format: settings.element_format,\n        entities: settings.entities,\n        entity_encoding: settings.entity_encoding,\n        indent: settings.indent,\n        indent_after: settings.indent_after,\n        indent_before: settings.indent_before\n      }));\n    };\n    var createParser = function (editor) {\n      var parser = DomParser(mkParserSettings(editor), editor.schema);\n      parser.addAttributeFilter('src,href,style,tabindex', function (nodes, name) {\n        var i = nodes.length, node, value;\n        var dom = editor.dom;\n        var internalName = 'data-mce-' + name;\n        while (i--) {\n          node = nodes[i];\n          value = node.attr(name);\n          if (value && !node.attr(internalName)) {\n            if (value.indexOf('data:') === 0 || value.indexOf('blob:') === 0) {\n              continue;\n            }\n            if (name === 'style') {\n              value = dom.serializeStyle(dom.parseStyle(value), node.name);\n              if (!value.length) {\n                value = null;\n              }\n              node.attr(internalName, value);\n              node.attr(name, value);\n            } else if (name === 'tabindex') {\n              node.attr(internalName, value);\n              node.attr(name, null);\n            } else {\n              node.attr(internalName, editor.convertURL(value, name, node.name));\n            }\n          }\n        }\n      });\n      parser.addNodeFilter('script', function (nodes) {\n        var i = nodes.length;\n        while (i--) {\n          var node = nodes[i];\n          var type = node.attr('type') || 'no/type';\n          if (type.indexOf('mce-') !== 0) {\n            node.attr('type', 'mce-' + type);\n          }\n        }\n      });\n      if (editor.settings.preserve_cdata) {\n        parser.addNodeFilter('#cdata', function (nodes) {\n          var i = nodes.length;\n          while (i--) {\n            var node = nodes[i];\n            node.type = 8;\n            node.name = '#comment';\n            node.value = '[CDATA[' + editor.dom.encode(node.value) + ']]';\n          }\n        });\n      }\n      parser.addNodeFilter('p,h1,h2,h3,h4,h5,h6,div', function (nodes) {\n        var i = nodes.length;\n        var nonEmptyElements = editor.schema.getNonEmptyElements();\n        while (i--) {\n          var node = nodes[i];\n          if (node.isEmpty(nonEmptyElements) && node.getAll('br').length === 0) {\n            node.append(new AstNode('br', 1)).shortEnded = true;\n          }\n        }\n      });\n      return parser;\n    };\n    var autoFocus = function (editor) {\n      if (editor.settings.auto_focus) {\n        Delay.setEditorTimeout(editor, function () {\n          var focusEditor;\n          if (editor.settings.auto_focus === true) {\n            focusEditor = editor;\n          } else {\n            focusEditor = editor.editorManager.get(editor.settings.auto_focus);\n          }\n          if (!focusEditor.destroyed) {\n            focusEditor.focus();\n          }\n        }, 100);\n      }\n    };\n    var moveSelectionToFirstCaretPosition = function (editor) {\n      var root = editor.dom.getRoot();\n      if (!editor.inline && (!hasAnyRanges(editor) || editor.selection.getStart(true) === root)) {\n        firstPositionIn(root).each(function (pos) {\n          var node = pos.getNode();\n          var caretPos = isTable$3(node) ? firstPositionIn(node).getOr(pos) : pos;\n          if (Env.browser.isIE()) {\n            storeNative(editor, caretPos.toRange());\n          } else {\n            editor.selection.setRng(caretPos.toRange());\n          }\n        });\n      }\n    };\n    var initEditor = function (editor) {\n      editor.bindPendingEventDelegates();\n      editor.initialized = true;\n      fireInit(editor);\n      editor.focus(true);\n      moveSelectionToFirstCaretPosition(editor);\n      editor.nodeChanged({ initial: true });\n      editor.execCallback('init_instance_callback', editor);\n      autoFocus(editor);\n    };\n    var getStyleSheetLoader$1 = function (editor) {\n      return editor.inline ? editor.ui.styleSheetLoader : editor.dom.styleSheetLoader;\n    };\n    var makeStylesheetLoadingPromises = function (editor, css, framedFonts) {\n      var promises = [new promiseObj(function (resolve, reject) {\n          return getStyleSheetLoader$1(editor).loadAll(css, resolve, reject);\n        })];\n      if (editor.inline) {\n        return promises;\n      } else {\n        return promises.concat([new promiseObj(function (resolve, reject) {\n            return editor.ui.styleSheetLoader.loadAll(framedFonts, resolve, reject);\n          })]);\n      }\n    };\n    var loadContentCss = function (editor) {\n      var styleSheetLoader = getStyleSheetLoader$1(editor);\n      var fontCss = getFontCss(editor);\n      var css = editor.contentCSS;\n      var removeCss = function () {\n        styleSheetLoader.unloadAll(css);\n        if (!editor.inline) {\n          editor.ui.styleSheetLoader.unloadAll(fontCss);\n        }\n      };\n      var loaded = function () {\n        if (editor.removed) {\n          removeCss();\n        } else {\n          editor.on('remove', removeCss);\n        }\n      };\n      if (editor.contentStyles.length > 0) {\n        var contentCssText_1 = '';\n        Tools.each(editor.contentStyles, function (style) {\n          contentCssText_1 += style + '\\r\\n';\n        });\n        editor.dom.addStyle(contentCssText_1);\n      }\n      var allStylesheets = promiseObj.all(makeStylesheetLoadingPromises(editor, css, fontCss)).then(loaded).catch(loaded);\n      if (editor.settings.content_style) {\n        appendStyle(editor, editor.settings.content_style);\n      }\n      return allStylesheets;\n    };\n    var preInit = function (editor) {\n      var settings = editor.settings, doc = editor.getDoc(), body = editor.getBody();\n      firePreInit(editor);\n      if (!settings.browser_spellcheck && !settings.gecko_spellcheck) {\n        doc.body.spellcheck = false;\n        DOM$6.setAttrib(body, 'spellcheck', 'false');\n      }\n      editor.quirks = Quirks(editor);\n      firePostRender(editor);\n      var directionality = getDirectionality(editor);\n      if (directionality !== undefined) {\n        body.dir = directionality;\n      }\n      if (settings.protect) {\n        editor.on('BeforeSetContent', function (e) {\n          Tools.each(settings.protect, function (pattern) {\n            e.content = e.content.replace(pattern, function (str) {\n              return '<!--mce:protected ' + escape(str) + '-->';\n            });\n          });\n        });\n      }\n      editor.on('SetContent', function () {\n        editor.addVisual(editor.getBody());\n      });\n      editor.on('compositionstart compositionend', function (e) {\n        editor.composing = e.type === 'compositionstart';\n      });\n    };\n    var loadInitialContent = function (editor) {\n      if (!isRtc(editor)) {\n        editor.load({\n          initial: true,\n          format: 'html'\n        });\n      }\n      editor.startContent = editor.getContent({ format: 'raw' });\n    };\n    var initEditorWithInitialContent = function (editor) {\n      if (editor.removed !== true) {\n        loadInitialContent(editor);\n        initEditor(editor);\n      }\n    };\n    var initContentBody = function (editor, skipWrite) {\n      var settings = editor.settings;\n      var targetElm = editor.getElement();\n      var doc = editor.getDoc();\n      if (!settings.inline) {\n        editor.getElement().style.visibility = editor.orgVisibility;\n      }\n      if (!skipWrite && !editor.inline) {\n        doc.open();\n        doc.write(editor.iframeHTML);\n        doc.close();\n      }\n      if (editor.inline) {\n        DOM$6.addClass(targetElm, 'mce-content-body');\n        editor.contentDocument = doc = document;\n        editor.contentWindow = window;\n        editor.bodyElement = targetElm;\n        editor.contentAreaContainer = targetElm;\n      }\n      var body = editor.getBody();\n      body.disabled = true;\n      editor.readonly = !!settings.readonly;\n      if (!editor.readonly) {\n        if (editor.inline && DOM$6.getStyle(body, 'position', true) === 'static') {\n          body.style.position = 'relative';\n        }\n        body.contentEditable = editor.getParam('content_editable_state', true);\n      }\n      body.disabled = false;\n      editor.editorUpload = EditorUpload(editor);\n      editor.schema = Schema(mkSchemaSettings(editor));\n      editor.dom = DOMUtils(doc, {\n        keep_values: true,\n        url_converter: editor.convertURL,\n        url_converter_scope: editor,\n        hex_colors: settings.force_hex_style_colors,\n        update_styles: true,\n        root_element: editor.inline ? editor.getBody() : null,\n        collect: function () {\n          return editor.inline;\n        },\n        schema: editor.schema,\n        contentCssCors: shouldUseContentCssCors(editor),\n        referrerPolicy: getReferrerPolicy(editor),\n        onSetAttrib: function (e) {\n          editor.fire('SetAttrib', e);\n        }\n      });\n      editor.parser = createParser(editor);\n      editor.serializer = DomSerializer(mkSerializerSettings(editor), editor);\n      editor.selection = EditorSelection(editor.dom, editor.getWin(), editor.serializer, editor);\n      editor.annotator = Annotator(editor);\n      editor.formatter = Formatter(editor);\n      editor.undoManager = UndoManager(editor);\n      editor._nodeChangeDispatcher = new NodeChange(editor);\n      editor._selectionOverrides = SelectionOverrides(editor);\n      setup$e(editor);\n      setup$3(editor);\n      if (!isRtc(editor)) {\n        setup$2(editor);\n      }\n      var caret = setup$4(editor);\n      setup$f(editor, caret);\n      setup$d(editor);\n      setup$g(editor);\n      var setupRtcThunk = setup$i(editor);\n      preInit(editor);\n      setupRtcThunk.fold(function () {\n        loadContentCss(editor).then(function () {\n          return initEditorWithInitialContent(editor);\n        });\n      }, function (setupRtc) {\n        editor.setProgressState(true);\n        loadContentCss(editor).then(function () {\n          setupRtc().then(function (_rtcMode) {\n            editor.setProgressState(false);\n            initEditorWithInitialContent(editor);\n          }, function (err) {\n            editor.notificationManager.open({\n              type: 'error',\n              text: String(err)\n            });\n            initEditorWithInitialContent(editor);\n          });\n        });\n      });\n    };\n\n    var DOM$5 = DOMUtils.DOM;\n    var relaxDomain = function (editor, ifr) {\n      if (document.domain !== window.location.hostname && Env.browser.isIE()) {\n        var bodyUuid = uuid('mce');\n        editor[bodyUuid] = function () {\n          initContentBody(editor);\n        };\n        var domainRelaxUrl = 'javascript:(function(){' + 'document.open();document.domain=\"' + document.domain + '\";' + 'var ed = window.parent.tinymce.get(\"' + editor.id + '\");document.write(ed.iframeHTML);' + 'document.close();ed.' + bodyUuid + '(true);})()';\n        DOM$5.setAttrib(ifr, 'src', domainRelaxUrl);\n        return true;\n      }\n      return false;\n    };\n    var createIframeElement = function (id, title, height, customAttrs) {\n      var iframe = SugarElement.fromTag('iframe');\n      setAll$1(iframe, customAttrs);\n      setAll$1(iframe, {\n        id: id + '_ifr',\n        frameBorder: '0',\n        allowTransparency: 'true',\n        title: title\n      });\n      add$1(iframe, 'tox-edit-area__iframe');\n      return iframe;\n    };\n    var getIframeHtml = function (editor) {\n      var iframeHTML = getDocType(editor) + '<html><head>';\n      if (getDocumentBaseUrl(editor) !== editor.documentBaseUrl) {\n        iframeHTML += '<base href=\"' + editor.documentBaseURI.getURI() + '\" />';\n      }\n      iframeHTML += '<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />';\n      var bodyId = getBodyId(editor);\n      var bodyClass = getBodyClass(editor);\n      var translatedAriaText = editor.translate(getIframeAriaText(editor));\n      if (getContentSecurityPolicy(editor)) {\n        iframeHTML += '<meta http-equiv=\"Content-Security-Policy\" content=\"' + getContentSecurityPolicy(editor) + '\" />';\n      }\n      iframeHTML += '</head>' + ('<body id=\"' + bodyId + '\" class=\"mce-content-body ' + bodyClass + '\" data-id=\"' + editor.id + '\" aria-label=\"' + translatedAriaText + '\">') + '<br>' + '</body></html>';\n      return iframeHTML;\n    };\n    var createIframe = function (editor, o) {\n      var iframeTitle = editor.translate('Rich Text Area');\n      var ifr = createIframeElement(editor.id, iframeTitle, o.height, getIframeAttrs(editor)).dom;\n      ifr.onload = function () {\n        ifr.onload = null;\n        editor.fire('load');\n      };\n      var isDomainRelaxed = relaxDomain(editor, ifr);\n      editor.contentAreaContainer = o.iframeContainer;\n      editor.iframeElement = ifr;\n      editor.iframeHTML = getIframeHtml(editor);\n      DOM$5.add(o.iframeContainer, ifr);\n      return isDomainRelaxed;\n    };\n    var init$1 = function (editor, boxInfo) {\n      var isDomainRelaxed = createIframe(editor, boxInfo);\n      if (boxInfo.editorContainer) {\n        DOM$5.get(boxInfo.editorContainer).style.display = editor.orgDisplay;\n        editor.hidden = DOM$5.isHidden(boxInfo.editorContainer);\n      }\n      editor.getElement().style.display = 'none';\n      DOM$5.setAttrib(editor.id, 'aria-hidden', 'true');\n      if (!isDomainRelaxed) {\n        initContentBody(editor);\n      }\n    };\n\n    var DOM$4 = DOMUtils.DOM;\n    var initPlugin = function (editor, initializedPlugins, plugin) {\n      var Plugin = PluginManager.get(plugin);\n      var pluginUrl = PluginManager.urls[plugin] || editor.documentBaseUrl.replace(/\\/$/, '');\n      plugin = Tools.trim(plugin);\n      if (Plugin && Tools.inArray(initializedPlugins, plugin) === -1) {\n        Tools.each(PluginManager.dependencies(plugin), function (dep) {\n          initPlugin(editor, initializedPlugins, dep);\n        });\n        if (editor.plugins[plugin]) {\n          return;\n        }\n        try {\n          var pluginInstance = new Plugin(editor, pluginUrl, editor.$);\n          editor.plugins[plugin] = pluginInstance;\n          if (pluginInstance.init) {\n            pluginInstance.init(editor, pluginUrl);\n            initializedPlugins.push(plugin);\n          }\n        } catch (e) {\n          pluginInitError(editor, plugin, e);\n        }\n      }\n    };\n    var trimLegacyPrefix = function (name) {\n      return name.replace(/^\\-/, '');\n    };\n    var initPlugins = function (editor) {\n      var initializedPlugins = [];\n      Tools.each(getPlugins(editor).split(/[ ,]/), function (name) {\n        initPlugin(editor, initializedPlugins, trimLegacyPrefix(name));\n      });\n    };\n    var initIcons = function (editor) {\n      var iconPackName = Tools.trim(getIconPackName(editor));\n      var currentIcons = editor.ui.registry.getAll().icons;\n      var loadIcons = __assign(__assign({}, IconManager.get('default').icons), IconManager.get(iconPackName).icons);\n      each$j(loadIcons, function (svgData, icon) {\n        if (!has$2(currentIcons, icon)) {\n          editor.ui.registry.addIcon(icon, svgData);\n        }\n      });\n    };\n    var initTheme = function (editor) {\n      var theme = getTheme(editor);\n      if (isString$1(theme)) {\n        editor.settings.theme = trimLegacyPrefix(theme);\n        var Theme = ThemeManager.get(theme);\n        editor.theme = new Theme(editor, ThemeManager.urls[theme]);\n        if (editor.theme.init) {\n          editor.theme.init(editor, ThemeManager.urls[theme] || editor.documentBaseUrl.replace(/\\/$/, ''), editor.$);\n        }\n      } else {\n        editor.theme = {};\n      }\n    };\n    var renderFromLoadedTheme = function (editor) {\n      return editor.theme.renderUI();\n    };\n    var renderFromThemeFunc = function (editor) {\n      var elm = editor.getElement();\n      var theme = getTheme(editor);\n      var info = theme(editor, elm);\n      if (info.editorContainer.nodeType) {\n        info.editorContainer.id = info.editorContainer.id || editor.id + '_parent';\n      }\n      if (info.iframeContainer && info.iframeContainer.nodeType) {\n        info.iframeContainer.id = info.iframeContainer.id || editor.id + '_iframecontainer';\n      }\n      info.height = info.iframeHeight ? info.iframeHeight : elm.offsetHeight;\n      return info;\n    };\n    var createThemeFalseResult = function (element) {\n      return {\n        editorContainer: element,\n        iframeContainer: element,\n        api: {}\n      };\n    };\n    var renderThemeFalseIframe = function (targetElement) {\n      var iframeContainer = DOM$4.create('div');\n      DOM$4.insertAfter(iframeContainer, targetElement);\n      return createThemeFalseResult(iframeContainer);\n    };\n    var renderThemeFalse = function (editor) {\n      var targetElement = editor.getElement();\n      return editor.inline ? createThemeFalseResult(null) : renderThemeFalseIframe(targetElement);\n    };\n    var renderThemeUi = function (editor) {\n      var elm = editor.getElement();\n      editor.orgDisplay = elm.style.display;\n      if (isString$1(getTheme(editor))) {\n        return renderFromLoadedTheme(editor);\n      } else if (isFunction(getTheme(editor))) {\n        return renderFromThemeFunc(editor);\n      } else {\n        return renderThemeFalse(editor);\n      }\n    };\n    var augmentEditorUiApi = function (editor, api) {\n      var uiApiFacade = {\n        show: Optional.from(api.show).getOr(noop),\n        hide: Optional.from(api.hide).getOr(noop),\n        disable: Optional.from(api.disable).getOr(noop),\n        isDisabled: Optional.from(api.isDisabled).getOr(never),\n        enable: function () {\n          if (!editor.mode.isReadOnly()) {\n            Optional.from(api.enable).map(call);\n          }\n        }\n      };\n      editor.ui = __assign(__assign({}, editor.ui), uiApiFacade);\n    };\n    var init = function (editor) {\n      editor.fire('ScriptsLoaded');\n      initIcons(editor);\n      initTheme(editor);\n      initPlugins(editor);\n      var renderInfo = renderThemeUi(editor);\n      augmentEditorUiApi(editor, Optional.from(renderInfo.api).getOr({}));\n      var boxInfo = {\n        editorContainer: renderInfo.editorContainer,\n        iframeContainer: renderInfo.iframeContainer\n      };\n      editor.editorContainer = boxInfo.editorContainer ? boxInfo.editorContainer : null;\n      appendContentCssFromSettings(editor);\n      if (editor.inline) {\n        return initContentBody(editor);\n      } else {\n        return init$1(editor, boxInfo);\n      }\n    };\n\n    var DOM$3 = DOMUtils.DOM;\n    var hasSkipLoadPrefix = function (name) {\n      return name.charAt(0) === '-';\n    };\n    var loadLanguage = function (scriptLoader, editor) {\n      var languageCode = getLanguageCode(editor);\n      var languageUrl = getLanguageUrl(editor);\n      if (I18n.hasCode(languageCode) === false && languageCode !== 'en') {\n        var url_1 = languageUrl !== '' ? languageUrl : editor.editorManager.baseURL + '/langs/' + languageCode + '.js';\n        scriptLoader.add(url_1, noop, undefined, function () {\n          languageLoadError(editor, url_1, languageCode);\n        });\n      }\n    };\n    var loadTheme = function (scriptLoader, editor, suffix, callback) {\n      var theme = getTheme(editor);\n      if (isString$1(theme)) {\n        if (!hasSkipLoadPrefix(theme) && !has$2(ThemeManager.urls, theme)) {\n          var themeUrl = getThemeUrl(editor);\n          if (themeUrl) {\n            ThemeManager.load(theme, editor.documentBaseURI.toAbsolute(themeUrl));\n          } else {\n            ThemeManager.load(theme, 'themes/' + theme + '/theme' + suffix + '.js');\n          }\n        }\n        scriptLoader.loadQueue(function () {\n          ThemeManager.waitFor(theme, callback);\n        });\n      } else {\n        callback();\n      }\n    };\n    var getIconsUrlMetaFromUrl = function (editor) {\n      return Optional.from(getIconsUrl(editor)).filter(function (url) {\n        return url.length > 0;\n      }).map(function (url) {\n        return {\n          url: url,\n          name: Optional.none()\n        };\n      });\n    };\n    var getIconsUrlMetaFromName = function (editor, name, suffix) {\n      return Optional.from(name).filter(function (name) {\n        return name.length > 0 && !IconManager.has(name);\n      }).map(function (name) {\n        return {\n          url: editor.editorManager.baseURL + '/icons/' + name + '/icons' + suffix + '.js',\n          name: Optional.some(name)\n        };\n      });\n    };\n    var loadIcons = function (scriptLoader, editor, suffix) {\n      var defaultIconsUrl = getIconsUrlMetaFromName(editor, 'default', suffix);\n      var customIconsUrl = getIconsUrlMetaFromUrl(editor).orThunk(function () {\n        return getIconsUrlMetaFromName(editor, getIconPackName(editor), '');\n      });\n      each$k(cat([\n        defaultIconsUrl,\n        customIconsUrl\n      ]), function (urlMeta) {\n        scriptLoader.add(urlMeta.url, noop, undefined, function () {\n          iconsLoadError(editor, urlMeta.url, urlMeta.name.getOrUndefined());\n        });\n      });\n    };\n    var loadPlugins = function (editor, suffix) {\n      Tools.each(getExternalPlugins$1(editor), function (url, name) {\n        PluginManager.load(name, url, noop, undefined, function () {\n          pluginLoadError(editor, url, name);\n        });\n        editor.settings.plugins += ' ' + name;\n      });\n      Tools.each(getPlugins(editor).split(/[ ,]/), function (plugin) {\n        plugin = Tools.trim(plugin);\n        if (plugin && !PluginManager.urls[plugin]) {\n          if (hasSkipLoadPrefix(plugin)) {\n            plugin = plugin.substr(1, plugin.length);\n            var dependencies = PluginManager.dependencies(plugin);\n            Tools.each(dependencies, function (depPlugin) {\n              var defaultSettings = {\n                prefix: 'plugins/',\n                resource: depPlugin,\n                suffix: '/plugin' + suffix + '.js'\n              };\n              var dep = PluginManager.createUrl(defaultSettings, depPlugin);\n              PluginManager.load(dep.resource, dep, noop, undefined, function () {\n                pluginLoadError(editor, dep.prefix + dep.resource + dep.suffix, dep.resource);\n              });\n            });\n          } else {\n            var url_2 = {\n              prefix: 'plugins/',\n              resource: plugin,\n              suffix: '/plugin' + suffix + '.js'\n            };\n            PluginManager.load(plugin, url_2, noop, undefined, function () {\n              pluginLoadError(editor, url_2.prefix + url_2.resource + url_2.suffix, plugin);\n            });\n          }\n        }\n      });\n    };\n    var loadScripts = function (editor, suffix) {\n      var scriptLoader = ScriptLoader.ScriptLoader;\n      loadTheme(scriptLoader, editor, suffix, function () {\n        loadLanguage(scriptLoader, editor);\n        loadIcons(scriptLoader, editor, suffix);\n        loadPlugins(editor, suffix);\n        scriptLoader.loadQueue(function () {\n          if (!editor.removed) {\n            init(editor);\n          }\n        }, editor, function () {\n          if (!editor.removed) {\n            init(editor);\n          }\n        });\n      });\n    };\n    var getStyleSheetLoader = function (element, editor) {\n      return instance.forElement(element, {\n        contentCssCors: hasContentCssCors(editor),\n        referrerPolicy: getReferrerPolicy(editor)\n      });\n    };\n    var render = function (editor) {\n      var id = editor.id;\n      I18n.setCode(getLanguageCode(editor));\n      var readyHandler = function () {\n        DOM$3.unbind(window, 'ready', readyHandler);\n        editor.render();\n      };\n      if (!EventUtils.Event.domLoaded) {\n        DOM$3.bind(window, 'ready', readyHandler);\n        return;\n      }\n      if (!editor.getElement()) {\n        return;\n      }\n      if (!Env.contentEditable) {\n        return;\n      }\n      var element = SugarElement.fromDom(editor.getElement());\n      var snapshot = clone$3(element);\n      editor.on('remove', function () {\n        eachr(element.dom.attributes, function (attr) {\n          return remove$6(element, attr.name);\n        });\n        setAll$1(element, snapshot);\n      });\n      editor.ui.styleSheetLoader = getStyleSheetLoader(element, editor);\n      if (!isInline(editor)) {\n        editor.orgVisibility = editor.getElement().style.visibility;\n        editor.getElement().style.visibility = 'hidden';\n      } else {\n        editor.inline = true;\n      }\n      var form = editor.getElement().form || DOM$3.getParent(id, 'form');\n      if (form) {\n        editor.formElement = form;\n        if (hasHiddenInput(editor) && !isTextareaOrInput(editor.getElement())) {\n          DOM$3.insertAfter(DOM$3.create('input', {\n            type: 'hidden',\n            name: id\n          }), id);\n          editor.hasHiddenInput = true;\n        }\n        editor.formEventDelegate = function (e) {\n          editor.fire(e.type, e);\n        };\n        DOM$3.bind(form, 'submit reset', editor.formEventDelegate);\n        editor.on('reset', function () {\n          editor.resetContent();\n        });\n        if (shouldPatchSubmit(editor) && !form.submit.nodeType && !form.submit.length && !form._mceOldSubmit) {\n          form._mceOldSubmit = form.submit;\n          form.submit = function () {\n            editor.editorManager.triggerSave();\n            editor.setDirty(false);\n            return form._mceOldSubmit(form);\n          };\n        }\n      }\n      editor.windowManager = WindowManager(editor);\n      editor.notificationManager = NotificationManager(editor);\n      if (isEncodingXml(editor)) {\n        editor.on('GetContent', function (e) {\n          if (e.save) {\n            e.content = DOM$3.encode(e.content);\n          }\n        });\n      }\n      if (shouldAddFormSubmitTrigger(editor)) {\n        editor.on('submit', function () {\n          if (editor.initialized) {\n            editor.save();\n          }\n        });\n      }\n      if (shouldAddUnloadTrigger(editor)) {\n        editor._beforeUnload = function () {\n          if (editor.initialized && !editor.destroyed && !editor.isHidden()) {\n            editor.save({\n              format: 'raw',\n              no_events: true,\n              set_dirty: false\n            });\n          }\n        };\n        editor.editorManager.on('BeforeUnload', editor._beforeUnload);\n      }\n      editor.editorManager.add(editor);\n      loadScripts(editor, editor.suffix);\n    };\n\n    var addVisual = function (editor, elm) {\n      return addVisual$1(editor, elm);\n    };\n\n    var legacyPropNames = {\n      'font-size': 'size',\n      'font-family': 'face'\n    };\n    var getSpecifiedFontProp = function (propName, rootElm, elm) {\n      var getProperty = function (elm) {\n        return getRaw(elm, propName).orThunk(function () {\n          if (name(elm) === 'font') {\n            return get$9(legacyPropNames, propName).bind(function (legacyPropName) {\n              return getOpt(elm, legacyPropName);\n            });\n          } else {\n            return Optional.none();\n          }\n        });\n      };\n      var isRoot = function (elm) {\n        return eq(SugarElement.fromDom(rootElm), elm);\n      };\n      return closest$1(SugarElement.fromDom(elm), function (elm) {\n        return getProperty(elm);\n      }, isRoot);\n    };\n    var normalizeFontFamily = function (fontFamily) {\n      return fontFamily.replace(/[\\'\\\"\\\\]/g, '').replace(/,\\s+/g, ',');\n    };\n    var getComputedFontProp = function (propName, elm) {\n      return Optional.from(DOMUtils.DOM.getStyle(elm, propName, true));\n    };\n    var getFontProp = function (propName) {\n      return function (rootElm, elm) {\n        return Optional.from(elm).map(SugarElement.fromDom).filter(isElement$6).bind(function (element) {\n          return getSpecifiedFontProp(propName, rootElm, element.dom).or(getComputedFontProp(propName, element.dom));\n        }).getOr('');\n      };\n    };\n    var getFontSize = getFontProp('font-size');\n    var getFontFamily = compose(normalizeFontFamily, getFontProp('font-family'));\n\n    var findFirstCaretElement = function (editor) {\n      return firstPositionIn(editor.getBody()).map(function (caret) {\n        var container = caret.container();\n        return isText$7(container) ? container.parentNode : container;\n      });\n    };\n    var getCaretElement = function (editor) {\n      return Optional.from(editor.selection.getRng()).bind(function (rng) {\n        var root = editor.getBody();\n        var atStartOfNode = rng.startContainer === root && rng.startOffset === 0;\n        return atStartOfNode ? Optional.none() : Optional.from(editor.selection.getStart(true));\n      });\n    };\n    var bindRange = function (editor, binder) {\n      return getCaretElement(editor).orThunk(curry(findFirstCaretElement, editor)).map(SugarElement.fromDom).filter(isElement$6).bind(binder);\n    };\n    var mapRange = function (editor, mapper) {\n      return bindRange(editor, compose1(Optional.some, mapper));\n    };\n\n    var fromFontSizeNumber = function (editor, value) {\n      if (/^[0-9.]+$/.test(value)) {\n        var fontSizeNumber = parseInt(value, 10);\n        if (fontSizeNumber >= 1 && fontSizeNumber <= 7) {\n          var fontSizes = getFontStyleValues(editor);\n          var fontClasses = getFontSizeClasses(editor);\n          if (fontClasses) {\n            return fontClasses[fontSizeNumber - 1] || value;\n          } else {\n            return fontSizes[fontSizeNumber - 1] || value;\n          }\n        } else {\n          return value;\n        }\n      } else {\n        return value;\n      }\n    };\n    var normalizeFontNames = function (font) {\n      var fonts = font.split(/\\s*,\\s*/);\n      return map$3(fonts, function (font) {\n        if (font.indexOf(' ') !== -1 && !(startsWith(font, '\"') || startsWith(font, '\\''))) {\n          return '\\'' + font + '\\'';\n        } else {\n          return font;\n        }\n      }).join(',');\n    };\n    var fontNameAction = function (editor, value) {\n      var font = fromFontSizeNumber(editor, value);\n      editor.formatter.toggle('fontname', { value: normalizeFontNames(font) });\n      editor.nodeChanged();\n    };\n    var fontNameQuery = function (editor) {\n      return mapRange(editor, function (elm) {\n        return getFontFamily(editor.getBody(), elm.dom);\n      }).getOr('');\n    };\n    var fontSizeAction = function (editor, value) {\n      editor.formatter.toggle('fontsize', { value: fromFontSizeNumber(editor, value) });\n      editor.nodeChanged();\n    };\n    var fontSizeQuery = function (editor) {\n      return mapRange(editor, function (elm) {\n        return getFontSize(editor.getBody(), elm.dom);\n      }).getOr('');\n    };\n\n    var lineHeightQuery = function (editor) {\n      return mapRange(editor, function (elm) {\n        var root = SugarElement.fromDom(editor.getBody());\n        var specifiedStyle = closest$1(elm, function (elm) {\n          return getRaw(elm, 'line-height');\n        }, curry(eq, root));\n        var computedStyle = function () {\n          var lineHeight = parseFloat(get$5(elm, 'line-height'));\n          var fontSize = parseFloat(get$5(elm, 'font-size'));\n          return String(lineHeight / fontSize);\n        };\n        return specifiedStyle.getOrThunk(computedStyle);\n      }).getOr('');\n    };\n    var lineHeightAction = function (editor, lineHeight) {\n      editor.formatter.toggle('lineheight', { value: String(lineHeight) });\n      editor.nodeChanged();\n    };\n\n    var processValue = function (value) {\n      if (typeof value !== 'string') {\n        var details = Tools.extend({\n          paste: value.paste,\n          data: { paste: value.paste }\n        }, value);\n        return {\n          content: value.content,\n          details: details\n        };\n      }\n      return {\n        content: value,\n        details: {}\n      };\n    };\n    var insertAtCaret = function (editor, value) {\n      var result = processValue(value);\n      insertContent(editor, result.content, result.details);\n    };\n\n    var each$4 = Tools.each;\n    var map = Tools.map, inArray = Tools.inArray;\n    var EditorCommands = function () {\n      function EditorCommands(editor) {\n        this.commands = {\n          state: {},\n          exec: {},\n          value: {}\n        };\n        this.editor = editor;\n        this.setupCommands(editor);\n      }\n      EditorCommands.prototype.execCommand = function (command, ui, value, args) {\n        var func, state = false;\n        var self = this;\n        if (self.editor.removed) {\n          return;\n        }\n        if (command.toLowerCase() !== 'mcefocus') {\n          if (!/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint)$/.test(command) && (!args || !args.skip_focus)) {\n            self.editor.focus();\n          } else {\n            restore(self.editor);\n          }\n        }\n        args = self.editor.fire('BeforeExecCommand', {\n          command: command,\n          ui: ui,\n          value: value\n        });\n        if (args.isDefaultPrevented()) {\n          return false;\n        }\n        var customCommand = command.toLowerCase();\n        if (func = self.commands.exec[customCommand]) {\n          func(customCommand, ui, value);\n          self.editor.fire('ExecCommand', {\n            command: command,\n            ui: ui,\n            value: value\n          });\n          return true;\n        }\n        each$4(this.editor.plugins, function (p) {\n          if (p.execCommand && p.execCommand(command, ui, value)) {\n            self.editor.fire('ExecCommand', {\n              command: command,\n              ui: ui,\n              value: value\n            });\n            state = true;\n            return false;\n          }\n        });\n        if (state) {\n          return state;\n        }\n        if (self.editor.theme && self.editor.theme.execCommand && self.editor.theme.execCommand(command, ui, value)) {\n          self.editor.fire('ExecCommand', {\n            command: command,\n            ui: ui,\n            value: value\n          });\n          return true;\n        }\n        try {\n          state = self.editor.getDoc().execCommand(command, ui, value);\n        } catch (ex) {\n        }\n        if (state) {\n          self.editor.fire('ExecCommand', {\n            command: command,\n            ui: ui,\n            value: value\n          });\n          return true;\n        }\n        return false;\n      };\n      EditorCommands.prototype.queryCommandState = function (command) {\n        var func;\n        if (this.editor.quirks.isHidden() || this.editor.removed) {\n          return;\n        }\n        command = command.toLowerCase();\n        if (func = this.commands.state[command]) {\n          return func(command);\n        }\n        try {\n          return this.editor.getDoc().queryCommandState(command);\n        } catch (ex) {\n        }\n        return false;\n      };\n      EditorCommands.prototype.queryCommandValue = function (command) {\n        var func;\n        if (this.editor.quirks.isHidden() || this.editor.removed) {\n          return;\n        }\n        command = command.toLowerCase();\n        if (func = this.commands.value[command]) {\n          return func(command);\n        }\n        try {\n          return this.editor.getDoc().queryCommandValue(command);\n        } catch (ex) {\n        }\n      };\n      EditorCommands.prototype.addCommands = function (commandList, type) {\n        if (type === void 0) {\n          type = 'exec';\n        }\n        var self = this;\n        each$4(commandList, function (callback, command) {\n          each$4(command.toLowerCase().split(','), function (command) {\n            self.commands[type][command] = callback;\n          });\n        });\n      };\n      EditorCommands.prototype.addCommand = function (command, callback, scope) {\n        var _this = this;\n        command = command.toLowerCase();\n        this.commands.exec[command] = function (command, ui, value, args) {\n          return callback.call(scope || _this.editor, ui, value, args);\n        };\n      };\n      EditorCommands.prototype.queryCommandSupported = function (command) {\n        command = command.toLowerCase();\n        if (this.commands.exec[command]) {\n          return true;\n        }\n        try {\n          return this.editor.getDoc().queryCommandSupported(command);\n        } catch (ex) {\n        }\n        return false;\n      };\n      EditorCommands.prototype.addQueryStateHandler = function (command, callback, scope) {\n        var _this = this;\n        command = command.toLowerCase();\n        this.commands.state[command] = function () {\n          return callback.call(scope || _this.editor);\n        };\n      };\n      EditorCommands.prototype.addQueryValueHandler = function (command, callback, scope) {\n        var _this = this;\n        command = command.toLowerCase();\n        this.commands.value[command] = function () {\n          return callback.call(scope || _this.editor);\n        };\n      };\n      EditorCommands.prototype.hasCustomCommand = function (command) {\n        command = command.toLowerCase();\n        return !!this.commands.exec[command];\n      };\n      EditorCommands.prototype.execNativeCommand = function (command, ui, value) {\n        if (ui === undefined) {\n          ui = false;\n        }\n        if (value === undefined) {\n          value = null;\n        }\n        return this.editor.getDoc().execCommand(command, ui, value);\n      };\n      EditorCommands.prototype.isFormatMatch = function (name) {\n        return this.editor.formatter.match(name);\n      };\n      EditorCommands.prototype.toggleFormat = function (name, value) {\n        this.editor.formatter.toggle(name, value);\n        this.editor.nodeChanged();\n      };\n      EditorCommands.prototype.storeSelection = function (type) {\n        this.selectionBookmark = this.editor.selection.getBookmark(type);\n      };\n      EditorCommands.prototype.restoreSelection = function () {\n        this.editor.selection.moveToBookmark(this.selectionBookmark);\n      };\n      EditorCommands.prototype.setupCommands = function (editor) {\n        var self = this;\n        this.addCommands({\n          'mceResetDesignMode,mceBeginUndoLevel': noop,\n          'mceEndUndoLevel,mceAddUndoLevel': function () {\n            editor.undoManager.add();\n          },\n          'mceFocus': function (_command, _ui, value) {\n            focus(editor, value);\n          },\n          'Cut,Copy,Paste': function (command) {\n            var doc = editor.getDoc();\n            var failed;\n            try {\n              self.execNativeCommand(command);\n            } catch (ex) {\n              failed = true;\n            }\n            if (command === 'paste' && !doc.queryCommandEnabled(command)) {\n              failed = true;\n            }\n            if (failed || !doc.queryCommandSupported(command)) {\n              var msg = editor.translate('Your browser doesn\\'t support direct access to the clipboard. ' + 'Please use the Ctrl+X/C/V keyboard shortcuts instead.');\n              if (Env.mac) {\n                msg = msg.replace(/Ctrl\\+/g, '\\u2318+');\n              }\n              editor.notificationManager.open({\n                text: msg,\n                type: 'error'\n              });\n            }\n          },\n          'unlink': function () {\n            if (editor.selection.isCollapsed()) {\n              var elm = editor.dom.getParent(editor.selection.getStart(), 'a');\n              if (elm) {\n                editor.dom.remove(elm, true);\n              }\n              return;\n            }\n            editor.formatter.remove('link');\n          },\n          'JustifyLeft,JustifyCenter,JustifyRight,JustifyFull,JustifyNone': function (command) {\n            var align = command.substring(7);\n            if (align === 'full') {\n              align = 'justify';\n            }\n            each$4('left,center,right,justify'.split(','), function (name) {\n              if (align !== name) {\n                editor.formatter.remove('align' + name);\n              }\n            });\n            if (align !== 'none') {\n              self.toggleFormat('align' + align);\n            }\n          },\n          'InsertUnorderedList,InsertOrderedList': function (command) {\n            var listParent;\n            self.execNativeCommand(command);\n            var listElm = editor.dom.getParent(editor.selection.getNode(), 'ol,ul');\n            if (listElm) {\n              listParent = listElm.parentNode;\n              if (/^(H[1-6]|P|ADDRESS|PRE)$/.test(listParent.nodeName)) {\n                self.storeSelection();\n                editor.dom.split(listParent, listElm);\n                self.restoreSelection();\n              }\n            }\n          },\n          'Bold,Italic,Underline,Strikethrough,Superscript,Subscript': function (command) {\n            self.toggleFormat(command);\n          },\n          'ForeColor,HiliteColor': function (command, ui, value) {\n            self.toggleFormat(command, { value: value });\n          },\n          'FontName': function (command, ui, value) {\n            fontNameAction(editor, value);\n          },\n          'FontSize': function (command, ui, value) {\n            fontSizeAction(editor, value);\n          },\n          'LineHeight': function (command, ui, value) {\n            lineHeightAction(editor, value);\n          },\n          'Lang': function (command, ui, lang) {\n            self.toggleFormat(command, {\n              value: lang.code,\n              customValue: lang.customCode\n            });\n          },\n          'RemoveFormat': function (command) {\n            editor.formatter.remove(command);\n          },\n          'mceBlockQuote': function () {\n            self.toggleFormat('blockquote');\n          },\n          'FormatBlock': function (command, ui, value) {\n            return self.toggleFormat(value || 'p');\n          },\n          'mceCleanup': function () {\n            var bookmark = editor.selection.getBookmark();\n            editor.setContent(editor.getContent());\n            editor.selection.moveToBookmark(bookmark);\n          },\n          'mceRemoveNode': function (command, ui, value) {\n            var node = value || editor.selection.getNode();\n            if (node !== editor.getBody()) {\n              self.storeSelection();\n              editor.dom.remove(node, true);\n              self.restoreSelection();\n            }\n          },\n          'mceSelectNodeDepth': function (command, ui, value) {\n            var counter = 0;\n            editor.dom.getParent(editor.selection.getNode(), function (node) {\n              if (node.nodeType === 1 && counter++ === value) {\n                editor.selection.select(node);\n                return false;\n              }\n            }, editor.getBody());\n          },\n          'mceSelectNode': function (command, ui, value) {\n            editor.selection.select(value);\n          },\n          'mceInsertContent': function (command, ui, value) {\n            insertAtCaret(editor, value);\n          },\n          'mceInsertRawHTML': function (command, ui, value) {\n            editor.selection.setContent('tiny_mce_marker');\n            var content = editor.getContent();\n            editor.setContent(content.replace(/tiny_mce_marker/g, function () {\n              return value;\n            }));\n          },\n          'mceInsertNewLine': function (command, ui, value) {\n            insert(editor, value);\n          },\n          'mceToggleFormat': function (command, ui, value) {\n            self.toggleFormat(value);\n          },\n          'mceSetContent': function (command, ui, value) {\n            editor.setContent(value);\n          },\n          'Indent,Outdent': function (command) {\n            handle(editor, command);\n          },\n          'mceRepaint': noop,\n          'InsertHorizontalRule': function () {\n            editor.execCommand('mceInsertContent', false, '<hr />');\n          },\n          'mceToggleVisualAid': function () {\n            editor.hasVisual = !editor.hasVisual;\n            editor.addVisual();\n          },\n          'mceReplaceContent': function (command, ui, value) {\n            editor.execCommand('mceInsertContent', false, value.replace(/\\{\\$selection\\}/g, editor.selection.getContent({ format: 'text' })));\n          },\n          'mceInsertLink': function (command, ui, value) {\n            if (typeof value === 'string') {\n              value = { href: value };\n            }\n            var anchor = editor.dom.getParent(editor.selection.getNode(), 'a');\n            value.href = value.href.replace(/ /g, '%20');\n            if (!anchor || !value.href) {\n              editor.formatter.remove('link');\n            }\n            if (value.href) {\n              editor.formatter.apply('link', value, anchor);\n            }\n          },\n          'selectAll': function () {\n            var editingHost = editor.dom.getParent(editor.selection.getStart(), isContentEditableTrue$4);\n            if (editingHost) {\n              var rng = editor.dom.createRng();\n              rng.selectNodeContents(editingHost);\n              editor.selection.setRng(rng);\n            }\n          },\n          'mceNewDocument': function () {\n            editor.setContent('');\n          },\n          'InsertLineBreak': function (command, ui, value) {\n            insert$1(editor, value);\n            return true;\n          }\n        });\n        var alignStates = function (name) {\n          return function () {\n            var selection = editor.selection;\n            var nodes = selection.isCollapsed() ? [editor.dom.getParent(selection.getNode(), editor.dom.isBlock)] : selection.getSelectedBlocks();\n            var matches = map(nodes, function (node) {\n              return !!editor.formatter.matchNode(node, name);\n            });\n            return inArray(matches, true) !== -1;\n          };\n        };\n        self.addCommands({\n          'JustifyLeft': alignStates('alignleft'),\n          'JustifyCenter': alignStates('aligncenter'),\n          'JustifyRight': alignStates('alignright'),\n          'JustifyFull': alignStates('alignjustify'),\n          'Bold,Italic,Underline,Strikethrough,Superscript,Subscript': function (command) {\n            return self.isFormatMatch(command);\n          },\n          'mceBlockQuote': function () {\n            return self.isFormatMatch('blockquote');\n          },\n          'Outdent': function () {\n            return canOutdent(editor);\n          },\n          'InsertUnorderedList,InsertOrderedList': function (command) {\n            var list = editor.dom.getParent(editor.selection.getNode(), 'ul,ol');\n            return list && (command === 'insertunorderedlist' && list.tagName === 'UL' || command === 'insertorderedlist' && list.tagName === 'OL');\n          }\n        }, 'state');\n        self.addCommands({\n          Undo: function () {\n            editor.undoManager.undo();\n          },\n          Redo: function () {\n            editor.undoManager.redo();\n          }\n        });\n        self.addQueryValueHandler('FontName', function () {\n          return fontNameQuery(editor);\n        }, this);\n        self.addQueryValueHandler('FontSize', function () {\n          return fontSizeQuery(editor);\n        }, this);\n        self.addQueryValueHandler('LineHeight', function () {\n          return lineHeightQuery(editor);\n        }, this);\n      };\n      return EditorCommands;\n    }();\n\n    var internalContentEditableAttr = 'data-mce-contenteditable';\n    var toggleClass = function (elm, cls, state) {\n      if (has(elm, cls) && state === false) {\n        remove$3(elm, cls);\n      } else if (state) {\n        add$1(elm, cls);\n      }\n    };\n    var setEditorCommandState = function (editor, cmd, state) {\n      try {\n        editor.getDoc().execCommand(cmd, false, String(state));\n      } catch (ex) {\n      }\n    };\n    var setContentEditable = function (elm, state) {\n      elm.dom.contentEditable = state ? 'true' : 'false';\n    };\n    var switchOffContentEditableTrue = function (elm) {\n      each$k(descendants(elm, '*[contenteditable=\"true\"]'), function (elm) {\n        set$1(elm, internalContentEditableAttr, 'true');\n        setContentEditable(elm, false);\n      });\n    };\n    var switchOnContentEditableTrue = function (elm) {\n      each$k(descendants(elm, '*[' + internalContentEditableAttr + '=\"true\"]'), function (elm) {\n        remove$6(elm, internalContentEditableAttr);\n        setContentEditable(elm, true);\n      });\n    };\n    var removeFakeSelection = function (editor) {\n      Optional.from(editor.selection.getNode()).each(function (elm) {\n        elm.removeAttribute('data-mce-selected');\n      });\n    };\n    var restoreFakeSelection = function (editor) {\n      editor.selection.setRng(editor.selection.getRng());\n    };\n    var toggleReadOnly = function (editor, state) {\n      var body = SugarElement.fromDom(editor.getBody());\n      toggleClass(body, 'mce-content-readonly', state);\n      if (state) {\n        editor.selection.controlSelection.hideResizeRect();\n        editor._selectionOverrides.hideFakeCaret();\n        removeFakeSelection(editor);\n        editor.readonly = true;\n        setContentEditable(body, false);\n        switchOffContentEditableTrue(body);\n      } else {\n        editor.readonly = false;\n        setContentEditable(body, true);\n        switchOnContentEditableTrue(body);\n        setEditorCommandState(editor, 'StyleWithCSS', false);\n        setEditorCommandState(editor, 'enableInlineTableEditing', false);\n        setEditorCommandState(editor, 'enableObjectResizing', false);\n        if (hasEditorOrUiFocus(editor)) {\n          editor.focus();\n        }\n        restoreFakeSelection(editor);\n        editor.nodeChanged();\n      }\n    };\n    var isReadOnly = function (editor) {\n      return editor.readonly;\n    };\n    var registerFilters = function (editor) {\n      editor.parser.addAttributeFilter('contenteditable', function (nodes) {\n        if (isReadOnly(editor)) {\n          each$k(nodes, function (node) {\n            node.attr(internalContentEditableAttr, node.attr('contenteditable'));\n            node.attr('contenteditable', 'false');\n          });\n        }\n      });\n      editor.serializer.addAttributeFilter(internalContentEditableAttr, function (nodes) {\n        if (isReadOnly(editor)) {\n          each$k(nodes, function (node) {\n            node.attr('contenteditable', node.attr(internalContentEditableAttr));\n          });\n        }\n      });\n      editor.serializer.addTempAttr(internalContentEditableAttr);\n    };\n    var registerReadOnlyContentFilters = function (editor) {\n      if (editor.serializer) {\n        registerFilters(editor);\n      } else {\n        editor.on('PreInit', function () {\n          registerFilters(editor);\n        });\n      }\n    };\n    var isClickEvent = function (e) {\n      return e.type === 'click';\n    };\n    var getAnchorHrefOpt = function (editor, elm) {\n      var isRoot = function (elm) {\n        return eq(elm, SugarElement.fromDom(editor.getBody()));\n      };\n      return closest$2(elm, 'a', isRoot).bind(function (a) {\n        return getOpt(a, 'href');\n      });\n    };\n    var processReadonlyEvents = function (editor, e) {\n      if (isClickEvent(e) && !VK.metaKeyPressed(e)) {\n        var elm = SugarElement.fromDom(e.target);\n        getAnchorHrefOpt(editor, elm).each(function (href) {\n          e.preventDefault();\n          if (/^#/.test(href)) {\n            var targetEl = editor.dom.select(href + ',[name=\"' + removeLeading(href, '#') + '\"]');\n            if (targetEl.length) {\n              editor.selection.scrollIntoView(targetEl[0], true);\n            }\n          } else {\n            window.open(href, '_blank', 'rel=noopener noreferrer,menubar=yes,toolbar=yes,location=yes,status=yes,resizable=yes,scrollbars=yes');\n          }\n        });\n      }\n    };\n    var registerReadOnlySelectionBlockers = function (editor) {\n      editor.on('ShowCaret', function (e) {\n        if (isReadOnly(editor)) {\n          e.preventDefault();\n        }\n      });\n      editor.on('ObjectSelected', function (e) {\n        if (isReadOnly(editor)) {\n          e.preventDefault();\n        }\n      });\n    };\n\n    var nativeEvents = Tools.makeMap('focus blur focusin focusout click dblclick mousedown mouseup mousemove mouseover beforepaste paste cut copy selectionchange ' + 'mouseout mouseenter mouseleave wheel keydown keypress keyup input beforeinput contextmenu dragstart dragend dragover ' + 'draggesture dragdrop drop drag submit ' + 'compositionstart compositionend compositionupdate touchstart touchmove touchend touchcancel', ' ');\n    var EventDispatcher = function () {\n      function EventDispatcher(settings) {\n        this.bindings = {};\n        this.settings = settings || {};\n        this.scope = this.settings.scope || this;\n        this.toggleEvent = this.settings.toggleEvent || never;\n      }\n      EventDispatcher.isNative = function (name) {\n        return !!nativeEvents[name.toLowerCase()];\n      };\n      EventDispatcher.prototype.fire = function (name, args) {\n        var lcName = name.toLowerCase();\n        var event = normalize$3(lcName, args || {}, this.scope);\n        if (this.settings.beforeFire) {\n          this.settings.beforeFire(event);\n        }\n        var handlers = this.bindings[lcName];\n        if (handlers) {\n          for (var i = 0, l = handlers.length; i < l; i++) {\n            var callback = handlers[i];\n            if (callback.removed) {\n              continue;\n            }\n            if (callback.once) {\n              this.off(lcName, callback.func);\n            }\n            if (event.isImmediatePropagationStopped()) {\n              return event;\n            }\n            if (callback.func.call(this.scope, event) === false) {\n              event.preventDefault();\n              return event;\n            }\n          }\n        }\n        return event;\n      };\n      EventDispatcher.prototype.on = function (name, callback, prepend, extra) {\n        if (callback === false) {\n          callback = never;\n        }\n        if (callback) {\n          var wrappedCallback = {\n            func: callback,\n            removed: false\n          };\n          if (extra) {\n            Tools.extend(wrappedCallback, extra);\n          }\n          var names = name.toLowerCase().split(' ');\n          var i = names.length;\n          while (i--) {\n            var currentName = names[i];\n            var handlers = this.bindings[currentName];\n            if (!handlers) {\n              handlers = [];\n              this.toggleEvent(currentName, true);\n            }\n            if (prepend) {\n              handlers = __spreadArray([wrappedCallback], handlers, true);\n            } else {\n              handlers = __spreadArray(__spreadArray([], handlers, true), [wrappedCallback], false);\n            }\n            this.bindings[currentName] = handlers;\n          }\n        }\n        return this;\n      };\n      EventDispatcher.prototype.off = function (name, callback) {\n        var _this = this;\n        if (name) {\n          var names = name.toLowerCase().split(' ');\n          var i = names.length;\n          while (i--) {\n            var currentName = names[i];\n            var handlers = this.bindings[currentName];\n            if (!currentName) {\n              each$j(this.bindings, function (_value, bindingName) {\n                _this.toggleEvent(bindingName, false);\n                delete _this.bindings[bindingName];\n              });\n              return this;\n            }\n            if (handlers) {\n              if (!callback) {\n                handlers.length = 0;\n              } else {\n                var filteredHandlers = partition(handlers, function (handler) {\n                  return handler.func === callback;\n                });\n                handlers = filteredHandlers.fail;\n                this.bindings[currentName] = handlers;\n                each$k(filteredHandlers.pass, function (handler) {\n                  handler.removed = true;\n                });\n              }\n              if (!handlers.length) {\n                this.toggleEvent(name, false);\n                delete this.bindings[currentName];\n              }\n            }\n          }\n        } else {\n          each$j(this.bindings, function (_value, name) {\n            _this.toggleEvent(name, false);\n          });\n          this.bindings = {};\n        }\n        return this;\n      };\n      EventDispatcher.prototype.once = function (name, callback, prepend) {\n        return this.on(name, callback, prepend, { once: true });\n      };\n      EventDispatcher.prototype.has = function (name) {\n        name = name.toLowerCase();\n        return !(!this.bindings[name] || this.bindings[name].length === 0);\n      };\n      return EventDispatcher;\n    }();\n\n    var getEventDispatcher = function (obj) {\n      if (!obj._eventDispatcher) {\n        obj._eventDispatcher = new EventDispatcher({\n          scope: obj,\n          toggleEvent: function (name, state) {\n            if (EventDispatcher.isNative(name) && obj.toggleNativeEvent) {\n              obj.toggleNativeEvent(name, state);\n            }\n          }\n        });\n      }\n      return obj._eventDispatcher;\n    };\n    var Observable = {\n      fire: function (name, args, bubble) {\n        var self = this;\n        if (self.removed && name !== 'remove' && name !== 'detach') {\n          return args;\n        }\n        var dispatcherArgs = getEventDispatcher(self).fire(name, args);\n        if (bubble !== false && self.parent) {\n          var parent_1 = self.parent();\n          while (parent_1 && !dispatcherArgs.isPropagationStopped()) {\n            parent_1.fire(name, dispatcherArgs, false);\n            parent_1 = parent_1.parent();\n          }\n        }\n        return dispatcherArgs;\n      },\n      on: function (name, callback, prepend) {\n        return getEventDispatcher(this).on(name, callback, prepend);\n      },\n      off: function (name, callback) {\n        return getEventDispatcher(this).off(name, callback);\n      },\n      once: function (name, callback) {\n        return getEventDispatcher(this).once(name, callback);\n      },\n      hasEventListeners: function (name) {\n        return getEventDispatcher(this).has(name);\n      }\n    };\n\n    var DOM$2 = DOMUtils.DOM;\n    var customEventRootDelegates;\n    var getEventTarget = function (editor, eventName) {\n      if (eventName === 'selectionchange') {\n        return editor.getDoc();\n      }\n      if (!editor.inline && /^mouse|touch|click|contextmenu|drop|dragover|dragend/.test(eventName)) {\n        return editor.getDoc().documentElement;\n      }\n      var eventRoot = getEventRoot(editor);\n      if (eventRoot) {\n        if (!editor.eventRoot) {\n          editor.eventRoot = DOM$2.select(eventRoot)[0];\n        }\n        return editor.eventRoot;\n      }\n      return editor.getBody();\n    };\n    var isListening = function (editor) {\n      return !editor.hidden && !isReadOnly(editor);\n    };\n    var fireEvent = function (editor, eventName, e) {\n      if (isListening(editor)) {\n        editor.fire(eventName, e);\n      } else if (isReadOnly(editor)) {\n        processReadonlyEvents(editor, e);\n      }\n    };\n    var bindEventDelegate = function (editor, eventName) {\n      var delegate;\n      if (!editor.delegates) {\n        editor.delegates = {};\n      }\n      if (editor.delegates[eventName] || editor.removed) {\n        return;\n      }\n      var eventRootElm = getEventTarget(editor, eventName);\n      if (getEventRoot(editor)) {\n        if (!customEventRootDelegates) {\n          customEventRootDelegates = {};\n          editor.editorManager.on('removeEditor', function () {\n            if (!editor.editorManager.activeEditor) {\n              if (customEventRootDelegates) {\n                each$j(customEventRootDelegates, function (_value, name) {\n                  editor.dom.unbind(getEventTarget(editor, name));\n                });\n                customEventRootDelegates = null;\n              }\n            }\n          });\n        }\n        if (customEventRootDelegates[eventName]) {\n          return;\n        }\n        delegate = function (e) {\n          var target = e.target;\n          var editors = editor.editorManager.get();\n          var i = editors.length;\n          while (i--) {\n            var body = editors[i].getBody();\n            if (body === target || DOM$2.isChildOf(target, body)) {\n              fireEvent(editors[i], eventName, e);\n            }\n          }\n        };\n        customEventRootDelegates[eventName] = delegate;\n        DOM$2.bind(eventRootElm, eventName, delegate);\n      } else {\n        delegate = function (e) {\n          fireEvent(editor, eventName, e);\n        };\n        DOM$2.bind(eventRootElm, eventName, delegate);\n        editor.delegates[eventName] = delegate;\n      }\n    };\n    var EditorObservable = __assign(__assign({}, Observable), {\n      bindPendingEventDelegates: function () {\n        var self = this;\n        Tools.each(self._pendingNativeEvents, function (name) {\n          bindEventDelegate(self, name);\n        });\n      },\n      toggleNativeEvent: function (name, state) {\n        var self = this;\n        if (name === 'focus' || name === 'blur') {\n          return;\n        }\n        if (self.removed) {\n          return;\n        }\n        if (state) {\n          if (self.initialized) {\n            bindEventDelegate(self, name);\n          } else {\n            if (!self._pendingNativeEvents) {\n              self._pendingNativeEvents = [name];\n            } else {\n              self._pendingNativeEvents.push(name);\n            }\n          }\n        } else if (self.initialized) {\n          self.dom.unbind(getEventTarget(self, name), name, self.delegates[name]);\n          delete self.delegates[name];\n        }\n      },\n      unbindAllNativeEvents: function () {\n        var self = this;\n        var body = self.getBody();\n        var dom = self.dom;\n        if (self.delegates) {\n          each$j(self.delegates, function (value, name) {\n            self.dom.unbind(getEventTarget(self, name), name, value);\n          });\n          delete self.delegates;\n        }\n        if (!self.inline && body && dom) {\n          body.onload = null;\n          dom.unbind(self.getWin());\n          dom.unbind(self.getDoc());\n        }\n        if (dom) {\n          dom.unbind(body);\n          dom.unbind(self.getContainer());\n        }\n      }\n    });\n\n    var defaultModes = [\n      'design',\n      'readonly'\n    ];\n    var switchToMode = function (editor, activeMode, availableModes, mode) {\n      var oldMode = availableModes[activeMode.get()];\n      var newMode = availableModes[mode];\n      try {\n        newMode.activate();\n      } catch (e) {\n        console.error('problem while activating editor mode ' + mode + ':', e);\n        return;\n      }\n      oldMode.deactivate();\n      if (oldMode.editorReadOnly !== newMode.editorReadOnly) {\n        toggleReadOnly(editor, newMode.editorReadOnly);\n      }\n      activeMode.set(mode);\n      fireSwitchMode(editor, mode);\n    };\n    var setMode = function (editor, availableModes, activeMode, mode) {\n      if (mode === activeMode.get()) {\n        return;\n      } else if (!has$2(availableModes, mode)) {\n        throw new Error('Editor mode \\'' + mode + '\\' is invalid');\n      }\n      if (editor.initialized) {\n        switchToMode(editor, activeMode, availableModes, mode);\n      } else {\n        editor.on('init', function () {\n          return switchToMode(editor, activeMode, availableModes, mode);\n        });\n      }\n    };\n    var registerMode = function (availableModes, mode, api) {\n      var _a;\n      if (contains$3(defaultModes, mode)) {\n        throw new Error('Cannot override default mode ' + mode);\n      }\n      return __assign(__assign({}, availableModes), (_a = {}, _a[mode] = __assign(__assign({}, api), {\n        deactivate: function () {\n          try {\n            api.deactivate();\n          } catch (e) {\n            console.error('problem while deactivating editor mode ' + mode + ':', e);\n          }\n        }\n      }), _a));\n    };\n\n    var create$4 = function (editor) {\n      var activeMode = Cell('design');\n      var availableModes = Cell({\n        design: {\n          activate: noop,\n          deactivate: noop,\n          editorReadOnly: false\n        },\n        readonly: {\n          activate: noop,\n          deactivate: noop,\n          editorReadOnly: true\n        }\n      });\n      registerReadOnlyContentFilters(editor);\n      registerReadOnlySelectionBlockers(editor);\n      return {\n        isReadOnly: function () {\n          return isReadOnly(editor);\n        },\n        set: function (mode) {\n          return setMode(editor, availableModes.get(), activeMode, mode);\n        },\n        get: function () {\n          return activeMode.get();\n        },\n        register: function (mode, api) {\n          availableModes.set(registerMode(availableModes.get(), mode, api));\n        }\n      };\n    };\n\n    var each$3 = Tools.each, explode$1 = Tools.explode;\n    var keyCodeLookup = {\n      f1: 112,\n      f2: 113,\n      f3: 114,\n      f4: 115,\n      f5: 116,\n      f6: 117,\n      f7: 118,\n      f8: 119,\n      f9: 120,\n      f10: 121,\n      f11: 122,\n      f12: 123\n    };\n    var modifierNames = Tools.makeMap('alt,ctrl,shift,meta,access');\n    var parseShortcut = function (pattern) {\n      var key;\n      var shortcut = {};\n      each$3(explode$1(pattern.toLowerCase(), '+'), function (value) {\n        if (value in modifierNames) {\n          shortcut[value] = true;\n        } else {\n          if (/^[0-9]{2,}$/.test(value)) {\n            shortcut.keyCode = parseInt(value, 10);\n          } else {\n            shortcut.charCode = value.charCodeAt(0);\n            shortcut.keyCode = keyCodeLookup[value] || value.toUpperCase().charCodeAt(0);\n          }\n        }\n      });\n      var id = [shortcut.keyCode];\n      for (key in modifierNames) {\n        if (shortcut[key]) {\n          id.push(key);\n        } else {\n          shortcut[key] = false;\n        }\n      }\n      shortcut.id = id.join(',');\n      if (shortcut.access) {\n        shortcut.alt = true;\n        if (Env.mac) {\n          shortcut.ctrl = true;\n        } else {\n          shortcut.shift = true;\n        }\n      }\n      if (shortcut.meta) {\n        if (Env.mac) {\n          shortcut.meta = true;\n        } else {\n          shortcut.ctrl = true;\n          shortcut.meta = false;\n        }\n      }\n      return shortcut;\n    };\n    var Shortcuts = function () {\n      function Shortcuts(editor) {\n        this.shortcuts = {};\n        this.pendingPatterns = [];\n        this.editor = editor;\n        var self = this;\n        editor.on('keyup keypress keydown', function (e) {\n          if ((self.hasModifier(e) || self.isFunctionKey(e)) && !e.isDefaultPrevented()) {\n            each$3(self.shortcuts, function (shortcut) {\n              if (self.matchShortcut(e, shortcut)) {\n                self.pendingPatterns = shortcut.subpatterns.slice(0);\n                if (e.type === 'keydown') {\n                  self.executeShortcutAction(shortcut);\n                }\n                return true;\n              }\n            });\n            if (self.matchShortcut(e, self.pendingPatterns[0])) {\n              if (self.pendingPatterns.length === 1) {\n                if (e.type === 'keydown') {\n                  self.executeShortcutAction(self.pendingPatterns[0]);\n                }\n              }\n              self.pendingPatterns.shift();\n            }\n          }\n        });\n      }\n      Shortcuts.prototype.add = function (pattern, desc, cmdFunc, scope) {\n        var self = this;\n        var func = self.normalizeCommandFunc(cmdFunc);\n        each$3(explode$1(Tools.trim(pattern)), function (pattern) {\n          var shortcut = self.createShortcut(pattern, desc, func, scope);\n          self.shortcuts[shortcut.id] = shortcut;\n        });\n        return true;\n      };\n      Shortcuts.prototype.remove = function (pattern) {\n        var shortcut = this.createShortcut(pattern);\n        if (this.shortcuts[shortcut.id]) {\n          delete this.shortcuts[shortcut.id];\n          return true;\n        }\n        return false;\n      };\n      Shortcuts.prototype.normalizeCommandFunc = function (cmdFunc) {\n        var self = this;\n        var cmd = cmdFunc;\n        if (typeof cmd === 'string') {\n          return function () {\n            self.editor.execCommand(cmd, false, null);\n          };\n        } else if (Tools.isArray(cmd)) {\n          return function () {\n            self.editor.execCommand(cmd[0], cmd[1], cmd[2]);\n          };\n        } else {\n          return cmd;\n        }\n      };\n      Shortcuts.prototype.createShortcut = function (pattern, desc, cmdFunc, scope) {\n        var shortcuts = Tools.map(explode$1(pattern, '>'), parseShortcut);\n        shortcuts[shortcuts.length - 1] = Tools.extend(shortcuts[shortcuts.length - 1], {\n          func: cmdFunc,\n          scope: scope || this.editor\n        });\n        return Tools.extend(shortcuts[0], {\n          desc: this.editor.translate(desc),\n          subpatterns: shortcuts.slice(1)\n        });\n      };\n      Shortcuts.prototype.hasModifier = function (e) {\n        return e.altKey || e.ctrlKey || e.metaKey;\n      };\n      Shortcuts.prototype.isFunctionKey = function (e) {\n        return e.type === 'keydown' && e.keyCode >= 112 && e.keyCode <= 123;\n      };\n      Shortcuts.prototype.matchShortcut = function (e, shortcut) {\n        if (!shortcut) {\n          return false;\n        }\n        if (shortcut.ctrl !== e.ctrlKey || shortcut.meta !== e.metaKey) {\n          return false;\n        }\n        if (shortcut.alt !== e.altKey || shortcut.shift !== e.shiftKey) {\n          return false;\n        }\n        if (e.keyCode === shortcut.keyCode || e.charCode && e.charCode === shortcut.charCode) {\n          e.preventDefault();\n          return true;\n        }\n        return false;\n      };\n      Shortcuts.prototype.executeShortcutAction = function (shortcut) {\n        return shortcut.func ? shortcut.func.call(shortcut.scope) : null;\n      };\n      return Shortcuts;\n    }();\n\n    var create$3 = function () {\n      var buttons = {};\n      var menuItems = {};\n      var popups = {};\n      var icons = {};\n      var contextMenus = {};\n      var contextToolbars = {};\n      var sidebars = {};\n      var add = function (collection, type) {\n        return function (name, spec) {\n          return collection[name.toLowerCase()] = __assign(__assign({}, spec), { type: type });\n        };\n      };\n      var addIcon = function (name, svgData) {\n        return icons[name.toLowerCase()] = svgData;\n      };\n      return {\n        addButton: add(buttons, 'button'),\n        addGroupToolbarButton: add(buttons, 'grouptoolbarbutton'),\n        addToggleButton: add(buttons, 'togglebutton'),\n        addMenuButton: add(buttons, 'menubutton'),\n        addSplitButton: add(buttons, 'splitbutton'),\n        addMenuItem: add(menuItems, 'menuitem'),\n        addNestedMenuItem: add(menuItems, 'nestedmenuitem'),\n        addToggleMenuItem: add(menuItems, 'togglemenuitem'),\n        addAutocompleter: add(popups, 'autocompleter'),\n        addContextMenu: add(contextMenus, 'contextmenu'),\n        addContextToolbar: add(contextToolbars, 'contexttoolbar'),\n        addContextForm: add(contextToolbars, 'contextform'),\n        addSidebar: add(sidebars, 'sidebar'),\n        addIcon: addIcon,\n        getAll: function () {\n          return {\n            buttons: buttons,\n            menuItems: menuItems,\n            icons: icons,\n            popups: popups,\n            contextMenus: contextMenus,\n            contextToolbars: contextToolbars,\n            sidebars: sidebars\n          };\n        }\n      };\n    };\n\n    var registry = function () {\n      var bridge = create$3();\n      return {\n        addAutocompleter: bridge.addAutocompleter,\n        addButton: bridge.addButton,\n        addContextForm: bridge.addContextForm,\n        addContextMenu: bridge.addContextMenu,\n        addContextToolbar: bridge.addContextToolbar,\n        addIcon: bridge.addIcon,\n        addMenuButton: bridge.addMenuButton,\n        addMenuItem: bridge.addMenuItem,\n        addNestedMenuItem: bridge.addNestedMenuItem,\n        addSidebar: bridge.addSidebar,\n        addSplitButton: bridge.addSplitButton,\n        addToggleButton: bridge.addToggleButton,\n        addGroupToolbarButton: bridge.addGroupToolbarButton,\n        addToggleMenuItem: bridge.addToggleMenuItem,\n        getAll: bridge.getAll\n      };\n    };\n\n    var DOM$1 = DOMUtils.DOM;\n    var extend$3 = Tools.extend, each$2 = Tools.each;\n    var resolve = Tools.resolve;\n    var ie = Env.ie;\n    var Editor = function () {\n      function Editor(id, settings, editorManager) {\n        var _this = this;\n        this.plugins = {};\n        this.contentCSS = [];\n        this.contentStyles = [];\n        this.loadedCSS = {};\n        this.isNotDirty = false;\n        this.editorManager = editorManager;\n        this.documentBaseUrl = editorManager.documentBaseURL;\n        extend$3(this, EditorObservable);\n        this.settings = getEditorSettings(this, id, this.documentBaseUrl, editorManager.defaultSettings, settings);\n        if (this.settings.suffix) {\n          editorManager.suffix = this.settings.suffix;\n        }\n        this.suffix = editorManager.suffix;\n        if (this.settings.base_url) {\n          editorManager._setBaseUrl(this.settings.base_url);\n        }\n        this.baseUri = editorManager.baseURI;\n        if (this.settings.referrer_policy) {\n          ScriptLoader.ScriptLoader._setReferrerPolicy(this.settings.referrer_policy);\n          DOMUtils.DOM.styleSheetLoader._setReferrerPolicy(this.settings.referrer_policy);\n        }\n        AddOnManager.languageLoad = this.settings.language_load;\n        AddOnManager.baseURL = editorManager.baseURL;\n        this.id = id;\n        this.setDirty(false);\n        this.documentBaseURI = new URI(this.settings.document_base_url, { base_uri: this.baseUri });\n        this.baseURI = this.baseUri;\n        this.inline = !!this.settings.inline;\n        this.shortcuts = new Shortcuts(this);\n        this.editorCommands = new EditorCommands(this);\n        if (this.settings.cache_suffix) {\n          Env.cacheSuffix = this.settings.cache_suffix.replace(/^[\\?\\&]+/, '');\n        }\n        this.ui = {\n          registry: registry(),\n          styleSheetLoader: undefined,\n          show: noop,\n          hide: noop,\n          enable: noop,\n          disable: noop,\n          isDisabled: never\n        };\n        var self = this;\n        var modeInstance = create$4(self);\n        this.mode = modeInstance;\n        this.setMode = modeInstance.set;\n        editorManager.fire('SetupEditor', { editor: this });\n        this.execCallback('setup', this);\n        this.$ = DomQuery.overrideDefaults(function () {\n          return {\n            context: _this.inline ? _this.getBody() : _this.getDoc(),\n            element: _this.getBody()\n          };\n        });\n      }\n      Editor.prototype.render = function () {\n        render(this);\n      };\n      Editor.prototype.focus = function (skipFocus) {\n        this.execCommand('mceFocus', false, skipFocus);\n      };\n      Editor.prototype.hasFocus = function () {\n        return hasFocus(this);\n      };\n      Editor.prototype.execCallback = function (name) {\n        var x = [];\n        for (var _i = 1; _i < arguments.length; _i++) {\n          x[_i - 1] = arguments[_i];\n        }\n        var self = this;\n        var callback = self.settings[name], scope;\n        if (!callback) {\n          return;\n        }\n        if (self.callbackLookup && (scope = self.callbackLookup[name])) {\n          callback = scope.func;\n          scope = scope.scope;\n        }\n        if (typeof callback === 'string') {\n          scope = callback.replace(/\\.\\w+$/, '');\n          scope = scope ? resolve(scope) : 0;\n          callback = resolve(callback);\n          self.callbackLookup = self.callbackLookup || {};\n          self.callbackLookup[name] = {\n            func: callback,\n            scope: scope\n          };\n        }\n        return callback.apply(scope || self, x);\n      };\n      Editor.prototype.translate = function (text) {\n        return I18n.translate(text);\n      };\n      Editor.prototype.getParam = function (name, defaultVal, type) {\n        return getParam(this, name, defaultVal, type);\n      };\n      Editor.prototype.hasPlugin = function (name, loaded) {\n        var hasPlugin = contains$3(getPlugins(this).split(/[ ,]/), name);\n        if (hasPlugin) {\n          return loaded ? PluginManager.get(name) !== undefined : true;\n        } else {\n          return false;\n        }\n      };\n      Editor.prototype.nodeChanged = function (args) {\n        this._nodeChangeDispatcher.nodeChanged(args);\n      };\n      Editor.prototype.addCommand = function (name, callback, scope) {\n        this.editorCommands.addCommand(name, callback, scope);\n      };\n      Editor.prototype.addQueryStateHandler = function (name, callback, scope) {\n        this.editorCommands.addQueryStateHandler(name, callback, scope);\n      };\n      Editor.prototype.addQueryValueHandler = function (name, callback, scope) {\n        this.editorCommands.addQueryValueHandler(name, callback, scope);\n      };\n      Editor.prototype.addShortcut = function (pattern, desc, cmdFunc, scope) {\n        this.shortcuts.add(pattern, desc, cmdFunc, scope);\n      };\n      Editor.prototype.execCommand = function (cmd, ui, value, args) {\n        return this.editorCommands.execCommand(cmd, ui, value, args);\n      };\n      Editor.prototype.queryCommandState = function (cmd) {\n        return this.editorCommands.queryCommandState(cmd);\n      };\n      Editor.prototype.queryCommandValue = function (cmd) {\n        return this.editorCommands.queryCommandValue(cmd);\n      };\n      Editor.prototype.queryCommandSupported = function (cmd) {\n        return this.editorCommands.queryCommandSupported(cmd);\n      };\n      Editor.prototype.show = function () {\n        var self = this;\n        if (self.hidden) {\n          self.hidden = false;\n          if (self.inline) {\n            self.getBody().contentEditable = 'true';\n          } else {\n            DOM$1.show(self.getContainer());\n            DOM$1.hide(self.id);\n          }\n          self.load();\n          self.fire('show');\n        }\n      };\n      Editor.prototype.hide = function () {\n        var self = this, doc = self.getDoc();\n        if (!self.hidden) {\n          if (ie && doc && !self.inline) {\n            doc.execCommand('SelectAll');\n          }\n          self.save();\n          if (self.inline) {\n            self.getBody().contentEditable = 'false';\n            if (self === self.editorManager.focusedEditor) {\n              self.editorManager.focusedEditor = null;\n            }\n          } else {\n            DOM$1.hide(self.getContainer());\n            DOM$1.setStyle(self.id, 'display', self.orgDisplay);\n          }\n          self.hidden = true;\n          self.fire('hide');\n        }\n      };\n      Editor.prototype.isHidden = function () {\n        return !!this.hidden;\n      };\n      Editor.prototype.setProgressState = function (state, time) {\n        this.fire('ProgressState', {\n          state: state,\n          time: time\n        });\n      };\n      Editor.prototype.load = function (args) {\n        var self = this;\n        var elm = self.getElement(), html;\n        if (self.removed) {\n          return '';\n        }\n        if (elm) {\n          args = args || {};\n          args.load = true;\n          var value = isTextareaOrInput(elm) ? elm.value : elm.innerHTML;\n          html = self.setContent(value, args);\n          args.element = elm;\n          if (!args.no_events) {\n            self.fire('LoadContent', args);\n          }\n          args.element = elm = null;\n          return html;\n        }\n      };\n      Editor.prototype.save = function (args) {\n        var self = this;\n        var elm = self.getElement(), html, form;\n        if (!elm || !self.initialized || self.removed) {\n          return;\n        }\n        args = args || {};\n        args.save = true;\n        args.element = elm;\n        html = args.content = self.getContent(args);\n        if (!args.no_events) {\n          self.fire('SaveContent', args);\n        }\n        if (args.format === 'raw') {\n          self.fire('RawSaveContent', args);\n        }\n        html = args.content;\n        if (!isTextareaOrInput(elm)) {\n          if (args.is_removing || !self.inline) {\n            elm.innerHTML = html;\n          }\n          if (form = DOM$1.getParent(self.id, 'form')) {\n            each$2(form.elements, function (elm) {\n              if (elm.name === self.id) {\n                elm.value = html;\n                return false;\n              }\n            });\n          }\n        } else {\n          elm.value = html;\n        }\n        args.element = elm = null;\n        if (args.set_dirty !== false) {\n          self.setDirty(false);\n        }\n        return html;\n      };\n      Editor.prototype.setContent = function (content, args) {\n        return setContent(this, content, args);\n      };\n      Editor.prototype.getContent = function (args) {\n        return getContent(this, args);\n      };\n      Editor.prototype.insertContent = function (content, args) {\n        if (args) {\n          content = extend$3({ content: content }, args);\n        }\n        this.execCommand('mceInsertContent', false, content);\n      };\n      Editor.prototype.resetContent = function (initialContent) {\n        if (initialContent === undefined) {\n          setContent(this, this.startContent, { format: 'raw' });\n        } else {\n          setContent(this, initialContent);\n        }\n        this.undoManager.reset();\n        this.setDirty(false);\n        this.nodeChanged();\n      };\n      Editor.prototype.isDirty = function () {\n        return !this.isNotDirty;\n      };\n      Editor.prototype.setDirty = function (state) {\n        var oldState = !this.isNotDirty;\n        this.isNotDirty = !state;\n        if (state && state !== oldState) {\n          this.fire('dirty');\n        }\n      };\n      Editor.prototype.getContainer = function () {\n        var self = this;\n        if (!self.container) {\n          self.container = DOM$1.get(self.editorContainer || self.id + '_parent');\n        }\n        return self.container;\n      };\n      Editor.prototype.getContentAreaContainer = function () {\n        return this.contentAreaContainer;\n      };\n      Editor.prototype.getElement = function () {\n        if (!this.targetElm) {\n          this.targetElm = DOM$1.get(this.id);\n        }\n        return this.targetElm;\n      };\n      Editor.prototype.getWin = function () {\n        var self = this;\n        var elm;\n        if (!self.contentWindow) {\n          elm = self.iframeElement;\n          if (elm) {\n            self.contentWindow = elm.contentWindow;\n          }\n        }\n        return self.contentWindow;\n      };\n      Editor.prototype.getDoc = function () {\n        var self = this;\n        var win;\n        if (!self.contentDocument) {\n          win = self.getWin();\n          if (win) {\n            self.contentDocument = win.document;\n          }\n        }\n        return self.contentDocument;\n      };\n      Editor.prototype.getBody = function () {\n        var doc = this.getDoc();\n        return this.bodyElement || (doc ? doc.body : null);\n      };\n      Editor.prototype.convertURL = function (url, name, elm) {\n        var self = this, settings = self.settings;\n        if (settings.urlconverter_callback) {\n          return self.execCallback('urlconverter_callback', url, elm, true, name);\n        }\n        if (!settings.convert_urls || elm && elm.nodeName === 'LINK' || url.indexOf('file:') === 0 || url.length === 0) {\n          return url;\n        }\n        if (settings.relative_urls) {\n          return self.documentBaseURI.toRelative(url);\n        }\n        url = self.documentBaseURI.toAbsolute(url, settings.remove_script_host);\n        return url;\n      };\n      Editor.prototype.addVisual = function (elm) {\n        addVisual(this, elm);\n      };\n      Editor.prototype.remove = function () {\n        remove(this);\n      };\n      Editor.prototype.destroy = function (automatic) {\n        destroy(this, automatic);\n      };\n      Editor.prototype.uploadImages = function (callback) {\n        return this.editorUpload.uploadImages(callback);\n      };\n      Editor.prototype._scanForImages = function () {\n        return this.editorUpload.scanForImages();\n      };\n      Editor.prototype.addButton = function () {\n        throw new Error('editor.addButton has been removed in tinymce 5x, use editor.ui.registry.addButton or editor.ui.registry.addToggleButton or editor.ui.registry.addSplitButton instead');\n      };\n      Editor.prototype.addSidebar = function () {\n        throw new Error('editor.addSidebar has been removed in tinymce 5x, use editor.ui.registry.addSidebar instead');\n      };\n      Editor.prototype.addMenuItem = function () {\n        throw new Error('editor.addMenuItem has been removed in tinymce 5x, use editor.ui.registry.addMenuItem instead');\n      };\n      Editor.prototype.addContextToolbar = function () {\n        throw new Error('editor.addContextToolbar has been removed in tinymce 5x, use editor.ui.registry.addContextToolbar instead');\n      };\n      return Editor;\n    }();\n\n    var DOM = DOMUtils.DOM;\n    var explode = Tools.explode, each$1 = Tools.each, extend$2 = Tools.extend;\n    var instanceCounter = 0, boundGlobalEvents = false;\n    var beforeUnloadDelegate;\n    var legacyEditors = [];\n    var editors = [];\n    var isValidLegacyKey = function (id) {\n      return id !== 'length';\n    };\n    var globalEventDelegate = function (e) {\n      var type = e.type;\n      each$1(EditorManager.get(), function (editor) {\n        switch (type) {\n        case 'scroll':\n          editor.fire('ScrollWindow', e);\n          break;\n        case 'resize':\n          editor.fire('ResizeWindow', e);\n          break;\n        }\n      });\n    };\n    var toggleGlobalEvents = function (state) {\n      if (state !== boundGlobalEvents) {\n        if (state) {\n          DomQuery(window).on('resize scroll', globalEventDelegate);\n        } else {\n          DomQuery(window).off('resize scroll', globalEventDelegate);\n        }\n        boundGlobalEvents = state;\n      }\n    };\n    var removeEditorFromList = function (targetEditor) {\n      var oldEditors = editors;\n      delete legacyEditors[targetEditor.id];\n      for (var i = 0; i < legacyEditors.length; i++) {\n        if (legacyEditors[i] === targetEditor) {\n          legacyEditors.splice(i, 1);\n          break;\n        }\n      }\n      editors = filter$4(editors, function (editor) {\n        return targetEditor !== editor;\n      });\n      if (EditorManager.activeEditor === targetEditor) {\n        EditorManager.activeEditor = editors.length > 0 ? editors[0] : null;\n      }\n      if (EditorManager.focusedEditor === targetEditor) {\n        EditorManager.focusedEditor = null;\n      }\n      return oldEditors.length !== editors.length;\n    };\n    var purgeDestroyedEditor = function (editor) {\n      if (editor && editor.initialized && !(editor.getContainer() || editor.getBody()).parentNode) {\n        removeEditorFromList(editor);\n        editor.unbindAllNativeEvents();\n        editor.destroy(true);\n        editor.removed = true;\n        editor = null;\n      }\n      return editor;\n    };\n    var isQuirksMode = document.compatMode !== 'CSS1Compat';\n    var EditorManager = __assign(__assign({}, Observable), {\n      baseURI: null,\n      baseURL: null,\n      defaultSettings: {},\n      documentBaseURL: null,\n      suffix: null,\n      $: DomQuery,\n      majorVersion: '5',\n      minorVersion: '10.9',\n      releaseDate: '2023-11-15',\n      editors: legacyEditors,\n      i18n: I18n,\n      activeEditor: null,\n      focusedEditor: null,\n      settings: {},\n      setup: function () {\n        var self = this;\n        var baseURL, documentBaseURL, suffix = '';\n        documentBaseURL = URI.getDocumentBaseUrl(document.location);\n        if (/^[^:]+:\\/\\/\\/?[^\\/]+\\//.test(documentBaseURL)) {\n          documentBaseURL = documentBaseURL.replace(/[\\?#].*$/, '').replace(/[\\/\\\\][^\\/]+$/, '');\n          if (!/[\\/\\\\]$/.test(documentBaseURL)) {\n            documentBaseURL += '/';\n          }\n        }\n        var preInit = window.tinymce || window.tinyMCEPreInit;\n        if (preInit) {\n          baseURL = preInit.base || preInit.baseURL;\n          suffix = preInit.suffix;\n        } else {\n          var scripts = document.getElementsByTagName('script');\n          for (var i = 0; i < scripts.length; i++) {\n            var src = scripts[i].src || '';\n            if (src === '') {\n              continue;\n            }\n            var srcScript = src.substring(src.lastIndexOf('/'));\n            if (/tinymce(\\.full|\\.jquery|)(\\.min|\\.dev|)\\.js/.test(src)) {\n              if (srcScript.indexOf('.min') !== -1) {\n                suffix = '.min';\n              }\n              baseURL = src.substring(0, src.lastIndexOf('/'));\n              break;\n            }\n          }\n          if (!baseURL && document.currentScript) {\n            var src = document.currentScript.src;\n            if (src.indexOf('.min') !== -1) {\n              suffix = '.min';\n            }\n            baseURL = src.substring(0, src.lastIndexOf('/'));\n          }\n        }\n        self.baseURL = new URI(documentBaseURL).toAbsolute(baseURL);\n        self.documentBaseURL = documentBaseURL;\n        self.baseURI = new URI(self.baseURL);\n        self.suffix = suffix;\n        setup$l(self);\n      },\n      overrideDefaults: function (defaultSettings) {\n        var baseUrl = defaultSettings.base_url;\n        if (baseUrl) {\n          this._setBaseUrl(baseUrl);\n        }\n        var suffix = defaultSettings.suffix;\n        if (defaultSettings.suffix) {\n          this.suffix = suffix;\n        }\n        this.defaultSettings = defaultSettings;\n        var pluginBaseUrls = defaultSettings.plugin_base_urls;\n        if (pluginBaseUrls !== undefined) {\n          each$j(pluginBaseUrls, function (pluginBaseUrl, pluginName) {\n            AddOnManager.PluginManager.urls[pluginName] = pluginBaseUrl;\n          });\n        }\n      },\n      init: function (settings) {\n        var self = this;\n        var result;\n        var invalidInlineTargets = Tools.makeMap('area base basefont br col frame hr img input isindex link meta param embed source wbr track ' + 'colgroup option table tbody tfoot thead tr th td script noscript style textarea video audio iframe object menu', ' ');\n        var isInvalidInlineTarget = function (settings, elm) {\n          return settings.inline && elm.tagName.toLowerCase() in invalidInlineTargets;\n        };\n        var createId = function (elm) {\n          var id = elm.id;\n          if (!id) {\n            id = get$9(elm, 'name').filter(function (name) {\n              return !DOM.get(name);\n            }).getOrThunk(DOM.uniqueId);\n            elm.setAttribute('id', id);\n          }\n          return id;\n        };\n        var execCallback = function (name) {\n          var callback = settings[name];\n          if (!callback) {\n            return;\n          }\n          return callback.apply(self, []);\n        };\n        var hasClass = function (elm, className) {\n          return className.constructor === RegExp ? className.test(elm.className) : DOM.hasClass(elm, className);\n        };\n        var findTargets = function (settings) {\n          var targets = [];\n          if (Env.browser.isIE() && Env.browser.version.major < 11) {\n            initError('TinyMCE does not support the browser you are using. For a list of supported' + ' browsers please see: https://www.tinymce.com/docs/get-started/system-requirements/');\n            return [];\n          } else if (isQuirksMode) {\n            initError('Failed to initialize the editor as the document is not in standards mode. ' + 'TinyMCE requires standards mode.');\n            return [];\n          }\n          if (settings.types) {\n            each$1(settings.types, function (type) {\n              targets = targets.concat(DOM.select(type.selector));\n            });\n            return targets;\n          } else if (settings.selector) {\n            return DOM.select(settings.selector);\n          } else if (settings.target) {\n            return [settings.target];\n          }\n          switch (settings.mode) {\n          case 'exact':\n            var l = settings.elements || '';\n            if (l.length > 0) {\n              each$1(explode(l), function (id) {\n                var elm = DOM.get(id);\n                if (elm) {\n                  targets.push(elm);\n                } else {\n                  each$1(document.forms, function (f) {\n                    each$1(f.elements, function (e) {\n                      if (e.name === id) {\n                        id = 'mce_editor_' + instanceCounter++;\n                        DOM.setAttrib(e, 'id', id);\n                        targets.push(e);\n                      }\n                    });\n                  });\n                }\n              });\n            }\n            break;\n          case 'textareas':\n          case 'specific_textareas':\n            each$1(DOM.select('textarea'), function (elm) {\n              if (settings.editor_deselector && hasClass(elm, settings.editor_deselector)) {\n                return;\n              }\n              if (!settings.editor_selector || hasClass(elm, settings.editor_selector)) {\n                targets.push(elm);\n              }\n            });\n            break;\n          }\n          return targets;\n        };\n        var provideResults = function (editors) {\n          result = editors;\n        };\n        var initEditors = function () {\n          var initCount = 0;\n          var editors = [];\n          var targets;\n          var createEditor = function (id, settings, targetElm) {\n            var editor = new Editor(id, settings, self);\n            editors.push(editor);\n            editor.on('init', function () {\n              if (++initCount === targets.length) {\n                provideResults(editors);\n              }\n            });\n            editor.targetElm = editor.targetElm || targetElm;\n            editor.render();\n          };\n          DOM.unbind(window, 'ready', initEditors);\n          execCallback('onpageload');\n          targets = DomQuery.unique(findTargets(settings));\n          if (settings.types) {\n            each$1(settings.types, function (type) {\n              Tools.each(targets, function (elm) {\n                if (DOM.is(elm, type.selector)) {\n                  createEditor(createId(elm), extend$2({}, settings, type), elm);\n                  return false;\n                }\n                return true;\n              });\n            });\n            return;\n          }\n          Tools.each(targets, function (elm) {\n            purgeDestroyedEditor(self.get(elm.id));\n          });\n          targets = Tools.grep(targets, function (elm) {\n            return !self.get(elm.id);\n          });\n          if (targets.length === 0) {\n            provideResults([]);\n          } else {\n            each$1(targets, function (elm) {\n              if (isInvalidInlineTarget(settings, elm)) {\n                initError('Could not initialize inline editor on invalid inline target element', elm);\n              } else {\n                createEditor(createId(elm), settings, elm);\n              }\n            });\n          }\n        };\n        self.settings = settings;\n        DOM.bind(window, 'ready', initEditors);\n        return new promiseObj(function (resolve) {\n          if (result) {\n            resolve(result);\n          } else {\n            provideResults = function (editors) {\n              resolve(editors);\n            };\n          }\n        });\n      },\n      get: function (id) {\n        if (arguments.length === 0) {\n          return editors.slice(0);\n        } else if (isString$1(id)) {\n          return find$3(editors, function (editor) {\n            return editor.id === id;\n          }).getOr(null);\n        } else if (isNumber(id)) {\n          return editors[id] ? editors[id] : null;\n        } else {\n          return null;\n        }\n      },\n      add: function (editor) {\n        var self = this;\n        var existingEditor = legacyEditors[editor.id];\n        if (existingEditor === editor) {\n          return editor;\n        }\n        if (self.get(editor.id) === null) {\n          if (isValidLegacyKey(editor.id)) {\n            legacyEditors[editor.id] = editor;\n          }\n          legacyEditors.push(editor);\n          editors.push(editor);\n        }\n        toggleGlobalEvents(true);\n        self.activeEditor = editor;\n        self.fire('AddEditor', { editor: editor });\n        if (!beforeUnloadDelegate) {\n          beforeUnloadDelegate = function (e) {\n            var event = self.fire('BeforeUnload');\n            if (event.returnValue) {\n              e.preventDefault();\n              e.returnValue = event.returnValue;\n              return event.returnValue;\n            }\n          };\n          window.addEventListener('beforeunload', beforeUnloadDelegate);\n        }\n        return editor;\n      },\n      createEditor: function (id, settings) {\n        return this.add(new Editor(id, settings, this));\n      },\n      remove: function (selector) {\n        var self = this;\n        var i, editor;\n        if (!selector) {\n          for (i = editors.length - 1; i >= 0; i--) {\n            self.remove(editors[i]);\n          }\n          return;\n        }\n        if (isString$1(selector)) {\n          each$1(DOM.select(selector), function (elm) {\n            editor = self.get(elm.id);\n            if (editor) {\n              self.remove(editor);\n            }\n          });\n          return;\n        }\n        editor = selector;\n        if (isNull(self.get(editor.id))) {\n          return null;\n        }\n        if (removeEditorFromList(editor)) {\n          self.fire('RemoveEditor', { editor: editor });\n        }\n        if (editors.length === 0) {\n          window.removeEventListener('beforeunload', beforeUnloadDelegate);\n        }\n        editor.remove();\n        toggleGlobalEvents(editors.length > 0);\n        return editor;\n      },\n      execCommand: function (cmd, ui, value) {\n        var self = this, editor = self.get(value);\n        switch (cmd) {\n        case 'mceAddEditor':\n          if (!self.get(value)) {\n            new Editor(value, self.settings, self).render();\n          }\n          return true;\n        case 'mceRemoveEditor':\n          if (editor) {\n            editor.remove();\n          }\n          return true;\n        case 'mceToggleEditor':\n          if (!editor) {\n            self.execCommand('mceAddEditor', false, value);\n            return true;\n          }\n          if (editor.isHidden()) {\n            editor.show();\n          } else {\n            editor.hide();\n          }\n          return true;\n        }\n        if (self.activeEditor) {\n          return self.activeEditor.execCommand(cmd, ui, value);\n        }\n        return false;\n      },\n      triggerSave: function () {\n        each$1(editors, function (editor) {\n          editor.save();\n        });\n      },\n      addI18n: function (code, items) {\n        I18n.add(code, items);\n      },\n      translate: function (text) {\n        return I18n.translate(text);\n      },\n      setActive: function (editor) {\n        var activeEditor = this.activeEditor;\n        if (this.activeEditor !== editor) {\n          if (activeEditor) {\n            activeEditor.fire('deactivate', { relatedTarget: editor });\n          }\n          editor.fire('activate', { relatedTarget: activeEditor });\n        }\n        this.activeEditor = editor;\n      },\n      _setBaseUrl: function (baseUrl) {\n        this.baseURL = new URI(this.documentBaseURL).toAbsolute(baseUrl.replace(/\\/+$/, ''));\n        this.baseURI = new URI(this.baseURL);\n      }\n    });\n    EditorManager.setup();\n\n    var min$1 = Math.min, max$1 = Math.max, round$1 = Math.round;\n    var relativePosition = function (rect, targetRect, rel) {\n      var x = targetRect.x;\n      var y = targetRect.y;\n      var w = rect.w;\n      var h = rect.h;\n      var targetW = targetRect.w;\n      var targetH = targetRect.h;\n      var relChars = (rel || '').split('');\n      if (relChars[0] === 'b') {\n        y += targetH;\n      }\n      if (relChars[1] === 'r') {\n        x += targetW;\n      }\n      if (relChars[0] === 'c') {\n        y += round$1(targetH / 2);\n      }\n      if (relChars[1] === 'c') {\n        x += round$1(targetW / 2);\n      }\n      if (relChars[3] === 'b') {\n        y -= h;\n      }\n      if (relChars[4] === 'r') {\n        x -= w;\n      }\n      if (relChars[3] === 'c') {\n        y -= round$1(h / 2);\n      }\n      if (relChars[4] === 'c') {\n        x -= round$1(w / 2);\n      }\n      return create$2(x, y, w, h);\n    };\n    var findBestRelativePosition = function (rect, targetRect, constrainRect, rels) {\n      var pos, i;\n      for (i = 0; i < rels.length; i++) {\n        pos = relativePosition(rect, targetRect, rels[i]);\n        if (pos.x >= constrainRect.x && pos.x + pos.w <= constrainRect.w + constrainRect.x && pos.y >= constrainRect.y && pos.y + pos.h <= constrainRect.h + constrainRect.y) {\n          return rels[i];\n        }\n      }\n      return null;\n    };\n    var inflate = function (rect, w, h) {\n      return create$2(rect.x - w, rect.y - h, rect.w + w * 2, rect.h + h * 2);\n    };\n    var intersect = function (rect, cropRect) {\n      var x1 = max$1(rect.x, cropRect.x);\n      var y1 = max$1(rect.y, cropRect.y);\n      var x2 = min$1(rect.x + rect.w, cropRect.x + cropRect.w);\n      var y2 = min$1(rect.y + rect.h, cropRect.y + cropRect.h);\n      if (x2 - x1 < 0 || y2 - y1 < 0) {\n        return null;\n      }\n      return create$2(x1, y1, x2 - x1, y2 - y1);\n    };\n    var clamp = function (rect, clampRect, fixedSize) {\n      var x1 = rect.x;\n      var y1 = rect.y;\n      var x2 = rect.x + rect.w;\n      var y2 = rect.y + rect.h;\n      var cx2 = clampRect.x + clampRect.w;\n      var cy2 = clampRect.y + clampRect.h;\n      var underflowX1 = max$1(0, clampRect.x - x1);\n      var underflowY1 = max$1(0, clampRect.y - y1);\n      var overflowX2 = max$1(0, x2 - cx2);\n      var overflowY2 = max$1(0, y2 - cy2);\n      x1 += underflowX1;\n      y1 += underflowY1;\n      if (fixedSize) {\n        x2 += underflowX1;\n        y2 += underflowY1;\n        x1 -= overflowX2;\n        y1 -= overflowY2;\n      }\n      x2 -= overflowX2;\n      y2 -= overflowY2;\n      return create$2(x1, y1, x2 - x1, y2 - y1);\n    };\n    var create$2 = function (x, y, w, h) {\n      return {\n        x: x,\n        y: y,\n        w: w,\n        h: h\n      };\n    };\n    var fromClientRect = function (clientRect) {\n      return create$2(clientRect.left, clientRect.top, clientRect.width, clientRect.height);\n    };\n    var Rect = {\n      inflate: inflate,\n      relativePosition: relativePosition,\n      findBestRelativePosition: findBestRelativePosition,\n      intersect: intersect,\n      clamp: clamp,\n      create: create$2,\n      fromClientRect: fromClientRect\n    };\n\n    var awaiter = function (resolveCb, rejectCb, timeout) {\n      if (timeout === void 0) {\n        timeout = 1000;\n      }\n      var done = false;\n      var timer = null;\n      var complete = function (completer) {\n        return function () {\n          var args = [];\n          for (var _i = 0; _i < arguments.length; _i++) {\n            args[_i] = arguments[_i];\n          }\n          if (!done) {\n            done = true;\n            if (timer !== null) {\n              clearTimeout(timer);\n              timer = null;\n            }\n            completer.apply(null, args);\n          }\n        };\n      };\n      var resolve = complete(resolveCb);\n      var reject = complete(rejectCb);\n      var start = function () {\n        var args = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n          args[_i] = arguments[_i];\n        }\n        if (!done && timer === null) {\n          timer = setTimeout(function () {\n            return reject.apply(null, args);\n          }, timeout);\n        }\n      };\n      return {\n        start: start,\n        resolve: resolve,\n        reject: reject\n      };\n    };\n    var create$1 = function () {\n      var tasks = {};\n      var resultFns = {};\n      var load = function (id, url) {\n        var loadErrMsg = 'Script at URL \"' + url + '\" failed to load';\n        var runErrMsg = 'Script at URL \"' + url + '\" did not call `tinymce.Resource.add(\\'' + id + '\\', data)` within 1 second';\n        if (tasks[id] !== undefined) {\n          return tasks[id];\n        } else {\n          var task = new promiseObj(function (resolve, reject) {\n            var waiter = awaiter(resolve, reject);\n            resultFns[id] = waiter.resolve;\n            ScriptLoader.ScriptLoader.loadScript(url, function () {\n              return waiter.start(runErrMsg);\n            }, function () {\n              return waiter.reject(loadErrMsg);\n            });\n          });\n          tasks[id] = task;\n          return task;\n        }\n      };\n      var add = function (id, data) {\n        if (resultFns[id] !== undefined) {\n          resultFns[id](data);\n          delete resultFns[id];\n        }\n        tasks[id] = promiseObj.resolve(data);\n      };\n      return {\n        load: load,\n        add: add\n      };\n    };\n    var Resource = create$1();\n\n    var each = Tools.each, extend$1 = Tools.extend;\n    var extendClass, initializing;\n    var Class = function () {\n    };\n    Class.extend = extendClass = function (props) {\n      var self = this;\n      var _super = self.prototype;\n      var Class = function () {\n        var i, mixins, mixin;\n        var self = this;\n        if (!initializing) {\n          if (self.init) {\n            self.init.apply(self, arguments);\n          }\n          mixins = self.Mixins;\n          if (mixins) {\n            i = mixins.length;\n            while (i--) {\n              mixin = mixins[i];\n              if (mixin.init) {\n                mixin.init.apply(self, arguments);\n              }\n            }\n          }\n        }\n      };\n      var dummy = function () {\n        return this;\n      };\n      var createMethod = function (name, fn) {\n        return function () {\n          var self = this;\n          var tmp = self._super;\n          self._super = _super[name];\n          var ret = fn.apply(self, arguments);\n          self._super = tmp;\n          return ret;\n        };\n      };\n      initializing = true;\n      var prototype = new self();\n      initializing = false;\n      if (props.Mixins) {\n        each(props.Mixins, function (mixin) {\n          for (var name_1 in mixin) {\n            if (name_1 !== 'init') {\n              props[name_1] = mixin[name_1];\n            }\n          }\n        });\n        if (_super.Mixins) {\n          props.Mixins = _super.Mixins.concat(props.Mixins);\n        }\n      }\n      if (props.Methods) {\n        each(props.Methods.split(','), function (name) {\n          props[name] = dummy;\n        });\n      }\n      if (props.Properties) {\n        each(props.Properties.split(','), function (name) {\n          var fieldName = '_' + name;\n          props[name] = function (value) {\n            var self = this;\n            if (value !== undefined) {\n              self[fieldName] = value;\n              return self;\n            }\n            return self[fieldName];\n          };\n        });\n      }\n      if (props.Statics) {\n        each(props.Statics, function (func, name) {\n          Class[name] = func;\n        });\n      }\n      if (props.Defaults && _super.Defaults) {\n        props.Defaults = extend$1({}, _super.Defaults, props.Defaults);\n      }\n      each$j(props, function (member, name) {\n        if (typeof member === 'function' && _super[name]) {\n          prototype[name] = createMethod(name, member);\n        } else {\n          prototype[name] = member;\n        }\n      });\n      Class.prototype = prototype;\n      Class.constructor = Class;\n      Class.extend = extendClass;\n      return Class;\n    };\n\n    var min = Math.min, max = Math.max, round = Math.round;\n    var Color = function (value) {\n      var self = {};\n      var r = 0, g = 0, b = 0;\n      var rgb2hsv = function (r, g, b) {\n        var h, s, v;\n        h = 0;\n        s = 0;\n        v = 0;\n        r = r / 255;\n        g = g / 255;\n        b = b / 255;\n        var minRGB = min(r, min(g, b));\n        var maxRGB = max(r, max(g, b));\n        if (minRGB === maxRGB) {\n          v = minRGB;\n          return {\n            h: 0,\n            s: 0,\n            v: v * 100\n          };\n        }\n        var d = r === minRGB ? g - b : b === minRGB ? r - g : b - r;\n        h = r === minRGB ? 3 : b === minRGB ? 1 : 5;\n        h = 60 * (h - d / (maxRGB - minRGB));\n        s = (maxRGB - minRGB) / maxRGB;\n        v = maxRGB;\n        return {\n          h: round(h),\n          s: round(s * 100),\n          v: round(v * 100)\n        };\n      };\n      var hsvToRgb = function (hue, saturation, brightness) {\n        hue = (parseInt(hue, 10) || 0) % 360;\n        saturation = parseInt(saturation, 10) / 100;\n        brightness = parseInt(brightness, 10) / 100;\n        saturation = max(0, min(saturation, 1));\n        brightness = max(0, min(brightness, 1));\n        if (saturation === 0) {\n          r = g = b = round(255 * brightness);\n          return;\n        }\n        var side = hue / 60;\n        var chroma = brightness * saturation;\n        var x = chroma * (1 - Math.abs(side % 2 - 1));\n        var match = brightness - chroma;\n        switch (Math.floor(side)) {\n        case 0:\n          r = chroma;\n          g = x;\n          b = 0;\n          break;\n        case 1:\n          r = x;\n          g = chroma;\n          b = 0;\n          break;\n        case 2:\n          r = 0;\n          g = chroma;\n          b = x;\n          break;\n        case 3:\n          r = 0;\n          g = x;\n          b = chroma;\n          break;\n        case 4:\n          r = x;\n          g = 0;\n          b = chroma;\n          break;\n        case 5:\n          r = chroma;\n          g = 0;\n          b = x;\n          break;\n        default:\n          r = g = b = 0;\n        }\n        r = round(255 * (r + match));\n        g = round(255 * (g + match));\n        b = round(255 * (b + match));\n      };\n      var toHex = function () {\n        var hex = function (val) {\n          val = parseInt(val, 10).toString(16);\n          return val.length > 1 ? val : '0' + val;\n        };\n        return '#' + hex(r) + hex(g) + hex(b);\n      };\n      var toRgb = function () {\n        return {\n          r: r,\n          g: g,\n          b: b\n        };\n      };\n      var toHsv = function () {\n        return rgb2hsv(r, g, b);\n      };\n      var parse = function (value) {\n        var matches;\n        if (typeof value === 'object') {\n          if ('r' in value) {\n            r = value.r;\n            g = value.g;\n            b = value.b;\n          } else if ('v' in value) {\n            hsvToRgb(value.h, value.s, value.v);\n          }\n        } else {\n          if (matches = /rgb\\s*\\(\\s*([0-9]+)\\s*,\\s*([0-9]+)\\s*,\\s*([0-9]+)[^\\)]*\\)/gi.exec(value)) {\n            r = parseInt(matches[1], 10);\n            g = parseInt(matches[2], 10);\n            b = parseInt(matches[3], 10);\n          } else if (matches = /#([0-F]{2})([0-F]{2})([0-F]{2})/gi.exec(value)) {\n            r = parseInt(matches[1], 16);\n            g = parseInt(matches[2], 16);\n            b = parseInt(matches[3], 16);\n          } else if (matches = /#([0-F])([0-F])([0-F])/gi.exec(value)) {\n            r = parseInt(matches[1] + matches[1], 16);\n            g = parseInt(matches[2] + matches[2], 16);\n            b = parseInt(matches[3] + matches[3], 16);\n          }\n        }\n        r = r < 0 ? 0 : r > 255 ? 255 : r;\n        g = g < 0 ? 0 : g > 255 ? 255 : g;\n        b = b < 0 ? 0 : b > 255 ? 255 : b;\n        return self;\n      };\n      if (value) {\n        parse(value);\n      }\n      self.toRgb = toRgb;\n      self.toHsv = toHsv;\n      self.toHex = toHex;\n      self.parse = parse;\n      return self;\n    };\n\n    var serialize = function (obj) {\n      var data = JSON.stringify(obj);\n      if (!isString$1(data)) {\n        return data;\n      }\n      return data.replace(/[\\u0080-\\uFFFF]/g, function (match) {\n        var hexCode = match.charCodeAt(0).toString(16);\n        return '\\\\u' + '0000'.substring(hexCode.length) + hexCode;\n      });\n    };\n    var JSONUtils = {\n      serialize: serialize,\n      parse: function (text) {\n        try {\n          return JSON.parse(text);\n        } catch (ex) {\n        }\n      }\n    };\n\n    var JSONP = {\n      callbacks: {},\n      count: 0,\n      send: function (settings) {\n        var self = this, dom = DOMUtils.DOM, count = settings.count !== undefined ? settings.count : self.count;\n        var id = 'tinymce_jsonp_' + count;\n        self.callbacks[count] = function (json) {\n          dom.remove(id);\n          delete self.callbacks[count];\n          settings.callback(json);\n        };\n        dom.add(dom.doc.body, 'script', {\n          id: id,\n          src: settings.url,\n          type: 'text/javascript'\n        });\n        self.count++;\n      }\n    };\n\n    var XHR = __assign(__assign({}, Observable), {\n      send: function (settings) {\n        var xhr, count = 0;\n        var ready = function () {\n          if (!settings.async || xhr.readyState === 4 || count++ > 10000) {\n            if (settings.success && count < 10000 && xhr.status === 200) {\n              settings.success.call(settings.success_scope, '' + xhr.responseText, xhr, settings);\n            } else if (settings.error) {\n              settings.error.call(settings.error_scope, count > 10000 ? 'TIMED_OUT' : 'GENERAL', xhr, settings);\n            }\n            xhr = null;\n          } else {\n            Delay.setTimeout(ready, 10);\n          }\n        };\n        settings.scope = settings.scope || this;\n        settings.success_scope = settings.success_scope || settings.scope;\n        settings.error_scope = settings.error_scope || settings.scope;\n        settings.async = settings.async !== false;\n        settings.data = settings.data || '';\n        XHR.fire('beforeInitialize', { settings: settings });\n        xhr = new XMLHttpRequest();\n        if (xhr.overrideMimeType) {\n          xhr.overrideMimeType(settings.content_type);\n        }\n        xhr.open(settings.type || (settings.data ? 'POST' : 'GET'), settings.url, settings.async);\n        if (settings.crossDomain) {\n          xhr.withCredentials = true;\n        }\n        if (settings.content_type) {\n          xhr.setRequestHeader('Content-Type', settings.content_type);\n        }\n        if (settings.requestheaders) {\n          Tools.each(settings.requestheaders, function (header) {\n            xhr.setRequestHeader(header.key, header.value);\n          });\n        }\n        xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');\n        xhr = XHR.fire('beforeSend', {\n          xhr: xhr,\n          settings: settings\n        }).xhr;\n        xhr.send(settings.data);\n        if (!settings.async) {\n          return ready();\n        }\n        Delay.setTimeout(ready, 10);\n      }\n    });\n\n    var extend = Tools.extend;\n    var JSONRequest = function () {\n      function JSONRequest(settings) {\n        this.settings = extend({}, settings);\n        this.count = 0;\n      }\n      JSONRequest.sendRPC = function (o) {\n        return new JSONRequest().send(o);\n      };\n      JSONRequest.prototype.send = function (args) {\n        var ecb = args.error, scb = args.success;\n        var xhrArgs = extend(this.settings, args);\n        xhrArgs.success = function (c, x) {\n          c = JSONUtils.parse(c);\n          if (typeof c === 'undefined') {\n            c = { error: 'JSON Parse error.' };\n          }\n          if (c.error) {\n            ecb.call(xhrArgs.error_scope || xhrArgs.scope, c.error, x);\n          } else {\n            scb.call(xhrArgs.success_scope || xhrArgs.scope, c.result);\n          }\n        };\n        xhrArgs.error = function (ty, x) {\n          if (ecb) {\n            ecb.call(xhrArgs.error_scope || xhrArgs.scope, ty, x);\n          }\n        };\n        xhrArgs.data = JSONUtils.serialize({\n          id: args.id || 'c' + this.count++,\n          method: args.method,\n          params: args.params\n        });\n        xhrArgs.content_type = 'application/json';\n        XHR.send(xhrArgs);\n      };\n      return JSONRequest;\n    }();\n\n    var create = function () {\n      return function () {\n        var data = {};\n        var keys = [];\n        var storage = {\n          getItem: function (key) {\n            var item = data[key];\n            return item ? item : null;\n          },\n          setItem: function (key, value) {\n            keys.push(key);\n            data[key] = String(value);\n          },\n          key: function (index) {\n            return keys[index];\n          },\n          removeItem: function (key) {\n            keys = keys.filter(function (k) {\n              return k === key;\n            });\n            delete data[key];\n          },\n          clear: function () {\n            keys = [];\n            data = {};\n          },\n          length: 0\n        };\n        Object.defineProperty(storage, 'length', {\n          get: function () {\n            return keys.length;\n          },\n          configurable: false,\n          enumerable: false\n        });\n        return storage;\n      }();\n    };\n\n    var localStorage;\n    try {\n      var test = '__storage_test__';\n      localStorage = window.localStorage;\n      localStorage.setItem(test, test);\n      localStorage.removeItem(test);\n    } catch (e) {\n      localStorage = create();\n    }\n    var LocalStorage = localStorage;\n\n    var publicApi = {\n      geom: { Rect: Rect },\n      util: {\n        Promise: promiseObj,\n        Delay: Delay,\n        Tools: Tools,\n        VK: VK,\n        URI: URI,\n        Class: Class,\n        EventDispatcher: EventDispatcher,\n        Observable: Observable,\n        I18n: I18n,\n        XHR: XHR,\n        JSON: JSONUtils,\n        JSONRequest: JSONRequest,\n        JSONP: JSONP,\n        LocalStorage: LocalStorage,\n        Color: Color,\n        ImageUploader: ImageUploader\n      },\n      dom: {\n        EventUtils: EventUtils,\n        Sizzle: Sizzle,\n        DomQuery: DomQuery,\n        TreeWalker: DomTreeWalker,\n        TextSeeker: TextSeeker,\n        DOMUtils: DOMUtils,\n        ScriptLoader: ScriptLoader,\n        RangeUtils: RangeUtils,\n        Serializer: DomSerializer,\n        StyleSheetLoader: StyleSheetLoader,\n        ControlSelection: ControlSelection,\n        BookmarkManager: BookmarkManager,\n        Selection: EditorSelection,\n        Event: EventUtils.Event\n      },\n      html: {\n        Styles: Styles,\n        Entities: Entities,\n        Node: AstNode,\n        Schema: Schema,\n        SaxParser: SaxParser,\n        DomParser: DomParser,\n        Writer: Writer,\n        Serializer: HtmlSerializer\n      },\n      Env: Env,\n      AddOnManager: AddOnManager,\n      Annotator: Annotator,\n      Formatter: Formatter,\n      UndoManager: UndoManager,\n      EditorCommands: EditorCommands,\n      WindowManager: WindowManager,\n      NotificationManager: NotificationManager,\n      EditorObservable: EditorObservable,\n      Shortcuts: Shortcuts,\n      Editor: Editor,\n      FocusManager: FocusManager,\n      EditorManager: EditorManager,\n      DOM: DOMUtils.DOM,\n      ScriptLoader: ScriptLoader.ScriptLoader,\n      PluginManager: PluginManager,\n      ThemeManager: ThemeManager,\n      IconManager: IconManager,\n      Resource: Resource,\n      trim: Tools.trim,\n      isArray: Tools.isArray,\n      is: Tools.is,\n      toArray: Tools.toArray,\n      makeMap: Tools.makeMap,\n      each: Tools.each,\n      map: Tools.map,\n      grep: Tools.grep,\n      inArray: Tools.inArray,\n      extend: Tools.extend,\n      create: Tools.create,\n      walk: Tools.walk,\n      createNS: Tools.createNS,\n      resolve: Tools.resolve,\n      explode: Tools.explode,\n      _addCacheSuffix: Tools._addCacheSuffix,\n      isOpera: Env.opera,\n      isWebKit: Env.webkit,\n      isIE: Env.ie,\n      isGecko: Env.gecko,\n      isMac: Env.mac\n    };\n    var tinymce = Tools.extend(EditorManager, publicApi);\n\n    var exportToModuleLoaders = function (tinymce) {\n      if (true) {\n        try {\n          module.exports = tinymce;\n        } catch (_) {\n        }\n      }\n    };\n    var exportToWindowGlobal = function (tinymce) {\n      window.tinymce = tinymce;\n      window.tinyMCE = tinymce;\n    };\n    exportToWindowGlobal(tinymce);\n    exportToModuleLoaders(tinymce);\n\n}());\n\n\n//# sourceURL=webpack://kd-libs/../../node_modules/tinymce/tinymce.js?");

/***/ })

}]);