(function (global, factory) {
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BpmnJSPropertiesPanel = {}));
})(this, (function (exports) { 'use strict';

  var n$1,
      u$1,
      i$3,
      t$2,
      o$3,
      r$1 = {},
      f$1 = [],
      e$2 = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;

  function c$1(n, l) {
    for (var u in l) n[u] = l[u];

    return n;
  }

  function s$1(n) {
    var l = n.parentNode;
    l && l.removeChild(n);
  }

  function a$2(n, l, u) {
    var i,
        t,
        o,
        r = arguments,
        f = {};

    for (o in l) "key" == o ? i = l[o] : "ref" == o ? t = l[o] : f[o] = l[o];

    if (arguments.length > 3) for (u = [u], o = 3; o < arguments.length; o++) u.push(r[o]);
    if (null != u && (f.children = u), "function" == typeof n && null != n.defaultProps) for (o in n.defaultProps) void 0 === f[o] && (f[o] = n.defaultProps[o]);
    return v$1(n, f, i, t, null);
  }

  function v$1(l, u, i, t, o) {
    var r = {
      type: l,
      props: u,
      key: i,
      ref: t,
      __k: null,
      __: null,
      __b: 0,
      __e: null,
      __d: void 0,
      __c: null,
      __h: null,
      constructor: void 0,
      __v: null == o ? ++n$1.__v : o
    };
    return null != n$1.vnode && n$1.vnode(r), r;
  }

  function h$1() {
    return {
      current: null
    };
  }

  function y$1(n) {
    return n.children;
  }

  function p$2(n, l) {
    this.props = n, this.context = l;
  }

  function d$1(n, l) {
    if (null == l) return n.__ ? d$1(n.__, n.__.__k.indexOf(n) + 1) : null;

    for (var u; l < n.__k.length; l++) if (null != (u = n.__k[l]) && null != u.__e) return u.__e;

    return "function" == typeof n.type ? d$1(n) : null;
  }

  function _$1(n) {
    var l, u;

    if (null != (n = n.__) && null != n.__c) {
      for (n.__e = n.__c.base = null, l = 0; l < n.__k.length; l++) if (null != (u = n.__k[l]) && null != u.__e) {
        n.__e = n.__c.base = u.__e;
        break;
      }

      return _$1(n);
    }
  }

  function k$2(l) {
    (!l.__d && (l.__d = !0) && u$1.push(l) && !b$1.__r++ || t$2 !== n$1.debounceRendering) && ((t$2 = n$1.debounceRendering) || i$3)(b$1);
  }

  function b$1() {
    for (var n; b$1.__r = u$1.length;) n = u$1.sort(function (n, l) {
      return n.__v.__b - l.__v.__b;
    }), u$1 = [], n.some(function (n) {
      var l, u, i, t, o, r;
      n.__d && (o = (t = (l = n).__v).__e, (r = l.__P) && (u = [], (i = c$1({}, t)).__v = t.__v + 1, I$1(r, t, i, l.__n, void 0 !== r.ownerSVGElement, null != t.__h ? [o] : null, u, null == o ? d$1(t) : o, t.__h), T$2(u, t), t.__e != o && _$1(t)));
    });
  }

  function m$1(n, l, u, i, t, o, e, c, s, a) {
    var h,
        p,
        _,
        k,
        b,
        m,
        w,
        A = i && i.__k || f$1,
        P = A.length;

    for (u.__k = [], h = 0; h < l.length; h++) if (null != (k = u.__k[h] = null == (k = l[h]) || "boolean" == typeof k ? null : "string" == typeof k || "number" == typeof k || "bigint" == typeof k ? v$1(null, k, null, null, k) : Array.isArray(k) ? v$1(y$1, {
      children: k
    }, null, null, null) : k.__b > 0 ? v$1(k.type, k.props, k.key, null, k.__v) : k)) {
      if (k.__ = u, k.__b = u.__b + 1, null === (_ = A[h]) || _ && k.key == _.key && k.type === _.type) A[h] = void 0;else for (p = 0; p < P; p++) {
        if ((_ = A[p]) && k.key == _.key && k.type === _.type) {
          A[p] = void 0;
          break;
        }

        _ = null;
      }
      I$1(n, k, _ = _ || r$1, t, o, e, c, s, a), b = k.__e, (p = k.ref) && _.ref != p && (w || (w = []), _.ref && w.push(_.ref, null, k), w.push(p, k.__c || b, k)), null != b ? (null == m && (m = b), "function" == typeof k.type && null != k.__k && k.__k === _.__k ? k.__d = s = g$2(k, s, n) : s = x$2(n, k, _, A, b, s), a || "option" !== u.type ? "function" == typeof u.type && (u.__d = s) : n.value = "") : s && _.__e == s && s.parentNode != n && (s = d$1(_));
    }

    for (u.__e = m, h = P; h--;) null != A[h] && ("function" == typeof u.type && null != A[h].__e && A[h].__e == u.__d && (u.__d = d$1(i, h + 1)), L$1(A[h], A[h]));

    if (w) for (h = 0; h < w.length; h++) z$1(w[h], w[++h], w[++h]);
  }

  function g$2(n, l, u) {
    var i, t;

    for (i = 0; i < n.__k.length; i++) (t = n.__k[i]) && (t.__ = n, l = "function" == typeof t.type ? g$2(t, l, u) : x$2(u, t, t, n.__k, t.__e, l));

    return l;
  }

  function w$2(n, l) {
    return l = l || [], null == n || "boolean" == typeof n || (Array.isArray(n) ? n.some(function (n) {
      w$2(n, l);
    }) : l.push(n)), l;
  }

  function x$2(n, l, u, i, t, o) {
    var r, f, e;
    if (void 0 !== l.__d) r = l.__d, l.__d = void 0;else if (null == u || t != o || null == t.parentNode) n: if (null == o || o.parentNode !== n) n.appendChild(t), r = null;else {
      for (f = o, e = 0; (f = f.nextSibling) && e < i.length; e += 2) if (f == t) break n;

      n.insertBefore(t, o), r = o;
    }
    return void 0 !== r ? r : t.nextSibling;
  }

  function A$2(n, l, u, i, t) {
    var o;

    for (o in u) "children" === o || "key" === o || o in l || C$2(n, o, null, u[o], i);

    for (o in l) t && "function" != typeof l[o] || "children" === o || "key" === o || "value" === o || "checked" === o || u[o] === l[o] || C$2(n, o, l[o], u[o], i);
  }

  function P$1(n, l, u) {
    "-" === l[0] ? n.setProperty(l, u) : n[l] = null == u ? "" : "number" != typeof u || e$2.test(l) ? u : u + "px";
  }

  function C$2(n, l, u, i, t) {
    var o;

    n: if ("style" === l) {
      if ("string" == typeof u) n.style.cssText = u;else {
        if ("string" == typeof i && (n.style.cssText = i = ""), i) for (l in i) u && l in u || P$1(n.style, l, "");
        if (u) for (l in u) i && u[l] === i[l] || P$1(n.style, l, u[l]);
      }
    } else if ("o" === l[0] && "n" === l[1]) o = l !== (l = l.replace(/Capture$/, "")), l = l.toLowerCase() in n ? l.toLowerCase().slice(2) : l.slice(2), n.l || (n.l = {}), n.l[l + o] = u, u ? i || n.addEventListener(l, o ? H$1 : $$1, o) : n.removeEventListener(l, o ? H$1 : $$1, o);else if ("dangerouslySetInnerHTML" !== l) {
      if (t) l = l.replace(/xlink[H:h]/, "h").replace(/sName$/, "s");else if ("href" !== l && "list" !== l && "form" !== l && "tabIndex" !== l && "download" !== l && l in n) try {
        n[l] = null == u ? "" : u;
        break n;
      } catch (n) {}
      "function" == typeof u || (null != u && (!1 !== u || "a" === l[0] && "r" === l[1]) ? n.setAttribute(l, u) : n.removeAttribute(l));
    }
  }

  function $$1(l) {
    this.l[l.type + !1](n$1.event ? n$1.event(l) : l);
  }

  function H$1(l) {
    this.l[l.type + !0](n$1.event ? n$1.event(l) : l);
  }

  function I$1(l, u, i, t, o, r, f, e, s) {
    var a,
        v,
        h,
        d,
        _,
        k,
        b,
        g,
        w,
        x,
        A,
        P = u.type;

    if (void 0 !== u.constructor) return null;
    null != i.__h && (s = i.__h, e = u.__e = i.__e, u.__h = null, r = [e]), (a = n$1.__b) && a(u);

    try {
      n: if ("function" == typeof P) {
        if (g = u.props, w = (a = P.contextType) && t[a.__c], x = a ? w ? w.props.value : a.__ : t, i.__c ? b = (v = u.__c = i.__c).__ = v.__E : ("prototype" in P && P.prototype.render ? u.__c = v = new P(g, x) : (u.__c = v = new p$2(g, x), v.constructor = P, v.render = M$1), w && w.sub(v), v.props = g, v.state || (v.state = {}), v.context = x, v.__n = t, h = v.__d = !0, v.__h = []), null == v.__s && (v.__s = v.state), null != P.getDerivedStateFromProps && (v.__s == v.state && (v.__s = c$1({}, v.__s)), c$1(v.__s, P.getDerivedStateFromProps(g, v.__s))), d = v.props, _ = v.state, h) null == P.getDerivedStateFromProps && null != v.componentWillMount && v.componentWillMount(), null != v.componentDidMount && v.__h.push(v.componentDidMount);else {
          if (null == P.getDerivedStateFromProps && g !== d && null != v.componentWillReceiveProps && v.componentWillReceiveProps(g, x), !v.__e && null != v.shouldComponentUpdate && !1 === v.shouldComponentUpdate(g, v.__s, x) || u.__v === i.__v) {
            v.props = g, v.state = v.__s, u.__v !== i.__v && (v.__d = !1), v.__v = u, u.__e = i.__e, u.__k = i.__k, u.__k.forEach(function (n) {
              n && (n.__ = u);
            }), v.__h.length && f.push(v);
            break n;
          }

          null != v.componentWillUpdate && v.componentWillUpdate(g, v.__s, x), null != v.componentDidUpdate && v.__h.push(function () {
            v.componentDidUpdate(d, _, k);
          });
        }
        v.context = x, v.props = g, v.state = v.__s, (a = n$1.__r) && a(u), v.__d = !1, v.__v = u, v.__P = l, a = v.render(v.props, v.state, v.context), v.state = v.__s, null != v.getChildContext && (t = c$1(c$1({}, t), v.getChildContext())), h || null == v.getSnapshotBeforeUpdate || (k = v.getSnapshotBeforeUpdate(d, _)), A = null != a && a.type === y$1 && null == a.key ? a.props.children : a, m$1(l, Array.isArray(A) ? A : [A], u, i, t, o, r, f, e, s), v.base = u.__e, u.__h = null, v.__h.length && f.push(v), b && (v.__E = v.__ = null), v.__e = !1;
      } else null == r && u.__v === i.__v ? (u.__k = i.__k, u.__e = i.__e) : u.__e = j$2(i.__e, u, i, t, o, r, f, s);

      (a = n$1.diffed) && a(u);
    } catch (l) {
      u.__v = null, (s || null != r) && (u.__e = e, u.__h = !!s, r[r.indexOf(e)] = null), n$1.__e(l, u, i);
    }
  }

  function T$2(l, u) {
    n$1.__c && n$1.__c(u, l), l.some(function (u) {
      try {
        l = u.__h, u.__h = [], l.some(function (n) {
          n.call(u);
        });
      } catch (l) {
        n$1.__e(l, u.__v);
      }
    });
  }

  function j$2(n, l, u, i, t, o, e, c) {
    var a,
        v,
        h,
        y,
        p = u.props,
        d = l.props,
        _ = l.type,
        k = 0;
    if ("svg" === _ && (t = !0), null != o) for (; k < o.length; k++) if ((a = o[k]) && (a === n || (_ ? a.localName == _ : 3 == a.nodeType))) {
      n = a, o[k] = null;
      break;
    }

    if (null == n) {
      if (null === _) return document.createTextNode(d);
      n = t ? document.createElementNS("http://www.w3.org/2000/svg", _) : document.createElement(_, d.is && d), o = null, c = !1;
    }

    if (null === _) p === d || c && n.data === d || (n.data = d);else {
      if (o = o && f$1.slice.call(n.childNodes), v = (p = u.props || r$1).dangerouslySetInnerHTML, h = d.dangerouslySetInnerHTML, !c) {
        if (null != o) for (p = {}, y = 0; y < n.attributes.length; y++) p[n.attributes[y].name] = n.attributes[y].value;
        (h || v) && (h && (v && h.__html == v.__html || h.__html === n.innerHTML) || (n.innerHTML = h && h.__html || ""));
      }

      if (A$2(n, d, p, t, c), h) l.__k = [];else if (k = l.props.children, m$1(n, Array.isArray(k) ? k : [k], l, u, i, t && "foreignObject" !== _, o, e, n.firstChild, c), null != o) for (k = o.length; k--;) null != o[k] && s$1(o[k]);
      c || ("value" in d && void 0 !== (k = d.value) && (k !== n.value || "progress" === _ && !k) && C$2(n, "value", k, p.value, !1), "checked" in d && void 0 !== (k = d.checked) && k !== n.checked && C$2(n, "checked", k, p.checked, !1));
    }
    return n;
  }

  function z$1(l, u, i) {
    try {
      "function" == typeof l ? l(u) : l.current = u;
    } catch (l) {
      n$1.__e(l, i);
    }
  }

  function L$1(l, u, i) {
    var t, o, r;

    if (n$1.unmount && n$1.unmount(l), (t = l.ref) && (t.current && t.current !== l.__e || z$1(t, null, u)), i || "function" == typeof l.type || (i = null != (o = l.__e)), l.__e = l.__d = void 0, null != (t = l.__c)) {
      if (t.componentWillUnmount) try {
        t.componentWillUnmount();
      } catch (l) {
        n$1.__e(l, u);
      }
      t.base = t.__P = null;
    }

    if (t = l.__k) for (r = 0; r < t.length; r++) t[r] && L$1(t[r], u, i);
    null != o && s$1(o);
  }

  function M$1(n, l, u) {
    return this.constructor(n, u);
  }

  function N$1(l, u, i) {
    var t, o, e;
    n$1.__ && n$1.__(l, u), o = (t = "function" == typeof i) ? null : i && i.__k || u.__k, e = [], I$1(u, l = (!t && i || u).__k = a$2(y$1, null, [l]), o || r$1, r$1, void 0 !== u.ownerSVGElement, !t && i ? [i] : o ? null : u.firstChild ? f$1.slice.call(u.childNodes) : null, e, !t && i ? i : o ? o.__e : u.firstChild, t), T$2(e, l);
  }

  function O$1(n, l) {
    N$1(n, l, O$1);
  }

  function S$1(n, l, u) {
    var i,
        t,
        o,
        r = arguments,
        f = c$1({}, n.props);

    for (o in l) "key" == o ? i = l[o] : "ref" == o ? t = l[o] : f[o] = l[o];

    if (arguments.length > 3) for (u = [u], o = 3; o < arguments.length; o++) u.push(r[o]);
    return null != u && (f.children = u), v$1(n.type, f, i || n.key, t || n.ref, null);
  }

  function q$1(n, l) {
    var u = {
      __c: l = "__cC" + o$3++,
      __: n,
      Consumer: function (n, l) {
        return n.children(l);
      },
      Provider: function (n) {
        var u, i;
        return this.getChildContext || (u = [], (i = {})[l] = this, this.getChildContext = function () {
          return i;
        }, this.shouldComponentUpdate = function (n) {
          this.props.value !== n.value && u.some(k$2);
        }, this.sub = function (n) {
          u.push(n);
          var l = n.componentWillUnmount;

          n.componentWillUnmount = function () {
            u.splice(u.indexOf(n), 1), l && l.call(n);
          };
        }), n.children;
      }
    };
    return u.Provider.__ = u.Consumer.contextType = u;
  }

  n$1 = {
    __e: function (n, l) {
      for (var u, i, t; l = l.__;) if ((u = l.__c) && !u.__) try {
        if ((i = u.constructor) && null != i.getDerivedStateFromError && (u.setState(i.getDerivedStateFromError(n)), t = u.__d), null != u.componentDidCatch && (u.componentDidCatch(n), t = u.__d), t) return u.__E = u;
      } catch (l) {
        n = l;
      }

      throw n;
    },
    __v: 0
  }, p$2.prototype.setState = function (n, l) {
    var u;
    u = null != this.__s && this.__s !== this.state ? this.__s : this.__s = c$1({}, this.state), "function" == typeof n && (n = n(c$1({}, u), this.props)), n && c$1(u, n), null != n && this.__v && (l && this.__h.push(l), k$2(this));
  }, p$2.prototype.forceUpdate = function (n) {
    this.__v && (this.__e = !0, n && this.__h.push(n), k$2(this));
  }, p$2.prototype.render = y$1, u$1 = [], i$3 = "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, b$1.__r = 0, o$3 = 0;

  var t$1,
      u,
      r,
      o$2 = 0,
      i$2 = [],
      c = n$1.__b,
      f = n$1.__r,
      e$1 = n$1.diffed,
      a$1 = n$1.__c,
      v = n$1.unmount;

  function m(t, r) {
    n$1.__h && n$1.__h(u, t, o$2 || r), o$2 = 0;
    var i = u.__H || (u.__H = {
      __: [],
      __h: []
    });
    return t >= i.__.length && i.__.push({}), i.__[t];
  }

  function l$1(n) {
    return o$2 = 1, p$1(w$1, n);
  }

  function p$1(n, r, o) {
    var i = m(t$1++, 2);
    return i.t = n, i.__c || (i.__ = [o ? o(r) : w$1(void 0, r), function (n) {
      var t = i.t(i.__[0], n);
      i.__[0] !== t && (i.__ = [t, i.__[1]], i.__c.setState({}));
    }], i.__c = u), i.__;
  }

  function y(r, o) {
    var i = m(t$1++, 3);
    !n$1.__s && k$1(i.__H, o) && (i.__ = r, i.__H = o, u.__H.__h.push(i));
  }

  function h(r, o) {
    var i = m(t$1++, 4);
    !n$1.__s && k$1(i.__H, o) && (i.__ = r, i.__H = o, u.__h.push(i));
  }

  function s(n) {
    return o$2 = 5, d(function () {
      return {
        current: n
      };
    }, []);
  }

  function _(n, t, u) {
    o$2 = 6, h(function () {
      "function" == typeof n ? n(t()) : n && (n.current = t());
    }, null == u ? u : u.concat(n));
  }

  function d(n, u) {
    var r = m(t$1++, 7);
    return k$1(r.__H, u) && (r.__ = n(), r.__H = u, r.__h = n), r.__;
  }

  function A$1(n, t) {
    return o$2 = 8, d(function () {
      return n;
    }, t);
  }

  function F$1(n) {
    var r = u.context[n.__c],
        o = m(t$1++, 9);
    return o.__c = n, r ? (null == o.__ && (o.__ = !0, r.sub(u)), r.props.value) : n.__;
  }

  function T$1(t, u) {
    n$1.useDebugValue && n$1.useDebugValue(u ? u(t) : t);
  }

  function x$1() {
    i$2.forEach(function (t) {
      if (t.__P) try {
        t.__H.__h.forEach(g$1), t.__H.__h.forEach(j$1), t.__H.__h = [];
      } catch (u) {
        t.__H.__h = [], n$1.__e(u, t.__v);
      }
    }), i$2 = [];
  }

  n$1.__b = function (n) {
    u = null, c && c(n);
  }, n$1.__r = function (n) {
    f && f(n), t$1 = 0;
    var r = (u = n.__c).__H;
    r && (r.__h.forEach(g$1), r.__h.forEach(j$1), r.__h = []);
  }, n$1.diffed = function (t) {
    e$1 && e$1(t);
    var o = t.__c;
    o && o.__H && o.__H.__h.length && (1 !== i$2.push(o) && r === n$1.requestAnimationFrame || ((r = n$1.requestAnimationFrame) || function (n) {
      var t,
          u = function () {
        clearTimeout(r), b && cancelAnimationFrame(t), setTimeout(n);
      },
          r = setTimeout(u, 100);

      b && (t = requestAnimationFrame(u));
    })(x$1)), u = void 0;
  }, n$1.__c = function (t, u) {
    u.some(function (t) {
      try {
        t.__h.forEach(g$1), t.__h = t.__h.filter(function (n) {
          return !n.__ || j$1(n);
        });
      } catch (r) {
        u.some(function (n) {
          n.__h && (n.__h = []);
        }), u = [], n$1.__e(r, t.__v);
      }
    }), a$1 && a$1(t, u);
  }, n$1.unmount = function (t) {
    v && v(t);
    var u = t.__c;
    if (u && u.__H) try {
      u.__H.__.forEach(g$1);
    } catch (t) {
      n$1.__e(t, u.__v);
    }
  };
  var b = "function" == typeof requestAnimationFrame;

  function g$1(n) {
    var t = u;
    "function" == typeof n.__c && n.__c(), u = t;
  }

  function j$1(n) {
    var t = u;
    n.__c = n.__(), u = t;
  }

  function k$1(n, t) {
    return !n || n.length !== t.length || t.some(function (t, u) {
      return t !== n[u];
    });
  }

  function w$1(n, t) {
    return "function" == typeof t ? t(n) : t;
  }

  /**
   * Flatten array, one level deep.
   *
   * @param {Array<?>} arr
   *
   * @return {Array<?>}
   */
  function flatten$1(arr) {
    return Array.prototype.concat.apply([], arr);
  }

  const nativeToString = Object.prototype.toString;
  const nativeHasOwnProperty = Object.prototype.hasOwnProperty;

  function isUndefined(obj) {
    return obj === undefined;
  }

  function isDefined(obj) {
    return obj !== undefined;
  }

  function isNil(obj) {
    return obj == null;
  }

  function isArray(obj) {
    return nativeToString.call(obj) === '[object Array]';
  }

  function isObject(obj) {
    return nativeToString.call(obj) === '[object Object]';
  }

  function isNumber(obj) {
    return nativeToString.call(obj) === '[object Number]';
  }

  function isFunction(obj) {
    const tag = nativeToString.call(obj);
    return tag === '[object Function]' || tag === '[object AsyncFunction]' || tag === '[object GeneratorFunction]' || tag === '[object AsyncGeneratorFunction]' || tag === '[object Proxy]';
  }

  function isString(obj) {
    return nativeToString.call(obj) === '[object String]';
  }
  /**
   * Ensure collection is an array.
   *
   * @param {Object} obj
   */


  function ensureArray(obj) {
    if (isArray(obj)) {
      return;
    }

    throw new Error('must supply array');
  }
  /**
   * Return true, if target owns a property with the given key.
   *
   * @param {Object} target
   * @param {String} key
   *
   * @return {Boolean}
   */


  function has(target, key) {
    return nativeHasOwnProperty.call(target, key);
  }
  /**
   * Find element in collection.
   *
   * @param  {Array|Object} collection
   * @param  {Function|Object} matcher
   *
   * @return {Object}
   */


  function find$1(collection, matcher) {
    matcher = toMatcher(matcher);
    let match;
    forEach(collection, function (val, key) {
      if (matcher(val, key)) {
        match = val;
        return false;
      }
    });
    return match;
  }
  /**
   * Find element index in collection.
   *
   * @param  {Array|Object} collection
   * @param  {Function} matcher
   *
   * @return {Object}
   */


  function findIndex(collection, matcher) {
    matcher = toMatcher(matcher);
    let idx = isArray(collection) ? -1 : undefined;
    forEach(collection, function (val, key) {
      if (matcher(val, key)) {
        idx = key;
        return false;
      }
    });
    return idx;
  }
  /**
   * Find element in collection.
   *
   * @param  {Array|Object} collection
   * @param  {Function} matcher
   *
   * @return {Array} result
   */


  function filter(collection, matcher) {
    let result = [];
    forEach(collection, function (val, key) {
      if (matcher(val, key)) {
        result.push(val);
      }
    });
    return result;
  }
  /**
   * Iterate over collection; returning something
   * (non-undefined) will stop iteration.
   *
   * @param  {Array|Object} collection
   * @param  {Function} iterator
   *
   * @return {Object} return result that stopped the iteration
   */


  function forEach(collection, iterator) {
    let val, result;

    if (isUndefined(collection)) {
      return;
    }

    const convertKey = isArray(collection) ? toNum : identity;

    for (let key in collection) {
      if (has(collection, key)) {
        val = collection[key];
        result = iterator(val, convertKey(key));

        if (result === false) {
          return val;
        }
      }
    }
  }
  /**
   * Return collection without element.
   *
   * @param  {Array} arr
   * @param  {Function} matcher
   *
   * @return {Array}
   */


  function without(arr, matcher) {
    if (isUndefined(arr)) {
      return [];
    }

    ensureArray(arr);
    matcher = toMatcher(matcher);
    return arr.filter(function (el, idx) {
      return !matcher(el, idx);
    });
  }
  /**
   * Reduce collection, returning a single result.
   *
   * @param  {Object|Array} collection
   * @param  {Function} iterator
   * @param  {Any} result
   *
   * @return {Any} result returned from last iterator
   */


  function reduce(collection, iterator, result) {
    forEach(collection, function (value, idx) {
      result = iterator(result, value, idx);
    });
    return result;
  }
  /**
   * Return true if every element in the collection
   * matches the criteria.
   *
   * @param  {Object|Array} collection
   * @param  {Function} matcher
   *
   * @return {Boolean}
   */


  function every(collection, matcher) {
    return !!reduce(collection, function (matches, val, key) {
      return matches && matcher(val, key);
    }, true);
  }
  /**
   * Return true if some elements in the collection
   * match the criteria.
   *
   * @param  {Object|Array} collection
   * @param  {Function} matcher
   *
   * @return {Boolean}
   */


  function some(collection, matcher) {
    return !!find$1(collection, matcher);
  }
  /**
   * Transform a collection into another collection
   * by piping each member through the given fn.
   *
   * @param  {Object|Array}   collection
   * @param  {Function} fn
   *
   * @return {Array} transformed collection
   */


  function map$1(collection, fn) {
    let result = [];
    forEach(collection, function (val, key) {
      result.push(fn(val, key));
    });
    return result;
  }
  /**
   * Get the collections keys.
   *
   * @param  {Object|Array} collection
   *
   * @return {Array}
   */


  function keys(collection) {
    return collection && Object.keys(collection) || [];
  }
  /**
   * Shorthand for `keys(o).length`.
   *
   * @param  {Object|Array} collection
   *
   * @return {Number}
   */


  function size(collection) {
    return keys(collection).length;
  }
  /**
   * Get the values in the collection.
   *
   * @param  {Object|Array} collection
   *
   * @return {Array}
   */


  function values(collection) {
    return map$1(collection, val => val);
  }
  /**
   * Group collection members by attribute.
   *
   * @param  {Object|Array} collection
   * @param  {Function} extractor
   *
   * @return {Object} map with { attrValue => [ a, b, c ] }
   */


  function groupBy(collection, extractor, grouped = {}) {
    extractor = toExtractor(extractor);
    forEach(collection, function (val) {
      let discriminator = extractor(val) || '_';
      let group = grouped[discriminator];

      if (!group) {
        group = grouped[discriminator] = [];
      }

      group.push(val);
    });
    return grouped;
  }

  function uniqueBy(extractor, ...collections) {
    extractor = toExtractor(extractor);
    let grouped = {};
    forEach(collections, c => groupBy(c, extractor, grouped));
    let result = map$1(grouped, function (val, key) {
      return val[0];
    });
    return result;
  }

  const unionBy = uniqueBy;
  /**
   * Sort collection by criteria.
   *
   * @param  {Object|Array} collection
   * @param  {String|Function} extractor
   *
   * @return {Array}
   */

  function sortBy(collection, extractor) {
    extractor = toExtractor(extractor);
    let sorted = [];
    forEach(collection, function (value, key) {
      let disc = extractor(value, key);
      let entry = {
        d: disc,
        v: value
      };

      for (var idx = 0; idx < sorted.length; idx++) {
        let {
          d
        } = sorted[idx];

        if (disc < d) {
          sorted.splice(idx, 0, entry);
          return;
        }
      } // not inserted, append (!)


      sorted.push(entry);
    });
    return map$1(sorted, e => e.v);
  }
  /**
   * Create an object pattern matcher.
   *
   * @example
   *
   * const matcher = matchPattern({ id: 1 });
   *
   * let element = find(elements, matcher);
   *
   * @param  {Object} pattern
   *
   * @return {Function} matcherFn
   */


  function matchPattern(pattern) {
    return function (el) {
      return every(pattern, function (val, key) {
        return el[key] === val;
      });
    };
  }

  function toExtractor(extractor) {
    return isFunction(extractor) ? extractor : e => {
      return e[extractor];
    };
  }

  function toMatcher(matcher) {
    return isFunction(matcher) ? matcher : e => {
      return e === matcher;
    };
  }

  function identity(arg) {
    return arg;
  }

  function toNum(arg) {
    return Number(arg);
  }
  /**
   * Debounce fn, calling it only once if the given time
   * elapsed between calls.
   *
   * Lodash-style the function exposes methods to `#clear`
   * and `#flush` to control internal behavior.
   *
   * @param  {Function} fn
   * @param  {Number} timeout
   *
   * @return {Function} debounced function
   */


  function debounce(fn, timeout) {
    let timer;
    let lastArgs;
    let lastThis;
    let lastNow;

    function fire(force) {
      let now = Date.now();
      let scheduledDiff = force ? 0 : lastNow + timeout - now;

      if (scheduledDiff > 0) {
        return schedule(scheduledDiff);
      }

      fn.apply(lastThis, lastArgs);
      clear();
    }

    function schedule(timeout) {
      timer = setTimeout(fire, timeout);
    }

    function clear() {
      if (timer) {
        clearTimeout(timer);
      }

      timer = lastNow = lastArgs = lastThis = undefined;
    }

    function flush() {
      if (timer) {
        fire(true);
      }

      clear();
    }

    function callback(...args) {
      lastNow = Date.now();
      lastArgs = args;
      lastThis = this; // ensure an execution is scheduled

      if (!timer) {
        schedule(timeout);
      }
    }

    callback.flush = flush;
    callback.cancel = clear;
    return callback;
  }
  /**
   * Throttle fn, calling at most once
   * in the given interval.
   *
   * @param  {Function} fn
   * @param  {Number} interval
   *
   * @return {Function} throttled function
   */


  function throttle(fn, interval) {
    let throttling = false;
    return function (...args) {
      if (throttling) {
        return;
      }

      fn(...args);
      throttling = true;
      setTimeout(() => {
        throttling = false;
      }, interval);
    };
  }
  /**
   * Bind function against target <this>.
   *
   * @param  {Function} fn
   * @param  {Object}   target
   *
   * @return {Function} bound function
   */


  function bind(fn, target) {
    return fn.bind(target);
  }
  /**
   * Convenience wrapper for `Object.assign`.
   *
   * @param {Object} target
   * @param {...Object} others
   *
   * @return {Object} the target
   */


  function assign(target, ...others) {
    return Object.assign(target, ...others);
  }
  /**
   * Sets a nested property of a given object to the specified value.
   *
   * This mutates the object and returns it.
   *
   * @param {Object} target The target of the set operation.
   * @param {(string|number)[]} path The path to the nested value.
   * @param {any} value The value to set.
   */


  function set(target, path, value) {
    let currentTarget = target;
    forEach(path, function (key, idx) {
      if (typeof key !== 'number' && typeof key !== 'string') {
        throw new Error('illegal key type: ' + typeof key + '. Key should be of type number or string.');
      }

      if (key === 'constructor') {
        throw new Error('illegal key: constructor');
      }

      if (key === '__proto__') {
        throw new Error('illegal key: __proto__');
      }

      let nextKey = path[idx + 1];
      let nextTarget = currentTarget[key];

      if (isDefined(nextKey) && isNil(nextTarget)) {
        nextTarget = currentTarget[key] = isNaN(+nextKey) ? {} : [];
      }

      if (isUndefined(nextKey)) {
        if (isUndefined(value)) {
          delete currentTarget[key];
        } else {
          currentTarget[key] = value;
        }
      } else {
        currentTarget = nextTarget;
      }
    });
    return target;
  }
  /**
   * Gets a nested property of a given object.
   *
   * @param {Object} target The target of the get operation.
   * @param {(string|number)[]} path The path to the nested value.
   * @param {any} [defaultValue] The value to return if no value exists.
   */


  function get(target, path, defaultValue) {
    let currentTarget = target;
    forEach(path, function (key) {
      // accessing nil property yields <undefined>
      if (isNil(currentTarget)) {
        currentTarget = undefined;
        return false;
      }

      currentTarget = currentTarget[key];
    });
    return isUndefined(currentTarget) ? defaultValue : currentTarget;
  }
  /**
   * Pick given properties from the target object.
   *
   * @param {Object} target
   * @param {Array} properties
   *
   * @return {Object} target
   */


  function pick(target, properties) {
    let result = {};
    let obj = Object(target);
    forEach(properties, function (prop) {
      if (prop in obj) {
        result[prop] = target[prop];
      }
    });
    return result;
  }
  /**
   * Pick all target properties, excluding the given ones.
   *
   * @param {Object} target
   * @param {Array} properties
   *
   * @return {Object} target
   */


  function omit(target, properties) {
    let result = {};
    let obj = Object(target);
    forEach(obj, function (prop, key) {
      if (properties.indexOf(key) === -1) {
        result[key] = prop;
      }
    });
    return result;
  }
  /**
   * Recursively merge `...sources` into given target.
   *
   * Does support merging objects; does not support merging arrays.
   *
   * @param {Object} target
   * @param {...Object} sources
   *
   * @return {Object} the target
   */


  function merge(target, ...sources) {
    if (!sources.length) {
      return target;
    }

    forEach(sources, function (source) {
      // skip non-obj sources, i.e. null
      if (!source || !isObject(source)) {
        return;
      }

      forEach(source, function (sourceVal, key) {
        if (key === '__proto__') {
          return;
        }

        let targetVal = target[key];

        if (isObject(sourceVal)) {
          if (!isObject(targetVal)) {
            // override target[key] with object
            targetVal = {};
          }

          target[key] = merge(targetVal, sourceVal);
        } else {
          target[key] = sourceVal;
        }
      });
    });
    return target;
  }

  var index_esm = /*#__PURE__*/Object.freeze({
    __proto__: null,
    assign: assign,
    bind: bind,
    debounce: debounce,
    ensureArray: ensureArray,
    every: every,
    filter: filter,
    find: find$1,
    findIndex: findIndex,
    flatten: flatten$1,
    forEach: forEach,
    get: get,
    groupBy: groupBy,
    has: has,
    isArray: isArray,
    isDefined: isDefined,
    isFunction: isFunction,
    isNil: isNil,
    isNumber: isNumber,
    isObject: isObject,
    isString: isString,
    isUndefined: isUndefined,
    keys: keys,
    map: map$1,
    matchPattern: matchPattern,
    merge: merge,
    omit: omit,
    pick: pick,
    reduce: reduce,
    set: set,
    size: size,
    some: some,
    sortBy: sortBy,
    throttle: throttle,
    unionBy: unionBy,
    uniqueBy: uniqueBy,
    values: values,
    without: without
  });

  function getAugmentedNamespace(n) {
    var f = n.default;
  	if (typeof f == "function") {
  		var a = function () {
  			return f.apply(this, arguments);
  		};
  		a.prototype = f.prototype;
    } else a = {};
    Object.defineProperty(a, '__esModule', {value: true});
  	Object.keys(n).forEach(function (k) {
  		var d = Object.getOwnPropertyDescriptor(n, k);
  		Object.defineProperty(a, k, d.get ? d : {
  			enumerable: true,
  			get: function () {
  				return n[k];
  			}
  		});
  	});
  	return a;
  }

  var classnames$1 = {exports: {}};

  /*!
    Copyright (c) 2018 Jed Watson.
    Licensed under the MIT License (MIT), see
    http://jedwatson.github.io/classnames
  */

  (function (module) {
  	/* global define */
  	(function () {

  	  var hasOwn = {}.hasOwnProperty;

  	  function classNames() {
  	    var classes = [];

  	    for (var i = 0; i < arguments.length; i++) {
  	      var arg = arguments[i];
  	      if (!arg) continue;
  	      var argType = typeof arg;

  	      if (argType === 'string' || argType === 'number') {
  	        classes.push(arg);
  	      } else if (Array.isArray(arg)) {
  	        if (arg.length) {
  	          var inner = classNames.apply(null, arg);

  	          if (inner) {
  	            classes.push(inner);
  	          }
  	        }
  	      } else if (argType === 'object') {
  	        if (arg.toString === Object.prototype.toString) {
  	          for (var key in arg) {
  	            if (hasOwn.call(arg, key) && arg[key]) {
  	              classes.push(key);
  	            }
  	          }
  	        } else {
  	          classes.push(arg.toString());
  	        }
  	      }
  	    }

  	    return classes.join(' ');
  	  }

  	  if (module.exports) {
  	    classNames.default = classNames;
  	    module.exports = classNames;
  	  } else {
  	    window.classNames = classNames;
  	  }
  	})();
  } (classnames$1));

  var classnames = classnames$1.exports;

  function C$1(n, t) {
    for (var e in t) n[e] = t[e];

    return n;
  }

  function S(n, t) {
    for (var e in n) if ("__source" !== e && !(e in t)) return !0;

    for (var r in t) if ("__source" !== r && n[r] !== t[r]) return !0;

    return !1;
  }

  function E(n) {
    this.props = n;
  }

  function g(n, t) {
    function e(n) {
      var e = this.props.ref,
          r = e == n.ref;
      return !r && e && (e.call ? e(null) : e.current = null), t ? !t(this.props, n) || !r : S(this.props, n);
    }

    function r(t) {
      return this.shouldComponentUpdate = e, a$2(n, t);
    }

    return r.displayName = "Memo(" + (n.displayName || n.name) + ")", r.prototype.isReactComponent = !0, r.__f = !0, r;
  }

  (E.prototype = new p$2()).isPureReactComponent = !0, E.prototype.shouldComponentUpdate = function (n, t) {
    return S(this.props, n) || S(this.state, t);
  };
  var w = n$1.__b;

  n$1.__b = function (n) {
    n.type && n.type.__f && n.ref && (n.props.ref = n.ref, n.ref = null), w && w(n);
  };

  var R = "undefined" != typeof Symbol && Symbol.for && Symbol.for("react.forward_ref") || 3911;

  function x(n) {
    function t(t, e) {
      var r = C$1({}, t);
      return delete r.ref, n(r, (e = t.ref || e) && ("object" != typeof e || "current" in e) ? e : null);
    }

    return t.$$typeof = R, t.render = t, t.prototype.isReactComponent = t.__f = !0, t.displayName = "ForwardRef(" + (n.displayName || n.name) + ")", t;
  }

  var N = function (n, t) {
    return null == n ? null : w$2(w$2(n).map(t));
  },
      k = {
    map: N,
    forEach: N,
    count: function (n) {
      return n ? w$2(n).length : 0;
    },
    only: function (n) {
      var t = w$2(n);
      if (1 !== t.length) throw "Children.only";
      return t[0];
    },
    toArray: w$2
  },
      A = n$1.__e;

  n$1.__e = function (n, t, e) {
    if (n.then) for (var r, u = t; u = u.__;) if ((r = u.__c) && r.__c) return null == t.__e && (t.__e = e.__e, t.__k = e.__k), r.__c(n, t);
    A(n, t, e);
  };

  var O = n$1.unmount;

  function L() {
    this.__u = 0, this.t = null, this.__b = null;
  }

  function U(n) {
    var t = n.__.__c;
    return t && t.__e && t.__e(n);
  }

  function D(n) {
    var t, e, r;

    function u(u) {
      if (t || (t = n()).then(function (n) {
        e = n.default || n;
      }, function (n) {
        r = n;
      }), r) throw r;
      if (!e) throw t;
      return a$2(e, u);
    }

    return u.displayName = "Lazy", u.__f = !0, u;
  }

  function F() {
    this.u = null, this.o = null;
  }

  n$1.unmount = function (n) {
    var t = n.__c;
    t && t.__R && t.__R(), t && !0 === n.__h && (n.type = null), O && O(n);
  }, (L.prototype = new p$2()).__c = function (n, t) {
    var e = t.__c,
        r = this;
    null == r.t && (r.t = []), r.t.push(e);

    var u = U(r.__v),
        o = !1,
        i = function () {
      o || (o = !0, e.__R = null, u ? u(l) : l());
    };

    e.__R = i;

    var l = function () {
      if (! --r.__u) {
        if (r.state.__e) {
          var n = r.state.__e;

          r.__v.__k[0] = function n(t, e, r) {
            return t && (t.__v = null, t.__k = t.__k && t.__k.map(function (t) {
              return n(t, e, r);
            }), t.__c && t.__c.__P === e && (t.__e && r.insertBefore(t.__e, t.__d), t.__c.__e = !0, t.__c.__P = r)), t;
          }(n, n.__c.__P, n.__c.__O);
        }

        var t;

        for (r.setState({
          __e: r.__b = null
        }); t = r.t.pop();) t.forceUpdate();
      }
    },
        f = !0 === t.__h;

    r.__u++ || f || r.setState({
      __e: r.__b = r.__v.__k[0]
    }), n.then(i, i);
  }, L.prototype.componentWillUnmount = function () {
    this.t = [];
  }, L.prototype.render = function (n, t) {
    if (this.__b) {
      if (this.__v.__k) {
        var e = document.createElement("div"),
            r = this.__v.__k[0].__c;

        this.__v.__k[0] = function n(t, e, r) {
          return t && (t.__c && t.__c.__H && (t.__c.__H.__.forEach(function (n) {
            "function" == typeof n.__c && n.__c();
          }), t.__c.__H = null), null != (t = C$1({}, t)).__c && (t.__c.__P === r && (t.__c.__P = e), t.__c = null), t.__k = t.__k && t.__k.map(function (t) {
            return n(t, e, r);
          })), t;
        }(this.__b, e, r.__O = r.__P);
      }

      this.__b = null;
    }

    var u = t.__e && a$2(y$1, null, n.fallback);
    return u && (u.__h = null), [a$2(y$1, null, t.__e ? null : n.children), u];
  };

  var M = function (n, t, e) {
    if (++e[1] === e[0] && n.o.delete(t), n.props.revealOrder && ("t" !== n.props.revealOrder[0] || !n.o.size)) for (e = n.u; e;) {
      for (; e.length > 3;) e.pop()();

      if (e[1] < e[0]) break;
      n.u = e = e[2];
    }
  };

  function T(n) {
    return this.getChildContext = function () {
      return n.context;
    }, n.children;
  }

  function j(n) {
    var t = this,
        e = n.i;
    t.componentWillUnmount = function () {
      N$1(null, t.l), t.l = null, t.i = null;
    }, t.i && t.i !== e && t.componentWillUnmount(), n.__v ? (t.l || (t.i = e, t.l = {
      nodeType: 1,
      parentNode: e,
      childNodes: [],
      appendChild: function (n) {
        this.childNodes.push(n), t.i.appendChild(n);
      },
      insertBefore: function (n, e) {
        this.childNodes.push(n), t.i.appendChild(n);
      },
      removeChild: function (n) {
        this.childNodes.splice(this.childNodes.indexOf(n) >>> 1, 1), t.i.removeChild(n);
      }
    }), N$1(a$2(T, {
      context: t.context
    }, n.__v), t.l)) : t.l && t.componentWillUnmount();
  }

  function I(n, t) {
    return a$2(j, {
      __v: n,
      i: t
    });
  }

  (F.prototype = new p$2()).__e = function (n) {
    var t = this,
        e = U(t.__v),
        r = t.o.get(n);
    return r[0]++, function (u) {
      var o = function () {
        t.props.revealOrder ? (r.push(u), M(t, n, r)) : u();
      };

      e ? e(o) : o();
    };
  }, F.prototype.render = function (n) {
    this.u = null, this.o = new Map();
    var t = w$2(n.children);
    n.revealOrder && "b" === n.revealOrder[0] && t.reverse();

    for (var e = t.length; e--;) this.o.set(t[e], this.u = [1, 0, this.u]);

    return n.children;
  }, F.prototype.componentDidUpdate = F.prototype.componentDidMount = function () {
    var n = this;
    this.o.forEach(function (t, e) {
      M(n, e, t);
    });
  };

  var W = "undefined" != typeof Symbol && Symbol.for && Symbol.for("react.element") || 60103,
      P = /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,
      V = function (n) {
    return ("undefined" != typeof Symbol && "symbol" == typeof Symbol() ? /fil|che|rad/i : /fil|che|ra/i).test(n);
  };

  function z(n, t, e) {
    return null == t.__k && (t.textContent = ""), N$1(n, t), "function" == typeof e && e(), n ? n.__c : null;
  }

  function B(n, t, e) {
    return O$1(n, t), "function" == typeof e && e(), n ? n.__c : null;
  }

  p$2.prototype.isReactComponent = {}, ["componentWillMount", "componentWillReceiveProps", "componentWillUpdate"].forEach(function (n) {
    Object.defineProperty(p$2.prototype, n, {
      configurable: !0,
      get: function () {
        return this["UNSAFE_" + n];
      },
      set: function (t) {
        Object.defineProperty(this, n, {
          configurable: !0,
          writable: !0,
          value: t
        });
      }
    });
  });
  var H = n$1.event;

  function Z() {}

  function Y() {
    return this.cancelBubble;
  }

  function $() {
    return this.defaultPrevented;
  }

  n$1.event = function (n) {
    return H && (n = H(n)), n.persist = Z, n.isPropagationStopped = Y, n.isDefaultPrevented = $, n.nativeEvent = n;
  };

  var q,
      G = {
    configurable: !0,
    get: function () {
      return this.class;
    }
  },
      J = n$1.vnode;

  n$1.vnode = function (n) {
    var t = n.type,
        e = n.props,
        r = e;

    if ("string" == typeof t) {
      for (var u in r = {}, e) {
        var o = e[u];
        "value" === u && "defaultValue" in e && null == o || ("defaultValue" === u && "value" in e && null == e.value ? u = "value" : "download" === u && !0 === o ? o = "" : /ondoubleclick/i.test(u) ? u = "ondblclick" : /^onchange(textarea|input)/i.test(u + t) && !V(e.type) ? u = "oninput" : /^on(Ani|Tra|Tou|BeforeInp)/.test(u) ? u = u.toLowerCase() : P.test(u) ? u = u.replace(/[A-Z0-9]/, "-$&").toLowerCase() : null === o && (o = void 0), r[u] = o);
      }

      "select" == t && r.multiple && Array.isArray(r.value) && (r.value = w$2(e.children).forEach(function (n) {
        n.props.selected = -1 != r.value.indexOf(n.props.value);
      })), "select" == t && null != r.defaultValue && (r.value = w$2(e.children).forEach(function (n) {
        n.props.selected = r.multiple ? -1 != r.defaultValue.indexOf(n.props.value) : r.defaultValue == n.props.value;
      })), n.props = r;
    }

    t && e.class != e.className && (G.enumerable = "className" in e, null != e.className && (r.class = e.className), Object.defineProperty(r, "className", G)), n.$$typeof = W, J && J(n);
  };

  var K = n$1.__r;

  n$1.__r = function (n) {
    K && K(n), q = n.__c;
  };

  var Q = {
    ReactCurrentDispatcher: {
      current: {
        readContext: function (n) {
          return q.__n[n.__c].props.value;
        }
      }
    }
  };

  "object" == typeof performance && "function" == typeof performance.now ? performance.now.bind(performance) : function () {
    return Date.now();
  };

  function fn(n) {
    return a$2.bind(null, n);
  }

  function cn(n) {
    return !!n && n.$$typeof === W;
  }

  function an(n) {
    return cn(n) ? S$1.apply(null, arguments) : n;
  }

  function sn(n) {
    return !!n.__k && (N$1(null, n), !0);
  }

  function hn(n) {
    return n && (n.base || 1 === n.nodeType && n) || null;
  }

  var pn = function (n, t) {
    return n(t);
  };

  var React = {
    useState: l$1,
    useReducer: p$1,
    useEffect: y,
    useLayoutEffect: h,
    useRef: s,
    useImperativeHandle: _,
    useMemo: d,
    useCallback: A$1,
    useContext: F$1,
    useDebugValue: T$1,
    version: "16.8.0",
    Children: k,
    render: z,
    hydrate: B,
    unmountComponentAtNode: sn,
    createPortal: I,
    createElement: a$2,
    createContext: q$1,
    createFactory: fn,
    cloneElement: an,
    createRef: h$1,
    Fragment: y$1,
    isValidElement: cn,
    findDOMNode: hn,
    Component: p$2,
    PureComponent: E,
    memo: g,
    forwardRef: x,
    unstable_batchedUpdates: pn,
    StrictMode: y$1,
    Suspense: L,
    SuspenseList: F,
    lazy: D,
    __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: Q
  };

  function o$1(_, o, e, n, t) {
    var f = {};

    for (var l in o) "ref" != l && (f[l] = o[l]);

    var s,
        u,
        a = {
      type: _,
      props: f,
      key: e,
      ref: o && o.ref,
      __k: null,
      __: null,
      __b: 0,
      __e: null,
      __d: void 0,
      __c: null,
      __h: null,
      constructor: void 0,
      __v: ++n$1.__v,
      __source: n,
      __self: t
    };
    if ("function" == typeof _ && (s = _.defaultProps)) for (u in s) void 0 === f[u] && (f[u] = s[u]);
    return n$1.vnode && n$1.vnode(a), a;
  }

  function _mergeNamespaces$1(n, m) {
    m.forEach(function (e) {
      e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
        if (k !== 'default' && !(k in n)) {
          var d = Object.getOwnPropertyDescriptor(e, k);
          Object.defineProperty(n, k, d.get ? d : {
            enumerable: true,
            get: function () {
              return e[k];
            }
          });
        }
      });
    });
    return Object.freeze(n);
  }

  var componentEvent = {};
  var bind$1 = window.addEventListener ? 'addEventListener' : 'attachEvent',
      unbind$1 = window.removeEventListener ? 'removeEventListener' : 'detachEvent',
      prefix = bind$1 !== 'addEventListener' ? 'on' : '';
  /**
   * Bind `el` event `type` to `fn`.
   *
   * @param {Element} el
   * @param {String} type
   * @param {Function} fn
   * @param {Boolean} capture
   * @return {Function}
   * @api public
   */

  var bind_1 = componentEvent.bind = function (el, type, fn, capture) {
    el[bind$1](prefix + type, fn, capture || false);
    return fn;
  };
  /**
   * Unbind `el` event `type`'s callback `fn`.
   *
   * @param {Element} el
   * @param {String} type
   * @param {Function} fn
   * @param {Boolean} capture
   * @return {Function}
   * @api public
   */


  var unbind_1 = componentEvent.unbind = function (el, type, fn, capture) {
    el[unbind$1](prefix + type, fn, capture || false);
    return fn;
  };

  var event = /*#__PURE__*/_mergeNamespaces$1({
    __proto__: null,
    bind: bind_1,
    unbind: unbind_1,
    'default': componentEvent
  }, [componentEvent]);
  /**
   * Expose `parse`.
   */

  var domify = parse;
  /**
   * Tests for browser support.
   */

  var innerHTMLBug = false;
  var bugTestDiv;

  if (typeof document !== 'undefined') {
    bugTestDiv = document.createElement('div'); // Setup

    bugTestDiv.innerHTML = '  <link/><table></table><a href="/a">a</a><input type="checkbox"/>'; // Make sure that link elements get serialized correctly by innerHTML
    // This requires a wrapper element in IE

    innerHTMLBug = !bugTestDiv.getElementsByTagName('link').length;
    bugTestDiv = undefined;
  }
  /**
   * Wrap map from jquery.
   */


  var map = {
    legend: [1, '<fieldset>', '</fieldset>'],
    tr: [2, '<table><tbody>', '</tbody></table>'],
    col: [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
    // for script/link/style tags to work in IE6-8, you have to wrap
    // in a div with a non-whitespace character in front, ha!
    _default: innerHTMLBug ? [1, 'X<div>', '</div>'] : [0, '', '']
  };
  map.td = map.th = [3, '<table><tbody><tr>', '</tr></tbody></table>'];
  map.option = map.optgroup = [1, '<select multiple="multiple">', '</select>'];
  map.thead = map.tbody = map.colgroup = map.caption = map.tfoot = [1, '<table>', '</table>'];
  map.polyline = map.ellipse = map.polygon = map.circle = map.text = map.line = map.path = map.rect = map.g = [1, '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">', '</svg>'];
  /**
   * Parse `html` and return a DOM Node instance, which could be a TextNode,
   * HTML DOM Node of some kind (<div> for example), or a DocumentFragment
   * instance, depending on the contents of the `html` string.
   *
   * @param {String} html - HTML string to "domify"
   * @param {Document} doc - The `document` instance to create the Node for
   * @return {DOMNode} the TextNode, DOM Node, or DocumentFragment instance
   * @api private
   */

  function parse(html, doc) {
    if ('string' != typeof html) throw new TypeError('String expected'); // default to the global `document` object

    if (!doc) doc = document; // tag name

    var m = /<([\w:]+)/.exec(html);
    if (!m) return doc.createTextNode(html);
    html = html.replace(/^\s+|\s+$/g, ''); // Remove leading/trailing whitespace

    var tag = m[1]; // body support

    if (tag == 'body') {
      var el = doc.createElement('html');
      el.innerHTML = html;
      return el.removeChild(el.lastChild);
    } // wrap map


    var wrap = Object.prototype.hasOwnProperty.call(map, tag) ? map[tag] : map._default;
    var depth = wrap[0];
    var prefix = wrap[1];
    var suffix = wrap[2];
    var el = doc.createElement('div');
    el.innerHTML = prefix + html + suffix;

    while (depth--) el = el.lastChild; // one element


    if (el.firstChild == el.lastChild) {
      return el.removeChild(el.firstChild);
    } // several elements


    var fragment = doc.createDocumentFragment();

    while (el.firstChild) {
      fragment.appendChild(el.removeChild(el.firstChild));
    }

    return fragment;
  }

  var domify$1 = domify;

  function query(selector, el) {
    el = el || document;
    return el.querySelector(selector);
  }

  /**
  The data structure for documents. @nonabstract
  */
  class Text {
    /**
    @internal
    */
    constructor() {}
    /**
    Get the line description around the given position.
    */


    lineAt(pos) {
      if (pos < 0 || pos > this.length) throw new RangeError(`Invalid position ${pos} in document of length ${this.length}`);
      return this.lineInner(pos, false, 1, 0);
    }
    /**
    Get the description for the given (1-based) line number.
    */


    line(n) {
      if (n < 1 || n > this.lines) throw new RangeError(`Invalid line number ${n} in ${this.lines}-line document`);
      return this.lineInner(n, true, 1, 0);
    }
    /**
    Replace a range of the text with the given content.
    */


    replace(from, to, text) {
      let parts = [];
      this.decompose(0, from, parts, 2
      /* Open.To */
      );
      if (text.length) text.decompose(0, text.length, parts, 1
      /* Open.From */
      | 2
      /* Open.To */
      );
      this.decompose(to, this.length, parts, 1
      /* Open.From */
      );
      return TextNode.from(parts, this.length - (to - from) + text.length);
    }
    /**
    Append another document to this one.
    */


    append(other) {
      return this.replace(this.length, this.length, other);
    }
    /**
    Retrieve the text between the given points.
    */


    slice(from, to = this.length) {
      let parts = [];
      this.decompose(from, to, parts, 0);
      return TextNode.from(parts, to - from);
    }
    /**
    Test whether this text is equal to another instance.
    */


    eq(other) {
      if (other == this) return true;
      if (other.length != this.length || other.lines != this.lines) return false;
      let start = this.scanIdentical(other, 1),
          end = this.length - this.scanIdentical(other, -1);
      let a = new RawTextCursor(this),
          b = new RawTextCursor(other);

      for (let skip = start, pos = start;;) {
        a.next(skip);
        b.next(skip);
        skip = 0;
        if (a.lineBreak != b.lineBreak || a.done != b.done || a.value != b.value) return false;
        pos += a.value.length;
        if (a.done || pos >= end) return true;
      }
    }
    /**
    Iterate over the text. When `dir` is `-1`, iteration happens
    from end to start. This will return lines and the breaks between
    them as separate strings.
    */


    iter(dir = 1) {
      return new RawTextCursor(this, dir);
    }
    /**
    Iterate over a range of the text. When `from` > `to`, the
    iterator will run in reverse.
    */


    iterRange(from, to = this.length) {
      return new PartialTextCursor(this, from, to);
    }
    /**
    Return a cursor that iterates over the given range of lines,
    _without_ returning the line breaks between, and yielding empty
    strings for empty lines.
    
    When `from` and `to` are given, they should be 1-based line numbers.
    */


    iterLines(from, to) {
      let inner;

      if (from == null) {
        inner = this.iter();
      } else {
        if (to == null) to = this.lines + 1;
        let start = this.line(from).from;
        inner = this.iterRange(start, Math.max(start, to == this.lines + 1 ? this.length : to <= 1 ? 0 : this.line(to - 1).to));
      }

      return new LineCursor(inner);
    }
    /**
    @internal
    */


    toString() {
      return this.sliceString(0);
    }
    /**
    Convert the document to an array of lines (which can be
    deserialized again via [`Text.of`](https://codemirror.net/6/docs/ref/#state.Text^of)).
    */


    toJSON() {
      let lines = [];
      this.flatten(lines);
      return lines;
    }
    /**
    Create a `Text` instance for the given array of lines.
    */


    static of(text) {
      if (text.length == 0) throw new RangeError("A document must have at least one line");
      if (text.length == 1 && !text[0]) return Text.empty;
      return text.length <= 32
      /* Tree.Branch */
      ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, []));
    }

  } // Leaves store an array of line strings. There are always line breaks
  // between these strings. Leaves are limited in size and have to be
  // contained in TextNode instances for bigger documents.


  class TextLeaf extends Text {
    constructor(text, length = textLength(text)) {
      super();
      this.text = text;
      this.length = length;
    }

    get lines() {
      return this.text.length;
    }

    get children() {
      return null;
    }

    lineInner(target, isLine, line, offset) {
      for (let i = 0;; i++) {
        let string = this.text[i],
            end = offset + string.length;
        if ((isLine ? line : end) >= target) return new Line(offset, end, line, string);
        offset = end + 1;
        line++;
      }
    }

    decompose(from, to, target, open) {
      let text = from <= 0 && to >= this.length ? this : new TextLeaf(sliceText(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));

      if (open & 1
      /* Open.From */
      ) {
        let prev = target.pop();
        let joined = appendText(text.text, prev.text.slice(), 0, text.length);

        if (joined.length <= 32
        /* Tree.Branch */
        ) {
          target.push(new TextLeaf(joined, prev.length + text.length));
        } else {
          let mid = joined.length >> 1;
          target.push(new TextLeaf(joined.slice(0, mid)), new TextLeaf(joined.slice(mid)));
        }
      } else {
        target.push(text);
      }
    }

    replace(from, to, text) {
      if (!(text instanceof TextLeaf)) return super.replace(from, to, text);
      let lines = appendText(this.text, appendText(text.text, sliceText(this.text, 0, from)), to);
      let newLen = this.length + text.length - (to - from);
      if (lines.length <= 32
      /* Tree.Branch */
      ) return new TextLeaf(lines, newLen);
      return TextNode.from(TextLeaf.split(lines, []), newLen);
    }

    sliceString(from, to = this.length, lineSep = "\n") {
      let result = "";

      for (let pos = 0, i = 0; pos <= to && i < this.text.length; i++) {
        let line = this.text[i],
            end = pos + line.length;
        if (pos > from && i) result += lineSep;
        if (from < end && to > pos) result += line.slice(Math.max(0, from - pos), to - pos);
        pos = end + 1;
      }

      return result;
    }

    flatten(target) {
      for (let line of this.text) target.push(line);
    }

    scanIdentical() {
      return 0;
    }

    static split(text, target) {
      let part = [],
          len = -1;

      for (let line of text) {
        part.push(line);
        len += line.length + 1;

        if (part.length == 32
        /* Tree.Branch */
        ) {
          target.push(new TextLeaf(part, len));
          part = [];
          len = -1;
        }
      }

      if (len > -1) target.push(new TextLeaf(part, len));
      return target;
    }

  } // Nodes provide the tree structure of the `Text` type. They store a
  // number of other nodes or leaves, taking care to balance themselves
  // on changes. There are implied line breaks _between_ the children of
  // a node (but not before the first or after the last child).


  class TextNode extends Text {
    constructor(children, length) {
      super();
      this.children = children;
      this.length = length;
      this.lines = 0;

      for (let child of children) this.lines += child.lines;
    }

    lineInner(target, isLine, line, offset) {
      for (let i = 0;; i++) {
        let child = this.children[i],
            end = offset + child.length,
            endLine = line + child.lines - 1;
        if ((isLine ? endLine : end) >= target) return child.lineInner(target, isLine, line, offset);
        offset = end + 1;
        line = endLine + 1;
      }
    }

    decompose(from, to, target, open) {
      for (let i = 0, pos = 0; pos <= to && i < this.children.length; i++) {
        let child = this.children[i],
            end = pos + child.length;

        if (from <= end && to >= pos) {
          let childOpen = open & ((pos <= from ? 1
          /* Open.From */
          : 0) | (end >= to ? 2
          /* Open.To */
          : 0));
          if (pos >= from && end <= to && !childOpen) target.push(child);else child.decompose(from - pos, to - pos, target, childOpen);
        }

        pos = end + 1;
      }
    }

    replace(from, to, text) {
      if (text.lines < this.lines) for (let i = 0, pos = 0; i < this.children.length; i++) {
        let child = this.children[i],
            end = pos + child.length; // Fast path: if the change only affects one child and the
        // child's size remains in the acceptable range, only update
        // that child

        if (from >= pos && to <= end) {
          let updated = child.replace(from - pos, to - pos, text);
          let totalLines = this.lines - child.lines + updated.lines;

          if (updated.lines < totalLines >> 5
          /* Tree.BranchShift */
          - 1 && updated.lines > totalLines >> 5
          /* Tree.BranchShift */
          + 1) {
            let copy = this.children.slice();
            copy[i] = updated;
            return new TextNode(copy, this.length - (to - from) + text.length);
          }

          return super.replace(pos, end, updated);
        }

        pos = end + 1;
      }
      return super.replace(from, to, text);
    }

    sliceString(from, to = this.length, lineSep = "\n") {
      let result = "";

      for (let i = 0, pos = 0; i < this.children.length && pos <= to; i++) {
        let child = this.children[i],
            end = pos + child.length;
        if (pos > from && i) result += lineSep;
        if (from < end && to > pos) result += child.sliceString(from - pos, to - pos, lineSep);
        pos = end + 1;
      }

      return result;
    }

    flatten(target) {
      for (let child of this.children) child.flatten(target);
    }

    scanIdentical(other, dir) {
      if (!(other instanceof TextNode)) return 0;
      let length = 0;
      let [iA, iB, eA, eB] = dir > 0 ? [0, 0, this.children.length, other.children.length] : [this.children.length - 1, other.children.length - 1, -1, -1];

      for (;; iA += dir, iB += dir) {
        if (iA == eA || iB == eB) return length;
        let chA = this.children[iA],
            chB = other.children[iB];
        if (chA != chB) return length + chA.scanIdentical(chB, dir);
        length += chA.length + 1;
      }
    }

    static from(children, length = children.reduce((l, ch) => l + ch.length + 1, -1)) {
      let lines = 0;

      for (let ch of children) lines += ch.lines;

      if (lines < 32
      /* Tree.Branch */
      ) {
        let flat = [];

        for (let ch of children) ch.flatten(flat);

        return new TextLeaf(flat, length);
      }

      let chunk = Math.max(32
      /* Tree.Branch */
      , lines >> 5
      /* Tree.BranchShift */
      ),
          maxChunk = chunk << 1,
          minChunk = chunk >> 1;
      let chunked = [],
          currentLines = 0,
          currentLen = -1,
          currentChunk = [];

      function add(child) {
        let last;

        if (child.lines > maxChunk && child instanceof TextNode) {
          for (let node of child.children) add(node);
        } else if (child.lines > minChunk && (currentLines > minChunk || !currentLines)) {
          flush();
          chunked.push(child);
        } else if (child instanceof TextLeaf && currentLines && (last = currentChunk[currentChunk.length - 1]) instanceof TextLeaf && child.lines + last.lines <= 32
        /* Tree.Branch */
        ) {
          currentLines += child.lines;
          currentLen += child.length + 1;
          currentChunk[currentChunk.length - 1] = new TextLeaf(last.text.concat(child.text), last.length + 1 + child.length);
        } else {
          if (currentLines + child.lines > chunk) flush();
          currentLines += child.lines;
          currentLen += child.length + 1;
          currentChunk.push(child);
        }
      }

      function flush() {
        if (currentLines == 0) return;
        chunked.push(currentChunk.length == 1 ? currentChunk[0] : TextNode.from(currentChunk, currentLen));
        currentLen = -1;
        currentLines = currentChunk.length = 0;
      }

      for (let child of children) add(child);

      flush();
      return chunked.length == 1 ? chunked[0] : new TextNode(chunked, length);
    }

  }

  Text.empty = /*@__PURE__*/new TextLeaf([""], 0);

  function textLength(text) {
    let length = -1;

    for (let line of text) length += line.length + 1;

    return length;
  }

  function appendText(text, target, from = 0, to = 1e9) {
    for (let pos = 0, i = 0, first = true; i < text.length && pos <= to; i++) {
      let line = text[i],
          end = pos + line.length;

      if (end >= from) {
        if (end > to) line = line.slice(0, to - pos);
        if (pos < from) line = line.slice(from - pos);

        if (first) {
          target[target.length - 1] += line;
          first = false;
        } else target.push(line);
      }

      pos = end + 1;
    }

    return target;
  }

  function sliceText(text, from, to) {
    return appendText(text, [""], from, to);
  }

  class RawTextCursor {
    constructor(text, dir = 1) {
      this.dir = dir;
      this.done = false;
      this.lineBreak = false;
      this.value = "";
      this.nodes = [text];
      this.offsets = [dir > 0 ? 1 : (text instanceof TextLeaf ? text.text.length : text.children.length) << 1];
    }

    nextInner(skip, dir) {
      this.done = this.lineBreak = false;

      for (;;) {
        let last = this.nodes.length - 1;
        let top = this.nodes[last],
            offsetValue = this.offsets[last],
            offset = offsetValue >> 1;
        let size = top instanceof TextLeaf ? top.text.length : top.children.length;

        if (offset == (dir > 0 ? size : 0)) {
          if (last == 0) {
            this.done = true;
            this.value = "";
            return this;
          }

          if (dir > 0) this.offsets[last - 1]++;
          this.nodes.pop();
          this.offsets.pop();
        } else if ((offsetValue & 1) == (dir > 0 ? 0 : 1)) {
          this.offsets[last] += dir;

          if (skip == 0) {
            this.lineBreak = true;
            this.value = "\n";
            return this;
          }

          skip--;
        } else if (top instanceof TextLeaf) {
          // Move to the next string
          let next = top.text[offset + (dir < 0 ? -1 : 0)];
          this.offsets[last] += dir;

          if (next.length > Math.max(0, skip)) {
            this.value = skip == 0 ? next : dir > 0 ? next.slice(skip) : next.slice(0, next.length - skip);
            return this;
          }

          skip -= next.length;
        } else {
          let next = top.children[offset + (dir < 0 ? -1 : 0)];

          if (skip > next.length) {
            skip -= next.length;
            this.offsets[last] += dir;
          } else {
            if (dir < 0) this.offsets[last]--;
            this.nodes.push(next);
            this.offsets.push(dir > 0 ? 1 : (next instanceof TextLeaf ? next.text.length : next.children.length) << 1);
          }
        }
      }
    }

    next(skip = 0) {
      if (skip < 0) {
        this.nextInner(-skip, -this.dir);
        skip = this.value.length;
      }

      return this.nextInner(skip, this.dir);
    }

  }

  class PartialTextCursor {
    constructor(text, start, end) {
      this.value = "";
      this.done = false;
      this.cursor = new RawTextCursor(text, start > end ? -1 : 1);
      this.pos = start > end ? text.length : 0;
      this.from = Math.min(start, end);
      this.to = Math.max(start, end);
    }

    nextInner(skip, dir) {
      if (dir < 0 ? this.pos <= this.from : this.pos >= this.to) {
        this.value = "";
        this.done = true;
        return this;
      }

      skip += Math.max(0, dir < 0 ? this.pos - this.to : this.from - this.pos);
      let limit = dir < 0 ? this.pos - this.from : this.to - this.pos;
      if (skip > limit) skip = limit;
      limit -= skip;
      let {
        value
      } = this.cursor.next(skip);
      this.pos += (value.length + skip) * dir;
      this.value = value.length <= limit ? value : dir < 0 ? value.slice(value.length - limit) : value.slice(0, limit);
      this.done = !this.value;
      return this;
    }

    next(skip = 0) {
      if (skip < 0) skip = Math.max(skip, this.from - this.pos);else if (skip > 0) skip = Math.min(skip, this.to - this.pos);
      return this.nextInner(skip, this.cursor.dir);
    }

    get lineBreak() {
      return this.cursor.lineBreak && this.value != "";
    }

  }

  class LineCursor {
    constructor(inner) {
      this.inner = inner;
      this.afterBreak = true;
      this.value = "";
      this.done = false;
    }

    next(skip = 0) {
      let {
        done,
        lineBreak,
        value
      } = this.inner.next(skip);

      if (done) {
        this.done = true;
        this.value = "";
      } else if (lineBreak) {
        if (this.afterBreak) {
          this.value = "";
        } else {
          this.afterBreak = true;
          this.next();
        }
      } else {
        this.value = value;
        this.afterBreak = false;
      }

      return this;
    }

    get lineBreak() {
      return false;
    }

  }

  if (typeof Symbol != "undefined") {
    Text.prototype[Symbol.iterator] = function () {
      return this.iter();
    };

    RawTextCursor.prototype[Symbol.iterator] = PartialTextCursor.prototype[Symbol.iterator] = LineCursor.prototype[Symbol.iterator] = function () {
      return this;
    };
  }
  /**
  This type describes a line in the document. It is created
  on-demand when lines are [queried](https://codemirror.net/6/docs/ref/#state.Text.lineAt).
  */


  class Line {
    /**
    @internal
    */
    constructor(
    /**
    The position of the start of the line.
    */
    from,
    /**
    The position at the end of the line (_before_ the line break,
    or at the end of document for the last line).
    */
    to,
    /**
    This line's line number (1-based).
    */
    number,
    /**
    The line's content.
    */
    text) {
      this.from = from;
      this.to = to;
      this.number = number;
      this.text = text;
    }
    /**
    The length of the line (not including any line break after it).
    */


    get length() {
      return this.to - this.from;
    }

  } // Compressed representation of the Grapheme_Cluster_Break=Extend
  // information from
  // http://www.unicode.org/Public/13.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.
  // Each pair of elements represents a range, as an offet from the
  // previous range and a length. Numbers are in base-36, with the empty
  // string being a shorthand for 1.


  let extend = /*@__PURE__*/"lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(s => s ? parseInt(s, 36) : 1); // Convert offsets into absolute values

  for (let i = 1; i < extend.length; i++) extend[i] += extend[i - 1];

  function isExtendingChar(code) {
    for (let i = 1; i < extend.length; i += 2) if (extend[i] > code) return extend[i - 1] <= code;

    return false;
  }

  function isRegionalIndicator(code) {
    return code >= 0x1F1E6 && code <= 0x1F1FF;
  }

  const ZWJ = 0x200d;
  /**
  Returns a next grapheme cluster break _after_ (not equal to)
  `pos`, if `forward` is true, or before otherwise. Returns `pos`
  itself if no further cluster break is available in the string.
  Moves across surrogate pairs, extending characters (when
  `includeExtending` is true), characters joined with zero-width
  joiners, and flag emoji.
  */

  function findClusterBreak(str, pos, forward = true, includeExtending = true) {
    return (forward ? nextClusterBreak : prevClusterBreak)(str, pos, includeExtending);
  }

  function nextClusterBreak(str, pos, includeExtending) {
    if (pos == str.length) return pos; // If pos is in the middle of a surrogate pair, move to its start

    if (pos && surrogateLow(str.charCodeAt(pos)) && surrogateHigh(str.charCodeAt(pos - 1))) pos--;
    let prev = codePointAt(str, pos);
    pos += codePointSize(prev);

    while (pos < str.length) {
      let next = codePointAt(str, pos);

      if (prev == ZWJ || next == ZWJ || includeExtending && isExtendingChar(next)) {
        pos += codePointSize(next);
        prev = next;
      } else if (isRegionalIndicator(next)) {
        let countBefore = 0,
            i = pos - 2;

        while (i >= 0 && isRegionalIndicator(codePointAt(str, i))) {
          countBefore++;
          i -= 2;
        }

        if (countBefore % 2 == 0) break;else pos += 2;
      } else {
        break;
      }
    }

    return pos;
  }

  function prevClusterBreak(str, pos, includeExtending) {
    while (pos > 0) {
      let found = nextClusterBreak(str, pos - 2, includeExtending);
      if (found < pos) return found;
      pos--;
    }

    return 0;
  }

  function surrogateLow(ch) {
    return ch >= 0xDC00 && ch < 0xE000;
  }

  function surrogateHigh(ch) {
    return ch >= 0xD800 && ch < 0xDC00;
  }
  /**
  Find the code point at the given position in a string (like the
  [`codePointAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
  string method).
  */


  function codePointAt(str, pos) {
    let code0 = str.charCodeAt(pos);
    if (!surrogateHigh(code0) || pos + 1 == str.length) return code0;
    let code1 = str.charCodeAt(pos + 1);
    if (!surrogateLow(code1)) return code0;
    return (code0 - 0xd800 << 10) + (code1 - 0xdc00) + 0x10000;
  }
  /**
  Given a Unicode codepoint, return the JavaScript string that
  respresents it (like
  [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)).
  */


  function fromCodePoint(code) {
    if (code <= 0xffff) return String.fromCharCode(code);
    code -= 0x10000;
    return String.fromCharCode((code >> 10) + 0xd800, (code & 1023) + 0xdc00);
  }
  /**
  The amount of positions a character takes up a JavaScript string.
  */


  function codePointSize(code) {
    return code < 0x10000 ? 1 : 2;
  }

  const DefaultSplit = /\r\n?|\n/;
  /**
  Distinguishes different ways in which positions can be mapped.
  */

  var MapMode = /*@__PURE__*/function (MapMode) {
    /**
    Map a position to a valid new position, even when its context
    was deleted.
    */
    MapMode[MapMode["Simple"] = 0] = "Simple";
    /**
    Return null if deletion happens across the position.
    */

    MapMode[MapMode["TrackDel"] = 1] = "TrackDel";
    /**
    Return null if the character _before_ the position is deleted.
    */

    MapMode[MapMode["TrackBefore"] = 2] = "TrackBefore";
    /**
    Return null if the character _after_ the position is deleted.
    */

    MapMode[MapMode["TrackAfter"] = 3] = "TrackAfter";
    return MapMode;
  }(MapMode || (MapMode = {}));
  /**
  A change description is a variant of [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet)
  that doesn't store the inserted text. As such, it can't be
  applied, but is cheaper to store and manipulate.
  */


  class ChangeDesc {
    // Sections are encoded as pairs of integers. The first is the
    // length in the current document, and the second is -1 for
    // unaffected sections, and the length of the replacement content
    // otherwise. So an insertion would be (0, n>0), a deletion (n>0,
    // 0), and a replacement two positive numbers.

    /**
    @internal
    */
    constructor(
    /**
    @internal
    */
    sections) {
      this.sections = sections;
    }
    /**
    The length of the document before the change.
    */


    get length() {
      let result = 0;

      for (let i = 0; i < this.sections.length; i += 2) result += this.sections[i];

      return result;
    }
    /**
    The length of the document after the change.
    */


    get newLength() {
      let result = 0;

      for (let i = 0; i < this.sections.length; i += 2) {
        let ins = this.sections[i + 1];
        result += ins < 0 ? this.sections[i] : ins;
      }

      return result;
    }
    /**
    False when there are actual changes in this set.
    */


    get empty() {
      return this.sections.length == 0 || this.sections.length == 2 && this.sections[1] < 0;
    }
    /**
    Iterate over the unchanged parts left by these changes. `posA`
    provides the position of the range in the old document, `posB`
    the new position in the changed document.
    */


    iterGaps(f) {
      for (let i = 0, posA = 0, posB = 0; i < this.sections.length;) {
        let len = this.sections[i++],
            ins = this.sections[i++];

        if (ins < 0) {
          f(posA, posB, len);
          posB += len;
        } else {
          posB += ins;
        }

        posA += len;
      }
    }
    /**
    Iterate over the ranges changed by these changes. (See
    [`ChangeSet.iterChanges`](https://codemirror.net/6/docs/ref/#state.ChangeSet.iterChanges) for a
    variant that also provides you with the inserted text.)
    `fromA`/`toA` provides the extent of the change in the starting
    document, `fromB`/`toB` the extent of the replacement in the
    changed document.
    
    When `individual` is true, adjacent changes (which are kept
    separate for [position mapping](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) are
    reported separately.
    */


    iterChangedRanges(f, individual = false) {
      iterChanges(this, f, individual);
    }
    /**
    Get a description of the inverted form of these changes.
    */


    get invertedDesc() {
      let sections = [];

      for (let i = 0; i < this.sections.length;) {
        let len = this.sections[i++],
            ins = this.sections[i++];
        if (ins < 0) sections.push(len, ins);else sections.push(ins, len);
      }

      return new ChangeDesc(sections);
    }
    /**
    Compute the combined effect of applying another set of changes
    after this one. The length of the document after this set should
    match the length before `other`.
    */


    composeDesc(other) {
      return this.empty ? other : other.empty ? this : composeSets(this, other);
    }
    /**
    Map this description, which should start with the same document
    as `other`, over another set of changes, so that it can be
    applied after it. When `before` is true, map as if the changes
    in `other` happened before the ones in `this`.
    */


    mapDesc(other, before = false) {
      return other.empty ? this : mapSet(this, other, before);
    }

    mapPos(pos, assoc = -1, mode = MapMode.Simple) {
      let posA = 0,
          posB = 0;

      for (let i = 0; i < this.sections.length;) {
        let len = this.sections[i++],
            ins = this.sections[i++],
            endA = posA + len;

        if (ins < 0) {
          if (endA > pos) return posB + (pos - posA);
          posB += len;
        } else {
          if (mode != MapMode.Simple && endA >= pos && (mode == MapMode.TrackDel && posA < pos && endA > pos || mode == MapMode.TrackBefore && posA < pos || mode == MapMode.TrackAfter && endA > pos)) return null;
          if (endA > pos || endA == pos && assoc < 0 && !len) return pos == posA || assoc < 0 ? posB : posB + ins;
          posB += ins;
        }

        posA = endA;
      }

      if (pos > posA) throw new RangeError(`Position ${pos} is out of range for changeset of length ${posA}`);
      return posB;
    }
    /**
    Check whether these changes touch a given range. When one of the
    changes entirely covers the range, the string `"cover"` is
    returned.
    */


    touchesRange(from, to = from) {
      for (let i = 0, pos = 0; i < this.sections.length && pos <= to;) {
        let len = this.sections[i++],
            ins = this.sections[i++],
            end = pos + len;
        if (ins >= 0 && pos <= to && end >= from) return pos < from && end > to ? "cover" : true;
        pos = end;
      }

      return false;
    }
    /**
    @internal
    */


    toString() {
      let result = "";

      for (let i = 0; i < this.sections.length;) {
        let len = this.sections[i++],
            ins = this.sections[i++];
        result += (result ? " " : "") + len + (ins >= 0 ? ":" + ins : "");
      }

      return result;
    }
    /**
    Serialize this change desc to a JSON-representable value.
    */


    toJSON() {
      return this.sections;
    }
    /**
    Create a change desc from its JSON representation (as produced
    by [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeDesc.toJSON).
    */


    static fromJSON(json) {
      if (!Array.isArray(json) || json.length % 2 || json.some(a => typeof a != "number")) throw new RangeError("Invalid JSON representation of ChangeDesc");
      return new ChangeDesc(json);
    }
    /**
    @internal
    */


    static create(sections) {
      return new ChangeDesc(sections);
    }

  }
  /**
  A change set represents a group of modifications to a document. It
  stores the document length, and can only be applied to documents
  with exactly that length.
  */


  class ChangeSet extends ChangeDesc {
    constructor(sections,
    /**
    @internal
    */
    inserted) {
      super(sections);
      this.inserted = inserted;
    }
    /**
    Apply the changes to a document, returning the modified
    document.
    */


    apply(doc) {
      if (this.length != doc.length) throw new RangeError("Applying change set to a document with the wrong length");
      iterChanges(this, (fromA, toA, fromB, _toB, text) => doc = doc.replace(fromB, fromB + (toA - fromA), text), false);
      return doc;
    }

    mapDesc(other, before = false) {
      return mapSet(this, other, before, true);
    }
    /**
    Given the document as it existed _before_ the changes, return a
    change set that represents the inverse of this set, which could
    be used to go from the document created by the changes back to
    the document as it existed before the changes.
    */


    invert(doc) {
      let sections = this.sections.slice(),
          inserted = [];

      for (let i = 0, pos = 0; i < sections.length; i += 2) {
        let len = sections[i],
            ins = sections[i + 1];

        if (ins >= 0) {
          sections[i] = ins;
          sections[i + 1] = len;
          let index = i >> 1;

          while (inserted.length < index) inserted.push(Text.empty);

          inserted.push(len ? doc.slice(pos, pos + len) : Text.empty);
        }

        pos += len;
      }

      return new ChangeSet(sections, inserted);
    }
    /**
    Combine two subsequent change sets into a single set. `other`
    must start in the document produced by `this`. If `this` goes
    `docA` → `docB` and `other` represents `docB` → `docC`, the
    returned value will represent the change `docA` → `docC`.
    */


    compose(other) {
      return this.empty ? other : other.empty ? this : composeSets(this, other, true);
    }
    /**
    Given another change set starting in the same document, maps this
    change set over the other, producing a new change set that can be
    applied to the document produced by applying `other`. When
    `before` is `true`, order changes as if `this` comes before
    `other`, otherwise (the default) treat `other` as coming first.
    
    Given two changes `A` and `B`, `A.compose(B.map(A))` and
    `B.compose(A.map(B, true))` will produce the same document. This
    provides a basic form of [operational
    transformation](https://en.wikipedia.org/wiki/Operational_transformation),
    and can be used for collaborative editing.
    */


    map(other, before = false) {
      return other.empty ? this : mapSet(this, other, before, true);
    }
    /**
    Iterate over the changed ranges in the document, calling `f` for
    each, with the range in the original document (`fromA`-`toA`)
    and the range that replaces it in the new document
    (`fromB`-`toB`).
    
    When `individual` is true, adjacent changes are reported
    separately.
    */


    iterChanges(f, individual = false) {
      iterChanges(this, f, individual);
    }
    /**
    Get a [change description](https://codemirror.net/6/docs/ref/#state.ChangeDesc) for this change
    set.
    */


    get desc() {
      return ChangeDesc.create(this.sections);
    }
    /**
    @internal
    */


    filter(ranges) {
      let resultSections = [],
          resultInserted = [],
          filteredSections = [];
      let iter = new SectionIter(this);

      done: for (let i = 0, pos = 0;;) {
        let next = i == ranges.length ? 1e9 : ranges[i++];

        while (pos < next || pos == next && iter.len == 0) {
          if (iter.done) break done;
          let len = Math.min(iter.len, next - pos);
          addSection(filteredSections, len, -1);
          let ins = iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0;
          addSection(resultSections, len, ins);
          if (ins > 0) addInsert(resultInserted, resultSections, iter.text);
          iter.forward(len);
          pos += len;
        }

        let end = ranges[i++];

        while (pos < end) {
          if (iter.done) break done;
          let len = Math.min(iter.len, end - pos);
          addSection(resultSections, len, -1);
          addSection(filteredSections, len, iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0);
          iter.forward(len);
          pos += len;
        }
      }

      return {
        changes: new ChangeSet(resultSections, resultInserted),
        filtered: ChangeDesc.create(filteredSections)
      };
    }
    /**
    Serialize this change set to a JSON-representable value.
    */


    toJSON() {
      let parts = [];

      for (let i = 0; i < this.sections.length; i += 2) {
        let len = this.sections[i],
            ins = this.sections[i + 1];
        if (ins < 0) parts.push(len);else if (ins == 0) parts.push([len]);else parts.push([len].concat(this.inserted[i >> 1].toJSON()));
      }

      return parts;
    }
    /**
    Create a change set for the given changes, for a document of the
    given length, using `lineSep` as line separator.
    */


    static of(changes, length, lineSep) {
      let sections = [],
          inserted = [],
          pos = 0;
      let total = null;

      function flush(force = false) {
        if (!force && !sections.length) return;
        if (pos < length) addSection(sections, length - pos, -1);
        let set = new ChangeSet(sections, inserted);
        total = total ? total.compose(set.map(total)) : set;
        sections = [];
        inserted = [];
        pos = 0;
      }

      function process(spec) {
        if (Array.isArray(spec)) {
          for (let sub of spec) process(sub);
        } else if (spec instanceof ChangeSet) {
          if (spec.length != length) throw new RangeError(`Mismatched change set length (got ${spec.length}, expected ${length})`);
          flush();
          total = total ? total.compose(spec.map(total)) : spec;
        } else {
          let {
            from,
            to = from,
            insert
          } = spec;
          if (from > to || from < 0 || to > length) throw new RangeError(`Invalid change range ${from} to ${to} (in doc of length ${length})`);
          let insText = !insert ? Text.empty : typeof insert == "string" ? Text.of(insert.split(lineSep || DefaultSplit)) : insert;
          let insLen = insText.length;
          if (from == to && insLen == 0) return;
          if (from < pos) flush();
          if (from > pos) addSection(sections, from - pos, -1);
          addSection(sections, to - from, insLen);
          addInsert(inserted, sections, insText);
          pos = to;
        }
      }

      process(changes);
      flush(!total);
      return total;
    }
    /**
    Create an empty changeset of the given length.
    */


    static empty(length) {
      return new ChangeSet(length ? [length, -1] : [], []);
    }
    /**
    Create a changeset from its JSON representation (as produced by
    [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeSet.toJSON).
    */


    static fromJSON(json) {
      if (!Array.isArray(json)) throw new RangeError("Invalid JSON representation of ChangeSet");
      let sections = [],
          inserted = [];

      for (let i = 0; i < json.length; i++) {
        let part = json[i];

        if (typeof part == "number") {
          sections.push(part, -1);
        } else if (!Array.isArray(part) || typeof part[0] != "number" || part.some((e, i) => i && typeof e != "string")) {
          throw new RangeError("Invalid JSON representation of ChangeSet");
        } else if (part.length == 1) {
          sections.push(part[0], 0);
        } else {
          while (inserted.length < i) inserted.push(Text.empty);

          inserted[i] = Text.of(part.slice(1));
          sections.push(part[0], inserted[i].length);
        }
      }

      return new ChangeSet(sections, inserted);
    }
    /**
    @internal
    */


    static createSet(sections, inserted) {
      return new ChangeSet(sections, inserted);
    }

  }

  function addSection(sections, len, ins, forceJoin = false) {
    if (len == 0 && ins <= 0) return;
    let last = sections.length - 2;
    if (last >= 0 && ins <= 0 && ins == sections[last + 1]) sections[last] += len;else if (len == 0 && sections[last] == 0) sections[last + 1] += ins;else if (forceJoin) {
      sections[last] += len;
      sections[last + 1] += ins;
    } else sections.push(len, ins);
  }

  function addInsert(values, sections, value) {
    if (value.length == 0) return;
    let index = sections.length - 2 >> 1;

    if (index < values.length) {
      values[values.length - 1] = values[values.length - 1].append(value);
    } else {
      while (values.length < index) values.push(Text.empty);

      values.push(value);
    }
  }

  function iterChanges(desc, f, individual) {
    let inserted = desc.inserted;

    for (let posA = 0, posB = 0, i = 0; i < desc.sections.length;) {
      let len = desc.sections[i++],
          ins = desc.sections[i++];

      if (ins < 0) {
        posA += len;
        posB += len;
      } else {
        let endA = posA,
            endB = posB,
            text = Text.empty;

        for (;;) {
          endA += len;
          endB += ins;
          if (ins && inserted) text = text.append(inserted[i - 2 >> 1]);
          if (individual || i == desc.sections.length || desc.sections[i + 1] < 0) break;
          len = desc.sections[i++];
          ins = desc.sections[i++];
        }

        f(posA, endA, posB, endB, text);
        posA = endA;
        posB = endB;
      }
    }
  }

  function mapSet(setA, setB, before, mkSet = false) {
    // Produce a copy of setA that applies to the document after setB
    // has been applied (assuming both start at the same document).
    let sections = [],
        insert = mkSet ? [] : null;
    let a = new SectionIter(setA),
        b = new SectionIter(setB); // Iterate over both sets in parallel. inserted tracks, for changes
    // in A that have to be processed piece-by-piece, whether their
    // content has been inserted already, and refers to the section
    // index.

    for (let inserted = -1;;) {
      if (a.ins == -1 && b.ins == -1) {
        // Move across ranges skipped by both sets.
        let len = Math.min(a.len, b.len);
        addSection(sections, len, -1);
        a.forward(len);
        b.forward(len);
      } else if (b.ins >= 0 && (a.ins < 0 || inserted == a.i || a.off == 0 && (b.len < a.len || b.len == a.len && !before))) {
        // If there's a change in B that comes before the next change in
        // A (ordered by start pos, then len, then before flag), skip
        // that (and process any changes in A it covers).
        let len = b.len;
        addSection(sections, b.ins, -1);

        while (len) {
          let piece = Math.min(a.len, len);

          if (a.ins >= 0 && inserted < a.i && a.len <= piece) {
            addSection(sections, 0, a.ins);
            if (insert) addInsert(insert, sections, a.text);
            inserted = a.i;
          }

          a.forward(piece);
          len -= piece;
        }

        b.next();
      } else if (a.ins >= 0) {
        // Process the part of a change in A up to the start of the next
        // non-deletion change in B (if overlapping).
        let len = 0,
            left = a.len;

        while (left) {
          if (b.ins == -1) {
            let piece = Math.min(left, b.len);
            len += piece;
            left -= piece;
            b.forward(piece);
          } else if (b.ins == 0 && b.len < left) {
            left -= b.len;
            b.next();
          } else {
            break;
          }
        }

        addSection(sections, len, inserted < a.i ? a.ins : 0);
        if (insert && inserted < a.i) addInsert(insert, sections, a.text);
        inserted = a.i;
        a.forward(a.len - left);
      } else if (a.done && b.done) {
        return insert ? ChangeSet.createSet(sections, insert) : ChangeDesc.create(sections);
      } else {
        throw new Error("Mismatched change set lengths");
      }
    }
  }

  function composeSets(setA, setB, mkSet = false) {
    let sections = [];
    let insert = mkSet ? [] : null;
    let a = new SectionIter(setA),
        b = new SectionIter(setB);

    for (let open = false;;) {
      if (a.done && b.done) {
        return insert ? ChangeSet.createSet(sections, insert) : ChangeDesc.create(sections);
      } else if (a.ins == 0) {
        // Deletion in A
        addSection(sections, a.len, 0, open);
        a.next();
      } else if (b.len == 0 && !b.done) {
        // Insertion in B
        addSection(sections, 0, b.ins, open);
        if (insert) addInsert(insert, sections, b.text);
        b.next();
      } else if (a.done || b.done) {
        throw new Error("Mismatched change set lengths");
      } else {
        let len = Math.min(a.len2, b.len),
            sectionLen = sections.length;

        if (a.ins == -1) {
          let insB = b.ins == -1 ? -1 : b.off ? 0 : b.ins;
          addSection(sections, len, insB, open);
          if (insert && insB) addInsert(insert, sections, b.text);
        } else if (b.ins == -1) {
          addSection(sections, a.off ? 0 : a.len, len, open);
          if (insert) addInsert(insert, sections, a.textBit(len));
        } else {
          addSection(sections, a.off ? 0 : a.len, b.off ? 0 : b.ins, open);
          if (insert && !b.off) addInsert(insert, sections, b.text);
        }

        open = (a.ins > len || b.ins >= 0 && b.len > len) && (open || sections.length > sectionLen);
        a.forward2(len);
        b.forward(len);
      }
    }
  }

  class SectionIter {
    constructor(set) {
      this.set = set;
      this.i = 0;
      this.next();
    }

    next() {
      let {
        sections
      } = this.set;

      if (this.i < sections.length) {
        this.len = sections[this.i++];
        this.ins = sections[this.i++];
      } else {
        this.len = 0;
        this.ins = -2;
      }

      this.off = 0;
    }

    get done() {
      return this.ins == -2;
    }

    get len2() {
      return this.ins < 0 ? this.len : this.ins;
    }

    get text() {
      let {
        inserted
      } = this.set,
          index = this.i - 2 >> 1;
      return index >= inserted.length ? Text.empty : inserted[index];
    }

    textBit(len) {
      let {
        inserted
      } = this.set,
          index = this.i - 2 >> 1;
      return index >= inserted.length && !len ? Text.empty : inserted[index].slice(this.off, len == null ? undefined : this.off + len);
    }

    forward(len) {
      if (len == this.len) this.next();else {
        this.len -= len;
        this.off += len;
      }
    }

    forward2(len) {
      if (this.ins == -1) this.forward(len);else if (len == this.ins) this.next();else {
        this.ins -= len;
        this.off += len;
      }
    }

  }
  /**
  A single selection range. When
  [`allowMultipleSelections`](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)
  is enabled, a [selection](https://codemirror.net/6/docs/ref/#state.EditorSelection) may hold
  multiple ranges. By default, selections hold exactly one range.
  */


  class SelectionRange {
    constructor(
    /**
    The lower boundary of the range.
    */
    from,
    /**
    The upper boundary of the range.
    */
    to, flags) {
      this.from = from;
      this.to = to;
      this.flags = flags;
    }
    /**
    The anchor of the range—the side that doesn't move when you
    extend it.
    */


    get anchor() {
      return this.flags & 16
      /* RangeFlag.Inverted */
      ? this.to : this.from;
    }
    /**
    The head of the range, which is moved when the range is
    [extended](https://codemirror.net/6/docs/ref/#state.SelectionRange.extend).
    */


    get head() {
      return this.flags & 16
      /* RangeFlag.Inverted */
      ? this.from : this.to;
    }
    /**
    True when `anchor` and `head` are at the same position.
    */


    get empty() {
      return this.from == this.to;
    }
    /**
    If this is a cursor that is explicitly associated with the
    character on one of its sides, this returns the side. -1 means
    the character before its position, 1 the character after, and 0
    means no association.
    */


    get assoc() {
      return this.flags & 4
      /* RangeFlag.AssocBefore */
      ? -1 : this.flags & 8
      /* RangeFlag.AssocAfter */
      ? 1 : 0;
    }
    /**
    The bidirectional text level associated with this cursor, if
    any.
    */


    get bidiLevel() {
      let level = this.flags & 3
      /* RangeFlag.BidiLevelMask */
      ;
      return level == 3 ? null : level;
    }
    /**
    The goal column (stored vertical offset) associated with a
    cursor. This is used to preserve the vertical position when
    [moving](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) across
    lines of different length.
    */


    get goalColumn() {
      let value = this.flags >> 5
      /* RangeFlag.GoalColumnOffset */
      ;
      return value == 33554431
      /* RangeFlag.NoGoalColumn */
      ? undefined : value;
    }
    /**
    Map this range through a change, producing a valid range in the
    updated document.
    */


    map(change, assoc = -1) {
      let from, to;

      if (this.empty) {
        from = to = change.mapPos(this.from, assoc);
      } else {
        from = change.mapPos(this.from, 1);
        to = change.mapPos(this.to, -1);
      }

      return from == this.from && to == this.to ? this : new SelectionRange(from, to, this.flags);
    }
    /**
    Extend this range to cover at least `from` to `to`.
    */


    extend(from, to = from) {
      if (from <= this.anchor && to >= this.anchor) return EditorSelection.range(from, to);
      let head = Math.abs(from - this.anchor) > Math.abs(to - this.anchor) ? from : to;
      return EditorSelection.range(this.anchor, head);
    }
    /**
    Compare this range to another range.
    */


    eq(other) {
      return this.anchor == other.anchor && this.head == other.head;
    }
    /**
    Return a JSON-serializable object representing the range.
    */


    toJSON() {
      return {
        anchor: this.anchor,
        head: this.head
      };
    }
    /**
    Convert a JSON representation of a range to a `SelectionRange`
    instance.
    */


    static fromJSON(json) {
      if (!json || typeof json.anchor != "number" || typeof json.head != "number") throw new RangeError("Invalid JSON representation for SelectionRange");
      return EditorSelection.range(json.anchor, json.head);
    }
    /**
    @internal
    */


    static create(from, to, flags) {
      return new SelectionRange(from, to, flags);
    }

  }
  /**
  An editor selection holds one or more selection ranges.
  */


  class EditorSelection {
    constructor(
    /**
    The ranges in the selection, sorted by position. Ranges cannot
    overlap (but they may touch, if they aren't empty).
    */
    ranges,
    /**
    The index of the _main_ range in the selection (which is
    usually the range that was added last).
    */
    mainIndex) {
      this.ranges = ranges;
      this.mainIndex = mainIndex;
    }
    /**
    Map a selection through a change. Used to adjust the selection
    position for changes.
    */


    map(change, assoc = -1) {
      if (change.empty) return this;
      return EditorSelection.create(this.ranges.map(r => r.map(change, assoc)), this.mainIndex);
    }
    /**
    Compare this selection to another selection.
    */


    eq(other) {
      if (this.ranges.length != other.ranges.length || this.mainIndex != other.mainIndex) return false;

      for (let i = 0; i < this.ranges.length; i++) if (!this.ranges[i].eq(other.ranges[i])) return false;

      return true;
    }
    /**
    Get the primary selection range. Usually, you should make sure
    your code applies to _all_ ranges, by using methods like
    [`changeByRange`](https://codemirror.net/6/docs/ref/#state.EditorState.changeByRange).
    */


    get main() {
      return this.ranges[this.mainIndex];
    }
    /**
    Make sure the selection only has one range. Returns a selection
    holding only the main range from this selection.
    */


    asSingle() {
      return this.ranges.length == 1 ? this : new EditorSelection([this.main], 0);
    }
    /**
    Extend this selection with an extra range.
    */


    addRange(range, main = true) {
      return EditorSelection.create([range].concat(this.ranges), main ? 0 : this.mainIndex + 1);
    }
    /**
    Replace a given range with another range, and then normalize the
    selection to merge and sort ranges if necessary.
    */


    replaceRange(range, which = this.mainIndex) {
      let ranges = this.ranges.slice();
      ranges[which] = range;
      return EditorSelection.create(ranges, this.mainIndex);
    }
    /**
    Convert this selection to an object that can be serialized to
    JSON.
    */


    toJSON() {
      return {
        ranges: this.ranges.map(r => r.toJSON()),
        main: this.mainIndex
      };
    }
    /**
    Create a selection from a JSON representation.
    */


    static fromJSON(json) {
      if (!json || !Array.isArray(json.ranges) || typeof json.main != "number" || json.main >= json.ranges.length) throw new RangeError("Invalid JSON representation for EditorSelection");
      return new EditorSelection(json.ranges.map(r => SelectionRange.fromJSON(r)), json.main);
    }
    /**
    Create a selection holding a single range.
    */


    static single(anchor, head = anchor) {
      return new EditorSelection([EditorSelection.range(anchor, head)], 0);
    }
    /**
    Sort and merge the given set of ranges, creating a valid
    selection.
    */


    static create(ranges, mainIndex = 0) {
      if (ranges.length == 0) throw new RangeError("A selection needs at least one range");

      for (let pos = 0, i = 0; i < ranges.length; i++) {
        let range = ranges[i];
        if (range.empty ? range.from <= pos : range.from < pos) return EditorSelection.normalized(ranges.slice(), mainIndex);
        pos = range.to;
      }

      return new EditorSelection(ranges, mainIndex);
    }
    /**
    Create a cursor selection range at the given position. You can
    safely ignore the optional arguments in most situations.
    */


    static cursor(pos, assoc = 0, bidiLevel, goalColumn) {
      return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4
      /* RangeFlag.AssocBefore */
      : 8
      /* RangeFlag.AssocAfter */
      ) | (bidiLevel == null ? 3 : Math.min(2, bidiLevel)) | (goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431
      /* RangeFlag.NoGoalColumn */
      ) << 5
      /* RangeFlag.GoalColumnOffset */
      );
    }
    /**
    Create a selection range.
    */


    static range(anchor, head, goalColumn) {
      let goal = (goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431
      /* RangeFlag.NoGoalColumn */
      ) << 5
      /* RangeFlag.GoalColumnOffset */
      ;
      return head < anchor ? SelectionRange.create(head, anchor, 16
      /* RangeFlag.Inverted */
      | goal | 8
      /* RangeFlag.AssocAfter */
      ) : SelectionRange.create(anchor, head, goal | (head > anchor ? 4
      /* RangeFlag.AssocBefore */
      : 0));
    }
    /**
    @internal
    */


    static normalized(ranges, mainIndex = 0) {
      let main = ranges[mainIndex];
      ranges.sort((a, b) => a.from - b.from);
      mainIndex = ranges.indexOf(main);

      for (let i = 1; i < ranges.length; i++) {
        let range = ranges[i],
            prev = ranges[i - 1];

        if (range.empty ? range.from <= prev.to : range.from < prev.to) {
          let from = prev.from,
              to = Math.max(range.to, prev.to);
          if (i <= mainIndex) mainIndex--;
          ranges.splice(--i, 2, range.anchor > range.head ? EditorSelection.range(to, from) : EditorSelection.range(from, to));
        }
      }

      return new EditorSelection(ranges, mainIndex);
    }

  }

  function checkSelection(selection, docLength) {
    for (let range of selection.ranges) if (range.to > docLength) throw new RangeError("Selection points outside of document");
  }

  let nextID = 0;
  /**
  A facet is a labeled value that is associated with an editor
  state. It takes inputs from any number of extensions, and combines
  those into a single output value.

  Examples of uses of facets are the [tab
  size](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize), [editor
  attributes](https://codemirror.net/6/docs/ref/#view.EditorView^editorAttributes), and [update
  listeners](https://codemirror.net/6/docs/ref/#view.EditorView^updateListener).
  */

  class Facet {
    constructor(
    /**
    @internal
    */
    combine,
    /**
    @internal
    */
    compareInput,
    /**
    @internal
    */
    compare, isStatic, enables) {
      this.combine = combine;
      this.compareInput = compareInput;
      this.compare = compare;
      this.isStatic = isStatic;
      /**
      @internal
      */

      this.id = nextID++;
      this.default = combine([]);
      this.extensions = typeof enables == "function" ? enables(this) : enables;
    }
    /**
    Define a new facet.
    */


    static define(config = {}) {
      return new Facet(config.combine || (a => a), config.compareInput || ((a, b) => a === b), config.compare || (!config.combine ? sameArray$1 : (a, b) => a === b), !!config.static, config.enables);
    }
    /**
    Returns an extension that adds the given value to this facet.
    */


    of(value) {
      return new FacetProvider([], this, 0
      /* Provider.Static */
      , value);
    }
    /**
    Create an extension that computes a value for the facet from a
    state. You must take care to declare the parts of the state that
    this value depends on, since your function is only called again
    for a new state when one of those parts changed.
    
    In cases where your value depends only on a single field, you'll
    want to use the [`from`](https://codemirror.net/6/docs/ref/#state.Facet.from) method instead.
    */


    compute(deps, get) {
      if (this.isStatic) throw new Error("Can't compute a static facet");
      return new FacetProvider(deps, this, 1
      /* Provider.Single */
      , get);
    }
    /**
    Create an extension that computes zero or more values for this
    facet from a state.
    */


    computeN(deps, get) {
      if (this.isStatic) throw new Error("Can't compute a static facet");
      return new FacetProvider(deps, this, 2
      /* Provider.Multi */
      , get);
    }

    from(field, get) {
      if (!get) get = x => x;
      return this.compute([field], state => get(state.field(field)));
    }

  }

  function sameArray$1(a, b) {
    return a == b || a.length == b.length && a.every((e, i) => e === b[i]);
  }

  class FacetProvider {
    constructor(dependencies, facet, type, value) {
      this.dependencies = dependencies;
      this.facet = facet;
      this.type = type;
      this.value = value;
      this.id = nextID++;
    }

    dynamicSlot(addresses) {
      var _a;

      let getter = this.value;
      let compare = this.facet.compareInput;
      let id = this.id,
          idx = addresses[id] >> 1,
          multi = this.type == 2
      /* Provider.Multi */
      ;
      let depDoc = false,
          depSel = false,
          depAddrs = [];

      for (let dep of this.dependencies) {
        if (dep == "doc") depDoc = true;else if (dep == "selection") depSel = true;else if ((((_a = addresses[dep.id]) !== null && _a !== void 0 ? _a : 1) & 1) == 0) depAddrs.push(addresses[dep.id]);
      }

      return {
        create(state) {
          state.values[idx] = getter(state);
          return 1
          /* SlotStatus.Changed */
          ;
        },

        update(state, tr) {
          if (depDoc && tr.docChanged || depSel && (tr.docChanged || tr.selection) || ensureAll(state, depAddrs)) {
            let newVal = getter(state);

            if (multi ? !compareArray(newVal, state.values[idx], compare) : !compare(newVal, state.values[idx])) {
              state.values[idx] = newVal;
              return 1
              /* SlotStatus.Changed */
              ;
            }
          }

          return 0;
        },

        reconfigure: (state, oldState) => {
          let newVal = getter(state);
          let oldAddr = oldState.config.address[id];

          if (oldAddr != null) {
            let oldVal = getAddr(oldState, oldAddr);

            if (this.dependencies.every(dep => {
              return dep instanceof Facet ? oldState.facet(dep) === state.facet(dep) : dep instanceof StateField ? oldState.field(dep, false) == state.field(dep, false) : true;
            }) || (multi ? compareArray(newVal, oldVal, compare) : compare(newVal, oldVal))) {
              state.values[idx] = oldVal;
              return 0;
            }
          }

          state.values[idx] = newVal;
          return 1
          /* SlotStatus.Changed */
          ;
        }
      };
    }

  }

  function compareArray(a, b, compare) {
    if (a.length != b.length) return false;

    for (let i = 0; i < a.length; i++) if (!compare(a[i], b[i])) return false;

    return true;
  }

  function ensureAll(state, addrs) {
    let changed = false;

    for (let addr of addrs) if (ensureAddr(state, addr) & 1
    /* SlotStatus.Changed */
    ) changed = true;

    return changed;
  }

  function dynamicFacetSlot(addresses, facet, providers) {
    let providerAddrs = providers.map(p => addresses[p.id]);
    let providerTypes = providers.map(p => p.type);
    let dynamic = providerAddrs.filter(p => !(p & 1));
    let idx = addresses[facet.id] >> 1;

    function get(state) {
      let values = [];

      for (let i = 0; i < providerAddrs.length; i++) {
        let value = getAddr(state, providerAddrs[i]);
        if (providerTypes[i] == 2
        /* Provider.Multi */
        ) for (let val of value) values.push(val);else values.push(value);
      }

      return facet.combine(values);
    }

    return {
      create(state) {
        for (let addr of providerAddrs) ensureAddr(state, addr);

        state.values[idx] = get(state);
        return 1
        /* SlotStatus.Changed */
        ;
      },

      update(state, tr) {
        if (!ensureAll(state, dynamic)) return 0;
        let value = get(state);
        if (facet.compare(value, state.values[idx])) return 0;
        state.values[idx] = value;
        return 1
        /* SlotStatus.Changed */
        ;
      },

      reconfigure(state, oldState) {
        let depChanged = ensureAll(state, providerAddrs);
        let oldProviders = oldState.config.facets[facet.id],
            oldValue = oldState.facet(facet);

        if (oldProviders && !depChanged && sameArray$1(providers, oldProviders)) {
          state.values[idx] = oldValue;
          return 0;
        }

        let value = get(state);

        if (facet.compare(value, oldValue)) {
          state.values[idx] = oldValue;
          return 0;
        }

        state.values[idx] = value;
        return 1
        /* SlotStatus.Changed */
        ;
      }

    };
  }

  const initField = /*@__PURE__*/Facet.define({
    static: true
  });
  /**
  Fields can store additional information in an editor state, and
  keep it in sync with the rest of the state.
  */

  class StateField {
    constructor(
    /**
    @internal
    */
    id, createF, updateF, compareF,
    /**
    @internal
    */
    spec) {
      this.id = id;
      this.createF = createF;
      this.updateF = updateF;
      this.compareF = compareF;
      this.spec = spec;
      /**
      @internal
      */

      this.provides = undefined;
    }
    /**
    Define a state field.
    */


    static define(config) {
      let field = new StateField(nextID++, config.create, config.update, config.compare || ((a, b) => a === b), config);
      if (config.provide) field.provides = config.provide(field);
      return field;
    }

    create(state) {
      let init = state.facet(initField).find(i => i.field == this);
      return ((init === null || init === void 0 ? void 0 : init.create) || this.createF)(state);
    }
    /**
    @internal
    */


    slot(addresses) {
      let idx = addresses[this.id] >> 1;
      return {
        create: state => {
          state.values[idx] = this.create(state);
          return 1
          /* SlotStatus.Changed */
          ;
        },
        update: (state, tr) => {
          let oldVal = state.values[idx];
          let value = this.updateF(oldVal, tr);
          if (this.compareF(oldVal, value)) return 0;
          state.values[idx] = value;
          return 1
          /* SlotStatus.Changed */
          ;
        },
        reconfigure: (state, oldState) => {
          if (oldState.config.address[this.id] != null) {
            state.values[idx] = oldState.field(this);
            return 0;
          }

          state.values[idx] = this.create(state);
          return 1
          /* SlotStatus.Changed */
          ;
        }
      };
    }
    /**
    Returns an extension that enables this field and overrides the
    way it is initialized. Can be useful when you need to provide a
    non-default starting value for the field.
    */


    init(create) {
      return [this, initField.of({
        field: this,
        create
      })];
    }
    /**
    State field instances can be used as
    [`Extension`](https://codemirror.net/6/docs/ref/#state.Extension) values to enable the field in a
    given state.
    */


    get extension() {
      return this;
    }

  }

  const Prec_ = {
    lowest: 4,
    low: 3,
    default: 2,
    high: 1,
    highest: 0
  };

  function prec(value) {
    return ext => new PrecExtension(ext, value);
  }
  /**
  By default extensions are registered in the order they are found
  in the flattened form of nested array that was provided.
  Individual extension values can be assigned a precedence to
  override this. Extensions that do not have a precedence set get
  the precedence of the nearest parent with a precedence, or
  [`default`](https://codemirror.net/6/docs/ref/#state.Prec.default) if there is no such parent. The
  final ordering of extensions is determined by first sorting by
  precedence and then by order within each precedence.
  */


  const Prec = {
    /**
    The highest precedence level, for extensions that should end up
    near the start of the precedence ordering.
    */
    highest: /*@__PURE__*/prec(Prec_.highest),

    /**
    A higher-than-default precedence, for extensions that should
    come before those with default precedence.
    */
    high: /*@__PURE__*/prec(Prec_.high),

    /**
    The default precedence, which is also used for extensions
    without an explicit precedence.
    */
    default: /*@__PURE__*/prec(Prec_.default),

    /**
    A lower-than-default precedence.
    */
    low: /*@__PURE__*/prec(Prec_.low),

    /**
    The lowest precedence level. Meant for things that should end up
    near the end of the extension order.
    */
    lowest: /*@__PURE__*/prec(Prec_.lowest)
  };

  class PrecExtension {
    constructor(inner, prec) {
      this.inner = inner;
      this.prec = prec;
    }

  }
  /**
  Extension compartments can be used to make a configuration
  dynamic. By [wrapping](https://codemirror.net/6/docs/ref/#state.Compartment.of) part of your
  configuration in a compartment, you can later
  [replace](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure) that part through a
  transaction.
  */


  class Compartment {
    /**
    Create an instance of this compartment to add to your [state
    configuration](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions).
    */
    of(ext) {
      return new CompartmentInstance(this, ext);
    }
    /**
    Create an [effect](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) that
    reconfigures this compartment.
    */


    reconfigure(content) {
      return Compartment.reconfigure.of({
        compartment: this,
        extension: content
      });
    }
    /**
    Get the current content of the compartment in the state, or
    `undefined` if it isn't present.
    */


    get(state) {
      return state.config.compartments.get(this);
    }

  }

  class CompartmentInstance {
    constructor(compartment, inner) {
      this.compartment = compartment;
      this.inner = inner;
    }

  }

  class Configuration {
    constructor(base, compartments, dynamicSlots, address, staticValues, facets) {
      this.base = base;
      this.compartments = compartments;
      this.dynamicSlots = dynamicSlots;
      this.address = address;
      this.staticValues = staticValues;
      this.facets = facets;
      this.statusTemplate = [];

      while (this.statusTemplate.length < dynamicSlots.length) this.statusTemplate.push(0
      /* SlotStatus.Unresolved */
      );
    }

    staticFacet(facet) {
      let addr = this.address[facet.id];
      return addr == null ? facet.default : this.staticValues[addr >> 1];
    }

    static resolve(base, compartments, oldState) {
      let fields = [];
      let facets = Object.create(null);
      let newCompartments = new Map();

      for (let ext of flatten(base, compartments, newCompartments)) {
        if (ext instanceof StateField) fields.push(ext);else (facets[ext.facet.id] || (facets[ext.facet.id] = [])).push(ext);
      }

      let address = Object.create(null);
      let staticValues = [];
      let dynamicSlots = [];

      for (let field of fields) {
        address[field.id] = dynamicSlots.length << 1;
        dynamicSlots.push(a => field.slot(a));
      }

      let oldFacets = oldState === null || oldState === void 0 ? void 0 : oldState.config.facets;

      for (let id in facets) {
        let providers = facets[id],
            facet = providers[0].facet;
        let oldProviders = oldFacets && oldFacets[id] || [];

        if (providers.every(p => p.type == 0
        /* Provider.Static */
        )) {
          address[facet.id] = staticValues.length << 1 | 1;

          if (sameArray$1(oldProviders, providers)) {
            staticValues.push(oldState.facet(facet));
          } else {
            let value = facet.combine(providers.map(p => p.value));
            staticValues.push(oldState && facet.compare(value, oldState.facet(facet)) ? oldState.facet(facet) : value);
          }
        } else {
          for (let p of providers) {
            if (p.type == 0
            /* Provider.Static */
            ) {
              address[p.id] = staticValues.length << 1 | 1;
              staticValues.push(p.value);
            } else {
              address[p.id] = dynamicSlots.length << 1;
              dynamicSlots.push(a => p.dynamicSlot(a));
            }
          }

          address[facet.id] = dynamicSlots.length << 1;
          dynamicSlots.push(a => dynamicFacetSlot(a, facet, providers));
        }
      }

      let dynamic = dynamicSlots.map(f => f(address));
      return new Configuration(base, newCompartments, dynamic, address, staticValues, facets);
    }

  }

  function flatten(extension, compartments, newCompartments) {
    let result = [[], [], [], [], []];
    let seen = new Map();

    function inner(ext, prec) {
      let known = seen.get(ext);

      if (known != null) {
        if (known <= prec) return;
        let found = result[known].indexOf(ext);
        if (found > -1) result[known].splice(found, 1);
        if (ext instanceof CompartmentInstance) newCompartments.delete(ext.compartment);
      }

      seen.set(ext, prec);

      if (Array.isArray(ext)) {
        for (let e of ext) inner(e, prec);
      } else if (ext instanceof CompartmentInstance) {
        if (newCompartments.has(ext.compartment)) throw new RangeError(`Duplicate use of compartment in extensions`);
        let content = compartments.get(ext.compartment) || ext.inner;
        newCompartments.set(ext.compartment, content);
        inner(content, prec);
      } else if (ext instanceof PrecExtension) {
        inner(ext.inner, ext.prec);
      } else if (ext instanceof StateField) {
        result[prec].push(ext);
        if (ext.provides) inner(ext.provides, prec);
      } else if (ext instanceof FacetProvider) {
        result[prec].push(ext);
        if (ext.facet.extensions) inner(ext.facet.extensions, Prec_.default);
      } else {
        let content = ext.extension;
        if (!content) throw new Error(`Unrecognized extension value in extension set (${ext}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);
        inner(content, prec);
      }
    }

    inner(extension, Prec_.default);
    return result.reduce((a, b) => a.concat(b));
  }

  function ensureAddr(state, addr) {
    if (addr & 1) return 2
    /* SlotStatus.Computed */
    ;
    let idx = addr >> 1;
    let status = state.status[idx];
    if (status == 4
    /* SlotStatus.Computing */
    ) throw new Error("Cyclic dependency between fields and/or facets");
    if (status & 2
    /* SlotStatus.Computed */
    ) return status;
    state.status[idx] = 4
    /* SlotStatus.Computing */
    ;
    let changed = state.computeSlot(state, state.config.dynamicSlots[idx]);
    return state.status[idx] = 2
    /* SlotStatus.Computed */
    | changed;
  }

  function getAddr(state, addr) {
    return addr & 1 ? state.config.staticValues[addr >> 1] : state.values[addr >> 1];
  }

  const languageData = /*@__PURE__*/Facet.define();
  const allowMultipleSelections = /*@__PURE__*/Facet.define({
    combine: values => values.some(v => v),
    static: true
  });
  const lineSeparator = /*@__PURE__*/Facet.define({
    combine: values => values.length ? values[0] : undefined,
    static: true
  });
  const changeFilter = /*@__PURE__*/Facet.define();
  const transactionFilter = /*@__PURE__*/Facet.define();
  const transactionExtender = /*@__PURE__*/Facet.define();
  const readOnly = /*@__PURE__*/Facet.define({
    combine: values => values.length ? values[0] : false
  });
  /**
  Annotations are tagged values that are used to add metadata to
  transactions in an extensible way. They should be used to model
  things that effect the entire transaction (such as its [time
  stamp](https://codemirror.net/6/docs/ref/#state.Transaction^time) or information about its
  [origin](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent)). For effects that happen
  _alongside_ the other changes made by the transaction, [state
  effects](https://codemirror.net/6/docs/ref/#state.StateEffect) are more appropriate.
  */

  class Annotation {
    /**
    @internal
    */
    constructor(
    /**
    The annotation type.
    */
    type,
    /**
    The value of this annotation.
    */
    value) {
      this.type = type;
      this.value = value;
    }
    /**
    Define a new type of annotation.
    */


    static define() {
      return new AnnotationType();
    }

  }
  /**
  Marker that identifies a type of [annotation](https://codemirror.net/6/docs/ref/#state.Annotation).
  */


  class AnnotationType {
    /**
    Create an instance of this annotation.
    */
    of(value) {
      return new Annotation(this, value);
    }

  }
  /**
  Representation of a type of state effect. Defined with
  [`StateEffect.define`](https://codemirror.net/6/docs/ref/#state.StateEffect^define).
  */


  class StateEffectType {
    /**
    @internal
    */
    constructor( // The `any` types in these function types are there to work
    // around TypeScript issue #37631, where the type guard on
    // `StateEffect.is` mysteriously stops working when these properly
    // have type `Value`.

    /**
    @internal
    */
    map) {
      this.map = map;
    }
    /**
    Create a [state effect](https://codemirror.net/6/docs/ref/#state.StateEffect) instance of this
    type.
    */


    of(value) {
      return new StateEffect(this, value);
    }

  }
  /**
  State effects can be used to represent additional effects
  associated with a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction.effects). They
  are often useful to model changes to custom [state
  fields](https://codemirror.net/6/docs/ref/#state.StateField), when those changes aren't implicit in
  document or selection changes.
  */


  class StateEffect {
    /**
    @internal
    */
    constructor(
    /**
    @internal
    */
    type,
    /**
    The value of this effect.
    */
    value) {
      this.type = type;
      this.value = value;
    }
    /**
    Map this effect through a position mapping. Will return
    `undefined` when that ends up deleting the effect.
    */


    map(mapping) {
      let mapped = this.type.map(this.value, mapping);
      return mapped === undefined ? undefined : mapped == this.value ? this : new StateEffect(this.type, mapped);
    }
    /**
    Tells you whether this effect object is of a given
    [type](https://codemirror.net/6/docs/ref/#state.StateEffectType).
    */


    is(type) {
      return this.type == type;
    }
    /**
    Define a new effect type. The type parameter indicates the type
    of values that his effect holds.
    */


    static define(spec = {}) {
      return new StateEffectType(spec.map || (v => v));
    }
    /**
    Map an array of effects through a change set.
    */


    static mapEffects(effects, mapping) {
      if (!effects.length) return effects;
      let result = [];

      for (let effect of effects) {
        let mapped = effect.map(mapping);
        if (mapped) result.push(mapped);
      }

      return result;
    }

  }
  /**
  This effect can be used to reconfigure the root extensions of
  the editor. Doing this will discard any extensions
  [appended](https://codemirror.net/6/docs/ref/#state.StateEffect^appendConfig), but does not reset
  the content of [reconfigured](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure)
  compartments.
  */


  StateEffect.reconfigure = /*@__PURE__*/StateEffect.define();
  /**
  Append extensions to the top-level configuration of the editor.
  */

  StateEffect.appendConfig = /*@__PURE__*/StateEffect.define();
  /**
  Changes to the editor state are grouped into transactions.
  Typically, a user action creates a single transaction, which may
  contain any number of document changes, may change the selection,
  or have other effects. Create a transaction by calling
  [`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update), or immediately
  dispatch one by calling
  [`EditorView.dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch).
  */

  class Transaction {
    constructor(
    /**
    The state from which the transaction starts.
    */
    startState,
    /**
    The document changes made by this transaction.
    */
    changes,
    /**
    The selection set by this transaction, or undefined if it
    doesn't explicitly set a selection.
    */
    selection,
    /**
    The effects added to the transaction.
    */
    effects,
    /**
    @internal
    */
    annotations,
    /**
    Whether the selection should be scrolled into view after this
    transaction is dispatched.
    */
    scrollIntoView) {
      this.startState = startState;
      this.changes = changes;
      this.selection = selection;
      this.effects = effects;
      this.annotations = annotations;
      this.scrollIntoView = scrollIntoView;
      /**
      @internal
      */

      this._doc = null;
      /**
      @internal
      */

      this._state = null;
      if (selection) checkSelection(selection, changes.newLength);
      if (!annotations.some(a => a.type == Transaction.time)) this.annotations = annotations.concat(Transaction.time.of(Date.now()));
    }
    /**
    @internal
    */


    static create(startState, changes, selection, effects, annotations, scrollIntoView) {
      return new Transaction(startState, changes, selection, effects, annotations, scrollIntoView);
    }
    /**
    The new document produced by the transaction. Contrary to
    [`.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state)`.doc`, accessing this won't
    force the entire new state to be computed right away, so it is
    recommended that [transaction
    filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) use this getter
    when they need to look at the new document.
    */


    get newDoc() {
      return this._doc || (this._doc = this.changes.apply(this.startState.doc));
    }
    /**
    The new selection produced by the transaction. If
    [`this.selection`](https://codemirror.net/6/docs/ref/#state.Transaction.selection) is undefined,
    this will [map](https://codemirror.net/6/docs/ref/#state.EditorSelection.map) the start state's
    current selection through the changes made by the transaction.
    */


    get newSelection() {
      return this.selection || this.startState.selection.map(this.changes);
    }
    /**
    The new state created by the transaction. Computed on demand
    (but retained for subsequent access), so it is recommended not to
    access it in [transaction
    filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) when possible.
    */


    get state() {
      if (!this._state) this.startState.applyTransaction(this);
      return this._state;
    }
    /**
    Get the value of the given annotation type, if any.
    */


    annotation(type) {
      for (let ann of this.annotations) if (ann.type == type) return ann.value;

      return undefined;
    }
    /**
    Indicates whether the transaction changed the document.
    */


    get docChanged() {
      return !this.changes.empty;
    }
    /**
    Indicates whether this transaction reconfigures the state
    (through a [configuration compartment](https://codemirror.net/6/docs/ref/#state.Compartment) or
    with a top-level configuration
    [effect](https://codemirror.net/6/docs/ref/#state.StateEffect^reconfigure).
    */


    get reconfigured() {
      return this.startState.config != this.state.config;
    }
    /**
    Returns true if the transaction has a [user
    event](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent) annotation that is equal to
    or more specific than `event`. For example, if the transaction
    has `"select.pointer"` as user event, `"select"` and
    `"select.pointer"` will match it.
    */


    isUserEvent(event) {
      let e = this.annotation(Transaction.userEvent);
      return !!(e && (e == event || e.length > event.length && e.slice(0, event.length) == event && e[event.length] == "."));
    }

  }
  /**
  Annotation used to store transaction timestamps. Automatically
  added to every transaction, holding `Date.now()`.
  */


  Transaction.time = /*@__PURE__*/Annotation.define();
  /**
  Annotation used to associate a transaction with a user interface
  event. Holds a string identifying the event, using a
  dot-separated format to support attaching more specific
  information. The events used by the core libraries are:

   - `"input"` when content is entered
     - `"input.type"` for typed input
       - `"input.type.compose"` for composition
     - `"input.paste"` for pasted input
     - `"input.drop"` when adding content with drag-and-drop
     - `"input.complete"` when autocompleting
   - `"delete"` when the user deletes content
     - `"delete.selection"` when deleting the selection
     - `"delete.forward"` when deleting forward from the selection
     - `"delete.backward"` when deleting backward from the selection
     - `"delete.cut"` when cutting to the clipboard
   - `"move"` when content is moved
     - `"move.drop"` when content is moved within the editor through drag-and-drop
   - `"select"` when explicitly changing the selection
     - `"select.pointer"` when selecting with a mouse or other pointing device
   - `"undo"` and `"redo"` for history actions

  Use [`isUserEvent`](https://codemirror.net/6/docs/ref/#state.Transaction.isUserEvent) to check
  whether the annotation matches a given event.
  */

  Transaction.userEvent = /*@__PURE__*/Annotation.define();
  /**
  Annotation indicating whether a transaction should be added to
  the undo history or not.
  */

  Transaction.addToHistory = /*@__PURE__*/Annotation.define();
  /**
  Annotation indicating (when present and true) that a transaction
  represents a change made by some other actor, not the user. This
  is used, for example, to tag other people's changes in
  collaborative editing.
  */

  Transaction.remote = /*@__PURE__*/Annotation.define();

  function joinRanges(a, b) {
    let result = [];

    for (let iA = 0, iB = 0;;) {
      let from, to;

      if (iA < a.length && (iB == b.length || b[iB] >= a[iA])) {
        from = a[iA++];
        to = a[iA++];
      } else if (iB < b.length) {
        from = b[iB++];
        to = b[iB++];
      } else return result;

      if (!result.length || result[result.length - 1] < from) result.push(from, to);else if (result[result.length - 1] < to) result[result.length - 1] = to;
    }
  }

  function mergeTransaction(a, b, sequential) {
    var _a;

    let mapForA, mapForB, changes;

    if (sequential) {
      mapForA = b.changes;
      mapForB = ChangeSet.empty(b.changes.length);
      changes = a.changes.compose(b.changes);
    } else {
      mapForA = b.changes.map(a.changes);
      mapForB = a.changes.mapDesc(b.changes, true);
      changes = a.changes.compose(mapForA);
    }

    return {
      changes,
      selection: b.selection ? b.selection.map(mapForB) : (_a = a.selection) === null || _a === void 0 ? void 0 : _a.map(mapForA),
      effects: StateEffect.mapEffects(a.effects, mapForA).concat(StateEffect.mapEffects(b.effects, mapForB)),
      annotations: a.annotations.length ? a.annotations.concat(b.annotations) : b.annotations,
      scrollIntoView: a.scrollIntoView || b.scrollIntoView
    };
  }

  function resolveTransactionInner(state, spec, docSize) {
    let sel = spec.selection,
        annotations = asArray(spec.annotations);
    if (spec.userEvent) annotations = annotations.concat(Transaction.userEvent.of(spec.userEvent));
    return {
      changes: spec.changes instanceof ChangeSet ? spec.changes : ChangeSet.of(spec.changes || [], docSize, state.facet(lineSeparator)),
      selection: sel && (sel instanceof EditorSelection ? sel : EditorSelection.single(sel.anchor, sel.head)),
      effects: asArray(spec.effects),
      annotations,
      scrollIntoView: !!spec.scrollIntoView
    };
  }

  function resolveTransaction(state, specs, filter) {
    let s = resolveTransactionInner(state, specs.length ? specs[0] : {}, state.doc.length);
    if (specs.length && specs[0].filter === false) filter = false;

    for (let i = 1; i < specs.length; i++) {
      if (specs[i].filter === false) filter = false;
      let seq = !!specs[i].sequential;
      s = mergeTransaction(s, resolveTransactionInner(state, specs[i], seq ? s.changes.newLength : state.doc.length), seq);
    }

    let tr = Transaction.create(state, s.changes, s.selection, s.effects, s.annotations, s.scrollIntoView);
    return extendTransaction(filter ? filterTransaction(tr) : tr);
  } // Finish a transaction by applying filters if necessary.


  function filterTransaction(tr) {
    let state = tr.startState; // Change filters

    let result = true;

    for (let filter of state.facet(changeFilter)) {
      let value = filter(tr);

      if (value === false) {
        result = false;
        break;
      }

      if (Array.isArray(value)) result = result === true ? value : joinRanges(result, value);
    }

    if (result !== true) {
      let changes, back;

      if (result === false) {
        back = tr.changes.invertedDesc;
        changes = ChangeSet.empty(state.doc.length);
      } else {
        let filtered = tr.changes.filter(result);
        changes = filtered.changes;
        back = filtered.filtered.mapDesc(filtered.changes).invertedDesc;
      }

      tr = Transaction.create(state, changes, tr.selection && tr.selection.map(back), StateEffect.mapEffects(tr.effects, back), tr.annotations, tr.scrollIntoView);
    } // Transaction filters


    let filters = state.facet(transactionFilter);

    for (let i = filters.length - 1; i >= 0; i--) {
      let filtered = filters[i](tr);
      if (filtered instanceof Transaction) tr = filtered;else if (Array.isArray(filtered) && filtered.length == 1 && filtered[0] instanceof Transaction) tr = filtered[0];else tr = resolveTransaction(state, asArray(filtered), false);
    }

    return tr;
  }

  function extendTransaction(tr) {
    let state = tr.startState,
        extenders = state.facet(transactionExtender),
        spec = tr;

    for (let i = extenders.length - 1; i >= 0; i--) {
      let extension = extenders[i](tr);
      if (extension && Object.keys(extension).length) spec = mergeTransaction(spec, resolveTransactionInner(state, extension, tr.changes.newLength), true);
    }

    return spec == tr ? tr : Transaction.create(state, tr.changes, tr.selection, spec.effects, spec.annotations, spec.scrollIntoView);
  }

  const none$1 = [];

  function asArray(value) {
    return value == null ? none$1 : Array.isArray(value) ? value : [value];
  }
  /**
  The categories produced by a [character
  categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer). These are used
  do things like selecting by word.
  */


  var CharCategory = /*@__PURE__*/function (CharCategory) {
    /**
    Word characters.
    */
    CharCategory[CharCategory["Word"] = 0] = "Word";
    /**
    Whitespace.
    */

    CharCategory[CharCategory["Space"] = 1] = "Space";
    /**
    Anything else.
    */

    CharCategory[CharCategory["Other"] = 2] = "Other";
    return CharCategory;
  }(CharCategory || (CharCategory = {}));

  const nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
  let wordChar;

  try {
    wordChar = /*@__PURE__*/new RegExp("[\\p{Alphabetic}\\p{Number}_]", "u");
  } catch (_) {}

  function hasWordChar(str) {
    if (wordChar) return wordChar.test(str);

    for (let i = 0; i < str.length; i++) {
      let ch = str[i];
      if (/\w/.test(ch) || ch > "\x80" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch))) return true;
    }

    return false;
  }

  function makeCategorizer(wordChars) {
    return char => {
      if (!/\S/.test(char)) return CharCategory.Space;
      if (hasWordChar(char)) return CharCategory.Word;

      for (let i = 0; i < wordChars.length; i++) if (char.indexOf(wordChars[i]) > -1) return CharCategory.Word;

      return CharCategory.Other;
    };
  }
  /**
  The editor state class is a persistent (immutable) data structure.
  To update a state, you [create](https://codemirror.net/6/docs/ref/#state.EditorState.update) a
  [transaction](https://codemirror.net/6/docs/ref/#state.Transaction), which produces a _new_ state
  instance, without modifying the original object.

  As such, _never_ mutate properties of a state directly. That'll
  just break things.
  */


  class EditorState {
    constructor(
    /**
    @internal
    */
    config,
    /**
    The current document.
    */
    doc,
    /**
    The current selection.
    */
    selection,
    /**
    @internal
    */
    values, computeSlot, tr) {
      this.config = config;
      this.doc = doc;
      this.selection = selection;
      this.values = values;
      this.status = config.statusTemplate.slice();
      this.computeSlot = computeSlot; // Fill in the computed state immediately, so that further queries
      // for it made during the update return this state

      if (tr) tr._state = this;

      for (let i = 0; i < this.config.dynamicSlots.length; i++) ensureAddr(this, i << 1);

      this.computeSlot = null;
    }

    field(field, require = true) {
      let addr = this.config.address[field.id];

      if (addr == null) {
        if (require) throw new RangeError("Field is not present in this state");
        return undefined;
      }

      ensureAddr(this, addr);
      return getAddr(this, addr);
    }
    /**
    Create a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction) that updates this
    state. Any number of [transaction specs](https://codemirror.net/6/docs/ref/#state.TransactionSpec)
    can be passed. Unless
    [`sequential`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.sequential) is set, the
    [changes](https://codemirror.net/6/docs/ref/#state.TransactionSpec.changes) (if any) of each spec
    are assumed to start in the _current_ document (not the document
    produced by previous specs), and its
    [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) and
    [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) are assumed to refer
    to the document created by its _own_ changes. The resulting
    transaction contains the combined effect of all the different
    specs. For [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection), later
    specs take precedence over earlier ones.
    */


    update(...specs) {
      return resolveTransaction(this, specs, true);
    }
    /**
    @internal
    */


    applyTransaction(tr) {
      let conf = this.config,
          {
        base,
        compartments
      } = conf;

      for (let effect of tr.effects) {
        if (effect.is(Compartment.reconfigure)) {
          if (conf) {
            compartments = new Map();
            conf.compartments.forEach((val, key) => compartments.set(key, val));
            conf = null;
          }

          compartments.set(effect.value.compartment, effect.value.extension);
        } else if (effect.is(StateEffect.reconfigure)) {
          conf = null;
          base = effect.value;
        } else if (effect.is(StateEffect.appendConfig)) {
          conf = null;
          base = asArray(base).concat(effect.value);
        }
      }

      let startValues;

      if (!conf) {
        conf = Configuration.resolve(base, compartments, this);
        let intermediateState = new EditorState(conf, this.doc, this.selection, conf.dynamicSlots.map(() => null), (state, slot) => slot.reconfigure(state, this), null);
        startValues = intermediateState.values;
      } else {
        startValues = tr.startState.values.slice();
      }

      new EditorState(conf, tr.newDoc, tr.newSelection, startValues, (state, slot) => slot.update(state, tr), tr);
    }
    /**
    Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
    replaces every selection range with the given content.
    */


    replaceSelection(text) {
      if (typeof text == "string") text = this.toText(text);
      return this.changeByRange(range => ({
        changes: {
          from: range.from,
          to: range.to,
          insert: text
        },
        range: EditorSelection.cursor(range.from + text.length)
      }));
    }
    /**
    Create a set of changes and a new selection by running the given
    function for each range in the active selection. The function
    can return an optional set of changes (in the coordinate space
    of the start document), plus an updated range (in the coordinate
    space of the document produced by the call's own changes). This
    method will merge all the changes and ranges into a single
    changeset and selection, and return it as a [transaction
    spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec), which can be passed to
    [`update`](https://codemirror.net/6/docs/ref/#state.EditorState.update).
    */


    changeByRange(f) {
      let sel = this.selection;
      let result1 = f(sel.ranges[0]);
      let changes = this.changes(result1.changes),
          ranges = [result1.range];
      let effects = asArray(result1.effects);

      for (let i = 1; i < sel.ranges.length; i++) {
        let result = f(sel.ranges[i]);
        let newChanges = this.changes(result.changes),
            newMapped = newChanges.map(changes);

        for (let j = 0; j < i; j++) ranges[j] = ranges[j].map(newMapped);

        let mapBy = changes.mapDesc(newChanges, true);
        ranges.push(result.range.map(mapBy));
        changes = changes.compose(newMapped);
        effects = StateEffect.mapEffects(effects, newMapped).concat(StateEffect.mapEffects(asArray(result.effects), mapBy));
      }

      return {
        changes,
        selection: EditorSelection.create(ranges, sel.mainIndex),
        effects
      };
    }
    /**
    Create a [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet) from the given change
    description, taking the state's document length and line
    separator into account.
    */


    changes(spec = []) {
      if (spec instanceof ChangeSet) return spec;
      return ChangeSet.of(spec, this.doc.length, this.facet(EditorState.lineSeparator));
    }
    /**
    Using the state's [line
    separator](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator), create a
    [`Text`](https://codemirror.net/6/docs/ref/#state.Text) instance from the given string.
    */


    toText(string) {
      return Text.of(string.split(this.facet(EditorState.lineSeparator) || DefaultSplit));
    }
    /**
    Return the given range of the document as a string.
    */


    sliceDoc(from = 0, to = this.doc.length) {
      return this.doc.sliceString(from, to, this.lineBreak);
    }
    /**
    Get the value of a state [facet](https://codemirror.net/6/docs/ref/#state.Facet).
    */


    facet(facet) {
      let addr = this.config.address[facet.id];
      if (addr == null) return facet.default;
      ensureAddr(this, addr);
      return getAddr(this, addr);
    }
    /**
    Convert this state to a JSON-serializable object. When custom
    fields should be serialized, you can pass them in as an object
    mapping property names (in the resulting object, which should
    not use `doc` or `selection`) to fields.
    */


    toJSON(fields) {
      let result = {
        doc: this.sliceDoc(),
        selection: this.selection.toJSON()
      };
      if (fields) for (let prop in fields) {
        let value = fields[prop];
        if (value instanceof StateField && this.config.address[value.id] != null) result[prop] = value.spec.toJSON(this.field(fields[prop]), this);
      }
      return result;
    }
    /**
    Deserialize a state from its JSON representation. When custom
    fields should be deserialized, pass the same object you passed
    to [`toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) when serializing as
    third argument.
    */


    static fromJSON(json, config = {}, fields) {
      if (!json || typeof json.doc != "string") throw new RangeError("Invalid JSON representation for EditorState");
      let fieldInit = [];
      if (fields) for (let prop in fields) {
        if (Object.prototype.hasOwnProperty.call(json, prop)) {
          let field = fields[prop],
              value = json[prop];
          fieldInit.push(field.init(state => field.spec.fromJSON(value, state)));
        }
      }
      return EditorState.create({
        doc: json.doc,
        selection: EditorSelection.fromJSON(json.selection),
        extensions: config.extensions ? fieldInit.concat([config.extensions]) : fieldInit
      });
    }
    /**
    Create a new state. You'll usually only need this when
    initializing an editor—updated states are created by applying
    transactions.
    */


    static create(config = {}) {
      let configuration = Configuration.resolve(config.extensions || [], new Map());
      let doc = config.doc instanceof Text ? config.doc : Text.of((config.doc || "").split(configuration.staticFacet(EditorState.lineSeparator) || DefaultSplit));
      let selection = !config.selection ? EditorSelection.single(0) : config.selection instanceof EditorSelection ? config.selection : EditorSelection.single(config.selection.anchor, config.selection.head);
      checkSelection(selection, doc.length);
      if (!configuration.staticFacet(allowMultipleSelections)) selection = selection.asSingle();
      return new EditorState(configuration, doc, selection, configuration.dynamicSlots.map(() => null), (state, slot) => slot.create(state), null);
    }
    /**
    The size (in columns) of a tab in the document, determined by
    the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet.
    */


    get tabSize() {
      return this.facet(EditorState.tabSize);
    }
    /**
    Get the proper [line-break](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)
    string for this state.
    */


    get lineBreak() {
      return this.facet(EditorState.lineSeparator) || "\n";
    }
    /**
    Returns true when the editor is
    [configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only.
    */


    get readOnly() {
      return this.facet(readOnly);
    }
    /**
    Look up a translation for the given phrase (via the
    [`phrases`](https://codemirror.net/6/docs/ref/#state.EditorState^phrases) facet), or return the
    original string if no translation is found.
    
    If additional arguments are passed, they will be inserted in
    place of markers like `$1` (for the first value) and `$2`, etc.
    A single `$` is equivalent to `$1`, and `$$` will produce a
    literal dollar sign.
    */


    phrase(phrase, ...insert) {
      for (let map of this.facet(EditorState.phrases)) if (Object.prototype.hasOwnProperty.call(map, phrase)) {
        phrase = map[phrase];
        break;
      }

      if (insert.length) phrase = phrase.replace(/\$(\$|\d*)/g, (m, i) => {
        if (i == "$") return "$";
        let n = +(i || 1);
        return !n || n > insert.length ? m : insert[n - 1];
      });
      return phrase;
    }
    /**
    Find the values for a given language data field, provided by the
    the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
    */


    languageDataAt(name, pos, side = -1) {
      let values = [];

      for (let provider of this.facet(languageData)) {
        for (let result of provider(this, pos, side)) {
          if (Object.prototype.hasOwnProperty.call(result, name)) values.push(result[name]);
        }
      }

      return values;
    }
    /**
    Return a function that can categorize strings (expected to
    represent a single [grapheme cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak))
    into one of:
    
     - Word (contains an alphanumeric character or a character
       explicitly listed in the local language's `"wordChars"`
       language data, which should be a string)
     - Space (contains only whitespace)
     - Other (anything else)
    */


    charCategorizer(at) {
      return makeCategorizer(this.languageDataAt("wordChars", at).join(""));
    }
    /**
    Find the word at the given position, meaning the range
    containing all [word](https://codemirror.net/6/docs/ref/#state.CharCategory.Word) characters
    around it. If no word characters are adjacent to the position,
    this returns null.
    */


    wordAt(pos) {
      let {
        text,
        from,
        length
      } = this.doc.lineAt(pos);
      let cat = this.charCategorizer(pos);
      let start = pos - from,
          end = pos - from;

      while (start > 0) {
        let prev = findClusterBreak(text, start, false);
        if (cat(text.slice(prev, start)) != CharCategory.Word) break;
        start = prev;
      }

      while (end < length) {
        let next = findClusterBreak(text, end);
        if (cat(text.slice(end, next)) != CharCategory.Word) break;
        end = next;
      }

      return start == end ? null : EditorSelection.range(start + from, end + from);
    }

  }
  /**
  A facet that, when enabled, causes the editor to allow multiple
  ranges to be selected. Be careful though, because by default the
  editor relies on the native DOM selection, which cannot handle
  multiple selections. An extension like
  [`drawSelection`](https://codemirror.net/6/docs/ref/#view.drawSelection) can be used to make
  secondary selections visible to the user.
  */


  EditorState.allowMultipleSelections = allowMultipleSelections;
  /**
  Configures the tab size to use in this state. The first
  (highest-precedence) value of the facet is used. If no value is
  given, this defaults to 4.
  */

  EditorState.tabSize = /*@__PURE__*/Facet.define({
    combine: values => values.length ? values[0] : 4
  });
  /**
  The line separator to use. By default, any of `"\n"`, `"\r\n"`
  and `"\r"` is treated as a separator when splitting lines, and
  lines are joined with `"\n"`.

  When you configure a value here, only that precise separator
  will be used, allowing you to round-trip documents through the
  editor without normalizing line separators.
  */

  EditorState.lineSeparator = lineSeparator;
  /**
  This facet controls the value of the
  [`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) getter, which is
  consulted by commands and extensions that implement editing
  functionality to determine whether they should apply. It
  defaults to false, but when its highest-precedence value is
  `true`, such functionality disables itself.

  Not to be confused with
  [`EditorView.editable`](https://codemirror.net/6/docs/ref/#view.EditorView^editable), which
  controls whether the editor's DOM is set to be editable (and
  thus focusable).
  */

  EditorState.readOnly = readOnly;
  /**
  Registers translation phrases. The
  [`phrase`](https://codemirror.net/6/docs/ref/#state.EditorState.phrase) method will look through
  all objects registered with this facet to find translations for
  its argument.
  */

  EditorState.phrases = /*@__PURE__*/Facet.define({
    compare(a, b) {
      let kA = Object.keys(a),
          kB = Object.keys(b);
      return kA.length == kB.length && kA.every(k => a[k] == b[k]);
    }

  });
  /**
  A facet used to register [language
  data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) providers.
  */

  EditorState.languageData = languageData;
  /**
  Facet used to register change filters, which are called for each
  transaction (unless explicitly
  [disabled](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter)), and can suppress
  part of the transaction's changes.

  Such a function can return `true` to indicate that it doesn't
  want to do anything, `false` to completely stop the changes in
  the transaction, or a set of ranges in which changes should be
  suppressed. Such ranges are represented as an array of numbers,
  with each pair of two numbers indicating the start and end of a
  range. So for example `[10, 20, 100, 110]` suppresses changes
  between 10 and 20, and between 100 and 110.
  */

  EditorState.changeFilter = changeFilter;
  /**
  Facet used to register a hook that gets a chance to update or
  replace transaction specs before they are applied. This will
  only be applied for transactions that don't have
  [`filter`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter) set to `false`. You
  can either return a single transaction spec (possibly the input
  transaction), or an array of specs (which will be combined in
  the same way as the arguments to
  [`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update)).

  When possible, it is recommended to avoid accessing
  [`Transaction.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state) in a filter,
  since it will force creation of a state that will then be
  discarded again, if the transaction is actually filtered.

  (This functionality should be used with care. Indiscriminately
  modifying transaction is likely to break something or degrade
  the user experience.)
  */

  EditorState.transactionFilter = transactionFilter;
  /**
  This is a more limited form of
  [`transactionFilter`](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter),
  which can only add
  [annotations](https://codemirror.net/6/docs/ref/#state.TransactionSpec.annotations) and
  [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects). _But_, this type
  of filter runs even if the transaction has disabled regular
  [filtering](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter), making it suitable
  for effects that don't need to touch the changes or selection,
  but do want to process every transaction.

  Extenders run _after_ filters, when both are present.
  */

  EditorState.transactionExtender = transactionExtender;
  Compartment.reconfigure = /*@__PURE__*/StateEffect.define();
  /**
  Utility function for combining behaviors to fill in a config
  object from an array of provided configs. `defaults` should hold
  default values for all optional fields in `Config`.

  The function will, by default, error
  when a field gets two values that aren't `===`-equal, but you can
  provide combine functions per field to do something else.
  */

  function combineConfig(configs, defaults, // Should hold only the optional properties of Config, but I haven't managed to express that
  combine = {}) {
    let result = {};

    for (let config of configs) for (let key of Object.keys(config)) {
      let value = config[key],
          current = result[key];
      if (current === undefined) result[key] = value;else if (current === value || value === undefined) ; // No conflict
      else if (Object.hasOwnProperty.call(combine, key)) result[key] = combine[key](current, value);else throw new Error("Config merge conflict for field " + key);
    }

    for (let key in defaults) if (result[key] === undefined) result[key] = defaults[key];

    return result;
  }
  /**
  Each range is associated with a value, which must inherit from
  this class.
  */


  class RangeValue {
    /**
    Compare this value with another value. Used when comparing
    rangesets. The default implementation compares by identity.
    Unless you are only creating a fixed number of unique instances
    of your value type, it is a good idea to implement this
    properly.
    */
    eq(other) {
      return this == other;
    }
    /**
    Create a [range](https://codemirror.net/6/docs/ref/#state.Range) with this value.
    */


    range(from, to = from) {
      return Range$1.create(from, to, this);
    }

  }

  RangeValue.prototype.startSide = RangeValue.prototype.endSide = 0;
  RangeValue.prototype.point = false;
  RangeValue.prototype.mapMode = MapMode.TrackDel;
  /**
  A range associates a value with a range of positions.
  */

  class Range$1 {
    constructor(
    /**
    The range's start position.
    */
    from,
    /**
    Its end position.
    */
    to,
    /**
    The value associated with this range.
    */
    value) {
      this.from = from;
      this.to = to;
      this.value = value;
    }
    /**
    @internal
    */


    static create(from, to, value) {
      return new Range$1(from, to, value);
    }

  }

  function cmpRange(a, b) {
    return a.from - b.from || a.value.startSide - b.value.startSide;
  }

  class Chunk {
    constructor(from, to, value, // Chunks are marked with the largest point that occurs
    // in them (or -1 for no points), so that scans that are
    // only interested in points (such as the
    // heightmap-related logic) can skip range-only chunks.
    maxPoint) {
      this.from = from;
      this.to = to;
      this.value = value;
      this.maxPoint = maxPoint;
    }

    get length() {
      return this.to[this.to.length - 1];
    } // Find the index of the given position and side. Use the ranges'
    // `from` pos when `end == false`, `to` when `end == true`.


    findIndex(pos, side, end, startAt = 0) {
      let arr = end ? this.to : this.from;

      for (let lo = startAt, hi = arr.length;;) {
        if (lo == hi) return lo;
        let mid = lo + hi >> 1;
        let diff = arr[mid] - pos || (end ? this.value[mid].endSide : this.value[mid].startSide) - side;
        if (mid == lo) return diff >= 0 ? lo : hi;
        if (diff >= 0) hi = mid;else lo = mid + 1;
      }
    }

    between(offset, from, to, f) {
      for (let i = this.findIndex(from, -1000000000
      /* C.Far */
      , true), e = this.findIndex(to, 1000000000
      /* C.Far */
      , false, i); i < e; i++) if (f(this.from[i] + offset, this.to[i] + offset, this.value[i]) === false) return false;
    }

    map(offset, changes) {
      let value = [],
          from = [],
          to = [],
          newPos = -1,
          maxPoint = -1;

      for (let i = 0; i < this.value.length; i++) {
        let val = this.value[i],
            curFrom = this.from[i] + offset,
            curTo = this.to[i] + offset,
            newFrom,
            newTo;

        if (curFrom == curTo) {
          let mapped = changes.mapPos(curFrom, val.startSide, val.mapMode);
          if (mapped == null) continue;
          newFrom = newTo = mapped;

          if (val.startSide != val.endSide) {
            newTo = changes.mapPos(curFrom, val.endSide);
            if (newTo < newFrom) continue;
          }
        } else {
          newFrom = changes.mapPos(curFrom, val.startSide);
          newTo = changes.mapPos(curTo, val.endSide);
          if (newFrom > newTo || newFrom == newTo && val.startSide > 0 && val.endSide <= 0) continue;
        }

        if ((newTo - newFrom || val.endSide - val.startSide) < 0) continue;
        if (newPos < 0) newPos = newFrom;
        if (val.point) maxPoint = Math.max(maxPoint, newTo - newFrom);
        value.push(val);
        from.push(newFrom - newPos);
        to.push(newTo - newPos);
      }

      return {
        mapped: value.length ? new Chunk(from, to, value, maxPoint) : null,
        pos: newPos
      };
    }

  }
  /**
  A range set stores a collection of [ranges](https://codemirror.net/6/docs/ref/#state.Range) in a
  way that makes them efficient to [map](https://codemirror.net/6/docs/ref/#state.RangeSet.map) and
  [update](https://codemirror.net/6/docs/ref/#state.RangeSet.update). This is an immutable data
  structure.
  */


  class RangeSet {
    constructor(
    /**
    @internal
    */
    chunkPos,
    /**
    @internal
    */
    chunk,
    /**
    @internal
    */
    nextLayer,
    /**
    @internal
    */
    maxPoint) {
      this.chunkPos = chunkPos;
      this.chunk = chunk;
      this.nextLayer = nextLayer;
      this.maxPoint = maxPoint;
    }
    /**
    @internal
    */


    static create(chunkPos, chunk, nextLayer, maxPoint) {
      return new RangeSet(chunkPos, chunk, nextLayer, maxPoint);
    }
    /**
    @internal
    */


    get length() {
      let last = this.chunk.length - 1;
      return last < 0 ? 0 : Math.max(this.chunkEnd(last), this.nextLayer.length);
    }
    /**
    The number of ranges in the set.
    */


    get size() {
      if (this.isEmpty) return 0;
      let size = this.nextLayer.size;

      for (let chunk of this.chunk) size += chunk.value.length;

      return size;
    }
    /**
    @internal
    */


    chunkEnd(index) {
      return this.chunkPos[index] + this.chunk[index].length;
    }
    /**
    Update the range set, optionally adding new ranges or filtering
    out existing ones.
    
    (Note: The type parameter is just there as a kludge to work
    around TypeScript variance issues that prevented `RangeSet<X>`
    from being a subtype of `RangeSet<Y>` when `X` is a subtype of
    `Y`.)
    */


    update(updateSpec) {
      let {
        add = [],
        sort = false,
        filterFrom = 0,
        filterTo = this.length
      } = updateSpec;
      let filter = updateSpec.filter;
      if (add.length == 0 && !filter) return this;
      if (sort) add = add.slice().sort(cmpRange);
      if (this.isEmpty) return add.length ? RangeSet.of(add) : this;
      let cur = new LayerCursor(this, null, -1).goto(0),
          i = 0,
          spill = [];
      let builder = new RangeSetBuilder();

      while (cur.value || i < add.length) {
        if (i < add.length && (cur.from - add[i].from || cur.startSide - add[i].value.startSide) >= 0) {
          let range = add[i++];
          if (!builder.addInner(range.from, range.to, range.value)) spill.push(range);
        } else if (cur.rangeIndex == 1 && cur.chunkIndex < this.chunk.length && (i == add.length || this.chunkEnd(cur.chunkIndex) < add[i].from) && (!filter || filterFrom > this.chunkEnd(cur.chunkIndex) || filterTo < this.chunkPos[cur.chunkIndex]) && builder.addChunk(this.chunkPos[cur.chunkIndex], this.chunk[cur.chunkIndex])) {
          cur.nextChunk();
        } else {
          if (!filter || filterFrom > cur.to || filterTo < cur.from || filter(cur.from, cur.to, cur.value)) {
            if (!builder.addInner(cur.from, cur.to, cur.value)) spill.push(Range$1.create(cur.from, cur.to, cur.value));
          }

          cur.next();
        }
      }

      return builder.finishInner(this.nextLayer.isEmpty && !spill.length ? RangeSet.empty : this.nextLayer.update({
        add: spill,
        filter,
        filterFrom,
        filterTo
      }));
    }
    /**
    Map this range set through a set of changes, return the new set.
    */


    map(changes) {
      if (changes.empty || this.isEmpty) return this;
      let chunks = [],
          chunkPos = [],
          maxPoint = -1;

      for (let i = 0; i < this.chunk.length; i++) {
        let start = this.chunkPos[i],
            chunk = this.chunk[i];
        let touch = changes.touchesRange(start, start + chunk.length);

        if (touch === false) {
          maxPoint = Math.max(maxPoint, chunk.maxPoint);
          chunks.push(chunk);
          chunkPos.push(changes.mapPos(start));
        } else if (touch === true) {
          let {
            mapped,
            pos
          } = chunk.map(start, changes);

          if (mapped) {
            maxPoint = Math.max(maxPoint, mapped.maxPoint);
            chunks.push(mapped);
            chunkPos.push(pos);
          }
        }
      }

      let next = this.nextLayer.map(changes);
      return chunks.length == 0 ? next : new RangeSet(chunkPos, chunks, next || RangeSet.empty, maxPoint);
    }
    /**
    Iterate over the ranges that touch the region `from` to `to`,
    calling `f` for each. There is no guarantee that the ranges will
    be reported in any specific order. When the callback returns
    `false`, iteration stops.
    */


    between(from, to, f) {
      if (this.isEmpty) return;

      for (let i = 0; i < this.chunk.length; i++) {
        let start = this.chunkPos[i],
            chunk = this.chunk[i];
        if (to >= start && from <= start + chunk.length && chunk.between(start, from - start, to - start, f) === false) return;
      }

      this.nextLayer.between(from, to, f);
    }
    /**
    Iterate over the ranges in this set, in order, including all
    ranges that end at or after `from`.
    */


    iter(from = 0) {
      return HeapCursor.from([this]).goto(from);
    }
    /**
    @internal
    */


    get isEmpty() {
      return this.nextLayer == this;
    }
    /**
    Iterate over the ranges in a collection of sets, in order,
    starting from `from`.
    */


    static iter(sets, from = 0) {
      return HeapCursor.from(sets).goto(from);
    }
    /**
    Iterate over two groups of sets, calling methods on `comparator`
    to notify it of possible differences.
    */


    static compare(oldSets, newSets,
    /**
    This indicates how the underlying data changed between these
    ranges, and is needed to synchronize the iteration. `from` and
    `to` are coordinates in the _new_ space, after these changes.
    */
    textDiff, comparator,
    /**
    Can be used to ignore all non-point ranges, and points below
    the given size. When -1, all ranges are compared.
    */
    minPointSize = -1) {
      let a = oldSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);
      let b = newSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);
      let sharedChunks = findSharedChunks(a, b, textDiff);
      let sideA = new SpanCursor(a, sharedChunks, minPointSize);
      let sideB = new SpanCursor(b, sharedChunks, minPointSize);
      textDiff.iterGaps((fromA, fromB, length) => compare(sideA, fromA, sideB, fromB, length, comparator));
      if (textDiff.empty && textDiff.length == 0) compare(sideA, 0, sideB, 0, 0, comparator);
    }
    /**
    Compare the contents of two groups of range sets, returning true
    if they are equivalent in the given range.
    */


    static eq(oldSets, newSets, from = 0, to) {
      if (to == null) to = 1000000000
      /* C.Far */
      ;
      let a = oldSets.filter(set => !set.isEmpty && newSets.indexOf(set) < 0);
      let b = newSets.filter(set => !set.isEmpty && oldSets.indexOf(set) < 0);
      if (a.length != b.length) return false;
      if (!a.length) return true;
      let sharedChunks = findSharedChunks(a, b);
      let sideA = new SpanCursor(a, sharedChunks, 0).goto(from),
          sideB = new SpanCursor(b, sharedChunks, 0).goto(from);

      for (;;) {
        if (sideA.to != sideB.to || !sameValues(sideA.active, sideB.active) || sideA.point && (!sideB.point || !sideA.point.eq(sideB.point))) return false;
        if (sideA.to > to) return true;
        sideA.next();
        sideB.next();
      }
    }
    /**
    Iterate over a group of range sets at the same time, notifying
    the iterator about the ranges covering every given piece of
    content. Returns the open count (see
    [`SpanIterator.span`](https://codemirror.net/6/docs/ref/#state.SpanIterator.span)) at the end
    of the iteration.
    */


    static spans(sets, from, to, iterator,
    /**
    When given and greater than -1, only points of at least this
    size are taken into account.
    */
    minPointSize = -1) {
      let cursor = new SpanCursor(sets, null, minPointSize).goto(from),
          pos = from;
      let open = cursor.openStart;

      for (;;) {
        let curTo = Math.min(cursor.to, to);

        if (cursor.point) {
          iterator.point(pos, curTo, cursor.point, cursor.activeForPoint(cursor.to), open, cursor.pointRank);
          open = cursor.openEnd(curTo) + (cursor.to > curTo ? 1 : 0);
        } else if (curTo > pos) {
          iterator.span(pos, curTo, cursor.active, open);
          open = cursor.openEnd(curTo);
        }

        if (cursor.to > to) break;
        pos = cursor.to;
        cursor.next();
      }

      return open;
    }
    /**
    Create a range set for the given range or array of ranges. By
    default, this expects the ranges to be _sorted_ (by start
    position and, if two start at the same position,
    `value.startSide`). You can pass `true` as second argument to
    cause the method to sort them.
    */


    static of(ranges, sort = false) {
      let build = new RangeSetBuilder();

      for (let range of ranges instanceof Range$1 ? [ranges] : sort ? lazySort(ranges) : ranges) build.add(range.from, range.to, range.value);

      return build.finish();
    }

  }
  /**
  The empty set of ranges.
  */


  RangeSet.empty = /*@__PURE__*/new RangeSet([], [], null, -1);

  function lazySort(ranges) {
    if (ranges.length > 1) for (let prev = ranges[0], i = 1; i < ranges.length; i++) {
      let cur = ranges[i];
      if (cmpRange(prev, cur) > 0) return ranges.slice().sort(cmpRange);
      prev = cur;
    }
    return ranges;
  }

  RangeSet.empty.nextLayer = RangeSet.empty;
  /**
  A range set builder is a data structure that helps build up a
  [range set](https://codemirror.net/6/docs/ref/#state.RangeSet) directly, without first allocating
  an array of [`Range`](https://codemirror.net/6/docs/ref/#state.Range) objects.
  */

  class RangeSetBuilder {
    /**
    Create an empty builder.
    */
    constructor() {
      this.chunks = [];
      this.chunkPos = [];
      this.chunkStart = -1;
      this.last = null;
      this.lastFrom = -1000000000
      /* C.Far */
      ;
      this.lastTo = -1000000000
      /* C.Far */
      ;
      this.from = [];
      this.to = [];
      this.value = [];
      this.maxPoint = -1;
      this.setMaxPoint = -1;
      this.nextLayer = null;
    }

    finishChunk(newArrays) {
      this.chunks.push(new Chunk(this.from, this.to, this.value, this.maxPoint));
      this.chunkPos.push(this.chunkStart);
      this.chunkStart = -1;
      this.setMaxPoint = Math.max(this.setMaxPoint, this.maxPoint);
      this.maxPoint = -1;

      if (newArrays) {
        this.from = [];
        this.to = [];
        this.value = [];
      }
    }
    /**
    Add a range. Ranges should be added in sorted (by `from` and
    `value.startSide`) order.
    */


    add(from, to, value) {
      if (!this.addInner(from, to, value)) (this.nextLayer || (this.nextLayer = new RangeSetBuilder())).add(from, to, value);
    }
    /**
    @internal
    */


    addInner(from, to, value) {
      let diff = from - this.lastTo || value.startSide - this.last.endSide;
      if (diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0) throw new Error("Ranges must be added sorted by `from` position and `startSide`");
      if (diff < 0) return false;
      if (this.from.length == 250
      /* C.ChunkSize */
      ) this.finishChunk(true);
      if (this.chunkStart < 0) this.chunkStart = from;
      this.from.push(from - this.chunkStart);
      this.to.push(to - this.chunkStart);
      this.last = value;
      this.lastFrom = from;
      this.lastTo = to;
      this.value.push(value);
      if (value.point) this.maxPoint = Math.max(this.maxPoint, to - from);
      return true;
    }
    /**
    @internal
    */


    addChunk(from, chunk) {
      if ((from - this.lastTo || chunk.value[0].startSide - this.last.endSide) < 0) return false;
      if (this.from.length) this.finishChunk(true);
      this.setMaxPoint = Math.max(this.setMaxPoint, chunk.maxPoint);
      this.chunks.push(chunk);
      this.chunkPos.push(from);
      let last = chunk.value.length - 1;
      this.last = chunk.value[last];
      this.lastFrom = chunk.from[last] + from;
      this.lastTo = chunk.to[last] + from;
      return true;
    }
    /**
    Finish the range set. Returns the new set. The builder can't be
    used anymore after this has been called.
    */


    finish() {
      return this.finishInner(RangeSet.empty);
    }
    /**
    @internal
    */


    finishInner(next) {
      if (this.from.length) this.finishChunk(false);
      if (this.chunks.length == 0) return next;
      let result = RangeSet.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(next) : next, this.setMaxPoint);
      this.from = null; // Make sure further `add` calls produce errors

      return result;
    }

  }

  function findSharedChunks(a, b, textDiff) {
    let inA = new Map();

    for (let set of a) for (let i = 0; i < set.chunk.length; i++) if (set.chunk[i].maxPoint <= 0) inA.set(set.chunk[i], set.chunkPos[i]);

    let shared = new Set();

    for (let set of b) for (let i = 0; i < set.chunk.length; i++) {
      let known = inA.get(set.chunk[i]);
      if (known != null && (textDiff ? textDiff.mapPos(known) : known) == set.chunkPos[i] && !(textDiff === null || textDiff === void 0 ? void 0 : textDiff.touchesRange(known, known + set.chunk[i].length))) shared.add(set.chunk[i]);
    }

    return shared;
  }

  class LayerCursor {
    constructor(layer, skip, minPoint, rank = 0) {
      this.layer = layer;
      this.skip = skip;
      this.minPoint = minPoint;
      this.rank = rank;
    }

    get startSide() {
      return this.value ? this.value.startSide : 0;
    }

    get endSide() {
      return this.value ? this.value.endSide : 0;
    }

    goto(pos, side = -1000000000
    /* C.Far */
    ) {
      this.chunkIndex = this.rangeIndex = 0;
      this.gotoInner(pos, side, false);
      return this;
    }

    gotoInner(pos, side, forward) {
      while (this.chunkIndex < this.layer.chunk.length) {
        let next = this.layer.chunk[this.chunkIndex];
        if (!(this.skip && this.skip.has(next) || this.layer.chunkEnd(this.chunkIndex) < pos || next.maxPoint < this.minPoint)) break;
        this.chunkIndex++;
        forward = false;
      }

      if (this.chunkIndex < this.layer.chunk.length) {
        let rangeIndex = this.layer.chunk[this.chunkIndex].findIndex(pos - this.layer.chunkPos[this.chunkIndex], side, true);
        if (!forward || this.rangeIndex < rangeIndex) this.setRangeIndex(rangeIndex);
      }

      this.next();
    }

    forward(pos, side) {
      if ((this.to - pos || this.endSide - side) < 0) this.gotoInner(pos, side, true);
    }

    next() {
      for (;;) {
        if (this.chunkIndex == this.layer.chunk.length) {
          this.from = this.to = 1000000000
          /* C.Far */
          ;
          this.value = null;
          break;
        } else {
          let chunkPos = this.layer.chunkPos[this.chunkIndex],
              chunk = this.layer.chunk[this.chunkIndex];
          let from = chunkPos + chunk.from[this.rangeIndex];
          this.from = from;
          this.to = chunkPos + chunk.to[this.rangeIndex];
          this.value = chunk.value[this.rangeIndex];
          this.setRangeIndex(this.rangeIndex + 1);
          if (this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint) break;
        }
      }
    }

    setRangeIndex(index) {
      if (index == this.layer.chunk[this.chunkIndex].value.length) {
        this.chunkIndex++;

        if (this.skip) {
          while (this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex])) this.chunkIndex++;
        }

        this.rangeIndex = 0;
      } else {
        this.rangeIndex = index;
      }
    }

    nextChunk() {
      this.chunkIndex++;
      this.rangeIndex = 0;
      this.next();
    }

    compare(other) {
      return this.from - other.from || this.startSide - other.startSide || this.rank - other.rank || this.to - other.to || this.endSide - other.endSide;
    }

  }

  class HeapCursor {
    constructor(heap) {
      this.heap = heap;
    }

    static from(sets, skip = null, minPoint = -1) {
      let heap = [];

      for (let i = 0; i < sets.length; i++) {
        for (let cur = sets[i]; !cur.isEmpty; cur = cur.nextLayer) {
          if (cur.maxPoint >= minPoint) heap.push(new LayerCursor(cur, skip, minPoint, i));
        }
      }

      return heap.length == 1 ? heap[0] : new HeapCursor(heap);
    }

    get startSide() {
      return this.value ? this.value.startSide : 0;
    }

    goto(pos, side = -1000000000
    /* C.Far */
    ) {
      for (let cur of this.heap) cur.goto(pos, side);

      for (let i = this.heap.length >> 1; i >= 0; i--) heapBubble(this.heap, i);

      this.next();
      return this;
    }

    forward(pos, side) {
      for (let cur of this.heap) cur.forward(pos, side);

      for (let i = this.heap.length >> 1; i >= 0; i--) heapBubble(this.heap, i);

      if ((this.to - pos || this.value.endSide - side) < 0) this.next();
    }

    next() {
      if (this.heap.length == 0) {
        this.from = this.to = 1000000000
        /* C.Far */
        ;
        this.value = null;
        this.rank = -1;
      } else {
        let top = this.heap[0];
        this.from = top.from;
        this.to = top.to;
        this.value = top.value;
        this.rank = top.rank;
        if (top.value) top.next();
        heapBubble(this.heap, 0);
      }
    }

  }

  function heapBubble(heap, index) {
    for (let cur = heap[index];;) {
      let childIndex = (index << 1) + 1;
      if (childIndex >= heap.length) break;
      let child = heap[childIndex];

      if (childIndex + 1 < heap.length && child.compare(heap[childIndex + 1]) >= 0) {
        child = heap[childIndex + 1];
        childIndex++;
      }

      if (cur.compare(child) < 0) break;
      heap[childIndex] = cur;
      heap[index] = child;
      index = childIndex;
    }
  }

  class SpanCursor {
    constructor(sets, skip, minPoint) {
      this.minPoint = minPoint;
      this.active = [];
      this.activeTo = [];
      this.activeRank = [];
      this.minActive = -1; // A currently active point range, if any

      this.point = null;
      this.pointFrom = 0;
      this.pointRank = 0;
      this.to = -1000000000
      /* C.Far */
      ;
      this.endSide = 0;
      this.openStart = -1;
      this.cursor = HeapCursor.from(sets, skip, minPoint);
    }

    goto(pos, side = -1000000000
    /* C.Far */
    ) {
      this.cursor.goto(pos, side);
      this.active.length = this.activeTo.length = this.activeRank.length = 0;
      this.minActive = -1;
      this.to = pos;
      this.endSide = side;
      this.openStart = -1;
      this.next();
      return this;
    }

    forward(pos, side) {
      while (this.minActive > -1 && (this.activeTo[this.minActive] - pos || this.active[this.minActive].endSide - side) < 0) this.removeActive(this.minActive);

      this.cursor.forward(pos, side);
    }

    removeActive(index) {
      remove$2(this.active, index);
      remove$2(this.activeTo, index);
      remove$2(this.activeRank, index);
      this.minActive = findMinIndex(this.active, this.activeTo);
    }

    addActive(trackOpen) {
      let i = 0,
          {
        value,
        to,
        rank
      } = this.cursor;

      while (i < this.activeRank.length && this.activeRank[i] <= rank) i++;

      insert(this.active, i, value);
      insert(this.activeTo, i, to);
      insert(this.activeRank, i, rank);
      if (trackOpen) insert(trackOpen, i, this.cursor.from);
      this.minActive = findMinIndex(this.active, this.activeTo);
    } // After calling this, if `this.point` != null, the next range is a
    // point. Otherwise, it's a regular range, covered by `this.active`.


    next() {
      let from = this.to,
          wasPoint = this.point;
      this.point = null;
      let trackOpen = this.openStart < 0 ? [] : null,
          trackExtra = 0;

      for (;;) {
        let a = this.minActive;

        if (a > -1 && (this.activeTo[a] - this.cursor.from || this.active[a].endSide - this.cursor.startSide) < 0) {
          if (this.activeTo[a] > from) {
            this.to = this.activeTo[a];
            this.endSide = this.active[a].endSide;
            break;
          }

          this.removeActive(a);
          if (trackOpen) remove$2(trackOpen, a);
        } else if (!this.cursor.value) {
          this.to = this.endSide = 1000000000
          /* C.Far */
          ;
          break;
        } else if (this.cursor.from > from) {
          this.to = this.cursor.from;
          this.endSide = this.cursor.startSide;
          break;
        } else {
          let nextVal = this.cursor.value;

          if (!nextVal.point) {
            // Opening a range
            this.addActive(trackOpen);
            if (this.cursor.from < from && this.cursor.to > from) trackExtra++;
            this.cursor.next();
          } else if (wasPoint && this.cursor.to == this.to && this.cursor.from < this.cursor.to) {
            // Ignore any non-empty points that end precisely at the end of the prev point
            this.cursor.next();
          } else {
            // New point
            this.point = nextVal;
            this.pointFrom = this.cursor.from;
            this.pointRank = this.cursor.rank;
            this.to = this.cursor.to;
            this.endSide = nextVal.endSide;
            if (this.cursor.from < from) trackExtra = 1;
            this.cursor.next();
            this.forward(this.to, this.endSide);
            break;
          }
        }
      }

      if (trackOpen) {
        let openStart = 0;

        while (openStart < trackOpen.length && trackOpen[openStart] < from) openStart++;

        this.openStart = openStart + trackExtra;
      }
    }

    activeForPoint(to) {
      if (!this.active.length) return this.active;
      let active = [];

      for (let i = this.active.length - 1; i >= 0; i--) {
        if (this.activeRank[i] < this.pointRank) break;
        if (this.activeTo[i] > to || this.activeTo[i] == to && this.active[i].endSide >= this.point.endSide) active.push(this.active[i]);
      }

      return active.reverse();
    }

    openEnd(to) {
      let open = 0;

      for (let i = this.activeTo.length - 1; i >= 0 && this.activeTo[i] > to; i--) open++;

      return open;
    }

  }

  function compare(a, startA, b, startB, length, comparator) {
    a.goto(startA);
    b.goto(startB);
    let endB = startB + length;
    let pos = startB,
        dPos = startB - startA;

    for (;;) {
      let diff = a.to + dPos - b.to || a.endSide - b.endSide;
      let end = diff < 0 ? a.to + dPos : b.to,
          clipEnd = Math.min(end, endB);

      if (a.point || b.point) {
        if (!(a.point && b.point && (a.point == b.point || a.point.eq(b.point)) && sameValues(a.activeForPoint(a.to + dPos), b.activeForPoint(b.to)))) comparator.comparePoint(pos, clipEnd, a.point, b.point);
      } else {
        if (clipEnd > pos && !sameValues(a.active, b.active)) comparator.compareRange(pos, clipEnd, a.active, b.active);
      }

      if (end > endB) break;
      pos = end;
      if (diff <= 0) a.next();
      if (diff >= 0) b.next();
    }
  }

  function sameValues(a, b) {
    if (a.length != b.length) return false;

    for (let i = 0; i < a.length; i++) if (a[i] != b[i] && !a[i].eq(b[i])) return false;

    return true;
  }

  function remove$2(array, index) {
    for (let i = index, e = array.length - 1; i < e; i++) array[i] = array[i + 1];

    array.pop();
  }

  function insert(array, index, value) {
    for (let i = array.length - 1; i >= index; i--) array[i + 1] = array[i];

    array[index] = value;
  }

  function findMinIndex(value, array) {
    let found = -1,
        foundPos = 1000000000
    /* C.Far */
    ;

    for (let i = 0; i < array.length; i++) if ((array[i] - foundPos || value[i].endSide - value[found].endSide) < 0) {
      found = i;
      foundPos = array[i];
    }

    return found;
  }
  /**
  Count the column position at the given offset into the string,
  taking extending characters and tab size into account.
  */


  function countColumn(string, tabSize, to = string.length) {
    let n = 0;

    for (let i = 0; i < to;) {
      if (string.charCodeAt(i) == 9) {
        n += tabSize - n % tabSize;
        i++;
      } else {
        n++;
        i = findClusterBreak(string, i);
      }
    }

    return n;
  }
  /**
  Find the offset that corresponds to the given column position in a
  string, taking extending characters and tab size into account. By
  default, the string length is returned when it is too short to
  reach the column. Pass `strict` true to make it return -1 in that
  situation.
  */


  function findColumn(string, col, tabSize, strict) {
    for (let i = 0, n = 0;;) {
      if (n >= col) return i;
      if (i == string.length) break;
      n += string.charCodeAt(i) == 9 ? tabSize - n % tabSize : 1;
      i = findClusterBreak(string, i);
    }

    return strict === true ? -1 : string.length;
  }

  const C = "\u037c";
  const COUNT = typeof Symbol == "undefined" ? "__" + C : Symbol.for(C);
  const SET = typeof Symbol == "undefined" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet");
  const top = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : {}; // :: - Style modules encapsulate a set of CSS rules defined from
  // JavaScript. Their definitions are only available in a given DOM
  // root after it has been _mounted_ there with `StyleModule.mount`.
  //
  // Style modules should be created once and stored somewhere, as
  // opposed to re-creating them every time you need them. The amount of
  // CSS rules generated for a given DOM root is bounded by the amount
  // of style modules that were used. So to avoid leaking rules, don't
  // create these dynamically, but treat them as one-time allocations.

  class StyleModule {
    // :: (Object<Style>, ?{finish: ?(string) → string})
    // Create a style module from the given spec.
    //
    // When `finish` is given, it is called on regular (non-`@`)
    // selectors (after `&` expansion) to compute the final selector.
    constructor(spec, options) {
      this.rules = [];
      let {
        finish
      } = options || {};

      function splitSelector(selector) {
        return /^@/.test(selector) ? [selector] : selector.split(/,\s*/);
      }

      function render(selectors, spec, target, isKeyframes) {
        let local = [],
            isAt = /^@(\w+)\b/.exec(selectors[0]),
            keyframes = isAt && isAt[1] == "keyframes";
        if (isAt && spec == null) return target.push(selectors[0] + ";");

        for (let prop in spec) {
          let value = spec[prop];

          if (/&/.test(prop)) {
            render(prop.split(/,\s*/).map(part => selectors.map(sel => part.replace(/&/, sel))).reduce((a, b) => a.concat(b)), value, target);
          } else if (value && typeof value == "object") {
            if (!isAt) throw new RangeError("The value of a property (" + prop + ") should be a primitive value.");
            render(splitSelector(prop), value, local, keyframes);
          } else if (value != null) {
            local.push(prop.replace(/_.*/, "").replace(/[A-Z]/g, l => "-" + l.toLowerCase()) + ": " + value + ";");
          }
        }

        if (local.length || keyframes) {
          target.push((finish && !isAt && !isKeyframes ? selectors.map(finish) : selectors).join(", ") + " {" + local.join(" ") + "}");
        }
      }

      for (let prop in spec) render(splitSelector(prop), spec[prop], this.rules);
    } // :: () → string
    // Returns a string containing the module's CSS rules.


    getRules() {
      return this.rules.join("\n");
    } // :: () → string
    // Generate a new unique CSS class name.


    static newName() {
      let id = top[COUNT] || 1;
      top[COUNT] = id + 1;
      return C + id.toString(36);
    } // :: (union<Document, ShadowRoot>, union<[StyleModule], StyleModule>)
    //
    // Mount the given set of modules in the given DOM root, which ensures
    // that the CSS rules defined by the module are available in that
    // context.
    //
    // Rules are only added to the document once per root.
    //
    // Rule order will follow the order of the modules, so that rules from
    // modules later in the array take precedence of those from earlier
    // modules. If you call this function multiple times for the same root
    // in a way that changes the order of already mounted modules, the old
    // order will be changed.


    static mount(root, modules) {
      (root[SET] || new StyleSet(root)).mount(Array.isArray(modules) ? modules : [modules]);
    }

  }
  let adoptedSet = null;

  class StyleSet {
    constructor(root) {
      if (!root.head && root.adoptedStyleSheets && typeof CSSStyleSheet != "undefined") {
        if (adoptedSet) {
          root.adoptedStyleSheets = [adoptedSet.sheet].concat(root.adoptedStyleSheets);
          return root[SET] = adoptedSet;
        }

        this.sheet = new CSSStyleSheet();
        root.adoptedStyleSheets = [this.sheet].concat(root.adoptedStyleSheets);
        adoptedSet = this;
      } else {
        this.styleTag = (root.ownerDocument || root).createElement("style");
        let target = root.head || root;
        target.insertBefore(this.styleTag, target.firstChild);
      }

      this.modules = [];
      root[SET] = this;
    }

    mount(modules) {
      let sheet = this.sheet;
      let pos = 0
      /* Current rule offset */
      ,
          j = 0;
      /* Index into this.modules */

      for (let i = 0; i < modules.length; i++) {
        let mod = modules[i],
            index = this.modules.indexOf(mod);

        if (index < j && index > -1) {
          // Ordering conflict
          this.modules.splice(index, 1);
          j--;
          index = -1;
        }

        if (index == -1) {
          this.modules.splice(j++, 0, mod);
          if (sheet) for (let k = 0; k < mod.rules.length; k++) sheet.insertRule(mod.rules[k], pos++);
        } else {
          while (j < index) pos += this.modules[j++].rules.length;

          pos += mod.rules.length;
          j++;
        }
      }

      if (!sheet) {
        let text = "";

        for (let i = 0; i < this.modules.length; i++) text += this.modules[i].getRules() + "\n";

        this.styleTag.textContent = text;
      }
    }

  } // Style::Object<union<Style,string>>
  //
  // A style is an object that, in the simple case, maps CSS property
  // names to strings holding their values, as in `{color: "red",
  // fontWeight: "bold"}`. The property names can be given in
  // camel-case—the library will insert a dash before capital letters
  // when converting them to CSS.
  //
  // If you include an underscore in a property name, it and everything
  // after it will be removed from the output, which can be useful when
  // providing a property multiple times, for browser compatibility
  // reasons.
  //
  // A property in a style object can also be a sub-selector, which
  // extends the current context to add a pseudo-selector or a child
  // selector. Such a property should contain a `&` character, which
  // will be replaced by the current selector. For example `{"&:before":
  // {content: '"hi"'}}`. Sub-selectors and regular properties can
  // freely be mixed in a given object. Any property containing a `&` is
  // assumed to be a sub-selector.
  //
  // Finally, a property can specify an @-block to be wrapped around the
  // styles defined inside the object that's the property's value. For
  // example to create a media query you can do `{"@media screen and
  // (min-width: 400px)": {...}}`.

  var base = {
    8: "Backspace",
    9: "Tab",
    10: "Enter",
    12: "NumLock",
    13: "Enter",
    16: "Shift",
    17: "Control",
    18: "Alt",
    20: "CapsLock",
    27: "Escape",
    32: " ",
    33: "PageUp",
    34: "PageDown",
    35: "End",
    36: "Home",
    37: "ArrowLeft",
    38: "ArrowUp",
    39: "ArrowRight",
    40: "ArrowDown",
    44: "PrintScreen",
    45: "Insert",
    46: "Delete",
    59: ";",
    61: "=",
    91: "Meta",
    92: "Meta",
    106: "*",
    107: "+",
    108: ",",
    109: "-",
    110: ".",
    111: "/",
    144: "NumLock",
    145: "ScrollLock",
    160: "Shift",
    161: "Shift",
    162: "Control",
    163: "Control",
    164: "Alt",
    165: "Alt",
    173: "-",
    186: ";",
    187: "=",
    188: ",",
    189: "-",
    190: ".",
    191: "/",
    192: "`",
    219: "[",
    220: "\\",
    221: "]",
    222: "'"
  };
  var shift = {
    48: ")",
    49: "!",
    50: "@",
    51: "#",
    52: "$",
    53: "%",
    54: "^",
    55: "&",
    56: "*",
    57: "(",
    59: ":",
    61: "+",
    173: "_",
    186: ":",
    187: "+",
    188: "<",
    189: "_",
    190: ">",
    191: "?",
    192: "~",
    219: "{",
    220: "|",
    221: "}",
    222: "\""
  };
  var chrome$1 = typeof navigator != "undefined" && /Chrome\/(\d+)/.exec(navigator.userAgent);
  typeof navigator != "undefined" && /Gecko\/\d+/.test(navigator.userAgent);
  var mac = typeof navigator != "undefined" && /Mac/.test(navigator.platform);
  var ie$1 = typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
  var brokenModifierNames = mac || chrome$1 && +chrome$1[1] < 57; // Fill in the digit keys

  for (var i$1 = 0; i$1 < 10; i$1++) base[48 + i$1] = base[96 + i$1] = String(i$1); // The function keys


  for (var i$1 = 1; i$1 <= 24; i$1++) base[i$1 + 111] = "F" + i$1; // And the alphabetic keys


  for (var i$1 = 65; i$1 <= 90; i$1++) {
    base[i$1] = String.fromCharCode(i$1 + 32);
    shift[i$1] = String.fromCharCode(i$1);
  } // For each code that doesn't have a shift-equivalent, copy the base name


  for (var code in base) if (!shift.hasOwnProperty(code)) shift[code] = base[code];

  function keyName(event) {
    var ignoreKey = brokenModifierNames && (event.ctrlKey || event.altKey || event.metaKey) || ie$1 && event.shiftKey && event.key && event.key.length == 1 || event.key == "Unidentified";
    var name = !ignoreKey && event.key || (event.shiftKey ? shift : base)[event.keyCode] || event.key || "Unidentified"; // Edge sometimes produces wrong names (Issue #3)

    if (name == "Esc") name = "Escape";
    if (name == "Del") name = "Delete"; // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8860571/

    if (name == "Left") name = "ArrowLeft";
    if (name == "Up") name = "ArrowUp";
    if (name == "Right") name = "ArrowRight";
    if (name == "Down") name = "ArrowDown";
    return name;
  }

  function getSelection(root) {
    let target; // Browsers differ on whether shadow roots have a getSelection
    // method. If it exists, use that, otherwise, call it on the
    // document.

    if (root.nodeType == 11) {
      // Shadow root
      target = root.getSelection ? root : root.ownerDocument;
    } else {
      target = root;
    }

    return target.getSelection();
  }

  function contains(dom, node) {
    return node ? dom == node || dom.contains(node.nodeType != 1 ? node.parentNode : node) : false;
  }

  function deepActiveElement(doc) {
    let elt = doc.activeElement;

    while (elt && elt.shadowRoot) elt = elt.shadowRoot.activeElement;

    return elt;
  }

  function hasSelection(dom, selection) {
    if (!selection.anchorNode) return false;

    try {
      // Firefox will raise 'permission denied' errors when accessing
      // properties of `sel.anchorNode` when it's in a generated CSS
      // element.
      return contains(dom, selection.anchorNode);
    } catch (_) {
      return false;
    }
  }

  function clientRectsFor(dom) {
    if (dom.nodeType == 3) return textRange(dom, 0, dom.nodeValue.length).getClientRects();else if (dom.nodeType == 1) return dom.getClientRects();else return [];
  } // Scans forward and backward through DOM positions equivalent to the
  // given one to see if the two are in the same place (i.e. after a
  // text node vs at the end of that text node)


  function isEquivalentPosition(node, off, targetNode, targetOff) {
    return targetNode ? scanFor(node, off, targetNode, targetOff, -1) || scanFor(node, off, targetNode, targetOff, 1) : false;
  }

  function domIndex(node) {
    for (var index = 0;; index++) {
      node = node.previousSibling;
      if (!node) return index;
    }
  }

  function scanFor(node, off, targetNode, targetOff, dir) {
    for (;;) {
      if (node == targetNode && off == targetOff) return true;

      if (off == (dir < 0 ? 0 : maxOffset(node))) {
        if (node.nodeName == "DIV") return false;
        let parent = node.parentNode;
        if (!parent || parent.nodeType != 1) return false;
        off = domIndex(node) + (dir < 0 ? 0 : 1);
        node = parent;
      } else if (node.nodeType == 1) {
        node = node.childNodes[off + (dir < 0 ? -1 : 0)];
        if (node.nodeType == 1 && node.contentEditable == "false") return false;
        off = dir < 0 ? maxOffset(node) : 0;
      } else {
        return false;
      }
    }
  }

  function maxOffset(node) {
    return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
  }

  const Rect0 = {
    left: 0,
    right: 0,
    top: 0,
    bottom: 0
  };

  function flattenRect(rect, left) {
    let x = left ? rect.left : rect.right;
    return {
      left: x,
      right: x,
      top: rect.top,
      bottom: rect.bottom
    };
  }

  function windowRect(win) {
    return {
      left: 0,
      right: win.innerWidth,
      top: 0,
      bottom: win.innerHeight
    };
  }

  function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
    let doc = dom.ownerDocument,
        win = doc.defaultView || window;

    for (let cur = dom; cur;) {
      if (cur.nodeType == 1) {
        // Element
        let bounding,
            top = cur == doc.body;

        if (top) {
          bounding = windowRect(win);
        } else {
          if (cur.scrollHeight <= cur.clientHeight && cur.scrollWidth <= cur.clientWidth) {
            cur = cur.assignedSlot || cur.parentNode;
            continue;
          }

          let rect = cur.getBoundingClientRect(); // Make sure scrollbar width isn't included in the rectangle

          bounding = {
            left: rect.left,
            right: rect.left + cur.clientWidth,
            top: rect.top,
            bottom: rect.top + cur.clientHeight
          };
        }

        let moveX = 0,
            moveY = 0;

        if (y == "nearest") {
          if (rect.top < bounding.top) {
            moveY = -(bounding.top - rect.top + yMargin);
            if (side > 0 && rect.bottom > bounding.bottom + moveY) moveY = rect.bottom - bounding.bottom + moveY + yMargin;
          } else if (rect.bottom > bounding.bottom) {
            moveY = rect.bottom - bounding.bottom + yMargin;
            if (side < 0 && rect.top - moveY < bounding.top) moveY = -(bounding.top + moveY - rect.top + yMargin);
          }
        } else {
          let rectHeight = rect.bottom - rect.top,
              boundingHeight = bounding.bottom - bounding.top;
          let targetTop = y == "center" && rectHeight <= boundingHeight ? rect.top + rectHeight / 2 - boundingHeight / 2 : y == "start" || y == "center" && side < 0 ? rect.top - yMargin : rect.bottom - boundingHeight + yMargin;
          moveY = targetTop - bounding.top;
        }

        if (x == "nearest") {
          if (rect.left < bounding.left) {
            moveX = -(bounding.left - rect.left + xMargin);
            if (side > 0 && rect.right > bounding.right + moveX) moveX = rect.right - bounding.right + moveX + xMargin;
          } else if (rect.right > bounding.right) {
            moveX = rect.right - bounding.right + xMargin;
            if (side < 0 && rect.left < bounding.left + moveX) moveX = -(bounding.left + moveX - rect.left + xMargin);
          }
        } else {
          let targetLeft = x == "center" ? rect.left + (rect.right - rect.left) / 2 - (bounding.right - bounding.left) / 2 : x == "start" == ltr ? rect.left - xMargin : rect.right - (bounding.right - bounding.left) + xMargin;
          moveX = targetLeft - bounding.left;
        }

        if (moveX || moveY) {
          if (top) {
            win.scrollBy(moveX, moveY);
          } else {
            let movedX = 0,
                movedY = 0;

            if (moveY) {
              let start = cur.scrollTop;
              cur.scrollTop += moveY;
              movedY = cur.scrollTop - start;
            }

            if (moveX) {
              let start = cur.scrollLeft;
              cur.scrollLeft += moveX;
              movedX = cur.scrollLeft - start;
            }

            rect = {
              left: rect.left - movedX,
              top: rect.top - movedY,
              right: rect.right - movedX,
              bottom: rect.bottom - movedY
            };
            if (movedX && Math.abs(movedX - moveX) < 1) x = "nearest";
            if (movedY && Math.abs(movedY - moveY) < 1) y = "nearest";
          }
        }

        if (top) break;
        cur = cur.assignedSlot || cur.parentNode;
      } else if (cur.nodeType == 11) {
        // A shadow root
        cur = cur.host;
      } else {
        break;
      }
    }
  }

  class DOMSelectionState {
    constructor() {
      this.anchorNode = null;
      this.anchorOffset = 0;
      this.focusNode = null;
      this.focusOffset = 0;
    }

    eq(domSel) {
      return this.anchorNode == domSel.anchorNode && this.anchorOffset == domSel.anchorOffset && this.focusNode == domSel.focusNode && this.focusOffset == domSel.focusOffset;
    }

    setRange(range) {
      this.set(range.anchorNode, range.anchorOffset, range.focusNode, range.focusOffset);
    }

    set(anchorNode, anchorOffset, focusNode, focusOffset) {
      this.anchorNode = anchorNode;
      this.anchorOffset = anchorOffset;
      this.focusNode = focusNode;
      this.focusOffset = focusOffset;
    }

  }

  let preventScrollSupported = null; // Feature-detects support for .focus({preventScroll: true}), and uses
  // a fallback kludge when not supported.

  function focusPreventScroll(dom) {
    if (dom.setActive) return dom.setActive(); // in IE

    if (preventScrollSupported) return dom.focus(preventScrollSupported);
    let stack = [];

    for (let cur = dom; cur; cur = cur.parentNode) {
      stack.push(cur, cur.scrollTop, cur.scrollLeft);
      if (cur == cur.ownerDocument) break;
    }

    dom.focus(preventScrollSupported == null ? {
      get preventScroll() {
        preventScrollSupported = {
          preventScroll: true
        };
        return true;
      }

    } : undefined);

    if (!preventScrollSupported) {
      preventScrollSupported = false;

      for (let i = 0; i < stack.length;) {
        let elt = stack[i++],
            top = stack[i++],
            left = stack[i++];
        if (elt.scrollTop != top) elt.scrollTop = top;
        if (elt.scrollLeft != left) elt.scrollLeft = left;
      }
    }
  }

  let scratchRange;

  function textRange(node, from, to = from) {
    let range = scratchRange || (scratchRange = document.createRange());
    range.setEnd(node, to);
    range.setStart(node, from);
    return range;
  }

  function dispatchKey(elt, name, code) {
    let options = {
      key: name,
      code: name,
      keyCode: code,
      which: code,
      cancelable: true
    };
    let down = new KeyboardEvent("keydown", options);
    down.synthetic = true;
    elt.dispatchEvent(down);
    let up = new KeyboardEvent("keyup", options);
    up.synthetic = true;
    elt.dispatchEvent(up);
    return down.defaultPrevented || up.defaultPrevented;
  }

  function getRoot$1(node) {
    while (node) {
      if (node && (node.nodeType == 9 || node.nodeType == 11 && node.host)) return node;
      node = node.assignedSlot || node.parentNode;
    }

    return null;
  }

  function clearAttributes(node) {
    while (node.attributes.length) node.removeAttributeNode(node.attributes[0]);
  }

  function atElementStart(doc, selection) {
    let node = selection.focusNode,
        offset = selection.focusOffset;
    if (!node || selection.anchorNode != node || selection.anchorOffset != offset) return false;

    for (;;) {
      if (offset) {
        if (node.nodeType != 1) return false;
        let prev = node.childNodes[offset - 1];
        if (prev.contentEditable == "false") offset--;else {
          node = prev;
          offset = maxOffset(node);
        }
      } else if (node == doc) {
        return true;
      } else {
        offset = domIndex(node);
        node = node.parentNode;
      }
    }
  }

  class DOMPos {
    constructor(node, offset, precise = true) {
      this.node = node;
      this.offset = offset;
      this.precise = precise;
    }

    static before(dom, precise) {
      return new DOMPos(dom.parentNode, domIndex(dom), precise);
    }

    static after(dom, precise) {
      return new DOMPos(dom.parentNode, domIndex(dom) + 1, precise);
    }

  }

  const noChildren = [];

  class ContentView {
    constructor() {
      this.parent = null;
      this.dom = null;
      this.dirty = 2
      /* Dirty.Node */
      ;
    }

    get editorView() {
      if (!this.parent) throw new Error("Accessing view in orphan content view");
      return this.parent.editorView;
    }

    get overrideDOMText() {
      return null;
    }

    get posAtStart() {
      return this.parent ? this.parent.posBefore(this) : 0;
    }

    get posAtEnd() {
      return this.posAtStart + this.length;
    }

    posBefore(view) {
      let pos = this.posAtStart;

      for (let child of this.children) {
        if (child == view) return pos;
        pos += child.length + child.breakAfter;
      }

      throw new RangeError("Invalid child in posBefore");
    }

    posAfter(view) {
      return this.posBefore(view) + view.length;
    } // Will return a rectangle directly before (when side < 0), after
    // (side > 0) or directly on (when the browser supports it) the
    // given position.


    coordsAt(_pos, _side) {
      return null;
    }

    sync(track) {
      if (this.dirty & 2
      /* Dirty.Node */
      ) {
        let parent = this.dom;
        let prev = null,
            next;

        for (let child of this.children) {
          if (child.dirty) {
            if (!child.dom && (next = prev ? prev.nextSibling : parent.firstChild)) {
              let contentView = ContentView.get(next);
              if (!contentView || !contentView.parent && contentView.canReuseDOM(child)) child.reuseDOM(next);
            }

            child.sync(track);
            child.dirty = 0
            /* Dirty.Not */
            ;
          }

          next = prev ? prev.nextSibling : parent.firstChild;
          if (track && !track.written && track.node == parent && next != child.dom) track.written = true;

          if (child.dom.parentNode == parent) {
            while (next && next != child.dom) next = rm$1(next);
          } else {
            parent.insertBefore(child.dom, next);
          }

          prev = child.dom;
        }

        next = prev ? prev.nextSibling : parent.firstChild;
        if (next && track && track.node == parent) track.written = true;

        while (next) next = rm$1(next);
      } else if (this.dirty & 1
      /* Dirty.Child */
      ) {
        for (let child of this.children) if (child.dirty) {
          child.sync(track);
          child.dirty = 0
          /* Dirty.Not */
          ;
        }
      }
    }

    reuseDOM(_dom) {}

    localPosFromDOM(node, offset) {
      let after;

      if (node == this.dom) {
        after = this.dom.childNodes[offset];
      } else {
        let bias = maxOffset(node) == 0 ? 0 : offset == 0 ? -1 : 1;

        for (;;) {
          let parent = node.parentNode;
          if (parent == this.dom) break;

          if (bias == 0 && parent.firstChild != parent.lastChild) {
            if (node == parent.firstChild) bias = -1;else bias = 1;
          }

          node = parent;
        }

        if (bias < 0) after = node;else after = node.nextSibling;
      }

      if (after == this.dom.firstChild) return 0;

      while (after && !ContentView.get(after)) after = after.nextSibling;

      if (!after) return this.length;

      for (let i = 0, pos = 0;; i++) {
        let child = this.children[i];
        if (child.dom == after) return pos;
        pos += child.length + child.breakAfter;
      }
    }

    domBoundsAround(from, to, offset = 0) {
      let fromI = -1,
          fromStart = -1,
          toI = -1,
          toEnd = -1;

      for (let i = 0, pos = offset, prevEnd = offset; i < this.children.length; i++) {
        let child = this.children[i],
            end = pos + child.length;
        if (pos < from && end > to) return child.domBoundsAround(from, to, pos);

        if (end >= from && fromI == -1) {
          fromI = i;
          fromStart = pos;
        }

        if (pos > to && child.dom.parentNode == this.dom) {
          toI = i;
          toEnd = prevEnd;
          break;
        }

        prevEnd = end;
        pos = end + child.breakAfter;
      }

      return {
        from: fromStart,
        to: toEnd < 0 ? offset + this.length : toEnd,
        startDOM: (fromI ? this.children[fromI - 1].dom.nextSibling : null) || this.dom.firstChild,
        endDOM: toI < this.children.length && toI >= 0 ? this.children[toI].dom : null
      };
    }

    markDirty(andParent = false) {
      this.dirty |= 2
      /* Dirty.Node */
      ;
      this.markParentsDirty(andParent);
    }

    markParentsDirty(childList) {
      for (let parent = this.parent; parent; parent = parent.parent) {
        if (childList) parent.dirty |= 2
        /* Dirty.Node */
        ;
        if (parent.dirty & 1
        /* Dirty.Child */
        ) return;
        parent.dirty |= 1
        /* Dirty.Child */
        ;
        childList = false;
      }
    }

    setParent(parent) {
      if (this.parent != parent) {
        this.parent = parent;
        if (this.dirty) this.markParentsDirty(true);
      }
    }

    setDOM(dom) {
      if (this.dom) this.dom.cmView = null;
      this.dom = dom;
      dom.cmView = this;
    }

    get rootView() {
      for (let v = this;;) {
        let parent = v.parent;
        if (!parent) return v;
        v = parent;
      }
    }

    replaceChildren(from, to, children = noChildren) {
      this.markDirty();

      for (let i = from; i < to; i++) {
        let child = this.children[i];
        if (child.parent == this) child.destroy();
      }

      this.children.splice(from, to - from, ...children);

      for (let i = 0; i < children.length; i++) children[i].setParent(this);
    }

    ignoreMutation(_rec) {
      return false;
    }

    ignoreEvent(_event) {
      return false;
    }

    childCursor(pos = this.length) {
      return new ChildCursor(this.children, pos, this.children.length);
    }

    childPos(pos, bias = 1) {
      return this.childCursor().findPos(pos, bias);
    }

    toString() {
      let name = this.constructor.name.replace("View", "");
      return name + (this.children.length ? "(" + this.children.join() + ")" : this.length ? "[" + (name == "Text" ? this.text : this.length) + "]" : "") + (this.breakAfter ? "#" : "");
    }

    static get(node) {
      return node.cmView;
    }

    get isEditable() {
      return true;
    }

    merge(from, to, source, hasStart, openStart, openEnd) {
      return false;
    }

    become(other) {
      return false;
    }

    canReuseDOM(other) {
      return other.constructor == this.constructor;
    } // When this is a zero-length view with a side, this should return a
    // number <= 0 to indicate it is before its position, or a
    // number > 0 when after its position.


    getSide() {
      return 0;
    }

    destroy() {
      this.parent = null;
    }

  }

  ContentView.prototype.breakAfter = 0; // Remove a DOM node and return its next sibling.

  function rm$1(dom) {
    let next = dom.nextSibling;
    dom.parentNode.removeChild(dom);
    return next;
  }

  class ChildCursor {
    constructor(children, pos, i) {
      this.children = children;
      this.pos = pos;
      this.i = i;
      this.off = 0;
    }

    findPos(pos, bias = 1) {
      for (;;) {
        if (pos > this.pos || pos == this.pos && (bias > 0 || this.i == 0 || this.children[this.i - 1].breakAfter)) {
          this.off = pos - this.pos;
          return this;
        }

        let next = this.children[--this.i];
        this.pos -= next.length + next.breakAfter;
      }
    }

  }

  function replaceRange(parent, fromI, fromOff, toI, toOff, insert, breakAtStart, openStart, openEnd) {
    let {
      children
    } = parent;
    let before = children.length ? children[fromI] : null;
    let last = insert.length ? insert[insert.length - 1] : null;
    let breakAtEnd = last ? last.breakAfter : breakAtStart; // Change within a single child

    if (fromI == toI && before && !breakAtStart && !breakAtEnd && insert.length < 2 && before.merge(fromOff, toOff, insert.length ? last : null, fromOff == 0, openStart, openEnd)) return;

    if (toI < children.length) {
      let after = children[toI]; // Make sure the end of the child after the update is preserved in `after`

      if (after && toOff < after.length) {
        // If we're splitting a child, separate part of it to avoid that
        // being mangled when updating the child before the update.
        if (fromI == toI) {
          after = after.split(toOff);
          toOff = 0;
        } // If the element after the replacement should be merged with
        // the last replacing element, update `content`


        if (!breakAtEnd && last && after.merge(0, toOff, last, true, 0, openEnd)) {
          insert[insert.length - 1] = after;
        } else {
          // Remove the start of the after element, if necessary, and
          // add it to `content`.
          if (toOff) after.merge(0, toOff, null, false, 0, openEnd);
          insert.push(after);
        }
      } else if (after === null || after === void 0 ? void 0 : after.breakAfter) {
        // The element at `toI` is entirely covered by this range.
        // Preserve its line break, if any.
        if (last) last.breakAfter = 1;else breakAtStart = 1;
      } // Since we've handled the next element from the current elements
      // now, make sure `toI` points after that.


      toI++;
    }

    if (before) {
      before.breakAfter = breakAtStart;

      if (fromOff > 0) {
        if (!breakAtStart && insert.length && before.merge(fromOff, before.length, insert[0], false, openStart, 0)) {
          before.breakAfter = insert.shift().breakAfter;
        } else if (fromOff < before.length || before.children.length && before.children[before.children.length - 1].length == 0) {
          before.merge(fromOff, before.length, null, false, openStart, 0);
        }

        fromI++;
      }
    } // Try to merge widgets on the boundaries of the replacement


    while (fromI < toI && insert.length) {
      if (children[toI - 1].become(insert[insert.length - 1])) {
        toI--;
        insert.pop();
        openEnd = insert.length ? 0 : openStart;
      } else if (children[fromI].become(insert[0])) {
        fromI++;
        insert.shift();
        openStart = insert.length ? 0 : openEnd;
      } else {
        break;
      }
    }

    if (!insert.length && fromI && toI < children.length && !children[fromI - 1].breakAfter && children[toI].merge(0, 0, children[fromI - 1], false, openStart, openEnd)) fromI--;
    if (fromI < toI || insert.length) parent.replaceChildren(fromI, toI, insert);
  }

  function mergeChildrenInto(parent, from, to, insert, openStart, openEnd) {
    let cur = parent.childCursor();
    let {
      i: toI,
      off: toOff
    } = cur.findPos(to, 1);
    let {
      i: fromI,
      off: fromOff
    } = cur.findPos(from, -1);
    let dLen = from - to;

    for (let view of insert) dLen += view.length;

    parent.length += dLen;
    replaceRange(parent, fromI, fromOff, toI, toOff, insert, 0, openStart, openEnd);
  }

  let nav = typeof navigator != "undefined" ? navigator : {
    userAgent: "",
    vendor: "",
    platform: ""
  };
  let doc = typeof document != "undefined" ? document : {
    documentElement: {
      style: {}
    }
  };
  const ie_edge = /*@__PURE__*/ /Edge\/(\d+)/.exec(nav.userAgent);
  const ie_upto10 = /*@__PURE__*/ /MSIE \d/.test(nav.userAgent);
  const ie_11up = /*@__PURE__*/ /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nav.userAgent);
  const ie = !!(ie_upto10 || ie_11up || ie_edge);
  const gecko = !ie && /*@__PURE__*/ /gecko\/(\d+)/i.test(nav.userAgent);
  const chrome = !ie && /*@__PURE__*/ /Chrome\/(\d+)/.exec(nav.userAgent);
  const webkit = ("webkitFontSmoothing" in doc.documentElement.style);
  const safari = !ie && /*@__PURE__*/ /Apple Computer/.test(nav.vendor);
  const ios = safari && ( /*@__PURE__*/ /Mobile\/\w+/.test(nav.userAgent) || nav.maxTouchPoints > 2);
  var browser = {
    mac: ios || /*@__PURE__*/ /Mac/.test(nav.platform),
    windows: /*@__PURE__*/ /Win/.test(nav.platform),
    linux: /*@__PURE__*/ /Linux|X11/.test(nav.platform),
    ie,
    ie_version: ie_upto10 ? doc.documentMode || 6 : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : 0,
    gecko,
    gecko_version: gecko ? +( /*@__PURE__*/ /Firefox\/(\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,
    chrome: !!chrome,
    chrome_version: chrome ? +chrome[1] : 0,
    ios,
    android: /*@__PURE__*/ /Android\b/.test(nav.userAgent),
    webkit,
    safari,
    webkit_version: webkit ? +( /*@__PURE__*/ /\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0,
    tabSize: doc.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
  };
  const MaxJoinLen = 256;

  class TextView extends ContentView {
    constructor(text) {
      super();
      this.text = text;
    }

    get length() {
      return this.text.length;
    }

    createDOM(textDOM) {
      this.setDOM(textDOM || document.createTextNode(this.text));
    }

    sync(track) {
      if (!this.dom) this.createDOM();

      if (this.dom.nodeValue != this.text) {
        if (track && track.node == this.dom) track.written = true;
        this.dom.nodeValue = this.text;
      }
    }

    reuseDOM(dom) {
      if (dom.nodeType == 3) this.createDOM(dom);
    }

    merge(from, to, source) {
      if (source && (!(source instanceof TextView) || this.length - (to - from) + source.length > MaxJoinLen)) return false;
      this.text = this.text.slice(0, from) + (source ? source.text : "") + this.text.slice(to);
      this.markDirty();
      return true;
    }

    split(from) {
      let result = new TextView(this.text.slice(from));
      this.text = this.text.slice(0, from);
      this.markDirty();
      return result;
    }

    localPosFromDOM(node, offset) {
      return node == this.dom ? offset : offset ? this.text.length : 0;
    }

    domAtPos(pos) {
      return new DOMPos(this.dom, pos);
    }

    domBoundsAround(_from, _to, offset) {
      return {
        from: offset,
        to: offset + this.length,
        startDOM: this.dom,
        endDOM: this.dom.nextSibling
      };
    }

    coordsAt(pos, side) {
      return textCoords(this.dom, pos, side);
    }

  }

  class MarkView extends ContentView {
    constructor(mark, children = [], length = 0) {
      super();
      this.mark = mark;
      this.children = children;
      this.length = length;

      for (let ch of children) ch.setParent(this);
    }

    setAttrs(dom) {
      clearAttributes(dom);
      if (this.mark.class) dom.className = this.mark.class;
      if (this.mark.attrs) for (let name in this.mark.attrs) dom.setAttribute(name, this.mark.attrs[name]);
      return dom;
    }

    reuseDOM(node) {
      if (node.nodeName == this.mark.tagName.toUpperCase()) {
        this.setDOM(node);
        this.dirty |= 4
        /* Dirty.Attrs */
        | 2
        /* Dirty.Node */
        ;
      }
    }

    sync(track) {
      if (!this.dom) this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));else if (this.dirty & 4
      /* Dirty.Attrs */
      ) this.setAttrs(this.dom);
      super.sync(track);
    }

    merge(from, to, source, _hasStart, openStart, openEnd) {
      if (source && (!(source instanceof MarkView && source.mark.eq(this.mark)) || from && openStart <= 0 || to < this.length && openEnd <= 0)) return false;
      mergeChildrenInto(this, from, to, source ? source.children : [], openStart - 1, openEnd - 1);
      this.markDirty();
      return true;
    }

    split(from) {
      let result = [],
          off = 0,
          detachFrom = -1,
          i = 0;

      for (let elt of this.children) {
        let end = off + elt.length;
        if (end > from) result.push(off < from ? elt.split(from - off) : elt);
        if (detachFrom < 0 && off >= from) detachFrom = i;
        off = end;
        i++;
      }

      let length = this.length - from;
      this.length = from;

      if (detachFrom > -1) {
        this.children.length = detachFrom;
        this.markDirty();
      }

      return new MarkView(this.mark, result, length);
    }

    domAtPos(pos) {
      return inlineDOMAtPos(this, pos);
    }

    coordsAt(pos, side) {
      return coordsInChildren(this, pos, side);
    }

  }

  function textCoords(text, pos, side) {
    let length = text.nodeValue.length;
    if (pos > length) pos = length;
    let from = pos,
        to = pos,
        flatten = 0;

    if (pos == 0 && side < 0 || pos == length && side >= 0) {
      if (!(browser.chrome || browser.gecko)) {
        // These browsers reliably return valid rectangles for empty ranges
        if (pos) {
          from--;
          flatten = 1;
        } // FIXME this is wrong in RTL text
        else if (to < length) {
          to++;
          flatten = -1;
        }
      }
    } else {
      if (side < 0) from--;else if (to < length) to++;
    }

    let rects = textRange(text, from, to).getClientRects();
    if (!rects.length) return Rect0;
    let rect = rects[(flatten ? flatten < 0 : side >= 0) ? 0 : rects.length - 1];
    if (browser.safari && !flatten && rect.width == 0) rect = Array.prototype.find.call(rects, r => r.width) || rect;
    return flatten ? flattenRect(rect, flatten < 0) : rect || null;
  } // Also used for collapsed ranges that don't have a placeholder widget!


  class WidgetView extends ContentView {
    constructor(widget, length, side) {
      super();
      this.widget = widget;
      this.length = length;
      this.side = side;
      this.prevWidget = null;
    }

    static create(widget, length, side) {
      return new (widget.customView || WidgetView)(widget, length, side);
    }

    split(from) {
      let result = WidgetView.create(this.widget, this.length - from, this.side);
      this.length -= from;
      return result;
    }

    sync() {
      if (!this.dom || !this.widget.updateDOM(this.dom)) {
        if (this.dom && this.prevWidget) this.prevWidget.destroy(this.dom);
        this.prevWidget = null;
        this.setDOM(this.widget.toDOM(this.editorView));
        this.dom.contentEditable = "false";
      }
    }

    getSide() {
      return this.side;
    }

    merge(from, to, source, hasStart, openStart, openEnd) {
      if (source && (!(source instanceof WidgetView) || !this.widget.compare(source.widget) || from > 0 && openStart <= 0 || to < this.length && openEnd <= 0)) return false;
      this.length = from + (source ? source.length : 0) + (this.length - to);
      return true;
    }

    become(other) {
      if (other.length == this.length && other instanceof WidgetView && other.side == this.side) {
        if (this.widget.constructor == other.widget.constructor) {
          if (!this.widget.eq(other.widget)) this.markDirty(true);
          if (this.dom && !this.prevWidget) this.prevWidget = this.widget;
          this.widget = other.widget;
          return true;
        }
      }

      return false;
    }

    ignoreMutation() {
      return true;
    }

    ignoreEvent(event) {
      return this.widget.ignoreEvent(event);
    }

    get overrideDOMText() {
      if (this.length == 0) return Text.empty;
      let top = this;

      while (top.parent) top = top.parent;

      let view = top.editorView,
          text = view && view.state.doc,
          start = this.posAtStart;
      return text ? text.slice(start, start + this.length) : Text.empty;
    }

    domAtPos(pos) {
      return pos == 0 ? DOMPos.before(this.dom) : DOMPos.after(this.dom, pos == this.length);
    }

    domBoundsAround() {
      return null;
    }

    coordsAt(pos, side) {
      let rects = this.dom.getClientRects(),
          rect = null;
      if (!rects.length) return Rect0;

      for (let i = pos > 0 ? rects.length - 1 : 0;; i += pos > 0 ? -1 : 1) {
        rect = rects[i];
        if (pos > 0 ? i == 0 : i == rects.length - 1 || rect.top < rect.bottom) break;
      }

      return pos == 0 && side > 0 || pos == this.length && side <= 0 ? rect : flattenRect(rect, pos == 0);
    }

    get isEditable() {
      return false;
    }

    destroy() {
      super.destroy();
      if (this.dom) this.widget.destroy(this.dom);
    }

  }

  class CompositionView extends WidgetView {
    domAtPos(pos) {
      let {
        topView,
        text
      } = this.widget;
      if (!topView) return new DOMPos(text, Math.min(pos, text.nodeValue.length));
      return scanCompositionTree(pos, 0, topView, text, (v, p) => v.domAtPos(p), p => new DOMPos(text, Math.min(p, text.nodeValue.length)));
    }

    sync() {
      this.setDOM(this.widget.toDOM());
    }

    localPosFromDOM(node, offset) {
      let {
        topView,
        text
      } = this.widget;
      if (!topView) return Math.min(offset, this.length);
      return posFromDOMInCompositionTree(node, offset, topView, text);
    }

    ignoreMutation() {
      return false;
    }

    get overrideDOMText() {
      return null;
    }

    coordsAt(pos, side) {
      let {
        topView,
        text
      } = this.widget;
      if (!topView) return textCoords(text, pos, side);
      return scanCompositionTree(pos, side, topView, text, (v, pos, side) => v.coordsAt(pos, side), (pos, side) => textCoords(text, pos, side));
    }

    destroy() {
      var _a;

      super.destroy();
      (_a = this.widget.topView) === null || _a === void 0 ? void 0 : _a.destroy();
    }

    get isEditable() {
      return true;
    }

    canReuseDOM() {
      return true;
    }

  } // Uses the old structure of a chunk of content view frozen for
  // composition to try and find a reasonable DOM location for the given
  // offset.


  function scanCompositionTree(pos, side, view, text, enterView, fromText) {
    if (view instanceof MarkView) {
      for (let child = view.dom.firstChild; child; child = child.nextSibling) {
        let desc = ContentView.get(child);
        if (!desc) return fromText(pos, side);
        let hasComp = contains(child, text);
        let len = desc.length + (hasComp ? text.nodeValue.length : 0);
        if (pos < len || pos == len && desc.getSide() <= 0) return hasComp ? scanCompositionTree(pos, side, desc, text, enterView, fromText) : enterView(desc, pos, side);
        pos -= len;
      }

      return enterView(view, view.length, -1);
    } else if (view.dom == text) {
      return fromText(pos, side);
    } else {
      return enterView(view, pos, side);
    }
  }

  function posFromDOMInCompositionTree(node, offset, view, text) {
    if (view instanceof MarkView) {
      for (let child of view.children) {
        let pos = 0,
            hasComp = contains(child.dom, text);
        if (contains(child.dom, node)) return pos + (hasComp ? posFromDOMInCompositionTree(node, offset, child, text) : child.localPosFromDOM(node, offset));
        pos += hasComp ? text.nodeValue.length : child.length;
      }
    } else if (view.dom == text) {
      return Math.min(offset, text.nodeValue.length);
    }

    return view.localPosFromDOM(node, offset);
  } // These are drawn around uneditable widgets to avoid a number of
  // browser bugs that show up when the cursor is directly next to
  // uneditable inline content.


  class WidgetBufferView extends ContentView {
    constructor(side) {
      super();
      this.side = side;
    }

    get length() {
      return 0;
    }

    merge() {
      return false;
    }

    become(other) {
      return other instanceof WidgetBufferView && other.side == this.side;
    }

    split() {
      return new WidgetBufferView(this.side);
    }

    sync() {
      if (!this.dom) {
        let dom = document.createElement("img");
        dom.className = "cm-widgetBuffer";
        dom.setAttribute("aria-hidden", "true");
        this.setDOM(dom);
      }
    }

    getSide() {
      return this.side;
    }

    domAtPos(pos) {
      return DOMPos.before(this.dom);
    }

    localPosFromDOM() {
      return 0;
    }

    domBoundsAround() {
      return null;
    }

    coordsAt(pos) {
      let imgRect = this.dom.getBoundingClientRect(); // Since the <img> height doesn't correspond to text height, try
      // to borrow the height from some sibling node.

      let siblingRect = inlineSiblingRect(this, this.side > 0 ? -1 : 1);
      return siblingRect && siblingRect.top < imgRect.bottom && siblingRect.bottom > imgRect.top ? {
        left: imgRect.left,
        right: imgRect.right,
        top: siblingRect.top,
        bottom: siblingRect.bottom
      } : imgRect;
    }

    get overrideDOMText() {
      return Text.empty;
    }

  }

  TextView.prototype.children = WidgetView.prototype.children = WidgetBufferView.prototype.children = noChildren;

  function inlineSiblingRect(view, side) {
    let parent = view.parent,
        index = parent ? parent.children.indexOf(view) : -1;

    while (parent && index >= 0) {
      if (side < 0 ? index > 0 : index < parent.children.length) {
        let next = parent.children[index + side];

        if (next instanceof TextView) {
          let nextRect = next.coordsAt(side < 0 ? next.length : 0, side);
          if (nextRect) return nextRect;
        }

        index += side;
      } else if (parent instanceof MarkView && parent.parent) {
        index = parent.parent.children.indexOf(parent) + (side < 0 ? 0 : 1);
        parent = parent.parent;
      } else {
        let last = parent.dom.lastChild;
        if (last && last.nodeName == "BR") return last.getClientRects()[0];
        break;
      }
    }

    return undefined;
  }

  function inlineDOMAtPos(parent, pos) {
    let dom = parent.dom,
        {
      children
    } = parent,
        i = 0;

    for (let off = 0; i < children.length; i++) {
      let child = children[i],
          end = off + child.length;
      if (end == off && child.getSide() <= 0) continue;
      if (pos > off && pos < end && child.dom.parentNode == dom) return child.domAtPos(pos - off);
      if (pos <= off) break;
      off = end;
    } //  if (i) return DOMPos.after(children[i - 1].dom!)


    for (let j = i; j > 0; j--) {
      let prev = children[j - 1];
      if (prev.dom.parentNode == dom) return prev.domAtPos(prev.length);
    }

    for (let j = i; j < children.length; j++) {
      let next = children[j];
      if (next.dom.parentNode == dom) return next.domAtPos(0);
    }

    return new DOMPos(dom, 0);
  } // Assumes `view`, if a mark view, has precisely 1 child.


  function joinInlineInto(parent, view, open) {
    let last,
        {
      children
    } = parent;

    if (open > 0 && view instanceof MarkView && children.length && (last = children[children.length - 1]) instanceof MarkView && last.mark.eq(view.mark)) {
      joinInlineInto(last, view.children[0], open - 1);
    } else {
      children.push(view);
      view.setParent(parent);
    }

    parent.length += view.length;
  }

  function coordsInChildren(view, pos, side) {
    for (let off = 0, i = 0; i < view.children.length; i++) {
      let child = view.children[i],
          end = off + child.length,
          next;

      if ((side <= 0 || end == view.length || child.getSide() > 0 ? end >= pos : end > pos) && (pos < end || i + 1 == view.children.length || (next = view.children[i + 1]).length || next.getSide() > 0)) {
        let flatten = 0;

        if (end == off) {
          if (child.getSide() <= 0) continue;
          flatten = side = -child.getSide();
        }

        let rect = child.coordsAt(Math.max(0, pos - off), side);
        return flatten && rect ? flattenRect(rect, side < 0) : rect;
      }

      off = end;
    }

    let last = view.dom.lastChild;
    if (!last) return view.dom.getBoundingClientRect();
    let rects = clientRectsFor(last);
    return rects[rects.length - 1] || null;
  }

  function combineAttrs(source, target) {
    for (let name in source) {
      if (name == "class" && target.class) target.class += " " + source.class;else if (name == "style" && target.style) target.style += ";" + source.style;else target[name] = source[name];
    }

    return target;
  }

  function attrsEq(a, b) {
    if (a == b) return true;
    if (!a || !b) return false;
    let keysA = Object.keys(a),
        keysB = Object.keys(b);
    if (keysA.length != keysB.length) return false;

    for (let key of keysA) {
      if (keysB.indexOf(key) == -1 || a[key] !== b[key]) return false;
    }

    return true;
  }

  function updateAttrs(dom, prev, attrs) {
    let changed = null;
    if (prev) for (let name in prev) if (!(attrs && name in attrs)) dom.removeAttribute(changed = name);
    if (attrs) for (let name in attrs) if (!(prev && prev[name] == attrs[name])) dom.setAttribute(changed = name, attrs[name]);
    return !!changed;
  }
  /**
  Widgets added to the content are described by subclasses of this
  class. Using a description object like that makes it possible to
  delay creating of the DOM structure for a widget until it is
  needed, and to avoid redrawing widgets even if the decorations
  that define them are recreated.
  */


  class WidgetType {
    /**
    Compare this instance to another instance of the same type.
    (TypeScript can't express this, but only instances of the same
    specific class will be passed to this method.) This is used to
    avoid redrawing widgets when they are replaced by a new
    decoration of the same type. The default implementation just
    returns `false`, which will cause new instances of the widget to
    always be redrawn.
    */
    eq(widget) {
      return false;
    }
    /**
    Update a DOM element created by a widget of the same type (but
    different, non-`eq` content) to reflect this widget. May return
    true to indicate that it could update, false to indicate it
    couldn't (in which case the widget will be redrawn). The default
    implementation just returns false.
    */


    updateDOM(dom) {
      return false;
    }
    /**
    @internal
    */


    compare(other) {
      return this == other || this.constructor == other.constructor && this.eq(other);
    }
    /**
    The estimated height this widget will have, to be used when
    estimating the height of content that hasn't been drawn. May
    return -1 to indicate you don't know. The default implementation
    returns -1.
    */


    get estimatedHeight() {
      return -1;
    }
    /**
    Can be used to configure which kinds of events inside the widget
    should be ignored by the editor. The default is to ignore all
    events.
    */


    ignoreEvent(event) {
      return true;
    }
    /**
    @internal
    */


    get customView() {
      return null;
    }
    /**
    This is called when the an instance of the widget is removed
    from the editor view.
    */


    destroy(dom) {}

  }
  /**
  The different types of blocks that can occur in an editor view.
  */


  var BlockType = /*@__PURE__*/function (BlockType) {
    /**
    A line of text.
    */
    BlockType[BlockType["Text"] = 0] = "Text";
    /**
    A block widget associated with the position after it.
    */

    BlockType[BlockType["WidgetBefore"] = 1] = "WidgetBefore";
    /**
    A block widget associated with the position before it.
    */

    BlockType[BlockType["WidgetAfter"] = 2] = "WidgetAfter";
    /**
    A block widget [replacing](https://codemirror.net/6/docs/ref/#view.Decoration^replace) a range of content.
    */

    BlockType[BlockType["WidgetRange"] = 3] = "WidgetRange";
    return BlockType;
  }(BlockType || (BlockType = {}));
  /**
  A decoration provides information on how to draw or style a piece
  of content. You'll usually use it wrapped in a
  [`Range`](https://codemirror.net/6/docs/ref/#state.Range), which adds a start and end position.
  @nonabstract
  */


  class Decoration extends RangeValue {
    constructor(
    /**
    @internal
    */
    startSide,
    /**
    @internal
    */
    endSide,
    /**
    @internal
    */
    widget,
    /**
    The config object used to create this decoration. You can
    include additional properties in there to store metadata about
    your decoration.
    */
    spec) {
      super();
      this.startSide = startSide;
      this.endSide = endSide;
      this.widget = widget;
      this.spec = spec;
    }
    /**
    @internal
    */


    get heightRelevant() {
      return false;
    }
    /**
    Create a mark decoration, which influences the styling of the
    content in its range. Nested mark decorations will cause nested
    DOM elements to be created. Nesting order is determined by
    precedence of the [facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), with
    the higher-precedence decorations creating the inner DOM nodes.
    Such elements are split on line boundaries and on the boundaries
    of lower-precedence decorations.
    */


    static mark(spec) {
      return new MarkDecoration(spec);
    }
    /**
    Create a widget decoration, which displays a DOM element at the
    given position.
    */


    static widget(spec) {
      let side = spec.side || 0,
          block = !!spec.block;
      side += block ? side > 0 ? 300000000
      /* Side.BlockAfter */
      : -400000000
      /* Side.BlockBefore */
      : side > 0 ? 100000000
      /* Side.InlineAfter */
      : -100000000
      /* Side.InlineBefore */
      ;
      return new PointDecoration(spec, side, side, block, spec.widget || null, false);
    }
    /**
    Create a replace decoration which replaces the given range with
    a widget, or simply hides it.
    */


    static replace(spec) {
      let block = !!spec.block,
          startSide,
          endSide;

      if (spec.isBlockGap) {
        startSide = -500000000
        /* Side.GapStart */
        ;
        endSide = 400000000
        /* Side.GapEnd */
        ;
      } else {
        let {
          start,
          end
        } = getInclusive(spec, block);
        startSide = (start ? block ? -300000000
        /* Side.BlockIncStart */
        : -1
        /* Side.InlineIncStart */
        : 500000000
        /* Side.NonIncStart */
        ) - 1;
        endSide = (end ? block ? 200000000
        /* Side.BlockIncEnd */
        : 1
        /* Side.InlineIncEnd */
        : -600000000
        /* Side.NonIncEnd */
        ) + 1;
      }

      return new PointDecoration(spec, startSide, endSide, block, spec.widget || null, true);
    }
    /**
    Create a line decoration, which can add DOM attributes to the
    line starting at the given position.
    */


    static line(spec) {
      return new LineDecoration(spec);
    }
    /**
    Build a [`DecorationSet`](https://codemirror.net/6/docs/ref/#view.DecorationSet) from the given
    decorated range or ranges. If the ranges aren't already sorted,
    pass `true` for `sort` to make the library sort them for you.
    */


    static set(of, sort = false) {
      return RangeSet.of(of, sort);
    }
    /**
    @internal
    */


    hasHeight() {
      return this.widget ? this.widget.estimatedHeight > -1 : false;
    }

  }
  /**
  The empty set of decorations.
  */


  Decoration.none = RangeSet.empty;

  class MarkDecoration extends Decoration {
    constructor(spec) {
      let {
        start,
        end
      } = getInclusive(spec);
      super(start ? -1
      /* Side.InlineIncStart */
      : 500000000
      /* Side.NonIncStart */
      , end ? 1
      /* Side.InlineIncEnd */
      : -600000000
      /* Side.NonIncEnd */
      , null, spec);
      this.tagName = spec.tagName || "span";
      this.class = spec.class || "";
      this.attrs = spec.attributes || null;
    }

    eq(other) {
      return this == other || other instanceof MarkDecoration && this.tagName == other.tagName && this.class == other.class && attrsEq(this.attrs, other.attrs);
    }

    range(from, to = from) {
      if (from >= to) throw new RangeError("Mark decorations may not be empty");
      return super.range(from, to);
    }

  }

  MarkDecoration.prototype.point = false;

  class LineDecoration extends Decoration {
    constructor(spec) {
      super(-200000000
      /* Side.Line */
      , -200000000
      /* Side.Line */
      , null, spec);
    }

    eq(other) {
      return other instanceof LineDecoration && attrsEq(this.spec.attributes, other.spec.attributes);
    }

    range(from, to = from) {
      if (to != from) throw new RangeError("Line decoration ranges must be zero-length");
      return super.range(from, to);
    }

  }

  LineDecoration.prototype.mapMode = MapMode.TrackBefore;
  LineDecoration.prototype.point = true;

  class PointDecoration extends Decoration {
    constructor(spec, startSide, endSide, block, widget, isReplace) {
      super(startSide, endSide, widget, spec);
      this.block = block;
      this.isReplace = isReplace;
      this.mapMode = !block ? MapMode.TrackDel : startSide <= 0 ? MapMode.TrackBefore : MapMode.TrackAfter;
    } // Only relevant when this.block == true


    get type() {
      return this.startSide < this.endSide ? BlockType.WidgetRange : this.startSide <= 0 ? BlockType.WidgetBefore : BlockType.WidgetAfter;
    }

    get heightRelevant() {
      return this.block || !!this.widget && this.widget.estimatedHeight >= 5;
    }

    eq(other) {
      return other instanceof PointDecoration && widgetsEq(this.widget, other.widget) && this.block == other.block && this.startSide == other.startSide && this.endSide == other.endSide;
    }

    range(from, to = from) {
      if (this.isReplace && (from > to || from == to && this.startSide > 0 && this.endSide <= 0)) throw new RangeError("Invalid range for replacement decoration");
      if (!this.isReplace && to != from) throw new RangeError("Widget decorations can only have zero-length ranges");
      return super.range(from, to);
    }

  }

  PointDecoration.prototype.point = true;

  function getInclusive(spec, block = false) {
    let {
      inclusiveStart: start,
      inclusiveEnd: end
    } = spec;
    if (start == null) start = spec.inclusive;
    if (end == null) end = spec.inclusive;
    return {
      start: start !== null && start !== void 0 ? start : block,
      end: end !== null && end !== void 0 ? end : block
    };
  }

  function widgetsEq(a, b) {
    return a == b || !!(a && b && a.compare(b));
  }

  function addRange(from, to, ranges, margin = 0) {
    let last = ranges.length - 1;
    if (last >= 0 && ranges[last] + margin >= from) ranges[last] = Math.max(ranges[last], to);else ranges.push(from, to);
  }

  class LineView extends ContentView {
    constructor() {
      super(...arguments);
      this.children = [];
      this.length = 0;
      this.prevAttrs = undefined;
      this.attrs = null;
      this.breakAfter = 0;
    } // Consumes source


    merge(from, to, source, hasStart, openStart, openEnd) {
      if (source) {
        if (!(source instanceof LineView)) return false;
        if (!this.dom) source.transferDOM(this); // Reuse source.dom when appropriate
      }

      if (hasStart) this.setDeco(source ? source.attrs : null);
      mergeChildrenInto(this, from, to, source ? source.children : [], openStart, openEnd);
      return true;
    }

    split(at) {
      let end = new LineView();
      end.breakAfter = this.breakAfter;
      if (this.length == 0) return end;
      let {
        i,
        off
      } = this.childPos(at);

      if (off) {
        end.append(this.children[i].split(off), 0);
        this.children[i].merge(off, this.children[i].length, null, false, 0, 0);
        i++;
      }

      for (let j = i; j < this.children.length; j++) end.append(this.children[j], 0);

      while (i > 0 && this.children[i - 1].length == 0) this.children[--i].destroy();

      this.children.length = i;
      this.markDirty();
      this.length = at;
      return end;
    }

    transferDOM(other) {
      if (!this.dom) return;
      this.markDirty();
      other.setDOM(this.dom);
      other.prevAttrs = this.prevAttrs === undefined ? this.attrs : this.prevAttrs;
      this.prevAttrs = undefined;
      this.dom = null;
    }

    setDeco(attrs) {
      if (!attrsEq(this.attrs, attrs)) {
        if (this.dom) {
          this.prevAttrs = this.attrs;
          this.markDirty();
        }

        this.attrs = attrs;
      }
    }

    append(child, openStart) {
      joinInlineInto(this, child, openStart);
    } // Only called when building a line view in ContentBuilder


    addLineDeco(deco) {
      let attrs = deco.spec.attributes,
          cls = deco.spec.class;
      if (attrs) this.attrs = combineAttrs(attrs, this.attrs || {});
      if (cls) this.attrs = combineAttrs({
        class: cls
      }, this.attrs || {});
    }

    domAtPos(pos) {
      return inlineDOMAtPos(this, pos);
    }

    reuseDOM(node) {
      if (node.nodeName == "DIV") {
        this.setDOM(node);
        this.dirty |= 4
        /* Dirty.Attrs */
        | 2
        /* Dirty.Node */
        ;
      }
    }

    sync(track) {
      var _a;

      if (!this.dom) {
        this.setDOM(document.createElement("div"));
        this.dom.className = "cm-line";
        this.prevAttrs = this.attrs ? null : undefined;
      } else if (this.dirty & 4
      /* Dirty.Attrs */
      ) {
        clearAttributes(this.dom);
        this.dom.className = "cm-line";
        this.prevAttrs = this.attrs ? null : undefined;
      }

      if (this.prevAttrs !== undefined) {
        updateAttrs(this.dom, this.prevAttrs, this.attrs);
        this.dom.classList.add("cm-line");
        this.prevAttrs = undefined;
      }

      super.sync(track);
      let last = this.dom.lastChild;

      while (last && ContentView.get(last) instanceof MarkView) last = last.lastChild;

      if (!last || !this.length || last.nodeName != "BR" && ((_a = ContentView.get(last)) === null || _a === void 0 ? void 0 : _a.isEditable) == false && (!browser.ios || !this.children.some(ch => ch instanceof TextView))) {
        let hack = document.createElement("BR");
        hack.cmIgnore = true;
        this.dom.appendChild(hack);
      }
    }

    measureTextSize() {
      if (this.children.length == 0 || this.length > 20) return null;
      let totalWidth = 0;

      for (let child of this.children) {
        if (!(child instanceof TextView) || /[^ -~]/.test(child.text)) return null;
        let rects = clientRectsFor(child.dom);
        if (rects.length != 1) return null;
        totalWidth += rects[0].width;
      }

      return !totalWidth ? null : {
        lineHeight: this.dom.getBoundingClientRect().height,
        charWidth: totalWidth / this.length
      };
    }

    coordsAt(pos, side) {
      return coordsInChildren(this, pos, side);
    }

    become(_other) {
      return false;
    }

    get type() {
      return BlockType.Text;
    }

    static find(docView, pos) {
      for (let i = 0, off = 0; i < docView.children.length; i++) {
        let block = docView.children[i],
            end = off + block.length;

        if (end >= pos) {
          if (block instanceof LineView) return block;
          if (end > pos) break;
        }

        off = end + block.breakAfter;
      }

      return null;
    }

  }

  class BlockWidgetView extends ContentView {
    constructor(widget, length, type) {
      super();
      this.widget = widget;
      this.length = length;
      this.type = type;
      this.breakAfter = 0;
      this.prevWidget = null;
    }

    merge(from, to, source, _takeDeco, openStart, openEnd) {
      if (source && (!(source instanceof BlockWidgetView) || !this.widget.compare(source.widget) || from > 0 && openStart <= 0 || to < this.length && openEnd <= 0)) return false;
      this.length = from + (source ? source.length : 0) + (this.length - to);
      return true;
    }

    domAtPos(pos) {
      return pos == 0 ? DOMPos.before(this.dom) : DOMPos.after(this.dom, pos == this.length);
    }

    split(at) {
      let len = this.length - at;
      this.length = at;
      let end = new BlockWidgetView(this.widget, len, this.type);
      end.breakAfter = this.breakAfter;
      return end;
    }

    get children() {
      return noChildren;
    }

    sync() {
      if (!this.dom || !this.widget.updateDOM(this.dom)) {
        if (this.dom && this.prevWidget) this.prevWidget.destroy(this.dom);
        this.prevWidget = null;
        this.setDOM(this.widget.toDOM(this.editorView));
        this.dom.contentEditable = "false";
      }
    }

    get overrideDOMText() {
      return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : Text.empty;
    }

    domBoundsAround() {
      return null;
    }

    become(other) {
      if (other instanceof BlockWidgetView && other.type == this.type && other.widget.constructor == this.widget.constructor) {
        if (!other.widget.eq(this.widget)) this.markDirty(true);
        if (this.dom && !this.prevWidget) this.prevWidget = this.widget;
        this.widget = other.widget;
        this.length = other.length;
        this.breakAfter = other.breakAfter;
        return true;
      }

      return false;
    }

    ignoreMutation() {
      return true;
    }

    ignoreEvent(event) {
      return this.widget.ignoreEvent(event);
    }

    destroy() {
      super.destroy();
      if (this.dom) this.widget.destroy(this.dom);
    }

  }

  class ContentBuilder {
    constructor(doc, pos, end, disallowBlockEffectsFor) {
      this.doc = doc;
      this.pos = pos;
      this.end = end;
      this.disallowBlockEffectsFor = disallowBlockEffectsFor;
      this.content = [];
      this.curLine = null;
      this.breakAtStart = 0;
      this.pendingBuffer = 0
      /* Buf.No */
      ; // Set to false directly after a widget that covers the position after it

      this.atCursorPos = true;
      this.openStart = -1;
      this.openEnd = -1;
      this.text = "";
      this.textOff = 0;
      this.cursor = doc.iter();
      this.skip = pos;
    }

    posCovered() {
      if (this.content.length == 0) return !this.breakAtStart && this.doc.lineAt(this.pos).from != this.pos;
      let last = this.content[this.content.length - 1];
      return !last.breakAfter && !(last instanceof BlockWidgetView && last.type == BlockType.WidgetBefore);
    }

    getLine() {
      if (!this.curLine) {
        this.content.push(this.curLine = new LineView());
        this.atCursorPos = true;
      }

      return this.curLine;
    }

    flushBuffer(active) {
      if (this.pendingBuffer) {
        this.curLine.append(wrapMarks(new WidgetBufferView(-1), active), active.length);
        this.pendingBuffer = 0
        /* Buf.No */
        ;
      }
    }

    addBlockWidget(view) {
      this.flushBuffer([]);
      this.curLine = null;
      this.content.push(view);
    }

    finish(openEnd) {
      if (!openEnd) this.flushBuffer([]);else this.pendingBuffer = 0
      /* Buf.No */
      ;
      if (!this.posCovered()) this.getLine();
    }

    buildText(length, active, openStart) {
      while (length > 0) {
        if (this.textOff == this.text.length) {
          let {
            value,
            lineBreak,
            done
          } = this.cursor.next(this.skip);
          this.skip = 0;
          if (done) throw new Error("Ran out of text content when drawing inline views");

          if (lineBreak) {
            if (!this.posCovered()) this.getLine();
            if (this.content.length) this.content[this.content.length - 1].breakAfter = 1;else this.breakAtStart = 1;
            this.flushBuffer([]);
            this.curLine = null;
            length--;
            continue;
          } else {
            this.text = value;
            this.textOff = 0;
          }
        }

        let take = Math.min(this.text.length - this.textOff, length, 512
        /* T.Chunk */
        );
        this.flushBuffer(active.slice(0, openStart));
        this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff, this.textOff + take)), active), openStart);
        this.atCursorPos = true;
        this.textOff += take;
        length -= take;
        openStart = 0;
      }
    }

    span(from, to, active, openStart) {
      this.buildText(to - from, active, openStart);
      this.pos = to;
      if (this.openStart < 0) this.openStart = openStart;
    }

    point(from, to, deco, active, openStart, index) {
      if (this.disallowBlockEffectsFor[index] && deco instanceof PointDecoration) {
        if (deco.block) throw new RangeError("Block decorations may not be specified via plugins");
        if (to > this.doc.lineAt(this.pos).to) throw new RangeError("Decorations that replace line breaks may not be specified via plugins");
      }

      let len = to - from;

      if (deco instanceof PointDecoration) {
        if (deco.block) {
          let {
            type
          } = deco;
          if (type == BlockType.WidgetAfter && !this.posCovered()) this.getLine();
          this.addBlockWidget(new BlockWidgetView(deco.widget || new NullWidget("div"), len, type));
        } else {
          let view = WidgetView.create(deco.widget || new NullWidget("span"), len, deco.startSide);
          let cursorBefore = this.atCursorPos && !view.isEditable && openStart <= active.length && (from < to || deco.startSide > 0);
          let cursorAfter = !view.isEditable && (from < to || deco.startSide <= 0);
          let line = this.getLine();
          if (this.pendingBuffer == 2
          /* Buf.IfCursor */
          && !cursorBefore) this.pendingBuffer = 0
          /* Buf.No */
          ;
          this.flushBuffer(active);

          if (cursorBefore) {
            line.append(wrapMarks(new WidgetBufferView(1), active), openStart);
            openStart = active.length + Math.max(0, openStart - active.length);
          }

          line.append(wrapMarks(view, active), openStart);
          this.atCursorPos = cursorAfter;
          this.pendingBuffer = !cursorAfter ? 0
          /* Buf.No */
          : from < to ? 1
          /* Buf.Yes */
          : 2
          /* Buf.IfCursor */
          ;
        }
      } else if (this.doc.lineAt(this.pos).from == this.pos) {
        // Line decoration
        this.getLine().addLineDeco(deco);
      }

      if (len) {
        // Advance the iterator past the replaced content
        if (this.textOff + len <= this.text.length) {
          this.textOff += len;
        } else {
          this.skip += len - (this.text.length - this.textOff);
          this.text = "";
          this.textOff = 0;
        }

        this.pos = to;
      }

      if (this.openStart < 0) this.openStart = openStart;
    }

    static build(text, from, to, decorations, dynamicDecorationMap) {
      let builder = new ContentBuilder(text, from, to, dynamicDecorationMap);
      builder.openEnd = RangeSet.spans(decorations, from, to, builder);
      if (builder.openStart < 0) builder.openStart = builder.openEnd;
      builder.finish(builder.openEnd);
      return builder;
    }

  }

  function wrapMarks(view, active) {
    for (let mark of active) view = new MarkView(mark, [view], view.length);

    return view;
  }

  class NullWidget extends WidgetType {
    constructor(tag) {
      super();
      this.tag = tag;
    }

    eq(other) {
      return other.tag == this.tag;
    }

    toDOM() {
      return document.createElement(this.tag);
    }

    updateDOM(elt) {
      return elt.nodeName.toLowerCase() == this.tag;
    }

  }

  const clickAddsSelectionRange = /*@__PURE__*/Facet.define();
  const dragMovesSelection$1 = /*@__PURE__*/Facet.define();
  const mouseSelectionStyle = /*@__PURE__*/Facet.define();
  const exceptionSink = /*@__PURE__*/Facet.define();
  const updateListener = /*@__PURE__*/Facet.define();
  const inputHandler$1 = /*@__PURE__*/Facet.define();
  const perLineTextDirection = /*@__PURE__*/Facet.define({
    combine: values => values.some(x => x)
  });

  class ScrollTarget {
    constructor(range, y = "nearest", x = "nearest", yMargin = 5, xMargin = 5) {
      this.range = range;
      this.y = y;
      this.x = x;
      this.yMargin = yMargin;
      this.xMargin = xMargin;
    }

    map(changes) {
      return changes.empty ? this : new ScrollTarget(this.range.map(changes), this.y, this.x, this.yMargin, this.xMargin);
    }

  }

  const scrollIntoView$1 = /*@__PURE__*/StateEffect.define({
    map: (t, ch) => t.map(ch)
  });
  /**
  Log or report an unhandled exception in client code. Should
  probably only be used by extension code that allows client code to
  provide functions, and calls those functions in a context where an
  exception can't be propagated to calling code in a reasonable way
  (for example when in an event handler).

  Either calls a handler registered with
  [`EditorView.exceptionSink`](https://codemirror.net/6/docs/ref/#view.EditorView^exceptionSink),
  `window.onerror`, if defined, or `console.error` (in which case
  it'll pass `context`, when given, as first argument).
  */

  function logException(state, exception, context) {
    let handler = state.facet(exceptionSink);
    if (handler.length) handler[0](exception);else if (window.onerror) window.onerror(String(exception), context, undefined, undefined, exception);else if (context) console.error(context + ":", exception);else console.error(exception);
  }

  const editable = /*@__PURE__*/Facet.define({
    combine: values => values.length ? values[0] : true
  });
  let nextPluginID = 0;
  const viewPlugin = /*@__PURE__*/Facet.define();
  /**
  View plugins associate stateful values with a view. They can
  influence the way the content is drawn, and are notified of things
  that happen in the view.
  */

  class ViewPlugin {
    constructor(
    /**
    @internal
    */
    id,
    /**
    @internal
    */
    create,
    /**
    @internal
    */
    domEventHandlers, buildExtensions) {
      this.id = id;
      this.create = create;
      this.domEventHandlers = domEventHandlers;
      this.extension = buildExtensions(this);
    }
    /**
    Define a plugin from a constructor function that creates the
    plugin's value, given an editor view.
    */


    static define(create, spec) {
      const {
        eventHandlers,
        provide,
        decorations: deco
      } = spec || {};
      return new ViewPlugin(nextPluginID++, create, eventHandlers, plugin => {
        let ext = [viewPlugin.of(plugin)];
        if (deco) ext.push(decorations.of(view => {
          let pluginInst = view.plugin(plugin);
          return pluginInst ? deco(pluginInst) : Decoration.none;
        }));
        if (provide) ext.push(provide(plugin));
        return ext;
      });
    }
    /**
    Create a plugin for a class whose constructor takes a single
    editor view as argument.
    */


    static fromClass(cls, spec) {
      return ViewPlugin.define(view => new cls(view), spec);
    }

  }

  class PluginInstance {
    constructor(spec) {
      this.spec = spec; // When starting an update, all plugins have this field set to the
      // update object, indicating they need to be updated. When finished
      // updating, it is set to `false`. Retrieving a plugin that needs to
      // be updated with `view.plugin` forces an eager update.

      this.mustUpdate = null; // This is null when the plugin is initially created, but
      // initialized on the first update.

      this.value = null;
    }

    update(view) {
      if (!this.value) {
        if (this.spec) {
          try {
            this.value = this.spec.create(view);
          } catch (e) {
            logException(view.state, e, "CodeMirror plugin crashed");
            this.deactivate();
          }
        }
      } else if (this.mustUpdate) {
        let update = this.mustUpdate;
        this.mustUpdate = null;

        if (this.value.update) {
          try {
            this.value.update(update);
          } catch (e) {
            logException(update.state, e, "CodeMirror plugin crashed");
            if (this.value.destroy) try {
              this.value.destroy();
            } catch (_) {}
            this.deactivate();
          }
        }
      }

      return this;
    }

    destroy(view) {
      var _a;

      if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.destroy) {
        try {
          this.value.destroy();
        } catch (e) {
          logException(view.state, e, "CodeMirror plugin crashed");
        }
      }
    }

    deactivate() {
      this.spec = this.value = null;
    }

  }

  const editorAttributes = /*@__PURE__*/Facet.define();
  const contentAttributes = /*@__PURE__*/Facet.define(); // Provide decorations

  const decorations = /*@__PURE__*/Facet.define();
  const atomicRanges = /*@__PURE__*/Facet.define();
  const scrollMargins = /*@__PURE__*/Facet.define();
  const styleModule = /*@__PURE__*/Facet.define();

  class ChangedRange {
    constructor(fromA, toA, fromB, toB) {
      this.fromA = fromA;
      this.toA = toA;
      this.fromB = fromB;
      this.toB = toB;
    }

    join(other) {
      return new ChangedRange(Math.min(this.fromA, other.fromA), Math.max(this.toA, other.toA), Math.min(this.fromB, other.fromB), Math.max(this.toB, other.toB));
    }

    addToSet(set) {
      let i = set.length,
          me = this;

      for (; i > 0; i--) {
        let range = set[i - 1];
        if (range.fromA > me.toA) continue;
        if (range.toA < me.fromA) break;
        me = me.join(range);
        set.splice(i - 1, 1);
      }

      set.splice(i, 0, me);
      return set;
    }

    static extendWithRanges(diff, ranges) {
      if (ranges.length == 0) return diff;
      let result = [];

      for (let dI = 0, rI = 0, posA = 0, posB = 0;; dI++) {
        let next = dI == diff.length ? null : diff[dI],
            off = posA - posB;
        let end = next ? next.fromB : 1e9;

        while (rI < ranges.length && ranges[rI] < end) {
          let from = ranges[rI],
              to = ranges[rI + 1];
          let fromB = Math.max(posB, from),
              toB = Math.min(end, to);
          if (fromB <= toB) new ChangedRange(fromB + off, toB + off, fromB, toB).addToSet(result);
          if (to > end) break;else rI += 2;
        }

        if (!next) return result;
        new ChangedRange(next.fromA, next.toA, next.fromB, next.toB).addToSet(result);
        posA = next.toA;
        posB = next.toB;
      }
    }

  }
  /**
  View [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this
  class, which describe what happened, whenever the view is updated.
  */


  class ViewUpdate {
    constructor(
    /**
    The editor view that the update is associated with.
    */
    view,
    /**
    The new editor state.
    */
    state,
    /**
    The transactions involved in the update. May be empty.
    */
    transactions) {
      this.view = view;
      this.state = state;
      this.transactions = transactions;
      /**
      @internal
      */

      this.flags = 0;
      this.startState = view.state;
      this.changes = ChangeSet.empty(this.startState.doc.length);

      for (let tr of transactions) this.changes = this.changes.compose(tr.changes);

      let changedRanges = [];
      this.changes.iterChangedRanges((fromA, toA, fromB, toB) => changedRanges.push(new ChangedRange(fromA, toA, fromB, toB)));
      this.changedRanges = changedRanges;
      let focus = view.hasFocus;

      if (focus != view.inputState.notifiedFocused) {
        view.inputState.notifiedFocused = focus;
        this.flags |= 1
        /* UpdateFlag.Focus */
        ;
      }
    }
    /**
    @internal
    */


    static create(view, state, transactions) {
      return new ViewUpdate(view, state, transactions);
    }
    /**
    Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or
    [visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this
    update.
    */


    get viewportChanged() {
      return (this.flags & 4
      /* UpdateFlag.Viewport */
      ) > 0;
    }
    /**
    Indicates whether the height of a block element in the editor
    changed in this update.
    */


    get heightChanged() {
      return (this.flags & 2
      /* UpdateFlag.Height */
      ) > 0;
    }
    /**
    Returns true when the document was modified or the size of the
    editor, or elements within the editor, changed.
    */


    get geometryChanged() {
      return this.docChanged || (this.flags & (8
      /* UpdateFlag.Geometry */
      | 2
      /* UpdateFlag.Height */
      )) > 0;
    }
    /**
    True when this update indicates a focus change.
    */


    get focusChanged() {
      return (this.flags & 1
      /* UpdateFlag.Focus */
      ) > 0;
    }
    /**
    Whether the document changed in this update.
    */


    get docChanged() {
      return !this.changes.empty;
    }
    /**
    Whether the selection was explicitly set in this update.
    */


    get selectionSet() {
      return this.transactions.some(tr => tr.selection);
    }
    /**
    @internal
    */


    get empty() {
      return this.flags == 0 && this.transactions.length == 0;
    }

  }
  /**
  Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
  */


  var Direction = /*@__PURE__*/function (Direction) {
    // (These are chosen to match the base levels, in bidi algorithm
    // terms, of spans in that direction.)

    /**
    Left-to-right.
    */
    Direction[Direction["LTR"] = 0] = "LTR";
    /**
    Right-to-left.
    */

    Direction[Direction["RTL"] = 1] = "RTL";
    return Direction;
  }(Direction || (Direction = {}));

  const LTR = Direction.LTR,
        RTL = Direction.RTL; // Decode a string with each type encoded as log2(type)

  function dec(str) {
    let result = [];

    for (let i = 0; i < str.length; i++) result.push(1 << +str[i]);

    return result;
  } // Character types for codepoints 0 to 0xf8


  const LowTypes = /*@__PURE__*/dec("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"); // Character types for codepoints 0x600 to 0x6f9

  const ArabicTypes = /*@__PURE__*/dec("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333");
  const Brackets = /*@__PURE__*/Object.create(null),
        BracketStack = []; // There's a lot more in
  // https://www.unicode.org/Public/UCD/latest/ucd/BidiBrackets.txt,
  // which are left out to keep code size down.

  for (let p of ["()", "[]", "{}"]) {
    let l = /*@__PURE__*/p.charCodeAt(0),
        r = /*@__PURE__*/p.charCodeAt(1);
    Brackets[l] = r;
    Brackets[r] = -l;
  }

  function charType(ch) {
    return ch <= 0xf7 ? LowTypes[ch] : 0x590 <= ch && ch <= 0x5f4 ? 2
    /* T.R */
    : 0x600 <= ch && ch <= 0x6f9 ? ArabicTypes[ch - 0x600] : 0x6ee <= ch && ch <= 0x8ac ? 4
    /* T.AL */
    : 0x2000 <= ch && ch <= 0x200b ? 256
    /* T.NI */
    : 0xfb50 <= ch && ch <= 0xfdff ? 4
    /* T.AL */
    : ch == 0x200c ? 256
    /* T.NI */
    : 1
    /* T.L */
    ;
  }

  const BidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;
  /**
  Represents a contiguous range of text that has a single direction
  (as in left-to-right or right-to-left).
  */

  class BidiSpan {
    /**
    @internal
    */
    constructor(
    /**
    The start of the span (relative to the start of the line).
    */
    from,
    /**
    The end of the span.
    */
    to,
    /**
    The ["bidi
    level"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)
    of the span (in this context, 0 means
    left-to-right, 1 means right-to-left, 2 means left-to-right
    number inside right-to-left text).
    */
    level) {
      this.from = from;
      this.to = to;
      this.level = level;
    }
    /**
    The direction of this span.
    */


    get dir() {
      return this.level % 2 ? RTL : LTR;
    }
    /**
    @internal
    */


    side(end, dir) {
      return this.dir == dir == end ? this.to : this.from;
    }
    /**
    @internal
    */


    static find(order, index, level, assoc) {
      let maybe = -1;

      for (let i = 0; i < order.length; i++) {
        let span = order[i];

        if (span.from <= index && span.to >= index) {
          if (span.level == level) return i; // When multiple spans match, if assoc != 0, take the one that
          // covers that side, otherwise take the one with the minimum
          // level.

          if (maybe < 0 || (assoc != 0 ? assoc < 0 ? span.from < index : span.to > index : order[maybe].level > span.level)) maybe = i;
        }
      }

      if (maybe < 0) throw new RangeError("Index out of range");
      return maybe;
    }

  } // Reused array of character types


  const types = [];

  function computeOrder(line, direction) {
    let len = line.length,
        outerType = direction == LTR ? 1
    /* T.L */
    : 2
    /* T.R */
    ,
        oppositeType = direction == LTR ? 2
    /* T.R */
    : 1
    /* T.L */
    ;
    if (!line || outerType == 1
    /* T.L */
    && !BidiRE.test(line)) return trivialOrder(len); // W1. Examine each non-spacing mark (NSM) in the level run, and
    // change the type of the NSM to the type of the previous
    // character. If the NSM is at the start of the level run, it will
    // get the type of sor.
    // W2. Search backwards from each instance of a European number
    // until the first strong type (R, L, AL, or sor) is found. If an
    // AL is found, change the type of the European number to Arabic
    // number.
    // W3. Change all ALs to R.
    // (Left after this: L, R, EN, AN, ET, CS, NI)

    for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
      let type = charType(line.charCodeAt(i));
      if (type == 512
      /* T.NSM */
      ) type = prev;else if (type == 8
      /* T.EN */
      && prevStrong == 4
      /* T.AL */
      ) type = 16
      /* T.AN */
      ;
      types[i] = type == 4
      /* T.AL */
      ? 2
      /* T.R */
      : type;
      if (type & 7
      /* T.Strong */
      ) prevStrong = type;
      prev = type;
    } // W5. A sequence of European terminators adjacent to European
    // numbers changes to all European numbers.
    // W6. Otherwise, separators and terminators change to Other
    // Neutral.
    // W7. Search backwards from each instance of a European number
    // until the first strong type (R, L, or sor) is found. If an L is
    // found, then change the type of the European number to L.
    // (Left after this: L, R, EN+AN, NI)


    for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
      let type = types[i];

      if (type == 128
      /* T.CS */
      ) {
        if (i < len - 1 && prev == types[i + 1] && prev & 24
        /* T.Num */
        ) type = types[i] = prev;else types[i] = 256
        /* T.NI */
        ;
      } else if (type == 64
      /* T.ET */
      ) {
        let end = i + 1;

        while (end < len && types[end] == 64
        /* T.ET */
        ) end++;

        let replace = i && prev == 8
        /* T.EN */
        || end < len && types[end] == 8
        /* T.EN */
        ? prevStrong == 1
        /* T.L */
        ? 1
        /* T.L */
        : 8
        /* T.EN */
        : 256
        /* T.NI */
        ;

        for (let j = i; j < end; j++) types[j] = replace;

        i = end - 1;
      } else if (type == 8
      /* T.EN */
      && prevStrong == 1
      /* T.L */
      ) {
        types[i] = 1
        /* T.L */
        ;
      }

      prev = type;
      if (type & 7
      /* T.Strong */
      ) prevStrong = type;
    } // N0. Process bracket pairs in an isolating run sequence
    // sequentially in the logical order of the text positions of the
    // opening paired brackets using the logic given below. Within this
    // scope, bidirectional types EN and AN are treated as R.


    for (let i = 0, sI = 0, context = 0, ch, br, type; i < len; i++) {
      // Keeps [startIndex, type, strongSeen] triples for each open
      // bracket on BracketStack.
      if (br = Brackets[ch = line.charCodeAt(i)]) {
        if (br < 0) {
          // Closing bracket
          for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
            if (BracketStack[sJ + 1] == -br) {
              let flags = BracketStack[sJ + 2];
              let type = flags & 2
              /* Bracketed.EmbedInside */
              ? outerType : !(flags & 4
              /* Bracketed.OppositeInside */
              ) ? 0 : flags & 1
              /* Bracketed.OppositeBefore */
              ? oppositeType : outerType;
              if (type) types[i] = types[BracketStack[sJ]] = type;
              sI = sJ;
              break;
            }
          }
        } else if (BracketStack.length == 189
        /* Bracketed.MaxDepth */
        ) {
          break;
        } else {
          BracketStack[sI++] = i;
          BracketStack[sI++] = ch;
          BracketStack[sI++] = context;
        }
      } else if ((type = types[i]) == 2
      /* T.R */
      || type == 1
      /* T.L */
      ) {
        let embed = type == outerType;
        context = embed ? 0 : 1
        /* Bracketed.OppositeBefore */
        ;

        for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
          let cur = BracketStack[sJ + 2];
          if (cur & 2
          /* Bracketed.EmbedInside */
          ) break;

          if (embed) {
            BracketStack[sJ + 2] |= 2
            /* Bracketed.EmbedInside */
            ;
          } else {
            if (cur & 4
            /* Bracketed.OppositeInside */
            ) break;
            BracketStack[sJ + 2] |= 4
            /* Bracketed.OppositeInside */
            ;
          }
        }
      }
    } // N1. A sequence of neutrals takes the direction of the
    // surrounding strong text if the text on both sides has the same
    // direction. European and Arabic numbers act as if they were R in
    // terms of their influence on neutrals. Start-of-level-run (sor)
    // and end-of-level-run (eor) are used at level run boundaries.
    // N2. Any remaining neutrals take the embedding direction.
    // (Left after this: L, R, EN+AN)


    for (let i = 0; i < len; i++) {
      if (types[i] == 256
      /* T.NI */
      ) {
        let end = i + 1;

        while (end < len && types[end] == 256
        /* T.NI */
        ) end++;

        let beforeL = (i ? types[i - 1] : outerType) == 1
        /* T.L */
        ;
        let afterL = (end < len ? types[end] : outerType) == 1
        /* T.L */
        ;
        let replace = beforeL == afterL ? beforeL ? 1
        /* T.L */
        : 2
        /* T.R */
        : outerType;

        for (let j = i; j < end; j++) types[j] = replace;

        i = end - 1;
      }
    } // Here we depart from the documented algorithm, in order to avoid
    // building up an actual levels array. Since there are only three
    // levels (0, 1, 2) in an implementation that doesn't take
    // explicit embedding into account, we can build up the order on
    // the fly, without following the level-based algorithm.


    let order = [];

    if (outerType == 1
    /* T.L */
    ) {
      for (let i = 0; i < len;) {
        let start = i,
            rtl = types[i++] != 1
        /* T.L */
        ;

        while (i < len && rtl == (types[i] != 1
        /* T.L */
        )) i++;

        if (rtl) {
          for (let j = i; j > start;) {
            let end = j,
                l = types[--j] != 2
            /* T.R */
            ;

            while (j > start && l == (types[j - 1] != 2
            /* T.R */
            )) j--;

            order.push(new BidiSpan(j, end, l ? 2 : 1));
          }
        } else {
          order.push(new BidiSpan(start, i, 0));
        }
      }
    } else {
      for (let i = 0; i < len;) {
        let start = i,
            rtl = types[i++] == 2
        /* T.R */
        ;

        while (i < len && rtl == (types[i] == 2
        /* T.R */
        )) i++;

        order.push(new BidiSpan(start, i, rtl ? 1 : 2));
      }
    }

    return order;
  }

  function trivialOrder(length) {
    return [new BidiSpan(0, length, 0)];
  }

  let movedOver = "";

  function moveVisually(line, order, dir, start, forward) {
    var _a;

    let startIndex = start.head - line.from,
        spanI = -1;

    if (startIndex == 0) {
      if (!forward || !line.length) return null;

      if (order[0].level != dir) {
        startIndex = order[0].side(false, dir);
        spanI = 0;
      }
    } else if (startIndex == line.length) {
      if (forward) return null;
      let last = order[order.length - 1];

      if (last.level != dir) {
        startIndex = last.side(true, dir);
        spanI = order.length - 1;
      }
    }

    if (spanI < 0) spanI = BidiSpan.find(order, startIndex, (_a = start.bidiLevel) !== null && _a !== void 0 ? _a : -1, start.assoc);
    let span = order[spanI]; // End of span. (But not end of line--that was checked for above.)

    if (startIndex == span.side(forward, dir)) {
      span = order[spanI += forward ? 1 : -1];
      startIndex = span.side(!forward, dir);
    }

    let indexForward = forward == (span.dir == dir);
    let nextIndex = findClusterBreak(line.text, startIndex, indexForward);
    movedOver = line.text.slice(Math.min(startIndex, nextIndex), Math.max(startIndex, nextIndex));
    if (nextIndex != span.side(forward, dir)) return EditorSelection.cursor(nextIndex + line.from, indexForward ? -1 : 1, span.level);
    let nextSpan = spanI == (forward ? order.length - 1 : 0) ? null : order[spanI + (forward ? 1 : -1)];
    if (!nextSpan && span.level != dir) return EditorSelection.cursor(forward ? line.to : line.from, forward ? -1 : 1, dir);
    if (nextSpan && nextSpan.level < span.level) return EditorSelection.cursor(nextSpan.side(!forward, dir) + line.from, forward ? 1 : -1, nextSpan.level);
    return EditorSelection.cursor(nextIndex + line.from, forward ? -1 : 1, span.level);
  }

  const LineBreakPlaceholder = "\uffff";

  class DOMReader {
    constructor(points, state) {
      this.points = points;
      this.text = "";
      this.lineSeparator = state.facet(EditorState.lineSeparator);
    }

    append(text) {
      this.text += text;
    }

    lineBreak() {
      this.text += LineBreakPlaceholder;
    }

    readRange(start, end) {
      if (!start) return this;
      let parent = start.parentNode;

      for (let cur = start;;) {
        this.findPointBefore(parent, cur);
        this.readNode(cur);
        let next = cur.nextSibling;
        if (next == end) break;
        let view = ContentView.get(cur),
            nextView = ContentView.get(next);
        if (view && nextView ? view.breakAfter : (view ? view.breakAfter : isBlockElement(cur)) || isBlockElement(next) && (cur.nodeName != "BR" || cur.cmIgnore)) this.lineBreak();
        cur = next;
      }

      this.findPointBefore(parent, end);
      return this;
    }

    readTextNode(node) {
      let text = node.nodeValue;

      for (let point of this.points) if (point.node == node) point.pos = this.text.length + Math.min(point.offset, text.length);

      for (let off = 0, re = this.lineSeparator ? null : /\r\n?|\n/g;;) {
        let nextBreak = -1,
            breakSize = 1,
            m;

        if (this.lineSeparator) {
          nextBreak = text.indexOf(this.lineSeparator, off);
          breakSize = this.lineSeparator.length;
        } else if (m = re.exec(text)) {
          nextBreak = m.index;
          breakSize = m[0].length;
        }

        this.append(text.slice(off, nextBreak < 0 ? text.length : nextBreak));
        if (nextBreak < 0) break;
        this.lineBreak();
        if (breakSize > 1) for (let point of this.points) if (point.node == node && point.pos > this.text.length) point.pos -= breakSize - 1;
        off = nextBreak + breakSize;
      }
    }

    readNode(node) {
      if (node.cmIgnore) return;
      let view = ContentView.get(node);
      let fromView = view && view.overrideDOMText;

      if (fromView != null) {
        this.findPointInside(node, fromView.length);

        for (let i = fromView.iter(); !i.next().done;) {
          if (i.lineBreak) this.lineBreak();else this.append(i.value);
        }
      } else if (node.nodeType == 3) {
        this.readTextNode(node);
      } else if (node.nodeName == "BR") {
        if (node.nextSibling) this.lineBreak();
      } else if (node.nodeType == 1) {
        this.readRange(node.firstChild, null);
      }
    }

    findPointBefore(node, next) {
      for (let point of this.points) if (point.node == node && node.childNodes[point.offset] == next) point.pos = this.text.length;
    }

    findPointInside(node, maxLen) {
      for (let point of this.points) if (node.nodeType == 3 ? point.node == node : node.contains(point.node)) point.pos = this.text.length + Math.min(maxLen, point.offset);
    }

  }

  function isBlockElement(node) {
    return node.nodeType == 1 && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(node.nodeName);
  }

  class DOMPoint {
    constructor(node, offset) {
      this.node = node;
      this.offset = offset;
      this.pos = -1;
    }

  }

  class DocView extends ContentView {
    constructor(view) {
      super();
      this.view = view;
      this.compositionDeco = Decoration.none;
      this.decorations = [];
      this.dynamicDecorationMap = []; // Track a minimum width for the editor. When measuring sizes in
      // measureVisibleLineHeights, this is updated to point at the width
      // of a given element and its extent in the document. When a change
      // happens in that range, these are reset. That way, once we've seen
      // a line/element of a given length, we keep the editor wide enough
      // to fit at least that element, until it is changed, at which point
      // we forget it again.

      this.minWidth = 0;
      this.minWidthFrom = 0;
      this.minWidthTo = 0; // Track whether the DOM selection was set in a lossy way, so that
      // we don't mess it up when reading it back it

      this.impreciseAnchor = null;
      this.impreciseHead = null;
      this.forceSelection = false; // Used by the resize observer to ignore resizes that we caused
      // ourselves

      this.lastUpdate = Date.now();
      this.setDOM(view.contentDOM);
      this.children = [new LineView()];
      this.children[0].setParent(this);
      this.updateDeco();
      this.updateInner([new ChangedRange(0, 0, 0, view.state.doc.length)], 0);
    }

    get editorView() {
      return this.view;
    }

    get length() {
      return this.view.state.doc.length;
    } // Update the document view to a given state. scrollIntoView can be
    // used as a hint to compute a new viewport that includes that
    // position, if we know the editor is going to scroll that position
    // into view.


    update(update) {
      let changedRanges = update.changedRanges;

      if (this.minWidth > 0 && changedRanges.length) {
        if (!changedRanges.every(({
          fromA,
          toA
        }) => toA < this.minWidthFrom || fromA > this.minWidthTo)) {
          this.minWidth = this.minWidthFrom = this.minWidthTo = 0;
        } else {
          this.minWidthFrom = update.changes.mapPos(this.minWidthFrom, 1);
          this.minWidthTo = update.changes.mapPos(this.minWidthTo, 1);
        }
      }

      if (this.view.inputState.composing < 0) this.compositionDeco = Decoration.none;else if (update.transactions.length || this.dirty) this.compositionDeco = computeCompositionDeco(this.view, update.changes); // When the DOM nodes around the selection are moved to another
      // parent, Chrome sometimes reports a different selection through
      // getSelection than the one that it actually shows to the user.
      // This forces a selection update when lines are joined to work
      // around that. Issue #54

      if ((browser.ie || browser.chrome) && !this.compositionDeco.size && update && update.state.doc.lines != update.startState.doc.lines) this.forceSelection = true;
      let prevDeco = this.decorations,
          deco = this.updateDeco();
      let decoDiff = findChangedDeco(prevDeco, deco, update.changes);
      changedRanges = ChangedRange.extendWithRanges(changedRanges, decoDiff);

      if (this.dirty == 0
      /* Dirty.Not */
      && changedRanges.length == 0) {
        return false;
      } else {
        this.updateInner(changedRanges, update.startState.doc.length);
        if (update.transactions.length) this.lastUpdate = Date.now();
        return true;
      }
    } // Used by update and the constructor do perform the actual DOM
    // update


    updateInner(changes, oldLength) {
      this.view.viewState.mustMeasureContent = true;
      this.updateChildren(changes, oldLength);
      let {
        observer
      } = this.view;
      observer.ignore(() => {
        // Lock the height during redrawing, since Chrome sometimes
        // messes with the scroll position during DOM mutation (though
        // no relayout is triggered and I cannot imagine how it can
        // recompute the scroll position without a layout)
        this.dom.style.height = this.view.viewState.contentHeight + "px";
        this.dom.style.flexBasis = this.minWidth ? this.minWidth + "px" : ""; // Chrome will sometimes, when DOM mutations occur directly
        // around the selection, get confused and report a different
        // selection from the one it displays (issue #218). This tries
        // to detect that situation.

        let track = browser.chrome || browser.ios ? {
          node: observer.selectionRange.focusNode,
          written: false
        } : undefined;
        this.sync(track);
        this.dirty = 0
        /* Dirty.Not */
        ;
        if (track && (track.written || observer.selectionRange.focusNode != track.node)) this.forceSelection = true;
        this.dom.style.height = "";
      });
      let gaps = [];
      if (this.view.viewport.from || this.view.viewport.to < this.view.state.doc.length) for (let child of this.children) if (child instanceof BlockWidgetView && child.widget instanceof BlockGapWidget) gaps.push(child.dom);
      observer.updateGaps(gaps);
    }

    updateChildren(changes, oldLength) {
      let cursor = this.childCursor(oldLength);

      for (let i = changes.length - 1;; i--) {
        let next = i >= 0 ? changes[i] : null;
        if (!next) break;
        let {
          fromA,
          toA,
          fromB,
          toB
        } = next;
        let {
          content,
          breakAtStart,
          openStart,
          openEnd
        } = ContentBuilder.build(this.view.state.doc, fromB, toB, this.decorations, this.dynamicDecorationMap);
        let {
          i: toI,
          off: toOff
        } = cursor.findPos(toA, 1);
        let {
          i: fromI,
          off: fromOff
        } = cursor.findPos(fromA, -1);
        replaceRange(this, fromI, fromOff, toI, toOff, content, breakAtStart, openStart, openEnd);
      }
    } // Sync the DOM selection to this.state.selection


    updateSelection(mustRead = false, fromPointer = false) {
      if (mustRead || !this.view.observer.selectionRange.focusNode) this.view.observer.readSelectionRange();
      if (!(fromPointer || this.mayControlSelection())) return;
      let force = this.forceSelection;
      this.forceSelection = false;
      let main = this.view.state.selection.main; // FIXME need to handle the case where the selection falls inside a block range

      let anchor = this.domAtPos(main.anchor);
      let head = main.empty ? anchor : this.domAtPos(main.head); // Always reset on Firefox when next to an uneditable node to
      // avoid invisible cursor bugs (#111)

      if (browser.gecko && main.empty && betweenUneditable(anchor)) {
        let dummy = document.createTextNode("");
        this.view.observer.ignore(() => anchor.node.insertBefore(dummy, anchor.node.childNodes[anchor.offset] || null));
        anchor = head = new DOMPos(dummy, 0);
        force = true;
      }

      let domSel = this.view.observer.selectionRange; // If the selection is already here, or in an equivalent position, don't touch it

      if (force || !domSel.focusNode || !isEquivalentPosition(anchor.node, anchor.offset, domSel.anchorNode, domSel.anchorOffset) || !isEquivalentPosition(head.node, head.offset, domSel.focusNode, domSel.focusOffset)) {
        this.view.observer.ignore(() => {
          // Chrome Android will hide the virtual keyboard when tapping
          // inside an uneditable node, and not bring it back when we
          // move the cursor to its proper position. This tries to
          // restore the keyboard by cycling focus.
          if (browser.android && browser.chrome && this.dom.contains(domSel.focusNode) && inUneditable(domSel.focusNode, this.dom)) {
            this.dom.blur();
            this.dom.focus({
              preventScroll: true
            });
          }

          let rawSel = getSelection(this.view.root);
          if (!rawSel) ;else if (main.empty) {
            // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
            if (browser.gecko) {
              let nextTo = nextToUneditable(anchor.node, anchor.offset);

              if (nextTo && nextTo != (1
              /* NextTo.Before */
              | 2
              /* NextTo.After */
              )) {
                let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1
                /* NextTo.Before */
                ? 1 : -1);
                if (text) anchor = new DOMPos(text, nextTo == 1
                /* NextTo.Before */
                ? 0 : text.nodeValue.length);
              }
            }

            rawSel.collapse(anchor.node, anchor.offset);
            if (main.bidiLevel != null && domSel.cursorBidiLevel != null) domSel.cursorBidiLevel = main.bidiLevel;
          } else if (rawSel.extend) {
            // Selection.extend can be used to create an 'inverted' selection
            // (one where the focus is before the anchor), but not all
            // browsers support it yet.
            rawSel.collapse(anchor.node, anchor.offset); // Safari will ignore the call above when the editor is
            // hidden, and then raise an error on the call to extend
            // (#940).

            try {
              rawSel.extend(head.node, head.offset);
            } catch (_) {}
          } else {
            // Primitive (IE) way
            let range = document.createRange();
            if (main.anchor > main.head) [anchor, head] = [head, anchor];
            range.setEnd(head.node, head.offset);
            range.setStart(anchor.node, anchor.offset);
            rawSel.removeAllRanges();
            rawSel.addRange(range);
          }
        });
        this.view.observer.setSelectionRange(anchor, head);
      }

      this.impreciseAnchor = anchor.precise ? null : new DOMPos(domSel.anchorNode, domSel.anchorOffset);
      this.impreciseHead = head.precise ? null : new DOMPos(domSel.focusNode, domSel.focusOffset);
    }

    enforceCursorAssoc() {
      if (this.compositionDeco.size) return;
      let cursor = this.view.state.selection.main;
      let sel = getSelection(this.view.root);
      if (!sel || !cursor.empty || !cursor.assoc || !sel.modify) return;
      let line = LineView.find(this, cursor.head);
      if (!line) return;
      let lineStart = line.posAtStart;
      if (cursor.head == lineStart || cursor.head == lineStart + line.length) return;
      let before = this.coordsAt(cursor.head, -1),
          after = this.coordsAt(cursor.head, 1);
      if (!before || !after || before.bottom > after.top) return;
      let dom = this.domAtPos(cursor.head + cursor.assoc);
      sel.collapse(dom.node, dom.offset);
      sel.modify("move", cursor.assoc < 0 ? "forward" : "backward", "lineboundary");
    }

    mayControlSelection() {
      let active = this.view.root.activeElement;
      return active == this.dom || hasSelection(this.dom, this.view.observer.selectionRange) && !(active && this.dom.contains(active));
    }

    nearest(dom) {
      for (let cur = dom; cur;) {
        let domView = ContentView.get(cur);
        if (domView && domView.rootView == this) return domView;
        cur = cur.parentNode;
      }

      return null;
    }

    posFromDOM(node, offset) {
      let view = this.nearest(node);
      if (!view) throw new RangeError("Trying to find position for a DOM position outside of the document");
      return view.localPosFromDOM(node, offset) + view.posAtStart;
    }

    domAtPos(pos) {
      let {
        i,
        off
      } = this.childCursor().findPos(pos, -1);

      for (; i < this.children.length - 1;) {
        let child = this.children[i];
        if (off < child.length || child instanceof LineView) break;
        i++;
        off = 0;
      }

      return this.children[i].domAtPos(off);
    }

    coordsAt(pos, side) {
      for (let off = this.length, i = this.children.length - 1;; i--) {
        let child = this.children[i],
            start = off - child.breakAfter - child.length;
        if (pos > start || pos == start && child.type != BlockType.WidgetBefore && child.type != BlockType.WidgetAfter && (!i || side == 2 || this.children[i - 1].breakAfter || this.children[i - 1].type == BlockType.WidgetBefore && side > -2)) return child.coordsAt(pos - start, side);
        off = start;
      }
    }

    measureVisibleLineHeights(viewport) {
      let result = [],
          {
        from,
        to
      } = viewport;
      let contentWidth = this.view.contentDOM.clientWidth;
      let isWider = contentWidth > Math.max(this.view.scrollDOM.clientWidth, this.minWidth) + 1;
      let widest = -1,
          ltr = this.view.textDirection == Direction.LTR;

      for (let pos = 0, i = 0; i < this.children.length; i++) {
        let child = this.children[i],
            end = pos + child.length;
        if (end > to) break;

        if (pos >= from) {
          let childRect = child.dom.getBoundingClientRect();
          result.push(childRect.height);

          if (isWider) {
            let last = child.dom.lastChild;
            let rects = last ? clientRectsFor(last) : [];

            if (rects.length) {
              let rect = rects[rects.length - 1];
              let width = ltr ? rect.right - childRect.left : childRect.right - rect.left;

              if (width > widest) {
                widest = width;
                this.minWidth = contentWidth;
                this.minWidthFrom = pos;
                this.minWidthTo = end;
              }
            }
          }
        }

        pos = end + child.breakAfter;
      }

      return result;
    }

    textDirectionAt(pos) {
      let {
        i
      } = this.childPos(pos, 1);
      return getComputedStyle(this.children[i].dom).direction == "rtl" ? Direction.RTL : Direction.LTR;
    }

    measureTextSize() {
      for (let child of this.children) {
        if (child instanceof LineView) {
          let measure = child.measureTextSize();
          if (measure) return measure;
        }
      } // If no workable line exists, force a layout of a measurable element


      let dummy = document.createElement("div"),
          lineHeight,
          charWidth;
      dummy.className = "cm-line";
      dummy.style.width = "99999px";
      dummy.textContent = "abc def ghi jkl mno pqr stu";
      this.view.observer.ignore(() => {
        this.dom.appendChild(dummy);
        let rect = clientRectsFor(dummy.firstChild)[0];
        lineHeight = dummy.getBoundingClientRect().height;
        charWidth = rect ? rect.width / 27 : 7;
        dummy.remove();
      });
      return {
        lineHeight,
        charWidth
      };
    }

    childCursor(pos = this.length) {
      // Move back to start of last element when possible, so that
      // `ChildCursor.findPos` doesn't have to deal with the edge case
      // of being after the last element.
      let i = this.children.length;
      if (i) pos -= this.children[--i].length;
      return new ChildCursor(this.children, pos, i);
    }

    computeBlockGapDeco() {
      let deco = [],
          vs = this.view.viewState;

      for (let pos = 0, i = 0;; i++) {
        let next = i == vs.viewports.length ? null : vs.viewports[i];
        let end = next ? next.from - 1 : this.length;

        if (end > pos) {
          let height = vs.lineBlockAt(end).bottom - vs.lineBlockAt(pos).top;
          deco.push(Decoration.replace({
            widget: new BlockGapWidget(height),
            block: true,
            inclusive: true,
            isBlockGap: true
          }).range(pos, end));
        }

        if (!next) break;
        pos = next.to + 1;
      }

      return Decoration.set(deco);
    }

    updateDeco() {
      let allDeco = this.view.state.facet(decorations).map((d, i) => {
        let dynamic = this.dynamicDecorationMap[i] = typeof d == "function";
        return dynamic ? d(this.view) : d;
      });

      for (let i = allDeco.length; i < allDeco.length + 3; i++) this.dynamicDecorationMap[i] = false;

      return this.decorations = [...allDeco, this.compositionDeco, this.computeBlockGapDeco(), this.view.viewState.lineGapDeco];
    }

    scrollIntoView(target) {
      let {
        range
      } = target;
      let rect = this.coordsAt(range.head, range.empty ? range.assoc : range.head > range.anchor ? -1 : 1),
          other;
      if (!rect) return;
      if (!range.empty && (other = this.coordsAt(range.anchor, range.anchor > range.head ? -1 : 1))) rect = {
        left: Math.min(rect.left, other.left),
        top: Math.min(rect.top, other.top),
        right: Math.max(rect.right, other.right),
        bottom: Math.max(rect.bottom, other.bottom)
      };
      let mLeft = 0,
          mRight = 0,
          mTop = 0,
          mBottom = 0;

      for (let margins of this.view.state.facet(scrollMargins).map(f => f(this.view))) if (margins) {
        let {
          left,
          right,
          top,
          bottom
        } = margins;
        if (left != null) mLeft = Math.max(mLeft, left);
        if (right != null) mRight = Math.max(mRight, right);
        if (top != null) mTop = Math.max(mTop, top);
        if (bottom != null) mBottom = Math.max(mBottom, bottom);
      }

      let targetRect = {
        left: rect.left - mLeft,
        top: rect.top - mTop,
        right: rect.right + mRight,
        bottom: rect.bottom + mBottom
      };
      scrollRectIntoView(this.view.scrollDOM, targetRect, range.head < range.anchor ? -1 : 1, target.x, target.y, target.xMargin, target.yMargin, this.view.textDirection == Direction.LTR);
    }

  }

  function betweenUneditable(pos) {
    return pos.node.nodeType == 1 && pos.node.firstChild && (pos.offset == 0 || pos.node.childNodes[pos.offset - 1].contentEditable == "false") && (pos.offset == pos.node.childNodes.length || pos.node.childNodes[pos.offset].contentEditable == "false");
  }

  class BlockGapWidget extends WidgetType {
    constructor(height) {
      super();
      this.height = height;
    }

    toDOM() {
      let elt = document.createElement("div");
      this.updateDOM(elt);
      return elt;
    }

    eq(other) {
      return other.height == this.height;
    }

    updateDOM(elt) {
      elt.style.height = this.height + "px";
      return true;
    }

    get estimatedHeight() {
      return this.height;
    }

  }

  function compositionSurroundingNode(view) {
    let sel = view.observer.selectionRange;
    let textNode = sel.focusNode && nearbyTextNode(sel.focusNode, sel.focusOffset, 0);
    if (!textNode) return null;
    let cView = view.docView.nearest(textNode);
    if (!cView) return null;

    if (cView instanceof LineView) {
      let topNode = textNode;

      while (topNode.parentNode != cView.dom) topNode = topNode.parentNode;

      let prev = topNode.previousSibling;

      while (prev && !ContentView.get(prev)) prev = prev.previousSibling;

      let pos = prev ? ContentView.get(prev).posAtEnd : cView.posAtStart;
      return {
        from: pos,
        to: pos,
        node: topNode,
        text: textNode
      };
    } else {
      for (;;) {
        let {
          parent
        } = cView;
        if (!parent) return null;
        if (parent instanceof LineView) break;
        cView = parent;
      }

      let from = cView.posAtStart;
      return {
        from,
        to: from + cView.length,
        node: cView.dom,
        text: textNode
      };
    }
  }

  function computeCompositionDeco(view, changes) {
    let surrounding = compositionSurroundingNode(view);
    if (!surrounding) return Decoration.none;
    let {
      from,
      to,
      node,
      text: textNode
    } = surrounding;
    let newFrom = changes.mapPos(from, 1),
        newTo = Math.max(newFrom, changes.mapPos(to, -1));
    let {
      state
    } = view,
        text = node.nodeType == 3 ? node.nodeValue : new DOMReader([], state).readRange(node.firstChild, null).text;

    if (newTo - newFrom < text.length) {
      if (state.doc.sliceString(newFrom, Math.min(state.doc.length, newFrom + text.length), LineBreakPlaceholder) == text) newTo = newFrom + text.length;else if (state.doc.sliceString(Math.max(0, newTo - text.length), newTo, LineBreakPlaceholder) == text) newFrom = newTo - text.length;else return Decoration.none;
    } else if (state.doc.sliceString(newFrom, newTo, LineBreakPlaceholder) != text) {
      return Decoration.none;
    }

    let topView = ContentView.get(node);
    if (topView instanceof CompositionView) topView = topView.widget.topView;else if (topView) topView.parent = null;
    return Decoration.set(Decoration.replace({
      widget: new CompositionWidget(node, textNode, topView),
      inclusive: true
    }).range(newFrom, newTo));
  }

  class CompositionWidget extends WidgetType {
    constructor(top, text, topView) {
      super();
      this.top = top;
      this.text = text;
      this.topView = topView;
    }

    eq(other) {
      return this.top == other.top && this.text == other.text;
    }

    toDOM() {
      return this.top;
    }

    ignoreEvent() {
      return false;
    }

    get customView() {
      return CompositionView;
    }

  }

  function nearbyTextNode(node, offset, side) {
    for (;;) {
      if (node.nodeType == 3) return node;

      if (node.nodeType == 1 && offset > 0 && side <= 0) {
        node = node.childNodes[offset - 1];
        offset = maxOffset(node);
      } else if (node.nodeType == 1 && offset < node.childNodes.length && side >= 0) {
        node = node.childNodes[offset];
        offset = 0;
      } else {
        return null;
      }
    }
  }

  function nextToUneditable(node, offset) {
    if (node.nodeType != 1) return 0;
    return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1
    /* NextTo.Before */
    : 0) | (offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2
    /* NextTo.After */
    : 0);
  }

  class DecorationComparator$1 {
    constructor() {
      this.changes = [];
    }

    compareRange(from, to) {
      addRange(from, to, this.changes);
    }

    comparePoint(from, to) {
      addRange(from, to, this.changes);
    }

  }

  function findChangedDeco(a, b, diff) {
    let comp = new DecorationComparator$1();
    RangeSet.compare(a, b, diff, comp);
    return comp.changes;
  }

  function inUneditable(node, inside) {
    for (let cur = node; cur && cur != inside; cur = cur.assignedSlot || cur.parentNode) {
      if (cur.nodeType == 1 && cur.contentEditable == 'false') {
        return true;
      }
    }

    return false;
  }

  function groupAt(state, pos, bias = 1) {
    let categorize = state.charCategorizer(pos);
    let line = state.doc.lineAt(pos),
        linePos = pos - line.from;
    if (line.length == 0) return EditorSelection.cursor(pos);
    if (linePos == 0) bias = 1;else if (linePos == line.length) bias = -1;
    let from = linePos,
        to = linePos;
    if (bias < 0) from = findClusterBreak(line.text, linePos, false);else to = findClusterBreak(line.text, linePos);
    let cat = categorize(line.text.slice(from, to));

    while (from > 0) {
      let prev = findClusterBreak(line.text, from, false);
      if (categorize(line.text.slice(prev, from)) != cat) break;
      from = prev;
    }

    while (to < line.length) {
      let next = findClusterBreak(line.text, to);
      if (categorize(line.text.slice(to, next)) != cat) break;
      to = next;
    }

    return EditorSelection.range(from + line.from, to + line.from);
  } // Search the DOM for the {node, offset} position closest to the given
  // coordinates. Very inefficient and crude, but can usually be avoided
  // by calling caret(Position|Range)FromPoint instead.


  function getdx(x, rect) {
    return rect.left > x ? rect.left - x : Math.max(0, x - rect.right);
  }

  function getdy(y, rect) {
    return rect.top > y ? rect.top - y : Math.max(0, y - rect.bottom);
  }

  function yOverlap(a, b) {
    return a.top < b.bottom - 1 && a.bottom > b.top + 1;
  }

  function upTop(rect, top) {
    return top < rect.top ? {
      top,
      left: rect.left,
      right: rect.right,
      bottom: rect.bottom
    } : rect;
  }

  function upBot(rect, bottom) {
    return bottom > rect.bottom ? {
      top: rect.top,
      left: rect.left,
      right: rect.right,
      bottom
    } : rect;
  }

  function domPosAtCoords(parent, x, y) {
    let closest,
        closestRect,
        closestX,
        closestY,
        closestOverlap = false;
    let above, below, aboveRect, belowRect;

    for (let child = parent.firstChild; child; child = child.nextSibling) {
      let rects = clientRectsFor(child);

      for (let i = 0; i < rects.length; i++) {
        let rect = rects[i];
        if (closestRect && yOverlap(closestRect, rect)) rect = upTop(upBot(rect, closestRect.bottom), closestRect.top);
        let dx = getdx(x, rect),
            dy = getdy(y, rect);
        if (dx == 0 && dy == 0) return child.nodeType == 3 ? domPosInText(child, x, y) : domPosAtCoords(child, x, y);

        if (!closest || closestY > dy || closestY == dy && closestX > dx) {
          closest = child;
          closestRect = rect;
          closestX = dx;
          closestY = dy;
          closestOverlap = !dx || (dx > 0 ? i < rects.length - 1 : i > 0);
        }

        if (dx == 0) {
          if (y > rect.bottom && (!aboveRect || aboveRect.bottom < rect.bottom)) {
            above = child;
            aboveRect = rect;
          } else if (y < rect.top && (!belowRect || belowRect.top > rect.top)) {
            below = child;
            belowRect = rect;
          }
        } else if (aboveRect && yOverlap(aboveRect, rect)) {
          aboveRect = upBot(aboveRect, rect.bottom);
        } else if (belowRect && yOverlap(belowRect, rect)) {
          belowRect = upTop(belowRect, rect.top);
        }
      }
    }

    if (aboveRect && aboveRect.bottom >= y) {
      closest = above;
      closestRect = aboveRect;
    } else if (belowRect && belowRect.top <= y) {
      closest = below;
      closestRect = belowRect;
    }

    if (!closest) return {
      node: parent,
      offset: 0
    };
    let clipX = Math.max(closestRect.left, Math.min(closestRect.right, x));
    if (closest.nodeType == 3) return domPosInText(closest, clipX, y);
    if (closestOverlap && closest.contentEditable != "false") return domPosAtCoords(closest, clipX, y);
    let offset = Array.prototype.indexOf.call(parent.childNodes, closest) + (x >= (closestRect.left + closestRect.right) / 2 ? 1 : 0);
    return {
      node: parent,
      offset
    };
  }

  function domPosInText(node, x, y) {
    let len = node.nodeValue.length;
    let closestOffset = -1,
        closestDY = 1e9,
        generalSide = 0;

    for (let i = 0; i < len; i++) {
      let rects = textRange(node, i, i + 1).getClientRects();

      for (let j = 0; j < rects.length; j++) {
        let rect = rects[j];
        if (rect.top == rect.bottom) continue;
        if (!generalSide) generalSide = x - rect.left;
        let dy = (rect.top > y ? rect.top - y : y - rect.bottom) - 1;

        if (rect.left - 1 <= x && rect.right + 1 >= x && dy < closestDY) {
          let right = x >= (rect.left + rect.right) / 2,
              after = right;

          if (browser.chrome || browser.gecko) {
            // Check for RTL on browsers that support getting client
            // rects for empty ranges.
            let rectBefore = textRange(node, i).getBoundingClientRect();
            if (rectBefore.left == rect.right) after = !right;
          }

          if (dy <= 0) return {
            node,
            offset: i + (after ? 1 : 0)
          };
          closestOffset = i + (after ? 1 : 0);
          closestDY = dy;
        }
      }
    }

    return {
      node,
      offset: closestOffset > -1 ? closestOffset : generalSide > 0 ? node.nodeValue.length : 0
    };
  }

  function posAtCoords(view, {
    x,
    y
  }, precise, bias = -1) {
    var _a;

    let content = view.contentDOM.getBoundingClientRect(),
        docTop = content.top + view.viewState.paddingTop;
    let block,
        {
      docHeight
    } = view.viewState;
    let yOffset = y - docTop;
    if (yOffset < 0) return 0;
    if (yOffset > docHeight) return view.state.doc.length; // Scan for a text block near the queried y position

    for (let halfLine = view.defaultLineHeight / 2, bounced = false;;) {
      block = view.elementAtHeight(yOffset);
      if (block.type == BlockType.Text) break;

      for (;;) {
        // Move the y position out of this block
        yOffset = bias > 0 ? block.bottom + halfLine : block.top - halfLine;
        if (yOffset >= 0 && yOffset <= docHeight) break; // If the document consists entirely of replaced widgets, we
        // won't find a text block, so return 0

        if (bounced) return precise ? null : 0;
        bounced = true;
        bias = -bias;
      }
    }

    y = docTop + yOffset;
    let lineStart = block.from; // If this is outside of the rendered viewport, we can't determine a position

    if (lineStart < view.viewport.from) return view.viewport.from == 0 ? 0 : precise ? null : posAtCoordsImprecise(view, content, block, x, y);
    if (lineStart > view.viewport.to) return view.viewport.to == view.state.doc.length ? view.state.doc.length : precise ? null : posAtCoordsImprecise(view, content, block, x, y); // Prefer ShadowRootOrDocument.elementFromPoint if present, fall back to document if not

    let doc = view.dom.ownerDocument;
    let root = view.root.elementFromPoint ? view.root : doc;
    let element = root.elementFromPoint(x, y);
    if (element && !view.contentDOM.contains(element)) element = null; // If the element is unexpected, clip x at the sides of the content area and try again

    if (!element) {
      x = Math.max(content.left + 1, Math.min(content.right - 1, x));
      element = root.elementFromPoint(x, y);
      if (element && !view.contentDOM.contains(element)) element = null;
    } // There's visible editor content under the point, so we can try
    // using caret(Position|Range)FromPoint as a shortcut


    let node,
        offset = -1;

    if (element && ((_a = view.docView.nearest(element)) === null || _a === void 0 ? void 0 : _a.isEditable) != false) {
      if (doc.caretPositionFromPoint) {
        let pos = doc.caretPositionFromPoint(x, y);
        if (pos) ({
          offsetNode: node,
          offset
        } = pos);
      } else if (doc.caretRangeFromPoint) {
        let range = doc.caretRangeFromPoint(x, y);

        if (range) {
          ({
            startContainer: node,
            startOffset: offset
          } = range);
          if (!view.contentDOM.contains(node) || browser.safari && isSuspiciousSafariCaretResult(node, offset, x) || browser.chrome && isSuspiciousChromeCaretResult(node, offset, x)) node = undefined;
        }
      }
    } // No luck, do our own (potentially expensive) search


    if (!node || !view.docView.dom.contains(node)) {
      let line = LineView.find(view.docView, lineStart);
      if (!line) return yOffset > block.top + block.height / 2 ? block.to : block.from;
      ({
        node,
        offset
      } = domPosAtCoords(line.dom, x, y));
    }

    return view.docView.posFromDOM(node, offset);
  }

  function posAtCoordsImprecise(view, contentRect, block, x, y) {
    let into = Math.round((x - contentRect.left) * view.defaultCharacterWidth);

    if (view.lineWrapping && block.height > view.defaultLineHeight * 1.5) {
      let line = Math.floor((y - block.top) / view.defaultLineHeight);
      into += line * view.viewState.heightOracle.lineLength;
    }

    let content = view.state.sliceDoc(block.from, block.to);
    return block.from + findColumn(content, into, view.state.tabSize);
  } // In case of a high line height, Safari's caretRangeFromPoint treats
  // the space between lines as belonging to the last character of the
  // line before. This is used to detect such a result so that it can be
  // ignored (issue #401).


  function isSuspiciousSafariCaretResult(node, offset, x) {
    let len;
    if (node.nodeType != 3 || offset != (len = node.nodeValue.length)) return false;

    for (let next = node.nextSibling; next; next = next.nextSibling) if (next.nodeType != 1 || next.nodeName != "BR") return false;

    return textRange(node, len - 1, len).getBoundingClientRect().left > x;
  } // Chrome will move positions between lines to the start of the next line


  function isSuspiciousChromeCaretResult(node, offset, x) {
    if (offset != 0) return false;

    for (let cur = node;;) {
      let parent = cur.parentNode;
      if (!parent || parent.nodeType != 1 || parent.firstChild != cur) return false;
      if (parent.classList.contains("cm-line")) break;
      cur = parent;
    }

    let rect = node.nodeType == 1 ? node.getBoundingClientRect() : textRange(node, 0, Math.max(node.nodeValue.length, 1)).getBoundingClientRect();
    return x - rect.left > 5;
  }

  function moveToLineBoundary(view, start, forward, includeWrap) {
    let line = view.state.doc.lineAt(start.head);
    let coords = !includeWrap || !view.lineWrapping ? null : view.coordsAtPos(start.assoc < 0 && start.head > line.from ? start.head - 1 : start.head);

    if (coords) {
      let editorRect = view.dom.getBoundingClientRect();
      let direction = view.textDirectionAt(line.from);
      let pos = view.posAtCoords({
        x: forward == (direction == Direction.LTR) ? editorRect.right - 1 : editorRect.left + 1,
        y: (coords.top + coords.bottom) / 2
      });
      if (pos != null) return EditorSelection.cursor(pos, forward ? -1 : 1);
    }

    let lineView = LineView.find(view.docView, start.head);
    let end = lineView ? forward ? lineView.posAtEnd : lineView.posAtStart : forward ? line.to : line.from;
    return EditorSelection.cursor(end, forward ? -1 : 1);
  }

  function moveByChar(view, start, forward, by) {
    let line = view.state.doc.lineAt(start.head),
        spans = view.bidiSpans(line);
    let direction = view.textDirectionAt(line.from);

    for (let cur = start, check = null;;) {
      let next = moveVisually(line, spans, direction, cur, forward),
          char = movedOver;

      if (!next) {
        if (line.number == (forward ? view.state.doc.lines : 1)) return cur;
        char = "\n";
        line = view.state.doc.line(line.number + (forward ? 1 : -1));
        spans = view.bidiSpans(line);
        next = EditorSelection.cursor(forward ? line.from : line.to);
      }

      if (!check) {
        if (!by) return next;
        check = by(char);
      } else if (!check(char)) {
        return cur;
      }

      cur = next;
    }
  }

  function byGroup(view, pos, start) {
    let categorize = view.state.charCategorizer(pos);
    let cat = categorize(start);
    return next => {
      let nextCat = categorize(next);
      if (cat == CharCategory.Space) cat = nextCat;
      return cat == nextCat;
    };
  }

  function moveVertically(view, start, forward, distance) {
    let startPos = start.head,
        dir = forward ? 1 : -1;
    if (startPos == (forward ? view.state.doc.length : 0)) return EditorSelection.cursor(startPos, start.assoc);
    let goal = start.goalColumn,
        startY;
    let rect = view.contentDOM.getBoundingClientRect();
    let startCoords = view.coordsAtPos(startPos),
        docTop = view.documentTop;

    if (startCoords) {
      if (goal == null) goal = startCoords.left - rect.left;
      startY = dir < 0 ? startCoords.top : startCoords.bottom;
    } else {
      let line = view.viewState.lineBlockAt(startPos);
      if (goal == null) goal = Math.min(rect.right - rect.left, view.defaultCharacterWidth * (startPos - line.from));
      startY = (dir < 0 ? line.top : line.bottom) + docTop;
    }

    let resolvedGoal = rect.left + goal;
    let dist = distance !== null && distance !== void 0 ? distance : view.defaultLineHeight >> 1;

    for (let extra = 0;; extra += 10) {
      let curY = startY + (dist + extra) * dir;
      let pos = posAtCoords(view, {
        x: resolvedGoal,
        y: curY
      }, false, dir);
      if (curY < rect.top || curY > rect.bottom || (dir < 0 ? pos < startPos : pos > startPos)) return EditorSelection.cursor(pos, start.assoc, undefined, goal);
    }
  }

  function skipAtoms(view, oldPos, pos) {
    let atoms = view.state.facet(atomicRanges).map(f => f(view));

    for (;;) {
      let moved = false;

      for (let set of atoms) {
        set.between(pos.from - 1, pos.from + 1, (from, to, value) => {
          if (pos.from > from && pos.from < to) {
            pos = oldPos.head > pos.from ? EditorSelection.cursor(from, 1) : EditorSelection.cursor(to, -1);
            moved = true;
          }
        });
      }

      if (!moved) return pos;
    }
  } // This will also be where dragging info and such goes


  class InputState {
    constructor(view) {
      this.lastKeyCode = 0;
      this.lastKeyTime = 0;
      this.lastTouchTime = 0;
      this.lastFocusTime = 0;
      this.lastScrollTop = 0;
      this.lastScrollLeft = 0;
      this.chromeScrollHack = -1; // On iOS, some keys need to have their default behavior happen
      // (after which we retroactively handle them and reset the DOM) to
      // avoid messing up the virtual keyboard state.

      this.pendingIOSKey = undefined;
      this.lastSelectionOrigin = null;
      this.lastSelectionTime = 0;
      this.lastEscPress = 0;
      this.lastContextMenu = 0;
      this.scrollHandlers = [];
      this.registeredEvents = [];
      this.customHandlers = []; // -1 means not in a composition. Otherwise, this counts the number
      // of changes made during the composition. The count is used to
      // avoid treating the start state of the composition, before any
      // changes have been made, as part of the composition.

      this.composing = -1; // Tracks whether the next change should be marked as starting the
      // composition (null means no composition, true means next is the
      // first, false means first has already been marked for this
      // composition)

      this.compositionFirstChange = null;
      this.compositionEndedAt = 0;
      this.mouseSelection = null;

      for (let type in handlers) {
        let handler = handlers[type];
        view.contentDOM.addEventListener(type, event => {
          if (!eventBelongsToEditor(view, event) || this.ignoreDuringComposition(event)) return;
          if (type == "keydown" && this.keydown(view, event)) return;
          if (this.mustFlushObserver(event)) view.observer.forceFlush();
          if (this.runCustomHandlers(type, view, event)) event.preventDefault();else handler(view, event);
        }, handlerOptions[type]);
        this.registeredEvents.push(type);
      }

      if (browser.chrome && browser.chrome_version == 102) {
        // FIXME remove at some point
        // On Chrome 102, viewport updates somehow stop wheel-based
        // scrolling. Turning off pointer events during the scroll seems
        // to avoid the issue.
        view.scrollDOM.addEventListener("wheel", () => {
          if (this.chromeScrollHack < 0) view.contentDOM.style.pointerEvents = "none";else window.clearTimeout(this.chromeScrollHack);
          this.chromeScrollHack = setTimeout(() => {
            this.chromeScrollHack = -1;
            view.contentDOM.style.pointerEvents = "";
          }, 100);
        }, {
          passive: true
        });
      }

      this.notifiedFocused = view.hasFocus; // On Safari adding an input event handler somehow prevents an
      // issue where the composition vanishes when you press enter.

      if (browser.safari) view.contentDOM.addEventListener("input", () => null);
    }

    setSelectionOrigin(origin) {
      this.lastSelectionOrigin = origin;
      this.lastSelectionTime = Date.now();
    }

    ensureHandlers(view, plugins) {
      var _a;

      let handlers;
      this.customHandlers = [];

      for (let plugin of plugins) if (handlers = (_a = plugin.update(view).spec) === null || _a === void 0 ? void 0 : _a.domEventHandlers) {
        this.customHandlers.push({
          plugin: plugin.value,
          handlers
        });

        for (let type in handlers) if (this.registeredEvents.indexOf(type) < 0 && type != "scroll") {
          this.registeredEvents.push(type);
          view.contentDOM.addEventListener(type, event => {
            if (!eventBelongsToEditor(view, event)) return;
            if (this.runCustomHandlers(type, view, event)) event.preventDefault();
          });
        }
      }
    }

    runCustomHandlers(type, view, event) {
      for (let set of this.customHandlers) {
        let handler = set.handlers[type];

        if (handler) {
          try {
            if (handler.call(set.plugin, event, view) || event.defaultPrevented) return true;
          } catch (e) {
            logException(view.state, e);
          }
        }
      }

      return false;
    }

    runScrollHandlers(view, event) {
      this.lastScrollTop = view.scrollDOM.scrollTop;
      this.lastScrollLeft = view.scrollDOM.scrollLeft;

      for (let set of this.customHandlers) {
        let handler = set.handlers.scroll;

        if (handler) {
          try {
            handler.call(set.plugin, event, view);
          } catch (e) {
            logException(view.state, e);
          }
        }
      }
    }

    keydown(view, event) {
      // Must always run, even if a custom handler handled the event
      this.lastKeyCode = event.keyCode;
      this.lastKeyTime = Date.now();
      if (event.keyCode == 9 && Date.now() < this.lastEscPress + 2000) return true; // Chrome for Android usually doesn't fire proper key events, but
      // occasionally does, usually surrounded by a bunch of complicated
      // composition changes. When an enter or backspace key event is
      // seen, hold off on handling DOM events for a bit, and then
      // dispatch it.

      if (browser.android && browser.chrome && !event.synthetic && (event.keyCode == 13 || event.keyCode == 8)) {
        view.observer.delayAndroidKey(event.key, event.keyCode);
        return true;
      } // Prevent the default behavior of Enter on iOS makes the
      // virtual keyboard get stuck in the wrong (lowercase)
      // state. So we let it go through, and then, in
      // applyDOMChange, notify key handlers of it and reset to
      // the state they produce.


      let pending;

      if (browser.ios && !event.synthetic && !event.altKey && !event.metaKey && ((pending = PendingKeys.find(key => key.keyCode == event.keyCode)) && !event.ctrlKey || EmacsyPendingKeys.indexOf(event.key) > -1 && event.ctrlKey && !event.shiftKey)) {
        this.pendingIOSKey = pending || event;
        setTimeout(() => this.flushIOSKey(view), 250);
        return true;
      }

      return false;
    }

    flushIOSKey(view) {
      let key = this.pendingIOSKey;
      if (!key) return false;
      this.pendingIOSKey = undefined;
      return dispatchKey(view.contentDOM, key.key, key.keyCode);
    }

    ignoreDuringComposition(event) {
      if (!/^key/.test(event.type)) return false;
      if (this.composing > 0) return true; // See https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/.
      // On some input method editors (IMEs), the Enter key is used to
      // confirm character selection. On Safari, when Enter is pressed,
      // compositionend and keydown events are sometimes emitted in the
      // wrong order. The key event should still be ignored, even when
      // it happens after the compositionend event.

      if (browser.safari && !browser.ios && Date.now() - this.compositionEndedAt < 100) {
        this.compositionEndedAt = 0;
        return true;
      }

      return false;
    }

    mustFlushObserver(event) {
      return event.type == "keydown" && event.keyCode != 229;
    }

    startMouseSelection(mouseSelection) {
      if (this.mouseSelection) this.mouseSelection.destroy();
      this.mouseSelection = mouseSelection;
    }

    update(update) {
      if (this.mouseSelection) this.mouseSelection.update(update);
      if (update.transactions.length) this.lastKeyCode = this.lastSelectionTime = 0;
    }

    destroy() {
      if (this.mouseSelection) this.mouseSelection.destroy();
    }

  }

  const PendingKeys = [{
    key: "Backspace",
    keyCode: 8,
    inputType: "deleteContentBackward"
  }, {
    key: "Enter",
    keyCode: 13,
    inputType: "insertParagraph"
  }, {
    key: "Delete",
    keyCode: 46,
    inputType: "deleteContentForward"
  }];
  const EmacsyPendingKeys = "dthko"; // Key codes for modifier keys

  const modifierCodes = [16, 17, 18, 20, 91, 92, 224, 225];

  class MouseSelection {
    constructor(view, startEvent, style, mustSelect) {
      this.view = view;
      this.style = style;
      this.mustSelect = mustSelect;
      this.lastEvent = startEvent;
      let doc = view.contentDOM.ownerDocument;
      doc.addEventListener("mousemove", this.move = this.move.bind(this));
      doc.addEventListener("mouseup", this.up = this.up.bind(this));
      this.extend = startEvent.shiftKey;
      this.multiple = view.state.facet(EditorState.allowMultipleSelections) && addsSelectionRange(view, startEvent);
      this.dragMove = dragMovesSelection(view, startEvent);
      this.dragging = isInPrimarySelection(view, startEvent) && getClickType(startEvent) == 1 ? null : false; // When clicking outside of the selection, immediately apply the
      // effect of starting the selection

      if (this.dragging === false) {
        startEvent.preventDefault();
        this.select(startEvent);
      }
    }

    move(event) {
      if (event.buttons == 0) return this.destroy();
      if (this.dragging !== false) return;
      this.select(this.lastEvent = event);
    }

    up(event) {
      if (this.dragging == null) this.select(this.lastEvent);
      if (!this.dragging) event.preventDefault();
      this.destroy();
    }

    destroy() {
      let doc = this.view.contentDOM.ownerDocument;
      doc.removeEventListener("mousemove", this.move);
      doc.removeEventListener("mouseup", this.up);
      this.view.inputState.mouseSelection = null;
    }

    select(event) {
      let selection = this.style.get(event, this.extend, this.multiple);
      if (this.mustSelect || !selection.eq(this.view.state.selection) || selection.main.assoc != this.view.state.selection.main.assoc) this.view.dispatch({
        selection,
        userEvent: "select.pointer",
        scrollIntoView: true
      });
      this.mustSelect = false;
    }

    update(update) {
      if (update.docChanged && this.dragging) this.dragging = this.dragging.map(update.changes);
      if (this.style.update(update)) setTimeout(() => this.select(this.lastEvent), 20);
    }

  }

  function addsSelectionRange(view, event) {
    let facet = view.state.facet(clickAddsSelectionRange);
    return facet.length ? facet[0](event) : browser.mac ? event.metaKey : event.ctrlKey;
  }

  function dragMovesSelection(view, event) {
    let facet = view.state.facet(dragMovesSelection$1);
    return facet.length ? facet[0](event) : browser.mac ? !event.altKey : !event.ctrlKey;
  }

  function isInPrimarySelection(view, event) {
    let {
      main
    } = view.state.selection;
    if (main.empty) return false; // On boundary clicks, check whether the coordinates are inside the
    // selection's client rectangles

    let sel = getSelection(view.root);
    if (!sel || sel.rangeCount == 0) return true;
    let rects = sel.getRangeAt(0).getClientRects();

    for (let i = 0; i < rects.length; i++) {
      let rect = rects[i];
      if (rect.left <= event.clientX && rect.right >= event.clientX && rect.top <= event.clientY && rect.bottom >= event.clientY) return true;
    }

    return false;
  }

  function eventBelongsToEditor(view, event) {
    if (!event.bubbles) return true;
    if (event.defaultPrevented) return false;

    for (let node = event.target, cView; node != view.contentDOM; node = node.parentNode) if (!node || node.nodeType == 11 || (cView = ContentView.get(node)) && cView.ignoreEvent(event)) return false;

    return true;
  }

  const handlers = /*@__PURE__*/Object.create(null);
  const handlerOptions = /*@__PURE__*/Object.create(null); // This is very crude, but unfortunately both these browsers _pretend_
  // that they have a clipboard API—all the objects and methods are
  // there, they just don't work, and they are hard to test.

  const brokenClipboardAPI = browser.ie && browser.ie_version < 15 || browser.ios && browser.webkit_version < 604;

  function capturePaste(view) {
    let parent = view.dom.parentNode;
    if (!parent) return;
    let target = parent.appendChild(document.createElement("textarea"));
    target.style.cssText = "position: fixed; left: -10000px; top: 10px";
    target.focus();
    setTimeout(() => {
      view.focus();
      target.remove();
      doPaste(view, target.value);
    }, 50);
  }

  function doPaste(view, input) {
    let {
      state
    } = view,
        changes,
        i = 1,
        text = state.toText(input);
    let byLine = text.lines == state.selection.ranges.length;
    let linewise = lastLinewiseCopy != null && state.selection.ranges.every(r => r.empty) && lastLinewiseCopy == text.toString();

    if (linewise) {
      let lastLine = -1;
      changes = state.changeByRange(range => {
        let line = state.doc.lineAt(range.from);
        if (line.from == lastLine) return {
          range
        };
        lastLine = line.from;
        let insert = state.toText((byLine ? text.line(i++).text : input) + state.lineBreak);
        return {
          changes: {
            from: line.from,
            insert
          },
          range: EditorSelection.cursor(range.from + insert.length)
        };
      });
    } else if (byLine) {
      changes = state.changeByRange(range => {
        let line = text.line(i++);
        return {
          changes: {
            from: range.from,
            to: range.to,
            insert: line.text
          },
          range: EditorSelection.cursor(range.from + line.length)
        };
      });
    } else {
      changes = state.replaceSelection(text);
    }

    view.dispatch(changes, {
      userEvent: "input.paste",
      scrollIntoView: true
    });
  }

  handlers.keydown = (view, event) => {
    view.inputState.setSelectionOrigin("select");
    if (event.keyCode == 27) view.inputState.lastEscPress = Date.now();else if (modifierCodes.indexOf(event.keyCode) < 0) view.inputState.lastEscPress = 0;
  };

  handlers.touchstart = (view, e) => {
    view.inputState.lastTouchTime = Date.now();
    view.inputState.setSelectionOrigin("select.pointer");
  };

  handlers.touchmove = view => {
    view.inputState.setSelectionOrigin("select.pointer");
  };

  handlerOptions.touchstart = handlerOptions.touchmove = {
    passive: true
  };

  handlers.mousedown = (view, event) => {
    view.observer.flush();
    if (view.inputState.lastTouchTime > Date.now() - 2000) return; // Ignore touch interaction

    let style = null;

    for (let makeStyle of view.state.facet(mouseSelectionStyle)) {
      style = makeStyle(view, event);
      if (style) break;
    }

    if (!style && event.button == 0) style = basicMouseSelection(view, event);

    if (style) {
      let mustFocus = view.root.activeElement != view.contentDOM;
      if (mustFocus) view.observer.ignore(() => focusPreventScroll(view.contentDOM));
      view.inputState.startMouseSelection(new MouseSelection(view, event, style, mustFocus));
    }
  };

  function rangeForClick(view, pos, bias, type) {
    if (type == 1) {
      // Single click
      return EditorSelection.cursor(pos, bias);
    } else if (type == 2) {
      // Double click
      return groupAt(view.state, pos, bias);
    } else {
      // Triple click
      let visual = LineView.find(view.docView, pos),
          line = view.state.doc.lineAt(visual ? visual.posAtEnd : pos);
      let from = visual ? visual.posAtStart : line.from,
          to = visual ? visual.posAtEnd : line.to;
      if (to < view.state.doc.length && to == line.to) to++;
      return EditorSelection.range(from, to);
    }
  }

  let insideY = (y, rect) => y >= rect.top && y <= rect.bottom;

  let inside = (x, y, rect) => insideY(y, rect) && x >= rect.left && x <= rect.right; // Try to determine, for the given coordinates, associated with the
  // given position, whether they are related to the element before or
  // the element after the position.


  function findPositionSide(view, pos, x, y) {
    let line = LineView.find(view.docView, pos);
    if (!line) return 1;
    let off = pos - line.posAtStart; // Line boundaries point into the line

    if (off == 0) return 1;
    if (off == line.length) return -1; // Positions on top of an element point at that element

    let before = line.coordsAt(off, -1);
    if (before && inside(x, y, before)) return -1;
    let after = line.coordsAt(off, 1);
    if (after && inside(x, y, after)) return 1; // This is probably a line wrap point. Pick before if the point is
    // beside it.

    return before && insideY(y, before) ? -1 : 1;
  }

  function queryPos(view, event) {
    let pos = view.posAtCoords({
      x: event.clientX,
      y: event.clientY
    }, false);
    return {
      pos,
      bias: findPositionSide(view, pos, event.clientX, event.clientY)
    };
  }

  const BadMouseDetail = browser.ie && browser.ie_version <= 11;
  let lastMouseDown = null,
      lastMouseDownCount = 0,
      lastMouseDownTime = 0;

  function getClickType(event) {
    if (!BadMouseDetail) return event.detail;
    let last = lastMouseDown,
        lastTime = lastMouseDownTime;
    lastMouseDown = event;
    lastMouseDownTime = Date.now();
    return lastMouseDownCount = !last || lastTime > Date.now() - 400 && Math.abs(last.clientX - event.clientX) < 2 && Math.abs(last.clientY - event.clientY) < 2 ? (lastMouseDownCount + 1) % 3 : 1;
  }

  function basicMouseSelection(view, event) {
    let start = queryPos(view, event),
        type = getClickType(event);
    let startSel = view.state.selection;
    let last = start,
        lastEvent = event;
    return {
      update(update) {
        if (update.docChanged) {
          start.pos = update.changes.mapPos(start.pos);
          startSel = startSel.map(update.changes);
          lastEvent = null;
        }
      },

      get(event, extend, multiple) {
        let cur;
        if (lastEvent && event.clientX == lastEvent.clientX && event.clientY == lastEvent.clientY) cur = last;else {
          cur = last = queryPos(view, event);
          lastEvent = event;
        }
        let range = rangeForClick(view, cur.pos, cur.bias, type);

        if (start.pos != cur.pos && !extend) {
          let startRange = rangeForClick(view, start.pos, start.bias, type);
          let from = Math.min(startRange.from, range.from),
              to = Math.max(startRange.to, range.to);
          range = from < range.from ? EditorSelection.range(from, to) : EditorSelection.range(to, from);
        }

        if (extend) return startSel.replaceRange(startSel.main.extend(range.from, range.to));else if (multiple && startSel.ranges.length > 1 && startSel.ranges.some(r => r.eq(range))) return removeRange(startSel, range);else if (multiple) return startSel.addRange(range);else return EditorSelection.create([range]);
      }

    };
  }

  function removeRange(sel, range) {
    for (let i = 0;; i++) {
      if (sel.ranges[i].eq(range)) return EditorSelection.create(sel.ranges.slice(0, i).concat(sel.ranges.slice(i + 1)), sel.mainIndex == i ? 0 : sel.mainIndex - (sel.mainIndex > i ? 1 : 0));
    }
  }

  handlers.dragstart = (view, event) => {
    let {
      selection: {
        main
      }
    } = view.state;
    let {
      mouseSelection
    } = view.inputState;
    if (mouseSelection) mouseSelection.dragging = main;

    if (event.dataTransfer) {
      event.dataTransfer.setData("Text", view.state.sliceDoc(main.from, main.to));
      event.dataTransfer.effectAllowed = "copyMove";
    }
  };

  function dropText(view, event, text, direct) {
    if (!text) return;
    let dropPos = view.posAtCoords({
      x: event.clientX,
      y: event.clientY
    }, false);
    event.preventDefault();
    let {
      mouseSelection
    } = view.inputState;
    let del = direct && mouseSelection && mouseSelection.dragging && mouseSelection.dragMove ? {
      from: mouseSelection.dragging.from,
      to: mouseSelection.dragging.to
    } : null;
    let ins = {
      from: dropPos,
      insert: text
    };
    let changes = view.state.changes(del ? [del, ins] : ins);
    view.focus();
    view.dispatch({
      changes,
      selection: {
        anchor: changes.mapPos(dropPos, -1),
        head: changes.mapPos(dropPos, 1)
      },
      userEvent: del ? "move.drop" : "input.drop"
    });
  }

  handlers.drop = (view, event) => {
    if (!event.dataTransfer) return;
    if (view.state.readOnly) return event.preventDefault();
    let files = event.dataTransfer.files;

    if (files && files.length) {
      // For a file drop, read the file's text.
      event.preventDefault();
      let text = Array(files.length),
          read = 0;

      let finishFile = () => {
        if (++read == files.length) dropText(view, event, text.filter(s => s != null).join(view.state.lineBreak), false);
      };

      for (let i = 0; i < files.length; i++) {
        let reader = new FileReader();
        reader.onerror = finishFile;

        reader.onload = () => {
          if (!/[\x00-\x08\x0e-\x1f]{2}/.test(reader.result)) text[i] = reader.result;
          finishFile();
        };

        reader.readAsText(files[i]);
      }
    } else {
      dropText(view, event, event.dataTransfer.getData("Text"), true);
    }
  };

  handlers.paste = (view, event) => {
    if (view.state.readOnly) return event.preventDefault();
    view.observer.flush();
    let data = brokenClipboardAPI ? null : event.clipboardData;

    if (data) {
      doPaste(view, data.getData("text/plain"));
      event.preventDefault();
    } else {
      capturePaste(view);
    }
  };

  function captureCopy(view, text) {
    // The extra wrapper is somehow necessary on IE/Edge to prevent the
    // content from being mangled when it is put onto the clipboard
    let parent = view.dom.parentNode;
    if (!parent) return;
    let target = parent.appendChild(document.createElement("textarea"));
    target.style.cssText = "position: fixed; left: -10000px; top: 10px";
    target.value = text;
    target.focus();
    target.selectionEnd = text.length;
    target.selectionStart = 0;
    setTimeout(() => {
      target.remove();
      view.focus();
    }, 50);
  }

  function copiedRange(state) {
    let content = [],
        ranges = [],
        linewise = false;

    for (let range of state.selection.ranges) if (!range.empty) {
      content.push(state.sliceDoc(range.from, range.to));
      ranges.push(range);
    }

    if (!content.length) {
      // Nothing selected, do a line-wise copy
      let upto = -1;

      for (let {
        from
      } of state.selection.ranges) {
        let line = state.doc.lineAt(from);

        if (line.number > upto) {
          content.push(line.text);
          ranges.push({
            from: line.from,
            to: Math.min(state.doc.length, line.to + 1)
          });
        }

        upto = line.number;
      }

      linewise = true;
    }

    return {
      text: content.join(state.lineBreak),
      ranges,
      linewise
    };
  }

  let lastLinewiseCopy = null;

  handlers.copy = handlers.cut = (view, event) => {
    let {
      text,
      ranges,
      linewise
    } = copiedRange(view.state);
    if (!text && !linewise) return;
    lastLinewiseCopy = linewise ? text : null;
    let data = brokenClipboardAPI ? null : event.clipboardData;

    if (data) {
      event.preventDefault();
      data.clearData();
      data.setData("text/plain", text);
    } else {
      captureCopy(view, text);
    }

    if (event.type == "cut" && !view.state.readOnly) view.dispatch({
      changes: ranges,
      scrollIntoView: true,
      userEvent: "delete.cut"
    });
  };

  function updateForFocusChange(view) {
    setTimeout(() => {
      if (view.hasFocus != view.inputState.notifiedFocused) view.update([]);
    }, 10);
  }

  handlers.focus = view => {
    view.inputState.lastFocusTime = Date.now(); // When focusing reset the scroll position, move it back to where it was

    if (!view.scrollDOM.scrollTop && (view.inputState.lastScrollTop || view.inputState.lastScrollLeft)) {
      view.scrollDOM.scrollTop = view.inputState.lastScrollTop;
      view.scrollDOM.scrollLeft = view.inputState.lastScrollLeft;
    }

    updateForFocusChange(view);
  };

  handlers.blur = view => {
    view.observer.clearSelectionRange();
    updateForFocusChange(view);
  };

  handlers.compositionstart = handlers.compositionupdate = view => {
    if (view.inputState.compositionFirstChange == null) view.inputState.compositionFirstChange = true;

    if (view.inputState.composing < 0) {
      // FIXME possibly set a timeout to clear it again on Android
      view.inputState.composing = 0;
    }
  };

  handlers.compositionend = view => {
    view.inputState.composing = -1;
    view.inputState.compositionEndedAt = Date.now();
    view.inputState.compositionFirstChange = null;
    if (browser.chrome && browser.android) view.observer.flushSoon();
    setTimeout(() => {
      // Force the composition state to be cleared if it hasn't already been
      if (view.inputState.composing < 0 && view.docView.compositionDeco.size) view.update([]);
    }, 50);
  };

  handlers.contextmenu = view => {
    view.inputState.lastContextMenu = Date.now();
  };

  handlers.beforeinput = (view, event) => {
    var _a; // Because Chrome Android doesn't fire useful key events, use
    // beforeinput to detect backspace (and possibly enter and delete,
    // but those usually don't even seem to fire beforeinput events at
    // the moment) and fake a key event for it.
    //
    // (preventDefault on beforeinput, though supported in the spec,
    // seems to do nothing at all on Chrome).


    let pending;

    if (browser.chrome && browser.android && (pending = PendingKeys.find(key => key.inputType == event.inputType))) {
      view.observer.delayAndroidKey(pending.key, pending.keyCode);

      if (pending.key == "Backspace" || pending.key == "Delete") {
        let startViewHeight = ((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0;
        setTimeout(() => {
          var _a; // Backspacing near uneditable nodes on Chrome Android sometimes
          // closes the virtual keyboard. This tries to crudely detect
          // that and refocus to get it back.


          if ((((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0) > startViewHeight + 10 && view.hasFocus) {
            view.contentDOM.blur();
            view.focus();
          }
        }, 100);
      }
    }
  };

  const wrappingWhiteSpace = ["pre-wrap", "normal", "pre-line", "break-spaces"];

  class HeightOracle {
    constructor() {
      this.doc = Text.empty;
      this.lineWrapping = false;
      this.heightSamples = {};
      this.lineHeight = 14;
      this.charWidth = 7;
      this.lineLength = 30; // Used to track, during updateHeight, if any actual heights changed

      this.heightChanged = false;
    }

    heightForGap(from, to) {
      let lines = this.doc.lineAt(to).number - this.doc.lineAt(from).number + 1;
      if (this.lineWrapping) lines += Math.ceil((to - from - lines * this.lineLength * 0.5) / this.lineLength);
      return this.lineHeight * lines;
    }

    heightForLine(length) {
      if (!this.lineWrapping) return this.lineHeight;
      let lines = 1 + Math.max(0, Math.ceil((length - this.lineLength) / (this.lineLength - 5)));
      return lines * this.lineHeight;
    }

    setDoc(doc) {
      this.doc = doc;
      return this;
    }

    mustRefreshForWrapping(whiteSpace) {
      return wrappingWhiteSpace.indexOf(whiteSpace) > -1 != this.lineWrapping;
    }

    mustRefreshForHeights(lineHeights) {
      let newHeight = false;

      for (let i = 0; i < lineHeights.length; i++) {
        let h = lineHeights[i];

        if (h < 0) {
          i++;
        } else if (!this.heightSamples[Math.floor(h * 10)]) {
          // Round to .1 pixels
          newHeight = true;
          this.heightSamples[Math.floor(h * 10)] = true;
        }
      }

      return newHeight;
    }

    refresh(whiteSpace, lineHeight, charWidth, lineLength, knownHeights) {
      let lineWrapping = wrappingWhiteSpace.indexOf(whiteSpace) > -1;
      let changed = Math.round(lineHeight) != Math.round(this.lineHeight) || this.lineWrapping != lineWrapping;
      this.lineWrapping = lineWrapping;
      this.lineHeight = lineHeight;
      this.charWidth = charWidth;
      this.lineLength = lineLength;

      if (changed) {
        this.heightSamples = {};

        for (let i = 0; i < knownHeights.length; i++) {
          let h = knownHeights[i];
          if (h < 0) i++;else this.heightSamples[Math.floor(h * 10)] = true;
        }
      }

      return changed;
    }

  } // This object is used by `updateHeight` to make DOM measurements
  // arrive at the right nides. The `heights` array is a sequence of
  // block heights, starting from position `from`.


  class MeasuredHeights {
    constructor(from, heights) {
      this.from = from;
      this.heights = heights;
      this.index = 0;
    }

    get more() {
      return this.index < this.heights.length;
    }

  }
  /**
  Record used to represent information about a block-level element
  in the editor view.
  */


  class BlockInfo {
    /**
    @internal
    */
    constructor(
    /**
    The start of the element in the document.
    */
    from,
    /**
    The length of the element.
    */
    length,
    /**
    The top position of the element (relative to the top of the
    document).
    */
    top,
    /**
    Its height.
    */
    height,
    /**
    The type of element this is. When querying lines, this may be
    an array of all the blocks that make up the line.
    */
    type) {
      this.from = from;
      this.length = length;
      this.top = top;
      this.height = height;
      this.type = type;
    }
    /**
    The end of the element as a document position.
    */


    get to() {
      return this.from + this.length;
    }
    /**
    The bottom position of the element.
    */


    get bottom() {
      return this.top + this.height;
    }
    /**
    @internal
    */


    join(other) {
      let detail = (Array.isArray(this.type) ? this.type : [this]).concat(Array.isArray(other.type) ? other.type : [other]);
      return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, detail);
    }

  }

  var QueryType = /*@__PURE__*/function (QueryType) {
    QueryType[QueryType["ByPos"] = 0] = "ByPos";
    QueryType[QueryType["ByHeight"] = 1] = "ByHeight";
    QueryType[QueryType["ByPosNoHeight"] = 2] = "ByPosNoHeight";
    return QueryType;
  }(QueryType || (QueryType = {}));

  const Epsilon = 1e-3;

  class HeightMap {
    constructor(length, // The number of characters covered
    height, // Height of this part of the document
    flags = 2
    /* Flag.Outdated */
    ) {
      this.length = length;
      this.height = height;
      this.flags = flags;
    }

    get outdated() {
      return (this.flags & 2
      /* Flag.Outdated */
      ) > 0;
    }

    set outdated(value) {
      this.flags = (value ? 2
      /* Flag.Outdated */
      : 0) | this.flags & ~2
      /* Flag.Outdated */
      ;
    }

    setHeight(oracle, height) {
      if (this.height != height) {
        if (Math.abs(this.height - height) > Epsilon) oracle.heightChanged = true;
        this.height = height;
      }
    } // Base case is to replace a leaf node, which simply builds a tree
    // from the new nodes and returns that (HeightMapBranch and
    // HeightMapGap override this to actually use from/to)


    replace(_from, _to, nodes) {
      return HeightMap.of(nodes);
    } // Again, these are base cases, and are overridden for branch and gap nodes.


    decomposeLeft(_to, result) {
      result.push(this);
    }

    decomposeRight(_from, result) {
      result.push(this);
    }

    applyChanges(decorations, oldDoc, oracle, changes) {
      let me = this;

      for (let i = changes.length - 1; i >= 0; i--) {
        let {
          fromA,
          toA,
          fromB,
          toB
        } = changes[i];
        let start = me.lineAt(fromA, QueryType.ByPosNoHeight, oldDoc, 0, 0);
        let end = start.to >= toA ? start : me.lineAt(toA, QueryType.ByPosNoHeight, oldDoc, 0, 0);
        toB += end.to - toA;
        toA = end.to;

        while (i > 0 && start.from <= changes[i - 1].toA) {
          fromA = changes[i - 1].fromA;
          fromB = changes[i - 1].fromB;
          i--;
          if (fromA < start.from) start = me.lineAt(fromA, QueryType.ByPosNoHeight, oldDoc, 0, 0);
        }

        fromB += start.from - fromA;
        fromA = start.from;
        let nodes = NodeBuilder.build(oracle, decorations, fromB, toB);
        me = me.replace(fromA, toA, nodes);
      }

      return me.updateHeight(oracle, 0);
    }

    static empty() {
      return new HeightMapText(0, 0);
    } // nodes uses null values to indicate the position of line breaks.
    // There are never line breaks at the start or end of the array, or
    // two line breaks next to each other, and the array isn't allowed
    // to be empty (same restrictions as return value from the builder).


    static of(nodes) {
      if (nodes.length == 1) return nodes[0];
      let i = 0,
          j = nodes.length,
          before = 0,
          after = 0;

      for (;;) {
        if (i == j) {
          if (before > after * 2) {
            let split = nodes[i - 1];
            if (split.break) nodes.splice(--i, 1, split.left, null, split.right);else nodes.splice(--i, 1, split.left, split.right);
            j += 1 + split.break;
            before -= split.size;
          } else if (after > before * 2) {
            let split = nodes[j];
            if (split.break) nodes.splice(j, 1, split.left, null, split.right);else nodes.splice(j, 1, split.left, split.right);
            j += 2 + split.break;
            after -= split.size;
          } else {
            break;
          }
        } else if (before < after) {
          let next = nodes[i++];
          if (next) before += next.size;
        } else {
          let next = nodes[--j];
          if (next) after += next.size;
        }
      }

      let brk = 0;

      if (nodes[i - 1] == null) {
        brk = 1;
        i--;
      } else if (nodes[i] == null) {
        brk = 1;
        j++;
      }

      return new HeightMapBranch(HeightMap.of(nodes.slice(0, i)), brk, HeightMap.of(nodes.slice(j)));
    }

  }

  HeightMap.prototype.size = 1;

  class HeightMapBlock extends HeightMap {
    constructor(length, height, type) {
      super(length, height);
      this.type = type;
    }

    blockAt(_height, _doc, top, offset) {
      return new BlockInfo(offset, this.length, top, this.height, this.type);
    }

    lineAt(_value, _type, doc, top, offset) {
      return this.blockAt(0, doc, top, offset);
    }

    forEachLine(from, to, doc, top, offset, f) {
      if (from <= offset + this.length && to >= offset) f(this.blockAt(0, doc, top, offset));
    }

    updateHeight(oracle, offset = 0, _force = false, measured) {
      if (measured && measured.from <= offset && measured.more) this.setHeight(oracle, measured.heights[measured.index++]);
      this.outdated = false;
      return this;
    }

    toString() {
      return `block(${this.length})`;
    }

  }

  class HeightMapText extends HeightMapBlock {
    constructor(length, height) {
      super(length, height, BlockType.Text);
      this.collapsed = 0; // Amount of collapsed content in the line

      this.widgetHeight = 0; // Maximum inline widget height
    }

    replace(_from, _to, nodes) {
      let node = nodes[0];

      if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && node.flags & 4
      /* Flag.SingleLine */
      ) && Math.abs(this.length - node.length) < 10) {
        if (node instanceof HeightMapGap) node = new HeightMapText(node.length, this.height);else node.height = this.height;
        if (!this.outdated) node.outdated = false;
        return node;
      } else {
        return HeightMap.of(nodes);
      }
    }

    updateHeight(oracle, offset = 0, force = false, measured) {
      if (measured && measured.from <= offset && measured.more) this.setHeight(oracle, measured.heights[measured.index++]);else if (force || this.outdated) this.setHeight(oracle, Math.max(this.widgetHeight, oracle.heightForLine(this.length - this.collapsed)));
      this.outdated = false;
      return this;
    }

    toString() {
      return `line(${this.length}${this.collapsed ? -this.collapsed : ""}${this.widgetHeight ? ":" + this.widgetHeight : ""})`;
    }

  }

  class HeightMapGap extends HeightMap {
    constructor(length) {
      super(length, 0);
    }

    lines(doc, offset) {
      let firstLine = doc.lineAt(offset).number,
          lastLine = doc.lineAt(offset + this.length).number;
      return {
        firstLine,
        lastLine,
        lineHeight: this.height / (lastLine - firstLine + 1)
      };
    }

    blockAt(height, doc, top, offset) {
      let {
        firstLine,
        lastLine,
        lineHeight
      } = this.lines(doc, offset);
      let line = Math.max(0, Math.min(lastLine - firstLine, Math.floor((height - top) / lineHeight)));
      let {
        from,
        length
      } = doc.line(firstLine + line);
      return new BlockInfo(from, length, top + lineHeight * line, lineHeight, BlockType.Text);
    }

    lineAt(value, type, doc, top, offset) {
      if (type == QueryType.ByHeight) return this.blockAt(value, doc, top, offset);

      if (type == QueryType.ByPosNoHeight) {
        let {
          from,
          to
        } = doc.lineAt(value);
        return new BlockInfo(from, to - from, 0, 0, BlockType.Text);
      }

      let {
        firstLine,
        lineHeight
      } = this.lines(doc, offset);
      let {
        from,
        length,
        number
      } = doc.lineAt(value);
      return new BlockInfo(from, length, top + lineHeight * (number - firstLine), lineHeight, BlockType.Text);
    }

    forEachLine(from, to, doc, top, offset, f) {
      let {
        firstLine,
        lineHeight
      } = this.lines(doc, offset);

      for (let pos = Math.max(from, offset), end = Math.min(offset + this.length, to); pos <= end;) {
        let line = doc.lineAt(pos);
        if (pos == from) top += lineHeight * (line.number - firstLine);
        f(new BlockInfo(line.from, line.length, top, lineHeight, BlockType.Text));
        top += lineHeight;
        pos = line.to + 1;
      }
    }

    replace(from, to, nodes) {
      let after = this.length - to;

      if (after > 0) {
        let last = nodes[nodes.length - 1];
        if (last instanceof HeightMapGap) nodes[nodes.length - 1] = new HeightMapGap(last.length + after);else nodes.push(null, new HeightMapGap(after - 1));
      }

      if (from > 0) {
        let first = nodes[0];
        if (first instanceof HeightMapGap) nodes[0] = new HeightMapGap(from + first.length);else nodes.unshift(new HeightMapGap(from - 1), null);
      }

      return HeightMap.of(nodes);
    }

    decomposeLeft(to, result) {
      result.push(new HeightMapGap(to - 1), null);
    }

    decomposeRight(from, result) {
      result.push(null, new HeightMapGap(this.length - from - 1));
    }

    updateHeight(oracle, offset = 0, force = false, measured) {
      let end = offset + this.length;

      if (measured && measured.from <= offset + this.length && measured.more) {
        // Fill in part of this gap with measured lines. We know there
        // can't be widgets or collapsed ranges in those lines, because
        // they would already have been added to the heightmap (gaps
        // only contain plain text).
        let nodes = [],
            pos = Math.max(offset, measured.from),
            singleHeight = -1;
        let wasChanged = oracle.heightChanged;
        if (measured.from > offset) nodes.push(new HeightMapGap(measured.from - offset - 1).updateHeight(oracle, offset));

        while (pos <= end && measured.more) {
          let len = oracle.doc.lineAt(pos).length;
          if (nodes.length) nodes.push(null);
          let height = measured.heights[measured.index++];
          if (singleHeight == -1) singleHeight = height;else if (Math.abs(height - singleHeight) >= Epsilon) singleHeight = -2;
          let line = new HeightMapText(len, height);
          line.outdated = false;
          nodes.push(line);
          pos += len + 1;
        }

        if (pos <= end) nodes.push(null, new HeightMapGap(end - pos).updateHeight(oracle, pos));
        let result = HeightMap.of(nodes);
        oracle.heightChanged = wasChanged || singleHeight < 0 || Math.abs(result.height - this.height) >= Epsilon || Math.abs(singleHeight - this.lines(oracle.doc, offset).lineHeight) >= Epsilon;
        return result;
      } else if (force || this.outdated) {
        this.setHeight(oracle, oracle.heightForGap(offset, offset + this.length));
        this.outdated = false;
      }

      return this;
    }

    toString() {
      return `gap(${this.length})`;
    }

  }

  class HeightMapBranch extends HeightMap {
    constructor(left, brk, right) {
      super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2
      /* Flag.Outdated */
      : 0));
      this.left = left;
      this.right = right;
      this.size = left.size + right.size;
    }

    get break() {
      return this.flags & 1
      /* Flag.Break */
      ;
    }

    blockAt(height, doc, top, offset) {
      let mid = top + this.left.height;
      return height < mid ? this.left.blockAt(height, doc, top, offset) : this.right.blockAt(height, doc, mid, offset + this.left.length + this.break);
    }

    lineAt(value, type, doc, top, offset) {
      let rightTop = top + this.left.height,
          rightOffset = offset + this.left.length + this.break;
      let left = type == QueryType.ByHeight ? value < rightTop : value < rightOffset;
      let base = left ? this.left.lineAt(value, type, doc, top, offset) : this.right.lineAt(value, type, doc, rightTop, rightOffset);
      if (this.break || (left ? base.to < rightOffset : base.from > rightOffset)) return base;
      let subQuery = type == QueryType.ByPosNoHeight ? QueryType.ByPosNoHeight : QueryType.ByPos;
      if (left) return base.join(this.right.lineAt(rightOffset, subQuery, doc, rightTop, rightOffset));else return this.left.lineAt(rightOffset, subQuery, doc, top, offset).join(base);
    }

    forEachLine(from, to, doc, top, offset, f) {
      let rightTop = top + this.left.height,
          rightOffset = offset + this.left.length + this.break;

      if (this.break) {
        if (from < rightOffset) this.left.forEachLine(from, to, doc, top, offset, f);
        if (to >= rightOffset) this.right.forEachLine(from, to, doc, rightTop, rightOffset, f);
      } else {
        let mid = this.lineAt(rightOffset, QueryType.ByPos, doc, top, offset);
        if (from < mid.from) this.left.forEachLine(from, mid.from - 1, doc, top, offset, f);
        if (mid.to >= from && mid.from <= to) f(mid);
        if (to > mid.to) this.right.forEachLine(mid.to + 1, to, doc, rightTop, rightOffset, f);
      }
    }

    replace(from, to, nodes) {
      let rightStart = this.left.length + this.break;
      if (to < rightStart) return this.balanced(this.left.replace(from, to, nodes), this.right);
      if (from > this.left.length) return this.balanced(this.left, this.right.replace(from - rightStart, to - rightStart, nodes));
      let result = [];
      if (from > 0) this.decomposeLeft(from, result);
      let left = result.length;

      for (let node of nodes) result.push(node);

      if (from > 0) mergeGaps(result, left - 1);

      if (to < this.length) {
        let right = result.length;
        this.decomposeRight(to, result);
        mergeGaps(result, right);
      }

      return HeightMap.of(result);
    }

    decomposeLeft(to, result) {
      let left = this.left.length;
      if (to <= left) return this.left.decomposeLeft(to, result);
      result.push(this.left);

      if (this.break) {
        left++;
        if (to >= left) result.push(null);
      }

      if (to > left) this.right.decomposeLeft(to - left, result);
    }

    decomposeRight(from, result) {
      let left = this.left.length,
          right = left + this.break;
      if (from >= right) return this.right.decomposeRight(from - right, result);
      if (from < left) this.left.decomposeRight(from, result);
      if (this.break && from < right) result.push(null);
      result.push(this.right);
    }

    balanced(left, right) {
      if (left.size > 2 * right.size || right.size > 2 * left.size) return HeightMap.of(this.break ? [left, null, right] : [left, right]);
      this.left = left;
      this.right = right;
      this.height = left.height + right.height;
      this.outdated = left.outdated || right.outdated;
      this.size = left.size + right.size;
      this.length = left.length + this.break + right.length;
      return this;
    }

    updateHeight(oracle, offset = 0, force = false, measured) {
      let {
        left,
        right
      } = this,
          rightStart = offset + left.length + this.break,
          rebalance = null;
      if (measured && measured.from <= offset + left.length && measured.more) rebalance = left = left.updateHeight(oracle, offset, force, measured);else left.updateHeight(oracle, offset, force);
      if (measured && measured.from <= rightStart + right.length && measured.more) rebalance = right = right.updateHeight(oracle, rightStart, force, measured);else right.updateHeight(oracle, rightStart, force);
      if (rebalance) return this.balanced(left, right);
      this.height = this.left.height + this.right.height;
      this.outdated = false;
      return this;
    }

    toString() {
      return this.left + (this.break ? " " : "-") + this.right;
    }

  }

  function mergeGaps(nodes, around) {
    let before, after;
    if (nodes[around] == null && (before = nodes[around - 1]) instanceof HeightMapGap && (after = nodes[around + 1]) instanceof HeightMapGap) nodes.splice(around - 1, 3, new HeightMapGap(before.length + 1 + after.length));
  }

  const relevantWidgetHeight = 5;

  class NodeBuilder {
    constructor(pos, oracle) {
      this.pos = pos;
      this.oracle = oracle;
      this.nodes = [];
      this.lineStart = -1;
      this.lineEnd = -1;
      this.covering = null;
      this.writtenTo = pos;
    }

    get isCovered() {
      return this.covering && this.nodes[this.nodes.length - 1] == this.covering;
    }

    span(_from, to) {
      if (this.lineStart > -1) {
        let end = Math.min(to, this.lineEnd),
            last = this.nodes[this.nodes.length - 1];
        if (last instanceof HeightMapText) last.length += end - this.pos;else if (end > this.pos || !this.isCovered) this.nodes.push(new HeightMapText(end - this.pos, -1));
        this.writtenTo = end;

        if (to > end) {
          this.nodes.push(null);
          this.writtenTo++;
          this.lineStart = -1;
        }
      }

      this.pos = to;
    }

    point(from, to, deco) {
      if (from < to || deco.heightRelevant) {
        let height = deco.widget ? deco.widget.estimatedHeight : 0;
        if (height < 0) height = this.oracle.lineHeight;
        let len = to - from;

        if (deco.block) {
          this.addBlock(new HeightMapBlock(len, height, deco.type));
        } else if (len || height >= relevantWidgetHeight) {
          this.addLineDeco(height, len);
        }
      } else if (to > from) {
        this.span(from, to);
      }

      if (this.lineEnd > -1 && this.lineEnd < this.pos) this.lineEnd = this.oracle.doc.lineAt(this.pos).to;
    }

    enterLine() {
      if (this.lineStart > -1) return;
      let {
        from,
        to
      } = this.oracle.doc.lineAt(this.pos);
      this.lineStart = from;
      this.lineEnd = to;

      if (this.writtenTo < from) {
        if (this.writtenTo < from - 1 || this.nodes[this.nodes.length - 1] == null) this.nodes.push(this.blankContent(this.writtenTo, from - 1));
        this.nodes.push(null);
      }

      if (this.pos > from) this.nodes.push(new HeightMapText(this.pos - from, -1));
      this.writtenTo = this.pos;
    }

    blankContent(from, to) {
      let gap = new HeightMapGap(to - from);
      if (this.oracle.doc.lineAt(from).to == to) gap.flags |= 4
      /* Flag.SingleLine */
      ;
      return gap;
    }

    ensureLine() {
      this.enterLine();
      let last = this.nodes.length ? this.nodes[this.nodes.length - 1] : null;
      if (last instanceof HeightMapText) return last;
      let line = new HeightMapText(0, -1);
      this.nodes.push(line);
      return line;
    }

    addBlock(block) {
      this.enterLine();
      if (block.type == BlockType.WidgetAfter && !this.isCovered) this.ensureLine();
      this.nodes.push(block);
      this.writtenTo = this.pos = this.pos + block.length;
      if (block.type != BlockType.WidgetBefore) this.covering = block;
    }

    addLineDeco(height, length) {
      let line = this.ensureLine();
      line.length += length;
      line.collapsed += length;
      line.widgetHeight = Math.max(line.widgetHeight, height);
      this.writtenTo = this.pos = this.pos + length;
    }

    finish(from) {
      let last = this.nodes.length == 0 ? null : this.nodes[this.nodes.length - 1];
      if (this.lineStart > -1 && !(last instanceof HeightMapText) && !this.isCovered) this.nodes.push(new HeightMapText(0, -1));else if (this.writtenTo < this.pos || last == null) this.nodes.push(this.blankContent(this.writtenTo, this.pos));
      let pos = from;

      for (let node of this.nodes) {
        if (node instanceof HeightMapText) node.updateHeight(this.oracle, pos);
        pos += node ? node.length : 1;
      }

      return this.nodes;
    } // Always called with a region that on both sides either stretches
    // to a line break or the end of the document.
    // The returned array uses null to indicate line breaks, but never
    // starts or ends in a line break, or has multiple line breaks next
    // to each other.


    static build(oracle, decorations, from, to) {
      let builder = new NodeBuilder(from, oracle);
      RangeSet.spans(decorations, from, to, builder, 0);
      return builder.finish(from);
    }

  }

  function heightRelevantDecoChanges(a, b, diff) {
    let comp = new DecorationComparator();
    RangeSet.compare(a, b, diff, comp, 0);
    return comp.changes;
  }

  class DecorationComparator {
    constructor() {
      this.changes = [];
    }

    compareRange() {}

    comparePoint(from, to, a, b) {
      if (from < to || a && a.heightRelevant || b && b.heightRelevant) addRange(from, to, this.changes, 5);
    }

  }

  function visiblePixelRange(dom, paddingTop) {
    let rect = dom.getBoundingClientRect();
    let doc = dom.ownerDocument,
        win = doc.defaultView || window;
    let left = Math.max(0, rect.left),
        right = Math.min(win.innerWidth, rect.right);
    let top = Math.max(0, rect.top),
        bottom = Math.min(win.innerHeight, rect.bottom);

    for (let parent = dom.parentNode; parent && parent != doc.body;) {
      if (parent.nodeType == 1) {
        let elt = parent;
        let style = window.getComputedStyle(elt);

        if ((elt.scrollHeight > elt.clientHeight || elt.scrollWidth > elt.clientWidth) && style.overflow != "visible") {
          let parentRect = elt.getBoundingClientRect();
          left = Math.max(left, parentRect.left);
          right = Math.min(right, parentRect.right);
          top = Math.max(top, parentRect.top);
          bottom = parent == dom.parentNode ? parentRect.bottom : Math.min(bottom, parentRect.bottom);
        }

        parent = style.position == "absolute" || style.position == "fixed" ? elt.offsetParent : elt.parentNode;
      } else if (parent.nodeType == 11) {
        // Shadow root
        parent = parent.host;
      } else {
        break;
      }
    }

    return {
      left: left - rect.left,
      right: Math.max(left, right) - rect.left,
      top: top - (rect.top + paddingTop),
      bottom: Math.max(top, bottom) - (rect.top + paddingTop)
    };
  }

  function fullPixelRange(dom, paddingTop) {
    let rect = dom.getBoundingClientRect();
    return {
      left: 0,
      right: rect.right - rect.left,
      top: paddingTop,
      bottom: rect.bottom - (rect.top + paddingTop)
    };
  } // Line gaps are placeholder widgets used to hide pieces of overlong
  // lines within the viewport, as a kludge to keep the editor
  // responsive when a ridiculously long line is loaded into it.


  class LineGap {
    constructor(from, to, size) {
      this.from = from;
      this.to = to;
      this.size = size;
    }

    static same(a, b) {
      if (a.length != b.length) return false;

      for (let i = 0; i < a.length; i++) {
        let gA = a[i],
            gB = b[i];
        if (gA.from != gB.from || gA.to != gB.to || gA.size != gB.size) return false;
      }

      return true;
    }

    draw(wrapping) {
      return Decoration.replace({
        widget: new LineGapWidget(this.size, wrapping)
      }).range(this.from, this.to);
    }

  }

  class LineGapWidget extends WidgetType {
    constructor(size, vertical) {
      super();
      this.size = size;
      this.vertical = vertical;
    }

    eq(other) {
      return other.size == this.size && other.vertical == this.vertical;
    }

    toDOM() {
      let elt = document.createElement("div");

      if (this.vertical) {
        elt.style.height = this.size + "px";
      } else {
        elt.style.width = this.size + "px";
        elt.style.height = "2px";
        elt.style.display = "inline-block";
      }

      return elt;
    }

    get estimatedHeight() {
      return this.vertical ? this.size : -1;
    }

  }

  class ViewState {
    constructor(state) {
      this.state = state; // These are contentDOM-local coordinates

      this.pixelViewport = {
        left: 0,
        right: window.innerWidth,
        top: 0,
        bottom: 0
      };
      this.inView = true;
      this.paddingTop = 0;
      this.paddingBottom = 0;
      this.contentDOMWidth = 0;
      this.contentDOMHeight = 0;
      this.editorHeight = 0;
      this.editorWidth = 0;
      this.heightOracle = new HeightOracle(); // See VP.MaxDOMHeight

      this.scaler = IdScaler;
      this.scrollTarget = null; // Briefly set to true when printing, to disable viewport limiting

      this.printing = false; // Flag set when editor content was redrawn, so that the next
      // measure stage knows it must read DOM layout

      this.mustMeasureContent = true;
      this.defaultTextDirection = Direction.RTL;
      this.visibleRanges = []; // Cursor 'assoc' is only significant when the cursor is on a line
      // wrap point, where it must stick to the character that it is
      // associated with. Since browsers don't provide a reasonable
      // interface to set or query this, when a selection is set that
      // might cause this to be significant, this flag is set. The next
      // measure phase will check whether the cursor is on a line-wrapping
      // boundary and, if so, reset it to make sure it is positioned in
      // the right place.

      this.mustEnforceCursorAssoc = false;
      this.stateDeco = state.facet(decorations).filter(d => typeof d != "function");
      this.heightMap = HeightMap.empty().applyChanges(this.stateDeco, Text.empty, this.heightOracle.setDoc(state.doc), [new ChangedRange(0, 0, 0, state.doc.length)]);
      this.viewport = this.getViewport(0, null);
      this.updateViewportLines();
      this.updateForViewport();
      this.lineGaps = this.ensureLineGaps([]);
      this.lineGapDeco = Decoration.set(this.lineGaps.map(gap => gap.draw(false)));
      this.computeVisibleRanges();
    }

    updateForViewport() {
      let viewports = [this.viewport],
          {
        main
      } = this.state.selection;

      for (let i = 0; i <= 1; i++) {
        let pos = i ? main.head : main.anchor;

        if (!viewports.some(({
          from,
          to
        }) => pos >= from && pos <= to)) {
          let {
            from,
            to
          } = this.lineBlockAt(pos);
          viewports.push(new Viewport(from, to));
        }
      }

      this.viewports = viewports.sort((a, b) => a.from - b.from);
      this.scaler = this.heightMap.height <= 7000000
      /* VP.MaxDOMHeight */
      ? IdScaler : new BigScaler(this.heightOracle.doc, this.heightMap, this.viewports);
    }

    updateViewportLines() {
      this.viewportLines = [];
      this.heightMap.forEachLine(this.viewport.from, this.viewport.to, this.state.doc, 0, 0, block => {
        this.viewportLines.push(this.scaler.scale == 1 ? block : scaleBlock(block, this.scaler));
      });
    }

    update(update, scrollTarget = null) {
      this.state = update.state;
      let prevDeco = this.stateDeco;
      this.stateDeco = this.state.facet(decorations).filter(d => typeof d != "function");
      let contentChanges = update.changedRanges;
      let heightChanges = ChangedRange.extendWithRanges(contentChanges, heightRelevantDecoChanges(prevDeco, this.stateDeco, update ? update.changes : ChangeSet.empty(this.state.doc.length)));
      let prevHeight = this.heightMap.height;
      this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);
      if (this.heightMap.height != prevHeight) update.flags |= 2
      /* UpdateFlag.Height */
      ;
      let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
      if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) || !this.viewportIsAppropriate(viewport)) viewport = this.getViewport(0, scrollTarget);
      let updateLines = !update.changes.empty || update.flags & 2
      /* UpdateFlag.Height */
      || viewport.from != this.viewport.from || viewport.to != this.viewport.to;
      this.viewport = viewport;
      this.updateForViewport();
      if (updateLines) this.updateViewportLines();
      if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000
      /* LG.DoubleMargin */
      ) this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
      update.flags |= this.computeVisibleRanges();
      if (scrollTarget) this.scrollTarget = scrollTarget;
      if (!this.mustEnforceCursorAssoc && update.selectionSet && update.view.lineWrapping && update.state.selection.main.empty && update.state.selection.main.assoc) this.mustEnforceCursorAssoc = true;
    }

    measure(view) {
      let dom = view.contentDOM,
          style = window.getComputedStyle(dom);
      let oracle = this.heightOracle;
      let whiteSpace = style.whiteSpace;
      this.defaultTextDirection = style.direction == "rtl" ? Direction.RTL : Direction.LTR;
      let refresh = this.heightOracle.mustRefreshForWrapping(whiteSpace);
      let measureContent = refresh || this.mustMeasureContent || this.contentDOMHeight != dom.clientHeight;
      this.contentDOMHeight = dom.clientHeight;
      this.mustMeasureContent = false;
      let result = 0,
          bias = 0; // Vertical padding

      let paddingTop = parseInt(style.paddingTop) || 0,
          paddingBottom = parseInt(style.paddingBottom) || 0;

      if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
        this.paddingTop = paddingTop;
        this.paddingBottom = paddingBottom;
        result |= 8
        /* UpdateFlag.Geometry */
        | 2
        /* UpdateFlag.Height */
        ;
      }

      if (this.editorWidth != view.scrollDOM.clientWidth) {
        if (oracle.lineWrapping) measureContent = true;
        this.editorWidth = view.scrollDOM.clientWidth;
        result |= 8
        /* UpdateFlag.Geometry */
        ;
      } // Pixel viewport


      let pixelViewport = (this.printing ? fullPixelRange : visiblePixelRange)(dom, this.paddingTop);
      let dTop = pixelViewport.top - this.pixelViewport.top,
          dBottom = pixelViewport.bottom - this.pixelViewport.bottom;
      this.pixelViewport = pixelViewport;
      let inView = this.pixelViewport.bottom > this.pixelViewport.top && this.pixelViewport.right > this.pixelViewport.left;

      if (inView != this.inView) {
        this.inView = inView;
        if (inView) measureContent = true;
      }

      if (!this.inView && !this.scrollTarget) return 0;
      let contentWidth = dom.clientWidth;

      if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
        this.contentDOMWidth = contentWidth;
        this.editorHeight = view.scrollDOM.clientHeight;
        result |= 8
        /* UpdateFlag.Geometry */
        ;
      }

      if (measureContent) {
        let lineHeights = view.docView.measureVisibleLineHeights(this.viewport);
        if (oracle.mustRefreshForHeights(lineHeights)) refresh = true;

        if (refresh || oracle.lineWrapping && Math.abs(contentWidth - this.contentDOMWidth) > oracle.charWidth) {
          let {
            lineHeight,
            charWidth
          } = view.docView.measureTextSize();
          refresh = oracle.refresh(whiteSpace, lineHeight, charWidth, contentWidth / charWidth, lineHeights);

          if (refresh) {
            view.docView.minWidth = 0;
            result |= 8
            /* UpdateFlag.Geometry */
            ;
          }
        }

        if (dTop > 0 && dBottom > 0) bias = Math.max(dTop, dBottom);else if (dTop < 0 && dBottom < 0) bias = Math.min(dTop, dBottom);
        oracle.heightChanged = false;

        for (let vp of this.viewports) {
          let heights = vp.from == this.viewport.from ? lineHeights : view.docView.measureVisibleLineHeights(vp);
          this.heightMap = this.heightMap.updateHeight(oracle, 0, refresh, new MeasuredHeights(vp.from, heights));
        }

        if (oracle.heightChanged) result |= 2
        /* UpdateFlag.Height */
        ;
      }

      let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) || this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from || this.scrollTarget.range.head > this.viewport.to);
      if (viewportChange) this.viewport = this.getViewport(bias, this.scrollTarget);
      this.updateForViewport();
      if (result & 2
      /* UpdateFlag.Height */
      || viewportChange) this.updateViewportLines();
      if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000
      /* LG.DoubleMargin */
      ) this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps));
      result |= this.computeVisibleRanges();

      if (this.mustEnforceCursorAssoc) {
        this.mustEnforceCursorAssoc = false; // This is done in the read stage, because moving the selection
        // to a line end is going to trigger a layout anyway, so it
        // can't be a pure write. It should be rare that it does any
        // writing.

        view.docView.enforceCursorAssoc();
      }

      return result;
    }

    get visibleTop() {
      return this.scaler.fromDOM(this.pixelViewport.top);
    }

    get visibleBottom() {
      return this.scaler.fromDOM(this.pixelViewport.bottom);
    }

    getViewport(bias, scrollTarget) {
      // This will divide VP.Margin between the top and the
      // bottom, depending on the bias (the change in viewport position
      // since the last update). It'll hold a number between 0 and 1
      let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000
      /* VP.Margin */
      / 2));
      let map = this.heightMap,
          doc = this.state.doc,
          {
        visibleTop,
        visibleBottom
      } = this;
      let viewport = new Viewport(map.lineAt(visibleTop - marginTop * 1000
      /* VP.Margin */
      , QueryType.ByHeight, doc, 0, 0).from, map.lineAt(visibleBottom + (1 - marginTop) * 1000
      /* VP.Margin */
      , QueryType.ByHeight, doc, 0, 0).to); // If scrollTarget is given, make sure the viewport includes that position

      if (scrollTarget) {
        let {
          head
        } = scrollTarget.range;

        if (head < viewport.from || head > viewport.to) {
          let viewHeight = Math.min(this.editorHeight, this.pixelViewport.bottom - this.pixelViewport.top);
          let block = map.lineAt(head, QueryType.ByPos, doc, 0, 0),
              topPos;
          if (scrollTarget.y == "center") topPos = (block.top + block.bottom) / 2 - viewHeight / 2;else if (scrollTarget.y == "start" || scrollTarget.y == "nearest" && head < viewport.from) topPos = block.top;else topPos = block.bottom - viewHeight;
          viewport = new Viewport(map.lineAt(topPos - 1000
          /* VP.Margin */
          / 2, QueryType.ByHeight, doc, 0, 0).from, map.lineAt(topPos + viewHeight + 1000
          /* VP.Margin */
          / 2, QueryType.ByHeight, doc, 0, 0).to);
        }
      }

      return viewport;
    }

    mapViewport(viewport, changes) {
      let from = changes.mapPos(viewport.from, -1),
          to = changes.mapPos(viewport.to, 1);
      return new Viewport(this.heightMap.lineAt(from, QueryType.ByPos, this.state.doc, 0, 0).from, this.heightMap.lineAt(to, QueryType.ByPos, this.state.doc, 0, 0).to);
    } // Checks if a given viewport covers the visible part of the
    // document and not too much beyond that.


    viewportIsAppropriate({
      from,
      to
    }, bias = 0) {
      if (!this.inView) return true;
      let {
        top
      } = this.heightMap.lineAt(from, QueryType.ByPos, this.state.doc, 0, 0);
      let {
        bottom
      } = this.heightMap.lineAt(to, QueryType.ByPos, this.state.doc, 0, 0);
      let {
        visibleTop,
        visibleBottom
      } = this;
      return (from == 0 || top <= visibleTop - Math.max(10
      /* VP.MinCoverMargin */
      , Math.min(-bias, 250
      /* VP.MaxCoverMargin */
      ))) && (to == this.state.doc.length || bottom >= visibleBottom + Math.max(10
      /* VP.MinCoverMargin */
      , Math.min(bias, 250
      /* VP.MaxCoverMargin */
      ))) && top > visibleTop - 2 * 1000
      /* VP.Margin */
      && bottom < visibleBottom + 2 * 1000
      /* VP.Margin */
      ;
    }

    mapLineGaps(gaps, changes) {
      if (!gaps.length || changes.empty) return gaps;
      let mapped = [];

      for (let gap of gaps) if (!changes.touchesRange(gap.from, gap.to)) mapped.push(new LineGap(changes.mapPos(gap.from), changes.mapPos(gap.to), gap.size));

      return mapped;
    } // Computes positions in the viewport where the start or end of a
    // line should be hidden, trying to reuse existing line gaps when
    // appropriate to avoid unneccesary redraws.
    // Uses crude character-counting for the positioning and sizing,
    // since actual DOM coordinates aren't always available and
    // predictable. Relies on generous margins (see LG.Margin) to hide
    // the artifacts this might produce from the user.


    ensureLineGaps(current) {
      let gaps = []; // This won't work at all in predominantly right-to-left text.

      if (this.defaultTextDirection != Direction.LTR) return gaps;

      for (let line of this.viewportLines) {
        if (line.length < 4000
        /* LG.DoubleMargin */
        ) continue;
        let structure = lineStructure(line.from, line.to, this.stateDeco);
        if (structure.total < 4000
        /* LG.DoubleMargin */
        ) continue;
        let viewFrom, viewTo;

        if (this.heightOracle.lineWrapping) {
          let marginHeight = 2000
          /* LG.Margin */
          / this.heightOracle.lineLength * this.heightOracle.lineHeight;
          viewFrom = findPosition(structure, (this.visibleTop - line.top - marginHeight) / line.height);
          viewTo = findPosition(structure, (this.visibleBottom - line.top + marginHeight) / line.height);
        } else {
          let totalWidth = structure.total * this.heightOracle.charWidth;
          let marginWidth = 2000
          /* LG.Margin */
          * this.heightOracle.charWidth;
          viewFrom = findPosition(structure, (this.pixelViewport.left - marginWidth) / totalWidth);
          viewTo = findPosition(structure, (this.pixelViewport.right + marginWidth) / totalWidth);
        }

        let outside = [];
        if (viewFrom > line.from) outside.push({
          from: line.from,
          to: viewFrom
        });
        if (viewTo < line.to) outside.push({
          from: viewTo,
          to: line.to
        });
        let sel = this.state.selection.main; // Make sure the gaps don't cover a selection end

        if (sel.from >= line.from && sel.from <= line.to) cutRange(outside, sel.from - 10
        /* LG.SelectionMargin */
        , sel.from + 10
        /* LG.SelectionMargin */
        );
        if (!sel.empty && sel.to >= line.from && sel.to <= line.to) cutRange(outside, sel.to - 10
        /* LG.SelectionMargin */
        , sel.to + 10
        /* LG.SelectionMargin */
        );

        for (let {
          from,
          to
        } of outside) if (to - from > 1000
        /* LG.HalfMargin */
        ) {
          gaps.push(find(current, gap => gap.from >= line.from && gap.to <= line.to && Math.abs(gap.from - from) < 1000
          /* LG.HalfMargin */
          && Math.abs(gap.to - to) < 1000
          /* LG.HalfMargin */
          ) || new LineGap(from, to, this.gapSize(line, from, to, structure)));
        }
      }

      return gaps;
    }

    gapSize(line, from, to, structure) {
      let fraction = findFraction(structure, to) - findFraction(structure, from);

      if (this.heightOracle.lineWrapping) {
        return line.height * fraction;
      } else {
        return structure.total * this.heightOracle.charWidth * fraction;
      }
    }

    updateLineGaps(gaps) {
      if (!LineGap.same(gaps, this.lineGaps)) {
        this.lineGaps = gaps;
        this.lineGapDeco = Decoration.set(gaps.map(gap => gap.draw(this.heightOracle.lineWrapping)));
      }
    }

    computeVisibleRanges() {
      let deco = this.stateDeco;
      if (this.lineGaps.length) deco = deco.concat(this.lineGapDeco);
      let ranges = [];
      RangeSet.spans(deco, this.viewport.from, this.viewport.to, {
        span(from, to) {
          ranges.push({
            from,
            to
          });
        },

        point() {}

      }, 20);
      let changed = ranges.length != this.visibleRanges.length || this.visibleRanges.some((r, i) => r.from != ranges[i].from || r.to != ranges[i].to);
      this.visibleRanges = ranges;
      return changed ? 4
      /* UpdateFlag.Viewport */
      : 0;
    }

    lineBlockAt(pos) {
      return pos >= this.viewport.from && pos <= this.viewport.to && this.viewportLines.find(b => b.from <= pos && b.to >= pos) || scaleBlock(this.heightMap.lineAt(pos, QueryType.ByPos, this.state.doc, 0, 0), this.scaler);
    }

    lineBlockAtHeight(height) {
      return scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(height), QueryType.ByHeight, this.state.doc, 0, 0), this.scaler);
    }

    elementAtHeight(height) {
      return scaleBlock(this.heightMap.blockAt(this.scaler.fromDOM(height), this.state.doc, 0, 0), this.scaler);
    }

    get docHeight() {
      return this.scaler.toDOM(this.heightMap.height);
    }

    get contentHeight() {
      return this.docHeight + this.paddingTop + this.paddingBottom;
    }

  }

  class Viewport {
    constructor(from, to) {
      this.from = from;
      this.to = to;
    }

  }

  function lineStructure(from, to, stateDeco) {
    let ranges = [],
        pos = from,
        total = 0;
    RangeSet.spans(stateDeco, from, to, {
      span() {},

      point(from, to) {
        if (from > pos) {
          ranges.push({
            from: pos,
            to: from
          });
          total += from - pos;
        }

        pos = to;
      }

    }, 20); // We're only interested in collapsed ranges of a significant size

    if (pos < to) {
      ranges.push({
        from: pos,
        to
      });
      total += to - pos;
    }

    return {
      total,
      ranges
    };
  }

  function findPosition({
    total,
    ranges
  }, ratio) {
    if (ratio <= 0) return ranges[0].from;
    if (ratio >= 1) return ranges[ranges.length - 1].to;
    let dist = Math.floor(total * ratio);

    for (let i = 0;; i++) {
      let {
        from,
        to
      } = ranges[i],
          size = to - from;
      if (dist <= size) return from + dist;
      dist -= size;
    }
  }

  function findFraction(structure, pos) {
    let counted = 0;

    for (let {
      from,
      to
    } of structure.ranges) {
      if (pos <= to) {
        counted += pos - from;
        break;
      }

      counted += to - from;
    }

    return counted / structure.total;
  }

  function cutRange(ranges, from, to) {
    for (let i = 0; i < ranges.length; i++) {
      let r = ranges[i];

      if (r.from < to && r.to > from) {
        let pieces = [];
        if (r.from < from) pieces.push({
          from: r.from,
          to: from
        });
        if (r.to > to) pieces.push({
          from: to,
          to: r.to
        });
        ranges.splice(i, 1, ...pieces);
        i += pieces.length - 1;
      }
    }
  }

  function find(array, f) {
    for (let val of array) if (f(val)) return val;

    return undefined;
  } // Don't scale when the document height is within the range of what
  // the DOM can handle.


  const IdScaler = {
    toDOM(n) {
      return n;
    },

    fromDOM(n) {
      return n;
    },

    scale: 1
  }; // When the height is too big (> VP.MaxDOMHeight), scale down the
  // regions outside the viewports so that the total height is
  // VP.MaxDOMHeight.

  class BigScaler {
    constructor(doc, heightMap, viewports) {
      let vpHeight = 0,
          base = 0,
          domBase = 0;
      this.viewports = viewports.map(({
        from,
        to
      }) => {
        let top = heightMap.lineAt(from, QueryType.ByPos, doc, 0, 0).top;
        let bottom = heightMap.lineAt(to, QueryType.ByPos, doc, 0, 0).bottom;
        vpHeight += bottom - top;
        return {
          from,
          to,
          top,
          bottom,
          domTop: 0,
          domBottom: 0
        };
      });
      this.scale = (7000000
      /* VP.MaxDOMHeight */
      - vpHeight) / (heightMap.height - vpHeight);

      for (let obj of this.viewports) {
        obj.domTop = domBase + (obj.top - base) * this.scale;
        domBase = obj.domBottom = obj.domTop + (obj.bottom - obj.top);
        base = obj.bottom;
      }
    }

    toDOM(n) {
      for (let i = 0, base = 0, domBase = 0;; i++) {
        let vp = i < this.viewports.length ? this.viewports[i] : null;
        if (!vp || n < vp.top) return domBase + (n - base) * this.scale;
        if (n <= vp.bottom) return vp.domTop + (n - vp.top);
        base = vp.bottom;
        domBase = vp.domBottom;
      }
    }

    fromDOM(n) {
      for (let i = 0, base = 0, domBase = 0;; i++) {
        let vp = i < this.viewports.length ? this.viewports[i] : null;
        if (!vp || n < vp.domTop) return base + (n - domBase) / this.scale;
        if (n <= vp.domBottom) return vp.top + (n - vp.domTop);
        base = vp.bottom;
        domBase = vp.domBottom;
      }
    }

  }

  function scaleBlock(block, scaler) {
    if (scaler.scale == 1) return block;
    let bTop = scaler.toDOM(block.top),
        bBottom = scaler.toDOM(block.bottom);
    return new BlockInfo(block.from, block.length, bTop, bBottom - bTop, Array.isArray(block.type) ? block.type.map(b => scaleBlock(b, scaler)) : block.type);
  }

  const theme$1 = /*@__PURE__*/Facet.define({
    combine: strs => strs.join(" ")
  });
  const darkTheme = /*@__PURE__*/Facet.define({
    combine: values => values.indexOf(true) > -1
  });
  const baseThemeID = /*@__PURE__*/StyleModule.newName(),
        baseLightID = /*@__PURE__*/StyleModule.newName(),
        baseDarkID = /*@__PURE__*/StyleModule.newName();
  const lightDarkIDs = {
    "&light": "." + baseLightID,
    "&dark": "." + baseDarkID
  };

  function buildTheme(main, spec, scopes) {
    return new StyleModule(spec, {
      finish(sel) {
        return /&/.test(sel) ? sel.replace(/&\w*/, m => {
          if (m == "&") return main;
          if (!scopes || !scopes[m]) throw new RangeError(`Unsupported selector: ${m}`);
          return scopes[m];
        }) : main + " " + sel;
      }

    });
  }

  const baseTheme$1$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
    "&.cm-editor": {
      position: "relative !important",
      boxSizing: "border-box",
      "&.cm-focused": {
        // Provide a simple default outline to make sure a focused
        // editor is visually distinct. Can't leave the default behavior
        // because that will apply to the content element, which is
        // inside the scrollable container and doesn't include the
        // gutters. We also can't use an 'auto' outline, since those
        // are, for some reason, drawn behind the element content, which
        // will cause things like the active line background to cover
        // the outline (#297).
        outline: "1px dotted #212121"
      },
      display: "flex !important",
      flexDirection: "column"
    },
    ".cm-scroller": {
      display: "flex !important",
      alignItems: "flex-start !important",
      fontFamily: "monospace",
      lineHeight: 1.4,
      height: "100%",
      overflowX: "auto",
      position: "relative",
      zIndex: 0
    },
    ".cm-content": {
      margin: 0,
      flexGrow: 2,
      flexShrink: 0,
      minHeight: "100%",
      display: "block",
      whiteSpace: "pre",
      wordWrap: "normal",
      boxSizing: "border-box",
      padding: "4px 0",
      outline: "none",
      "&[contenteditable=true]": {
        WebkitUserModify: "read-write-plaintext-only"
      }
    },
    ".cm-lineWrapping": {
      whiteSpace_fallback: "pre-wrap",
      whiteSpace: "break-spaces",
      wordBreak: "break-word",
      overflowWrap: "anywhere",
      flexShrink: 1
    },
    "&light .cm-content": {
      caretColor: "black"
    },
    "&dark .cm-content": {
      caretColor: "white"
    },
    ".cm-line": {
      display: "block",
      padding: "0 2px 0 4px"
    },
    ".cm-selectionLayer": {
      zIndex: -1,
      contain: "size style"
    },
    ".cm-selectionBackground": {
      position: "absolute"
    },
    "&light .cm-selectionBackground": {
      background: "#d9d9d9"
    },
    "&dark .cm-selectionBackground": {
      background: "#222"
    },
    "&light.cm-focused .cm-selectionBackground": {
      background: "#d7d4f0"
    },
    "&dark.cm-focused .cm-selectionBackground": {
      background: "#233"
    },
    ".cm-cursorLayer": {
      zIndex: 100,
      contain: "size style",
      pointerEvents: "none"
    },
    "&.cm-focused .cm-cursorLayer": {
      animation: "steps(1) cm-blink 1.2s infinite"
    },
    // Two animations defined so that we can switch between them to
    // restart the animation without forcing another style
    // recomputation.
    "@keyframes cm-blink": {
      "0%": {},
      "50%": {
        opacity: 0
      },
      "100%": {}
    },
    "@keyframes cm-blink2": {
      "0%": {},
      "50%": {
        opacity: 0
      },
      "100%": {}
    },
    ".cm-cursor, .cm-dropCursor": {
      position: "absolute",
      borderLeft: "1.2px solid black",
      marginLeft: "-0.6px",
      pointerEvents: "none"
    },
    ".cm-cursor": {
      display: "none"
    },
    "&dark .cm-cursor": {
      borderLeftColor: "#444"
    },
    "&.cm-focused .cm-cursor": {
      display: "block"
    },
    "&light .cm-activeLine": {
      backgroundColor: "#cceeff44"
    },
    "&dark .cm-activeLine": {
      backgroundColor: "#99eeff33"
    },
    "&light .cm-specialChar": {
      color: "red"
    },
    "&dark .cm-specialChar": {
      color: "#f78"
    },
    ".cm-gutters": {
      flexShrink: 0,
      display: "flex",
      height: "100%",
      boxSizing: "border-box",
      left: 0,
      zIndex: 200
    },
    "&light .cm-gutters": {
      backgroundColor: "#f5f5f5",
      color: "#6c6c6c",
      borderRight: "1px solid #ddd"
    },
    "&dark .cm-gutters": {
      backgroundColor: "#333338",
      color: "#ccc"
    },
    ".cm-gutter": {
      display: "flex !important",
      flexDirection: "column",
      flexShrink: 0,
      boxSizing: "border-box",
      minHeight: "100%",
      overflow: "hidden"
    },
    ".cm-gutterElement": {
      boxSizing: "border-box"
    },
    ".cm-lineNumbers .cm-gutterElement": {
      padding: "0 3px 0 5px",
      minWidth: "20px",
      textAlign: "right",
      whiteSpace: "nowrap"
    },
    "&light .cm-activeLineGutter": {
      backgroundColor: "#e2f2ff"
    },
    "&dark .cm-activeLineGutter": {
      backgroundColor: "#222227"
    },
    ".cm-panels": {
      boxSizing: "border-box",
      position: "sticky",
      left: 0,
      right: 0
    },
    "&light .cm-panels": {
      backgroundColor: "#f5f5f5",
      color: "black"
    },
    "&light .cm-panels-top": {
      borderBottom: "1px solid #ddd"
    },
    "&light .cm-panels-bottom": {
      borderTop: "1px solid #ddd"
    },
    "&dark .cm-panels": {
      backgroundColor: "#333338",
      color: "white"
    },
    ".cm-tab": {
      display: "inline-block",
      overflow: "hidden",
      verticalAlign: "bottom"
    },
    ".cm-widgetBuffer": {
      verticalAlign: "text-top",
      height: "1em",
      width: 0,
      display: "inline"
    },
    ".cm-placeholder": {
      color: "#888",
      display: "inline-block",
      verticalAlign: "top"
    },
    ".cm-button": {
      verticalAlign: "middle",
      color: "inherit",
      fontSize: "70%",
      padding: ".2em 1em",
      borderRadius: "1px"
    },
    "&light .cm-button": {
      backgroundImage: "linear-gradient(#eff1f5, #d9d9df)",
      border: "1px solid #888",
      "&:active": {
        backgroundImage: "linear-gradient(#b4b4b4, #d0d3d6)"
      }
    },
    "&dark .cm-button": {
      backgroundImage: "linear-gradient(#393939, #111)",
      border: "1px solid #888",
      "&:active": {
        backgroundImage: "linear-gradient(#111, #333)"
      }
    },
    ".cm-textfield": {
      verticalAlign: "middle",
      color: "inherit",
      fontSize: "70%",
      border: "1px solid silver",
      padding: ".2em .5em"
    },
    "&light .cm-textfield": {
      backgroundColor: "white"
    },
    "&dark .cm-textfield": {
      border: "1px solid #555",
      backgroundColor: "inherit"
    }
  }, lightDarkIDs);
  const observeOptions = {
    childList: true,
    characterData: true,
    subtree: true,
    attributes: true,
    characterDataOldValue: true
  }; // IE11 has very broken mutation observers, so we also listen to
  // DOMCharacterDataModified there

  const useCharData = browser.ie && browser.ie_version <= 11;

  class DOMObserver {
    constructor(view, onChange, onScrollChanged) {
      this.view = view;
      this.onChange = onChange;
      this.onScrollChanged = onScrollChanged;
      this.active = false; // The known selection. Kept in our own object, as opposed to just
      // directly accessing the selection because:
      //  - Safari doesn't report the right selection in shadow DOM
      //  - Reading from the selection forces a DOM layout
      //  - This way, we can ignore selectionchange events if we have
      //    already seen the 'new' selection

      this.selectionRange = new DOMSelectionState(); // Set when a selection change is detected, cleared on flush

      this.selectionChanged = false;
      this.delayedFlush = -1;
      this.resizeTimeout = -1;
      this.queue = [];
      this.delayedAndroidKey = null;
      this.lastChange = 0;
      this.scrollTargets = [];
      this.intersection = null;
      this.resize = null;
      this.intersecting = false;
      this.gapIntersection = null;
      this.gaps = []; // Timeout for scheduling check of the parents that need scroll handlers

      this.parentCheck = -1;
      this.dom = view.contentDOM;
      this.observer = new MutationObserver(mutations => {
        for (let mut of mutations) this.queue.push(mut); // IE11 will sometimes (on typing over a selection or
        // backspacing out a single character text node) call the
        // observer callback before actually updating the DOM.
        //
        // Unrelatedly, iOS Safari will, when ending a composition,
        // sometimes first clear it, deliver the mutations, and then
        // reinsert the finished text. CodeMirror's handling of the
        // deletion will prevent the reinsertion from happening,
        // breaking composition.


        if ((browser.ie && browser.ie_version <= 11 || browser.ios && view.composing) && mutations.some(m => m.type == "childList" && m.removedNodes.length || m.type == "characterData" && m.oldValue.length > m.target.nodeValue.length)) this.flushSoon();else this.flush();
      });
      if (useCharData) this.onCharData = event => {
        this.queue.push({
          target: event.target,
          type: "characterData",
          oldValue: event.prevValue
        });
        this.flushSoon();
      };
      this.onSelectionChange = this.onSelectionChange.bind(this);
      this.onResize = this.onResize.bind(this);
      this.onPrint = this.onPrint.bind(this);
      this.onScroll = this.onScroll.bind(this);

      if (typeof ResizeObserver == "function") {
        this.resize = new ResizeObserver(() => {
          if (this.view.docView.lastUpdate < Date.now() - 75) this.onResize();
        });
        this.resize.observe(view.scrollDOM);
      }

      this.addWindowListeners(this.win = view.win);
      this.start();

      if (typeof IntersectionObserver == "function") {
        this.intersection = new IntersectionObserver(entries => {
          if (this.parentCheck < 0) this.parentCheck = setTimeout(this.listenForScroll.bind(this), 1000);

          if (entries.length > 0 && entries[entries.length - 1].intersectionRatio > 0 != this.intersecting) {
            this.intersecting = !this.intersecting;
            if (this.intersecting != this.view.inView) this.onScrollChanged(document.createEvent("Event"));
          }
        }, {});
        this.intersection.observe(this.dom);
        this.gapIntersection = new IntersectionObserver(entries => {
          if (entries.length > 0 && entries[entries.length - 1].intersectionRatio > 0) this.onScrollChanged(document.createEvent("Event"));
        }, {});
      }

      this.listenForScroll();
      this.readSelectionRange();
    }

    onScroll(e) {
      if (this.intersecting) this.flush(false);
      this.onScrollChanged(e);
    }

    onResize() {
      if (this.resizeTimeout < 0) this.resizeTimeout = setTimeout(() => {
        this.resizeTimeout = -1;
        this.view.requestMeasure();
      }, 50);
    }

    onPrint() {
      this.view.viewState.printing = true;
      this.view.measure();
      setTimeout(() => {
        this.view.viewState.printing = false;
        this.view.requestMeasure();
      }, 500);
    }

    updateGaps(gaps) {
      if (this.gapIntersection && (gaps.length != this.gaps.length || this.gaps.some((g, i) => g != gaps[i]))) {
        this.gapIntersection.disconnect();

        for (let gap of gaps) this.gapIntersection.observe(gap);

        this.gaps = gaps;
      }
    }

    onSelectionChange(event) {
      let wasChanged = this.selectionChanged;
      if (!this.readSelectionRange() || this.delayedAndroidKey) return;
      let {
        view
      } = this,
          sel = this.selectionRange;
      if (view.state.facet(editable) ? view.root.activeElement != this.dom : !hasSelection(view.dom, sel)) return;
      let context = sel.anchorNode && view.docView.nearest(sel.anchorNode);

      if (context && context.ignoreEvent(event)) {
        if (!wasChanged) this.selectionChanged = false;
        return;
      } // Deletions on IE11 fire their events in the wrong order, giving
      // us a selection change event before the DOM changes are
      // reported.
      // Chrome Android has a similar issue when backspacing out a
      // selection (#645).


      if ((browser.ie && browser.ie_version <= 11 || browser.android && browser.chrome) && !view.state.selection.main.empty && // (Selection.isCollapsed isn't reliable on IE)
      sel.focusNode && isEquivalentPosition(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset)) this.flushSoon();else this.flush(false);
    }

    readSelectionRange() {
      let {
        view
      } = this; // The Selection object is broken in shadow roots in Safari. See
      // https://github.com/codemirror/dev/issues/414

      let range = browser.safari && view.root.nodeType == 11 && deepActiveElement(this.dom.ownerDocument) == this.dom && safariSelectionRangeHack(this.view) || getSelection(view.root);
      if (!range || this.selectionRange.eq(range)) return false;
      let local = hasSelection(this.dom, range); // Detect the situation where the browser has, on focus, moved the
      // selection to the start of the content element. Reset it to the
      // position from the editor state.

      if (local && !this.selectionChanged && view.inputState.lastFocusTime > Date.now() - 200 && view.inputState.lastTouchTime < Date.now() - 300 && atElementStart(this.dom, range)) {
        this.view.inputState.lastFocusTime = 0;
        view.docView.updateSelection();
        return false;
      }

      this.selectionRange.setRange(range);
      if (local) this.selectionChanged = true;
      return true;
    }

    setSelectionRange(anchor, head) {
      this.selectionRange.set(anchor.node, anchor.offset, head.node, head.offset);
      this.selectionChanged = false;
    }

    clearSelectionRange() {
      this.selectionRange.set(null, 0, null, 0);
    }

    listenForScroll() {
      this.parentCheck = -1;
      let i = 0,
          changed = null;

      for (let dom = this.dom; dom;) {
        if (dom.nodeType == 1) {
          if (!changed && i < this.scrollTargets.length && this.scrollTargets[i] == dom) i++;else if (!changed) changed = this.scrollTargets.slice(0, i);
          if (changed) changed.push(dom);
          dom = dom.assignedSlot || dom.parentNode;
        } else if (dom.nodeType == 11) {
          // Shadow root
          dom = dom.host;
        } else {
          break;
        }
      }

      if (i < this.scrollTargets.length && !changed) changed = this.scrollTargets.slice(0, i);

      if (changed) {
        for (let dom of this.scrollTargets) dom.removeEventListener("scroll", this.onScroll);

        for (let dom of this.scrollTargets = changed) dom.addEventListener("scroll", this.onScroll);
      }
    }

    ignore(f) {
      if (!this.active) return f();

      try {
        this.stop();
        return f();
      } finally {
        this.start();
        this.clear();
      }
    }

    start() {
      if (this.active) return;
      this.observer.observe(this.dom, observeOptions);
      if (useCharData) this.dom.addEventListener("DOMCharacterDataModified", this.onCharData);
      this.active = true;
    }

    stop() {
      if (!this.active) return;
      this.active = false;
      this.observer.disconnect();
      if (useCharData) this.dom.removeEventListener("DOMCharacterDataModified", this.onCharData);
    } // Throw away any pending changes


    clear() {
      this.processRecords();
      this.queue.length = 0;
      this.selectionChanged = false;
    } // Chrome Android, especially in combination with GBoard, not only
    // doesn't reliably fire regular key events, but also often
    // surrounds the effect of enter or backspace with a bunch of
    // composition events that, when interrupted, cause text duplication
    // or other kinds of corruption. This hack makes the editor back off
    // from handling DOM changes for a moment when such a key is
    // detected (via beforeinput or keydown), and then tries to flush
    // them or, if that has no effect, dispatches the given key.


    delayAndroidKey(key, keyCode) {
      var _a;

      if (!this.delayedAndroidKey) this.view.win.requestAnimationFrame(() => {
        let key = this.delayedAndroidKey;
        this.delayedAndroidKey = null;
        this.delayedFlush = -1;
        if (!this.flush() && key.force) dispatchKey(this.dom, key.key, key.keyCode);
      }); // Since backspace beforeinput is sometimes signalled spuriously,
      // Enter always takes precedence.

      if (!this.delayedAndroidKey || key == "Enter") this.delayedAndroidKey = {
        key,
        keyCode,
        // Only run the key handler when no changes are detected if
        // this isn't coming right after another change, in which case
        // it is probably part of a weird chain of updates, and should
        // be ignored if it returns the DOM to its previous state.
        force: this.lastChange < Date.now() - 50 || !!((_a = this.delayedAndroidKey) === null || _a === void 0 ? void 0 : _a.force)
      };
    }

    flushSoon() {
      if (this.delayedFlush < 0) this.delayedFlush = this.view.win.requestAnimationFrame(() => {
        this.delayedFlush = -1;
        this.flush();
      });
    }

    forceFlush() {
      if (this.delayedFlush >= 0) {
        this.view.win.cancelAnimationFrame(this.delayedFlush);
        this.delayedFlush = -1;
      }

      this.flush();
    }

    processRecords() {
      let records = this.queue;

      for (let mut of this.observer.takeRecords()) records.push(mut);

      if (records.length) this.queue = [];
      let from = -1,
          to = -1,
          typeOver = false;

      for (let record of records) {
        let range = this.readMutation(record);
        if (!range) continue;
        if (range.typeOver) typeOver = true;

        if (from == -1) {
          ({
            from,
            to
          } = range);
        } else {
          from = Math.min(range.from, from);
          to = Math.max(range.to, to);
        }
      }

      return {
        from,
        to,
        typeOver
      };
    } // Apply pending changes, if any


    flush(readSelection = true) {
      // Completely hold off flushing when pending keys are set—the code
      // managing those will make sure processRecords is called and the
      // view is resynchronized after
      if (this.delayedFlush >= 0 || this.delayedAndroidKey) return false;
      if (readSelection) this.readSelectionRange();
      let {
        from,
        to,
        typeOver
      } = this.processRecords();
      let newSel = this.selectionChanged && hasSelection(this.dom, this.selectionRange);
      if (from < 0 && !newSel) return false;
      if (from > -1) this.lastChange = Date.now();
      this.view.inputState.lastFocusTime = 0;
      this.selectionChanged = false;
      let startState = this.view.state;
      let handled = this.onChange(from, to, typeOver); // The view wasn't updated

      if (this.view.state == startState) this.view.update([]);
      return handled;
    }

    readMutation(rec) {
      let cView = this.view.docView.nearest(rec.target);
      if (!cView || cView.ignoreMutation(rec)) return null;
      cView.markDirty(rec.type == "attributes");
      if (rec.type == "attributes") cView.dirty |= 4
      /* Dirty.Attrs */
      ;

      if (rec.type == "childList") {
        let childBefore = findChild(cView, rec.previousSibling || rec.target.previousSibling, -1);
        let childAfter = findChild(cView, rec.nextSibling || rec.target.nextSibling, 1);
        return {
          from: childBefore ? cView.posAfter(childBefore) : cView.posAtStart,
          to: childAfter ? cView.posBefore(childAfter) : cView.posAtEnd,
          typeOver: false
        };
      } else if (rec.type == "characterData") {
        return {
          from: cView.posAtStart,
          to: cView.posAtEnd,
          typeOver: rec.target.nodeValue == rec.oldValue
        };
      } else {
        return null;
      }
    }

    setWindow(win) {
      if (win != this.win) {
        this.removeWindowListeners(this.win);
        this.win = win;
        this.addWindowListeners(this.win);
      }
    }

    addWindowListeners(win) {
      win.addEventListener("resize", this.onResize);
      win.addEventListener("beforeprint", this.onPrint);
      win.addEventListener("scroll", this.onScroll);
      win.document.addEventListener("selectionchange", this.onSelectionChange);
    }

    removeWindowListeners(win) {
      win.removeEventListener("scroll", this.onScroll);
      win.removeEventListener("resize", this.onResize);
      win.removeEventListener("beforeprint", this.onPrint);
      win.document.removeEventListener("selectionchange", this.onSelectionChange);
    }

    destroy() {
      var _a, _b, _c;

      this.stop();
      (_a = this.intersection) === null || _a === void 0 ? void 0 : _a.disconnect();
      (_b = this.gapIntersection) === null || _b === void 0 ? void 0 : _b.disconnect();
      (_c = this.resize) === null || _c === void 0 ? void 0 : _c.disconnect();

      for (let dom of this.scrollTargets) dom.removeEventListener("scroll", this.onScroll);

      this.removeWindowListeners(this.win);
      clearTimeout(this.parentCheck);
      clearTimeout(this.resizeTimeout);
    }

  }

  function findChild(cView, dom, dir) {
    while (dom) {
      let curView = ContentView.get(dom);
      if (curView && curView.parent == cView) return curView;
      let parent = dom.parentNode;
      dom = parent != cView.dom ? parent : dir > 0 ? dom.nextSibling : dom.previousSibling;
    }

    return null;
  } // Used to work around a Safari Selection/shadow DOM bug (#414)


  function safariSelectionRangeHack(view) {
    let found = null; // Because Safari (at least in 2018-2021) doesn't provide regular
    // access to the selection inside a shadowroot, we have to perform a
    // ridiculous hack to get at it—using `execCommand` to trigger a
    // `beforeInput` event so that we can read the target range from the
    // event.

    function read(event) {
      event.preventDefault();
      event.stopImmediatePropagation();
      found = event.getTargetRanges()[0];
    }

    view.contentDOM.addEventListener("beforeinput", read, true);
    view.dom.ownerDocument.execCommand("indent");
    view.contentDOM.removeEventListener("beforeinput", read, true);
    if (!found) return null;
    let anchorNode = found.startContainer,
        anchorOffset = found.startOffset;
    let focusNode = found.endContainer,
        focusOffset = found.endOffset;
    let curAnchor = view.docView.domAtPos(view.state.selection.main.anchor); // Since such a range doesn't distinguish between anchor and head,
    // use a heuristic that flips it around if its end matches the
    // current anchor.

    if (isEquivalentPosition(curAnchor.node, curAnchor.offset, focusNode, focusOffset)) [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];
    return {
      anchorNode,
      anchorOffset,
      focusNode,
      focusOffset
    };
  }

  function applyDOMChange(view, start, end, typeOver) {
    let change, newSel;
    let sel = view.state.selection.main;

    if (start > -1) {
      let bounds = view.docView.domBoundsAround(start, end, 0);
      if (!bounds || view.state.readOnly) return false;
      let {
        from,
        to
      } = bounds;
      let selPoints = view.docView.impreciseHead || view.docView.impreciseAnchor ? [] : selectionPoints(view);
      let reader = new DOMReader(selPoints, view.state);
      reader.readRange(bounds.startDOM, bounds.endDOM);
      let preferredPos = sel.from,
          preferredSide = null; // Prefer anchoring to end when Backspace is pressed (or, on
      // Android, when something was deleted)

      if (view.inputState.lastKeyCode === 8 && view.inputState.lastKeyTime > Date.now() - 100 || browser.android && reader.text.length < to - from) {
        preferredPos = sel.to;
        preferredSide = "end";
      }

      let diff = findDiff(view.state.doc.sliceString(from, to, LineBreakPlaceholder), reader.text, preferredPos - from, preferredSide);

      if (diff) {
        // Chrome inserts two newlines when pressing shift-enter at the
        // end of a line. This drops one of those.
        if (browser.chrome && view.inputState.lastKeyCode == 13 && diff.toB == diff.from + 2 && reader.text.slice(diff.from, diff.toB) == LineBreakPlaceholder + LineBreakPlaceholder) diff.toB--;
        change = {
          from: from + diff.from,
          to: from + diff.toA,
          insert: Text.of(reader.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder))
        };
      }

      newSel = selectionFromPoints(selPoints, from);
    } else if (view.hasFocus || !view.state.facet(editable)) {
      let domSel = view.observer.selectionRange;
      let {
        impreciseHead: iHead,
        impreciseAnchor: iAnchor
      } = view.docView;
      let head = iHead && iHead.node == domSel.focusNode && iHead.offset == domSel.focusOffset || !contains(view.contentDOM, domSel.focusNode) ? view.state.selection.main.head : view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset);
      let anchor = iAnchor && iAnchor.node == domSel.anchorNode && iAnchor.offset == domSel.anchorOffset || !contains(view.contentDOM, domSel.anchorNode) ? view.state.selection.main.anchor : view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset);
      if (head != sel.head || anchor != sel.anchor) newSel = EditorSelection.single(anchor, head);
    }

    if (!change && !newSel) return false; // Heuristic to notice typing over a selected character

    if (!change && typeOver && !sel.empty && newSel && newSel.main.empty) change = {
      from: sel.from,
      to: sel.to,
      insert: view.state.doc.slice(sel.from, sel.to)
    }; // If the change is inside the selection and covers most of it,
    // assume it is a selection replace (with identical characters at
    // the start/end not included in the diff)
    else if (change && change.from >= sel.from && change.to <= sel.to && (change.from != sel.from || change.to != sel.to) && sel.to - sel.from - (change.to - change.from) <= 4) change = {
      from: sel.from,
      to: sel.to,
      insert: view.state.doc.slice(sel.from, change.from).append(change.insert).append(view.state.doc.slice(change.to, sel.to))
    }; // Detect insert-period-on-double-space Mac behavior, and transform
    // it into a regular space insert.
    else if ((browser.mac || browser.android) && change && change.from == change.to && change.from == sel.head - 1 && change.insert.toString() == ".") change = {
      from: sel.from,
      to: sel.to,
      insert: Text.of([" "])
    };

    if (change) {
      let startState = view.state;
      if (browser.ios && view.inputState.flushIOSKey(view)) return true; // Android browsers don't fire reasonable key events for enter,
      // backspace, or delete. So this detects changes that look like
      // they're caused by those keys, and reinterprets them as key
      // events. (Some of these keys are also handled by beforeinput
      // events and the pendingAndroidKey mechanism, but that's not
      // reliable in all situations.)

      if (browser.android && (change.from == sel.from && change.to == sel.to && change.insert.length == 1 && change.insert.lines == 2 && dispatchKey(view.contentDOM, "Enter", 13) || change.from == sel.from - 1 && change.to == sel.to && change.insert.length == 0 && dispatchKey(view.contentDOM, "Backspace", 8) || change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 && dispatchKey(view.contentDOM, "Delete", 46))) return true;
      let text = change.insert.toString();
      if (view.state.facet(inputHandler$1).some(h => h(view, change.from, change.to, text))) return true;
      if (view.inputState.composing >= 0) view.inputState.composing++;
      let tr;

      if (change.from >= sel.from && change.to <= sel.to && change.to - change.from >= (sel.to - sel.from) / 3 && (!newSel || newSel.main.empty && newSel.main.from == change.from + change.insert.length) && view.inputState.composing < 0) {
        let before = sel.from < change.from ? startState.sliceDoc(sel.from, change.from) : "";
        let after = sel.to > change.to ? startState.sliceDoc(change.to, sel.to) : "";
        tr = startState.replaceSelection(view.state.toText(before + change.insert.sliceString(0, undefined, view.state.lineBreak) + after));
      } else {
        let changes = startState.changes(change);
        let mainSel = newSel && !startState.selection.main.eq(newSel.main) && newSel.main.to <= changes.newLength ? newSel.main : undefined; // Try to apply a composition change to all cursors

        if (startState.selection.ranges.length > 1 && view.inputState.composing >= 0 && change.to <= sel.to && change.to >= sel.to - 10) {
          let replaced = view.state.sliceDoc(change.from, change.to);
          let compositionRange = compositionSurroundingNode(view) || view.state.doc.lineAt(sel.head);
          let offset = sel.to - change.to,
              size = sel.to - sel.from;
          tr = startState.changeByRange(range => {
            if (range.from == sel.from && range.to == sel.to) return {
              changes,
              range: mainSel || range.map(changes)
            };
            let to = range.to - offset,
                from = to - replaced.length;
            if (range.to - range.from != size || view.state.sliceDoc(from, to) != replaced || // Unfortunately, there's no way to make multiple
            // changes in the same node work without aborting
            // composition, so cursors in the composition range are
            // ignored.
            compositionRange && range.to >= compositionRange.from && range.from <= compositionRange.to) return {
              range
            };
            let rangeChanges = startState.changes({
              from,
              to,
              insert: change.insert
            }),
                selOff = range.to - sel.to;
            return {
              changes: rangeChanges,
              range: !mainSel ? range.map(rangeChanges) : EditorSelection.range(Math.max(0, mainSel.anchor + selOff), Math.max(0, mainSel.head + selOff))
            };
          });
        } else {
          tr = {
            changes,
            selection: mainSel && startState.selection.replaceRange(mainSel)
          };
        }
      }

      let userEvent = "input.type";

      if (view.composing) {
        userEvent += ".compose";

        if (view.inputState.compositionFirstChange) {
          userEvent += ".start";
          view.inputState.compositionFirstChange = false;
        }
      }

      view.dispatch(tr, {
        scrollIntoView: true,
        userEvent
      });
      return true;
    } else if (newSel && !newSel.main.eq(sel)) {
      let scrollIntoView = false,
          userEvent = "select";

      if (view.inputState.lastSelectionTime > Date.now() - 50) {
        if (view.inputState.lastSelectionOrigin == "select") scrollIntoView = true;
        userEvent = view.inputState.lastSelectionOrigin;
      }

      view.dispatch({
        selection: newSel,
        scrollIntoView,
        userEvent
      });
      return true;
    } else {
      return false;
    }
  }

  function findDiff(a, b, preferredPos, preferredSide) {
    let minLen = Math.min(a.length, b.length);
    let from = 0;

    while (from < minLen && a.charCodeAt(from) == b.charCodeAt(from)) from++;

    if (from == minLen && a.length == b.length) return null;
    let toA = a.length,
        toB = b.length;

    while (toA > 0 && toB > 0 && a.charCodeAt(toA - 1) == b.charCodeAt(toB - 1)) {
      toA--;
      toB--;
    }

    if (preferredSide == "end") {
      let adjust = Math.max(0, from - Math.min(toA, toB));
      preferredPos -= toA + adjust - from;
    }

    if (toA < from && a.length < b.length) {
      let move = preferredPos <= from && preferredPos >= toA ? from - preferredPos : 0;
      from -= move;
      toB = from + (toB - toA);
      toA = from;
    } else if (toB < from) {
      let move = preferredPos <= from && preferredPos >= toB ? from - preferredPos : 0;
      from -= move;
      toA = from + (toA - toB);
      toB = from;
    }

    return {
      from,
      toA,
      toB
    };
  }

  function selectionPoints(view) {
    let result = [];
    if (view.root.activeElement != view.contentDOM) return result;
    let {
      anchorNode,
      anchorOffset,
      focusNode,
      focusOffset
    } = view.observer.selectionRange;

    if (anchorNode) {
      result.push(new DOMPoint(anchorNode, anchorOffset));
      if (focusNode != anchorNode || focusOffset != anchorOffset) result.push(new DOMPoint(focusNode, focusOffset));
    }

    return result;
  }

  function selectionFromPoints(points, base) {
    if (points.length == 0) return null;
    let anchor = points[0].pos,
        head = points.length == 2 ? points[1].pos : anchor;
    return anchor > -1 && head > -1 ? EditorSelection.single(anchor + base, head + base) : null;
  } // The editor's update state machine looks something like this:
  //
  //     Idle → Updating ⇆ Idle (unchecked) → Measuring → Idle
  //                                         ↑      ↓
  //                                         Updating (measure)
  //
  // The difference between 'Idle' and 'Idle (unchecked)' lies in
  // whether a layout check has been scheduled. A regular update through
  // the `update` method updates the DOM in a write-only fashion, and
  // relies on a check (scheduled with `requestAnimationFrame`) to make
  // sure everything is where it should be and the viewport covers the
  // visible code. That check continues to measure and then optionally
  // update until it reaches a coherent state.

  /**
  An editor view represents the editor's user interface. It holds
  the editable DOM surface, and possibly other elements such as the
  line number gutter. It handles events and dispatches state
  transactions for editing actions.
  */


  class EditorView {
    /**
    Construct a new view. You'll want to either provide a `parent`
    option, or put `view.dom` into your document after creating a
    view, so that the user can see the editor.
    */
    constructor(config = {}) {
      this.plugins = [];
      this.pluginMap = new Map();
      this.editorAttrs = {};
      this.contentAttrs = {};
      this.bidiCache = [];
      this.destroyed = false;
      /**
      @internal
      */

      this.updateState = 2
      /* UpdateState.Updating */
      ;
      /**
      @internal
      */

      this.measureScheduled = -1;
      /**
      @internal
      */

      this.measureRequests = [];
      this.contentDOM = document.createElement("div");
      this.scrollDOM = document.createElement("div");
      this.scrollDOM.tabIndex = -1;
      this.scrollDOM.className = "cm-scroller";
      this.scrollDOM.appendChild(this.contentDOM);
      this.announceDOM = document.createElement("div");
      this.announceDOM.style.cssText = "position: absolute; top: -10000px";
      this.announceDOM.setAttribute("aria-live", "polite");
      this.dom = document.createElement("div");
      this.dom.appendChild(this.announceDOM);
      this.dom.appendChild(this.scrollDOM);

      this._dispatch = config.dispatch || (tr => this.update([tr]));

      this.dispatch = this.dispatch.bind(this);
      this._root = config.root || getRoot$1(config.parent) || document;
      this.viewState = new ViewState(config.state || EditorState.create(config));
      this.plugins = this.state.facet(viewPlugin).map(spec => new PluginInstance(spec));

      for (let plugin of this.plugins) plugin.update(this);

      this.observer = new DOMObserver(this, (from, to, typeOver) => {
        return applyDOMChange(this, from, to, typeOver);
      }, event => {
        this.inputState.runScrollHandlers(this, event);
        if (this.observer.intersecting) this.measure();
      });
      this.inputState = new InputState(this);
      this.inputState.ensureHandlers(this, this.plugins);
      this.docView = new DocView(this);
      this.mountStyles();
      this.updateAttrs();
      this.updateState = 0
      /* UpdateState.Idle */
      ;
      this.requestMeasure();
      if (config.parent) config.parent.appendChild(this.dom);
    }
    /**
    The current editor state.
    */


    get state() {
      return this.viewState.state;
    }
    /**
    To be able to display large documents without consuming too much
    memory or overloading the browser, CodeMirror only draws the
    code that is visible (plus a margin around it) to the DOM. This
    property tells you the extent of the current drawn viewport, in
    document positions.
    */


    get viewport() {
      return this.viewState.viewport;
    }
    /**
    When there are, for example, large collapsed ranges in the
    viewport, its size can be a lot bigger than the actual visible
    content. Thus, if you are doing something like styling the
    content in the viewport, it is preferable to only do so for
    these ranges, which are the subset of the viewport that is
    actually drawn.
    */


    get visibleRanges() {
      return this.viewState.visibleRanges;
    }
    /**
    Returns false when the editor is entirely scrolled out of view
    or otherwise hidden.
    */


    get inView() {
      return this.viewState.inView;
    }
    /**
    Indicates whether the user is currently composing text via
    [IME](https://en.wikipedia.org/wiki/Input_method), and at least
    one change has been made in the current composition.
    */


    get composing() {
      return this.inputState.composing > 0;
    }
    /**
    Indicates whether the user is currently in composing state. Note
    that on some platforms, like Android, this will be the case a
    lot, since just putting the cursor on a word starts a
    composition there.
    */


    get compositionStarted() {
      return this.inputState.composing >= 0;
    }
    /**
    The document or shadow root that the view lives in.
    */


    get root() {
      return this._root;
    }
    /**
    @internal
    */


    get win() {
      return this.dom.ownerDocument.defaultView || window;
    }

    dispatch(...input) {
      this._dispatch(input.length == 1 && input[0] instanceof Transaction ? input[0] : this.state.update(...input));
    }
    /**
    Update the view for the given array of transactions. This will
    update the visible document and selection to match the state
    produced by the transactions, and notify view plugins of the
    change. You should usually call
    [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this
    as a primitive.
    */


    update(transactions) {
      if (this.updateState != 0
      /* UpdateState.Idle */
      ) throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
      let redrawn = false,
          attrsChanged = false,
          update;
      let state = this.state;

      for (let tr of transactions) {
        if (tr.startState != state) throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");
        state = tr.state;
      }

      if (this.destroyed) {
        this.viewState.state = state;
        return;
      }

      this.observer.clear(); // When the phrases change, redraw the editor

      if (state.facet(EditorState.phrases) != this.state.facet(EditorState.phrases)) return this.setState(state);
      update = ViewUpdate.create(this, state, transactions);
      let scrollTarget = this.viewState.scrollTarget;

      try {
        this.updateState = 2
        /* UpdateState.Updating */
        ;

        for (let tr of transactions) {
          if (scrollTarget) scrollTarget = scrollTarget.map(tr.changes);

          if (tr.scrollIntoView) {
            let {
              main
            } = tr.state.selection;
            scrollTarget = new ScrollTarget(main.empty ? main : EditorSelection.cursor(main.head, main.head > main.anchor ? -1 : 1));
          }

          for (let e of tr.effects) if (e.is(scrollIntoView$1)) scrollTarget = e.value;
        }

        this.viewState.update(update, scrollTarget);
        this.bidiCache = CachedOrder.update(this.bidiCache, update.changes);

        if (!update.empty) {
          this.updatePlugins(update);
          this.inputState.update(update);
        }

        redrawn = this.docView.update(update);
        if (this.state.facet(styleModule) != this.styleModules) this.mountStyles();
        attrsChanged = this.updateAttrs();
        this.showAnnouncements(transactions);
        this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent("select.pointer")));
      } finally {
        this.updateState = 0
        /* UpdateState.Idle */
        ;
      }

      if (update.startState.facet(theme$1) != update.state.facet(theme$1)) this.viewState.mustMeasureContent = true;
      if (redrawn || attrsChanged || scrollTarget || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent) this.requestMeasure();
      if (!update.empty) for (let listener of this.state.facet(updateListener)) listener(update);
    }
    /**
    Reset the view to the given state. (This will cause the entire
    document to be redrawn and all view plugins to be reinitialized,
    so you should probably only use it when the new state isn't
    derived from the old state. Otherwise, use
    [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
    */


    setState(newState) {
      if (this.updateState != 0
      /* UpdateState.Idle */
      ) throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");

      if (this.destroyed) {
        this.viewState.state = newState;
        return;
      }

      this.updateState = 2
      /* UpdateState.Updating */
      ;
      let hadFocus = this.hasFocus;

      try {
        for (let plugin of this.plugins) plugin.destroy(this);

        this.viewState = new ViewState(newState);
        this.plugins = newState.facet(viewPlugin).map(spec => new PluginInstance(spec));
        this.pluginMap.clear();

        for (let plugin of this.plugins) plugin.update(this);

        this.docView = new DocView(this);
        this.inputState.ensureHandlers(this, this.plugins);
        this.mountStyles();
        this.updateAttrs();
        this.bidiCache = [];
      } finally {
        this.updateState = 0
        /* UpdateState.Idle */
        ;
      }

      if (hadFocus) this.focus();
      this.requestMeasure();
    }

    updatePlugins(update) {
      let prevSpecs = update.startState.facet(viewPlugin),
          specs = update.state.facet(viewPlugin);

      if (prevSpecs != specs) {
        let newPlugins = [];

        for (let spec of specs) {
          let found = prevSpecs.indexOf(spec);

          if (found < 0) {
            newPlugins.push(new PluginInstance(spec));
          } else {
            let plugin = this.plugins[found];
            plugin.mustUpdate = update;
            newPlugins.push(plugin);
          }
        }

        for (let plugin of this.plugins) if (plugin.mustUpdate != update) plugin.destroy(this);

        this.plugins = newPlugins;
        this.pluginMap.clear();
        this.inputState.ensureHandlers(this, this.plugins);
      } else {
        for (let p of this.plugins) p.mustUpdate = update;
      }

      for (let i = 0; i < this.plugins.length; i++) this.plugins[i].update(this);
    }
    /**
    @internal
    */


    measure(flush = true) {
      if (this.destroyed) return;
      if (this.measureScheduled > -1) cancelAnimationFrame(this.measureScheduled);
      this.measureScheduled = 0; // Prevent requestMeasure calls from scheduling another animation frame

      if (flush) this.observer.forceFlush();
      let updated = null;
      let {
        scrollHeight,
        scrollTop,
        clientHeight
      } = this.scrollDOM;
      let refHeight = scrollTop > scrollHeight - clientHeight - 4 ? scrollHeight : scrollTop;

      try {
        for (let i = 0;; i++) {
          this.updateState = 1
          /* UpdateState.Measuring */
          ;
          let oldViewport = this.viewport;
          let refBlock = this.viewState.lineBlockAtHeight(refHeight);
          let changed = this.viewState.measure(this);
          if (!changed && !this.measureRequests.length && this.viewState.scrollTarget == null) break;

          if (i > 5) {
            console.warn(this.measureRequests.length ? "Measure loop restarted more than 5 times" : "Viewport failed to stabilize");
            break;
          }

          let measuring = []; // Only run measure requests in this cycle when the viewport didn't change

          if (!(changed & 4
          /* UpdateFlag.Viewport */
          )) [this.measureRequests, measuring] = [measuring, this.measureRequests];
          let measured = measuring.map(m => {
            try {
              return m.read(this);
            } catch (e) {
              logException(this.state, e);
              return BadMeasure;
            }
          });
          let update = ViewUpdate.create(this, this.state, []),
              redrawn = false,
              scrolled = false;
          update.flags |= changed;
          if (!updated) updated = update;else updated.flags |= changed;
          this.updateState = 2
          /* UpdateState.Updating */
          ;

          if (!update.empty) {
            this.updatePlugins(update);
            this.inputState.update(update);
            this.updateAttrs();
            redrawn = this.docView.update(update);
          }

          for (let i = 0; i < measuring.length; i++) if (measured[i] != BadMeasure) {
            try {
              let m = measuring[i];
              if (m.write) m.write(measured[i], this);
            } catch (e) {
              logException(this.state, e);
            }
          }

          if (this.viewState.scrollTarget) {
            this.docView.scrollIntoView(this.viewState.scrollTarget);
            this.viewState.scrollTarget = null;
            scrolled = true;
          } else {
            let diff = this.viewState.lineBlockAt(refBlock.from).top - refBlock.top;

            if (diff > 1 || diff < -1) {
              this.scrollDOM.scrollTop += diff;
              scrolled = true;
            }
          }

          if (redrawn) this.docView.updateSelection(true);
          if (this.viewport.from == oldViewport.from && this.viewport.to == oldViewport.to && !scrolled && this.measureRequests.length == 0) break;
        }
      } finally {
        this.updateState = 0
        /* UpdateState.Idle */
        ;
        this.measureScheduled = -1;
      }

      if (updated && !updated.empty) for (let listener of this.state.facet(updateListener)) listener(updated);
    }
    /**
    Get the CSS classes for the currently active editor themes.
    */


    get themeClasses() {
      return baseThemeID + " " + (this.state.facet(darkTheme) ? baseDarkID : baseLightID) + " " + this.state.facet(theme$1);
    }

    updateAttrs() {
      let editorAttrs = attrsFromFacet(this, editorAttributes, {
        class: "cm-editor" + (this.hasFocus ? " cm-focused " : " ") + this.themeClasses
      });
      let contentAttrs = {
        spellcheck: "false",
        autocorrect: "off",
        autocapitalize: "off",
        translate: "no",
        contenteditable: !this.state.facet(editable) ? "false" : "true",
        class: "cm-content",
        style: `${browser.tabSize}: ${this.state.tabSize}`,
        role: "textbox",
        "aria-multiline": "true"
      };
      if (this.state.readOnly) contentAttrs["aria-readonly"] = "true";
      attrsFromFacet(this, contentAttributes, contentAttrs);
      let changed = this.observer.ignore(() => {
        let changedContent = updateAttrs(this.contentDOM, this.contentAttrs, contentAttrs);
        let changedEditor = updateAttrs(this.dom, this.editorAttrs, editorAttrs);
        return changedContent || changedEditor;
      });
      this.editorAttrs = editorAttrs;
      this.contentAttrs = contentAttrs;
      return changed;
    }

    showAnnouncements(trs) {
      let first = true;

      for (let tr of trs) for (let effect of tr.effects) if (effect.is(EditorView.announce)) {
        if (first) this.announceDOM.textContent = "";
        first = false;
        let div = this.announceDOM.appendChild(document.createElement("div"));
        div.textContent = effect.value;
      }
    }

    mountStyles() {
      this.styleModules = this.state.facet(styleModule);
      StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1$1).reverse());
    }

    readMeasured() {
      if (this.updateState == 2
      /* UpdateState.Updating */
      ) throw new Error("Reading the editor layout isn't allowed during an update");
      if (this.updateState == 0
      /* UpdateState.Idle */
      && this.measureScheduled > -1) this.measure(false);
    }
    /**
    Schedule a layout measurement, optionally providing callbacks to
    do custom DOM measuring followed by a DOM write phase. Using
    this is preferable reading DOM layout directly from, for
    example, an event handler, because it'll make sure measuring and
    drawing done by other components is synchronized, avoiding
    unnecessary DOM layout computations.
    */


    requestMeasure(request) {
      if (this.measureScheduled < 0) this.measureScheduled = this.win.requestAnimationFrame(() => this.measure());

      if (request) {
        if (request.key != null) for (let i = 0; i < this.measureRequests.length; i++) {
          if (this.measureRequests[i].key === request.key) {
            this.measureRequests[i] = request;
            return;
          }
        }
        this.measureRequests.push(request);
      }
    }
    /**
    Get the value of a specific plugin, if present. Note that
    plugins that crash can be dropped from a view, so even when you
    know you registered a given plugin, it is recommended to check
    the return value of this method.
    */


    plugin(plugin) {
      let known = this.pluginMap.get(plugin);
      if (known === undefined || known && known.spec != plugin) this.pluginMap.set(plugin, known = this.plugins.find(p => p.spec == plugin) || null);
      return known && known.update(this).value;
    }
    /**
    The top position of the document, in screen coordinates. This
    may be negative when the editor is scrolled down. Points
    directly to the top of the first line, not above the padding.
    */


    get documentTop() {
      return this.contentDOM.getBoundingClientRect().top + this.viewState.paddingTop;
    }
    /**
    Reports the padding above and below the document.
    */


    get documentPadding() {
      return {
        top: this.viewState.paddingTop,
        bottom: this.viewState.paddingBottom
      };
    }
    /**
    Find the text line or block widget at the given vertical
    position (which is interpreted as relative to the [top of the
    document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop)).
    */


    elementAtHeight(height) {
      this.readMeasured();
      return this.viewState.elementAtHeight(height);
    }
    /**
    Find the line block (see
    [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given
    height, again interpreted relative to the [top of the
    document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop).
    */


    lineBlockAtHeight(height) {
      this.readMeasured();
      return this.viewState.lineBlockAtHeight(height);
    }
    /**
    Get the extent and vertical position of all [line
    blocks](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) in the viewport. Positions
    are relative to the [top of the
    document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop);
    */


    get viewportLineBlocks() {
      return this.viewState.viewportLines;
    }
    /**
    Find the line block around the given document position. A line
    block is a range delimited on both sides by either a
    non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^replace) line breaks, or the
    start/end of the document. It will usually just hold a line of
    text, but may be broken into multiple textblocks by block
    widgets.
    */


    lineBlockAt(pos) {
      return this.viewState.lineBlockAt(pos);
    }
    /**
    The editor's total content height.
    */


    get contentHeight() {
      return this.viewState.contentHeight;
    }
    /**
    Move a cursor position by [grapheme
    cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak). `forward` determines whether
    the motion is away from the line start, or towards it. In
    bidirectional text, the line is traversed in visual order, using
    the editor's [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
    When the start position was the last one on the line, the
    returned position will be across the line break. If there is no
    further line, the original position is returned.
    
    By default, this method moves over a single cluster. The
    optional `by` argument can be used to move across more. It will
    be called with the first cluster as argument, and should return
    a predicate that determines, for each subsequent cluster,
    whether it should also be moved over.
    */


    moveByChar(start, forward, by) {
      return skipAtoms(this, start, moveByChar(this, start, forward, by));
    }
    /**
    Move a cursor position across the next group of either
    [letters](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) or non-letter
    non-whitespace characters.
    */


    moveByGroup(start, forward) {
      return skipAtoms(this, start, moveByChar(this, start, forward, initial => byGroup(this, start.head, initial)));
    }
    /**
    Move to the next line boundary in the given direction. If
    `includeWrap` is true, line wrapping is on, and there is a
    further wrap point on the current line, the wrap point will be
    returned. Otherwise this function will return the start or end
    of the line.
    */


    moveToLineBoundary(start, forward, includeWrap = true) {
      return moveToLineBoundary(this, start, forward, includeWrap);
    }
    /**
    Move a cursor position vertically. When `distance` isn't given,
    it defaults to moving to the next line (including wrapped
    lines). Otherwise, `distance` should provide a positive distance
    in pixels.
    
    When `start` has a
    [`goalColumn`](https://codemirror.net/6/docs/ref/#state.SelectionRange.goalColumn), the vertical
    motion will use that as a target horizontal position. Otherwise,
    the cursor's own horizontal position is used. The returned
    cursor will have its goal column set to whichever column was
    used.
    */


    moveVertically(start, forward, distance) {
      return skipAtoms(this, start, moveVertically(this, start, forward, distance));
    }
    /**
    Find the DOM parent node and offset (child offset if `node` is
    an element, character offset when it is a text node) at the
    given document position.
    
    Note that for positions that aren't currently in
    `visibleRanges`, the resulting DOM position isn't necessarily
    meaningful (it may just point before or after a placeholder
    element).
    */


    domAtPos(pos) {
      return this.docView.domAtPos(pos);
    }
    /**
    Find the document position at the given DOM node. Can be useful
    for associating positions with DOM events. Will raise an error
    when `node` isn't part of the editor content.
    */


    posAtDOM(node, offset = 0) {
      return this.docView.posFromDOM(node, offset);
    }

    posAtCoords(coords, precise = true) {
      this.readMeasured();
      return posAtCoords(this, coords, precise);
    }
    /**
    Get the screen coordinates at the given document position.
    `side` determines whether the coordinates are based on the
    element before (-1) or after (1) the position (if no element is
    available on the given side, the method will transparently use
    another strategy to get reasonable coordinates).
    */


    coordsAtPos(pos, side = 1) {
      this.readMeasured();
      let rect = this.docView.coordsAt(pos, side);
      if (!rect || rect.left == rect.right) return rect;
      let line = this.state.doc.lineAt(pos),
          order = this.bidiSpans(line);
      let span = order[BidiSpan.find(order, pos - line.from, -1, side)];
      return flattenRect(rect, span.dir == Direction.LTR == side > 0);
    }
    /**
    The default width of a character in the editor. May not
    accurately reflect the width of all characters (given variable
    width fonts or styling of invididual ranges).
    */


    get defaultCharacterWidth() {
      return this.viewState.heightOracle.charWidth;
    }
    /**
    The default height of a line in the editor. May not be accurate
    for all lines.
    */


    get defaultLineHeight() {
      return this.viewState.heightOracle.lineHeight;
    }
    /**
    The text direction
    ([`direction`](https://developer.mozilla.org/en-US/docs/Web/CSS/direction)
    CSS property) of the editor's content element.
    */


    get textDirection() {
      return this.viewState.defaultTextDirection;
    }
    /**
    Find the text direction of the block at the given position, as
    assigned by CSS. If
    [`perLineTextDirection`](https://codemirror.net/6/docs/ref/#view.EditorView^perLineTextDirection)
    isn't enabled, or the given position is outside of the viewport,
    this will always return the same as
    [`textDirection`](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection). Note that
    this may trigger a DOM layout.
    */


    textDirectionAt(pos) {
      let perLine = this.state.facet(perLineTextDirection);
      if (!perLine || pos < this.viewport.from || pos > this.viewport.to) return this.textDirection;
      this.readMeasured();
      return this.docView.textDirectionAt(pos);
    }
    /**
    Whether this editor [wraps lines](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping)
    (as determined by the
    [`white-space`](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space)
    CSS property of its content element).
    */


    get lineWrapping() {
      return this.viewState.heightOracle.lineWrapping;
    }
    /**
    Returns the bidirectional text structure of the given line
    (which should be in the current document) as an array of span
    objects. The order of these spans matches the [text
    direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection)—if that is
    left-to-right, the leftmost spans come first, otherwise the
    rightmost spans come first.
    */


    bidiSpans(line) {
      if (line.length > MaxBidiLine) return trivialOrder(line.length);
      let dir = this.textDirectionAt(line.from);

      for (let entry of this.bidiCache) if (entry.from == line.from && entry.dir == dir) return entry.order;

      let order = computeOrder(line.text, dir);
      this.bidiCache.push(new CachedOrder(line.from, line.to, dir, order));
      return order;
    }
    /**
    Check whether the editor has focus.
    */


    get hasFocus() {
      var _a; // Safari return false for hasFocus when the context menu is open
      // or closing, which leads us to ignore selection changes from the
      // context menu because it looks like the editor isn't focused.
      // This kludges around that.


      return (this.dom.ownerDocument.hasFocus() || browser.safari && ((_a = this.inputState) === null || _a === void 0 ? void 0 : _a.lastContextMenu) > Date.now() - 3e4) && this.root.activeElement == this.contentDOM;
    }
    /**
    Put focus on the editor.
    */


    focus() {
      this.observer.ignore(() => {
        focusPreventScroll(this.contentDOM);
        this.docView.updateSelection();
      });
    }
    /**
    Update the [root](https://codemirror.net/6/docs/ref/##view.EditorViewConfig.root) in which the editor lives. This is only
    necessary when moving the editor's existing DOM to a new window or shadow root.
    */


    setRoot(root) {
      if (this._root != root) {
        this._root = root;
        this.observer.setWindow((root.nodeType == 9 ? root : root.ownerDocument).defaultView || window);
        this.mountStyles();
      }
    }
    /**
    Clean up this editor view, removing its element from the
    document, unregistering event handlers, and notifying
    plugins. The view instance can no longer be used after
    calling this.
    */


    destroy() {
      for (let plugin of this.plugins) plugin.destroy(this);

      this.plugins = [];
      this.inputState.destroy();
      this.dom.remove();
      this.observer.destroy();
      if (this.measureScheduled > -1) cancelAnimationFrame(this.measureScheduled);
      this.destroyed = true;
    }
    /**
    Returns an effect that can be
    [added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a transaction to
    cause it to scroll the given position or range into view.
    */


    static scrollIntoView(pos, options = {}) {
      return scrollIntoView$1.of(new ScrollTarget(typeof pos == "number" ? EditorSelection.cursor(pos) : pos, options.y, options.x, options.yMargin, options.xMargin));
    }
    /**
    Returns an extension that can be used to add DOM event handlers.
    The value should be an object mapping event names to handler
    functions. For any given event, such functions are ordered by
    extension precedence, and the first handler to return true will
    be assumed to have handled that event, and no other handlers or
    built-in behavior will be activated for it. These are registered
    on the [content element](https://codemirror.net/6/docs/ref/#view.EditorView.contentDOM), except
    for `scroll` handlers, which will be called any time the
    editor's [scroll element](https://codemirror.net/6/docs/ref/#view.EditorView.scrollDOM) or one of
    its parent nodes is scrolled.
    */


    static domEventHandlers(handlers) {
      return ViewPlugin.define(() => ({}), {
        eventHandlers: handlers
      });
    }
    /**
    Create a theme extension. The first argument can be a
    [`style-mod`](https://github.com/marijnh/style-mod#documentation)
    style spec providing the styles for the theme. These will be
    prefixed with a generated class for the style.
    
    Because the selectors will be prefixed with a scope class, rule
    that directly match the editor's [wrapper
    element](https://codemirror.net/6/docs/ref/#view.EditorView.dom)—to which the scope class will be
    added—need to be explicitly differentiated by adding an `&` to
    the selector for that element—for example
    `&.cm-focused`.
    
    When `dark` is set to true, the theme will be marked as dark,
    which will cause the `&dark` rules from [base
    themes](https://codemirror.net/6/docs/ref/#view.EditorView^baseTheme) to be used (as opposed to
    `&light` when a light theme is active).
    */


    static theme(spec, options) {
      let prefix = StyleModule.newName();
      let result = [theme$1.of(prefix), styleModule.of(buildTheme(`.${prefix}`, spec))];
      if (options && options.dark) result.push(darkTheme.of(true));
      return result;
    }
    /**
    Create an extension that adds styles to the base theme. Like
    with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the
    place of the editor wrapper element when directly targeting
    that. You can also use `&dark` or `&light` instead to only
    target editors with a dark or light theme.
    */


    static baseTheme(spec) {
      return Prec.lowest(styleModule.of(buildTheme("." + baseThemeID, spec, lightDarkIDs)));
    }
    /**
    Retrieve an editor view instance from the view's DOM
    representation.
    */


    static findFromDOM(dom) {
      var _a;

      let content = dom.querySelector(".cm-content");
      let cView = content && ContentView.get(content) || ContentView.get(dom);
      return ((_a = cView === null || cView === void 0 ? void 0 : cView.rootView) === null || _a === void 0 ? void 0 : _a.view) || null;
    }

  }
  /**
  Facet to add a [style
  module](https://github.com/marijnh/style-mod#documentation) to
  an editor view. The view will ensure that the module is
  mounted in its [document
  root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
  */


  EditorView.styleModule = styleModule;
  /**
  An input handler can override the way changes to the editable
  DOM content are handled. Handlers are passed the document
  positions between which the change was found, and the new
  content. When one returns true, no further input handlers are
  called and the default behavior is prevented.
  */

  EditorView.inputHandler = inputHandler$1;
  /**
  By default, the editor assumes all its content has the same
  [text direction](https://codemirror.net/6/docs/ref/#view.Direction). Configure this with a `true`
  value to make it read the text direction of every (rendered)
  line separately.
  */

  EditorView.perLineTextDirection = perLineTextDirection;
  /**
  Allows you to provide a function that should be called when the
  library catches an exception from an extension (mostly from view
  plugins, but may be used by other extensions to route exceptions
  from user-code-provided callbacks). This is mostly useful for
  debugging and logging. See [`logException`](https://codemirror.net/6/docs/ref/#view.logException).
  */

  EditorView.exceptionSink = exceptionSink;
  /**
  A facet that can be used to register a function to be called
  every time the view updates.
  */

  EditorView.updateListener = updateListener;
  /**
  Facet that controls whether the editor content DOM is editable.
  When its highest-precedence value is `false`, the element will
  not have its `contenteditable` attribute set. (Note that this
  doesn't affect API calls that change the editor content, even
  when those are bound to keys or buttons. See the
  [`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) facet for that.)
  */

  EditorView.editable = editable;
  /**
  Allows you to influence the way mouse selection happens. The
  functions in this facet will be called for a `mousedown` event
  on the editor, and can return an object that overrides the way a
  selection is computed from that mouse click or drag.
  */

  EditorView.mouseSelectionStyle = mouseSelectionStyle;
  /**
  Facet used to configure whether a given selection drag event
  should move or copy the selection. The given predicate will be
  called with the `mousedown` event, and can return `true` when
  the drag should move the content.
  */

  EditorView.dragMovesSelection = dragMovesSelection$1;
  /**
  Facet used to configure whether a given selecting click adds a
  new range to the existing selection or replaces it entirely. The
  default behavior is to check `event.metaKey` on macOS, and
  `event.ctrlKey` elsewhere.
  */

  EditorView.clickAddsSelectionRange = clickAddsSelectionRange;
  /**
  A facet that determines which [decorations](https://codemirror.net/6/docs/ref/#view.Decoration)
  are shown in the view. Decorations can be provided in two
  ways—directly, or via a function that takes an editor view.

  Only decoration sets provided directly are allowed to influence
  the editor's vertical layout structure. The ones provided as
  functions are called _after_ the new viewport has been computed,
  and thus **must not** introduce block widgets or replacing
  decorations that cover line breaks.

  If you want decorated ranges to behave like atomic units for
  cursor motion and deletion purposes, also provide the range set
  containing the decorations to
  [`EditorView.atomicRanges`](https://codemirror.net/6/docs/ref/#view.EditorView^atomicRanges).
  */

  EditorView.decorations = decorations;
  /**
  Used to provide ranges that should be treated as atoms as far as
  cursor motion is concerned. This causes methods like
  [`moveByChar`](https://codemirror.net/6/docs/ref/#view.EditorView.moveByChar) and
  [`moveVertically`](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) (and the
  commands built on top of them) to skip across such regions when
  a selection endpoint would enter them. This does _not_ prevent
  direct programmatic [selection
  updates](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) from moving into such
  regions.
  */

  EditorView.atomicRanges = atomicRanges;
  /**
  Facet that allows extensions to provide additional scroll
  margins (space around the sides of the scrolling element that
  should be considered invisible). This can be useful when the
  plugin introduces elements that cover part of that element (for
  example a horizontally fixed gutter).
  */

  EditorView.scrollMargins = scrollMargins;
  /**
  This facet records whether a dark theme is active. The extension
  returned by [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme) automatically
  includes an instance of this when the `dark` option is set to
  true.
  */

  EditorView.darkTheme = darkTheme;
  /**
  Facet that provides additional DOM attributes for the editor's
  editable DOM element.
  */

  EditorView.contentAttributes = contentAttributes;
  /**
  Facet that provides DOM attributes for the editor's outer
  element.
  */

  EditorView.editorAttributes = editorAttributes;
  /**
  An extension that enables line wrapping in the editor (by
  setting CSS `white-space` to `pre-wrap` in the content).
  */

  EditorView.lineWrapping = /*@__PURE__*/EditorView.contentAttributes.of({
    "class": "cm-lineWrapping"
  });
  /**
  State effect used to include screen reader announcements in a
  transaction. These will be added to the DOM in a visually hidden
  element with `aria-live="polite"` set, and should be used to
  describe effects that are visually obvious but may not be
  noticed by screen reader users (such as moving to the next
  search match).
  */

  EditorView.announce = /*@__PURE__*/StateEffect.define(); // Maximum line length for which we compute accurate bidi info

  const MaxBidiLine = 4096;
  const BadMeasure = {};

  class CachedOrder {
    constructor(from, to, dir, order) {
      this.from = from;
      this.to = to;
      this.dir = dir;
      this.order = order;
    }

    static update(cache, changes) {
      if (changes.empty) return cache;
      let result = [],
          lastDir = cache.length ? cache[cache.length - 1].dir : Direction.LTR;

      for (let i = Math.max(0, cache.length - 10); i < cache.length; i++) {
        let entry = cache[i];
        if (entry.dir == lastDir && !changes.touchesRange(entry.from, entry.to)) result.push(new CachedOrder(changes.mapPos(entry.from, 1), changes.mapPos(entry.to, -1), entry.dir, entry.order));
      }

      return result;
    }

  }

  function attrsFromFacet(view, facet, base) {
    for (let sources = view.state.facet(facet), i = sources.length - 1; i >= 0; i--) {
      let source = sources[i],
          value = typeof source == "function" ? source(view) : source;
      if (value) combineAttrs(value, base);
    }

    return base;
  }

  const currentPlatform = browser.mac ? "mac" : browser.windows ? "win" : browser.linux ? "linux" : "key";

  function normalizeKeyName(name, platform) {
    const parts = name.split(/-(?!$)/);
    let result = parts[parts.length - 1];
    if (result == "Space") result = " ";
    let alt, ctrl, shift, meta;

    for (let i = 0; i < parts.length - 1; ++i) {
      const mod = parts[i];
      if (/^(cmd|meta|m)$/i.test(mod)) meta = true;else if (/^a(lt)?$/i.test(mod)) alt = true;else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true;else if (/^s(hift)?$/i.test(mod)) shift = true;else if (/^mod$/i.test(mod)) {
        if (platform == "mac") meta = true;else ctrl = true;
      } else throw new Error("Unrecognized modifier name: " + mod);
    }

    if (alt) result = "Alt-" + result;
    if (ctrl) result = "Ctrl-" + result;
    if (meta) result = "Meta-" + result;
    if (shift) result = "Shift-" + result;
    return result;
  }

  function modifiers(name, event, shift) {
    if (event.altKey) name = "Alt-" + name;
    if (event.ctrlKey) name = "Ctrl-" + name;
    if (event.metaKey) name = "Meta-" + name;
    if (shift !== false && event.shiftKey) name = "Shift-" + name;
    return name;
  }

  const handleKeyEvents = /*@__PURE__*/Prec.default( /*@__PURE__*/EditorView.domEventHandlers({
    keydown(event, view) {
      return runHandlers(getKeymap(view.state), event, view, "editor");
    }

  }));
  /**
  Facet used for registering keymaps.

  You can add multiple keymaps to an editor. Their priorities
  determine their precedence (the ones specified early or with high
  priority get checked first). When a handler has returned `true`
  for a given key, no further handlers are called.
  */

  const keymap = /*@__PURE__*/Facet.define({
    enables: handleKeyEvents
  });
  const Keymaps = /*@__PURE__*/new WeakMap(); // This is hidden behind an indirection, rather than directly computed
  // by the facet, to keep internal types out of the facet's type.

  function getKeymap(state) {
    let bindings = state.facet(keymap);
    let map = Keymaps.get(bindings);
    if (!map) Keymaps.set(bindings, map = buildKeymap(bindings.reduce((a, b) => a.concat(b), [])));
    return map;
  }

  let storedPrefix = null;
  const PrefixTimeout = 4000;

  function buildKeymap(bindings, platform = currentPlatform) {
    let bound = Object.create(null);
    let isPrefix = Object.create(null);

    let checkPrefix = (name, is) => {
      let current = isPrefix[name];
      if (current == null) isPrefix[name] = is;else if (current != is) throw new Error("Key binding " + name + " is used both as a regular binding and as a multi-stroke prefix");
    };

    let add = (scope, key, command, preventDefault) => {
      let scopeObj = bound[scope] || (bound[scope] = Object.create(null));
      let parts = key.split(/ (?!$)/).map(k => normalizeKeyName(k, platform));

      for (let i = 1; i < parts.length; i++) {
        let prefix = parts.slice(0, i).join(" ");
        checkPrefix(prefix, true);
        if (!scopeObj[prefix]) scopeObj[prefix] = {
          preventDefault: true,
          commands: [view => {
            let ourObj = storedPrefix = {
              view,
              prefix,
              scope
            };
            setTimeout(() => {
              if (storedPrefix == ourObj) storedPrefix = null;
            }, PrefixTimeout);
            return true;
          }]
        };
      }

      let full = parts.join(" ");
      checkPrefix(full, false);
      let binding = scopeObj[full] || (scopeObj[full] = {
        preventDefault: false,
        commands: []
      });
      binding.commands.push(command);
      if (preventDefault) binding.preventDefault = true;
    };

    for (let b of bindings) {
      let name = b[platform] || b.key;
      if (!name) continue;

      for (let scope of b.scope ? b.scope.split(" ") : ["editor"]) {
        add(scope, name, b.run, b.preventDefault);
        if (b.shift) add(scope, "Shift-" + name, b.shift, b.preventDefault);
      }
    }

    return bound;
  }

  function runHandlers(map, event, view, scope) {
    let name = keyName(event);
    let charCode = codePointAt(name, 0),
        isChar = codePointSize(charCode) == name.length && name != " ";
    let prefix = "",
        fallthrough = false;

    if (storedPrefix && storedPrefix.view == view && storedPrefix.scope == scope) {
      prefix = storedPrefix.prefix + " ";
      if (fallthrough = modifierCodes.indexOf(event.keyCode) < 0) storedPrefix = null;
    }

    let runFor = binding => {
      if (binding) {
        for (let cmd of binding.commands) if (cmd(view)) return true;

        if (binding.preventDefault) fallthrough = true;
      }

      return false;
    };

    let scopeObj = map[scope],
        baseName,
        shiftName;

    if (scopeObj) {
      if (runFor(scopeObj[prefix + modifiers(name, event, !isChar)])) return true;

      if (isChar && (event.shiftKey || event.altKey || event.metaKey || charCode > 127) && (baseName = base[event.keyCode]) && baseName != name) {
        if (runFor(scopeObj[prefix + modifiers(baseName, event, true)])) return true;else if (event.shiftKey && (shiftName = shift[event.keyCode]) != name && shiftName != baseName && runFor(scopeObj[prefix + modifiers(shiftName, event, false)])) return true;
      } else if (isChar && event.shiftKey) {
        if (runFor(scopeObj[prefix + modifiers(name, event, true)])) return true;
      }
    }

    return fallthrough;
  }

  const CanHidePrimary = !browser.ios; // FIXME test IE
  const themeSpec = {
    ".cm-line": {
      "& ::selection": {
        backgroundColor: "transparent !important"
      },
      "&::selection": {
        backgroundColor: "transparent !important"
      }
    }
  };
  if (CanHidePrimary) themeSpec[".cm-line"].caretColor = "transparent !important";

  const Outside = "-10000px";

  class TooltipViewManager {
    constructor(view, facet, createTooltipView) {
      this.facet = facet;
      this.createTooltipView = createTooltipView;
      this.input = view.state.facet(facet);
      this.tooltips = this.input.filter(t => t);
      this.tooltipViews = this.tooltips.map(createTooltipView);
    }

    update(update) {
      let input = update.state.facet(this.facet);
      let tooltips = input.filter(x => x);

      if (input === this.input) {
        for (let t of this.tooltipViews) if (t.update) t.update(update);

        return false;
      }

      let tooltipViews = [];

      for (let i = 0; i < tooltips.length; i++) {
        let tip = tooltips[i],
            known = -1;
        if (!tip) continue;

        for (let i = 0; i < this.tooltips.length; i++) {
          let other = this.tooltips[i];
          if (other && other.create == tip.create) known = i;
        }

        if (known < 0) {
          tooltipViews[i] = this.createTooltipView(tip);
        } else {
          let tooltipView = tooltipViews[i] = this.tooltipViews[known];
          if (tooltipView.update) tooltipView.update(update);
        }
      }

      for (let t of this.tooltipViews) if (tooltipViews.indexOf(t) < 0) t.dom.remove();

      this.input = input;
      this.tooltips = tooltips;
      this.tooltipViews = tooltipViews;
      return true;
    }

  }

  function windowSpace(view) {
    let {
      win
    } = view;
    return {
      top: 0,
      left: 0,
      bottom: win.innerHeight,
      right: win.innerWidth
    };
  }

  const tooltipConfig = /*@__PURE__*/Facet.define({
    combine: values => {
      var _a, _b, _c;

      return {
        position: browser.ios ? "absolute" : ((_a = values.find(conf => conf.position)) === null || _a === void 0 ? void 0 : _a.position) || "fixed",
        parent: ((_b = values.find(conf => conf.parent)) === null || _b === void 0 ? void 0 : _b.parent) || null,
        tooltipSpace: ((_c = values.find(conf => conf.tooltipSpace)) === null || _c === void 0 ? void 0 : _c.tooltipSpace) || windowSpace
      };
    }
  });
  const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
    constructor(view) {
      this.view = view;
      this.inView = true;
      this.lastTransaction = 0;
      this.measureTimeout = -1;
      let config = view.state.facet(tooltipConfig);
      this.position = config.position;
      this.parent = config.parent;
      this.classes = view.themeClasses;
      this.createContainer();
      this.measureReq = {
        read: this.readMeasure.bind(this),
        write: this.writeMeasure.bind(this),
        key: this
      };
      this.manager = new TooltipViewManager(view, showTooltip, t => this.createTooltip(t));
      this.intersectionObserver = typeof IntersectionObserver == "function" ? new IntersectionObserver(entries => {
        if (Date.now() > this.lastTransaction - 50 && entries.length > 0 && entries[entries.length - 1].intersectionRatio < 1) this.measureSoon();
      }, {
        threshold: [1]
      }) : null;
      this.observeIntersection();
      view.win.addEventListener("resize", this.measureSoon = this.measureSoon.bind(this));
      this.maybeMeasure();
    }

    createContainer() {
      if (this.parent) {
        this.container = document.createElement("div");
        this.container.style.position = "relative";
        this.container.className = this.view.themeClasses;
        this.parent.appendChild(this.container);
      } else {
        this.container = this.view.dom;
      }
    }

    observeIntersection() {
      if (this.intersectionObserver) {
        this.intersectionObserver.disconnect();

        for (let tooltip of this.manager.tooltipViews) this.intersectionObserver.observe(tooltip.dom);
      }
    }

    measureSoon() {
      if (this.measureTimeout < 0) this.measureTimeout = setTimeout(() => {
        this.measureTimeout = -1;
        this.maybeMeasure();
      }, 50);
    }

    update(update) {
      if (update.transactions.length) this.lastTransaction = Date.now();
      let updated = this.manager.update(update);
      if (updated) this.observeIntersection();
      let shouldMeasure = updated || update.geometryChanged;
      let newConfig = update.state.facet(tooltipConfig);

      if (newConfig.position != this.position) {
        this.position = newConfig.position;

        for (let t of this.manager.tooltipViews) t.dom.style.position = this.position;

        shouldMeasure = true;
      }

      if (newConfig.parent != this.parent) {
        if (this.parent) this.container.remove();
        this.parent = newConfig.parent;
        this.createContainer();

        for (let t of this.manager.tooltipViews) this.container.appendChild(t.dom);

        shouldMeasure = true;
      } else if (this.parent && this.view.themeClasses != this.classes) {
        this.classes = this.container.className = this.view.themeClasses;
      }

      if (shouldMeasure) this.maybeMeasure();
    }

    createTooltip(tooltip) {
      let tooltipView = tooltip.create(this.view);
      tooltipView.dom.classList.add("cm-tooltip");

      if (tooltip.arrow && !tooltipView.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")) {
        let arrow = document.createElement("div");
        arrow.className = "cm-tooltip-arrow";
        tooltipView.dom.appendChild(arrow);
      }

      tooltipView.dom.style.position = this.position;
      tooltipView.dom.style.top = Outside;
      this.container.appendChild(tooltipView.dom);
      if (tooltipView.mount) tooltipView.mount(this.view);
      return tooltipView;
    }

    destroy() {
      var _a;

      this.view.win.removeEventListener("resize", this.measureSoon);

      for (let {
        dom
      } of this.manager.tooltipViews) dom.remove();

      (_a = this.intersectionObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
      clearTimeout(this.measureTimeout);
    }

    readMeasure() {
      let editor = this.view.dom.getBoundingClientRect();
      return {
        editor,
        parent: this.parent ? this.container.getBoundingClientRect() : editor,
        pos: this.manager.tooltips.map((t, i) => {
          let tv = this.manager.tooltipViews[i];
          return tv.getCoords ? tv.getCoords(t.pos) : this.view.coordsAtPos(t.pos);
        }),
        size: this.manager.tooltipViews.map(({
          dom
        }) => dom.getBoundingClientRect()),
        space: this.view.state.facet(tooltipConfig).tooltipSpace(this.view)
      };
    }

    writeMeasure(measured) {
      let {
        editor,
        space
      } = measured;
      let others = [];

      for (let i = 0; i < this.manager.tooltips.length; i++) {
        let tooltip = this.manager.tooltips[i],
            tView = this.manager.tooltipViews[i],
            {
          dom
        } = tView;
        let pos = measured.pos[i],
            size = measured.size[i]; // Hide tooltips that are outside of the editor.

        if (!pos || pos.bottom <= Math.max(editor.top, space.top) || pos.top >= Math.min(editor.bottom, space.bottom) || pos.right < Math.max(editor.left, space.left) - .1 || pos.left > Math.min(editor.right, space.right) + .1) {
          dom.style.top = Outside;
          continue;
        }

        let arrow = tooltip.arrow ? tView.dom.querySelector(".cm-tooltip-arrow") : null;
        let arrowHeight = arrow ? 7
        /* Arrow.Size */
        : 0;
        let width = size.right - size.left,
            height = size.bottom - size.top;
        let offset = tView.offset || noOffset,
            ltr = this.view.textDirection == Direction.LTR;
        let left = size.width > space.right - space.left ? ltr ? space.left : space.right - size.width : ltr ? Math.min(pos.left - (arrow ? 14
        /* Arrow.Offset */
        : 0) + offset.x, space.right - width) : Math.max(space.left, pos.left - width + (arrow ? 14
        /* Arrow.Offset */
        : 0) - offset.x);
        let above = !!tooltip.above;
        if (!tooltip.strictSide && (above ? pos.top - (size.bottom - size.top) - offset.y < space.top : pos.bottom + (size.bottom - size.top) + offset.y > space.bottom) && above == space.bottom - pos.bottom > pos.top - space.top) above = !above;
        let top = above ? pos.top - height - arrowHeight - offset.y : pos.bottom + arrowHeight + offset.y;
        let right = left + width;
        if (tView.overlap !== true) for (let r of others) if (r.left < right && r.right > left && r.top < top + height && r.bottom > top) top = above ? r.top - height - 2 - arrowHeight : r.bottom + arrowHeight + 2;

        if (this.position == "absolute") {
          dom.style.top = top - measured.parent.top + "px";
          dom.style.left = left - measured.parent.left + "px";
        } else {
          dom.style.top = top + "px";
          dom.style.left = left + "px";
        }

        if (arrow) arrow.style.left = `${pos.left + (ltr ? offset.x : -offset.x) - (left + 14
      /* Arrow.Offset */
      - 7
      /* Arrow.Size */
      )}px`;
        if (tView.overlap !== true) others.push({
          left,
          top,
          right,
          bottom: top + height
        });
        dom.classList.toggle("cm-tooltip-above", above);
        dom.classList.toggle("cm-tooltip-below", !above);
        if (tView.positioned) tView.positioned();
      }
    }

    maybeMeasure() {
      if (this.manager.tooltips.length) {
        if (this.view.inView) this.view.requestMeasure(this.measureReq);

        if (this.inView != this.view.inView) {
          this.inView = this.view.inView;
          if (!this.inView) for (let tv of this.manager.tooltipViews) tv.dom.style.top = Outside;
        }
      }
    }

  }, {
    eventHandlers: {
      scroll() {
        this.maybeMeasure();
      }

    }
  });
  const baseTheme$4 = /*@__PURE__*/EditorView.baseTheme({
    ".cm-tooltip": {
      zIndex: 100
    },
    "&light .cm-tooltip": {
      border: "1px solid #bbb",
      backgroundColor: "#f5f5f5"
    },
    "&light .cm-tooltip-section:not(:first-child)": {
      borderTop: "1px solid #bbb"
    },
    "&dark .cm-tooltip": {
      backgroundColor: "#333338",
      color: "white"
    },
    ".cm-tooltip-arrow": {
      height: `${7
    /* Arrow.Size */
    }px`,
      width: `${7
    /* Arrow.Size */
    * 2}px`,
      position: "absolute",
      zIndex: -1,
      overflow: "hidden",
      "&:before, &:after": {
        content: "''",
        position: "absolute",
        width: 0,
        height: 0,
        borderLeft: `${7
      /* Arrow.Size */
      }px solid transparent`,
        borderRight: `${7
      /* Arrow.Size */
      }px solid transparent`
      },
      ".cm-tooltip-above &": {
        bottom: `-${7
      /* Arrow.Size */
      }px`,
        "&:before": {
          borderTop: `${7
        /* Arrow.Size */
        }px solid #bbb`
        },
        "&:after": {
          borderTop: `${7
        /* Arrow.Size */
        }px solid #f5f5f5`,
          bottom: "1px"
        }
      },
      ".cm-tooltip-below &": {
        top: `-${7
      /* Arrow.Size */
      }px`,
        "&:before": {
          borderBottom: `${7
        /* Arrow.Size */
        }px solid #bbb`
        },
        "&:after": {
          borderBottom: `${7
        /* Arrow.Size */
        }px solid #f5f5f5`,
          top: "1px"
        }
      }
    },
    "&dark .cm-tooltip .cm-tooltip-arrow": {
      "&:before": {
        borderTopColor: "#333338",
        borderBottomColor: "#333338"
      },
      "&:after": {
        borderTopColor: "transparent",
        borderBottomColor: "transparent"
      }
    }
  });
  const noOffset = {
    x: 0,
    y: 0
  };
  /**
  Facet to which an extension can add a value to show a tooltip.
  */

  const showTooltip = /*@__PURE__*/Facet.define({
    enables: [tooltipPlugin, baseTheme$4]
  });
  const showHoverTooltip = /*@__PURE__*/Facet.define();

  class HoverTooltipHost {
    constructor(view) {
      this.view = view;
      this.mounted = false;
      this.dom = document.createElement("div");
      this.dom.classList.add("cm-tooltip-hover");
      this.manager = new TooltipViewManager(view, showHoverTooltip, t => this.createHostedView(t));
    } // Needs to be static so that host tooltip instances always match


    static create(view) {
      return new HoverTooltipHost(view);
    }

    createHostedView(tooltip) {
      let hostedView = tooltip.create(this.view);
      hostedView.dom.classList.add("cm-tooltip-section");
      this.dom.appendChild(hostedView.dom);
      if (this.mounted && hostedView.mount) hostedView.mount(this.view);
      return hostedView;
    }

    mount(view) {
      for (let hostedView of this.manager.tooltipViews) {
        if (hostedView.mount) hostedView.mount(view);
      }

      this.mounted = true;
    }

    positioned() {
      for (let hostedView of this.manager.tooltipViews) {
        if (hostedView.positioned) hostedView.positioned();
      }
    }

    update(update) {
      this.manager.update(update);
    }

  }

  const showHoverTooltipHost = /*@__PURE__*/showTooltip.compute([showHoverTooltip], state => {
    let tooltips = state.facet(showHoverTooltip).filter(t => t);
    if (tooltips.length === 0) return null;
    return {
      pos: Math.min(...tooltips.map(t => t.pos)),
      end: Math.max(...tooltips.filter(t => t.end != null).map(t => t.end)),
      create: HoverTooltipHost.create,
      above: tooltips[0].above,
      arrow: tooltips.some(t => t.arrow)
    };
  });

  class HoverPlugin {
    constructor(view, source, field, setHover, hoverTime) {
      this.view = view;
      this.source = source;
      this.field = field;
      this.setHover = setHover;
      this.hoverTime = hoverTime;
      this.hoverTimeout = -1;
      this.restartTimeout = -1;
      this.pending = null;
      this.lastMove = {
        x: 0,
        y: 0,
        target: view.dom,
        time: 0
      };
      this.checkHover = this.checkHover.bind(this);
      view.dom.addEventListener("mouseleave", this.mouseleave = this.mouseleave.bind(this));
      view.dom.addEventListener("mousemove", this.mousemove = this.mousemove.bind(this));
    }

    update() {
      if (this.pending) {
        this.pending = null;
        clearTimeout(this.restartTimeout);
        this.restartTimeout = setTimeout(() => this.startHover(), 20);
      }
    }

    get active() {
      return this.view.state.field(this.field);
    }

    checkHover() {
      this.hoverTimeout = -1;
      if (this.active) return;
      let hovered = Date.now() - this.lastMove.time;
      if (hovered < this.hoverTime) this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime - hovered);else this.startHover();
    }

    startHover() {
      clearTimeout(this.restartTimeout);
      let {
        lastMove
      } = this;
      let pos = this.view.contentDOM.contains(lastMove.target) ? this.view.posAtCoords(lastMove) : null;
      if (pos == null) return;
      let posCoords = this.view.coordsAtPos(pos);
      if (posCoords == null || lastMove.y < posCoords.top || lastMove.y > posCoords.bottom || lastMove.x < posCoords.left - this.view.defaultCharacterWidth || lastMove.x > posCoords.right + this.view.defaultCharacterWidth) return;
      let bidi = this.view.bidiSpans(this.view.state.doc.lineAt(pos)).find(s => s.from <= pos && s.to >= pos);
      let rtl = bidi && bidi.dir == Direction.RTL ? -1 : 1;
      let open = this.source(this.view, pos, lastMove.x < posCoords.left ? -rtl : rtl);

      if (open === null || open === void 0 ? void 0 : open.then) {
        let pending = this.pending = {
          pos
        };
        open.then(result => {
          if (this.pending == pending) {
            this.pending = null;
            if (result) this.view.dispatch({
              effects: this.setHover.of(result)
            });
          }
        }, e => logException(this.view.state, e, "hover tooltip"));
      } else if (open) {
        this.view.dispatch({
          effects: this.setHover.of(open)
        });
      }
    }

    mousemove(event) {
      var _a;

      this.lastMove = {
        x: event.clientX,
        y: event.clientY,
        target: event.target,
        time: Date.now()
      };
      if (this.hoverTimeout < 0) this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime);
      let tooltip = this.active;

      if (tooltip && !isInTooltip(this.lastMove.target) || this.pending) {
        let {
          pos
        } = tooltip || this.pending,
            end = (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.end) !== null && _a !== void 0 ? _a : pos;

        if (pos == end ? this.view.posAtCoords(this.lastMove) != pos : !isOverRange(this.view, pos, end, event.clientX, event.clientY, 6
        /* Hover.MaxDist */
        )) {
          this.view.dispatch({
            effects: this.setHover.of(null)
          });
          this.pending = null;
        }
      }
    }

    mouseleave() {
      clearTimeout(this.hoverTimeout);
      this.hoverTimeout = -1;
      if (this.active) this.view.dispatch({
        effects: this.setHover.of(null)
      });
    }

    destroy() {
      clearTimeout(this.hoverTimeout);
      this.view.dom.removeEventListener("mouseleave", this.mouseleave);
      this.view.dom.removeEventListener("mousemove", this.mousemove);
    }

  }

  function isInTooltip(elt) {
    for (let cur = elt; cur; cur = cur.parentNode) if (cur.nodeType == 1 && cur.classList.contains("cm-tooltip")) return true;

    return false;
  }

  function isOverRange(view, from, to, x, y, margin) {
    let range = document.createRange();
    let fromDOM = view.domAtPos(from),
        toDOM = view.domAtPos(to);
    range.setEnd(toDOM.node, toDOM.offset);
    range.setStart(fromDOM.node, fromDOM.offset);
    let rects = range.getClientRects();
    range.detach();

    for (let i = 0; i < rects.length; i++) {
      let rect = rects[i];
      let dist = Math.max(rect.top - y, y - rect.bottom, rect.left - x, x - rect.right);
      if (dist <= margin) return true;
    }

    return false;
  }
  /**
  Set up a hover tooltip, which shows up when the pointer hovers
  over ranges of text. The callback is called when the mouse hovers
  over the document text. It should, if there is a tooltip
  associated with position `pos`, return the tooltip description
  (either directly or in a promise). The `side` argument indicates
  on which side of the position the pointer is—it will be -1 if the
  pointer is before the position, 1 if after the position.

  Note that all hover tooltips are hosted within a single tooltip
  container element. This allows multiple tooltips over the same
  range to be "merged" together without overlapping.
  */


  function hoverTooltip(source, options = {}) {
    let setHover = StateEffect.define();
    let hoverState = StateField.define({
      create() {
        return null;
      },

      update(value, tr) {
        if (value && (options.hideOnChange && (tr.docChanged || tr.selection) || options.hideOn && options.hideOn(tr, value))) return null;

        if (value && tr.docChanged) {
          let newPos = tr.changes.mapPos(value.pos, -1, MapMode.TrackDel);
          if (newPos == null) return null;
          let copy = Object.assign(Object.create(null), value);
          copy.pos = newPos;
          if (value.end != null) copy.end = tr.changes.mapPos(value.end);
          value = copy;
        }

        for (let effect of tr.effects) {
          if (effect.is(setHover)) value = effect.value;
          if (effect.is(closeHoverTooltipEffect)) value = null;
        }

        return value;
      },

      provide: f => showHoverTooltip.from(f)
    });
    return [hoverState, ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300
    /* Hover.Time */
    )), showHoverTooltipHost];
  }
  /**
  Get the active tooltip view for a given tooltip, if available.
  */


  function getTooltip(view, tooltip) {
    let plugin = view.plugin(tooltipPlugin);
    if (!plugin) return null;
    let found = plugin.manager.tooltips.indexOf(tooltip);
    return found < 0 ? null : plugin.manager.tooltipViews[found];
  }

  const closeHoverTooltipEffect = /*@__PURE__*/StateEffect.define();

  const panelConfig = /*@__PURE__*/Facet.define({
    combine(configs) {
      let topContainer, bottomContainer;

      for (let c of configs) {
        topContainer = topContainer || c.topContainer;
        bottomContainer = bottomContainer || c.bottomContainer;
      }

      return {
        topContainer,
        bottomContainer
      };
    }

  });

  const panelPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
    constructor(view) {
      this.input = view.state.facet(showPanel);
      this.specs = this.input.filter(s => s);
      this.panels = this.specs.map(spec => spec(view));
      let conf = view.state.facet(panelConfig);
      this.top = new PanelGroup(view, true, conf.topContainer);
      this.bottom = new PanelGroup(view, false, conf.bottomContainer);
      this.top.sync(this.panels.filter(p => p.top));
      this.bottom.sync(this.panels.filter(p => !p.top));

      for (let p of this.panels) {
        p.dom.classList.add("cm-panel");
        if (p.mount) p.mount();
      }
    }

    update(update) {
      let conf = update.state.facet(panelConfig);

      if (this.top.container != conf.topContainer) {
        this.top.sync([]);
        this.top = new PanelGroup(update.view, true, conf.topContainer);
      }

      if (this.bottom.container != conf.bottomContainer) {
        this.bottom.sync([]);
        this.bottom = new PanelGroup(update.view, false, conf.bottomContainer);
      }

      this.top.syncClasses();
      this.bottom.syncClasses();
      let input = update.state.facet(showPanel);

      if (input != this.input) {
        let specs = input.filter(x => x);
        let panels = [],
            top = [],
            bottom = [],
            mount = [];

        for (let spec of specs) {
          let known = this.specs.indexOf(spec),
              panel;

          if (known < 0) {
            panel = spec(update.view);
            mount.push(panel);
          } else {
            panel = this.panels[known];
            if (panel.update) panel.update(update);
          }

          panels.push(panel);
          (panel.top ? top : bottom).push(panel);
        }

        this.specs = specs;
        this.panels = panels;
        this.top.sync(top);
        this.bottom.sync(bottom);

        for (let p of mount) {
          p.dom.classList.add("cm-panel");
          if (p.mount) p.mount();
        }
      } else {
        for (let p of this.panels) if (p.update) p.update(update);
      }
    }

    destroy() {
      this.top.sync([]);
      this.bottom.sync([]);
    }

  }, {
    provide: plugin => EditorView.scrollMargins.of(view => {
      let value = view.plugin(plugin);
      return value && {
        top: value.top.scrollMargin(),
        bottom: value.bottom.scrollMargin()
      };
    })
  });

  class PanelGroup {
    constructor(view, top, container) {
      this.view = view;
      this.top = top;
      this.container = container;
      this.dom = undefined;
      this.classes = "";
      this.panels = [];
      this.syncClasses();
    }

    sync(panels) {
      for (let p of this.panels) if (p.destroy && panels.indexOf(p) < 0) p.destroy();

      this.panels = panels;
      this.syncDOM();
    }

    syncDOM() {
      if (this.panels.length == 0) {
        if (this.dom) {
          this.dom.remove();
          this.dom = undefined;
        }

        return;
      }

      if (!this.dom) {
        this.dom = document.createElement("div");
        this.dom.className = this.top ? "cm-panels cm-panels-top" : "cm-panels cm-panels-bottom";
        this.dom.style[this.top ? "top" : "bottom"] = "0";
        let parent = this.container || this.view.dom;
        parent.insertBefore(this.dom, this.top ? parent.firstChild : null);
      }

      let curDOM = this.dom.firstChild;

      for (let panel of this.panels) {
        if (panel.dom.parentNode == this.dom) {
          while (curDOM != panel.dom) curDOM = rm(curDOM);

          curDOM = curDOM.nextSibling;
        } else {
          this.dom.insertBefore(panel.dom, curDOM);
        }
      }

      while (curDOM) curDOM = rm(curDOM);
    }

    scrollMargin() {
      return !this.dom || this.container ? 0 : Math.max(0, this.top ? this.dom.getBoundingClientRect().bottom - Math.max(0, this.view.scrollDOM.getBoundingClientRect().top) : Math.min(innerHeight, this.view.scrollDOM.getBoundingClientRect().bottom) - this.dom.getBoundingClientRect().top);
    }

    syncClasses() {
      if (!this.container || this.classes == this.view.themeClasses) return;

      for (let cls of this.classes.split(" ")) if (cls) this.container.classList.remove(cls);

      for (let cls of (this.classes = this.view.themeClasses).split(" ")) if (cls) this.container.classList.add(cls);
    }

  }

  function rm(node) {
    let next = node.nextSibling;
    node.remove();
    return next;
  }
  /**
  Opening a panel is done by providing a constructor function for
  the panel through this facet. (The panel is closed again when its
  constructor is no longer provided.) Values of `null` are ignored.
  */


  const showPanel = /*@__PURE__*/Facet.define({
    enables: panelPlugin
  });
  /**
  A gutter marker represents a bit of information attached to a line
  in a specific gutter. Your own custom markers have to extend this
  class.
  */

  class GutterMarker extends RangeValue {
    /**
    @internal
    */
    compare(other) {
      return this == other || this.constructor == other.constructor && this.eq(other);
    }
    /**
    Compare this marker to another marker of the same type.
    */


    eq(other) {
      return false;
    }
    /**
    Called if the marker has a `toDOM` method and its representation
    was removed from a gutter.
    */


    destroy(dom) {}

  }

  GutterMarker.prototype.elementClass = "";
  GutterMarker.prototype.toDOM = undefined;
  GutterMarker.prototype.mapMode = MapMode.TrackBefore;
  GutterMarker.prototype.startSide = GutterMarker.prototype.endSide = -1;
  GutterMarker.prototype.point = true;

  // FIXME profile adding a per-Tree TreeNode cache, validating it by
  // parent pointer
  /// The default maximum length of a `TreeBuffer` node.
  const DefaultBufferLength = 1024;
  let nextPropID = 0;

  class Range {
    constructor(from, to) {
      this.from = from;
      this.to = to;
    }

  } /// Each [node type](#common.NodeType) or [individual tree](#common.Tree)
  /// can have metadata associated with it in props. Instances of this
  /// class represent prop names.


  class NodeProp {
    /// Create a new node prop type.
    constructor(config = {}) {
      this.id = nextPropID++;
      this.perNode = !!config.perNode;

      this.deserialize = config.deserialize || (() => {
        throw new Error("This node type doesn't define a deserialize function");
      });
    } /// This is meant to be used with
    /// [`NodeSet.extend`](#common.NodeSet.extend) or
    /// [`LRParser.configure`](#lr.ParserConfig.props) to compute
    /// prop values for each node type in the set. Takes a [match
    /// object](#common.NodeType^match) or function that returns undefined
    /// if the node type doesn't get this prop, and the prop's value if
    /// it does.


    add(match) {
      if (this.perNode) throw new RangeError("Can't add per-node props to node types");
      if (typeof match != "function") match = NodeType.match(match);
      return type => {
        let result = match(type);
        return result === undefined ? null : [this, result];
      };
    }

  } /// Prop that is used to describe matching delimiters. For opening
  /// delimiters, this holds an array of node names (written as a
  /// space-separated string when declaring this prop in a grammar)
  /// for the node types of closing delimiters that match it.


  NodeProp.closedBy = new NodeProp({
    deserialize: str => str.split(" ")
  }); /// The inverse of [`closedBy`](#common.NodeProp^closedBy). This is
  /// attached to closing delimiters, holding an array of node names
  /// of types of matching opening delimiters.

  NodeProp.openedBy = new NodeProp({
    deserialize: str => str.split(" ")
  }); /// Used to assign node types to groups (for example, all node
  /// types that represent an expression could be tagged with an
  /// `"Expression"` group).

  NodeProp.group = new NodeProp({
    deserialize: str => str.split(" ")
  }); /// The hash of the [context](#lr.ContextTracker.constructor)
  /// that the node was parsed in, if any. Used to limit reuse of
  /// contextual nodes.

  NodeProp.contextHash = new NodeProp({
    perNode: true
  }); /// The distance beyond the end of the node that the tokenizer
  /// looked ahead for any of the tokens inside the node. (The LR
  /// parser only stores this when it is larger than 25, for
  /// efficiency reasons.)

  NodeProp.lookAhead = new NodeProp({
    perNode: true
  }); /// This per-node prop is used to replace a given node, or part of a
  /// node, with another tree. This is useful to include trees from
  /// different languages in mixed-language parsers.

  NodeProp.mounted = new NodeProp({
    perNode: true
  }); /// A mounted tree, which can be [stored](#common.NodeProp^mounted) on

  const noProps = Object.create(null); /// Each node in a syntax tree has a node type associated with it.

  class NodeType {
    /// @internal
    constructor( /// The name of the node type. Not necessarily unique, but if the
    /// grammar was written properly, different node types with the
    /// same name within a node set should play the same semantic
    /// role.
    name, /// @internal
    props, /// The id of this node in its set. Corresponds to the term ids
    /// used in the parser.
    id, /// @internal
    flags = 0) {
      this.name = name;
      this.props = props;
      this.id = id;
      this.flags = flags;
    } /// Define a node type.


    static define(spec) {
      let props = spec.props && spec.props.length ? Object.create(null) : noProps;
      let flags = (spec.top ? 1
      /* Top */
      : 0) | (spec.skipped ? 2
      /* Skipped */
      : 0) | (spec.error ? 4
      /* Error */
      : 0) | (spec.name == null ? 8
      /* Anonymous */
      : 0);
      let type = new NodeType(spec.name || "", props, spec.id, flags);
      if (spec.props) for (let src of spec.props) {
        if (!Array.isArray(src)) src = src(type);

        if (src) {
          if (src[0].perNode) throw new RangeError("Can't store a per-node prop on a node type");
          props[src[0].id] = src[1];
        }
      }
      return type;
    } /// Retrieves a node prop for this type. Will return `undefined` if
    /// the prop isn't present on this node.


    prop(prop) {
      return this.props[prop.id];
    } /// True when this is the top node of a grammar.


    get isTop() {
      return (this.flags & 1
      /* Top */
      ) > 0;
    } /// True when this node is produced by a skip rule.


    get isSkipped() {
      return (this.flags & 2
      /* Skipped */
      ) > 0;
    } /// Indicates whether this is an error node.


    get isError() {
      return (this.flags & 4
      /* Error */
      ) > 0;
    } /// When true, this node type doesn't correspond to a user-declared
    /// named node, for example because it is used to cache repetition.


    get isAnonymous() {
      return (this.flags & 8
      /* Anonymous */
      ) > 0;
    } /// Returns true when this node's name or one of its
    /// [groups](#common.NodeProp^group) matches the given string.


    is(name) {
      if (typeof name == 'string') {
        if (this.name == name) return true;
        let group = this.prop(NodeProp.group);
        return group ? group.indexOf(name) > -1 : false;
      }

      return this.id == name;
    } /// Create a function from node types to arbitrary values by
    /// specifying an object whose property names are node or
    /// [group](#common.NodeProp^group) names. Often useful with
    /// [`NodeProp.add`](#common.NodeProp.add). You can put multiple
    /// names, separated by spaces, in a single property name to map
    /// multiple node names to a single value.


    static match(map) {
      let direct = Object.create(null);

      for (let prop in map) for (let name of prop.split(" ")) direct[name] = map[prop];

      return node => {
        for (let groups = node.prop(NodeProp.group), i = -1; i < (groups ? groups.length : 0); i++) {
          let found = direct[i < 0 ? node.name : groups[i]];
          if (found) return found;
        }
      };
    }

  } /// An empty dummy node type to use when no actual type is available.


  NodeType.none = new NodeType("", Object.create(null), 0, 8
  /* Anonymous */
  ); /// A node set holds a collection of node types. It is used to
  /// compactly represent trees by storing their type ids, rather than a
  /// full pointer to the type object, in a numeric array. Each parser
  /// [has](#lr.LRParser.nodeSet) a node set, and [tree
  /// buffers](#common.TreeBuffer) can only store collections of nodes
  /// from the same set. A set can have a maximum of 2**16 (65536) node
  /// types in it, so that the ids fit into 16-bit typed array slots.

  class NodeSet {
    /// Create a set with the given types. The `id` property of each
    /// type should correspond to its position within the array.
    constructor( /// The node types in this set, by id.
    types) {
      this.types = types;

      for (let i = 0; i < types.length; i++) if (types[i].id != i) throw new RangeError("Node type ids should correspond to array positions when creating a node set");
    } /// Create a copy of this set with some node properties added. The
    /// arguments to this method can be created with
    /// [`NodeProp.add`](#common.NodeProp.add).


    extend(...props) {
      let newTypes = [];

      for (let type of this.types) {
        let newProps = null;

        for (let source of props) {
          let add = source(type);

          if (add) {
            if (!newProps) newProps = Object.assign({}, type.props);
            newProps[add[0].id] = add[1];
          }
        }

        newTypes.push(newProps ? new NodeType(type.name, newProps, type.id, type.flags) : type);
      }

      return new NodeSet(newTypes);
    }

  }

  const CachedNode = new WeakMap(),
        CachedInnerNode = new WeakMap(); /// Options that control iteration. Can be combined with the `|`
  /// operator to enable multiple ones.

  var IterMode;

  (function (IterMode) {
    /// When enabled, iteration will only visit [`Tree`](#common.Tree)
    /// objects, not nodes packed into
    /// [`TreeBuffer`](#common.TreeBuffer)s.
    IterMode[IterMode["ExcludeBuffers"] = 1] = "ExcludeBuffers"; /// Enable this to make iteration include anonymous nodes (such as
    /// the nodes that wrap repeated grammar constructs into a balanced
    /// tree).

    IterMode[IterMode["IncludeAnonymous"] = 2] = "IncludeAnonymous"; /// By default, regular [mounted](#common.NodeProp^mounted) nodes
    /// replace their base node in iteration. Enable this to ignore them
    /// instead.

    IterMode[IterMode["IgnoreMounts"] = 4] = "IgnoreMounts"; /// This option only applies in
    /// [`enter`](#common.SyntaxNode.enter)-style methods. It tells the
    /// library to not enter mounted overlays if one covers the given
    /// position.

    IterMode[IterMode["IgnoreOverlays"] = 8] = "IgnoreOverlays";
  })(IterMode || (IterMode = {})); /// A piece of syntax tree. There are two ways to approach these
  /// trees: the way they are actually stored in memory, and the
  /// convenient way.
  ///
  /// Syntax trees are stored as a tree of `Tree` and `TreeBuffer`
  /// objects. By packing detail information into `TreeBuffer` leaf
  /// nodes, the representation is made a lot more memory-efficient.
  ///
  /// However, when you want to actually work with tree nodes, this
  /// representation is very awkward, so most client code will want to
  /// use the [`TreeCursor`](#common.TreeCursor) or
  /// [`SyntaxNode`](#common.SyntaxNode) interface instead, which provides
  /// a view on some part of this data structure, and can be used to
  /// move around to adjacent nodes.


  class Tree {
    /// Construct a new tree. See also [`Tree.build`](#common.Tree^build).
    constructor( /// The type of the top node.
    type, /// This node's child nodes.
    children, /// The positions (offsets relative to the start of this tree) of
    /// the children.
    positions, /// The total length of this tree
    length, /// Per-node [node props](#common.NodeProp) to associate with this node.
    props) {
      this.type = type;
      this.children = children;
      this.positions = positions;
      this.length = length; /// @internal

      this.props = null;

      if (props && props.length) {
        this.props = Object.create(null);

        for (let [prop, value] of props) this.props[typeof prop == "number" ? prop : prop.id] = value;
      }
    } /// @internal


    toString() {
      let mounted = this.prop(NodeProp.mounted);
      if (mounted && !mounted.overlay) return mounted.tree.toString();
      let children = "";

      for (let ch of this.children) {
        let str = ch.toString();

        if (str) {
          if (children) children += ",";
          children += str;
        }
      }

      return !this.type.name ? children : (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (children.length ? "(" + children + ")" : "");
    } /// Get a [tree cursor](#common.TreeCursor) positioned at the top of
    /// the tree. Mode can be used to [control](#common.IterMode) which
    /// nodes the cursor visits.


    cursor(mode = 0) {
      return new TreeCursor(this.topNode, mode);
    } /// Get a [tree cursor](#common.TreeCursor) pointing into this tree
    /// at the given position and side (see
    /// [`moveTo`](#common.TreeCursor.moveTo).


    cursorAt(pos, side = 0, mode = 0) {
      let scope = CachedNode.get(this) || this.topNode;
      let cursor = new TreeCursor(scope);
      cursor.moveTo(pos, side);
      CachedNode.set(this, cursor._tree);
      return cursor;
    } /// Get a [syntax node](#common.SyntaxNode) object for the top of the
    /// tree.


    get topNode() {
      return new TreeNode(this, 0, 0, null);
    } /// Get the [syntax node](#common.SyntaxNode) at the given position.
    /// If `side` is -1, this will move into nodes that end at the
    /// position. If 1, it'll move into nodes that start at the
    /// position. With 0, it'll only enter nodes that cover the position
    /// from both sides.
    ///
    /// Note that this will not enter
    /// [overlays](#common.MountedTree.overlay), and you often want
    /// [`resolveInner`](#common.Tree.resolveInner) instead.


    resolve(pos, side = 0) {
      let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);
      CachedNode.set(this, node);
      return node;
    } /// Like [`resolve`](#common.Tree.resolve), but will enter
    /// [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
    /// pointing into the innermost overlaid tree at the given position
    /// (with parent links going through all parent structure, including
    /// the host trees).


    resolveInner(pos, side = 0) {
      let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, true);
      CachedInnerNode.set(this, node);
      return node;
    } /// Iterate over the tree and its children, calling `enter` for any
    /// node that touches the `from`/`to` region (if given) before
    /// running over such a node's children, and `leave` (if given) when
    /// leaving the node. When `enter` returns `false`, that node will
    /// not have its children iterated over (or `leave` called).


    iterate(spec) {
      let {
        enter,
        leave,
        from = 0,
        to = this.length
      } = spec;

      for (let c = this.cursor((spec.mode || 0) | IterMode.IncludeAnonymous);;) {
        let entered = false;

        if (c.from <= to && c.to >= from && (c.type.isAnonymous || enter(c) !== false)) {
          if (c.firstChild()) continue;
          entered = true;
        }

        for (;;) {
          if (entered && leave && !c.type.isAnonymous) leave(c);
          if (c.nextSibling()) break;
          if (!c.parent()) return;
          entered = true;
        }
      }
    } /// Get the value of the given [node prop](#common.NodeProp) for this
    /// node. Works with both per-node and per-type props.


    prop(prop) {
      return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : undefined;
    } /// Returns the node's [per-node props](#common.NodeProp.perNode) in a
    /// format that can be passed to the [`Tree`](#common.Tree)
    /// constructor.


    get propValues() {
      let result = [];
      if (this.props) for (let id in this.props) result.push([+id, this.props[id]]);
      return result;
    } /// Balance the direct children of this tree, producing a copy of
    /// which may have children grouped into subtrees with type
    /// [`NodeType.none`](#common.NodeType^none).


    balance(config = {}) {
      return this.children.length <= 8
      /* BranchFactor */
      ? this : balanceRange(NodeType.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new Tree(NodeType.none, children, positions, length)));
    } /// Build a tree from a postfix-ordered buffer of node information,
    /// or a cursor over such a buffer.


    static build(data) {
      return buildTree(data);
    }

  } /// The empty tree


  Tree.empty = new Tree(NodeType.none, [], [], 0);

  class FlatBufferCursor {
    constructor(buffer, index) {
      this.buffer = buffer;
      this.index = index;
    }

    get id() {
      return this.buffer[this.index - 4];
    }

    get start() {
      return this.buffer[this.index - 3];
    }

    get end() {
      return this.buffer[this.index - 2];
    }

    get size() {
      return this.buffer[this.index - 1];
    }

    get pos() {
      return this.index;
    }

    next() {
      this.index -= 4;
    }

    fork() {
      return new FlatBufferCursor(this.buffer, this.index);
    }

  } /// Tree buffers contain (type, start, end, endIndex) quads for each
  /// node. In such a buffer, nodes are stored in prefix order (parents
  /// before children, with the endIndex of the parent indicating which
  /// children belong to it).


  class TreeBuffer {
    /// Create a tree buffer.
    constructor( /// The buffer's content.
    buffer, /// The total length of the group of nodes in the buffer.
    length, /// The node set used in this buffer.
    set) {
      this.buffer = buffer;
      this.length = length;
      this.set = set;
    } /// @internal


    get type() {
      return NodeType.none;
    } /// @internal


    toString() {
      let result = [];

      for (let index = 0; index < this.buffer.length;) {
        result.push(this.childString(index));
        index = this.buffer[index + 3];
      }

      return result.join(",");
    } /// @internal


    childString(index) {
      let id = this.buffer[index],
          endIndex = this.buffer[index + 3];
      let type = this.set.types[id],
          result = type.name;
      if (/\W/.test(result) && !type.isError) result = JSON.stringify(result);
      index += 4;
      if (endIndex == index) return result;
      let children = [];

      while (index < endIndex) {
        children.push(this.childString(index));
        index = this.buffer[index + 3];
      }

      return result + "(" + children.join(",") + ")";
    } /// @internal


    findChild(startIndex, endIndex, dir, pos, side) {
      let {
        buffer
      } = this,
          pick = -1;

      for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {
        if (checkSide(side, pos, buffer[i + 1], buffer[i + 2])) {
          pick = i;
          if (dir > 0) break;
        }
      }

      return pick;
    } /// @internal


    slice(startI, endI, from, to) {
      let b = this.buffer;
      let copy = new Uint16Array(endI - startI);

      for (let i = startI, j = 0; i < endI;) {
        copy[j++] = b[i++];
        copy[j++] = b[i++] - from;
        copy[j++] = b[i++] - from;
        copy[j++] = b[i++] - startI;
      }

      return new TreeBuffer(copy, to - from, this.set);
    }

  }

  function checkSide(side, pos, from, to) {
    switch (side) {
      case -2
      /* Before */
      :
        return from < pos;

      case -1
      /* AtOrBefore */
      :
        return to >= pos && from < pos;

      case 0
      /* Around */
      :
        return from < pos && to > pos;

      case 1
      /* AtOrAfter */
      :
        return from <= pos && to > pos;

      case 2
      /* After */
      :
        return to > pos;

      case 4
      /* DontCare */
      :
        return true;
    }
  }

  function enterUnfinishedNodesBefore(node, pos) {
    let scan = node.childBefore(pos);

    while (scan) {
      let last = scan.lastChild;
      if (!last || last.to != scan.to) break;

      if (last.type.isError && last.from == last.to) {
        node = scan;
        scan = last.prevSibling;
      } else {
        scan = last;
      }
    }

    return node;
  }

  function resolveNode(node, pos, side, overlays) {
    var _a; // Move up to a node that actually holds the position, if possible


    while (node.from == node.to || (side < 1 ? node.from >= pos : node.from > pos) || (side > -1 ? node.to <= pos : node.to < pos)) {
      let parent = !overlays && node instanceof TreeNode && node.index < 0 ? null : node.parent;
      if (!parent) return node;
      node = parent;
    }

    let mode = overlays ? 0 : IterMode.IgnoreOverlays; // Must go up out of overlays when those do not overlap with pos

    if (overlays) for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {
      if (scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from) node = parent;
    }

    for (;;) {
      let inner = node.enter(pos, side, mode);
      if (!inner) return node;
      node = inner;
    }
  }

  class TreeNode {
    constructor(_tree, from, // Index in parent node, set to -1 if the node is not a direct child of _parent.node (overlay)
    index, _parent) {
      this._tree = _tree;
      this.from = from;
      this.index = index;
      this._parent = _parent;
    }

    get type() {
      return this._tree.type;
    }

    get name() {
      return this._tree.type.name;
    }

    get to() {
      return this.from + this._tree.length;
    }

    nextChild(i, dir, pos, side, mode = 0) {
      for (let parent = this;;) {
        for (let {
          children,
          positions
        } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {
          let next = children[i],
              start = positions[i] + parent.from;
          if (!checkSide(side, pos, start, start + next.length)) continue;

          if (next instanceof TreeBuffer) {
            if (mode & IterMode.ExcludeBuffers) continue;
            let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
            if (index > -1) return new BufferNode(new BufferContext(parent, next, i, start), null, index);
          } else if (mode & IterMode.IncludeAnonymous || !next.type.isAnonymous || hasChild(next)) {
            let mounted;
            if (!(mode & IterMode.IgnoreMounts) && next.props && (mounted = next.prop(NodeProp.mounted)) && !mounted.overlay) return new TreeNode(mounted.tree, start, i, parent);
            let inner = new TreeNode(next, start, i, parent);
            return mode & IterMode.IncludeAnonymous || !inner.type.isAnonymous ? inner : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);
          }
        }

        if (mode & IterMode.IncludeAnonymous || !parent.type.isAnonymous) return null;
        if (parent.index >= 0) i = parent.index + dir;else i = dir < 0 ? -1 : parent._parent._tree.children.length;
        parent = parent._parent;
        if (!parent) return null;
      }
    }

    get firstChild() {
      return this.nextChild(0, 1, 0, 4
      /* DontCare */
      );
    }

    get lastChild() {
      return this.nextChild(this._tree.children.length - 1, -1, 0, 4
      /* DontCare */
      );
    }

    childAfter(pos) {
      return this.nextChild(0, 1, pos, 2
      /* After */
      );
    }

    childBefore(pos) {
      return this.nextChild(this._tree.children.length - 1, -1, pos, -2
      /* Before */
      );
    }

    enter(pos, side, mode = 0) {
      let mounted;

      if (!(mode & IterMode.IgnoreOverlays) && (mounted = this._tree.prop(NodeProp.mounted)) && mounted.overlay) {
        let rPos = pos - this.from;

        for (let {
          from,
          to
        } of mounted.overlay) {
          if ((side > 0 ? from <= rPos : from < rPos) && (side < 0 ? to >= rPos : to > rPos)) return new TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
        }
      }

      return this.nextChild(0, 1, pos, side, mode);
    }

    nextSignificantParent() {
      let val = this;

      while (val.type.isAnonymous && val._parent) val = val._parent;

      return val;
    }

    get parent() {
      return this._parent ? this._parent.nextSignificantParent() : null;
    }

    get nextSibling() {
      return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4
      /* DontCare */
      ) : null;
    }

    get prevSibling() {
      return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4
      /* DontCare */
      ) : null;
    }

    cursor(mode = 0) {
      return new TreeCursor(this, mode);
    }

    get tree() {
      return this._tree;
    }

    toTree() {
      return this._tree;
    }

    resolve(pos, side = 0) {
      return resolveNode(this, pos, side, false);
    }

    resolveInner(pos, side = 0) {
      return resolveNode(this, pos, side, true);
    }

    enterUnfinishedNodesBefore(pos) {
      return enterUnfinishedNodesBefore(this, pos);
    }

    getChild(type, before = null, after = null) {
      let r = getChildren(this, type, before, after);
      return r.length ? r[0] : null;
    }

    getChildren(type, before = null, after = null) {
      return getChildren(this, type, before, after);
    } /// @internal


    toString() {
      return this._tree.toString();
    }

    get node() {
      return this;
    }

    matchContext(context) {
      return matchNodeContext(this, context);
    }

  }

  function getChildren(node, type, before, after) {
    let cur = node.cursor(),
        result = [];
    if (!cur.firstChild()) return result;
    if (before != null) while (!cur.type.is(before)) if (!cur.nextSibling()) return result;

    for (;;) {
      if (after != null && cur.type.is(after)) return result;
      if (cur.type.is(type)) result.push(cur.node);
      if (!cur.nextSibling()) return after == null ? result : [];
    }
  }

  function matchNodeContext(node, context, i = context.length - 1) {
    for (let p = node.parent; i >= 0; p = p.parent) {
      if (!p) return false;

      if (!p.type.isAnonymous) {
        if (context[i] && context[i] != p.name) return false;
        i--;
      }
    }

    return true;
  }

  class BufferContext {
    constructor(parent, buffer, index, start) {
      this.parent = parent;
      this.buffer = buffer;
      this.index = index;
      this.start = start;
    }

  }

  class BufferNode {
    constructor(context, _parent, index) {
      this.context = context;
      this._parent = _parent;
      this.index = index;
      this.type = context.buffer.set.types[context.buffer.buffer[index]];
    }

    get name() {
      return this.type.name;
    }

    get from() {
      return this.context.start + this.context.buffer.buffer[this.index + 1];
    }

    get to() {
      return this.context.start + this.context.buffer.buffer[this.index + 2];
    }

    child(dir, pos, side) {
      let {
        buffer
      } = this.context;
      let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
      return index < 0 ? null : new BufferNode(this.context, this, index);
    }

    get firstChild() {
      return this.child(1, 0, 4
      /* DontCare */
      );
    }

    get lastChild() {
      return this.child(-1, 0, 4
      /* DontCare */
      );
    }

    childAfter(pos) {
      return this.child(1, pos, 2
      /* After */
      );
    }

    childBefore(pos) {
      return this.child(-1, pos, -2
      /* Before */
      );
    }

    enter(pos, side, mode = 0) {
      if (mode & IterMode.ExcludeBuffers) return null;
      let {
        buffer
      } = this.context;
      let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
      return index < 0 ? null : new BufferNode(this.context, this, index);
    }

    get parent() {
      return this._parent || this.context.parent.nextSignificantParent();
    }

    externalSibling(dir) {
      return this._parent ? null : this.context.parent.nextChild(this.context.index + dir, dir, 0, 4
      /* DontCare */
      );
    }

    get nextSibling() {
      let {
        buffer
      } = this.context;
      let after = buffer.buffer[this.index + 3];
      if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length)) return new BufferNode(this.context, this._parent, after);
      return this.externalSibling(1);
    }

    get prevSibling() {
      let {
        buffer
      } = this.context;
      let parentStart = this._parent ? this._parent.index + 4 : 0;
      if (this.index == parentStart) return this.externalSibling(-1);
      return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4
      /* DontCare */
      ));
    }

    cursor(mode = 0) {
      return new TreeCursor(this, mode);
    }

    get tree() {
      return null;
    }

    toTree() {
      let children = [],
          positions = [];
      let {
        buffer
      } = this.context;
      let startI = this.index + 4,
          endI = buffer.buffer[this.index + 3];

      if (endI > startI) {
        let from = buffer.buffer[this.index + 1],
            to = buffer.buffer[this.index + 2];
        children.push(buffer.slice(startI, endI, from, to));
        positions.push(0);
      }

      return new Tree(this.type, children, positions, this.to - this.from);
    }

    resolve(pos, side = 0) {
      return resolveNode(this, pos, side, false);
    }

    resolveInner(pos, side = 0) {
      return resolveNode(this, pos, side, true);
    }

    enterUnfinishedNodesBefore(pos) {
      return enterUnfinishedNodesBefore(this, pos);
    } /// @internal


    toString() {
      return this.context.buffer.childString(this.index);
    }

    getChild(type, before = null, after = null) {
      let r = getChildren(this, type, before, after);
      return r.length ? r[0] : null;
    }

    getChildren(type, before = null, after = null) {
      return getChildren(this, type, before, after);
    }

    get node() {
      return this;
    }

    matchContext(context) {
      return matchNodeContext(this, context);
    }

  } /// A tree cursor object focuses on a given node in a syntax tree, and
  /// allows you to move to adjacent nodes.


  class TreeCursor {
    /// @internal
    constructor(node, /// @internal
    mode = 0) {
      this.mode = mode; /// @internal

      this.buffer = null;
      this.stack = []; /// @internal

      this.index = 0;
      this.bufferNode = null;

      if (node instanceof TreeNode) {
        this.yieldNode(node);
      } else {
        this._tree = node.context.parent;
        this.buffer = node.context;

        for (let n = node._parent; n; n = n._parent) this.stack.unshift(n.index);

        this.bufferNode = node;
        this.yieldBuf(node.index);
      }
    } /// Shorthand for `.type.name`.


    get name() {
      return this.type.name;
    }

    yieldNode(node) {
      if (!node) return false;
      this._tree = node;
      this.type = node.type;
      this.from = node.from;
      this.to = node.to;
      return true;
    }

    yieldBuf(index, type) {
      this.index = index;
      let {
        start,
        buffer
      } = this.buffer;
      this.type = type || buffer.set.types[buffer.buffer[index]];
      this.from = start + buffer.buffer[index + 1];
      this.to = start + buffer.buffer[index + 2];
      return true;
    }

    yield(node) {
      if (!node) return false;

      if (node instanceof TreeNode) {
        this.buffer = null;
        return this.yieldNode(node);
      }

      this.buffer = node.context;
      return this.yieldBuf(node.index, node.type);
    } /// @internal


    toString() {
      return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
    } /// @internal


    enterChild(dir, pos, side) {
      if (!this.buffer) return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));
      let {
        buffer
      } = this.buffer;
      let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
      if (index < 0) return false;
      this.stack.push(this.index);
      return this.yieldBuf(index);
    } /// Move the cursor to this node's first child. When this returns
    /// false, the node has no child, and the cursor has not been moved.


    firstChild() {
      return this.enterChild(1, 0, 4
      /* DontCare */
      );
    } /// Move the cursor to this node's last child.


    lastChild() {
      return this.enterChild(-1, 0, 4
      /* DontCare */
      );
    } /// Move the cursor to the first child that ends after `pos`.


    childAfter(pos) {
      return this.enterChild(1, pos, 2
      /* After */
      );
    } /// Move to the last child that starts before `pos`.


    childBefore(pos) {
      return this.enterChild(-1, pos, -2
      /* Before */
      );
    } /// Move the cursor to the child around `pos`. If side is -1 the
    /// child may end at that position, when 1 it may start there. This
    /// will also enter [overlaid](#common.MountedTree.overlay)
    /// [mounted](#common.NodeProp^mounted) trees unless `overlays` is
    /// set to false.


    enter(pos, side, mode = this.mode) {
      if (!this.buffer) return this.yield(this._tree.enter(pos, side, mode));
      return mode & IterMode.ExcludeBuffers ? false : this.enterChild(1, pos, side);
    } /// Move to the node's parent node, if this isn't the top node.


    parent() {
      if (!this.buffer) return this.yieldNode(this.mode & IterMode.IncludeAnonymous ? this._tree._parent : this._tree.parent);
      if (this.stack.length) return this.yieldBuf(this.stack.pop());
      let parent = this.mode & IterMode.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
      this.buffer = null;
      return this.yieldNode(parent);
    } /// @internal


    sibling(dir) {
      if (!this.buffer) return !this._tree._parent ? false : this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4
      /* DontCare */
      , this.mode));
      let {
        buffer
      } = this.buffer,
          d = this.stack.length - 1;

      if (dir < 0) {
        let parentStart = d < 0 ? 0 : this.stack[d] + 4;
        if (this.index != parentStart) return this.yieldBuf(buffer.findChild(parentStart, this.index, -1, 0, 4
        /* DontCare */
        ));
      } else {
        let after = buffer.buffer[this.index + 3];
        if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3])) return this.yieldBuf(after);
      }

      return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4
      /* DontCare */
      , this.mode)) : false;
    } /// Move to this node's next sibling, if any.


    nextSibling() {
      return this.sibling(1);
    } /// Move to this node's previous sibling, if any.


    prevSibling() {
      return this.sibling(-1);
    }

    atLastNode(dir) {
      let index,
          parent,
          {
        buffer
      } = this;

      if (buffer) {
        if (dir > 0) {
          if (this.index < buffer.buffer.buffer.length) return false;
        } else {
          for (let i = 0; i < this.index; i++) if (buffer.buffer.buffer[i + 3] < this.index) return false;
        }

        ({
          index,
          parent
        } = buffer);
      } else {
        ({
          index,
          _parent: parent
        } = this._tree);
      }

      for (; parent; ({
        index,
        _parent: parent
      } = parent)) {
        if (index > -1) for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {
          let child = parent._tree.children[i];
          if (this.mode & IterMode.IncludeAnonymous || child instanceof TreeBuffer || !child.type.isAnonymous || hasChild(child)) return false;
        }
      }

      return true;
    }

    move(dir, enter) {
      if (enter && this.enterChild(dir, 0, 4
      /* DontCare */
      )) return true;

      for (;;) {
        if (this.sibling(dir)) return true;
        if (this.atLastNode(dir) || !this.parent()) return false;
      }
    } /// Move to the next node in a
    /// [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order_(NLR))
    /// traversal, going from a node to its first child or, if the
    /// current node is empty or `enter` is false, its next sibling or
    /// the next sibling of the first parent node that has one.


    next(enter = true) {
      return this.move(1, enter);
    } /// Move to the next node in a last-to-first pre-order traveral. A
    /// node is followed by its last child or, if it has none, its
    /// previous sibling or the previous sibling of the first parent
    /// node that has one.


    prev(enter = true) {
      return this.move(-1, enter);
    } /// Move the cursor to the innermost node that covers `pos`. If
    /// `side` is -1, it will enter nodes that end at `pos`. If it is 1,
    /// it will enter nodes that start at `pos`.


    moveTo(pos, side = 0) {
      // Move up to a node that actually holds the position, if possible
      while (this.from == this.to || (side < 1 ? this.from >= pos : this.from > pos) || (side > -1 ? this.to <= pos : this.to < pos)) if (!this.parent()) break; // Then scan down into child nodes as far as possible


      while (this.enterChild(1, pos, side)) {}

      return this;
    } /// Get a [syntax node](#common.SyntaxNode) at the cursor's current
    /// position.


    get node() {
      if (!this.buffer) return this._tree;
      let cache = this.bufferNode,
          result = null,
          depth = 0;

      if (cache && cache.context == this.buffer) {
        scan: for (let index = this.index, d = this.stack.length; d >= 0;) {
          for (let c = cache; c; c = c._parent) if (c.index == index) {
            if (index == this.index) return c;
            result = c;
            depth = d + 1;
            break scan;
          }

          index = this.stack[--d];
        }
      }

      for (let i = depth; i < this.stack.length; i++) result = new BufferNode(this.buffer, result, this.stack[i]);

      return this.bufferNode = new BufferNode(this.buffer, result, this.index);
    } /// Get the [tree](#common.Tree) that represents the current node, if
    /// any. Will return null when the node is in a [tree
    /// buffer](#common.TreeBuffer).


    get tree() {
      return this.buffer ? null : this._tree._tree;
    } /// Iterate over the current node and all its descendants, calling
    /// `enter` when entering a node and `leave`, if given, when leaving
    /// one. When `enter` returns `false`, any children of that node are
    /// skipped, and `leave` isn't called for it.


    iterate(enter, leave) {
      for (let depth = 0;;) {
        let mustLeave = false;

        if (this.type.isAnonymous || enter(this) !== false) {
          if (this.firstChild()) {
            depth++;
            continue;
          }

          if (!this.type.isAnonymous) mustLeave = true;
        }

        for (;;) {
          if (mustLeave && leave) leave(this);
          mustLeave = this.type.isAnonymous;
          if (this.nextSibling()) break;
          if (!depth) return;
          this.parent();
          depth--;
          mustLeave = true;
        }
      }
    } /// Test whether the current node matches a given context—a sequence
    /// of direct parent node names. Empty strings in the context array
    /// are treated as wildcards.


    matchContext(context) {
      if (!this.buffer) return matchNodeContext(this.node, context);
      let {
        buffer
      } = this.buffer,
          {
        types
      } = buffer.set;

      for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {
        if (d < 0) return matchNodeContext(this.node, context, i);
        let type = types[buffer.buffer[this.stack[d]]];

        if (!type.isAnonymous) {
          if (context[i] && context[i] != type.name) return false;
          i--;
        }
      }

      return true;
    }

  }

  function hasChild(tree) {
    return tree.children.some(ch => ch instanceof TreeBuffer || !ch.type.isAnonymous || hasChild(ch));
  }

  function buildTree(data) {
    var _a;

    let {
      buffer,
      nodeSet,
      maxBufferLength = DefaultBufferLength,
      reused = [],
      minRepeatType = nodeSet.types.length
    } = data;
    let cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer;
    let types = nodeSet.types;
    let contextHash = 0,
        lookAhead = 0;

    function takeNode(parentStart, minPos, children, positions, inRepeat) {
      let {
        id,
        start,
        end,
        size
      } = cursor;
      let lookAheadAtStart = lookAhead;

      while (size < 0) {
        cursor.next();

        if (size == -1
        /* Reuse */
        ) {
          let node = reused[id];
          children.push(node);
          positions.push(start - parentStart);
          return;
        } else if (size == -3
        /* ContextChange */
        ) {
          // Context change
          contextHash = id;
          return;
        } else if (size == -4
        /* LookAhead */
        ) {
          lookAhead = id;
          return;
        } else {
          throw new RangeError(`Unrecognized record size: ${size}`);
        }
      }

      let type = types[id],
          node,
          buffer;
      let startPos = start - parentStart;

      if (end - start <= maxBufferLength && (buffer = findBufferSize(cursor.pos - minPos, inRepeat))) {
        // Small enough for a buffer, and no reused nodes inside
        let data = new Uint16Array(buffer.size - buffer.skip);
        let endPos = cursor.pos - buffer.size,
            index = data.length;

        while (cursor.pos > endPos) index = copyToBuffer(buffer.start, data, index);

        node = new TreeBuffer(data, end - buffer.start, nodeSet);
        startPos = buffer.start - parentStart;
      } else {
        // Make it a node
        let endPos = cursor.pos - size;
        cursor.next();
        let localChildren = [],
            localPositions = [];
        let localInRepeat = id >= minRepeatType ? id : -1;
        let lastGroup = 0,
            lastEnd = end;

        while (cursor.pos > endPos) {
          if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
            if (cursor.end <= lastEnd - maxBufferLength) {
              makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart);
              lastGroup = localChildren.length;
              lastEnd = cursor.end;
            }

            cursor.next();
          } else {
            takeNode(start, endPos, localChildren, localPositions, localInRepeat);
          }
        }

        if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length) makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart);
        localChildren.reverse();
        localPositions.reverse();

        if (localInRepeat > -1 && lastGroup > 0) {
          let make = makeBalanced(type);
          node = balanceRange(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);
        } else {
          node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end);
        }
      }

      children.push(node);
      positions.push(startPos);
    }

    function makeBalanced(type) {
      return (children, positions, length) => {
        let lookAhead = 0,
            lastI = children.length - 1,
            last,
            lookAheadProp;

        if (lastI >= 0 && (last = children[lastI]) instanceof Tree) {
          if (!lastI && last.type == type && last.length == length) return last;
          if (lookAheadProp = last.prop(NodeProp.lookAhead)) lookAhead = positions[lastI] + last.length + lookAheadProp;
        }

        return makeTree(type, children, positions, length, lookAhead);
      };
    }

    function makeRepeatLeaf(children, positions, base, i, from, to, type, lookAhead) {
      let localChildren = [],
          localPositions = [];

      while (children.length > i) {
        localChildren.push(children.pop());
        localPositions.push(positions.pop() + base - from);
      }

      children.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead - to));
      positions.push(from - base);
    }

    function makeTree(type, children, positions, length, lookAhead = 0, props) {
      if (contextHash) {
        let pair = [NodeProp.contextHash, contextHash];
        props = props ? [pair].concat(props) : [pair];
      }

      if (lookAhead > 25) {
        let pair = [NodeProp.lookAhead, lookAhead];
        props = props ? [pair].concat(props) : [pair];
      }

      return new Tree(type, children, positions, length, props);
    }

    function findBufferSize(maxSize, inRepeat) {
      // Scan through the buffer to find previous siblings that fit
      // together in a TreeBuffer, and don't contain any reused nodes
      // (which can't be stored in a buffer).
      // If `inRepeat` is > -1, ignore node boundaries of that type for
      // nesting, but make sure the end falls either at the start
      // (`maxSize`) or before such a node.
      let fork = cursor.fork();
      let size = 0,
          start = 0,
          skip = 0,
          minStart = fork.end - maxBufferLength;
      let result = {
        size: 0,
        start: 0,
        skip: 0
      };

      scan: for (let minPos = fork.pos - maxSize; fork.pos > minPos;) {
        let nodeSize = fork.size; // Pretend nested repeat nodes of the same type don't exist

        if (fork.id == inRepeat && nodeSize >= 0) {
          // Except that we store the current state as a valid return
          // value.
          result.size = size;
          result.start = start;
          result.skip = skip;
          skip += 4;
          size += 4;
          fork.next();
          continue;
        }

        let startPos = fork.pos - nodeSize;
        if (nodeSize < 0 || startPos < minPos || fork.start < minStart) break;
        let localSkipped = fork.id >= minRepeatType ? 4 : 0;
        let nodeStart = fork.start;
        fork.next();

        while (fork.pos > startPos) {
          if (fork.size < 0) {
            if (fork.size == -3
            /* ContextChange */
            ) localSkipped += 4;else break scan;
          } else if (fork.id >= minRepeatType) {
            localSkipped += 4;
          }

          fork.next();
        }

        start = nodeStart;
        size += nodeSize;
        skip += localSkipped;
      }

      if (inRepeat < 0 || size == maxSize) {
        result.size = size;
        result.start = start;
        result.skip = skip;
      }

      return result.size > 4 ? result : undefined;
    }

    function copyToBuffer(bufferStart, buffer, index) {
      let {
        id,
        start,
        end,
        size
      } = cursor;
      cursor.next();

      if (size >= 0 && id < minRepeatType) {
        let startIndex = index;

        if (size > 4) {
          let endPos = cursor.pos - (size - 4);

          while (cursor.pos > endPos) index = copyToBuffer(bufferStart, buffer, index);
        }

        buffer[--index] = startIndex;
        buffer[--index] = end - bufferStart;
        buffer[--index] = start - bufferStart;
        buffer[--index] = id;
      } else if (size == -3
      /* ContextChange */
      ) {
        contextHash = id;
      } else if (size == -4
      /* LookAhead */
      ) {
        lookAhead = id;
      }

      return index;
    }

    let children = [],
        positions = [];

    while (cursor.pos > 0) takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1);

    let length = (_a = data.length) !== null && _a !== void 0 ? _a : children.length ? positions[0] + children[0].length : 0;
    return new Tree(types[data.topID], children.reverse(), positions.reverse(), length);
  }

  const nodeSizeCache = new WeakMap();

  function nodeSize(balanceType, node) {
    if (!balanceType.isAnonymous || node instanceof TreeBuffer || node.type != balanceType) return 1;
    let size = nodeSizeCache.get(node);

    if (size == null) {
      size = 1;

      for (let child of node.children) {
        if (child.type != balanceType || !(child instanceof Tree)) {
          size = 1;
          break;
        }

        size += nodeSize(balanceType, child);
      }

      nodeSizeCache.set(node, size);
    }

    return size;
  }

  function balanceRange( // The type the balanced tree's inner nodes.
  balanceType, // The direct children and their positions
  children, positions, // The index range in children/positions to use
  from, to, // The start position of the nodes, relative to their parent.
  start, // Length of the outer node
  length, // Function to build the top node of the balanced tree
  mkTop, // Function to build internal nodes for the balanced tree
  mkTree) {
    let total = 0;

    for (let i = from; i < to; i++) total += nodeSize(balanceType, children[i]);

    let maxChild = Math.ceil(total * 1.5 / 8
    /* BranchFactor */
    );
    let localChildren = [],
        localPositions = [];

    function divide(children, positions, from, to, offset) {
      for (let i = from; i < to;) {
        let groupFrom = i,
            groupStart = positions[i],
            groupSize = nodeSize(balanceType, children[i]);
        i++;

        for (; i < to; i++) {
          let nextSize = nodeSize(balanceType, children[i]);
          if (groupSize + nextSize >= maxChild) break;
          groupSize += nextSize;
        }

        if (i == groupFrom + 1) {
          if (groupSize > maxChild) {
            let only = children[groupFrom]; // Only trees can have a size > 1

            divide(only.children, only.positions, 0, only.children.length, positions[groupFrom] + offset);
            continue;
          }

          localChildren.push(children[groupFrom]);
        } else {
          let length = positions[i - 1] + children[i - 1].length - groupStart;
          localChildren.push(balanceRange(balanceType, children, positions, groupFrom, i, groupStart, length, null, mkTree));
        }

        localPositions.push(groupStart + offset - start);
      }
    }

    divide(children, positions, from, to, 0);
    return (mkTop || mkTree)(localChildren, localPositions, length);
  } /// Provides a way to associate values with pieces of trees. As long
  /// parsing](#common.Parser.startParse) to track parts of old trees
  /// that can be reused in a new parse. An array of fragments is used
  /// to track regions of an old tree whose nodes might be reused in new
  /// parses. Use the static
  /// [`applyChanges`](#common.TreeFragment^applyChanges) method to
  /// update fragments for document changes.


  class TreeFragment {
    /// Construct a tree fragment. You'll usually want to use
    /// [`addTree`](#common.TreeFragment^addTree) and
    /// [`applyChanges`](#common.TreeFragment^applyChanges) instead of
    /// calling this directly.
    constructor( /// The start of the unchanged range pointed to by this fragment.
    /// This refers to an offset in the _updated_ document (as opposed
    /// to the original tree).
    from, /// The end of the unchanged range.
    to, /// The tree that this fragment is based on.
    tree, /// The offset between the fragment's tree and the document that
    /// this fragment can be used against. Add this when going from
    /// document to tree positions, subtract it to go from tree to
    /// document positions.
    offset, openStart = false, openEnd = false) {
      this.from = from;
      this.to = to;
      this.tree = tree;
      this.offset = offset;
      this.open = (openStart ? 1
      /* Start */
      : 0) | (openEnd ? 2
      /* End */
      : 0);
    } /// Whether the start of the fragment represents the start of a
    /// parse, or the end of a change. (In the second case, it may not
    /// be safe to reuse some nodes at the start, depending on the
    /// parsing algorithm.)


    get openStart() {
      return (this.open & 1
      /* Start */
      ) > 0;
    } /// Whether the end of the fragment represents the end of a
    /// full-document parse, or the start of a change.


    get openEnd() {
      return (this.open & 2
      /* End */
      ) > 0;
    } /// Create a set of fragments from a freshly parsed tree, or update
    /// an existing set of fragments by replacing the ones that overlap
    /// with a tree with content from the new tree. When `partial` is
    /// true, the parse is treated as incomplete, and the resulting
    /// fragment has [`openEnd`](#common.TreeFragment.openEnd) set to
    /// true.


    static addTree(tree, fragments = [], partial = false) {
      let result = [new TreeFragment(0, tree.length, tree, 0, false, partial)];

      for (let f of fragments) if (f.to > tree.length) result.push(f);

      return result;
    } /// Apply a set of edits to an array of fragments, removing or
    /// splitting fragments as necessary to remove edited ranges, and
    /// adjusting offsets for fragments that moved.


    static applyChanges(fragments, changes, minGap = 128) {
      if (!changes.length) return fragments;
      let result = [];
      let fI = 1,
          nextF = fragments.length ? fragments[0] : null;

      for (let cI = 0, pos = 0, off = 0;; cI++) {
        let nextC = cI < changes.length ? changes[cI] : null;
        let nextPos = nextC ? nextC.fromA : 1e9;
        if (nextPos - pos >= minGap) while (nextF && nextF.from < nextPos) {
          let cut = nextF;

          if (pos >= cut.from || nextPos <= cut.to || off) {
            let fFrom = Math.max(cut.from, pos) - off,
                fTo = Math.min(cut.to, nextPos) - off;
            cut = fFrom >= fTo ? null : new TreeFragment(fFrom, fTo, cut.tree, cut.offset + off, cI > 0, !!nextC);
          }

          if (cut) result.push(cut);
          if (nextF.to > nextPos) break;
          nextF = fI < fragments.length ? fragments[fI++] : null;
        }
        if (!nextC) break;
        pos = nextC.toA;
        off = nextC.toA - nextC.toB;
      }

      return result;
    }

  } /// A superclass that parsers should extend.


  class Parser {
    /// Start a parse, returning a [partial parse](#common.PartialParse)
    /// object. [`fragments`](#common.TreeFragment) can be passed in to
    /// make the parse incremental.
    ///
    /// By default, the entire input is parsed. You can pass `ranges`,
    /// which should be a sorted array of non-empty, non-overlapping
    /// ranges, to parse only those ranges. The tree returned in that
    /// case will start at `ranges[0].from`.
    startParse(input, fragments, ranges) {
      if (typeof input == "string") input = new StringInput(input);
      ranges = !ranges ? [new Range(0, input.length)] : ranges.length ? ranges.map(r => new Range(r.from, r.to)) : [new Range(0, 0)];
      return this.createParse(input, fragments || [], ranges);
    } /// Run a full parse, returning the resulting tree.


    parse(input, fragments, ranges) {
      let parse = this.startParse(input, fragments, ranges);

      for (;;) {
        let done = parse.advance();
        if (done) return done;
      }
    }

  }

  class StringInput {
    constructor(string) {
      this.string = string;
    }

    get length() {
      return this.string.length;
    }

    chunk(from) {
      return this.string.slice(from);
    }

    get lineChunks() {
      return false;
    }

    read(from, to) {
      return this.string.slice(from, to);
    }

  } /// Create a parse wrapper that, after the inner parse completes,

  new NodeProp({
    perNode: true
  });

  let nextTagID = 0; /// Highlighting tags are markers that denote a highlighting category.
  /// They are [associated](#highlight.styleTags) with parts of a syntax
  /// tree by a language mode, and then mapped to an actual CSS style by
  /// a [highlighter](#highlight.Highlighter).
  ///
  /// Because syntax tree node types and highlight styles have to be
  /// able to talk the same language, CodeMirror uses a mostly _closed_
  /// [vocabulary](#highlight.tags) of syntax tags (as opposed to
  /// traditional open string-based systems, which make it hard for
  /// highlighting themes to cover all the tokens produced by the
  /// various languages).
  ///
  /// It _is_ possible to [define](#highlight.Tag^define) your own
  /// highlighting tags for system-internal use (where you control both
  /// the language package and the highlighter), but such tags will not
  /// be picked up by regular highlighters (though you can derive them
  /// from standard tags to allow highlighters to fall back to those).

  class Tag {
    /// @internal
    constructor( /// The set of this tag and all its parent tags, starting with
    /// this one itself and sorted in order of decreasing specificity.
    set, /// The base unmodified tag that this one is based on, if it's
    /// modified @internal
    base, /// The modifiers applied to this.base @internal
    modified) {
      this.set = set;
      this.base = base;
      this.modified = modified; /// @internal

      this.id = nextTagID++;
    } /// Define a new tag. If `parent` is given, the tag is treated as a
    /// sub-tag of that parent, and
    /// [highlighters](#highlight.tagHighlighter) that don't mention
    /// this tag will try to fall back to the parent tag (or grandparent
    /// tag, etc).


    static define(parent) {
      if (parent === null || parent === void 0 ? void 0 : parent.base) throw new Error("Can not derive from a modified tag");
      let tag = new Tag([], null, []);
      tag.set.push(tag);
      if (parent) for (let t of parent.set) tag.set.push(t);
      return tag;
    } /// Define a tag _modifier_, which is a function that, given a tag,
    /// will return a tag that is a subtag of the original. Applying the
    /// same modifier to a twice tag will return the same value (`m1(t1)
    /// == m1(t1)`) and applying multiple modifiers will, regardless or
    /// order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
    ///
    /// When multiple modifiers are applied to a given base tag, each
    /// smaller set of modifiers is registered as a parent, so that for
    /// example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
    /// `m1(m3(t1)`, and so on.


    static defineModifier() {
      let mod = new Modifier();
      return tag => {
        if (tag.modified.indexOf(mod) > -1) return tag;
        return Modifier.get(tag.base || tag, tag.modified.concat(mod).sort((a, b) => a.id - b.id));
      };
    }

  }

  let nextModifierID = 0;

  class Modifier {
    constructor() {
      this.instances = [];
      this.id = nextModifierID++;
    }

    static get(base, mods) {
      if (!mods.length) return base;
      let exists = mods[0].instances.find(t => t.base == base && sameArray(mods, t.modified));
      if (exists) return exists;
      let set = [],
          tag = new Tag(set, base, mods);

      for (let m of mods) m.instances.push(tag);

      let configs = permute(mods);

      for (let parent of base.set) for (let config of configs) set.push(Modifier.get(parent, config));

      return tag;
    }

  }

  function sameArray(a, b) {
    return a.length == b.length && a.every((x, i) => x == b[i]);
  }

  function permute(array) {
    let result = [array];

    for (let i = 0; i < array.length; i++) {
      for (let a of permute(array.slice(0, i).concat(array.slice(i + 1)))) result.push(a);
    }

    return result;
  } /// This function is used to add a set of tags to a language syntax
  /// via [`NodeSet.extend`](#common.NodeSet.extend) or
  /// [`LRParser.configure`](#lr.LRParser.configure).
  ///
  /// The argument object maps node selectors to [highlighting
  /// tags](#highlight.Tag) or arrays of tags.
  ///
  /// Node selectors may hold one or more (space-separated) node paths.
  /// Such a path can be a [node name](#common.NodeType.name), or
  /// multiple node names (or `*` wildcards) separated by slash
  /// characters, as in `"Block/Declaration/VariableName"`. Such a path
  /// matches the final node but only if its direct parent nodes are the
  /// other nodes mentioned. A `*` in such a path matches any parent,
  /// but only a single level—wildcards that match multiple parents
  /// aren't supported, both for efficiency reasons and because Lezer
  /// trees make it rather hard to reason about what they would match.)
  ///
  /// A path can be ended with `/...` to indicate that the tag assigned
  /// to the node should also apply to all child nodes, even if they
  /// match their own style (by default, only the innermost style is
  /// used).
  ///
  /// When a path ends in `!`, as in `Attribute!`, no further matching
  /// happens for the node's child nodes, and the entire node gets the
  /// given style.
  ///
  /// In this notation, node names that contain `/`, `!`, `*`, or `...`
  /// must be quoted as JSON strings.
  ///
  /// For example:
  ///
  /// ```javascript
  /// parser.withProps(
  ///   styleTags({
  ///     // Style Number and BigNumber nodes
  ///     "Number BigNumber": tags.number,
  ///     // Style Escape nodes whose parent is String
  ///     "String/Escape": tags.escape,
  ///     // Style anything inside Attributes nodes
  ///     "Attributes!": tags.meta,
  ///     // Add a style to all content inside Italic nodes
  ///     "Italic/...": tags.emphasis,
  ///     // Style InvalidString nodes as both `string` and `invalid`
  ///     "InvalidString": [tags.string, tags.invalid],
  ///     // Style the node named "/" as punctuation
  ///     '"/"': tags.punctuation
  ///   })
  /// )
  /// ```


  function styleTags(spec) {
    let byName = Object.create(null);

    for (let prop in spec) {
      let tags = spec[prop];
      if (!Array.isArray(tags)) tags = [tags];

      for (let part of prop.split(" ")) if (part) {
        let pieces = [],
            mode = 2
        /* Normal */
        ,
            rest = part;

        for (let pos = 0;;) {
          if (rest == "..." && pos > 0 && pos + 3 == part.length) {
            mode = 1
            /* Inherit */
            ;
            break;
          }

          let m = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(rest);
          if (!m) throw new RangeError("Invalid path: " + part);
          pieces.push(m[0] == "*" ? "" : m[0][0] == '"' ? JSON.parse(m[0]) : m[0]);
          pos += m[0].length;
          if (pos == part.length) break;
          let next = part[pos++];

          if (pos == part.length && next == "!") {
            mode = 0
            /* Opaque */
            ;
            break;
          }

          if (next != "/") throw new RangeError("Invalid path: " + part);
          rest = part.slice(pos);
        }

        let last = pieces.length - 1,
            inner = pieces[last];
        if (!inner) throw new RangeError("Invalid path: " + part);
        let rule = new Rule(tags, mode, last > 0 ? pieces.slice(0, last) : null);
        byName[inner] = rule.sort(byName[inner]);
      }
    }

    return ruleNodeProp.add(byName);
  }

  const ruleNodeProp = new NodeProp();

  class Rule {
    constructor(tags, mode, context, next) {
      this.tags = tags;
      this.mode = mode;
      this.context = context;
      this.next = next;
    }

    get opaque() {
      return this.mode == 0
      /* Opaque */
      ;
    }

    get inherit() {
      return this.mode == 1
      /* Inherit */
      ;
    }

    sort(other) {
      if (!other || other.depth < this.depth) {
        this.next = other;
        return this;
      }

      other.next = this.sort(other.next);
      return other;
    }

    get depth() {
      return this.context ? this.context.length : 0;
    }

  }

  Rule.empty = new Rule([], 2
  /* Normal */
  , null); /// Define a [highlighter](#highlight.Highlighter) from an array of
  /// tag/class pairs. Classes associated with more specific tags will
  /// take precedence.

  function tagHighlighter(tags, options) {
    let map = Object.create(null);

    for (let style of tags) {
      if (!Array.isArray(style.tag)) map[style.tag.id] = style.class;else for (let tag of style.tag) map[tag.id] = style.class;
    }

    let {
      scope,
      all = null
    } = options || {};
    return {
      style: tags => {
        let cls = all;

        for (let tag of tags) {
          for (let sub of tag.set) {
            let tagClass = map[sub.id];

            if (tagClass) {
              cls = cls ? cls + " " + tagClass : tagClass;
              break;
            }
          }
        }

        return cls;
      },
      scope
    };
  }

  function highlightTags(highlighters, tags) {
    let result = null;

    for (let highlighter of highlighters) {
      let value = highlighter.style(tags);
      if (value) result = result ? result + " " + value : value;
    }

    return result;
  } /// Highlight the given [tree](#common.Tree) with the given
  /// [highlighter](#highlight.Highlighter).


  function highlightTree(tree, highlighter, /// Assign styling to a region of the text. Will be called, in order
  /// of position, for any ranges where more than zero classes apply.
  /// `classes` is a space separated string of CSS classes.
  putStyle, /// The start of the range to highlight.
  from = 0, /// The end of the range.
  to = tree.length) {
    let builder = new HighlightBuilder(from, Array.isArray(highlighter) ? highlighter : [highlighter], putStyle);
    builder.highlightRange(tree.cursor(), from, to, "", builder.highlighters);
    builder.flush(to);
  }

  class HighlightBuilder {
    constructor(at, highlighters, span) {
      this.at = at;
      this.highlighters = highlighters;
      this.span = span;
      this.class = "";
    }

    startSpan(at, cls) {
      if (cls != this.class) {
        this.flush(at);
        if (at > this.at) this.at = at;
        this.class = cls;
      }
    }

    flush(to) {
      if (to > this.at && this.class) this.span(this.at, to, this.class);
    }

    highlightRange(cursor, from, to, inheritedClass, highlighters) {
      let {
        type,
        from: start,
        to: end
      } = cursor;
      if (start >= to || end <= from) return;
      if (type.isTop) highlighters = this.highlighters.filter(h => !h.scope || h.scope(type));
      let cls = inheritedClass;
      let rule = getStyleTags(cursor) || Rule.empty;
      let tagCls = highlightTags(highlighters, rule.tags);

      if (tagCls) {
        if (cls) cls += " ";
        cls += tagCls;
        if (rule.mode == 1
        /* Inherit */
        ) inheritedClass += (inheritedClass ? " " : "") + tagCls;
      }

      this.startSpan(cursor.from, cls);
      if (rule.opaque) return;
      let mounted = cursor.tree && cursor.tree.prop(NodeProp.mounted);

      if (mounted && mounted.overlay) {
        let inner = cursor.node.enter(mounted.overlay[0].from + start, 1);
        let innerHighlighters = this.highlighters.filter(h => !h.scope || h.scope(mounted.tree.type));
        let hasChild = cursor.firstChild();

        for (let i = 0, pos = start;; i++) {
          let next = i < mounted.overlay.length ? mounted.overlay[i] : null;
          let nextPos = next ? next.from + start : end;
          let rangeFrom = Math.max(from, pos),
              rangeTo = Math.min(to, nextPos);

          if (rangeFrom < rangeTo && hasChild) {
            while (cursor.from < rangeTo) {
              this.highlightRange(cursor, rangeFrom, rangeTo, inheritedClass, highlighters);
              this.startSpan(Math.min(to, cursor.to), cls);
              if (cursor.to >= nextPos || !cursor.nextSibling()) break;
            }
          }

          if (!next || nextPos > to) break;
          pos = next.to + start;

          if (pos > from) {
            this.highlightRange(inner.cursor(), Math.max(from, next.from + start), Math.min(to, pos), inheritedClass, innerHighlighters);
            this.startSpan(pos, cls);
          }
        }

        if (hasChild) cursor.parent();
      } else if (cursor.firstChild()) {
        do {
          if (cursor.to <= from) continue;
          if (cursor.from >= to) break;
          this.highlightRange(cursor, from, to, inheritedClass, highlighters);
          this.startSpan(Math.min(to, cursor.to), cls);
        } while (cursor.nextSibling());

        cursor.parent();
      }
    }

  } /// Match a syntax node's [highlight rules](#highlight.styleTags). If
  /// there's a match, return its set of tags, and whether it is
  /// opaque (uses a `!`) or applies to all child nodes (`/...`).


  function getStyleTags(node) {
    let rule = node.type.prop(ruleNodeProp);

    while (rule && rule.context && !node.matchContext(rule.context)) rule = rule.next;

    return rule || null;
  }

  const t = Tag.define;
  const comment = t(),
        name$1 = t(),
        typeName = t(name$1),
        propertyName = t(name$1),
        literal = t(),
        string = t(literal),
        number = t(literal),
        content = t(),
        heading = t(content),
        keyword = t(),
        operator = t(),
        punctuation = t(),
        bracket = t(punctuation),
        meta = t(); /// The default set of highlighting [tags](#highlight.Tag).
  ///
  /// This collection is heavily biased towards programming languages,
  /// and necessarily incomplete. A full ontology of syntactic
  /// constructs would fill a stack of books, and be impractical to
  /// write themes for. So try to make do with this set. If all else
  /// fails, [open an
  /// issue](https://github.com/codemirror/codemirror.next) to propose a
  /// new tag, or [define](#highlight.Tag^define) a local custom tag for
  /// your use case.
  ///
  /// Note that it is not obligatory to always attach the most specific
  /// tag possible to an element—if your grammar can't easily
  /// distinguish a certain type of element (such as a local variable),
  /// it is okay to style it as its more general variant (a variable).
  /// 
  /// For tags that extend some parent tag, the documentation links to
  /// the parent.

  const tags$1 = {
    /// A comment.
    comment,
    /// A line [comment](#highlight.tags.comment).
    lineComment: t(comment),
    /// A block [comment](#highlight.tags.comment).
    blockComment: t(comment),
    /// A documentation [comment](#highlight.tags.comment).
    docComment: t(comment),
    /// Any kind of identifier.
    name: name$1,
    /// The [name](#highlight.tags.name) of a variable.
    variableName: t(name$1),
    /// A type [name](#highlight.tags.name).
    typeName: typeName,
    /// A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
    tagName: t(typeName),
    /// A property or field [name](#highlight.tags.name).
    propertyName: propertyName,
    /// An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
    attributeName: t(propertyName),
    /// The [name](#highlight.tags.name) of a class.
    className: t(name$1),
    /// A label [name](#highlight.tags.name).
    labelName: t(name$1),
    /// A namespace [name](#highlight.tags.name).
    namespace: t(name$1),
    /// The [name](#highlight.tags.name) of a macro.
    macroName: t(name$1),
    /// A literal value.
    literal,
    /// A string [literal](#highlight.tags.literal).
    string,
    /// A documentation [string](#highlight.tags.string).
    docString: t(string),
    /// A character literal (subtag of [string](#highlight.tags.string)).
    character: t(string),
    /// An attribute value (subtag of [string](#highlight.tags.string)).
    attributeValue: t(string),
    /// A number [literal](#highlight.tags.literal).
    number,
    /// An integer [number](#highlight.tags.number) literal.
    integer: t(number),
    /// A floating-point [number](#highlight.tags.number) literal.
    float: t(number),
    /// A boolean [literal](#highlight.tags.literal).
    bool: t(literal),
    /// Regular expression [literal](#highlight.tags.literal).
    regexp: t(literal),
    /// An escape [literal](#highlight.tags.literal), for example a
    /// backslash escape in a string.
    escape: t(literal),
    /// A color [literal](#highlight.tags.literal).
    color: t(literal),
    /// A URL [literal](#highlight.tags.literal).
    url: t(literal),
    /// A language keyword.
    keyword,
    /// The [keyword](#highlight.tags.keyword) for the self or this
    /// object.
    self: t(keyword),
    /// The [keyword](#highlight.tags.keyword) for null.
    null: t(keyword),
    /// A [keyword](#highlight.tags.keyword) denoting some atomic value.
    atom: t(keyword),
    /// A [keyword](#highlight.tags.keyword) that represents a unit.
    unit: t(keyword),
    /// A modifier [keyword](#highlight.tags.keyword).
    modifier: t(keyword),
    /// A [keyword](#highlight.tags.keyword) that acts as an operator.
    operatorKeyword: t(keyword),
    /// A control-flow related [keyword](#highlight.tags.keyword).
    controlKeyword: t(keyword),
    /// A [keyword](#highlight.tags.keyword) that defines something.
    definitionKeyword: t(keyword),
    /// A [keyword](#highlight.tags.keyword) related to defining or
    /// interfacing with modules.
    moduleKeyword: t(keyword),
    /// An operator.
    operator,
    /// An [operator](#highlight.tags.operator) that dereferences something.
    derefOperator: t(operator),
    /// Arithmetic-related [operator](#highlight.tags.operator).
    arithmeticOperator: t(operator),
    /// Logical [operator](#highlight.tags.operator).
    logicOperator: t(operator),
    /// Bit [operator](#highlight.tags.operator).
    bitwiseOperator: t(operator),
    /// Comparison [operator](#highlight.tags.operator).
    compareOperator: t(operator),
    /// [Operator](#highlight.tags.operator) that updates its operand.
    updateOperator: t(operator),
    /// [Operator](#highlight.tags.operator) that defines something.
    definitionOperator: t(operator),
    /// Type-related [operator](#highlight.tags.operator).
    typeOperator: t(operator),
    /// Control-flow [operator](#highlight.tags.operator).
    controlOperator: t(operator),
    /// Program or markup punctuation.
    punctuation,
    /// [Punctuation](#highlight.tags.punctuation) that separates
    /// things.
    separator: t(punctuation),
    /// Bracket-style [punctuation](#highlight.tags.punctuation).
    bracket,
    /// Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
    /// tokens).
    angleBracket: t(bracket),
    /// Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
    /// tokens).
    squareBracket: t(bracket),
    /// Parentheses (usually `(` and `)` tokens). Subtag of
    /// [bracket](#highlight.tags.bracket).
    paren: t(bracket),
    /// Braces (usually `{` and `}` tokens). Subtag of
    /// [bracket](#highlight.tags.bracket).
    brace: t(bracket),
    /// Content, for example plain text in XML or markup documents.
    content,
    /// [Content](#highlight.tags.content) that represents a heading.
    heading,
    /// A level 1 [heading](#highlight.tags.heading).
    heading1: t(heading),
    /// A level 2 [heading](#highlight.tags.heading).
    heading2: t(heading),
    /// A level 3 [heading](#highlight.tags.heading).
    heading3: t(heading),
    /// A level 4 [heading](#highlight.tags.heading).
    heading4: t(heading),
    /// A level 5 [heading](#highlight.tags.heading).
    heading5: t(heading),
    /// A level 6 [heading](#highlight.tags.heading).
    heading6: t(heading),
    /// A prose separator (such as a horizontal rule).
    contentSeparator: t(content),
    /// [Content](#highlight.tags.content) that represents a list.
    list: t(content),
    /// [Content](#highlight.tags.content) that represents a quote.
    quote: t(content),
    /// [Content](#highlight.tags.content) that is emphasized.
    emphasis: t(content),
    /// [Content](#highlight.tags.content) that is styled strong.
    strong: t(content),
    /// [Content](#highlight.tags.content) that is part of a link.
    link: t(content),
    /// [Content](#highlight.tags.content) that is styled as code or
    /// monospace.
    monospace: t(content),
    /// [Content](#highlight.tags.content) that has a strike-through
    /// style.
    strikethrough: t(content),
    /// Inserted text in a change-tracking format.
    inserted: t(),
    /// Deleted text.
    deleted: t(),
    /// Changed text.
    changed: t(),
    /// An invalid or unsyntactic element.
    invalid: t(),
    /// Metadata or meta-instruction.
    meta,
    /// [Metadata](#highlight.tags.meta) that applies to the entire
    /// document.
    documentMeta: t(meta),
    /// [Metadata](#highlight.tags.meta) that annotates or adds
    /// attributes to a given syntactic element.
    annotation: t(meta),
    /// Processing instruction or preprocessor directive. Subtag of
    /// [meta](#highlight.tags.meta).
    processingInstruction: t(meta),
    /// [Modifier](#highlight.Tag^defineModifier) that indicates that a
    /// given element is being defined. Expected to be used with the
    /// various [name](#highlight.tags.name) tags.
    definition: Tag.defineModifier(),
    /// [Modifier](#highlight.Tag^defineModifier) that indicates that
    /// something is constant. Mostly expected to be used with
    /// [variable names](#highlight.tags.variableName).
    constant: Tag.defineModifier(),
    /// [Modifier](#highlight.Tag^defineModifier) used to indicate that
    /// a [variable](#highlight.tags.variableName) or [property
    /// name](#highlight.tags.propertyName) is being called or defined
    /// as a function.
    function: Tag.defineModifier(),
    /// [Modifier](#highlight.Tag^defineModifier) that can be applied to
    /// [names](#highlight.tags.name) to indicate that they belong to
    /// the language's standard environment.
    standard: Tag.defineModifier(),
    /// [Modifier](#highlight.Tag^defineModifier) that indicates a given
    /// [names](#highlight.tags.name) is local to some scope.
    local: Tag.defineModifier(),
    /// A generic variant [modifier](#highlight.Tag^defineModifier) that
    /// can be used to tag language-specific alternative variants of
    /// some common tag. It is recommended for themes to define special
    /// forms of at least the [string](#highlight.tags.string) and
    /// [variable name](#highlight.tags.variableName) tags, since those
    /// come up a lot.
    special: Tag.defineModifier()
  }; /// This is a highlighter that adds stable, predictable classes to
  /// tokens, for styling with external CSS.
  ///
  /// The following tags are mapped to their name prefixed with `"tok-"`
  /// (for example `"tok-comment"`):
  ///
  /// * [`link`](#highlight.tags.link)
  /// * [`heading`](#highlight.tags.heading)
  /// * [`emphasis`](#highlight.tags.emphasis)
  /// * [`strong`](#highlight.tags.strong)
  /// * [`keyword`](#highlight.tags.keyword)
  /// * [`atom`](#highlight.tags.atom)
  /// * [`bool`](#highlight.tags.bool)
  /// * [`url`](#highlight.tags.url)
  /// * [`labelName`](#highlight.tags.labelName)
  /// * [`inserted`](#highlight.tags.inserted)
  /// * [`deleted`](#highlight.tags.deleted)
  /// * [`literal`](#highlight.tags.literal)
  /// * [`string`](#highlight.tags.string)
  /// * [`number`](#highlight.tags.number)
  /// * [`variableName`](#highlight.tags.variableName)
  /// * [`typeName`](#highlight.tags.typeName)
  /// * [`namespace`](#highlight.tags.namespace)
  /// * [`className`](#highlight.tags.className)
  /// * [`macroName`](#highlight.tags.macroName)
  /// * [`propertyName`](#highlight.tags.propertyName)
  /// * [`operator`](#highlight.tags.operator)
  /// * [`comment`](#highlight.tags.comment)
  /// * [`meta`](#highlight.tags.meta)
  /// * [`punctuation`](#highlight.tags.punctuation)
  /// * [`invalid`](#highlight.tags.invalid)
  ///
  /// In addition, these mappings are provided:
  ///
  /// * [`regexp`](#highlight.tags.regexp),
  ///   [`escape`](#highlight.tags.escape), and
  ///   [`special`](#highlight.tags.special)[`(string)`](#highlight.tags.string)
  ///   are mapped to `"tok-string2"`
  /// * [`special`](#highlight.tags.special)[`(variableName)`](#highlight.tags.variableName)
  ///   to `"tok-variableName2"`
  /// * [`local`](#highlight.tags.local)[`(variableName)`](#highlight.tags.variableName)
  ///   to `"tok-variableName tok-local"`
  /// * [`definition`](#highlight.tags.definition)[`(variableName)`](#highlight.tags.variableName)
  ///   to `"tok-variableName tok-definition"`
  /// * [`definition`](#highlight.tags.definition)[`(propertyName)`](#highlight.tags.propertyName)
  ///   to `"tok-propertyName tok-definition"`

  tagHighlighter([{
    tag: tags$1.link,
    class: "tok-link"
  }, {
    tag: tags$1.heading,
    class: "tok-heading"
  }, {
    tag: tags$1.emphasis,
    class: "tok-emphasis"
  }, {
    tag: tags$1.strong,
    class: "tok-strong"
  }, {
    tag: tags$1.keyword,
    class: "tok-keyword"
  }, {
    tag: tags$1.atom,
    class: "tok-atom"
  }, {
    tag: tags$1.bool,
    class: "tok-bool"
  }, {
    tag: tags$1.url,
    class: "tok-url"
  }, {
    tag: tags$1.labelName,
    class: "tok-labelName"
  }, {
    tag: tags$1.inserted,
    class: "tok-inserted"
  }, {
    tag: tags$1.deleted,
    class: "tok-deleted"
  }, {
    tag: tags$1.literal,
    class: "tok-literal"
  }, {
    tag: tags$1.string,
    class: "tok-string"
  }, {
    tag: tags$1.number,
    class: "tok-number"
  }, {
    tag: [tags$1.regexp, tags$1.escape, tags$1.special(tags$1.string)],
    class: "tok-string2"
  }, {
    tag: tags$1.variableName,
    class: "tok-variableName"
  }, {
    tag: tags$1.local(tags$1.variableName),
    class: "tok-variableName tok-local"
  }, {
    tag: tags$1.definition(tags$1.variableName),
    class: "tok-variableName tok-definition"
  }, {
    tag: tags$1.special(tags$1.variableName),
    class: "tok-variableName2"
  }, {
    tag: tags$1.definition(tags$1.propertyName),
    class: "tok-propertyName tok-definition"
  }, {
    tag: tags$1.typeName,
    class: "tok-typeName"
  }, {
    tag: tags$1.namespace,
    class: "tok-namespace"
  }, {
    tag: tags$1.className,
    class: "tok-className"
  }, {
    tag: tags$1.macroName,
    class: "tok-macroName"
  }, {
    tag: tags$1.propertyName,
    class: "tok-propertyName"
  }, {
    tag: tags$1.operator,
    class: "tok-operator"
  }, {
    tag: tags$1.comment,
    class: "tok-comment"
  }, {
    tag: tags$1.meta,
    class: "tok-meta"
  }, {
    tag: tags$1.invalid,
    class: "tok-invalid"
  }, {
    tag: tags$1.punctuation,
    class: "tok-punctuation"
  }]);

  var _a;
  /**
  Node prop stored in a parser's top syntax node to provide the
  facet that stores language-specific data for that language.
  */


  const languageDataProp = /*@__PURE__*/new NodeProp();
  /**
  Helper function to define a facet (to be added to the top syntax
  node(s) for a language via
  [`languageDataProp`](https://codemirror.net/6/docs/ref/#language.languageDataProp)), that will be
  used to associate language data with the language. You
  probably only need this when subclassing
  [`Language`](https://codemirror.net/6/docs/ref/#language.Language).
  */

  function defineLanguageFacet(baseData) {
    return Facet.define({
      combine: baseData ? values => values.concat(baseData) : undefined
    });
  }
  /**
  A language object manages parsing and per-language
  [metadata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). Parse data is
  managed as a [Lezer](https://lezer.codemirror.net) tree. The class
  can be used directly, via the [`LRLanguage`](https://codemirror.net/6/docs/ref/#language.LRLanguage)
  subclass for [Lezer](https://lezer.codemirror.net/) LR parsers, or
  via the [`StreamLanguage`](https://codemirror.net/6/docs/ref/#language.StreamLanguage) subclass
  for stream parsers.
  */


  class Language$1 {
    /**
    Construct a language object. If you need to invoke this
    directly, first define a data facet with
    [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then
    configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it
    to the language's outer syntax node.
    */
    constructor(
    /**
    The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) facet
    used for this language.
    */
    data, parser, extraExtensions = []) {
      this.data = data; // Kludge to define EditorState.tree as a debugging helper,
      // without the EditorState package actually knowing about
      // languages and lezer trees.

      if (!EditorState.prototype.hasOwnProperty("tree")) Object.defineProperty(EditorState.prototype, "tree", {
        get() {
          return syntaxTree(this);
        }

      });
      this.parser = parser;
      this.extension = [language$1.of(this), EditorState.languageData.of((state, pos, side) => state.facet(languageDataFacetAt(state, pos, side)))].concat(extraExtensions);
    }
    /**
    Query whether this language is active at the given position.
    */


    isActiveAt(state, pos, side = -1) {
      return languageDataFacetAt(state, pos, side) == this.data;
    }
    /**
    Find the document regions that were parsed using this language.
    The returned regions will _include_ any nested languages rooted
    in this language, when those exist.
    */


    findRegions(state) {
      let lang = state.facet(language$1);
      if ((lang === null || lang === void 0 ? void 0 : lang.data) == this.data) return [{
        from: 0,
        to: state.doc.length
      }];
      if (!lang || !lang.allowsNesting) return [];
      let result = [];

      let explore = (tree, from) => {
        if (tree.prop(languageDataProp) == this.data) {
          result.push({
            from,
            to: from + tree.length
          });
          return;
        }

        let mount = tree.prop(NodeProp.mounted);

        if (mount) {
          if (mount.tree.prop(languageDataProp) == this.data) {
            if (mount.overlay) for (let r of mount.overlay) result.push({
              from: r.from + from,
              to: r.to + from
            });else result.push({
              from: from,
              to: from + tree.length
            });
            return;
          } else if (mount.overlay) {
            let size = result.length;
            explore(mount.tree, mount.overlay[0].from + from);
            if (result.length > size) return;
          }
        }

        for (let i = 0; i < tree.children.length; i++) {
          let ch = tree.children[i];
          if (ch instanceof Tree) explore(ch, tree.positions[i] + from);
        }
      };

      explore(syntaxTree(state), 0);
      return result;
    }
    /**
    Indicates whether this language allows nested languages. The
    default implementation returns true.
    */


    get allowsNesting() {
      return true;
    }

  }
  /**
  @internal
  */


  Language$1.setState = /*@__PURE__*/StateEffect.define();

  function languageDataFacetAt(state, pos, side) {
    let topLang = state.facet(language$1);
    if (!topLang) return null;
    let facet = topLang.data;

    if (topLang.allowsNesting) {
      for (let node = syntaxTree(state).topNode; node; node = node.enter(pos, side, IterMode.ExcludeBuffers)) facet = node.type.prop(languageDataProp) || facet;
    }

    return facet;
  }
  /**
  A subclass of [`Language`](https://codemirror.net/6/docs/ref/#language.Language) for use with Lezer
  [LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser)
  parsers.
  */


  class LRLanguage extends Language$1 {
    constructor(data, parser) {
      super(data, parser);
      this.parser = parser;
    }
    /**
    Define a language from a parser.
    */


    static define(spec) {
      let data = defineLanguageFacet(spec.languageData);
      return new LRLanguage(data, spec.parser.configure({
        props: [languageDataProp.add(type => type.isTop ? data : undefined)]
      }));
    }
    /**
    Create a new instance of this language with a reconfigured
    version of its parser.
    */


    configure(options) {
      return new LRLanguage(this.data, this.parser.configure(options));
    }

    get allowsNesting() {
      return this.parser.hasWrappers();
    }

  }
  /**
  Get the syntax tree for a state, which is the current (possibly
  incomplete) parse tree of the active
  [language](https://codemirror.net/6/docs/ref/#language.Language), or the empty tree if there is no
  language available.
  */


  function syntaxTree(state) {
    let field = state.field(Language$1.state, false);
    return field ? field.tree : Tree.empty;
  }


  class DocInput {
    constructor(doc, length = doc.length) {
      this.doc = doc;
      this.length = length;
      this.cursorPos = 0;
      this.string = "";
      this.cursor = doc.iter();
    }

    syncTo(pos) {
      this.string = this.cursor.next(pos - this.cursorPos).value;
      this.cursorPos = pos + this.string.length;
      return this.cursorPos - this.string.length;
    }

    chunk(pos) {
      this.syncTo(pos);
      return this.string;
    }

    get lineChunks() {
      return true;
    }

    read(from, to) {
      let stringStart = this.cursorPos - this.string.length;
      if (from < stringStart || to >= this.cursorPos) return this.doc.sliceString(from, to);else return this.string.slice(from - stringStart, to - stringStart);
    }

  }

  let currentContext = null;
  /**
  A parse context provided to parsers working on the editor content.
  */

  class ParseContext {
    constructor(parser,
    /**
    The current editor state.
    */
    state,
    /**
    Tree fragments that can be reused by incremental re-parses.
    */
    fragments = [],
    /**
    @internal
    */
    tree,
    /**
    @internal
    */
    treeLen,
    /**
    The current editor viewport (or some overapproximation
    thereof). Intended to be used for opportunistically avoiding
    work (in which case
    [`skipUntilInView`](https://codemirror.net/6/docs/ref/#language.ParseContext.skipUntilInView)
    should be called to make sure the parser is restarted when the
    skipped region becomes visible).
    */
    viewport,
    /**
    @internal
    */
    skipped,
    /**
    This is where skipping parsers can register a promise that,
    when resolved, will schedule a new parse. It is cleared when
    the parse worker picks up the promise. @internal
    */
    scheduleOn) {
      this.parser = parser;
      this.state = state;
      this.fragments = fragments;
      this.tree = tree;
      this.treeLen = treeLen;
      this.viewport = viewport;
      this.skipped = skipped;
      this.scheduleOn = scheduleOn;
      this.parse = null;
      /**
      @internal
      */

      this.tempSkipped = [];
    }
    /**
    @internal
    */


    static create(parser, state, viewport) {
      return new ParseContext(parser, state, [], Tree.empty, 0, viewport, [], null);
    }

    startParse() {
      return this.parser.startParse(new DocInput(this.state.doc), this.fragments);
    }
    /**
    @internal
    */


    work(until, upto) {
      if (upto != null && upto >= this.state.doc.length) upto = undefined;

      if (this.tree != Tree.empty && this.isDone(upto !== null && upto !== void 0 ? upto : this.state.doc.length)) {
        this.takeTree();
        return true;
      }

      return this.withContext(() => {
        var _a;

        if (typeof until == "number") {
          let endTime = Date.now() + until;

          until = () => Date.now() > endTime;
        }

        if (!this.parse) this.parse = this.startParse();
        if (upto != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > upto) && upto < this.state.doc.length) this.parse.stopAt(upto);

        for (;;) {
          let done = this.parse.advance();

          if (done) {
            this.fragments = this.withoutTempSkipped(TreeFragment.addTree(done, this.fragments, this.parse.stoppedAt != null));
            this.treeLen = (_a = this.parse.stoppedAt) !== null && _a !== void 0 ? _a : this.state.doc.length;
            this.tree = done;
            this.parse = null;
            if (this.treeLen < (upto !== null && upto !== void 0 ? upto : this.state.doc.length)) this.parse = this.startParse();else return true;
          }

          if (until()) return false;
        }
      });
    }
    /**
    @internal
    */


    takeTree() {
      let pos, tree;

      if (this.parse && (pos = this.parse.parsedPos) >= this.treeLen) {
        if (this.parse.stoppedAt == null || this.parse.stoppedAt > pos) this.parse.stopAt(pos);
        this.withContext(() => {
          while (!(tree = this.parse.advance())) {}
        });
        this.treeLen = pos;
        this.tree = tree;
        this.fragments = this.withoutTempSkipped(TreeFragment.addTree(this.tree, this.fragments, true));
        this.parse = null;
      }
    }

    withContext(f) {
      let prev = currentContext;
      currentContext = this;

      try {
        return f();
      } finally {
        currentContext = prev;
      }
    }

    withoutTempSkipped(fragments) {
      for (let r; r = this.tempSkipped.pop();) fragments = cutFragments(fragments, r.from, r.to);

      return fragments;
    }
    /**
    @internal
    */


    changes(changes, newState) {
      let {
        fragments,
        tree,
        treeLen,
        viewport,
        skipped
      } = this;
      this.takeTree();

      if (!changes.empty) {
        let ranges = [];
        changes.iterChangedRanges((fromA, toA, fromB, toB) => ranges.push({
          fromA,
          toA,
          fromB,
          toB
        }));
        fragments = TreeFragment.applyChanges(fragments, ranges);
        tree = Tree.empty;
        treeLen = 0;
        viewport = {
          from: changes.mapPos(viewport.from, -1),
          to: changes.mapPos(viewport.to, 1)
        };

        if (this.skipped.length) {
          skipped = [];

          for (let r of this.skipped) {
            let from = changes.mapPos(r.from, 1),
                to = changes.mapPos(r.to, -1);
            if (from < to) skipped.push({
              from,
              to
            });
          }
        }
      }

      return new ParseContext(this.parser, newState, fragments, tree, treeLen, viewport, skipped, this.scheduleOn);
    }
    /**
    @internal
    */


    updateViewport(viewport) {
      if (this.viewport.from == viewport.from && this.viewport.to == viewport.to) return false;
      this.viewport = viewport;
      let startLen = this.skipped.length;

      for (let i = 0; i < this.skipped.length; i++) {
        let {
          from,
          to
        } = this.skipped[i];

        if (from < viewport.to && to > viewport.from) {
          this.fragments = cutFragments(this.fragments, from, to);
          this.skipped.splice(i--, 1);
        }
      }

      if (this.skipped.length >= startLen) return false;
      this.reset();
      return true;
    }
    /**
    @internal
    */


    reset() {
      if (this.parse) {
        this.takeTree();
        this.parse = null;
      }
    }
    /**
    Notify the parse scheduler that the given region was skipped
    because it wasn't in view, and the parse should be restarted
    when it comes into view.
    */


    skipUntilInView(from, to) {
      this.skipped.push({
        from,
        to
      });
    }
    /**
    Returns a parser intended to be used as placeholder when
    asynchronously loading a nested parser. It'll skip its input and
    mark it as not-really-parsed, so that the next update will parse
    it again.
    
    When `until` is given, a reparse will be scheduled when that
    promise resolves.
    */


    static getSkippingParser(until) {
      return new class extends Parser {
        createParse(input, fragments, ranges) {
          let from = ranges[0].from,
              to = ranges[ranges.length - 1].to;
          let parser = {
            parsedPos: from,

            advance() {
              let cx = currentContext;

              if (cx) {
                for (let r of ranges) cx.tempSkipped.push(r);

                if (until) cx.scheduleOn = cx.scheduleOn ? Promise.all([cx.scheduleOn, until]) : until;
              }

              this.parsedPos = to;
              return new Tree(NodeType.none, [], [], to - from);
            },

            stoppedAt: null,

            stopAt() {}

          };
          return parser;
        }

      }();
    }
    /**
    @internal
    */


    isDone(upto) {
      upto = Math.min(upto, this.state.doc.length);
      let frags = this.fragments;
      return this.treeLen >= upto && frags.length && frags[0].from == 0 && frags[0].to >= upto;
    }
    /**
    Get the context for the current parse, or `null` if no editor
    parse is in progress.
    */


    static get() {
      return currentContext;
    }

  }

  function cutFragments(fragments, from, to) {
    return TreeFragment.applyChanges(fragments, [{
      fromA: from,
      toA: to,
      fromB: from,
      toB: to
    }]);
  }

  class LanguageState {
    constructor( // A mutable parse state that is used to preserve work done during
    // the lifetime of a state when moving to the next state.
    context) {
      this.context = context;
      this.tree = context.tree;
    }

    apply(tr) {
      if (!tr.docChanged && this.tree == this.context.tree) return this;
      let newCx = this.context.changes(tr.changes, tr.state); // If the previous parse wasn't done, go forward only up to its
      // end position or the end of the viewport, to avoid slowing down
      // state updates with parse work beyond the viewport.

      let upto = this.context.treeLen == tr.startState.doc.length ? undefined : Math.max(tr.changes.mapPos(this.context.treeLen), newCx.viewport.to);
      if (!newCx.work(20
      /* Apply */
      , upto)) newCx.takeTree();
      return new LanguageState(newCx);
    }

    static init(state) {
      let vpTo = Math.min(3000
      /* InitViewport */
      , state.doc.length);
      let parseState = ParseContext.create(state.facet(language$1).parser, state, {
        from: 0,
        to: vpTo
      });
      if (!parseState.work(20
      /* Apply */
      , vpTo)) parseState.takeTree();
      return new LanguageState(parseState);
    }

  }

  Language$1.state = /*@__PURE__*/StateField.define({
    create: LanguageState.init,

    update(value, tr) {
      for (let e of tr.effects) if (e.is(Language$1.setState)) return e.value;

      if (tr.startState.facet(language$1) != tr.state.facet(language$1)) return LanguageState.init(tr.state);
      return value.apply(tr);
    }

  });

  let requestIdle = callback => {
    let timeout = setTimeout(() => callback(), 500
    /* MaxPause */
    );
    return () => clearTimeout(timeout);
  };

  if (typeof requestIdleCallback != "undefined") requestIdle = callback => {
    let idle = -1,
        timeout = setTimeout(() => {
      idle = requestIdleCallback(callback, {
        timeout: 500
        /* MaxPause */
        - 100
        /* MinPause */

      });
    }, 100
    /* MinPause */
    );
    return () => idle < 0 ? clearTimeout(timeout) : cancelIdleCallback(idle);
  };
  const isInputPending = typeof navigator != "undefined" && ((_a = navigator.scheduling) === null || _a === void 0 ? void 0 : _a.isInputPending) ? () => navigator.scheduling.isInputPending() : null;
  const parseWorker = /*@__PURE__*/ViewPlugin.fromClass(class ParseWorker {
    constructor(view) {
      this.view = view;
      this.working = null;
      this.workScheduled = 0; // End of the current time chunk

      this.chunkEnd = -1; // Milliseconds of budget left for this chunk

      this.chunkBudget = -1;
      this.work = this.work.bind(this);
      this.scheduleWork();
    }

    update(update) {
      let cx = this.view.state.field(Language$1.state).context;
      if (cx.updateViewport(update.view.viewport) || this.view.viewport.to > cx.treeLen) this.scheduleWork();

      if (update.docChanged) {
        if (this.view.hasFocus) this.chunkBudget += 50
        /* ChangeBonus */
        ;
        this.scheduleWork();
      }

      this.checkAsyncSchedule(cx);
    }

    scheduleWork() {
      if (this.working) return;
      let {
        state
      } = this.view,
          field = state.field(Language$1.state);
      if (field.tree != field.context.tree || !field.context.isDone(state.doc.length)) this.working = requestIdle(this.work);
    }

    work(deadline) {
      this.working = null;
      let now = Date.now();

      if (this.chunkEnd < now && (this.chunkEnd < 0 || this.view.hasFocus)) {
        // Start a new chunk
        this.chunkEnd = now + 30000
        /* ChunkTime */
        ;
        this.chunkBudget = 3000
        /* ChunkBudget */
        ;
      }

      if (this.chunkBudget <= 0) return; // No more budget

      let {
        state,
        viewport: {
          to: vpTo
        }
      } = this.view,
          field = state.field(Language$1.state);
      if (field.tree == field.context.tree && field.context.isDone(vpTo + 100000
      /* MaxParseAhead */
      )) return;
      let endTime = Date.now() + Math.min(this.chunkBudget, 100
      /* Slice */
      , deadline && !isInputPending ? Math.max(25
      /* MinSlice */
      , deadline.timeRemaining() - 5) : 1e9);
      let viewportFirst = field.context.treeLen < vpTo && state.doc.length > vpTo + 1000;
      let done = field.context.work(() => {
        return isInputPending && isInputPending() || Date.now() > endTime;
      }, vpTo + (viewportFirst ? 0 : 100000
      /* MaxParseAhead */
      ));
      this.chunkBudget -= Date.now() - now;

      if (done || this.chunkBudget <= 0) {
        field.context.takeTree();
        this.view.dispatch({
          effects: Language$1.setState.of(new LanguageState(field.context))
        });
      }

      if (this.chunkBudget > 0 && !(done && !viewportFirst)) this.scheduleWork();
      this.checkAsyncSchedule(field.context);
    }

    checkAsyncSchedule(cx) {
      if (cx.scheduleOn) {
        this.workScheduled++;
        cx.scheduleOn.then(() => this.scheduleWork()).catch(err => logException(this.view.state, err)).then(() => this.workScheduled--);
        cx.scheduleOn = null;
      }
    }

    destroy() {
      if (this.working) this.working();
    }

    isWorking() {
      return !!(this.working || this.workScheduled > 0);
    }

  }, {
    eventHandlers: {
      focus() {
        this.scheduleWork();
      }

    }
  });
  /**
  The facet used to associate a language with an editor state. Used
  by `Language` object's `extension` property (so you don't need to
  manually wrap your languages in this). Can be used to access the
  current language on a state.
  */

  const language$1 = /*@__PURE__*/Facet.define({
    combine(languages) {
      return languages.length ? languages[0] : null;
    },

    enables: [Language$1.state, parseWorker]
  });
  /**
  This class bundles a [language](https://codemirror.net/6/docs/ref/#language.Language) with an
  optional set of supporting extensions. Language packages are
  encouraged to export a function that optionally takes a
  configuration object and returns a `LanguageSupport` instance, as
  the main way for client code to use the package.
  */

  class LanguageSupport {
    /**
    Create a language support object.
    */
    constructor(
    /**
    The language object.
    */
    language,
    /**
    An optional set of supporting extensions. When nesting a
    language in another language, the outer language is encouraged
    to include the supporting extensions for its inner languages
    in its own set of support extensions.
    */
    support = []) {
      this.language = language;
      this.support = support;
      this.extension = [language, support];
    }

  }
  /**
  Facet that defines a way to provide a function that computes the
  appropriate indentation depth at the start of a given line, or
  `null` to indicate no appropriate indentation could be determined.
  */


  const indentService = /*@__PURE__*/Facet.define();
  /**
  Facet for overriding the unit by which indentation happens.
  Should be a string consisting either entirely of spaces or
  entirely of tabs. When not set, this defaults to 2 spaces.
  */

  const indentUnit = /*@__PURE__*/Facet.define({
    combine: values => {
      if (!values.length) return "  ";
      if (!/^(?: +|\t+)$/.test(values[0])) throw new Error("Invalid indent unit: " + JSON.stringify(values[0]));
      return values[0];
    }
  });
  /**
  Return the _column width_ of an indent unit in the state.
  Determined by the [`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit)
  facet, and [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) when that
  contains tabs.
  */

  function getIndentUnit(state) {
    let unit = state.facet(indentUnit);
    return unit.charCodeAt(0) == 9 ? state.tabSize * unit.length : unit.length;
  }
  /**
  Create an indentation string that covers columns 0 to `cols`.
  Will use tabs for as much of the columns as possible when the
  [`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit) facet contains
  tabs.
  */


  function indentString(state, cols) {
    let result = "",
        ts = state.tabSize;
    if (state.facet(indentUnit).charCodeAt(0) == 9) while (cols >= ts) {
      result += "\t";
      cols -= ts;
    }

    for (let i = 0; i < cols; i++) result += " ";

    return result;
  }
  /**
  Get the indentation at the given position. Will first consult any
  [indent services](https://codemirror.net/6/docs/ref/#language.indentService) that are registered,
  and if none of those return an indentation, this will check the
  syntax tree for the [indent node prop](https://codemirror.net/6/docs/ref/#language.indentNodeProp)
  and use that if found. Returns a number when an indentation could
  be determined, and null otherwise.
  */


  function getIndentation(context, pos) {
    if (context instanceof EditorState) context = new IndentContext(context);

    for (let service of context.state.facet(indentService)) {
      let result = service(context, pos);
      if (result != null) return result;
    }

    let tree = syntaxTree(context.state);
    return tree ? syntaxIndentation(context, tree, pos) : null;
  }
  /**
  Indentation contexts are used when calling [indentation
  services](https://codemirror.net/6/docs/ref/#language.indentService). They provide helper utilities
  useful in indentation logic, and can selectively override the
  indentation reported for some lines.
  */


  class IndentContext {
    /**
    Create an indent context.
    */
    constructor(
    /**
    The editor state.
    */
    state,
    /**
    @internal
    */
    options = {}) {
      this.state = state;
      this.options = options;
      this.unit = getIndentUnit(state);
    }
    /**
    Get a description of the line at the given position, taking
    [simulated line
    breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
    into account. If there is such a break at `pos`, the `bias`
    argument determines whether the part of the line line before or
    after the break is used.
    */


    lineAt(pos, bias = 1) {
      let line = this.state.doc.lineAt(pos);
      let {
        simulateBreak,
        simulateDoubleBreak
      } = this.options;

      if (simulateBreak != null && simulateBreak >= line.from && simulateBreak <= line.to) {
        if (simulateDoubleBreak && simulateBreak == pos) return {
          text: "",
          from: pos
        };else if (bias < 0 ? simulateBreak < pos : simulateBreak <= pos) return {
          text: line.text.slice(simulateBreak - line.from),
          from: simulateBreak
        };else return {
          text: line.text.slice(0, simulateBreak - line.from),
          from: line.from
        };
      }

      return line;
    }
    /**
    Get the text directly after `pos`, either the entire line
    or the next 100 characters, whichever is shorter.
    */


    textAfterPos(pos, bias = 1) {
      if (this.options.simulateDoubleBreak && pos == this.options.simulateBreak) return "";
      let {
        text,
        from
      } = this.lineAt(pos, bias);
      return text.slice(pos - from, Math.min(text.length, pos + 100 - from));
    }
    /**
    Find the column for the given position.
    */


    column(pos, bias = 1) {
      let {
        text,
        from
      } = this.lineAt(pos, bias);
      let result = this.countColumn(text, pos - from);
      let override = this.options.overrideIndentation ? this.options.overrideIndentation(from) : -1;
      if (override > -1) result += override - this.countColumn(text, text.search(/\S|$/));
      return result;
    }
    /**
    Find the column position (taking tabs into account) of the given
    position in the given string.
    */


    countColumn(line, pos = line.length) {
      return countColumn(line, this.state.tabSize, pos);
    }
    /**
    Find the indentation column of the line at the given point.
    */


    lineIndent(pos, bias = 1) {
      let {
        text,
        from
      } = this.lineAt(pos, bias);
      let override = this.options.overrideIndentation;

      if (override) {
        let overriden = override(from);
        if (overriden > -1) return overriden;
      }

      return this.countColumn(text, text.search(/\S|$/));
    }
    /**
    Returns the [simulated line
    break](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
    for this context, if any.
    */


    get simulatedBreak() {
      return this.options.simulateBreak || null;
    }

  }
  /**
  A syntax tree node prop used to associate indentation strategies
  with node types. Such a strategy is a function from an indentation
  context to a column number or null, where null indicates that no
  definitive indentation can be determined.
  */


  const indentNodeProp = /*@__PURE__*/new NodeProp(); // Compute the indentation for a given position from the syntax tree.

  function syntaxIndentation(cx, ast, pos) {
    return indentFrom(ast.resolveInner(pos).enterUnfinishedNodesBefore(pos), pos, cx);
  }

  function ignoreClosed(cx) {
    return cx.pos == cx.options.simulateBreak && cx.options.simulateDoubleBreak;
  }

  function indentStrategy(tree) {
    let strategy = tree.type.prop(indentNodeProp);
    if (strategy) return strategy;
    let first = tree.firstChild,
        close;

    if (first && (close = first.type.prop(NodeProp.closedBy))) {
      let last = tree.lastChild,
          closed = last && close.indexOf(last.name) > -1;
      return cx => delimitedStrategy(cx, true, 1, undefined, closed && !ignoreClosed(cx) ? last.from : undefined);
    }

    return tree.parent == null ? topIndent : null;
  }

  function indentFrom(node, pos, base) {
    for (; node; node = node.parent) {
      let strategy = indentStrategy(node);
      if (strategy) return strategy(TreeIndentContext.create(base, pos, node));
    }

    return null;
  }

  function topIndent() {
    return 0;
  }
  /**
  Objects of this type provide context information and helper
  methods to indentation functions registered on syntax nodes.
  */


  class TreeIndentContext extends IndentContext {
    constructor(base,
    /**
    The position at which indentation is being computed.
    */
    pos,
    /**
    The syntax tree node to which the indentation strategy
    applies.
    */
    node) {
      super(base.state, base.options);
      this.base = base;
      this.pos = pos;
      this.node = node;
    }
    /**
    @internal
    */


    static create(base, pos, node) {
      return new TreeIndentContext(base, pos, node);
    }
    /**
    Get the text directly after `this.pos`, either the entire line
    or the next 100 characters, whichever is shorter.
    */


    get textAfter() {
      return this.textAfterPos(this.pos);
    }
    /**
    Get the indentation at the reference line for `this.node`, which
    is the line on which it starts, unless there is a node that is
    _not_ a parent of this node covering the start of that line. If
    so, the line at the start of that node is tried, again skipping
    on if it is covered by another such node.
    */


    get baseIndent() {
      let line = this.state.doc.lineAt(this.node.from); // Skip line starts that are covered by a sibling (or cousin, etc)

      for (;;) {
        let atBreak = this.node.resolve(line.from);

        while (atBreak.parent && atBreak.parent.from == atBreak.from) atBreak = atBreak.parent;

        if (isParent(atBreak, this.node)) break;
        line = this.state.doc.lineAt(atBreak.from);
      }

      return this.lineIndent(line.from);
    }
    /**
    Continue looking for indentations in the node's parent nodes,
    and return the result of that.
    */


    continue() {
      let parent = this.node.parent;
      return parent ? indentFrom(parent, this.pos, this.base) : 0;
    }

  }

  function isParent(parent, of) {
    for (let cur = of; cur; cur = cur.parent) if (parent == cur) return true;

    return false;
  } // Check whether a delimited node is aligned (meaning there are
  // non-skipped nodes on the same line as the opening delimiter). And
  // if so, return the opening token.


  function bracketedAligned(context) {
    let tree = context.node;
    let openToken = tree.childAfter(tree.from),
        last = tree.lastChild;
    if (!openToken) return null;
    let sim = context.options.simulateBreak;
    let openLine = context.state.doc.lineAt(openToken.from);
    let lineEnd = sim == null || sim <= openLine.from ? openLine.to : Math.min(openLine.to, sim);

    for (let pos = openToken.to;;) {
      let next = tree.childAfter(pos);
      if (!next || next == last) return null;
      if (!next.type.isSkipped) return next.from < lineEnd ? openToken : null;
      pos = next.to;
    }
  }
  /**
  An indentation strategy for delimited (usually bracketed) nodes.
  Will, by default, indent one unit more than the parent's base
  indent unless the line starts with a closing token. When `align`
  is true and there are non-skipped nodes on the node's opening
  line, the content of the node will be aligned with the end of the
  opening node, like this:

      foo(bar,
          baz)
  */


  function delimitedIndent({
    closing,
    align = true,
    units = 1
  }) {
    return context => delimitedStrategy(context, align, units, closing);
  }

  function delimitedStrategy(context, align, units, closing, closedAt) {
    let after = context.textAfter,
        space = after.match(/^\s*/)[0].length;
    let closed = closing && after.slice(space, space + closing.length) == closing || closedAt == context.pos + space;
    let aligned = align ? bracketedAligned(context) : null;
    if (aligned) return closed ? context.column(aligned.from) : context.column(aligned.to);
    return context.baseIndent + (closed ? 0 : context.unit * units);
  }
  /**
  Creates an indentation strategy that, by default, indents
  continued lines one unit more than the node's base indentation.
  You can provide `except` to prevent indentation of lines that
  match a pattern (for example `/^else\b/` in `if`/`else`
  constructs), and you can change the amount of units used with the
  `units` option.
  */


  function continuedIndent({
    except,
    units = 1
  } = {}) {
    return context => {
      let matchExcept = except && except.test(context.textAfter);
      return context.baseIndent + (matchExcept ? 0 : units * context.unit);
    };
  }

  const DontIndentBeyond = 200;
  /**
  Enables reindentation on input. When a language defines an
  `indentOnInput` field in its [language
  data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt), which must hold a regular
  expression, the line at the cursor will be reindented whenever new
  text is typed and the input from the start of the line up to the
  cursor matches that regexp.

  To avoid unneccesary reindents, it is recommended to start the
  regexp with `^` (usually followed by `\s*`), and end it with `$`.
  For example, `/^\s*\}$/` will reindent when a closing brace is
  added at the start of a line.
  */

  function indentOnInput() {
    return EditorState.transactionFilter.of(tr => {
      if (!tr.docChanged || !tr.isUserEvent("input.type") && !tr.isUserEvent("input.complete")) return tr;
      let rules = tr.startState.languageDataAt("indentOnInput", tr.startState.selection.main.head);
      if (!rules.length) return tr;
      let doc = tr.newDoc,
          {
        head
      } = tr.newSelection.main,
          line = doc.lineAt(head);
      if (head > line.from + DontIndentBeyond) return tr;
      let lineStart = doc.sliceString(line.from, head);
      if (!rules.some(r => r.test(lineStart))) return tr;
      let {
        state
      } = tr,
          last = -1,
          changes = [];

      for (let {
        head
      } of state.selection.ranges) {
        let line = state.doc.lineAt(head);
        if (line.from == last) continue;
        last = line.from;
        let indent = getIndentation(state, line.from);
        if (indent == null) continue;
        let cur = /^\s*/.exec(line.text)[0];
        let norm = indentString(state, indent);
        if (cur != norm) changes.push({
          from: line.from,
          to: line.from + cur.length,
          insert: norm
        });
      }

      return changes.length ? [tr, {
        changes,
        sequential: true
      }] : tr;
    });
  }
  /**
  This node prop is used to associate folding information with
  syntax node types. Given a syntax node, it should check whether
  that tree is foldable and return the range that can be collapsed
  when it is.
  */

  const foldNodeProp = /*@__PURE__*/new NodeProp();
  /**
  [Fold](https://codemirror.net/6/docs/ref/#language.foldNodeProp) function that folds everything but
  the first and the last child of a syntax node. Useful for nodes
  that start and end with delimiters.
  */

  function foldInside(node) {
    let first = node.firstChild,
        last = node.lastChild;
    return first && first.to < last.from ? {
      from: first.to,
      to: last.type.isError ? node.to : last.from
    } : null;
  }
  /**
  A highlight style associates CSS styles with higlighting
  [tags](https://lezer.codemirror.net/docs/ref#highlight.Tag).
  */

  class HighlightStyle {
    constructor(spec, options) {
      let modSpec;

      function def(spec) {
        let cls = StyleModule.newName();
        (modSpec || (modSpec = Object.create(null)))["." + cls] = spec;
        return cls;
      }

      const all = typeof options.all == "string" ? options.all : options.all ? def(options.all) : undefined;
      const scopeOpt = options.scope;
      this.scope = scopeOpt instanceof Language$1 ? type => type.prop(languageDataProp) == scopeOpt.data : scopeOpt ? type => type == scopeOpt : undefined;
      this.style = tagHighlighter(spec.map(style => ({
        tag: style.tag,
        class: style.class || def(Object.assign({}, style, {
          tag: null
        }))
      })), {
        all
      }).style;
      this.module = modSpec ? new StyleModule(modSpec) : null;
      this.themeType = options.themeType;
    }
    /**
    Create a highlighter style that associates the given styles to
    the given tags. The specs must be objects that hold a style tag
    or array of tags in their `tag` property, and either a single
    `class` property providing a static CSS class (for highlighter
    that rely on external styling), or a
    [`style-mod`](https://github.com/marijnh/style-mod#documentation)-style
    set of CSS properties (which define the styling for those tags).
    
    The CSS rules created for a highlighter will be emitted in the
    order of the spec's properties. That means that for elements that
    have multiple tags associated with them, styles defined further
    down in the list will have a higher CSS precedence than styles
    defined earlier.
    */


    static define(specs, options) {
      return new HighlightStyle(specs, options || {});
    }

  }

  const highlighterFacet = /*@__PURE__*/Facet.define();
  const fallbackHighlighter = /*@__PURE__*/Facet.define({
    combine(values) {
      return values.length ? [values[0]] : null;
    }

  });

  function getHighlighters(state) {
    let main = state.facet(highlighterFacet);
    return main.length ? main : state.facet(fallbackHighlighter);
  }
  /**
  Wrap a highlighter in an editor extension that uses it to apply
  syntax highlighting to the editor content.

  When multiple (non-fallback) styles are provided, the styling
  applied is the union of the classes they emit.
  */


  function syntaxHighlighting(highlighter, options) {
    let ext = [treeHighlighter],
        themeType;

    if (highlighter instanceof HighlightStyle) {
      if (highlighter.module) ext.push(EditorView.styleModule.of(highlighter.module));
      themeType = highlighter.themeType;
    }

    if (options === null || options === void 0 ? void 0 : options.fallback) ext.push(fallbackHighlighter.of(highlighter));else if (themeType) ext.push(highlighterFacet.computeN([EditorView.darkTheme], state => {
      return state.facet(EditorView.darkTheme) == (themeType == "dark") ? [highlighter] : [];
    }));else ext.push(highlighterFacet.of(highlighter));
    return ext;
  }

  class TreeHighlighter {
    constructor(view) {
      this.markCache = Object.create(null);
      this.tree = syntaxTree(view.state);
      this.decorations = this.buildDeco(view, getHighlighters(view.state));
    }

    update(update) {
      let tree = syntaxTree(update.state),
          highlighters = getHighlighters(update.state);
      let styleChange = highlighters != getHighlighters(update.startState);

      if (tree.length < update.view.viewport.to && !styleChange && tree.type == this.tree.type) {
        this.decorations = this.decorations.map(update.changes);
      } else if (tree != this.tree || update.viewportChanged || styleChange) {
        this.tree = tree;
        this.decorations = this.buildDeco(update.view, highlighters);
      }
    }

    buildDeco(view, highlighters) {
      if (!highlighters || !this.tree.length) return Decoration.none;
      let builder = new RangeSetBuilder();

      for (let {
        from,
        to
      } of view.visibleRanges) {
        highlightTree(this.tree, highlighters, (from, to, style) => {
          builder.add(from, to, this.markCache[style] || (this.markCache[style] = Decoration.mark({
            class: style
          })));
        }, from, to);
      }

      return builder.finish();
    }

  }

  const treeHighlighter = /*@__PURE__*/Prec.high( /*@__PURE__*/ViewPlugin.fromClass(TreeHighlighter, {
    decorations: v => v.decorations
  }));
  const baseTheme$3 = /*@__PURE__*/EditorView.baseTheme({
    "&.cm-focused .cm-matchingBracket": {
      backgroundColor: "#328c8252"
    },
    "&.cm-focused .cm-nonmatchingBracket": {
      backgroundColor: "#bb555544"
    }
  });
  const DefaultScanDist = 10000,
        DefaultBrackets = "()[]{}";
  const bracketMatchingConfig = /*@__PURE__*/Facet.define({
    combine(configs) {
      return combineConfig(configs, {
        afterCursor: true,
        brackets: DefaultBrackets,
        maxScanDistance: DefaultScanDist,
        renderMatch: defaultRenderMatch
      });
    }

  });
  const matchingMark = /*@__PURE__*/Decoration.mark({
    class: "cm-matchingBracket"
  }),
        nonmatchingMark = /*@__PURE__*/Decoration.mark({
    class: "cm-nonmatchingBracket"
  });

  function defaultRenderMatch(match) {
    let decorations = [];
    let mark = match.matched ? matchingMark : nonmatchingMark;
    decorations.push(mark.range(match.start.from, match.start.to));
    if (match.end) decorations.push(mark.range(match.end.from, match.end.to));
    return decorations;
  }

  const bracketMatchingState = /*@__PURE__*/StateField.define({
    create() {
      return Decoration.none;
    },

    update(deco, tr) {
      if (!tr.docChanged && !tr.selection) return deco;
      let decorations = [];
      let config = tr.state.facet(bracketMatchingConfig);

      for (let range of tr.state.selection.ranges) {
        if (!range.empty) continue;
        let match = matchBrackets(tr.state, range.head, -1, config) || range.head > 0 && matchBrackets(tr.state, range.head - 1, 1, config) || config.afterCursor && (matchBrackets(tr.state, range.head, 1, config) || range.head < tr.state.doc.length && matchBrackets(tr.state, range.head + 1, -1, config));
        if (match) decorations = decorations.concat(config.renderMatch(match, tr.state));
      }

      return Decoration.set(decorations, true);
    },

    provide: f => EditorView.decorations.from(f)
  });
  const bracketMatchingUnique = [bracketMatchingState, baseTheme$3];
  /**
  Create an extension that enables bracket matching. Whenever the
  cursor is next to a bracket, that bracket and the one it matches
  are highlighted. Or, when no matching bracket is found, another
  highlighting style is used to indicate this.
  */

  function bracketMatching(config = {}) {
    return [bracketMatchingConfig.of(config), bracketMatchingUnique];
  }

  function matchingNodes(node, dir, brackets) {
    let byProp = node.prop(dir < 0 ? NodeProp.openedBy : NodeProp.closedBy);
    if (byProp) return byProp;

    if (node.name.length == 1) {
      let index = brackets.indexOf(node.name);
      if (index > -1 && index % 2 == (dir < 0 ? 1 : 0)) return [brackets[index + dir]];
    }

    return null;
  }
  /**
  Find the matching bracket for the token at `pos`, scanning
  direction `dir`. Only the `brackets` and `maxScanDistance`
  properties are used from `config`, if given. Returns null if no
  bracket was found at `pos`, or a match result otherwise.
  */


  function matchBrackets(state, pos, dir, config = {}) {
    let maxScanDistance = config.maxScanDistance || DefaultScanDist,
        brackets = config.brackets || DefaultBrackets;
    let tree = syntaxTree(state),
        node = tree.resolveInner(pos, dir);

    for (let cur = node; cur; cur = cur.parent) {
      let matches = matchingNodes(cur.type, dir, brackets);
      if (matches && cur.from < cur.to) return matchMarkedBrackets(state, pos, dir, cur, matches, brackets);
    }

    return matchPlainBrackets(state, pos, dir, tree, node.type, maxScanDistance, brackets);
  }

  function matchMarkedBrackets(_state, _pos, dir, token, matching, brackets) {
    let parent = token.parent,
        firstToken = {
      from: token.from,
      to: token.to
    };
    let depth = 0,
        cursor = parent === null || parent === void 0 ? void 0 : parent.cursor();
    if (cursor && (dir < 0 ? cursor.childBefore(token.from) : cursor.childAfter(token.to))) do {
      if (dir < 0 ? cursor.to <= token.from : cursor.from >= token.to) {
        if (depth == 0 && matching.indexOf(cursor.type.name) > -1 && cursor.from < cursor.to) {
          return {
            start: firstToken,
            end: {
              from: cursor.from,
              to: cursor.to
            },
            matched: true
          };
        } else if (matchingNodes(cursor.type, dir, brackets)) {
          depth++;
        } else if (matchingNodes(cursor.type, -dir, brackets)) {
          if (depth == 0) return {
            start: firstToken,
            end: cursor.from == cursor.to ? undefined : {
              from: cursor.from,
              to: cursor.to
            },
            matched: false
          };
          depth--;
        }
      }
    } while (dir < 0 ? cursor.prevSibling() : cursor.nextSibling());
    return {
      start: firstToken,
      matched: false
    };
  }

  function matchPlainBrackets(state, pos, dir, tree, tokenType, maxScanDistance, brackets) {
    let startCh = dir < 0 ? state.sliceDoc(pos - 1, pos) : state.sliceDoc(pos, pos + 1);
    let bracket = brackets.indexOf(startCh);
    if (bracket < 0 || bracket % 2 == 0 != dir > 0) return null;
    let startToken = {
      from: dir < 0 ? pos - 1 : pos,
      to: dir > 0 ? pos + 1 : pos
    };
    let iter = state.doc.iterRange(pos, dir > 0 ? state.doc.length : 0),
        depth = 0;

    for (let distance = 0; !iter.next().done && distance <= maxScanDistance;) {
      let text = iter.value;
      if (dir < 0) distance += text.length;
      let basePos = pos + distance * dir;

      for (let pos = dir > 0 ? 0 : text.length - 1, end = dir > 0 ? text.length : -1; pos != end; pos += dir) {
        let found = brackets.indexOf(text[pos]);
        if (found < 0 || tree.resolveInner(basePos + pos, 1).type != tokenType) continue;

        if (found % 2 == 0 == dir > 0) {
          depth++;
        } else if (depth == 1) {
          // Closing
          return {
            start: startToken,
            end: {
              from: basePos + pos,
              to: basePos + pos + 1
            },
            matched: found >> 1 == bracket >> 1
          };
        } else {
          depth--;
        }
      }

      if (dir > 0) distance += text.length;
    }

    return iter.done ? {
      start: startToken,
      matched: false
    } : null;
  } // Counts the column offset in a string, taking tabs into account.

  const noTokens = /*@__PURE__*/Object.create(null);
  const typeArray = [NodeType.none];
  const warned = [];
  const defaultTable = /*@__PURE__*/Object.create(null);

  for (let [legacyName, name] of [["variable", "variableName"], ["variable-2", "variableName.special"], ["string-2", "string.special"], ["def", "variableName.definition"], ["tag", "tagName"], ["attribute", "attributeName"], ["type", "typeName"], ["builtin", "variableName.standard"], ["qualifier", "modifier"], ["error", "invalid"], ["header", "heading"], ["property", "propertyName"]]) defaultTable[legacyName] = /*@__PURE__*/createTokenType(noTokens, name);

  function warnForPart(part, msg) {
    if (warned.indexOf(part) > -1) return;
    warned.push(part);
    console.warn(msg);
  }

  function createTokenType(extra, tagStr) {
    let tag = null;

    for (let part of tagStr.split(".")) {
      let value = extra[part] || tags$1[part];

      if (!value) {
        warnForPart(part, `Unknown highlighting tag ${part}`);
      } else if (typeof value == "function") {
        if (!tag) warnForPart(part, `Modifier ${part} used at start of tag`);else tag = value(tag);
      } else {
        if (tag) warnForPart(part, `Tag ${part} used as modifier`);else tag = value;
      }
    }

    if (!tag) return 0;
    let name = tagStr.replace(/ /g, "_"),
        type = NodeType.define({
      id: typeArray.length,
      name,
      props: [styleTags({
        [name]: tag
      })]
    });
    typeArray.push(type);
    return type.id;
  }

  /**
  An instance of this is passed to completion source functions.
  */

  class CompletionContext {
    /**
    Create a new completion context. (Mostly useful for testing
    completion sources—in the editor, the extension will create
    these for you.)
    */
    constructor(
    /**
    The editor state that the completion happens in.
    */
    state,
    /**
    The position at which the completion is happening.
    */
    pos,
    /**
    Indicates whether completion was activated explicitly, or
    implicitly by typing. The usual way to respond to this is to
    only return completions when either there is part of a
    completable entity before the cursor, or `explicit` is true.
    */
    explicit) {
      this.state = state;
      this.pos = pos;
      this.explicit = explicit;
      /**
      @internal
      */

      this.abortListeners = [];
    }
    /**
    Get the extent, content, and (if there is a token) type of the
    token before `this.pos`.
    */


    tokenBefore(types) {
      let token = syntaxTree(this.state).resolveInner(this.pos, -1);

      while (token && types.indexOf(token.name) < 0) token = token.parent;

      return token ? {
        from: token.from,
        to: this.pos,
        text: this.state.sliceDoc(token.from, this.pos),
        type: token.type
      } : null;
    }
    /**
    Get the match of the given expression directly before the
    cursor.
    */


    matchBefore(expr) {
      let line = this.state.doc.lineAt(this.pos);
      let start = Math.max(line.from, this.pos - 250);
      let str = line.text.slice(start - line.from, this.pos - line.from);
      let found = str.search(ensureAnchor(expr, false));
      return found < 0 ? null : {
        from: start + found,
        to: this.pos,
        text: str.slice(found)
      };
    }
    /**
    Yields true when the query has been aborted. Can be useful in
    asynchronous queries to avoid doing work that will be ignored.
    */


    get aborted() {
      return this.abortListeners == null;
    }
    /**
    Allows you to register abort handlers, which will be called when
    the query is
    [aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted).
    */


    addEventListener(type, listener) {
      if (type == "abort" && this.abortListeners) this.abortListeners.push(listener);
    }

  }

  function toSet(chars) {
    let flat = Object.keys(chars).join("");
    let words = /\w/.test(flat);
    if (words) flat = flat.replace(/\w/g, "");
    return `[${words ? "\\w" : ""}${flat.replace(/[^\w\s]/g, "\\$&")}]`;
  }

  function prefixMatch(options) {
    let first = Object.create(null),
        rest = Object.create(null);

    for (let {
      label
    } of options) {
      first[label[0]] = true;

      for (let i = 1; i < label.length; i++) rest[label[i]] = true;
    }

    let source = toSet(first) + toSet(rest) + "*$";
    return [new RegExp("^" + source), new RegExp(source)];
  }
  /**
  Given a a fixed array of options, return an autocompleter that
  completes them.
  */


  function completeFromList(list) {
    let options = list.map(o => typeof o == "string" ? {
      label: o
    } : o);
    let [validFor, match] = options.every(o => /^\w+$/.test(o.label)) ? [/\w*$/, /\w+$/] : prefixMatch(options);
    return context => {
      let token = context.matchBefore(match);
      return token || context.explicit ? {
        from: token ? token.from : context.pos,
        options,
        validFor
      } : null;
    };
  }

  class Option {
    constructor(completion, source, match) {
      this.completion = completion;
      this.source = source;
      this.match = match;
    }

  }

  function cur(state) {
    return state.selection.main.head;
  } // Make sure the given regexp has a $ at its end and, if `start` is
  // true, a ^ at its start.


  function ensureAnchor(expr, start) {
    var _a;

    let {
      source
    } = expr;
    let addStart = start && source[0] != "^",
        addEnd = source[source.length - 1] != "$";
    if (!addStart && !addEnd) return expr;
    return new RegExp(`${addStart ? "^" : ""}(?:${source})${addEnd ? "$" : ""}`, (_a = expr.flags) !== null && _a !== void 0 ? _a : expr.ignoreCase ? "i" : "");
  }
  /**
  Helper function that returns a transaction spec which inserts a
  completion's text in the main selection range, and any other
  selection range that has the same text in front of it.
  */

  function insertCompletionText(state, text, from, to) {
    return Object.assign(Object.assign({}, state.changeByRange(range => {
      if (range == state.selection.main) return {
        changes: {
          from: from,
          to: to,
          insert: text
        },
        range: EditorSelection.cursor(from + text.length)
      };
      let len = to - from;
      if (!range.empty || len && state.sliceDoc(range.from - len, range.from) != state.sliceDoc(from, to)) return {
        range
      };
      return {
        changes: {
          from: range.from - len,
          to: range.from,
          insert: text
        },
        range: EditorSelection.cursor(range.from - len + text.length)
      };
    })), {
      userEvent: "input.complete"
    });
  }

  function applyCompletion(view, option) {
    const apply = option.completion.apply || option.completion.label;
    let result = option.source;
    if (typeof apply == "string") view.dispatch(insertCompletionText(view.state, apply, result.from, result.to));else apply(view, option.completion, result.from, result.to);
  }

  const SourceCache = /*@__PURE__*/new WeakMap();

  function asSource(source) {
    if (!Array.isArray(source)) return source;
    let known = SourceCache.get(source);
    if (!known) SourceCache.set(source, known = completeFromList(source));
    return known;
  } // A pattern matcher for fuzzy completion matching. Create an instance
  // once for a pattern, and then use that to match any number of
  // completions.


  class FuzzyMatcher {
    constructor(pattern) {
      this.pattern = pattern;
      this.chars = [];
      this.folded = []; // Buffers reused by calls to `match` to track matched character
      // positions.

      this.any = [];
      this.precise = [];
      this.byWord = [];

      for (let p = 0; p < pattern.length;) {
        let char = codePointAt(pattern, p),
            size = codePointSize(char);
        this.chars.push(char);
        let part = pattern.slice(p, p + size),
            upper = part.toUpperCase();
        this.folded.push(codePointAt(upper == part ? part.toLowerCase() : upper, 0));
        p += size;
      }

      this.astral = pattern.length != this.chars.length;
    } // Matches a given word (completion) against the pattern (input).
    // Will return null for no match, and otherwise an array that starts
    // with the match score, followed by any number of `from, to` pairs
    // indicating the matched parts of `word`.
    //
    // The score is a number that is more negative the worse the match
    // is. See `Penalty` above.


    match(word) {
      if (this.pattern.length == 0) return [0];
      if (word.length < this.pattern.length) return null;
      let {
        chars,
        folded,
        any,
        precise,
        byWord
      } = this; // For single-character queries, only match when they occur right
      // at the start

      if (chars.length == 1) {
        let first = codePointAt(word, 0);
        return first == chars[0] ? [0, 0, codePointSize(first)] : first == folded[0] ? [-200
        /* Penalty.CaseFold */
        , 0, codePointSize(first)] : null;
      }

      let direct = word.indexOf(this.pattern);
      if (direct == 0) return [0, 0, this.pattern.length];
      let len = chars.length,
          anyTo = 0;

      if (direct < 0) {
        for (let i = 0, e = Math.min(word.length, 200); i < e && anyTo < len;) {
          let next = codePointAt(word, i);
          if (next == chars[anyTo] || next == folded[anyTo]) any[anyTo++] = i;
          i += codePointSize(next);
        } // No match, exit immediately


        if (anyTo < len) return null;
      } // This tracks the extent of the precise (non-folded, not
      // necessarily adjacent) match


      let preciseTo = 0; // Tracks whether there is a match that hits only characters that
      // appear to be starting words. `byWordFolded` is set to true when
      // a case folded character is encountered in such a match

      let byWordTo = 0,
          byWordFolded = false; // If we've found a partial adjacent match, these track its state

      let adjacentTo = 0,
          adjacentStart = -1,
          adjacentEnd = -1;
      let hasLower = /[a-z]/.test(word),
          wordAdjacent = true; // Go over the option's text, scanning for the various kinds of matches

      for (let i = 0, e = Math.min(word.length, 200), prevType = 0
      /* Tp.NonWord */
      ; i < e && byWordTo < len;) {
        let next = codePointAt(word, i);

        if (direct < 0) {
          if (preciseTo < len && next == chars[preciseTo]) precise[preciseTo++] = i;

          if (adjacentTo < len) {
            if (next == chars[adjacentTo] || next == folded[adjacentTo]) {
              if (adjacentTo == 0) adjacentStart = i;
              adjacentEnd = i + 1;
              adjacentTo++;
            } else {
              adjacentTo = 0;
            }
          }
        }

        let ch,
            type = next < 0xff ? next >= 48 && next <= 57 || next >= 97 && next <= 122 ? 2
        /* Tp.Lower */
        : next >= 65 && next <= 90 ? 1
        /* Tp.Upper */
        : 0
        /* Tp.NonWord */
        : (ch = fromCodePoint(next)) != ch.toLowerCase() ? 1
        /* Tp.Upper */
        : ch != ch.toUpperCase() ? 2
        /* Tp.Lower */
        : 0
        /* Tp.NonWord */
        ;

        if (!i || type == 1
        /* Tp.Upper */
        && hasLower || prevType == 0
        /* Tp.NonWord */
        && type != 0
        /* Tp.NonWord */
        ) {
          if (chars[byWordTo] == next || folded[byWordTo] == next && (byWordFolded = true)) byWord[byWordTo++] = i;else if (byWord.length) wordAdjacent = false;
        }

        prevType = type;
        i += codePointSize(next);
      }

      if (byWordTo == len && byWord[0] == 0 && wordAdjacent) return this.result(-100
      /* Penalty.ByWord */
      + (byWordFolded ? -200
      /* Penalty.CaseFold */
      : 0), byWord, word);
      if (adjacentTo == len && adjacentStart == 0) return [-200
      /* Penalty.CaseFold */
      - word.length, 0, adjacentEnd];
      if (direct > -1) return [-700
      /* Penalty.NotStart */
      - word.length, direct, direct + this.pattern.length];
      if (adjacentTo == len) return [-200
      /* Penalty.CaseFold */
      + -700
      /* Penalty.NotStart */
      - word.length, adjacentStart, adjacentEnd];
      if (byWordTo == len) return this.result(-100
      /* Penalty.ByWord */
      + (byWordFolded ? -200
      /* Penalty.CaseFold */
      : 0) + -700
      /* Penalty.NotStart */
      + (wordAdjacent ? 0 : -1100
      /* Penalty.Gap */
      ), byWord, word);
      return chars.length == 2 ? null : this.result((any[0] ? -700
      /* Penalty.NotStart */
      : 0) + -200
      /* Penalty.CaseFold */
      + -1100
      /* Penalty.Gap */
      , any, word);
    }

    result(score, positions, word) {
      let result = [score - word.length],
          i = 1;

      for (let pos of positions) {
        let to = pos + (this.astral ? codePointSize(codePointAt(word, pos)) : 1);
        if (i > 1 && result[i - 1] == pos) result[i - 1] = to;else {
          result[i++] = pos;
          result[i++] = to;
        }
      }

      return result;
    }

  }

  const completionConfig = /*@__PURE__*/Facet.define({
    combine(configs) {
      return combineConfig(configs, {
        activateOnTyping: true,
        selectOnOpen: true,
        override: null,
        closeOnBlur: true,
        maxRenderedOptions: 100,
        defaultKeymap: true,
        optionClass: () => "",
        aboveCursor: false,
        icons: true,
        addToOptions: [],
        compareCompletions: (a, b) => a.label.localeCompare(b.label),
        interactionDelay: 75
      }, {
        defaultKeymap: (a, b) => a && b,
        closeOnBlur: (a, b) => a && b,
        icons: (a, b) => a && b,
        optionClass: (a, b) => c => joinClass(a(c), b(c)),
        addToOptions: (a, b) => a.concat(b)
      });
    }

  });

  function joinClass(a, b) {
    return a ? b ? a + " " + b : a : b;
  }

  function optionContent(config) {
    let content = config.addToOptions.slice();
    if (config.icons) content.push({
      render(completion) {
        let icon = document.createElement("div");
        icon.classList.add("cm-completionIcon");
        if (completion.type) icon.classList.add(...completion.type.split(/\s+/g).map(cls => "cm-completionIcon-" + cls));
        icon.setAttribute("aria-hidden", "true");
        return icon;
      },

      position: 20
    });
    content.push({
      render(completion, _s, match) {
        let labelElt = document.createElement("span");
        labelElt.className = "cm-completionLabel";
        let {
          label
        } = completion,
            off = 0;

        for (let j = 1; j < match.length;) {
          let from = match[j++],
              to = match[j++];
          if (from > off) labelElt.appendChild(document.createTextNode(label.slice(off, from)));
          let span = labelElt.appendChild(document.createElement("span"));
          span.appendChild(document.createTextNode(label.slice(from, to)));
          span.className = "cm-completionMatchedText";
          off = to;
        }

        if (off < label.length) labelElt.appendChild(document.createTextNode(label.slice(off)));
        return labelElt;
      },

      position: 50
    }, {
      render(completion) {
        if (!completion.detail) return null;
        let detailElt = document.createElement("span");
        detailElt.className = "cm-completionDetail";
        detailElt.textContent = completion.detail;
        return detailElt;
      },

      position: 80
    });
    return content.sort((a, b) => a.position - b.position).map(a => a.render);
  }

  function rangeAroundSelected(total, selected, max) {
    if (total <= max) return {
      from: 0,
      to: total
    };
    if (selected < 0) selected = 0;

    if (selected <= total >> 1) {
      let off = Math.floor(selected / max);
      return {
        from: off * max,
        to: (off + 1) * max
      };
    }

    let off = Math.floor((total - selected) / max);
    return {
      from: total - (off + 1) * max,
      to: total - off * max
    };
  }

  class CompletionTooltip {
    constructor(view, stateField) {
      this.view = view;
      this.stateField = stateField;
      this.info = null;
      this.placeInfo = {
        read: () => this.measureInfo(),
        write: pos => this.positionInfo(pos),
        key: this
      };
      let cState = view.state.field(stateField);
      let {
        options,
        selected
      } = cState.open;
      let config = view.state.facet(completionConfig);
      this.optionContent = optionContent(config);
      this.optionClass = config.optionClass;
      this.range = rangeAroundSelected(options.length, selected, config.maxRenderedOptions);
      this.dom = document.createElement("div");
      this.dom.className = "cm-tooltip-autocomplete";
      this.dom.addEventListener("mousedown", e => {
        for (let dom = e.target, match; dom && dom != this.dom; dom = dom.parentNode) {
          if (dom.nodeName == "LI" && (match = /-(\d+)$/.exec(dom.id)) && +match[1] < options.length) {
            applyCompletion(view, options[+match[1]]);
            e.preventDefault();
            return;
          }
        }
      });
      this.list = this.dom.appendChild(this.createListBox(options, cState.id, this.range));
      this.list.addEventListener("scroll", () => {
        if (this.info) this.view.requestMeasure(this.placeInfo);
      });
    }

    mount() {
      this.updateSel();
    }

    update(update) {
      if (update.state.field(this.stateField) != update.startState.field(this.stateField)) this.updateSel();
    }

    positioned() {
      if (this.info) this.view.requestMeasure(this.placeInfo);
    }

    updateSel() {
      let cState = this.view.state.field(this.stateField),
          open = cState.open;

      if (open.selected > -1 && open.selected < this.range.from || open.selected >= this.range.to) {
        this.range = rangeAroundSelected(open.options.length, open.selected, this.view.state.facet(completionConfig).maxRenderedOptions);
        this.list.remove();
        this.list = this.dom.appendChild(this.createListBox(open.options, cState.id, this.range));
        this.list.addEventListener("scroll", () => {
          if (this.info) this.view.requestMeasure(this.placeInfo);
        });
      }

      if (this.updateSelectedOption(open.selected)) {
        if (this.info) {
          this.info.remove();
          this.info = null;
        }

        let {
          completion
        } = open.options[open.selected];
        let {
          info
        } = completion;
        if (!info) return;
        let infoResult = typeof info === 'string' ? document.createTextNode(info) : info(completion);
        if (!infoResult) return;

        if ('then' in infoResult) {
          infoResult.then(node => {
            if (node && this.view.state.field(this.stateField, false) == cState) this.addInfoPane(node);
          }).catch(e => logException(this.view.state, e, "completion info"));
        } else {
          this.addInfoPane(infoResult);
        }
      }
    }

    addInfoPane(content) {
      let dom = this.info = document.createElement("div");
      dom.className = "cm-tooltip cm-completionInfo";
      dom.appendChild(content);
      this.dom.appendChild(dom);
      this.view.requestMeasure(this.placeInfo);
    }

    updateSelectedOption(selected) {
      let set = null;

      for (let opt = this.list.firstChild, i = this.range.from; opt; opt = opt.nextSibling, i++) {
        if (i == selected) {
          if (!opt.hasAttribute("aria-selected")) {
            opt.setAttribute("aria-selected", "true");
            set = opt;
          }
        } else {
          if (opt.hasAttribute("aria-selected")) opt.removeAttribute("aria-selected");
        }
      }

      if (set) scrollIntoView(this.list, set);
      return set;
    }

    measureInfo() {
      let sel = this.dom.querySelector("[aria-selected]");
      if (!sel || !this.info) return null;
      let win = this.dom.ownerDocument.defaultView || window;
      let listRect = this.dom.getBoundingClientRect();
      let infoRect = this.info.getBoundingClientRect();
      let selRect = sel.getBoundingClientRect();
      if (selRect.top > Math.min(win.innerHeight, listRect.bottom) - 10 || selRect.bottom < Math.max(0, listRect.top) + 10) return null;
      let rtl = this.view.textDirection == Direction.RTL,
          left = rtl,
          narrow = false,
          maxWidth;
      let top = "",
          bottom = "";
      let spaceLeft = listRect.left,
          spaceRight = win.innerWidth - listRect.right;
      if (left && spaceLeft < Math.min(infoRect.width, spaceRight)) left = false;else if (!left && spaceRight < Math.min(infoRect.width, spaceLeft)) left = true;

      if (infoRect.width <= (left ? spaceLeft : spaceRight)) {
        top = Math.max(0, Math.min(selRect.top, win.innerHeight - infoRect.height)) - listRect.top + "px";
        maxWidth = Math.min(400
        /* Info.Width */
        , left ? spaceLeft : spaceRight) + "px";
      } else {
        narrow = true;
        maxWidth = Math.min(400
        /* Info.Width */
        , (rtl ? listRect.right : win.innerWidth - listRect.left) - 30
        /* Info.Margin */
        ) + "px";
        let spaceBelow = win.innerHeight - listRect.bottom;
        if (spaceBelow >= infoRect.height || spaceBelow > listRect.top) // Below the completion
          top = selRect.bottom - listRect.top + "px";else // Above it
          bottom = listRect.bottom - selRect.top + "px";
      }

      return {
        top,
        bottom,
        maxWidth,
        class: narrow ? rtl ? "left-narrow" : "right-narrow" : left ? "left" : "right"
      };
    }

    positionInfo(pos) {
      if (this.info) {
        if (pos) {
          this.info.style.top = pos.top;
          this.info.style.bottom = pos.bottom;
          this.info.style.maxWidth = pos.maxWidth;
          this.info.className = "cm-tooltip cm-completionInfo cm-completionInfo-" + pos.class;
        } else {
          this.info.style.top = "-1e6px";
        }
      }
    }

    createListBox(options, id, range) {
      const ul = document.createElement("ul");
      ul.id = id;
      ul.setAttribute("role", "listbox");
      ul.setAttribute("aria-expanded", "true");
      ul.setAttribute("aria-label", this.view.state.phrase("Completions"));

      for (let i = range.from; i < range.to; i++) {
        let {
          completion,
          match
        } = options[i];
        const li = ul.appendChild(document.createElement("li"));
        li.id = id + "-" + i;
        li.setAttribute("role", "option");
        let cls = this.optionClass(completion);
        if (cls) li.className = cls;

        for (let source of this.optionContent) {
          let node = source(completion, this.view.state, match);
          if (node) li.appendChild(node);
        }
      }

      if (range.from) ul.classList.add("cm-completionListIncompleteTop");
      if (range.to < options.length) ul.classList.add("cm-completionListIncompleteBottom");
      return ul;
    }

  } // We allocate a new function instance every time the completion
  // changes to force redrawing/repositioning of the tooltip


  function completionTooltip(stateField) {
    return view => new CompletionTooltip(view, stateField);
  }

  function scrollIntoView(container, element) {
    let parent = container.getBoundingClientRect();
    let self = element.getBoundingClientRect();
    if (self.top < parent.top) container.scrollTop -= parent.top - self.top;else if (self.bottom > parent.bottom) container.scrollTop += self.bottom - parent.bottom;
  } // Used to pick a preferred option when two options with the same
  // label occur in the result.


  function score(option) {
    return (option.boost || 0) * 100 + (option.apply ? 10 : 0) + (option.info ? 5 : 0) + (option.type ? 1 : 0);
  }

  function sortOptions(active, state) {
    let options = [],
        i = 0;

    for (let a of active) if (a.hasResult()) {
      if (a.result.filter === false) {
        let getMatch = a.result.getMatch;

        for (let option of a.result.options) {
          let match = [1e9 - i++];
          if (getMatch) for (let n of getMatch(option)) match.push(n);
          options.push(new Option(option, a, match));
        }
      } else {
        let matcher = new FuzzyMatcher(state.sliceDoc(a.from, a.to)),
            match;

        for (let option of a.result.options) if (match = matcher.match(option.label)) {
          if (option.boost != null) match[0] += option.boost;
          options.push(new Option(option, a, match));
        }
      }
    }

    let result = [],
        prev = null;
    let compare = state.facet(completionConfig).compareCompletions;

    for (let opt of options.sort((a, b) => b.match[0] - a.match[0] || compare(a.completion, b.completion))) {
      if (!prev || prev.label != opt.completion.label || prev.detail != opt.completion.detail || prev.type != null && opt.completion.type != null && prev.type != opt.completion.type || prev.apply != opt.completion.apply) result.push(opt);else if (score(opt.completion) > score(prev)) result[result.length - 1] = opt;
      prev = opt.completion;
    }

    return result;
  }

  class CompletionDialog {
    constructor(options, attrs, tooltip, timestamp, selected) {
      this.options = options;
      this.attrs = attrs;
      this.tooltip = tooltip;
      this.timestamp = timestamp;
      this.selected = selected;
    }

    setSelected(selected, id) {
      return selected == this.selected || selected >= this.options.length ? this : new CompletionDialog(this.options, makeAttrs(id, selected), this.tooltip, this.timestamp, selected);
    }

    static build(active, state, id, prev, conf) {
      let options = sortOptions(active, state);
      if (!options.length) return null;
      let selected = state.facet(completionConfig).selectOnOpen ? 0 : -1;

      if (prev && prev.selected != selected && prev.selected != -1) {
        let selectedValue = prev.options[prev.selected].completion;

        for (let i = 0; i < options.length; i++) if (options[i].completion == selectedValue) {
          selected = i;
          break;
        }
      }

      return new CompletionDialog(options, makeAttrs(id, selected), {
        pos: active.reduce((a, b) => b.hasResult() ? Math.min(a, b.from) : a, 1e8),
        create: completionTooltip(completionState),
        above: conf.aboveCursor
      }, prev ? prev.timestamp : Date.now(), selected);
    }

    map(changes) {
      return new CompletionDialog(this.options, this.attrs, Object.assign(Object.assign({}, this.tooltip), {
        pos: changes.mapPos(this.tooltip.pos)
      }), this.timestamp, this.selected);
    }

  }

  class CompletionState {
    constructor(active, id, open) {
      this.active = active;
      this.id = id;
      this.open = open;
    }

    static start() {
      return new CompletionState(none, "cm-ac-" + Math.floor(Math.random() * 2e6).toString(36), null);
    }

    update(tr) {
      let {
        state
      } = tr,
          conf = state.facet(completionConfig);
      let sources = conf.override || state.languageDataAt("autocomplete", cur(state)).map(asSource);
      let active = sources.map(source => {
        let value = this.active.find(s => s.source == source) || new ActiveSource(source, this.active.some(a => a.state != 0
        /* State.Inactive */
        ) ? 1
        /* State.Pending */
        : 0
        /* State.Inactive */
        );
        return value.update(tr, conf);
      });
      if (active.length == this.active.length && active.every((a, i) => a == this.active[i])) active = this.active;
      let open = tr.selection || active.some(a => a.hasResult() && tr.changes.touchesRange(a.from, a.to)) || !sameResults(active, this.active) ? CompletionDialog.build(active, state, this.id, this.open, conf) : this.open && tr.docChanged ? this.open.map(tr.changes) : this.open;
      if (!open && active.every(a => a.state != 1
      /* State.Pending */
      ) && active.some(a => a.hasResult())) active = active.map(a => a.hasResult() ? new ActiveSource(a.source, 0
      /* State.Inactive */
      ) : a);

      for (let effect of tr.effects) if (effect.is(setSelectedEffect)) open = open && open.setSelected(effect.value, this.id);

      return active == this.active && open == this.open ? this : new CompletionState(active, this.id, open);
    }

    get tooltip() {
      return this.open ? this.open.tooltip : null;
    }

    get attrs() {
      return this.open ? this.open.attrs : baseAttrs;
    }

  }

  function sameResults(a, b) {
    if (a == b) return true;

    for (let iA = 0, iB = 0;;) {
      while (iA < a.length && !a[iA].hasResult) iA++;

      while (iB < b.length && !b[iB].hasResult) iB++;

      let endA = iA == a.length,
          endB = iB == b.length;
      if (endA || endB) return endA == endB;
      if (a[iA++].result != b[iB++].result) return false;
    }
  }

  const baseAttrs = {
    "aria-autocomplete": "list"
  };

  function makeAttrs(id, selected) {
    let result = {
      "aria-autocomplete": "list",
      "aria-haspopup": "listbox",
      "aria-controls": id
    };
    if (selected > -1) result["aria-activedescendant"] = id + "-" + selected;
    return result;
  }

  const none = [];

  function getUserEvent(tr) {
    return tr.isUserEvent("input.type") ? "input" : tr.isUserEvent("delete.backward") ? "delete" : null;
  }

  class ActiveSource {
    constructor(source, state, explicitPos = -1) {
      this.source = source;
      this.state = state;
      this.explicitPos = explicitPos;
    }

    hasResult() {
      return false;
    }

    update(tr, conf) {
      let event = getUserEvent(tr),
          value = this;
      if (event) value = value.handleUserEvent(tr, event, conf);else if (tr.docChanged) value = value.handleChange(tr);else if (tr.selection && value.state != 0
      /* State.Inactive */
      ) value = new ActiveSource(value.source, 0
      /* State.Inactive */
      );

      for (let effect of tr.effects) {
        if (effect.is(startCompletionEffect)) value = new ActiveSource(value.source, 1
        /* State.Pending */
        , effect.value ? cur(tr.state) : -1);else if (effect.is(closeCompletionEffect)) value = new ActiveSource(value.source, 0
        /* State.Inactive */
        );else if (effect.is(setActiveEffect)) for (let active of effect.value) if (active.source == value.source) value = active;
      }

      return value;
    }

    handleUserEvent(tr, type, conf) {
      return type == "delete" || !conf.activateOnTyping ? this.map(tr.changes) : new ActiveSource(this.source, 1
      /* State.Pending */
      );
    }

    handleChange(tr) {
      return tr.changes.touchesRange(cur(tr.startState)) ? new ActiveSource(this.source, 0
      /* State.Inactive */
      ) : this.map(tr.changes);
    }

    map(changes) {
      return changes.empty || this.explicitPos < 0 ? this : new ActiveSource(this.source, this.state, changes.mapPos(this.explicitPos));
    }

  }

  class ActiveResult extends ActiveSource {
    constructor(source, explicitPos, result, from, to) {
      super(source, 2
      /* State.Result */
      , explicitPos);
      this.result = result;
      this.from = from;
      this.to = to;
    }

    hasResult() {
      return true;
    }

    handleUserEvent(tr, type, conf) {
      var _a;

      let from = tr.changes.mapPos(this.from),
          to = tr.changes.mapPos(this.to, 1);
      let pos = cur(tr.state);
      if ((this.explicitPos < 0 ? pos <= from : pos < this.from) || pos > to || type == "delete" && cur(tr.startState) == this.from) return new ActiveSource(this.source, type == "input" && conf.activateOnTyping ? 1
      /* State.Pending */
      : 0
      /* State.Inactive */
      );
      let explicitPos = this.explicitPos < 0 ? -1 : tr.changes.mapPos(this.explicitPos),
          updated;
      if (checkValid(this.result.validFor, tr.state, from, to)) return new ActiveResult(this.source, explicitPos, this.result, from, to);
      if (this.result.update && (updated = this.result.update(this.result, from, to, new CompletionContext(tr.state, pos, explicitPos >= 0)))) return new ActiveResult(this.source, explicitPos, updated, updated.from, (_a = updated.to) !== null && _a !== void 0 ? _a : cur(tr.state));
      return new ActiveSource(this.source, 1
      /* State.Pending */
      , explicitPos);
    }

    handleChange(tr) {
      return tr.changes.touchesRange(this.from, this.to) ? new ActiveSource(this.source, 0
      /* State.Inactive */
      ) : this.map(tr.changes);
    }

    map(mapping) {
      return mapping.empty ? this : new ActiveResult(this.source, this.explicitPos < 0 ? -1 : mapping.mapPos(this.explicitPos), this.result, mapping.mapPos(this.from), mapping.mapPos(this.to, 1));
    }

  }

  function checkValid(validFor, state, from, to) {
    if (!validFor) return false;
    let text = state.sliceDoc(from, to);
    return typeof validFor == "function" ? validFor(text, from, to, state) : ensureAnchor(validFor, true).test(text);
  }

  const startCompletionEffect = /*@__PURE__*/StateEffect.define();
  const closeCompletionEffect = /*@__PURE__*/StateEffect.define();
  const setActiveEffect = /*@__PURE__*/StateEffect.define({
    map(sources, mapping) {
      return sources.map(s => s.map(mapping));
    }

  });
  const setSelectedEffect = /*@__PURE__*/StateEffect.define();
  const completionState = /*@__PURE__*/StateField.define({
    create() {
      return CompletionState.start();
    },

    update(value, tr) {
      return value.update(tr);
    },

    provide: f => [showTooltip.from(f, val => val.tooltip), EditorView.contentAttributes.from(f, state => state.attrs)]
  });
  /**
  Returns a command that moves the completion selection forward or
  backward by the given amount.
  */

  function moveCompletionSelection(forward, by = "option") {
    return view => {
      let cState = view.state.field(completionState, false);
      if (!cState || !cState.open || Date.now() - cState.open.timestamp < view.state.facet(completionConfig).interactionDelay) return false;
      let step = 1,
          tooltip;
      if (by == "page" && (tooltip = getTooltip(view, cState.open.tooltip))) step = Math.max(2, Math.floor(tooltip.dom.offsetHeight / tooltip.dom.querySelector("li").offsetHeight) - 1);
      let {
        length
      } = cState.open.options;
      let selected = cState.open.selected > -1 ? cState.open.selected + step * (forward ? 1 : -1) : forward ? 0 : length - 1;
      if (selected < 0) selected = by == "page" ? 0 : length - 1;else if (selected >= length) selected = by == "page" ? length - 1 : 0;
      view.dispatch({
        effects: setSelectedEffect.of(selected)
      });
      return true;
    };
  }
  /**
  Accept the current completion.
  */


  const acceptCompletion = view => {
    let cState = view.state.field(completionState, false);
    if (view.state.readOnly || !cState || !cState.open || cState.open.selected < 0 || Date.now() - cState.open.timestamp < view.state.facet(completionConfig).interactionDelay) return false;
    applyCompletion(view, cState.open.options[cState.open.selected]);
    return true;
  };
  /**
  Explicitly start autocompletion.
  */


  const startCompletion = view => {
    let cState = view.state.field(completionState, false);
    if (!cState) return false;
    view.dispatch({
      effects: startCompletionEffect.of(true)
    });
    return true;
  };
  /**
  Close the currently active completion.
  */


  const closeCompletion = view => {
    let cState = view.state.field(completionState, false);
    if (!cState || !cState.active.some(a => a.state != 0
    /* State.Inactive */
    )) return false;
    view.dispatch({
      effects: closeCompletionEffect.of(null)
    });
    return true;
  };

  class RunningQuery {
    constructor(active, context) {
      this.active = active;
      this.context = context;
      this.time = Date.now();
      this.updates = []; // Note that 'undefined' means 'not done yet', whereas 'null' means
      // 'query returned null'.

      this.done = undefined;
    }

  }

  const DebounceTime = 50,
        MaxUpdateCount = 50,
        MinAbortTime = 1000;
  const completionPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
    constructor(view) {
      this.view = view;
      this.debounceUpdate = -1;
      this.running = [];
      this.debounceAccept = -1;
      this.composing = 0
      /* CompositionState.None */
      ;

      for (let active of view.state.field(completionState).active) if (active.state == 1
      /* State.Pending */
      ) this.startQuery(active);
    }

    update(update) {
      let cState = update.state.field(completionState);
      if (!update.selectionSet && !update.docChanged && update.startState.field(completionState) == cState) return;
      let doesReset = update.transactions.some(tr => {
        return (tr.selection || tr.docChanged) && !getUserEvent(tr);
      });

      for (let i = 0; i < this.running.length; i++) {
        let query = this.running[i];

        if (doesReset || query.updates.length + update.transactions.length > MaxUpdateCount && Date.now() - query.time > MinAbortTime) {
          for (let handler of query.context.abortListeners) {
            try {
              handler();
            } catch (e) {
              logException(this.view.state, e);
            }
          }

          query.context.abortListeners = null;
          this.running.splice(i--, 1);
        } else {
          query.updates.push(...update.transactions);
        }
      }

      if (this.debounceUpdate > -1) clearTimeout(this.debounceUpdate);
      this.debounceUpdate = cState.active.some(a => a.state == 1
      /* State.Pending */
      && !this.running.some(q => q.active.source == a.source)) ? setTimeout(() => this.startUpdate(), DebounceTime) : -1;
      if (this.composing != 0
      /* CompositionState.None */
      ) for (let tr of update.transactions) {
        if (getUserEvent(tr) == "input") this.composing = 2
        /* CompositionState.Changed */
        ;else if (this.composing == 2
        /* CompositionState.Changed */
        && tr.selection) this.composing = 3
        /* CompositionState.ChangedAndMoved */
        ;
      }
    }

    startUpdate() {
      this.debounceUpdate = -1;
      let {
        state
      } = this.view,
          cState = state.field(completionState);

      for (let active of cState.active) {
        if (active.state == 1
        /* State.Pending */
        && !this.running.some(r => r.active.source == active.source)) this.startQuery(active);
      }
    }

    startQuery(active) {
      let {
        state
      } = this.view,
          pos = cur(state);
      let context = new CompletionContext(state, pos, active.explicitPos == pos);
      let pending = new RunningQuery(active, context);
      this.running.push(pending);
      Promise.resolve(active.source(context)).then(result => {
        if (!pending.context.aborted) {
          pending.done = result || null;
          this.scheduleAccept();
        }
      }, err => {
        this.view.dispatch({
          effects: closeCompletionEffect.of(null)
        });
        logException(this.view.state, err);
      });
    }

    scheduleAccept() {
      if (this.running.every(q => q.done !== undefined)) this.accept();else if (this.debounceAccept < 0) this.debounceAccept = setTimeout(() => this.accept(), DebounceTime);
    } // For each finished query in this.running, try to create a result
    // or, if appropriate, restart the query.


    accept() {
      var _a;

      if (this.debounceAccept > -1) clearTimeout(this.debounceAccept);
      this.debounceAccept = -1;
      let updated = [];
      let conf = this.view.state.facet(completionConfig);

      for (let i = 0; i < this.running.length; i++) {
        let query = this.running[i];
        if (query.done === undefined) continue;
        this.running.splice(i--, 1);

        if (query.done) {
          let active = new ActiveResult(query.active.source, query.active.explicitPos, query.done, query.done.from, (_a = query.done.to) !== null && _a !== void 0 ? _a : cur(query.updates.length ? query.updates[0].startState : this.view.state)); // Replay the transactions that happened since the start of
          // the request and see if that preserves the result

          for (let tr of query.updates) active = active.update(tr, conf);

          if (active.hasResult()) {
            updated.push(active);
            continue;
          }
        }

        let current = this.view.state.field(completionState).active.find(a => a.source == query.active.source);

        if (current && current.state == 1
        /* State.Pending */
        ) {
          if (query.done == null) {
            // Explicitly failed. Should clear the pending status if it
            // hasn't been re-set in the meantime.
            let active = new ActiveSource(query.active.source, 0
            /* State.Inactive */
            );

            for (let tr of query.updates) active = active.update(tr, conf);

            if (active.state != 1
            /* State.Pending */
            ) updated.push(active);
          } else {
            // Cleared by subsequent transactions. Restart.
            this.startQuery(current);
          }
        }
      }

      if (updated.length) this.view.dispatch({
        effects: setActiveEffect.of(updated)
      });
    }

  }, {
    eventHandlers: {
      blur() {
        let state = this.view.state.field(completionState, false);
        if (state && state.tooltip && this.view.state.facet(completionConfig).closeOnBlur) this.view.dispatch({
          effects: closeCompletionEffect.of(null)
        });
      },

      compositionstart() {
        this.composing = 1
        /* CompositionState.Started */
        ;
      },

      compositionend() {
        if (this.composing == 3
        /* CompositionState.ChangedAndMoved */
        ) {
          // Safari fires compositionend events synchronously, possibly
          // from inside an update, so dispatch asynchronously to avoid reentrancy
          setTimeout(() => this.view.dispatch({
            effects: startCompletionEffect.of(false)
          }), 20);
        }

        this.composing = 0
        /* CompositionState.None */
        ;
      }

    }
  });
  const baseTheme$2 = /*@__PURE__*/EditorView.baseTheme({
    ".cm-tooltip.cm-tooltip-autocomplete": {
      "& > ul": {
        fontFamily: "monospace",
        whiteSpace: "nowrap",
        overflow: "hidden auto",
        maxWidth_fallback: "700px",
        maxWidth: "min(700px, 95vw)",
        minWidth: "250px",
        maxHeight: "10em",
        listStyle: "none",
        margin: 0,
        padding: 0,
        "& > li": {
          overflowX: "hidden",
          textOverflow: "ellipsis",
          cursor: "pointer",
          padding: "1px 3px",
          lineHeight: 1.2
        }
      }
    },
    "&light .cm-tooltip-autocomplete ul li[aria-selected]": {
      background: "#17c",
      color: "white"
    },
    "&dark .cm-tooltip-autocomplete ul li[aria-selected]": {
      background: "#347",
      color: "white"
    },
    ".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after": {
      content: '"···"',
      opacity: 0.5,
      display: "block",
      textAlign: "center"
    },
    ".cm-tooltip.cm-completionInfo": {
      position: "absolute",
      padding: "3px 9px",
      width: "max-content",
      maxWidth: `${400
    /* Info.Width */
    }px`,
      boxSizing: "border-box"
    },
    ".cm-completionInfo.cm-completionInfo-left": {
      right: "100%"
    },
    ".cm-completionInfo.cm-completionInfo-right": {
      left: "100%"
    },
    ".cm-completionInfo.cm-completionInfo-left-narrow": {
      right: `${30
    /* Info.Margin */
    }px`
    },
    ".cm-completionInfo.cm-completionInfo-right-narrow": {
      left: `${30
    /* Info.Margin */
    }px`
    },
    "&light .cm-snippetField": {
      backgroundColor: "#00000022"
    },
    "&dark .cm-snippetField": {
      backgroundColor: "#ffffff22"
    },
    ".cm-snippetFieldPosition": {
      verticalAlign: "text-top",
      width: 0,
      height: "1.15em",
      display: "inline-block",
      margin: "0 -0.7px -.7em",
      borderLeft: "1.4px dotted #888"
    },
    ".cm-completionMatchedText": {
      textDecoration: "underline"
    },
    ".cm-completionDetail": {
      marginLeft: "0.5em",
      fontStyle: "italic"
    },
    ".cm-completionIcon": {
      fontSize: "90%",
      width: ".8em",
      display: "inline-block",
      textAlign: "center",
      paddingRight: ".6em",
      opacity: "0.6"
    },
    ".cm-completionIcon-function, .cm-completionIcon-method": {
      "&:after": {
        content: "'ƒ'"
      }
    },
    ".cm-completionIcon-class": {
      "&:after": {
        content: "'○'"
      }
    },
    ".cm-completionIcon-interface": {
      "&:after": {
        content: "'◌'"
      }
    },
    ".cm-completionIcon-variable": {
      "&:after": {
        content: "'𝑥'"
      }
    },
    ".cm-completionIcon-constant": {
      "&:after": {
        content: "'𝐶'"
      }
    },
    ".cm-completionIcon-type": {
      "&:after": {
        content: "'𝑡'"
      }
    },
    ".cm-completionIcon-enum": {
      "&:after": {
        content: "'∪'"
      }
    },
    ".cm-completionIcon-property": {
      "&:after": {
        content: "'□'"
      }
    },
    ".cm-completionIcon-keyword": {
      "&:after": {
        content: "'🔑\uFE0E'"
      } // Disable emoji rendering

    },
    ".cm-completionIcon-namespace": {
      "&:after": {
        content: "'▢'"
      }
    },
    ".cm-completionIcon-text": {
      "&:after": {
        content: "'abc'",
        fontSize: "50%",
        verticalAlign: "middle"
      }
    }
  });

  class FieldPos {
    constructor(field, line, from, to) {
      this.field = field;
      this.line = line;
      this.from = from;
      this.to = to;
    }

  }

  class FieldRange {
    constructor(field, from, to) {
      this.field = field;
      this.from = from;
      this.to = to;
    }

    map(changes) {
      let from = changes.mapPos(this.from, -1, MapMode.TrackDel);
      let to = changes.mapPos(this.to, 1, MapMode.TrackDel);
      return from == null || to == null ? null : new FieldRange(this.field, from, to);
    }

  }

  class Snippet {
    constructor(lines, fieldPositions) {
      this.lines = lines;
      this.fieldPositions = fieldPositions;
    }

    instantiate(state, pos) {
      let text = [],
          lineStart = [pos];
      let lineObj = state.doc.lineAt(pos),
          baseIndent = /^\s*/.exec(lineObj.text)[0];

      for (let line of this.lines) {
        if (text.length) {
          let indent = baseIndent,
              tabs = /^\t*/.exec(line)[0].length;

          for (let i = 0; i < tabs; i++) indent += state.facet(indentUnit);

          lineStart.push(pos + indent.length - tabs);
          line = indent + line.slice(tabs);
        }

        text.push(line);
        pos += line.length + 1;
      }

      let ranges = this.fieldPositions.map(pos => new FieldRange(pos.field, lineStart[pos.line] + pos.from, lineStart[pos.line] + pos.to));
      return {
        text,
        ranges
      };
    }

    static parse(template) {
      let fields = [];
      let lines = [],
          positions = [],
          m;

      for (let line of template.split(/\r\n?|\n/)) {
        while (m = /[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(line)) {
          let seq = m[1] ? +m[1] : null,
              name = m[2] || m[3] || "",
              found = -1;

          for (let i = 0; i < fields.length; i++) {
            if (seq != null ? fields[i].seq == seq : name ? fields[i].name == name : false) found = i;
          }

          if (found < 0) {
            let i = 0;

            while (i < fields.length && (seq == null || fields[i].seq != null && fields[i].seq < seq)) i++;

            fields.splice(i, 0, {
              seq,
              name
            });
            found = i;

            for (let pos of positions) if (pos.field >= found) pos.field++;
          }

          positions.push(new FieldPos(found, lines.length, m.index, m.index + name.length));
          line = line.slice(0, m.index) + name + line.slice(m.index + m[0].length);
        }

        for (let esc; esc = /([$#])\\{/.exec(line);) {
          line = line.slice(0, esc.index) + esc[1] + "{" + line.slice(esc.index + esc[0].length);

          for (let pos of positions) if (pos.line == lines.length && pos.from > esc.index) {
            pos.from--;
            pos.to--;
          }
        }

        lines.push(line);
      }

      return new Snippet(lines, positions);
    }

  }

  let fieldMarker = /*@__PURE__*/Decoration.widget({
    widget: /*@__PURE__*/new class extends WidgetType {
      toDOM() {
        let span = document.createElement("span");
        span.className = "cm-snippetFieldPosition";
        return span;
      }

      ignoreEvent() {
        return false;
      }

    }()
  });
  let fieldRange = /*@__PURE__*/Decoration.mark({
    class: "cm-snippetField"
  });

  class ActiveSnippet {
    constructor(ranges, active) {
      this.ranges = ranges;
      this.active = active;
      this.deco = Decoration.set(ranges.map(r => (r.from == r.to ? fieldMarker : fieldRange).range(r.from, r.to)));
    }

    map(changes) {
      let ranges = [];

      for (let r of this.ranges) {
        let mapped = r.map(changes);
        if (!mapped) return null;
        ranges.push(mapped);
      }

      return new ActiveSnippet(ranges, this.active);
    }

    selectionInsideField(sel) {
      return sel.ranges.every(range => this.ranges.some(r => r.field == this.active && r.from <= range.from && r.to >= range.to));
    }

  }

  const setActive = /*@__PURE__*/StateEffect.define({
    map(value, changes) {
      return value && value.map(changes);
    }

  });
  const moveToField = /*@__PURE__*/StateEffect.define();
  const snippetState = /*@__PURE__*/StateField.define({
    create() {
      return null;
    },

    update(value, tr) {
      for (let effect of tr.effects) {
        if (effect.is(setActive)) return effect.value;
        if (effect.is(moveToField) && value) return new ActiveSnippet(value.ranges, effect.value);
      }

      if (value && tr.docChanged) value = value.map(tr.changes);
      if (value && tr.selection && !value.selectionInsideField(tr.selection)) value = null;
      return value;
    },

    provide: f => EditorView.decorations.from(f, val => val ? val.deco : Decoration.none)
  });

  function fieldSelection(ranges, field) {
    return EditorSelection.create(ranges.filter(r => r.field == field).map(r => EditorSelection.range(r.from, r.to)));
  }
  /**
  Convert a snippet template to a function that can
  [apply](https://codemirror.net/6/docs/ref/#autocomplete.Completion.apply) it. Snippets are written
  using syntax like this:

      "for (let ${index} = 0; ${index} < ${end}; ${index}++) {\n\t${}\n}"

  Each `${}` placeholder (you may also use `#{}`) indicates a field
  that the user can fill in. Its name, if any, will be the default
  content for the field.

  When the snippet is activated by calling the returned function,
  the code is inserted at the given position. Newlines in the
  template are indented by the indentation of the start line, plus
  one [indent unit](https://codemirror.net/6/docs/ref/#language.indentUnit) per tab character after
  the newline.

  On activation, (all instances of) the first field are selected.
  The user can move between fields with Tab and Shift-Tab as long as
  the fields are active. Moving to the last field or moving the
  cursor out of the current field deactivates the fields.

  The order of fields defaults to textual order, but you can add
  numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
  a custom order.

  To include a literal `${` or `#{` in your template, put a
  backslash after the dollar or hash and before the brace (`$\\{`).
  This will be removed and the sequence will not be interpreted as a
  placeholder.
  */


  function snippet(template) {
    let snippet = Snippet.parse(template);
    return (editor, _completion, from, to) => {
      let {
        text,
        ranges
      } = snippet.instantiate(editor.state, from);
      let spec = {
        changes: {
          from,
          to,
          insert: Text.of(text)
        },
        scrollIntoView: true
      };
      if (ranges.length) spec.selection = fieldSelection(ranges, 0);

      if (ranges.length > 1) {
        let active = new ActiveSnippet(ranges, 0);
        let effects = spec.effects = [setActive.of(active)];
        if (editor.state.field(snippetState, false) === undefined) effects.push(StateEffect.appendConfig.of([snippetState, addSnippetKeymap, snippetPointerHandler, baseTheme$2]));
      }

      editor.dispatch(editor.state.update(spec));
    };
  }

  function moveField(dir) {
    return ({
      state,
      dispatch
    }) => {
      let active = state.field(snippetState, false);
      if (!active || dir < 0 && active.active == 0) return false;
      let next = active.active + dir,
          last = dir > 0 && !active.ranges.some(r => r.field == next + dir);
      dispatch(state.update({
        selection: fieldSelection(active.ranges, next),
        effects: setActive.of(last ? null : new ActiveSnippet(active.ranges, next))
      }));
      return true;
    };
  }
  /**
  A command that clears the active snippet, if any.
  */


  const clearSnippet = ({
    state,
    dispatch
  }) => {
    let active = state.field(snippetState, false);
    if (!active) return false;
    dispatch(state.update({
      effects: setActive.of(null)
    }));
    return true;
  };
  /**
  Move to the next snippet field, if available.
  */


  const nextSnippetField = /*@__PURE__*/moveField(1);
  /**
  Move to the previous snippet field, if available.
  */

  const prevSnippetField = /*@__PURE__*/moveField(-1);
  const defaultSnippetKeymap = [{
    key: "Tab",
    run: nextSnippetField,
    shift: prevSnippetField
  }, {
    key: "Escape",
    run: clearSnippet
  }];
  /**
  A facet that can be used to configure the key bindings used by
  snippets. The default binds Tab to
  [`nextSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.nextSnippetField), Shift-Tab to
  [`prevSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.prevSnippetField), and Escape
  to [`clearSnippet`](https://codemirror.net/6/docs/ref/#autocomplete.clearSnippet).
  */

  const snippetKeymap = /*@__PURE__*/Facet.define({
    combine(maps) {
      return maps.length ? maps[0] : defaultSnippetKeymap;
    }

  });
  const addSnippetKeymap = /*@__PURE__*/Prec.highest( /*@__PURE__*/keymap.compute([snippetKeymap], state => state.facet(snippetKeymap)));
  /**
  Create a completion from a snippet. Returns an object with the
  properties from `completion`, plus an `apply` function that
  applies the snippet.
  */

  function snippetCompletion(template, completion) {
    return Object.assign(Object.assign({}, completion), {
      apply: snippet(template)
    });
  }

  const snippetPointerHandler = /*@__PURE__*/EditorView.domEventHandlers({
    mousedown(event, view) {
      let active = view.state.field(snippetState, false),
          pos;
      if (!active || (pos = view.posAtCoords({
        x: event.clientX,
        y: event.clientY
      })) == null) return false;
      let match = active.ranges.find(r => r.from <= pos && r.to >= pos);
      if (!match || match.field == active.active) return false;
      view.dispatch({
        selection: fieldSelection(active.ranges, match.field),
        effects: setActive.of(active.ranges.some(r => r.field > match.field) ? new ActiveSnippet(active.ranges, match.field) : null)
      });
      return true;
    }

  });

  const defaults = {
    brackets: ["(", "[", "{", "'", '"'],
    before: ")]}:;>",
    stringPrefixes: []
  };
  const closeBracketEffect = /*@__PURE__*/StateEffect.define({
    map(value, mapping) {
      let mapped = mapping.mapPos(value, -1, MapMode.TrackAfter);
      return mapped == null ? undefined : mapped;
    }

  });
  const skipBracketEffect = /*@__PURE__*/StateEffect.define({
    map(value, mapping) {
      return mapping.mapPos(value);
    }

  });
  const closedBracket = /*@__PURE__*/new class extends RangeValue {}();
  closedBracket.startSide = 1;
  closedBracket.endSide = -1;
  const bracketState = /*@__PURE__*/StateField.define({
    create() {
      return RangeSet.empty;
    },

    update(value, tr) {
      if (tr.selection) {
        let lineStart = tr.state.doc.lineAt(tr.selection.main.head).from;
        let prevLineStart = tr.startState.doc.lineAt(tr.startState.selection.main.head).from;
        if (lineStart != tr.changes.mapPos(prevLineStart, -1)) value = RangeSet.empty;
      }

      value = value.map(tr.changes);

      for (let effect of tr.effects) {
        if (effect.is(closeBracketEffect)) value = value.update({
          add: [closedBracket.range(effect.value, effect.value + 1)]
        });else if (effect.is(skipBracketEffect)) value = value.update({
          filter: from => from != effect.value
        });
      }

      return value;
    }

  });
  /**
  Extension to enable bracket-closing behavior. When a closeable
  bracket is typed, its closing bracket is immediately inserted
  after the cursor. When closing a bracket directly in front of a
  closing bracket inserted by the extension, the cursor moves over
  that bracket.
  */

  function closeBrackets() {
    return [inputHandler, bracketState];
  }

  const definedClosing = "()[]{}<>";

  function closing(ch) {
    for (let i = 0; i < definedClosing.length; i += 2) if (definedClosing.charCodeAt(i) == ch) return definedClosing.charAt(i + 1);

    return fromCodePoint(ch < 128 ? ch : ch + 1);
  }

  function config(state, pos) {
    return state.languageDataAt("closeBrackets", pos)[0] || defaults;
  }

  const android = typeof navigator == "object" && /*@__PURE__*/ /Android\b/.test(navigator.userAgent);
  const inputHandler = /*@__PURE__*/EditorView.inputHandler.of((view, from, to, insert) => {
    if ((android ? view.composing : view.compositionStarted) || view.state.readOnly) return false;
    let sel = view.state.selection.main;
    if (insert.length > 2 || insert.length == 2 && codePointSize(codePointAt(insert, 0)) == 1 || from != sel.from || to != sel.to) return false;
    let tr = insertBracket(view.state, insert);
    if (!tr) return false;
    view.dispatch(tr);
    return true;
  });
  /**
  Implements the extension's behavior on text insertion. If the
  given string counts as a bracket in the language around the
  selection, and replacing the selection with it requires custom
  behavior (inserting a closing version or skipping past a
  previously-closed bracket), this function returns a transaction
  representing that custom behavior. (You only need this if you want
  to programmatically insert brackets—the
  [`closeBrackets`](https://codemirror.net/6/docs/ref/#autocomplete.closeBrackets) extension will
  take care of running this for user input.)
  */

  function insertBracket(state, bracket) {
    let conf = config(state, state.selection.main.head);
    let tokens = conf.brackets || defaults.brackets;

    for (let tok of tokens) {
      let closed = closing(codePointAt(tok, 0));
      if (bracket == tok) return closed == tok ? handleSame(state, tok, tokens.indexOf(tok + tok + tok) > -1, conf) : handleOpen(state, tok, closed, conf.before || defaults.before);
      if (bracket == closed && closedBracketAt(state, state.selection.main.from)) return handleClose(state, tok, closed);
    }

    return null;
  }

  function closedBracketAt(state, pos) {
    let found = false;
    state.field(bracketState).between(0, state.doc.length, from => {
      if (from == pos) found = true;
    });
    return found;
  }

  function nextChar(doc, pos) {
    let next = doc.sliceString(pos, pos + 2);
    return next.slice(0, codePointSize(codePointAt(next, 0)));
  }

  function handleOpen(state, open, close, closeBefore) {
    let dont = null,
        changes = state.changeByRange(range => {
      if (!range.empty) return {
        changes: [{
          insert: open,
          from: range.from
        }, {
          insert: close,
          from: range.to
        }],
        effects: closeBracketEffect.of(range.to + open.length),
        range: EditorSelection.range(range.anchor + open.length, range.head + open.length)
      };
      let next = nextChar(state.doc, range.head);
      if (!next || /\s/.test(next) || closeBefore.indexOf(next) > -1) return {
        changes: {
          insert: open + close,
          from: range.head
        },
        effects: closeBracketEffect.of(range.head + open.length),
        range: EditorSelection.cursor(range.head + open.length)
      };
      return {
        range: dont = range
      };
    });
    return dont ? null : state.update(changes, {
      scrollIntoView: true,
      userEvent: "input.type"
    });
  }

  function handleClose(state, _open, close) {
    let dont = null,
        moved = state.selection.ranges.map(range => {
      if (range.empty && nextChar(state.doc, range.head) == close) return EditorSelection.cursor(range.head + close.length);
      return dont = range;
    });
    return dont ? null : state.update({
      selection: EditorSelection.create(moved, state.selection.mainIndex),
      scrollIntoView: true,
      effects: state.selection.ranges.map(({
        from
      }) => skipBracketEffect.of(from))
    });
  } // Handles cases where the open and close token are the same, and
  // possibly triple quotes (as in `"""abc"""`-style quoting).


  function handleSame(state, token, allowTriple, config) {
    let stringPrefixes = config.stringPrefixes || defaults.stringPrefixes;
    let dont = null,
        changes = state.changeByRange(range => {
      if (!range.empty) return {
        changes: [{
          insert: token,
          from: range.from
        }, {
          insert: token,
          from: range.to
        }],
        effects: closeBracketEffect.of(range.to + token.length),
        range: EditorSelection.range(range.anchor + token.length, range.head + token.length)
      };
      let pos = range.head,
          next = nextChar(state.doc, pos),
          start;

      if (next == token) {
        if (nodeStart(state, pos)) {
          return {
            changes: {
              insert: token + token,
              from: pos
            },
            effects: closeBracketEffect.of(pos + token.length),
            range: EditorSelection.cursor(pos + token.length)
          };
        } else if (closedBracketAt(state, pos)) {
          let isTriple = allowTriple && state.sliceDoc(pos, pos + token.length * 3) == token + token + token;
          return {
            range: EditorSelection.cursor(pos + token.length * (isTriple ? 3 : 1)),
            effects: skipBracketEffect.of(pos)
          };
        }
      } else if (allowTriple && state.sliceDoc(pos - 2 * token.length, pos) == token + token && (start = canStartStringAt(state, pos - 2 * token.length, stringPrefixes)) > -1 && nodeStart(state, start)) {
        return {
          changes: {
            insert: token + token + token + token,
            from: pos
          },
          effects: closeBracketEffect.of(pos + token.length),
          range: EditorSelection.cursor(pos + token.length)
        };
      } else if (state.charCategorizer(pos)(next) != CharCategory.Word) {
        if (canStartStringAt(state, pos, stringPrefixes) > -1 && !probablyInString(state, pos, token, stringPrefixes)) return {
          changes: {
            insert: token + token,
            from: pos
          },
          effects: closeBracketEffect.of(pos + token.length),
          range: EditorSelection.cursor(pos + token.length)
        };
      }

      return {
        range: dont = range
      };
    });
    return dont ? null : state.update(changes, {
      scrollIntoView: true,
      userEvent: "input.type"
    });
  }

  function nodeStart(state, pos) {
    let tree = syntaxTree(state).resolveInner(pos + 1);
    return tree.parent && tree.from == pos;
  }

  function probablyInString(state, pos, quoteToken, prefixes) {
    let node = syntaxTree(state).resolveInner(pos, -1);
    let maxPrefix = prefixes.reduce((m, p) => Math.max(m, p.length), 0);

    for (let i = 0; i < 5; i++) {
      let start = state.sliceDoc(node.from, Math.min(node.to, node.from + quoteToken.length + maxPrefix));
      let quotePos = start.indexOf(quoteToken);

      if (!quotePos || quotePos > -1 && prefixes.indexOf(start.slice(0, quotePos)) > -1) {
        let first = node.firstChild;

        while (first && first.from == node.from && first.to - first.from > quoteToken.length + quotePos) {
          if (state.sliceDoc(first.to - quoteToken.length, first.to) == quoteToken) return false;
          first = first.firstChild;
        }

        return true;
      }

      let parent = node.to == pos && node.parent;
      if (!parent) break;
      node = parent;
    }

    return false;
  }

  function canStartStringAt(state, pos, prefixes) {
    let charCat = state.charCategorizer(pos);
    if (charCat(state.sliceDoc(pos - 1, pos)) != CharCategory.Word) return pos;

    for (let prefix of prefixes) {
      let start = pos - prefix.length;
      if (state.sliceDoc(start, pos) == prefix && charCat(state.sliceDoc(start - 1, start)) != CharCategory.Word) return start;
    }

    return -1;
  }
  /**
  Returns an extension that enables autocompletion.
  */


  function autocompletion$1(config = {}) {
    return [completionState, completionConfig.of(config), completionPlugin, completionKeymapExt, baseTheme$2];
  }
  /**
  Basic keybindings for autocompletion.

   - Ctrl-Space: [`startCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.startCompletion)
   - Escape: [`closeCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.closeCompletion)
   - ArrowDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true)`
   - ArrowUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false)`
   - PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
   - PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
   - Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion)
  */


  const completionKeymap = [{
    key: "Ctrl-Space",
    run: startCompletion
  }, {
    key: "Escape",
    run: closeCompletion
  }, {
    key: "ArrowDown",
    run: /*@__PURE__*/moveCompletionSelection(true)
  }, {
    key: "ArrowUp",
    run: /*@__PURE__*/moveCompletionSelection(false)
  }, {
    key: "PageDown",
    run: /*@__PURE__*/moveCompletionSelection(true, "page")
  }, {
    key: "PageUp",
    run: /*@__PURE__*/moveCompletionSelection(false, "page")
  }, {
    key: "Enter",
    run: acceptCompletion
  }];
  const completionKeymapExt = /*@__PURE__*/Prec.highest( /*@__PURE__*/keymap.computeN([completionConfig], state => state.facet(completionConfig).defaultKeymap ? [completionKeymap] : []));

  /**
  Comment or uncomment the current selection. Will use line comments
  if available, otherwise falling back to block comments.
  */

  const toggleComment = target => {
    let config = getConfig(target.state);
    return config.line ? toggleLineComment(target) : config.block ? toggleBlockCommentByLine(target) : false;
  };

  function command(f, option) {
    return ({
      state,
      dispatch
    }) => {
      if (state.readOnly) return false;
      let tr = f(option, state);
      if (!tr) return false;
      dispatch(state.update(tr));
      return true;
    };
  }
  /**
  Comment or uncomment the current selection using line comments.
  The line comment syntax is taken from the
  [`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
  data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
  */


  const toggleLineComment = /*@__PURE__*/command(changeLineComment, 0
  /* Toggle */
  );
  /**
  Comment or uncomment the current selection using block comments.
  The block comment syntax is taken from the
  [`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
  data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
  */

  const toggleBlockComment = /*@__PURE__*/command(changeBlockComment, 0
  /* Toggle */
  );
  /**
  Comment or uncomment the lines around the current selection using
  block comments.
  */

  const toggleBlockCommentByLine = /*@__PURE__*/command((o, s) => changeBlockComment(o, s, selectedLineRanges(s)), 0
  /* Toggle */
  );

  function getConfig(state, pos = state.selection.main.head) {
    let data = state.languageDataAt("commentTokens", pos);
    return data.length ? data[0] : {};
  }

  const SearchMargin = 50;
  /**
  Determines if the given range is block-commented in the given
  state.
  */

  function findBlockComment(state, {
    open,
    close
  }, from, to) {
    let textBefore = state.sliceDoc(from - SearchMargin, from);
    let textAfter = state.sliceDoc(to, to + SearchMargin);
    let spaceBefore = /\s*$/.exec(textBefore)[0].length,
        spaceAfter = /^\s*/.exec(textAfter)[0].length;
    let beforeOff = textBefore.length - spaceBefore;

    if (textBefore.slice(beforeOff - open.length, beforeOff) == open && textAfter.slice(spaceAfter, spaceAfter + close.length) == close) {
      return {
        open: {
          pos: from - spaceBefore,
          margin: spaceBefore && 1
        },
        close: {
          pos: to + spaceAfter,
          margin: spaceAfter && 1
        }
      };
    }

    let startText, endText;

    if (to - from <= 2 * SearchMargin) {
      startText = endText = state.sliceDoc(from, to);
    } else {
      startText = state.sliceDoc(from, from + SearchMargin);
      endText = state.sliceDoc(to - SearchMargin, to);
    }

    let startSpace = /^\s*/.exec(startText)[0].length,
        endSpace = /\s*$/.exec(endText)[0].length;
    let endOff = endText.length - endSpace - close.length;

    if (startText.slice(startSpace, startSpace + open.length) == open && endText.slice(endOff, endOff + close.length) == close) {
      return {
        open: {
          pos: from + startSpace + open.length,
          margin: /\s/.test(startText.charAt(startSpace + open.length)) ? 1 : 0
        },
        close: {
          pos: to - endSpace - close.length,
          margin: /\s/.test(endText.charAt(endOff - 1)) ? 1 : 0
        }
      };
    }

    return null;
  }

  function selectedLineRanges(state) {
    let ranges = [];

    for (let r of state.selection.ranges) {
      let fromLine = state.doc.lineAt(r.from);
      let toLine = r.to <= fromLine.to ? fromLine : state.doc.lineAt(r.to);
      let last = ranges.length - 1;
      if (last >= 0 && ranges[last].to > fromLine.from) ranges[last].to = toLine.to;else ranges.push({
        from: fromLine.from,
        to: toLine.to
      });
    }

    return ranges;
  } // Performs toggle, comment and uncomment of block comments in
  // languages that support them.


  function changeBlockComment(option, state, ranges = state.selection.ranges) {
    let tokens = ranges.map(r => getConfig(state, r.from).block);
    if (!tokens.every(c => c)) return null;
    let comments = ranges.map((r, i) => findBlockComment(state, tokens[i], r.from, r.to));

    if (option != 2
    /* Uncomment */
    && !comments.every(c => c)) {
      return {
        changes: state.changes(ranges.map((range, i) => {
          if (comments[i]) return [];
          return [{
            from: range.from,
            insert: tokens[i].open + " "
          }, {
            from: range.to,
            insert: " " + tokens[i].close
          }];
        }))
      };
    } else if (option != 1
    /* Comment */
    && comments.some(c => c)) {
      let changes = [];

      for (let i = 0, comment; i < comments.length; i++) if (comment = comments[i]) {
        let token = tokens[i],
            {
          open,
          close
        } = comment;
        changes.push({
          from: open.pos - token.open.length,
          to: open.pos + open.margin
        }, {
          from: close.pos - close.margin,
          to: close.pos + token.close.length
        });
      }

      return {
        changes
      };
    }

    return null;
  } // Performs toggle, comment and uncomment of line comments.


  function changeLineComment(option, state, ranges = state.selection.ranges) {
    let lines = [];
    let prevLine = -1;

    for (let {
      from,
      to
    } of ranges) {
      let startI = lines.length,
          minIndent = 1e9;

      for (let pos = from; pos <= to;) {
        let line = state.doc.lineAt(pos);

        if (line.from > prevLine && (from == to || to > line.from)) {
          prevLine = line.from;
          let token = getConfig(state, pos).line;
          if (!token) continue;
          let indent = /^\s*/.exec(line.text)[0].length;
          let empty = indent == line.length;
          let comment = line.text.slice(indent, indent + token.length) == token ? indent : -1;
          if (indent < line.text.length && indent < minIndent) minIndent = indent;
          lines.push({
            line,
            comment,
            token,
            indent,
            empty,
            single: false
          });
        }

        pos = line.to + 1;
      }

      if (minIndent < 1e9) for (let i = startI; i < lines.length; i++) if (lines[i].indent < lines[i].line.text.length) lines[i].indent = minIndent;
      if (lines.length == startI + 1) lines[startI].single = true;
    }

    if (option != 2
    /* Uncomment */
    && lines.some(l => l.comment < 0 && (!l.empty || l.single))) {
      let changes = [];

      for (let {
        line,
        token,
        indent,
        empty,
        single
      } of lines) if (single || !empty) changes.push({
        from: line.from + indent,
        insert: token + " "
      });

      let changeSet = state.changes(changes);
      return {
        changes: changeSet,
        selection: state.selection.map(changeSet, 1)
      };
    } else if (option != 1
    /* Comment */
    && lines.some(l => l.comment >= 0)) {
      let changes = [];

      for (let {
        line,
        comment,
        token
      } of lines) if (comment >= 0) {
        let from = line.from + comment,
            to = from + token.length;
        if (line.text[to - line.from] == " ") to++;
        changes.push({
          from,
          to
        });
      }

      return {
        changes
      };
    }

    return null;
  }

  function updateSel(sel, by) {
    return EditorSelection.create(sel.ranges.map(by), sel.mainIndex);
  }

  function setSel(state, selection) {
    return state.update({
      selection,
      scrollIntoView: true,
      userEvent: "select"
    });
  }

  function moveSel({
    state,
    dispatch
  }, how) {
    let selection = updateSel(state.selection, how);
    if (selection.eq(state.selection)) return false;
    dispatch(setSel(state, selection));
    return true;
  }

  function rangeEnd(range, forward) {
    return EditorSelection.cursor(forward ? range.to : range.from);
  }

  function cursorByChar(view, forward) {
    return moveSel(view, range => range.empty ? view.moveByChar(range, forward) : rangeEnd(range, forward));
  }

  function ltrAtCursor(view) {
    return view.textDirectionAt(view.state.selection.main.head) == Direction.LTR;
  }
  /**
  Move the selection one character to the left (which is backward in
  left-to-right text, forward in right-to-left text).
  */


  const cursorCharLeft = view => cursorByChar(view, !ltrAtCursor(view));
  /**
  Move the selection one character to the right.
  */


  const cursorCharRight = view => cursorByChar(view, ltrAtCursor(view));

  function cursorByGroup(view, forward) {
    return moveSel(view, range => range.empty ? view.moveByGroup(range, forward) : rangeEnd(range, forward));
  }
  /**
  Move the selection to the left across one group of word or
  non-word (but also non-space) characters.
  */


  const cursorGroupLeft = view => cursorByGroup(view, !ltrAtCursor(view));
  /**
  Move the selection one group to the right.
  */


  const cursorGroupRight = view => cursorByGroup(view, ltrAtCursor(view));

  function interestingNode(state, node, bracketProp) {
    if (node.type.prop(bracketProp)) return true;
    let len = node.to - node.from;
    return len && (len > 2 || /[^\s,.;:]/.test(state.sliceDoc(node.from, node.to))) || node.firstChild;
  }

  function moveBySyntax(state, start, forward) {
    let pos = syntaxTree(state).resolveInner(start.head);
    let bracketProp = forward ? NodeProp.closedBy : NodeProp.openedBy; // Scan forward through child nodes to see if there's an interesting
    // node ahead.

    for (let at = start.head;;) {
      let next = forward ? pos.childAfter(at) : pos.childBefore(at);
      if (!next) break;
      if (interestingNode(state, next, bracketProp)) pos = next;else at = forward ? next.to : next.from;
    }

    let bracket = pos.type.prop(bracketProp),
        match,
        newPos;
    if (bracket && (match = forward ? matchBrackets(state, pos.from, 1) : matchBrackets(state, pos.to, -1)) && match.matched) newPos = forward ? match.end.to : match.end.from;else newPos = forward ? pos.to : pos.from;
    return EditorSelection.cursor(newPos, forward ? -1 : 1);
  }
  /**
  Move the cursor over the next syntactic element to the left.
  */


  const cursorSyntaxLeft = view => moveSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view)));
  /**
  Move the cursor over the next syntactic element to the right.
  */


  const cursorSyntaxRight = view => moveSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view)));

  function cursorByLine(view, forward) {
    return moveSel(view, range => {
      if (!range.empty) return rangeEnd(range, forward);
      let moved = view.moveVertically(range, forward);
      return moved.head != range.head ? moved : view.moveToLineBoundary(range, forward);
    });
  }
  /**
  Move the selection one line up.
  */


  const cursorLineUp = view => cursorByLine(view, false);
  /**
  Move the selection one line down.
  */


  const cursorLineDown = view => cursorByLine(view, true);

  function pageHeight(view) {
    return Math.max(view.defaultLineHeight, Math.min(view.dom.clientHeight, innerHeight) - 5);
  }

  function cursorByPage(view, forward) {
    let {
      state
    } = view,
        selection = updateSel(state.selection, range => {
      return range.empty ? view.moveVertically(range, forward, pageHeight(view)) : rangeEnd(range, forward);
    });
    if (selection.eq(state.selection)) return false;
    let startPos = view.coordsAtPos(state.selection.main.head);
    let scrollRect = view.scrollDOM.getBoundingClientRect();
    let effect;
    if (startPos && startPos.top > scrollRect.top && startPos.bottom < scrollRect.bottom && startPos.top - scrollRect.top <= view.scrollDOM.scrollHeight - view.scrollDOM.scrollTop - view.scrollDOM.clientHeight) effect = EditorView.scrollIntoView(selection.main.head, {
      y: "start",
      yMargin: startPos.top - scrollRect.top
    });
    view.dispatch(setSel(state, selection), {
      effects: effect
    });
    return true;
  }
  /**
  Move the selection one page up.
  */


  const cursorPageUp = view => cursorByPage(view, false);
  /**
  Move the selection one page down.
  */


  const cursorPageDown = view => cursorByPage(view, true);

  function moveByLineBoundary(view, start, forward) {
    let line = view.lineBlockAt(start.head),
        moved = view.moveToLineBoundary(start, forward);
    if (moved.head == start.head && moved.head != (forward ? line.to : line.from)) moved = view.moveToLineBoundary(start, forward, false);

    if (!forward && moved.head == line.from && line.length) {
      let space = /^\s*/.exec(view.state.sliceDoc(line.from, Math.min(line.from + 100, line.to)))[0].length;
      if (space && start.head != line.from + space) moved = EditorSelection.cursor(line.from + space);
    }

    return moved;
  }
  /**
  Move the selection to the next line wrap point, or to the end of
  the line if there isn't one left on this line.
  */


  const cursorLineBoundaryForward = view => moveSel(view, range => moveByLineBoundary(view, range, true));
  /**
  Move the selection to previous line wrap point, or failing that to
  the start of the line. If the line is indented, and the cursor
  isn't already at the end of the indentation, this will move to the
  end of the indentation instead of the start of the line.
  */


  const cursorLineBoundaryBackward = view => moveSel(view, range => moveByLineBoundary(view, range, false));
  /**
  Move the selection one line wrap point to the left.
  */


  const cursorLineBoundaryLeft = view => moveSel(view, range => moveByLineBoundary(view, range, !ltrAtCursor(view)));
  /**
  Move the selection one line wrap point to the right.
  */


  const cursorLineBoundaryRight = view => moveSel(view, range => moveByLineBoundary(view, range, ltrAtCursor(view)));
  /**
  Move the selection to the start of the line.
  */


  const cursorLineStart = view => moveSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).from, 1));
  /**
  Move the selection to the end of the line.
  */


  const cursorLineEnd = view => moveSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).to, -1));

  function toMatchingBracket(state, dispatch, extend) {
    let found = false,
        selection = updateSel(state.selection, range => {
      let matching = matchBrackets(state, range.head, -1) || matchBrackets(state, range.head, 1) || range.head > 0 && matchBrackets(state, range.head - 1, 1) || range.head < state.doc.length && matchBrackets(state, range.head + 1, -1);
      if (!matching || !matching.end) return range;
      found = true;
      let head = matching.start.from == range.head ? matching.end.to : matching.end.from;
      return extend ? EditorSelection.range(range.anchor, head) : EditorSelection.cursor(head);
    });
    if (!found) return false;
    dispatch(setSel(state, selection));
    return true;
  }
  /**
  Move the selection to the bracket matching the one it is currently
  on, if any.
  */


  const cursorMatchingBracket = ({
    state,
    dispatch
  }) => toMatchingBracket(state, dispatch, false);

  function extendSel(view, how) {
    let selection = updateSel(view.state.selection, range => {
      let head = how(range);
      return EditorSelection.range(range.anchor, head.head, head.goalColumn);
    });
    if (selection.eq(view.state.selection)) return false;
    view.dispatch(setSel(view.state, selection));
    return true;
  }

  function selectByChar(view, forward) {
    return extendSel(view, range => view.moveByChar(range, forward));
  }
  /**
  Move the selection head one character to the left, while leaving
  the anchor in place.
  */


  const selectCharLeft = view => selectByChar(view, !ltrAtCursor(view));
  /**
  Move the selection head one character to the right.
  */


  const selectCharRight = view => selectByChar(view, ltrAtCursor(view));

  function selectByGroup(view, forward) {
    return extendSel(view, range => view.moveByGroup(range, forward));
  }
  /**
  Move the selection head one [group](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) to
  the left.
  */


  const selectGroupLeft = view => selectByGroup(view, !ltrAtCursor(view));
  /**
  Move the selection head one group to the right.
  */


  const selectGroupRight = view => selectByGroup(view, ltrAtCursor(view));
  /**
  Move the selection head over the next syntactic element to the left.
  */


  const selectSyntaxLeft = view => extendSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view)));
  /**
  Move the selection head over the next syntactic element to the right.
  */


  const selectSyntaxRight = view => extendSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view)));

  function selectByLine(view, forward) {
    return extendSel(view, range => view.moveVertically(range, forward));
  }
  /**
  Move the selection head one line up.
  */


  const selectLineUp = view => selectByLine(view, false);
  /**
  Move the selection head one line down.
  */


  const selectLineDown = view => selectByLine(view, true);

  function selectByPage(view, forward) {
    return extendSel(view, range => view.moveVertically(range, forward, pageHeight(view)));
  }
  /**
  Move the selection head one page up.
  */


  const selectPageUp = view => selectByPage(view, false);
  /**
  Move the selection head one page down.
  */


  const selectPageDown = view => selectByPage(view, true);
  /**
  Move the selection head to the next line boundary.
  */


  const selectLineBoundaryForward = view => extendSel(view, range => moveByLineBoundary(view, range, true));
  /**
  Move the selection head to the previous line boundary.
  */


  const selectLineBoundaryBackward = view => extendSel(view, range => moveByLineBoundary(view, range, false));
  /**
  Move the selection head one line boundary to the left.
  */


  const selectLineBoundaryLeft = view => extendSel(view, range => moveByLineBoundary(view, range, !ltrAtCursor(view)));
  /**
  Move the selection head one line boundary to the right.
  */


  const selectLineBoundaryRight = view => extendSel(view, range => moveByLineBoundary(view, range, ltrAtCursor(view)));
  /**
  Move the selection head to the start of the line.
  */


  const selectLineStart = view => extendSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).from));
  /**
  Move the selection head to the end of the line.
  */


  const selectLineEnd = view => extendSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).to));
  /**
  Move the selection to the start of the document.
  */


  const cursorDocStart = ({
    state,
    dispatch
  }) => {
    dispatch(setSel(state, {
      anchor: 0
    }));
    return true;
  };
  /**
  Move the selection to the end of the document.
  */


  const cursorDocEnd = ({
    state,
    dispatch
  }) => {
    dispatch(setSel(state, {
      anchor: state.doc.length
    }));
    return true;
  };
  /**
  Move the selection head to the start of the document.
  */


  const selectDocStart = ({
    state,
    dispatch
  }) => {
    dispatch(setSel(state, {
      anchor: state.selection.main.anchor,
      head: 0
    }));
    return true;
  };
  /**
  Move the selection head to the end of the document.
  */


  const selectDocEnd = ({
    state,
    dispatch
  }) => {
    dispatch(setSel(state, {
      anchor: state.selection.main.anchor,
      head: state.doc.length
    }));
    return true;
  };
  /**
  Select the entire document.
  */


  const selectAll = ({
    state,
    dispatch
  }) => {
    dispatch(state.update({
      selection: {
        anchor: 0,
        head: state.doc.length
      },
      userEvent: "select"
    }));
    return true;
  };
  /**
  Expand the selection to cover entire lines.
  */


  const selectLine = ({
    state,
    dispatch
  }) => {
    let ranges = selectedLineBlocks(state).map(({
      from,
      to
    }) => EditorSelection.range(from, Math.min(to + 1, state.doc.length)));
    dispatch(state.update({
      selection: EditorSelection.create(ranges),
      userEvent: "select"
    }));
    return true;
  };
  /**
  Select the next syntactic construct that is larger than the
  selection. Note that this will only work insofar as the language
  [provider](https://codemirror.net/6/docs/ref/#language.language) you use builds up a full
  syntax tree.
  */


  const selectParentSyntax = ({
    state,
    dispatch
  }) => {
    let selection = updateSel(state.selection, range => {
      var _a;

      let context = syntaxTree(state).resolveInner(range.head, 1);

      while (!(context.from < range.from && context.to >= range.to || context.to > range.to && context.from <= range.from || !((_a = context.parent) === null || _a === void 0 ? void 0 : _a.parent))) context = context.parent;

      return EditorSelection.range(context.to, context.from);
    });
    dispatch(setSel(state, selection));
    return true;
  };
  /**
  Simplify the current selection. When multiple ranges are selected,
  reduce it to its main range. Otherwise, if the selection is
  non-empty, convert it to a cursor selection.
  */


  const simplifySelection = ({
    state,
    dispatch
  }) => {
    let cur = state.selection,
        selection = null;
    if (cur.ranges.length > 1) selection = EditorSelection.create([cur.main]);else if (!cur.main.empty) selection = EditorSelection.create([EditorSelection.cursor(cur.main.head)]);
    if (!selection) return false;
    dispatch(setSel(state, selection));
    return true;
  };

  function deleteBy({
    state,
    dispatch
  }, by) {
    if (state.readOnly) return false;
    let event = "delete.selection";
    let changes = state.changeByRange(range => {
      let {
        from,
        to
      } = range;

      if (from == to) {
        let towards = by(from);
        if (towards < from) event = "delete.backward";else if (towards > from) event = "delete.forward";
        from = Math.min(from, towards);
        to = Math.max(to, towards);
      }

      return from == to ? {
        range
      } : {
        changes: {
          from,
          to
        },
        range: EditorSelection.cursor(from)
      };
    });
    if (changes.changes.empty) return false;
    dispatch(state.update(changes, {
      scrollIntoView: true,
      userEvent: event,
      effects: event == "delete.selection" ? EditorView.announce.of(state.phrase("Selection deleted")) : undefined
    }));
    return true;
  }

  function skipAtomic(target, pos, forward) {
    if (target instanceof EditorView) for (let ranges of target.state.facet(EditorView.atomicRanges).map(f => f(target))) ranges.between(pos, pos, (from, to) => {
      if (from < pos && to > pos) pos = forward ? to : from;
    });
    return pos;
  }

  const deleteByChar = (target, forward) => deleteBy(target, pos => {
    let {
      state
    } = target,
        line = state.doc.lineAt(pos),
        before,
        targetPos;

    if (!forward && pos > line.from && pos < line.from + 200 && !/[^ \t]/.test(before = line.text.slice(0, pos - line.from))) {
      if (before[before.length - 1] == "\t") return pos - 1;
      let col = countColumn(before, state.tabSize),
          drop = col % getIndentUnit(state) || getIndentUnit(state);

      for (let i = 0; i < drop && before[before.length - 1 - i] == " "; i++) pos--;

      targetPos = pos;
    } else {
      targetPos = findClusterBreak(line.text, pos - line.from, forward, forward) + line.from;
      if (targetPos == pos && line.number != (forward ? state.doc.lines : 1)) targetPos += forward ? 1 : -1;
    }

    return skipAtomic(target, targetPos, forward);
  });
  /**
  Delete the selection, or, for cursor selections, the character
  before the cursor.
  */


  const deleteCharBackward = view => deleteByChar(view, false);
  /**
  Delete the selection or the character after the cursor.
  */


  const deleteCharForward = view => deleteByChar(view, true);

  const deleteByGroup = (target, forward) => deleteBy(target, start => {
    let pos = start,
        {
      state
    } = target,
        line = state.doc.lineAt(pos);
    let categorize = state.charCategorizer(pos);

    for (let cat = null;;) {
      if (pos == (forward ? line.to : line.from)) {
        if (pos == start && line.number != (forward ? state.doc.lines : 1)) pos += forward ? 1 : -1;
        break;
      }

      let next = findClusterBreak(line.text, pos - line.from, forward) + line.from;
      let nextChar = line.text.slice(Math.min(pos, next) - line.from, Math.max(pos, next) - line.from);
      let nextCat = categorize(nextChar);
      if (cat != null && nextCat != cat) break;
      if (nextChar != " " || pos != start) cat = nextCat;
      pos = next;
    }

    return skipAtomic(target, pos, forward);
  });
  /**
  Delete the selection or backward until the end of the next
  [group](https://codemirror.net/6/docs/ref/#view.EditorView.moveByGroup), only skipping groups of
  whitespace when they consist of a single space.
  */


  const deleteGroupBackward = target => deleteByGroup(target, false);
  /**
  Delete the selection or forward until the end of the next group.
  */


  const deleteGroupForward = target => deleteByGroup(target, true);
  /**
  Delete the selection, or, if it is a cursor selection, delete to
  the end of the line. If the cursor is directly at the end of the
  line, delete the line break after it.
  */


  const deleteToLineEnd = view => deleteBy(view, pos => {
    let lineEnd = view.lineBlockAt(pos).to;
    return skipAtomic(view, pos < lineEnd ? lineEnd : Math.min(view.state.doc.length, pos + 1), true);
  });
  /**
  Delete the selection, or, if it is a cursor selection, delete to
  the start of the line. If the cursor is directly at the start of the
  line, delete the line break before it.
  */


  const deleteToLineStart = view => deleteBy(view, pos => {
    let lineStart = view.lineBlockAt(pos).from;
    return skipAtomic(view, pos > lineStart ? lineStart : Math.max(0, pos - 1), false);
  });
  /**
  Replace each selection range with a line break, leaving the cursor
  on the line before the break.
  */


  const splitLine = ({
    state,
    dispatch
  }) => {
    if (state.readOnly) return false;
    let changes = state.changeByRange(range => {
      return {
        changes: {
          from: range.from,
          to: range.to,
          insert: Text.of(["", ""])
        },
        range: EditorSelection.cursor(range.from)
      };
    });
    dispatch(state.update(changes, {
      scrollIntoView: true,
      userEvent: "input"
    }));
    return true;
  };
  /**
  Flip the characters before and after the cursor(s).
  */


  const transposeChars = ({
    state,
    dispatch
  }) => {
    if (state.readOnly) return false;
    let changes = state.changeByRange(range => {
      if (!range.empty || range.from == 0 || range.from == state.doc.length) return {
        range
      };
      let pos = range.from,
          line = state.doc.lineAt(pos);
      let from = pos == line.from ? pos - 1 : findClusterBreak(line.text, pos - line.from, false) + line.from;
      let to = pos == line.to ? pos + 1 : findClusterBreak(line.text, pos - line.from, true) + line.from;
      return {
        changes: {
          from,
          to,
          insert: state.doc.slice(pos, to).append(state.doc.slice(from, pos))
        },
        range: EditorSelection.cursor(to)
      };
    });
    if (changes.changes.empty) return false;
    dispatch(state.update(changes, {
      scrollIntoView: true,
      userEvent: "move.character"
    }));
    return true;
  };

  function selectedLineBlocks(state) {
    let blocks = [],
        upto = -1;

    for (let range of state.selection.ranges) {
      let startLine = state.doc.lineAt(range.from),
          endLine = state.doc.lineAt(range.to);
      if (!range.empty && range.to == endLine.from) endLine = state.doc.lineAt(range.to - 1);

      if (upto >= startLine.number) {
        let prev = blocks[blocks.length - 1];
        prev.to = endLine.to;
        prev.ranges.push(range);
      } else {
        blocks.push({
          from: startLine.from,
          to: endLine.to,
          ranges: [range]
        });
      }

      upto = endLine.number + 1;
    }

    return blocks;
  }

  function moveLine(state, dispatch, forward) {
    if (state.readOnly) return false;
    let changes = [],
        ranges = [];

    for (let block of selectedLineBlocks(state)) {
      if (forward ? block.to == state.doc.length : block.from == 0) continue;
      let nextLine = state.doc.lineAt(forward ? block.to + 1 : block.from - 1);
      let size = nextLine.length + 1;

      if (forward) {
        changes.push({
          from: block.to,
          to: nextLine.to
        }, {
          from: block.from,
          insert: nextLine.text + state.lineBreak
        });

        for (let r of block.ranges) ranges.push(EditorSelection.range(Math.min(state.doc.length, r.anchor + size), Math.min(state.doc.length, r.head + size)));
      } else {
        changes.push({
          from: nextLine.from,
          to: block.from
        }, {
          from: block.to,
          insert: state.lineBreak + nextLine.text
        });

        for (let r of block.ranges) ranges.push(EditorSelection.range(r.anchor - size, r.head - size));
      }
    }

    if (!changes.length) return false;
    dispatch(state.update({
      changes,
      scrollIntoView: true,
      selection: EditorSelection.create(ranges, state.selection.mainIndex),
      userEvent: "move.line"
    }));
    return true;
  }
  /**
  Move the selected lines up one line.
  */


  const moveLineUp = ({
    state,
    dispatch
  }) => moveLine(state, dispatch, false);
  /**
  Move the selected lines down one line.
  */


  const moveLineDown = ({
    state,
    dispatch
  }) => moveLine(state, dispatch, true);

  function copyLine(state, dispatch, forward) {
    if (state.readOnly) return false;
    let changes = [];

    for (let block of selectedLineBlocks(state)) {
      if (forward) changes.push({
        from: block.from,
        insert: state.doc.slice(block.from, block.to) + state.lineBreak
      });else changes.push({
        from: block.to,
        insert: state.lineBreak + state.doc.slice(block.from, block.to)
      });
    }

    dispatch(state.update({
      changes,
      scrollIntoView: true,
      userEvent: "input.copyline"
    }));
    return true;
  }
  /**
  Create a copy of the selected lines. Keep the selection in the top copy.
  */


  const copyLineUp = ({
    state,
    dispatch
  }) => copyLine(state, dispatch, false);
  /**
  Create a copy of the selected lines. Keep the selection in the bottom copy.
  */


  const copyLineDown = ({
    state,
    dispatch
  }) => copyLine(state, dispatch, true);
  /**
  Delete selected lines.
  */


  const deleteLine = view => {
    if (view.state.readOnly) return false;
    let {
      state
    } = view,
        changes = state.changes(selectedLineBlocks(state).map(({
      from,
      to
    }) => {
      if (from > 0) from--;else if (to < state.doc.length) to++;
      return {
        from,
        to
      };
    }));
    let selection = updateSel(state.selection, range => view.moveVertically(range, true)).map(changes);
    view.dispatch({
      changes,
      selection,
      scrollIntoView: true,
      userEvent: "delete.line"
    });
    return true;
  };

  function isBetweenBrackets(state, pos) {
    if (/\(\)|\[\]|\{\}/.test(state.sliceDoc(pos - 1, pos + 1))) return {
      from: pos,
      to: pos
    };
    let context = syntaxTree(state).resolveInner(pos);
    let before = context.childBefore(pos),
        after = context.childAfter(pos),
        closedBy;
    if (before && after && before.to <= pos && after.from >= pos && (closedBy = before.type.prop(NodeProp.closedBy)) && closedBy.indexOf(after.name) > -1 && state.doc.lineAt(before.to).from == state.doc.lineAt(after.from).from) return {
      from: before.to,
      to: after.from
    };
    return null;
  }
  /**
  Replace the selection with a newline and indent the newly created
  line(s). If the current line consists only of whitespace, this
  will also delete that whitespace. When the cursor is between
  matching brackets, an additional newline will be inserted after
  the cursor.
  */


  const insertNewlineAndIndent = /*@__PURE__*/newlineAndIndent(false);
  /**
  Create a blank, indented line below the current line.
  */

  const insertBlankLine = /*@__PURE__*/newlineAndIndent(true);

  function newlineAndIndent(atEof) {
    return ({
      state,
      dispatch
    }) => {
      if (state.readOnly) return false;
      let changes = state.changeByRange(range => {
        let {
          from,
          to
        } = range,
            line = state.doc.lineAt(from);
        let explode = !atEof && from == to && isBetweenBrackets(state, from);
        if (atEof) from = to = (to <= line.to ? line : state.doc.lineAt(to)).to;
        let cx = new IndentContext(state, {
          simulateBreak: from,
          simulateDoubleBreak: !!explode
        });
        let indent = getIndentation(cx, from);
        if (indent == null) indent = /^\s*/.exec(state.doc.lineAt(from).text)[0].length;

        while (to < line.to && /\s/.test(line.text[to - line.from])) to++;

        if (explode) ({
          from,
          to
        } = explode);else if (from > line.from && from < line.from + 100 && !/\S/.test(line.text.slice(0, from))) from = line.from;
        let insert = ["", indentString(state, indent)];
        if (explode) insert.push(indentString(state, cx.lineIndent(line.from, -1)));
        return {
          changes: {
            from,
            to,
            insert: Text.of(insert)
          },
          range: EditorSelection.cursor(from + 1 + insert[1].length)
        };
      });
      dispatch(state.update(changes, {
        scrollIntoView: true,
        userEvent: "input"
      }));
      return true;
    };
  }

  function changeBySelectedLine(state, f) {
    let atLine = -1;
    return state.changeByRange(range => {
      let changes = [];

      for (let pos = range.from; pos <= range.to;) {
        let line = state.doc.lineAt(pos);

        if (line.number > atLine && (range.empty || range.to > line.from)) {
          f(line, changes, range);
          atLine = line.number;
        }

        pos = line.to + 1;
      }

      let changeSet = state.changes(changes);
      return {
        changes,
        range: EditorSelection.range(changeSet.mapPos(range.anchor, 1), changeSet.mapPos(range.head, 1))
      };
    });
  }
  /**
  Auto-indent the selected lines. This uses the [indentation service
  facet](https://codemirror.net/6/docs/ref/#language.indentService) as source for auto-indent
  information.
  */


  const indentSelection = ({
    state,
    dispatch
  }) => {
    if (state.readOnly) return false;
    let updated = Object.create(null);
    let context = new IndentContext(state, {
      overrideIndentation: start => {
        let found = updated[start];
        return found == null ? -1 : found;
      }
    });
    let changes = changeBySelectedLine(state, (line, changes, range) => {
      let indent = getIndentation(context, line.from);
      if (indent == null) return;
      if (!/\S/.test(line.text)) indent = 0;
      let cur = /^\s*/.exec(line.text)[0];
      let norm = indentString(state, indent);

      if (cur != norm || range.from < line.from + cur.length) {
        updated[line.from] = indent;
        changes.push({
          from: line.from,
          to: line.from + cur.length,
          insert: norm
        });
      }
    });
    if (!changes.changes.empty) dispatch(state.update(changes, {
      userEvent: "indent"
    }));
    return true;
  };
  /**
  Add a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation to all selected
  lines.
  */


  const indentMore = ({
    state,
    dispatch
  }) => {
    if (state.readOnly) return false;
    dispatch(state.update(changeBySelectedLine(state, (line, changes) => {
      changes.push({
        from: line.from,
        insert: state.facet(indentUnit)
      });
    }), {
      userEvent: "input.indent"
    }));
    return true;
  };
  /**
  Remove a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation from all
  selected lines.
  */


  const indentLess = ({
    state,
    dispatch
  }) => {
    if (state.readOnly) return false;
    dispatch(state.update(changeBySelectedLine(state, (line, changes) => {
      let space = /^\s*/.exec(line.text)[0];
      if (!space) return;
      let col = countColumn(space, state.tabSize),
          keep = 0;
      let insert = indentString(state, Math.max(0, col - getIndentUnit(state)));

      while (keep < space.length && keep < insert.length && space.charCodeAt(keep) == insert.charCodeAt(keep)) keep++;

      changes.push({
        from: line.from + keep,
        to: line.from + space.length,
        insert: insert.slice(keep)
      });
    }), {
      userEvent: "delete.dedent"
    }));
    return true;
  };
  /**
  Array of key bindings containing the Emacs-style bindings that are
  available on macOS by default.

   - Ctrl-b: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)
   - Ctrl-f: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)
   - Ctrl-p: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)
   - Ctrl-n: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)
   - Ctrl-a: [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)
   - Ctrl-e: [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)
   - Ctrl-d: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)
   - Ctrl-h: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)
   - Ctrl-k: [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd)
   - Ctrl-Alt-h: [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)
   - Ctrl-o: [`splitLine`](https://codemirror.net/6/docs/ref/#commands.splitLine)
   - Ctrl-t: [`transposeChars`](https://codemirror.net/6/docs/ref/#commands.transposeChars)
   - Ctrl-v: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown)
   - Alt-v: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp)
  */


  const emacsStyleKeymap = [{
    key: "Ctrl-b",
    run: cursorCharLeft,
    shift: selectCharLeft,
    preventDefault: true
  }, {
    key: "Ctrl-f",
    run: cursorCharRight,
    shift: selectCharRight
  }, {
    key: "Ctrl-p",
    run: cursorLineUp,
    shift: selectLineUp
  }, {
    key: "Ctrl-n",
    run: cursorLineDown,
    shift: selectLineDown
  }, {
    key: "Ctrl-a",
    run: cursorLineStart,
    shift: selectLineStart
  }, {
    key: "Ctrl-e",
    run: cursorLineEnd,
    shift: selectLineEnd
  }, {
    key: "Ctrl-d",
    run: deleteCharForward
  }, {
    key: "Ctrl-h",
    run: deleteCharBackward
  }, {
    key: "Ctrl-k",
    run: deleteToLineEnd
  }, {
    key: "Ctrl-Alt-h",
    run: deleteGroupBackward
  }, {
    key: "Ctrl-o",
    run: splitLine
  }, {
    key: "Ctrl-t",
    run: transposeChars
  }, {
    key: "Ctrl-v",
    run: cursorPageDown
  }];
  /**
  An array of key bindings closely sticking to platform-standard or
  widely used bindings. (This includes the bindings from
  [`emacsStyleKeymap`](https://codemirror.net/6/docs/ref/#commands.emacsStyleKeymap), with their `key`
  property changed to `mac`.)

   - ArrowLeft: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)
   - ArrowRight: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)
   - Ctrl-ArrowLeft (Alt-ArrowLeft on macOS): [`cursorGroupLeft`](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) ([`selectGroupLeft`](https://codemirror.net/6/docs/ref/#commands.selectGroupLeft) with Shift)
   - Ctrl-ArrowRight (Alt-ArrowRight on macOS): [`cursorGroupRight`](https://codemirror.net/6/docs/ref/#commands.cursorGroupRight) ([`selectGroupRight`](https://codemirror.net/6/docs/ref/#commands.selectGroupRight) with Shift)
   - Cmd-ArrowLeft (on macOS): [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)
   - Cmd-ArrowRight (on macOS): [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)
   - ArrowUp: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)
   - ArrowDown: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)
   - Cmd-ArrowUp (on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)
   - Cmd-ArrowDown (on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)
   - Ctrl-ArrowUp (on macOS): [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)
   - Ctrl-ArrowDown (on macOS): [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)
   - PageUp: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)
   - PageDown: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)
   - Home: [`cursorLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryBackward) ([`selectLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryBackward) with Shift)
   - End: [`cursorLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryForward) ([`selectLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryForward) with Shift)
   - Ctrl-Home (Cmd-Home on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)
   - Ctrl-End (Cmd-Home on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)
   - Enter: [`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent)
   - Ctrl-a (Cmd-a on macOS): [`selectAll`](https://codemirror.net/6/docs/ref/#commands.selectAll)
   - Backspace: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)
   - Delete: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)
   - Ctrl-Backspace (Alt-Backspace on macOS): [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)
   - Ctrl-Delete (Alt-Delete on macOS): [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward)
   - Cmd-Backspace (macOS): [`deleteToLineStart`](https://codemirror.net/6/docs/ref/#commands.deleteToLineStart).
   - Cmd-Delete (macOS): [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd).
  */

  const standardKeymap = /*@__PURE__*/[{
    key: "ArrowLeft",
    run: cursorCharLeft,
    shift: selectCharLeft,
    preventDefault: true
  }, {
    key: "Mod-ArrowLeft",
    mac: "Alt-ArrowLeft",
    run: cursorGroupLeft,
    shift: selectGroupLeft,
    preventDefault: true
  }, {
    mac: "Cmd-ArrowLeft",
    run: cursorLineBoundaryLeft,
    shift: selectLineBoundaryLeft,
    preventDefault: true
  }, {
    key: "ArrowRight",
    run: cursorCharRight,
    shift: selectCharRight,
    preventDefault: true
  }, {
    key: "Mod-ArrowRight",
    mac: "Alt-ArrowRight",
    run: cursorGroupRight,
    shift: selectGroupRight,
    preventDefault: true
  }, {
    mac: "Cmd-ArrowRight",
    run: cursorLineBoundaryRight,
    shift: selectLineBoundaryRight,
    preventDefault: true
  }, {
    key: "ArrowUp",
    run: cursorLineUp,
    shift: selectLineUp,
    preventDefault: true
  }, {
    mac: "Cmd-ArrowUp",
    run: cursorDocStart,
    shift: selectDocStart
  }, {
    mac: "Ctrl-ArrowUp",
    run: cursorPageUp,
    shift: selectPageUp
  }, {
    key: "ArrowDown",
    run: cursorLineDown,
    shift: selectLineDown,
    preventDefault: true
  }, {
    mac: "Cmd-ArrowDown",
    run: cursorDocEnd,
    shift: selectDocEnd
  }, {
    mac: "Ctrl-ArrowDown",
    run: cursorPageDown,
    shift: selectPageDown
  }, {
    key: "PageUp",
    run: cursorPageUp,
    shift: selectPageUp
  }, {
    key: "PageDown",
    run: cursorPageDown,
    shift: selectPageDown
  }, {
    key: "Home",
    run: cursorLineBoundaryBackward,
    shift: selectLineBoundaryBackward,
    preventDefault: true
  }, {
    key: "Mod-Home",
    run: cursorDocStart,
    shift: selectDocStart
  }, {
    key: "End",
    run: cursorLineBoundaryForward,
    shift: selectLineBoundaryForward,
    preventDefault: true
  }, {
    key: "Mod-End",
    run: cursorDocEnd,
    shift: selectDocEnd
  }, {
    key: "Enter",
    run: insertNewlineAndIndent
  }, {
    key: "Mod-a",
    run: selectAll
  }, {
    key: "Backspace",
    run: deleteCharBackward,
    shift: deleteCharBackward
  }, {
    key: "Delete",
    run: deleteCharForward
  }, {
    key: "Mod-Backspace",
    mac: "Alt-Backspace",
    run: deleteGroupBackward
  }, {
    key: "Mod-Delete",
    mac: "Alt-Delete",
    run: deleteGroupForward
  }, {
    mac: "Mod-Backspace",
    run: deleteToLineStart
  }, {
    mac: "Mod-Delete",
    run: deleteToLineEnd
  }].concat( /*@__PURE__*/emacsStyleKeymap.map(b => ({
    mac: b.key,
    run: b.run,
    shift: b.shift
  })));
  /**
  The default keymap. Includes all bindings from
  [`standardKeymap`](https://codemirror.net/6/docs/ref/#commands.standardKeymap) plus the following:

  - Alt-ArrowLeft (Ctrl-ArrowLeft on macOS): [`cursorSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxLeft) ([`selectSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxLeft) with Shift)
  - Alt-ArrowRight (Ctrl-ArrowRight on macOS): [`cursorSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxRight) ([`selectSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxRight) with Shift)
  - Alt-ArrowUp: [`moveLineUp`](https://codemirror.net/6/docs/ref/#commands.moveLineUp)
  - Alt-ArrowDown: [`moveLineDown`](https://codemirror.net/6/docs/ref/#commands.moveLineDown)
  - Shift-Alt-ArrowUp: [`copyLineUp`](https://codemirror.net/6/docs/ref/#commands.copyLineUp)
  - Shift-Alt-ArrowDown: [`copyLineDown`](https://codemirror.net/6/docs/ref/#commands.copyLineDown)
  - Escape: [`simplifySelection`](https://codemirror.net/6/docs/ref/#commands.simplifySelection)
  - Ctrl-Enter (Comd-Enter on macOS): [`insertBlankLine`](https://codemirror.net/6/docs/ref/#commands.insertBlankLine)
  - Alt-l (Ctrl-l on macOS): [`selectLine`](https://codemirror.net/6/docs/ref/#commands.selectLine)
  - Ctrl-i (Cmd-i on macOS): [`selectParentSyntax`](https://codemirror.net/6/docs/ref/#commands.selectParentSyntax)
  - Ctrl-[ (Cmd-[ on macOS): [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess)
  - Ctrl-] (Cmd-] on macOS): [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore)
  - Ctrl-Alt-\\ (Cmd-Alt-\\ on macOS): [`indentSelection`](https://codemirror.net/6/docs/ref/#commands.indentSelection)
  - Shift-Ctrl-k (Shift-Cmd-k on macOS): [`deleteLine`](https://codemirror.net/6/docs/ref/#commands.deleteLine)
  - Shift-Ctrl-\\ (Shift-Cmd-\\ on macOS): [`cursorMatchingBracket`](https://codemirror.net/6/docs/ref/#commands.cursorMatchingBracket)
  - Ctrl-/ (Cmd-/ on macOS): [`toggleComment`](https://codemirror.net/6/docs/ref/#commands.toggleComment).
  - Shift-Alt-a: [`toggleBlockComment`](https://codemirror.net/6/docs/ref/#commands.toggleBlockComment).
  */

  const defaultKeymap = /*@__PURE__*/[{
    key: "Alt-ArrowLeft",
    mac: "Ctrl-ArrowLeft",
    run: cursorSyntaxLeft,
    shift: selectSyntaxLeft
  }, {
    key: "Alt-ArrowRight",
    mac: "Ctrl-ArrowRight",
    run: cursorSyntaxRight,
    shift: selectSyntaxRight
  }, {
    key: "Alt-ArrowUp",
    run: moveLineUp
  }, {
    key: "Shift-Alt-ArrowUp",
    run: copyLineUp
  }, {
    key: "Alt-ArrowDown",
    run: moveLineDown
  }, {
    key: "Shift-Alt-ArrowDown",
    run: copyLineDown
  }, {
    key: "Escape",
    run: simplifySelection
  }, {
    key: "Mod-Enter",
    run: insertBlankLine
  }, {
    key: "Alt-l",
    mac: "Ctrl-l",
    run: selectLine
  }, {
    key: "Mod-i",
    run: selectParentSyntax,
    preventDefault: true
  }, {
    key: "Mod-[",
    run: indentLess
  }, {
    key: "Mod-]",
    run: indentMore
  }, {
    key: "Mod-Alt-\\",
    run: indentSelection
  }, {
    key: "Shift-Mod-k",
    run: deleteLine
  }, {
    key: "Shift-Mod-\\",
    run: cursorMatchingBracket
  }, {
    key: "Mod-/",
    run: toggleComment
  }, {
    key: "Alt-A",
    run: toggleBlockComment
  }].concat(standardKeymap);

  function crelt() {
    var elt = arguments[0];
    if (typeof elt == "string") elt = document.createElement(elt);
    var i = 1,
        next = arguments[1];

    if (next && typeof next == "object" && next.nodeType == null && !Array.isArray(next)) {
      for (var name in next) if (Object.prototype.hasOwnProperty.call(next, name)) {
        var value = next[name];
        if (typeof value == "string") elt.setAttribute(name, value);else if (value != null) elt[name] = value;
      }

      i++;
    }

    for (; i < arguments.length; i++) add$3(elt, arguments[i]);

    return elt;
  }

  function add$3(elt, child) {
    if (typeof child == "string") {
      elt.appendChild(document.createTextNode(child));
    } else if (child == null) ; else if (child.nodeType != null) {
      elt.appendChild(child);
    } else if (Array.isArray(child)) {
      for (var i = 0; i < child.length; i++) add$3(elt, child[i]);
    } else {
      throw new RangeError("Unsupported child node: " + child);
    }
  }

  class SelectedDiagnostic {
    constructor(from, to, diagnostic) {
      this.from = from;
      this.to = to;
      this.diagnostic = diagnostic;
    }

  }

  class LintState {
    constructor(diagnostics, panel, selected) {
      this.diagnostics = diagnostics;
      this.panel = panel;
      this.selected = selected;
    }

    static init(diagnostics, panel, state) {
      // Filter the list of diagnostics for which to create markers
      let markedDiagnostics = diagnostics;
      let diagnosticFilter = state.facet(lintConfig).markerFilter;
      if (diagnosticFilter) markedDiagnostics = diagnosticFilter(markedDiagnostics);
      let ranges = Decoration.set(markedDiagnostics.map(d => {
        // For zero-length ranges or ranges covering only a line break, create a widget
        return d.from == d.to || d.from == d.to - 1 && state.doc.lineAt(d.from).to == d.from ? Decoration.widget({
          widget: new DiagnosticWidget(d),
          diagnostic: d
        }).range(d.from) : Decoration.mark({
          attributes: {
            class: "cm-lintRange cm-lintRange-" + d.severity
          },
          diagnostic: d
        }).range(d.from, d.to);
      }), true);
      return new LintState(ranges, panel, findDiagnostic(ranges));
    }

  }

  function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
    let found = null;
    diagnostics.between(after, 1e9, (from, to, {
      spec
    }) => {
      if (diagnostic && spec.diagnostic != diagnostic) return;
      found = new SelectedDiagnostic(from, to, spec.diagnostic);
      return false;
    });
    return found;
  }

  function hideTooltip(tr, tooltip) {
    return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(tooltip.pos));
  }

  function maybeEnableLint(state, effects) {
    return state.field(lintState, false) ? effects : effects.concat(StateEffect.appendConfig.of([lintState, EditorView.decorations.compute([lintState], state => {
      let {
        selected,
        panel
      } = state.field(lintState);
      return !selected || !panel || selected.from == selected.to ? Decoration.none : Decoration.set([activeMark.range(selected.from, selected.to)]);
    }), hoverTooltip(lintTooltip, {
      hideOn: hideTooltip
    }), baseTheme$1]));
  }
  /**
  Returns a transaction spec which updates the current set of
  diagnostics, and enables the lint extension if if wasn't already
  active.
  */


  function setDiagnostics(state, diagnostics) {
    return {
      effects: maybeEnableLint(state, [setDiagnosticsEffect.of(diagnostics)])
    };
  }
  /**
  The state effect that updates the set of active diagnostics. Can
  be useful when writing an extension that needs to track these.
  */


  const setDiagnosticsEffect = /*@__PURE__*/StateEffect.define();
  const togglePanel = /*@__PURE__*/StateEffect.define();
  const movePanelSelection = /*@__PURE__*/StateEffect.define();
  const lintState = /*@__PURE__*/StateField.define({
    create() {
      return new LintState(Decoration.none, null, null);
    },

    update(value, tr) {
      if (tr.docChanged) {
        let mapped = value.diagnostics.map(tr.changes),
            selected = null;

        if (value.selected) {
          let selPos = tr.changes.mapPos(value.selected.from, 1);
          selected = findDiagnostic(mapped, value.selected.diagnostic, selPos) || findDiagnostic(mapped, null, selPos);
        }

        value = new LintState(mapped, value.panel, selected);
      }

      for (let effect of tr.effects) {
        if (effect.is(setDiagnosticsEffect)) {
          value = LintState.init(effect.value, value.panel, tr.state);
        } else if (effect.is(togglePanel)) {
          value = new LintState(value.diagnostics, effect.value ? LintPanel.open : null, value.selected);
        } else if (effect.is(movePanelSelection)) {
          value = new LintState(value.diagnostics, value.panel, effect.value);
        }
      }

      return value;
    },

    provide: f => [showPanel.from(f, val => val.panel), EditorView.decorations.from(f, s => s.diagnostics)]
  });

  const activeMark = /*@__PURE__*/Decoration.mark({
    class: "cm-lintRange cm-lintRange-active"
  });

  function lintTooltip(view, pos, side) {
    let {
      diagnostics
    } = view.state.field(lintState);
    let found = [],
        stackStart = 2e8,
        stackEnd = 0;
    diagnostics.between(pos - (side < 0 ? 1 : 0), pos + (side > 0 ? 1 : 0), (from, to, {
      spec
    }) => {
      if (pos >= from && pos <= to && (from == to || (pos > from || side > 0) && (pos < to || side < 0))) {
        found.push(spec.diagnostic);
        stackStart = Math.min(from, stackStart);
        stackEnd = Math.max(to, stackEnd);
      }
    });
    let diagnosticFilter = view.state.facet(lintConfig).tooltipFilter;
    if (diagnosticFilter) found = diagnosticFilter(found);
    if (!found.length) return null;
    return {
      pos: stackStart,
      end: stackEnd,
      above: view.state.doc.lineAt(stackStart).to < stackEnd,

      create() {
        return {
          dom: diagnosticsTooltip(view, found)
        };
      }

    };
  }

  function diagnosticsTooltip(view, diagnostics) {
    return crelt("ul", {
      class: "cm-tooltip-lint"
    }, diagnostics.map(d => renderDiagnostic(view, d, false)));
  }
  /**
  Command to close the lint panel, when open.
  */


  const closeLintPanel = view => {
    let field = view.state.field(lintState, false);
    if (!field || !field.panel) return false;
    view.dispatch({
      effects: togglePanel.of(false)
    });
    return true;
  };
  const lintPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
    constructor(view) {
      this.view = view;
      this.timeout = -1;
      this.set = true;
      let {
        delay
      } = view.state.facet(lintConfig);
      this.lintTime = Date.now() + delay;
      this.run = this.run.bind(this);
      this.timeout = setTimeout(this.run, delay);
    }

    run() {
      let now = Date.now();

      if (now < this.lintTime - 10) {
        setTimeout(this.run, this.lintTime - now);
      } else {
        this.set = false;
        let {
          state
        } = this.view,
            {
          sources
        } = state.facet(lintConfig);
        Promise.all(sources.map(source => Promise.resolve(source(this.view)))).then(annotations => {
          let all = annotations.reduce((a, b) => a.concat(b));
          if (this.view.state.doc == state.doc) this.view.dispatch(setDiagnostics(this.view.state, all));
        }, error => {
          logException(this.view.state, error);
        });
      }
    }

    update(update) {
      let config = update.state.facet(lintConfig);

      if (update.docChanged || config != update.startState.facet(lintConfig)) {
        this.lintTime = Date.now() + config.delay;

        if (!this.set) {
          this.set = true;
          this.timeout = setTimeout(this.run, config.delay);
        }
      }
    }

    force() {
      if (this.set) {
        this.lintTime = Date.now();
        this.run();
      }
    }

    destroy() {
      clearTimeout(this.timeout);
    }

  });
  const lintConfig = /*@__PURE__*/Facet.define({
    combine(input) {
      return Object.assign({
        sources: input.map(i => i.source)
      }, combineConfig(input.map(i => i.config), {
        delay: 750,
        markerFilter: null,
        tooltipFilter: null
      }));
    },

    enables: lintPlugin
  });
  /**
  Given a diagnostic source, this function returns an extension that
  enables linting with that source. It will be called whenever the
  editor is idle (after its content changed).
  */

  function linter$1(source, config = {}) {
    return lintConfig.of({
      source,
      config
    });
  }

  function assignKeys(actions) {
    let assigned = [];
    if (actions) actions: for (let {
      name
    } of actions) {
      for (let i = 0; i < name.length; i++) {
        let ch = name[i];

        if (/[a-zA-Z]/.test(ch) && !assigned.some(c => c.toLowerCase() == ch.toLowerCase())) {
          assigned.push(ch);
          continue actions;
        }
      }

      assigned.push("");
    }
    return assigned;
  }

  function renderDiagnostic(view, diagnostic, inPanel) {
    var _a;

    let keys = inPanel ? assignKeys(diagnostic.actions) : [];
    return crelt("li", {
      class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity
    }, crelt("span", {
      class: "cm-diagnosticText"
    }, diagnostic.renderMessage ? diagnostic.renderMessage() : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
      let click = e => {
        e.preventDefault();
        let found = findDiagnostic(view.state.field(lintState).diagnostics, diagnostic);
        if (found) action.apply(view, found.from, found.to);
      };

      let {
        name
      } = action,
          keyIndex = keys[i] ? name.indexOf(keys[i]) : -1;
      let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex), crelt("u", name.slice(keyIndex, keyIndex + 1)), name.slice(keyIndex + 1)];
      return crelt("button", {
        type: "button",
        class: "cm-diagnosticAction",
        onclick: click,
        onmousedown: click,
        "aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
      }, nameElt);
    }), diagnostic.source && crelt("div", {
      class: "cm-diagnosticSource"
    }, diagnostic.source));
  }

  class DiagnosticWidget extends WidgetType {
    constructor(diagnostic) {
      super();
      this.diagnostic = diagnostic;
    }

    eq(other) {
      return other.diagnostic == this.diagnostic;
    }

    toDOM() {
      return crelt("span", {
        class: "cm-lintPoint cm-lintPoint-" + this.diagnostic.severity
      });
    }

  }

  class PanelItem {
    constructor(view, diagnostic) {
      this.diagnostic = diagnostic;
      this.id = "item_" + Math.floor(Math.random() * 0xffffffff).toString(16);
      this.dom = renderDiagnostic(view, diagnostic, true);
      this.dom.id = this.id;
      this.dom.setAttribute("role", "option");
    }

  }

  class LintPanel {
    constructor(view) {
      this.view = view;
      this.items = [];

      let onkeydown = event => {
        if (event.keyCode == 27) {
          // Escape
          closeLintPanel(this.view);
          this.view.focus();
        } else if (event.keyCode == 38 || event.keyCode == 33) {
          // ArrowUp, PageUp
          this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
        } else if (event.keyCode == 40 || event.keyCode == 34) {
          // ArrowDown, PageDown
          this.moveSelection((this.selectedIndex + 1) % this.items.length);
        } else if (event.keyCode == 36) {
          // Home
          this.moveSelection(0);
        } else if (event.keyCode == 35) {
          // End
          this.moveSelection(this.items.length - 1);
        } else if (event.keyCode == 13) {
          // Enter
          this.view.focus();
        } else if (event.keyCode >= 65 && event.keyCode <= 90 && this.selectedIndex >= 0) {
          // A-Z
          let {
            diagnostic
          } = this.items[this.selectedIndex],
              keys = assignKeys(diagnostic.actions);

          for (let i = 0; i < keys.length; i++) if (keys[i].toUpperCase().charCodeAt(0) == event.keyCode) {
            let found = findDiagnostic(this.view.state.field(lintState).diagnostics, diagnostic);
            if (found) diagnostic.actions[i].apply(view, found.from, found.to);
          }
        } else {
          return;
        }

        event.preventDefault();
      };

      let onclick = event => {
        for (let i = 0; i < this.items.length; i++) {
          if (this.items[i].dom.contains(event.target)) this.moveSelection(i);
        }
      };

      this.list = crelt("ul", {
        tabIndex: 0,
        role: "listbox",
        "aria-label": this.view.state.phrase("Diagnostics"),
        onkeydown,
        onclick
      });
      this.dom = crelt("div", {
        class: "cm-panel-lint"
      }, this.list, crelt("button", {
        type: "button",
        name: "close",
        "aria-label": this.view.state.phrase("close"),
        onclick: () => closeLintPanel(this.view)
      }, "×"));
      this.update();
    }

    get selectedIndex() {
      let selected = this.view.state.field(lintState).selected;
      if (!selected) return -1;

      for (let i = 0; i < this.items.length; i++) if (this.items[i].diagnostic == selected.diagnostic) return i;

      return -1;
    }

    update() {
      let {
        diagnostics,
        selected
      } = this.view.state.field(lintState);
      let i = 0,
          needsSync = false,
          newSelectedItem = null;
      diagnostics.between(0, this.view.state.doc.length, (_start, _end, {
        spec
      }) => {
        let found = -1,
            item;

        for (let j = i; j < this.items.length; j++) if (this.items[j].diagnostic == spec.diagnostic) {
          found = j;
          break;
        }

        if (found < 0) {
          item = new PanelItem(this.view, spec.diagnostic);
          this.items.splice(i, 0, item);
          needsSync = true;
        } else {
          item = this.items[found];

          if (found > i) {
            this.items.splice(i, found - i);
            needsSync = true;
          }
        }

        if (selected && item.diagnostic == selected.diagnostic) {
          if (!item.dom.hasAttribute("aria-selected")) {
            item.dom.setAttribute("aria-selected", "true");
            newSelectedItem = item;
          }
        } else if (item.dom.hasAttribute("aria-selected")) {
          item.dom.removeAttribute("aria-selected");
        }

        i++;
      });

      while (i < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0)) {
        needsSync = true;
        this.items.pop();
      }

      if (this.items.length == 0) {
        this.items.push(new PanelItem(this.view, {
          from: -1,
          to: -1,
          severity: "info",
          message: this.view.state.phrase("No diagnostics")
        }));
        needsSync = true;
      }

      if (newSelectedItem) {
        this.list.setAttribute("aria-activedescendant", newSelectedItem.id);
        this.view.requestMeasure({
          key: this,
          read: () => ({
            sel: newSelectedItem.dom.getBoundingClientRect(),
            panel: this.list.getBoundingClientRect()
          }),
          write: ({
            sel,
            panel
          }) => {
            if (sel.top < panel.top) this.list.scrollTop -= panel.top - sel.top;else if (sel.bottom > panel.bottom) this.list.scrollTop += sel.bottom - panel.bottom;
          }
        });
      } else if (this.selectedIndex < 0) {
        this.list.removeAttribute("aria-activedescendant");
      }

      if (needsSync) this.sync();
    }

    sync() {
      let domPos = this.list.firstChild;

      function rm() {
        let prev = domPos;
        domPos = prev.nextSibling;
        prev.remove();
      }

      for (let item of this.items) {
        if (item.dom.parentNode == this.list) {
          while (domPos != item.dom) rm();

          domPos = item.dom.nextSibling;
        } else {
          this.list.insertBefore(item.dom, domPos);
        }
      }

      while (domPos) rm();
    }

    moveSelection(selectedIndex) {
      if (this.selectedIndex < 0) return;
      let field = this.view.state.field(lintState);
      let selection = findDiagnostic(field.diagnostics, this.items[selectedIndex].diagnostic);
      if (!selection) return;
      this.view.dispatch({
        selection: {
          anchor: selection.from,
          head: selection.to
        },
        scrollIntoView: true,
        effects: movePanelSelection.of(selection)
      });
    }

    static open(view) {
      return new LintPanel(view);
    }

  }

  function svg(content, attrs = `viewBox="0 0 40 40"`) {
    return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${attrs}>${encodeURIComponent(content)}</svg>')`;
  }

  function underline(color) {
    return svg(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${color}" fill="none" stroke-width=".7"/>`, `width="6" height="3"`);
  }

  const baseTheme$1 = /*@__PURE__*/EditorView.baseTheme({
    ".cm-diagnostic": {
      padding: "3px 6px 3px 8px",
      marginLeft: "-1px",
      display: "block",
      whiteSpace: "pre-wrap"
    },
    ".cm-diagnostic-error": {
      borderLeft: "5px solid #d11"
    },
    ".cm-diagnostic-warning": {
      borderLeft: "5px solid orange"
    },
    ".cm-diagnostic-info": {
      borderLeft: "5px solid #999"
    },
    ".cm-diagnosticAction": {
      font: "inherit",
      border: "none",
      padding: "2px 4px",
      backgroundColor: "#444",
      color: "white",
      borderRadius: "3px",
      marginLeft: "8px"
    },
    ".cm-diagnosticSource": {
      fontSize: "70%",
      opacity: .7
    },
    ".cm-lintRange": {
      backgroundPosition: "left bottom",
      backgroundRepeat: "repeat-x",
      paddingBottom: "0.7px"
    },
    ".cm-lintRange-error": {
      backgroundImage: /*@__PURE__*/underline("#d11")
    },
    ".cm-lintRange-warning": {
      backgroundImage: /*@__PURE__*/underline("orange")
    },
    ".cm-lintRange-info": {
      backgroundImage: /*@__PURE__*/underline("#999")
    },
    ".cm-lintRange-active": {
      backgroundColor: "#ffdd9980"
    },
    ".cm-tooltip-lint": {
      padding: 0,
      margin: 0
    },
    ".cm-lintPoint": {
      position: "relative",
      "&:after": {
        content: '""',
        position: "absolute",
        bottom: 0,
        left: "-2px",
        borderLeft: "3px solid transparent",
        borderRight: "3px solid transparent",
        borderBottom: "4px solid #d11"
      }
    },
    ".cm-lintPoint-warning": {
      "&:after": {
        borderBottomColor: "orange"
      }
    },
    ".cm-lintPoint-info": {
      "&:after": {
        borderBottomColor: "#999"
      }
    },
    ".cm-panel.cm-panel-lint": {
      position: "relative",
      "& ul": {
        maxHeight: "100px",
        overflowY: "auto",
        "& [aria-selected]": {
          backgroundColor: "#ddd",
          "& u": {
            textDecoration: "underline"
          }
        },
        "&:focus [aria-selected]": {
          background_fallback: "#bdf",
          backgroundColor: "Highlight",
          color_fallback: "white",
          color: "HighlightText"
        },
        "& u": {
          textDecoration: "none"
        },
        padding: 0,
        margin: 0
      },
      "& [name=close]": {
        position: "absolute",
        top: "0",
        right: "2px",
        background: "inherit",
        border: "none",
        font: "inherit",
        padding: 0,
        margin: 0
      }
    }
  });

  /// parsing progress. They also provide some properties and methods
  /// that external code such as a tokenizer can use to get information
  /// about the parse state.

  class Stack {
    /// @internal
    constructor( /// The parse that this stack is part of @internal
    p, /// Holds state, input pos, buffer index triplets for all but the
    /// top state @internal
    stack, /// The current parse state @internal
    state, // The position at which the next reduce should take place. This
    // can be less than `this.pos` when skipped expressions have been
    // added to the stack (which should be moved outside of the next
    // reduction)
    /// @internal
    reducePos, /// The input position up to which this stack has parsed.
    pos, /// The dynamic score of the stack, including dynamic precedence
    /// and error-recovery penalties
    /// @internal
    score, // The output buffer. Holds (type, start, end, size) quads
    // representing nodes created by the parser, where `size` is
    // amount of buffer array entries covered by this node.
    /// @internal
    buffer, // The base offset of the buffer. When stacks are split, the split
    // instance shared the buffer history with its parent up to
    // `bufferBase`, which is the absolute offset (including the
    // offset of previous splits) into the buffer at which this stack
    // starts writing.
    /// @internal
    bufferBase, /// @internal
    curContext, /// @internal
    lookAhead = 0, // A parent stack from which this was split off, if any. This is
    // set up so that it always points to a stack that has some
    // additional buffer content, never to a stack with an equal
    // `bufferBase`.
    /// @internal
    parent) {
      this.p = p;
      this.stack = stack;
      this.state = state;
      this.reducePos = reducePos;
      this.pos = pos;
      this.score = score;
      this.buffer = buffer;
      this.bufferBase = bufferBase;
      this.curContext = curContext;
      this.lookAhead = lookAhead;
      this.parent = parent;
    } /// @internal


    toString() {
      return `[${this.stack.filter((_, i) => i % 3 == 0).concat(this.state)}]@${this.pos}${this.score ? "!" + this.score : ""}`;
    } // Start an empty stack
    /// @internal


    static start(p, state, pos = 0) {
      let cx = p.parser.context;
      return new Stack(p, [], state, pos, pos, 0, [], 0, cx ? new StackContext(cx, cx.start) : null, 0, null);
    } /// The stack's current [context](#lr.ContextTracker) value, if
    /// any. Its type will depend on the context tracker's type
    /// parameter, or it will be `null` if there is no context
    /// tracker.


    get context() {
      return this.curContext ? this.curContext.context : null;
    } // Push a state onto the stack, tracking its start position as well
    // as the buffer base at that point.
    /// @internal


    pushState(state, start) {
      this.stack.push(this.state, start, this.bufferBase + this.buffer.length);
      this.state = state;
    } // Apply a reduce action
    /// @internal


    reduce(action) {
      let depth = action >> 19
      /* ReduceDepthShift */
      ,
          type = action & 65535
      /* ValueMask */
      ;
      let {
        parser
      } = this.p;
      let dPrec = parser.dynamicPrecedence(type);
      if (dPrec) this.score += dPrec;

      if (depth == 0) {
        this.pushState(parser.getGoto(this.state, type, true), this.reducePos); // Zero-depth reductions are a special case—they add stuff to
        // the stack without popping anything off.

        if (type < parser.minRepeatTerm) this.storeNode(type, this.reducePos, this.reducePos, 4, true);
        this.reduceContext(type, this.reducePos);
        return;
      } // Find the base index into `this.stack`, content after which will
      // be dropped. Note that with `StayFlag` reductions we need to
      // consume two extra frames (the dummy parent node for the skipped
      // expression and the state that we'll be staying in, which should
      // be moved to `this.state`).


      let base = this.stack.length - (depth - 1) * 3 - (action & 262144
      /* StayFlag */
      ? 6 : 0);
      let start = this.stack[base - 2];
      let bufferBase = this.stack[base - 1],
          count = this.bufferBase + this.buffer.length - bufferBase; // Store normal terms or `R -> R R` repeat reductions

      if (type < parser.minRepeatTerm || action & 131072
      /* RepeatFlag */
      ) {
        let pos = parser.stateFlag(this.state, 1
        /* Skipped */
        ) ? this.pos : this.reducePos;
        this.storeNode(type, start, pos, count + 4, true);
      }

      if (action & 262144
      /* StayFlag */
      ) {
        this.state = this.stack[base];
      } else {
        let baseStateID = this.stack[base - 3];
        this.state = parser.getGoto(baseStateID, type, true);
      }

      while (this.stack.length > base) this.stack.pop();

      this.reduceContext(type, start);
    } // Shift a value into the buffer
    /// @internal


    storeNode(term, start, end, size = 4, isReduce = false) {
      if (term == 0
      /* Err */
      && (!this.stack.length || this.stack[this.stack.length - 1] < this.buffer.length + this.bufferBase)) {
        // Try to omit/merge adjacent error nodes
        let cur = this,
            top = this.buffer.length;

        if (top == 0 && cur.parent) {
          top = cur.bufferBase - cur.parent.bufferBase;
          cur = cur.parent;
        }

        if (top > 0 && cur.buffer[top - 4] == 0
        /* Err */
        && cur.buffer[top - 1] > -1) {
          if (start == end) return;

          if (cur.buffer[top - 2] >= start) {
            cur.buffer[top - 2] = end;
            return;
          }
        }
      }

      if (!isReduce || this.pos == end) {
        // Simple case, just append
        this.buffer.push(term, start, end, size);
      } else {
        // There may be skipped nodes that have to be moved forward
        let index = this.buffer.length;
        if (index > 0 && this.buffer[index - 4] != 0
        /* Err */
        ) while (index > 0 && this.buffer[index - 2] > end) {
          // Move this record forward
          this.buffer[index] = this.buffer[index - 4];
          this.buffer[index + 1] = this.buffer[index - 3];
          this.buffer[index + 2] = this.buffer[index - 2];
          this.buffer[index + 3] = this.buffer[index - 1];
          index -= 4;
          if (size > 4) size -= 4;
        }
        this.buffer[index] = term;
        this.buffer[index + 1] = start;
        this.buffer[index + 2] = end;
        this.buffer[index + 3] = size;
      }
    } // Apply a shift action
    /// @internal


    shift(action, next, nextEnd) {
      let start = this.pos;

      if (action & 131072
      /* GotoFlag */
      ) {
        this.pushState(action & 65535
        /* ValueMask */
        , this.pos);
      } else if ((action & 262144
      /* StayFlag */
      ) == 0) {
        // Regular shift
        let nextState = action,
            {
          parser
        } = this.p;

        if (nextEnd > this.pos || next <= parser.maxNode) {
          this.pos = nextEnd;
          if (!parser.stateFlag(nextState, 1
          /* Skipped */
          )) this.reducePos = nextEnd;
        }

        this.pushState(nextState, start);
        this.shiftContext(next, start);
        if (next <= parser.maxNode) this.buffer.push(next, start, nextEnd, 4);
      } else {
        // Shift-and-stay, which means this is a skipped token
        this.pos = nextEnd;
        this.shiftContext(next, start);
        if (next <= this.p.parser.maxNode) this.buffer.push(next, start, nextEnd, 4);
      }
    } // Apply an action
    /// @internal


    apply(action, next, nextEnd) {
      if (action & 65536
      /* ReduceFlag */
      ) this.reduce(action);else this.shift(action, next, nextEnd);
    } // Add a prebuilt (reused) node into the buffer.
    /// @internal


    useNode(value, next) {
      let index = this.p.reused.length - 1;

      if (index < 0 || this.p.reused[index] != value) {
        this.p.reused.push(value);
        index++;
      }

      let start = this.pos;
      this.reducePos = this.pos = start + value.length;
      this.pushState(next, start);
      this.buffer.push(index, start, this.reducePos, -1
      /* size == -1 means this is a reused value */
      );
      if (this.curContext) this.updateContext(this.curContext.tracker.reuse(this.curContext.context, value, this, this.p.stream.reset(this.pos - value.length)));
    } // Split the stack. Due to the buffer sharing and the fact
    // that `this.stack` tends to stay quite shallow, this isn't very
    // expensive.
    /// @internal


    split() {
      let parent = this;
      let off = parent.buffer.length; // Because the top of the buffer (after this.pos) may be mutated
      // to reorder reductions and skipped tokens, and shared buffers
      // should be immutable, this copies any outstanding skipped tokens
      // to the new buffer, and puts the base pointer before them.

      while (off > 0 && parent.buffer[off - 2] > parent.reducePos) off -= 4;

      let buffer = parent.buffer.slice(off),
          base = parent.bufferBase + off; // Make sure parent points to an actual parent with content, if there is such a parent.

      while (parent && base == parent.bufferBase) parent = parent.parent;

      return new Stack(this.p, this.stack.slice(), this.state, this.reducePos, this.pos, this.score, buffer, base, this.curContext, this.lookAhead, parent);
    } // Try to recover from an error by 'deleting' (ignoring) one token.
    /// @internal


    recoverByDelete(next, nextEnd) {
      let isNode = next <= this.p.parser.maxNode;
      if (isNode) this.storeNode(next, this.pos, nextEnd, 4);
      this.storeNode(0
      /* Err */
      , this.pos, nextEnd, isNode ? 8 : 4);
      this.pos = this.reducePos = nextEnd;
      this.score -= 190
      /* Delete */
      ;
    } /// Check if the given term would be able to be shifted (optionally
    /// after some reductions) on this stack. This can be useful for
    /// external tokenizers that want to make sure they only provide a
    /// given token when it applies.


    canShift(term) {
      for (let sim = new SimulatedStack(this);;) {
        let action = this.p.parser.stateSlot(sim.state, 4
        /* DefaultReduce */
        ) || this.p.parser.hasAction(sim.state, term);
        if ((action & 65536
        /* ReduceFlag */
        ) == 0) return true;
        if (action == 0) return false;
        sim.reduce(action);
      }
    } // Apply up to Recover.MaxNext recovery actions that conceptually
    // inserts some missing token or rule.
    /// @internal


    recoverByInsert(next) {
      if (this.stack.length >= 300
      /* MaxInsertStackDepth */
      ) return [];
      let nextStates = this.p.parser.nextStates(this.state);

      if (nextStates.length > 4
      /* MaxNext */
      << 1 || this.stack.length >= 120
      /* DampenInsertStackDepth */
      ) {
        let best = [];

        for (let i = 0, s; i < nextStates.length; i += 2) {
          if ((s = nextStates[i + 1]) != this.state && this.p.parser.hasAction(s, next)) best.push(nextStates[i], s);
        }

        if (this.stack.length < 120
        /* DampenInsertStackDepth */
        ) for (let i = 0; best.length < 4
        /* MaxNext */
        << 1 && i < nextStates.length; i += 2) {
          let s = nextStates[i + 1];
          if (!best.some((v, i) => i & 1 && v == s)) best.push(nextStates[i], s);
        }
        nextStates = best;
      }

      let result = [];

      for (let i = 0; i < nextStates.length && result.length < 4
      /* MaxNext */
      ; i += 2) {
        let s = nextStates[i + 1];
        if (s == this.state) continue;
        let stack = this.split();
        stack.pushState(s, this.pos);
        stack.storeNode(0
        /* Err */
        , stack.pos, stack.pos, 4, true);
        stack.shiftContext(nextStates[i], this.pos);
        stack.score -= 200
        /* Insert */
        ;
        result.push(stack);
      }

      return result;
    } // Force a reduce, if possible. Return false if that can't
    // be done.
    /// @internal


    forceReduce() {
      let reduce = this.p.parser.stateSlot(this.state, 5
      /* ForcedReduce */
      );
      if ((reduce & 65536
      /* ReduceFlag */
      ) == 0) return false;
      let {
        parser
      } = this.p;

      if (!parser.validAction(this.state, reduce)) {
        let depth = reduce >> 19
        /* ReduceDepthShift */
        ,
            term = reduce & 65535
        /* ValueMask */
        ;
        let target = this.stack.length - depth * 3;
        if (target < 0 || parser.getGoto(this.stack[target], term, false) < 0) return false;
        this.storeNode(0
        /* Err */
        , this.reducePos, this.reducePos, 4, true);
        this.score -= 100
        /* Reduce */
        ;
      }

      this.reducePos = this.pos;
      this.reduce(reduce);
      return true;
    } /// @internal


    forceAll() {
      while (!this.p.parser.stateFlag(this.state, 2
      /* Accepting */
      )) {
        if (!this.forceReduce()) {
          this.storeNode(0
          /* Err */
          , this.pos, this.pos, 4, true);
          break;
        }
      }

      return this;
    } /// Check whether this state has no further actions (assumed to be a direct descendant of the
    /// top state, since any other states must be able to continue
    /// somehow). @internal


    get deadEnd() {
      if (this.stack.length != 3) return false;
      let {
        parser
      } = this.p;
      return parser.data[parser.stateSlot(this.state, 1
      /* Actions */
      )] == 65535
      /* End */
      && !parser.stateSlot(this.state, 4
      /* DefaultReduce */
      );
    } /// Restart the stack (put it back in its start state). Only safe
    /// when this.stack.length == 3 (state is directly below the top
    /// state). @internal


    restart() {
      this.state = this.stack[0];
      this.stack.length = 0;
    } /// @internal


    sameState(other) {
      if (this.state != other.state || this.stack.length != other.stack.length) return false;

      for (let i = 0; i < this.stack.length; i += 3) if (this.stack[i] != other.stack[i]) return false;

      return true;
    } /// Get the parser used by this stack.


    get parser() {
      return this.p.parser;
    } /// Test whether a given dialect (by numeric ID, as exported from
    /// the terms file) is enabled.


    dialectEnabled(dialectID) {
      return this.p.parser.dialect.flags[dialectID];
    }

    shiftContext(term, start) {
      if (this.curContext) this.updateContext(this.curContext.tracker.shift(this.curContext.context, term, this, this.p.stream.reset(start)));
    }

    reduceContext(term, start) {
      if (this.curContext) this.updateContext(this.curContext.tracker.reduce(this.curContext.context, term, this, this.p.stream.reset(start)));
    } /// @internal


    emitContext() {
      let last = this.buffer.length - 1;
      if (last < 0 || this.buffer[last] != -3) this.buffer.push(this.curContext.hash, this.reducePos, this.reducePos, -3);
    } /// @internal


    emitLookAhead() {
      let last = this.buffer.length - 1;
      if (last < 0 || this.buffer[last] != -4) this.buffer.push(this.lookAhead, this.reducePos, this.reducePos, -4);
    }

    updateContext(context) {
      if (context != this.curContext.context) {
        let newCx = new StackContext(this.curContext.tracker, context);
        if (newCx.hash != this.curContext.hash) this.emitContext();
        this.curContext = newCx;
      }
    } /// @internal


    setLookAhead(lookAhead) {
      if (lookAhead > this.lookAhead) {
        this.emitLookAhead();
        this.lookAhead = lookAhead;
      }
    } /// @internal


    close() {
      if (this.curContext && this.curContext.tracker.strict) this.emitContext();
      if (this.lookAhead > 0) this.emitLookAhead();
    }

  }

  class StackContext {
    constructor(tracker, context) {
      this.tracker = tracker;
      this.context = context;
      this.hash = tracker.strict ? tracker.hash(context) : 0;
    }

  }

  var Recover;

  (function (Recover) {
    Recover[Recover["Insert"] = 200] = "Insert";
    Recover[Recover["Delete"] = 190] = "Delete";
    Recover[Recover["Reduce"] = 100] = "Reduce";
    Recover[Recover["MaxNext"] = 4] = "MaxNext";
    Recover[Recover["MaxInsertStackDepth"] = 300] = "MaxInsertStackDepth";
    Recover[Recover["DampenInsertStackDepth"] = 120] = "DampenInsertStackDepth";
  })(Recover || (Recover = {})); // Used to cheaply run some reductions to scan ahead without mutating
  // an entire stack


  class SimulatedStack {
    constructor(start) {
      this.start = start;
      this.state = start.state;
      this.stack = start.stack;
      this.base = this.stack.length;
    }

    reduce(action) {
      let term = action & 65535
      /* ValueMask */
      ,
          depth = action >> 19
      /* ReduceDepthShift */
      ;

      if (depth == 0) {
        if (this.stack == this.start.stack) this.stack = this.stack.slice();
        this.stack.push(this.state, 0, 0);
        this.base += 3;
      } else {
        this.base -= (depth - 1) * 3;
      }

      let goto = this.start.p.parser.getGoto(this.stack[this.base - 3], term, true);
      this.state = goto;
    }

  } // This is given to `Tree.build` to build a buffer, and encapsulates
  // the parent-stack-walking necessary to read the nodes.


  class StackBufferCursor {
    constructor(stack, pos, index) {
      this.stack = stack;
      this.pos = pos;
      this.index = index;
      this.buffer = stack.buffer;
      if (this.index == 0) this.maybeNext();
    }

    static create(stack, pos = stack.bufferBase + stack.buffer.length) {
      return new StackBufferCursor(stack, pos, pos - stack.bufferBase);
    }

    maybeNext() {
      let next = this.stack.parent;

      if (next != null) {
        this.index = this.stack.bufferBase - next.bufferBase;
        this.stack = next;
        this.buffer = next.buffer;
      }
    }

    get id() {
      return this.buffer[this.index - 4];
    }

    get start() {
      return this.buffer[this.index - 3];
    }

    get end() {
      return this.buffer[this.index - 2];
    }

    get size() {
      return this.buffer[this.index - 1];
    }

    next() {
      this.index -= 4;
      this.pos -= 4;
      if (this.index == 0) this.maybeNext();
    }

    fork() {
      return new StackBufferCursor(this.stack, this.pos, this.index);
    }

  }

  class CachedToken {
    constructor() {
      this.start = -1;
      this.value = -1;
      this.end = -1;
      this.extended = -1;
      this.lookAhead = 0;
      this.mask = 0;
      this.context = 0;
    }

  }

  const nullToken = new CachedToken(); /// [Tokenizers](#lr.ExternalTokenizer) interact with the input
  /// through this interface. It presents the input as a stream of
  /// characters, tracking lookahead and hiding the complexity of
  /// [ranges](#common.Parser.parse^ranges) from tokenizer code.

  class InputStream {
    /// @internal
    constructor( /// @internal
    input, /// @internal
    ranges) {
      this.input = input;
      this.ranges = ranges; /// @internal

      this.chunk = ""; /// @internal

      this.chunkOff = 0; /// Backup chunk

      this.chunk2 = "";
      this.chunk2Pos = 0; /// The character code of the next code unit in the input, or -1
      /// when the stream is at the end of the input.

      this.next = -1; /// @internal

      this.token = nullToken;
      this.rangeIndex = 0;
      this.pos = this.chunkPos = ranges[0].from;
      this.range = ranges[0];
      this.end = ranges[ranges.length - 1].to;
      this.readNext();
    } /// @internal


    resolveOffset(offset, assoc) {
      let range = this.range,
          index = this.rangeIndex;
      let pos = this.pos + offset;

      while (pos < range.from) {
        if (!index) return null;
        let next = this.ranges[--index];
        pos -= range.from - next.to;
        range = next;
      }

      while (assoc < 0 ? pos > range.to : pos >= range.to) {
        if (index == this.ranges.length - 1) return null;
        let next = this.ranges[++index];
        pos += next.from - range.to;
        range = next;
      }

      return pos;
    } /// @internal


    clipPos(pos) {
      if (pos >= this.range.from && pos < this.range.to) return pos;

      for (let range of this.ranges) if (range.to > pos) return Math.max(pos, range.from);

      return this.end;
    } /// Look at a code unit near the stream position. `.peek(0)` equals
    /// `.next`, `.peek(-1)` gives you the previous character, and so
    /// on.
    ///
    /// Note that looking around during tokenizing creates dependencies
    /// on potentially far-away content, which may reduce the
    /// effectiveness incremental parsing—when looking forward—or even
    /// cause invalid reparses when looking backward more than 25 code
    /// units, since the library does not track lookbehind.


    peek(offset) {
      let idx = this.chunkOff + offset,
          pos,
          result;

      if (idx >= 0 && idx < this.chunk.length) {
        pos = this.pos + offset;
        result = this.chunk.charCodeAt(idx);
      } else {
        let resolved = this.resolveOffset(offset, 1);
        if (resolved == null) return -1;
        pos = resolved;

        if (pos >= this.chunk2Pos && pos < this.chunk2Pos + this.chunk2.length) {
          result = this.chunk2.charCodeAt(pos - this.chunk2Pos);
        } else {
          let i = this.rangeIndex,
              range = this.range;

          while (range.to <= pos) range = this.ranges[++i];

          this.chunk2 = this.input.chunk(this.chunk2Pos = pos);
          if (pos + this.chunk2.length > range.to) this.chunk2 = this.chunk2.slice(0, range.to - pos);
          result = this.chunk2.charCodeAt(0);
        }
      }

      if (pos >= this.token.lookAhead) this.token.lookAhead = pos + 1;
      return result;
    } /// Accept a token. By default, the end of the token is set to the
    /// current stream position, but you can pass an offset (relative to
    /// the stream position) to change that.


    acceptToken(token, endOffset = 0) {
      let end = endOffset ? this.resolveOffset(endOffset, -1) : this.pos;
      if (end == null || end < this.token.start) throw new RangeError("Token end out of bounds");
      this.token.value = token;
      this.token.end = end;
    }

    getChunk() {
      if (this.pos >= this.chunk2Pos && this.pos < this.chunk2Pos + this.chunk2.length) {
        let {
          chunk,
          chunkPos
        } = this;
        this.chunk = this.chunk2;
        this.chunkPos = this.chunk2Pos;
        this.chunk2 = chunk;
        this.chunk2Pos = chunkPos;
        this.chunkOff = this.pos - this.chunkPos;
      } else {
        this.chunk2 = this.chunk;
        this.chunk2Pos = this.chunkPos;
        let nextChunk = this.input.chunk(this.pos);
        let end = this.pos + nextChunk.length;
        this.chunk = end > this.range.to ? nextChunk.slice(0, this.range.to - this.pos) : nextChunk;
        this.chunkPos = this.pos;
        this.chunkOff = 0;
      }
    }

    readNext() {
      if (this.chunkOff >= this.chunk.length) {
        this.getChunk();
        if (this.chunkOff == this.chunk.length) return this.next = -1;
      }

      return this.next = this.chunk.charCodeAt(this.chunkOff);
    } /// Move the stream forward N (defaults to 1) code units. Returns
    /// the new value of [`next`](#lr.InputStream.next).


    advance(n = 1) {
      this.chunkOff += n;

      while (this.pos + n >= this.range.to) {
        if (this.rangeIndex == this.ranges.length - 1) return this.setDone();
        n -= this.range.to - this.pos;
        this.range = this.ranges[++this.rangeIndex];
        this.pos = this.range.from;
      }

      this.pos += n;
      if (this.pos >= this.token.lookAhead) this.token.lookAhead = this.pos + 1;
      return this.readNext();
    }

    setDone() {
      this.pos = this.chunkPos = this.end;
      this.range = this.ranges[this.rangeIndex = this.ranges.length - 1];
      this.chunk = "";
      return this.next = -1;
    } /// @internal


    reset(pos, token) {
      if (token) {
        this.token = token;
        token.start = pos;
        token.lookAhead = pos + 1;
        token.value = token.extended = -1;
      } else {
        this.token = nullToken;
      }

      if (this.pos != pos) {
        this.pos = pos;

        if (pos == this.end) {
          this.setDone();
          return this;
        }

        while (pos < this.range.from) this.range = this.ranges[--this.rangeIndex];

        while (pos >= this.range.to) this.range = this.ranges[++this.rangeIndex];

        if (pos >= this.chunkPos && pos < this.chunkPos + this.chunk.length) {
          this.chunkOff = pos - this.chunkPos;
        } else {
          this.chunk = "";
          this.chunkOff = 0;
        }

        this.readNext();
      }

      return this;
    } /// @internal


    read(from, to) {
      if (from >= this.chunkPos && to <= this.chunkPos + this.chunk.length) return this.chunk.slice(from - this.chunkPos, to - this.chunkPos);
      if (from >= this.chunk2Pos && to <= this.chunk2Pos + this.chunk2.length) return this.chunk2.slice(from - this.chunk2Pos, to - this.chunk2Pos);
      if (from >= this.range.from && to <= this.range.to) return this.input.read(from, to);
      let result = "";

      for (let r of this.ranges) {
        if (r.from >= to) break;
        if (r.to > from) result += this.input.read(Math.max(r.from, from), Math.min(r.to, to));
      }

      return result;
    }

  } /// @internal


  class TokenGroup {
    constructor(data, id) {
      this.data = data;
      this.id = id;
    }

    token(input, stack) {
      readToken(this.data, input, stack, this.id);
    }

  }

  TokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false; /// `@external tokens` declarations in the grammar should resolve to
  /// an instance of this class.

  class ExternalTokenizer {
    /// Create a tokenizer. The first argument is the function that,
    /// given an input stream, scans for the types of tokens it
    /// recognizes at the stream's position, and calls
    /// [`acceptToken`](#lr.InputStream.acceptToken) when it finds
    /// one.
    constructor( /// @internal
    token, options = {}) {
      this.token = token;
      this.contextual = !!options.contextual;
      this.fallback = !!options.fallback;
      this.extend = !!options.extend;
    }

  } // Tokenizer data is stored a big uint16 array containing, for each
  // state:
  //
  //  - A group bitmask, indicating what token groups are reachable from
  //    this state, so that paths that can only lead to tokens not in
  //    any of the current groups can be cut off early.
  //
  //  - The position of the end of the state's sequence of accepting
  //    tokens
  //
  //  - The number of outgoing edges for the state
  //
  //  - The accepting tokens, as (token id, group mask) pairs
  //
  //  - The outgoing edges, as (start character, end character, state
  //    index) triples, with end character being exclusive
  //
  // This function interprets that data, running through a stream as
  // long as new states with the a matching group mask can be reached,
  // and updating `input.token` when it matches a token.


  function readToken(data, input, stack, group) {
    let state = 0,
        groupMask = 1 << group,
        {
      parser
    } = stack.p,
        {
      dialect
    } = parser;

    scan: for (;;) {
      if ((groupMask & data[state]) == 0) break;
      let accEnd = data[state + 1]; // Check whether this state can lead to a token in the current group
      // Accept tokens in this state, possibly overwriting
      // lower-precedence / shorter tokens

      for (let i = state + 3; i < accEnd; i += 2) if ((data[i + 1] & groupMask) > 0) {
        let term = data[i];

        if (dialect.allows(term) && (input.token.value == -1 || input.token.value == term || parser.overrides(term, input.token.value))) {
          input.acceptToken(term);
          break;
        }
      }

      let next = input.next,
          low = 0,
          high = data[state + 2]; // Special case for EOF

      if (input.next < 0 && high > low && data[accEnd + high * 3 - 3] == 65535
      /* End */
      ) {
        state = data[accEnd + high * 3 - 1];
        continue scan;
      } // Do a binary search on the state's edges


      for (; low < high;) {
        let mid = low + high >> 1;
        let index = accEnd + mid + (mid << 1);
        let from = data[index],
            to = data[index + 1];
        if (next < from) high = mid;else if (next >= to) low = mid + 1;else {
          state = data[index + 2];
          input.advance();
          continue scan;
        }
      }

      break;
    }
  } // See lezer-generator/src/encode.ts for comments about the encoding
  // used here


  function decodeArray(input, Type = Uint16Array) {
    if (typeof input != "string") return input;
    let array = null;

    for (let pos = 0, out = 0; pos < input.length;) {
      let value = 0;

      for (;;) {
        let next = input.charCodeAt(pos++),
            stop = false;

        if (next == 126
        /* BigValCode */
        ) {
          value = 65535
          /* BigVal */
          ;
          break;
        }

        if (next >= 92
        /* Gap2 */
        ) next--;
        if (next >= 34
        /* Gap1 */
        ) next--;
        let digit = next - 32
        /* Start */
        ;

        if (digit >= 46
        /* Base */
        ) {
          digit -= 46
          /* Base */
          ;
          stop = true;
        }

        value += digit;
        if (stop) break;
        value *= 46
        /* Base */
        ;
      }

      if (array) array[out++] = value;else array = new Type(value);
    }

    return array;
  } // Environment variable used to control console output


  const verbose = typeof process != "undefined" && process.env && /\bparse\b/.test(process.env.LOG);
  let stackIDs = null;
  var Safety;

  (function (Safety) {
    Safety[Safety["Margin"] = 25] = "Margin";
  })(Safety || (Safety = {}));

  function cutAt(tree, pos, side) {
    let cursor = tree.cursor(IterMode.IncludeAnonymous);
    cursor.moveTo(pos);

    for (;;) {
      if (!(side < 0 ? cursor.childBefore(pos) : cursor.childAfter(pos))) for (;;) {
        if ((side < 0 ? cursor.to < pos : cursor.from > pos) && !cursor.type.isError) return side < 0 ? Math.max(0, Math.min(cursor.to - 1, pos - 25
        /* Margin */
        )) : Math.min(tree.length, Math.max(cursor.from + 1, pos + 25
        /* Margin */
        ));
        if (side < 0 ? cursor.prevSibling() : cursor.nextSibling()) break;
        if (!cursor.parent()) return side < 0 ? 0 : tree.length;
      }
    }
  }

  class FragmentCursor {
    constructor(fragments, nodeSet) {
      this.fragments = fragments;
      this.nodeSet = nodeSet;
      this.i = 0;
      this.fragment = null;
      this.safeFrom = -1;
      this.safeTo = -1;
      this.trees = [];
      this.start = [];
      this.index = [];
      this.nextFragment();
    }

    nextFragment() {
      let fr = this.fragment = this.i == this.fragments.length ? null : this.fragments[this.i++];

      if (fr) {
        this.safeFrom = fr.openStart ? cutAt(fr.tree, fr.from + fr.offset, 1) - fr.offset : fr.from;
        this.safeTo = fr.openEnd ? cutAt(fr.tree, fr.to + fr.offset, -1) - fr.offset : fr.to;

        while (this.trees.length) {
          this.trees.pop();
          this.start.pop();
          this.index.pop();
        }

        this.trees.push(fr.tree);
        this.start.push(-fr.offset);
        this.index.push(0);
        this.nextStart = this.safeFrom;
      } else {
        this.nextStart = 1e9;
      }
    } // `pos` must be >= any previously given `pos` for this cursor


    nodeAt(pos) {
      if (pos < this.nextStart) return null;

      while (this.fragment && this.safeTo <= pos) this.nextFragment();

      if (!this.fragment) return null;

      for (;;) {
        let last = this.trees.length - 1;

        if (last < 0) {
          // End of tree
          this.nextFragment();
          return null;
        }

        let top = this.trees[last],
            index = this.index[last];

        if (index == top.children.length) {
          this.trees.pop();
          this.start.pop();
          this.index.pop();
          continue;
        }

        let next = top.children[index];
        let start = this.start[last] + top.positions[index];

        if (start > pos) {
          this.nextStart = start;
          return null;
        }

        if (next instanceof Tree) {
          if (start == pos) {
            if (start < this.safeFrom) return null;
            let end = start + next.length;

            if (end <= this.safeTo) {
              let lookAhead = next.prop(NodeProp.lookAhead);
              if (!lookAhead || end + lookAhead < this.fragment.to) return next;
            }
          }

          this.index[last]++;

          if (start + next.length >= Math.max(this.safeFrom, pos)) {
            // Enter this node
            this.trees.push(next);
            this.start.push(start);
            this.index.push(0);
          }
        } else {
          this.index[last]++;
          this.nextStart = start + next.length;
        }
      }
    }

  }

  class TokenCache {
    constructor(parser, stream) {
      this.stream = stream;
      this.tokens = [];
      this.mainToken = null;
      this.actions = [];
      this.tokens = parser.tokenizers.map(_ => new CachedToken());
    }

    getActions(stack) {
      let actionIndex = 0;
      let main = null;
      let {
        parser
      } = stack.p,
          {
        tokenizers
      } = parser;
      let mask = parser.stateSlot(stack.state, 3
      /* TokenizerMask */
      );
      let context = stack.curContext ? stack.curContext.hash : 0;
      let lookAhead = 0;

      for (let i = 0; i < tokenizers.length; i++) {
        if ((1 << i & mask) == 0) continue;
        let tokenizer = tokenizers[i],
            token = this.tokens[i];
        if (main && !tokenizer.fallback) continue;

        if (tokenizer.contextual || token.start != stack.pos || token.mask != mask || token.context != context) {
          this.updateCachedToken(token, tokenizer, stack);
          token.mask = mask;
          token.context = context;
        }

        if (token.lookAhead > token.end + 25
        /* Margin */
        ) lookAhead = Math.max(token.lookAhead, lookAhead);

        if (token.value != 0
        /* Err */
        ) {
          let startIndex = actionIndex;
          if (token.extended > -1) actionIndex = this.addActions(stack, token.extended, token.end, actionIndex);
          actionIndex = this.addActions(stack, token.value, token.end, actionIndex);

          if (!tokenizer.extend) {
            main = token;
            if (actionIndex > startIndex) break;
          }
        }
      }

      while (this.actions.length > actionIndex) this.actions.pop();

      if (lookAhead) stack.setLookAhead(lookAhead);

      if (!main && stack.pos == this.stream.end) {
        main = new CachedToken();
        main.value = stack.p.parser.eofTerm;
        main.start = main.end = stack.pos;
        actionIndex = this.addActions(stack, main.value, main.end, actionIndex);
      }

      this.mainToken = main;
      return this.actions;
    }

    getMainToken(stack) {
      if (this.mainToken) return this.mainToken;
      let main = new CachedToken(),
          {
        pos,
        p
      } = stack;
      main.start = pos;
      main.end = Math.min(pos + 1, p.stream.end);
      main.value = pos == p.stream.end ? p.parser.eofTerm : 0
      /* Err */
      ;
      return main;
    }

    updateCachedToken(token, tokenizer, stack) {
      let start = this.stream.clipPos(stack.pos);
      tokenizer.token(this.stream.reset(start, token), stack);

      if (token.value > -1) {
        let {
          parser
        } = stack.p;

        for (let i = 0; i < parser.specialized.length; i++) if (parser.specialized[i] == token.value) {
          let result = parser.specializers[i](this.stream.read(token.start, token.end), stack);

          if (result >= 0 && stack.p.parser.dialect.allows(result >> 1)) {
            if ((result & 1) == 0
            /* Specialize */
            ) token.value = result >> 1;else token.extended = result >> 1;
            break;
          }
        }
      } else {
        token.value = 0
        /* Err */
        ;
        token.end = this.stream.clipPos(start + 1);
      }
    }

    putAction(action, token, end, index) {
      // Don't add duplicate actions
      for (let i = 0; i < index; i += 3) if (this.actions[i] == action) return index;

      this.actions[index++] = action;
      this.actions[index++] = token;
      this.actions[index++] = end;
      return index;
    }

    addActions(stack, token, end, index) {
      let {
        state
      } = stack,
          {
        parser
      } = stack.p,
          {
        data
      } = parser;

      for (let set = 0; set < 2; set++) {
        for (let i = parser.stateSlot(state, set ? 2
        /* Skip */
        : 1
        /* Actions */
        );; i += 3) {
          if (data[i] == 65535
          /* End */
          ) {
            if (data[i + 1] == 1
            /* Next */
            ) {
              i = pair(data, i + 2);
            } else {
              if (index == 0 && data[i + 1] == 2
              /* Other */
              ) index = this.putAction(pair(data, i + 2), token, end, index);
              break;
            }
          }

          if (data[i] == token) index = this.putAction(pair(data, i + 1), token, end, index);
        }
      }

      return index;
    }

  }

  var Rec;

  (function (Rec) {
    Rec[Rec["Distance"] = 5] = "Distance";
    Rec[Rec["MaxRemainingPerStep"] = 3] = "MaxRemainingPerStep"; // When two stacks have been running independently long enough to
    // add this many elements to their buffers, prune one.

    Rec[Rec["MinBufferLengthPrune"] = 500] = "MinBufferLengthPrune";
    Rec[Rec["ForceReduceLimit"] = 10] = "ForceReduceLimit"; // Once a stack reaches this depth (in .stack.length) force-reduce
    // it back to CutTo to avoid creating trees that overflow the stack
    // on recursive traversal.

    Rec[Rec["CutDepth"] = 15000] = "CutDepth";
    Rec[Rec["CutTo"] = 9000] = "CutTo";
  })(Rec || (Rec = {}));

  class Parse {
    constructor(parser, input, fragments, ranges) {
      this.parser = parser;
      this.input = input;
      this.ranges = ranges;
      this.recovering = 0;
      this.nextStackID = 0x2654; // ♔, ♕, ♖, ♗, ♘, ♙, ♠, ♡, ♢, ♣, ♤, ♥, ♦, ♧

      this.minStackPos = 0;
      this.reused = [];
      this.stoppedAt = null;
      this.stream = new InputStream(input, ranges);
      this.tokens = new TokenCache(parser, this.stream);
      this.topTerm = parser.top[1];
      let {
        from
      } = ranges[0];
      this.stacks = [Stack.start(this, parser.top[0], from)];
      this.fragments = fragments.length && this.stream.end - from > parser.bufferLength * 4 ? new FragmentCursor(fragments, parser.nodeSet) : null;
    }

    get parsedPos() {
      return this.minStackPos;
    } // Move the parser forward. This will process all parse stacks at
    // `this.pos` and try to advance them to a further position. If no
    // stack for such a position is found, it'll start error-recovery.
    //
    // When the parse is finished, this will return a syntax tree. When
    // not, it returns `null`.


    advance() {
      let stacks = this.stacks,
          pos = this.minStackPos; // This will hold stacks beyond `pos`.

      let newStacks = this.stacks = [];
      let stopped, stoppedTokens; // Keep advancing any stacks at `pos` until they either move
      // forward or can't be advanced. Gather stacks that can't be
      // advanced further in `stopped`.

      for (let i = 0; i < stacks.length; i++) {
        let stack = stacks[i];

        for (;;) {
          this.tokens.mainToken = null;

          if (stack.pos > pos) {
            newStacks.push(stack);
          } else if (this.advanceStack(stack, newStacks, stacks)) {
            continue;
          } else {
            if (!stopped) {
              stopped = [];
              stoppedTokens = [];
            }

            stopped.push(stack);
            let tok = this.tokens.getMainToken(stack);
            stoppedTokens.push(tok.value, tok.end);
          }

          break;
        }
      }

      if (!newStacks.length) {
        let finished = stopped && findFinished(stopped);
        if (finished) return this.stackToTree(finished);

        if (this.parser.strict) {
          if (verbose && stopped) console.log("Stuck with token " + (this.tokens.mainToken ? this.parser.getName(this.tokens.mainToken.value) : "none"));
          throw new SyntaxError("No parse at " + pos);
        }

        if (!this.recovering) this.recovering = 5
        /* Distance */
        ;
      }

      if (this.recovering && stopped) {
        let finished = this.stoppedAt != null && stopped[0].pos > this.stoppedAt ? stopped[0] : this.runRecovery(stopped, stoppedTokens, newStacks);
        if (finished) return this.stackToTree(finished.forceAll());
      }

      if (this.recovering) {
        let maxRemaining = this.recovering == 1 ? 1 : this.recovering * 3
        /* MaxRemainingPerStep */
        ;

        if (newStacks.length > maxRemaining) {
          newStacks.sort((a, b) => b.score - a.score);

          while (newStacks.length > maxRemaining) newStacks.pop();
        }

        if (newStacks.some(s => s.reducePos > pos)) this.recovering--;
      } else if (newStacks.length > 1) {
        // Prune stacks that are in the same state, or that have been
        // running without splitting for a while, to avoid getting stuck
        // with multiple successful stacks running endlessly on.
        outer: for (let i = 0; i < newStacks.length - 1; i++) {
          let stack = newStacks[i];

          for (let j = i + 1; j < newStacks.length; j++) {
            let other = newStacks[j];

            if (stack.sameState(other) || stack.buffer.length > 500
            /* MinBufferLengthPrune */
            && other.buffer.length > 500
            /* MinBufferLengthPrune */
            ) {
              if ((stack.score - other.score || stack.buffer.length - other.buffer.length) > 0) {
                newStacks.splice(j--, 1);
              } else {
                newStacks.splice(i--, 1);
                continue outer;
              }
            }
          }
        }
      }

      this.minStackPos = newStacks[0].pos;

      for (let i = 1; i < newStacks.length; i++) if (newStacks[i].pos < this.minStackPos) this.minStackPos = newStacks[i].pos;

      return null;
    }

    stopAt(pos) {
      if (this.stoppedAt != null && this.stoppedAt < pos) throw new RangeError("Can't move stoppedAt forward");
      this.stoppedAt = pos;
    } // Returns an updated version of the given stack, or null if the
    // stack can't advance normally. When `split` and `stacks` are
    // given, stacks split off by ambiguous operations will be pushed to
    // `split`, or added to `stacks` if they move `pos` forward.


    advanceStack(stack, stacks, split) {
      let start = stack.pos,
          {
        parser
      } = this;
      let base = verbose ? this.stackID(stack) + " -> " : "";
      if (this.stoppedAt != null && start > this.stoppedAt) return stack.forceReduce() ? stack : null;

      if (this.fragments) {
        let strictCx = stack.curContext && stack.curContext.tracker.strict,
            cxHash = strictCx ? stack.curContext.hash : 0;

        for (let cached = this.fragments.nodeAt(start); cached;) {
          let match = this.parser.nodeSet.types[cached.type.id] == cached.type ? parser.getGoto(stack.state, cached.type.id) : -1;

          if (match > -1 && cached.length && (!strictCx || (cached.prop(NodeProp.contextHash) || 0) == cxHash)) {
            stack.useNode(cached, match);
            if (verbose) console.log(base + this.stackID(stack) + ` (via reuse of ${parser.getName(cached.type.id)})`);
            return true;
          }

          if (!(cached instanceof Tree) || cached.children.length == 0 || cached.positions[0] > 0) break;
          let inner = cached.children[0];
          if (inner instanceof Tree && cached.positions[0] == 0) cached = inner;else break;
        }
      }

      let defaultReduce = parser.stateSlot(stack.state, 4
      /* DefaultReduce */
      );

      if (defaultReduce > 0) {
        stack.reduce(defaultReduce);
        if (verbose) console.log(base + this.stackID(stack) + ` (via always-reduce ${parser.getName(defaultReduce & 65535
      /* ValueMask */
      )})`);
        return true;
      }

      if (stack.stack.length >= 15000
      /* CutDepth */
      ) {
        while (stack.stack.length > 9000
        /* CutTo */
        && stack.forceReduce()) {}
      }

      let actions = this.tokens.getActions(stack);

      for (let i = 0; i < actions.length;) {
        let action = actions[i++],
            term = actions[i++],
            end = actions[i++];
        let last = i == actions.length || !split;
        let localStack = last ? stack : stack.split();
        localStack.apply(action, term, end);
        if (verbose) console.log(base + this.stackID(localStack) + ` (via ${(action & 65536
      /* ReduceFlag */
      ) == 0 ? "shift" : `reduce of ${parser.getName(action & 65535
      /* ValueMask */
      )}`} for ${parser.getName(term)} @ ${start}${localStack == stack ? "" : ", split"})`);
        if (last) return true;else if (localStack.pos > start) stacks.push(localStack);else split.push(localStack);
      }

      return false;
    } // Advance a given stack forward as far as it will go. Returns the
    // (possibly updated) stack if it got stuck, or null if it moved
    // forward and was given to `pushStackDedup`.


    advanceFully(stack, newStacks) {
      let pos = stack.pos;

      for (;;) {
        if (!this.advanceStack(stack, null, null)) return false;

        if (stack.pos > pos) {
          pushStackDedup(stack, newStacks);
          return true;
        }
      }
    }

    runRecovery(stacks, tokens, newStacks) {
      let finished = null,
          restarted = false;

      for (let i = 0; i < stacks.length; i++) {
        let stack = stacks[i],
            token = tokens[i << 1],
            tokenEnd = tokens[(i << 1) + 1];
        let base = verbose ? this.stackID(stack) + " -> " : "";

        if (stack.deadEnd) {
          if (restarted) continue;
          restarted = true;
          stack.restart();
          if (verbose) console.log(base + this.stackID(stack) + " (restarted)");
          let done = this.advanceFully(stack, newStacks);
          if (done) continue;
        }

        let force = stack.split(),
            forceBase = base;

        for (let j = 0; force.forceReduce() && j < 10
        /* ForceReduceLimit */
        ; j++) {
          if (verbose) console.log(forceBase + this.stackID(force) + " (via force-reduce)");
          let done = this.advanceFully(force, newStacks);
          if (done) break;
          if (verbose) forceBase = this.stackID(force) + " -> ";
        }

        for (let insert of stack.recoverByInsert(token)) {
          if (verbose) console.log(base + this.stackID(insert) + " (via recover-insert)");
          this.advanceFully(insert, newStacks);
        }

        if (this.stream.end > stack.pos) {
          if (tokenEnd == stack.pos) {
            tokenEnd++;
            token = 0
            /* Err */
            ;
          }

          stack.recoverByDelete(token, tokenEnd);
          if (verbose) console.log(base + this.stackID(stack) + ` (via recover-delete ${this.parser.getName(token)})`);
          pushStackDedup(stack, newStacks);
        } else if (!finished || finished.score < stack.score) {
          finished = stack;
        }
      }

      return finished;
    } // Convert the stack's buffer to a syntax tree.


    stackToTree(stack) {
      stack.close();
      return Tree.build({
        buffer: StackBufferCursor.create(stack),
        nodeSet: this.parser.nodeSet,
        topID: this.topTerm,
        maxBufferLength: this.parser.bufferLength,
        reused: this.reused,
        start: this.ranges[0].from,
        length: stack.pos - this.ranges[0].from,
        minRepeatType: this.parser.minRepeatTerm
      });
    }

    stackID(stack) {
      let id = (stackIDs || (stackIDs = new WeakMap())).get(stack);
      if (!id) stackIDs.set(stack, id = String.fromCodePoint(this.nextStackID++));
      return id + stack;
    }

  }

  function pushStackDedup(stack, newStacks) {
    for (let i = 0; i < newStacks.length; i++) {
      let other = newStacks[i];

      if (other.pos == stack.pos && other.sameState(stack)) {
        if (newStacks[i].score < stack.score) newStacks[i] = stack;
        return;
      }
    }

    newStacks.push(stack);
  }

  class Dialect {
    constructor(source, flags, disabled) {
      this.source = source;
      this.flags = flags;
      this.disabled = disabled;
    }

    allows(term) {
      return !this.disabled || this.disabled[term] == 0;
    }

  }

  const id = x => x; /// Context trackers are used to track stateful context (such as
  /// indentation in the Python grammar, or parent elements in the XML
  /// grammar) needed by external tokenizers. You declare them in a
  /// grammar file as `@context exportName from "module"`.
  ///
  /// Context values should be immutable, and can be updated (replaced)
  /// on shift or reduce actions.
  ///
  /// The export used in a `@context` declaration should be of this
  /// type.


  class ContextTracker {
    /// Define a context tracker.
    constructor(spec) {
      this.start = spec.start;
      this.shift = spec.shift || id;
      this.reduce = spec.reduce || id;
      this.reuse = spec.reuse || id;

      this.hash = spec.hash || (() => 0);

      this.strict = spec.strict !== false;
    }

  } /// Holds the parse tables for a given grammar, as generated by
  /// `lezer-generator`, and provides [methods](#common.Parser) to parse
  /// content with.


  class LRParser extends Parser {
    /// @internal
    constructor(spec) {
      super(); /// @internal

      this.wrappers = [];
      if (spec.version != 14
      /* Version */
      ) throw new RangeError(`Parser version (${spec.version}) doesn't match runtime version (${14
    /* Version */
    })`);
      let nodeNames = spec.nodeNames.split(" ");
      this.minRepeatTerm = nodeNames.length;

      for (let i = 0; i < spec.repeatNodeCount; i++) nodeNames.push("");

      let topTerms = Object.keys(spec.topRules).map(r => spec.topRules[r][1]);
      let nodeProps = [];

      for (let i = 0; i < nodeNames.length; i++) nodeProps.push([]);

      function setProp(nodeID, prop, value) {
        nodeProps[nodeID].push([prop, prop.deserialize(String(value))]);
      }

      if (spec.nodeProps) for (let propSpec of spec.nodeProps) {
        let prop = propSpec[0];
        if (typeof prop == "string") prop = NodeProp[prop];

        for (let i = 1; i < propSpec.length;) {
          let next = propSpec[i++];

          if (next >= 0) {
            setProp(next, prop, propSpec[i++]);
          } else {
            let value = propSpec[i + -next];

            for (let j = -next; j > 0; j--) setProp(propSpec[i++], prop, value);

            i++;
          }
        }
      }
      this.nodeSet = new NodeSet(nodeNames.map((name, i) => NodeType.define({
        name: i >= this.minRepeatTerm ? undefined : name,
        id: i,
        props: nodeProps[i],
        top: topTerms.indexOf(i) > -1,
        error: i == 0,
        skipped: spec.skippedNodes && spec.skippedNodes.indexOf(i) > -1
      })));
      if (spec.propSources) this.nodeSet = this.nodeSet.extend(...spec.propSources);
      this.strict = false;
      this.bufferLength = DefaultBufferLength;
      let tokenArray = decodeArray(spec.tokenData);
      this.context = spec.context;
      this.specializerSpecs = spec.specialized || [];
      this.specialized = new Uint16Array(this.specializerSpecs.length);

      for (let i = 0; i < this.specializerSpecs.length; i++) this.specialized[i] = this.specializerSpecs[i].term;

      this.specializers = this.specializerSpecs.map(getSpecializer);
      this.states = decodeArray(spec.states, Uint32Array);
      this.data = decodeArray(spec.stateData);
      this.goto = decodeArray(spec.goto);
      this.maxTerm = spec.maxTerm;
      this.tokenizers = spec.tokenizers.map(value => typeof value == "number" ? new TokenGroup(tokenArray, value) : value);
      this.topRules = spec.topRules;
      this.dialects = spec.dialects || {};
      this.dynamicPrecedences = spec.dynamicPrecedences || null;
      this.tokenPrecTable = spec.tokenPrec;
      this.termNames = spec.termNames || null;
      this.maxNode = this.nodeSet.types.length - 1;
      this.dialect = this.parseDialect();
      this.top = this.topRules[Object.keys(this.topRules)[0]];
    }

    createParse(input, fragments, ranges) {
      let parse = new Parse(this, input, fragments, ranges);

      for (let w of this.wrappers) parse = w(parse, input, fragments, ranges);

      return parse;
    } /// Get a goto table entry @internal


    getGoto(state, term, loose = false) {
      let table = this.goto;
      if (term >= table[0]) return -1;

      for (let pos = table[term + 1];;) {
        let groupTag = table[pos++],
            last = groupTag & 1;
        let target = table[pos++];
        if (last && loose) return target;

        for (let end = pos + (groupTag >> 1); pos < end; pos++) if (table[pos] == state) return target;

        if (last) return -1;
      }
    } /// Check if this state has an action for a given terminal @internal


    hasAction(state, terminal) {
      let data = this.data;

      for (let set = 0; set < 2; set++) {
        for (let i = this.stateSlot(state, set ? 2
        /* Skip */
        : 1
        /* Actions */
        ), next;; i += 3) {
          if ((next = data[i]) == 65535
          /* End */
          ) {
            if (data[i + 1] == 1
            /* Next */
            ) next = data[i = pair(data, i + 2)];else if (data[i + 1] == 2
            /* Other */
            ) return pair(data, i + 2);else break;
          }

          if (next == terminal || next == 0
          /* Err */
          ) return pair(data, i + 1);
        }
      }

      return 0;
    } /// @internal


    stateSlot(state, slot) {
      return this.states[state * 6
      /* Size */
      + slot];
    } /// @internal


    stateFlag(state, flag) {
      return (this.stateSlot(state, 0
      /* Flags */
      ) & flag) > 0;
    } /// @internal


    validAction(state, action) {
      if (action == this.stateSlot(state, 4
      /* DefaultReduce */
      )) return true;

      for (let i = this.stateSlot(state, 1
      /* Actions */
      );; i += 3) {
        if (this.data[i] == 65535
        /* End */
        ) {
          if (this.data[i + 1] == 1
          /* Next */
          ) i = pair(this.data, i + 2);else return false;
        }

        if (action == pair(this.data, i + 1)) return true;
      }
    } /// Get the states that can follow this one through shift actions or
    /// goto jumps. @internal


    nextStates(state) {
      let result = [];

      for (let i = this.stateSlot(state, 1
      /* Actions */
      );; i += 3) {
        if (this.data[i] == 65535
        /* End */
        ) {
          if (this.data[i + 1] == 1
          /* Next */
          ) i = pair(this.data, i + 2);else break;
        }

        if ((this.data[i + 2] & 65536
        /* ReduceFlag */
        >> 16) == 0) {
          let value = this.data[i + 1];
          if (!result.some((v, i) => i & 1 && v == value)) result.push(this.data[i], value);
        }
      }

      return result;
    } /// @internal


    overrides(token, prev) {
      let iPrev = findOffset(this.data, this.tokenPrecTable, prev);
      return iPrev < 0 || findOffset(this.data, this.tokenPrecTable, token) < iPrev;
    } /// Configure the parser. Returns a new parser instance that has the
    /// given settings modified. Settings not provided in `config` are
    /// kept from the original parser.


    configure(config) {
      // Hideous reflection-based kludge to make it easy to create a
      // slightly modified copy of a parser.
      let copy = Object.assign(Object.create(LRParser.prototype), this);
      if (config.props) copy.nodeSet = this.nodeSet.extend(...config.props);

      if (config.top) {
        let info = this.topRules[config.top];
        if (!info) throw new RangeError(`Invalid top rule name ${config.top}`);
        copy.top = info;
      }

      if (config.tokenizers) copy.tokenizers = this.tokenizers.map(t => {
        let found = config.tokenizers.find(r => r.from == t);
        return found ? found.to : t;
      });

      if (config.specializers) {
        copy.specializers = this.specializers.slice();
        copy.specializerSpecs = this.specializerSpecs.map((s, i) => {
          let found = config.specializers.find(r => r.from == s.external);
          if (!found) return s;
          let spec = Object.assign(Object.assign({}, s), {
            external: found.to
          });
          copy.specializers[i] = getSpecializer(spec);
          return spec;
        });
      }

      if (config.contextTracker) copy.context = config.contextTracker;
      if (config.dialect) copy.dialect = this.parseDialect(config.dialect);
      if (config.strict != null) copy.strict = config.strict;
      if (config.wrap) copy.wrappers = copy.wrappers.concat(config.wrap);
      if (config.bufferLength != null) copy.bufferLength = config.bufferLength;
      return copy;
    } /// Tells you whether any [parse wrappers](#lr.ParserConfig.wrap)
    /// are registered for this parser.


    hasWrappers() {
      return this.wrappers.length > 0;
    } /// Returns the name associated with a given term. This will only
    /// work for all terms when the parser was generated with the
    /// `--names` option. By default, only the names of tagged terms are
    /// stored.


    getName(term) {
      return this.termNames ? this.termNames[term] : String(term <= this.maxNode && this.nodeSet.types[term].name || term);
    } /// The eof term id is always allocated directly after the node
    /// types. @internal


    get eofTerm() {
      return this.maxNode + 1;
    } /// The type of top node produced by the parser.


    get topNode() {
      return this.nodeSet.types[this.top[1]];
    } /// @internal


    dynamicPrecedence(term) {
      let prec = this.dynamicPrecedences;
      return prec == null ? 0 : prec[term] || 0;
    } /// @internal


    parseDialect(dialect) {
      let values = Object.keys(this.dialects),
          flags = values.map(() => false);
      if (dialect) for (let part of dialect.split(" ")) {
        let id = values.indexOf(part);
        if (id >= 0) flags[id] = true;
      }
      let disabled = null;

      for (let i = 0; i < values.length; i++) if (!flags[i]) {
        for (let j = this.dialects[values[i]], id; (id = this.data[j++]) != 65535
        /* End */
        ;) (disabled || (disabled = new Uint8Array(this.maxTerm + 1)))[id] = 1;
      }

      return new Dialect(dialect, flags, disabled);
    } /// Used by the output of the parser generator. Not available to
    /// user code.


    static deserialize(spec) {
      return new LRParser(spec);
    }

  }

  function pair(data, off) {
    return data[off] | data[off + 1] << 16;
  }

  function findOffset(data, start, term) {
    for (let i = start, next; (next = data[i]) != 65535
    /* End */
    ; i++) if (next == term) return i - start;

    return -1;
  }

  function findFinished(stacks) {
    let best = null;

    for (let stack of stacks) {
      let stopped = stack.p.stoppedAt;
      if ((stack.pos == stack.p.stream.end || stopped != null && stack.pos > stopped) && stack.p.parser.stateFlag(stack.state, 2
      /* Accepting */
      ) && (!best || best.score < stack.score)) best = stack;
    }

    return best;
  }

  function getSpecializer(spec) {
    if (spec.external) {
      let mask = spec.extend ? 1
      /* Extend */
      : 0
      /* Specialize */
      ;
      return (value, stack) => spec.external(value, stack) << 1 | mask;
    }

    return spec.get;
  }

  const propertyIdentifier = 119,
        identifier = 120,
        nameIdentifier = 121,
        insertSemi = 122,
        expression0 = 126,
        ForExpression = 4,
        forExpressionStart = 129,
        ForInExpression = 7,
        Name$4 = 8,
        Identifier = 9,
        AdditionalIdentifier = 10,
        forExpressionBodyStart = 137,
        IfExpression = 18,
        ifExpressionStart = 138,
        QuantifiedExpression = 22,
        quantifiedExpressionStart = 139,
        QuantifiedInExpression = 26,
        PositiveUnaryTest = 36,
        ArithmeticExpression = 40,
        arithmeticPlusStart = 143,
        arithmeticTimesStart = 144,
        arithmeticExpStart = 145,
        arithmeticUnaryStart = 146,
        VariableName$1 = 47,
        PathExpression = 67,
        pathExpressionStart = 151,
        FilterExpression = 69,
        filterExpressionStart = 152,
        FunctionInvocation = 71,
        functionInvocationStart = 153,
        ParameterName = 75,
        nil = 158,
        NumericLiteral = 78,
        StringLiteral = 79,
        BooleanLiteral = 80,
        FunctionDefinition = 89,
        functionDefinitionStart = 166,
        Context = 96,
        contextStart = 168,
        ContextEntry = 97,
        PropertyName = 99,
        PropertyIdentifier = 100;
  const LOG_PARSE = typeof process != 'undefined' && process.env && /\bfparse(:dbg)?\b/.test(process.env.LOG);
  const LOG_PARSE_DEBUG = typeof process != 'undefined' && process.env && /\fparse:dbg\b/.test(process.env.LOG);
  const LOG_VARS = typeof process != 'undefined' && process.env && /\bcontext?\b/.test(process.env.LOG);
  const spaceChars = [9, 11, 12, 32, 133, 160, 5760, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200, 8201, 8202, 8232, 8233, 8239, 8287, 12288];
  const newlineChars = chars('\n\r');
  const additionalNameChars = chars("'./-+*");
  /**
   * @param { string } str
   * @return { number[] }
   */

  function chars(str) {
    return Array.from(str).map(s => s.charCodeAt(0));
  }
  /**
   * @param { number } ch
   * @return { boolean }
   */


  function isStartChar(ch) {
    return ch === 63 // ?
    || ch === 95 // _
    || ch >= 65 && ch <= 90 // A-Z
    || ch >= 97 && ch <= 122 // a-z
    || ch >= 161 && !isPartChar(ch) && !isSpace(ch);
  }
  /**
   * @param { number } ch
   * @return { boolean }
   */


  function isAdditional(ch) {
    return additionalNameChars.includes(ch);
  }
  /**
   * @param { number } ch
   * @return { boolean }
   */


  function isPartChar(ch) {
    return ch >= 48 && ch <= 57 // 0-9
    || ch === 0xB7 || ch >= 0x0300 && ch <= 0x036F || ch >= 0x203F && ch <= 0x2040;
  }
  /**
   * @param { number } ch
   * @return { boolean }
   */


  function isSpace(ch) {
    return spaceChars.includes(ch);
  } // eslint-disable-next-line


  function indent(str, spaces) {
    return spaces.concat(str.split(/\n/g).join('\n' + spaces));
  }
  /**
   * @param { import('@lezer/lr').InputStream } input
   * @param  { number } [offset]
   * @param { boolean } [includeOperators]
   *
   * @return { { token: string, offset: number } | null }
   */


  function parseAdditionalSymbol(input, offset = 0) {
    const next = input.peek(offset);

    if (isAdditional(next)) {
      return {
        offset: 1,
        token: String.fromCharCode(next)
      };
    }

    return null;
  }
  /**
   * @param { import('@lezer/lr').InputStream } input
   * @param { number } [offset]
   * @param { boolean } [namePart]
   *
   * @return { { token: string, offset: number } | null }
   */


  function parseIdentifier(input, offset = 0, namePart = false) {
    for (let inside = false, chars = [], i = 0;; i++) {
      const next = input.peek(offset + i);

      if (isStartChar(next) || (inside || namePart) && isPartChar(next)) {
        if (!inside) {
          inside = true;
        }

        chars.push(next);
      } else {
        if (chars.length) {
          return {
            token: String.fromCharCode(...chars),
            offset: i
          };
        }

        return null;
      }
    }
  }
  /**
   * @param { import('@lezer/lr').InputStream } input
   * @param  { number } offset
   *
   * @return { { token: string, offset: number } | null }
   */


  function parseSpaces(input, offset) {
    for (let inside = false, i = 0;; i++) {
      let next = input.peek(offset + i);

      if (isSpace(next)) {
        if (!inside) {
          inside = true;
        }
      } else {
        if (inside) {
          return {
            token: ' ',
            offset: i
          };
        }

        return null;
      }
    }
  }
  /**
   * Parse a name from the input and return the first match, if any.
   *
   * @param { import('@lezer/lr').InputStream } input
   * @param { Variables } variables
   *
   * @return { { token: string, offset: number, term: number } | null }
   */


  function parseName(input, variables) {
    const contextKeys = variables.contextKeys();
    const start = variables.tokens;

    for (let i = 0, tokens = [], nextMatch = null;;) {
      const namePart = start.length + tokens.length > 0;
      const maybeSpace = tokens.length > 0;
      const match = parseIdentifier(input, i, namePart) || namePart && parseAdditionalSymbol(input, i) || maybeSpace && parseSpaces(input, i); // match is required

      if (!match) {
        return nextMatch;
      }

      const {
        token,
        offset
      } = match;
      i += offset;

      if (token === ' ') {
        continue;
      }

      tokens = [...tokens, token];
      const name = [...start, ...tokens].join(' ');

      if (contextKeys.some(el => el === name)) {
        const token = tokens[0];
        nextMatch = {
          token,
          offset: token.length,
          term: nameIdentifier
        };
      }

      if (dateTimeIdentifiers.some(el => el === name)) {
        const token = tokens[0]; // parse date time identifiers as normal
        // identifiers to allow specialization to kick in
        //
        // cf. https://github.com/nikku/lezer-feel/issues/8

        nextMatch = {
          token,
          offset: token.length,
          term: identifier
        };
      }

      if (!contextKeys.some(el => el.startsWith(name)) && !dateTimeIdentifiers.some(el => el.startsWith(name))) {
        return nextMatch;
      }
    }
  }

  const identifiersMap = {
    [identifier]: 'identifier',
    [nameIdentifier]: 'nameIdentifier'
  };
  const identifiers = new ExternalTokenizer((input, stack) => {
    LOG_PARSE_DEBUG && console.log('%s: T <identifier | nameIdentifier>', input.pos);
    const nameMatch = parseName(input, stack.context);
    const start = stack.context.tokens;
    const match = nameMatch || parseIdentifier(input, 0, start.length > 0);

    if (match) {
      input.advance(match.offset);
      input.acceptToken(nameMatch ? nameMatch.term : identifier);
      LOG_PARSE && console.log('%s: MATCH <%s> <%s>', input.pos, nameMatch ? identifiersMap[nameMatch.term] : 'identifier', match.token);
    }
  }, {
    contextual: true
  });
  const propertyIdentifiers = new ExternalTokenizer((input, stack) => {
    LOG_PARSE_DEBUG && console.log('%s: T <propertyIdentifier>', input.pos);
    const start = stack.context.tokens;
    const match = parseIdentifier(input, 0, start.length > 0);

    if (match) {
      input.advance(match.offset);
      input.acceptToken(propertyIdentifier);
      LOG_PARSE && console.log('%s: MATCH <propertyIdentifier> <%s>', input.pos, match.token);
    }
  });
  const insertSemicolon = new ExternalTokenizer((input, stack) => {
    LOG_PARSE_DEBUG && console.log('%s: T <insertSemi>', input.pos);
    let offset;
    let insert = false;

    for (offset = 0;; offset++) {
      const char = input.peek(offset);

      if (spaceChars.includes(char)) {
        continue;
      }

      if (newlineChars.includes(char)) {
        insert = true;
      }

      break;
    }

    if (insert) {
      const identifier = parseIdentifier(input, offset + 1);
      const spaces = parseSpaces(input, offset + 1);

      if (spaces || identifier && /^(then|else|return|satisfies)$/.test(identifier.token)) {
        return;
      }

      LOG_PARSE && console.log('%s: MATCH <insertSemi>', input.pos);
      input.acceptToken(insertSemi);
    }
  });
  const prefixedContextStarts = {
    [functionInvocationStart]: 'FunctionInvocation',
    [filterExpressionStart]: 'FilterExpression',
    [pathExpressionStart]: 'PathExpression'
  };
  const contextStarts = {
    [contextStart]: 'Context',
    [functionDefinitionStart]: 'FunctionDefinition',
    [forExpressionStart]: 'ForExpression',
    [ifExpressionStart]: 'IfExpression',
    [quantifiedExpressionStart]: 'QuantifiedExpression'
  };
  const contextEnds = {
    [Context]: 'Context',
    [FunctionDefinition]: 'FunctionDefinition',
    [ForExpression]: 'ForExpression',
    [IfExpression]: 'IfExpression',
    [QuantifiedExpression]: 'QuantifiedExpression',
    [PathExpression]: 'PathExpression',
    [FunctionInvocation]: 'FunctionInvocation',
    [FilterExpression]: 'FilterExpression',
    [ArithmeticExpression]: 'ArithmeticExpression'
  };

  class ValueProducer {
    /**
     * @param { Function } fn
     */
    constructor(fn) {
      this.fn = fn;
    }

    get(variables) {
      return this.fn(variables);
    }
    /**
     * @param { Function }
     *
     * @return { ValueProducer }
     */


    static of(fn) {
      return new ValueProducer(fn);
    }

  }

  const dateTimeLiterals = {
    'date and time': 1,
    'date': 1,
    'time': 1,
    'duration': 1
  };
  const dateTimeIdentifiers = Object.keys(dateTimeLiterals);

  class Variables {
    constructor({
      name = 'Expressions',
      tokens = [],
      children = [],
      parent = null,
      context = {},
      value,
      raw
    } = {}) {
      this.name = name;
      this.tokens = tokens;
      this.children = children;
      this.parent = parent;
      this.context = context;
      this.value = value;
      this.raw = raw;
    }

    enterScope(name) {
      const childScope = this.of({
        name,
        parent: this
      });
      LOG_VARS && console.log('[%s] enter', childScope.path, childScope.context);
      return childScope;
    }

    exitScope(str) {
      if (!this.parent) {
        LOG_VARS && console.log('[%s] NO exit %o\n%s', this.path, this.context, indent(str, '  '));
        return this;
      }

      LOG_VARS && console.log('[%s] exit %o\n%s', this.path, this.context, indent(str, '  '));
      return this.parent.pushChild(this);
    }

    token(part) {
      LOG_VARS && console.log('[%s] token <%s> + <%s>', this.path, this.tokens.join(' '), part);
      return this.assign({
        tokens: [...this.tokens, part]
      });
    }

    literal(value) {
      LOG_VARS && console.log('[%s] literal %o', this.path, value);
      return this.pushChild(this.of({
        name: 'Literal',
        value
      }));
    }
    /**
     * Return computed scope value
     *
     * @return {any}
     */


    computedValue() {
      for (let scope = this;; scope = scope.children.slice(-1)[0]) {
        if (!scope) {
          return null;
        }

        if (scope.value) {
          return scope.value;
        }
      }
    }

    contextKeys() {
      return Object.keys(this.context).map(normalizeContextKey);
    }

    get path() {
      return this.parent?.path?.concat(' > ', this.name) || this.name;
    }
    /**
     * Return value of variable.
     *
     * @param { string } variable
     * @return { any } value
     */


    get(variable) {
      const names = [variable, variable && normalizeContextKey(variable)];
      const contextKey = Object.keys(this.context).find(key => names.includes(normalizeContextKey(key)));

      if (typeof contextKey === 'undefined') {
        return undefined;
      }

      const val = this.context[contextKey];

      if (val instanceof ValueProducer) {
        return val.get(this);
      } else {
        return val;
      }
    }

    resolveName() {
      const variable = this.tokens.join(' ');
      const tokens = [];
      const parentScope = this.assign({
        tokens
      });
      const variableScope = this.of({
        name: 'VariableName',
        parent: parentScope,
        value: this.get(variable),
        raw: variable
      });
      LOG_VARS && console.log('[%s] resolve name <%s=%s>', variableScope.path, variable, this.get(variable));
      return parentScope.pushChild(variableScope);
    }

    pushChild(child) {
      if (!child) {
        return this;
      }

      const parent = this.assign({
        children: [...this.children, child]
      });
      child.parent = parent;
      return parent;
    }

    pushChildren(children) {
      let parent = this;

      for (const child of children) {
        parent = parent.pushChild(child);
      }

      return parent;
    }

    declareName() {
      if (this.tokens.length === 0) {
        throw Error('no tokens to declare name');
      }

      const variableName = this.tokens.join(' ');
      LOG_VARS && console.log('[%s] declareName <%s>', this.path, variableName);
      return this.assign({
        tokens: []
      }).pushChild(this.of({
        name: 'Name',
        value: variableName
      }));
    }

    define(name, value) {
      if (typeof name !== 'string') {
        LOG_VARS && console.log('[%s] no define <%s=%s>', this.path, name, value);
        return this;
      }

      LOG_VARS && console.log('[%s] define <%s=%s>', this.path, name, value);
      const context = { ...this.context,
        [name]: value
      };
      return this.assign({
        context
      });
    }
    /**
     * @param { Record<string, any> } [options]
     *
     * @return { Variables }
     */


    assign(options = {}) {
      return Variables.of({ ...this,
        ...options
      });
    }
    /**
     * @param { Record<string, any> } [options]
     *
     * @return { Variables }
     */


    of(options = {}) {
      const defaultOptions = {
        context: this.context,
        parent: this.parent
      };
      return Variables.of({ ...defaultOptions,
        ...options
      });
    }

    static of(options) {
      const {
        name,
        tokens = [],
        children = [],
        parent = null,
        context = {},
        value,
        raw
      } = options;
      return new Variables({
        name,
        tokens: [...tokens],
        children: [...children],
        context: { ...context
        },
        parent,
        value,
        raw
      });
    }

  }
  /**
   * @param { string } name
   *
   * @return { string } normalizedName
   */


  function normalizeContextKey(name) {
    return name.replace(/\s*([./\-'+*])\s*/g, ' $1 ').replace(/\s{2,}/g, ' ').trim();
  }
  /**
   * Wrap children of variables under the given named child.
   *
   * @param { Variables } variables
   * @param { string } name
   * @param { string } code
   * @return { Variables }
   */


  function wrap(variables, scopeName, code) {
    const parts = variables.children.filter(c => c.name !== scopeName);
    const children = variables.children.filter(c => c.name === scopeName);
    const namePart = parts[0];
    const valuePart = parts[Math.max(1, parts.length - 1)];
    const name = namePart.computedValue();
    const value = valuePart?.computedValue() || null;
    return variables.assign({
      children
    }).enterScope(scopeName).pushChildren(parts).exitScope(code).define(name, value);
  }
  /**
   * @param { any } context
   *
   * @return { ContextTracker<Variables> }
   */


  function trackVariables(context = {}) {
    const start = Variables.of({
      context
    });
    return new ContextTracker({
      start,

      reduce(variables, term, stack, input) {
        if (term === Context) {
          variables = variables.assign({
            value: variables.context
          });
        }

        if (term === IfExpression) {
          const [thenPart, elsePart] = variables.children.slice(-2);
          variables = variables.assign({
            value: { ...thenPart?.computedValue(),
              ...elsePart?.computedValue()
            }
          });
        }

        if (term === FilterExpression) {
          const [sourcePart, _] = variables.children.slice(-2);
          variables = variables.assign({
            value: sourcePart?.computedValue()
          });
        }

        if (term === FunctionInvocation) {
          const [name, ...args] = variables.children; // preserve type information through `get value(context, key)` utility

          if (name?.raw === 'get value') {
            variables = getContextValue(variables, args);
          }
        }

        const start = contextStarts[term];

        if (start) {
          return variables.enterScope(start);
        }

        const prefixedStart = prefixedContextStarts[term]; // pull <expression> into new <prefixedStart> context

        if (prefixedStart) {
          const children = variables.children.slice(0, -1);
          const lastChild = variables.children.slice(-1)[0];
          return variables.assign({
            children
          }).enterScope(prefixedStart).pushChild(lastChild).assign({
            context: { ...variables.context,
              ...lastChild?.computedValue()
            }
          });
        }

        const code = input.read(input.pos, stack.pos);
        const end = contextEnds[term];

        if (end) {
          return variables.exitScope(code);
        }

        if (term === ContextEntry) {
          return wrap(variables, 'ContextEntry', code);
        }

        if (term === ForInExpression || term === QuantifiedInExpression) {
          return wrap(variables, 'InExpression', code);
        } // define <partial> within ForExpression body


        if (term === forExpressionBodyStart) {
          return variables.define('partial', ValueProducer.of(variables => {
            return variables.children[variables.children.length - 1]?.computedValue();
          }));
        }

        if (term === ParameterName) {
          const [left] = variables.children.slice(-1);
          const name = left.computedValue(); // TODO: attach type information

          return variables.define(name, 1);
        } // pull <expression> into ArithmeticExpression child


        if (term === arithmeticPlusStart || term === arithmeticTimesStart || term === arithmeticExpStart) {
          const children = variables.children.slice(0, -1);
          const lastChild = variables.children.slice(-1)[0];
          return variables.assign({
            children
          }).enterScope('ArithmeticExpression').pushChild(lastChild);
        }

        if (term === arithmeticUnaryStart) {
          return variables.enterScope('ArithmeticExpression');
        }

        if (term === Identifier || term === AdditionalIdentifier || term === PropertyIdentifier) {
          return variables.token(code);
        }

        if (term === StringLiteral) {
          return variables.literal(code.replace(/^"|"$/g, ''));
        }

        if (term === BooleanLiteral) {
          return variables.literal(code === 'true' ? true : false);
        }

        if (term === NumericLiteral) {
          return variables.literal(parseFloat(code));
        }

        if (term === nil) {
          return variables.literal(null);
        }

        if (term === VariableName$1) {
          return variables.resolveName();
        }

        if (term === Name$4 || term === PropertyName) {
          return variables.declareName();
        }

        if (term === expression0 || term === PositiveUnaryTest) {
          if (variables.tokens.length > 0) {
            throw new Error('uncleared name');
          }
        }

        if (term === expression0) {
          let parent = variables;

          while (parent.parent) {
            parent = parent.exitScope(code);
          }

          return parent;
        }

        return variables;
      }

    });
  }

  const variableTracker = trackVariables({}); // helpers //////////////

  function getContextValue(variables, args) {
    if (!args.length) {
      return variables.assign({
        value: null
      });
    }

    if (args[0].name === 'Name') {
      args = extractNamedArgs(args, ['m', 'key']);
    }

    if (args.length !== 2) {
      return variables.assign({
        value: null
      });
    }

    const [context, key] = args;
    const keyValue = key?.computedValue();
    const contextValue = context?.computedValue();

    if (!contextValue || typeof contextValue !== 'object' || typeof keyValue !== 'string') {
      return variables.assign({
        value: null
      });
    }

    return variables.assign({
      value: [normalizeContextKey(keyValue), keyValue].reduce((value, keyValue) => {
        if (keyValue in contextValue) {
          return contextValue[keyValue];
        }

        return value;
      }, null)
    });
  }

  function extractNamedArgs(args, argNames) {
    const context = {};

    for (let i = 0; i < args.length; i += 2) {
      const [name, value] = args.slice(i, i + 2);
      context[name.value] = value;
    }

    return argNames.map(name => context[name]);
  }

  const feelHighlighting = styleTags({
    StringLiteral: tags$1.string,
    NumericLiteral: tags$1.number,
    BooleanLiteral: tags$1.bool,
    'AtLiteral!': tags$1.special(tags$1.string),
    CompareOp: tags$1.compareOperator,
    ArithOp: tags$1.arithmeticOperator,
    'for if then else some every satisfies between return': tags$1.controlKeyword,
    'in instance of and or': tags$1.operatorKeyword,
    function: tags$1.definitionKeyword,
    as: tags$1.keyword,
    'Type/...': tags$1.typeName,
    Wildcard: tags$1.special,
    null: tags$1.null,
    LineComment: tags$1.lineComment,
    BlockComment: tags$1.blockComment,
    'VariableName! "?"': tags$1.variableName,
    'DateTimeConstructor! SpecialFunctionName!': tags$1.function(tags$1.special(tags$1.variableName)),
    'List Interval': tags$1.list,
    Context: tags$1.definition(tags$1.literal),
    'Name!': tags$1.definition(tags$1.variableName),
    'Key/Name! ContextEntryType/Name!': tags$1.definition(tags$1.propertyName),
    'PathExpression/VariableName!': tags$1.function(tags$1.propertyName),
    'FormalParameter/ParameterName!': tags$1.function(tags$1.definition(tags$1.variableName)),
    '( )': tags$1.paren,
    '[ ]': tags$1.squareBracket,
    '{ }': tags$1.brace,
    '.': tags$1.derefOperator,
    ', ;': tags$1.separator,
    '..': tags$1.punctuation
  }); // This file was generated by lezer-generator. You probably shouldn't edit it.

  const spec_identifier = {
    __proto__: null,
    for: 10,
    in: 30,
    return: 34,
    if: 38,
    then: 40,
    else: 42,
    some: 46,
    every: 48,
    satisfies: 55,
    or: 58,
    and: 62,
    between: 70,
    instance: 86,
    of: 89,
    days: 99,
    time: 101,
    duration: 103,
    years: 105,
    months: 107,
    date: 109,
    list: 115,
    context: 121,
    function: 128,
    null: 154,
    true: 324,
    false: 324,
    "?": 168,
    external: 184,
    not: 207
  };
  const parser = LRParser.deserialize({
    version: 14,
    states: "!$jO`QYOOO$gQYOOOOQU'#Ce'#CeO$qQYO'#C`O%zQ^O'#FOOOQQ'#Fd'#FdO'dQYO'#FdO`QYO'#DUOOQU'#Em'#EmO)QQ^O'#D]OOQO'#Fk'#FkO,PQWO'#DuOOQU'#D|'#D|OOQU'#D}'#D}OOQU'#EO'#EOO,UOWO'#ERO,PQWO'#EPOOQU'#EP'#EPOOQU'#Fq'#FqOOQU'#Fo'#FoO,ZQYO'#EUO`QYO'#EVO,{QYO'#EWO,ZQYO'#ETOOQU'#ET'#ETOOQU'#FQ'#FQO.aQ^O'#FQO/sQWO'#EXOOQP'#Fz'#FzO/xQXO'#E`OOQU'#Fw'#FwOOQU'#FP'#FPOOQQ'#Eh'#EhQ`QYOOOOQQ'#FR'#FROOQQ'#F['#F[O`QYO'#CnOOQQ'#F]'#F]O$qQYO'#CrO0TQYO'#DvOOQU'#Fp'#FpO0YQYO'#EQOOQO'#EQ'#EQOOQO'#Fx'#FxO1lQYO'#DQO2SQWO'#F`OOQO'#DS'#DSO2_QYO'#FdQOQWOOO2fQWOOO3YQYO'#CdO3gQYO'#FTOOQQ'#Cc'#CcO3lQYO'#FSOOQQ'#Cb'#CbO3tQYO,58zO`QYO,59hOOQQ'#Fa'#FaOOQQ'#Fb'#FbOOQQ'#Fc'#FcO`QYO,59pO`QYO,59pO`QYO,59pOOQQ'#Fi'#FiO$qQYO,5:]OOQQ'#Fj'#FjO`QYO,5:_OOQQ,5;j,5;jO`QYO,59dO`QYO,59fO`QYO,59hO3yQYO,59hO5gQYO,59rOOQU,5:h,5:hO5lQ^O,59pOOQU-E8k-E8kO8kQYO'#FlOOQU,5:a,5:aOOQU,5:m,5:mOOQU,5:k,5:kO8rQ^O'#D[O;qQWO'#D|OOQU'#Fv'#FvO;vQWO,5:pO;{QYO,5:qO>ZQ^O'#D[O>eQYO'#FoO@sQYO'#FnOAQQWO,5:rOOQU,5:o,5:oOOQU,5;l,5;lOAVQYO,5:sOOQP'#Ed'#EdOAyQXO'#EcOOQO'#Eb'#EbOBQQWO'#EaOBVQWO'#F{OB_QWO,5:zOOQQ-E8f-E8fOBdQYO,59YO3gQYO'#F_OOQQ'#Cv'#CvOBkQYO'#F^OOQQ'#Cu'#CuOBsQYO,59^OBxQYO,5:bOB}QYO,5:lO`QYO'#ElOCSQWO,5;zO`QYOOOOQR'#Cf'#CfOOQQ'#Ei'#EiOCyQYO,59OO`QYO,5;oOOQQ'#FW'#FWO$qQYO'#EjODZQYO,5;nO`QYO1G.fOOQQ'#FZ'#FZODcQ^O1G/SOFxQ^O1G/[OI_Q^O1G/[ONZQ^O1G/[OOQU1G/w1G/wONwQYO1G/yO!#UQ^O1G/OO!%rQ^O1G/QO!'QQYO1G/SO`QYO1G/SOOQU1G/S1G/SO!'XQYO1G/^O!'sQ^O'#CdOOQO'#Dy'#DyO!)VQWO'#DxO!)[QWO'#FmOOQO'#Dw'#DwOOQO'#Dz'#DzO!)dQWO,5<WO$qQYO'#EnO!)iQ^O,59vO,ZQYO1G0[OOQU1G0]1G0]O`QYO'#ErO!,hQWO,5<YOOQU1G0^1G0^O!,sQWO'#EZO!-OQWO'#FyOOQO'#EY'#EYO!-WQWO1G0_OOQP'#Et'#EtO!-]QXO,5:}O`QYO,5:{O!-dQXO'#EuO!-lQWO,5<gOOQU1G0f1G0fO`QYO1G.tO`QYO,5;yO$qQYO'#EkO!-tQYO,5;xO`QYO1G.xO!-|QYO1G/|OOQO1G0W1G0WOOQO,5;W,5;WOOQO-E8j-E8jO!.RQWOOOOQQ-E8g-E8gO!.WQYO'#ClOOQQ1G1Z1G1ZOOQQ,5;U,5;UOOQQ-E8h-E8hO!.eQ^O7+$QOOQU7+%e7+%eO`QYO7+$nO!/}QYO,5:qO!0UQWO7+$nOOQU'#DZ'#DZO!0ZQYO'#D^O!0`QYO'#D^O!0eQYO'#D^O!0jQ`O'#DfO!0oQ`O'#DiO!0tQ`O'#DmOOQU7+$x7+$xO`QYO,5:dO$qQYO'#EqO!0yQWO,5<XOOQU1G1r1G1rOOQU,5;Y,5;YOOQU-E8l-E8lO!1RQWO7+%vO!1^QYO,5;^OOQO-E8p-E8pO!'XQYO,5:uO$qQYO'#EsO!1kQWO,5<eO!1sQYO7+%yOOQP-E8r-E8rO!1zQYO1G0gOOQO,5;a,5;aOOQO-E8s-E8sO!4kQ^O7+$`O!4rQYO1G1eOOQQ,5;V,5;VOOQQ-E8i-E8iO!4|Q^O7+$dOOQO7+%h7+%hO`QYO,59WO!6fQ^O<<HYOOQU<<HY<<HYO!8{QYO,59xO!9QQYO,59xO!9VQYO,59xO!9[QYO,5:QO$qQYO,5:TO!9vQbO,5:XO!9}QYO1G0OOOQO,5;],5;]OOQO-E8o-E8oOOQU<<Ib<<IbOOQO1G0a1G0aOOQO,5;_,5;_OOQO-E8q-E8qO!:XQ^O'#E]OOQU<<Ie<<IeO`QYO<<IeO`QYO<<GzO!;qQYO1G.rO!;{QYO1G/dOOQU1G/d1G/dO!<QQbO'#D]O!<cQ`O'#D[O!<nQ`O1G/lO!<sQWO'#DlO!<xQ`O'#FeOOQO'#Dk'#DkO!=QQ`O1G/oOOQO'#Dp'#DpO!=VQ`O'#FgOOQO'#Do'#DoO!=_Q`O1G/sOOQUAN?PAN?PO!=dQ^OAN=fOOQU7+%O7+%OO!>|Q`O,59vOOQU7+%W7+%WO!9[QYO,5:WO$qQYO'#EoO!?XQ`O,5<POOQU7+%Z7+%ZO!9[QYO'#EpO!?aQ`O,5<RO!?iQ`O7+%_OOQO1G/r1G/rOOQO,5;Z,5;ZOOQO-E8m-E8mOOQO,5;[,5;[OOQO-E8n-E8nO!'XQYO<<HyOOQUAN>eAN>eO!?nQ^O'#FQO`QYO,59hO`QYO,59pO`QYO,59pO`QYO,59pO`QYO,59dO`QYO,59fO3yQYO,59hO`QYO1G.fO!@XQYO1G/SO!AuQYO1G/[O!CcQYO1G/[O!F^QYO1G/OO!HRQYO1G/QO$qQYO'#EnO`QYO1G.tO`QYO1G.xO!HcQYO7+$QO`QYO7+$nO!ISQYO7+%yO!JwQYO7+$`O!KOQYO7+$`O!KVQ^O7+$`O!K^QYO7+$dO!K}QYO<<HYO!MkQYO'#E]O`QYO<<IeO`QYO<<GzO!N[QYOAN=fO!9[QYO<<HyO`QYO'#DUO!N{Q^O'#DQO3tQYO,58zO#!eQYO,59YO#!lQYO,59^O#!qQYO1G/SO#!xQWO1G0_O`QYO1G.tO#!}Q`O7+%_O`QYO1G.tO$qQYO'#C`O`QYO'#CnO$qQYO'#CrO`QYO,59hOAVQYO,5:sO##SQYO,59YO##ZQ`O1G/sO##`QYO,59YO##gQWO'#EXO`QYO'#CnO`QYO,59hO`QYO,59pO`QYO,59pO`QYO,59pO`QYO,59dO`QYO,59fO3yQYO,59hO`QYO1G.fO##lQ^O1G/SO##sQ^O1G/[O##zQ^O1G/[O#$RQ^O1G/OO#$iQ^O1G/QO`QYO1G.xO#%}Q^O7+$QO`QYO7+$nO#'jQYO7+%yO#'qQ^O7+$dO#)^Q^O<<HYO!9vQbO,5:XO#)eQ^O'#E]O`QYO<<IeP`QYO<<GzP#+QQ^OAN=fO#,TQ^O'#DQO`QYO'#CnO`QYO'#DUO3tQYO,58zO#-pQYO,59^O#-uQYO1G/SO#-|QWO1G0_O#.RQ`O'#DmO`QYO,59hO`QYO,59pO`QYO,59pO`QYO,59pO`QYO,59dO`QYO,59fO3yQYO,59hO`QYO1G.fO#.WQYO1G/SO#._QYO1G/[O#.fQYO1G/[O#.mQYO1G/OO#/TQYO1G/QO`QYO1G.xO#0iQYO7+$QO`QYO7+$nO#1]QYO7+%yO#1dQYO7+$dO#2WQYO<<HYO#2_QYO'#E]O`QYO<<IeP`QYO<<GzP#3RQYOAN=fO`QYO'#DUO3tQYO,58zO#4UQYO,59^O#4ZQYO1G/SO#4bQWO1G0_O$qQYO'#C`O$qQYO'#CrO`QYO,59hOAVQYO,5:sO#4gQWO'#EXO$qQYO'#C`O$qQYO'#CrO#4lQYO'#DQO`QYO,59hOAVQYO,5:sO#5VQWO'#EX",
    stateData: "#5[~O#pOS#qOSPOSQOS~OTrOZUO[TOcsOguOhuOrgOueO!SzO!TzO!UwO!WyO!b{O!fdO!hfO!oxO!viO#RlO#lQO#mQO$f[O$g]O$h^O$i_O~OTrO[TOcsOguOhuOrgOueO!SzO!TzO!UwO!WyO!b{O!fdO!hfO!oxO!viO#RlO#lQO#mQO$f[O$g]O$h^O$i_O~OZ!PO#Z!RO~P!|O#lQO#mQO~OZ!ZO[!ZO]![O^![O_!iOm!fOo!gOq!YOr!YOs!hOy!]O{!jO!h!cO#x!aOu$_X~O#n!eO$p!eOT#rXc#rXg#rXh#rX!S#rX!T#rX!U#rX!W#rX!b#rX!f#rX!o#rX!v#rX#R#rX#j#rX#l#rX#m#rX$f#rX$g#rX$h#rX$i#rX~P$yO$f!kOT$WXZ$WX[$WXc$WXg$WXh$WXr$WXu$WX!S$WX!T$WX!U$WX!W$WX!b$WX!f$WX!h$WX!o$WX!v$WX#R$WX#l$WX#m$WX$g$WX$h$WX$i$WX~O#lQO#mQOT!PXZ!PX[!PX]!PX^!PX_!PXc!PXg!PXh!PXm!PXo!PXq!PXr!PXs!PXu!PXy!PX{!PX!S!PX!T!PX!U!PX!W!PX!b!PX!f!PX!h!PX!o!PX!v!PX#R!PX#j!PX#n!PX#x!PX$f!PX$g!PX$h!PX$i!PX$p!PX#|!PX#{!PXw!PXd!PXa!PX#Q!PXe!PXk!PX~Ou!nO~O$g]O~OZ!sO!SzO!TzO!WyO#lQO#mQO$f[O$g]O$h^O$i_O~O!f$bP~P`O#n!|OZ#tX[#tX]#tX^#tX_#tXm#tXo#tXq#tXr#tXs#tXu#tXy#tX{#tX!f#tX!h#tX#j#tX#x#tXe#tX~OT#tXc#tXg#tXh#tX!S#tX!T#tX!U#tX!W#tX!b#tX!o#tX!v#tX#R#tX#l#tX#m#tX#n#tX$f#tX$g#tX$h#tX$i#tX$p#tX~P-SOu!}O~O#k#OO$g]O#Q$oP~Oo#]O~Oo#^Ou!tX~OZ!ZO[!ZO]![O^![Oy!]O{!jO!h!cO#x!aOu$_X#jtX#|tXwtX!ftXdtXatX#{tX#QtXktX~O_&tOm&rOo&sOq&nOr&nOs'jO~P0bO#|#_O#j$SXw$SX~O#j#YX~P'dOu#aO~OZ#bO[#bO]#bO^#bO#lQO#mQO#x#bO#y#bO$YWX~O_WXwWX#|WX~P2kO_#fO~O#|#gOa#vX~Oa#jO~OTrOZUO[TOcsOguOhuOrgOu#tO!SzO!TzO!UwO!WyO!b{O!fdO!hfO!oxO!viO#RlO#lQO#mQO$f[O$g]O$h^O$i_O~O|#vO~O{!jO!h!cO#x!aOTxaZxa[xa]xa^xa_xacxagxahxamxaoxaqxarxasxau$_Xyxa!Sxa!Txa!Uxa!Wxa!bxa!fxa!oxa!vxa#Rxa#jxa#lxa#mxa#nxa$fxa$gxa$hxa$ixa$pxa#|xawxadxaaxa#{xa#Qxaexakxa~Ow$bP~P`O#x$OO#{!OXT!OXZ!OX[!OX]!OX^!OX_!OXc!OXg!OXh!OXm!OXo!OXq!OXr!OXs!OXu!OXy!OX{!OX!S!OX!T!OX!U!OX!W!OX!b!OX!f!OX!h!OX!o!OX!v!OX#R!OX#j!OX#l!OX#m!OX#n!OX$f!OX$g!OX$h!OX$i!OX$p!OX#|!OXw!OXd!OXa!OX#Q!OXe!OXk!OX~O$f!kO~O#{$QO~OZ!ZO[!ZO]![O^![O_&tOm&rOo&sOq&nOr&nOs'jOw$ROy!]O{!jO!h!cO#x!aOu$_X~O#n!|OZ#tX[#tX]#tX^#tX_#tXm#tXo#tXq#tXr#tXs#tXu#tXw#tXy#tX{#tX!h#tX!f#tX#|#tX~O#x$OO#{!OX~P=POZ$cX[$cX]$cX^$cX_$cXm$cXo$cXq$cXr$cXs$cXu$cXw$cXy$cX{$cX!h$cX#x$cX#{$jX!f$cX#|$cX~OZ!ZO[!ZO]![O^![O_&tOm&rOo&sOq&nOr&nOs'jOy!]O{!jO!h!cO#x!aOu$_X~O#|$SO!f$bXw$bX~P?rO!f$UO~O#lQO#mQOw$mP~OZ#bO[#bO]#bO^#bO#k#OO#x#bO#y#bO~O$Y#VX~PAbO$Y$]O~O#|$^O#Q$oX~O#Q$`O~Od$aO~P?rO#|$cOk$QX~Ok$eO~O!V$fO~O!S$gO~O#|#_O#j$Saw$Sa~OZ#bO[#bO]#bO^#bO#lQO#mQO#x#bO#y#bO~O_Wa$YWawWa#|Wa~PC_O#|#gOa#va~OZ!ZO[!ZO]![O^![Oy!]O{!jO!h!cO#x!aOTpi_picpigpihpimpiopiqpirpispiu$_X!Spi!Tpi!Upi!Wpi!bpi!fpi!opi!vpi#Rpi#jpi#lpi#mpi#npi$fpi$gpi$hpi$ipi$ppi~O]![O^![Oy!]O{!jO!h!cO#x!aOTxiZxi[xi_xicxigxihximxioxiqxirxisxiu$_X!Sxi!Txi!Uxi!Wxi!bxi!fxi!oxi!vxi#Rxi#jxi#lxi#mxi#nxi$fxi$gxi$hxi$ixi$pxi~Oy!]O{!jO!h!cO#x!aOTxiZxi[xi]xi^xi_xicxigxihximxioxiqxirxisxiu$_X!Sxi!Txi!Uxi!Wxi!bxi!fxi!oxi!vxi#Rxi#jxi#lxi#mxi#nxi$fxi$gxi$hxi$ixi$pxi~O{!jO!h!cO#x!aOTxiZxi[xi]xi^xi_xicxigxihximxioxiqxirxisxiu$_X!Sxi!Txi!Uxi!Wxi!bxi!fxi!oxi!vxi#Rxi#jxi#lxi#mxi#nxi$fxi$gxi$hxi$ixi$pxiexi~Oyxi#|xiwxidxiaxi#{xi#Qxikxi~PKtO!f$qO~P?rOZ!ZO[!ZO]![O^![Oy!]O{!jO!h!cO#x!aOTlicliglihlimliu$_X!Sli!Tli!Uli!Wli!bli!fli!oli!vli#Rli#jli#lli#mli#nli$fli$gli$hli$ili$pli~O_!iOo!gOq!YOr!YOs!hO~P! OOZ!ZO[!ZO]![O^![Oy!]O{!jO!h!cO#x!aOTnicnignihnimnioniu$_X!Sni!Tni!Uni!Wni!bni!fni!oni!vni#Rni#jni#lni#mni#nni$fni$gni$hni$ini$pni~O_!iOq!YOr!YOs!hO~P!#iOZ!ZO[!ZO]![O^![O_&tOm&rOq&nOr&nOs'jOy!]O{!jO!h!cO#x!aOu$_X~Oo$rO~P!&SO!R$vO!U$wO!W$xO!Z$yO!^$zO!b${O#lQO#mQO~OZ#aX[#aX]#aX^#aX_#aXm#aXo#aXq#aXr#aXs#aXu#aXw#aXy#aX{#aX!h#aX#l#aX#m#aX#n#aX#x#aX#|#aX~P2kO$Y$}O~O#|%OOw$aX~Ow%QO~O#x$OO#{!OaT!OaZ!Oa[!Oa]!Oa^!Oa_!Oac!Oag!Oah!Oam!Oao!Oaq!Oar!Oas!Oau!Oay!Oa{!Oa!S!Oa!T!Oa!U!Oa!W!Oa!b!Oa!f!Oa!h!Oa!o!Oa!v!Oa#R!Oa#j!Oa#l!Oa#m!Oa#n!Oa$f!Oa$g!Oa$h!Oa$i!Oa$p!Oa#|!Oaw!Oad!Oaa!Oa#Q!Oae!Oak!Oa~O#|$SO!f$baw$ba~O$Y%WOw!}X#|!}X~O#|%XOw$mX~Ow%ZO~O$Y#Va~PAbO#k#OO$g]O~O#|$^O#Q$oa~O#|$cOk$Qa~O!T%eO~Ow!QO~O#{%fOa`X#|`X~P?rOTSqcSqgSqhSq!SSq!TSq!USq!WSq!bSq!fSq!oSq!vSq#RSq#jSq#lSq#mSq#nSq$fSq$gSq$hSq$iSq$pSq~P$yO#|tX~P;{Ow%hO~Oo%iO~Oo%jO~Oo%kO~O![%lO~O![%mO~O![%nO~O#|%OOw$aa~Ow%rO!f%rO!h%rO~O!f#fa#|#faw#fa~P?rO#|%XOw$ma~O#O%xO~P`O#Q#Ti#|#Ti~P?rOZ!ZO[!ZO]![O^![O_'wOm'uOo'vOq'qOr'qOs)XOy!]O{!jO!h!cO#x!aOTbqcbqgbqhbqu$_X!Sbq!Tbq!Ubq!Wbq!bbq!fbq!obq!vbq#Rbq#jbq#lbq#mbq#nbq$fbq$gbq$hbq$ibq$pbq~Oe%yO~P!2UOk$Ri#|$Ri~P?rOTfqcfqgfqhfq!Sfq!Tfq!Ufq!Wfq!bfq!ffq!ofq!vfq#Rfq#jfq#lfq#mfq#nfq$ffq$gfq$hfq$ifq$pfq~P$yOZ!ZO[!ZO]![O^![Oy!]O{!jO!h!cO#x!aOTpy_pycpygpyhpympyopyqpyrpyspyu$_X!Spy!Tpy!Upy!Wpy!bpy!fpy!opy!vpy#Rpy#jpy#lpy#mpy#npy$fpy$gpy$hpy$ipy$ppy~O!S%{O~O!V%{O~O!S%|O~O!R$vO!U$wO!W$xO!Z$yO!^$zO!b(bO#lQO#mQO~O!X$ZP~P!9[Ow!li#|!li~P?rOT#PXc#PXg#PXh#PX!S#PX!T#PX!U#PX!W#PX!b#PX!f#PX!o#PX!v#PX#R#PX#j#PX#l#PX#m#PX#n#PX$f#PX$g#PX$h#PX$i#PX$p#PX~P$yOa`i#|`i~P?rO!T&[O~O#lQO#mQO!X!PX#x!PX#|!PX~O#x&{O!X!OX#|!OX~O!X&^O~O$Y&_O~O#|&`O!X$XX~O!X&bO~O#|&cO!X$ZX~O!X&eO~OTb!Rcb!Rgb!Rhb!R!Sb!R!Tb!R!Ub!R!Wb!R!bb!R!fb!R!ob!R!vb!R#Rb!R#jb!R#lb!R#mb!R#nb!R$fb!R$gb!R$hb!R$ib!R$pb!R~P$yO#x&{O!X!Oa#|!Oa~O#|&`O!X$Xa~O#|&cO!X$Za~O$[&kO~O#|#tXd#tXw#tXa#tX#{#tX#Q#tXk#tX~P-SOZ!ZO[!ZO]![O^![Oy!]O{!jO!h!cO#x!aO_pimpiopiqpirpispiu$_X#jpi#|piwpi!fpidpiapi#{pi#Qpikpi~O]![O^![Oy!]O{!jO!h!cO#x!aOZxi[xi_ximxioxiqxirxisxiu$_X#jxi#|xiwxi!fxidxiaxi#{xi#Qxikxi~Oy!]O{!jO!h!cO#x!aOZxi[xi]xi^xi_ximxioxiqxirxisxiu$_X#jxi#|xiwxi!fxidxiaxi#{xi#Qxikxi~OZ!ZO[!ZO]![O^![Oy!]O{!jO!h!cO#x!aOmliu$_X#jli#|liwli!flidliali#{li#Qlikli~O_&tOo&sOq&nOr&nOs'jO~P!EPOZ!ZO[!ZO]![O^![Oy!]O{!jO!h!cO#x!aOmnioniu$_X#jni#|niwni!fnidniani#{ni#Qnikni~O_&tOq&nOr&nOs'jO~P!FqO#jSq#|SqwSq!fSqdSqaSq#{Sq#QSqkSq~P?rO#O'XO~P`OZ!ZO[!ZO]![O^![O_(iOm(gOo(hOq(cOr(cOs)ROy!]O{!jO!h!cO#x!aOu$_X#jbq#|bqwbq!fbqdbqabq#{bq#Qbqkbq~Oe'YO~P!IZOebq~P!IZOebq~P!2UO#jfq#|fqwfq!ffqdfqafq#{fq#Qfqkfq~P?rOZ!ZO[!ZO]![O^![Oy!]O{!jO!h!cO#x!aO_pympyopyqpyrpyspyu$_X#jpy#|pywpy!fpydpyapy#{py#Qpykpy~O#j#PX#|#PXw#PX!f#PXd#PXa#PX#{#PX#Q#PXk#PX~P?rO#jb!R#|b!Rwb!R!fb!Rdb!Rab!R#{b!R#Qb!Rkb!R~P?rOTtXctXgtXhtX!StX!TtX!UtX!WtX!btX!ftX!otX!vtX#RtX#jtX#ltX#mtX#ntX$ftX$gtX$htX$itX$ptX~P$yOd&|O~P?rOk&}O~Oo'PO~P!&SOw'QO~O$['[O~Od'dO~P?rO!X'eO~Od'fO~P?rOu'kO~Oepi~PDcOexi~PFxOexi~PI_O_'wOo'vOq'qOr'qOs)XOeli~P! OO_'wOq'qOr'qOs)XOeni~P!#iOZ!ZO[!ZO]![O^![O_'wOm'uOo'vOq'qOr'qOs)XOy!]O{!jO!h!cO#x!aOu$_X~OTSqcSqeSqgSqhSq!SSq!TSq!USq!WSq!bSq!fSq!oSq!vSq#RSq#jSq#lSq#mSq#nSq$fSq$gSq$hSq$iSq$pSq~P#$|O#O(WO~P`OTfqcfqefqgfqhfq!Sfq!Tfq!Ufq!Wfq!bfq!ffq!ofq!vfq#Rfq#jfq#lfq#mfq#nfq$ffq$gfq$hfq$ifq$pfq~P#$|Oepy~P!6fOT#PXc#PXe#PXg#PXh#PX!S#PX!T#PX!U#PX!W#PX!b#PX!f#PX!o#PX!v#PX#R#PX#j#PX#l#PX#m#PX#n#PX$f#PX$g#PX$h#PX$i#PX$p#PX~P#$|OZ!ZO[!ZO]![O^![O_'wOm'uOo'vOq'qOr'qOs)XOy!]O{!jO!h!cO#x!aOu$_X~Qb!RTtXctXetXgtXhtX!StX!TtX!UtX!WtX!btX!ftX!otX!vtX#RtX#jtX#ltX#mtX#ntX$ftX$gtX$htX$itX$ptX~P#$|Ok(OO~Oo(QO~P!&SOw(RO~O![(UO~Oepi~P!@XOexi~P!AuOexi~P!CcO_(iOo(hOq(cOr(cOs)ROeli~P!EPO_(iOq(cOr(cOs)ROeni~P!FqOZ!ZO[!ZO]![O^![O_(iOm(gOo(hOq(cOr(cOs)ROy!]O{!jO!h!cO#x!aOu$_X~OeSq#jSq#|SqwSq!fSqdSqaSq#{Sq#QSqkSq~P#/hO#O(wO~P`Oefq#jfq#|fqwfq!ffqdfqafq#{fq#Qfqkfq~P#/hOepy~P!K}Oe#PX#j#PX#|#PXw#PX!f#PXd#PXa#PX#{#PX#Q#PXk#PX~P#/hOZ!ZO[!ZO]![O^![O_(iOm(gOo(hOq(cOr(cOs)ROy!]O{!jO!h!cO#x!aOu$_X~Qb!Rk(pO~Oo(rO~P!&SOw(sO~Ou)SO~O_(iOm(gOo(hOq(cOr(cOs)ROetX~P0bOu)YO~O",
    goto: "!6x$pPPPP$qP&k&w'Q'm*ePPPPP*nP$qPPP$qPP*q*}P$qP$qP$qPPP+WP+fP$qP$qPP+o,U,i,^PPPPPPP,^PP,^P/O/R,^P/X/_$qP$qP$q/f1`1c1i1`P1t3q1t1t5u7rP$q9o$q;i;i=c=oP=xPP;i>U>[5q>`P>hP>k>q>x?O?U?[AkAvA|BSBYB`BfBlPPPPPPPPBrBvGnIhKhKnPPKuPPK{LXNX!!X!!_!!f!!k!$Q!%k!'Y!)YP!)]P!)a!*z!,e!._!.e!.h$q!.n!0hPPPP!2iGn!2u!4u!4{!6u$oiOPVefqt!Y!^!_!`!d!f!g!h!i!n#_#a#e#i#t$S$]$a$b$e$r$}%Z%f%x%y&n&o&p&q&r&s&t&u&|&}'P'Q'X'Y']'d'f'h'j'p'q'r's't'u'v'w'x(O(Q(R(W(X([(](c(d(e(f(g(h(i(j(p(r(s(w(x(z)R)XQ!XRQ'_'gQ(^)UR({)PW!VR'g)P)UR$n#gY!TR#g'g)P)UY#Wv$c'i)Q)V^#x!n!}%O%X'k)S)YT&Q%m&`%`WOPVXdefgqt!Y!^!_!`!b!d!f!g!h!i#_#a#e#i#t#v$O$Q$S$]$a$b$e$r$}%W%Z%f%l%n%x%y%}&_&c&k&n&o&p&q&r&s&t&u&{&|&}'P'Q'X'Y'[']'d'f'h'j'p'q'r's't'u'v'w'x(O(Q(R(U(W(X([(](c(d(e(f(g(h(i(j(p(r(s(w(x(z)R)Xt!SRv!}#g$c%O%X%m&`'g'i'k)P)Q)S)U)V)YU#c!S#d#wR#w!nU#c!S#d#wT$Z#P$[R$m#eQ#[vQ'a'iQ(_)VR(|)QW#Yv'i)Q)VR%b$cU}P#a#tW#u!i&t'w(iR$h#_Q!QPQ$j#aR$t#tQ$|#vQ%s%WQ&P%lU&U%n&c(UQ&f&_T&l&k'[[!tdefg#t$Qc$u#v%W%l%n&_&c&k'[(U!bjOVq!Y!^!_!`!f!g!i#i$a$e$r%Z%x%y'd'q'r's't'u'v'w'x(O(Q(R(W(X(][!rdg#v$Q%W&kU!wef#tQ#o!bS%R$O&{[&O%l%n&_&c'[(U#V&mPt!d!h!n#_#a#e$S$]$b$}%f&n&o&p&q&r&s&t&u&|&}'P'Q'X'Y']'f'h'j'p([(c(d(e(f(g(h(i(j(p(r(s(w(x(z)R)XR&T%mQ&R%mR&g&`Q&X%nR'm(US&V%n(UR&i&c$oYOPVefqt!Y!^!_!`!d!f!g!h!i!n#_#a#e#i#t$S$]$a$b$e$r$}%Z%f%x%y&n&o&p&q&r&s&t&u&|&}'P'Q'X'Y']'d'f'h'j'p'q'r's't'u'v'w'x(O(Q(R(W(X([(](c(d(e(f(g(h(i(j(p(r(s(w(x(z)R)XR#}!nQ#z!nR%p%OS#y!n%OZ$V!}%X'k)S)Y$ubOPVdefgqt!Y!^!_!`!d!f!g!h!i!n#_#a#e#i#t$Q$S$]$a$b$e$r$}%Z%f%x%y&n&o&p&q&r&s&t&u&|&}'P'Q'X'Y']'d'f'h'j'p'q'r's't'u'v'w'x(O(Q(R(W(X([(](c(d(e(f(g(h(i(j(p(r(s(w(x(z)R)X$tbOPVdefgqt!Y!^!_!`!d!f!g!h!i!n#_#a#e#i#t$Q$S$]$a$b$e$r$}%Z%f%x%y&n&o&p&q&r&s&t&u&|&}'P'Q'X'Y']'d'f'h'j'p'q'r's't'u'v'w'x(O(Q(R(W(X([(](c(d(e(f(g(h(i(j(p(r(s(w(x(z)R)XQ!p_T#Qm$^$u`OPVdefgqt!Y!^!_!`!d!f!g!h!i!n#_#a#e#i#t$Q$S$]$a$b$e$r$}%Z%f%x%y&n&o&p&q&r&s&t&u&|&}'P'Q'X'Y']'d'f'h'j'p'q'r's't'u'v'w'x(O(Q(R(W(X([(](c(d(e(f(g(h(i(j(p(r(s(w(x(z)R)X$uaOPVdefgqt!Y!^!_!`!d!f!g!h!i!n#_#a#e#i#t$Q$S$]$a$b$e$r$}%Z%f%x%y&n&o&p&q&r&s&t&u&|&}'P'Q'X'Y']'d'f'h'j'p'q'r's't'u'v'w'x(O(Q(R(W(X([(](c(d(e(f(g(h(i(j(p(r(s(w(x(z)R)X$ohOPVefqt!Y!^!_!`!d!f!g!h!i!n#_#a#e#i#t$S$]$a$b$e$r$}%Z%f%x%y&n&o&p&q&r&s&t&u&|&}'P'Q'X'Y']'d'f'h'j'p'q'r's't'u'v'w'x(O(Q(R(W(X([(](c(d(e(f(g(h(i(j(p(r(s(w(x(z)R)X$onOPVefqt!Y!^!_!`!d!f!g!h!i!n#_#a#e#i#t$S$]$a$b$e$r$}%Z%f%x%y&n&o&p&q&r&s&t&u&|&}'P'Q'X'Y']'d'f'h'j'p'q'r's't'u'v'w'x(O(Q(R(W(X([(](c(d(e(f(g(h(i(j(p(r(s(w(x(z)R)XQ$Y!}Q'c'kQ(a)YR)O)SW$W!}'k)S)YR%t%XW%w%Z'Q(R(sX&Y%x'X(W(wQ#SmR%^$^T#Rm$^S#Pm$^T$Z#P$[R!QPQqOR#UqS#d!S#wR$k#dQ#h!VR$o#hQ$d#YR%c$dQ#`}R$i#`%OXOPVdefgqt!Y!^!_!`!b!d!f!g!h!i!n#_#a#e#i#t#v$O$Q$S$]$a$b$e$r$}%W%Z%f%x%y&k&n&o&p&q&r&s&t&u&|&}'P'Q'X'Y']'d'f'h'j'p'q'r's't'u'v'w'x(O(Q(R(W(X([(](c(d(e(f(g(h(i(j(p(r(s(w(x(z)R)XS!mX%}_%}%l%n&_&c&{'[(US$P!r!wS%S$P&]R&]&OQ&a&RR&h&aQ&d&VR&j&dQ%P#zR%q%PQ$T!yR%V$TQ%Y$WR%u%YQ$[#PR%[$[Q$_#SR%_$_TpOqSSOqW|P#_#a&tW!lV'](](zQ!veS!yf!nQ#VtQ#k!YQ#l!^Q#m!_W#n!`&q't(fQ#p!dQ#q!fQ#r!gQ#s!hQ$l#eQ$p#iQ$s#tQ%U$SQ%]$]Q%`$aQ%a$bQ%d$eQ%g$rQ%o$}S%v%Z%xQ%z%fQ&Z%yQ&v&nQ&w&oQ&x&pQ&y&rQ&z&sQ'O&uQ'R&|Q'S'fQ'T'dQ'U&}Q'V'PS'W'Q'XQ'Z'YQ'^!iQ'`'hQ'b'jQ'l'pQ'n([Q'y'qQ'z'rQ'{'sQ'|'uQ'}'vQ(P'xQ(S(OQ(T(QS(V(R(WQ(Y(XQ(Z'wQ(`)XQ(k(cQ(l(dQ(m(eQ(n(gQ(o(hQ(q(jQ(t(pQ(u(rS(v(s(wQ(y(xQ(})RR)W(i$ooOPVefqt!Y!^!_!`!d!f!g!h!i!n#_#a#e#i#t$S$]$a$b$e$r$}%Z%f%x%y&n&o&p&q&r&s&t&u&|&}'P'Q'X'Y']'d'f'h'j'p'q'r's't'u'v'w'x(O(Q(R(W(X([(](c(d(e(f(g(h(i(j(p(r(s(w(x(z)R)XpROVq!Y!^!_!`!f!g!i#i$e$r%Z%x%y!j'gPeft!d!h!n#_#a#e#t$S$]$b$}%f&n&o&p&q&r&s&t&u&}'P'Q'X'Y']'h'j'p([)R)Xp)P&|'f(c(d(e(f(g(h(i(j(p(r(s(w(x(zq)U$a'd'q'r's't'u'v'w'x(O(Q(R(W(X(]X!WR'g)P)UZ!UR#g'g)P)UQ#e!TR$b#WQ#i!XQ&u'_Q'x(^R(j({ptOVq!Y!^!_!`!f!g!i#i$e$r%Z%x%y!j'hPeft!d!h!n#_#a#e#t$S$]$b$}%f&n&o&p&q&r&s&t&u&}'P'Q'X'Y']'h'j'p([)R)Xp'p$a'd'q'r's't'u'v'w'x(O(Q(R(W(X(]q([&|'f(c(d(e(f(g(h(i(j(p(r(s(w(x(zpvOVq!Y!^!_!`!f!g!i#i$e$r%Z%x%y!j'iPeft!d!h!n#_#a#e#t$S$]$b$}%f&n&o&p&q&r&s&t&u&}'P'Q'X'Y']'h'j'p([)R)Xp)Q&|'f(c(d(e(f(g(h(i(j(p(r(s(w(x(zq)V$a'd'q'r's't'u'v'w'x(O(Q(R(W(X(]X#Zv'i)Q)VZ#Xv$c'i)Q)VV!OP#a#td!^S#k#q#r$p%d%g%v&Z'^!W&o|!v!y#V#p#s$l$s%U%]%a%o%z&v&y&z'O'U'V'W'Z'`'b'l'n(`(}f'r%`'T'y'|'}(P(S(T(V(Y(Zg(d'R'S(k(n(o(q(t(u(v(y)Wf!_S#k#l#q#r$p%d%g%v&Z'^!Y&p|!v!y#V#p#s$l$s%U%]%a%o%z&v&w&y&z'O'U'V'W'Z'`'b'l'n(`(}h's%`'T'y'z'|'}(P(S(T(V(Y(Zi(e'R'S(k(l(n(o(q(t(u(v(y)Wh!`S#k#l#m#q#r$p%d%g%v&Z'^![&q|!v!y#V#p#s$l$s%U%]%a%o%z&v&w&x&y&z'O'U'V'W'Z'`'b'l'n(`(}j't%`'T'y'z'{'|'}(P(S(T(V(Y(Zk(f'R'S(k(l(m(n(o(q(t(u(v(y)WpVOVq!Y!^!_!`!f!g!i#i$e$r%Z%x%y!j']Peft!d!h!n#_#a#e#t$S$]$b$}%f&n&o&p&q&r&s&t&u&}'P'Q'X'Y']'h'j'p([)R)Xp(]$a'd'q'r's't'u'v'w'x(O(Q(R(W(X(]q(z&|'f(c(d(e(f(g(h(i(j(p(r(s(w(x(zR&S%mT&W%n(U$P!bS|!l!v!y#V#k#l#m#n#p#q#r#s$l$p$s%U%]%`%a%d%g%o%v%z&Z&v&w&x&y&z'O'R'S'T'U'V'W'Z'^'`'b'l'n'y'z'{'|'}(P(S(T(V(Y(Z(`(k(l(m(n(o(q(t(u(v(y(})W$P!dS|!l!v!y#V#k#l#m#n#p#q#r#s$l$p$s%U%]%`%a%d%g%o%v%z&Z&v&w&x&y&z'O'R'S'T'U'V'W'Z'^'`'b'l'n'y'z'{'|'}(P(S(T(V(Y(Z(`(k(l(m(n(o(q(t(u(v(y(})W$oZOPVefqt!Y!^!_!`!d!f!g!h!i!n#_#a#e#i#t$S$]$a$b$e$r$}%Z%f%x%y&n&o&p&q&r&s&t&u&|&}'P'Q'X'Y']'d'f'h'j'p'q'r's't'u'v'w'x(O(Q(R(W(X([(](c(d(e(f(g(h(i(j(p(r(s(w(x(z)R)XQ!oZR!q`R#{!nQ!zfR#|!n$ocOPVefqt!Y!^!_!`!d!f!g!h!i!n#_#a#e#i#t$S$]$a$b$e$r$}%Z%f%x%y&n&o&p&q&r&s&t&u&|&}'P'Q'X'Y']'d'f'h'j'p'q'r's't'u'v'w'x(O(Q(R(W(X([(](c(d(e(f(g(h(i(j(p(r(s(w(x(z)R)X$hcOPVqt!Y!^!_!`!d!f!g!h!i!n#_#a#e#i$S$]$a$b$e$r$}%Z%f%x%y&n&o&p&q&r&s&t&u&|&}'P'Q'X'Y']'d'f'h'j'p'q'r's't'u'v'w'x(O(Q(R(W(X([(](c(d(e(f(g(h(i(j(p(r(s(w(x(z)R)XU!tdg$QV!xef#tW!udef#tQ!{gR%T$QpkOVq!Y!^!_!`!f!g!i#i$e$r%Z%x%y!j'oPeft!d!h!n#_#a#e#t$S$]$b$}%f&n&o&p&q&r&s&t&u&}'P'Q'X'Y']'h'j'p([)R)Xp)T&|'f(c(d(e(f(g(h(i(j(p(r(s(w(x(zq)Z$a'd'q'r's't'u'v'w'x(O(Q(R(W(X(]X$X!}'k)S)Y$omOPVefqt!Y!^!_!`!d!f!g!h!i!n#_#a#e#i#t$S$]$a$b$e$r$}%Z%f%x%y&n&o&p&q&r&s&t&u&|&}'P'Q'X'Y']'d'f'h'j'p'q'r's't'u'v'w'x(O(Q(R(W(X([(](c(d(e(f(g(h(i(j(p(r(s(w(x(z)R)XR#Tm",
    nodeNames: "⚠ LineComment BlockComment Expressions ForExpression for InExpressions InExpression Name Identifier Identifier ArithOp ArithOp ArithOp ArithOp in IterationContext return IfExpression if then else QuantifiedExpression some every InExpressions InExpression satisfies Disjunction or Conjunction and Comparison CompareOp CompareOp between PositiveUnaryTest ( PositiveUnaryTests ) ArithmeticExpression ArithOp InstanceOfExpression instance of Type QualifiedName VariableName SpecialType days time duration years months date > ListType list < ContextType context ContextEntryTypes ContextEntryType FunctionType function ArgumentTypes ArgumentType PathExpression ] FilterExpression [ FunctionInvocation SpecialFunctionName NamedParameters NamedParameter ParameterName PositionalParameters null NumericLiteral StringLiteral BooleanLiteral DateTimeLiteral DateTimeConstructor AtLiteral ? SimplePositiveUnaryTest Interval ParenthesizedExpression List FunctionDefinition FormalParameters FormalParameter external FunctionBody } { Context ContextEntry Key Name Identifier UnaryTests Wildcard not",
    maxTerm: 170,
    context: variableTracker,
    nodeProps: [["group", -17, 4, 18, 22, 28, 30, 32, 40, 42, 67, 69, 71, 84, 85, 87, 88, 89, 96, "Expression", 47, "Expression Expression", -5, 77, 78, 79, 80, 81, "Expression Literal"], ["closedBy", 37, ")", 70, "]", 95, "}"], ["openedBy", 39, "(", 68, "[", 94, "{"]],
    propSources: [feelHighlighting],
    skippedNodes: [0, 1, 2],
    repeatNodeCount: 14,
    tokenData: ")x~RuXY#fYZ$ZZ[#f]^$Zpq#fqr$`rs$kwx%_xy%dyz%iz{%n{|%{|}&Q}!O&V!O!P&d!P!Q&|!Q![(X![!](j!]!^(o!^!_(t!_!`$f!`!a)T!b!c)_!}#O)d#P#Q)i#Q#R%v#o#p)n#q#r)s$f$g#f#BY#BZ#f$IS$I_#f$I|$I}$Z$I}$JO$Z$JT$JU#f$KV$KW#f&FU&FV#f?HT?HU#f~#kY#p~XY#fZ[#fpq#f$f$g#f#BY#BZ#f$IS$I_#f$JT$JU#f$KV$KW#f&FU&FV#f?HT?HU#f~$`O#q~~$cP!_!`$f~$kOq~~$pU$g~OY$kZr$krs%Ss#O$k#O#P%X#P~$k~%XO$g~~%[PO~$k~%dO#y~~%iOu~~%nOw~~%sP^~z{%v~%{Oy~~&QO[~~&VO#|~R&[PZP!`!a&_Q&dO$[Q~&iQ#x~!O!P&o!Q![&t~&tO#{~~&yP$f~!Q![&t~'RQ]~z{'X!P!Q'|~'[ROz'Xz{'e{~'X~'hTOz'Xz{'e{!P'X!P!Q'w!Q~'X~'|OQ~~(RQP~OY'|Z~'|~(^Q$f~!O!P(d!Q![(X~(gP!Q![&t~(oO$Y~~(tO$p~R({P![QrP!_!`)OP)TOrPR)[P!XQrP!_!`)O~)dO$i~~)iO!h~~)nO!f~~)sO#R~~)xO#Q~",
    tokenizers: [propertyIdentifiers, identifiers, insertSemicolon, 0, 1],
    topRules: {
      "Expressions": [0, 3],
      "UnaryTests": [1, 101]
    },
    dynamicPrecedences: {
      "30": -1,
      "71": -1,
      "73": -1,
      "126": -1
    },
    specialized: [{
      term: 120,
      get: value => spec_identifier[value] || -1
    }],
    tokenPrec: 0
  });

  // / [snippets](#autocomplete.snippet).

  const snippets = [/*@__PURE__*/snippetCompletion('function(${params}) ${body}', {
    label: 'function',
    detail: 'definition',
    type: 'keyword'
  }), /*@__PURE__*/snippetCompletion('for ${var} in ${collection} return ${value}', {
    label: 'for',
    detail: 'expression',
    type: 'keyword'
  }), /*@__PURE__*/snippetCompletion('every ${var} in ${collection} satisfies ${condition}', {
    label: 'every',
    detail: 'quantified expression',
    type: 'keyword'
  }), /*@__PURE__*/snippetCompletion('some ${var} in ${collection} satisfies ${condition}', {
    label: 'some',
    detail: 'quantified expression',
    type: 'keyword'
  }), /*@__PURE__*/snippetCompletion('if ${condition} then ${value}', {
    label: 'if',
    detail: 'block',
    type: 'keyword'
  }), /*@__PURE__*/snippetCompletion('if ${condition} then ${value} else ${other value}', {
    label: 'if',
    detail: '/ else block',
    type: 'keyword'
  })]; // / A language provider based on the [Lezer FEEL
  // / parser](https://github.com/nikku/lezer-feel), extended with
  // / highlighting and indentation information.

  const feelLanguage = /*@__PURE__*/LRLanguage.define({
    parser: /*@__PURE__*/parser.configure({
      props: [/*@__PURE__*/indentNodeProp.add({
        'Context': /*@__PURE__*/delimitedIndent({
          closing: '}'
        }),
        'List FilterExpression': /*@__PURE__*/delimitedIndent({
          closing: ']'
        }),
        'ParenthesizedExpression FunctionInvocation': /*@__PURE__*/delimitedIndent({
          closing: ')'
        }),
        'ForExpression QuantifiedExpression IfExpression': /*@__PURE__*/continuedIndent({
          except: /^\s*(then|else|return|satisfies)\b/
        }),
        'FunctionDefinition': /*@__PURE__*/continuedIndent({
          except: /^\s*(\(|\))/
        })
      }), /*@__PURE__*/foldNodeProp.add({
        Context: foldInside,
        List: foldInside,

        FunctionDefinition(node) {
          const last = node.getChild(')');
          if (!last) return null;
          return {
            from: last.to,
            to: node.to
          };
        }

      })]
    }),
    languageData: {
      indentOnInput: /^\s*(\)|\}|\]|then|else|return|satisfies)$/,
      commentTokens: {
        line: '//',
        block: {
          open: '/*',
          close: '*/'
        }
      }
    }
  }); // / A language provider for TypeScript.

  function isNodeEmpty(node) {
    return node.from === node.to;
  }

  function isPathExpression(node) {
    if (!node) {
      return false;
    }

    if (node.name === 'PathExpression') {
      return true;
    }

    return isPathExpression(node.parent);
  }

  var tags = [{
    name: "not()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>negand</code>: boolean</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">not(true);\n// false\n</code></pre>\n"
  }, {
    name: "is defined()",
    description: "<p>Checks if a given value is defined. A value is defined if it exists, and it is an instance of one of the FEEL data types including <code>null</code>.</p>\n<p>The function can be used to check if a variable or a context entry (e.g. a property of a variable) exists. It allows differentiating between a <code>null</code> variable and a value that doesn&#39;t exist.</p>\n<ul>\n<li>parameters:<ul>\n<li><code>value</code>: any</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">is defined(1)\n// true\n\nis defined(null)\n// true\n\nis defined(x)\n// false - if no variable &quot;x&quot; exists\n\nis defined(x.y)\n// false - if no variable &quot;x&quot; exists or it doesn&#39;t have a property &quot;y&quot;\n</code></pre>\n"
  }, {
    name: "get value()",
    description: "<p>Returns the value of the context entry with the given key.</p>\n<ul>\n<li>parameters:<ul>\n<li><code>context</code>: context</li>\n<li><code>key</code>: string</li>\n</ul>\n</li>\n<li>result: any</li>\n</ul>\n<pre><code class=\"language-js\">get value({foo: 123}, &quot;foo&quot;)\n// 123\n</code></pre>\n"
  }, {
    name: "get entries()",
    description: "<p>Returns the entries of the context as a list of key-value-pairs.</p>\n<ul>\n<li>parameters:<ul>\n<li><code>context</code>: context</li>\n</ul>\n</li>\n<li>result: list of context which contains two entries for &quot;key&quot; and &quot;value&quot;</li>\n</ul>\n<pre><code class=\"language-js\">get entries({foo: 123})\n// [{key: &quot;foo&quot;, value: 123}]\n</code></pre>\n"
  }, {
    name: "put()",
    description: "<p>Add the given key and value to a context. Returns a new context that includes the entry. It might override an existing entry of the context.</p>\n<p>Returns <code>null</code> if the value is not defined.</p>\n<ul>\n<li>parameters:<ul>\n<li><code>context</code>: context</li>\n<li><code>key</code>: string</li>\n<li><code>value</code>: any</li>\n</ul>\n</li>\n<li>result: context</li>\n</ul>\n<pre><code class=\"language-js\">put({ x: 1 }, &quot;y&quot;, 2);\n// {x:1, y:2}\n</code></pre>\n"
  }, {
    name: "put all()",
    description: "<p>Union the given contexts (two or more). Returns a new context that includes all entries of the given contexts. It might override context entries if the keys are equal. The entries are overridden in the same order as the contexts are passed in the method.</p>\n<p>Returns <code>null</code> if one of the values is not a context.</p>\n<ul>\n<li>parameters:<ul>\n<li><code>contexts</code>: contexts as varargs</li>\n</ul>\n</li>\n<li>result: context</li>\n</ul>\n<pre><code class=\"language-js\">put all({x:1}, {y:2})\n// {x:1, y:2}\n</code></pre>\n"
  }, {
    name: "date()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>from</code>: string / date-time</li>\n<li>or <code>year</code>, <code>month</code>, <code>day</code>: number</li>\n</ul>\n</li>\n<li>result: date</li>\n</ul>\n<pre><code class=\"language-js\">date(birthday)\n// date(&quot;2018-04-29&quot;)\n\ndate(date and time(&quot;2012-12-25T11:00:00&quot;))\n// date(&quot;2012-12-25&quot;)\n\ndate(2012, 12, 25)\n// date(&quot;2012-12-25&quot;)\n</code></pre>\n"
  }, {
    name: "time()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>from</code>: string / date-time</li>\n<li>or <code>hour</code>, <code>minute</code>, <code>second</code>: number<ul>\n<li>(optional) <code>offset</code>: day-time-duration</li>\n</ul>\n</li>\n</ul>\n</li>\n<li>result: time</li>\n</ul>\n<pre><code class=\"language-js\">time(lunchTime)\n// time(&quot;12:00:00&quot;)\n\ntime(date and time(&quot;2012-12-25T11:00:00&quot;))\n// time(&quot;11:00:00&quot;)\n\ntime(23, 59, 0)\n// time(&quot;23:59:00&quot;)\n\ntime(14, 30, 0, duration(&quot;PT1H&quot;))\n// time(&quot;15:30:00&quot;)\n</code></pre>\n"
  }, {
    name: "date and time()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>date</code>: date / date-time</li>\n<li><code>time</code>: time</li>\n<li>or <code>from</code>: string</li>\n</ul>\n</li>\n<li>result: date-time</li>\n</ul>\n<pre><code class=\"language-js\">date and time(date(&quot;2012-12-24&quot;),time(&quot;T23:59:00&quot;))\n// date and time(&quot;2012-12-24T23:59:00&quot;)\n\ndate and time(date and time(&quot;2012-12-25T11:00:00&quot;),time(&quot;T23:59:00&quot;))\n// date and time(&quot;2012-12-25T23:59:00&quot;)\n\ndate and time(birthday)\n// date and time(&quot;2018-04-29T009:30:00&quot;)\n</code></pre>\n"
  }, {
    name: "duration()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>from</code>: string</li>\n</ul>\n</li>\n<li>result: day-time-duration or year-month-duration</li>\n</ul>\n<pre><code class=\"language-js\">duration(weekDays);\n// duration(&quot;P5D&quot;)\n\nduration(age);\n// duration(&quot;P32Y&quot;)\n</code></pre>\n"
  }, {
    name: "years and months duration()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>from</code>: date</li>\n<li><code>to</code>: date</li>\n</ul>\n</li>\n<li>result: year-month-duration</li>\n</ul>\n<pre><code class=\"language-js\">years and months duration(date(&quot;2011-12-22&quot;), date(&quot;2013-08-24&quot;))\n// duration(&quot;P1Y8M&quot;)\n</code></pre>\n"
  }, {
    name: "number()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>from</code>: string</li>\n</ul>\n</li>\n<li>result: number</li>\n</ul>\n<pre><code class=\"language-js\">number(&quot;1500.5&quot;);\n// 1500.5\n</code></pre>\n"
  }, {
    name: "string()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>from</code>: any</li>\n</ul>\n</li>\n<li>result: string</li>\n</ul>\n<pre><code class=\"language-js\">string(1.1);\n// &quot;1.1&quot;\n\nstring(date(&quot;2012-12-25&quot;));\n// &quot;2012-12-25&quot;\n</code></pre>\n"
  }, {
    name: "context()",
    description: "<p>Constructs a context of the given list of key-value pairs. It is the reverse function to <a href=\"feel-built-in-functions-context.md#get-entries\">get entries()</a>.</p>\n<p>Each key-value pair must be a context with two entries: <code>key</code> and <code>value</code>. The entry with name <code>key</code> must have a value of the type <code>string</code>.</p>\n<p>It might override context entries if the keys are equal. The entries are overridden in the same order as the contexts in the given list.</p>\n<p>Returns <code>null</code> if one of the entries is not a context or if a context doesn&#39;t contain the required entries.</p>\n<ul>\n<li>parameters:<ul>\n<li><code>entries</code>: list of contexts</li>\n</ul>\n</li>\n<li>result: context</li>\n</ul>\n<pre><code class=\"language-js\">context([\n  { key: &quot;a&quot;, value: 1 },\n  { key: &quot;b&quot;, value: 2 },\n]);\n// {a:1, b:2}\n</code></pre>\n"
  }, {
    name: "list contains()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list</li>\n<li><code>element</code>: any</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">list contains([1,2,3], 2)\n// true\n</code></pre>\n"
  }, {
    name: "count()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list</li>\n</ul>\n</li>\n<li>result: number</li>\n</ul>\n<pre><code class=\"language-js\">count([1, 2, 3]);\n// 3\n</code></pre>\n"
  }, {
    name: "min()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list of numbers</li>\n<li>or numbers as varargs</li>\n</ul>\n</li>\n<li>result: number</li>\n</ul>\n<pre><code class=\"language-js\">min([1, 2, 3]);\n// 1\n\nmin(1, 2, 3);\n// 1\n</code></pre>\n"
  }, {
    name: "max()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list of numbers</li>\n<li>or numbers as varargs</li>\n</ul>\n</li>\n<li>result: number</li>\n</ul>\n<pre><code class=\"language-js\">min([1, 2, 3]);\n// 3\n\nmin(1, 2, 3);\n// 3\n</code></pre>\n"
  }, {
    name: "sum()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list of numbers</li>\n<li>or numbers as varargs</li>\n</ul>\n</li>\n<li>result: number</li>\n</ul>\n<pre><code class=\"language-js\">min([1, 2, 3]);\n// 6\n\nmin(1, 2, 3);\n// 6\n</code></pre>\n"
  }, {
    name: "product()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list of numbers</li>\n<li>or numbers as varargs</li>\n</ul>\n</li>\n<li>result: number</li>\n</ul>\n<pre><code class=\"language-js\">product([2, 3, 4]);\n// 24\n\nproduct(2, 3, 4);\n// 24\n</code></pre>\n"
  }, {
    name: "mean()",
    description: "<p>Returns the arithmetic mean (i.e. average).</p>\n<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list of numbers</li>\n<li>or numbers as varargs</li>\n</ul>\n</li>\n<li>result: number</li>\n</ul>\n<pre><code class=\"language-js\">mean([1, 2, 3]);\n// 2\n\nmean(1, 2, 3);\n// 2\n</code></pre>\n"
  }, {
    name: "median()",
    description: "<p>Returns the median element of the list of numbers.</p>\n<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list of numbers</li>\n<li>or numbers as varargs</li>\n</ul>\n</li>\n<li>result: number</li>\n</ul>\n<pre><code class=\"language-js\">median(8, 2, 5, 3, 4);\n// 4\n\nmedian([6, 1, 2, 3]);\n// 2.5\n</code></pre>\n"
  }, {
    name: "stddev()",
    description: "<p>Returns the standard deviation.</p>\n<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list of numbers</li>\n<li>or numbers as varargs</li>\n</ul>\n</li>\n<li>result: number</li>\n</ul>\n<pre><code class=\"language-js\">stddev(2, 4, 7, 5);\n// 2.0816659994661326\n\nstddev([2, 4, 7, 5]);\n// 2.0816659994661326\n</code></pre>\n"
  }, {
    name: "mode()",
    description: "<p>Returns the mode of the list of numbers.</p>\n<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list of numbers</li>\n<li>or numbers as varargs</li>\n</ul>\n</li>\n<li>result: list of numbers</li>\n</ul>\n<pre><code class=\"language-js\">mode(6, 3, 9, 6, 6);\n// [6]\n\nmode([6, 1, 9, 6, 1]);\n// [1, 6]\n</code></pre>\n"
  }, {
    name: "and()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list of booleans</li>\n<li>or booleans as varargs</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">and([true, false]);\n// false\n\nand(false, null, true);\n// false\n</code></pre>\n"
  }, {
    name: "all()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list of booleans</li>\n<li>or booleans as varargs</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">and([true, false]);\n// false\n\nand(false, null, true);\n// false\n</code></pre>\n"
  }, {
    name: "or()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list of booleans</li>\n<li>or booleans as varargs</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">or([false, true]);\n// true\n\nor(false, null, true);\n// true\n</code></pre>\n"
  }, {
    name: "any()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list of booleans</li>\n<li>or booleans as varargs</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">or([false, true]);\n// true\n\nor(false, null, true);\n// true\n</code></pre>\n"
  }, {
    name: "sublist()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list</li>\n<li><code>start position</code>: number</li>\n<li>(optional) <code>length</code>: number</li>\n</ul>\n</li>\n<li>result: list</li>\n</ul>\n<pre><code class=\"language-js\">sublist([1, 2, 3], 2);\n// [2,3]\n\nsublist([1, 2, 3], 1, 2);\n// [1,2]\n</code></pre>\n"
  }, {
    name: "append()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list</li>\n<li><code>items</code>: elements as varargs</li>\n</ul>\n</li>\n<li>result: list</li>\n</ul>\n<pre><code class=\"language-js\">append([1], 2, 3);\n// [1,2,3]\n</code></pre>\n"
  }, {
    name: "concatenate()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>lists</code>: lists as varargs</li>\n</ul>\n</li>\n<li>result: list</li>\n</ul>\n<pre><code class=\"language-js\">concatenate([1, 2], [3]);\n// [1,2,3]\n\nconcatenate([1], [2], [3]);\n// [1,2,3]\n</code></pre>\n"
  }, {
    name: "insert before()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list</li>\n<li><code>position</code>: number</li>\n<li><code>newItem</code>: any</li>\n</ul>\n</li>\n<li>result: list</li>\n</ul>\n<pre><code class=\"language-js\">insert before([1,3],1,2)\n// [1,2,3]\n</code></pre>\n"
  }, {
    name: "remove()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list</li>\n<li><code>position</code>: number</li>\n</ul>\n</li>\n<li>result: list</li>\n</ul>\n<pre><code class=\"language-js\">remove([1, 2, 3], 2);\n// [1,3]\n</code></pre>\n"
  }, {
    name: "reverse()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list</li>\n</ul>\n</li>\n<li>result: list</li>\n</ul>\n<pre><code class=\"language-js\">reverse([1, 2, 3]);\n// [3,2,1]\n</code></pre>\n"
  }, {
    name: "index of()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list</li>\n<li><code>match</code>: any</li>\n</ul>\n</li>\n<li>result: list of numbers</li>\n</ul>\n<pre><code class=\"language-js\">index of([1,2,3,2],2)\n// [2,4]\n</code></pre>\n"
  }, {
    name: "union()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>lists</code>: lists as varargs</li>\n</ul>\n</li>\n<li>result: list</li>\n</ul>\n<pre><code class=\"language-js\">union([1, 2], [2, 3]);\n// [1,2,3]\n</code></pre>\n"
  }, {
    name: "distinct values()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list</li>\n</ul>\n</li>\n<li>result: list</li>\n</ul>\n<pre><code class=\"language-js\">distinct values([1,2,3,2,1])\n// [1,2,3]\n</code></pre>\n"
  }, {
    name: "flatten()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list</li>\n</ul>\n</li>\n<li>result: list</li>\n</ul>\n<pre><code class=\"language-js\">flatten([[1, 2], [[3]], 4]);\n// [1,2,3,4]\n</code></pre>\n"
  }, {
    name: "sort()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>list</code>: list</li>\n<li><code>precedes</code>: function with two arguments and boolean result</li>\n</ul>\n</li>\n<li>result: list</li>\n</ul>\n<pre><code class=\"language-js\">sort(list: [3,1,4,5,2], precedes: function(x,y) x &lt; y)\n// [1,2,3,4,5]\n</code></pre>\n"
  }, {
    name: "string join()",
    description: "<p>This joins a list of strings into a single string. This is similar to\nJava&#39;s <a href=\"https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/Collectors.html#joining(java.lang.CharSequence,java.lang.CharSequence,java.lang.CharSequence)\">joining</a>\nfunction.</p>\n<p>If an item of the list is <code>null</code>, the item is ignored for the result string. If an item is\nneither a string nor <code>null</code>, the function returns <code>null</code> instead of a string.</p>\n<ul>\n<li>Parameters:<ul>\n<li><code>list</code>: The list of strings to join</li>\n<li><code>delimiter</code>: (Optional) The string used between each element (default: empty string)</li>\n<li><code>prefix</code>: (Optional) The string used at the beginning of the joined result (default:\nempty string)</li>\n<li><code>suffix</code>: (Optional) The string used at the end of the joined result (default: empty\nstring)</li>\n</ul>\n</li>\n<li>Result: The joined list as a string</li>\n</ul>\n<pre><code class=\"language-js\">string join([&quot;a&quot;,&quot;b&quot;,&quot;c&quot;])\n// &quot;abc&quot;\nstring join([&quot;a&quot;], &quot;X&quot;)\n// &quot;a&quot;\nstring join([&quot;a&quot;,&quot;b&quot;,&quot;c&quot;], &quot;, &quot;)\n// &quot;a, b, c&quot;\nstring join([&quot;a&quot;,&quot;b&quot;,&quot;c&quot;], &quot;, &quot;, &quot;[&quot;, &quot;]&quot;)\n// &quot;[a, b, c]&quot;\nstring join([&quot;a&quot;,null,&quot;c&quot;])\n// &quot;ac&quot;\nstring join([])\n// &quot;&quot;\n</code></pre>\n"
  }, {
    name: "decimal()",
    description: "<p>Round the given number at the given scale using the given rounding mode. If no rounding mode is passed in, it uses <code>HALF_EVEN</code> as default.</p>\n<ul>\n<li>parameters:<ul>\n<li><code>n</code>: number</li>\n<li><code>scale</code>: number</li>\n<li>(optional) <code>mode</code>: string - one of <code>UP, DOWN, CEILING, FLOOR, HALF_UP, HALF_DOWN, HALF_EVEN, UNNECESSARY</code> (default: <code>HALF_EVEN</code>)</li>\n</ul>\n</li>\n<li>result: number</li>\n</ul>\n<pre><code class=\"language-js\">decimal(1 / 3, 2);\n// .33\n\ndecimal(1.5, 0);\n// 2\n\ndecimal(2.5, 0, &quot;half_up&quot;);\n// 3\n</code></pre>\n"
  }, {
    name: "floor()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>n</code>: number</li>\n</ul>\n</li>\n<li>result: number</li>\n</ul>\n<pre><code class=\"language-js\">floor(1.5);\n// 1\n\nfloor(-1.5);\n// -2\n</code></pre>\n"
  }, {
    name: "ceiling()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>n</code>: number</li>\n</ul>\n</li>\n<li>result: number</li>\n</ul>\n<pre><code class=\"language-js\">ceiling(1.5);\n// 2\n\nfloor(-1.5);\n// -1\n</code></pre>\n"
  }, {
    name: "abs()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>number</code>: number</li>\n</ul>\n</li>\n<li>result: number</li>\n</ul>\n<pre><code class=\"language-js\">abs(10);\n// 10\n\nabs(-10);\n// 10\n</code></pre>\n"
  }, {
    name: "modulo()",
    description: "<p>Returns the remainder of the division of dividend by divisor.</p>\n<ul>\n<li>parameters:<ul>\n<li><code>dividend</code>: number</li>\n<li><code>divisor</code>: number</li>\n</ul>\n</li>\n<li>result: number</li>\n</ul>\n<pre><code class=\"language-js\">modulo(12, 5);\n// 2\n</code></pre>\n"
  }, {
    name: "sqrt()",
    description: "<p>Returns the square root.</p>\n<ul>\n<li>parameters:<ul>\n<li><code>number</code>: number</li>\n</ul>\n</li>\n<li>result: number</li>\n</ul>\n<pre><code class=\"language-js\">sqrt(16);\n// 4\n</code></pre>\n"
  }, {
    name: "log()",
    description: "<p>Returns the natural logarithm (base e) of the number.</p>\n<ul>\n<li>parameters:<ul>\n<li><code>number</code>: number</li>\n</ul>\n</li>\n<li>result: number</li>\n</ul>\n<pre><code class=\"language-js\">log(10);\n// 2.302585092994046\n</code></pre>\n"
  }, {
    name: "exp()",
    description: "<p>Returns the Euler’s number e raised to the power of number .</p>\n<ul>\n<li>parameters:<ul>\n<li><code>number</code>: number</li>\n</ul>\n</li>\n<li>result: number</li>\n</ul>\n<pre><code class=\"language-js\">exp(5);\n// 148.4131591025766\n</code></pre>\n"
  }, {
    name: "odd()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>number</code>: number</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">odd(5);\n// true\n</code></pre>\n"
  }, {
    name: "even()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>number</code>: number</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">odd(5);\n// false\n</code></pre>\n"
  }, {
    name: "before()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>point1</code>, <code>point2</code>: any</li>\n<li>or <code>range</code>: range, <code>point</code>: any</li>\n<li>or <code>point</code>: any, <code>range</code>: range</li>\n<li>or <code>range1</code>, <code>range2</code>: range</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">before(1, 10)\n// true\n\nbefore(10, 1)\n// false\n\nbefore(1, [2..5])\n// true\n\nbefore([1..5], 10)\n// true\n\nbefore([1..5], [6..10])\n// true\n\nbefore([1..5),[5..10])\n// true\n</code></pre>\n"
  }, {
    name: "after()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>point1</code>, <code>point2</code>: any</li>\n<li>or <code>range</code>: range, <code>point</code>: any</li>\n<li>or <code>point</code>: any, <code>range</code>: range</li>\n<li>or <code>range1</code>, <code>range2</code>: range</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">after(10, 1)\n// true\n\nafter(1, 10)\n// false\n\nafter(12, [2..5])\n// true\n\n([1..5], 10)\n// false\n\nbefore([6..10], [1..5])\n// true\n\nbefore([5..10], [1..5))\n// true\n</code></pre>\n"
  }, {
    name: "meets()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>range1</code>: range</li>\n<li><code>range2</code>: range</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">meets([1..5], [5..10])\n// true\n\nmeets([1..3], [4..6])\n// false\n\nmeets([1..3], [3..5])\n// true\n\nmeets([1..5], (5..8])\n// false\n</code></pre>\n"
  }, {
    name: "met by()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>range1</code>: range</li>\n<li><code>range2</code>: range</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">met by([5..10], [1..5])\n// true\n\nmet by([3..4], [1..2])\n// false\n\nmet by([3..5], [1..3])\n// true\n\nmet by((5..8], [1..5))\n// false\n\nmet by([5..10], [1..5))\n// false\n</code></pre>\n"
  }, {
    name: "overlaps()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>range1</code>: range</li>\n<li><code>range2</code>: range</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">overlaps([5..10], [1..6])\n// true\n\noverlaps((3..7], [1..4])\n// true\n\noverlaps([1..3], (3..6])\n// false\n\noverlaps((5..8], [1..5))\n// false\n\noverlaps([4..10], [1..5))\n// treu\n</code></pre>\n"
  }, {
    name: "overlaps before()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>range1</code>: range</li>\n<li><code>range2</code>: range</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">overlaps before([1..5], [4..10])\n// true\n\noverlaps before([3..4], [1..2])\n// false\n\noverlaps before([1..3], (3..5])\n// false\n\noverlaps before([1..5), (3..8])\n// true\n\noverlaps before([1..5), [5..10])\n// false\n</code></pre>\n"
  }, {
    name: "overlaps after()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>range1</code>: range</li>\n<li><code>range2</code>: range</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">overlaps after([4..10], [1..5])\n// true\n\noverlaps after([3..4], [1..2])\n// false\n\noverlaps after([3..5], [1..3))\n// false\n\noverlaps after((5..8], [1..5))\n// false\n\noverlaps after([4..10], [1..5))\n// true\n</code></pre>\n"
  }, {
    name: "finishes()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>point</code>: any, <code>range</code>: range</li>\n<li>or <code>range1</code>, <code>range2</code>: range</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">finishes(5, [1..5])\n// true\n\nfinishes(10, [1..7])\n// false\n\nfinishes([3..5], [1..5])\n// true\n\nfinishes((1..5], [1..5))\n// false\n\nfinishes([5..10], [1..10))\n// false\n</code></pre>\n"
  }, {
    name: "finished by()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>range</code>: range, <code>point</code>: any</li>\n<li>or <code>range1</code>, <code>range2</code>: range</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">finishes by([5..10], 10)\n// true\n\nfinishes by([3..4], 2)\n// false\n\nfinishes by([3..5], [1..5])\n// true\n\nfinishes by((5..8], [1..5))\n// false\n\nfinishes by([5..10], (1..10))\n// true\n</code></pre>\n"
  }, {
    name: "includes()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>range</code>: range, <code>point</code>: any</li>\n<li>or <code>range1</code>, <code>range2</code>: range</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">includes([5..10], 6)\n// true\n\nincludes([3..4], 5)\n// false\n\nincludes([1..10], [4..6])\n// true\n\nincludes((5..8], [1..5))\n// false\n\nincludes([1..10], [1..5))\n// true\n</code></pre>\n"
  }, {
    name: "during()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>point</code>: any, <code>range</code>: range</li>\n<li>or <code>range1</code>, <code>range2</code>: range</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">during(5, [1..10])\n// true\n\nduring(12, [1..10])\n// false\n\nduring(1, (1..10])\n// false\n\nduring([4..6], [1..10))\n// true\n\nduring((1..5], (1..10])\n// true\n</code></pre>\n"
  }, {
    name: "starts()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>point</code>: any, <code>range</code>: range</li>\n<li>or <code>range1</code>, <code>range2</code>: range</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">starts(1, [1..5])\n// true\n\nstarts(1, (1..8])\n// false\n\nstarts((1..5], [1..5])\n// false\n\nstarts([1..10], [1..10])\n// true\n\nstarts((1..10), (1..10))\n// true\n</code></pre>\n"
  }, {
    name: "started by()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>range</code>: range, <code>point</code>: any</li>\n<li>or <code>range1</code>, <code>range2</code>: range</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">started by([1..10], 1)\n// true\n\nstarted by((1..10], 1)\n// false\n\nstarted by([1..10], [1..5])\n// true\n\nstarted by((1..10], [1..5))\n// false\n\nstarted by([1..10], [1..10))\n// true\n</code></pre>\n"
  }, {
    name: "coincides()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>point1</code>, <code>point2</code>: any</li>\n<li>or <code>range1</code>, <code>range2</code>: range</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">coincides(5, 5)\n// true\n\ncoincides(3, 4)\n// false\n\ncoincides([1..5], [1..5])\n// true\n\ncoincides((1..5], [1..5))\n// false\n\ncoincides([1..5], [2..6])\n// false\n</code></pre>\n"
  }, {
    name: "substring()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>string</code>: string</li>\n<li><code>start position</code>: number</li>\n<li>(optional) <code>length</code>: number</li>\n</ul>\n</li>\n<li>result: string</li>\n</ul>\n<pre><code class=\"language-js\">substring(&quot;foobar&quot;, 3);\n// &quot;obar&quot;\n\nsubstring(&quot;foobar&quot;, 3, 3);\n// &quot;oba&quot;\n</code></pre>\n"
  }, {
    name: "string length()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>string</code>: string</li>\n</ul>\n</li>\n<li>result: number</li>\n</ul>\n<pre><code class=\"language-js\">string length(&quot;foo&quot;)\n// 3\n</code></pre>\n"
  }, {
    name: "upper case()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>string</code>: string</li>\n</ul>\n</li>\n<li>result: string</li>\n</ul>\n<pre><code class=\"language-js\">upper case(&quot;aBc4&quot;)\n// &quot;ABC4&quot;\n</code></pre>\n"
  }, {
    name: "lower case()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>string</code>: string</li>\n</ul>\n</li>\n<li>result: string</li>\n</ul>\n<pre><code class=\"language-js\">lower case(&quot;aBc4&quot;)\n// &quot;abc4&quot;\n</code></pre>\n"
  }, {
    name: "substring before()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>string</code>: string</li>\n<li><code>match</code>: string</li>\n</ul>\n</li>\n<li>result: string</li>\n</ul>\n<pre><code class=\"language-js\">substring before(&quot;foobar&quot;, &quot;bar&quot;)\n// &quot;foo&quot;\n</code></pre>\n"
  }, {
    name: "substring after()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>string</code>: string</li>\n<li><code>match</code>: string</li>\n</ul>\n</li>\n<li>result: string</li>\n</ul>\n<pre><code class=\"language-js\">substring after(&quot;foobar&quot;, &quot;ob&quot;)\n// &quot;ar&quot;\n</code></pre>\n"
  }, {
    name: "contains()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>string</code>: string</li>\n<li><code>match</code>: string</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">contains(&quot;foobar&quot;, &quot;of&quot;);\n// false\n</code></pre>\n"
  }, {
    name: "starts with()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>input</code>: string</li>\n<li><code>match</code>: string</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">starts with(&quot;foobar&quot;, &quot;fo&quot;)\n// true\n</code></pre>\n"
  }, {
    name: "ends with()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>input</code>: string</li>\n<li><code>match</code>: string</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">ends with(&quot;foobar&quot;, &quot;r&quot;)\n// true\n</code></pre>\n"
  }, {
    name: "matches()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>input</code>: string</li>\n<li><code>pattern</code>: string (regular expression)</li>\n</ul>\n</li>\n<li>result: boolean</li>\n</ul>\n<pre><code class=\"language-js\">matches(&quot;foobar&quot;, &quot;^fo*bar&quot;);\n// true\n</code></pre>\n"
  }, {
    name: "replace()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>input</code>: string</li>\n<li><code>pattern</code>: string (regular expression)</li>\n<li><code>replacement</code>: string (e.g. <code>$1</code> returns the first match group)</li>\n<li>(optional) <code>flags</code>: string (&quot;s&quot;, &quot;m&quot;, &quot;i&quot;, &quot;x&quot;)</li>\n</ul>\n</li>\n<li>result: string</li>\n</ul>\n<pre><code class=\"language-js\">replace(&quot;abcd&quot;, &quot;(ab)|(a)&quot;, &quot;[1=$1][2=$2]&quot;);\n// &quot;[1=ab][2=]cd&quot;\n\nreplace(&quot;0123456789&quot;, &quot;(d{3})(d{3})(d{4})&quot;, &quot;($1) $2-$3&quot;);\n// &quot;(012) 345-6789&quot;\n</code></pre>\n"
  }, {
    name: "split()",
    description: "<ul>\n<li>parameters:<ul>\n<li><code>string</code>: string</li>\n<li><code>delimiter</code>: string (regular expression)</li>\n</ul>\n</li>\n<li>result: list of strings</li>\n</ul>\n<pre><code class=\"language-js\">split(&quot;John Doe&quot;, &quot;s&quot;);\n// [&quot;John&quot;, &quot;Doe&quot;]\n\nsplit(&quot;a;b;c;;&quot;, &quot;;&quot;);\n// [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;&quot;, &quot;&quot;]\n</code></pre>\n"
  }, {
    name: "extract()",
    description: "<p>Returns all matches of the pattern in the given string. Returns an empty list if the pattern doesn&#39;t\nmatch.</p>\n<ul>\n<li>parameters:<ul>\n<li><code>string</code>: string</li>\n<li><code>pattern</code>: string (regular expression)</li>\n</ul>\n</li>\n<li>result: list of strings</li>\n</ul>\n<pre><code class=\"language-js\">extract(&quot;references are 1234, 1256, 1378&quot;, &quot;12[0-9]*&quot;);\n// [&quot;1234&quot;,&quot;1256&quot;]\n</code></pre>\n"
  }, {
    name: "now()",
    description: "<p>Returns the current date and time including the timezone.</p>\n<ul>\n<li>parameters: no</li>\n<li>result: date-time with timezone</li>\n</ul>\n<pre><code class=\"language-js\">now();\n// date and time(&quot;2020-07-31T14:27:30@Europe/Berlin&quot;)\n</code></pre>\n"
  }, {
    name: "today()",
    description: "<p>Returns the current date.</p>\n<ul>\n<li>parameters: no</li>\n<li>result: date</li>\n</ul>\n<pre><code class=\"language-js\">today();\n// date(&quot;2020-07-31&quot;)\n</code></pre>\n"
  }, {
    name: "day of week()",
    description: "<p>Returns the day of the week according to the Gregorian calendar. Note that it always returns the English name of the day.</p>\n<ul>\n<li>parameters:<ul>\n<li><code>date</code>: date/date-time</li>\n</ul>\n</li>\n<li>result: string</li>\n</ul>\n<pre><code class=\"language-js\">day of week(date(&quot;2019-09-17&quot;))\n// &quot;Tuesday&quot;\n</code></pre>\n"
  }, {
    name: "day of year()",
    description: "<p>Returns the Gregorian number of the day within the year.</p>\n<ul>\n<li>parameters:<ul>\n<li><code>date</code>: date/date-time</li>\n</ul>\n</li>\n<li>result: number</li>\n</ul>\n<pre><code class=\"language-js\">day of year(date(&quot;2019-09-17&quot;))\n// 260\n</code></pre>\n"
  }, {
    name: "week of year()",
    description: "<p>Returns the Gregorian number of the week within the year, according to ISO 8601.</p>\n<ul>\n<li>parameters:<ul>\n<li><code>date</code>: date/date-time</li>\n</ul>\n</li>\n<li>result: number</li>\n</ul>\n<pre><code class=\"language-js\">week of year(date(&quot;2019-09-17&quot;))\n// 38\n</code></pre>\n"
  }, {
    name: "month of year()",
    description: "<p>Returns the month of the week according to the Gregorian calendar. Note that it always returns the English name of the month.</p>\n<ul>\n<li>parameters:<ul>\n<li><code>date</code>: date/date-time</li>\n</ul>\n</li>\n<li>result: string</li>\n</ul>\n<pre><code class=\"language-js\">month of year(date(&quot;2019-09-17&quot;))\n// &quot;September&quot;\n</code></pre>\n"
  }, {
    name: "abs()",
    description: "<p>Returns the absolute value of a given duration.</p>\n<ul>\n<li>parameters:<ul>\n<li><code>n</code>: days-time-duration/years-months-duration</li>\n</ul>\n</li>\n<li>result: duration</li>\n</ul>\n<pre><code class=\"language-js\">abs(duration(&quot;-PT5H&quot;));\n// &quot;duration(&quot;PT5H&quot;)&quot;\n\nabs(duration(&quot;PT5H&quot;));\n// &quot;duration(&quot;PT5H&quot;)&quot;\n\nabs(duration(&quot;-P2M&quot;));\n// duration(&quot;P2M&quot;)\n</code></pre>\n"
  }];
  const options = tags.map(tag => snippetCompletion(tag.name.replace('()', '(#{1})'), {
    label: tag.name,
    type: 'function',
    info: () => {
      const html = domify$1(tag.description);
      return html;
    }
  }));

  var builtins = context => {
    let nodeBefore = syntaxTree(context.state).resolve(context.pos, -1); // For the special case of empty nodes, we need to check the current node
    // as well. The previous node could be part of another token, e.g.
    // when typing functions "abs(".

    let nextNode = nodeBefore.nextSibling;
    const isInEmptyNode = isNodeEmpty(nodeBefore) || nextNode && nextNode.from === context.pos && isNodeEmpty(nextNode);

    if (isInEmptyNode) {
      return context.explicit ? {
        from: context.pos,
        options: options
      } : null;
    } // Don't auto-complete on path expressions/context keys/...


    if (nodeBefore.parent && nodeBefore.parent.name !== 'VariableName' || isPathExpression(nodeBefore)) {
      return null;
    }

    return {
      from: nodeBefore.from,
      options: options
    };
  };

  var variables = variables => context => {
    const options = variables.map(v => ({
      label: v.name,
      type: 'variable',
      info: v.info,
      detail: v.detail
    })); // In most cases, use what is typed before the cursor

    let nodeBefore = syntaxTree(context.state).resolve(context.pos, -1); // For the special case of empty nodes, we need to check the current node
    // as well. The previous node could be part of another token, e.g.
    // when typing functions "abs(".

    let nextNode = nodeBefore.nextSibling;
    const isInEmptyNode = isNodeEmpty(nodeBefore) || nextNode && nextNode.from === context.pos && isNodeEmpty(nextNode);

    if (isInEmptyNode) {
      return context.explicit ? {
        from: context.pos,
        options: options
      } : null;
    }

    const result = {
      from: nodeBefore.from,
      options: options
    }; // Only auto-complete variables

    if (nodeBefore.parent && nodeBefore.parent.name !== 'VariableName' || isPathExpression(nodeBefore)) {
      return null;
    }

    return result;
  };

  function autocompletion(context) {
    return [autocompletion$1({
      override: [variables(context), builtins, completeFromList(snippets)]
    })];
  }

  function language() {
    return new LanguageSupport(feelLanguage, []);
  }

  const FeelLinter = function (editorView) {
    const messages = []; // don't lint if the Editor is empty

    if (editorView.state.doc.length === 0) {
      return messages;
    }

    const tree = syntaxTree(editorView.state);
    tree.iterate({
      enter: node => {
        if (node.type.isError) {
          const error = node.toString();
          /* The error has the pattern [⚠ || ⚠(NodeType)]. The regex extracts the node type from inside the brackets */

          const match = /\((.*?)\)/.exec(error);
          const nodeType = match && match[1];
          let message;

          if (nodeType) {
            message = 'unexpected ' + nodeType;
          } else {
            message = 'expression expected';
          }

          messages.push({
            from: node.from,
            to: node.to,
            severity: 'error',
            message: message,
            source: 'syntaxError'
          });
        }
      }
    });
    return messages;
  };

  var syntaxLinter = linter$1(FeelLinter);
  var linter = [syntaxLinter];
  const baseTheme = EditorView.theme({
    '& .cm-content': {
      padding: '0px'
    },
    '& .cm-line': {
      padding: '0px'
    },
    '&.cm-editor.cm-focused': {
      outline: 'none'
    },
    '& .cm-completionInfo ul': {
      margin: 0,
      paddingLeft: '15px'
    },
    '& .cm-completionInfo pre': {
      marginBottom: 0,
      whiteSpace: 'pre-wrap'
    },
    '& .cm-completionInfo p': {
      marginTop: 0
    },
    '& .cm-completionInfo p:not(:last-of-type)': {
      marginBottom: 0
    }
  });
  const highlightTheme = EditorView.baseTheme({
    '& .variableName': {
      color: '#10f'
    },
    '& .number': {
      color: '#164'
    },
    '& .string': {
      color: '#a11'
    },
    '& .bool': {
      color: '#219'
    },
    '& .function': {
      color: '#aa3731',
      fontWeight: 'bold'
    },
    '& .control': {
      color: '#708'
    }
  });
  const syntaxClasses = syntaxHighlighting(HighlightStyle.define([{
    tag: tags$1.variableName,
    class: 'variableName'
  }, {
    tag: tags$1.name,
    class: 'variableName'
  }, {
    tag: tags$1.number,
    class: 'number'
  }, {
    tag: tags$1.string,
    class: 'string'
  }, {
    tag: tags$1.bool,
    class: 'bool'
  }, {
    tag: tags$1.function(tags$1.variableName),
    class: 'function'
  }, {
    tag: tags$1.function(tags$1.special(tags$1.variableName)),
    class: 'function'
  }, {
    tag: tags$1.controlKeyword,
    class: 'control'
  }, {
    tag: tags$1.operatorKeyword,
    class: 'control'
  }]));
  var theme = [baseTheme, highlightTheme, syntaxClasses];
  /**
   * Creates a FEEL editor in the supplied container
   *
   * @param {Object} config
   * @param {DOMNode} config.container
   * @param {Function} [config.onChange]
   * @param {Function} [config.onKeyDown]
   * @param {Function} [config.onLint]
   * @param {Boolean} [config.readOnly]
   * @param {String} [config.value]
   * @param {Array} [config.variables]
   *
   * @returns {Object} editor
   */

  function FeelEditor({
    container,
    onChange = () => {},
    onKeyDown = () => {},
    onLint = () => {},
    readOnly = false,
    value = '',
    variables = []
  }) {
    const changeHandler = EditorView.updateListener.of(update => {
      if (update.docChanged) {
        onChange(update.state.doc.toString());
      }
    });
    const lintHandler = EditorView.updateListener.of(update => {
      const diagnosticEffects = update.transactions.flatMap(t => t.effects).filter(effect => effect.is(setDiagnosticsEffect));

      if (!diagnosticEffects.length) {
        return;
      }

      const messages = diagnosticEffects.flatMap(effect => effect.value);
      onLint(messages);
    });
    const keyHandler = EditorView.domEventHandlers({
      keydown: onKeyDown
    });
    const extensions = [keymap.of([...defaultKeymap]), changeHandler, keyHandler, language(), autocompletion(variables), theme, linter, indentOnInput(), bracketMatching(), closeBrackets(), lintHandler];

    if (readOnly) {
      extensions.push(EditorView.editable.of(false));
    }

    this._cmEditor = new EditorView({
      state: EditorState.create({
        doc: value,
        extensions: extensions
      }),
      parent: container
    });
    return this;
  }
  /**
   * Replaces the content of the Editor
   *
   * @param {String} value
   */


  FeelEditor.prototype.setValue = function (value) {
    this._cmEditor.dispatch({
      changes: {
        from: 0,
        to: this._cmEditor.state.doc.length,
        insert: value
      }
    });
  };
  /**
   * Sets the focus in the editor.
   */


  FeelEditor.prototype.focus = function (position) {
    const cmEditor = this._cmEditor;
    cmEditor.focus();

    if (typeof position === 'number') {
      const end = cmEditor.state.doc.length;
      cmEditor.dispatch({
        selection: {
          anchor: position <= end ? position : end
        }
      });
    }
  };
  /**
   * Returns the current selection ranges. If no text is selected, a single
   * range with the start and end index at the cursor position will be returned.
   *
   * @returns {Object} selection
   * @returns {Array} selection.ranges
   */


  FeelEditor.prototype.getSelection = function () {
    return this._cmEditor.state.selection;
  };

  var ArrowIcon = function ArrowIcon(props) {
    return o$1("svg", { ...props,
      children: o$1("path", {
        fillRule: "evenodd",
        d: "m11.657 8-4.95 4.95a1 1 0 0 1-1.414-1.414L8.828 8 5.293 4.464A1 1 0 1 1 6.707 3.05L11.657 8Z"
      })
    });
  };

  ArrowIcon.defaultProps = {
    xmlns: "http://www.w3.org/2000/svg",
    width: "16",
    height: "16"
  };

  var CreateIcon = function CreateIcon(props) {
    return o$1("svg", { ...props,
      children: o$1("path", {
        fillRule: "evenodd",
        d: "M9 13V9h4a1 1 0 0 0 0-2H9V3a1 1 0 1 0-2 0v4H3a1 1 0 1 0 0 2h4v4a1 1 0 0 0 2 0Z"
      })
    });
  };

  CreateIcon.defaultProps = {
    xmlns: "http://www.w3.org/2000/svg",
    width: "16",
    height: "16"
  };

  var DeleteIcon = function DeleteIcon(props) {
    return o$1("svg", { ...props,
      children: o$1("path", {
        fillRule: "evenodd",
        d: "M12 6v7c0 1.1-.4 1.55-1.5 1.55h-5C4.4 14.55 4 14.1 4 13V6h8Zm-1.5 1.5h-5v4.3c0 .66.5 1.2 1.111 1.2H9.39c.611 0 1.111-.54 1.111-1.2V7.5ZM13 3h-2l-1-1H6L5 3H3v1.5h10V3Z"
      })
    });
  };

  DeleteIcon.defaultProps = {
    xmlns: "http://www.w3.org/2000/svg",
    width: "16",
    height: "16"
  };

  var ExternalLinkIcon = function ExternalLinkIcon(props) {
    return o$1("svg", { ...props,
      children: o$1("path", {
        fillRule: "evenodd",
        clipRule: "evenodd",
        d: "M12.637 12.637v-4.72h1.362v4.721c0 .36-.137.676-.411.95-.275.275-.591.412-.95.412H3.362c-.38 0-.703-.132-.967-.396A1.315 1.315 0 0 1 2 12.638V3.362c0-.38.132-.703.396-.967S2.982 2 3.363 2h4.553v1.363H3.363v9.274h9.274ZM14 2H9.28l-.001 1.362h2.408L5.065 9.984l.95.95 6.622-6.622v2.409H14V2Z",
        fill: "#818798"
      })
    });
  };

  ExternalLinkIcon.defaultProps = {
    width: "16",
    height: "16",
    fill: "none",
    xmlns: "http://www.w3.org/2000/svg"
  };

  var FeelRequiredIcon = function FeelRequiredIcon(props) {
    return o$1("svg", { ...props,
      children: [o$1("path", {
        d: "M5.8 7.06V5.95h4.307v1.11H5.8Zm0 3.071v-1.11h4.307v1.11H5.8Z",
        fill: "currentColor"
      }), o$1("path", {
        fillRule: "evenodd",
        clipRule: "evenodd",
        d: "M8 3.268A4.732 4.732 0 1 0 12.732 8H14a6 6 0 1 1-6-6v1.268Z",
        fill: "currentColor"
      }), o$1("path", {
        d: "m11.28 6.072-.832-.56 1.016-1.224L10 3.848l.312-.912 1.392.584L11.632 2h1.032l-.072 1.52 1.392-.584.312.912-1.464.44 1.008 1.224-.832.552-.864-1.296-.864 1.304Z",
        fill: "currentColor"
      })]
    });
  };

  FeelRequiredIcon.defaultProps = {
    viewBox: "0 0 16 16",
    fill: "none",
    xmlns: "http://www.w3.org/2000/svg"
  };

  var FeelOptionalIcon = function FeelOptionalIcon(props) {
    return o$1("svg", { ...props,
      children: [o$1("path", {
        d: "M5.845 7.04V5.93h4.307v1.11H5.845Zm0 3.07V9h4.307v1.11H5.845Z",
        fill: "currentColor"
      }), o$1("path", {
        fillRule: "evenodd",
        clipRule: "evenodd",
        d: "M3.286 8a4.714 4.714 0 1 0 9.428 0 4.714 4.714 0 0 0-9.428 0ZM8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2Z",
        fill: "currentColor"
      })]
    });
  };

  FeelOptionalIcon.defaultProps = {
    viewBox: "0 0 16 16",
    fill: "none",
    xmlns: "http://www.w3.org/2000/svg"
  };

  function Header$1(props) {
    const {
      element,
      headerProvider
    } = props;
    const {
      getElementIcon,
      getDocumentationRef,
      getElementLabel,
      getTypeLabel
    } = headerProvider;
    const label = getElementLabel(element);
    const type = getTypeLabel(element);
    const documentationRef = getDocumentationRef && getDocumentationRef(element);
    const ElementIcon = getElementIcon(element);
    return o$1("div", {
      class: "bio-properties-panel-header",
      children: [o$1("div", {
        class: "bio-properties-panel-header-icon",
        children: ElementIcon && o$1(ElementIcon, {
          width: "32",
          height: "32",
          viewBox: "0 0 32 32"
        })
      }), o$1("div", {
        class: "bio-properties-panel-header-labels",
        children: [o$1("div", {
          title: type,
          class: "bio-properties-panel-header-type",
          children: type
        }), label ? o$1("div", {
          title: label,
          class: "bio-properties-panel-header-label",
          children: label
        }) : null]
      }), o$1("div", {
        class: "bio-properties-panel-header-actions",
        children: documentationRef ? o$1("a", {
          rel: "noopener",
          class: "bio-properties-panel-header-link",
          href: documentationRef,
          title: "Open documentation",
          target: "_blank",
          children: o$1(ExternalLinkIcon, {})
        }) : null
      })]
    });
  }

  const DescriptionContext = q$1({
    description: {},
    getDescriptionForId: () => {}
  });
  const ErrorsContext = q$1({
    errors: {}
  });
  /**
   * @typedef {Function} <propertiesPanel.showEntry> callback
   *
   * @example
   *
   * useEvent('propertiesPanel.showEntry', ({ focus = false, ...rest }) => {
   *   // ...
   * });
   *
   * @param {Object} context
   * @param {boolean} [context.focus]
   *
   * @returns void
   */

  const EventContext = q$1({
    eventBus: null
  });
  const LayoutContext = q$1({
    layout: {},
    setLayout: () => {},
    getLayoutForKey: () => {},
    setLayoutForKey: () => {}
  });
  /**
   * Accesses the global DescriptionContext and returns a description for a given id and element.
   *
   * @example
   * ```jsx
   * function TextField(props) {
   *   const description = useDescriptionContext('input1', element);
   * }
   * ```
   *
   * @param {string} id
   * @param {object} element
   *
   * @returns {string}
   */

  function useDescriptionContext(id, element) {
    const {
      getDescriptionForId
    } = F$1(DescriptionContext);
    return getDescriptionForId(id, element);
  }

  function useError(id) {
    const {
      errors
    } = F$1(ErrorsContext);
    return errors[id];
  }
  /**
   * Subscribe to an event immediately. Update subscription after inputs changed.
   *
   * @param {string} event
   * @param {Function} callback
   */


  function useEvent(event, callback, eventBus) {
    const eventContext = F$1(EventContext);

    if (!eventBus) {
      ({
        eventBus
      } = eventContext);
    }

    const didMount = s(false); // (1) subscribe immediately

    if (eventBus && !didMount.current) {
      eventBus.on(event, callback);
    } // (2) update subscription after inputs changed


    y(() => {
      if (eventBus && didMount.current) {
        eventBus.on(event, callback);
      }

      didMount.current = true;
      return () => {
        if (eventBus) {
          eventBus.off(event, callback);
        }
      };
    }, [callback, event, eventBus]);
  }

  const KEY_LENGTH = 6;
  /**
   * Create a persistent key factory for plain objects without id.
   *
   * @example
   * ```jsx
   * function List({ objects }) {
   *   const getKey = useKeyFactory();
   *   return (<ol>{
   *     objects.map(obj => {
   *       const key = getKey(obj);
   *       return <li key={key}>obj.name</li>
   *     })
   *   }</ol>);
   * }
   * ```
   *
   * @param {any[]} dependencies
   * @returns {(element: object) => string}
   */

  function useKeyFactory(dependencies = []) {
    const map = d(() => new Map(), dependencies);

    const getKey = el => {
      let key = map.get(el);

      if (!key) {
        key = Math.random().toString().slice(-KEY_LENGTH);
        map.set(el, key);
      }

      return key;
    };

    return getKey;
  }
  /**
   * Creates a state that persists in the global LayoutContext.
   *
   * @example
   * ```jsx
   * function Group(props) {
   *   const [ open, setOpen ] = useLayoutState([ 'groups', 'foo', 'open' ], false);
   * }
   * ```
   *
   * @param {(string|number)[]} path
   * @param {any} [defaultValue]
   *
   * @returns {[ any, Function ]}
   */


  function useLayoutState(path, defaultValue) {
    const {
      getLayoutForKey,
      setLayoutForKey
    } = F$1(LayoutContext);
    const layoutForKey = getLayoutForKey(path, defaultValue);
    const [value, set] = l$1(layoutForKey);

    const setState = newValue => {
      // (1) set component state
      set(newValue); // (2) set context

      setLayoutForKey(path, newValue);
    };

    return [value, setState];
  }
  /**
   * @pinussilvestrus: we need to introduce our own hook to persist the previous
   * state on updates.
   *
   * cf. https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state
   */


  function usePrevious(value) {
    const ref = s();
    y(() => {
      ref.current = value;
    });
    return ref.current;
  }
  /**
   * Subscribe to `propertiesPanel.showEntry`.
   *
   * @param {string} id
   *
   * @returns {import('preact').Ref}
   */


  function useShowEntryEvent(id) {
    const {
      onShow
    } = F$1(LayoutContext);
    const ref = s();
    const focus = s(false);
    const onShowEntry = A$1(event => {
      if (event.id === id) {
        onShow();

        if (!focus.current) {
          focus.current = true;
        }
      }
    }, [id]);
    y(() => {
      if (focus.current && ref.current) {
        if (isFunction(ref.current.focus)) {
          ref.current.focus();
        }

        if (isFunction(ref.current.select)) {
          ref.current.select();
        }

        focus.current = false;
      }
    });
    useEvent('propertiesPanel.showEntry', onShowEntry);
    return ref;
  }
  /**
   * @callback setSticky
   * @param {boolean} value
   */

  /**
   * Use IntersectionObserver to identify when DOM element is in sticky mode.
   * If sticky is observered setSticky(true) will be called.
   * If sticky mode is left, setSticky(false) will be called.
   *
   *
   * @param {Object} ref
   * @param {string} scrollContainerSelector
   * @param {setSticky} setSticky
   */


  function useStickyIntersectionObserver(ref, scrollContainerSelector, setSticky) {
    y(() => {
      const Observer = IntersectionObserver; // return early if IntersectionObserver is not available

      if (!Observer) {
        return;
      }

      let observer;

      if (ref.current) {
        const scrollContainer = query(scrollContainerSelector);
        observer = new Observer(entries => {
          entries.forEach(entry => {
            if (entry.intersectionRatio < 1) {
              setSticky(true);
            } else if (entry.intersectionRatio === 1) {
              setSticky(false);
            }
          });
        }, {
          root: scrollContainer,
          rootMargin: '0px 0px 999999% 0px',
          // Use bottom margin to avoid stickyness when scrolling out to bottom
          threshold: [1]
        });
        observer.observe(ref.current);
      } // Unobserve if unmounted


      return () => {
        if (ref.current && observer) {
          observer.unobserve(ref.current);
        }
      };
    }, [ref, scrollContainerSelector, setSticky]);
  }
  /**
   * Creates a static function reference with changing body.
   * This is necessary when external libraries require a callback function
   * that has references to state variables.
   *
   * Usage:
   * const callback = useStaticCallback((val) => {val === currentState});
   *
   * The `callback` reference is static and can be safely used in external
   * libraries or as a prop that does not cause rerendering of children.
   *
   * @param {Function} callback function with changing reference
   * @returns {Function} static function reference
   */


  function useStaticCallback(callback) {
    const callbackRef = s(callback);
    callbackRef.current = callback;
    return A$1((...args) => callbackRef.current(...args), []);
  }

  function Group(props) {
    const {
      element,
      entries = [],
      id,
      label,
      shouldOpen = false
    } = props;
    const groupRef = s(null);
    const [open, setOpen] = useLayoutState(['groups', id, 'open'], shouldOpen);
    const onShow = A$1(() => setOpen(true), [setOpen]);

    const toggleOpen = () => setOpen(!open);

    const [edited, setEdited] = l$1(false);
    const [sticky, setSticky] = l$1(false); // set edited state depending on all entries

    y(() => {
      const hasOneEditedEntry = entries.find(entry => {
        const {
          id,
          isEdited
        } = entry;
        const entryNode = query(`[data-entry-id="${id}"]`);

        if (!isFunction(isEdited) || !entryNode) {
          return false;
        }

        const inputNode = query('.bio-properties-panel-input', entryNode);
        return isEdited(inputNode);
      });
      setEdited(hasOneEditedEntry);
    }, [entries]); // set css class when group is sticky to top

    useStickyIntersectionObserver(groupRef, 'div.bio-properties-panel-scroll-container', setSticky);
    const propertiesPanelContext = { ...F$1(LayoutContext),
      onShow
    };
    return o$1("div", {
      class: "bio-properties-panel-group",
      "data-group-id": 'group-' + id,
      ref: groupRef,
      children: [o$1("div", {
        class: classnames('bio-properties-panel-group-header', edited ? '' : 'empty', open ? 'open' : '', sticky && open ? 'sticky' : ''),
        onClick: toggleOpen,
        children: [o$1("div", {
          title: label,
          class: "bio-properties-panel-group-header-title",
          children: label
        }), o$1("div", {
          class: "bio-properties-panel-group-header-buttons",
          children: [edited && o$1(DataMarker, {}), o$1("button", {
            title: "Toggle section",
            class: "bio-properties-panel-group-header-button bio-properties-panel-arrow",
            children: o$1(ArrowIcon, {
              class: open ? 'bio-properties-panel-arrow-down' : 'bio-properties-panel-arrow-right'
            })
          })]
        })]
      }), o$1("div", {
        class: classnames('bio-properties-panel-group-entries', open ? 'open' : ''),
        children: o$1(LayoutContext.Provider, {
          value: propertiesPanelContext,
          children: entries.map(entry => {
            const {
              component: Component,
              id
            } = entry;
            return a$2(Component, { ...entry,
              element: element,
              key: id
            });
          })
        })
      })]
    });
  }

  function DataMarker() {
    return o$1("div", {
      title: "Section contains data",
      class: "bio-properties-panel-dot"
    });
  }
  /**
   * @typedef { {
   *  text: (element: object) => string,
   *  icon?: (element: Object) => import('preact').Component
   * } } PlaceholderDefinition
   *
   * @param { PlaceholderDefinition } props
   */


  function Placeholder(props) {
    const {
      text,
      icon: Icon
    } = props;
    return o$1("div", {
      class: "bio-properties-panel open",
      children: o$1("section", {
        class: "bio-properties-panel-placeholder",
        children: [Icon && o$1(Icon, {
          class: "bio-properties-panel-placeholder-icon"
        }), o$1("p", {
          class: "bio-properties-panel-placeholder-text",
          children: text
        })]
      })
    });
  }

  const DEFAULT_LAYOUT = {
    open: true
  };
  const DEFAULT_DESCRIPTION = {};
  /**
   * @typedef { {
   *    component: import('preact').Component,
   *    id: String,
   *    isEdited?: Function
   * } } EntryDefinition
   *
   * @typedef { {
   *    autoFocusEntry: String,
   *    autoOpen?: Boolean,
   *    entries: Array<EntryDefinition>,
   *    id: String,
   *    label: String,
   *    remove: (event: MouseEvent) => void
   * } } ListItemDefinition
   *
   * @typedef { {
   *    add: (event: MouseEvent) => void,
   *    component: import('preact').Component,
   *    element: Object,
   *    id: String,
   *    items: Array<ListItemDefinition>,
   *    label: String,
   *    shouldSort?: Boolean,
   *    shouldOpen?: Boolean
   * } } ListGroupDefinition
   *
   * @typedef { {
   *    component?: import('preact').Component,
   *    entries: Array<EntryDefinition>,
   *    id: String,
   *    label: String,
   *    shouldOpen?: Boolean
   * } } GroupDefinition
   *
   *  @typedef { {
   *    [id: String]: GetDescriptionFunction
   * } } DescriptionConfig
   *
   * @callback { {
   * @param {string} id
   * @param {Object} element
   * @returns {string}
   * } } GetDescriptionFunction
   *
   * @typedef { {
   *  getEmpty: (element: object) => import('./components/Placeholder').PlaceholderDefinition,
   *  getMultiple: (element: Object) => import('./components/Placeholder').PlaceholderDefinition
   * } } PlaceholderProvider
   *
   */

  /**
   * A basic properties panel component. Describes *how* content will be rendered, accepts
   * data from implementor to describe *what* will be rendered.
   *
   * @param {Object} props
   * @param {Object|Array} props.element
   * @param {import('./components/Header').HeaderProvider} props.headerProvider
   * @param {PlaceholderProvider} [props.placeholderProvider]
   * @param {Array<GroupDefinition|ListGroupDefinition>} props.groups
   * @param {Object} [props.layoutConfig]
   * @param {Function} [props.layoutChanged]
   * @param {DescriptionConfig} [props.descriptionConfig]
   * @param {Function} [props.descriptionLoaded]
   * @param {Object} [props.eventBus]
   */

  function PropertiesPanel(props) {
    const {
      element,
      headerProvider,
      placeholderProvider,
      groups,
      layoutConfig = {},
      layoutChanged,
      descriptionConfig = {},
      descriptionLoaded,
      eventBus
    } = props; // set-up layout context

    const [layout, setLayout] = l$1(createLayout(layoutConfig));
    y(() => {
      if (typeof layoutChanged === 'function') {
        layoutChanged(layout);
      }
    }, [layout, layoutChanged]);

    const getLayoutForKey = (key, defaultValue) => {
      return get(layout, key, defaultValue);
    };

    const setLayoutForKey = (key, config) => {
      const newLayout = assign({}, layout);
      set(newLayout, key, config);
      setLayout(newLayout);
    };

    const layoutContext = {
      layout,
      setLayout,
      getLayoutForKey,
      setLayoutForKey
    }; // set-up description context

    const description = createDescriptionContext(descriptionConfig);

    if (typeof descriptionLoaded === 'function') {
      descriptionLoaded(description);
    }

    const getDescriptionForId = (id, element) => {
      return description[id] && description[id](element);
    };

    const descriptionContext = {
      description,
      getDescriptionForId
    };
    const [errors, setErrors] = l$1({});

    const onSetErrors = ({
      errors
    }) => setErrors(errors);

    useEvent('propertiesPanel.setErrors', onSetErrors, eventBus);
    const errorsContext = {
      errors
    };
    const eventContext = {
      eventBus
    };
    const propertiesPanelContext = {
      element
    }; // empty state

    if (placeholderProvider && !element) {
      return o$1(Placeholder, { ...placeholderProvider.getEmpty()
      });
    } // multiple state


    if (placeholderProvider && isArray(element)) {
      return o$1(Placeholder, { ...placeholderProvider.getMultiple()
      });
    }

    return o$1(LayoutContext.Provider, {
      value: propertiesPanelContext,
      children: o$1(ErrorsContext.Provider, {
        value: errorsContext,
        children: o$1(DescriptionContext.Provider, {
          value: descriptionContext,
          children: o$1(LayoutContext.Provider, {
            value: layoutContext,
            children: o$1(EventContext.Provider, {
              value: eventContext,
              children: o$1("div", {
                class: classnames('bio-properties-panel', layout.open ? 'open' : ''),
                children: [o$1(Header$1, {
                  element: element,
                  headerProvider: headerProvider
                }), o$1("div", {
                  class: "bio-properties-panel-scroll-container",
                  children: groups.map(group => {
                    const {
                      component: Component = Group,
                      id
                    } = group;
                    return a$2(Component, { ...group,
                      key: id,
                      element: element
                    });
                  })
                })]
              })
            })
          })
        })
      })
    });
  } // helpers //////////////////


  function createLayout(overrides) {
    return { ...DEFAULT_LAYOUT,
      ...overrides
    };
  }

  function createDescriptionContext(overrides) {
    return { ...DEFAULT_DESCRIPTION,
      ...overrides
    };
  }

  function DropdownButton(props) {
    const {
      class: className,
      children,
      menuItems = []
    } = props;
    const dropdownRef = s(null);
    const menuRef = s(null);
    const [open, setOpen] = l$1(false);

    const close = () => setOpen(false);

    function onDropdownToggle(event) {
      if (menuRef.current && menuRef.current.contains(event.target)) {
        return;
      }

      event.stopPropagation();
      setOpen(open => !open);
    }

    function onActionClick(event, action) {
      event.stopPropagation();
      close();
      action();
    }

    useGlobalClick([dropdownRef.current], () => close());
    return o$1("div", {
      class: classnames('bio-properties-panel-dropdown-button', {
        open
      }, className),
      onClick: onDropdownToggle,
      ref: dropdownRef,
      children: [children, o$1("div", {
        class: "bio-properties-panel-dropdown-button__menu",
        ref: menuRef,
        children: menuItems.map((item, index) => o$1(MenuItem, {
          onClick: onActionClick,
          item: item
        }, index))
      })]
    });
  }

  function MenuItem({
    item,
    onClick
  }) {
    if (item.separator) {
      return o$1("div", {
        class: "bio-properties-panel-dropdown-button__menu-item bio-properties-panel-dropdown-button__menu-item--separator"
      });
    }

    if (item.action) {
      return o$1("button", {
        class: "bio-properties-panel-dropdown-button__menu-item bio-properties-panel-dropdown-button__menu-item--actionable",
        onClick: event => onClick(event, item.action),
        children: item.entry
      });
    }

    return o$1("div", {
      class: "bio-properties-panel-dropdown-button__menu-item",
      children: item.entry
    });
  }
  /**
   *
   * @param {Array<null | Element>} ignoredElements
   * @param {Function} callback
   */


  function useGlobalClick(ignoredElements, callback) {
    y(() => {
      /**
       * @param {MouseEvent} event
       */
      function listener(event) {
        if (ignoredElements.some(element => element && element.contains(event.target))) {
          return;
        }

        callback();
      }

      document.addEventListener('click', listener, {
        capture: true
      });
      return () => document.removeEventListener('click', listener, {
        capture: true
      });
    }, [...ignoredElements, callback]);
  }

  function HeaderButton(props) {
    const {
      children = null,
      class: classname,
      onClick = () => {},
      ...otherProps
    } = props;
    return o$1("button", { ...otherProps,
      onClick: onClick,
      class: classnames('bio-properties-panel-group-header-button', classname),
      children: children
    });
  }

  function CollapsibleEntry(props) {
    const {
      element,
      entries = [],
      id,
      label,
      open: shouldOpen,
      remove
    } = props;
    const [open, setOpen] = l$1(shouldOpen);

    const toggleOpen = () => setOpen(!open);

    const {
      onShow
    } = F$1(LayoutContext);
    const propertiesPanelContext = { ...F$1(LayoutContext),
      onShow: A$1(() => {
        setOpen(true);

        if (isFunction(onShow)) {
          onShow();
        }
      }, [onShow, setOpen])
    }; // todo(pinussilvestrus): translate once we have a translate mechanism for the core

    const placeholderLabel = '<empty>';
    return o$1("div", {
      "data-entry-id": id,
      class: classnames('bio-properties-panel-collapsible-entry', open ? 'open' : ''),
      children: [o$1("div", {
        class: "bio-properties-panel-collapsible-entry-header",
        onClick: toggleOpen,
        children: [o$1("div", {
          title: label || placeholderLabel,
          class: classnames('bio-properties-panel-collapsible-entry-header-title', !label && 'empty'),
          children: label || placeholderLabel
        }), o$1("button", {
          title: "Toggle list item",
          class: "bio-properties-panel-arrow  bio-properties-panel-collapsible-entry-arrow",
          children: o$1(ArrowIcon, {
            class: open ? 'bio-properties-panel-arrow-down' : 'bio-properties-panel-arrow-right'
          })
        }), remove ? o$1("button", {
          title: "Delete item",
          class: "bio-properties-panel-remove-entry",
          onClick: remove,
          children: o$1(DeleteIcon, {})
        }) : null]
      }), o$1("div", {
        class: classnames('bio-properties-panel-collapsible-entry-entries', open ? 'open' : ''),
        children: o$1(LayoutContext.Provider, {
          value: propertiesPanelContext,
          children: entries.map(entry => {
            const {
              component: Component,
              id
            } = entry;
            return a$2(Component, { ...entry,
              element: element,
              key: id
            });
          })
        })
      })]
    });
  }

  function ListItem$1(props) {
    const {
      autoFocusEntry,
      autoOpen
    } = props; // focus specified entry on auto open

    y(() => {
      if (autoOpen && autoFocusEntry) {
        const entry = query(`[data-entry-id="${autoFocusEntry}"]`);
        const focusableInput = query('.bio-properties-panel-input', entry);

        if (focusableInput) {
          if (isFunction(focusableInput.select)) {
            focusableInput.select();
          } else if (isFunction(focusableInput.focus)) {
            focusableInput.focus();
          }
        }
      }
    }, [autoOpen, autoFocusEntry]);
    return o$1("div", {
      class: "bio-properties-panel-list-item",
      children: o$1(CollapsibleEntry, { ...props,
        open: autoOpen
      })
    });
  }

  const noop$2 = () => {};
  /**
   * @param {import('../PropertiesPanel').ListGroupDefinition} props
   */


  function ListGroup(props) {
    const {
      add,
      element,
      id,
      items,
      label,
      shouldOpen = true,
      shouldSort = true
    } = props;
    const groupRef = s(null);
    const [open, setOpen] = useLayoutState(['groups', id, 'open'], false);
    const [sticky, setSticky] = l$1(false);
    const onShow = A$1(() => setOpen(true), [setOpen]);
    const [ordering, setOrdering] = l$1([]);
    const [newItemAdded, setNewItemAdded] = l$1(false);
    const prevItems = usePrevious(items);
    const prevElement = usePrevious(element);
    const elementChanged = element !== prevElement;
    const shouldHandleEffects = !elementChanged && (shouldSort || shouldOpen); // reset initial ordering when element changes (before first render)

    if (elementChanged) {
      setOrdering(createOrdering(shouldSort ? sortItems(items) : items));
    } // keep ordering in sync to items - and open changes
    // (0) set initial ordering from given items


    y(() => {
      if (!prevItems || !shouldSort) {
        setOrdering(createOrdering(items));
      }
    }, [items, element]); // (1) items were added

    y(() => {
      if (shouldHandleEffects && prevItems && items.length > prevItems.length) {
        let add = [];
        items.forEach(item => {
          if (!ordering.includes(item.id)) {
            add.push(item.id);
          }
        });
        let newOrdering = ordering; // open if not open and configured

        if (!open && shouldOpen) {
          toggleOpen(); // if I opened and I should sort, then sort items

          if (shouldSort) {
            newOrdering = createOrdering(sortItems(items));
          }
        } // add new items on top or bottom depending on sorting behavior


        newOrdering = newOrdering.filter(item => !add.includes(item));

        if (shouldSort) {
          newOrdering.unshift(...add);
        } else {
          newOrdering.push(...add);
        }

        setOrdering(newOrdering);
        setNewItemAdded(true);
      } else {
        setNewItemAdded(false);
      }
    }, [items, open, shouldHandleEffects]); // (2) sort items on open if shouldSort is set

    y(() => {
      if (shouldSort && open && !newItemAdded) {
        setOrdering(createOrdering(sortItems(items)));
      }
    }, [open, shouldSort]); // (3) items were deleted

    y(() => {
      if (shouldHandleEffects && prevItems && items.length < prevItems.length) {
        let keep = [];
        ordering.forEach(o => {
          if (getItem(items, o)) {
            keep.push(o);
          }
        });
        setOrdering(keep);
      }
    }, [items, shouldHandleEffects]); // set css class when group is sticky to top

    useStickyIntersectionObserver(groupRef, 'div.bio-properties-panel-scroll-container', setSticky);

    const toggleOpen = () => setOpen(!open);

    const hasItems = !!items.length;
    const propertiesPanelContext = { ...F$1(LayoutContext),
      onShow
    };
    return o$1("div", {
      class: "bio-properties-panel-group",
      "data-group-id": 'group-' + id,
      ref: groupRef,
      children: [o$1("div", {
        class: classnames('bio-properties-panel-group-header', hasItems ? '' : 'empty', hasItems && open ? 'open' : '', sticky && open ? 'sticky' : ''),
        onClick: hasItems ? toggleOpen : noop$2,
        children: [o$1("div", {
          title: label,
          class: "bio-properties-panel-group-header-title",
          children: label
        }), o$1("div", {
          class: "bio-properties-panel-group-header-buttons",
          children: [add ? o$1("button", {
            title: "Create new list item",
            class: "bio-properties-panel-group-header-button bio-properties-panel-add-entry",
            onClick: add,
            children: [o$1(CreateIcon, {}), !hasItems ? o$1("span", {
              class: "bio-properties-panel-add-entry-label",
              children: "Create"
            }) : null]
          }) : null, hasItems ? o$1("div", {
            title: `List contains ${items.length} item${items.length != 1 ? 's' : ''}`,
            class: "bio-properties-panel-list-badge",
            children: items.length
          }) : null, hasItems ? o$1("button", {
            title: "Toggle section",
            class: "bio-properties-panel-group-header-button bio-properties-panel-arrow",
            children: o$1(ArrowIcon, {
              class: open ? 'bio-properties-panel-arrow-down' : 'bio-properties-panel-arrow-right'
            })
          }) : null]
        })]
      }), o$1("div", {
        class: classnames('bio-properties-panel-list', open && hasItems ? 'open' : ''),
        children: o$1(LayoutContext.Provider, {
          value: propertiesPanelContext,
          children: ordering.map((o, index) => {
            const item = getItem(items, o);

            if (!item) {
              return;
            }

            const {
              id
            } = item; // if item was added, open first or last item based on ordering

            const autoOpen = newItemAdded && (shouldSort ? index === 0 : index === ordering.length - 1);
            return a$2(ListItem$1, { ...item,
              autoOpen: autoOpen,
              element: element,
              index: index,
              key: id
            });
          })
        })
      })]
    });
  } // helpers ////////////////////

  /**
   * Sorts given items alphanumeric by label
   */


  function sortItems(items) {
    return sortBy(items, i => i.label.toLowerCase());
  }

  function getItem(items, id) {
    return find$1(items, i => i.id === id);
  }

  function createOrdering(items) {
    return items.map(i => i.id);
  }

  function Description$2(props) {
    const {
      element,
      forId,
      value
    } = props;
    const contextDescription = useDescriptionContext(forId, element);
    const description = value || contextDescription;

    if (description) {
      return o$1("div", {
        class: "bio-properties-panel-description",
        children: description
      });
    }
  }

  function Checkbox(props) {
    const {
      id,
      label,
      onChange,
      disabled,
      value = false,
      onFocus,
      onBlur
    } = props;
    const [localValue, setLocalValue] = l$1(value);

    const handleChangeCallback = ({
      target
    }) => {
      onChange(target.checked);
    };

    const handleChange = e => {
      handleChangeCallback(e);
      setLocalValue(e.target.value);
    };

    y(() => {
      if (value === localValue) {
        return;
      }

      setLocalValue(value);
    }, [value]);
    const ref = useShowEntryEvent(id);
    return o$1("div", {
      class: "bio-properties-panel-checkbox",
      children: [o$1("input", {
        ref: ref,
        id: prefixId$7(id),
        name: id,
        onFocus: onFocus,
        onBlur: onBlur,
        type: "checkbox",
        class: "bio-properties-panel-input",
        onChange: handleChange,
        checked: localValue,
        disabled: disabled
      }), o$1("label", {
        for: prefixId$7(id),
        class: "bio-properties-panel-label",
        children: label
      })]
    });
  }
  /**
   * @param {Object} props
   * @param {Object} props.element
   * @param {String} props.id
   * @param {String} props.description
   * @param {String} props.label
   * @param {Function} props.getValue
   * @param {Function} props.setValue
   * @param {Function} props.onFocus
   * @param {Function} props.onBlur
   * @param {boolean} [props.disabled]
   */


  function CheckboxEntry(props) {
    const {
      element,
      id,
      description,
      label,
      getValue,
      setValue,
      disabled,
      onFocus,
      onBlur
    } = props;
    const value = getValue(element);
    const error = useError(id);
    return o$1("div", {
      class: "bio-properties-panel-entry bio-properties-panel-checkbox-entry",
      "data-entry-id": id,
      children: [o$1(Checkbox, {
        disabled: disabled,
        id: id,
        label: label,
        onChange: setValue,
        onFocus: onFocus,
        onBlur: onBlur,
        value: value
      }, element), error && o$1("div", {
        class: "bio-properties-panel-error",
        children: error
      }), o$1(Description$2, {
        forId: id,
        element: element,
        value: description
      })]
    });
  }

  function isEdited$7(node) {
    return node && !!node.checked;
  } // helpers /////////////////


  function prefixId$7(id) {
    return `bio-properties-panel-${id}`;
  }

  const useBufferedFocus = function (editor, ref) {
    const [buffer, setBuffer] = l$1(undefined);
    ref.current = d(() => ({
      focus: argument => {
        if (editor) {
          editor.focus(argument);
        } else {
          setBuffer(argument);
        }
      }
    }), [editor]);
    y(() => {
      if (typeof buffer !== 'undefined' && editor) {
        editor.focus(buffer);
        setBuffer(false);
      }
    }, [editor, buffer]);
  };

  const CodeEditor = x((props, ref) => {
    const {
      value,
      onInput,
      onFeelToggle,
      onLint = () => {},
      disabled,
      variables
    } = props;
    const inputRef = s();
    const [editor, setEditor] = l$1();
    const [localValue, setLocalValue] = l$1(value || '');
    useBufferedFocus(editor, ref);
    const handleInput = useStaticCallback(newValue => {
      onInput(newValue);
      setLocalValue(newValue);
    });
    y(() => {
      let editor;
      /* Trigger FEEL toggle when
       *
       * - `backspace` is pressed
       * - AND the cursor is at the beginning of the input
       */

      const onKeyDown = e => {
        if (e.key !== 'Backspace' || !editor) {
          return;
        }

        const selection = editor.getSelection();
        const range = selection.ranges[selection.mainIndex];

        if (range.from === 0 && range.to === 0) {
          onFeelToggle();
        }
      };

      editor = new FeelEditor({
        container: inputRef.current,
        onChange: handleInput,
        onKeyDown: onKeyDown,
        onLint: onLint,
        value: localValue,
        variables: variables
      });
      setEditor(editor);
      return () => {
        onLint([]);
        inputRef.current.innerHTML = '';
        setEditor(null);
      };
    }, [variables]);
    y(() => {
      if (!editor) {
        return;
      }

      if (value === localValue) {
        return;
      }

      editor.setValue(value);
      setLocalValue(value);
    }, [value]);

    const handleClick = () => {
      ref.current.focus();
    };

    return o$1("div", {
      class: classnames('bio-properties-panel-feel-editor-container', disabled ? 'disabled' : null),
      children: o$1("div", {
        name: props.name,
        class: classnames('bio-properties-panel-input', localValue ? 'edited' : null),
        ref: inputRef,
        onClick: handleClick
      })
    });
  });

  function FeelIndicator(props) {
    const {
      active
    } = props;

    if (!active) {
      return null;
    }

    return o$1("span", {
      class: "bio-properties-panel-feel-indicator",
      children: "="
    });
  }

  const noop$1 = () => {};
  /**
   * @param {Object} props
   * @param {Object} props.label
   * @param {String} props.feel
   */


  function FeelIcon(props) {
    const {
      label,
      feel = false,
      active,
      disabled = false,
      onClick = noop$1
    } = props;
    const feelRequiredLabel = ' must be a FEEL expression';
    const feelOptionalLabel = ' can optionally be a FEEL expression';

    const handleClick = e => {
      onClick(e); // when pointer event was created from keyboard, keep focus on button

      if (!e.pointerType) {
        e.stopPropagation();
      }
    };

    return o$1("button", {
      class: classnames('bio-properties-panel-feel-icon', active ? 'active' : null, feel === 'required' ? 'required' : 'optional'),
      onClick: handleClick,
      disabled: feel === 'required' || disabled,
      title: label + (feel === 'required' ? feelRequiredLabel : feelOptionalLabel),
      children: feel === 'required' ? o$1(FeelRequiredIcon, {}) : o$1(FeelOptionalIcon, {})
    });
  }

  const noop = () => {};

  function FeelTextfield(props) {
    const {
      debounce,
      id,
      label,
      onInput,
      onError,
      feel,
      value = '',
      disabled = false,
      variables,
      OptionalComponent = OptionalFeelInput
    } = props;
    const [localValue, _setLocalValue] = l$1(value);
    const editorRef = useShowEntryEvent(id);
    const containerRef = s();
    const feelActive = localValue.startsWith('=') || feel === 'required';
    const feelOnlyValue = localValue.startsWith('=') ? localValue.substring(1) : localValue;
    const [focus, _setFocus] = l$1(undefined);

    const setFocus = (offset = 0) => {
      const hasFocus = containerRef.current.contains(document.activeElement); // Keep caret position if it is already focused, otherwise focus at the end

      const position = hasFocus ? document.activeElement.selectionStart : Infinity;

      _setFocus(position + offset);
    };

    const handleInputCallback = d(() => {
      return debounce(newValue => {
        onInput(newValue);
      });
    }, [onInput, debounce]);

    const setLocalValue = newValue => {
      _setLocalValue(newValue);

      if (!newValue || newValue === '=') {
        handleInputCallback(undefined);
      } else {
        handleInputCallback(newValue);
      }
    };

    const handleFeelToggle = useStaticCallback(() => {
      if (feel === 'required') {
        return;
      }

      if (!feelActive) {
        setLocalValue('=' + localValue);
      } else {
        setLocalValue(feelOnlyValue);
      }
    });

    const handleLocalInput = newValue => {
      if (feelActive) {
        newValue = '=' + newValue;
      }

      if (newValue === localValue) {
        return;
      }

      setLocalValue(newValue);

      if (!feelActive && newValue.startsWith('=')) {
        // focus is behind `=` sign that will be removed
        setFocus(-1);
      }
    };

    const handleLint = useStaticCallback(lint => {
      if (!(lint && lint.length)) {
        onError(undefined);
        return;
      }

      const error = lint[0];
      const message = `${error.source}: ${error.message}`;
      onError(message);
    });
    y(() => {
      if (typeof focus !== 'undefined') {
        editorRef.current.focus(focus);

        _setFocus(undefined);
      }
    }, [focus]);
    y(() => {
      if (value === localValue) {
        return;
      } // External value change removed content => keep FEEL configuration


      if (!value) {
        setLocalValue(feelActive ? '=' : '');
        return;
      }

      setLocalValue(value);
    }, [value]); // copy-paste integration

    y(() => {
      const copyHandler = event => {
        if (!feelActive) {
          return;
        }

        event.clipboardData.setData('application/FEEL', event.clipboardData.getData('text'));
      };

      const pasteHandler = event => {
        if (feelActive) {
          return;
        }

        const data = event.clipboardData.getData('application/FEEL');

        if (data) {
          setTimeout(() => {
            handleFeelToggle();
            setFocus();
          });
        }
      };

      containerRef.current.addEventListener('copy', copyHandler);
      containerRef.current.addEventListener('cut', copyHandler);
      containerRef.current.addEventListener('paste', pasteHandler);
      return () => {
        containerRef.current.removeEventListener('copy', copyHandler);
        containerRef.current.removeEventListener('cut', copyHandler);
        containerRef.current.removeEventListener('paste', pasteHandler);
      };
    }, [containerRef, feelActive, handleFeelToggle, setFocus]);
    return o$1("div", {
      class: "bio-properties-panel-feel-entry",
      children: [o$1("label", {
        for: prefixId$6(id),
        class: "bio-properties-panel-label",
        onClick: () => setFocus(),
        children: [label, o$1(FeelIcon, {
          label: label,
          feel: feel,
          onClick: handleFeelToggle,
          active: feelActive
        })]
      }), o$1("div", {
        class: "bio-properties-panel-feel-container",
        ref: containerRef,
        children: [o$1(FeelIndicator, {
          active: feelActive,
          disabled: feel !== 'optional' || disabled,
          onClick: handleFeelToggle
        }), feelActive ? o$1(CodeEditor, {
          id: prefixId$6(id),
          name: id,
          onInput: handleLocalInput,
          disabled: disabled,
          onFeelToggle: () => {
            handleFeelToggle();
            setFocus(true);
          },
          onLint: handleLint,
          value: feelOnlyValue,
          variables: variables,
          ref: editorRef
        }) : o$1(OptionalComponent, { ...props,
          onInput: handleLocalInput,
          value: localValue,
          ref: editorRef
        })]
      })]
    });
  }

  const OptionalFeelInput = x((props, ref) => {
    const {
      id,
      disabled,
      onInput,
      value,
      onFocus,
      onBlur
    } = props;
    const inputRef = s(); // To be consistent with the FEEL editor, set focus at start of input
    // this ensures clean editing experience when switching with the keyboard

    ref.current = {
      focus: position => {
        const input = inputRef.current;

        if (!input) {
          return;
        }

        input.focus();

        if (typeof position === 'number') {
          if (position > value.length) {
            position = value.length;
          }

          input.setSelectionRange(position, position);
        }
      }
    };
    return o$1("input", {
      id: prefixId$6(id),
      type: "text",
      ref: inputRef,
      name: id,
      spellCheck: "false",
      autoComplete: "off",
      disabled: disabled,
      class: "bio-properties-panel-input",
      onInput: e => onInput(e.target.value),
      onFocus: onFocus,
      onBlur: onBlur,
      value: value || ''
    });
  });
  const OptionalFeelTextArea = x((props, ref) => {
    const {
      id,
      disabled,
      onInput,
      value,
      onFocus,
      onBlur
    } = props;
    const inputRef = s(); // To be consistent with the FEEL editor, set focus at start of input
    // this ensures clean editing experience when switching with the keyboard

    ref.current = {
      focus: () => {
        const input = inputRef.current;

        if (!input) {
          return;
        }

        input.focus();
        input.setSelectionRange(0, 0);
      }
    };
    return o$1("textarea", {
      id: prefixId$6(id),
      type: "text",
      ref: inputRef,
      name: id,
      spellCheck: "false",
      autoComplete: "off",
      disabled: disabled,
      class: "bio-properties-panel-input",
      onInput: e => onInput(e.target.value),
      onFocus: onFocus,
      onBlur: onBlur,
      value: value || ''
    });
  });
  /**
   * @param {Object} props
   * @param {Object} props.element
   * @param {String} props.id
   * @param {String} props.description
   * @param {Boolean} props.debounce
   * @param {Boolean} props.disabled
   * @param {String} props.label
   * @param {Function} props.getValue
   * @param {Function} props.setValue
   * @param {Function} props.validate
   */

  function FeelEntry(props) {
    const {
      element,
      id,
      description,
      debounce,
      disabled,
      feel,
      label,
      getValue,
      setValue,
      validate,
      show = noop,
      example,
      variables,
      onFocus,
      onBlur
    } = props;
    const [cachedInvalidValue, setCachedInvalidValue] = l$1(null);
    const [validationError, setValidationError] = l$1(null);
    const [localError, setLocalError] = l$1(null);
    let value = getValue(element);
    const previousValue = usePrevious(value);
    y(() => {
      if (isFunction(validate)) {
        const newValidationError = validate(value) || null;
        setValidationError(newValidationError);
      }
    }, [value]);
    const onInput = useStaticCallback(newValue => {
      let newValidationError = null;

      if (isFunction(validate)) {
        newValidationError = validate(newValue) || null;
      }

      if (newValidationError) {
        setCachedInvalidValue(newValue);
      } else {
        // don't create multiple commandStack entries for the same value
        if (newValue !== value) {
          setValue(newValue);
        }
      }

      setValidationError(newValidationError);
    });
    const onError = A$1(err => {
      setLocalError(err);
    }, []);

    if (previousValue === value && validationError) {
      value = cachedInvalidValue;
    }

    const temporaryError = useError(id);
    const error = localError || temporaryError || validationError;
    return o$1("div", {
      class: classnames(props.class, 'bio-properties-panel-entry', error ? 'has-error' : ''),
      "data-entry-id": id,
      children: [o$1(FeelTextfield, {
        debounce: debounce,
        disabled: disabled,
        feel: feel,
        id: id,
        label: label,
        onInput: onInput,
        onError: onError,
        onFocus: onFocus,
        onBlur: onBlur,
        example: example,
        show: show,
        value: value,
        variables: variables,
        OptionalComponent: props.OptionalComponent
      }, element), error && o$1("div", {
        class: "bio-properties-panel-error",
        children: error
      }), o$1(Description$2, {
        forId: id,
        element: element,
        value: description
      })]
    });
  }
  /**
   * @param {Object} props
   * @param {Object} props.element
   * @param {String} props.id
   * @param {String} props.description
   * @param {Boolean} props.debounce
   * @param {Boolean} props.disabled
   * @param {String} props.label
   * @param {Function} props.getValue
   * @param {Function} props.setValue
   * @param {Function} props.onFocus
   * @param {Function} props.onBlur
   * @param {Function} props.validate
   */


  function FeelTextArea(props) {
    return o$1(FeelEntry, {
      class: "bio-properties-panel-feel-textarea",
      OptionalComponent: OptionalFeelTextArea,
      ...props
    });
  }

  function isEdited$6(node) {
    return node && (!!node.value || node.classList.contains('edited'));
  } // helpers /////////////////


  function prefixId$6(id) {
    return `bio-properties-panel-${id}`;
  }

  function List(props) {
    const {
      id,
      element,
      items = [],
      component,
      label = '<empty>',
      open: shouldOpen,
      onAdd,
      onRemove,
      autoFocusEntry,
      compareFn,
      ...restProps
    } = props;
    const [open, setOpen] = l$1(!!shouldOpen);
    const hasItems = !!items.length;

    const toggleOpen = () => hasItems && setOpen(!open);

    const opening = !usePrevious(open) && open;
    const elementChanged = usePrevious(element) !== element;
    const shouldReset = opening || elementChanged;
    const sortedItems = useSortedItems(items, compareFn, shouldReset);
    const newItems = useNewItems(items, elementChanged);
    y(() => {
      if (open && !hasItems) {
        setOpen(false);
      }
    }, [open, hasItems]);
    /**
     * @param {MouseEvent} event
     */

    function addItem(event) {
      event.stopPropagation();
      onAdd();

      if (!open) {
        setOpen(true);
      }
    }

    return o$1("div", {
      "data-entry-id": id,
      class: classnames('bio-properties-panel-entry', 'bio-properties-panel-list-entry', hasItems ? '' : 'empty', open ? 'open' : ''),
      children: [o$1("div", {
        class: "bio-properties-panel-list-entry-header",
        onClick: toggleOpen,
        children: [o$1("div", {
          title: label,
          class: classnames('bio-properties-panel-list-entry-header-title', open && 'open'),
          children: label
        }), o$1("div", {
          class: "bio-properties-panel-list-entry-header-buttons",
          children: [o$1("button", {
            title: "Create new list item",
            onClick: addItem,
            class: "bio-properties-panel-add-entry",
            children: [o$1(CreateIcon, {}), !hasItems ? o$1("span", {
              class: "bio-properties-panel-add-entry-label",
              children: "Create"
            }) : null]
          }), hasItems && o$1("div", {
            title: `List contains ${items.length} item${items.length != 1 ? 's' : ''}`,
            class: "bio-properties-panel-list-badge",
            children: items.length
          }), hasItems && o$1("button", {
            title: "Toggle list item",
            class: "bio-properties-panel-arrow",
            children: o$1(ArrowIcon, {
              class: open ? 'bio-properties-panel-arrow-down' : 'bio-properties-panel-arrow-right'
            })
          })]
        })]
      }), hasItems && o$1(ItemsList, { ...restProps,
        autoFocusEntry: autoFocusEntry,
        component: component,
        element: element,
        id: id,
        items: sortedItems,
        newItems: newItems,
        onRemove: onRemove,
        open: open
      })]
    });
  }

  function ItemsList(props) {
    const {
      autoFocusEntry,
      component: Component,
      element,
      id,
      items,
      newItems,
      onRemove,
      open,
      ...restProps
    } = props;
    const getKey = useKeyFactory();
    const newItem = newItems[0];
    y(() => {
      if (newItem && autoFocusEntry) {
        // (0) select the parent entry (containing all list items)
        const entry = query(`[data-entry-id="${id}"]`); // (1) select the first input or a custom element to be focussed

        const selector = typeof autoFocusEntry === 'boolean' ? '.bio-properties-panel-input' : autoFocusEntry;
        const focusableInput = query(selector, entry); // (2) set focus

        if (focusableInput) {
          if (isFunction(focusableInput.select)) {
            focusableInput.select();
          } else if (isFunction(focusableInput.focus)) {
            focusableInput.focus();
          }
        }
      }
    }, [newItem, autoFocusEntry, id]);
    return o$1("ol", {
      class: classnames('bio-properties-panel-list-entry-items', open ? 'open' : ''),
      children: items.map((item, index) => {
        const key = getKey(item);
        return o$1("li", {
          class: "bio-properties-panel-list-entry-item",
          children: [o$1(Component, { ...restProps,
            element: element,
            id: id,
            index: index,
            item: item,
            open: item === newItem
          }), onRemove && o$1("button", {
            type: "button",
            title: "Delete item",
            class: "bio-properties-panel-remove-entry bio-properties-panel-remove-list-entry",
            onClick: () => onRemove && onRemove(item),
            children: o$1(DeleteIcon, {})
          })]
        }, key);
      })
    });
  }
  /**
   * Place new items in the beginning of the list and sort the rest with provided function.
   *
   * @template Item
   * @param {Item[]} currentItems
   * @param {(a: Item, b: Item) => 0 | 1 | -1} [compareFn] function used to sort items
   * @param {boolean} [shouldReset=false] set to `true` to reset state of the hook
   * @returns {Item[]}
   */


  function useSortedItems(currentItems, compareFn, shouldReset = false) {
    const itemsRef = s(currentItems.slice()); // (1) Reset and optionally sort.

    if (shouldReset) {
      itemsRef.current = currentItems.slice();

      if (compareFn) {
        itemsRef.current.sort(compareFn);
      }
    } else {
      const items = itemsRef.current; // (2) Add new item to the list.

      for (const item of currentItems) {
        if (!items.includes(item)) {
          // Unshift or push depending on whether we have a compareFn
          compareFn ? items.unshift(item) : items.push(item);
        }
      } // (3) Filter out removed items.


      itemsRef.current = items.filter(item => currentItems.includes(item));
    }

    return itemsRef.current;
  }

  function useNewItems(items = [], shouldReset) {
    const previousItems = usePrevious(items.slice()) || [];

    if (shouldReset) {
      return [];
    }

    return previousItems ? items.filter(item => !previousItems.includes(item)) : [];
  }

  function Select(props) {
    const {
      id,
      label,
      onChange,
      options = [],
      value,
      disabled,
      onFocus,
      onBlur
    } = props;
    const ref = useShowEntryEvent(id);
    const [localValue, setLocalValue] = l$1(value);

    const handleChangeCallback = ({
      target
    }) => {
      onChange(target.value);
    };

    const handleChange = e => {
      handleChangeCallback(e);
      setLocalValue(e.target.value);
    };

    y(() => {
      if (value === localValue) {
        return;
      }

      setLocalValue(value);
    }, [value]);
    return o$1("div", {
      class: "bio-properties-panel-select",
      children: [o$1("label", {
        for: prefixId$4(id),
        class: "bio-properties-panel-label",
        children: label
      }), o$1("select", {
        ref: ref,
        id: prefixId$4(id),
        name: id,
        class: "bio-properties-panel-input",
        onInput: handleChange,
        onFocus: onFocus,
        onBlur: onBlur,
        value: localValue,
        disabled: disabled,
        children: options.map((option, idx) => {
          return o$1("option", {
            value: option.value,
            disabled: option.disabled,
            children: option.label
          }, idx);
        })
      })]
    });
  }
  /**
   * @param {object} props
   * @param {object} props.element
   * @param {string} props.id
   * @param {string} [props.description]
   * @param {string} props.label
   * @param {Function} props.getValue
   * @param {Function} props.setValue
   * @param {Function} props.onFocus
   * @param {Function} props.onBlur
   * @param {Function} props.getOptions
   * @param {boolean} [props.disabled]
   */


  function SelectEntry(props) {
    const {
      element,
      id,
      description,
      label,
      getValue,
      setValue,
      getOptions,
      disabled,
      onFocus,
      onBlur
    } = props;
    const value = getValue(element);
    const options = getOptions(element);
    const error = useError(id);
    return o$1("div", {
      class: classnames('bio-properties-panel-entry', error ? 'has-error' : ''),
      "data-entry-id": id,
      children: [o$1(Select, {
        id: id,
        label: label,
        value: value,
        onChange: setValue,
        onFocus: onFocus,
        onBlur: onBlur,
        options: options,
        disabled: disabled
      }, element), error && o$1("div", {
        class: "bio-properties-panel-error",
        children: error
      }), o$1(Description$2, {
        forId: id,
        element: element,
        value: description
      })]
    });
  }

  function isEdited$4(node) {
    return node && !!node.value;
  } // helpers /////////////////


  function prefixId$4(id) {
    return `bio-properties-panel-${id}`;
  }

  function Simple(props) {
    const {
      debounce,
      disabled,
      element,
      getValue,
      id,
      onBlur,
      onFocus,
      setValue
    } = props;
    const value = getValue(element);
    const [localValue, setLocalValue] = l$1(value);
    const handleInputCallback = d(() => {
      return debounce(({
        target
      }) => setValue(target.value.length ? target.value : undefined));
    }, [setValue, debounce]);

    const handleInput = e => {
      handleInputCallback(e);
      setLocalValue(e.target.value);
    };

    y(() => {
      if (value === localValue) {
        return;
      }

      setLocalValue(value);
    }, [value]);
    return o$1("div", {
      class: "bio-properties-panel-simple",
      children: o$1("input", {
        id: prefixId$3(id),
        type: "text",
        name: id,
        spellCheck: "false",
        autoComplete: "off",
        disabled: disabled,
        class: "bio-properties-panel-input",
        onInput: handleInput,
        "aria-label": localValue || '<empty>',
        onFocus: onFocus,
        onBlur: onBlur,
        value: localValue
      }, element)
    });
  }


  function prefixId$3(id) {
    return `bio-properties-panel-${id}`;
  }

  function TextArea(props) {
    const {
      id,
      label,
      rows = 2,
      debounce,
      onInput,
      value = '',
      disabled,
      monospace,
      onFocus,
      onBlur
    } = props;
    const [localValue, setLocalValue] = l$1(value);
    const ref = useShowEntryEvent(id);
    const handleInputCallback = d(() => {
      return debounce(({
        target
      }) => onInput(target.value.length ? target.value : undefined));
    }, [onInput, debounce]);

    const handleInput = e => {
      handleInputCallback(e);
      setLocalValue(e.target.value);
    };

    y(() => {
      if (value === localValue) {
        return;
      }

      setLocalValue(value);
    }, [value]);
    return o$1("div", {
      class: "bio-properties-panel-textarea",
      children: [o$1("label", {
        for: prefixId$2(id),
        class: "bio-properties-panel-label",
        children: label
      }), o$1("textarea", {
        ref: ref,
        id: prefixId$2(id),
        name: id,
        spellCheck: "false",
        class: classnames('bio-properties-panel-input', monospace ? 'bio-properties-panel-input-monospace' : ''),
        onInput: handleInput,
        onFocus: onFocus,
        onBlur: onBlur,
        rows: rows,
        value: localValue,
        disabled: disabled
      })]
    });
  }
  /**
   * @param {object} props
   * @param {object} props.element
   * @param {string} props.id
   * @param {string} props.description
   * @param {boolean} props.debounce
   * @param {string} props.label
   * @param {Function} props.getValue
   * @param {Function} props.setValue
   * @param {Function} props.onFocus
   * @param {Function} props.onBlur
   * @param {number} props.rows
   * @param {boolean} props.monospace
   * @param {boolean} [props.disabled]
   */


  function TextAreaEntry(props) {
    const {
      element,
      id,
      description,
      debounce,
      label,
      getValue,
      setValue,
      rows,
      monospace,
      disabled,
      onFocus,
      onBlur
    } = props;
    const value = getValue(element);
    const error = useError(id);
    return o$1("div", {
      class: classnames('bio-properties-panel-entry', error ? 'has-error' : ''),
      "data-entry-id": id,
      children: [o$1(TextArea, {
        id: id,
        label: label,
        value: value,
        onInput: setValue,
        onFocus: onFocus,
        onBlur: onBlur,
        rows: rows,
        debounce: debounce,
        monospace: monospace,
        disabled: disabled
      }, element), error && o$1("div", {
        class: "bio-properties-panel-error",
        children: error
      }), o$1(Description$2, {
        forId: id,
        element: element,
        value: description
      })]
    });
  }

  function isEdited$2(node) {
    return node && !!node.value;
  } // helpers /////////////////


  function prefixId$2(id) {
    return `bio-properties-panel-${id}`;
  }

  function Textfield(props) {
    const {
      debounce,
      disabled = false,
      id,
      label,
      onInput,
      onFocus,
      onBlur,
      value = ''
    } = props;
    const [localValue, setLocalValue] = l$1(value || '');
    const ref = useShowEntryEvent(id);
    const handleInputCallback = d(() => {
      return debounce(({
        target
      }) => onInput(target.value.length ? target.value : undefined));
    }, [onInput, debounce]);

    const handleInput = e => {
      handleInputCallback(e);
      setLocalValue(e.target.value);
    };

    y(() => {
      if (value === localValue) {
        return;
      }

      setLocalValue(value);
    }, [value]);
    return o$1("div", {
      class: "bio-properties-panel-textfield",
      children: [o$1("label", {
        for: prefixId$1(id),
        class: "bio-properties-panel-label",
        children: label
      }), o$1("input", {
        ref: ref,
        id: prefixId$1(id),
        type: "text",
        name: id,
        spellCheck: "false",
        autoComplete: "off",
        disabled: disabled,
        class: "bio-properties-panel-input",
        onInput: handleInput,
        onFocus: onFocus,
        onBlur: onBlur,
        value: localValue
      })]
    });
  }
  /**
   * @param {Object} props
   * @param {Object} props.element
   * @param {String} props.id
   * @param {String} props.description
   * @param {Boolean} props.debounce
   * @param {Boolean} props.disabled
   * @param {String} props.label
   * @param {Function} props.getValue
   * @param {Function} props.setValue
   * @param {Function} props.onFocus
   * @param {Function} props.onBlur
   * @param {Function} props.validate
   */


  function TextfieldEntry(props) {
    const {
      element,
      id,
      description,
      debounce,
      disabled,
      label,
      getValue,
      setValue,
      validate,
      onFocus,
      onBlur
    } = props;
    const [cachedInvalidValue, setCachedInvalidValue] = l$1(null);
    const globalError = useError(id);
    const [localError, setLocalError] = l$1(null);
    let value = getValue(element);
    const previousValue = usePrevious(value);
    y(() => {
      if (isFunction(validate)) {
        const newValidationError = validate(value) || null;
        setLocalError(newValidationError);
      }
    }, [value]);

    const onInput = newValue => {
      let newValidationError = null;

      if (isFunction(validate)) {
        newValidationError = validate(newValue) || null;
      }

      if (newValidationError) {
        setCachedInvalidValue(newValue);
      } else {
        setValue(newValue);
      }

      setLocalError(newValidationError);
    };

    if (previousValue === value && localError) {
      value = cachedInvalidValue;
    }

    const error = globalError || localError;
    return o$1("div", {
      class: classnames('bio-properties-panel-entry', error ? 'has-error' : ''),
      "data-entry-id": id,
      children: [o$1(Textfield, {
        debounce: debounce,
        disabled: disabled,
        id: id,
        label: label,
        onInput: onInput,
        onFocus: onFocus,
        onBlur: onBlur,
        value: value
      }, element), error && o$1("div", {
        class: "bio-properties-panel-error",
        children: error
      }), o$1(Description$2, {
        forId: id,
        element: element,
        value: description
      })]
    });
  }

  function isEdited$1(node) {
    return node && !!node.value;
  } // helpers /////////////////


  function prefixId$1(id) {
    return `bio-properties-panel-${id}`;
  }

  function ToggleSwitch(props) {
    const {
      id,
      label,
      onInput,
      value,
      switcherLabel,
      onFocus,
      onBlur
    } = props;
    const [localValue, setLocalValue] = l$1(value);

    const handleInputCallback = async () => {
      onInput(!value);
    };

    const handleInput = e => {
      handleInputCallback();
      setLocalValue(e.target.value);
    };

    y(() => {
      if (value === localValue) {
        return;
      }

      setLocalValue(value);
    }, [value]);
    return o$1("div", {
      class: "bio-properties-panel-toggle-switch",
      children: [o$1("label", {
        class: "bio-properties-panel-label",
        for: prefixId$5(id),
        children: label
      }), o$1("div", {
        class: "bio-properties-panel-field-wrapper",
        children: [o$1("label", {
          class: "bio-properties-panel-toggle-switch__switcher",
          children: [o$1("input", {
            id: prefixId$5(id),
            class: "bio-properties-panel-input",
            type: "checkbox",
            onFocus: onFocus,
            onBlur: onBlur,
            name: id,
            onInput: handleInput,
            checked: !!localValue
          }), o$1("span", {
            class: "bio-properties-panel-toggle-switch__slider"
          })]
        }), o$1("p", {
          class: "bio-properties-panel-toggle-switch__label",
          children: switcherLabel
        })]
      })]
    });
  }
  /**
   * @param {Object} props
   * @param {Object} props.element
   * @param {String} props.id
   * @param {String} props.description
   * @param {String} props.label
   * @param {String} props.switcherLabel
   * @param {Function} props.getValue
   * @param {Function} props.setValue
   * @param {Function} props.onFocus
   * @param {Function} props.onBlur
   */


  function ToggleSwitchEntry(props) {
    const {
      element,
      id,
      description,
      label,
      switcherLabel,
      getValue,
      setValue,
      onFocus,
      onBlur
    } = props;
    const value = getValue(element);
    return o$1("div", {
      class: "bio-properties-panel-entry bio-properties-panel-toggle-switch-entry",
      "data-entry-id": id,
      children: [o$1(ToggleSwitch, {
        id: id,
        label: label,
        value: value,
        onInput: setValue,
        onFocus: onFocus,
        onBlur: onBlur,
        switcherLabel: switcherLabel
      }), o$1(Description$2, {
        forId: id,
        element: element,
        value: description
      })]
    });
  }

  function isEdited(node) {
    return node && !!node.checked;
  } // helpers /////////////////


  function prefixId$5(id) {
    return `bio-properties-panel-${id}`;
  }

  const DEFAULT_DEBOUNCE_TIME = 300;

  function debounceInput(debounceDelay) {
    return function _debounceInput(fn) {
      if (debounceDelay !== false) {
        var debounceTime = isNumber(debounceDelay) ? debounceDelay : DEFAULT_DEBOUNCE_TIME;
        return debounce(fn, debounceTime);
      } else {
        return fn;
      }
    };
  }

  debounceInput.$inject = ['config.debounceInput'];
  var index$4 = {
    debounceInput: ['factory', debounceInput]
  };

  const BpmnPropertiesPanelContext = q$1({
    selectedElement: null,
    injector: null,

    getService() {
      return null;
    }

  });

  /**
   * Is an element of the given BPMN type?
   *
   * @param  {djs.model.Base|ModdleElement} element
   * @param  {string} type
   *
   * @return {boolean}
   */

  function is$4(element, type) {
    var bo = getBusinessObject$1(element);
    return bo && typeof bo.$instanceOf === 'function' && bo.$instanceOf(type);
  }
  /**
   * Return true if element has any of the given types.
   *
   * @param {djs.model.Base} element
   * @param {Array<string>} types
   *
   * @return {boolean}
   */

  function isAny(element, types) {
    return some(types, function (t) {
      return is$4(element, t);
    });
  }
  /**
   * Return the business object for a given element.
   *
   * @param  {djs.model.Base|ModdleElement} element
   *
   * @return {ModdleElement}
   */

  function getBusinessObject$1(element) {
    return element && element.businessObject || element;
  }
  /**
   * Return the di object for a given element.
   *
   * @param  {djs.model.Base} element
   *
   * @return {ModdleElement}
   */

  function getDi(element) {
    return element && element.di;
  }

  function getLabelAttr(semantic) {
    if (is$4(semantic, 'bpmn:FlowElement') || is$4(semantic, 'bpmn:Participant') || is$4(semantic, 'bpmn:Lane') || is$4(semantic, 'bpmn:SequenceFlow') || is$4(semantic, 'bpmn:MessageFlow') || is$4(semantic, 'bpmn:DataInput') || is$4(semantic, 'bpmn:DataOutput')) {
      return 'name';
    }

    if (is$4(semantic, 'bpmn:TextAnnotation')) {
      return 'text';
    }

    if (is$4(semantic, 'bpmn:Group')) {
      return 'categoryValueRef';
    }
  }

  function getCategoryValue(semantic) {
    var categoryValueRef = semantic['categoryValueRef'];

    if (!categoryValueRef) {
      return '';
    }

    return categoryValueRef.value || '';
  }

  function getLabel(element) {
    var semantic = element.businessObject,
        attr = getLabelAttr(semantic);

    if (attr) {
      if (attr === 'categoryValueRef') {
        return getCategoryValue(semantic);
      }

      return semantic[attr] || '';
    }
  }
  function setLabel(element, text, isExternal) {
    var semantic = element.businessObject,
        attr = getLabelAttr(semantic);

    if (attr) {
      if (attr === 'categoryValueRef') {
        semantic['categoryValueRef'].value = text;
      } else {
        semantic[attr] = text;
      }
    }

    return element;
  }

  function isExpanded(element, di) {
    if (is$4(element, 'bpmn:CallActivity')) {
      return false;
    }

    if (is$4(element, 'bpmn:SubProcess')) {
      di = di || getDi(element);

      if (di && is$4(di, 'bpmndi:BPMNPlane')) {
        return true;
      }

      return di && !!di.isExpanded;
    }

    if (is$4(element, 'bpmn:Participant')) {
      return !!getBusinessObject$1(element).processRef;
    }

    return true;
  }
  function isInterrupting(element) {
    return element && getBusinessObject$1(element).isInterrupting !== false;
  }
  function isEventSubProcess(element) {
    return element && !!getBusinessObject$1(element).triggeredByEvent;
  }

  function useService(type, strict) {
    const {
      getService
    } = F$1(BpmnPropertiesPanelContext);
    return getService(type, strict);
  }

  function _extends$1o() { _extends$1o = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1o.apply(this, arguments); }
  var AssociationIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$1o({
    width: "32",
    height: "32",
    xmlns: "http://www.w3.org/2000/svg"
  }, props), /*#__PURE__*/React.createElement("path", {
    stroke: "#000",
    strokeWidth: "2",
    fill: "none",
    strokeDasharray: "3.3,6",
    strokeLinecap: "square",
    d: "M1.5 30.5l29-29"
  })));

  function _extends$1n() { _extends$1n = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1n.apply(this, arguments); }
  var BusinessRuleTaskIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$1n({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M6.494 3C2.916 3 0 5.903 0 9.475v13.383c0 3.572 2.916 6.475 6.494 6.475h19.012c3.578 0 6.494-2.903 6.494-6.475V9.475C32 5.903 29.084 3 25.506 3H6.494zm0 2h19.012C28.015 5 30 6.98 30 9.475v13.383c0 2.495-1.985 4.475-4.494 4.475H6.494C3.985 27.333 2 25.353 2 22.858V9.475C2 6.98 3.985 5 6.494 5zM5.296 7.398v12.665h16.87V7.398H5.296zm.718 4.386h15.433v3.44H9.985v-3.432h-.719v3.431H6.014v-3.44zm0 4.158h3.252v3.403H6.014v-3.403zm3.97 0h11.463v3.403H9.985v-3.403z"
  }), /*#__PURE__*/React.createElement("path", {
    d: "M6.079 8.209v3.587H21.44V8.209z"
  })));

  function _extends$1m() { _extends$1m = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1m.apply(this, arguments); }
  var CallActivityIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$1m({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M24.978 3c3.761 0 6.89 2.979 7.018 6.695l.004.238V22.4c0 3.747-3.05 6.804-6.783 6.93l-.24.003H7.023c-3.761 0-6.89-2.978-7.018-6.695L0 22.4V9.933C0 6.187 3.05 3.13 6.783 3.004L7.023 3h17.955zm0 3.667H7.022c-1.842 0-3.255 1.344-3.35 3.079l-.005.187V22.4c0 1.761 1.35 3.167 3.16 3.262l.195.005L10 25.666V15h12v10.666h2.978c1.842 0 3.255-1.344 3.35-3.079l.005-.187V9.933c0-1.761-1.35-3.166-3.16-3.261l-.195-.005zm-3.732 9.087H10.754v9.912h10.491v-9.912zm-4.475 1.817v2.658h2.658v1.542H16.77v2.658H15.23V21.77H12.57V20.23h2.658V17.57h1.542z"
  })));

  function _extends$1l() { _extends$1l = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1l.apply(this, arguments); }
  var CollaborationIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$1l({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("g", {
    fillRule: "evenodd"
  }, /*#__PURE__*/React.createElement("path", {
    fillRule: "nonzero",
    d: "M0 0v8.62h32V0H0zm1.655 7.054v-5.37h28.62v5.37H1.656zM0 23.38V32h32v-8.62H0zm1.655 7.054v-5.37h28.62v5.37H1.656z"
  }), /*#__PURE__*/React.createElement("path", {
    d: "M24 8l4 7h-8l4-7zm0 2l-2.28 4h4.56L24 10zM23.5 21h1v3h-1zM23.5 15h1v3h-1zM8 24l-4-7h8l-4 7zm0-2l2.28-4H5.72L8 22zM7.5 8h1v3h-1zM7.5 14h1v3h-1z"
  }))));

  function _extends$1k() { _extends$1k = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1k.apply(this, arguments); }
  var ConditionalFlowIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$1k({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M32 .041S20.42 5.95 14.537 8.713c1.26 1.15 2.432 2.392 3.648 3.588-5.703 5.78-3.15 3.303-8.087 8.316l-8.472 1.377L0 32l10.006-1.626.098-.598 1.279-7.873c4.975-5.052 2.403-2.555 8.118-8.346 1.218 1.214 2.43 2.435 3.648 3.648C26.29 11.018 32 .041 32 .041zM9.603 22.397L8.54 28.91 2.03 29.97l1.061-6.515 6.512-1.058z"
  })));

  function _extends$1j() { _extends$1j = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1j.apply(this, arguments); }
  var ConnectionIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$1j({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M32 .06S20.33 6.014 14.403 8.798c1.27 1.16 2.451 2.41 3.676 3.616L0 30.734 1.325 32l18.08-18.32c1.227 1.223 2.448 2.453 3.676 3.676C26.247 11.12 32 .06 32 .06z"
  })));

  function _extends$1i() { _extends$1i = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1i.apply(this, arguments); }
  var DataInputOutputAssociationIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$1i({
    width: "32",
    height: "32",
    xmlns: "http://www.w3.org/2000/svg"
  }, props), /*#__PURE__*/React.createElement("path", {
    stroke: "#000",
    strokeWidth: "2",
    strokeLinecap: "round",
    strokeDasharray: "1.1,4.3",
    d: "M1.5 30.5L27 5"
  }), /*#__PURE__*/React.createElement("path", {
    d: "M31.803.197L26.5 16.107l-1.52-1.52 3.783-11.35-11.35 3.783-1.52-1.52z"
  })));

  function _extends$1h() { _extends$1h = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1h.apply(this, arguments); }
  var DataInputIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$1h({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M20.833 0H3.488v32H28V7.36L20.833 0zm-2.105 1.818v7.507h7.454v20.857H5.306V1.818h13.422zm1.818.493l5.06 5.196h-5.06V2.311zm-9.182.86v3.744H7.081v3.222h4.283v3.743l5.7-5.354-5.7-5.354zm.808 1.868l3.711 3.487-3.71 3.487V9.329H7.888V7.723h4.283V5.039z"
  })));

  function _extends$1g() { _extends$1g = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1g.apply(this, arguments); }
  var DataObjectIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$1g({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M21.345 0H4v32h24.512V7.36L21.345 0zM19.24 1.818v7.507h7.454v20.857H5.818V1.818H19.24zm1.818.493l5.06 5.196h-5.06V2.311z"
  })));

  function _extends$1f() { _extends$1f = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1f.apply(this, arguments); }
  var DataOutputIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$1f({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M20.833 0H3.488v32H28V7.36L20.833 0zm-2.105 1.818v7.507h7.454v20.857H5.306V1.818h13.422zm1.818.493l5.06 5.196h-5.06V2.311zm-9.182.86v3.744H7.081v3.222h4.283v3.743l5.7-5.354-5.7-5.354z"
  })));

  function _extends$1e() { _extends$1e = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1e.apply(this, arguments); }
  var DataStoreIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$1e({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M16.008 1c-3.712 0-7.417.306-10.319.939-1.45.316-2.7.71-3.68 1.226C1.065 3.662.297 4.304.061 5.23a.823.823 0 00-.035.15L0 5.502l.017.084c-.012 7.41 0 14.46 0 22.08l.017.082c.203.985.995 1.656 1.975 2.172.98.517 2.23.91 3.68 1.226 2.902.633 6.607.94 10.319.94 3.711 0 7.416-.307 10.318-.94 1.451-.316 2.701-.71 3.68-1.226.98-.516 1.772-1.187 1.975-2.172l.017-.082V5.541a.825.825 0 000-.106v-.016l-.002-.013a.823.823 0 00-.046-.197c-.244-.916-1.007-1.55-1.943-2.044-.98-.516-2.23-.91-3.68-1.226C23.423 1.306 19.718 1 16.006 1zm0 1.646c3.62 0 7.245.308 9.968.901 1.36.297 2.497.67 3.263 1.074.612.323.932.643 1.063.882-.131.24-.451.56-1.063.882-.766.404-1.902.777-3.263 1.074-2.723.594-6.349.901-9.968.901-3.62 0-7.245-.307-9.968-.901-1.361-.297-2.497-.67-3.264-1.074-.611-.322-.931-.642-1.062-.882.13-.24.451-.56 1.062-.882.767-.403 1.903-.777 3.264-1.074 2.723-.593 6.348-.9 9.968-.9zM1.664 7.647c.112.067.227.132.345.194.98.517 2.23.91 3.68 1.226 2.902.633 6.607.94 10.319.94 3.711 0 7.416-.307 10.318-.94 1.451-.316 2.701-.71 3.68-1.226.119-.062.234-.127.346-.194v1.93c-.08.245-.398.619-1.113.995-.766.404-1.902.777-3.263 1.074-2.723.594-6.349.901-9.968.901-3.62 0-7.245-.307-9.968-.9-1.361-.298-2.497-.671-3.264-1.075-.714-.376-1.032-.75-1.112-.995v-1.93zm0 4.187c.112.067.227.132.345.195.98.516 2.23.91 3.68 1.226 2.902.632 6.607.938 10.319.938 3.711 0 7.416-.306 10.318-.938 1.451-.317 2.701-.71 3.68-1.226.119-.063.234-.128.346-.195v1.93c-.08.245-.398.619-1.113.995-.766.404-1.902.777-3.263 1.074-2.723.594-6.349.901-9.968.901-3.62 0-7.245-.307-9.968-.9-1.361-.298-2.497-.67-3.264-1.075-.714-.376-1.032-.75-1.112-.995v-1.93zm0 4.188c.112.067.227.131.345.194.98.516 2.23.91 3.68 1.226 2.902.633 6.607.939 10.319.939 3.711 0 7.416-.306 10.318-.94 1.451-.316 2.701-.709 3.68-1.225.119-.063.234-.127.346-.194V27.47c-.08.245-.398.618-1.113.995-.766.404-1.902.777-3.263 1.074-2.723.594-6.349.9-9.968.9-3.62 0-7.245-.306-9.968-.9-1.361-.297-2.497-.67-3.264-1.074-.714-.377-1.032-.75-1.112-.995V16.022z"
  })));

  function _extends$1d() { _extends$1d = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1d.apply(this, arguments); }
  var DefaultFlowIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$1d({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M32 .06S20.33 6.014 14.403 8.798c1.27 1.16 2.451 2.41 3.676 3.616L6.84 23.804H.046v1.755h5.063L0 30.735 1.325 32l6.357-6.441h7.145v-1.756H9.414l9.99-10.123c1.228 1.223 2.45 2.453 3.677 3.676C26.247 11.12 32 .06 32 .06z"
  })));

  function _extends$1c() { _extends$1c = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1c.apply(this, arguments); }
  var EndEventCancelIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$1c({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.676.051C7.943.058.834 6.501.104 14.21c-.783 6.565 2.912 13.427 8.942 16.216 5.6 2.737 12.789 1.87 17.434-2.344 4.725-4.09 6.79-11.06 4.714-17.006C29.22 5.009 23.394.364 16.978.083A18.532 18.532 0 0015.676.05zm.317 5.006c5.695-.165 10.916 4.858 10.983 10.555.246 5.212-3.67 10.33-8.864 11.204-5.026 1.007-10.6-1.898-12.36-6.777-1.894-4.826.039-10.928 4.649-13.46a11.082 11.082 0 015.592-1.522zm-3.955 3.918L8.94 12.072l3.985 3.985-3.913 3.913 3.048 3.047 3.913-3.913 3.987 3.987 3.096-3.096-3.987-3.987 3.913-3.913-3.047-3.048-3.913 3.913-3.985-3.985z"
  })));

  function _extends$1b() { _extends$1b = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1b.apply(this, arguments); }
  var EndEventCompensationIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$1b({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.676.051C7.943.058.834 6.501.104 14.21c-.783 6.565 2.912 13.427 8.942 16.216 5.6 2.737 12.789 1.87 17.434-2.344 4.725-4.09 6.79-11.06 4.714-17.006C29.22 5.009 23.394.364 16.978.083A18.532 18.532 0 0015.676.05zm.317 5.006c5.695-.165 10.916 4.858 10.983 10.555.246 5.212-3.67 10.33-8.864 11.204-5.026 1.007-10.6-1.898-12.36-6.777-1.894-4.826.039-10.928 4.649-13.46a11.082 11.082 0 015.592-1.522zm-.56 5.744l-7.407 5.23 7.408 5.234v-5.057c2.384 1.687 4.771 3.371 7.157 5.057V10.801l-7.157 5.054v-5.054z"
  })));

  function _extends$1a() { _extends$1a = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1a.apply(this, arguments); }
  var EndEventErrorIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$1a({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.676.051C7.943.058.834 6.501.104 14.21c-.783 6.565 2.912 13.427 8.942 16.216 5.6 2.737 12.789 1.87 17.434-2.344 4.725-4.09 6.79-11.06 4.714-17.006C29.22 5.009 23.394.364 16.978.083A18.532 18.532 0 0015.676.05zm.317 5.006c5.695-.165 10.916 4.858 10.983 10.555.246 5.212-3.67 10.33-8.864 11.204-5.026 1.007-10.6-1.898-12.36-6.777-1.894-4.826.039-10.928 4.649-13.46a11.082 11.082 0 015.592-1.522zm6.132 4.166l-3.633 7.363-4.516-5.874-4.102 12.131 4.599-5.91 4.743 5.427 2.909-13.137z"
  })));

  function _extends$19() { _extends$19 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$19.apply(this, arguments); }
  var EndEventEscalationIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$19({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.676.051C7.943.058.834 6.501.104 14.21c-.783 6.565 2.912 13.427 8.942 16.216 5.6 2.737 12.789 1.87 17.434-2.344 4.725-4.09 6.79-11.06 4.714-17.006C29.22 5.009 23.394.364 16.978.083A18.532 18.532 0 0015.676.05zm.317 5.006c5.695-.165 10.916 4.858 10.983 10.555.246 5.212-3.67 10.33-8.864 11.204-5.026 1.007-10.6-1.898-12.36-6.777-1.894-4.826.039-10.928 4.649-13.46a11.082 11.082 0 015.592-1.522zm.006 3.9c-1.672 4.653-2.733 9.5-4.406 14.153 1.535-1.525 2.872-3.234 4.406-4.759l4.406 4.76c-1.497-4.71-2.91-9.445-4.406-14.155z"
  })));

  function _extends$18() { _extends$18 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$18.apply(this, arguments); }
  var EndEventLinkIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$18({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.676 0C7.943.007.834 6.45.104 14.16c-.783 6.565 2.912 13.427 8.942 16.216 5.6 2.737 12.789 1.87 17.434-2.344 4.725-4.09 6.79-11.06 4.714-17.006C29.22 4.958 23.394.313 16.978.032A18.532 18.532 0 0015.676 0zm.317 5.006c5.695-.165 10.916 4.858 10.983 10.555.246 5.212-3.67 10.33-8.864 11.204-5.026 1.007-10.6-1.898-12.36-6.777-1.894-4.826.039-10.928 4.649-13.46a11.082 11.082 0 015.592-1.522zm1.78 4.065v3.555H9.779v6.713h7.994v3.554l5.828-6.91-5.828-6.912z"
  })));

  function _extends$17() { _extends$17 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$17.apply(this, arguments); }
  var EndEventMessageIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$17({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.676 0C7.943.007.834 6.45.104 14.16c-.783 6.565 2.912 13.427 8.942 16.216 5.6 2.737 12.789 1.87 17.434-2.344 4.725-4.09 6.79-11.06 4.714-17.006C29.22 4.958 23.394.313 16.978.032A18.532 18.532 0 0015.676 0zm.317 5.006c5.695-.165 10.916 4.858 10.983 10.555.246 5.212-3.67 10.33-8.864 11.204-5.026 1.007-10.6-1.898-12.36-6.777-1.894-4.826.039-10.928 4.649-13.46a11.082 11.082 0 015.592-1.522zm-5.91 5.448l6.041 4.9 6.04-4.9H10.084zm-1.34 1.137v9.92h14.513v-9.718l-7.132 5.786-7.381-5.988z"
  })));

  function _extends$16() { _extends$16 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$16.apply(this, arguments); }
  var EndEventMultipleIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$16({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.676 0C7.943.007.834 6.45.104 14.16c-.783 6.565 2.912 13.427 8.942 16.216 5.6 2.737 12.789 1.87 17.434-2.344 4.725-4.09 6.79-11.06 4.714-17.006C29.22 4.958 23.394.313 16.978.032A18.529 18.529 0 0015.676 0zm.317 5.006c5.695-.165 10.916 4.858 10.983 10.555.246 5.212-3.67 10.33-8.864 11.204-5.026 1.007-10.6-1.898-12.36-6.777-1.894-4.826.039-10.928 4.649-13.46a11.082 11.082 0 015.592-1.522zm.011 3.039l-7.619 5.53 2.91 8.95h9.418l2.91-8.95-7.619-5.53z"
  })));

  function _extends$15() { _extends$15 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$15.apply(this, arguments); }
  var EndEventNoneIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$15({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.84.042C8.654-.01 1.913 5.437.4 12.454-1.057 18.62 1.554 25.495 6.784 29.09c5.076 3.636 12.31 3.92 17.59.544 5.309-3.251 8.435-9.744 7.445-15.921C30.91 7.307 25.795 1.738 19.442.422a16.064 16.064 0 00-3.602-.38zm.382 5.01c5.28-.017 10.13 4.353 10.669 9.61.687 5.025-2.552 10.281-7.423 11.792-4.754 1.617-10.486-.447-12.962-4.856-2.74-4.575-1.574-11.094 2.768-14.27a11.05 11.05 0 016.948-2.276z"
  })));

  function _extends$14() { _extends$14 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$14.apply(this, arguments); }
  var EndEventSignalIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$14({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.676.051C7.943.058.834 6.501.104 14.21c-.783 6.565 2.912 13.427 8.942 16.216 5.6 2.737 12.789 1.87 17.434-2.344 4.725-4.09 6.79-11.06 4.714-17.006C29.22 5.009 23.394.364 16.978.083A18.532 18.532 0 0015.676.05zm.317 5.006c5.695-.165 10.916 4.858 10.983 10.555.246 5.212-3.67 10.33-8.864 11.204-5.026 1.007-10.6-1.898-12.36-6.777-1.894-4.826.039-10.928 4.649-13.46a11.082 11.082 0 015.592-1.522zm.006 3.492c-2.261 4.07-4.532 8.136-6.797 12.204h13.595L15.999 8.55z"
  })));

  function _extends$13() { _extends$13 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$13.apply(this, arguments); }
  var EndEventTerminateIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$13({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.676.051C7.943.058.834 6.501.104 14.21c-.783 6.565 2.912 13.427 8.942 16.216 5.6 2.737 12.789 1.87 17.434-2.344 4.725-4.09 6.79-11.06 4.714-17.006C29.22 5.009 23.394.364 16.978.083A18.532 18.532 0 0015.676.05zm.317 5.006c5.695-.165 10.916 4.858 10.983 10.555.246 5.212-3.67 10.33-8.864 11.204-5.026 1.007-10.6-1.898-12.36-6.777-1.894-4.826.039-10.928 4.649-13.46a11.082 11.082 0 015.592-1.522zm.006 2.859c-5.264-.2-9.495 5.551-7.755 10.516 1.366 5.085 8.108 7.436 12.339 4.301 4.455-2.807 4.708-9.943.462-13.058A8.128 8.128 0 0016 7.915z"
  })));

  function _extends$12() { _extends$12 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$12.apply(this, arguments); }
  var EventSubProcessExpandedIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$12({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M7.295 4.78h1.779V3.003h-1.78V4.78zm3.558 0h1.779V3.003h-1.78V4.78zm3.557 0h1.78V3.003h-1.78V4.78zm3.558 0h1.78V3.003h-1.78V4.78zm3.558 0h1.779V3.003h-1.779V4.78zm3.558 0c.55.014 1.106-.034 1.654.045l.245-1.762c-.629-.096-1.266-.05-1.9-.061V4.78zM5.732 3.004a5.933 5.933 0 00-.915.093c.111.582.226 1.164.315 1.75.358-.101.947.098.746-.483-.096-.382.164-1.208-.146-1.36zm22.372 2.281c.427.234.812.547 1.13.915.42-.4 1.002-.777 1.33-1.18a5.863 5.863 0 00-1.593-1.289l-.867 1.554zm-25.27-1.44c-.587.354-1.11.811-1.539 1.345.47.333.96.86 1.417 1.077.299-.362.66-.673 1.065-.913-.328-.493-.55-1.055-.944-1.509zM30.515 7.26c-.563.046-.557.342-.378.784.154.25-.097.862.25.85.525-.023 1.14.043 1.612-.032a5.891 5.891 0 00-.362-2.027l-1.122.425zM.268 7.114A6.042 6.042 0 000 9.052h1.78c-.013-.5.047-1.003.208-1.478L.296 7.027l-.026.079-.002.008zM30.22 12.45H32v-1.779h-1.779v1.779zm-30.22.16h1.78v-1.779H0v1.78zm30.22 3.398H32v-1.78h-1.779v1.78zm-30.22.16h1.78v-1.779H0v1.779zm30.22 3.398H32v-1.78h-1.779v1.78zm-30.22.16h1.78v-1.78H0v1.78zm30.22 3.397H32v-1.779h-1.779v1.78zm-30.22.16h1.78v-1.778H0v1.778zm30.137 1.47a4.059 4.059 0 01-.522 1.32c.506.283 1.046.715 1.53.908a5.836 5.836 0 00.744-1.918c-.576-.094-1.209-.264-1.752-.31zm-29.984.51c.157.676.435 1.325.82 1.904l1.486-.977a4.065 4.065 0 01-.577-1.347l-1.73.42zm28.427 1.943c-.371.277-.79.49-1.234.627l.548 1.693a5.84 5.84 0 001.835-.96l-1.082-1.412-.066.05-.001.002zm-26.164 1.47c.567.413 1.21.722 1.886.907.14-.569.343-1.175.444-1.722a4.062 4.062 0 01-1.283-.624l-1.047 1.438zm3.88 1.119h1.779v-1.78h-1.78v1.78zm3.55 0h1.787v-1.78H9.846v1.78zm3.565 0h1.78v-1.78h-1.78v1.78zm3.558 0h1.78v-1.78h-1.78v1.78zm3.451 0h1.743v-1.78h-1.743v1.78zm3.665 0h1.779v-1.78h-1.78v1.78zm-1.922-.545V16.776H9.846V29.25h12.318zM10.967 17.905h10.068V27.97H10.967V17.905zm1.336 3.998v1.711h7.396v-1.711h-7.396z",
    opacity: ".97"
  })));

  function _extends$11() { _extends$11 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$11.apply(this, arguments); }
  var GatewayComplexIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$11({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M16.001 0a1.29 1.29 0 00-.917.373L.373 15.084a1.316 1.316 0 00.002 1.834l14.71 14.709a1.313 1.313 0 001.833 0l14.711-14.711a1.316 1.316 0 00-.002-1.834L16.917.372A1.294 1.294 0 0016.002 0zM16 2.181l13.821 13.821L16 29.823 2.179 16.003 16 2.18zm-.327 6.79v.007l-.145.027-.118.08-.083.123-.028.145v4.954L11.793 10.8l-.125-.08-.14-.029-.144.027-.122.082-.46.46-.085.125-.026.142.028.14.08.125 3.505 3.505H9.347l-.001-.002-.145.032-.118.08-.083.122-.028.146v.652l.029.147.082.119.12.08.144.032h4.956L10.8 20.207v-.001l-.084.124-.026.142.028.14.08.124.46.461.126.082.14.029.143-.027.124-.084L15.3 17.69v4.964-.001l.028.147.082.12.12.08.144.031h.652l.148-.03.118-.08.083-.12.028-.146v-4.962l3.505 3.505.126.082.14.027.142-.027.124-.084.461-.46.083-.123s.028-.144.027-.146l-.028-.14-.082-.126-3.496-3.496h4.948l.148-.03.119-.08.082-.12.028-.147v-.652l-.028-.145-.083-.122-.119-.08s-.147-.033-.147-.031h-4.964l3.512-3.512.082-.122.029-.144-.028-.14-.084-.124-.46-.461-.123-.082-.14-.027-.145.027-.122.082-3.507 3.507V9.348l-.028-.146-.082-.122-.12-.08-.147-.029h-.652z"
  })));

  function _extends$10() { _extends$10 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$10.apply(this, arguments); }
  var GatewayEventBasedIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$10({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M16 0a1.29 1.29 0 00-.918.373L.371 15.084a1.316 1.316 0 00.002 1.834l14.71 14.709a1.313 1.313 0 001.833 0l14.711-14.711a1.316 1.316 0 00-.002-1.834L16.915.372A1.294 1.294 0 0016 0zm-.002 2.181l13.821 13.821-13.821 13.821-13.821-13.82L15.998 2.18zm0 5.876l-.254.185-7.377 5.355 2.915 8.964h9.433l2.915-8.964-7.631-5.54zm0 1.07l6.614 4.8-2.526 7.769h-8.175l-2.526-7.768 6.614-4.802z"
  })));

  function _extends$$() { _extends$$ = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$$.apply(this, arguments); }
  var GatewayNoneIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$$({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M.373 15.084a1.316 1.316 0 00.002 1.834l14.71 14.709a1.313 1.313 0 001.833 0l14.711-14.711a1.316 1.316 0 00-.002-1.834L16.917.373a1.313 1.313 0 00-1.833 0L.373 15.084zm1.806.918L16 2.182l13.821 13.82L16 29.823 2.179 16.003z"
  })));

  function _extends$_() { _extends$_ = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$_.apply(this, arguments); }
  var GatewayOrIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$_({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M16.001 0a1.29 1.29 0 00-.917.373L.373 15.084a1.316 1.316 0 00.002 1.834l14.71 14.709a1.313 1.313 0 001.833 0l14.711-14.711a1.316 1.316 0 00-.002-1.834L16.917.372A1.294 1.294 0 0016.002 0zM16 2.181l13.821 13.821L16 29.823 2.179 16.003 16 2.18zm0 6.379a7.447 7.447 0 00-7.44 7.441A7.447 7.447 0 0016 23.443 7.447 7.447 0 0023.443 16a7.447 7.447 0 00-7.441-7.441zm0 .825a6.61 6.61 0 016.617 6.616A6.61 6.61 0 0116 22.618 6.61 6.61 0 019.385 16 6.61 6.61 0 0116 9.385z"
  })));

  function _extends$Z() { _extends$Z = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$Z.apply(this, arguments); }
  var GatewayParallelIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$Z({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M16.001 0a1.29 1.29 0 00-.917.373L.373 15.084a1.316 1.316 0 00.002 1.834l14.71 14.709a1.313 1.313 0 001.833 0l14.711-14.711a1.316 1.316 0 00-.002-1.834L16.917.372A1.294 1.294 0 0016.002 0zM16 2.181l13.821 13.821L16 29.823 2.179 16.003 16 2.18zm-.377 5.708l-.168.032-.136.092-.096.14-.032.168v6.868h-6.87l-.002-.002-.166.037-.137.092v-.002l-.095.141-.033.167v.753s.032.169.034.17l.094.138.138.092.167.036h6.87v6.867l-.001-.001.033.17.095.138.138.092s.166.035.167.037h.752l.17-.036.137-.092.095-.137.033-.17v-6.867h6.868l.17-.035.137-.092.095-.137.033-.17v-.753s-.033-.165-.032-.167l-.096-.14-.138-.093s-.17-.037-.17-.035H16.81V8.323l-.033-.168-.094-.14-.138-.092-.17-.034h-.752z"
  })));

  function _extends$Y() { _extends$Y = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$Y.apply(this, arguments); }
  var GatewayXorIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$Y({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M16 0a1.29 1.29 0 00-.918.373L.371 15.084a1.316 1.316 0 00.002 1.834l14.71 14.709a1.313 1.313 0 001.833 0l14.711-14.711a1.316 1.316 0 00-.002-1.834L16.915.372A1.294 1.294 0 0016 0zm-.002 2.181l13.821 13.821-13.821 13.821-13.821-13.82L15.998 2.18zm-5.162 7.69l-.166.032-.141.096-.532.532s-.097.142-.097.144l-.03.164.032.162.093.144 4.857 4.858-4.855 4.855v-.001L9.9 21l-.03.164.032.162s.093.142.093.144l.531.532.146.095.162.032.164-.03.144-.097 4.855-4.856 4.857 4.857.145.095.162.032.164-.03.144-.097.531-.532.095-.14.033-.168-.033-.162-.095-.146L17.144 16 22 11.144l.095-.14.033-.166-.033-.163-.097-.144-.532-.532-.14-.095-.163-.032-.166.032-.141.095L16 14.855l-4.858-4.858v-.002l-.144-.092-.162-.032z"
  })));

  function _extends$X() { _extends$X = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$X.apply(this, arguments); }
  var GroupIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$X({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M6.34.016c-2.333.025-4.684 1.77-5.29 4.17C.608 5.848.88 7.608.804 9.314v2.922h2.041c.038-2.332-.076-4.673.062-7C3.14 3.355 4.869 1.938 6.643 2.04h8.956V.009c-3.086 0-6.173-.02-9.258 0v.007zm13.094 2.023h1.92V.009h-1.92v2.03zm5.756 0c1.265-.069 2.66.045 3.602 1.055 1.036.983 1.201 2.523 1.122 3.91v6.313h2.078c-.03-2.677.062-5.36-.047-8.032-.17-2.743-2.62-5.111-5.215-5.236-.511-.064-1.027-.02-1.54-.033v2.023zM.803 18.319h2.041v-2.026H.804v2.026zm29.11 1.084h2.08v-2.03h-2.08v2.03zM.804 26.148c.004 2.218 1.393 4.366 3.313 5.28 1.728.853 3.681.448 5.521.544.43-.112 1.29.231 1.435-.183v-1.847c-1.788-.043-3.584.094-5.365-.082-1.67-.354-2.919-2.048-2.863-3.844v-3.644H.804v3.777zm29.11-.068c.04 1.961-1.508 3.787-3.381 3.842-1.954.06-3.914.02-5.87.026v2.03c2.118-.042 4.242.08 6.355-.063 2.524-.264 4.818-2.644 4.94-5.323.08-1.039.014-2.085.035-3.126h-2.078v2.613zm-15.006 5.898h1.92v-2.03h-1.92v2.03z"
  })));

  function _extends$W() { _extends$W = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$W.apply(this, arguments); }
  var IntermediateEventCatchCancelIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$W({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.975.049C8.195-.111.935 6.286.125 14.03c-.855 6.55 2.741 13.46 8.74 16.314 5.666 2.847 13.012 1.99 17.71-2.33 4.745-4.162 6.727-11.243 4.532-17.206C29.09 4.93 23.445.454 17.201.095c-.408-.03-.817-.046-1.226-.046zm-.181 1.724c7.134-.269 13.84 5.68 14.399 12.804.686 6.283-3.267 12.792-9.283 14.862-5.847 2.162-13.025.06-16.557-5.141C.728 19.22.872 11.725 4.985 6.962c2.632-3.171 6.671-5.174 10.809-5.19zm.283 1.553c-6.6-.21-12.671 5.585-12.79 12.185-.292 5.964 4.129 11.817 10.034 12.953 5.47 1.198 11.584-1.613 14.025-6.702 2.525-4.97 1.396-11.585-2.912-15.215-2.282-2.022-5.3-3.217-8.357-3.22zM16 5.021c5.818-.154 11.117 5.082 11.024 10.905.103 5.384-4.23 10.5-9.636 11.043-5.075.667-10.426-2.587-11.885-7.552-1.53-4.73.48-10.428 4.888-12.864A11.082 11.082 0 0116 5.021zm-3.956 3.946l-3.096 3.097 3.985 3.985-3.913 3.913 3.047 3.048 3.913-3.913 3.988 3.987 3.097-3.096L19.076 16l3.914-3.913-3.048-3.048-3.913 3.913-3.986-3.985zm-.002 1.222l3.988 3.987 3.913-3.913 1.826 1.826-3.913 3.913 3.985 3.986-1.873 1.873-3.985-3.985-3.913 3.913-1.827-1.827 3.914-3.913-3.988-3.987 1.873-1.873z"
  })));

  function _extends$V() { _extends$V = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$V.apply(this, arguments); }
  var IntermediateEventCatchCompensationIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$V({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.975.049C8.195-.11.935 6.286.125 14.03c-.855 6.55 2.741 13.46 8.74 16.314 5.666 2.847 13.012 1.99 17.71-2.33 4.745-4.162 6.727-11.243 4.532-17.206C29.09 4.93 23.445.453 17.201.095c-.408-.03-.817-.046-1.226-.046zm-.181 1.724c7.134-.269 13.84 5.68 14.399 12.804.686 6.283-3.267 12.792-9.283 14.862-5.847 2.162-13.025.06-16.557-5.141C.728 19.22.872 11.725 4.985 6.962c2.632-3.171 6.671-5.174 10.809-5.19zm.283 1.553c-6.6-.21-12.671 5.585-12.79 12.185-.292 5.964 4.129 11.817 10.034 12.953 5.47 1.198 11.584-1.613 14.025-6.702 2.525-4.97 1.396-11.585-2.912-15.216-2.282-2.021-5.3-3.216-8.357-3.22zM16 5.021c5.818-.154 11.117 5.082 11.024 10.905.103 5.384-4.23 10.5-9.636 11.043-5.075.667-10.426-2.587-11.885-7.552-1.53-4.73.48-10.428 4.888-12.864A11.083 11.083 0 0116 5.021zm-.56 5.772l-7.408 5.231 7.409 5.234v-5.057c2.385 1.687 4.771 3.371 7.157 5.057V10.793l-7.157 5.055v-5.055zm-.865 1.665v7.125l-5.048-3.562 5.048-3.563zm7.161 0v7.132l-5.048-3.566 5.048-3.566z"
  })));

  function _extends$U() { _extends$U = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$U.apply(this, arguments); }
  var IntermediateEventCatchConditionIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$U({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.97.04h-.127C8.713-.018 2.003 5.334.437 12.286c-1.51 6.123.98 13.005 6.136 16.665 5.125 3.788 12.546 4.105 17.912.623 5.272-3.276 8.33-9.766 7.325-15.916-.904-6.241-5.79-11.7-11.95-13.143A16.082 16.082 0 0015.97.04zm-.181 1.724c.115 0 .23 0 .347.003 6.625-.066 12.823 5.149 13.89 11.69 1.13 5.91-1.908 12.349-7.262 15.138-5.473 3.013-12.866 1.884-17.116-2.726C1.291 21.372.444 13.914 3.802 8.602c2.493-4.112 7.169-6.819 11.987-6.838zm.283 1.554c-.117 0-.234.002-.351.005-6.1 0-11.691 5.049-12.346 11.114-.78 5.684 2.795 11.612 8.218 13.52 5.139 1.943 11.416.101 14.624-4.38 3.461-4.583 3.262-11.538-.596-15.831-2.36-2.747-5.924-4.423-9.549-4.428zm-.078 1.695c.078 0 .156 0 .234.003 5.4 0 10.321 4.556 10.734 9.942.563 5.13-2.958 10.364-7.971 11.678-4.832 1.41-10.457-.935-12.746-5.446-2.463-4.559-1.2-10.795 3.014-13.883a11.072 11.072 0 016.735-2.294zm-5.352 4.266V22.761h10.716V9.279H10.642zm.863.866h8.987v11.75h-8.987v-11.75zm.927 1.323v.862h7.133v-.862h-7.133zm0 2.602v.866h7.133v-.866h-7.133zm0 3.008v.862h7.133v-.862h-7.133zm0 2.717v.863h7.133v-.863h-7.133z"
  })));

  function _extends$T() { _extends$T = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$T.apply(this, arguments); }
  var IntermediateEventCatchErrorIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$T({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.975.049C8.195-.11.935 6.286.125 14.03c-.855 6.55 2.741 13.46 8.74 16.314 5.666 2.847 13.012 1.99 17.71-2.33 4.745-4.162 6.727-11.243 4.532-17.206C29.09 4.93 23.445.453 17.201.095c-.408-.03-.817-.046-1.226-.046zm-.181 1.724c7.134-.269 13.84 5.68 14.399 12.804.686 6.283-3.267 12.792-9.283 14.862-5.847 2.162-13.025.06-16.557-5.141C.728 19.22.872 11.725 4.985 6.962c2.632-3.171 6.671-5.174 10.809-5.19zm.283 1.553c-6.6-.21-12.671 5.585-12.79 12.185-.292 5.964 4.129 11.817 10.034 12.953 5.47 1.198 11.584-1.613 14.025-6.702 2.525-4.97 1.396-11.585-2.912-15.216-2.282-2.021-5.3-3.216-8.357-3.22zM16 5.021c5.818-.154 11.117 5.082 11.024 10.905.103 5.384-4.23 10.5-9.636 11.043-5.075.667-10.426-2.587-11.885-7.552-1.53-4.73.48-10.428 4.888-12.864A11.083 11.083 0 0116 5.021zm6.132 4.194c-1.21 2.455-2.422 4.91-3.633 7.364l-4.516-5.875-4.103 12.133 4.6-5.912c1.58 1.81 3.162 3.619 4.744 5.429L22.13 9.215zM14.383 13.1l4.295 5.445 1.073-2.387-1.027 4.131-4.384-5.157-1.778 2.75 1.821-4.782z"
  })));

  function _extends$S() { _extends$S = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$S.apply(this, arguments); }
  var IntermediateEventCatchEscalationIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$S({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.975.049C8.195-.11.935 6.286.125 14.03c-.855 6.55 2.741 13.46 8.74 16.314 5.666 2.847 13.012 1.99 17.71-2.33 4.745-4.162 6.727-11.243 4.532-17.206C29.09 4.93 23.445.453 17.201.095c-.408-.03-.817-.046-1.226-.046zm-.181 1.724c7.134-.269 13.84 5.68 14.399 12.804.686 6.283-3.267 12.792-9.283 14.862-5.847 2.162-13.025.06-16.557-5.141C.728 19.22.872 11.725 4.985 6.962c2.632-3.171 6.671-5.174 10.809-5.19zm.283 1.553c-6.6-.21-12.671 5.585-12.79 12.185-.292 5.964 4.129 11.817 10.034 12.953 5.47 1.198 11.584-1.613 14.025-6.702 2.525-4.97 1.396-11.585-2.912-15.216-2.282-2.021-5.3-3.216-8.357-3.22zM16 5.021c5.818-.154 11.117 5.082 11.024 10.905.103 5.384-4.23 10.5-9.636 11.043-5.075.667-10.426-2.587-11.885-7.552-1.53-4.73.48-10.428 4.888-12.864A11.083 11.083 0 0116 5.021zm.006 3.927c-1.672 4.654-2.734 9.502-4.406 14.155 1.534-1.525 2.872-3.234 4.406-4.759l4.406 4.76c-1.496-4.71-2.91-9.446-4.406-14.156zm.032 2.929c.822 2.586 1.598 5.186 2.42 7.771l-2.42-2.612c-.682.597-2.452 2.884-2.338 2.388.87-2.487 1.447-5.067 2.338-7.547z"
  })));

  function _extends$R() { _extends$R = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$R.apply(this, arguments); }
  var IntermediateEventCatchLinkIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$R({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.975.049C8.195-.11.935 6.286.125 14.03c-.855 6.55 2.741 13.46 8.74 16.314 5.666 2.847 13.012 1.99 17.71-2.33 4.745-4.162 6.727-11.243 4.532-17.206C29.09 4.93 23.445.453 17.201.095c-.408-.03-.817-.046-1.226-.046zm-.181 1.724c7.134-.269 13.84 5.68 14.399 12.804.686 6.283-3.267 12.792-9.283 14.862-5.847 2.162-13.025.06-16.557-5.141C.728 19.22.872 11.725 4.985 6.962c2.632-3.171 6.671-5.174 10.809-5.19zm.283 1.553c-6.6-.21-12.671 5.585-12.79 12.185-.292 5.964 4.129 11.817 10.034 12.953 5.47 1.198 11.584-1.613 14.025-6.702 2.525-4.97 1.396-11.585-2.912-15.216-2.282-2.021-5.3-3.216-8.357-3.22zM16 5.021c5.818-.154 11.117 5.082 11.024 10.905.103 5.384-4.23 10.5-9.636 11.043-5.075.667-10.426-2.587-11.885-7.552-1.53-4.73.48-10.428 4.888-12.864A11.083 11.083 0 0116 5.021zm1.78 4.093v3.555H9.785v6.714h7.994v3.554l5.829-6.911-5.83-6.912zm.974 2.584l3.61 4.295-3.61 4.294v-1.933h-7.88v-4.688h7.88v-1.968z"
  })));

  function _extends$Q() { _extends$Q = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$Q.apply(this, arguments); }
  var IntermediateEventCatchMessageIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$Q({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.975.049C8.195-.11.935 6.286.125 14.03c-.855 6.55 2.741 13.46 8.74 16.314 5.666 2.847 13.012 1.99 17.71-2.33 4.745-4.162 6.727-11.243 4.532-17.206C29.09 4.93 23.445.453 17.201.095c-.408-.03-.817-.046-1.226-.046zm-.181 1.724c7.134-.269 13.84 5.68 14.399 12.804.686 6.283-3.267 12.792-9.283 14.862-5.847 2.162-13.025.06-16.557-5.141C.728 19.22.872 11.725 4.985 6.962c2.632-3.171 6.671-5.174 10.809-5.19zm.283 1.553c-6.6-.21-12.671 5.585-12.79 12.185-.292 5.964 4.129 11.817 10.034 12.953 5.47 1.198 11.584-1.613 14.025-6.702 2.525-4.97 1.396-11.585-2.912-15.216-2.282-2.021-5.3-3.216-8.357-3.22zM16 5.021c5.818-.154 11.117 5.082 11.024 10.905.103 5.384-4.23 10.5-9.636 11.043-5.075.667-10.426-2.587-11.885-7.552-1.53-4.73.48-10.428 4.888-12.864A11.083 11.083 0 0116 5.021zm-7.245 5.475v11.06h14.502v-11.06H8.754zm3.222 1.728h8.057c-1.427.878-2.854 2.806-4.281 3.016l-3.776-3.016zm9.554 1.017v6.587H10.48V13.24l5.524 4.414 5.526-4.414z"
  })));

  function _extends$P() { _extends$P = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$P.apply(this, arguments); }
  var IntermediateEventCatchMultipleIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$P({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.975.003C8.195-.156.935 6.24.125 13.985c-.855 6.55 2.741 13.46 8.74 16.314 5.666 2.847 13.012 1.99 17.71-2.33 4.745-4.162 6.727-11.243 4.532-17.206C29.09 4.884 23.445.407 17.201.049c-.408-.03-.817-.046-1.226-.046zm-.181 1.724c7.134-.269 13.84 5.68 14.399 12.804.686 6.283-3.267 12.792-9.283 14.862-5.847 2.162-13.025.06-16.557-5.141C.728 19.174.872 11.679 4.985 6.916c2.632-3.171 6.671-5.174 10.809-5.19zm.283 1.553c-6.6-.21-12.671 5.585-12.79 12.185-.292 5.964 4.129 11.817 10.034 12.953 5.47 1.198 11.584-1.613 14.025-6.702 2.525-4.97 1.396-11.585-2.912-15.216-2.282-2.021-5.3-3.216-8.357-3.22zM16 4.975c5.818-.154 11.117 5.082 11.024 10.905.103 5.384-4.23 10.5-9.636 11.043-5.075.667-10.426-2.587-11.885-7.552-1.53-4.73.48-10.428 4.888-12.864A11.083 11.083 0 0116 4.975zm.006 3.073l-7.62 5.531 2.91 8.95h9.42l2.91-8.95-7.62-5.53zm0 1.067l6.604 4.794-2.523 7.757h-8.162l-2.522-7.757 6.603-4.794z"
  })));

  function _extends$O() { _extends$O = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$O.apply(this, arguments); }
  var IntermediateEventCatchNonInterruptingConditionIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$O({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M10.638 9.563V23.056h10.724V9.563H10.638zm.863.866h8.995v11.76H11.5V10.43zm.928 1.324v.862h7.139v-.862h-7.14zm0 2.605v.866h7.139v-.866h-7.14zm0 3.01v.863h7.139v-.863h-7.14zm0 2.72v.863h7.139v-.864h-7.14zM15.999.308h-.004l-.188.001h-.011l-.188.004h-.011L15.41.32h-.011l-.187.008h-.005L15.2.33l-.187.01h-.005l-.005.001-.187.013h-.011L14.62.37h-.01l-.186.018h-.011l-.185.02-.005.001h-.006l-.185.022-.005.001h-.005l-.185.025h-.005l-.005.001-.185.027h-.005l-.005.001-.184.029h-.005l-.005.001-.183.031-.006.001-.005.001-.182.033-.006.001-.005.001-.182.035-.005.001-.005.001-.182.038h-.005l-.005.002-.181.04h-.005l-.005.002-.18.042-.006.001-.005.001-.18.044-.005.002h-.005l-.17.045-.152.054-.139.082-.121.106-.1.127-.074.143-.046.155-.017.16.013.16.043.156.07.145.097.13.119.108.137.085.15.058.159.03.16-.001.133-.023.165-.043.168-.041.171-.04.171-.037.172-.036.17-.033.173-.03.17-.03.177-.027.171-.025.175-.022.175-.02.175-.02.176-.016.175-.014.177-.012.176-.01.177-.007.174-.006.177-.003.178-.001h.177l.178.004.174.006.177.007.176.01.177.012.175.014.176.017.175.018.175.02.175.023.171.025.176.027.17.03.174.03.17.033.171.036.154.033.16.02.161-.01.156-.04.146-.069.131-.094.111-.117.087-.135.061-.15.032-.158.002-.16-.027-.16-.057-.15L20 1.023l-.108-.12-.128-.097-.145-.073-.128-.038-.158-.035-.005-.001-.005-.001L19.14.62h-.005l-.005-.002-.182-.035h-.006L18.938.58l-.182-.033h-.006l-.005-.002-.183-.03-.005-.001-.006-.001-.183-.029h-.005l-.006-.001-.184-.027h-.005l-.005-.001-.185-.024h-.005L17.968.43 17.783.41l-.006-.001h-.005l-.185-.02h-.006l-.005-.001L17.39.37h-.005L17.38.368l-.187-.015h-.005l-.005-.001-.187-.013h-.011L16.8.328h-.011L16.6.32h-.011l-.187-.006h-.011L16.204.31h-.011L16.005.31H16zm9.016 2.935l-.16.004-.158.033-.15.062-.134.09-.116.111-.093.132-.067.147-.038.156-.01.161.022.16.05.153.078.141.103.124.102.087.045.034.142.106.137.105.14.11.136.11.135.112.134.115.134.117.13.115.132.122.128.12.127.122.126.125.124.126.124.128.121.13.118.128.118.132.117.133.113.134.113.136.11.136.109.137.109.142.104.14.103.14.101.142.1.144.099.146.095.145.094.147.093.15.092.15.087.149.087.15.084.152.084.155.08.152.08.155.04.081.084.138.11.119.128.096.145.072.155.043.16.013.16-.016.155-.046.144-.074.127-.099.106-.12.083-.14.055-.151.026-.16-.004-.16-.034-.158-.05-.124-.042-.085-.002-.004-.003-.005-.084-.165-.002-.004-.003-.005-.086-.164-.002-.004-.003-.005-.088-.162-.002-.005-.003-.005-.09-.161-.002-.005-.003-.004-.092-.16-.003-.005-.002-.005-.094-.16-.003-.004-.003-.004-.096-.159-.002-.004-.003-.005-.098-.157-.003-.004-.003-.005-.1-.156-.003-.004-.003-.005-.101-.154-.003-.005-.003-.004-.104-.154-.003-.004-.003-.005-.106-.152-.003-.005-.003-.004-.108-.151-.003-.004-.003-.005-.11-.15-.003-.004-.003-.004-.111-.15-.004-.003-.003-.005-.113-.147-.004-.004-.003-.005-.115-.146-.004-.004-.003-.004-.117-.145-.004-.004-.003-.004-.12-.144-.003-.004-.003-.004-.121-.142-.004-.004-.003-.004-.123-.141-.003-.004-.004-.004-.125-.14-.003-.004-.004-.004-.127-.138-.003-.004-.004-.004-.128-.136-.004-.004-.004-.004-.13-.135-.004-.004-.004-.004-.132-.134-.003-.004-.004-.003-.134-.133-.004-.003-.004-.004-.135-.13-.004-.004-.004-.004-.136-.128-.004-.004-.004-.004-.138-.126-.004-.004-.004-.003-.14-.125-.004-.004-.004-.003-.14-.123-.005-.004-.004-.003-.142-.121-.004-.004-.004-.003-.144-.12-.004-.003-.004-.003-.145-.117-.004-.004-.004-.003-.147-.115-.004-.004-.004-.003-.148-.113-.004-.003-.004-.004-.149-.111-.004-.003-.004-.004-.05-.036-.14-.083-.15-.055-.16-.027zm-18.381.344l-.161.008-.157.037-.147.066-.111.074-.04.032-.005.003-.004.004-.145.117-.004.003-.004.004-.144.119-.004.003-.004.004-.142.12-.004.004-.004.004-.141.123-.004.003-.004.004-.14.125-.004.003-.004.004-.138.126-.004.004-.004.004-.136.128-.004.004-.004.004-.135.13-.004.004-.004.003-.134.133-.004.003L4.682 5l-.132.134-.003.004-.004.004-.13.135-.004.004-.004.004-.128.136-.004.004-.004.004-.126.138-.004.004-.003.004-.125.14-.004.004-.003.004-.123.14-.004.005-.003.004-.121.142-.004.004-.003.004-.12.144-.003.004-.003.004-.117.145-.004.004-.003.004-.115.146-.004.005-.003.004-.113.147-.003.005-.004.004-.111.149-.003.004-.004.004-.11.15-.002.005-.003.004-.108.151-.003.004-.003.005-.106.152-.003.005-.003.004-.104.154-.003.004-.003.005-.102.154-.003.005-.002.004-.1.156-.003.005-.003.004-.098.157-.003.005-.003.004-.096.159-.002.004-.003.005-.094.16-.003.004-.002.004-.092.16-.003.005-.003.005-.09.161-.002.005-.003.005-.088.162-.002.005-.003.004-.086.164-.002.005-.002.004-.084.165-.003.005-.002.004-.082.166-.002.004-.003.005-.08.167-.002.004-.002.005-.078.168-.002.004-.002.005-.045.1-.053.153-.023.16.007.16.037.157.065.148.092.132.114.114.134.09.148.064.157.035.161.006.16-.025.152-.054.14-.08.121-.106.1-.126.065-.118.043-.095.074-.16.075-.155.077-.157.08-.155.08-.152.083-.155.085-.152.086-.15.088-.149.091-.15.094-.15.094-.147.095-.145.099-.146.1-.144.1-.142.104-.14.104-.14.11-.142.107-.137.11-.136.114-.136.113-.134.117-.133.118-.132.117-.129.122-.13.124-.127.123-.126.127-.125.127-.122.128-.12.132-.122.13-.115.133-.117.135-.115.135-.111.136-.11.037-.03.117-.11.094-.132.068-.146.04-.156.01-.161-.02-.16-.05-.154-.076-.141-.102-.125-.123-.104-.14-.08-.153-.051-.16-.023zM16 3.595h-.005l-.148.001h-.01l-.147.003h-.011l-.147.005h-.011l-.146.007h-.011l-.146.009h-.011l-.146.01h-.005l-.005.001-.146.012h-.011l-.145.014h-.006l-.005.001-.05.006-.158.031-.15.06-.135.088-.117.111-.094.13-.069.147-.04.156-.01.16.019.16.049.154.076.142.102.125.123.105.14.08.152.051.16.023.134-.003.045-.005.135-.013.133-.01.136-.01.135-.007.137-.006.136-.004.136-.003h.274l.136.003.136.004.136.006.136.007.136.01.133.01.135.013.135.014.135.016.134.018.132.018.134.021.133.023.133.024.133.025.13.027.132.03.132.03.129.031.13.034.129.035.129.036.13.04.126.038.128.042.126.042.128.045.127.047.126.047.12.048.127.051.123.052.006.002.147.048.16.021.16-.009.157-.038.147-.067.131-.093.112-.116.089-.135.062-.149.033-.158.004-.16-.027-.16-.055-.151-.083-.139-.107-.12-.127-.099-.118-.063-.004-.001-.005-.003-.005-.002-.133-.056-.005-.002-.005-.002-.134-.054-.004-.002-.005-.002-.135-.053-.005-.002-.005-.002-.135-.051-.005-.002-.005-.002-.135-.05-.005-.001-.005-.002-.137-.048-.005-.001-.005-.002-.137-.046-.005-.002-.005-.002-.137-.044-.005-.002-.005-.001-.138-.043-.006-.002-.005-.001-.138-.042-.005-.001-.005-.002-.14-.04H19.4l-.005-.002-.14-.038-.005-.001-.005-.002-.14-.036-.005-.001-.005-.001-.141-.035-.005-.001-.005-.001-.142-.033-.005-.001-.005-.001-.142-.031-.005-.002h-.005l-.142-.03-.005-.001-.005-.001-.143-.028h-.005l-.005-.002-.143-.025-.006-.001-.005-.001-.143-.024-.005-.001-.006-.001-.143-.022-.006-.001h-.005l-.144-.022h-.005l-.006-.001-.144-.019h-.005l-.006-.001-.144-.017h-.006l-.005-.001-.145-.016h-.011l-.145-.014H17.1l-.005-.001-.146-.012h-.01l-.146-.01-.006-.001h-.005l-.146-.009h-.011l-.147-.006h-.01L16.32 3.6h-.011l-.147-.003h-.011l-.147-.001H16zm-5.482 1.366l-.16.008-.157.037-.123.053-.06.032-.005.002-.004.003-.128.069-.004.002-.005.003-.126.07-.005.003-.004.002-.126.072-.005.003-.004.003-.125.073-.004.003-.005.003-.124.075-.004.003-.005.002-.123.077-.004.003-.005.003-.122.078-.004.003-.005.003-.121.08-.004.002-.005.003-.12.082-.005.003-.004.003-.12.083-.004.003-.004.003-.118.084-.005.003-.004.003-.118.086-.004.003-.004.003-.117.088-.004.003-.004.003-.116.089-.004.003-.004.004-.114.09-.005.003-.004.003-.113.092-.004.004-.004.003-.113.093-.004.004-.004.003-.111.095-.005.003-.004.004-.11.096-.004.004-.004.003-.11.098-.003.003-.004.004-.108.1-.004.003-.004.003-.107.101-.004.004-.004.003-.106.102-.004.004-.003.004-.105.103-.004.004-.004.004-.103.105-.004.004-.004.003-.102.106-.003.004-.004.004-.1.107-.004.004-.004.004-.099.108-.004.004-.003.004-.098.11-.003.003-.004.004-.096.11-.004.005-.003.004-.095.111-.003.004-.004.004-.093.113-.003.004-.004.004-.092.113-.003.004-.003.005-.09.114-.004.004-.003.004-.089.116-.003.004-.003.004-.088.117-.003.004-.003.004-.086.118-.003.004-.003.005-.084.118-.003.004-.003.005-.083.12-.003.003-.003.005-.082.12-.003.005-.002.004-.068.103-.076.142-.048.154-.018.16.011.161.041.156.07.146.095.13.117.11.136.086.15.06.158.03.162.002.158-.03.15-.057.138-.085.119-.109.082-.105.065-.099.075-.11.077-.113.077-.107.08-.11.08-.108.084-.108.083-.105.086-.106.086-.104.088-.104.089-.101.09-.102.093-.101.093-.099.094-.097.095-.096.098-.097.098-.095.099-.093.1-.092.103-.091.101-.089.104-.088.104-.086.106-.086.106-.083.106-.082.109-.082.108-.079.11-.078.11-.076.112-.076.112-.074.113-.072.113-.071.115-.07.115-.068.118-.067.117-.065.12-.065.054-.029.135-.088.116-.111.094-.132.068-.146.04-.156.009-.161-.02-.16-.05-.153-.078-.142-.102-.125-.123-.103-.141-.079-.153-.051-.16-.022zm13.91 2.116l-.162.008-.157.037-.147.066-.132.092-.113.116-.09.134-.063.148-.034.157-.005.162.025.159.055.152.082.138.086.103.09.09.094.098.092.099.093.1.091.103.089.101.088.104.086.104.086.106.083.105.083.108.08.108.081.11.077.107.077.112.075.111.075.114.072.113.071.113.07.114.068.118.067.115.065.118.064.117.062.117.061.121.059.119.059.122.056.121.054.12.055.125.051.123.051.125.048.123.048.127.047.126.044.125.043.128.042.129.039.126.038.13.022.076.058.15.085.137.11.119.129.096.145.07.155.043.16.013.161-.017.154-.046.144-.075.126-.1.106-.12.082-.14.055-.151.025-.16-.005-.16-.026-.132-.023-.082-.002-.005-.001-.005-.042-.139-.001-.005-.002-.005-.043-.138-.001-.005-.002-.005-.044-.137-.002-.005-.002-.005-.046-.137-.002-.005-.001-.005-.048-.137-.002-.005-.002-.005-.05-.135-.001-.005-.002-.005-.051-.135-.002-.005-.002-.005-.053-.135-.002-.005-.002-.005-.054-.133-.002-.005-.002-.005-.057-.133-.002-.005-.002-.005-.057-.132-.003-.005-.002-.005-.06-.132-.001-.005-.002-.004-.061-.132-.003-.004-.002-.005-.063-.13-.002-.005-.002-.005-.064-.13-.003-.004-.002-.005-.066-.129-.002-.004-.003-.005-.067-.128-.002-.005-.003-.004-.069-.128-.002-.004-.003-.005-.07-.126-.003-.005-.003-.004-.072-.126-.002-.005-.003-.004-.074-.125-.002-.004-.003-.005-.075-.124-.003-.004-.003-.005-.076-.123-.003-.004-.003-.005-.078-.122-.003-.004-.003-.005-.08-.121-.003-.004-.003-.005-.081-.12-.003-.005-.003-.004-.083-.12-.003-.004-.003-.004-.084-.118-.003-.005-.003-.004-.086-.118-.003-.004-.004-.004-.087-.117-.003-.004-.003-.004-.09-.116-.002-.004-.004-.004-.09-.114-.003-.005-.004-.004-.091-.113-.004-.004-.003-.004-.094-.113-.003-.004-.003-.004-.095-.111-.004-.004-.003-.004-.096-.11-.004-.005-.003-.004-.098-.11-.004-.003-.003-.004-.1-.108-.003-.004-.004-.004-.1-.107-.004-.004-.004-.004-.102-.106-.003-.003-.004-.004-.093-.095-.124-.103-.14-.08-.153-.05-.16-.023zM4.45 13.135l-.161.002-.158.032-.15.06-.135.088-.118.11-.094.131-.069.146-.035.129-.026.132v.005l-.002.005-.025.143-.001.005-.001.006-.024.143-.001.005-.001.006-.022.143-.001.006-.001.005-.02.144-.001.005-.001.005-.019.145v.005l-.001.006-.017.144v.006l-.001.005-.016.145v.011l-.014.145v.005l-.001.006-.012.146v.01l-.01.146-.001.006v.005l-.009.146v.011l-.007.146v.011l-.004.147v.011l-.003.147v.01l-.002.148v.01l.001.148v.01l.003.147v.011l.005.147v.01l.007.147v.011l.009.146v.011l.01.146v.01l.013.146v.011l.014.145v.005l.001.006.016.145v.011l.018.144v.006l.001.005.019.144v.006l.001.005.021.144v.005l.002.006.022.143v.006l.002.005.024.143v.005l.002.006.025.143.001.005.001.005.028.143.001.005.001.005.03.142v.005l.002.006.03.141.002.005.001.005.033.142v.005l.002.005.035.14v.006l.002.005.036.14.002.005.001.005.038.14.001.005.002.005.04.14v.005l.002.005.042.138.001.006.002.005.042.138.002.005.002.005.017.054.064.148.09.134.114.114.132.092.148.065.157.037.16.007.16-.023.153-.052.14-.08.123-.104.102-.125.076-.142.049-.153.02-.16-.011-.161-.031-.13-.017-.051-.039-.126-.038-.13-.037-.128-.035-.13-.033-.128-.033-.134-.03-.13-.029-.131-.026-.13-.026-.133-.024-.133-.023-.133-.02-.132-.02-.136-.017-.132-.016-.135-.014-.135-.012-.133-.012-.138-.009-.133-.007-.136-.006-.138-.004-.134-.003-.136v-.274l.003-.136.004-.134.006-.139.007-.136.01-.133.01-.138.013-.132.014-.135.016-.135.017-.132.02-.137.02-.13.023-.134.024-.133.024-.126.016-.16-.014-.161-.044-.155-.072-.145-.098-.128-.12-.108-.137-.084-.15-.057-.16-.029zm26.698 1.601l-.161.01-.157.04-.146.067-.131.093-.112.117-.088.135-.061.149-.033.157-.005.134.006.14.006.176.003.177.001.178-.001.177-.003.178-.006.177-.007.176-.01.177-.012.176-.015.176-.016.173-.018.175-.02.175-.024.174-.025.175-.026.17-.03.174-.03.173-.033.17-.036.172-.037.17-.04.17-.042.172-.043.168-.045.166-.048.169-.05.167-.052.168-.053.164-.056.166-.058.166-.06.16-.062.165-.062.158-.066.165-.068.16-.07.16-.07.158-.075.159-.074.155-.079.158-.08.158-.06.15-.03.158-.001.161.029.159.058.15.085.137.108.119.13.097.144.07.156.044.16.013.16-.017.155-.046.143-.074.127-.1.107-.12.07-.115.083-.164.003-.005.002-.004.082-.166.002-.005.003-.004.08-.167.002-.005.002-.004.078-.168.002-.005.002-.004.076-.169.002-.004.002-.005.074-.17.002-.004.002-.005.072-.17.002-.005.002-.005.07-.171.001-.005.002-.005.068-.172.002-.004.002-.005.065-.173.002-.005.002-.005.063-.173.002-.005.002-.005.06-.174.003-.005.001-.005.06-.175.001-.005.002-.005.057-.176.001-.005.002-.005.055-.177.001-.005.002-.005.052-.177.002-.005.001-.005.051-.178.001-.005.002-.005.048-.179.002-.005v-.005l.047-.179.001-.005.002-.005.044-.18v-.005l.002-.005.042-.18.001-.006.001-.005.04-.181.001-.005.001-.005.037-.182.002-.005v-.005l.036-.182v-.006l.002-.005.033-.182v-.006l.002-.005.03-.183.001-.005.001-.005.029-.184v-.005l.001-.006.027-.184v-.005l.001-.005.024-.185v-.005l.001-.005.022-.185v-.006l.001-.005.02-.185v-.006l.001-.005.017-.186v-.005l.001-.005.015-.187v-.005l.001-.005.013-.187v-.01l.01-.187.001-.006v-.005l.009-.187v-.011l.006-.187V16.7l.004-.188v-.011l.001-.188v-.01l-.001-.188v-.011l-.004-.188v-.011l-.006-.187v-.011l-.007-.145-.022-.16-.05-.152-.08-.141-.103-.124-.125-.102-.141-.077-.153-.05-.16-.02zm-30.21.572l-.161.001-.158.032-.15.06-.136.087-.117.11-.095.131-.068.146-.04.156-.012.133-.001.14v.01l.001.188v.011l.004.188v.011l.006.187v.011l.008.187v.011l.011.187v.005l.001.005.013.187v.01l.016.187v.01l.018.186v.011l.02.185.001.005v.006l.022.185.001.005v.005l.025.185v.005l.001.005.027.184v.006l.001.005.029.184v.005l.001.005.031.183.001.005.001.006.033.182.001.005.001.006.035.182.001.005.001.005.038.182v.005l.002.005.04.181v.005l.002.005.042.18.001.006.001.005.044.18.002.005v.005l.047.18.001.004.002.005.048.179.002.005.001.005.05.178.002.005.001.005.053.177.002.005.001.005.055.177.002.005.001.005.057.176.002.005.001.005.06.175.001.005.002.005.061.174.002.005.002.005.063.173.002.005.002.005.065.173.002.005.002.004.067.172.002.005.002.005.07.171.002.005.002.005.072.17.002.005.002.004.074.17.002.005.002.004.076.169.002.004.002.005.078.168.002.004.002.005.08.167.003.004.002.005.082.166.002.004.003.005.02.04.086.136.11.118.13.095.146.07.156.041.16.012.16-.019.155-.048.142-.075.126-.1.105-.123.08-.14.054-.152.024-.16-.006-.16-.036-.158-.051-.123-.018-.034-.078-.158-.074-.155-.074-.16-.071-.157-.07-.16-.068-.16-.067-.165-.062-.158-.062-.164-.059-.161-.058-.166-.056-.166-.053-.164-.052-.168-.05-.167-.048-.17-.045-.165-.043-.168-.043-.172-.039-.17-.037-.17-.036-.172-.033-.17-.03-.173-.03-.174-.027-.17-.025-.175-.022-.174-.021-.175-.018-.175-.017-.173-.014-.176-.012-.176-.01-.177-.007-.176-.006-.177-.003-.178-.001-.177v-.134l-.013-.16-.044-.156-.072-.144-.097-.129-.12-.108-.137-.085-.15-.057-.159-.028zm26.798 2.024l-.16.007-.157.038-.148.066-.132.092-.113.115-.09.134-.062.148-.03.127-.001.004-.023.134-.024.133-.026.133-.026.13-.03.132-.03.129-.032.134-.033.128-.035.13-.037.128-.038.13-.04.126-.04.128-.044.128-.044.126-.046.126-.048.126-.05.125-.05.125-.051.122-.054.123-.055.122-.056.12-.058.122-.06.12-.061.12-.063.119-.062.116-.067.119-.066.116-.069.115-.069.115-.07.113-.073.113-.074.112-.076.113-.077.112-.077.107-.08.11-.08.107-.085.11-.044.056-.088.135-.06.15-.033.158-.002.16.027.16.057.15.083.138.108.12.128.098.144.072.155.045.16.015.161-.016.155-.044.144-.073.128-.098.09-.099.05-.061.003-.004.003-.005.089-.115.003-.004.003-.005.088-.116.003-.004.003-.005.086-.117.003-.004.003-.005.084-.118.003-.004.003-.005.083-.12.003-.004.003-.004.081-.12.003-.005.003-.004.08-.121.003-.005.003-.004.078-.122.003-.005.003-.004.077-.123.002-.005.003-.004.075-.124.003-.005.003-.004.073-.125.003-.005.003-.004.072-.126.002-.004.003-.005.07-.126.003-.005.002-.005.07-.127.002-.004.002-.005.068-.128.002-.005.002-.004.066-.13.003-.004.002-.005.064-.13.002-.004.003-.005.062-.13.002-.005.003-.005.06-.13.003-.005.002-.005.06-.132.002-.005.002-.005.057-.132.003-.005.002-.005.056-.133.002-.005.002-.005.054-.134.002-.004.002-.005.053-.135.002-.005.002-.005.051-.135.002-.005.002-.005.05-.135.001-.005.002-.005.048-.137.001-.005.002-.005.046-.137.002-.005.002-.005.044-.137.002-.005.002-.005.042-.138.002-.005.001-.006.042-.138.001-.005.002-.005.04-.14v-.005l.002-.005.038-.14.001-.005.002-.005.036-.14.001-.005.001-.005.035-.141.001-.005.001-.005.033-.142.001-.005.001-.005.031-.141.001-.006.002-.005.029-.142v-.005l.002-.005.028-.143v-.005l.002-.005.025-.143.001-.006.001-.005.024-.143.001-.005.001-.006.001-.006.01-.161-.02-.16-.05-.154-.077-.141-.102-.125-.123-.104-.141-.079-.153-.051-.16-.022zM6.841 23.019l-.16.024-.152.053-.14.08-.122.105-.101.126-.076.142-.048.154-.018.16.011.161.041.156.07.146.077.109.04.048.003.004.003.004.095.111.003.004.004.004.096.11.004.005.003.004.098.109.003.004.004.004.1.108.003.004.003.004.101.107.004.004.003.004.102.105.004.004.004.004.103.105.004.004.004.003.105.104.003.004.004.003.106.102.004.004.004.004.107.1.004.004.004.004.108.099.004.003.004.004.11.098.003.003.004.004.11.096.004.003.005.004.11.095.005.003.004.004.113.093.004.003.004.004.113.091.004.004.005.003.114.09.004.004.004.003.116.089.004.003.004.003.117.088.004.003.004.003.118.086.004.003.005.003.118.084.004.003.005.003.119.083.004.003.005.003.12.081.005.003.004.003.121.08.005.003.004.003.122.078.005.003.004.003.123.076.005.003.004.003.124.075.005.003.004.003.125.073.004.003.005.002.126.073.004.002.005.003.126.07.005.003.004.002.128.07.004.002.005.002.128.067.005.003.004.002.13.066.004.002.005.003.13.064.004.002.005.003.13.062.005.002.004.003.132.06.004.003.005.002.132.06.005.002.005.002.132.057.005.002.005.002.133.057.005.002.005.002.133.054.005.002.005.002.13.05.154.045.16.016.16-.015.156-.045.144-.072.128-.098.108-.12.083-.138.057-.15.028-.16-.003-.16-.032-.159-.061-.149-.088-.135-.11-.117-.132-.094-.12-.058-.124-.049-.126-.051-.122-.051-.122-.054-.12-.054-.126-.058-.119-.057-.12-.06-.12-.06-.118-.063-.117-.064-.119-.066-.116-.066-.115-.068-.115-.07-.113-.07-.115-.074-.112-.074-.11-.075-.11-.076-.112-.08-.11-.08-.109-.081-.106-.082-.104-.082-.106-.086-.105-.087-.101-.086-.105-.091-.1-.09-.1-.091-.1-.094-.097-.094-.1-.098-.093-.095-.096-.1-.093-.098-.092-.101-.089-.1-.09-.102-.088-.104-.036-.043-.114-.114-.133-.091-.148-.065-.157-.036-.161-.006zm15.063 2.701l-.16.014-.156.044-.12.057-.06.034-.12.066-.117.064-.118.062-.12.061-.12.06-.118.057-.126.058-.12.054-.122.054-.122.05-.126.052-.125.05-.124.046-.127.047-.125.044-.129.043-.126.04-.13.042-.128.038-.127.035-.13.036-.131.034-.129.031-.132.03-.13.03-.135.027-.133.026-.13.023-.13.022-.137.021-.132.02-.134.017-.132.015-.138.015-.135.013-.133.01-.138.01-.136.007-.134.006-.136.004-.14.003-.16.018-.155.047-.142.076-.127.1-.105.122-.08.14-.054.151-.025.16.006.16.035.158.064.148.09.134.114.114.133.092.147.065.157.036.134.008.145-.002h.011l.147-.005h.01l.147-.007h.011l.146-.009h.011l.146-.01h.005l.005-.001.146-.012h.011l.145-.014h.005l.006-.001.145-.016h.011l.144-.018h.006l.005-.001.144-.02h.011l.144-.021.005-.001h.006l.143-.023.006-.001h.005l.143-.025h.005l.006-.002.143-.026h.005l.005-.002.143-.027.005-.001.005-.001.142-.03h.005l.005-.002.142-.03.005-.002.005-.001.142-.033.005-.001.005-.001.14-.035.006-.001.005-.001.14-.037h.005l.005-.002.14-.038.005-.002h.005l.14-.04.005-.002.005-.001.138-.042.005-.001.006-.002.138-.043.005-.001.005-.002.137-.044.005-.002.005-.002.137-.046.005-.002.005-.001.137-.048.005-.002.005-.002.135-.05.005-.001.005-.002.135-.051.005-.002.005-.002.135-.053.005-.002.004-.002.134-.054.005-.002.005-.002.133-.057.005-.002.005-.002.132-.057.005-.003.005-.002.132-.06.005-.001.004-.002.131-.061.005-.003.005-.002.13-.062.005-.003.005-.002.13-.064.004-.003.005-.002.128-.066.005-.002.005-.003.128-.067.005-.002.004-.003.127-.069.005-.002.005-.003.126-.07.005-.003.004-.003.065-.037.132-.093.112-.115.089-.135.062-.149.034-.157.003-.161-.026-.16-.055-.15-.082-.14-.107-.12-.127-.1-.144-.073-.154-.046-.16-.016zM6.33 27.127l-.16.023-.152.053-.14.08-.122.105-.101.126-.076.142-.048.154-.02.16.012.161.041.156.07.146.094.13.096.093.032.026.004.003.004.004.145.117.004.003.004.004.146.115.005.003.004.004.147.113.005.003.004.004.149.111.004.003.004.003.15.11.005.003.004.003.151.108.004.003.005.003.152.106.005.003.004.003.154.104.004.003.005.003.154.102.005.002.004.003.156.1.005.003.004.003.157.098.005.003.004.002.159.096.004.003.005.003.16.094.004.003.004.002.16.092.005.003.005.002.161.09.005.003.005.002.162.088.005.003.004.002.164.086.005.003.004.002.165.084.005.003.004.002.166.082.004.002.005.003.167.08.004.002.005.002.168.078.004.002.005.002.168.076.005.002.005.002.17.074.004.002.005.002.17.072.005.002.005.002.17.07.006.002.005.001.171.068.005.002.005.002.173.065.005.002.005.002.173.063.005.002.005.002.174.06.005.003.005.001.175.06.005.001.005.002.176.057.005.001.005.002.176.055.006.001.005.002.177.052.005.002.005.001.178.05.005.002.005.002.178.048.006.001.005.002.179.046.005.001.005.002.18.044h.005l.005.002.18.042.006.001.005.001.159.035.16.02.16-.01.157-.04.146-.069.13-.094.112-.117.087-.136.06-.149.033-.158.002-.161-.028-.159-.057-.15-.084-.138-.108-.12-.128-.098-.144-.072-.128-.039-.154-.033-.168-.04-.171-.041-.17-.044-.168-.046-.167-.047-.168-.05-.165-.051-.166-.054-.166-.056-.163-.057-.165-.06-.161-.062-.164-.064-.16-.065-.16-.068-.162-.07-.157-.07-.157-.074-.157-.075-.156-.077-.153-.079-.156-.082-.153-.082-.154-.086-.15-.086-.152-.09-.148-.09-.147-.092-.149-.095-.145-.095-.144-.098-.145-.1-.143-.102-.14-.103-.14-.104-.14-.108-.139-.11-.136-.11-.027-.022-.133-.091-.148-.065-.157-.036-.161-.006zm19.215.087l-.16.01-.157.039-.146.067-.11.076-.064.051-.139.11-.14.108-.14.104-.14.103-.143.101-.145.101-.144.098-.145.095-.149.095-.148.093-.147.089-.152.09-.15.086-.154.086-.153.082-.156.082-.153.079-.156.077-.157.075-.158.073-.157.071-.16.07-.16.068-.161.065-.164.064-.161.061-.165.06-.163.058-.166.056-.166.054-.166.051-.167.05-.167.047-.17.046-.168.044-.171.042-.168.039-.17.037-.11.023-.154.047-.143.075-.126.1-.106.122-.081.139-.054.152-.025.16.006.16.035.158.063.148.09.133.114.115.132.092.148.065.157.037.16.007.133-.016.115-.024.005-.001.005-.001.181-.04h.005l.005-.002.18-.042.006-.001.005-.001.18-.044.005-.002.005-.001.18-.046.004-.002h.005l.179-.05h.005l.005-.002.178-.05.005-.002.005-.002.177-.052.005-.002.005-.001.177-.055.005-.002.005-.001.176-.057.005-.002.005-.002.175-.059.005-.001.005-.002.174-.061.005-.002.005-.002.173-.063.005-.002.005-.002.173-.065.004-.002.005-.002.172-.068.005-.002.005-.002.171-.07.005-.001.005-.002.17-.072.005-.002.004-.002.17-.074.005-.002.004-.002.169-.076.004-.002.005-.002.168-.078.004-.002.005-.003.167-.08.004-.002.005-.002.166-.082.004-.002.005-.003.165-.084.004-.002.005-.003.163-.086.005-.002.005-.003.162-.088.005-.002.005-.003.161-.09.005-.002.004-.003.16-.092.005-.003.005-.002.16-.094.004-.003.004-.003.158-.096.005-.002.004-.003.158-.098.004-.003.005-.003.156-.1.004-.003.004-.003.155-.101.005-.003.004-.003.154-.104.004-.003.004-.003.153-.106.004-.003.005-.003.151-.108.004-.003.005-.003.15-.11.004-.003.004-.003.149-.112.004-.003.004-.003.148-.113.004-.004.004-.003.147-.115.004-.004.004-.003.068-.055.116-.113.092-.132.066-.147.038-.157.008-.16-.022-.16-.05-.153-.08-.14-.103-.125-.124-.102-.142-.077-.153-.05-.16-.02z"
  })));

  function _extends$N() { _extends$N = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$N.apply(this, arguments); }
  var IntermediateEventCatchNonInterruptingEscalationIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$N({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M16.012 9.222c-1.673 4.657-2.735 9.508-4.409 14.164 1.536-1.526 2.874-3.236 4.41-4.762l4.408 4.762c-1.497-4.712-2.911-9.451-4.409-14.164zm.032 2.93c.823 2.588 1.599 5.19 2.421 7.777l-2.42-2.614c-.683.598-2.454 2.886-2.34 2.39.871-2.489 1.448-5.07 2.34-7.552zM16.012.312c-1.448.02-2.93.157-4.302.628-.852.447-.255 1.863.66 1.574 2.255-.608 4.648-.607 6.922-.108.934.075 1.228-1.376.338-1.67C18.451.44 17.227.317 16.012.311zm9.012 2.934c-.913-.104-1.272 1.258-.454 1.648 1.834 1.36 3.293 3.185 4.31 5.22.526.776 1.842.098 1.515-.78a15.522 15.522 0 00-5.06-6.006c-.1-.044-.203-.07-.31-.082zM6.65 3.59c-.762.089-1.24.809-1.805 1.267C3.38 6.295 2.163 8.007 1.37 9.905c-.266.898 1.094 1.484 1.564.675a14.825 14.825 0 014.327-5.56c.476-.515.09-1.419-.612-1.431zm9.362.007c-.698.066-1.689-.16-2.033.635-.282.733.535 1.358 1.217 1.125 1.806-.147 3.63.203 5.293.907.902.255 1.472-1.112.656-1.573-1.6-.735-3.374-1.089-5.133-1.094zm-5.479 1.365c-.835.15-1.517.76-2.21 1.226-1.203.94-2.318 2.061-3.057 3.402-.33.904 1.063 1.552 1.547.723 1.045-1.656 2.596-2.925 4.285-3.873.545-.499.171-1.463-.565-1.478zm13.903 2.115c-.875-.07-1.22 1.173-.501 1.627 1.325 1.34 2.188 3.062 2.748 4.84.468.84 1.869.21 1.557-.699-.604-2.118-1.751-4.097-3.351-5.615a.93.93 0 00-.453-.153zM4.467 13.132c-.822-.07-.996.826-1.046 1.455-.256 1.93-.094 3.933.562 5.769.406.844 1.807.365 1.612-.551a11.498 11.498 0 01-.334-5.808.874.874 0 00-.794-.865zm26.687 1.6c-.746-.037-1.014.785-.879 1.395.043 2.393-.57 4.771-1.66 6.894-.31.884 1.02 1.536 1.53.75a15.632 15.632 0 001.821-8.372.876.876 0 00-.812-.667zm-30.197.571c-.782-.073-1.044.775-.933 1.404.068 2.414.661 4.833 1.809 6.962.534.77 1.842.076 1.505-.798a14.833 14.833 0 01-1.603-6.861.876.876 0 00-.778-.707zm26.787 2.024c-.777-.048-.952.797-1.021 1.392-.354 1.692-1.202 3.231-2.216 4.608-.407.872.925 1.638 1.48.852 1.361-1.733 2.296-3.827 2.582-6.017a.874.874 0 00-.825-.835zM6.857 23.012c-.808.018-1.082 1.122-.47 1.59 1.393 1.607 3.187 2.886 5.194 3.599.91.222 1.43-1.165.598-1.596a11.495 11.495 0 01-4.723-3.396.899.899 0 00-.599-.197zm15.057 2.7c-.81.194-1.504.76-2.325.972-1.203.458-2.5.536-3.758.664-.869.307-.573 1.728.346 1.663 2.201-.034 4.412-.626 6.293-1.778.604-.495.227-1.532-.556-1.521zM6.346 27.118c-.833.008-1.11 1.218-.395 1.617 1.986 1.602 4.358 2.749 6.868 3.226.933.076 1.227-1.376.338-1.67a14.838 14.838 0 01-6.345-3.066.929.929 0 00-.466-.107zm19.208.087c-.766.09-1.241.841-1.922 1.158-1.516.991-3.251 1.58-4.996 2.005-.872.405-.346 1.849.584 1.604 2.543-.526 4.98-1.66 6.963-3.344.47-.52.072-1.42-.63-1.423z"
  })));

  function _extends$M() { _extends$M = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$M.apply(this, arguments); }
  var IntermediateEventCatchNonInterruptingMessageIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$M({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M8.742 10.464v11.072h14.516V10.464H8.742zm3.224 1.73h8.066a69569 69569 0 00-4.034 3.22l-4.032-3.22zm9.565 1.018v6.594H10.469v-6.593L16 17.63l5.532-4.419zM16 0h-.005l-.188.001h-.011l-.188.004h-.011l-.187.006h-.011l-.187.008h-.005L15.2.02l-.187.01h-.005l-.005.001-.187.013h-.011L14.62.06h-.01l-.186.018h-.011l-.185.02-.005.001h-.006l-.185.022-.005.001h-.005l-.185.025h-.005l-.005.001-.185.027h-.005l-.005.001-.184.029h-.005l-.005.001-.183.031-.006.001-.005.001-.182.033-.006.001-.005.001-.182.035-.005.001-.005.001-.182.038h-.005l-.005.002-.181.04h-.005l-.005.002-.18.042-.006.001-.005.001-.18.044-.005.002h-.005l-.17.045-.152.054-.139.082-.121.106-.1.127-.074.143-.046.155-.017.16.013.16.043.156.07.145.097.13.119.108.137.085.15.058.159.03.16-.001.133-.023.165-.043.168-.041.171-.04.171-.037.172-.036.17-.033.173-.03.17-.03.177-.027.171-.025.175-.022.175-.02.175-.02.176-.016.175-.014.177-.012.176-.01.177-.007.174-.006.177-.003L16 1.73h.177l.178.004.174.006.177.007.176.01.177.012.175.014.176.017.175.018.175.02.175.023.171.025.176.027.17.03.174.03.17.033.171.036.154.033.16.02.161-.01.156-.04.146-.069.131-.094.111-.117.087-.135.061-.15.032-.158.002-.16-.027-.16-.057-.15L20 .714l-.108-.12-.128-.097-.145-.073-.128-.038-.158-.035-.005-.001-.005-.001L19.14.31h-.005l-.005-.002-.182-.035h-.006l-.005-.002-.182-.033h-.006l-.005-.002-.183-.03-.005-.001-.006-.001-.183-.029h-.005l-.006-.001-.184-.027h-.005l-.005-.001-.185-.024h-.005L17.968.12 17.783.1l-.006-.001h-.005l-.185-.02h-.006l-.005-.001L17.39.06h-.005L17.38.06l-.187-.015h-.005l-.005-.001-.187-.013h-.011L16.8.02h-.011L16.6.01h-.011l-.187-.006h-.011L16.204 0h-.011L16.005 0H16zm9.015 2.935l-.16.004-.158.033-.15.062-.134.09-.116.111-.093.132-.067.147-.038.156-.01.161.022.16.05.153.078.141.103.124.102.087.045.034.142.106.137.105.14.11.136.11.135.112.134.115.134.117.13.115.132.122.128.12.127.122.126.125.124.126.124.128.121.13.118.128.118.132.117.133.113.134.113.136.11.136.109.137.109.142.104.14.103.14.101.142.1.144.099.146.095.145.094.147.093.15.092.15.087.149.087.15.084.152.084.155.08.152.08.155.04.081.084.138.11.119.128.096.145.072.155.043.16.013.16-.016.155-.046.144-.074.127-.099.106-.12.083-.14.055-.151.026-.16-.004-.16-.034-.158-.05-.124-.042-.085-.002-.004-.003-.005-.084-.165-.002-.004-.003-.005-.086-.164-.002-.004-.003-.005-.088-.162-.002-.005-.003-.005-.09-.161-.002-.005-.003-.004-.092-.16-.003-.005-.002-.005-.094-.16-.003-.004-.003-.004-.096-.159-.002-.004-.003-.005-.098-.157-.003-.004-.003-.005-.1-.156-.003-.004-.003-.005-.101-.154-.003-.005-.003-.004-.104-.154-.003-.004-.003-.005-.106-.152-.003-.005-.003-.004-.108-.151-.003-.004-.003-.005-.11-.15-.003-.004-.003-.004-.111-.15-.004-.003-.003-.005-.113-.147-.004-.004-.003-.005-.115-.146-.004-.004-.003-.004-.117-.145-.004-.004-.003-.004-.12-.144-.003-.004-.003-.004-.121-.142-.004-.004-.003-.004-.123-.141-.003-.004-.004-.004-.125-.14-.003-.004-.004-.004-.127-.138-.003-.004-.004-.004-.128-.136-.004-.004-.004-.004-.13-.135-.004-.004-.004-.004-.132-.134-.003-.004-.004-.003-.134-.133-.004-.003-.004-.004-.135-.13-.004-.004-.004-.004-.136-.128-.004-.004-.004-.004-.138-.126-.004-.004-.004-.003-.14-.125-.004-.004-.004-.003-.14-.123-.005-.004-.004-.003-.142-.121-.004-.004-.004-.003-.144-.12-.004-.003-.004-.003-.145-.117-.004-.004-.004-.003-.147-.115-.004-.004-.004-.003-.148-.113-.004-.003-.004-.004-.149-.111-.004-.003-.004-.004-.05-.036-.14-.083-.15-.055-.16-.027zM6.634 3.28l-.161.008-.157.037-.147.066-.111.074-.04.032-.005.003-.004.004-.145.117-.004.003-.004.004-.144.119-.004.003-.004.004-.142.12-.004.004-.004.004-.141.123-.004.003-.004.004-.14.125-.004.003-.004.004-.138.126-.004.004-.004.004-.136.128-.004.004-.004.004-.135.13-.004.004-.004.003-.134.133-.004.003-.004.004-.132.134-.003.004-.004.004-.13.135-.004.004-.004.004-.128.136-.004.004-.004.004-.126.138-.004.004-.003.004-.125.14-.004.004-.003.004-.123.14-.004.005-.003.004-.121.142-.004.004-.003.004-.12.144-.003.004-.003.004-.117.145-.004.004-.003.004-.115.146-.004.005-.003.004-.113.147-.003.005-.004.004-.111.149-.003.004-.004.004-.11.15-.002.005-.003.004-.108.151-.003.004-.003.005-.106.152-.003.005-.003.004-.104.154-.003.004-.003.005-.102.154-.003.005-.002.004-.1.156-.003.005-.003.004-.098.157-.003.005-.003.004-.096.159-.002.004-.003.005-.094.16-.003.004-.002.004-.092.16-.003.005-.003.005-.09.161-.002.005-.003.005-.088.162-.002.005-.003.004-.086.164-.002.005-.002.004-.084.165-.003.005-.002.004-.082.166-.002.004-.003.005-.08.167-.002.004-.002.005-.078.168-.002.004-.002.005-.045.1-.053.153-.023.16.007.16.037.157.065.148.092.132.114.114.134.09.148.064.157.035.161.006.16-.025.152-.054.14-.08.121-.106.1-.126.065-.118.043-.095.074-.16.075-.155.077-.157.08-.155.08-.152.083-.155.085-.152.086-.15.088-.149.091-.15.094-.15.094-.147.095-.145.099-.146.1-.144.1-.142.104-.14.104-.14.11-.142.107-.137.11-.136.114-.136.113-.134.117-.133.118-.132.117-.129.122-.13.124-.127.123-.126.127-.125.127-.122.128-.12.132-.122.13-.115.133-.117.135-.115.135-.111.136-.11.037-.03.117-.11.094-.132.068-.146.04-.156.01-.161-.02-.16-.05-.154-.076-.141-.102-.125-.123-.104-.14-.08-.153-.051-.16-.023zM16 3.286h-.005l-.148.001h-.01l-.147.003h-.011l-.147.005h-.011l-.146.007h-.011l-.146.009h-.011l-.146.01h-.005l-.005.001-.146.012h-.011l-.145.014h-.006l-.005.001-.05.006-.158.031-.15.06-.135.088-.117.111-.094.13-.069.147-.04.156-.01.16.019.16.049.154.076.142.102.125.123.105.14.08.152.051.16.023.134-.003.045-.005.135-.013.133-.01.136-.01.135-.007.137-.006.136-.004.136-.003h.274l.136.003.136.004.136.006.136.007.136.01.133.01.135.013.135.014.135.016.134.018.132.018.134.021.133.023.133.024.133.025.13.027.132.03.132.03.129.031.13.034.129.035.129.036.13.04.126.038.128.042.126.042.128.045.127.047.126.047.12.048.127.051.123.052.006.002.147.048.16.021.16-.009.157-.038.147-.067.131-.093.112-.116.089-.135.062-.149.033-.158.004-.16-.027-.16-.055-.151-.083-.139-.107-.12-.127-.099-.118-.063-.004-.001-.005-.003-.005-.002-.133-.056-.005-.002-.005-.002-.134-.054-.004-.002-.005-.002-.135-.053-.005-.002-.005-.002-.135-.051-.005-.002-.005-.002-.135-.05-.005-.001-.005-.002-.137-.048-.005-.001-.005-.002-.137-.046-.005-.002-.005-.002-.137-.044-.005-.002-.005-.001-.138-.043-.006-.002-.005-.001-.138-.042-.005-.001-.005-.002-.14-.04H19.4l-.005-.002-.14-.038-.005-.001-.005-.002-.14-.036-.005-.001-.005-.001-.141-.035-.005-.001-.005-.001-.142-.033-.005-.001-.005-.001-.142-.031-.005-.002h-.005l-.142-.03-.005-.001-.005-.001-.143-.028h-.005l-.005-.002-.143-.025-.006-.001-.005-.001-.143-.024-.005-.001-.006-.001-.143-.022-.006-.001h-.005l-.144-.022h-.005l-.006-.001-.144-.019h-.005l-.006-.001-.144-.017h-.006l-.005-.001-.145-.016h-.011l-.145-.014H17.1l-.005-.001-.146-.012h-.01l-.146-.01-.006-.001h-.005l-.146-.009h-.011l-.147-.006h-.01l-.147-.005h-.011l-.147-.003h-.011l-.147-.001H16zm-5.482 1.366l-.16.008-.157.037-.123.053-.06.032-.005.002-.004.003-.128.069-.004.002-.005.003-.126.07-.005.003-.004.002-.126.072-.005.003-.004.003-.125.073-.004.003-.005.003-.124.075-.004.003-.005.002-.123.077-.004.003-.005.003-.122.078-.004.003-.005.003-.121.08-.004.002-.005.003-.12.082-.005.003-.004.003-.12.083-.004.003-.004.003-.118.084-.005.003-.004.003-.118.086-.004.003-.004.003-.117.088-.004.003-.004.003-.116.089-.004.003-.004.004-.114.09-.005.003-.004.003-.113.092-.004.004-.004.003-.113.093-.004.004-.004.003-.111.095-.005.003-.004.004-.11.096-.004.004-.004.003-.11.098-.003.003-.004.004-.108.1-.004.003-.004.003-.107.101-.004.004-.004.003-.106.102-.004.004-.003.004-.105.103-.004.004-.004.004-.103.105-.004.004-.004.003-.102.106-.003.004-.004.004-.1.107-.004.004-.004.004-.099.108-.004.004-.003.004-.098.11-.003.003-.004.004-.096.11-.004.005-.003.004-.095.111-.003.004-.004.004-.093.113-.003.004-.004.004-.092.113-.003.004-.003.005-.09.114-.004.004-.003.004-.089.116-.003.004-.003.004-.088.117-.003.004-.003.004-.086.118-.003.004-.003.005-.084.118-.003.004-.003.005-.083.12-.003.003-.003.005-.082.12-.003.005-.002.004-.068.103-.076.142-.048.154-.018.16.011.161.041.156.07.146.095.13.117.11.136.086.15.06.158.03.162.002.158-.03.15-.057.138-.085.119-.109.082-.105.065-.099.075-.11.077-.113.077-.107.08-.11.08-.108.084-.108.083-.105.086-.106.086-.104.088-.104.089-.101.09-.102.093-.101.093-.099.094-.097.095-.096.098-.097.098-.095.099-.093.1-.092.103-.091.101-.089.104-.088.104-.086.106-.086.106-.083.106-.082.109-.082.108-.079.11-.078.11-.076.112-.076.112-.074.113-.072.113-.071.115-.07.115-.068.118-.067.117-.065.12-.065.054-.029.135-.088.116-.111.094-.132.068-.146.04-.156.009-.161-.02-.16-.05-.153-.078-.142-.102-.125-.123-.103-.141-.079-.153-.051-.16-.022zm13.91 2.116l-.162.008-.157.037-.147.066-.132.092-.113.116-.09.134-.063.148-.034.157-.005.162.025.159.055.152.082.138.086.103.09.09.094.098.092.099.093.1.091.103.089.101.088.104.086.104.086.106.083.105.083.108.08.108.081.11.077.107.077.112.075.111.075.114.072.113.071.113.07.114.068.118.067.115.065.118.064.117.062.117.061.121.059.119.059.122.056.121.054.12.055.125.051.123.051.125.048.123.048.127.047.126.044.125.043.128.042.129.039.126.038.13.022.076.058.15.085.137.11.119.129.096.145.07.155.043.16.013.161-.017.154-.046.144-.075.126-.1.106-.12.082-.14.055-.151.025-.16-.005-.16-.026-.132-.023-.082-.002-.005-.001-.005-.042-.139-.001-.005-.002-.005-.043-.138-.001-.005-.002-.005-.044-.137-.002-.005-.002-.005-.046-.137-.002-.005-.001-.005-.048-.137-.002-.005-.002-.005-.05-.135-.001-.005-.002-.005-.051-.135-.002-.005-.002-.005-.053-.135-.002-.005-.002-.005-.054-.133-.002-.005-.002-.005-.057-.133-.002-.005-.002-.005-.057-.132-.003-.005-.002-.005-.06-.132-.001-.005-.002-.004-.061-.132-.003-.004-.002-.005-.063-.13-.002-.005-.002-.005-.064-.13-.003-.004-.002-.005-.066-.129-.002-.004-.003-.005-.067-.128-.002-.005-.003-.004-.069-.128-.002-.004-.003-.005-.07-.126-.003-.005-.003-.004-.072-.126-.002-.005-.003-.004-.074-.125-.002-.004-.003-.005-.075-.124-.003-.004-.003-.005-.076-.123-.003-.004-.003-.005-.078-.122-.003-.004-.003-.005-.08-.121-.003-.004-.003-.005-.081-.12-.003-.005-.003-.004-.083-.12-.003-.004-.003-.004-.084-.118-.003-.005-.003-.004-.086-.118-.003-.004-.004-.004-.087-.117-.003-.004-.003-.004-.09-.116-.002-.004-.004-.004-.09-.114-.003-.005-.004-.004-.091-.113-.004-.004-.003-.004-.094-.113-.003-.004-.003-.004-.095-.111-.004-.004-.003-.004-.096-.11-.004-.005-.003-.004-.098-.11-.004-.003-.003-.004-.1-.108-.003-.004-.004-.004-.1-.107-.004-.004-.004-.004-.102-.106-.003-.003-.004-.004-.093-.095-.124-.103-.14-.08-.153-.05-.16-.023zM4.45 12.826l-.161.002-.158.032-.15.06-.135.088-.118.11-.094.131-.069.146-.035.129-.026.132v.005l-.002.005-.025.143-.001.005-.001.006-.024.143-.001.005-.001.006-.022.143-.001.006-.001.005-.02.144-.001.005-.001.005-.019.145v.005l-.001.006-.017.144v.006l-.001.005-.016.145v.011l-.014.145v.005l-.001.006-.012.146v.01l-.01.146-.001.006v.005l-.009.146v.011l-.007.146v.011l-.004.147v.011l-.003.147v.01l-.002.148v.01l.001.148v.01l.003.147v.011l.005.147v.01l.007.147v.011l.009.146v.011l.01.146v.01l.013.146v.011l.014.145v.005l.001.006.016.145v.011l.018.144v.006l.001.005.019.144v.006l.001.005.021.144v.005l.002.006.022.143v.006l.002.005.024.143v.005l.002.006.025.143.001.005.001.005.028.143.001.005.001.005.03.142v.005l.002.006.03.141.002.005.001.005.033.142v.005l.002.005.035.14v.006l.002.005.036.14.002.005.001.005.038.14.001.005.002.005.04.14v.005l.002.005.042.138.001.006.002.005.042.138.002.005.002.005.017.054.064.148.09.134.114.114.132.092.148.065.157.037.16.007.16-.023.153-.052.14-.08.123-.104.102-.125.076-.142.049-.153.02-.16-.011-.161-.031-.13-.017-.051-.039-.126-.038-.13-.037-.128-.035-.13-.033-.128-.033-.134-.03-.13-.029-.131-.026-.13-.026-.133-.024-.133-.023-.133-.02-.132-.02-.136-.017-.132-.016-.135-.014-.135-.012-.133-.012-.138-.009-.133-.007-.136-.006-.138-.004-.134-.003-.136v-.274l.003-.136.004-.134.006-.139.007-.136.01-.133.01-.138.013-.132.014-.135.016-.135.017-.132.02-.137.02-.13.023-.134.024-.133.024-.126.016-.16-.014-.161-.044-.155-.072-.145-.098-.128-.12-.108-.137-.084-.15-.057-.16-.029zm26.698 1.601l-.161.01-.157.04-.146.067-.131.093-.112.117-.088.135-.061.149-.033.157-.005.134.006.14.006.176.003.177.001.178-.001.177-.003.178-.006.177-.007.176-.01.177-.012.176-.015.176-.016.173-.018.175-.02.175-.024.174-.025.175-.026.17-.03.174-.03.173-.033.17-.036.172-.037.17-.04.17-.042.172-.043.168-.045.166-.048.169-.05.167-.052.168-.053.164-.056.166-.058.166-.06.16-.062.165-.062.158-.066.165-.068.16-.07.16-.07.158-.075.159-.074.155-.079.158-.08.158-.06.15-.03.158-.001.161.029.159.058.15.085.137.108.119.13.097.144.07.156.044.16.013.16-.017.155-.046.143-.074.127-.1.107-.12.07-.115.083-.164.003-.005.002-.004.082-.166.002-.005.003-.004.08-.167.002-.005.002-.004.078-.168.002-.005.002-.004.076-.169.002-.004.002-.005.074-.17.002-.004.002-.005.072-.17.002-.005.002-.005.07-.171.001-.005.002-.005.068-.172.002-.004.002-.005.065-.173.002-.005.002-.005.063-.173.002-.005.002-.005.06-.174.003-.005.001-.005.06-.175.001-.005.002-.005.057-.176.001-.005.002-.005.055-.177.001-.005.002-.005.052-.177.002-.005.001-.005.051-.178.001-.005.002-.005.048-.179.002-.005v-.005l.047-.179.001-.005.002-.005.044-.18v-.005l.002-.005.042-.18.001-.006.001-.005.04-.181.001-.005.001-.005.037-.182.002-.005v-.005l.036-.182v-.006l.002-.005.033-.182v-.006l.002-.005.03-.183.001-.005.001-.005.029-.184v-.005l.001-.006.027-.184v-.005l.001-.005.024-.185v-.005l.001-.005.022-.185v-.006l.001-.005.02-.185v-.006l.001-.005.017-.186v-.005l.001-.005.015-.187v-.005l.001-.005.013-.187v-.01l.01-.187.001-.006v-.005l.009-.187v-.011l.006-.187v-.011l.004-.188v-.011l.001-.188v-.01l-.001-.188v-.011l-.004-.188v-.011l-.006-.187v-.011l-.007-.145-.022-.16-.05-.152-.08-.141-.103-.124-.125-.102-.141-.077-.153-.05-.16-.02zM.938 15L.777 15l-.158.032-.15.06-.136.087-.117.11-.095.131-.068.146-.04.156-.012.133-.001.14v.01l.001.188v.011l.004.188v.011l.006.187v.011l.008.187v.011l.011.187v.005l.001.005.013.187v.01l.016.187v.01l.018.186v.011l.02.185.001.005v.006l.022.185.001.005v.005l.025.185v.005l.001.005.027.184v.006l.001.005.029.184v.005l.001.005.031.183.001.005.001.006.033.182.001.005.001.006.035.182.001.005.001.005.038.182v.005l.002.005.04.181v.005l.002.005.042.18.001.006.001.005.044.18.002.005v.005l.047.18.001.004.002.005.048.179.002.005.001.005.05.178.002.005.001.005.053.177.002.005.001.005.055.177.002.005.001.005.057.176.002.005.001.005.06.175.001.005.002.005.061.174.002.005.002.005.063.173.002.005.002.005.065.173.002.005.002.004.067.172.002.005.002.005.07.171.002.005.002.005.072.17.002.005.002.004.074.17.002.005.002.004.076.169.002.004.002.005.078.168.002.004.002.005.08.167.003.004.002.005.082.166.002.004.003.005.02.04.086.136.11.118.13.095.146.07.156.041.16.012.16-.019.155-.048.142-.075.126-.1.105-.123.08-.14.054-.152.024-.16-.006-.16-.036-.158-.051-.123-.018-.034-.078-.158L3.1 22.1l-.074-.16-.071-.157-.07-.16-.068-.16-.067-.165-.062-.158-.062-.164-.059-.161-.058-.166-.056-.166-.053-.164-.052-.168-.05-.167-.048-.17-.045-.165-.043-.168-.043-.172-.039-.17-.037-.17-.036-.172-.033-.17-.03-.173-.03-.174-.027-.17-.025-.175-.022-.174-.021-.175-.018-.175-.017-.173-.014-.176-.012-.176-.01-.177-.007-.176-.006-.177-.003-.178L1.73 16v-.134l-.013-.16-.044-.156-.072-.144-.097-.129-.12-.108-.137-.085-.15-.057L.938 15zm26.798 2.024l-.16.007-.157.038-.148.066-.132.092-.113.115-.09.134-.062.148-.03.127-.001.004-.023.134-.024.133-.026.133-.026.13-.03.132-.03.129-.032.134-.033.128-.035.13-.037.128-.038.13-.04.126-.04.128-.044.128-.044.126-.046.126-.048.126-.05.125-.05.125-.051.122-.054.123-.055.122-.056.12-.058.122-.06.12-.061.12-.063.119-.062.116-.067.119-.066.116-.069.115-.069.115-.07.113-.073.113-.074.112-.076.113-.077.112-.077.107-.08.11-.08.107-.085.11-.044.056-.088.135-.06.15-.033.158-.002.16.027.16.057.15.083.138.108.12.128.098.144.072.155.045.16.015.161-.016.155-.044.144-.073.128-.098.09-.099.05-.061.003-.004.003-.005.089-.115.003-.004.003-.005.088-.116.003-.004.003-.005.086-.117.003-.004.003-.005.084-.118.003-.004.003-.005.083-.12.003-.004.003-.004.081-.12.003-.005.003-.004.08-.121.003-.005.003-.004.078-.122.003-.005.003-.004.077-.123.002-.005.003-.004.075-.124.003-.005.003-.004.073-.125.003-.005.003-.004.072-.126.002-.004.003-.005.07-.126.003-.005.002-.005.07-.127.002-.004.002-.005.068-.128.002-.005.002-.004.066-.13.003-.004.002-.005.064-.13.002-.004.003-.005.062-.13.002-.005.003-.005.06-.13.003-.005.002-.005.06-.132.002-.005.002-.005.057-.132.003-.005.002-.005.056-.133.002-.005.002-.005.054-.134.002-.004.002-.005.053-.135.002-.005.002-.005.051-.135.002-.005.002-.005.05-.135.001-.005.002-.005.048-.137.001-.005.002-.005.046-.137.002-.005.002-.005.044-.137.002-.005.002-.005.042-.138.002-.005.001-.006.042-.138.001-.005.002-.005.04-.14V19.4l.002-.005.038-.14.001-.005.002-.005.036-.14.001-.005.001-.005.035-.141.001-.005.001-.005.033-.142.001-.005.001-.005.031-.141.001-.006.002-.005.029-.142v-.005l.002-.005.028-.143v-.005l.002-.005.025-.143.001-.006.001-.005.024-.143.001-.005.001-.006.001-.006.01-.161-.02-.16-.05-.154-.077-.141-.102-.125-.123-.104-.141-.079-.153-.051-.16-.022zM6.841 22.71l-.16.024-.152.053-.14.08-.122.105-.101.126-.076.142-.048.154-.018.16.011.161.041.156.07.146.077.109.04.048.003.004.003.004.095.111.003.004.004.004.096.11.004.005.003.004.098.109.003.004.004.004.1.108.003.004.003.004.101.107.004.004.003.004.102.105.004.004.004.004.103.105.004.004.004.003.105.104.003.004.004.003.106.102.004.004.004.004.107.1.004.004.004.004.108.099.004.003.004.004.11.098.003.003.004.004.11.096.004.003.005.004.11.095.005.003.004.004.113.093.004.003.004.004.113.091.004.004.005.003.114.09.004.004.004.003.116.089.004.003.004.003.117.088.004.003.004.003.118.086.004.003.005.003.118.084.004.003.005.003.119.083.004.003.005.003.12.081.005.003.004.003.121.08.005.003.004.003.122.078.005.003.004.003.123.076.005.003.004.003.124.075.005.003.004.003.125.073.004.003.005.002.126.073.004.002.005.003.126.07.005.003.004.002.128.07.004.002.005.002.128.067.005.003.004.002.13.066.004.002.005.003.13.064.004.002.005.003.13.062.005.002.004.003.132.06.004.003.005.002.132.06.005.002.005.002.132.057.005.002.005.002.133.057.005.002.005.002.133.054.005.002.005.002.13.05.154.045.16.016.16-.015.156-.045.144-.072.128-.098.108-.12.083-.138.057-.15.028-.16-.003-.16-.032-.159-.061-.149-.088-.135-.11-.117-.132-.094-.12-.058-.124-.049-.126-.051-.122-.051-.122-.054-.12-.054-.126-.058-.119-.057-.12-.06-.12-.06-.118-.063-.117-.064-.119-.066-.116-.066-.115-.068-.115-.07-.113-.07-.115-.074-.112-.074-.11-.075-.11-.076-.112-.08-.11-.08-.109-.081-.106-.082-.104-.082-.106-.086-.105-.087-.101-.086-.105-.091-.1-.09-.1-.091-.1-.094-.097-.094-.1-.098-.093-.095-.096-.1-.093-.098-.092-.101-.089-.1-.09-.102-.088-.104-.036-.043-.114-.114-.133-.091-.148-.065-.157-.036-.161-.006zm15.063 2.701l-.16.014-.156.044-.12.057-.06.034-.12.066-.117.064-.118.062-.12.061-.12.06-.118.057-.126.058-.12.054-.122.054-.122.05-.126.052-.125.05-.124.046-.127.047-.125.044-.129.043-.126.04-.13.042-.128.038-.127.035-.13.036-.131.034-.129.031-.132.03-.13.03-.135.027-.133.026-.13.023-.13.022-.137.021-.132.02-.134.017-.132.015-.138.015-.135.013-.133.01-.138.01-.136.007-.134.006-.136.004-.14.003-.16.018-.155.047-.142.076-.127.1-.105.122-.08.14-.054.151-.025.16.006.16.035.158.064.148.09.134.114.114.133.092.147.065.157.036.134.008.145-.002h.011l.147-.005h.01l.147-.007h.011l.146-.009h.011l.146-.01h.005l.005-.001.146-.012h.011l.145-.014h.005l.006-.001.145-.016h.011l.144-.018h.006l.005-.001.144-.02h.011l.144-.021.005-.001h.006l.143-.023.006-.001h.005l.143-.025h.005l.006-.002.143-.026h.005l.005-.002.143-.027.005-.001.005-.001.142-.03h.005l.005-.002.142-.03.005-.002.005-.001.142-.033.005-.001.005-.001.14-.035.006-.001.005-.001.14-.037h.005l.005-.002.14-.038.005-.002h.005l.14-.04.005-.002.005-.001.138-.042.005-.001.006-.002.138-.043.005-.001.005-.002.137-.044.005-.002.005-.002.137-.046.005-.002.005-.001.137-.048.005-.002.005-.002.135-.05.005-.001.005-.002.135-.051.005-.002.005-.002.135-.053.005-.002.004-.002.134-.054.005-.002.005-.002.133-.057.005-.002.005-.002.132-.057.005-.003.005-.002.132-.06.005-.001.004-.002.131-.061.005-.003.005-.002.13-.062.005-.003.005-.002.13-.064.004-.003.005-.002.128-.066.005-.002.005-.003.128-.067.005-.002.004-.003.127-.069.005-.002.005-.003.126-.07.005-.003.004-.003.065-.037.132-.093.112-.115.089-.135.062-.149.034-.157.003-.161-.026-.16-.055-.15-.082-.14-.107-.12-.127-.1-.144-.073-.154-.046-.16-.016zM6.33 26.818l-.16.023-.152.053-.14.08-.122.105-.101.126-.076.142-.048.154-.02.16.012.161.041.156.07.146.094.13.096.093.032.026.004.003.004.004.145.117.004.003.004.004.146.115.005.003.004.004.147.113.005.003.004.004.149.111.004.003.004.003.15.11.005.003.004.003.151.108.004.003.005.003.152.106.005.003.004.003.154.104.004.003.005.003.154.102.005.002.004.003.156.1.005.003.004.003.157.098.005.003.004.002.159.096.004.003.005.003.16.094.004.003.004.002.16.092.005.003.005.002.161.09.005.003.005.002.162.088.005.003.004.002.164.086.005.003.004.002.165.084.005.003.004.002.166.082.004.002.005.003.167.08.004.002.005.002.168.078.004.002.005.002.168.076.005.002.005.002.17.074.004.002.005.002.17.072.005.002.005.002.17.07.006.002.005.001.171.068.005.002.005.002.173.065.005.002.005.002.173.063.005.002.005.002.174.06.005.003.005.001.175.06.005.001.005.002.176.057.005.001.005.002.176.055.006.001.005.002.177.052.005.002.005.001.178.05.005.002.005.002.178.048.006.001.005.002.179.046.005.001.005.002.18.044h.005l.005.002.18.042.006.001.005.001.159.035.16.02.16-.01.157-.04.146-.069.13-.094.112-.117.087-.136.06-.149.033-.158.002-.161-.028-.159-.057-.15-.084-.138-.108-.12-.128-.098-.144-.072-.128-.039-.154-.033-.168-.04-.171-.041-.17-.044-.168-.046-.167-.047-.168-.05-.165-.051-.166-.054-.166-.056-.163-.057-.165-.06-.161-.062-.164-.064-.16-.065-.16-.068-.162-.07-.157-.07-.157-.074-.157-.075-.156-.077-.153-.079-.156-.082-.153-.082-.154-.086-.15-.086-.152-.09-.148-.09-.147-.092-.149-.095-.145-.095-.144-.098-.145-.1-.143-.102-.14-.103-.14-.104-.14-.108-.139-.11-.136-.11-.027-.022-.133-.091-.148-.065-.157-.036-.161-.006zm19.215.087l-.16.01-.157.039-.146.067-.11.076-.064.051-.139.11-.14.108-.14.104-.14.103-.143.101-.145.101-.144.098-.145.095-.149.095-.148.093-.147.089-.152.09-.15.086-.154.086-.153.082-.156.082-.153.079-.156.077-.157.075-.158.073-.157.071-.16.07-.16.068-.161.065-.164.064-.161.061-.165.06-.163.058-.166.056-.166.054-.166.051-.167.05-.167.047-.17.046-.168.044-.171.042-.168.039-.17.037-.11.023-.154.047-.143.075-.126.1-.106.122-.081.139-.054.152-.025.16.006.16.035.158.063.148.09.133.114.115.132.092.148.065.157.037.16.007.133-.016.115-.024.005-.001.005-.001.181-.04h.005l.005-.002.18-.042.006-.001.005-.001.18-.044.005-.002.005-.001.18-.046.004-.002h.005l.179-.05h.005l.005-.002.178-.05.005-.002.005-.002.177-.052.005-.002.005-.001.177-.055.005-.002.005-.001.176-.057.005-.002.005-.002.175-.059.005-.001.005-.002.174-.061.005-.002.005-.002.173-.063.005-.002.005-.002.173-.065.004-.002.005-.002.172-.068.005-.002.005-.002.171-.07.005-.001.005-.002.17-.072.005-.002.004-.002.17-.074.005-.002.004-.002.169-.076.004-.002.005-.002.168-.078.004-.002.005-.003.167-.08.004-.002.005-.002.166-.082.004-.002.005-.003.165-.084.004-.002.005-.003.163-.086.005-.002.005-.003.162-.088.005-.002.005-.003.161-.09.005-.002.004-.003.16-.092.005-.003.005-.002.16-.094.004-.003.004-.003.158-.096.005-.002.004-.003.158-.098.004-.003.005-.003.156-.1.004-.003.004-.003.155-.101.005-.003.004-.003.154-.104.004-.003.004-.003.153-.106.004-.003.005-.003.151-.108.004-.003.005-.003.15-.11.004-.003.004-.003.149-.112.004-.003.004-.003.148-.113.004-.004.004-.003.147-.115.004-.004.004-.003.068-.055.116-.113.092-.132.066-.147.038-.157.008-.16-.022-.16-.05-.153-.08-.14-.103-.125-.124-.102-.142-.077-.153-.05-.16-.02z"
  })));

  function _extends$L() { _extends$L = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$L.apply(this, arguments); }
  var IntermediateEventCatchNonInterruptingMultipleIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$L({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M23.637 13.902l-7.625-5.535-7.624 5.535 2.912 8.956h9.425l2.912-8.956zm-1.017.33l-2.524 7.762H11.93l-2.524-7.762 6.607-4.796 6.608 4.796zM16.012.311c-1.448.02-2.93.157-4.302.628-.852.447-.255 1.863.66 1.574 2.255-.608 4.648-.607 6.922-.108.934.075 1.228-1.376.338-1.67C18.451.44 17.227.317 16.012.311zm9.012 2.934c-.913-.104-1.272 1.258-.454 1.648 1.834 1.36 3.293 3.185 4.31 5.22.526.776 1.842.098 1.515-.78a15.522 15.522 0 00-5.06-6.006c-.1-.044-.203-.07-.31-.082zM6.65 3.59c-.762.089-1.24.809-1.805 1.267C3.38 6.295 2.163 8.007 1.37 9.905c-.266.898 1.094 1.484 1.564.675a14.825 14.825 0 014.327-5.56c.476-.515.09-1.419-.612-1.431zm9.362.007c-.698.066-1.689-.16-2.033.635-.282.733.535 1.358 1.217 1.125 1.806-.147 3.63.203 5.293.907.902.255 1.472-1.112.656-1.573-1.6-.735-3.374-1.089-5.133-1.094zm-5.479 1.365c-.835.15-1.517.76-2.21 1.226-1.203.94-2.318 2.061-3.057 3.402-.33.904 1.063 1.552 1.547.723 1.045-1.656 2.596-2.925 4.285-3.873.545-.499.171-1.463-.565-1.478zm13.903 2.115c-.875-.07-1.22 1.173-.501 1.627 1.325 1.34 2.188 3.062 2.748 4.84.468.84 1.869.21 1.557-.699-.604-2.118-1.751-4.097-3.351-5.615a.93.93 0 00-.453-.153zM4.467 13.132c-.822-.07-.996.826-1.046 1.455-.256 1.93-.094 3.933.562 5.769.406.844 1.807.365 1.612-.551a11.498 11.498 0 01-.334-5.808.874.874 0 00-.794-.865zm26.687 1.6c-.746-.037-1.014.785-.879 1.395.043 2.393-.57 4.771-1.66 6.894-.31.884 1.02 1.536 1.53.75a15.632 15.632 0 001.821-8.372.876.876 0 00-.812-.667zm-30.197.571c-.782-.073-1.044.775-.933 1.404.068 2.414.661 4.833 1.809 6.962.534.77 1.842.076 1.505-.798a14.833 14.833 0 01-1.603-6.861.876.876 0 00-.778-.707zm26.787 2.024c-.777-.048-.952.797-1.021 1.392-.354 1.692-1.202 3.231-2.216 4.608-.407.872.925 1.638 1.48.852 1.361-1.733 2.296-3.827 2.582-6.017a.874.874 0 00-.825-.835zM6.857 23.012c-.808.018-1.082 1.122-.47 1.59 1.393 1.607 3.187 2.886 5.194 3.599.91.222 1.43-1.165.598-1.596a11.495 11.495 0 01-4.723-3.396.899.899 0 00-.599-.197zm15.057 2.7c-.81.194-1.504.76-2.325.972-1.203.458-2.5.536-3.758.664-.869.307-.573 1.728.346 1.663 2.201-.034 4.412-.626 6.293-1.778.604-.495.227-1.532-.556-1.521zM6.346 27.118c-.833.008-1.11 1.218-.395 1.617 1.986 1.602 4.358 2.749 6.868 3.226.933.076 1.227-1.376.338-1.67a14.838 14.838 0 01-6.345-3.066.929.929 0 00-.466-.107zm19.208.087c-.766.09-1.241.841-1.922 1.158-1.516.991-3.251 1.58-4.996 2.005-.872.405-.346 1.849.584 1.604 2.543-.526 4.98-1.66 6.963-3.344.47-.52.072-1.42-.63-1.423z"
  })));

  function _extends$K() { _extends$K = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$K.apply(this, arguments); }
  var IntermediateEventCatchNonInterruptingParallelIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$K({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M13.51 9.081v4.428H9.08v4.982h4.428v4.428h4.982V18.49h4.428v-4.982H18.49V9.081h-4.982zm.83.83h3.32v4.428h4.429v3.322H17.66v4.428h-3.32v-4.454H9.91v-3.296h4.428V9.911zM16 0h-.005l-.188.001h-.011l-.188.004h-.011l-.187.006h-.011l-.187.008h-.005L15.2.02l-.187.01h-.005l-.005.001-.187.013h-.011L14.62.06h-.01l-.186.018h-.011l-.185.02-.005.001h-.006l-.185.022-.005.001h-.005l-.185.025h-.005l-.005.001-.185.027h-.005l-.005.001-.184.029h-.005l-.005.001-.183.031-.006.001-.005.001-.182.033-.006.001-.005.001-.182.035-.005.001-.005.001-.182.038h-.005l-.005.002-.181.04h-.005l-.005.002-.18.042-.006.001-.005.001-.18.044-.005.002h-.005l-.17.045-.152.054-.139.082-.121.106-.1.127-.074.143-.046.155-.017.16.013.16.043.156.07.145.097.13.119.108.137.085.15.058.159.03.16-.001.133-.023.165-.043.168-.041.171-.04.171-.037.172-.036.17-.033.173-.03.17-.03.177-.027.171-.025.175-.022.175-.02.175-.02.176-.016.175-.014.177-.012.176-.01.177-.007.174-.006.177-.003L16 1.73h.177l.178.004.174.006.177.007.176.01.177.012.175.014.176.017.175.018.175.02.175.023.171.025.176.027.17.03.174.03.17.033.171.036.154.033.16.02.161-.01.156-.04.146-.069.131-.094.111-.117.087-.135.061-.15.032-.158.002-.16-.027-.16-.057-.15L20 .714l-.108-.12-.128-.097-.145-.073-.128-.038-.158-.035-.005-.001-.005-.001L19.14.31h-.005l-.005-.002-.182-.035h-.006l-.005-.002-.182-.033h-.006l-.005-.002-.183-.03-.005-.001-.006-.001-.183-.029h-.005l-.006-.001-.184-.027h-.005l-.005-.001-.185-.024h-.005L17.968.12 17.783.1l-.006-.001h-.005l-.185-.02h-.006l-.005-.001L17.39.06h-.005L17.38.06l-.187-.015h-.005l-.005-.001-.187-.013h-.011L16.8.02h-.011L16.6.01h-.011l-.187-.006h-.011L16.204 0h-.011L16.005 0H16zm9.015 2.935l-.16.004-.158.033-.15.062-.134.09-.116.111-.093.132-.067.147-.038.156-.01.161.022.16.05.153.078.141.103.124.102.087.045.034.142.106.137.105.14.11.136.11.135.112.134.115.134.117.13.115.132.122.128.12.127.122.126.125.124.126.124.128.121.13.118.128.118.132.117.133.113.134.113.136.11.136.109.137.109.142.104.14.103.14.101.142.1.144.099.146.095.145.094.147.093.15.092.15.087.149.087.15.084.152.084.155.08.152.08.155.04.081.084.138.11.119.128.096.145.072.155.043.16.013.16-.016.155-.046.144-.074.127-.099.106-.12.083-.14.055-.151.026-.16-.004-.16-.034-.158-.05-.124-.042-.085-.002-.004-.003-.005-.084-.165-.002-.004-.003-.005-.086-.164-.002-.004-.003-.005-.088-.162-.002-.005-.003-.005-.09-.161-.002-.005-.003-.004-.092-.16-.003-.005-.002-.005-.094-.16-.003-.004-.003-.004-.096-.159-.002-.004-.003-.005-.098-.157-.003-.004-.003-.005-.1-.156-.003-.004-.003-.005-.101-.154-.003-.005-.003-.004-.104-.154-.003-.004-.003-.005-.106-.152-.003-.005-.003-.004-.108-.151-.003-.004-.003-.005-.11-.15-.003-.004-.003-.004-.111-.15-.004-.003-.003-.005-.113-.147-.004-.004-.003-.005-.115-.146-.004-.004-.003-.004-.117-.145-.004-.004-.003-.004-.12-.144-.003-.004-.003-.004-.121-.142-.004-.004-.003-.004-.123-.141-.003-.004-.004-.004-.125-.14-.003-.004-.004-.004-.127-.138-.003-.004-.004-.004-.128-.136-.004-.004-.004-.004-.13-.135-.004-.004-.004-.004-.132-.134-.003-.004-.004-.003-.134-.133-.004-.003-.004-.004-.135-.13-.004-.004-.004-.004-.136-.128-.004-.004-.004-.004-.138-.126-.004-.004-.004-.003-.14-.125-.004-.004-.004-.003-.14-.123-.005-.004-.004-.003-.142-.121-.004-.004-.004-.003-.144-.12-.004-.003-.004-.003-.145-.117-.004-.004-.004-.003-.147-.115-.004-.004-.004-.003-.148-.113-.004-.003-.004-.004-.149-.111-.004-.003-.004-.004-.05-.036-.14-.083-.15-.055-.16-.027zM6.634 3.28l-.161.008-.157.037-.147.066-.111.074-.04.032-.005.003-.004.004-.145.117-.004.003-.004.004-.144.119-.004.003-.004.004-.142.12-.004.004-.004.004-.141.123-.004.003-.004.004-.14.125-.004.003-.004.004-.138.126-.004.004-.004.004-.136.128-.004.004-.004.004-.135.13-.004.004-.004.003-.134.133-.004.003-.004.004-.132.134-.003.004-.004.004-.13.135-.004.004-.004.004-.128.136-.004.004-.004.004-.126.138-.004.004-.003.004-.125.14-.004.004-.003.004-.123.14-.004.005-.003.004-.121.142-.004.004-.003.004-.12.144-.003.004-.003.004-.117.145-.004.004-.003.004-.115.146-.004.005-.003.004-.113.147-.003.005-.004.004-.111.149-.003.004-.004.004-.11.15-.002.005-.003.004-.108.151-.003.004-.003.005-.106.152-.003.005-.003.004-.104.154-.003.004-.003.005-.102.154-.003.005-.002.004-.1.156-.003.005-.003.004-.098.157-.003.005-.003.004-.096.159-.002.004-.003.005-.094.16-.003.004-.002.004-.092.16-.003.005-.003.005-.09.161-.002.005-.003.005-.088.162-.002.005-.003.004-.086.164-.002.005-.002.004-.084.165-.003.005-.002.004-.082.166-.002.004-.003.005-.08.167-.002.004-.002.005-.078.168-.002.004-.002.005-.045.1-.053.153-.023.16.007.16.037.157.065.148.092.132.114.114.134.09.148.064.157.035.161.006.16-.025.152-.054.14-.08.121-.106.1-.126.065-.118.043-.095.074-.16.075-.155.077-.157.08-.155.08-.152.083-.155.085-.152.086-.15.088-.149.091-.15.094-.15.094-.147.095-.145.099-.146.1-.144.1-.142.104-.14.104-.14.11-.142.107-.137.11-.136.114-.136.113-.134.117-.133.118-.132.117-.129.122-.13.124-.127.123-.126.127-.125.127-.122.128-.12.132-.122.13-.115.133-.117.135-.115.135-.111.136-.11.037-.03.117-.11.094-.132.068-.146.04-.156.01-.161-.02-.16-.05-.154-.076-.141-.102-.125-.123-.104-.14-.08-.153-.051-.16-.023zM16 3.286h-.005l-.148.001h-.01l-.147.003h-.011l-.147.005h-.011l-.146.007h-.011l-.146.009h-.011l-.146.01h-.005l-.005.001-.146.012h-.011l-.145.014h-.006l-.005.001-.05.006-.158.031-.15.06-.135.088-.117.111-.094.13-.069.147-.04.156-.01.16.019.16.049.154.076.142.102.125.123.105.14.08.152.051.16.023.134-.003.045-.005.135-.013.133-.01.136-.01.135-.007.137-.006.136-.004.136-.003h.274l.136.003.136.004.136.006.136.007.136.01.133.01.135.013.135.014.135.016.134.018.132.018.134.021.133.023.133.024.133.025.13.027.132.03.132.03.129.031.13.034.129.035.129.036.13.04.126.038.128.042.126.042.128.045.127.047.126.047.12.048.127.051.123.052.006.002.147.048.16.021.16-.009.157-.038.147-.067.131-.093.112-.116.089-.135.062-.149.033-.158.004-.16-.027-.16-.055-.151-.083-.139-.107-.12-.127-.099-.118-.063-.004-.001-.005-.003-.005-.002-.133-.056-.005-.002-.005-.002-.134-.054-.004-.002-.005-.002-.135-.053-.005-.002-.005-.002-.135-.051-.005-.002-.005-.002-.135-.05-.005-.001-.005-.002-.137-.048-.005-.001-.005-.002-.137-.046-.005-.002-.005-.002-.137-.044-.005-.002-.005-.001-.138-.043-.006-.002-.005-.001-.138-.042-.005-.001-.005-.002-.14-.04H19.4l-.005-.002-.14-.038-.005-.001-.005-.002-.14-.036-.005-.001-.005-.001-.141-.035-.005-.001-.005-.001-.142-.033-.005-.001-.005-.001-.142-.031-.005-.002h-.005l-.142-.03-.005-.001-.005-.001-.143-.028h-.005l-.005-.002-.143-.025-.006-.001-.005-.001-.143-.024-.005-.001-.006-.001-.143-.022-.006-.001h-.005l-.144-.022h-.005l-.006-.001-.144-.019h-.005l-.006-.001-.144-.017h-.006l-.005-.001-.145-.016h-.011l-.145-.014H17.1l-.005-.001-.146-.012h-.01l-.146-.01-.006-.001h-.005l-.146-.009h-.011l-.147-.006h-.01l-.147-.005h-.011l-.147-.003h-.011l-.147-.001H16zm-5.482 1.366l-.16.008-.157.037-.123.053-.06.032-.005.002-.004.003-.128.069-.004.002-.005.003-.126.07-.005.003-.004.002-.126.072-.005.003-.004.003-.125.073-.004.003-.005.003-.124.075-.004.003-.005.002-.123.077-.004.003-.005.003-.122.078-.004.003-.005.003-.121.08-.004.002-.005.003-.12.082-.005.003-.004.003-.12.083-.004.003-.004.003-.118.084-.005.003-.004.003-.118.086-.004.003-.004.003-.117.088-.004.003-.004.003-.116.089-.004.003-.004.004-.114.09-.005.003-.004.003-.113.092-.004.004-.004.003-.113.093-.004.004-.004.003-.111.095-.005.003-.004.004-.11.096-.004.004-.004.003-.11.098-.003.003-.004.004-.108.1-.004.003-.004.003-.107.101-.004.004-.004.003-.106.102-.004.004-.003.004-.105.103-.004.004-.004.004-.103.105-.004.004-.004.003-.102.106-.003.004-.004.004-.1.107-.004.004-.004.004-.099.108-.004.004-.003.004-.098.11-.003.003-.004.004-.096.11-.004.005-.003.004-.095.111-.003.004-.004.004-.093.113-.003.004-.004.004-.092.113-.003.004-.003.005-.09.114-.004.004-.003.004-.089.116-.003.004-.003.004-.088.117-.003.004-.003.004-.086.118-.003.004-.003.005-.084.118-.003.004-.003.005-.083.12-.003.003-.003.005-.082.12-.003.005-.002.004-.068.103-.076.142-.048.154-.018.16.011.161.041.156.07.146.095.13.117.11.136.086.15.06.158.03.162.002.158-.03.15-.057.138-.085.119-.109.082-.105.065-.099.075-.11.077-.113.077-.107.08-.11.08-.108.084-.108.083-.105.086-.106.086-.104.088-.104.089-.101.09-.102.093-.101.093-.099.094-.097.095-.096.098-.097.098-.095.099-.093.1-.092.103-.091.101-.089.104-.088.104-.086.106-.086.106-.083.106-.082.109-.082.108-.079.11-.078.11-.076.112-.076.112-.074.113-.072.113-.071.115-.07.115-.068.118-.067.117-.065.12-.065.054-.029.135-.088.116-.111.094-.132.068-.146.04-.156.009-.161-.02-.16-.05-.153-.078-.142-.102-.125-.123-.103-.141-.079-.153-.051-.16-.022zm13.91 2.116l-.162.008-.157.037-.147.066-.132.092-.113.116-.09.134-.063.148-.034.157-.005.162.025.159.055.152.082.138.086.103.09.09.094.098.092.099.093.1.091.103.089.101.088.104.086.104.086.106.083.105.083.108.08.108.081.11.077.107.077.112.075.111.075.114.072.113.071.113.07.114.068.118.067.115.065.118.064.117.062.117.061.121.059.119.059.122.056.121.054.12.055.125.051.123.051.125.048.123.048.127.047.126.044.125.043.128.042.129.039.126.038.13.022.076.058.15.085.137.11.119.129.096.145.07.155.043.16.013.161-.017.154-.046.144-.075.126-.1.106-.12.082-.14.055-.151.025-.16-.005-.16-.026-.132-.023-.082-.002-.005-.001-.005-.042-.139-.001-.005-.002-.005-.043-.138-.001-.005-.002-.005-.044-.137-.002-.005-.002-.005-.046-.137-.002-.005-.001-.005-.048-.137-.002-.005-.002-.005-.05-.135-.001-.005-.002-.005-.051-.135-.002-.005-.002-.005-.053-.135-.002-.005-.002-.005-.054-.133-.002-.005-.002-.005-.057-.133-.002-.005-.002-.005-.057-.132-.003-.005-.002-.005-.06-.132-.001-.005-.002-.004-.061-.132-.003-.004-.002-.005-.063-.13-.002-.005-.002-.005-.064-.13-.003-.004-.002-.005-.066-.129-.002-.004-.003-.005-.067-.128-.002-.005-.003-.004-.069-.128-.002-.004-.003-.005-.07-.126-.003-.005-.003-.004-.072-.126-.002-.005-.003-.004-.074-.125-.002-.004-.003-.005-.075-.124-.003-.004-.003-.005-.076-.123-.003-.004-.003-.005-.078-.122-.003-.004-.003-.005-.08-.121-.003-.004-.003-.005-.081-.12-.003-.005-.003-.004-.083-.12-.003-.004-.003-.004-.084-.118-.003-.005-.003-.004-.086-.118-.003-.004-.004-.004-.087-.117-.003-.004-.003-.004-.09-.116-.002-.004-.004-.004-.09-.114-.003-.005-.004-.004-.091-.113-.004-.004-.003-.004-.094-.113-.003-.004-.003-.004-.095-.111-.004-.004-.003-.004-.096-.11-.004-.005-.003-.004-.098-.11-.004-.003-.003-.004-.1-.108-.003-.004-.004-.004-.1-.107-.004-.004-.004-.004-.102-.106-.003-.003-.004-.004-.093-.095-.124-.103-.14-.08-.153-.05-.16-.023zM4.45 12.826l-.161.002-.158.032-.15.06-.135.088-.118.11-.094.131-.069.146-.035.129-.026.132v.005l-.002.005-.025.143-.001.005-.001.006-.024.143-.001.005-.001.006-.022.143-.001.006-.001.005-.02.144-.001.005-.001.005-.019.145v.005l-.001.006-.017.144v.006l-.001.005-.016.145v.011l-.014.145v.005l-.001.006-.012.146v.01l-.01.146-.001.006v.005l-.009.146v.011l-.007.146v.011l-.004.147v.011l-.003.147v.01l-.002.148v.01l.001.148v.01l.003.147v.011l.005.147v.01l.007.147v.011l.009.146v.011l.01.146v.01l.013.146v.011l.014.145v.005l.001.006.016.145v.011l.018.144v.006l.001.005.019.144v.006l.001.005.021.144v.005l.002.006.022.143v.006l.002.005.024.143v.005l.002.006.025.143.001.005.001.005.028.143.001.005.001.005.03.142v.005l.002.006.03.141.002.005.001.005.033.142v.005l.002.005.035.14v.006l.002.005.036.14.002.005.001.005.038.14.001.005.002.005.04.14v.005l.002.005.042.138.001.006.002.005.042.138.002.005.002.005.017.054.064.148.09.134.114.114.132.092.148.065.157.037.16.007.16-.023.153-.052.14-.08.123-.104.102-.125.076-.142.049-.153.02-.16-.011-.161-.031-.13-.017-.051-.039-.126-.038-.13-.037-.128-.035-.13-.033-.128-.033-.134-.03-.13-.029-.131-.026-.13-.026-.133-.024-.133-.023-.133-.02-.132-.02-.136-.017-.132-.016-.135-.014-.135-.012-.133-.012-.138-.009-.133-.007-.136-.006-.138-.004-.134-.003-.136v-.274l.003-.136.004-.134.006-.139.007-.136.01-.133.01-.138.013-.132.014-.135.016-.135.017-.132.02-.137.02-.13.023-.134.024-.133.024-.126.016-.16-.014-.161-.044-.155-.072-.145-.098-.128-.12-.108-.137-.084-.15-.057-.16-.029zm26.698 1.601l-.161.01-.157.04-.146.067-.131.093-.112.117-.088.135-.061.149-.033.157-.005.134.006.14.006.176.003.177.001.178-.001.177-.003.178-.006.177-.007.176-.01.177-.012.176-.015.176-.016.173-.018.175-.02.175-.024.174-.025.175-.026.17-.03.174-.03.173-.033.17-.036.172-.037.17-.04.17-.042.172-.043.168-.045.166-.048.169-.05.167-.052.168-.053.164-.056.166-.058.166-.06.16-.062.165-.062.158-.066.165-.068.16-.07.16-.07.158-.075.159-.074.155-.079.158-.08.158-.06.15-.03.158-.001.161.029.159.058.15.085.137.108.119.13.097.144.07.156.044.16.013.16-.017.155-.046.143-.074.127-.1.107-.12.07-.115.083-.164.003-.005.002-.004.082-.166.002-.005.003-.004.08-.167.002-.005.002-.004.078-.168.002-.005.002-.004.076-.169.002-.004.002-.005.074-.17.002-.004.002-.005.072-.17.002-.005.002-.005.07-.171.001-.005.002-.005.068-.172.002-.004.002-.005.065-.173.002-.005.002-.005.063-.173.002-.005.002-.005.06-.174.003-.005.001-.005.06-.175.001-.005.002-.005.057-.176.001-.005.002-.005.055-.177.001-.005.002-.005.052-.177.002-.005.001-.005.051-.178.001-.005.002-.005.048-.179.002-.005v-.005l.047-.179.001-.005.002-.005.044-.18v-.005l.002-.005.042-.18.001-.006.001-.005.04-.181.001-.005.001-.005.037-.182.002-.005v-.005l.036-.182v-.006l.002-.005.033-.182v-.006l.002-.005.03-.183.001-.005.001-.005.029-.184v-.005l.001-.006.027-.184v-.005l.001-.005.024-.185v-.005l.001-.005.022-.185v-.006l.001-.005.02-.185v-.006l.001-.005.017-.186v-.005l.001-.005.015-.187v-.005l.001-.005.013-.187v-.01l.01-.187.001-.006v-.005l.009-.187v-.011l.006-.187v-.011l.004-.188v-.011l.001-.188v-.01l-.001-.188v-.011l-.004-.188v-.011l-.006-.187v-.011l-.007-.145-.022-.16-.05-.152-.08-.141-.103-.124-.125-.102-.141-.077-.153-.05-.16-.02zM.938 15L.777 15l-.158.032-.15.06-.136.087-.117.11-.095.131-.068.146-.04.156-.012.133-.001.14v.01l.001.188v.011l.004.188v.011l.006.187v.011l.008.187v.011l.011.187v.005l.001.005.013.187v.01l.016.187v.01l.018.186v.011l.02.185.001.005v.006l.022.185.001.005v.005l.025.185v.005l.001.005.027.184v.006l.001.005.029.184v.005l.001.005.031.183.001.005.001.006.033.182.001.005.001.006.035.182.001.005.001.005.038.182v.005l.002.005.04.181v.005l.002.005.042.18.001.006.001.005.044.18.002.005v.005l.047.18.001.004.002.005.048.179.002.005.001.005.05.178.002.005.001.005.053.177.002.005.001.005.055.177.002.005.001.005.057.176.002.005.001.005.06.175.001.005.002.005.061.174.002.005.002.005.063.173.002.005.002.005.065.173.002.005.002.004.067.172.002.005.002.005.07.171.002.005.002.005.072.17.002.005.002.004.074.17.002.005.002.004.076.169.002.004.002.005.078.168.002.004.002.005.08.167.003.004.002.005.082.166.002.004.003.005.02.04.086.136.11.118.13.095.146.07.156.041.16.012.16-.019.155-.048.142-.075.126-.1.105-.123.08-.14.054-.152.024-.16-.006-.16-.036-.158-.051-.123-.018-.034-.078-.158L3.1 22.1l-.074-.16-.071-.157-.07-.16-.068-.16-.067-.165-.062-.158-.062-.164-.059-.161-.058-.166-.056-.166-.053-.164-.052-.168-.05-.167-.048-.17-.045-.165-.043-.168-.043-.172-.039-.17-.037-.17-.036-.172-.033-.17-.03-.173-.03-.174-.027-.17-.025-.175-.022-.174-.021-.175-.018-.175-.017-.173-.014-.176-.012-.176-.01-.177-.007-.176-.006-.177-.003-.178L1.73 16v-.134l-.013-.16-.044-.156-.072-.144-.097-.129-.12-.108-.137-.085-.15-.057L.938 15zm26.798 2.024l-.16.007-.157.038-.148.066-.132.092-.113.115-.09.134-.062.148-.03.127-.001.004-.023.134-.024.133-.026.133-.026.13-.03.132-.03.129-.032.134-.033.128-.035.13-.037.128-.038.13-.04.126-.04.128-.044.128-.044.126-.046.126-.048.126-.05.125-.05.125-.051.122-.054.123-.055.122-.056.12-.058.122-.06.12-.061.12-.063.119-.062.116-.067.119-.066.116-.069.115-.069.115-.07.113-.073.113-.074.112-.076.113-.077.112-.077.107-.08.11-.08.107-.085.11-.044.056-.088.135-.06.15-.033.158-.002.16.027.16.057.15.083.138.108.12.128.098.144.072.155.045.16.015.161-.016.155-.044.144-.073.128-.098.09-.099.05-.061.003-.004.003-.005.089-.115.003-.004.003-.005.088-.116.003-.004.003-.005.086-.117.003-.004.003-.005.084-.118.003-.004.003-.005.083-.12.003-.004.003-.004.081-.12.003-.005.003-.004.08-.121.003-.005.003-.004.078-.122.003-.005.003-.004.077-.123.002-.005.003-.004.075-.124.003-.005.003-.004.073-.125.003-.005.003-.004.072-.126.002-.004.003-.005.07-.126.003-.005.002-.005.07-.127.002-.004.002-.005.068-.128.002-.005.002-.004.066-.13.003-.004.002-.005.064-.13.002-.004.003-.005.062-.13.002-.005.003-.005.06-.13.003-.005.002-.005.06-.132.002-.005.002-.005.057-.132.003-.005.002-.005.056-.133.002-.005.002-.005.054-.134.002-.004.002-.005.053-.135.002-.005.002-.005.051-.135.002-.005.002-.005.05-.135.001-.005.002-.005.048-.137.001-.005.002-.005.046-.137.002-.005.002-.005.044-.137.002-.005.002-.005.042-.138.002-.005.001-.006.042-.138.001-.005.002-.005.04-.14V19.4l.002-.005.038-.14.001-.005.002-.005.036-.14.001-.005.001-.005.035-.141.001-.005.001-.005.033-.142.001-.005.001-.005.031-.141.001-.006.002-.005.029-.142v-.005l.002-.005.028-.143v-.005l.002-.005.025-.143.001-.006.001-.005.024-.143.001-.005.001-.006.001-.006.01-.161-.02-.16-.05-.154-.077-.141-.102-.125-.123-.104-.141-.079-.153-.051-.16-.022zM6.841 22.71l-.16.024-.152.053-.14.08-.122.105-.101.126-.076.142-.048.154-.018.16.011.161.041.156.07.146.077.109.04.048.003.004.003.004.095.111.003.004.004.004.096.11.004.005.003.004.098.109.003.004.004.004.1.108.003.004.003.004.101.107.004.004.003.004.102.105.004.004.004.004.103.105.004.004.004.003.105.104.003.004.004.003.106.102.004.004.004.004.107.1.004.004.004.004.108.099.004.003.004.004.11.098.003.003.004.004.11.096.004.003.005.004.11.095.005.003.004.004.113.093.004.003.004.004.113.091.004.004.005.003.114.09.004.004.004.003.116.089.004.003.004.003.117.088.004.003.004.003.118.086.004.003.005.003.118.084.004.003.005.003.119.083.004.003.005.003.12.081.005.003.004.003.121.08.005.003.004.003.122.078.005.003.004.003.123.076.005.003.004.003.124.075.005.003.004.003.125.073.004.003.005.002.126.073.004.002.005.003.126.07.005.003.004.002.128.07.004.002.005.002.128.067.005.003.004.002.13.066.004.002.005.003.13.064.004.002.005.003.13.062.005.002.004.003.132.06.004.003.005.002.132.06.005.002.005.002.132.057.005.002.005.002.133.057.005.002.005.002.133.054.005.002.005.002.13.05.154.045.16.016.16-.015.156-.045.144-.072.128-.098.108-.12.083-.138.057-.15.028-.16-.003-.16-.032-.159-.061-.149-.088-.135-.11-.117-.132-.094-.12-.058-.124-.049-.126-.051-.122-.051-.122-.054-.12-.054-.126-.058-.119-.057-.12-.06-.12-.06-.118-.063-.117-.064-.119-.066-.116-.066-.115-.068-.115-.07-.113-.07-.115-.074-.112-.074-.11-.075-.11-.076-.112-.08-.11-.08-.109-.081-.106-.082-.104-.082-.106-.086-.105-.087-.101-.086-.105-.091-.1-.09-.1-.091-.1-.094-.097-.094-.1-.098-.093-.095-.096-.1-.093-.098-.092-.101-.089-.1-.09-.102-.088-.104-.036-.043-.114-.114-.133-.091-.148-.065-.157-.036-.161-.006zm15.063 2.701l-.16.014-.156.044-.12.057-.06.034-.12.066-.117.064-.118.062-.12.061-.12.06-.118.057-.126.058-.12.054-.122.054-.122.05-.126.052-.125.05-.124.046-.127.047-.125.044-.129.043-.126.04-.13.042-.128.038-.127.035-.13.036-.131.034-.129.031-.132.03-.13.03-.135.027-.133.026-.13.023-.13.022-.137.021-.132.02-.134.017-.132.015-.138.015-.135.013-.133.01-.138.01-.136.007-.134.006-.136.004-.14.003-.16.018-.155.047-.142.076-.127.1-.105.122-.08.14-.054.151-.025.16.006.16.035.158.064.148.09.134.114.114.133.092.147.065.157.036.134.008.145-.002h.011l.147-.005h.01l.147-.007h.011l.146-.009h.011l.146-.01h.005l.005-.001.146-.012h.011l.145-.014h.005l.006-.001.145-.016h.011l.144-.018h.006l.005-.001.144-.02h.011l.144-.021.005-.001h.006l.143-.023.006-.001h.005l.143-.025h.005l.006-.002.143-.026h.005l.005-.002.143-.027.005-.001.005-.001.142-.03h.005l.005-.002.142-.03.005-.002.005-.001.142-.033.005-.001.005-.001.14-.035.006-.001.005-.001.14-.037h.005l.005-.002.14-.038.005-.002h.005l.14-.04.005-.002.005-.001.138-.042.005-.001.006-.002.138-.043.005-.001.005-.002.137-.044.005-.002.005-.002.137-.046.005-.002.005-.001.137-.048.005-.002.005-.002.135-.05.005-.001.005-.002.135-.051.005-.002.005-.002.135-.053.005-.002.004-.002.134-.054.005-.002.005-.002.133-.057.005-.002.005-.002.132-.057.005-.003.005-.002.132-.06.005-.001.004-.002.131-.061.005-.003.005-.002.13-.062.005-.003.005-.002.13-.064.004-.003.005-.002.128-.066.005-.002.005-.003.128-.067.005-.002.004-.003.127-.069.005-.002.005-.003.126-.07.005-.003.004-.003.065-.037.132-.093.112-.115.089-.135.062-.149.034-.157.003-.161-.026-.16-.055-.15-.082-.14-.107-.12-.127-.1-.144-.073-.154-.046-.16-.016zM6.33 26.818l-.16.023-.152.053-.14.08-.122.105-.101.126-.076.142-.048.154-.02.16.012.161.041.156.07.146.094.13.096.093.032.026.004.003.004.004.145.117.004.003.004.004.146.115.005.003.004.004.147.113.005.003.004.004.149.111.004.003.004.003.15.11.005.003.004.003.151.108.004.003.005.003.152.106.005.003.004.003.154.104.004.003.005.003.154.102.005.002.004.003.156.1.005.003.004.003.157.098.005.003.004.002.159.096.004.003.005.003.16.094.004.003.004.002.16.092.005.003.005.002.161.09.005.003.005.002.162.088.005.003.004.002.164.086.005.003.004.002.165.084.005.003.004.002.166.082.004.002.005.003.167.08.004.002.005.002.168.078.004.002.005.002.168.076.005.002.005.002.17.074.004.002.005.002.17.072.005.002.005.002.17.07.006.002.005.001.171.068.005.002.005.002.173.065.005.002.005.002.173.063.005.002.005.002.174.06.005.003.005.001.175.06.005.001.005.002.176.057.005.001.005.002.176.055.006.001.005.002.177.052.005.002.005.001.178.05.005.002.005.002.178.048.006.001.005.002.179.046.005.001.005.002.18.044h.005l.005.002.18.042.006.001.005.001.159.035.16.02.16-.01.157-.04.146-.069.13-.094.112-.117.087-.136.06-.149.033-.158.002-.161-.028-.159-.057-.15-.084-.138-.108-.12-.128-.098-.144-.072-.128-.039-.154-.033-.168-.04-.171-.041-.17-.044-.168-.046-.167-.047-.168-.05-.165-.051-.166-.054-.166-.056-.163-.057-.165-.06-.161-.062-.164-.064-.16-.065-.16-.068-.162-.07-.157-.07-.157-.074-.157-.075-.156-.077-.153-.079-.156-.082-.153-.082-.154-.086-.15-.086-.152-.09-.148-.09-.147-.092-.149-.095-.145-.095-.144-.098-.145-.1-.143-.102-.14-.103-.14-.104-.14-.108-.139-.11-.136-.11-.027-.022-.133-.091-.148-.065-.157-.036-.161-.006zm19.215.087l-.16.01-.157.039-.146.067-.11.076-.064.051-.139.11-.14.108-.14.104-.14.103-.143.101-.145.101-.144.098-.145.095-.149.095-.148.093-.147.089-.152.09-.15.086-.154.086-.153.082-.156.082-.153.079-.156.077-.157.075-.158.073-.157.071-.16.07-.16.068-.161.065-.164.064-.161.061-.165.06-.163.058-.166.056-.166.054-.166.051-.167.05-.167.047-.17.046-.168.044-.171.042-.168.039-.17.037-.11.023-.154.047-.143.075-.126.1-.106.122-.081.139-.054.152-.025.16.006.16.035.158.063.148.09.133.114.115.132.092.148.065.157.037.16.007.133-.016.115-.024.005-.001.005-.001.181-.04h.005l.005-.002.18-.042.006-.001.005-.001.18-.044.005-.002.005-.001.18-.046.004-.002h.005l.179-.05h.005l.005-.002.178-.05.005-.002.005-.002.177-.052.005-.002.005-.001.177-.055.005-.002.005-.001.176-.057.005-.002.005-.002.175-.059.005-.001.005-.002.174-.061.005-.002.005-.002.173-.063.005-.002.005-.002.173-.065.004-.002.005-.002.172-.068.005-.002.005-.002.171-.07.005-.001.005-.002.17-.072.005-.002.004-.002.17-.074.005-.002.004-.002.169-.076.004-.002.005-.002.168-.078.004-.002.005-.003.167-.08.004-.002.005-.002.166-.082.004-.002.005-.003.165-.084.004-.002.005-.003.163-.086.005-.002.005-.003.162-.088.005-.002.005-.003.161-.09.005-.002.004-.003.16-.092.005-.003.005-.002.16-.094.004-.003.004-.003.158-.096.005-.002.004-.003.158-.098.004-.003.005-.003.156-.1.004-.003.004-.003.155-.101.005-.003.004-.003.154-.104.004-.003.004-.003.153-.106.004-.003.005-.003.151-.108.004-.003.005-.003.15-.11.004-.003.004-.003.149-.112.004-.003.004-.003.148-.113.004-.004.004-.003.147-.115.004-.004.004-.003.068-.055.116-.113.092-.132.066-.147.038-.157.008-.16-.022-.16-.05-.153-.08-.14-.103-.125-.124-.102-.142-.077-.153-.05-.16-.02z",
    opacity: ".98"
  })));

  function _extends$J() { _extends$J = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$J.apply(this, arguments); }
  var IntermediateEventCatchNonInterruptingSignalIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$J({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M16.012 8.816L9.21 21.026h13.606l-6.803-12.21zm0 1.776l5.332 9.57H10.681l5.331-9.57zm0-10.281c-1.448.02-2.93.157-4.302.628-.852.447-.255 1.863.66 1.574 2.255-.608 4.648-.607 6.922-.108.934.075 1.228-1.376.338-1.67C18.451.44 17.227.317 16.012.311zm9.012 2.934c-.913-.104-1.272 1.258-.454 1.648 1.834 1.36 3.293 3.185 4.31 5.22.526.776 1.842.098 1.515-.78a15.522 15.522 0 00-5.06-6.006c-.1-.044-.203-.07-.31-.082zM6.65 3.59c-.762.089-1.24.809-1.805 1.267C3.38 6.295 2.163 8.007 1.37 9.905c-.266.898 1.094 1.484 1.564.675a14.825 14.825 0 014.327-5.56c.476-.515.09-1.419-.612-1.431zm9.362.007c-.698.066-1.689-.16-2.033.635-.282.733.535 1.358 1.217 1.125 1.806-.147 3.63.203 5.293.907.902.255 1.472-1.112.656-1.573-1.6-.735-3.374-1.089-5.133-1.094zm-5.479 1.365c-.835.15-1.517.76-2.21 1.226-1.203.94-2.318 2.061-3.057 3.402-.33.904 1.063 1.552 1.547.723 1.045-1.656 2.596-2.925 4.285-3.873.545-.499.171-1.463-.565-1.478zm13.903 2.115c-.875-.07-1.22 1.173-.501 1.627 1.325 1.34 2.188 3.062 2.748 4.84.468.84 1.869.21 1.557-.699-.604-2.118-1.751-4.097-3.351-5.615a.93.93 0 00-.453-.153zM4.467 13.132c-.822-.07-.996.826-1.046 1.455-.256 1.93-.094 3.933.562 5.769.406.844 1.807.365 1.612-.551a11.498 11.498 0 01-.334-5.808.874.874 0 00-.794-.865zm26.687 1.6c-.746-.037-1.014.785-.879 1.395.043 2.393-.57 4.771-1.66 6.894-.31.884 1.02 1.536 1.53.75a15.632 15.632 0 001.821-8.372.876.876 0 00-.812-.667zm-30.197.571c-.782-.073-1.044.775-.933 1.404.068 2.414.661 4.833 1.809 6.962.534.77 1.842.076 1.505-.798a14.833 14.833 0 01-1.603-6.861.876.876 0 00-.778-.707zm26.787 2.024c-.777-.048-.952.797-1.021 1.392-.354 1.692-1.202 3.231-2.216 4.608-.407.872.925 1.638 1.48.852 1.361-1.733 2.296-3.827 2.582-6.017a.874.874 0 00-.825-.835zM6.857 23.012c-.808.018-1.082 1.122-.47 1.59 1.393 1.607 3.187 2.886 5.194 3.599.91.222 1.43-1.165.598-1.596a11.495 11.495 0 01-4.723-3.396.899.899 0 00-.599-.197zm15.057 2.7c-.81.194-1.504.76-2.325.972-1.203.458-2.5.536-3.758.664-.869.307-.573 1.728.346 1.663 2.201-.034 4.412-.626 6.293-1.778.604-.495.227-1.532-.556-1.521zM6.346 27.118c-.833.008-1.11 1.218-.395 1.617 1.986 1.602 4.358 2.749 6.868 3.226.933.076 1.227-1.376.338-1.67a14.838 14.838 0 01-6.345-3.066.929.929 0 00-.466-.107zm19.208.087c-.766.09-1.241.841-1.922 1.158-1.516.991-3.251 1.58-4.996 2.005-.872.405-.346 1.849.584 1.604 2.543-.526 4.98-1.66 6.963-3.344.47-.52.072-1.42-.63-1.423z"
  })));

  function _extends$I() { _extends$I = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$I.apply(this, arguments); }
  var IntermediateEventCatchNonInterruptingTimerIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$I({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.998 8.406c-3.018-.041-5.92 1.926-7.031 4.727-1.138 2.695-.51 6.012 1.537 8.103 1.99 2.141 5.268 2.93 8.014 1.927 2.878-.98 4.992-3.827 5.068-6.87.153-2.957-1.624-5.88-4.3-7.137a7.552 7.552 0 00-3.288-.75zm0 1.384c2.759-.052 5.373 1.973 6.015 4.655.704 2.578-.482 5.517-2.791 6.867-2.358 1.48-5.682 1.086-7.618-.918-2.043-1.971-2.407-5.381-.84-7.745 1.11-1.763 3.15-2.88 5.234-2.86zm1.962 1.765l-2.074 3.762c-.64.068-.793 1.04-.202 1.3.39.27.696-.18 1.052-.165h3.17v-.865h-3.182l1.993-3.615c-.252-.14-.505-.278-.757-.417zm-1.965-8.268h-.158l-.147.003h-.011l-.147.005h-.011l-.146.007h-.011l-.146.009h-.011l-.146.01h-.005l-.005.001-.146.012h-.011l-.145.014h-.006l-.005.001-.05.006-.158.031-.15.06-.135.088-.117.111-.094.13-.069.147-.04.156-.01.16.019.16.049.154.076.142.102.125.123.105.14.08.152.051.16.023.134-.003.045-.005.135-.013.133-.01.136-.01.135-.007.137-.006.136-.004.136-.003h.274l.136.003.136.004.136.006.136.007.136.01.133.01.135.013.135.014.135.016.134.018.132.018.134.021.133.023.133.024.133.025.13.027.132.03.132.03.129.031.13.034.129.035.129.036.13.04.126.038.128.042.126.042.128.045.127.047.126.048.12.047.127.051.123.052.006.002.147.048.16.021.16-.009.157-.038.147-.067.131-.093.112-.116.089-.135.062-.149.033-.158.004-.16-.027-.16-.055-.151-.083-.138-.107-.121-.127-.099-.118-.063-.004-.001-.005-.003-.005-.002-.133-.056-.005-.002-.005-.002-.134-.054-.004-.002-.005-.002-.135-.053-.005-.002-.005-.002-.135-.051-.005-.002-.005-.002-.135-.05-.005-.001-.005-.002-.137-.048-.005-.001-.005-.002-.137-.046-.005-.002-.005-.002-.137-.044-.005-.002-.005-.001-.138-.043-.005-.002-.006-.001-.138-.042-.005-.001-.005-.002-.14-.04H19.4l-.005-.002-.14-.038-.005-.001-.005-.002-.14-.036-.005-.001-.005-.001-.141-.035-.005-.001-.005-.001-.142-.033-.005-.001-.005-.001-.141-.031-.006-.002h-.005l-.142-.03-.005-.001-.005-.001-.143-.028h-.005l-.005-.001-.143-.026-.006-.001-.005-.001-.143-.024-.005-.001-.006-.001-.143-.022-.006-.001h-.005l-.144-.022h-.005l-.006-.001-.144-.019h-.005l-.006-.001-.144-.017h-.006l-.005-.001-.145-.016h-.011l-.145-.014H17.1l-.005-.001-.146-.012h-.01l-.146-.01-.006-.001h-.005l-.146-.009h-.011l-.147-.006h-.01l-.147-.005h-.011l-.147-.003h-.01l-.148-.001h-.01zM10.357 4.66l-.156.037-.123.053-.06.032-.005.002-.004.003-.128.069-.004.002-.005.003-.126.07-.005.003-.004.002-.126.072-.005.003-.004.003-.125.073-.004.003-.005.003-.124.075-.004.003-.005.002-.123.077-.004.003-.005.003-.122.078-.004.003-.005.003-.121.08-.004.002-.005.003-.12.082-.005.003-.004.003-.12.083-.004.003-.004.003-.118.084-.005.003-.004.003-.118.086-.004.003-.004.003-.117.088-.004.003-.004.003-.116.089-.004.003-.004.004-.114.09-.005.003-.004.003-.113.092-.004.004-.004.003-.113.093-.004.004-.004.003-.111.095-.004.003-.005.004-.11.096-.004.004-.004.003-.109.098-.004.003-.004.004-.108.1-.004.003-.004.003-.107.101-.004.004-.004.003-.106.102-.003.004-.004.004-.105.103-.004.004-.004.004-.103.105-.004.004-.004.003-.102.106-.003.004-.004.004-.1.107-.004.004-.004.004-.099.108-.004.004-.003.004-.098.11-.003.003-.004.004-.096.11-.004.005-.003.004-.095.111-.003.004-.004.004-.093.113-.003.004-.004.004-.092.113-.003.004-.003.005-.09.114-.004.004-.003.004-.089.116-.003.004-.003.004-.088.117-.003.004-.003.005-.086.117-.003.004-.003.005-.084.118-.003.004-.003.005-.083.12-.003.003-.003.005-.082.12-.003.005-.002.004-.068.103-.076.142-.048.154-.018.16.011.161.041.156.07.146.095.13.117.11.136.086.15.06.158.03.162.002.158-.029.15-.058.138-.085.119-.108.082-.106.065-.099.075-.11.077-.113.077-.107.08-.11.08-.108.084-.108.083-.105.086-.106.086-.104.088-.104.089-.101.09-.102.093-.101.093-.099.094-.097.095-.096.098-.097.098-.095.099-.093.1-.092.103-.091.101-.089.104-.088.104-.086.106-.086.106-.083.106-.082.109-.082.108-.079.11-.078.11-.076.112-.076.112-.074.113-.072.113-.071.115-.07.115-.068.118-.067.117-.065.12-.065.054-.029.135-.088.116-.111.094-.132.068-.146.04-.156.009-.161-.02-.16-.05-.153-.078-.142-.102-.125-.123-.103-.141-.079-.153-.051-.16-.022-.16.008zm13.91 2.116l-.158.037-.147.066-.132.092-.113.116-.09.134-.063.148-.034.157-.005.162.026.159.054.152.082.139.086.102.09.09.094.098.093.099.092.1.091.103.089.101.088.104.086.104.086.106.083.105.083.108.08.108.081.11.077.107.077.112.075.111.075.114.072.113.071.113.07.115.068.117.067.115.065.118.064.117.062.118.061.12.059.119.059.122.056.121.054.12.055.125.051.123.051.125.048.123.049.127.046.126.044.125.043.128.042.129.039.126.038.13.022.076.058.15.086.137.109.119.129.096.145.07.155.043.16.013.161-.017.155-.046.143-.074.126-.1.106-.122.082-.138.055-.152.025-.16-.005-.16-.026-.132-.023-.082-.002-.005-.001-.005-.042-.139-.001-.005-.002-.005-.043-.138-.001-.005-.002-.005-.044-.137-.002-.005-.002-.005-.046-.137-.002-.005-.001-.005-.048-.137-.002-.005-.002-.005-.05-.135-.001-.005-.002-.005-.051-.135-.002-.005-.002-.005-.053-.135-.002-.005-.002-.005-.054-.133-.002-.005-.002-.005-.057-.133-.002-.005-.002-.005-.057-.132-.003-.005-.002-.005-.059-.132-.002-.005-.002-.004-.061-.132-.003-.004-.002-.005-.062-.13-.003-.005-.002-.005-.064-.13-.003-.004-.002-.005-.066-.129-.002-.004-.003-.005-.067-.128-.002-.005-.003-.004-.069-.128-.002-.004-.003-.005-.07-.126-.003-.005-.003-.004-.072-.126-.002-.005-.003-.004-.073-.125-.003-.004-.003-.005-.075-.124-.003-.004-.003-.005-.076-.123-.003-.004-.003-.005-.078-.122-.003-.004-.003-.005-.08-.121-.003-.004-.003-.005-.08-.12-.004-.005-.003-.004-.083-.12-.003-.004-.003-.004-.084-.118-.003-.005-.003-.004-.086-.117-.003-.005-.003-.004-.088-.117-.003-.004-.003-.004-.09-.116-.002-.004-.004-.004-.09-.114-.003-.005-.004-.004-.091-.113-.004-.004-.003-.004-.093-.113-.004-.004-.003-.004-.095-.111-.004-.004-.003-.004-.096-.11-.004-.005-.003-.004-.098-.109-.004-.004-.003-.004-.1-.108-.003-.004-.004-.004-.1-.107-.004-.004-.004-.004-.102-.106-.003-.003-.004-.004-.093-.095-.124-.103-.14-.08-.153-.05-.16-.023-.16.008zM4.288 12.828l-.158.032-.15.06-.135.088-.117.11-.095.131-.069.146-.035.129-.026.132v.005l-.002.005-.025.143-.001.005-.001.006-.024.143-.001.005-.001.006-.022.143-.001.006-.001.005-.02.144-.001.005-.001.006-.019.144v.005l-.001.006-.017.144v.006l-.001.005-.016.145v.011l-.014.145v.006l-.001.005-.012.146v.01l-.01.146-.001.006v.005l-.009.146v.011l-.007.146v.011l-.004.147v.011l-.003.147v.01l-.002.148v.01l.001.148v.01l.003.147v.011l.005.147v.01l.007.147v.011l.009.146v.011l.01.146v.01l.013.146v.011l.014.145v.005l.001.006.016.145v.011l.018.144v.006l.001.005.019.144v.006l.001.005.021.144v.005l.002.006.022.143v.006l.002.005.024.143v.005l.002.006.025.143.001.005.001.005.028.143.001.005.001.005.03.142v.005l.002.006.03.141.002.005.001.006.033.14v.006l.002.005.035.14v.006l.002.005.036.14.002.005.001.005.038.14.001.005.002.005.04.14v.005l.002.005.042.138.001.006.002.005.042.138.002.005.002.005.017.054.064.148.09.134.114.114.132.092.148.065.157.037.16.007.16-.023.153-.052.14-.08.123-.103.102-.126.076-.142.049-.153.02-.16-.01-.161-.032-.13-.017-.051-.039-.126-.038-.13-.037-.128-.035-.13-.033-.128-.033-.134-.03-.13-.029-.131-.026-.13-.026-.132-.024-.134-.023-.133-.02-.132-.02-.136-.017-.132-.016-.135-.014-.135-.012-.133-.012-.138-.009-.133-.007-.136-.006-.138-.004-.134-.003-.136v-.274l.003-.136.004-.134.006-.139.007-.136.01-.132.01-.139.013-.132.014-.135.016-.135.017-.132.02-.137.02-.13.023-.134.024-.133.024-.126.016-.16-.014-.161-.044-.155-.072-.145-.098-.128-.12-.108-.137-.084-.15-.057-.16-.029-.16.002zm23.286 4.202l-.156.038-.148.066-.132.092-.113.115-.09.134-.062.148-.03.127-.001.004-.023.134-.024.134-.026.132-.026.13-.03.132-.03.129-.032.134-.033.128-.035.13-.037.128-.038.13-.04.126-.04.128-.044.128-.044.126-.046.126-.048.126-.05.125-.05.125-.051.122-.054.123-.055.122-.056.12-.058.122-.06.12-.061.12-.062.119-.063.116-.067.119-.066.116-.068.115-.07.115-.07.113-.073.113-.074.112-.076.113-.077.112-.077.107-.08.11-.08.108-.085.109-.044.056-.088.135-.06.15-.033.158-.002.16.027.16.057.15.083.138.108.12.128.098.144.072.155.045.16.015.161-.016.155-.044.144-.073.128-.098.09-.099.05-.061.003-.004.003-.005.089-.115.003-.004.003-.005.088-.116.003-.004.003-.005.086-.117.003-.004.003-.005.084-.118.003-.004.003-.005.083-.12.003-.004.003-.004.082-.12.003-.005.002-.004.08-.121.003-.005.003-.004.078-.122.003-.005.003-.004.077-.123.002-.005.003-.004.075-.124.003-.005.003-.004.073-.125.003-.004.003-.005.072-.126.002-.004.003-.005.07-.126.003-.005.002-.005.07-.127.002-.004.002-.005.068-.128.002-.005.002-.004.066-.13.003-.004.002-.005.064-.13.002-.004.003-.005.062-.13.003-.005.002-.005.06-.13.003-.005.002-.005.06-.132.002-.005.002-.005.057-.132.003-.005.002-.005.056-.133.002-.005.002-.005.054-.134.002-.004.002-.005.053-.135.002-.005.002-.005.051-.135.002-.005.002-.005.05-.135.001-.005.002-.005.048-.137.001-.005.002-.005.046-.137.002-.005.002-.005.044-.137.002-.005.002-.005.042-.138.002-.005.002-.006.04-.138.002-.005.002-.005.04-.14V19.4l.002-.005.038-.14.001-.005.002-.005.036-.14.001-.005.001-.005.035-.141.001-.005.001-.005.033-.141.001-.006.001-.005.031-.141.002-.006v-.005l.03-.142.001-.005.001-.005.028-.143v-.005l.002-.005.025-.143.001-.006.001-.005.024-.143.001-.005.001-.006.001-.006.01-.161-.02-.16-.05-.154-.077-.141-.102-.125-.123-.104-.141-.079-.153-.051-.16-.022-.16.007zM6.681 22.734l-.152.053-.14.08-.122.105-.101.126-.076.142-.048.154-.018.16.011.161.041.156.07.146.077.11.04.047.003.004.003.004.095.111.003.004.004.004.096.11.004.005.003.004.098.109.003.004.004.004.1.108.003.004.003.004.101.107.004.004.003.004.102.106.004.003.004.004.103.105.004.004.004.004.105.103.004.004.003.003.106.102.004.004.004.004.107.1.004.004.004.004.108.099.004.003.004.004.11.098.003.003.004.004.11.096.005.004.004.003.11.095.005.003.004.004.113.093.004.003.004.004.113.091.004.004.005.003.114.09.004.004.004.003.116.089.004.003.004.003.117.088.004.003.004.003.118.086.004.003.005.003.118.084.004.003.005.003.119.083.004.003.005.003.12.081.005.003.004.003.121.08.005.003.004.003.122.078.005.003.004.003.123.076.005.003.004.003.124.075.005.003.004.003.125.073.004.003.005.003.126.072.004.002.005.003.126.07.005.003.004.002.128.07.004.002.005.002.128.068.005.002.004.002.13.066.004.003.005.002.13.064.004.002.005.003.13.062.005.002.004.003.132.06.004.003.005.002.132.06.005.002.005.002.132.057.005.002.005.003.133.056.005.002.005.002.133.054.005.002.005.002.13.05.154.045.16.016.161-.015.155-.045.144-.072.128-.098.108-.12.083-.138.057-.15.028-.16-.003-.16-.032-.158-.061-.15-.088-.135-.11-.117-.132-.094-.12-.058-.124-.049-.126-.051-.122-.051-.122-.054-.12-.054-.126-.058-.119-.057-.12-.06-.12-.06-.118-.063-.117-.064-.119-.066-.116-.066-.115-.068-.115-.07-.113-.07-.115-.074-.112-.074-.11-.075-.11-.076-.112-.079-.11-.08-.109-.082-.106-.082-.104-.082-.106-.086-.105-.087-.101-.086-.105-.091-.1-.09-.1-.091-.1-.094-.097-.094-.1-.098-.093-.095-.096-.1-.093-.098-.092-.101-.089-.1-.09-.102-.088-.104-.036-.043-.114-.114-.133-.091-.148-.065-.157-.036-.161-.006-.16.024zm15.063 2.691l-.156.044-.12.057-.06.034-.12.066-.116.064-.119.062-.12.061-.12.06-.118.057-.126.058-.12.054-.122.054-.122.05-.126.052-.125.05-.124.046-.127.047-.125.044-.129.043-.126.04-.13.042-.128.038-.127.036-.13.035-.131.034-.129.031-.132.03-.13.03-.135.027-.133.026-.13.023-.13.022-.137.021-.132.02-.134.017-.132.015-.138.015-.135.013-.133.01-.138.01-.136.007-.134.006-.136.004-.14.003-.16.018-.155.047-.142.076-.127.1-.105.122-.08.14-.054.151-.025.16.006.16.035.158.064.148.09.134.114.114.133.092.147.065.157.036.134.008.145-.002h.011l.147-.005h.01l.147-.007h.011l.146-.009h.011l.146-.01h.005l.005-.001.146-.012h.011l.145-.014h.005l.006-.001.145-.016h.011l.144-.018h.006l.005-.001.144-.02h.011l.144-.021h.005l.006-.002.143-.022h.006l.005-.002.143-.024h.005l.006-.002.143-.026h.005l.005-.002.143-.027.005-.001.005-.001.142-.03h.005l.005-.002.142-.03.005-.002.005-.001.142-.033.005-.001.005-.001.14-.035.006-.001.005-.001.14-.036.005-.002.005-.001.14-.038.005-.001.005-.002.14-.04h.005l.005-.002.138-.042.005-.001.006-.002.138-.043.005-.001.005-.002.137-.044.005-.002.005-.002.137-.046.005-.002.005-.001.137-.048.005-.002.005-.002.135-.05.005-.001.005-.002.135-.051.005-.002.005-.002.135-.053.005-.002.004-.002.134-.054.005-.002.005-.002.133-.056.005-.003.005-.002.132-.057.005-.002.005-.003.132-.059.005-.002.004-.002.131-.061.005-.003.005-.002.13-.062.005-.003.005-.002.13-.064.004-.002.005-.003.129-.066.004-.002.005-.003.128-.067.005-.002.004-.003.127-.069.005-.002.005-.003.126-.07.005-.003.004-.002.065-.038.132-.093.112-.115.089-.135.062-.149.034-.157.004-.161-.027-.16-.055-.15-.082-.14-.107-.12-.127-.1-.144-.073-.154-.045-.16-.017-.161.014zM15.994 0l-.187.001h-.011l-.188.004h-.011l-.187.006h-.011l-.187.008h-.005L15.2.02l-.187.01h-.005l-.005.001-.187.013h-.01L14.62.06h-.01l-.186.018h-.011l-.185.02-.005.001h-.006l-.185.022-.005.001h-.005l-.185.025h-.005l-.005.001-.184.027h-.006l-.005.001-.184.029h-.005l-.005.001-.183.031-.005.001-.006.001-.182.033-.006.001-.005.001-.182.035-.005.001-.005.001-.182.038h-.005l-.005.002-.181.04h-.005l-.005.002-.18.042-.006.001-.005.001-.18.044-.005.002h-.005l-.17.045-.152.054-.139.082-.121.106-.1.127-.074.143-.046.155-.017.16.013.16.043.156.07.145.097.13.119.108.137.085.15.058.159.03.16-.001.133-.023.165-.043.168-.041.171-.04.171-.037.172-.036.17-.033.173-.03.17-.03.177-.027.171-.025.175-.022.175-.02.175-.02.176-.016.175-.014.177-.012.176-.01.177-.007.174-.006.177-.003L16 1.73h.177l.178.004.174.006.177.007.176.01.177.012.175.014.176.017.175.018.175.02.175.023.171.025.177.027.17.03.173.03.17.033.171.036.154.033.16.02.161-.01.156-.04.146-.069.131-.094.111-.117.088-.135.06-.15.032-.158.002-.16-.027-.16-.057-.15L20 .714l-.108-.12-.128-.097-.144-.073-.129-.038-.158-.035-.005-.001-.005-.001L19.14.31h-.005l-.005-.002-.182-.035h-.006l-.005-.002-.182-.033h-.006l-.005-.002-.183-.03-.005-.001-.005-.001-.184-.029h-.005l-.006-.001-.184-.027h-.005l-.005-.001-.185-.024h-.005L17.968.12 17.783.1l-.006-.001h-.005l-.185-.02h-.006l-.005-.001L17.39.06 17.385.06h-.005l-.187-.015h-.005l-.005-.001-.187-.013h-.01L16.799.02h-.011L16.6.01h-.011l-.187-.006h-.011L16.204 0h-.011L16.005 0h-.01zm8.86 2.939l-.157.033-.15.062-.134.09-.116.111-.093.132-.067.147-.038.156-.01.161.022.16.05.153.078.141.103.124.102.087.045.034.142.106.137.105.14.11.136.11.135.112.134.115.134.117.13.115.132.122.128.12.127.122.127.125.123.126.124.128.121.13.118.128.118.132.117.133.113.134.113.136.11.136.109.137.109.142.104.14.103.14.101.142.1.144.099.146.095.145.094.147.093.15.092.15.087.149.087.15.085.152.083.155.08.152.08.155.04.081.084.138.11.119.128.096.145.072.155.043.16.013.161-.016.155-.046.143-.074.127-.099.106-.12.083-.14.055-.151.026-.16-.004-.16-.034-.158-.05-.124-.042-.085-.002-.004-.003-.005-.084-.165-.002-.004-.003-.005-.086-.164-.002-.004-.003-.005-.088-.162-.002-.005-.003-.005-.09-.161-.002-.005-.003-.004-.092-.16-.002-.005-.003-.005-.094-.16-.003-.004-.003-.004-.096-.159-.002-.004-.003-.005-.098-.157-.003-.004-.003-.005-.1-.156-.003-.004-.002-.005-.102-.154-.003-.005-.003-.004-.104-.154-.003-.004-.003-.005-.106-.152-.003-.004-.003-.005-.108-.151-.003-.004-.003-.005-.11-.15-.003-.004-.003-.004-.111-.15-.004-.003-.003-.005-.113-.147-.004-.004-.003-.005-.115-.146-.004-.004-.003-.004-.117-.145-.004-.004-.003-.004-.12-.144-.003-.004-.003-.004-.121-.142-.003-.004-.004-.004-.123-.141-.003-.004-.004-.004-.125-.14-.003-.004-.004-.004-.127-.138-.003-.004-.004-.004-.128-.136-.004-.004-.004-.004-.13-.135-.004-.004-.003-.004-.133-.134-.003-.004-.004-.003-.134-.133-.004-.003-.004-.004-.135-.13-.004-.004-.004-.004-.136-.128-.004-.004-.004-.004-.138-.126-.004-.004-.004-.003-.14-.125-.004-.004-.004-.003-.14-.123-.005-.004-.004-.003-.142-.121-.004-.004-.004-.003-.144-.12-.004-.003-.004-.003-.145-.117-.004-.004-.004-.003-.147-.115-.004-.004-.004-.003-.148-.113-.004-.003-.004-.004-.149-.111-.004-.003-.004-.004-.05-.036-.14-.083-.15-.055-.16-.027-.16.004zm-18.381.348l-.157.037-.147.066-.111.074-.04.032-.005.003-.004.004-.145.117-.004.003-.004.004-.144.119-.004.003-.004.004-.142.12-.004.004-.004.004-.141.123-.004.003-.004.004-.14.125-.004.003-.004.004-.138.126-.004.004-.004.004-.136.128-.004.004-.004.004-.135.13-.004.004-.004.003-.134.133-.004.003-.004.004-.132.134-.003.004-.004.004-.13.135-.004.004-.004.004-.128.136-.004.004-.004.004-.126.138-.004.004-.003.004-.125.14-.004.004-.003.004-.123.14-.004.005-.003.004-.121.142-.004.004-.003.004-.12.144-.003.004-.003.004-.117.145-.004.004-.003.004-.115.146-.004.005-.003.004-.113.147-.003.005-.004.004-.111.149-.003.004-.004.004-.11.15-.002.005-.003.004-.108.151-.003.005-.003.004-.106.152-.003.005-.003.004-.104.154-.003.004-.003.005-.102.154-.003.005-.002.004-.1.156-.003.005-.003.004-.098.157-.003.005-.003.004-.096.159-.002.004-.003.005-.094.16-.003.004-.002.004-.092.16-.003.005-.003.005-.09.161-.002.005-.003.005-.088.162-.002.005-.003.004-.086.164-.002.005-.002.004-.084.165-.003.005-.002.004-.082.166-.002.005-.003.004-.08.167-.002.004-.002.005-.078.168-.002.004-.002.005-.045.1-.053.153-.023.16.007.16.037.157.065.148.092.132.114.114.134.09.148.064.157.035.161.006.16-.025.152-.054.14-.08.121-.106.1-.126.065-.118.043-.095.074-.16.075-.155.077-.157.08-.155.08-.152.083-.155.085-.152.086-.15.088-.149.091-.15.094-.15.094-.147.095-.145.099-.146.1-.144.1-.142.104-.14.104-.14.11-.142.107-.137.11-.136.114-.136.113-.134.117-.133.118-.132.117-.129.122-.13.124-.127.123-.126.127-.125.127-.122.128-.12.132-.122.13-.115.133-.117.135-.115.135-.111.136-.11.037-.03.117-.11.094-.132.068-.146.04-.156.01-.161-.02-.16-.05-.154-.076-.141-.102-.125-.123-.104-.14-.08-.153-.051-.16-.023-.161.008zm24.514 11.15l-.157.04-.146.067-.131.093-.112.117-.088.135-.061.149-.033.157-.005.134.006.14.006.176.003.177.001.178-.001.177-.003.178-.006.177-.007.176-.01.177-.012.176-.015.176-.016.173-.018.175-.02.175-.024.174-.024.175-.027.17-.03.174-.03.173-.033.17-.036.172-.037.17-.04.17-.042.172-.043.168-.045.166-.048.169-.05.167-.052.168-.053.164-.056.166-.058.166-.06.161-.061.164-.063.158-.066.165-.068.16-.07.16-.07.158-.075.159-.074.155-.078.158-.081.158-.06.15-.03.158-.001.161.029.159.058.15.085.137.108.12.13.096.144.07.156.044.16.013.16-.017.155-.046.143-.074.127-.1.107-.12.07-.115.083-.164.003-.005.002-.004.082-.166.002-.005.003-.004.08-.167.002-.005.002-.004.078-.168.002-.004.002-.005.076-.169.002-.004.002-.005.074-.17.002-.004.002-.005.072-.17.002-.005.002-.005.07-.17.002-.006.001-.005.068-.172.002-.004.002-.005.065-.173.002-.005.002-.005.063-.173.002-.005.002-.005.06-.174.003-.005.001-.005.06-.175.001-.005.002-.005.057-.176.001-.005.002-.005.055-.177.001-.005.002-.005.052-.177.002-.005.001-.005.051-.178.001-.005.002-.005.048-.179.002-.005v-.005l.047-.179.001-.005.002-.005.044-.18v-.005l.002-.005.042-.18.001-.006.001-.005.04-.18.001-.006.001-.005.038-.182v-.005l.002-.005.035-.182v-.006l.002-.005.033-.182v-.006l.002-.005.03-.183.001-.005.001-.005.029-.184v-.005l.001-.006.027-.184v-.005l.001-.005.024-.185v-.005l.001-.005.022-.185v-.006l.001-.005.02-.185v-.006l.001-.005.017-.186v-.005l.001-.005.015-.187v-.005l.001-.005.013-.187v-.01l.01-.187.001-.006v-.005l.009-.187v-.011l.006-.187v-.011l.004-.188v-.011l.001-.188v-.01l-.001-.188v-.011l-.004-.188v-.011l-.006-.187v-.011l-.007-.145-.022-.16-.05-.152-.08-.141-.103-.124-.125-.102-.141-.077-.153-.05-.16-.02-.161.009zM.777 15l-.158.032-.15.06-.136.087-.117.11-.095.131-.068.146-.04.156-.012.133-.001.14v.01l.001.188v.011l.004.188v.011l.006.187v.011l.008.187v.011l.011.187v.005l.001.005.013.187v.01l.016.187v.01l.018.186v.011l.02.185.001.005v.006l.022.185.001.005v.005l.025.185v.005l.001.005.027.184v.006l.001.005.029.184v.005l.001.005.031.183.001.005.001.006.033.182.001.005.001.006.035.182.001.005.001.005.038.182v.005l.002.005.04.181v.005l.002.005.042.18.001.006.001.005.044.18.002.005v.005l.047.18.001.004.002.005.048.179.002.005.001.005.05.178.002.005.001.005.053.177.002.005.001.005.055.177.002.005.001.005.057.176.002.005.001.005.06.175.001.005.002.005.061.174.002.005.002.005.063.173.002.005.002.005.065.173.002.005.002.004.067.172.002.005.002.005.07.171.002.005.002.005.072.17.002.005.002.005.074.169.002.005.002.004.076.169.002.005.002.004.078.168.002.004.002.005.08.167.003.004.002.005.082.166.002.004.003.005.02.04.086.136.11.118.13.095.146.07.156.041.16.012.16-.019.155-.048.142-.075.126-.1.105-.123.08-.14.054-.152.024-.16-.006-.16-.036-.158-.051-.123-.018-.034-.078-.158L3.1 22.1l-.074-.16-.071-.156-.07-.162-.068-.16-.067-.164-.062-.158-.062-.164-.059-.161-.058-.166-.056-.166-.053-.164-.052-.168-.05-.167-.048-.17-.045-.165-.043-.168-.043-.172-.039-.17-.037-.17-.036-.172-.033-.17-.03-.173-.03-.174-.027-.17-.025-.175-.022-.174-.021-.175-.018-.175-.017-.173-.014-.176-.012-.176-.01-.177-.007-.176-.006-.177-.003-.178L1.73 16v-.134l-.013-.16-.044-.156-.072-.144-.097-.129-.12-.108-.137-.085-.15-.057L.938 15 .777 15zM6.17 26.842l-.152.052-.14.08-.122.105-.101.126-.076.142-.048.154-.02.16.012.161.041.156.07.146.094.13.096.093.032.026.004.003.004.004.145.117.004.003.004.004.146.115.005.003.004.004.147.113.005.003.004.004.149.111.004.003.004.003.15.11.005.003.004.003.151.108.005.003.004.003.152.106.005.003.004.003.154.104.004.003.005.003.154.102.005.002.004.003.156.1.005.003.004.003.157.098.005.003.004.002.159.096.004.003.005.003.16.094.004.003.004.002.16.092.005.003.005.002.161.09.005.003.005.003.162.088.005.002.004.002.164.087.005.002.004.002.165.084.005.003.004.002.166.082.004.002.005.003.167.08.004.002.005.002.168.078.004.002.005.002.169.076.004.002.005.002.17.074.004.002.005.002.17.072.005.002.005.002.17.07.006.002.005.001.171.068.005.002.005.002.173.065.005.002.005.002.173.063.005.002.005.002.174.061.005.002.005.001.175.06.005.001.005.002.176.057.005.001.005.002.177.055.005.001.005.002.177.052.005.002.005.001.178.051.005.001.005.002.178.048.006.002h.005l.179.047.005.001.005.002.18.044h.005l.005.002.18.042.006.001.005.001.159.035.16.02.16-.01.157-.04.146-.069.13-.094.112-.117.087-.136.06-.149.033-.158.002-.161-.028-.159-.057-.15-.084-.138-.108-.12-.128-.098-.144-.072-.128-.039-.154-.033-.168-.04-.171-.041-.169-.044-.17-.045-.166-.048-.168-.05-.165-.051-.166-.054-.166-.056-.163-.057-.165-.06-.161-.062-.164-.064-.16-.065-.16-.068-.162-.07-.157-.07-.157-.074-.157-.075-.156-.077-.153-.079-.156-.082-.153-.082-.154-.086-.15-.086-.152-.09-.148-.09-.147-.092-.149-.095-.145-.095-.144-.098-.145-.1-.143-.102-.14-.103-.14-.104-.14-.108-.139-.11-.136-.11-.027-.022-.133-.091-.148-.065-.157-.036-.161-.006-.16.024zm19.214.073l-.156.039-.146.067-.11.076-.064.051-.139.11-.14.108-.14.104-.14.103-.143.101-.145.101-.144.098-.145.095-.149.095-.148.093-.147.089-.152.09-.15.086-.154.086-.153.082-.156.082-.153.079-.156.077-.157.075-.157.073-.158.071-.16.07-.16.068-.161.065-.164.064-.161.061-.165.06-.163.058-.166.056-.166.054-.166.051-.167.05-.167.048-.17.045-.168.044-.171.042-.168.039-.17.037-.11.023-.154.047-.143.075-.126.1-.106.122-.081.139-.054.152-.025.16.006.16.035.158.063.148.09.133.114.115.132.092.148.065.157.037.16.008.133-.017.115-.024h.005l.005-.002.181-.04h.005l.005-.002.18-.042.006-.001.005-.001.18-.044.005-.002h.005l.18-.047.004-.001.005-.002.179-.048.005-.002.005-.001.178-.05.005-.002.005-.002.177-.052.005-.002.005-.001.177-.055.005-.002.005-.001.176-.057.005-.002.005-.002.175-.059.005-.001.005-.002.174-.061.005-.002.005-.002.173-.063.005-.002.005-.002.173-.065.005-.002.004-.002.172-.068.005-.001.005-.002.171-.07.005-.002.005-.002.17-.072.005-.002.005-.002.169-.074.005-.002.004-.002.169-.076.004-.002.005-.002.168-.078.004-.002.005-.002.167-.08.004-.003.005-.002.166-.082.004-.002.005-.003.165-.084.004-.002.005-.002.163-.087.005-.002.005-.002.162-.088.005-.003.005-.003.161-.09.005-.002.004-.003.16-.092.005-.002.005-.003.16-.094.004-.003.004-.003.158-.096.005-.002.004-.003.158-.098.004-.003.005-.003.156-.1.004-.003.004-.002.155-.102.005-.003.004-.003.154-.104.004-.003.005-.003.152-.106.004-.003.005-.003.151-.108.004-.003.005-.003.15-.11.004-.003.004-.003.149-.111.004-.004.004-.003.148-.113.004-.004.004-.003.147-.115.004-.004.004-.003.068-.055.116-.113.092-.132.066-.147.038-.157.008-.16-.022-.16-.05-.153-.08-.14-.103-.125-.124-.102-.142-.077-.153-.05-.16-.02-.16.009z"
  })));

  function _extends$H() { _extends$H = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$H.apply(this, arguments); }
  var IntermediateEventCatchParallelMultipleIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$H({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.975.003C8.195-.157.935 6.24.125 13.985c-.855 6.55 2.741 13.46 8.74 16.314 5.666 2.847 13.012 1.99 17.71-2.33 4.745-4.162 6.727-11.243 4.532-17.206C29.09 4.884 23.445.408 17.201.049c-.408-.03-.817-.046-1.226-.046zm-.181 1.724c7.134-.269 13.84 5.68 14.399 12.804.686 6.283-3.267 12.792-9.283 14.862-5.847 2.162-13.025.06-16.557-5.141C.728 19.174.872 11.679 4.985 6.916c2.632-3.171 6.671-5.174 10.809-5.19zm.283 1.553c-6.6-.21-12.671 5.585-12.79 12.185-.292 5.964 4.129 11.817 10.034 12.953 5.47 1.198 11.584-1.613 14.025-6.702 2.525-4.97 1.396-11.585-2.912-15.215-2.282-2.022-5.3-3.217-8.357-3.22zM16 4.975c5.818-.154 11.117 5.082 11.024 10.905.103 5.384-4.23 10.5-9.636 11.043-5.075.667-10.426-2.587-11.885-7.552-1.53-4.73.48-10.428 4.888-12.864A11.082 11.082 0 0116 4.975zm-2.15 3.281v5.534H8.213v4.38h5.636v5.534h4.31V18.17h5.639v-4.38h-5.64V8.256h-4.31zm.865.865h2.583v5.534h5.635v2.65h-5.635v5.533h-2.583v-5.534h-5.64v-2.649h5.64V9.121z"
  })));

  function _extends$G() { _extends$G = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$G.apply(this, arguments); }
  var IntermediateEventCatchSignalIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$G({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.975.049C8.195-.11.935 6.286.125 14.03c-.855 6.55 2.741 13.46 8.74 16.314 5.666 2.847 13.012 1.99 17.71-2.33 4.745-4.162 6.727-11.243 4.532-17.206C29.09 4.93 23.445.453 17.201.095c-.408-.03-.817-.046-1.226-.046zm-.181 1.724c7.134-.269 13.84 5.68 14.399 12.804.686 6.283-3.267 12.792-9.283 14.862-5.847 2.162-13.025.06-16.557-5.141C.728 19.22.872 11.725 4.985 6.962c2.632-3.171 6.671-5.174 10.809-5.19zm.283 1.553c-6.6-.21-12.671 5.585-12.79 12.185-.292 5.964 4.129 11.817 10.034 12.953 5.47 1.198 11.584-1.613 14.025-6.702 2.525-4.97 1.396-11.585-2.912-15.216-2.282-2.021-5.3-3.216-8.357-3.22zM16 5.021c5.818-.154 11.117 5.082 11.024 10.905.103 5.384-4.23 10.5-9.636 11.043-5.075.667-10.426-2.587-11.885-7.552-1.53-4.73.48-10.428 4.888-12.864A11.083 11.083 0 0116 5.021zm.006 3.521L9.206 20.745h13.598L16.005 8.542zm0 1.775l5.329 9.564H10.677l5.328-9.564z"
  })));

  function _extends$F() { _extends$F = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$F.apply(this, arguments); }
  var IntermediateEventCatchTimerIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$F({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.97.04h-.127C8.713-.018 2.003 5.334.437 12.286c-1.51 6.123.98 13.005 6.136 16.665 5.125 3.788 12.546 4.105 17.912.623 5.272-3.276 8.33-9.766 7.325-15.916-.904-6.241-5.79-11.7-11.95-13.143A16.082 16.082 0 0015.97.04zm-.181 1.724c.115 0 .23 0 .347.003 6.625-.066 12.823 5.149 13.89 11.69 1.13 5.91-1.908 12.349-7.262 15.138-5.473 3.013-12.866 1.884-17.116-2.726C1.291 21.372.444 13.914 3.802 8.602c2.493-4.112 7.169-6.819 11.987-6.838zm.283 1.554c-.117 0-.234.002-.351.005-6.1 0-11.691 5.049-12.346 11.114-.78 5.684 2.795 11.612 8.218 13.52 5.139 1.943 11.416.101 14.624-4.38 3.461-4.583 3.262-11.538-.596-15.831-2.36-2.747-5.924-4.423-9.549-4.428zm-.078 1.695c.078 0 .156 0 .234.003 5.4 0 10.321 4.556 10.734 9.942.563 5.13-2.958 10.364-7.971 11.678-4.832 1.41-10.457-.935-12.746-5.446-2.463-4.559-1.2-10.795 3.014-13.883a11.072 11.072 0 016.735-2.294zm-.137 3.42c-2.965.02-5.792 1.968-6.884 4.722-1.137 2.693-.509 6.007 1.536 8.096 1.988 2.14 5.263 2.929 8.007 1.926 2.875-.98 4.987-3.824 5.063-6.865.154-2.954-1.622-5.875-4.295-7.13a7.545 7.545 0 00-3.427-.75zm.27 1.381c2.708.013 5.249 2.014 5.88 4.652.704 2.576-.481 5.512-2.788 6.862-2.356 1.478-5.677 1.084-7.611-.918-2.042-1.97-2.405-5.376-.839-7.738 1.11-1.762 3.146-2.877 5.229-2.857h.13zm1.831 1.764l-2.072 3.76c-.64.068-.792 1.039-.202 1.298.39.27.696-.18 1.051-.164h3.168v-.864h-3.18l1.992-3.612-.757-.418z"
  })));

  function _extends$E() { _extends$E = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$E.apply(this, arguments); }
  var IntermediateEventNoneIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$E({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.848.001C8.113-.093.931 6.281.125 13.983c-.855 6.55 2.741 13.46 8.74 16.314 5.666 2.847 13.012 1.99 17.71-2.33 4.745-4.162 6.727-11.243 4.532-17.207C29.105 4.938 23.55.48 17.367.06A16.448 16.448 0 0015.848 0v.001zm.293 1.727c7.113-.099 13.662 5.97 14.077 13.08.56 6.299-3.516 12.735-9.582 14.679-5.798 2.004-12.806-.12-16.283-5.237C.717 19.159.874 11.638 5.016 6.876 7.722 3.638 11.902 1.63 16.14 1.728zm-.415 1.555C9.157 3.258 3.256 9.156 3.278 15.729c-.16 5.965 4.365 11.725 10.293 12.737 5.409 1.065 11.37-1.744 13.775-6.753 2.534-4.986 1.386-11.627-2.953-15.251-2.364-2.077-5.512-3.27-8.667-3.18zm.507 1.692c5.82-.026 11.013 5.318 10.79 11.143-.024 5.3-4.313 10.267-9.636 10.803-5.075.667-10.426-2.588-11.885-7.553-1.535-4.744.494-10.46 4.925-12.885a11.072 11.072 0 015.806-1.508z"
  })));

  function _extends$D() { _extends$D = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$D.apply(this, arguments); }
  var IntermediateEventThrowCompensationIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$D({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.975.003C8.195-.156.935 6.24.125 13.985c-.855 6.55 2.741 13.46 8.74 16.314 5.666 2.847 13.012 1.99 17.71-2.33 4.745-4.162 6.727-11.243 4.532-17.206C29.09 4.884 23.445.407 17.201.049c-.408-.03-.817-.046-1.226-.046zm-.181 1.724c7.134-.269 13.84 5.68 14.399 12.804.686 6.283-3.267 12.792-9.283 14.862-5.847 2.162-13.025.06-16.557-5.141C.728 19.174.872 11.679 4.985 6.916c2.632-3.171 6.671-5.174 10.809-5.19zm.283 1.553c-6.6-.21-12.671 5.585-12.79 12.185-.292 5.964 4.129 11.817 10.034 12.953 5.47 1.198 11.584-1.613 14.025-6.702 2.525-4.97 1.396-11.585-2.912-15.216-2.282-2.021-5.3-3.216-8.357-3.22zM16 4.975c5.818-.154 11.117 5.082 11.024 10.905.103 5.384-4.23 10.5-9.636 11.043-5.075.667-10.426-2.587-11.885-7.552-1.53-4.73.48-10.428 4.888-12.864A11.083 11.083 0 0116 4.975zm-.56 5.772l-7.408 5.231 7.409 5.234v-5.057c2.385 1.687 4.771 3.371 7.157 5.057V10.747l-7.157 5.055v-5.055z"
  })));

  function _extends$C() { _extends$C = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$C.apply(this, arguments); }
  var IntermediateEventThrowEscalationIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$C({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.975.049C8.195-.11.935 6.286.125 14.03c-.855 6.55 2.741 13.46 8.74 16.314 5.666 2.847 13.012 1.99 17.71-2.33 4.745-4.162 6.727-11.243 4.532-17.206C29.09 4.93 23.445.453 17.201.095c-.408-.03-.817-.046-1.226-.046zm-.181 1.724c7.134-.269 13.84 5.68 14.399 12.804.686 6.283-3.267 12.792-9.283 14.862-5.847 2.162-13.025.06-16.557-5.141C.728 19.22.872 11.725 4.985 6.962c2.632-3.171 6.671-5.174 10.809-5.19zm.283 1.553c-6.6-.21-12.671 5.585-12.79 12.185-.292 5.964 4.129 11.817 10.034 12.953 5.47 1.198 11.584-1.613 14.025-6.702 2.525-4.97 1.396-11.585-2.912-15.216-2.282-2.021-5.3-3.216-8.357-3.22zM16 5.021c5.818-.154 11.117 5.082 11.024 10.905.103 5.384-4.23 10.5-9.636 11.043-5.075.667-10.426-2.587-11.885-7.552-1.53-4.73.48-10.428 4.888-12.864A11.083 11.083 0 0116 5.021zm.006 3.927c-1.672 4.654-2.734 9.502-4.406 14.155 1.534-1.525 2.872-3.234 4.406-4.759l4.406 4.76c-1.496-4.71-2.91-9.446-4.406-14.156z"
  })));

  function _extends$B() { _extends$B = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$B.apply(this, arguments); }
  var IntermediateEventThrowLinkIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$B({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.975.049C8.195-.11.935 6.286.125 14.03c-.855 6.55 2.741 13.46 8.74 16.314 5.666 2.847 13.012 1.99 17.71-2.33 4.745-4.162 6.727-11.243 4.532-17.206C29.09 4.93 23.445.453 17.201.095c-.408-.03-.817-.046-1.226-.046zm-.181 1.724c7.134-.269 13.84 5.68 14.399 12.804.686 6.283-3.267 12.792-9.283 14.862-5.847 2.162-13.025.06-16.557-5.141C.728 19.22.872 11.725 4.985 6.962c2.632-3.171 6.671-5.174 10.809-5.19zm.283 1.553c-6.6-.21-12.671 5.585-12.79 12.185-.292 5.964 4.129 11.817 10.034 12.953 5.47 1.198 11.584-1.613 14.025-6.702 2.525-4.97 1.396-11.585-2.912-15.216-2.282-2.021-5.3-3.216-8.357-3.22zM16 5.021c5.818-.154 11.117 5.082 11.024 10.905.103 5.384-4.23 10.5-9.636 11.043-5.075.667-10.426-2.587-11.885-7.552-1.53-4.73.48-10.428 4.888-12.864A11.083 11.083 0 0116 5.021zm1.78 4.093v3.555H9.785v6.714h7.994v3.554l5.829-6.911-5.83-6.912z"
  })));

  function _extends$A() { _extends$A = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$A.apply(this, arguments); }
  var IntermediateEventThrowMessageIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$A({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.975.003C8.195-.156.935 6.24.125 13.985c-.855 6.55 2.741 13.46 8.74 16.314 5.666 2.847 13.012 1.99 17.71-2.33 4.745-4.162 6.727-11.243 4.532-17.206C29.09 4.884 23.445.407 17.201.049c-.408-.03-.817-.046-1.226-.046zm-.181 1.724c7.134-.269 13.84 5.68 14.399 12.804.686 6.283-3.267 12.792-9.283 14.862-5.847 2.162-13.025.06-16.557-5.141C.728 19.174.872 11.679 4.985 6.916c2.632-3.171 6.671-5.174 10.809-5.19zm.283 1.553c-6.6-.21-12.671 5.585-12.79 12.185-.292 5.964 4.129 11.817 10.034 12.953 5.47 1.198 11.584-1.613 14.025-6.702 2.525-4.97 1.396-11.585-2.912-15.216-2.282-2.021-5.3-3.216-8.357-3.22zM16 4.975c5.818-.154 11.117 5.082 11.024 10.905.103 5.384-4.23 10.5-9.636 11.043-5.075.667-10.426-2.587-11.885-7.552-1.53-4.73.48-10.428 4.888-12.864A11.083 11.083 0 0116 4.975zm-5.91 5.475l6.04 4.901 6.042-4.9H10.088zm-1.341 1.138v9.921h14.514V11.79l-7.132 5.787-7.382-5.99z"
  })));

  function _extends$z() { _extends$z = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$z.apply(this, arguments); }
  var IntermediateEventThrowMultipleIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$z({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.975.003C8.195-.156.935 6.24.125 13.985c-.855 6.55 2.741 13.46 8.74 16.314 5.666 2.847 13.012 1.99 17.71-2.33 4.745-4.162 6.727-11.243 4.532-17.206C29.09 4.884 23.445.407 17.201.049c-.408-.03-.817-.046-1.226-.046zm-.181 1.724c7.134-.269 13.84 5.68 14.399 12.804.686 6.283-3.267 12.792-9.283 14.862-5.847 2.162-13.025.06-16.557-5.141C.728 19.174.872 11.679 4.985 6.916c2.632-3.171 6.671-5.174 10.809-5.19zm.283 1.553c-6.6-.21-12.671 5.585-12.79 12.185-.292 5.964 4.129 11.817 10.034 12.953 5.47 1.198 11.584-1.613 14.025-6.702 2.525-4.97 1.396-11.585-2.912-15.216-2.282-2.021-5.3-3.216-8.357-3.22zM16 4.975c5.818-.154 11.117 5.082 11.024 10.905.103 5.384-4.23 10.5-9.636 11.043-5.075.667-10.426-2.587-11.885-7.552-1.53-4.73.48-10.428 4.888-12.864A11.083 11.083 0 0116 4.975zm.006 3.073l-7.62 5.532 2.91 8.95h9.42l2.91-8.95-7.62-5.532z"
  })));

  function _extends$y() { _extends$y = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$y.apply(this, arguments); }
  var IntermediateEventThrowSignalIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$y({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.975.003C8.195-.156.935 6.24.125 13.985c-.855 6.55 2.741 13.46 8.74 16.314 5.666 2.847 13.012 1.99 17.71-2.33 4.745-4.162 6.727-11.243 4.532-17.206C29.09 4.884 23.445.407 17.201.049c-.408-.03-.817-.046-1.226-.046zm-.181 1.724c7.134-.269 13.84 5.68 14.399 12.804.686 6.283-3.267 12.792-9.283 14.862-5.847 2.162-13.025.06-16.557-5.141C.728 19.174.872 11.679 4.985 6.916c2.632-3.171 6.671-5.174 10.809-5.19zm.283 1.553c-6.6-.21-12.671 5.585-12.79 12.185-.292 5.964 4.129 11.817 10.034 12.953 5.47 1.198 11.584-1.613 14.025-6.702 2.525-4.97 1.396-11.585-2.912-15.216-2.282-2.021-5.3-3.216-8.357-3.22zM16 4.975c5.818-.154 11.117 5.082 11.024 10.905.103 5.384-4.23 10.5-9.636 11.043-5.075.667-10.426-2.587-11.885-7.552-1.53-4.73.48-10.428 4.888-12.864A11.083 11.083 0 0116 4.975zm.006 3.52c-2.261 4.07-4.533 8.136-6.798 12.205h13.596L16.005 8.495z"
  })));

  function _extends$x() { _extends$x = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$x.apply(this, arguments); }
  var LaneIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$x({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M0 7v18.62h32V7H0zm1.655 17.056V8.684h28.62v15.372H1.656z"
  })));

  function _extends$w() { _extends$w = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$w.apply(this, arguments); }
  var ManualTaskIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$w({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M6.494 3C2.916 3 0 5.903 0 9.475v13.383c0 3.572 2.916 6.475 6.494 6.475h19.012c3.578 0 6.494-2.903 6.494-6.475V9.475C32 5.903 29.084 3 25.506 3H6.494zm0 2h19.012C28.015 5 30 6.98 30 9.475v13.383c0 2.495-1.985 4.475-4.494 4.475H6.494C3.985 27.333 2 25.353 2 22.858V9.475C2 6.98 3.985 5 6.494 5zm4.43 1.328c-.222.005-.43.09-.606.203-.985.638-4.356 2.977-5.096 3.486-.67.46-1.12 1.153-1.38 1.974-.27.858-.235 1.793-.232 2.576.002.59.016 1.104.17 1.727.22.908.634 1.63 1.23 2.118.597.49 1.363.732 2.23.734 3.038.012 6.078.016 9.119 0 .327-.002.645-.127.848-.37.204-.241.287-.56.291-.914a1.732 1.732 0 00-.097-.625h.327c.335 0 .641-.11.852-.316.21-.206.317-.475.374-.754a1.783 1.783 0 00-.126-1.143 1.18 1.18 0 00.877-.521c.196-.306.257-.666.258-1.025.001-.375-.088-.738-.293-1.033a1.179 1.179 0 00-.958-.512h-.478c.108-.237.156-.505.155-.782-.003-.373-.098-.721-.316-.99a1.21 1.21 0 00-.943-.43c-2.273-.004-4.236.018-6.412.012l-.19-.001c.102-.104.202-.205.312-.314.337-.336.662-.652.83-.869.4-.516.46-1.215.123-1.729-.178-.272-.439-.456-.72-.494a.93.93 0 00-.148-.008zm.029.728l.022.001c.055.008.115.027.209.172.132.201.126.606-.09.884-.079.102-.431.465-.767.8-.337.334-.657.643-.815.836-.153.186-.096.338-.056.435.04.096.085.212.298.263.063.014.066.01.086.012l.066.003c2.429.027 4.986-.004 7.223-.003.194 0 .293.056.379.162.086.105.151.286.153.533 0 .257-.065.467-.155.59-.09.124-.183.182-.37.183-1.706-.001-3.411-.005-5.117-.009v.731c2.23.004 4.461.01 6.692.012.17 0 .265.06.361.2.096.138.164.364.163.615 0 .268-.058.501-.143.634-.085.132-.162.193-.385.195-2.32-.001-4.554-.006-6.688-.003v.73c1.905 0 3.809.003 5.713.001.194.005.316.09.416.26.102.173.151.442.093.728-.04.193-.102.313-.17.38-.067.065-.148.108-.343.108h-5.71l.002.734c1.445 0 2.89-.01 4.334-.001.162 0 .232.041.297.123.064.081.123.238.12.488-.003.244-.061.385-.12.455-.06.07-.127.11-.296.11-3.037.016-6.076.012-9.113 0-.735-.002-1.316-.196-1.77-.568-.454-.372-.793-.935-.986-1.728-.134-.546-.146-.978-.148-1.558-.003-.796-.018-1.664.199-2.354.222-.705.582-1.24 1.096-1.593.75-.515 4.14-2.866 5.079-3.474a.504.504 0 01.241-.087z"
  })));

  function _extends$v() { _extends$v = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$v.apply(this, arguments); }
  var MessageFlowIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$v({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M4.073 26.607l1.295 1.296L1.325 32l-.662-.633L0 30.735l4.073-4.128zm6.953-7.046l1.296 1.296L1.325 32l7.555-7.656-1.295-1.296 1.455-1.474 1.986-2.013zM32 .06s-2.699 5.189-5.417 10.462l-.326.633c-1.14 2.214-2.265 4.407-3.176 6.2-1.228-1.222-2.449-2.452-3.676-3.675l-3.57 3.618-1.297-1.296 3.541-3.588c-.98-.964-1.932-1.958-2.923-2.91l-.753-.706c2.68-1.258 6.533-3.165 9.95-4.876l.617-.309C28.838 1.673 32 .06 32 .06zm-4.126 4.06l-.015.007-.115.057-.048.024-.115.057L17.7 9.172l5.017 4.948 5.157-10z"
  })));

  function _extends$u() { _extends$u = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$u.apply(this, arguments); }
  var ParticipantIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$u({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M0 5v22.069h32V5H0zm30.276 1.684v18.82H6.62V6.684h23.655zm-28.62 0h3.31v18.82h-3.31V6.684z"
  })));

  function _extends$t() { _extends$t = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$t.apply(this, arguments); }
  var ProcessIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$t({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    fillRule: "evenodd",
    d: "M16.177 0l.137.002c.452.009.9.037 1.342.082.346.036.62.303.68.646l.437 2.536c.055.319.296.57.608.655.986.269 1.923.653 2.796 1.14.28.155.624.145.885-.039l2.083-1.47a.775.775 0 01.937.022c.86.699 1.645 1.484 2.343 2.343.22.27.223.653.023.937l-1.439 2.038a.833.833 0 00-.031.896c.512.889.92 1.846 1.204 2.855a.833.833 0 00.653.601l2.435.42c.342.059.61.333.645.679a15.928 15.928 0 01.08 2.064l-.003.114c-.012.382-.038.76-.077 1.134a.775.775 0 01-.645.68l-2.396.412a.835.835 0 00-.656.61 12.511 12.511 0 01-1.2 2.917.832.832 0 00.034.892l1.396 1.978c.2.284.196.667-.023.936a16.104 16.104 0 01-2.343 2.343.775.775 0 01-.937.023l-1.99-1.404a.833.833 0 00-.88-.026c-.907.516-1.886.922-2.916 1.2a.833.833 0 00-.61.656l-.414 2.396a.775.775 0 01-.679.646 16.096 16.096 0 01-3.312 0 .775.775 0 01-.679-.646l-.423-2.452a.834.834 0 00-.598-.636 12.474 12.474 0 01-1.468-.514 12.49 12.49 0 01-1.417-.68.833.833 0 00-.878.03l-2.026 1.43a.775.775 0 01-.937-.023 16.069 16.069 0 01-2.342-2.342.774.774 0 01-.024-.936l1.402-1.986a.833.833 0 00.032-.896 12.507 12.507 0 01-1.214-2.911.833.833 0 00-.655-.606l-2.386-.412a.775.775 0 01-.646-.678 16.097 16.097 0 010-3.314.775.775 0 01.646-.678l2.386-.412a.833.833 0 00.655-.606 12.507 12.507 0 011.214-2.911.833.833 0 00-.032-.896L3.552 6.853a.774.774 0 01.023-.936 16.091 16.091 0 012.343-2.343.775.775 0 01.937-.023l2.03 1.433c.26.177.6.182.874.028.915-.512 1.88-.9 2.87-1.167a.833.833 0 00.612-.656l.424-2.46a.775.775 0 01.679-.645C14.845.032 15.348.004 15.85 0h.326zM16 6.4c-5.302 0-9.6 4.297-9.6 9.599 0 5.302 4.298 9.6 9.6 9.6s9.6-4.298 9.6-9.6-4.298-9.6-9.6-9.6zm-3 4.283c0-1.425 1.637-2.203 2.715-1.29l5.69 4.815c.794.672.794 1.91 0 2.583l-5.69 4.815c-1.078.913-2.715.134-2.715-1.29z"
  })));

  function _extends$s() { _extends$s = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$s.apply(this, arguments); }
  var ReceiveTaskIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$s({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M6.494 3C2.916 3 0 5.903 0 9.475v13.383c0 3.572 2.916 6.475 6.494 6.475h19.012c3.578 0 6.494-2.903 6.494-6.475V9.475C32 5.903 29.084 3 25.506 3H6.494zm0 2h19.012C28.015 5 30 6.98 30 9.475v13.383c0 2.495-1.985 4.475-4.494 4.475H6.494C3.985 27.333 2 25.353 2 22.858V9.475C2 6.98 3.985 5 6.494 5zM5.23 7.764v11.577h17.55V7.764H5.23zm1.816.758h13.917l-6.959 4.577-6.958-4.577zm-1.06.21l8.018 5.274 8.018-5.275v9.853H5.987V8.73z"
  })));

  function _extends$r() { _extends$r = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$r.apply(this, arguments); }
  var ScriptTaskIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$r({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M6.494 3C2.916 3 0 5.903 0 9.475v13.383c0 3.572 2.916 6.475 6.494 6.475h19.012c3.578 0 6.494-2.903 6.494-6.475V9.475C32 5.903 29.084 3 25.506 3H6.494zm0 2h19.012C28.015 5 30 6.98 30 9.475v13.383c0 2.495-1.985 4.475-4.494 4.475H6.494C3.985 27.333 2 25.353 2 22.858V9.475C2 6.98 3.985 5 6.494 5zm2.99 3.077l-.077.045-.026.015c-1.09.646-1.84 1.239-2.336 1.818-.496.579-.735 1.162-.742 1.725-.014 1.119.812 1.958 1.544 2.708.732.75 1.385 1.456 1.446 2.041.032.298-.039.598-.364 1.008-.324.408-.911.897-1.85 1.445l-1.388.808h8.56l.101-.059c.996-.58 1.667-1.116 2.094-1.655.429-.54.603-1.107.547-1.638-.11-1.052-.967-1.818-1.688-2.556-.721-.739-1.306-1.436-1.298-2.092.004-.331.132-.7.535-1.171.402-.47 1.08-1.02 2.119-1.636l1.362-.806h-8.54zm.241.867h5.271a6.83 6.83 0 00-1.113 1.01c-.496.58-.736 1.163-.743 1.726-.014 1.119.812 1.958 1.544 2.708.732.75 1.385 1.456 1.446 2.041.032.298-.039.598-.364 1.008-.312.393-.872.862-1.753 1.386H8.728c.367-.286.658-.566.88-.847.43-.54.604-1.107.548-1.638-.11-1.052-.968-1.818-1.688-2.556-.721-.739-1.306-1.435-1.298-2.092.004-.331.132-.7.534-1.171.389-.454 1.04-.984 2.021-1.575zm-1.233 1.48v.4h4.12v-.4h-4.12zm-.154 2.158v.4H12.6v-.4H8.34zm1.931 2.158v.4h4.126v-.4H10.27zm.59 2.158v.4h4.276v-.4h-4.276z"
  })));

  function _extends$q() { _extends$q = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$q.apply(this, arguments); }
  var SendTaskIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$q({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M6.494 3C2.916 3 0 5.903 0 9.475v13.383c0 3.572 2.916 6.475 6.494 6.475h19.012c3.578 0 6.494-2.903 6.494-6.475V9.475C32 5.903 29.084 3 25.506 3H6.494zm0 2h19.012C28.015 5 30 6.98 30 9.475v13.383c0 2.495-1.985 4.475-4.494 4.475H6.494C3.985 27.333 2 25.353 2 22.858V9.475C2 6.98 3.985 5 6.494 5zm-1.38 3.16l8.332 4.717L21.78 8.16H5.114zm.021 1.745v9.309H21.8V9.905l-8.353 4.655-8.31-4.655z"
  })));

  function _extends$p() { _extends$p = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$p.apply(this, arguments); }
  var ServiceTaskIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$p({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M6.494 3C2.916 3 0 5.903 0 9.475v13.383c0 3.572 2.916 6.475 6.494 6.475h19.012c3.578 0 6.494-2.903 6.494-6.475V9.475C32 5.903 29.084 3 25.506 3H6.494zm0 2h19.012C28.015 5 30 6.98 30 9.475v13.383c0 2.495-1.985 4.475-4.494 4.475H6.494C3.985 27.333 2 25.353 2 22.858V9.475C2 6.98 3.985 5 6.494 5zm1.22 1.681V7.84c-.329.093-.63.223-.914.382l-.83-.82-1.554 1.561.83.82c-.16.288-.285.594-.372.911l-1.177.002v2.2l1.189-.004c.109.431.345.819.58 1.165v-1.898l-1.038.004v-.737l1.034-.002.058-.294c.084-.429.252-.838.493-1.203l.165-.25-.727-.718.523-.526.728.719.247-.165c.379-.25.793-.417 1.206-.505l.291-.06-.002-1.01h.75L9.19 8.417H11.16c-.185-.221-.951-.508-1.237-.588L9.93 6.68H7.713zm2.078 2.105l.003 1.158a4.19 4.19 0 00-.915.383l-.83-.821-1.553 1.562.83.82c-.16.288-.286.593-.373.91l-1.176.003v2.2l1.188-.004c.094.326.224.624.383.905l-.85.847 1.57 1.543.847-.843c.29.161.599.286.919.373v1.198c.756.006 1.56.003 2.206.003V17.81a4.19 4.19 0 00.915-.383l.847.835 1.554-1.56-.848-.836c.16-.288.286-.594.373-.912l1.152-.007V12.75l-1.165.007a4.09 4.09 0 00-.382-.905l.805-.807-1.57-1.546-.804.806a4.16 4.16 0 00-.915-.372l.007-1.147H9.792zm.732.73h.751l-.006 1.005.297.058c.43.085.844.252 1.21.492l.25.162.701-.704.528.52-.702.704.169.25c.248.374.412.779.505 1.196l.061.292 1.016-.006v.737l-1.01.006-.058.292c-.085.43-.252.838-.494 1.205l-.165.25.744.733-.523.525-.743-.734-.248.165c-.378.247-.789.418-1.203.503l-.294.058v1.067h-.745v-1.059l-.295-.057a3.395 3.395 0 01-1.21-.492l-.248-.162-.747.743-.528-.52.747-.744-.17-.25a3.546 3.546 0 01-.506-1.196l-.06-.291-1.04.004v-.738l1.034-.002.058-.294c.085-.428.252-.837.493-1.203l.165-.25-.726-.718.522-.526.728.72.248-.166a3.546 3.546 0 011.205-.504l.292-.06-.003-1.01zm.388 2.685a1.65 1.65 0 00-1.645 1.645c0 .904.74 1.645 1.645 1.645a1.65 1.65 0 001.645-1.645 1.65 1.65 0 00-1.645-1.645zm0 .73a.91.91 0 01.915.915.91.91 0 01-.915.914.91.91 0 01-.915-.914.91.91 0 01.915-.915z"
  })));

  function _extends$o() { _extends$o = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$o.apply(this, arguments); }
  var StartEventCompensationIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$o({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.995.001C9.705-.084 3.643 3.964 1.257 9.775-1.235 15.485.06 22.577 4.42 27.03c4.193 4.513 11.102 6.17 16.887 4.058 5.996-2.042 10.423-7.93 10.664-14.269.403-6.227-3.26-12.44-8.87-15.153A15.924 15.924 0 0015.994 0zm0 1.73c6.213-.108 12.122 4.355 13.726 10.357 1.678 5.653-.592 12.198-5.463 15.547-5.06 3.719-12.564 3.45-17.343-.626C2.101 23.171.377 16.07 2.848 10.44c2.14-5.205 7.515-8.774 13.147-8.708zm-.566 9.03l-7.415 5.235 7.415 5.238v-5.062c2.386 1.689 4.775 3.375 7.163 5.062V10.761l-7.163 5.058v-5.058zm-.866 1.666v7.13L9.51 15.993l5.052-3.565zm7.166 0v7.137l-5.052-3.568 5.052-3.569z"
  })));

  function _extends$n() { _extends$n = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$n.apply(this, arguments); }
  var StartEventConditionIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$n({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M16 0C7.174 0 0 7.174 0 16s7.174 16 16 16 16-7.174 16-16S24.826 0 16 0zm0 1.73c7.892 0 14.27 6.378 14.27 14.27 0 7.891-6.379 14.27-14.27 14.27S1.73 23.891 1.73 16C1.73 8.108 8.108 1.73 16 1.73zm-5.362 7.523v13.493h10.724V9.253H10.638zm.863.866h8.995V21.88H11.501V10.12zm.928 1.324v.863h7.139v-.863h-7.139zm0 2.605v.867h7.139v-.867h-7.139zm0 3.01v.864h7.139v-.863h-7.139zm0 2.72v.863h7.139v-.863h-7.139z"
  })));

  function _extends$m() { _extends$m = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$m.apply(this, arguments); }
  var StartEventErrorIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$m({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.995.005C9.705-.08 3.643 3.968 1.257 9.78-1.235 15.49.06 22.581 4.42 27.034c4.193 4.513 11.102 6.17 16.887 4.058 5.996-2.042 10.423-7.93 10.664-14.269.403-6.227-3.26-12.44-8.87-15.153A15.924 15.924 0 0015.994.005zm0 1.73c6.213-.108 12.122 4.355 13.726 10.357 1.678 5.653-.592 12.198-5.463 15.547-5.06 3.719-12.564 3.45-17.343-.626-4.814-3.838-6.538-10.939-4.067-16.57 2.14-5.205 7.515-8.774 13.147-8.708zm6.13 7.45l-3.635 7.37-4.52-5.88c-1.37 4.048-2.738 8.095-4.106 12.143l4.603-5.917 4.748 5.433 2.91-13.149zm-7.754 3.889l4.299 5.449 1.073-2.39-1.028 4.135-4.387-5.16-1.78 2.75 1.823-4.784z"
  })));

  function _extends$l() { _extends$l = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$l.apply(this, arguments); }
  var StartEventEscalationIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$l({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.995.001C9.705-.084 3.643 3.964 1.257 9.775-1.235 15.485.06 22.577 4.42 27.03c4.193 4.513 11.102 6.17 16.887 4.058 5.996-2.042 10.423-7.93 10.664-14.269.403-6.227-3.26-12.44-8.87-15.153A15.924 15.924 0 0015.994 0zm0 1.73c6.213-.108 12.122 4.355 13.726 10.357 1.678 5.653-.592 12.198-5.463 15.547-5.06 3.719-12.564 3.45-17.343-.626C2.101 23.171.377 16.07 2.848 10.44c2.14-5.205 7.515-8.774 13.147-8.708zm0 7.183c-1.674 4.658-2.736 9.509-4.41 14.166 1.535-1.526 2.874-3.236 4.41-4.763l4.41 4.763c-1.499-4.713-2.913-9.453-4.41-14.166zm.032 2.931c.822 2.588 1.598 5.19 2.42 7.778l-2.42-2.615c-.683.598-2.455 2.887-2.34 2.39.871-2.489 1.448-5.07 2.34-7.553z"
  })));

  function _extends$k() { _extends$k = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$k.apply(this, arguments); }
  var StartEventMessageIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$k({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.995.001C9.705-.084 3.643 3.964 1.257 9.775-1.235 15.485.06 22.577 4.42 27.03c4.193 4.513 11.102 6.17 16.887 4.058 5.996-2.042 10.423-7.93 10.664-14.269.403-6.227-3.26-12.44-8.87-15.153A15.924 15.924 0 0015.994 0zm0 1.73c6.213-.108 12.122 4.355 13.726 10.357 1.678 5.653-.592 12.198-5.463 15.547-5.06 3.719-12.564 3.45-17.343-.626C2.101 23.171.377 16.07 2.848 10.44c2.14-5.205 7.515-8.774 13.147-8.708zm-7.257 8.732v11.069h14.513v-11.07H8.738zm3.224 1.73h8.064c-1.428.878-2.857 2.807-4.285 3.018l-3.779-3.019zm9.562 1.017v6.593H10.465V13.21l5.528 4.417 5.53-4.418z"
  })));

  function _extends$j() { _extends$j = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$j.apply(this, arguments); }
  var StartEventMultipleIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$j({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.995.001C9.705-.084 3.643 3.964 1.257 9.775-1.235 15.485.06 22.577 4.42 27.03c4.193 4.513 11.102 6.17 16.887 4.058 5.996-2.042 10.423-7.93 10.664-14.269.403-6.227-3.26-12.44-8.87-15.153A15.924 15.924 0 0015.994 0zm0 1.73c6.213-.108 12.122 4.355 13.726 10.357 1.678 5.653-.592 12.198-5.463 15.547-5.06 3.719-12.564 3.45-17.343-.626C2.101 23.171.377 16.07 2.848 10.44c2.14-5.205 7.515-8.774 13.147-8.708zm0 6.328l-7.626 5.536c.97 2.986 1.942 5.971 2.913 8.957h9.426l2.912-8.957-7.625-5.536zm0 1.068l6.609 4.798-2.525 7.763H11.91l-2.524-7.763 6.609-4.798z"
  })));

  function _extends$i() { _extends$i = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$i.apply(this, arguments); }
  var StartEventNonInterruptingConditionIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$i({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M10.632 9.189V22.68h10.723V9.189H10.632zm.862.865h8.994v11.76H11.494v-11.76zm.928 1.324v.863h7.138v-.863h-7.138zm0 2.605v.866h7.138v-.866h-7.138zm0 3.01v.863h7.138v-.863h-7.138zm0 2.72v.862h7.138v-.863h-7.138zM16.12 0h-.232l-.22.004h-.012l-.221.006h-.012l-.22.01h-.012l-.22.013h-.012l-.22.016h-.012l-.22.019h-.005l-.006.001-.22.021h-.006l-.005.001-.22.025h-.011l-.22.028h-.005l-.006.002-.219.03h-.005l-.006.001-.218.033-.006.001-.006.001-.217.036-.006.001-.006.001-.217.039-.006.001-.006.001-.216.042-.006.001-.006.001-.215.045-.006.001-.006.002-.215.047-.006.002-.006.001-.214.05-.006.002-.006.002-.115.029-.152.053-.14.081-.122.106-.1.126-.075.143-.047.154-.018.16.012.16.042.156.07.145.095.13.118.11.137.086.15.059.158.03h.161l.132-.022.11-.028.202-.047.203-.046.208-.043.202-.039.206-.037.206-.034.205-.03.208-.03.205-.025.209-.023.208-.02.21-.017.209-.015.207-.011.21-.009.21-.006.207-.003h.21l.21.002.207.005.207.008.212.011.207.014.208.017.209.019.208.022.205.025.206.028.207.03.208.035.205.036.202.039.052.01.16.018.16-.012.156-.042.146-.07.13-.096.109-.119.085-.136.06-.15.03-.159v-.16l-.03-.16-.059-.15-.086-.136-.109-.118-.13-.096-.145-.07-.128-.038-.057-.011-.006-.002h-.006l-.216-.042-.006-.001-.006-.001-.217-.039H18.9l-.006-.002-.217-.035-.006-.001-.006-.001-.218-.032-.006-.001-.006-.001-.218-.03h-.006l-.006-.001-.219-.027h-.011l-.22-.024-.005-.001h-.006l-.22-.021h-.006l-.006-.001-.22-.017-.005-.001h-.006L17.06.03h-.012l-.22-.012h-.012l-.22-.01h-.012l-.22-.005h-.012L16.132 0h-.012zm8.715 2.783l-.157.034-.149.063-.134.089-.116.112-.092.132-.067.147-.038.157-.008.16.021.16.051.153.079.141.103.124.102.087.052.038h.001l.087.064v.001l.082.061.002.001.076.059h.001l.084.065.082.066.002.001.079.063.002.002.077.063.081.067.002.002.077.065.076.065.001.002.08.07.078.07h.002l.075.068.077.072.002.001.073.069.077.073.072.07.002.001.077.076.07.07v.001l.075.076.07.073.002.001.074.079.002.002.069.074.069.075.074.082.07.08.002.001.068.079h.001l.067.079.068.082.065.078.001.002.068.083.067.084.063.081.001.002.067.087.002.002.063.084.001.001.064.087.008.01.008.01.095.12.093.121.09.119.087.119.088.122.086.123.084.12.081.122.001.002.084.126.08.126.08.127.077.126.079.131.074.127.075.131.073.131.07.13.07.133.069.133.045.09.086.137.109.119.13.096.144.07.156.042.16.013.16-.017.155-.047.143-.075.126-.1.106-.121.082-.14.054-.151.025-.16-.005-.16-.035-.158-.05-.124-.048-.095-.002-.004-.002-.004-.073-.14-.002-.005-.002-.004-.074-.14-.002-.004-.002-.004-.076-.14-.002-.003-.002-.004-.077-.139-.003-.004-.002-.004-.078-.138-.003-.004-.002-.003-.08-.137-.002-.004-.003-.004-.081-.136-.002-.004-.003-.004-.083-.136-.002-.003-.002-.004-.085-.135-.002-.004-.003-.003-.085-.134-.003-.004-.002-.004-.087-.132-.003-.004-.003-.004-.088-.132-.003-.003-.002-.004-.09-.13-.003-.005-.003-.003-.091-.13-.003-.004-.002-.004-.093-.129-.003-.003-.003-.004-.094-.128-.003-.004-.003-.003-.095-.127-.003-.004-.003-.004-.097-.125-.003-.004-.003-.004-.09-.114-.06-.082-.003-.003-.002-.003-.069-.091-.002-.004-.002-.003-.07-.09-.003-.003-.002-.003-.07-.09-.003-.003-.002-.003-.071-.09-.002-.003-.003-.002-.072-.089-.002-.003-.002-.003-.073-.088-.002-.003-.002-.002-.074-.087-.002-.003-.002-.003-.074-.086-.003-.003-.002-.003-.074-.086-.003-.002-.002-.003-.075-.085-.003-.003-.002-.002-.076-.084-.002-.003-.003-.003-.076-.083-.002-.003-.003-.003-.077-.082-.002-.003-.003-.002-.077-.082-.003-.003-.003-.002-.078-.081-.002-.003-.003-.003-.078-.08-.003-.002-.003-.003-.079-.08-.002-.002-.003-.002-.08-.08-.002-.002-.003-.002-.08-.078-.003-.003-.003-.002-.08-.077-.003-.003-.003-.002-.082-.077-.002-.002-.003-.002-.082-.076-.003-.002-.002-.003-.083-.075-.003-.002-.002-.003-.084-.074-.002-.002-.003-.002-.084-.074-.003-.002-.002-.002-.085-.073-.002-.002-.003-.003-.085-.071-.003-.003-.002-.002-.086-.07-.003-.003-.002-.002-.086-.07-.003-.003-.003-.002-.086-.07-.003-.002-.003-.002-.087-.069-.002-.002-.003-.002-.088-.068-.002-.002-.003-.002-.088-.067-.003-.003-.003-.002-.088-.066-.003-.002-.003-.002-.089-.066-.003-.002-.003-.002-.057-.042-.14-.082-.15-.055-.16-.026-.16.004zM6.377 3.21l-.157.037-.148.066-.111.074-.007.006-.003.002-.003.002-.086.069-.003.002-.002.002-.086.07-.003.002-.002.002-.086.07-.002.003-.003.002-.085.071-.002.002-.003.003-.084.071-.003.003-.002.002-.084.072-.003.003-.002.002-.083.073-.003.003-.002.002-.083.074-.002.002-.003.003-.082.074-.003.003-.002.002-.081.076-.003.002-.003.002-.08.077-.003.002-.003.003-.08.076-.002.003-.003.002-.08.078-.002.002-.003.003-.079.078-.002.003-.003.002-.078.08-.003.002-.002.002-.078.08-.002.003-.003.002-.077.08-.003.004-.002.002-.077.081-.002.003-.003.003-.076.082-.002.002-.003.003-.075.082-.002.003-.003.003-.074.083-.003.003-.002.003-.074.084-.003.003-.002.002-.074.085-.002.003-.002.003-.073.085-.003.003-.002.003-.072.086-.002.003-.003.003-.071.087-.003.003-.002.002-.07.088-.003.003-.002.003-.07.088-.003.003-.002.003-.07.09-.002.002-.002.003-.069.09-.002.003-.003.003-.068.09-.002.003-.002.003-.067.092-.003.003-.002.003-.067.092-.002.003-.002.003-.066.092-.002.003-.002.004-.066.093-.002.003-.002.003-.065.094-.002.003-.002.004-.064.094-.002.003-.002.004-.063.095-.002.003-.002.003-.063.097-.002.003-.002.003-.046.073-.05.07-.003.002-.002.003-.067.093-.003.003-.002.003-.066.094-.002.003-.002.003-.066.094-.002.003-.002.003-.064.094-.002.004-.002.003-.064.094-.002.004-.002.003-.062.095-.002.003-.002.003-.062.096-.002.003-.002.003-.06.096-.003.003-.002.003-.06.096-.001.004-.002.003-.059.096-.002.004-.002.003-.058.097-.002.003-.001.003-.057.098-.002.003-.002.003-.056.098-.002.003-.002.003-.055.098-.002.004-.001.003-.055.098-.001.004-.002.003-.054.099-.001.003-.002.003-.052.1-.002.002-.002.004-.051.1-.002.002-.002.004-.05.1-.002.003-.002.003-.05.1v.003l-.002.004-.05.1v.003l-.002.004-.048.1-.002.004-.001.003-.047.101-.002.003-.001.004-.013.027-.052.152-.024.16.006.16.037.157.064.148.091.133.114.114.134.09.147.065.157.036.162.006.159-.024.152-.053.14-.08.122-.105.1-.126.066-.117.01-.023.044-.095.045-.095.002-.003.042-.087.048-.097.048-.095v-.001l.048-.092.001-.001.047-.09.05-.093.002-.002.049-.09.052-.092.001-.002.051-.089.001-.002.051-.087.053-.088.001-.002.055-.091.057-.091.057-.09.001-.002.057-.089.055-.083.001-.002.06-.09.06-.088.062-.089.001-.001.06-.084.063-.088.065-.089.017-.023.016-.025.06-.094.059-.09v-.002l.058-.086.057-.086.001-.001.062-.09.062-.088.001-.002.06-.085.002-.002.06-.082.063-.087.064-.084.002-.002.061-.08.065-.084.064-.08v-.001l.067-.083.067-.082.07-.083.069-.08.063-.074.074-.083.068-.077.002-.002.07-.076.07-.075.072-.077.001-.001.067-.07.076-.078.002-.002.07-.07.075-.075.002-.002.072-.07.075-.072.002-.002.073-.069.074-.068.001-.001.08-.073.076-.068.002-.002.072-.063v-.001l.078-.067.079-.068.002-.001.08-.068.002-.002.077-.063.082-.066.001-.001.075-.06.002-.002.006-.004.117-.111.094-.131.068-.146.04-.156.01-.161-.019-.16-.049-.154-.076-.141-.102-.125-.123-.105-.14-.079-.153-.052-.16-.023-.16.007zm24.596 11.088l-.156.04-.146.067-.131.094-.112.117-.087.135-.061.15-.033.157-.004.134.007.142.005.152.004.15.002.149v.153l.001.011v.015l.004.11.002.11v.002l.002.106v.321l-.003.102-.002.106-.004.107-.005.105-.006.106-.006.106-.008.106v.002l-.008.103v.002l-.01.1-.01.105-.01.105-.013.105-.012.099v.002l-.014.108-.014.1-.016.105-.016.103v.002l-.017.099-.018.104-.019.103v.002l-.019.097-.02.104-.022.103v.001l-.022.098-.023.103v.002l-.024.096-.025.103v.002l-.024.096-.027.102v.003l-.026.093v.001l-.029.103v.002l-.03.099-.028.097v.002l-.03.095-.03.096v.001l-.033.1-.031.095v.002l-.035.1v.003l-.034.094v.003l-.035.096v.001l-.034.09v.002l-.038.098-.036.093v.002l-.038.095-.079.194-.08.188-.085.189-.087.19-.09.184-.092.183-.095.184-.05.093-.064.148-.034.158-.005.16.026.16.054.151.082.14.106.12.127.1.143.075.154.046.16.017.161-.013.156-.042.144-.071.13-.096.109-.119.072-.112.053-.099.003-.005.003-.006.102-.195.003-.006.003-.006.098-.196.003-.006.003-.006.096-.197.002-.006.003-.006.093-.2.002-.006.003-.006.09-.2.002-.006.003-.007.086-.202.003-.006.002-.006.084-.203.002-.005.001-.005.04-.102.002-.003.001-.003.04-.103.001-.003.001-.003.04-.103v-.004l.001-.003.039-.103v-.003l.002-.003.037-.104.001-.003.001-.003.037-.104v-.004l.002-.003.035-.104.002-.003v-.004l.035-.104.002-.004v-.003l.034-.105.002-.003v-.003l.034-.105v-.004l.002-.003.032-.106.001-.003.001-.003.031-.106.001-.003.001-.004.031-.106.001-.003.001-.004.03-.106v-.003l.002-.004.028-.107.001-.003.001-.003.028-.107.001-.004.001-.003.027-.107.001-.004v-.003l.027-.108.001-.003v-.004l.026-.108.001-.003v-.004l.025-.108.001-.003v-.004l.025-.108v-.004l.001-.003.023-.109v-.003l.001-.004.022-.109v-.003l.002-.004.02-.109.001-.004v-.003l.02-.11.002-.003v-.004l.02-.11v-.007l.019-.11v-.003l.001-.004.017-.11v-.004l.001-.003.017-.11v-.008l.016-.11v-.004l.001-.004.015-.11v-.008l.015-.111v-.008l.013-.111v-.007l.013-.112v-.007l.011-.112v-.004l.001-.004.01-.112v-.007l.01-.112v-.008l.008-.112v-.008l.007-.113v-.007l.007-.113v-.008l.005-.113v-.007l.005-.114v-.007l.003-.114v-.007l.003-.114v-.129l.001-.114v-.13l-.003-.114v-.008l-.003-.115v-.007l-.003-.102v-.155l-.003-.158v-.01l-.004-.158v-.01l-.006-.158v-.01l-.007-.148-.023-.16-.051-.152-.08-.14-.103-.124-.125-.102-.142-.077-.153-.05-.16-.02-.161.01zm-30.213.66l-.157.034-.149.063-.134.09-.115.113-.092.132-.067.147-.037.156-.009.134.001.11V15.95l.006.22v.012l.01.22v.012l.012.22v.006l.001.006.015.22v.005l.001.006.018.22.001.006v.006l.022.219v.006l.001.006.024.219.001.006v.006l.028.218.001.006v.006l.031.218.001.006.001.006.033.218.001.006.001.005.037.218v.006l.002.005.04.217v.006l.001.006.043.216.001.006.001.006.046.216v.005l.002.006.048.215.002.006.001.006.051.214.002.006v.006l.055.214.002.005.001.006.057.213.002.006.001.005.06.213.002.005.001.006.063.212.002.005.001.006.066.21.002.006.002.006.068.21.002.005.002.005.07.21.003.005.002.005.074.208.002.006.002.005.077.207.002.006.002.005.08.206.002.005.002.006.082.204.002.006.002.005.086.204.002.005.002.006.088.202.002.005.003.006.09.2.003.006.002.005.094.2.002.006.003.005.096.199.002.005.003.005.03.062.086.137.11.118.128.097.145.07.156.043.16.013.16-.017.155-.047.143-.074.127-.1.106-.121.081-.14.055-.15.025-.16-.005-.161-.034-.158-.05-.124-.028-.055-.092-.19-.087-.188-.087-.192-.083-.19-.08-.193-.078-.194-.076-.196-.073-.195-.07-.197-.067-.198-.065-.199-.063-.2-.059-.2-.056-.2-.055-.204-.05-.201-.049-.202-.046-.205-.043-.206-.04-.203-.038-.207-.034-.204-.032-.207-.028-.205-.026-.207-.023-.208-.02-.207-.018-.207-.014-.208-.011-.207-.009-.208-.005-.207-.002-.104-.017-.16-.046-.155-.074-.143-.1-.126-.121-.107-.139-.081-.152-.055-.159-.025-.161.004zm24.585 11.83l-.156.039-.146.068-.11.076-.015.012-.163.129-.166.127-.168.125-.17.124-.17.12-.172.118-.173.115-.176.114-.177.111-.18.11-.178.105-.182.104-.182.101-.184.1-.184.095-.189.095-.186.09-.188.089-.19.086-.19.082-.193.081-.195.078-.191.074-.197.073-.195.07-.196.065-.198.064-.198.061-.2.058-.2.055-.2.052-.2.049-.151.035-.153.05-.141.078-.125.103-.103.124-.078.14-.05.154-.022.16.009.16.038.157.067.147.093.132.116.112.134.089.149.062.158.034.16.003.133-.02.158-.035.006-.002.006-.001.213-.052.006-.002.007-.001.212-.056.006-.001.006-.002.212-.058.006-.002.006-.002.211-.061.006-.002.006-.002.21-.064.006-.002.006-.002.21-.067.005-.002.006-.002.208-.07.006-.002.006-.003.207-.073.006-.002.006-.002.206-.077.006-.002.005-.002.206-.08.005-.001.006-.003.204-.082.006-.002.005-.002.203-.085.006-.003.005-.002.202-.088.006-.002.005-.003.2-.09.006-.003.006-.003.2-.093.005-.003.005-.002.198-.096.006-.003.005-.003.197-.099.005-.002.005-.003.196-.102.005-.002.005-.003.195-.105.005-.002.005-.003.193-.107.005-.003.005-.003.191-.11.005-.003.005-.003.19-.112.005-.003.005-.003.189-.115.005-.003.005-.003.187-.117.005-.003.004-.004.186-.12.005-.003.004-.003.184-.122.005-.003.005-.004.182-.125.004-.003.005-.003.18-.128.005-.003.005-.003.179-.13.004-.003.005-.004.177-.132.004-.004.005-.003.175-.135.005-.003.004-.004.173-.137.005-.003.004-.004.019-.015.115-.113.092-.132.066-.147.038-.157.008-.16-.022-.16-.052-.153-.079-.14-.103-.124-.125-.102-.142-.078-.153-.05-.16-.02-.16.01zm-19.17.054l-.153.051-.14.079-.124.103-.103.125-.077.141-.05.153-.02.16.009.161.04.156.067.147.093.131.095.094.047.04.005.004.005.004.17.14.005.004.005.004.172.137.004.004.005.003.086.067.003.002.003.002.087.067.003.002.003.002.088.066.002.003.003.002.089.065.002.002.003.002.09.065.002.002.003.002.09.064.002.002.003.002.09.063.003.002.003.002.09.063.003.002.003.002.092.062.002.002.003.002.092.061.003.002.003.002.092.06.003.003.003.001.093.06.003.002.003.002.093.06.003.001.003.002.094.058.003.002.003.002.095.058.003.001.003.002.095.057.003.002.003.002.095.056.003.002.003.002.096.055.004.002.003.001.096.055.003.002.003.002.098.053.003.002.003.002.097.053.004.002.003.001.098.053.003.001.003.002.099.052.003.001.003.002.1.05.003.002.003.002.1.05.003.002.003.001.1.05h.003l.004.003.1.048.004.001.003.002.101.048.003.001.004.002.101.046.004.002.003.001.102.046.004.002.003.001.103.045.003.002.003.001.103.045.004.001.003.002.104.043.003.001.004.002.104.042.003.002.004.001.104.042.004.001.003.002.105.04.004.002.003.001.106.04.003.002h.004l.106.04.004.001.003.002.107.038.003.001.004.001.107.038.003.001.004.001.107.037.004.001.004.001.108.036.003.001.004.001.108.035.004.001.003.001.11.034.003.001.004.001.109.033.004.002h.003l.11.033h.004l.003.002.11.031.004.001.004.001.084.023.081.028.004.001.003.001.109.037.003.001.004.001.109.036.003.001.004.001.109.035h.003l.004.002.11.033.003.001.003.001.11.033.003.001.004.001.109.031.004.002h.003l.11.031.003.001.004.001.11.03h.003l.003.001.11.029h.004l.003.002.11.027.003.001.004.001.11.027h.003l.004.001.004.001.16.022.16-.008.157-.038.147-.067.132-.092.112-.116.09-.134.062-.149.034-.157.004-.161-.025-.16-.055-.151-.082-.139-.107-.12-.127-.1-.143-.074-.124-.04h-.003l-.104-.025-.103-.026h-.002l-.095-.026h-.001l-.101-.027h-.002l-.1-.028h-.002l-.103-.03-.104-.032-.097-.03h-.002l-.103-.033-.102-.033-.101-.034-.106-.036-.027-.01-.027-.007-.107-.03-.104-.029-.104-.03h-.002l-.097-.03-.102-.032-.102-.032-.102-.034-.103-.035-.096-.034-.1-.036-.101-.037h-.002l-.094-.036-.096-.037-.097-.04h-.002l-.099-.04-.098-.042h-.002l-.092-.04-.097-.043-.095-.043-.097-.044h-.002l-.09-.043-.094-.045-.094-.046-.093-.047-.09-.046-.096-.05-.088-.047-.002-.001-.09-.049-.094-.052-.002-.002-.087-.049-.087-.05h-.002l-.088-.053h-.001l-.09-.055-.086-.052-.002-.001-.089-.055-.084-.054h-.002l-.09-.059h-.001l-.085-.056-.001-.001-.084-.056-.082-.056h-.001l-.086-.06-.082-.058H7.79l-.086-.062-.002-.002-.08-.058-.081-.06h-.001l-.085-.064-.002-.002-.076-.058-.002-.002-.082-.064-.161-.128-.162-.133-.04-.034-.132-.092-.147-.066-.157-.038-.16-.008-.16.022z"
  })));

  function _extends$h() { _extends$h = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$h.apply(this, arguments); }
  var StartEventNonInterruptingEscalationIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$h({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M16 9.209c-1.674 4.655-2.735 9.504-4.408 14.16 1.534-1.526 2.873-3.235 4.407-4.761l4.408 4.76c-1.497-4.71-2.91-9.448-4.408-14.16zm.031 2.93c.822 2.586 1.598 5.187 2.42 7.774l-2.42-2.614c-.682.598-2.453 2.886-2.34 2.389.873-2.488 1.45-5.068 2.34-7.55zM16.132.364c-1.51.016-3.055.139-4.492.614-.854.442-.266 1.861.651 1.578 2.266-.58 4.656-.596 6.944-.144.935.063 1.21-1.391.318-1.674-1.118-.26-2.274-.361-3.42-.374zm8.865 2.777c-.931-.1-1.262 1.29-.425 1.666 1.863 1.364 3.222 3.298 4.322 5.296.617.737 1.875-.145 1.398-.979-1.184-2.275-2.808-4.384-4.923-5.866a.863.863 0 00-.372-.117zM6.55 3.564c-.734.078-1.196.762-1.735 1.206C3.552 6.02 2.55 7.511 1.681 9.053c-.31.533-.71 1.33-.03 1.767.615.432 1.282-.132 1.446-.742.796-1.475 1.746-2.89 2.934-4.08.43-.548 1.292-.822 1.34-1.595a.874.874 0 00-.822-.839zm24.582 11.078c-.771-.033-1.004.82-.873 1.437.13 2.395-.471 4.797-1.615 6.897-.33.876.984 1.559 1.512.785a14.276 14.276 0 001.761-8.54.865.865 0 00-.785-.579zm-30.195.666c-.774-.06-1.032.785-.905 1.407.117 2.41.732 4.81 1.858 6.945.528.774 1.84.09 1.51-.786A15.932 15.932 0 011.728 16a.876.876 0 00-.79-.692zm24.57 11.817c-.762.099-1.243.835-1.919 1.16-1.514 1.002-3.237 1.632-4.978 2.092-.864.423-.307 1.855.616 1.591 2.528-.578 4.93-1.75 6.913-3.421.469-.522.07-1.42-.631-1.422zm-19.16.042c-.845.001-1.12 1.228-.395 1.628 1.665 1.401 3.667 2.348 5.76 2.912.618.178 1.482.565 1.893-.177.355-.628-.226-1.297-.87-1.326-1.972-.515-3.912-1.285-5.5-2.594-.26-.213-.522-.472-.888-.443z"
  })));

  function _extends$g() { _extends$g = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$g.apply(this, arguments); }
  var StartEventNonInterruptingMessageIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$g({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M8.746 10.393v11.064h14.506V10.393H8.746zm3.223 1.728h8.06c-1.428.879-2.856 2.807-4.283 3.018l-3.777-3.018zm9.557 1.018v6.59H10.473v-6.59l5.525 4.416 5.528-4.416zM16.132 0c-1.51.016-3.055.139-4.492.614-.854.442-.266 1.861.651 1.578 2.266-.58 4.656-.596 6.944-.144.935.063 1.21-1.391.318-1.674-1.118-.26-2.274-.361-3.42-.374zm8.865 2.777c-.931-.1-1.262 1.29-.425 1.666 1.863 1.364 3.222 3.298 4.322 5.296.617.737 1.875-.145 1.398-.979-1.184-2.275-2.808-4.384-4.923-5.866a.863.863 0 00-.372-.117zM6.55 3.2c-.734.078-1.196.762-1.735 1.206C3.552 5.656 2.55 7.147 1.681 8.69c-.31.533-.71 1.33-.03 1.767.615.432 1.282-.132 1.446-.742.796-1.475 1.746-2.89 2.934-4.08.43-.548 1.292-.822 1.34-1.595a.874.874 0 00-.822-.839zm24.582 11.078c-.771-.033-1.004.82-.873 1.437.13 2.395-.471 4.797-1.615 6.897-.33.876.984 1.559 1.512.785a14.276 14.276 0 001.761-8.54.865.865 0 00-.785-.579zm-30.195.666c-.774-.06-1.032.785-.905 1.407.117 2.41.732 4.81 1.858 6.945.528.774 1.84.09 1.51-.786a15.932 15.932 0 01-1.672-6.874.876.876 0 00-.79-.692zm24.57 11.817c-.762.099-1.243.835-1.919 1.16-1.514 1.002-3.237 1.632-4.978 2.092-.864.423-.307 1.855.616 1.591 2.528-.578 4.93-1.75 6.913-3.421.469-.522.07-1.42-.631-1.422zm-19.16.042c-.845.001-1.12 1.228-.395 1.628 1.665 1.401 3.667 2.348 5.76 2.912.618.178 1.482.565 1.893-.177.355-.628-.226-1.297-.87-1.326-1.972-.515-3.912-1.285-5.5-2.594-.26-.213-.522-.472-.888-.443z"
  })));

  function _extends$f() { _extends$f = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$f.apply(this, arguments); }
  var StartEventNonInterruptingMultipleIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$f({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M23.621 13.524L16 7.99l-7.622 5.534 2.911 8.952h9.422l2.911-8.952zm-1.016.33l-2.523 7.759h-8.165l-2.524-7.76L16 9.059l6.606 4.796zM16.132 0c-1.51.016-3.055.139-4.492.614-.854.442-.266 1.861.651 1.578 2.266-.58 4.656-.596 6.944-.144.935.063 1.21-1.391.318-1.674-1.118-.26-2.274-.361-3.42-.374zm8.865 2.777c-.931-.1-1.262 1.29-.425 1.666 1.863 1.364 3.222 3.298 4.322 5.296.617.737 1.875-.145 1.398-.979-1.184-2.275-2.808-4.384-4.923-5.866a.863.863 0 00-.372-.117zM6.55 3.2c-.734.078-1.196.762-1.735 1.206C3.552 5.656 2.55 7.147 1.681 8.69c-.31.533-.71 1.33-.03 1.767.615.432 1.282-.132 1.446-.742.796-1.475 1.746-2.89 2.934-4.08.43-.548 1.292-.822 1.34-1.595a.874.874 0 00-.822-.839zm24.582 11.078c-.771-.033-1.004.82-.873 1.437.13 2.395-.471 4.797-1.615 6.897-.33.876.984 1.559 1.512.785a14.276 14.276 0 001.761-8.54.865.865 0 00-.785-.579zm-30.195.666c-.774-.06-1.032.785-.905 1.407.117 2.41.732 4.81 1.858 6.945.528.774 1.84.09 1.51-.786a15.932 15.932 0 01-1.672-6.874.876.876 0 00-.79-.692zm24.57 11.817c-.762.099-1.243.835-1.919 1.16-1.514 1.002-3.237 1.632-4.978 2.092-.864.423-.307 1.855.616 1.591 2.528-.578 4.93-1.75 6.913-3.421.469-.522.07-1.42-.631-1.422zm-19.16.042c-.845.001-1.12 1.228-.395 1.628 1.665 1.401 3.667 2.348 5.76 2.912.618.178 1.482.565 1.893-.177.355-.628-.226-1.297-.87-1.326-1.972-.515-3.912-1.285-5.5-2.594-.26-.213-.522-.472-.888-.443z"
  })));

  function _extends$e() { _extends$e = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$e.apply(this, arguments); }
  var StartEventNonInterruptingParallelMultipleIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$e({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M13.503 9.016v4.428H9.075v4.98h4.428v4.428h4.98v-4.427h4.428v-4.981h-4.427V9.016h-4.981zm.83.83h3.32v4.428h4.428v3.32h-4.428v4.428h-3.32v-4.454H9.905v-3.294h4.428V9.846zM16.12 0h-.232l-.22.004h-.012l-.221.006h-.012l-.22.01h-.012l-.22.013h-.012l-.22.016h-.012l-.22.019h-.005l-.006.001-.22.021h-.006l-.005.001-.22.025h-.011l-.22.028h-.005l-.006.002-.219.03h-.005l-.006.001-.218.033-.006.001-.006.001-.217.036-.006.001-.006.001-.217.039-.006.001-.006.001-.216.042-.006.001-.006.001-.215.045-.006.001-.006.002-.215.047-.006.002-.006.001-.214.05-.006.002-.006.002-.115.029-.152.053-.14.081-.122.106-.1.126-.075.143-.047.154-.018.16.012.16.042.156.07.145.095.13.118.11.137.086.15.059.158.03h.161l.132-.022.11-.028.202-.047.203-.046.208-.043.202-.039.206-.037.206-.034.205-.03.208-.03.205-.025.209-.023.208-.02.21-.017.209-.015.207-.011.21-.009.21-.006.207-.003h.21l.21.002.207.005.207.008.212.011.207.014.208.017.209.019.208.022.205.025.206.028.207.03.208.035.205.036.202.039.052.01.16.018.16-.012.156-.042.146-.07.13-.096.109-.119.085-.136.06-.15.03-.159v-.16l-.03-.16-.059-.15-.086-.136-.109-.118-.13-.096-.145-.07-.128-.038-.057-.011-.006-.002h-.006l-.216-.042-.006-.001-.006-.001-.217-.039H18.9l-.006-.002-.217-.035-.006-.001-.006-.001-.218-.032-.006-.001-.006-.001-.218-.03h-.006l-.006-.001-.219-.027h-.011l-.22-.024-.005-.001h-.006l-.22-.021h-.006l-.006-.001-.22-.017-.005-.001h-.006L17.06.03h-.012l-.22-.012h-.012l-.22-.01h-.012l-.22-.005h-.012L16.132 0h-.012zm8.715 2.783l-.157.034-.149.063-.134.089-.116.112-.092.132-.067.147-.038.157-.008.16.021.16.051.153.079.141.103.124.102.087.052.038h.001l.087.064v.001l.082.061.002.001.076.059h.001l.084.065.082.066.002.001.079.063.002.002.077.063.081.067.002.002.077.065.076.065.001.002.08.07.078.07h.002l.075.068.077.072.002.001.073.069.077.073.072.07.002.001.077.076.07.07v.001l.075.076.07.073.002.001.074.079.002.002.069.074.069.075.074.082.07.08.002.001.068.079h.001l.067.079.068.082.065.078.001.002.068.083.067.084.063.081.001.002.067.087.002.002.063.084.001.001.064.087.008.01.008.01.095.12.093.121.09.119.087.119.088.122.086.123.084.12.081.122.001.002.084.126.08.126.08.127.077.126.079.131.074.127.075.131.073.131.07.13.07.133.069.133.045.09.086.137.109.119.13.096.144.07.156.042.16.013.16-.017.155-.047.143-.075.126-.1.106-.121.082-.14.054-.151.025-.16-.005-.16-.035-.158-.05-.124-.048-.095-.002-.004-.002-.004-.073-.14-.002-.005-.002-.004-.074-.14-.002-.004-.002-.004-.076-.14-.002-.003-.002-.004-.077-.139-.003-.004-.002-.004-.078-.138-.003-.004-.002-.003-.08-.137-.002-.004-.003-.004-.081-.136-.002-.004-.003-.004-.083-.136-.002-.003-.002-.004-.085-.135-.002-.004-.003-.003-.085-.134-.003-.004-.002-.004-.087-.132-.003-.004-.003-.004-.088-.132-.003-.003-.002-.004-.09-.13-.003-.005-.003-.003-.091-.13-.003-.004-.002-.004-.093-.129-.003-.003-.003-.004-.094-.128-.003-.004-.003-.003-.095-.127-.003-.004-.003-.004-.097-.125-.003-.004-.003-.004-.09-.114-.06-.082-.003-.003-.002-.003-.069-.091-.002-.004-.002-.003-.07-.09-.003-.003-.002-.003-.07-.09-.003-.003-.002-.003-.071-.09-.002-.003-.003-.002-.072-.089-.002-.003-.002-.003-.073-.088-.002-.003-.002-.002-.074-.087-.002-.003-.002-.003-.074-.086-.003-.003-.002-.003-.074-.086-.003-.002-.002-.003-.075-.085-.003-.003-.002-.002-.076-.084-.002-.003-.003-.003-.076-.083-.002-.003-.003-.003-.077-.082-.002-.003-.003-.002-.077-.082-.003-.003-.003-.002-.078-.081-.002-.003-.003-.003-.078-.08-.003-.002-.003-.003-.079-.08-.002-.002-.003-.002-.08-.08-.002-.002-.003-.002-.08-.078-.003-.003-.003-.002-.08-.077-.003-.003-.003-.002-.082-.077-.002-.002-.003-.002-.082-.076-.003-.002-.002-.003-.083-.075-.003-.002-.002-.003-.084-.074-.002-.002-.003-.002-.084-.074-.003-.002-.002-.002-.085-.073-.002-.002-.003-.003-.085-.071-.003-.003-.002-.002-.086-.07-.003-.003-.002-.002-.086-.07-.003-.003-.003-.002-.086-.07-.003-.002-.003-.002-.087-.069-.002-.002-.003-.002-.088-.068-.002-.002-.003-.002-.088-.067-.003-.003-.003-.002-.088-.066-.003-.002-.003-.002-.089-.066-.003-.002-.003-.002-.057-.042-.14-.082-.15-.055-.16-.026-.16.004zM6.377 3.21l-.157.037-.148.066-.111.074-.007.006-.003.002-.003.002-.086.069-.003.002-.002.002-.086.07-.003.002-.002.002-.086.07-.002.003-.003.002-.085.071-.002.002-.003.003-.084.071-.003.003-.002.002-.084.072-.003.003-.002.002-.083.073-.003.003-.002.002-.083.074-.002.002-.003.003-.082.074-.003.003-.002.002-.081.076-.003.002-.003.002-.08.077-.003.002-.003.003-.08.076-.002.003-.003.002-.08.078-.002.002-.003.003-.079.078-.002.003-.003.002-.078.08-.003.002-.002.002-.078.08-.002.003-.003.002-.077.08-.003.004-.002.002-.077.081-.002.003-.003.003-.076.082-.002.002-.003.003-.075.082-.002.003-.003.003-.074.083-.003.003-.002.003-.074.084-.003.003-.002.002-.074.085-.002.003-.002.003-.073.085-.003.003-.002.003-.072.086-.002.003-.003.003-.071.087-.003.003-.002.002-.07.088-.003.003-.002.003-.07.088-.003.003-.002.003-.07.09-.002.002-.002.003-.069.09-.002.003-.003.003-.068.09-.002.003-.002.003-.067.092-.003.003-.002.003-.067.092-.002.003-.002.003-.066.092-.002.003-.002.004-.066.093-.002.003-.002.003-.065.094-.002.003-.002.004-.064.094-.002.003-.002.004-.063.095-.002.003-.002.003-.063.097-.002.003-.002.003-.046.073-.05.07-.003.002-.002.003-.067.093-.003.003-.002.003-.066.094-.002.003-.002.003-.066.094-.002.003-.002.003-.064.094-.002.004-.002.003-.064.094-.002.004-.002.003-.062.095-.002.003-.002.003-.062.096-.002.003-.002.003-.06.096-.003.003-.002.003-.06.096-.001.004-.002.003-.059.096-.002.004-.002.003-.058.097-.002.003-.001.003-.057.098-.002.003-.002.003-.056.098-.002.003-.002.003-.055.098-.002.004-.001.003-.055.098-.001.004-.002.003-.054.099-.001.003-.002.003-.052.1-.002.002-.002.004-.051.1-.002.002-.002.004-.05.1-.002.003-.002.003-.05.1v.003l-.002.004-.05.1v.003l-.002.004-.048.1-.002.004-.001.003-.047.101-.002.003-.001.004-.013.027-.052.152-.024.16.006.16.037.157.064.148.091.133.114.114.134.09.147.065.157.036.162.006.159-.024.152-.053.14-.08.122-.105.1-.126.066-.117.01-.023.044-.095.045-.095.002-.003.042-.087.048-.097.048-.095v-.001l.048-.092.001-.001.047-.09.05-.093.002-.002.049-.09.052-.092.001-.002.051-.089.001-.002.051-.087.053-.088.001-.002.055-.091.057-.091.057-.09.001-.002.057-.089.055-.083.001-.002.06-.09.06-.088.062-.089.001-.001.06-.084.063-.088.065-.089.017-.023.016-.025.06-.094.059-.09v-.002l.058-.086.057-.086.001-.001.062-.09.062-.088.001-.002.06-.085.002-.002.06-.082.063-.087.064-.084.002-.002.061-.08.065-.084.064-.08v-.001l.067-.083.067-.082.07-.083.069-.08.063-.074.074-.083.068-.077.002-.002.07-.076.07-.075.072-.077.001-.001.067-.07.076-.078.002-.002.07-.07.075-.075.002-.002.072-.07.075-.072.002-.002.073-.069.074-.068.001-.001.08-.073.076-.068.002-.002.072-.063v-.001l.078-.067.079-.068.002-.001.08-.068.002-.002.077-.063.082-.066.001-.001.075-.06.002-.002.006-.004.117-.111.094-.131.068-.146.04-.156.01-.161-.019-.16-.049-.154-.076-.141-.102-.125-.123-.105-.14-.079-.153-.052-.16-.023-.16.007zm24.596 11.088l-.156.04-.146.067-.131.094-.112.117-.087.135-.061.15-.033.157-.004.134.007.142.005.152.004.15.002.149v.153l.001.011v.015l.004.11.002.11v.002l.002.106v.321l-.003.102-.002.106-.004.107-.005.105-.006.106-.006.106-.008.106v.002l-.008.103v.002l-.01.1-.01.105-.01.105-.013.105-.012.099v.002l-.014.108-.014.1-.016.105-.016.103v.002l-.017.099-.018.104-.019.103v.002l-.019.097-.02.104-.022.103v.001l-.022.098-.023.103v.002l-.024.096-.025.103v.002l-.024.096-.027.102v.003l-.026.093v.001l-.029.103v.002l-.03.099-.028.097v.002l-.03.095-.03.096v.001l-.033.1-.031.095v.002l-.035.1v.003l-.034.094v.003l-.035.096v.001l-.034.09v.002l-.038.098-.036.093v.002l-.038.095-.079.194-.08.188-.085.189-.087.19-.09.184-.092.183-.095.184-.05.093-.064.148-.034.158-.005.16.026.16.054.151.082.14.106.12.127.1.143.075.154.046.16.017.161-.013.156-.042.144-.071.13-.096.109-.119.072-.112.053-.099.003-.005.003-.006.102-.195.003-.006.003-.006.098-.196.003-.006.003-.006.096-.197.002-.006.003-.006.093-.2.002-.006.003-.006.09-.2.002-.006.003-.007.086-.202.003-.006.002-.006.084-.203.002-.005.001-.005.04-.102.002-.003.001-.003.04-.103.001-.003.001-.003.04-.103v-.004l.001-.003.039-.103v-.003l.002-.003.037-.104.001-.003.001-.003.037-.104v-.004l.002-.003.035-.104.002-.003v-.004l.035-.104.002-.004v-.003l.034-.105.002-.003v-.003l.034-.105v-.004l.002-.003.032-.106.001-.003.001-.003.031-.106.001-.003.001-.004.031-.106.001-.003.001-.004.03-.106v-.003l.002-.004.028-.107.001-.003.001-.003.028-.107.001-.004.001-.003.027-.107.001-.004v-.003l.027-.108.001-.003v-.004l.026-.108.001-.003v-.004l.025-.108.001-.003v-.004l.025-.108v-.004l.001-.003.023-.109v-.003l.001-.004.022-.109v-.003l.002-.004.02-.109.001-.004v-.003l.02-.11.002-.003v-.004l.02-.11v-.007l.019-.11v-.003l.001-.004.017-.11v-.004l.001-.003.017-.11v-.008l.016-.11v-.004l.001-.004.015-.11v-.008l.015-.111v-.008l.013-.111v-.007l.013-.112v-.007l.011-.112v-.004l.001-.004.01-.112v-.007l.01-.112v-.008l.008-.112v-.008l.007-.113v-.007l.007-.113v-.008l.005-.113v-.007l.005-.114v-.007l.003-.114v-.007l.003-.114v-.129l.001-.114v-.13l-.003-.114v-.008l-.003-.115v-.007l-.003-.102v-.155l-.003-.158v-.01l-.004-.158v-.01l-.006-.158v-.01l-.007-.148-.023-.16-.051-.152-.08-.14-.103-.124-.125-.102-.142-.077-.153-.05-.16-.02-.161.01zm-30.213.66l-.157.034-.149.063-.134.09-.115.113-.092.132-.067.147-.037.156-.009.134.001.11V15.95l.006.22v.012l.01.22v.012l.012.22v.006l.001.006.015.22v.005l.001.006.018.22.001.006v.006l.022.219v.006l.001.006.024.219.001.006v.006l.028.218.001.006v.006l.031.218.001.006.001.006.033.218.001.006.001.005.037.218v.006l.002.005.04.217v.006l.001.006.043.216.001.006.001.006.046.216v.005l.002.006.048.215.002.006.001.006.051.214.002.006v.006l.055.214.002.005.001.006.057.213.002.006.001.005.06.213.002.005.001.006.063.212.002.005.001.006.066.21.002.006.002.006.068.21.002.005.002.005.07.21.003.005.002.005.074.208.002.006.002.005.077.207.002.006.002.005.08.206.002.005.002.006.082.204.002.006.002.005.086.204.002.005.002.006.088.202.002.005.003.006.09.2.003.006.002.005.094.2.002.006.003.005.096.199.002.005.003.005.03.062.086.137.11.118.128.097.145.07.156.043.16.013.16-.017.155-.047.143-.074.127-.1.106-.121.081-.14.055-.15.025-.16-.005-.161-.034-.158-.05-.124-.028-.055-.092-.19-.087-.188-.087-.192-.083-.19-.08-.193-.078-.194-.076-.196-.073-.195-.07-.197-.067-.198-.065-.199-.063-.2-.059-.2-.056-.2-.055-.204-.05-.201-.049-.202-.046-.205-.043-.206-.04-.203-.038-.207-.034-.204-.032-.207-.028-.205-.026-.207-.023-.208-.02-.207-.018-.207-.014-.208-.011-.207-.009-.208-.005-.207-.002-.104-.017-.16-.046-.155-.074-.143-.1-.126-.121-.107-.139-.081-.152-.055-.159-.025-.161.004zm24.585 11.83l-.156.039-.146.068-.11.076-.015.012-.163.129-.166.127-.168.125-.17.124-.17.12-.172.118-.173.115-.176.114-.177.111-.18.11-.178.105-.182.104-.182.101-.184.1-.184.095-.189.095-.186.09-.188.089-.19.086-.19.082-.193.081-.195.078-.191.074-.197.073-.195.07-.196.065-.198.064-.198.061-.2.058-.2.055-.2.052-.2.049-.151.035-.153.05-.141.078-.125.103-.103.124-.078.14-.05.154-.022.16.009.16.038.157.067.147.093.132.116.112.134.089.149.062.158.034.16.003.133-.02.158-.035.006-.002.006-.001.213-.052.006-.002.007-.001.212-.056.006-.001.006-.002.212-.058.006-.002.006-.002.211-.061.006-.002.006-.002.21-.064.006-.002.006-.002.21-.067.005-.002.006-.002.208-.07.006-.002.006-.003.207-.073.006-.002.006-.002.206-.077.006-.002.005-.002.206-.08.005-.001.006-.003.204-.082.006-.002.005-.002.203-.085.006-.003.005-.002.202-.088.006-.002.005-.003.2-.09.006-.003.006-.003.2-.093.005-.003.005-.002.198-.096.006-.003.005-.003.197-.099.005-.002.005-.003.196-.102.005-.002.005-.003.195-.105.005-.002.005-.003.193-.107.005-.003.005-.003.191-.11.005-.003.005-.003.19-.112.005-.003.005-.003.189-.115.005-.003.005-.003.187-.117.005-.003.004-.004.186-.12.005-.003.004-.003.184-.122.005-.003.005-.004.182-.125.004-.003.005-.003.18-.128.005-.003.005-.003.179-.13.004-.003.005-.004.177-.132.004-.004.005-.003.175-.135.005-.003.004-.004.173-.137.005-.003.004-.004.019-.015.115-.113.092-.132.066-.147.038-.157.008-.16-.022-.16-.052-.153-.079-.14-.103-.124-.125-.102-.142-.078-.153-.05-.16-.02-.16.01zm-19.17.054l-.153.051-.14.079-.124.103-.103.125-.077.141-.05.153-.02.16.009.161.04.156.067.147.093.131.095.094.047.04.005.004.005.004.17.14.005.004.005.004.172.137.004.004.005.003.086.067.003.002.003.002.087.067.003.002.003.002.088.066.002.003.003.002.089.065.002.002.003.002.09.065.002.002.003.002.09.064.002.002.003.002.09.063.003.002.003.002.09.063.003.002.003.002.092.062.002.002.003.002.092.061.003.002.003.002.092.06.003.003.003.001.093.06.003.002.003.002.093.06.003.001.003.002.094.058.003.002.003.002.095.058.003.001.003.002.095.057.003.002.003.002.095.056.003.002.003.002.096.055.004.002.003.001.096.055.003.002.003.002.098.053.003.002.003.002.097.053.004.002.003.001.098.053.003.001.003.002.099.052.003.001.003.002.1.05.003.002.003.002.1.05.003.002.003.001.1.05h.003l.004.003.1.048.004.001.003.002.101.048.003.001.004.002.101.046.004.002.003.001.102.046.004.002.003.001.103.045.003.002.003.001.103.045.004.001.003.002.104.043.003.001.004.002.104.042.003.002.004.001.104.042.004.001.003.002.105.04.004.002.003.001.106.04.003.002h.004l.106.04.004.001.003.002.107.038.003.001.004.001.107.038.003.001.004.001.107.037.004.001.004.001.108.036.003.001.004.001.108.035.004.001.003.001.11.034.003.001.004.001.109.033.004.002h.003l.11.033h.004l.003.002.11.031.004.001.004.001.084.023.081.028.004.001.003.001.109.037.003.001.004.001.109.036.003.001.004.001.109.035h.003l.004.002.11.033.003.001.003.001.11.033.003.001.004.001.109.031.004.002h.003l.11.031.003.001.004.001.11.03h.003l.003.001.11.029h.004l.003.002.11.027.003.001.004.001.11.027h.003l.004.001.004.001.16.022.16-.008.157-.038.147-.067.132-.092.112-.116.09-.134.062-.149.034-.157.004-.161-.025-.16-.055-.151-.082-.139-.107-.12-.127-.1-.143-.074-.124-.04h-.003l-.104-.025-.103-.026h-.002l-.095-.026h-.001l-.101-.027h-.002l-.1-.028h-.002l-.103-.03-.104-.032-.097-.03h-.002l-.103-.033-.102-.033-.101-.034-.106-.036-.027-.01-.027-.007-.107-.03-.104-.029-.104-.03h-.002l-.097-.03-.102-.032-.102-.032-.102-.034-.103-.035-.096-.034-.1-.036-.101-.037h-.002l-.094-.036-.096-.037-.097-.04h-.002l-.099-.04-.098-.042h-.002l-.092-.04-.097-.043-.095-.043-.097-.044h-.002l-.09-.043-.094-.045-.094-.046-.093-.047-.09-.046-.096-.05-.088-.047-.002-.001-.09-.049-.094-.052-.002-.002-.087-.049-.087-.05h-.002l-.088-.053h-.001l-.09-.055-.086-.052-.002-.001-.089-.055-.084-.054h-.002l-.09-.059h-.001l-.085-.056-.001-.001-.084-.056-.082-.056h-.001l-.086-.06-.082-.058H7.79l-.086-.062-.002-.002-.08-.058-.081-.06h-.001l-.085-.064-.002-.002-.076-.058-.002-.002-.082-.064-.161-.128-.162-.133-.04-.034-.132-.092-.147-.066-.157-.038-.16-.008-.16.022z",
    opacity: ".98"
  })));

  function _extends$d() { _extends$d = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$d.apply(this, arguments); }
  var StartEventNonInterruptingSignalIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$d({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M16.007 8.82L9.21 21.022h13.596L16.007 8.82zm0 1.775l5.328 9.563H10.68l5.327-9.563zM16.14.386c-1.571.236-4.195-.284-4.9 1.381.619 1.703 2.745.069 4.085.365 1.421-.13 2.84.2 4.235.259C21.27.784 18.19.344 17 .413a20.456 20.456 0 00-.86-.027zM25 3.162c-2.19.694.401 2.26 1.181 3.094 1.083 1.152 1.954 2.484 2.715 3.864 1.48 1.005 1.845-1.26.81-2.03-1.158-1.897-2.613-3.704-4.513-4.89l-.192-.038zm-18.438.423c-1.793.712-2.909 2.548-4.01 4.061-.773.814-2.211 3.653.005 3.211 1.123-1.469 1.87-3.306 3.267-4.614.664-.7 2.73-2.013.738-2.658zm24.57 11.072c-1.659.435-.468 2.667-.99 3.895a13.427 13.427 0 01-1.497 4.435c-.23 1.659 1.991 1.165 2.018-.199a14.277 14.277 0 001.254-7.552.865.865 0 00-.785-.579zm-30.18.666c-1.677.386-.633 2.667-.608 3.876.371 1.623.792 3.35 1.79 4.696 2.382.321.571-2.338.292-3.492a15.92 15.92 0 01-.684-4.39.877.877 0 00-.79-.69zm24.558 11.81c-1.755.865-3.303 2.266-5.274 2.765-1.162-.016-3.074 1.271-1.331 2.102 2.66-.447 5.163-1.733 7.236-3.445.472-.506.06-1.432-.631-1.421zm-19.151.043c-2.004.786.416 2.405 1.43 2.913 1.608.904 3.379 1.636 5.208 1.877 1.77-.804-.228-2.094-1.357-2.073-1.75-.537-3.403-1.396-4.798-2.586l-.227-.104-.256-.027z"
  })));

  function _extends$c() { _extends$c = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$c.apply(this, arguments); }
  var StartEventNonInterruptingTimerIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$c({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.991 8.7c-3.018-.042-5.92 1.925-7.03 4.725-1.138 2.695-.509 6.011 1.537 8.102 1.99 2.142 5.267 2.93 8.013 1.927 2.877-.98 4.99-3.826 5.067-6.87.153-2.956-1.624-5.88-4.299-7.135a7.551 7.551 0 00-3.288-.75zm0 1.383c2.758-.052 5.372 1.972 6.014 4.654.704 2.578-.482 5.516-2.79 6.867-2.358 1.48-5.682 1.085-7.617-.919-2.043-1.97-2.407-5.38-.84-7.743 1.11-1.764 3.149-2.88 5.233-2.86zm1.962 1.764l-2.074 3.762c-.64.068-.793 1.04-.202 1.3.39.27.696-.18 1.052-.165h3.17v-.865h-3.182l1.993-3.614-.757-.418zM16.12.358h-.232l-.22.004h-.012l-.221.006h-.012l-.22.01h-.012l-.22.013h-.012l-.22.016h-.012l-.22.019h-.005l-.006.001-.22.021h-.006l-.005.001-.22.025h-.011l-.22.028h-.005l-.006.002-.219.03h-.005l-.006.001-.218.033-.006.001-.006.001-.217.036-.006.001-.006.001-.217.039-.006.001-.006.001-.216.042-.006.001-.006.001-.215.045-.006.001-.006.002-.215.047-.006.002-.006.001-.214.05-.006.002-.006.002-.115.029-.152.053-.14.081-.122.106-.1.126-.075.143-.047.154-.018.16.012.16.042.156.07.145.095.13.118.11.137.086.15.059.158.03h.161l.132-.022.11-.028.202-.047.203-.046.208-.043.202-.039.206-.037.206-.034.205-.03.208-.03.205-.025.209-.023.208-.02.21-.017.209-.015.207-.011.21-.009.21-.006.207-.003h.21l.21.002.207.005.207.008.212.011.207.014.208.017.209.019.208.022.205.025.206.028.207.03.208.035.205.036.202.039.052.01.16.018.16-.012.156-.042.146-.07.13-.096.109-.119.085-.136.06-.15.03-.159v-.16l-.03-.16-.059-.15-.086-.136L19.823.9l-.13-.096-.145-.07-.128-.038-.057-.011-.006-.002h-.006L19.135.64l-.006-.001-.006-.001-.217-.039H18.9l-.006-.002-.217-.035-.006-.001-.006-.001-.218-.032-.006-.001-.006-.001-.218-.03h-.006l-.006-.001-.219-.027h-.011l-.22-.024-.005-.001h-.006l-.22-.021h-.006L17.512.42l-.22-.017-.005-.001h-.006l-.22-.015h-.012l-.22-.012h-.012l-.22-.01h-.012l-.22-.005h-.012l-.221-.003h-.012zm8.715 2.783l-.157.034-.149.063-.134.089-.116.112-.092.132-.067.147-.038.157-.008.16.021.16.051.153.079.141.103.124.102.087.052.038h.001l.087.064v.001l.082.061.002.001.076.059h.001l.084.065.082.066.002.001.079.063.002.002.077.063.081.067.002.002.077.065.076.065.001.002.08.07.078.07h.002l.075.068.077.072.002.001.073.069.077.073.072.07.002.001.077.076.07.07v.001l.075.076.07.073.002.001.074.079.002.002.069.074.069.075.074.082.07.08.002.001.068.079h.001l.067.079.068.082.065.078.001.002.068.083.067.084.063.081.001.002.067.087.002.002.063.084.001.001.064.087.008.01.008.01.095.12.093.121.09.119.087.119.088.122.086.123.084.12.081.122.001.002.084.126.08.126.08.127.077.126.079.131.074.127.075.131.073.131.07.13.07.133.069.133.045.09.086.137.109.119.13.096.144.07.156.042.16.013.16-.017.155-.047.143-.075.126-.1.106-.121.082-.14.054-.151.025-.16-.005-.16-.035-.158-.05-.124-.048-.095-.002-.004-.002-.004-.073-.14-.002-.005-.002-.004-.074-.14-.002-.004-.002-.004-.076-.14-.002-.003-.002-.004-.077-.139-.003-.004-.002-.004-.078-.138-.003-.004-.002-.003-.08-.137-.002-.004-.003-.004-.081-.136-.002-.004-.003-.004-.083-.136-.002-.003-.002-.004-.085-.135-.002-.004-.003-.003-.085-.134-.003-.004-.002-.004-.087-.132-.003-.004-.003-.004-.088-.132-.003-.003-.002-.004-.09-.13-.003-.005-.003-.003-.091-.13-.003-.004-.002-.004-.093-.129-.003-.003-.003-.004-.094-.128-.003-.004-.003-.003-.095-.127-.003-.004-.003-.004-.097-.125-.003-.004-.003-.004-.09-.114-.06-.082-.003-.003-.002-.003-.069-.091-.002-.004-.002-.003-.07-.09-.003-.003-.002-.003-.07-.09-.003-.003-.002-.003-.071-.09-.002-.003-.003-.002-.072-.089-.002-.003-.002-.003-.073-.088-.002-.003-.002-.002-.074-.087-.002-.003-.002-.003-.074-.086-.003-.003-.002-.003-.074-.086-.003-.002-.002-.003-.075-.085-.003-.003-.002-.002-.076-.084-.002-.003-.003-.003-.076-.083-.002-.003-.003-.003-.077-.082-.002-.003-.003-.002-.077-.082-.003-.003-.003-.002-.078-.081-.002-.003-.003-.003-.078-.08-.003-.002-.003-.003-.079-.08-.002-.002-.003-.002-.08-.08-.002-.002-.003-.002-.08-.078-.003-.003-.003-.002-.08-.077-.003-.003-.003-.002-.082-.077-.002-.002-.003-.002-.082-.076-.003-.002-.002-.003-.083-.075-.003-.002-.002-.003-.084-.074-.002-.002-.003-.002-.084-.074-.003-.002-.002-.002-.085-.073-.002-.002-.003-.003-.085-.071-.003-.003-.002-.002-.086-.07-.003-.003-.002-.002-.086-.07-.003-.003-.003-.002-.086-.07-.003-.002-.003-.002-.087-.069-.002-.002-.003-.002-.088-.068-.002-.002-.003-.002-.088-.067-.003-.003-.003-.002-.088-.066-.003-.002-.003-.002-.089-.066-.003-.002-.003-.002-.057-.042-.14-.082-.15-.055-.16-.026-.16.004zm-18.458.426l-.157.037-.148.066-.111.074-.007.006-.003.002-.003.002-.086.069-.003.002-.002.002-.086.07-.003.002-.002.002-.086.07-.002.003-.003.002-.085.071-.002.002-.003.003-.084.071-.003.003-.002.002-.084.072-.003.003-.002.002-.083.073-.003.003-.002.002-.083.074-.002.002-.003.003-.082.074-.003.003-.002.002-.081.076-.003.002-.003.002-.08.077-.003.002-.003.003-.08.076-.002.003-.003.002-.08.078-.002.002-.003.003-.079.078-.002.003-.003.002-.078.08-.003.002-.002.002-.078.08-.002.003-.003.002-.077.08-.003.004-.002.002-.077.081-.002.003-.003.003-.076.082-.002.002-.003.003-.075.082-.002.003-.003.003-.074.083-.003.003-.002.003-.074.084-.003.003-.002.002-.074.085-.002.003-.002.003-.073.085-.003.003-.002.003-.072.086-.002.003-.003.003-.071.087-.003.003-.002.002-.07.088-.003.003-.002.003-.07.088-.003.003-.002.003-.07.09-.002.002-.002.003-.069.09-.002.003-.003.003-.068.09-.002.003-.002.003-.067.092-.003.003-.002.003-.067.092-.002.003-.002.003-.066.092-.002.003-.002.004-.066.093-.002.003-.002.003-.065.094-.002.003-.002.004-.064.094-.002.003-.002.004-.063.095-.002.003-.002.003-.063.097-.002.003-.002.003-.046.073-.05.07-.003.002-.002.003-.067.093-.003.003-.002.003-.066.094-.002.003-.002.003-.066.094-.002.003-.002.003-.064.094-.002.004-.002.003-.064.094-.002.004-.002.003-.062.095-.002.003-.002.003-.062.096-.002.003-.002.003-.06.096-.003.003-.002.003-.06.096-.001.004-.002.003-.059.096-.002.004-.002.003-.058.097-.002.003-.001.003-.057.098-.002.003-.002.003-.056.098-.002.003-.002.003-.055.098-.002.004-.001.003-.055.098-.001.004-.002.003-.054.099-.001.003-.002.003-.052.1-.002.002-.002.004-.051.1-.002.002-.002.004-.05.1-.002.003-.002.003-.05.1v.003l-.002.004-.05.1V9.5l-.002.004-.048.1-.002.004-.001.003-.047.101-.002.003-.001.004-.013.027-.052.152-.024.16.006.16.037.157.064.148.091.133.114.114.134.09.147.065.157.036.162.006.159-.024.152-.053.14-.08.122-.105.1-.126.066-.117.01-.023.044-.095.045-.095.002-.003.042-.087.048-.097.048-.095v-.001l.048-.092.001-.001.047-.09.05-.093.002-.002.049-.09.052-.092.001-.002.051-.089.001-.002.051-.087.053-.088.001-.002.055-.091.057-.091.057-.09.001-.002.057-.089.055-.083.001-.002.06-.09.06-.088.062-.089.001-.001.06-.084.063-.088.065-.089.017-.023.016-.025.06-.094.059-.09v-.002l.058-.086.057-.086.001-.001.062-.09.062-.088.001-.002.06-.085.002-.002.06-.082.063-.087.064-.084.002-.002.061-.08.065-.084.064-.08v-.001l.067-.083.067-.082.07-.083.069-.08.063-.074.074-.083.068-.077.002-.002.07-.076.07-.075.072-.077.001-.001.067-.07.076-.078.002-.002.07-.07.075-.075.002-.002.072-.07.075-.072.002-.002.073-.069.074-.068.001-.001.08-.073.076-.068.002-.002.072-.063v-.001l.078-.067.079-.068.002-.001.08-.068.002-.002.077-.063.082-.066.001-.001.075-.06.002-.002.006-.004.117-.111.094-.131.068-.146.04-.156.01-.161-.019-.16-.049-.154-.076-.141-.102-.125-.123-.105-.14-.079-.153-.052-.16-.023-.16.007zm24.596 11.088l-.156.04-.146.067-.131.094-.112.117-.087.135-.061.15-.033.157-.004.134.007.142.005.152.004.15.002.149v.153l.001.011v.015l.004.11.002.11v.002l.002.106v.321l-.003.102-.002.106-.004.107-.005.105-.006.106-.006.106-.008.106v.002l-.008.103v.002l-.01.1-.01.105-.01.105-.013.105-.012.099v.002l-.014.108-.014.1-.016.105-.016.103v.002l-.017.099-.018.104-.019.103v.002l-.019.097-.02.104-.022.103v.001l-.022.098-.023.103v.002l-.024.096-.025.103v.002l-.024.096-.027.102v.003l-.026.093v.001l-.029.103v.002l-.03.099-.028.097v.002l-.03.095-.03.096v.001l-.033.1-.031.095v.002l-.035.1v.003l-.034.094v.003l-.035.096v.001l-.034.09v.002l-.038.098-.036.093v.002l-.038.095-.079.194-.08.188-.085.189-.087.19-.09.184-.092.183-.095.184-.05.093-.064.148-.034.158-.005.16.026.16.054.151.082.14.106.12.127.1.143.075.154.046.16.017.161-.013.156-.042.144-.071.13-.096.109-.119.072-.112.053-.099.003-.005.003-.006.102-.195.003-.006.003-.006.098-.196.003-.006.003-.006.096-.197.002-.006.003-.006.093-.2.002-.006.003-.006.09-.2.002-.006.003-.007.086-.202.003-.006.002-.006.084-.203.002-.005.001-.005.04-.102.002-.003.001-.003.04-.103.001-.003.001-.003.04-.103v-.004l.001-.003.039-.103v-.003l.002-.003.037-.104.001-.003.001-.003.037-.104v-.004l.002-.003.035-.104.002-.003v-.004l.035-.104.002-.004v-.003l.034-.105.002-.003v-.003l.034-.105v-.004l.002-.003.032-.106.001-.003.001-.003.031-.106.001-.003.001-.004.031-.106.001-.003.001-.004.03-.106v-.003l.002-.004.028-.107.001-.003.001-.003.028-.107.001-.004.001-.003.027-.107.001-.004v-.003l.027-.108.001-.003v-.004l.026-.108.001-.003v-.004l.025-.108.001-.003v-.004l.025-.108v-.004l.001-.003.023-.109v-.003l.001-.004.022-.109v-.003l.002-.004.02-.109.001-.004v-.003l.02-.11.002-.003v-.004l.02-.11v-.007l.019-.11v-.003l.001-.004.017-.11v-.004l.001-.003.017-.11v-.008l.016-.11v-.004l.001-.004.015-.11v-.008l.015-.111v-.008l.013-.111v-.007l.013-.112v-.007l.011-.112v-.004l.001-.004.01-.112v-.007l.01-.112v-.008l.008-.112v-.008l.007-.113v-.007l.007-.113v-.008l.005-.113v-.007l.005-.114v-.007l.003-.114v-.007l.003-.114v-.129l.001-.114v-.13l-.003-.114V16.5l-.003-.115v-.007l-.003-.102v-.155l-.003-.158v-.01l-.004-.158v-.01l-.006-.158v-.01l-.007-.148-.023-.16-.051-.152-.08-.14-.103-.124-.125-.102-.142-.077-.153-.05-.16-.02-.161.01zm-30.213.66l-.157.034-.149.063-.134.09-.115.113-.092.132-.067.147-.037.156-.009.134.001.11V16.308l.006.22v.012l.01.22v.012l.012.22v.006l.001.006.015.22v.005l.001.006.018.22.001.006v.006l.022.219v.006l.001.006.024.219.001.006v.006l.028.218.001.006v.006l.031.218.001.006.001.006.033.218.001.006.001.005.037.218v.006l.002.005.04.217v.006l.001.006.043.216.001.006.001.006.046.216v.005l.002.006.048.215.002.006.001.006.051.214.002.006v.006l.055.214.002.005.001.006.057.213.002.006.001.005.06.213.002.005.001.006.063.212.002.005.001.006.066.21.002.006.002.006.068.21.002.005.002.005.07.21.003.005.002.005.074.208.002.006.002.005.077.207.002.006.002.005.08.206.002.005.002.006.082.204.002.006.002.005.086.204.002.005.002.006.088.202.002.005.003.006.09.2.003.006.002.005.094.2.002.006.003.005.096.199.002.005.003.005.03.062.086.137.11.118.128.097.145.07.156.043.16.013.16-.017.155-.047.143-.074.127-.1.106-.121.081-.14.055-.15.025-.16-.005-.161-.034-.158-.05-.124-.028-.055-.092-.19-.087-.188-.087-.192-.083-.19-.08-.193-.078-.194-.076-.196-.073-.195-.07-.197-.067-.198-.065-.199-.063-.2-.059-.2-.056-.2-.055-.204-.05-.201-.049-.202-.046-.205-.043-.206-.04-.203-.038-.207-.034-.204-.032-.207-.028-.205-.026-.207-.023-.208-.02-.207-.018-.207-.014-.208-.011-.207-.009-.208-.005-.207-.002-.104-.017-.16-.046-.155-.074-.143-.1-.126-.121-.107-.139-.081-.152-.055-.159-.025-.161.004zm24.585 11.83l-.156.039-.146.068-.11.076-.015.012-.163.129-.166.127-.168.125-.17.124-.17.12-.172.118-.173.115-.176.114-.177.111-.18.11-.178.105-.182.104-.182.101-.184.1-.184.095-.189.095-.186.09-.188.089-.19.086-.19.082-.193.081-.195.078-.191.074-.197.073-.195.07-.196.065-.198.064-.198.061-.2.058-.2.055-.2.052-.2.049-.151.035-.153.05-.141.078-.125.103-.103.124-.078.14-.05.154-.022.16.009.16.038.157.067.147.093.132.116.112.134.089.149.062.158.034.16.003.133-.02.158-.035.006-.002.006-.001.213-.052.006-.002.007-.001.212-.056.006-.001.006-.002.212-.058.006-.002.006-.002.211-.061.006-.002.006-.002.21-.064.006-.002.006-.002.21-.067.005-.002.006-.002.208-.07.006-.002.006-.003.207-.073.006-.002.006-.002.206-.077.006-.002.005-.002.206-.08.005-.001.006-.003.204-.082.006-.002.005-.002.203-.085.006-.003.005-.002.202-.088.006-.002.005-.003.2-.09.006-.003.006-.003.2-.093.005-.003.005-.002.198-.096.006-.003.005-.003.197-.099.005-.002.005-.003.196-.102.005-.002.005-.003.195-.105.005-.002.005-.003.193-.107.005-.003.005-.003.191-.11.005-.003.005-.003.19-.112.005-.003.005-.003.189-.115.005-.003.005-.003.187-.117.005-.003.004-.004.186-.12.005-.003.004-.003.184-.122.005-.003.005-.004.182-.125.004-.003.005-.003.18-.128.005-.003.005-.003.179-.13.004-.003.005-.004.177-.132.004-.004.005-.003.175-.135.005-.003.004-.004.173-.137.005-.003.004-.004.019-.015.115-.113.092-.132.066-.147.038-.157.008-.16-.022-.16-.052-.153-.079-.14-.103-.124-.125-.102-.142-.078-.153-.05-.16-.02-.16.01zm-19.17.054l-.153.051-.14.079-.124.103-.103.125-.077.141-.05.153-.02.16.009.161.04.156.067.147.093.131.095.094.047.04.005.004.005.004.17.14.005.004.005.004.172.137.004.004.005.003.086.067.003.002.003.002.087.067.003.002.003.002.088.066.002.003.003.002.089.065.002.002.003.002.09.065.002.002.003.002.09.064.002.002.003.002.09.063.003.002.003.002.09.063.003.002.003.002.092.062.002.002.003.002.092.061.003.002.003.002.092.06.003.003.003.001.093.06.003.002.003.002.093.06.003.001.003.002.094.058.003.002.003.002.095.058.003.001.003.002.095.057.003.002.003.002.095.056.003.002.003.002.096.055.004.002.003.001.096.055.003.002.003.002.098.053.003.002.003.002.097.053.004.002.003.001.098.053.003.001.003.002.099.052.003.001.003.002.1.05.003.002.003.002.1.05.003.002.003.001.1.05h.003l.004.003.1.048.004.001.003.002.101.048.003.001.004.002.101.046.004.002.003.001.102.046.004.002.003.001.103.045.003.002.003.001.103.045.004.001.003.002.104.043.003.001.004.002.104.042.003.002.004.001.104.042.004.001.003.002.105.04.004.002.003.001.106.04.003.002h.004l.106.04.004.001.003.002.107.038.003.001.004.001.107.038.003.001.004.001.107.037.004.001.004.001.108.036.003.001.004.001.108.035.004.001.003.001.11.034.003.001.004.001.109.033.004.002h.003l.11.033h.004l.003.002.11.031.004.001.004.001.084.023.081.028.004.001.003.001.109.037.003.001.004.001.109.036.003.001.004.001.109.035h.003l.004.002.11.033.003.001.003.001.11.033.003.001.004.001.109.031.004.002h.003l.11.031.003.001.004.001.11.03h.003l.003.001.11.029h.004l.003.002.11.027.003.001.004.001.11.027h.003l.004.001.004.001.16.022.16-.008.157-.038.147-.067.132-.092.112-.116.09-.134.062-.149.034-.157.004-.161-.025-.16-.055-.151-.082-.139-.107-.12-.127-.1-.143-.074-.124-.04h-.003l-.104-.025-.103-.026h-.002l-.095-.026h-.001l-.101-.027h-.002l-.1-.028h-.002l-.103-.03-.104-.032-.097-.03h-.002l-.103-.033-.102-.033-.101-.034-.106-.036-.027-.01-.027-.007-.107-.03-.104-.029-.104-.03h-.002l-.097-.03-.102-.032-.102-.032-.102-.034-.103-.035-.096-.034-.1-.036-.101-.037h-.002l-.094-.036-.096-.037-.097-.04h-.002l-.099-.04-.098-.042h-.002l-.092-.04-.097-.043-.095-.043-.097-.044h-.002l-.09-.043-.094-.045-.094-.046-.093-.047-.09-.046-.096-.05-.088-.047-.002-.001-.09-.049-.094-.052-.002-.002-.087-.049-.087-.05h-.002l-.088-.053h-.001l-.09-.055-.086-.052-.002-.001-.089-.055-.084-.054h-.002l-.09-.059h-.001l-.085-.056-.001-.001-.084-.056-.082-.056h-.001l-.086-.06-.082-.058H7.79l-.086-.062-.002-.002-.08-.058-.081-.06h-.001l-.085-.064-.002-.002-.076-.058-.002-.002-.082-.064-.161-.128-.162-.133-.04-.034-.132-.092-.147-.066-.157-.038-.16-.008-.16.022z"
  })));

  function _extends$b() { _extends$b = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$b.apply(this, arguments); }
  var StartEventNoneIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$b({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.847.004C9.61-.016 3.624 4.014 1.257 9.78-1.235 15.49.06 22.581 4.42 27.034c4.193 4.513 11.101 6.17 16.887 4.058 5.996-2.042 10.423-7.93 10.664-14.268.403-6.228-3.26-12.441-8.87-15.154A15.924 15.924 0 0015.846.004zm.439 1.729c6.105.033 11.856 4.45 13.435 10.359 1.678 5.653-.592 12.198-5.463 15.547-5.06 3.719-12.564 3.45-17.343-.625-4.814-3.84-6.538-10.94-4.067-16.57 2.14-5.206 7.515-8.775 13.147-8.71.097-.001.194-.002.29-.001z"
  })));

  function _extends$a() { _extends$a = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$a.apply(this, arguments); }
  var StartEventParallelMultipleIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$a({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.847 0C9.61-.02 3.624 4.01 1.257 9.775-1.235 15.485.06 22.577 4.42 27.03c4.193 4.513 11.101 6.17 16.887 4.058 5.996-2.042 10.423-7.93 10.664-14.268.403-6.228-3.26-12.441-8.87-15.154A15.924 15.924 0 0015.846 0zm.439 1.729c6.105.033 11.856 4.45 13.435 10.359 1.678 5.653-.592 12.198-5.463 15.547-5.06 3.719-12.564 3.45-17.343-.625C2.101 23.17.377 16.07 2.848 10.44c2.134-5.2 7.522-8.78 13.147-8.71.097-.001.194-.002.29-.001zM13.504 9.08v4.427H9.077v4.98h4.427v4.427h4.98v-4.427h4.428v-4.98h-4.427V9.08h-4.98zm.83.83h3.32v4.427h4.428v3.32h-4.427v4.427h-3.32v-4.453H9.906v-3.294h4.427V9.91z"
  })));

  function _extends$9() { _extends$9 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$9.apply(this, arguments); }
  var StartEventSignalIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$9({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M15.995.005C9.705-.08 3.643 3.968 1.257 9.78-1.235 15.49.06 22.581 4.42 27.034c4.193 4.513 11.102 6.17 16.887 4.058 5.996-2.042 10.423-7.93 10.664-14.269.403-6.227-3.26-12.44-8.87-15.153A15.924 15.924 0 0015.994.005zm0 1.73c6.213-.108 12.122 4.355 13.726 10.357 1.678 5.653-.592 12.198-5.463 15.547-5.06 3.719-12.564 3.45-17.343-.626-4.814-3.838-6.538-10.939-4.067-16.57 2.14-5.205 7.515-8.774 13.147-8.708zm0 6.776L9.19 20.724H22.8L15.995 8.511zm0 1.777l5.332 9.572H10.662l5.333-9.572z"
  })));

  function _extends$8() { _extends$8 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$8.apply(this, arguments); }
  var StartEventTimerIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$8({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M16 0C7.174 0 0 7.174 0 16s7.174 16 16 16 16-7.174 16-16S24.826 0 16 0zm0 1.73c7.892 0 14.27 6.378 14.27 14.27 0 7.891-6.379 14.27-14.27 14.27S1.73 23.891 1.73 16C1.73 8.108 8.108 1.73 16 1.73zm-.143 6.676c-2.967.02-5.797 1.97-6.89 4.727-1.138 2.695-.51 6.012 1.537 8.102 1.99 2.142 5.268 2.932 8.014 1.928 2.878-.98 4.992-3.827 5.068-6.87.153-2.957-1.624-5.881-4.3-7.137a7.552 7.552 0 00-3.43-.75zm.27 1.383c2.71.012 5.254 2.015 5.886 4.656.704 2.577-.482 5.517-2.791 6.867-2.358 1.48-5.682 1.085-7.618-.918-2.043-1.971-2.407-5.381-.84-7.745 1.11-1.763 3.15-2.88 5.234-2.86h.13zm1.833 1.765l-2.074 3.763c-.64.068-.793 1.04-.202 1.3.39.27.696-.18 1.052-.165h3.17v-.865h-3.181l1.992-3.615-.757-.418z"
  })));

  function _extends$7() { _extends$7 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$7.apply(this, arguments); }
  var SubprocessCollapsedIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$7({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M5.637 3A5.644 5.644 0 000 8.637v15.417a5.644 5.644 0 005.637 5.637h20.726A5.644 5.644 0 0032 24.054V8.637A5.644 5.644 0 0026.363 3H5.637zm0 1.778h20.726a3.83 3.83 0 013.859 3.859v15.417a3.83 3.83 0 01-3.859 3.858h-4.201V16.695H9.838v11.217H5.637a3.83 3.83 0 01-3.859-3.858V8.637a3.83 3.83 0 013.859-3.859zm5.33 13.046h10.066v10.065H10.967V17.824zm4.189 1.431V22.06H12.35v1.689h2.804V26.554h1.69V23.749h2.804V22.06h-2.804V19.255h-1.69z"
  })));

  function _extends$6() { _extends$6 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$6.apply(this, arguments); }
  var SubprocessExpandedIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$6({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M5.636 3A5.642 5.642 0 000 8.636v15.418a5.643 5.643 0 005.636 5.636h20.728A5.643 5.643 0 0032 24.054V8.636A5.642 5.642 0 0026.364 3H5.636zm0 1.778h20.728a3.83 3.83 0 013.858 3.858v15.418a3.83 3.83 0 01-3.858 3.858h-4.203V16.723H9.84v11.189H5.636a3.83 3.83 0 01-3.858-3.858V8.636a3.83 3.83 0 013.858-3.858zm5.331 13.074h10.066v10.06H10.967v-10.06zm1.336 3.996v1.711h7.394v-1.71h-7.394z"
  })));

  function _extends$5() { _extends$5 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$5.apply(this, arguments); }
  var TaskNoneIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$5({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M6.494 2.667C2.916 2.667 0 5.57 0 9.142v13.383C0 26.097 2.916 29 6.494 29h19.012C29.084 29 32 26.097 32 22.525V9.142c0-3.572-2.916-6.475-6.494-6.475H6.494zm0 2h19.012c2.509 0 4.494 1.98 4.494 4.475v13.383C30 25.02 28.015 27 25.506 27H6.494C3.985 27 2 25.02 2 22.525V9.142c0-2.495 1.985-4.475 4.494-4.475z"
  })));

  function _extends$4() { _extends$4 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$4.apply(this, arguments); }
  var TextAnnotationicon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$4({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M22.087 0v31.647H32v-1.788h-8.125V1.788H32V0h-9.913zm-2.924 13.999l-2.737 2.167 2.167 2.738 2.738-2.167-2.168-2.738zm-5.475 4.335L10.95 20.5l2.168 2.738 2.737-2.168-2.167-2.737zm-5.475 4.335l-2.738 2.167 2.168 2.738 2.737-2.168-2.167-2.737zm-5.476 4.335L0 29.17l2.167 2.738 2.738-2.168-2.168-2.737z"
  })));

  function _extends$3() { _extends$3 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3.apply(this, arguments); }
  var TransactionIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$3({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M5.422 3A5.424 5.424 0 000 8.422v15.822a5.424 5.424 0 005.422 5.423h21.156A5.424 5.424 0 0032 24.244V8.422A5.424 5.424 0 0026.578 3H5.422zm0 1.244h21.156a4.155 4.155 0 014.178 4.178v15.822a4.155 4.155 0 01-4.178 4.178H5.422a4.155 4.155 0 01-4.178-4.178V8.422a4.155 4.155 0 014.178-4.178zm1.056 1.778a3.373 3.373 0 00-3.367 3.366v13.89a3.373 3.373 0 003.367 3.366h19.044a3.373 3.373 0 003.367-3.366V9.388a3.373 3.373 0 00-3.367-3.366H6.478zm0 1.245h19.044c1.187 0 2.122.935 2.122 2.121v13.89a2.104 2.104 0 01-2.122 2.122H6.478a2.104 2.104 0 01-2.122-2.122V9.388c0-1.186.935-2.121 2.122-2.121z"
  })));

  function _extends$2() { _extends$2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
  var UserTaskIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$2({
    xmlns: "http://www.w3.org/2000/svg",
    width: "32",
    height: "32"
  }, props), /*#__PURE__*/React.createElement("path", {
    fillRule: "evenodd",
    d: "M10.263 7.468c-1.698 0-2.912 1.305-2.915 2.791v.001c0 .45.121.924.311 1.352.138.309.308.593.516.82-1.235.423-2.683 1.119-3.414 2.49l-.04.075v4.44h11.083v-4.44l-.04-.074c-.72-1.352-2.136-2.047-3.36-2.471.597-.608.774-1.392.774-2.192-.004-1.487-1.218-2.792-2.915-2.792zm-1.16 1.583c.08 0 .165.003.26.008.757.045 1.012.181 1.207.31.196.13.334.252.851.268.404-.016.598-.087.737-.169.056-.033.103-.067.152-.1.128.275.197.578.198.893 0 .894-.154 1.52-.975 2.034l.08.604c.171.052.348.11.527.171.025.105.054.242.073.387.02.153.029.311.016.43a.422.422 0 01-.056.19c-.417.417-1.157.66-1.908.66-.75 0-1.49-.243-1.908-.66a.422.422 0 01-.056-.19 1.949 1.949 0 01.016-.43c.02-.146.049-.284.074-.388.177-.062.352-.118.521-.17l.048-.648a.616.616 0 00-.126-.118c-.183-.138-.405-.44-.562-.793-.157-.353-.254-.757-.254-1.08 0-.387.105-.758.297-1.079l.11-.04c.143-.046.339-.09.679-.09zm-1.448 4.304l-.002.014c-.025.185-.04.387-.018.589.021.202.074.42.248.593.595.594 1.494.857 2.382.857.889 0 1.788-.263 2.382-.857.174-.174.227-.391.249-.593a2.496 2.496 0 00-.018-.59l-.002-.01c.903.396 1.776.963 2.258 1.81v3.599H13.53v-2.538h-.67v2.538H7.651v-2.538h-.67v2.538H5.39v-3.599c.483-.849 1.359-1.416 2.264-1.813zM6.495 3C2.914 3 0 5.903 0 9.475v13.383c0 3.572 2.916 6.475 6.494 6.475h19.012c3.578 0 6.494-2.903 6.494-6.475V9.475C32 5.903 29.084 3 25.506 3H6.494zm0 2h19.01C28.016 5 30 6.98 30 9.475v13.383c0 2.495-1.985 4.475-4.494 4.475H6.494C3.985 27.333 2 25.353 2 22.858V9.475C2 6.98 3.985 5 6.494 5z"
  })));

  var iconsByType = {
    'Association': AssociationIcon,
    'BusinessRuleTask': BusinessRuleTaskIcon,
    'CallActivity': CallActivityIcon,
    'Collaboration': CollaborationIcon,
    'ConditionalFlow': ConditionalFlowIcon,
    'SequenceFlow': ConnectionIcon,
    'DataInput': DataInputIcon,
    'DataInputAssociation': DataInputOutputAssociationIcon,
    'DataOutput': DataOutputIcon,
    'DataOutputAssociation': DataInputOutputAssociationIcon,
    'DataObjectReference': DataObjectIcon,
    'DataStoreReference': DataStoreIcon,
    'DefaultFlow': DefaultFlowIcon,
    'CancelEndEvent': EndEventCancelIcon,
    'CompensateEndEvent': EndEventCompensationIcon,
    'ErrorEndEvent': EndEventErrorIcon,
    'EscalationEndEvent': EndEventEscalationIcon,
    'LinkEndEvent': EndEventLinkIcon,
    'MessageEndEvent': EndEventMessageIcon,
    'MultipleEndEvent': EndEventMultipleIcon,
    'EndEvent': EndEventNoneIcon,
    'SignalEndEvent': EndEventSignalIcon,
    'TerminateEndEvent': EndEventTerminateIcon,
    'EventSubProcess': EventSubProcessExpandedIcon,
    'ComplexGateway': GatewayComplexIcon,
    'EventBasedGateway': GatewayEventBasedIcon,
    'ExclusiveGateway': GatewayXorIcon,
    'Gateway': GatewayNoneIcon,
    'InclusiveGateway': GatewayOrIcon,
    'ParallelGateway': GatewayParallelIcon,
    'Group': GroupIcon,
    'CancelIntermediateCatchEvent': IntermediateEventCatchCancelIcon,
    'CompensateIntermediateCatchEvent': IntermediateEventCatchCompensationIcon,
    'ConditionalIntermediateCatchEvent': IntermediateEventCatchConditionIcon,
    'ErrorIntermediateCatchEvent': IntermediateEventCatchErrorIcon,
    'EscalationIntermediateCatchEvent': IntermediateEventCatchEscalationIcon,
    'LinkIntermediateCatchEvent': IntermediateEventCatchLinkIcon,
    'MessageIntermediateCatchEvent': IntermediateEventCatchMessageIcon,
    'MultipleIntermediateCatchEvent': IntermediateEventCatchMultipleIcon,
    'ConditionalIntermediateCatchEventNonInterrupting': IntermediateEventCatchNonInterruptingConditionIcon,
    'EscalationIntermediateCatchEventNonInterrupting': IntermediateEventCatchNonInterruptingEscalationIcon,
    'MessageIntermediateCatchEventNonInterrupting': IntermediateEventCatchNonInterruptingMessageIcon,
    'MultipleIntermediateCatchEventNonInterrupting': IntermediateEventCatchNonInterruptingMultipleIcon,
    'ParallelIntermediateCatchEventNonInterrupting': IntermediateEventCatchNonInterruptingParallelIcon,
    'SignalIntermediateCatchEventNonInterrupting': IntermediateEventCatchNonInterruptingSignalIcon,
    'TimerIntermediateCatchEventNonInterrupting': IntermediateEventCatchNonInterruptingTimerIcon,
    'ParallelMultipleIntermediateCatchEvent': IntermediateEventCatchParallelMultipleIcon,
    'SignalIntermediateCatchEvent': IntermediateEventCatchSignalIcon,
    'TimerIntermediateCatchEvent': IntermediateEventCatchTimerIcon,
    'IntermediateThrowEvent': IntermediateEventNoneIcon,
    'CompensateIntermediateThrowEvent': IntermediateEventThrowCompensationIcon,
    'EscalationIntermediateThrowEvent': IntermediateEventThrowEscalationIcon,
    'LinkIntermediateThrowEvent': IntermediateEventThrowLinkIcon,
    'MessageIntermediateThrowEvent': IntermediateEventThrowMessageIcon,
    'MultipleIntermediateThrowEvent': IntermediateEventThrowMultipleIcon,
    'SignalIntermediateThrowEvent': IntermediateEventThrowSignalIcon,
    'Lane': LaneIcon,
    'ManualTask': ManualTaskIcon,
    'MessageFlow': MessageFlowIcon,
    'Participant': ParticipantIcon,
    'Process': ProcessIcon,
    'ReceiveTask': ReceiveTaskIcon,
    'ScriptTask': ScriptTaskIcon,
    'SendTask': SendTaskIcon,
    'ServiceTask': ServiceTaskIcon,
    'CompensateStartEvent': StartEventCompensationIcon,
    'ConditionalStartEvent': StartEventConditionIcon,
    'ErrorStartEvent': StartEventErrorIcon,
    'EscalationStartEvent': StartEventEscalationIcon,
    'MessageStartEvent': StartEventMessageIcon,
    'MultipleStartEvent': StartEventMultipleIcon,
    'ConditionalStartEventNonInterrupting': StartEventNonInterruptingConditionIcon,
    'EscalationStartEventNonInterrupting': StartEventNonInterruptingEscalationIcon,
    'MessageStartEventNonInterrupting': StartEventNonInterruptingMessageIcon,
    'MultipleStartEventNonInterrupting': StartEventNonInterruptingMultipleIcon,
    'ParallelMultipleStartEventNonInterrupting': StartEventNonInterruptingParallelMultipleIcon,
    'SignalStartEventNonInterrupting': StartEventNonInterruptingSignalIcon,
    'TimerStartEventNonInterrupting': StartEventNonInterruptingTimerIcon,
    'CancelBoundaryEvent': IntermediateEventCatchCancelIcon,
    'CompensateBoundaryEvent': IntermediateEventCatchCompensationIcon,
    'ConditionalBoundaryEvent': IntermediateEventCatchConditionIcon,
    'ErrorBoundaryEvent': IntermediateEventCatchErrorIcon,
    'EscalationBoundaryEvent': IntermediateEventCatchEscalationIcon,
    'LinkBoundaryEvent': IntermediateEventCatchLinkIcon,
    'MessageBoundaryEvent': IntermediateEventCatchMessageIcon,
    'MultipleBoundaryEvent': IntermediateEventCatchMultipleIcon,
    'BoundaryEvent': IntermediateEventNoneIcon,
    'ConditionalBoundaryEventNonInterrupting': IntermediateEventCatchNonInterruptingConditionIcon,
    'EscalationBoundaryEventNonInterrupting': IntermediateEventCatchNonInterruptingEscalationIcon,
    'MessageBoundaryEventNonInterrupting': IntermediateEventCatchNonInterruptingMessageIcon,
    'MultipleBoundaryEventNonInterrupting': IntermediateEventCatchNonInterruptingMultipleIcon,
    'ParallelBoundaryEventNonInterrupting': IntermediateEventCatchNonInterruptingParallelIcon,
    'SignalBoundaryEventNonInterrupting': IntermediateEventCatchNonInterruptingSignalIcon,
    'TimerBoundaryEventNonInterrupting': IntermediateEventCatchNonInterruptingTimerIcon,
    'ParallelMultipleBoundaryEvent': IntermediateEventCatchParallelMultipleIcon,
    'SignalBoundaryEvent': IntermediateEventCatchSignalIcon,
    'TimerBoundaryEvent': IntermediateEventCatchTimerIcon,
    'StartEvent': StartEventNoneIcon,
    'ParallelMultipleStartEvent': StartEventParallelMultipleIcon,
    'SignalStartEvent': StartEventSignalIcon,
    'TimerStartEvent': StartEventTimerIcon,
    'CollapsedSubProcess': SubprocessCollapsedIcon,
    'CollapsedAdHocSubProcess': SubprocessCollapsedIcon,
    'ExpandedSubProcess': SubprocessExpandedIcon,
    'ExpandedAdHocSubProcess': SubprocessExpandedIcon,
    'Task': TaskNoneIcon,
    'TextAnnotation': TextAnnotationicon,
    'Transaction': TransactionIcon,
    'UserTask': UserTaskIcon
  };

  function getConcreteType(element) {
    const {
      type: elementType
    } = element;
    let type = getRawType(elementType); // (1) event definition types

    const eventDefinition = getEventDefinition$2(element);

    if (eventDefinition) {
      type = `${getEventDefinitionPrefix(eventDefinition)}${type}`; // (1.1) interrupting / non interrupting

      if (is$4(element, 'bpmn:StartEvent') && !isInterrupting(element) || is$4(element, 'bpmn:BoundaryEvent') && !isCancelActivity(element)) {
        type = `${type}NonInterrupting`;
      }

      return type;
    } // (2) sub process types


    if (is$4(element, 'bpmn:SubProcess') && !is$4(element, 'bpmn:Transaction')) {
      if (isEventSubProcess(element)) {
        type = `Event${type}`;
      } else {
        const expanded = isExpanded(element) && !isPlane(element);
        type = `${expanded ? 'Expanded' : 'Collapsed'}${type}`;
      }
    } // (3) conditional + default flows


    if (isDefaultFlow(element)) {
      type = 'DefaultFlow';
    }

    if (isConditionalFlow(element)) {
      type = 'ConditionalFlow';
    }

    return type;
  }
  const PanelHeaderProvider = {
    getDocumentationRef: element => {
      const elementTemplates = getTemplatesService();

      if (elementTemplates) {
        return getTemplateDocumentation(element, elementTemplates);
      }
    },
    getElementLabel: element => {
      if (is$4(element, 'bpmn:Process')) {
        return getBusinessObject$1(element).name;
      }

      return getLabel(element);
    },
    getElementIcon: element => {
      const concreteType = getConcreteType(element);
      const elementTemplates = getTemplatesService();

      if (elementTemplates) {
        const template = getTemplate(element, elementTemplates);

        if (template && template.icon) {
          return () => o$1("img", {
            class: "bio-properties-panel-header-template-icon",
            width: "32",
            height: "32",
            src: template.icon.contents
          });
        }
      }

      return iconsByType[concreteType];
    },
    getTypeLabel: element => {
      const elementTemplates = getTemplatesService();

      if (elementTemplates) {
        const template = getTemplate(element, elementTemplates);

        if (template && template.name) {
          return template.name;
        }
      }

      const concreteType = getConcreteType(element);
      return concreteType.replace(/(\B[A-Z])/g, ' $1').replace(/(\bNon Interrupting)/g, '($1)');
    }
  }; // helpers ///////////////////////

  function isCancelActivity(element) {
    const businessObject = getBusinessObject$1(element);
    return businessObject && businessObject.cancelActivity !== false;
  }

  function getEventDefinition$2(element) {
    const businessObject = getBusinessObject$1(element),
          eventDefinitions = businessObject.eventDefinitions;
    return eventDefinitions && eventDefinitions[0];
  }

  function getRawType(type) {
    return type.split(':')[1];
  }

  function getEventDefinitionPrefix(eventDefinition) {
    const rawType = getRawType(eventDefinition.$type);
    return rawType.replace('EventDefinition', '');
  }

  function isDefaultFlow(element) {
    const businessObject = getBusinessObject$1(element);
    const sourceBusinessObject = getBusinessObject$1(element.source);

    if (!is$4(element, 'bpmn:SequenceFlow') || !sourceBusinessObject) {
      return false;
    }

    return sourceBusinessObject.default && sourceBusinessObject.default === businessObject && (is$4(sourceBusinessObject, 'bpmn:Gateway') || is$4(sourceBusinessObject, 'bpmn:Activity'));
  }

  function isConditionalFlow(element) {
    const businessObject = getBusinessObject$1(element);
    const sourceBusinessObject = getBusinessObject$1(element.source);

    if (!is$4(element, 'bpmn:SequenceFlow') || !sourceBusinessObject) {
      return false;
    }

    return businessObject.conditionExpression && is$4(sourceBusinessObject, 'bpmn:Activity');
  }

  function isPlane(element) {
    // Backwards compatibility for bpmn-js<8
    const di = element && (element.di || getBusinessObject$1(element).di);
    return is$4(di, 'bpmndi:BPMNPlane');
  }

  function getTemplatesService() {
    // eslint-disable-next-line react-hooks/rules-of-hooks
    return useService('elementTemplates', false);
  }

  function getTemplate(element, elementTemplates) {
    return elementTemplates.get(element);
  }

  function getTemplateDocumentation(element, elementTemplates) {
    const template = getTemplate(element, elementTemplates);
    return template && template.documentationRef;
  }

  function _extends$1() { _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
  var EmptyIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends$1({
    xmlns: "http://www.w3.org/2000/svg",
    xmlnsXlink: "http://www.w3.org/1999/xlink",
    width: "64",
    height: "64"
  }, props), /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("rect", {
    id: "a",
    width: "57",
    height: "47",
    x: "3",
    y: "8",
    rx: "7"
  }), /*#__PURE__*/React.createElement("mask", {
    id: "b",
    width: "57",
    height: "47",
    x: "0",
    y: "0",
    fill: "#fff",
    maskContentUnits: "userSpaceOnUse",
    maskUnits: "objectBoundingBox"
  }, /*#__PURE__*/React.createElement("use", {
    xlinkHref: "#a"
  }))), /*#__PURE__*/React.createElement("g", {
    fill: "none",
    fillRule: "evenodd"
  }, /*#__PURE__*/React.createElement("path", {
    fill: "#818798",
    d: "M52 11a5 5 0 015 5v31a5 5 0 01-5 5H11a5 5 0 01-5-5V16a5 5 0 015-5h41zm0 2H11a3 3 0 00-2.995 2.824L8 16v31a3 3 0 002.824 2.995L11 50h41a3 3 0 002.995-2.824L55 47V16a3 3 0 00-2.824-2.995L52 13z"
  }), /*#__PURE__*/React.createElement("path", {
    fill: "#D5D7DD",
    d: "M16 24h31v6H16zM21 33h21v6H21z"
  }), /*#__PURE__*/React.createElement("use", {
    stroke: "#B9BCC6",
    strokeDasharray: "5 2",
    strokeWidth: "2",
    mask: "url(#b)",
    xlinkHref: "#a"
  }))));

  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
  var MultipleIcon = (({
    styles = {},
    ...props
  }) => /*#__PURE__*/React.createElement("svg", _extends({
    xmlns: "http://www.w3.org/2000/svg",
    xmlnsXlink: "http://www.w3.org/1999/xlink",
    width: "128",
    height: "64"
  }, props), /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("path", {
    id: "a",
    d: "M9 9h110v47H9z"
  }), /*#__PURE__*/React.createElement("mask", {
    id: "b",
    width: "110",
    height: "47",
    x: "0",
    y: "0",
    fill: "#fff",
    maskContentUnits: "userSpaceOnUse",
    maskUnits: "objectBoundingBox"
  }, /*#__PURE__*/React.createElement("use", {
    xlinkHref: "#a"
  }))), /*#__PURE__*/React.createElement("g", {
    fill: "none",
    fillRule: "evenodd"
  }, /*#__PURE__*/React.createElement("path", {
    fill: "#818798",
    d: "M25 20.272L37.728 33 25 45.728 12.272 33 25 20.272zm0 2.829L15.1 33l9.9 9.9 9.9-9.9-9.9-9.9z"
  }), /*#__PURE__*/React.createElement("path", {
    fill: "#D5D7DD",
    d: "M17 47h16v6H17z"
  }), /*#__PURE__*/React.createElement("path", {
    fill: "#818798",
    d: "M35 32h27v2H35z"
  }), /*#__PURE__*/React.createElement("path", {
    fill: "#818798",
    d: "M60 30v6l6-3z"
  }), /*#__PURE__*/React.createElement("path", {
    fill: "#D5D7DD",
    d: "M80 34h21v6H80z"
  }), /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("path", {
    fill: "#818798",
    d: "M111 12a5 5 0 015 5v31a5 5 0 01-5 5H70a5 5 0 01-5-5V17a5 5 0 015-5h41zm0 2H70a3 3 0 00-3 3v31a3 3 0 003 3h41a3 3 0 003-3V17a3 3 0 00-3-3z"
  }), /*#__PURE__*/React.createElement("path", {
    fill: "#D5D7DD",
    d: "M75 25h31v6H75z"
  })), /*#__PURE__*/React.createElement("use", {
    stroke: "#B9BCC6",
    strokeDasharray: "5 2",
    strokeWidth: "2",
    mask: "url(#b)",
    xlinkHref: "#a"
  }))));

  const PanelPlaceholderProvider = translate => {
    if (!translate) translate = text => text;
    return {
      getEmpty: () => {
        return {
          text: translate('Select an element to edit its properties.'),
          icon: EmptyIcon
        };
      },
      getMultiple: () => {
        return {
          text: translate('Multiple elements are selected. Select a single element to edit its properties.'),
          icon: MultipleIcon
        };
      }
    };
  };

  function BpmnPropertiesPanel(props) {
    const {
      element,
      injector,
      getProviders,
      layoutConfig,
      descriptionConfig
    } = props;
    const canvas = injector.get('canvas');
    const elementRegistry = injector.get('elementRegistry');
    const eventBus = injector.get('eventBus');
    const translate = injector.get('translate');
    const [state, setState] = l$1({
      selectedElement: element
    });
    const selectedElement = state.selectedElement;
    /**
     * @param {djs.model.Base | Array<djs.model.Base>} element
     */

    const _update = element => {
      if (!element) {
        return;
      }

      let newSelectedElement = element; // handle labels

      if (newSelectedElement && newSelectedElement.type === 'label') {
        newSelectedElement = newSelectedElement.labelTarget;
      }

      setState({ ...state,
        selectedElement: newSelectedElement
      }); // notify interested parties on property panel updates

      eventBus.fire('propertiesPanel.updated', {
        element: newSelectedElement
      });
    }; // (2) react on element changes
    // (2a) selection changed


    y(() => {
      const onSelectionChanged = e => {
        const {
          newSelection = []
        } = e;

        if (newSelection.length > 1) {
          return _update(newSelection);
        }

        const newElement = newSelection[0];
        const rootElement = canvas.getRootElement();

        if (isImplicitRoot$1(rootElement)) {
          return;
        }

        _update(newElement || rootElement);
      };

      eventBus.on('selection.changed', onSelectionChanged);
      return () => {
        eventBus.off('selection.changed', onSelectionChanged);
      };
    }, []); // (2b) selected element changed

    y(() => {
      const onElementsChanged = e => {
        const elements = e.elements;
        const updatedElement = findElement(elements, selectedElement);

        if (updatedElement && elementExists(updatedElement, elementRegistry)) {
          _update(updatedElement);
        }
      };

      eventBus.on('elements.changed', onElementsChanged);
      return () => {
        eventBus.off('elements.changed', onElementsChanged);
      };
    }, [selectedElement]); // (2c) root element changed

    y(() => {
      const onRootAdded = e => {
        const element = e.element;

        _update(element);
      };

      eventBus.on('root.added', onRootAdded);
      return () => {
        eventBus.off('root.added', onRootAdded);
      };
    }, [selectedElement]); // (2d) provided entries changed

    y(() => {
      const onProvidersChanged = () => {
        _update(selectedElement);
      };

      eventBus.on('propertiesPanel.providersChanged', onProvidersChanged);
      return () => {
        eventBus.off('propertiesPanel.providersChanged', onProvidersChanged);
      };
    }, [selectedElement]); // (2e) element templates changed

    y(() => {
      const onTemplatesChanged = () => {
        _update(selectedElement);
      };

      eventBus.on('elementTemplates.changed', onTemplatesChanged);
      return () => {
        eventBus.off('elementTemplates.changed', onTemplatesChanged);
      };
    }, [selectedElement]); // (3) create properties panel context

    const bpmnPropertiesPanelContext = {
      selectedElement,
      injector,

      getService(type, strict) {
        return injector.get(type, strict);
      }

    }; // (4) retrieve groups for selected element

    const providers = getProviders(selectedElement);
    const groups = d(() => {
      return reduce(providers, function (groups, provider) {
        // do not collect groups for multi element state
        if (isArray(selectedElement)) {
          return [];
        }

        const updater = provider.getGroups(selectedElement);
        return updater(groups);
      }, []);
    }, [providers, selectedElement]); // (5) notify layout changes

    const onLayoutChanged = layout => {
      eventBus.fire('propertiesPanel.layoutChanged', {
        layout
      });
    }; // (6) notify description changes


    const onDescriptionLoaded = description => {
      eventBus.fire('propertiesPanel.descriptionLoaded', {
        description
      });
    };

    return o$1(BpmnPropertiesPanelContext.Provider, {
      value: bpmnPropertiesPanelContext,
      children: o$1(PropertiesPanel, {
        element: selectedElement,
        headerProvider: PanelHeaderProvider,
        placeholderProvider: PanelPlaceholderProvider(translate),
        groups: groups,
        layoutConfig: layoutConfig,
        layoutChanged: onLayoutChanged,
        descriptionConfig: descriptionConfig,
        descriptionLoaded: onDescriptionLoaded,
        eventBus: eventBus
      })
    });
  } // helpers //////////////////////////

  function isImplicitRoot$1(element) {
    // Backwards compatibility for diagram-js<7.4.0, see https://github.com/bpmn-io/bpmn-properties-panel/pull/102
    return element && (element.isImplicit || element.id === '__implicitroot');
  }

  function findElement(elements, element) {
    return find$1(elements, e => e === element);
  }

  function elementExists(element, elementRegistry) {
    return element && elementRegistry.get(element.id);
  }

  var KEYCODE_Y = 89;
  var KEYCODE_Z = 90;
  var KEYS_REDO = ['y', 'Y', KEYCODE_Y];
  var KEYS_UNDO = ['z', 'Z', KEYCODE_Z];
  /**
   * @param {KeyboardEvent} event
   */

  function isCmd(event) {
    // ensure we don't react to AltGr
    // (mapped to CTRL + ALT)
    if (event.altKey) {
      return false;
    }

    return event.ctrlKey || event.metaKey;
  }
  /**
   * Checks if key pressed is one of provided keys.
   *
   * @param {string|Array<string>} keys
   * @param {KeyboardEvent} event
   */

  function isKey(keys, event) {
    keys = isArray(keys) ? keys : [keys];
    return keys.indexOf(event.key) !== -1 || keys.indexOf(event.keyCode) !== -1;
  }
  /**
   * @param {KeyboardEvent} event
   */

  function isShift(event) {
    return event.shiftKey;
  }
  function isUndo(event) {
    return isCmd(event) && !isShift(event) && isKey(KEYS_UNDO, event);
  }
  function isRedo(event) {
    return isCmd(event) && (isKey(KEYS_REDO, event) || isKey(KEYS_UNDO, event) && isShift(event));
  }

  const DEFAULT_PRIORITY$1 = 1000;
  /**
   * @typedef { import('@bpmn-io/properties-panel').GroupDefinition } GroupDefinition
   * @typedef { import('@bpmn-io/properties-panel').ListGroupDefinition } ListGroupDefinition
   * @typedef { { getGroups: (ModdleElement) => (Array{GroupDefinition|ListGroupDefinition}) => Array{GroupDefinition|ListGroupDefinition}) } PropertiesProvider
   */

  class BpmnPropertiesPanelRenderer {
    constructor(config, injector, eventBus) {
      const {
        parent,
        layout: layoutConfig,
        description: descriptionConfig
      } = config || {};
      this._eventBus = eventBus;
      this._injector = injector;
      this._layoutConfig = layoutConfig;
      this._descriptionConfig = descriptionConfig;
      this._container = domify$1('<div style="height: 100%" class="bio-properties-panel-container"></div>');
      var commandStack = injector.get('commandStack', false);
      commandStack && setupKeyboard(this._container, eventBus, commandStack);
      eventBus.on('diagram.init', () => {
        if (parent) {
          this.attachTo(parent);
        }
      });
      eventBus.on('diagram.destroy', () => {
        this.detach();
      });
      eventBus.on('root.added', event => {
        const {
          element
        } = event;

        this._render(element);
      });
    }
    /**
     * Attach the properties panel to a parent node.
     *
     * @param {HTMLElement} container
     */


    attachTo(container) {
      if (!container) {
        throw new Error('container required');
      } // unwrap jQuery if provided


      if (container.get && container.constructor.prototype.jquery) {
        container = container.get(0);
      }

      if (typeof container === 'string') {
        container = query(container);
      } // (1) detach from old parent


      this.detach(); // (2) append to parent container

      container.appendChild(this._container); // (3) notify interested parties

      this._eventBus.fire('propertiesPanel.attach');
    }
    /**
     * Detach the properties panel from its parent node.
     */


    detach() {
      const parentNode = this._container.parentNode;

      if (parentNode) {
        parentNode.removeChild(this._container);

        this._eventBus.fire('propertiesPanel.detach');
      }
    }
    /**
     * Register a new properties provider to the properties panel.
     *
     * @param {Number} [priority]
     * @param {PropertiesProvider} provider
     */


    registerProvider(priority, provider) {
      if (!provider) {
        provider = priority;
        priority = DEFAULT_PRIORITY$1;
      }

      if (typeof provider.getGroups !== 'function') {
        console.error('Properties provider does not implement #getGroups(element) API');
        return;
      }

      this._eventBus.on('propertiesPanel.getProviders', priority, function (event) {
        event.providers.push(provider);
      });

      this._eventBus.fire('propertiesPanel.providersChanged');
    }

    _getProviders() {
      const event = this._eventBus.createEvent({
        type: 'propertiesPanel.getProviders',
        providers: []
      });

      this._eventBus.fire(event);

      return event.providers;
    }

    _render(element) {
      const canvas = this._injector.get('canvas');

      if (!element) {
        element = canvas.getRootElement();
      }

      if (isImplicitRoot(element)) {
        return;
      }

      N$1(o$1(BpmnPropertiesPanel, {
        element: element,
        injector: this._injector,
        getProviders: this._getProviders.bind(this),
        layoutConfig: this._layoutConfig,
        descriptionConfig: this._descriptionConfig
      }), this._container);

      this._eventBus.fire('propertiesPanel.rendered');
    }

    _destroy() {
      if (this._container) {
        N$1(null, this._container);

        this._eventBus.fire('propertiesPanel.destroyed');
      }
    }

  }
  BpmnPropertiesPanelRenderer.$inject = ['config.propertiesPanel', 'injector', 'eventBus']; // helpers ///////////////////////

  function isImplicitRoot(element) {
    // Backwards compatibility for diagram-js<7.4.0, see https://github.com/bpmn-io/bpmn-properties-panel/pull/102
    return element && (element.isImplicit || element.id === '__implicitroot');
  }
  /**
   * Setup keyboard bindings (undo, redo) on the given container.
   *
   * @param {Element} container
   * @param {EventBus} eventBus
   * @param {CommandStack} commandStack
   */


  function setupKeyboard(container, eventBus, commandStack) {
    function cancel(event) {
      event.preventDefault();
      event.stopPropagation();
    }

    function handleKeys(event) {
      if (isUndo(event)) {
        commandStack.undo();
        return cancel(event);
      }

      if (isRedo(event)) {
        commandStack.redo();
        return cancel(event);
      }
    }

    eventBus.on('keyboard.bind', function () {
      event.bind(container, 'keydown', handleKeys);
    });
    eventBus.on('keyboard.unbind', function () {
      event.unbind(container, 'keydown', handleKeys);
    });
  }

  /**
   * A handler that combines and executes multiple commands.
   *
   * All updates are bundled on the command stack and executed in one step.
   * This also makes it possible to revert the changes in one step.
   *
   * Example use case: remove the camunda:formKey attribute and in addition
   * add all form fields needed for the camunda:formData property.
   */

  class MultiCommandHandler {
    constructor(commandStack) {
      this._commandStack = commandStack;
    }

    preExecute(context) {
      const commandStack = this._commandStack;
      forEach(context, function (command) {
        commandStack.execute(command.cmd, command.context);
      });
    }

  }
  MultiCommandHandler.$inject = ['commandStack'];

  const HANDLERS = {
    'properties-panel.multi-command-executor': MultiCommandHandler
  };

  function CommandInitializer(eventBus, commandStack) {
    eventBus.on('diagram.init', function () {
      forEach(HANDLERS, function (handler, id) {
        commandStack.registerHandler(id, handler);
      });
    });
  }

  CommandInitializer.$inject = ['eventBus', 'commandStack'];
  var Commands = {
    __init__: [CommandInitializer]
  };

  var index$3 = {
    __depends__: [Commands, index$4],
    __init__: ['propertiesPanel'],
    propertiesPanel: ['type', BpmnPropertiesPanelRenderer]
  };

  function ReferenceSelectEntry(props) {
    const {
      autoFocusEntry,
      element,
      getOptions
    } = props;
    const options = getOptions(element);
    const prevOptions = usePrevious(options); // auto focus specifc other entry when options changed

    y(() => {
      if (autoFocusEntry && prevOptions && options.length > prevOptions.length) {
        const entry = query(`[data-entry-id="${autoFocusEntry}"]`);
        const focusableInput = query('.bio-properties-panel-input', entry);

        if (focusableInput) {
          focusableInput.select();
        }
      }
    }, [options]);
    return o$1(SelectEntry, { ...props
    });
  }

  function isErrorSupported(element) {
    return isAny(element, ['bpmn:StartEvent', 'bpmn:BoundaryEvent', 'bpmn:EndEvent']) && !!getErrorEventDefinition(element);
  }
  function getErrorEventDefinition(element) {
    return getEventDefinition$1(element, 'bpmn:ErrorEventDefinition');
  }
  function getTimerEventDefinition$1(element) {
    return getEventDefinition$1(element, 'bpmn:TimerEventDefinition');
  }
  function getError(element) {
    const errorEventDefinition = getErrorEventDefinition(element);
    return errorEventDefinition && errorEventDefinition.get('errorRef');
  }
  function getEventDefinition$1(element, eventType) {
    const businessObject = getBusinessObject$1(element);
    const eventDefinitions = businessObject.get('eventDefinitions') || [];
    return find$1(eventDefinitions, function (definition) {
      return is$4(definition, eventType);
    });
  }
  function isMessageSupported(element) {
    return is$4(element, 'bpmn:ReceiveTask') || isAny(element, ['bpmn:StartEvent', 'bpmn:EndEvent', 'bpmn:IntermediateThrowEvent', 'bpmn:BoundaryEvent', 'bpmn:IntermediateCatchEvent']) && !!getMessageEventDefinition(element);
  }
  function getMessageEventDefinition(element) {
    if (is$4(element, 'bpmn:ReceiveTask')) {
      return getBusinessObject$1(element);
    }

    return getEventDefinition$1(element, 'bpmn:MessageEventDefinition');
  }
  function getMessage(element) {
    const messageEventDefinition = getMessageEventDefinition(element);
    return messageEventDefinition && messageEventDefinition.get('messageRef');
  }
  function getLinkEventDefinition(element) {
    return getEventDefinition$1(element, 'bpmn:LinkEventDefinition');
  }
  function getSignalEventDefinition(element) {
    return getEventDefinition$1(element, 'bpmn:SignalEventDefinition');
  }
  function isLinkSupported(element) {
    return isAny(element, ['bpmn:IntermediateThrowEvent', 'bpmn:IntermediateCatchEvent']) && !!getLinkEventDefinition(element);
  }
  function isSignalSupported(element) {
    return is$4(element, 'bpmn:Event') && !!getSignalEventDefinition(element);
  }
  function getSignal(element) {
    const signalEventDefinition = getSignalEventDefinition(element);
    return signalEventDefinition && signalEventDefinition.get('signalRef');
  }
  function getEscalationEventDefinition(element) {
    return getEventDefinition$1(element, 'bpmn:EscalationEventDefinition');
  }
  function isEscalationSupported(element) {
    return is$4(element, 'bpmn:Event') && !!getEscalationEventDefinition(element);
  }
  function getEscalation(element) {
    const escalationEventDefinition = getEscalationEventDefinition(element);
    return escalationEventDefinition && escalationEventDefinition.get('escalationRef');
  }
  function isCompensationSupported(element) {
    return isAny(element, ['bpmn:EndEvent', 'bpmn:IntermediateThrowEvent']) && !!getCompensateEventDefinition(element);
  }
  function getCompensateEventDefinition(element) {
    return getEventDefinition$1(element, 'bpmn:CompensateEventDefinition');
  }
  function getCompensateActivity(element) {
    const compensateEventDefinition = getCompensateEventDefinition(element);
    return compensateEventDefinition && compensateEventDefinition.get('activityRef');
  }

  /**
   * @typedef { import('@bpmn-io/properties-panel').EntryDefinition } Entry
   */

  /**
   * @returns {Array<Entry>} entries
   */

  function CompensationProps(props) {
    const {
      element
    } = props;

    if (!isCompensationSupported(element)) {
      return [];
    }

    return [{
      id: 'waitForCompletion',
      component: WaitForCompletion,
      isEdited: isEdited$7
    }, {
      id: 'activityRef',
      component: ActivityRef,
      isEdited: isEdited$4
    }];
  }

  function WaitForCompletion(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const compensateEventDefinition = getCompensateEventDefinition(element);

    const getValue = () => {
      return compensateEventDefinition.get('waitForCompletion');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: compensateEventDefinition,
        properties: {
          waitForCompletion: value
        }
      });
    };

    return CheckboxEntry({
      element,
      id: 'waitForCompletion',
      label: translate('Wait for completion'),
      getValue,
      setValue
    });
  }

  function ActivityRef(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const elementRegistry = useService('elementRegistry');
    const translate = useService('translate');
    const compensateEventDefinition = getCompensateEventDefinition(element);

    const getValue = () => {
      const activityRef = getCompensateActivity(element);
      return activityRef && activityRef.get('id');
    };

    const setValue = value => {
      // update (or remove) activityRef
      const activityRef = value ? getBusinessObject$1(elementRegistry.get(value)) : undefined;
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: compensateEventDefinition,
        properties: {
          activityRef
        }
      });
    };

    const getOptions = () => {
      let options = [{
        value: '',
        label: translate('<none>')
      }];
      const activities = findActivityRefs(element);
      sortByName$6(activities).forEach(function (activity) {
        options.push({
          value: activity.id,
          label: createOptionLabel(activity)
        });
      });
      return options;
    };

    return ReferenceSelectEntry({
      element,
      id: 'activityRef',
      label: translate('Activity reference'),
      getValue,
      setValue,
      getOptions
    });
  } // helper /////////////////////////


  function getFlowElements(element, type) {
    const {
      flowElements
    } = element;
    return flowElements.filter(function (flowElement) {
      return is$4(flowElement, type);
    });
  }

  function getContainedActivities(element) {
    return getFlowElements(element, 'bpmn:Activity');
  }

  function getContainedBoundaryEvents(element) {
    return getFlowElements(element, 'bpmn:BoundaryEvent');
  }
  /**
   * Checks whether an Activity is attaching a CompensateEvent of the parent container.
   *
   * @param {ModdleElement} activity
   * @param {Array<ModdleElement>} boundaryEvents
   * @returns {Boolean}
   */


  function hasCompensationEventAttached(activity, boundaryEvents) {
    const {
      id: activityId
    } = activity;
    return !!find$1(boundaryEvents, function (boundaryEvent) {
      const {
        attachedToRef
      } = boundaryEvent;
      const compensateEventDefinition = getCompensateEventDefinition(boundaryEvent);
      return attachedToRef && compensateEventDefinition && attachedToRef.id === activityId;
    });
  }
  /**
   * Checks whether an Activity can be compensated. That's the case when it is
   * a) a CallActivity
   * b) a SubProcess, when it is not event based and not a compensation
   * c) any other Activity, when it is attaching a CompensateEvent of the parent container
   *
   * @param {ModdleElement} activity
   * @param {Array<ModdleElement>} boundaryEvents
   * @returns {Boolean}
   */


  function canBeCompensated(activity, boundaryEvents) {
    return is$4(activity, 'bpmn:CallActivity') || is$4(activity, 'bpmn:SubProcess') && !activity.triggeredByEvent && !activity.isForCompensation || hasCompensationEventAttached(activity, boundaryEvents);
  }

  function getActivitiesForCompensation(element) {
    const activities = getContainedActivities(element);
    const boundaryEvents = getContainedBoundaryEvents(element);
    return activities.filter(function (activity) {
      return canBeCompensated(activity, boundaryEvents);
    });
  }
  /**
   * Retrieves all possible activities to reference for a Compensation.
   *
   * @param {djs.model.Base} element
   * @returns {Array<ModdleElement>}
   */


  function findActivityRefs(element) {
    const businessObject = getBusinessObject$1(element);
    let parent = businessObject.$parent; // (1) get all activities in parent container

    let activities = getActivitiesForCompensation(parent); // (2) if throwing compensation event is inside an EventSubProcess,
    // also get all activities outside of the event sub process

    if (is$4(parent, 'bpmn:SubProcess') && parent.triggeredByEvent) {
      parent = parent.$parent;

      if (parent) {
        activities = [...activities, ...getActivitiesForCompensation(parent)];
      }
    }

    return activities;
  }
  /**
   * Retrieves an option label in the form
   * a) with name: "my Task (id=Task_1)"
   * b) without name: "(id=Task_1)"
   *
   * @param {ModdleElement} activity
   * @returns {String}
   */


  function createOptionLabel(activity) {
    const {
      id,
      name
    } = activity;
    return `${name ? name + ' ' : ''}(id=${id})`;
  }

  function sortByName$6(elements) {
    return sortBy(elements, e => (e.name || '').toLowerCase());
  }

  const DOCUMENTATION_TEXT_FORMAT = 'text/plain';
  /**
   * @typedef { import('@bpmn-io/properties-panel').EntryDefinition } Entry
   */

  /**
   * @returns {Array<Entry>} entries
   */

  function DocumentationProps(props) {
    const {
      element
    } = props;
    const entries = [{
      id: 'documentation',
      component: ElementDocumentationProperty,
      isEdited: isEdited$2
    }];

    if (hasProcessRef$2(element)) {
      entries.push({
        id: 'processDocumentation',
        component: ProcessDocumentationProperty,
        isEdited: isEdited$2
      });
    }

    return entries;
  }

  function ElementDocumentationProperty(props) {
    const {
      element
    } = props;
    const bpmnFactory = useService('bpmnFactory');
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const getValue = getDocumentation(getBusinessObject$1(element));
    const setValue = setDocumentation(element, getBusinessObject$1(element), bpmnFactory, commandStack);
    return TextAreaEntry({
      element,
      id: 'documentation',
      label: translate('Element documentation'),
      getValue,
      setValue,
      debounce
    });
  }

  function ProcessDocumentationProperty(props) {
    const {
      element
    } = props;
    const bpmnFactory = useService('bpmnFactory');
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const processRef = getBusinessObject$1(element).processRef;
    const getValue = getDocumentation(processRef);
    const setValue = setDocumentation(element, processRef, bpmnFactory, commandStack);
    return TextAreaEntry({
      element,
      id: 'processDocumentation',
      label: translate('Process documentation'),
      getValue,
      setValue,
      debounce
    });
  } // helper ////////////////////////////


  function hasProcessRef$2(element) {
    return is$4(element, 'bpmn:Participant') && element.businessObject.get('processRef');
  }

  function findDocumentation(docs) {
    return docs.find(function (d) {
      return (d.textFormat || DOCUMENTATION_TEXT_FORMAT) === DOCUMENTATION_TEXT_FORMAT;
    });
  }
  /**
   * Retrieves a documentation element from a given moddle element.
   *
   * @param {ModdleElement} businessObject
   *
   * @returns {ModdleElement} documentation element inside the given moddle element.
   */


  function getDocumentation(businessObject) {
    return function () {
      const documentation = findDocumentation(businessObject && businessObject.get('documentation'));
      return documentation && documentation.text;
    };
  }
  /**
   * Sets a documentation element for a given moddle element.
   *
   * @param {ModdleElement} businessObject
   */


  function setDocumentation(element, businessObject, bpmnFactory, commandStack) {
    return function (value) {
      let documentation = findDocumentation(businessObject && businessObject.get('documentation')); // (1) update or removing existing documentation

      if (documentation) {
        if (value) {
          return commandStack.execute('element.updateModdleProperties', {
            element,
            moddleElement: documentation,
            properties: {
              text: value
            }
          });
        } else {
          return commandStack.execute('element.updateModdleProperties', {
            element,
            moddleElement: businessObject,
            properties: {
              documentation: without(businessObject.get('documentation'), documentation)
            }
          });
        }
      } // (2) create new documentation entry


      if (value) {
        documentation = bpmnFactory.create('bpmn:Documentation', {
          text: value
        });
        return commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: businessObject,
          properties: {
            documentation: [...businessObject.get('documentation'), documentation]
          }
        });
      }
    };
  }

  function createCommonjsModule(fn, module) {
    return module = {
      exports: {}
    }, fn(module, module.exports), module.exports;
  }

  var hat_1 = createCommonjsModule(function (module) {
    var hat = module.exports = function (bits, base) {
      if (!base) base = 16;
      if (bits === undefined) bits = 128;
      if (bits <= 0) return '0';
      var digits = Math.log(Math.pow(2, bits)) / Math.log(base);

      for (var i = 2; digits === Infinity; i *= 2) {
        digits = Math.log(Math.pow(2, bits / i)) / Math.log(base) * i;
      }

      var rem = digits - Math.floor(digits);
      var res = '';

      for (var i = 0; i < Math.floor(digits); i++) {
        var x = Math.floor(Math.random() * base).toString(base);
        res = x + res;
      }

      if (rem) {
        var b = Math.pow(base, rem);
        var x = Math.floor(Math.random() * b).toString(base);
        res = x + res;
      }

      var parsed = parseInt(res, base);

      if (parsed !== Infinity && parsed >= Math.pow(2, bits)) {
        return hat(bits, base);
      } else return res;
    };

    hat.rack = function (bits, base, expandBy) {
      var fn = function (data) {
        var iters = 0;

        do {
          if (iters++ > 10) {
            if (expandBy) bits += expandBy;else throw new Error('too many ID collisions, use more bits');
          }

          var id = hat(bits, base);
        } while (Object.hasOwnProperty.call(hats, id));

        hats[id] = data;
        return id;
      };

      var hats = fn.hats = {};

      fn.get = function (id) {
        return fn.hats[id];
      };

      fn.set = function (id, value) {
        fn.hats[id] = value;
        return fn;
      };

      fn.bits = bits || 128;
      fn.base = base || 16;
      return fn;
    };
  });
  /**
   * Create a new id generator / cache instance.
   *
   * You may optionally provide a seed that is used internally.
   *
   * @param {Seed} seed
   */

  function Ids(seed) {
    if (!(this instanceof Ids)) {
      return new Ids(seed);
    }

    seed = seed || [128, 36, 1];
    this._seed = seed.length ? hat_1.rack(seed[0], seed[1], seed[2]) : seed;
  }
  /**
   * Generate a next id.
   *
   * @param {Object} [element] element to bind the id to
   *
   * @return {String} id
   */


  Ids.prototype.next = function (element) {
    return this._seed(element || true);
  };
  /**
   * Generate a next id with a given prefix.
   *
   * @param {Object} [element] element to bind the id to
   *
   * @return {String} id
   */


  Ids.prototype.nextPrefixed = function (prefix, element) {
    var id;

    do {
      id = prefix + this.next(true);
    } while (this.assigned(id)); // claim {prefix}{random}


    this.claim(id, element); // return

    return id;
  };
  /**
   * Manually claim an existing id.
   *
   * @param {String} id
   * @param {String} [element] element the id is claimed by
   */


  Ids.prototype.claim = function (id, element) {
    this._seed.set(id, element || true);
  };
  /**
   * Returns true if the given id has already been assigned.
   *
   * @param  {String} id
   * @return {Boolean}
   */


  Ids.prototype.assigned = function (id) {
    return this._seed.get(id) || false;
  };
  /**
   * Unclaim an id.
   *
   * @param  {String} id the id to unclaim
   */


  Ids.prototype.unclaim = function (id) {
    delete this._seed.hats[id];
  };
  /**
   * Clear all claimed ids.
   */


  Ids.prototype.clear = function () {
    var hats = this._seed.hats,
        id;

    for (id in hats) {
      this.unclaim(id);
    }
  };

  /**
   * Create a new element and set its parent.
   *
   * @param {String} elementType of the new element
   * @param {Object} properties of the new element in key-value pairs
   * @param {moddle.object} parent of the new element
   * @param {BpmnFactory} factory which creates the new element
   *
   * @returns {djs.model.Base} element which is created
   */

  function createElement(elementType, properties, parent, factory) {
    const element = factory.create(elementType, properties);

    if (parent) {
      element.$parent = parent;
    }

    return element;
  }
  /**
   * generate a semantic id with given prefix
   */

  function nextId(prefix) {
    const ids = new Ids([32, 32, 1]);
    return ids.nextPrefixed(prefix);
  }
  function getRoot(businessObject) {
    let parent = businessObject;

    while (parent.$parent) {
      parent = parent.$parent;
    }

    return parent;
  }
  function filterElementsByType(objectList, type) {
    const list = objectList || [];
    return list.filter(element => is$4(element, type));
  }
  function findRootElementsByType(businessObject, referencedType) {
    const root = getRoot(businessObject);
    return filterElementsByType(root.get('rootElements'), referencedType);
  }
  function findRootElementById(businessObject, type, id) {
    const elements = findRootElementsByType(businessObject, type);
    return elements.find(element => element.id === id);
  }

  const EMPTY_OPTION$4 = '';
  const CREATE_NEW_OPTION$4 = 'create-new';
  /**
   * @typedef { import('@bpmn-io/properties-panel').EntryDefinition } Entry
   */

  /**
   * @returns {Array<Entry>} entries
   */

  function ErrorProps$1(props) {
    const {
      element
    } = props;

    if (!isErrorSupported(element)) {
      return [];
    }

    const error = getError(element);
    let entries = [{
      id: 'errorRef',
      component: ErrorRef$1,
      isEdited: isEdited$4
    }];

    if (error) {
      entries = [...entries, {
        id: 'errorName',
        component: ErrorName$1,
        isEdited: isEdited$1
      }, {
        id: 'errorCode',
        component: ErrorCode$1,
        isEdited: isEdited$1
      }];
    }

    return entries;
  }

  function ErrorRef$1(props) {
    const {
      element
    } = props;
    const bpmnFactory = useService('bpmnFactory');
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const errorEventDefinition = getErrorEventDefinition(element);

    const getValue = () => {
      const error = getError(element);

      if (error) {
        return error.get('id');
      }

      return EMPTY_OPTION$4;
    };

    const setValue = value => {
      const root = getRoot(errorEventDefinition);
      const commands = [];
      let error; // (1) create new error

      if (value === CREATE_NEW_OPTION$4) {
        error = createElement('bpmn:Error', {
          name: nextId('Error_')
        }, root, bpmnFactory);
        value = error.get('id');
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: root,
            properties: {
              rootElements: [...root.get('rootElements'), error]
            }
          }
        });
      } // (2) update (or remove) errorRef


      error = error || findRootElementById(errorEventDefinition, 'bpmn:Error', value);
      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: errorEventDefinition,
          properties: {
            errorRef: error
          }
        }
      }); // (3) commit all updates

      return commandStack.execute('properties-panel.multi-command-executor', commands);
    };

    const getOptions = () => {
      let options = [{
        value: EMPTY_OPTION$4,
        label: translate('<none>')
      }, {
        value: CREATE_NEW_OPTION$4,
        label: translate('Create new ...')
      }];
      const errors = findRootElementsByType(getBusinessObject$1(element), 'bpmn:Error');
      sortByName$5(errors).forEach(error => {
        options.push({
          value: error.get('id'),
          label: error.get('name')
        });
      });
      return options;
    };

    return ReferenceSelectEntry({
      element,
      id: 'errorRef',
      label: translate('Global error reference'),
      autoFocusEntry: 'errorName',
      getValue,
      setValue,
      getOptions
    });
  }

  function ErrorName$1(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const error = getError(element);

    const getValue = () => {
      return error.get('name');
    };

    const setValue = value => {
      return commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: error,
        properties: {
          name: value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'errorName',
      label: translate('Name'),
      getValue,
      setValue,
      debounce
    });
  }

  function ErrorCode$1(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const error = getError(element);

    const getValue = () => {
      return error.get('errorCode');
    };

    const setValue = value => {
      return commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: error,
        properties: {
          errorCode: value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'errorCode',
      label: translate('Code'),
      getValue,
      setValue,
      debounce
    });
  } // helper /////////////////////////


  function sortByName$5(elements) {
    return sortBy(elements, e => (e.name || '').toLowerCase());
  }

  const CREATE_NEW_OPTION$3 = 'create-new';
  /**
   * @typedef { import('@bpmn-io/properties-panel').EntryDefinition } Entry
   */

  /**
   * @returns {Array<Entry>} entries
   */

  function EscalationProps$1(props) {
    const {
      element
    } = props;

    if (!isEscalationSupported(element)) {
      return [];
    }

    const escalation = getEscalation(element);
    let entries = [{
      id: 'escalationRef',
      component: EscalationRef,
      isEdited: isEdited$4
    }];

    if (escalation) {
      entries = [...entries, {
        id: 'escalationName',
        component: EscalationName,
        isEdited: isEdited$1
      }, {
        id: 'escalationCode',
        component: EscalationCode,
        isEdited: isEdited$1
      }];
    }

    return entries;
  }

  function EscalationRef(props) {
    const {
      element
    } = props;
    const bpmnFactory = useService('bpmnFactory');
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const escalationEventDefinition = getEscalationEventDefinition(element);

    const getValue = () => {
      const escalation = getEscalation(element);
      return escalation && escalation.get('id');
    };

    const setValue = value => {
      const root = getRoot(escalationEventDefinition);
      const commands = [];
      let escalation; // (1) create new escalation

      if (value === CREATE_NEW_OPTION$3) {
        const id = nextId('Escalation_');
        escalation = createElement('bpmn:Escalation', {
          id,
          name: id
        }, root, bpmnFactory);
        value = escalation.get('id');
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: root,
            properties: {
              rootElements: [...root.get('rootElements'), escalation]
            }
          }
        });
      } // (2) update (or remove) escalationRef


      escalation = escalation || findRootElementById(escalationEventDefinition, 'bpmn:Escalation', value);
      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: escalationEventDefinition,
          properties: {
            escalationRef: escalation
          }
        }
      }); // (3) commit all updates

      return commandStack.execute('properties-panel.multi-command-executor', commands);
    };

    const getOptions = () => {
      let options = [{
        value: '',
        label: translate('<none>')
      }, {
        value: CREATE_NEW_OPTION$3,
        label: translate('Create new ...')
      }];
      const escalations = findRootElementsByType(getBusinessObject$1(element), 'bpmn:Escalation');
      sortByName$4(escalations).forEach(escalation => {
        options.push({
          value: escalation.get('id'),
          label: escalation.get('name')
        });
      });
      return options;
    };

    return ReferenceSelectEntry({
      element,
      id: 'escalationRef',
      label: translate('Global escalation reference'),
      autoFocusEntry: 'escalationName',
      getValue,
      setValue,
      getOptions
    });
  }

  function EscalationName(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const escalation = getEscalation(element);

    const getValue = () => {
      return escalation.get('name');
    };

    const setValue = value => {
      return commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: escalation,
        properties: {
          name: value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'escalationName',
      label: translate('Name'),
      getValue,
      setValue,
      debounce
    });
  }

  function EscalationCode(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const escalation = getEscalation(element);

    const getValue = () => {
      return escalation.get('escalationCode');
    };

    const setValue = value => {
      return commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: escalation,
        properties: {
          escalationCode: value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'escalationCode',
      label: translate('Code'),
      getValue,
      setValue,
      debounce
    });
  } // helper /////////////////////////


  function sortByName$4(elements) {
    return sortBy(elements, e => (e.name || '').toLowerCase());
  }

  /**
   * @typedef { import('@bpmn-io/properties-panel').EntryDefinition } Entry
   */

  /**
   * @returns {Array<Entry>} entries
   */

  function ExecutableProps(props) {
    const {
      element
    } = props;

    if (!is$4(element, 'bpmn:Process') && !hasProcessRef$1(element)) {
      return [];
    }

    return [{
      id: 'isExecutable',
      component: Executable,
      isEdited: isEdited$7
    }];
  }

  function Executable(props) {
    const {
      element
    } = props;
    const modeling = useService('modeling');
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    let getValue, setValue;

    setValue = value => {
      modeling.updateProperties(element, {
        isExecutable: value
      });
    };

    getValue = element => {
      return element.businessObject.isExecutable;
    }; // handle properties on processRef level for participants


    if (is$4(element, 'bpmn:Participant')) {
      const process = element.businessObject.get('processRef');

      setValue = value => {
        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: process,
          properties: {
            isExecutable: value
          }
        });
      };

      getValue = () => {
        return process.get('isExecutable');
      };
    }

    return CheckboxEntry({
      element,
      id: 'isExecutable',
      label: translate('Executable'),
      getValue,
      setValue
    });
  } // helper /////////////////////


  function hasProcessRef$1(element) {
    return is$4(element, 'bpmn:Participant') && element.businessObject.get('processRef');
  }

  const SPACE_REGEX = /\s/; // for QName validation as per http://www.w3.org/TR/REC-xml/#NT-NameChar

  const QNAME_REGEX = /^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i; // for ID validation as per BPMN Schema (QName - Namespace)

  const ID_REGEX = /^[a-z_][\w-.]*$/i;
  /**
   * checks whether the id value is valid
   *
   * @param {ModdleElement} element
   * @param {String} idValue
   * @param {Function} translate
   *
   * @return {String} error message
   */

  function isIdValid(element, idValue, translate) {
    const assigned = element.$model.ids.assigned(idValue);
    const idAlreadyExists = assigned && assigned !== element;

    if (!idValue) {
      return translate('ID must not be empty.');
    }

    if (idAlreadyExists) {
      return translate('ID must be unique.');
    }

    return validateId(idValue, translate);
  }
  function validateId(idValue, translate) {
    if (containsSpace(idValue)) {
      return translate('ID must not contain spaces.');
    }

    if (!ID_REGEX.test(idValue)) {
      if (QNAME_REGEX.test(idValue)) {
        return translate('ID must not contain prefix.');
      }

      return translate('ID must be a valid QName.');
    }
  }
  function containsSpace(value) {
    return SPACE_REGEX.test(value);
  }

  /**
   * @typedef { import('@bpmn-io/properties-panel').EntryDefinition } Entry
   */

  /**
   * @returns {Array<Entry>} entries
   */

  function IdProps() {
    return [{
      id: 'id',
      component: Id$3,
      isEdited: isEdited$1
    }];
  }

  function Id$3(props) {
    const {
      element
    } = props;
    const modeling = useService('modeling');
    const debounce = useService('debounceInput');
    const translate = useService('translate');

    const setValue = value => {
      modeling.updateProperties(element, {
        id: value
      });
    };

    const getValue = element => {
      return element.businessObject.id;
    };

    const validate = value => {
      const businessObject = getBusinessObject$1(element);
      return isIdValid(businessObject, value, translate);
    };

    return TextfieldEntry({
      element,
      id: 'id',
      label: translate(is$4(element, 'bpmn:Participant') ? 'Participant ID' : 'ID'),
      getValue,
      setValue,
      debounce,
      validate
    });
  }

  /**
   * @typedef { import('@bpmn-io/properties-panel').EntryDefinition } Entry
   */

  /**
   * @returns {Array<Entry>} entries
   */

  function LinkProps(props) {
    const {
      element
    } = props;

    if (!isLinkSupported(element)) {
      return [];
    }

    return [{
      id: 'linkName',
      component: LinkName,
      isEdited: isEdited$1
    }];
  }

  function LinkName(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const linkEventDefinition = getLinkEventDefinition(element);

    const getValue = () => {
      return linkEventDefinition.get('name');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: linkEventDefinition,
        properties: {
          name: value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'linkName',
      label: translate('Name'),
      getValue,
      setValue,
      debounce
    });
  }

  const EMPTY_OPTION$3 = '';
  const CREATE_NEW_OPTION$2 = 'create-new';
  /**
   * @typedef { import('@bpmn-io/properties-panel').EntryDefinition } Entry
   */

  /**
   * @returns {Array<Entry>} entries
   */

  function MessageProps$1(props) {
    const {
      element
    } = props;

    if (!isMessageSupported(element)) {
      return [];
    }

    const message = getMessage(element);
    let entries = [{
      id: 'messageRef',
      component: MessageRef,
      isEdited: isEdited$4
    }];

    if (message) {
      entries = [...entries, {
        id: 'messageName',
        component: MessageName$1,
        isEdited: isEdited$1
      }];
    }

    return entries;
  }

  function MessageRef(props) {
    const {
      element
    } = props;
    const bpmnFactory = useService('bpmnFactory');
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const messageEventDefinition = getMessageEventDefinition(element);

    const getValue = () => {
      const message = getMessage(element);

      if (message) {
        return message.get('id');
      }

      return EMPTY_OPTION$3;
    };

    const setValue = value => {
      const root = getRoot(messageEventDefinition);
      const commands = [];
      let message; // (1) create new message

      if (value === CREATE_NEW_OPTION$2) {
        const id = nextId('Message_');
        message = createElement('bpmn:Message', {
          id,
          name: id
        }, root, bpmnFactory);
        value = message.get('id');
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: root,
            properties: {
              rootElements: [...root.get('rootElements'), message]
            }
          }
        });
      } // (2) update (or remove) messageRef


      message = message || findRootElementById(messageEventDefinition, 'bpmn:Message', value);
      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: messageEventDefinition,
          properties: {
            messageRef: message
          }
        }
      }); // (3) commit all updates

      return commandStack.execute('properties-panel.multi-command-executor', commands);
    };

    const getOptions = () => {
      let options = [{
        value: EMPTY_OPTION$3,
        label: translate('<none>')
      }, {
        value: CREATE_NEW_OPTION$2,
        label: translate('Create new ...')
      }];
      const messages = findRootElementsByType(getBusinessObject$1(element), 'bpmn:Message');
      sortByName$3(messages).forEach(message => {
        options.push({
          value: message.get('id'),
          label: message.get('name')
        });
      });
      return options;
    };

    return ReferenceSelectEntry({
      element,
      id: 'messageRef',
      label: translate('Global message reference'),
      autoFocusEntry: 'messageName',
      getValue,
      setValue,
      getOptions
    });
  }

  function MessageName$1(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const message = getMessage(element);

    const getValue = () => {
      return message.get('name');
    };

    const setValue = value => {
      return commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: message,
        properties: {
          name: value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'messageName',
      label: translate('Name'),
      getValue,
      setValue,
      debounce
    });
  } // helper /////////////////////////


  function sortByName$3(elements) {
    return sortBy(elements, e => (e.name || '').toLowerCase());
  }

  /**
   * @typedef { import('@bpmn-io/properties-panel').EntryDefinition } Entry
   */

  /**
   * @returns {Array<Entry>} entries
   */

  function MultiInstanceProps$2(props) {
    const {
      element
    } = props;

    if (!isMultiInstanceSupported$1(element)) {
      return [];
    }

    const entries = [{
      id: 'loopCardinality',
      component: LoopCardinality,
      isEdited: isEdited$1
    }, {
      id: 'completionCondition',
      component: CompletionCondition$1,
      isEdited: isEdited$1
    }];
    return entries;
  }

  function LoopCardinality(props) {
    const {
      element
    } = props;
    const bpmnFactory = useService('bpmnFactory');
    const debounce = useService('debounceInput');
    const commandStack = useService('commandStack');
    const translate = useService('translate');

    const getValue = () => {
      return getLoopCardinalityValue(element);
    };

    const setValue = value => {
      return commandStack.execute('element.updateModdleProperties', updateFormalExpression(element, 'loopCardinality', value, bpmnFactory));
    };

    return TextfieldEntry({
      element,
      id: 'loopCardinality',
      label: translate('Loop cardinality'),
      getValue,
      setValue,
      debounce
    });
  }

  function CompletionCondition$1(props) {
    const {
      element
    } = props;
    const bpmnFactory = useService('bpmnFactory');
    const debounce = useService('debounceInput');
    const commandStack = useService('commandStack');
    const translate = useService('translate');

    const getValue = () => {
      return getCompletionConditionValue(element);
    };

    const setValue = value => {
      return commandStack.execute('element.updateModdleProperties', updateFormalExpression(element, 'completionCondition', value, bpmnFactory));
    };

    return TextfieldEntry({
      element,
      id: 'completionCondition',
      label: translate('Completion condition'),
      getValue,
      setValue,
      debounce
    });
  } // helper ////////////////////////////
  // generic ///////////////////////////

  /**
   * isMultiInstanceSupported - check whether given element supports MultiInstanceLoopCharacteristics.
   *
   * @param {djs.model.Base} element
   * @return {boolean}
   */


  function isMultiInstanceSupported$1(element) {
    const loopCharacteristics = getLoopCharacteristics$2(element);
    return !!loopCharacteristics && is$4(loopCharacteristics, 'bpmn:MultiInstanceLoopCharacteristics');
  }
  /**
   * getBody - get the body of a given expression.
   *
   * @param {ModdleElement<bpmn:FormalExpression>} expression
   * @return {string} the body (value) of the expression
   */


  function getBody(expression) {
    return expression && expression.get('body');
  }
  /**
   * getProperty - get a property value of the loop characteristics.
   *
   * @param {djs.model.Base} element
   * @param {string} propertyName
   *
   * @return {any} the property value
   */


  function getProperty$2(element, propertyName) {
    const loopCharacteristics = getLoopCharacteristics$2(element);
    return loopCharacteristics && loopCharacteristics.get(propertyName);
  }
  /**
   * getLoopCharacteristics - get loopCharacteristics of a given element.
   *
   * @param {djs.model.Base} element
   * @return {ModdleElement<bpmn:MultiInstanceLoopCharacteristics> | undefined}
   */


  function getLoopCharacteristics$2(element) {
    const bo = getBusinessObject$1(element);
    return bo.loopCharacteristics;
  }
  /**
   * createFormalExpression - creates a 'bpmn:FormalExpression' element.
   *
   * @param {ModdleElement} parent
   * @param {string} body
   * @param {BpmnFactory} bpmnFactory
   *
   * @result {ModdleElement<bpmn:FormalExpression>} a formal expression
   */


  function createFormalExpression$1(parent, body, bpmnFactory) {
    return createElement('bpmn:FormalExpression', {
      body: body
    }, parent, bpmnFactory);
  }
  /**
   * updateFormalExpression - updates a specific formal expression of the loop characteristics.
   *
   * @param {djs.model.Base} element
   * @param {string} propertyName
   * @param {string} newValue
   * @param {BpmnFactory} bpmnFactory
   */


  function updateFormalExpression(element, propertyName, newValue, bpmnFactory) {
    const loopCharacteristics = getLoopCharacteristics$2(element);
    const expressionProps = {};

    if (!newValue) {
      // remove formal expression
      expressionProps[propertyName] = undefined;
      return {
        element,
        moddleElement: loopCharacteristics,
        properties: expressionProps
      };
    }

    const existingExpression = loopCharacteristics.get(propertyName);

    if (!existingExpression) {
      // add formal expression
      expressionProps[propertyName] = createFormalExpression$1(loopCharacteristics, newValue, bpmnFactory);
      return {
        element,
        moddleElement: loopCharacteristics,
        properties: expressionProps
      };
    } // edit existing formal expression


    return {
      element,
      moddleElement: existingExpression,
      properties: {
        body: newValue
      }
    };
  } // loopCardinality

  /**
   * getLoopCardinality - get the loop cardinality of the loop characteristics.
   *
   * @param {djs.model.Base} element
   *
   * @return {ModdleElement<bpmn:FormalExpression>} an expression representing the loop cardinality
   */


  function getLoopCardinality(element) {
    return getProperty$2(element, 'loopCardinality');
  }
  /**
   * getLoopCardinalityValue - get the loop cardinality value of the loop characteristics.
   *
   * @param {djs.model.Base} element
   *
   * @return {string} the loop cardinality value
   */


  function getLoopCardinalityValue(element) {
    const loopCardinality = getLoopCardinality(element);
    return getBody(loopCardinality);
  } // completionCondition /////////////////////

  /**
   * getCompletionCondition - get the completion condition of the loop characteristics.
   *
   * @param {djs.model.Base} element
   *
   * @return {ModdleElement<bpmn:FormalExpression>} an expression representing the completion condition
   */


  function getCompletionCondition$1(element) {
    return getProperty$2(element, 'completionCondition');
  }
  /**
   * getCompletionConditionValue - get the completion condition value of the loop characteristics.
   *
   * @param {djs.model.Base} element
   *
   * @return {string} the completion condition value
   */


  function getCompletionConditionValue(element) {
    const completionCondition = getCompletionCondition$1(element);
    return getBody(completionCondition);
  }

  /**
   * Failsafe remove an element from a collection
   *
   * @param  {Array<Object>} [collection]
   * @param  {Object} [element]
   *
   * @return {number} the previous index of the element
   */
  /**
   * Fail save add an element to the given connection, ensuring
   * it does not yet exist.
   *
   * @param {Array<Object>} collection
   * @param {Object} element
   * @param {number} idx
   */

  function add$2(collection, element, idx) {
    if (!collection || !element) {
      return;
    }

    if (typeof idx !== 'number') {
      idx = -1;
    }

    var currentIdx = collection.indexOf(element);

    if (currentIdx !== -1) {
      if (currentIdx === idx) {
        // nothing to do, position has not changed
        return;
      } else {
        if (idx !== -1) {
          // remove from current position
          collection.splice(currentIdx, 1);
        } else {
          // already exists in collection
          return;
        }
      }
    }

    if (idx !== -1) {
      // insert at specified position
      collection.splice(idx, 0, element);
    } else {
      // push to end
      collection.push(element);
    }
  }

  /**
   * @typedef { import('@bpmn-io/properties-panel').EntryDefinition } Entry
   */

  /**
   * @returns {Array<Entry>} entries
   */

  function NameProps(props) {
    const {
      element
    } = props;

    if (isAny(element, ['bpmn:Collaboration', 'bpmn:DataAssociation', 'bpmn:Association'])) {
      return [];
    }

    return [{
      id: 'name',
      component: Name$3,
      isEdited: isEdited$1
    }];
  }

  function Name$3(props) {
    const {
      element
    } = props;
    const modeling = useService('modeling');
    const debounce = useService('debounceInput');
    const canvas = useService('canvas');
    const bpmnFactory = useService('bpmnFactory');
    const translate = useService('translate'); // (1) default: name

    let options = {
      element,
      id: 'name',
      label: translate('Name'),
      debounce,
      setValue: value => {
        modeling.updateProperties(element, {
          name: value
        });
      },
      getValue: element => {
        return element.businessObject.name;
      }
    }; // (2) text annotations

    if (is$4(element, 'bpmn:TextAnnotation')) {
      options = { ...options,
        setValue: value => {
          modeling.updateProperties(element, {
            text: value
          });
        },
        getValue: element => {
          return element.businessObject.text;
        }
      };
    } // (3) groups
    else if (is$4(element, 'bpmn:Group')) {
      options = { ...options,
        setValue: value => {
          const businessObject = getBusinessObject$1(element),
                categoryValueRef = businessObject.categoryValueRef;

          if (!categoryValueRef) {
            initializeCategory(businessObject, canvas.getRootElement(), bpmnFactory);
          }

          modeling.updateLabel(element, value);
        },
        getValue: element => {
          const businessObject = getBusinessObject$1(element),
                categoryValueRef = businessObject.categoryValueRef;
          return categoryValueRef && categoryValueRef.value;
        }
      };
    } // (4) participants (only update label)
    else if (is$4(element, 'bpmn:Participant')) {
      options.label = translate('Participant Name');
    }

    return TextfieldEntry(options);
  } // helpers ////////////////////////


  function initializeCategory(businessObject, rootElement, bpmnFactory) {
    const definitions = getBusinessObject$1(rootElement).$parent;
    const categoryValue = createCategoryValue(definitions, bpmnFactory);
    businessObject.categoryValueRef = categoryValue;
  }

  function createCategoryValue(definitions, bpmnFactory) {
    const categoryValue = bpmnFactory.create('bpmn:CategoryValue');
    const category = bpmnFactory.create('bpmn:Category', {
      categoryValue: [categoryValue]
    }); // add to correct place

    add$2(definitions.get('rootElements'), category);
    getBusinessObject$1(category).$parent = definitions;
    getBusinessObject$1(categoryValue).$parent = category;
    return categoryValue;
  }

  /**
   * @typedef { import('@bpmn-io/properties-panel').EntryDefinition } Entry
   */

  /**
   * @returns {Array<Entry>} entries
   */

  function ProcessProps(props) {
    const {
      element
    } = props;

    if (!hasProcessRef(element)) {
      return [];
    }

    return [{
      id: 'processId',
      component: ProcessId,
      isEdited: isEdited$1
    }, {
      id: 'processName',
      component: ProcessName,
      isEdited: isEdited$1
    }];
  }

  function ProcessName(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const process = element.businessObject.get('processRef');

    const getValue = () => {
      return process.get('name');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: process,
        properties: {
          name: value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'processName',
      label: translate('Process name'),
      getValue,
      setValue,
      debounce
    });
  }

  function ProcessId(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const process = element.businessObject.get('processRef');

    const getValue = () => {
      return process.get('id');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: process,
        properties: {
          id: value
        }
      });
    };

    const validate = value => {
      return isIdValid(process, value, translate);
    };

    return TextfieldEntry({
      element,
      id: 'processId',
      label: translate('Process ID'),
      getValue,
      setValue,
      debounce,
      validate
    });
  } // helper ////////////////


  function hasProcessRef(element) {
    return is$4(element, 'bpmn:Participant') && element.businessObject.get('processRef');
  }

  const EMPTY_OPTION$2 = '';
  const CREATE_NEW_OPTION$1 = 'create-new';
  /**
   * @typedef { import('@bpmn-io/properties-panel').EntryDefinition } Entry
   */

  /**
   * @returns {Array<Entry>} entries
   */

  function SignalProps(props) {
    const {
      element
    } = props;

    if (!isSignalSupported(element)) {
      return [];
    }

    const signal = getSignal(element);
    let entries = [{
      id: 'signalRef',
      component: SignalRef,
      isEdited: isEdited$4
    }];

    if (signal) {
      entries = [...entries, {
        id: 'signalName',
        component: SignalName,
        isEdited: isEdited$1
      }];
    }

    return entries;
  }

  function SignalRef(props) {
    const {
      element
    } = props;
    const bpmnFactory = useService('bpmnFactory');
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const signalEventDefinition = getSignalEventDefinition(element);

    const getValue = () => {
      const signal = getSignal(element);

      if (signal) {
        return signal.get('id');
      }

      return EMPTY_OPTION$2;
    };

    const setValue = value => {
      const root = getRoot(signalEventDefinition);
      const commands = [];
      let signal; // (1) create new signal

      if (value === CREATE_NEW_OPTION$1) {
        const id = nextId('Signal_');
        signal = createElement('bpmn:Signal', {
          id,
          name: id
        }, root, bpmnFactory);
        value = signal.get('id');
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: root,
            properties: {
              rootElements: [...root.get('rootElements'), signal]
            }
          }
        });
      } // (2) update (or remove) signalRef


      signal = signal || findRootElementById(signalEventDefinition, 'bpmn:Signal', value);
      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: signalEventDefinition,
          properties: {
            signalRef: signal
          }
        }
      }); // (3) commit all updates

      return commandStack.execute('properties-panel.multi-command-executor', commands);
    };

    const getOptions = () => {
      let options = [{
        value: EMPTY_OPTION$2,
        label: translate('<none>')
      }, {
        value: CREATE_NEW_OPTION$1,
        label: translate('Create new ...')
      }];
      const signals = findRootElementsByType(getBusinessObject$1(element), 'bpmn:Signal');
      sortByName$2(signals).forEach(signal => {
        options.push({
          value: signal.get('id'),
          label: signal.get('name')
        });
      });
      return options;
    };

    return ReferenceSelectEntry({
      element,
      id: 'signalRef',
      label: translate('Global signal reference'),
      autoFocusEntry: 'signalName',
      getValue,
      setValue,
      getOptions
    });
  }

  function SignalName(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const signal = getSignal(element);

    const getValue = () => {
      return signal.get('name');
    };

    const setValue = value => {
      return commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: signal,
        properties: {
          name: value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'signalName',
      label: translate('Name'),
      getValue,
      setValue,
      debounce
    });
  } // helper /////////////////////////


  function sortByName$2(elements) {
    return sortBy(elements, e => (e.name || '').toLowerCase());
  }

  function isTimerSupported(element) {
    return isAny(element, ['bpmn:StartEvent', 'bpmn:IntermediateCatchEvent', 'bpmn:BoundaryEvent']) && !!getTimerEventDefinition(element);
  }
  /**
   * Get the timer definition type for a given timer event definition.
   *
   * @param {ModdleElement<bpmn:TimerEventDefinition>} timer
   *
   * @return {string|undefined} the timer definition type
   */

  function getTimerDefinitionType(timer) {
    if (!timer) {
      return;
    }

    const timeDate = timer.get('timeDate');

    if (typeof timeDate !== 'undefined') {
      return 'timeDate';
    }

    const timeCycle = timer.get('timeCycle');

    if (typeof timeCycle !== 'undefined') {
      return 'timeCycle';
    }

    const timeDuration = timer.get('timeDuration');

    if (typeof timeDuration !== 'undefined') {
      return 'timeDuration';
    }
  }
  function getTimerEventDefinition(element) {
    return getEventDefinition(element, 'bpmn:TimerEventDefinition');
  }
  function getEventDefinition(element, eventType) {
    const businessObject = getBusinessObject$1(element);
    const eventDefinitions = businessObject.get('eventDefinitions') || [];
    return find$1(eventDefinitions, function (definition) {
      return is$4(definition, eventType);
    });
  }

  function TimerProps$2(props) {
    const {
      element,
      listener,
      idPrefix
    } = props;
    let {
      timerEventDefinition
    } = props;

    if (!timerEventDefinition) {
      const businessObject = getBusinessObject$1(element);
      timerEventDefinition = getTimerEventDefinition(businessObject);
    }

    const timerEventDefinitionType = getTimerDefinitionType(timerEventDefinition); // (1) Only show for supported elements

    if (!isTimerSupported(element) && !isTimerSupportedOnListener$1(listener)) {
      return [];
    } // (2) Provide entries, have a value only if selection was made


    const entries = [];
    entries.push({
      id: getId$1(idPrefix, 'timerEventDefinitionType'),
      component: TimerEventDefinitionType$2,
      isEdited: isEdited$4,
      timerEventDefinition,
      timerEventDefinitionType
    });

    if (timerEventDefinitionType) {
      entries.push({
        id: getId$1(idPrefix, 'timerEventDefinitionValue'),
        component: TimerEventDefinitionValue$2,
        isEdited: isEdited$1,
        timerEventDefinition,
        timerEventDefinitionType
      });
    }

    return entries;
  }
  /**
   * TimerEventDefinitionType - Generic select entry allowing to select a specific
   * timerEventDefintionType. To be used together with timerEventDefinitionValue.
   *
   * @param  {type} props
   * @return {SelectEntry}
   */

  function TimerEventDefinitionType$2(props) {
    const {
      element,
      timerEventDefinition,
      timerEventDefinitionType
    } = props;
    const commandStack = useService('commandStack'),
          bpmnFactory = useService('bpmnFactory'),
          translate = useService('translate');

    const getValue = () => {
      return timerEventDefinitionType || '';
    };

    const setValue = value => {
      // (1) Check if value is different to current type
      if (value === timerEventDefinitionType) {
        return;
      } // (2) Create empty formalExpression element


      const formalExpression = bpmnFactory.create('bpmn:FormalExpression', {
        body: undefined
      });
      formalExpression.$parent = timerEventDefinition; // (3) Set the value for selected timerEventDefinitionType

      const newProps = {
        timeDuration: undefined,
        timeDate: undefined,
        timeCycle: undefined
      };

      if (value !== '') {
        newProps[value] = formalExpression;
      } // (4) Execute businessObject update


      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: timerEventDefinition,
        properties: newProps
      });
    };

    const getOptions = element => {
      return [{
        value: '',
        label: translate('<none>')
      }, {
        value: 'timeDate',
        label: translate('Date')
      }, {
        value: 'timeDuration',
        label: translate('Duration')
      }, {
        value: 'timeCycle',
        label: translate('Cycle')
      }];
    };

    return SelectEntry({
      element,
      id: 'timerEventDefinitionType',
      label: translate('Type'),
      getValue,
      setValue,
      getOptions
    });
  }
  /**
   * TimerEventDefinitionValue - Generic textField entry allowing to specify the
   * timerEventDefintionValue based on the set timerEventDefintionType. To be used
   * together with timerEventDefinitionType.
   *
   * @param  {type} props
   * @return {TextFieldEntry}
   */


  function TimerEventDefinitionValue$2(props) {
    const {
      element,
      timerEventDefinition,
      timerEventDefinitionType
    } = props;
    const commandStack = useService('commandStack'),
          translate = useService('translate'),
          debounce = useService('debounceInput');
    const timerEventFormalExpression = timerEventDefinition.get(timerEventDefinitionType);

    const getValue = () => {
      return timerEventFormalExpression && timerEventFormalExpression.get('body');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: timerEventFormalExpression,
        properties: {
          body: value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'timerEventDefinitionValue',
      label: translate('Value'),
      getValue,
      setValue,
      debounce,
      description: getTimerEventDefinitionValueDescription$2(timerEventDefinitionType, translate)
    });
  } // helper //////////////////////////


  function getTimerEventDefinitionValueDescription$2(timerDefinitionType, translate) {
    switch (timerDefinitionType) {
      case 'timeDate':
        return o$1("div", {
          children: [o$1("p", {
            children: translate('A specific point in time defined as ISO 8601 combined date and time representation.')
          }), o$1("ul", {
            children: [o$1("li", {
              children: [o$1("code", {
                children: "2019-10-01T12:00:00Z"
              }), " - ", translate('UTC time')]
            }), o$1("li", {
              children: [o$1("code", {
                children: "2019-10-02T08:09:40+02:00"
              }), " - ", translate('UTC plus 2 hours zone offset')]
            })]
          }), o$1("a", {
            href: "https://docs.camunda.org/manual/latest/reference/bpmn20/events/timer-events/#time-date",
            target: "_blank",
            rel: "noopener",
            children: translate('Documentation: Timer events')
          })]
        });

      case 'timeCycle':
        return o$1("div", {
          children: [o$1("p", {
            children: translate('A cycle defined as ISO 8601 repeating intervals format.')
          }), o$1("ul", {
            children: [o$1("li", {
              children: [o$1("code", {
                children: "R5/PT10S"
              }), " - ", translate('every 10 seconds, up to 5 times')]
            }), o$1("li", {
              children: [o$1("code", {
                children: "R/P1D"
              }), " - ", translate('every day, infinitely')]
            })]
          }), o$1("a", {
            href: "https://docs.camunda.org/manual/latest/reference/bpmn20/events/timer-events/#time-cycle",
            target: "_blank",
            rel: "noopener",
            children: translate('Documentation: Timer events')
          })]
        });

      case 'timeDuration':
        return o$1("div", {
          children: [o$1("p", {
            children: translate('A time duration defined as ISO 8601 durations format.')
          }), o$1("ul", {
            children: [o$1("li", {
              children: [o$1("code", {
                children: "PT15S"
              }), " - ", translate('15 seconds')]
            }), o$1("li", {
              children: [o$1("code", {
                children: "PT1H30M"
              }), " - ", translate('1 hour and 30 minutes')]
            }), o$1("li", {
              children: [o$1("code", {
                children: "P14D"
              }), " - ", translate('14 days')]
            })]
          }), o$1("a", {
            href: "https://docs.camunda.org/manual/latest/reference/bpmn20/events/timer-events/#time-duration",
            target: "_blank",
            rel: "noopener",
            children: translate('Documentation: Timer events')
          })]
        });
    }
  }

  function isTimerSupportedOnListener$1(listener) {
    return listener && is$4(listener, 'camunda:TaskListener') && getTimerEventDefinition(listener);
  }

  function getId$1(idPrefix, id) {
    return idPrefix ? idPrefix + id : id;
  }

  function GeneralGroup(element, injector) {
    const translate = injector.get('translate');
    const entries = [...NameProps({
      element
    }), ...IdProps(), ...ProcessProps({
      element
    }), ...ExecutableProps({
      element
    })];
    return {
      id: 'general',
      label: translate('General'),
      entries,
      component: Group
    };
  }

  function CompensationGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Compensation'),
      id: 'compensation',
      component: Group,
      entries: [...CompensationProps({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function DocumentationGroup(element, injector) {
    const translate = injector.get('translate');
    const entries = [...DocumentationProps({
      element
    })];
    return {
      id: 'documentation',
      label: translate('Documentation'),
      entries,
      component: Group
    };
  }

  function ErrorGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      id: 'error',
      label: translate('Error'),
      component: Group,
      entries: [...ErrorProps$1({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function MessageGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      id: 'message',
      label: translate('Message'),
      component: Group,
      entries: [...MessageProps$1({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function SignalGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      id: 'signal',
      label: translate('Signal'),
      component: Group,
      entries: [...SignalProps({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function LinkGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Link'),
      id: 'link',
      component: Group,
      entries: [...LinkProps({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function EscalationGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      id: 'escalation',
      label: translate('Escalation'),
      component: Group,
      entries: [...EscalationProps$1({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function TimerGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Timer'),
      id: 'timer',
      component: Group,
      entries: [...TimerProps$2({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function MultiInstanceGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Multi-instance'),
      id: 'multiInstance',
      component: Group,
      entries: [...MultiInstanceProps$2({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function getGroups(element, injector) {
    const groups = [GeneralGroup(element, injector), DocumentationGroup(element, injector), CompensationGroup(element, injector), ErrorGroup(element, injector), LinkGroup(element, injector), MessageGroup(element, injector), MultiInstanceGroup(element, injector), SignalGroup(element, injector), EscalationGroup(element, injector), TimerGroup(element, injector)]; // contract: if a group returns null, it should not be displayed at all

    return groups.filter(group => group !== null);
  }

  class BpmnPropertiesProvider {
    constructor(propertiesPanel, injector) {
      propertiesPanel.registerProvider(this);
      this._injector = injector;
    }

    getGroups(element) {
      return groups => {
        groups = groups.concat(getGroups(element, this._injector));
        return groups;
      };
    }

  }
  BpmnPropertiesProvider.$inject = ['propertiesPanel', 'injector'];

  var index$2 = {
    __init__: ['bpmnPropertiesProvider'],
    bpmnPropertiesProvider: ['type', BpmnPropertiesProvider]
  };

  /**
   * Get extension elements of business object. Optionally filter by type.
   *
   * @param  {ModdleElement} businessObject
   * @param  {String} [type=undefined]
   * @returns {Array<ModdleElement>}
   */

  function getExtensionElementsList(businessObject, type = undefined) {
    const extensionElements = businessObject.get('extensionElements');

    if (!extensionElements) {
      return [];
    }

    const values = extensionElements.get('values');

    if (!values || !values.length) {
      return [];
    }

    if (type) {
      return values.filter(value => is$4(value, type));
    }

    return values;
  }
  /**
   * Add one or more extension elements. Create bpmn:ExtensionElements if it doesn't exist.
   *
   * @param {ModdleElement} element
   * @param {ModdleElement} businessObject
   * @param {ModdleElement|Array<ModdleElement>} extensionElementsToAdd
   * @param {CommandStack} commandStack
   */

  function addExtensionElements(element, businessObject, extensionElementToAdd, bpmnFactory, commandStack) {
    const commands = [];
    let extensionElements = businessObject.get('extensionElements'); // (1) create bpmn:ExtensionElements if it doesn't exist

    if (!extensionElements) {
      extensionElements = createElement('bpmn:ExtensionElements', {
        values: []
      }, businessObject, bpmnFactory);
      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: businessObject,
          properties: {
            extensionElements
          }
        }
      });
    }

    extensionElementToAdd.$parent = extensionElements; // (2) add extension element to list

    commands.push({
      cmd: 'element.updateModdleProperties',
      context: {
        element,
        moddleElement: extensionElements,
        properties: {
          values: [...extensionElements.get('values'), extensionElementToAdd]
        }
      }
    });
    commandStack.execute('properties-panel.multi-command-executor', commands);
  }
  /**
   * Remove one or more extension elements. Remove bpmn:ExtensionElements afterwards if it's empty.
   *
   * @param {ModdleElement} element
   * @param {ModdleElement} businessObject
   * @param {ModdleElement|Array<ModdleElement>} extensionElementsToRemove
   * @param {CommandStack} commandStack
   */

  function removeExtensionElements(element, businessObject, extensionElementsToRemove, commandStack) {
    if (!isArray(extensionElementsToRemove)) {
      extensionElementsToRemove = [extensionElementsToRemove];
    }

    const extensionElements = businessObject.get('extensionElements'),
          values = extensionElements.get('values').filter(value => !extensionElementsToRemove.includes(value));
    commandStack.execute('element.updateModdleProperties', {
      element,
      moddleElement: extensionElements,
      properties: {
        values
      }
    });
  }

  var zeebe = {};

  var require$$0 = /*@__PURE__*/getAugmentedNamespace(index_esm);

  Object.defineProperty(zeebe, '__esModule', {
    value: true
  });

  var minDash$1 = require$$0;
  /**
   * Get a inputOutput from the business object
   *
   * @param {ModdleElement} element
   *
   * @return {ModdleElement} the inputOutput object
   */


  function getInputOutput$2(element) {
    return (getElements$3(element, 'zeebe:IoMapping') || [])[0];
  }
  /**
   * Return all input parameters existing in the business object, and
   * an empty array if none exist.
   *
   * @param  {ModdleElement} element
   *
   * @return {Array<ModdleElement>} a list of input parameter objects
   */


  function getInputParameters$3(element) {
    return getParameters$3(element, 'inputParameters');
  }
  /**
   * Return out mappings existing in the business object
   *
   * @param {ModdleElement} element
   *
   * @return {Array<ModdleElement>}
   */


  function getOutMappings$3(element) {
    return (getInputOutput$2(element) || {}).outputParameters;
  }
  /**
   * Return out mappings existing in the business object
   *
   * @param {ModdleElement} element
   *
   * @return {Array<ModdleElement>}
   */


  function getInMappings$2(element) {
    return (getInputOutput$2(element) || {}).inputParameters;
  }
  /**
   * Get the inputElement name from a loopCharacteristics
   *
   * @param {MoodleElement} loopCharacteristics
   * @returns {String} outputCollection
   */


  function getInputElement(loopCharacteristics) {
    const extensionElement = getElements$3(loopCharacteristics, 'zeebe:LoopCharacteristics')[0];
    return extensionElement && extensionElement.inputElement;
  }
  /**
   * Get the outputCollection name from a loopCharacteristics
   *
   * @param {MoodleElement} loopCharacteristics
   * @returns {String} outputCollection
   */


  function getOutputCollection(loopCharacteristics) {
    const extensionElement = getElements$3(loopCharacteristics, 'zeebe:LoopCharacteristics')[0];
    return extensionElement && extensionElement.outputCollection;
  }
  /**
   * Get a calledDecision from the business object
   *
   * @param {MoodleElement} element
   * @returns {MoodleElement} the calledDecision object
   */


  function getCalledDecision$2(element) {
    return (getElements$3(element, 'zeebe:CalledDecision') || [])[0];
  } // helpers //////////


  function getElements$3(element, type, property) {
    var elements = getExtensionElements$2(element, type);
    return !property ? elements : (elements[0] || {})[property] || [];
  }

  function getParameters$3(element, property) {
    var inputOutput = getInputOutput$2(element);
    return inputOutput && inputOutput.get(property) || [];
  }

  function getExtensionElements$2(element, type) {
    var elements = [];
    var extensionElements = element.get('extensionElements');

    if (typeof extensionElements !== 'undefined') {
      var extensionValues = extensionElements.get('values');

      if (typeof extensionValues !== 'undefined') {
        elements = minDash$1.filter(extensionValues, function (value) {
          return is$2$1(value, type);
        });
      }
    }

    return elements;
  }

  function is$2$1(element, type) {
    return element && typeof element.$instanceOf === 'function' && element.$instanceOf(type);
  }
  /**
   * Get all parent elements for a given element.
   *
   * @param {ModdleElement|string} element
   *
   * @returns {Array<ModdleElement>}
   */


  function getParents$1(element) {
    var parents = [];
    var current = element;

    while (current.$parent) {
      parents.push(current.$parent);
      current = current.$parent;
    }

    return parents;
  }
  /**
   * Iterate over each element in a collection, calling the iterator function `fn`
   * with (element, index, recursionDepth).
   *
   * Recurse into all elements that are returned by `fn`.
   *
   * @param  {Object|Array<Object>} elements
   * @param  {Function} fn iterator function called with (element, index, recursionDepth)
   * @param  {number} [depth] maximum recursion depth
   */


  function eachElement$1(elements, fn, depth) {
    depth = depth || 0;

    if (!minDash$1.isArray(elements)) {
      elements = [elements];
    }

    minDash$1.forEach(elements, function (s, i) {
      var filter = fn(s, i, depth);

      if (minDash$1.isArray(filter) && filter.length) {
        eachElement$1(filter, fn, depth + 1);
      }
    });
  }
  /**
   * Adds an element to a collection and returns true if the
   * element was added.
   *
   * @param {Array<Object>} elements
   * @param {Object} e
   * @param {boolean} unique
   */


  function add$1(elements, e, unique) {
    var canAdd = !unique || elements.indexOf(e) === -1;

    if (canAdd) {
      elements.push(e);
    }

    return canAdd;
  }
  /**
   * Collects self + flow elements up to a given depth from a list of elements.
   *
   * @param  {ModdleElement|Array<ModdleElement>} elements the elements to select the flowElements from
   * @param  {boolean} unique whether to return a unique result set (no duplicates)
   * @param  {number} maxDepth the depth to search through or -1 for infinite
   *
   * @return {Array<ModdleElement>} found elements
   */


  function selfAndFlowElements$1(elements, unique, maxDepth) {
    var result = [],
        processedFlowElements = [];
    eachElement$1(elements, function (element, i, depth) {
      add$1(result, element, unique);
      var flowElements = element.flowElements; // max traversal depth not reached yet

      if (maxDepth === -1 || depth < maxDepth) {
        // flowElements exist && flowElements not yet processed
        if (flowElements && add$1(processedFlowElements, flowElements, unique)) {
          return flowElements;
        }
      }
    });
    return result;
  }
  /**
   * Return self + ALL flowElements for a number of elements
   *
   * @param  {Array<ModdleElement>} elements to query
   * @param  {boolean} allowDuplicates to allow duplicates in the result set
   *
   * @return {Array<ModdleElement>} the collected elements
   */


  function selfAndAllFlowElements$1(elements, allowDuplicates) {
    return selfAndFlowElements$1(elements, !allowDuplicates, -1);
  }
  /**
   * Return full moddle element for given element id
   *
   * @param {string} elementId
   * @param {ModdleElement} rootElement
   *
   * @returns {ModdleElement}
   */


  function getElement$1(elementId, rootElement) {
    var allElements = selfAndAllFlowElements$1(rootElement);
    return minDash$1.find(allElements, function (element) {
      return element.id === elementId;
    });
  }

  function addVariableToList$1(variablesList, newVariable) {
    var foundIdx = minDash$1.findIndex(variablesList, function (variable) {
      return variable.name === newVariable.name && variable.scope === newVariable.scope;
    });

    if (foundIdx >= 0) {
      variablesList[foundIdx].origin = combineArrays$1$1(variablesList[foundIdx].origin, newVariable.origin);
    } else {
      variablesList.push(newVariable);
    }
  }
  /**
   * Creates new process variable definition object
   * Identifies correct (highest) scope, in which variable is available
   *
   * @param {ModdleElement} flowElement
   * @param {String} name
   * @param {ModdleElement} defaultScope
   *
   * @returns {ProcessVariable}
   */


  function createProcessVariable$1(flowElement, name, defaultScope) {
    var scope = getScope$1$1(flowElement, defaultScope, name);
    return {
      name: name,
      origin: [flowElement],
      scope: scope
    };
  } // helpers ////////////////////

  /**
   * Set parent container if it defines it's own scope for the variable, so
   * when it defines an input mapping for it. Otherwise returns the default global scope
   */


  function getScope$1$1(element, globalScope, variableName) {
    var parents = getParents$1(element);
    var scopedParent = minDash$1.find(parents, function (parent) {
      return is$1$1(parent, 'bpmn:SubProcess') && hasInputParameter$1(parent, variableName);
    });
    return scopedParent ? scopedParent : globalScope;
  }

  function is$1$1(element, type) {
    return element && typeof element.$instanceOf === 'function' && element.$instanceOf(type);
  }

  function hasInputParameter$1(element, name) {
    return minDash$1.find(getInputParameters$3(element), function (input) {
      return input.target === name;
    });
  }

  function combineArrays$1$1(a, b) {
    return a.concat(b);
  }
  /**
   * Retrieves process variables defined in output mappings, e.g.
   *
   * <bpmn:serviceTask id="ServiceTask">
   *   <bpmn:extensionElements>
   *     <zeebe:ioMapping>
   *       <zeebe:input source="= source" target="variable1" />
   *     </zeebe:ioMapping>
   *   </bpmn:extensionElements>
   * </bpmn:serviceTask>
   *
   * => Adds one variable "variable1" to the list.
   *
   */


  function extractInMappings(options) {
    var elements = options.elements,
        processVariables = options.processVariables;

    if (!minDash$1.isArray(elements)) {
      elements = [elements];
    }

    minDash$1.forEach(elements, function (element) {
      var inMappings = getInMappings$2(element); // extract all variables with correct scope

      minDash$1.forEach(inMappings, function (mapping) {
        var newVariable = createProcessVariable$1(element, mapping.target, element);
        addVariableToList$1(processVariables, newVariable);
      });
    });
    return processVariables;
  }
  /**
   * Retrieves process variables defined in result variables, e.g.
   *
   * <bpmn:serviceTask id="ServiceTask">
   *   <bpmn:multiInstanceLoopCharacteristics>
   *     <bpmn:extensionElements>
   *       <zeebe:loopCharacteristics inputElement="inputElement" outputCollection="outputCollection" />
   *     </bpmn:extensionElements>
   *   </bpmn:multiInstanceLoopCharacteristics>
   * </bpmn:serviceTask>
   *
   * => Adds one variable "inputElement"to the list.
   *
   */


  function extractInputElement(options) {
    var elements = options.elements,
        processVariables = options.processVariables;

    if (!minDash$1.isArray(elements)) {
      elements = [elements];
    }

    minDash$1.forEach(elements, function (element) {
      var loopCharacteristics = element.loopCharacteristics;
      var inputElement = loopCharacteristics && getInputElement(loopCharacteristics);

      if (inputElement) {
        var newVariable = createProcessVariable$1(element, inputElement, element);
        addVariableToList$1(processVariables, newVariable);
      }
    });
    return processVariables;
  }
  /**
   * Retrieves process variables defined in output mappings, e.g.
   *
   * <bpmn:serviceTask id="ServiceTask">
   *   <bpmn:extensionElements>
   *     <zeebe:ioMapping>
   *       <zeebe:output source="= source" target="variable1" />
   *     </zeebe:ioMapping>
   *   </bpmn:extensionElements>
   * </bpmn:serviceTask>
   *
   * => Adds one variable "variable1" to the list.
   *
   */


  function extractOutMappings$1(options) {
    var elements = options.elements,
        containerElement = options.containerElement,
        processVariables = options.processVariables;

    if (!minDash$1.isArray(elements)) {
      elements = [elements];
    }

    minDash$1.forEach(elements, function (element) {
      var outMappings = getOutMappings$3(element); // extract all variables with correct scope

      minDash$1.forEach(outMappings, function (mapping) {
        var newVariable = createProcessVariable$1(element, mapping.target, containerElement);
        addVariableToList$1(processVariables, newVariable);
      });
    });
    return processVariables;
  }
  /**
   * Retrieves process variables defined in output collection, e.g.
   *
   * <bpmn:serviceTask id="ServiceTask">
   *   <bpmn:multiInstanceLoopCharacteristics>
   *     <bpmn:extensionElements>
   *       <zeebe:loopCharacteristics inputElement="inputElement" outputCollection="outputCollection" />
   *     </bpmn:extensionElements>
   *   </bpmn:multiInstanceLoopCharacteristics>
   * </bpmn:serviceTask>
   *
   * => Adds one variable "outputCollection"to the list.
   *
   */


  function extractOutputCollections(options) {
    var elements = options.elements,
        containerElement = options.containerElement,
        processVariables = options.processVariables;

    if (!minDash$1.isArray(elements)) {
      elements = [elements];
    }

    minDash$1.forEach(elements, function (element) {
      var loopCharacteristics = element.loopCharacteristics;
      var outputCollection = loopCharacteristics && getOutputCollection(loopCharacteristics);

      if (outputCollection) {
        var newVariable = createProcessVariable$1(element, outputCollection, containerElement);
        addVariableToList$1(processVariables, newVariable);
      }
    });
    return processVariables;
  }
  /**
   * Retrieves process variables defined in result variables, e.g.
   *
   *   <bpmn:businessRuleTask id="Activity_1">
   *     <bpmn:extensionElements>
   *       <zeebe:calledDecision resultVariable="variable1" />
   *     </bpmn:extensionElements>
   *   </bpmn:businessRuleTask>
   *
   *
   * => Adds one variable "variable1"to the list.
   *
   */


  function extractResultVariables$1(options) {
    var elements = options.elements,
        containerElement = options.containerElement,
        processVariables = options.processVariables;

    if (!minDash$1.isArray(elements)) {
      elements = [elements];
    }

    minDash$1.forEach(elements, function (element) {
      var calledDecision = getCalledDecision$2(element);

      if (!calledDecision) {
        return;
      }

      var resultVariable = calledDecision.resultVariable;

      if (resultVariable) {
        var newVariable = createProcessVariable$1(element, resultVariable, containerElement);
        addVariableToList$1(processVariables, newVariable);
      }
    });
    return processVariables;
  }

  var extractors$1 = [extractInMappings, extractInputElement, extractOutMappings$1, extractOutputCollections, extractResultVariables$1];
  /**
   * @typedef {Object} ProcessVariable
   * @property {string} name
   * @property {Array<ModdleElement>} origin
   * @property {ModdleElement} scope
   */
  // api /////////////////////////

  /**
   * Retrieves all process variables for a given container element.
   * @param {ModdleElement} containerElement
   *
   * @returns {Array<ProcessVariable>}
   */

  function getProcessVariables$1(containerElement) {
    var processVariables = []; // (1) extract all flow elements inside the container

    var elements = selfAndAllFlowElements$1([containerElement], false); // (2) extract all variables from the extractors

    minDash$1.forEach(extractors$1, function (extractor) {
      extractor({
        elements: elements,
        containerElement: containerElement,
        processVariables: processVariables
      });
    });
    return processVariables;
  }
  /**
   * Retrieves all variables which are available in the given scope
   *
   * * Exclude variables which are only available in other scopes
   * * Exclude variables which are produced by the given element
   * * Include variables which are available in parent scopes
   *
   * @param {string} scope
   * @param {ModdleElement} rootElement element from where to extract all variables
   *
   * @returns {Array<ProcessVariable>}
   */


  function getVariablesForScope$1(scope, rootElement) {
    var allVariables = getProcessVariables$1(rootElement);
    var scopeElement = getElement$1(scope, rootElement); // (1) get variables for given scope

    var scopeVariables = minDash$1.filter(allVariables, function (variable) {
      return variable.scope.id === scopeElement.id;
    }); // (2) get variables for parent scopes

    var parents = getParents$1(scopeElement);
    var parentsScopeVariables = minDash$1.filter(allVariables, function (variable) {
      return minDash$1.find(parents, function (parent) {
        return parent.id === variable.scope.id;
      });
    });
    return combineArrays$2(scopeVariables, parentsScopeVariables);
  }

  function getVariablesForElement(element) {
    return getVariablesForScope$1(getScope$2(element), getRootElement$1(element));
  }

  function getScope$2(element) {
    const bo = getBusinessObject(element);

    if (is$3(element, 'bpmn:Participant')) {
      return bo.processRef.id;
    }

    return bo.id;
  }

  function getRootElement$1(element) {
    const businessObject = getBusinessObject(element);

    if (is$3(businessObject, 'bpmn:Participant')) {
      return businessObject.processRef;
    }

    if (is$3(businessObject, 'bpmn:Process')) {
      return businessObject;
    }

    let parent = businessObject;

    while (parent.$parent && !is$3(parent, 'bpmn:Process')) {
      parent = parent.$parent;
    }

    return parent;
  } // helpers ////////////////////


  function combineArrays$2(a, b) {
    return a.concat(b);
  }

  function getBusinessObject(element) {
    return element && element.businessObject || element;
  }

  function is$3(element, type) {
    var bo = getBusinessObject(element);
    return bo && typeof bo.$instanceOf === 'function' && bo.$instanceOf(type);
  }

  zeebe.getProcessVariables = getProcessVariables$1;
  var getVariablesForElement_1 = zeebe.getVariablesForElement = getVariablesForElement;
  zeebe.getVariablesForScope = getVariablesForScope$1;

  function withVariableContext(Component) {
    return props => {
      const {
        bpmnElement,
        element
      } = props;
      const bo = (bpmnElement || element).businessObject;
      const context = d(() => {
        const variables = getVariablesForElement_1(bo);
        return variables.map(variable => {
          return {
            name: variable.name,
            info: 'Written in ' + variable.origin.map(origin => origin.name || origin.id).join(', ')
          };
        });
      }, [bo]);
      return o$1(Component, { ...props,
        variables: context
      });
    };
  }

  function AssignmentDefinitionProps(props) {
    const {
      element
    } = props;

    if (!is$4(element, 'bpmn:UserTask')) {
      return [];
    }

    return [{
      id: 'assignmentDefinitionAssignee',
      component: Assignee$1,
      isEdited: isEdited$6
    }, {
      id: 'assignmentDefinitionCandidateGroups',
      component: CandidateGroups$1,
      isEdited: isEdited$6
    }, {
      id: 'assignmentDefinitionCandidateUsers',
      component: CandidateUsers$1,
      isEdited: isEdited$6
    }];
  }

  function Assignee$1(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const bpmnFactory = useService('bpmnFactory');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return (getAssignmentDefinition(element) || {}).assignee;
    };

    const setValue = value => {
      const commands = [];
      const businessObject = getBusinessObject$1(element);
      let extensionElements = businessObject.get('extensionElements'); // (1) ensure extension elements

      if (!extensionElements) {
        extensionElements = createElement('bpmn:ExtensionElements', {
          values: []
        }, businessObject, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: businessObject,
            properties: {
              extensionElements
            }
          }
        });
      } // (2) ensure AssignmentDefinition


      let assignmentDefinition = getAssignmentDefinition(element);

      if (!assignmentDefinition) {
        assignmentDefinition = createElement('zeebe:AssignmentDefinition', {}, extensionElements, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), assignmentDefinition]
            }
          }
        });
      } // (3) update assignee definition type


      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: assignmentDefinition,
          properties: {
            assignee: value
          }
        }
      }); // (4) commit all updates

      commandStack.execute('properties-panel.multi-command-executor', commands);
    };

    return withVariableContext(FeelEntry)({
      element,
      id: 'assignmentDefinitionAssignee',
      label: translate('Assignee'),
      feel: 'optional',
      getValue,
      setValue,
      debounce
    });
  }

  function CandidateGroups$1(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const bpmnFactory = useService('bpmnFactory');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return (getAssignmentDefinition(element) || {}).candidateGroups;
    };

    const setValue = value => {
      let commands = [];
      const businessObject = getBusinessObject$1(element);
      let extensionElements = businessObject.get('extensionElements'); // (1) ensure extension elements

      if (!extensionElements) {
        extensionElements = createElement('bpmn:ExtensionElements', {
          values: []
        }, businessObject, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: businessObject,
            properties: {
              extensionElements
            }
          }
        });
      } // (2) ensure assignmentDefinition


      let assignmentDefinition = getAssignmentDefinition(element);

      if (!assignmentDefinition) {
        assignmentDefinition = createElement('zeebe:AssignmentDefinition', {}, extensionElements, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), assignmentDefinition]
            }
          }
        });
      } // (3) update candidateGroups


      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: assignmentDefinition,
          properties: {
            candidateGroups: value
          }
        }
      });
      commandStack.execute('properties-panel.multi-command-executor', commands);
    };

    return withVariableContext(FeelEntry)({
      element,
      id: 'assignmentDefinitionCandidateGroups',
      label: translate('Candidate groups'),
      feel: 'optional',
      getValue,
      setValue,
      debounce
    });
  }

  function CandidateUsers$1(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const bpmnFactory = useService('bpmnFactory');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return (getAssignmentDefinition(element) || {}).candidateUsers;
    };

    const setValue = value => {
      let commands = [];
      const businessObject = getBusinessObject$1(element);
      let extensionElements = businessObject.get('extensionElements'); // (1) ensure extension elements

      if (!extensionElements) {
        extensionElements = createElement('bpmn:ExtensionElements', {
          values: []
        }, businessObject, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: businessObject,
            properties: {
              extensionElements
            }
          }
        });
      } // (2) ensure assignmentDefinition


      let assignmentDefinition = getAssignmentDefinition(element);

      if (!assignmentDefinition) {
        assignmentDefinition = createElement('zeebe:AssignmentDefinition', {}, extensionElements, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), assignmentDefinition]
            }
          }
        });
      } // (3) update candidateUsers


      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: assignmentDefinition,
          properties: {
            candidateUsers: value
          }
        }
      });
      commandStack.execute('properties-panel.multi-command-executor', commands);
    };

    return withVariableContext(FeelEntry)({
      element,
      id: 'assignmentDefinitionCandidateUsers',
      label: translate('Candidate users'),
      feel: 'optional',
      getValue,
      setValue,
      debounce
    });
  } // helper ///////////////////////


  function getAssignmentDefinition(element) {
    const businessObject = getBusinessObject$1(element);
    return getExtensionElementsList(businessObject, 'zeebe:AssignmentDefinition')[0];
  }

  const DMN_IMPLEMENTATION_OPTION = 'dmn',
        JOB_WORKER_IMPLEMENTATION_OPTION = 'jobWorker',
        DEFAULT_IMPLEMENTATION_OPTION = '';
  function BusinessRuleImplementationProps(props) {
    const {
      element
    } = props;

    if (!is$4(element, 'bpmn:BusinessRuleTask')) {
      return [];
    }

    return [{
      id: 'businessRuleImplementation',
      component: BusinessRuleImplementation,
      isEdited: () => isBusinessRuleImplementationEdited(element)
    }];
  }

  function BusinessRuleImplementation(props) {
    const {
      element,
      id
    } = props;
    const commandStack = useService('commandStack');
    const bpmnFactory = useService('bpmnFactory');
    const translate = useService('translate');

    const getValue = () => {
      if (getCalledDecision$1(element)) {
        return DMN_IMPLEMENTATION_OPTION;
      }

      if (getTaskDefinition$2(element)) {
        return JOB_WORKER_IMPLEMENTATION_OPTION;
      }

      return DEFAULT_IMPLEMENTATION_OPTION;
    };
    /**
     * Set value by either creating a zeebe:calledDecision or a zeebe:taskDefintion
     * extension element. Note that they must not exist both at the same time, however
     * this will be ensured by a bpmn-js behavior (and not by the propPanel).
     */


    const setValue = value => {
      let extensionElement, extensionElementType;

      if (value === DMN_IMPLEMENTATION_OPTION) {
        extensionElement = getCalledDecision$1(element);
        extensionElementType = 'zeebe:CalledDecision';
      } else if (value === JOB_WORKER_IMPLEMENTATION_OPTION) {
        extensionElement = getTaskDefinition$2(element);
        extensionElementType = 'zeebe:TaskDefinition';
      } else {
        resetElement(element, commandStack);
      }

      if (!extensionElement && extensionElementType) {
        extensionElement = createElement(extensionElementType, {}, null, bpmnFactory);
        updateExtensionElements(element, extensionElement, bpmnFactory, commandStack);
      }
    };

    const getOptions = () => {
      const options = [{
        value: DEFAULT_IMPLEMENTATION_OPTION,
        label: translate('<none>')
      }, {
        value: DMN_IMPLEMENTATION_OPTION,
        label: translate('DMN decision')
      }, {
        value: JOB_WORKER_IMPLEMENTATION_OPTION,
        label: translate('Job worker')
      }];
      return options;
    };

    return SelectEntry({
      element,
      id,
      label: translate('Implementation'),
      getValue,
      setValue,
      getOptions
    });
  } // helper ///////////////////////


  function getTaskDefinition$2(element) {
    const businessObject = getBusinessObject$1(element);
    return getExtensionElementsList(businessObject, 'zeebe:TaskDefinition')[0];
  }

  function getCalledDecision$1(element) {
    const businessObject = getBusinessObject$1(element);
    return getExtensionElementsList(businessObject, 'zeebe:CalledDecision')[0];
  }

  function isBusinessRuleImplementationEdited(element) {
    return getTaskDefinition$2(element);
  }

  function resetElement(element, commandStack) {
    const businessObject = getBusinessObject$1(element);
    const taskDefintion = getTaskDefinition$2(element);
    const calledDecision = getCalledDecision$1(element);

    if (taskDefintion) {
      removeExtensionElements(element, businessObject, taskDefintion, commandStack);
    }

    if (calledDecision) {
      removeExtensionElements(element, businessObject, calledDecision, commandStack);
    }
  }

  function updateExtensionElements(element, extensionElementToAdd, bpmnFactory, commandStack) {
    const businessObject = getBusinessObject$1(element);
    const commands = [];
    let extensionElements = businessObject.get('extensionElements');
    let extensionElementValues; // (1) create bpmn:ExtensionElements if it doesn't exist

    if (!extensionElements) {
      extensionElements = createElement('bpmn:ExtensionElements', {
        values: []
      }, businessObject, bpmnFactory);
      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: businessObject,
          properties: {
            extensionElements
          }
        }
      });
    }

    extensionElementToAdd.$parent = extensionElements; // (2) remove old exension element from extensionElements

    if (is$4(extensionElementToAdd, 'zeebe:TaskDefinition')) {
      extensionElementValues = without(extensionElements.get('values'), getCalledDecision$1(element));
    } else if (is$4(extensionElementToAdd, 'zeebe:CalledDecision')) {
      extensionElementValues = without(extensionElements.get('values'), getTaskDefinition$2(element));
    } // (3) add extension element to list


    commands.push({
      cmd: 'element.updateModdleProperties',
      context: {
        element,
        moddleElement: extensionElements,
        properties: {
          values: [...extensionElementValues, extensionElementToAdd]
        }
      }
    });
    commandStack.execute('properties-panel.multi-command-executor', commands);
  }

  function CalledDecisionProps(props) {
    const {
      element
    } = props;

    if (!is$4(element, 'bpmn:BusinessRuleTask') || !getCalledDecision(element)) {
      return [];
    }

    return [{
      id: 'decisionId',
      component: DecisionID,
      isEdited: isEdited$6
    }, {
      id: 'resultVariable',
      component: ResultVariable$3,
      isEdited: isEdited$1
    }];
  }

  function DecisionID(props) {
    const {
      element,
      id
    } = props;
    const commandStack = useService('commandStack');
    const bpmnFactory = useService('bpmnFactory');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return (getCalledDecision(element) || {}).decisionId;
    };

    const setValue = value => {
      const commands = [];
      const businessObject = getBusinessObject$1(element);
      let extensionElements = businessObject.get('extensionElements'); // (1) ensure extension elements

      if (!extensionElements) {
        extensionElements = createElement('bpmn:ExtensionElements', {
          values: []
        }, businessObject, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: businessObject,
            properties: {
              extensionElements
            }
          }
        });
      } // (2) ensure calledDecision


      let calledDecision = getCalledDecision(element);

      if (!calledDecision) {
        calledDecision = createElement('zeebe:CalledDecision', {}, extensionElements, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), calledDecision]
            }
          }
        });
      } // (3) update caledDecision.decisionId


      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: calledDecision,
          properties: {
            decisionId: value
          }
        }
      }); // (4) commit all updates

      commandStack.execute('properties-panel.multi-command-executor', commands);
    };

    return withVariableContext(FeelEntry)({
      element,
      id,
      label: translate('Decision ID'),
      feel: 'optional',
      getValue,
      setValue,
      debounce
    });
  }

  function ResultVariable$3(props) {
    const {
      element,
      id
    } = props;
    const commandStack = useService('commandStack');
    const bpmnFactory = useService('bpmnFactory');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return (getCalledDecision(element) || {}).resultVariable;
    };

    const setValue = value => {
      const commands = [];
      const businessObject = getBusinessObject$1(element);
      let extensionElements = businessObject.get('extensionElements'); // (1) ensure extension elements

      if (!extensionElements) {
        extensionElements = createElement('bpmn:ExtensionElements', {
          values: []
        }, businessObject, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: businessObject,
            properties: {
              extensionElements
            }
          }
        });
      } // (2) ensure calledDecision


      let calledDecision = getCalledDecision(element);

      if (!calledDecision) {
        calledDecision = createElement('zeebe:CalledDecision', {}, extensionElements, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), calledDecision]
            }
          }
        });
      } // (3) update caledDecision.decisionId


      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: calledDecision,
          properties: {
            resultVariable: value
          }
        }
      }); // (4) commit all updates

      commandStack.execute('properties-panel.multi-command-executor', commands);
    };

    return TextfieldEntry({
      element,
      id,
      label: translate('Result variable'),
      getValue,
      setValue,
      debounce
    });
  } // helper ///////////////////////


  function getCalledDecision(element) {
    const businessObject = getBusinessObject$1(element);
    return getExtensionElementsList(businessObject, 'zeebe:CalledDecision')[0];
  }

  function ConditionProps$1(props) {
    const {
      element
    } = props;

    if (!is$4(element, 'bpmn:SequenceFlow')) {
      return [];
    }

    const conditionProps = [];

    if (isConditionalSource$1(element.source)) {
      conditionProps.push({
        id: 'conditionExpression',
        component: ConditionExpression$1,
        isEdited: isEdited$6
      });
    }

    return conditionProps;
  }

  function ConditionExpression$1(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack'),
          bpmnFactory = useService('bpmnFactory'),
          translate = useService('translate'),
          debounce = useService('debounceInput');

    const getValue = () => {
      return getConditionExpression$1(element);
    };

    const setValue = value => {
      const commands = [];
      const businessObject = getBusinessObject$1(element); // (1) If we set value to a default flow, make it a non-default flow
      // by updating the element source

      const source = element.source;

      if (source.businessObject.default === businessObject) {
        commands.push({
          cmd: 'element.updateProperties',
          context: {
            element: source,
            properties: {
              'default': undefined
            }
          }
        });
      } // (2) Create and set formalExpression element containing the conditionExpression,
      // unless the provided value is empty


      const formalExpressionElement = value && value != '' ? createElement('bpmn:FormalExpression', {
        body: value
      }, businessObject, bpmnFactory) : undefined;
      commands.push({
        cmd: 'element.updateProperties',
        context: {
          element: element,
          properties: {
            conditionExpression: formalExpressionElement
          }
        }
      }); // (3) Execute the commands

      commandStack.execute('properties-panel.multi-command-executor', commands);
    };

    return withVariableContext(FeelEntry)({
      element,
      id: 'conditionExpression',
      label: translate('Condition expression'),
      feel: 'required',
      getValue,
      setValue,
      debounce
    });
  } // helper //////////////////////////


  const CONDITIONAL_SOURCES$1 = ['bpmn:Activity', 'bpmn:ExclusiveGateway', 'bpmn:InclusiveGateway'];

  function isConditionalSource$1(element) {
    return isAny(element, CONDITIONAL_SOURCES$1);
  }
  /**
   * getConditionExpression - get the body value of a condition expression for a given element
   *
   * @param  {ModdleElement} element
   *
   * @return {string|undefined}
   */


  function getConditionExpression$1(element) {
    const businessObject = getBusinessObject$1(element);
    const conditionExpression = businessObject.conditionExpression;

    if (conditionExpression) {
      return conditionExpression.get('body');
    }
  }

  function FormProps$1(props) {
    const {
      element,
      injector
    } = props;
    const formHelper = injector.invoke(FormHelper);

    if (!is$4(element, 'bpmn:UserTask')) {
      return [];
    }

    const entries = [{
      id: 'formType',
      component: FormType$1,
      isEdited: isEdited$4
    }];

    if (isCamundaForm(element, formHelper)) {
      entries.push({
        id: 'formConfiguration',
        component: FormConfiguration,
        isEdited: isEdited$2
      });
    } else if (isCustomKey(element, formHelper)) {
      entries.push({
        id: 'customFormKey',
        component: CustomFormKey,
        isEdited: isEdited$1
      });
    }

    return entries;
  }

  function FormType$1(props) {
    const {
      element
    } = props;
    const translate = useService('translate');
    const injector = useService('injector');
    const formHelper = injector.invoke(FormHelper);

    const getValue = () => {
      const formDefinition = formHelper.getFormDefinition(element);
      const userTaskForm = formHelper.getUserTaskForm(element);

      if (formDefinition) {
        if (userTaskForm) {
          return 'camundaForm';
        }

        return 'formKey';
      }

      return '';
    };

    const setValue = value => {
      formHelper.resetForm(element);

      if (value === 'camundaForm') {
        formHelper.setUserTaskForm(element, '');
      } else if (value === 'formKey') {
        formHelper.setFormDefinition(element, '');
      }
    };

    const getOptions = () => {
      return [{
        value: '',
        label: translate('<none>')
      }, {
        value: 'camundaForm',
        label: translate('Camunda forms')
      }, {
        value: 'formKey',
        label: translate('Custom form key')
      }];
    };

    return SelectEntry({
      element,
      id: 'formType',
      label: translate('Type'),
      getValue,
      setValue,
      getOptions
    });
  }

  function FormConfiguration(props) {
    const {
      element
    } = props;
    const injector = useService('injector');
    const debounce = useService('debounceInput');
    const translate = useService('translate');
    const formHelper = injector.invoke(FormHelper);

    const getValue = () => {
      const userTaskForm = formHelper.getUserTaskForm(element);
      return userTaskForm.get('body');
    };

    const setValue = value => {
      formHelper.setUserTaskForm(element, value);
    };

    return TextAreaEntry({
      element,
      id: 'formConfiguration',
      label: translate('Form JSON configuration'),
      rows: 4,
      getValue,
      setValue,
      debounce
    });
  }

  function CustomFormKey(props) {
    const {
      element
    } = props;
    const injector = useService('injector');
    const debounce = useService('debounceInput');
    const translate = useService('translate');
    const formHelper = injector.invoke(FormHelper);

    const getValue = () => {
      const formDefinition = formHelper.getFormDefinition(element);
      return formDefinition.get('formKey');
    };

    const setValue = value => {
      formHelper.setFormDefinition(element, value);
    };

    return TextfieldEntry({
      element,
      id: 'customFormKey',
      label: translate('Form key'),
      getValue,
      setValue,
      debounce
    });
  }

  const USER_TASK_FORM_PREFIX = 'userTaskForm_';

  function FormHelper(bpmnFactory, commandStack) {
    function getFormDefinition(element) {
      const businessObject = getBusinessObject$1(element);
      const formDefinitions = getExtensionElementsList(businessObject, 'zeebe:FormDefinition');
      return formDefinitions[0];
    }

    function getUserTaskForm(element, parent) {
      const rootElement = parent || getRootElement(element); // (1) get form definition from user task

      const formDefinition = getFormDefinition(element);

      if (isUndefined(formDefinition)) {
        return;
      }

      const formKey = formDefinition.get('formKey'); // (2) retrieve user task form via form key

      const userTaskForm = findUserTaskForm(formKey, rootElement);
      return userTaskForm;
    }

    function ensureTaskForm(element, values) {
      let commands = [];
      const rootElement = getRootElement(element); // (1) ensure root element extension elements

      let rootExtensionElements = rootElement.get('extensionElements');

      if (!rootExtensionElements) {
        rootExtensionElements = createElement('bpmn:ExtensionElements', {
          values: []
        }, rootElement, bpmnFactory);
        commands.push(UpdateModdlePropertiesCmd(element, rootElement, {
          extensionElements: rootExtensionElements
        }));
      } // (2) ensure user task form


      let userTaskForm = getUserTaskForm(element); // (2.1) create user task form if doesn't exist

      if (!userTaskForm) {
        userTaskForm = createUserTaskForm(values, rootExtensionElements, bpmnFactory);
        commands.push(UpdateModdlePropertiesCmd(element, rootExtensionElements, {
          values: [...rootExtensionElements.get('values'), userTaskForm]
        }));
      }

      commands.push(UpdateModdlePropertiesCmd(element, userTaskForm, values));
      return commands;
    }

    function ensureFormDefinition(element, customFormKey) {
      const businessObject = getBusinessObject$1(element);
      let commands = []; // (1) ensure extension elements

      let extensionElements = businessObject.get('extensionElements');

      if (isUndefined(extensionElements)) {
        extensionElements = createElement('bpmn:ExtensionElements', {
          values: []
        }, businessObject, bpmnFactory);
        commands.push(UpdateModdlePropertiesCmd(element, businessObject, {
          extensionElements: extensionElements
        }));
      } // (2) ensure form definition


      let formDefinition = getFormDefinition(element); // (2.1) create if doesn't exist

      if (!formDefinition) {
        let formKey = customFormKey;

        if (isUndefined(formKey)) {
          const formId = createFormId();
          formKey = createFormKey(formId);
        }

        formDefinition = createFormDefinition({
          formKey
        }, extensionElements, bpmnFactory);
        commands.push(UpdateModdlePropertiesCmd(element, extensionElements, {
          values: [...extensionElements.get('values'), formDefinition]
        }));
      } // (2.2) update existing form definition with custom key
      else if (customFormKey) {
        commands.push(UpdateModdlePropertiesCmd(element, formDefinition, {
          formKey: customFormKey
        }));
      }

      return {
        formId: resolveFormId(formDefinition.get('formKey')),
        commands
      };
    }

    function setFormDefinition(element, customFormKey) {
      const {
        commands
      } = ensureFormDefinition(element, customFormKey);
      commandStack.execute('properties-panel.multi-command-executor', commands);
    }

    function setUserTaskForm(element, value) {
      const {
        formId,
        commands: formDefCommands
      } = ensureFormDefinition(element);
      const userTaskCommands = ensureTaskForm(element, {
        id: formId,
        body: value
      });
      const commands = formDefCommands.concat(userTaskCommands);
      commandStack.execute('properties-panel.multi-command-executor', commands);
    }

    function unsetFormDefinition(element) {
      const businessObject = getBusinessObject$1(element),
            extensionElements = businessObject.get('extensionElements');
      let commands = [];
      const formDefinition = getFormDefinition(element);

      if (!formDefinition) {
        return commands;
      }

      let values = without(extensionElements.get('values'), formDefinition);
      commands.push(UpdateModdlePropertiesCmd(element, extensionElements, {
        values
      }));
      return commands;
    }

    function resetForm(element) {
      const rootElement = getRootElement(element),
            rootExtensionElements = rootElement.get('extensionElements'); // (1) remove form definition

      const commands = unsetFormDefinition(element); // (2) remove referenced user task form

      const userTaskForm = getUserTaskForm(element);

      if (!userTaskForm) {
        commandStack.execute('properties-panel.multi-command-executor', commands);
        return;
      }

      const values = without(rootExtensionElements.get('values'), userTaskForm);
      commands.push(UpdateModdlePropertiesCmd(element, rootExtensionElements, {
        values
      }));
      commandStack.execute('properties-panel.multi-command-executor', commands);
    }

    function createFormKey(formId) {
      return 'camunda-forms:bpmn:' + formId;
    }

    function createFormId() {
      return nextId(USER_TASK_FORM_PREFIX);
    }

    function resolveFormId(formKey) {
      return formKey.split(':')[2];
    }

    function createFormDefinition(properties, extensionElements, bpmnFactory) {
      return createElement('zeebe:FormDefinition', properties, extensionElements, bpmnFactory);
    }

    function createUserTaskForm(properties, extensionElements, bpmnFactory) {
      return createElement('zeebe:UserTaskForm', properties, extensionElements, bpmnFactory);
    }

    function findUserTaskForm(formKey, rootElement) {
      const forms = getExtensionElementsList(rootElement, 'zeebe:UserTaskForm');
      return find$1(forms, function (userTaskForm) {
        return createFormKey(userTaskForm.id) === formKey;
      });
    }

    function getRootElement(element) {
      const businessObject = getBusinessObject$1(element);
      let parent = businessObject;

      while (parent.$parent && !is$4(parent, 'bpmn:Process')) {
        parent = parent.$parent;
      }

      return parent;
    }

    return {
      getFormDefinition,
      getUserTaskForm,
      setFormDefinition,
      setUserTaskForm,
      resetForm
    };
  }

  FormHelper.$inject = ['bpmnFactory', 'commandStack']; // helpers /////////////

  function UpdateModdlePropertiesCmd(element, businessObject, newProperties) {
    return {
      cmd: 'element.updateModdleProperties',
      context: {
        element,
        moddleElement: businessObject,
        properties: newProperties
      }
    };
  }

  function isCamundaForm(element, formHelper) {
    const formDefinition = formHelper.getFormDefinition(element);
    const userTaskForm = formHelper.getUserTaskForm(element);
    return formDefinition && userTaskForm;
  }

  function isCustomKey(element, formHelper) {
    const formDefinition = formHelper.getFormDefinition(element);
    const userTaskForm = formHelper.getUserTaskForm(element);
    return formDefinition && !userTaskForm;
  }

  function Header(props) {
    const {
      idPrefix,
      header
    } = props;
    const entries = [{
      id: idPrefix + '-key',
      component: KeyProperty,
      header,
      idPrefix
    }, {
      id: idPrefix + '-value',
      component: ValueProperty$2,
      header,
      idPrefix
    }];
    return entries;
  }

  function KeyProperty(props) {
    const {
      idPrefix,
      element,
      header
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: header,
        properties: {
          key: value
        }
      });
    };

    const getValue = header => {
      return header.key;
    };

    return TextfieldEntry({
      element: header,
      id: idPrefix + '-key',
      label: translate('Key'),
      getValue,
      setValue,
      debounce
    });
  }

  function ValueProperty$2(props) {
    const {
      idPrefix,
      element,
      header
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: header,
        properties: {
          value
        }
      });
    };

    const getValue = header => {
      return header.value;
    };

    return TextfieldEntry({
      element: header,
      id: idPrefix + '-value',
      label: translate('Value'),
      getValue,
      setValue,
      debounce
    });
  }

  function isZeebeServiceTask(element) {
    if (!is$4(element, 'zeebe:ZeebeServiceTask')) return false;

    if (is$4(element, 'bpmn:EndEvent') || is$4(element, 'bpmn:IntermediateThrowEvent')) {
      return !!getMessageEventDefinition(element);
    } // A BusinessRuleTask is per default not a ServiceTask, only if it has a TaskDefinition
    // (ie. if the implementation is set to ==JobWorker)


    if (is$4(element, 'bpmn:BusinessRuleTask') && !getTaskDefinition$1(element)) {
      return false;
    }

    return true;
  }
  function isMessageEndEvent(element) {
    return is$4(element, 'bpmn:EndEvent') && !!getMessageEventDefinition(element);
  }
  function isMessageThrowEvent(element) {
    return is$4(element, 'bpmn:IntermediateThrowEvent') && !!getMessageEventDefinition(element);
  } // helper ////////////////

  function getTaskDefinition$1(element) {
    const businessObject = getBusinessObject$1(element);
    return getExtensionElementsList(businessObject, 'zeebe:TaskDefinition')[0];
  }

  function areHeadersSupported(element) {
    return is$4(element, 'bpmn:UserTask') || isZeebeServiceTask(element);
  }
  /**
   * Get first zeebe:TaskHeaders element for a specific element.
   *
   * @param  {ModdleElement} element
   *
   * @return {ModdleElement} a zeebe:TaskHeader element
   */

  function getTaskHeaders(element) {
    const businessObject = getBusinessObject$1(element);
    return getExtensionElementsList(businessObject, 'zeebe:TaskHeaders')[0];
  }
  /**
   * Retrieve all zeebe:Header elements for a specific element.
   *
   * @param  {ModdleElement} element
   *
   * @return {Array<ModdleElement>} a list of zeebe:Header elements
   */

  function getHeaders(element) {
    const taskHeaders = getTaskHeaders(element);
    return taskHeaders ? taskHeaders.get('values') : [];
  }

  function HeaderProps({
    element,
    injector
  }) {
    if (!areHeadersSupported(element)) {
      return null;
    }

    const headers = getHeaders(element) || [];
    const bpmnFactory = injector.get('bpmnFactory'),
          commandStack = injector.get('commandStack');
    const items = headers.map((header, index) => {
      const id = element.id + '-header-' + index;
      return {
        id,
        label: header.get('key') || '',
        entries: Header({
          idPrefix: id,
          element,
          header
        }),
        autoFocusEntry: id + '-key',
        remove: removeFactory$c({
          commandStack,
          element,
          header
        })
      };
    });
    return {
      items,
      add: addFactory$9({
        bpmnFactory,
        commandStack,
        element
      })
    };
  }

  function removeFactory$c({
    commandStack,
    element,
    header
  }) {
    return function (event) {
      event.stopPropagation();
      let commands = [];
      const taskHeaders = getTaskHeaders(element);

      if (!taskHeaders) {
        return;
      }

      const newTaskHeaders = without(taskHeaders.get('values'), header);
      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: taskHeaders,
          properties: {
            values: newTaskHeaders
          }
        }
      }); // remove zeebe:TaskHeaders if there are no headers anymore

      if (!newTaskHeaders.length) {
        const businessObject = getBusinessObject$1(element),
              extensionElements = businessObject.get('extensionElements');
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: without(extensionElements.get('values'), taskHeaders)
            }
          }
        });
      }

      commandStack.execute('properties-panel.multi-command-executor', commands);
    };
  }

  function addFactory$9({
    bpmnFactory,
    commandStack,
    element
  }) {
    return function (event) {
      event.stopPropagation();
      let commands = [];
      const businessObject = getBusinessObject$1(element);
      let extensionElements = businessObject.get('extensionElements'); // (1) ensure extension elements

      if (!extensionElements) {
        extensionElements = createElement('bpmn:ExtensionElements', {
          values: []
        }, businessObject, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: businessObject,
            properties: {
              extensionElements
            }
          }
        });
      } // (2) ensure zeebe:TaskHeaders


      let taskHeaders = getTaskHeaders(element);

      if (!taskHeaders) {
        const parent = extensionElements;
        taskHeaders = createElement('zeebe:TaskHeaders', {
          values: []
        }, parent, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), taskHeaders]
            }
          }
        });
      } // (3) create header


      const header = createElement('zeebe:Header', {}, taskHeaders, bpmnFactory); // (4) add header to list

      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: taskHeaders,
          properties: {
            values: [...taskHeaders.get('values'), header]
          }
        }
      });
      commandStack.execute('properties-panel.multi-command-executor', commands);
    };
  }

  function InputOutputParameter$1(props) {
    const {
      idPrefix,
      parameter
    } = props;
    const entries = [{
      id: idPrefix + '-target',
      component: TargetProperty,
      idPrefix,
      parameter
    }, {
      id: idPrefix + '-source',
      component: SourceProperty,
      idPrefix,
      parameter
    }];
    return entries;
  }

  function TargetProperty(props) {
    const {
      idPrefix,
      element,
      parameter
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: parameter,
        properties: {
          target: value
        }
      });
    };

    const getValue = parameter => {
      return parameter.target;
    };

    return TextfieldEntry({
      element: parameter,
      id: idPrefix + '-target',
      label: translate(is$4(parameter, 'zeebe:Input') ? 'Local variable name' : 'Process variable name'),
      getValue,
      setValue,
      debounce
    });
  }

  function SourceProperty(props) {
    const {
      idPrefix,
      element,
      parameter
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: parameter,
        properties: {
          source: value
        }
      });
    };

    const getValue = parameter => {
      return parameter.source;
    };

    return withVariableContext(FeelEntry)({
      bpmnElement: element,
      element: parameter,
      id: idPrefix + '-source',
      label: translate('Variable assignment value'),
      feel: 'required',
      getValue,
      setValue,
      debounce
    });
  }

  function getElements$2(bo, type, prop) {
    const elems = getExtensionElementsList(bo, type);
    return !prop ? elems : (elems[0] || {})[prop] || [];
  }

  function getParameters$2(element, prop) {
    const ioMapping = getIoMapping(element);
    return ioMapping && ioMapping.get(prop) || [];
  }
  /**
   * Get a ioMapping from the business object
   *
   * @param {djs.model.Base} element
   *
   * @return {ModdleElement} the ioMapping object
   */


  function getIoMapping(element) {
    const bo = getBusinessObject$1(element);
    return (getElements$2(bo, 'zeebe:IoMapping') || [])[0];
  }
  /**
   * Return all input parameters existing in the business object, and
   * an empty array if none exist.
   *
   * @param  {djs.model.Base} element
   *
   * @return {Array} a list of input parameter objects
   */

  function getInputParameters$2(element) {
    return getParameters$2.apply(this, [element, 'inputParameters']);
  }
  /**
   * Return all output parameters existing in the business object, and
   * an empty array if none exist.
   *
   * @param  {djs.model.Base} element
   *
   * @return {Array} a list of output parameter objects
   */

  function getOutputParameters$2(element) {
    return getParameters$2.apply(this, [element, 'outputParameters']);
  }
  function areInputParametersSupported$1(element) {
    return isAny(element, ['bpmn:UserTask', 'bpmn:SubProcess', 'bpmn:CallActivity', 'bpmn:BusinessRuleTask']) || isZeebeServiceTask(element);
  }
  function areOutputParametersSupported$1(element) {
    return isAny(element, ['zeebe:ZeebeServiceTask', 'bpmn:UserTask', 'bpmn:SubProcess', 'bpmn:ReceiveTask', 'bpmn:CallActivity', 'bpmn:Event', 'bpmn:BusinessRuleTask']);
  }
  function createIOMapping(properties, parent, bpmnFactory) {
    return createElement('zeebe:IoMapping', properties, parent, bpmnFactory);
  }

  function InputProps$1({
    element,
    injector
  }) {
    if (!areInputParametersSupported$1(element)) {
      return null;
    }

    const inputParameters = getInputParameters$2(element) || [];
    const bpmnFactory = injector.get('bpmnFactory'),
          commandStack = injector.get('commandStack');
    const items = inputParameters.map((parameter, index) => {
      const id = element.id + '-input-' + index;
      return {
        id,
        label: parameter.get('target') || '',
        entries: InputOutputParameter$1({
          idPrefix: id,
          element,
          parameter
        }),
        autoFocusEntry: id + '-target',
        remove: removeFactory$b({
          commandStack,
          element,
          parameter
        })
      };
    });
    return {
      items,
      add: addFactory$8({
        element,
        bpmnFactory,
        commandStack
      })
    };
  }

  function removeFactory$b({
    commandStack,
    element,
    parameter
  }) {
    return function (event) {
      event.stopPropagation();
      const commands = [];
      const ioMapping = getIoMapping(element);

      if (!ioMapping) {
        return;
      }

      const inputParameters = without(ioMapping.get('inputParameters'), parameter);
      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: ioMapping,
          properties: {
            inputParameters
          }
        }
      });
      const businessObject = getBusinessObject$1(element),
            extensionElements = businessObject.get('extensionElements'),
            values = without(extensionElements.get('values'), ioMapping); // remove ioMapping if there are no input/output parameters anymore

      if (!inputParameters.length && !ioMapping.get('outputParameters').length) {
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values
            }
          }
        });
      }

      commandStack.execute('properties-panel.multi-command-executor', commands);
    };
  }

  function addFactory$8({
    element,
    bpmnFactory,
    commandStack
  }) {
    return function (event) {
      event.stopPropagation();
      const commands = [];
      const businessObject = getBusinessObject$1(element);
      let extensionElements = businessObject.get('extensionElements'); // (1) ensure extension elements

      if (!extensionElements) {
        extensionElements = createElement('bpmn:ExtensionElements', {
          values: []
        }, businessObject, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: businessObject,
            properties: {
              extensionElements
            }
          }
        });
      } // (2) ensure IoMapping


      let ioMapping = getIoMapping(element);

      if (!ioMapping) {
        ioMapping = createIOMapping({
          inputParameters: [],
          outputParameters: []
        }, extensionElements, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), ioMapping]
            }
          }
        });
      } // (3) create parameter


      const newParameter = createElement('zeebe:Input', {
        source: '',
        target: nextId('InputVariable_')
      }, ioMapping, bpmnFactory); // (4) add parameter to list

      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: ioMapping,
          properties: {
            inputParameters: [...ioMapping.get('inputParameters'), newParameter]
          }
        }
      });
      commandStack.execute('properties-panel.multi-command-executor', commands);
    };
  }

  function MessageProps(props) {
    const {
      element
    } = props;
    const message = getMessage(element);
    const entries = [];

    if (message) {
      entries.push({
        id: 'messageName',
        component: MessageName,
        isEdited: isEdited$6
      });
    }

    if (message && canHaveSubscriptionCorrelationKey(element)) {
      entries.push({
        id: 'messageSubscriptionCorrelationKey',
        component: SubscriptionCorrelationKey,
        isEdited: isEdited$6
      });
    }

    return entries;
  }

  function MessageName(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const message = getMessage(element);

    const getValue = () => {
      return message.get('name');
    };

    const setValue = value => {
      return commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: message,
        properties: {
          name: value
        }
      });
    };

    return withVariableContext(FeelEntry)({
      element,
      id: 'messageName',
      label: translate('Name'),
      feel: 'optional',
      getValue,
      setValue,
      debounce
    });
  }

  function SubscriptionCorrelationKey(props) {
    const {
      element
    } = props;
    const bpmnFactory = useService('bpmnFactory');
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return getCorrelationKey(element);
    };

    const setValue = value => {
      const commands = [];
      const message = getMessage(element);
      let extensionElements = message.get('extensionElements'); // (1) ensure extension elements

      if (!extensionElements) {
        extensionElements = createElement('bpmn:ExtensionElements', {
          values: []
        }, message, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: message,
            properties: {
              extensionElements
            }
          }
        });
      } // (2) ensure subscription


      let subscription = getSubscription(element);

      if (!subscription) {
        subscription = createElement('zeebe:Subscription', {}, extensionElements, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), subscription]
            }
          }
        });
      } // (3) update subscription correlation key


      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: subscription,
          properties: {
            correlationKey: value
          }
        }
      }); // (4) commit all updates

      commandStack.execute('properties-panel.multi-command-executor', commands);
    };

    return withVariableContext(FeelEntry)({
      element,
      id: 'messageSubscriptionCorrelationKey',
      label: translate('Subscription correlation key'),
      feel: 'required',
      getValue,
      setValue,
      debounce
    });
  } // helper ///////////////////////


  function canHaveSubscriptionCorrelationKey(element) {
    // (1) allow for receive task
    if (is$4(element, 'bpmn:ReceiveTask')) {
      return true;
    } // (2) allow for non start events


    if (!is$4(element, 'bpmn:StartEvent')) {
      return true;
    } // (3) allow for start events inside event sub processes


    if (is$4(element, 'bpmn:StartEvent') && isEventSubProcess(element.parent)) {
      return true;
    }

    return false;
  }

  function getCorrelationKey(element) {
    const subscription = getSubscription(element);
    return subscription ? subscription.get('correlationKey') : '';
  }

  function getSubscription(element) {
    const message = getMessage(element);
    const subscriptions = getSubscriptions(message);
    return subscriptions[0];
  }

  function getSubscriptions(message) {
    const extensionElements = getExtensionElementsList(message, 'zeebe:Subscription');
    return extensionElements;
  }

  function MultiInstanceProps$1(props) {
    const {
      element
    } = props;

    if (!supportsMultiInstances(element)) {
      return [];
    }

    return [{
      id: 'multiInstance-inputCollection',
      component: InputCollection,
      isEdited: isEdited$6
    }, {
      id: 'multiInstance-inputElement',
      component: InputElement,
      isEdited: isEdited$1
    }, {
      id: 'multiInstance-outputCollection',
      component: OutputCollection,
      isEdited: isEdited$1
    }, {
      id: 'multiInstance-outputElement',
      component: OutputElement,
      isEdited: isEdited$6
    }, {
      id: 'multiInstance-completionCondition',
      component: CompletionCondition,
      isEdited: isEdited$6
    }];
  }

  function InputCollection(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const bpmnFactory = useService('bpmnFactory');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return getProperty$1(element, 'inputCollection');
    };

    const setValue = value => {
      return setProperty(element, 'inputCollection', value, commandStack, bpmnFactory);
    };

    return withVariableContext(FeelEntry)({
      element,
      id: 'multiInstance-inputCollection',
      label: translate('Input collection'),
      feel: 'required',
      getValue,
      setValue,
      debounce
    });
  }

  function InputElement(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const bpmnFactory = useService('bpmnFactory');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return getProperty$1(element, 'inputElement');
    };

    const setValue = value => {
      return setProperty(element, 'inputElement', value, commandStack, bpmnFactory);
    };

    return TextfieldEntry({
      element,
      id: 'multiInstance-inputElement',
      label: translate('Input element'),
      getValue,
      setValue,
      debounce
    });
  }

  function OutputCollection(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const bpmnFactory = useService('bpmnFactory');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return getProperty$1(element, 'outputCollection');
    };

    const setValue = value => {
      return setProperty(element, 'outputCollection', value, commandStack, bpmnFactory);
    };

    return TextfieldEntry({
      element,
      id: 'multiInstance-outputCollection',
      label: translate('Output collection'),
      getValue,
      setValue,
      debounce
    });
  }

  function OutputElement(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const bpmnFactory = useService('bpmnFactory');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return getProperty$1(element, 'outputElement');
    };

    const setValue = value => {
      return setProperty(element, 'outputElement', value, commandStack, bpmnFactory);
    };

    return withVariableContext(FeelEntry)({
      element,
      id: 'multiInstance-outputElement',
      label: translate('Output element'),
      feel: 'required',
      getValue,
      setValue,
      debounce
    });
  }

  function CompletionCondition(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const bpmnFactory = useService('bpmnFactory');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      const completionCondition = getCompletionCondition(element);
      return completionCondition && completionCondition.get('body');
    };

    const setValue = value => {
      if (value && value !== '') {
        const loopCharacteristics = getLoopCharacteristics$1(element);
        const completionCondition = createElement('bpmn:FormalExpression', {
          body: value
        }, loopCharacteristics, bpmnFactory);
        setCompletionCondition(element, commandStack, completionCondition);
      } else {
        setCompletionCondition(element, commandStack, undefined);
      }
    };

    return withVariableContext(FeelEntry)({
      element,
      id: 'multiInstance-completionCondition',
      label: translate('Completion condition'),
      feel: 'required',
      getValue,
      setValue,
      debounce
    });
  } // helper ///////////////////////


  function getLoopCharacteristics$1(element) {
    const businessObject = getBusinessObject$1(element);
    return businessObject.get('loopCharacteristics');
  }

  function getZeebeLoopCharacteristics(loopCharacteristics) {
    const extensionElements = getExtensionElementsList(loopCharacteristics, 'zeebe:LoopCharacteristics');
    return extensionElements && extensionElements[0];
  }

  function supportsMultiInstances(element) {
    return !!getLoopCharacteristics$1(element);
  }

  function getCompletionCondition(element) {
    return getLoopCharacteristics$1(element).get('completionCondition');
  }

  function setCompletionCondition(element, commandStack, completionCondition = undefined) {
    commandStack.execute('element.updateModdleProperties', {
      element,
      moddleElement: getLoopCharacteristics$1(element),
      properties: {
        completionCondition
      }
    });
  }

  function getProperty$1(element, propertyName) {
    const loopCharacteristics = getLoopCharacteristics$1(element),
          zeebeLoopCharacteristics = getZeebeLoopCharacteristics(loopCharacteristics);
    return zeebeLoopCharacteristics && zeebeLoopCharacteristics.get(propertyName);
  }

  function setProperty(element, propertyName, value, commandStack, bpmnFactory) {
    const loopCharacteristics = getLoopCharacteristics$1(element);
    const commands = []; // (1) ensure extension elements

    let extensionElements = loopCharacteristics.get('extensionElements');

    if (!extensionElements) {
      extensionElements = createElement('bpmn:ExtensionElements', {
        values: []
      }, loopCharacteristics, bpmnFactory);
      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: loopCharacteristics,
          properties: {
            extensionElements
          }
        }
      });
    } // (2) ensure zeebe loop characteristics


    let zeebeLoopCharacteristics = getZeebeLoopCharacteristics(loopCharacteristics);

    if (!zeebeLoopCharacteristics) {
      zeebeLoopCharacteristics = createElement('zeebe:LoopCharacteristics', {}, extensionElements, bpmnFactory);
      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: extensionElements,
          properties: {
            values: [...extensionElements.get('values'), zeebeLoopCharacteristics]
          }
        }
      });
    } // (3) update defined property


    commands.push({
      cmd: 'element.updateModdleProperties',
      context: {
        element,
        moddleElement: zeebeLoopCharacteristics,
        properties: {
          [propertyName]: value
        }
      }
    }); // (4) commit all updates

    commandStack.execute('properties-panel.multi-command-executor', commands);
  }

  function getProcessId(element) {
    const calledElement = getCalledElement(element);
    return calledElement ? calledElement.get('processId') : '';
  }
  function getCalledElement(element) {
    const calledElements = getCalledElements(element);
    return calledElements[0];
  }

  function getCalledElements(element) {
    const bo = getBusinessObject$1(element);
    const extElements = getExtensionElementsList(bo, 'zeebe:CalledElement');
    return extElements;
  }

  function OutputPropagationProps(props) {
    const {
      element
    } = props;

    if (!is$4(element, 'bpmn:CallActivity')) {
      return [];
    }

    return [{
      id: 'propagateAllChildVariables',
      component: PropagateAllChildVariables,
      isEdited: isEdited
    }];
  }

  function PropagateAllChildVariables(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack'),
          bpmnFactory = useService('bpmnFactory'),
          translate = useService('translate');
    const propagateAllChildVariables = isPropagateAllChildVariables(element);

    const getValue = () => {
      return propagateAllChildVariables;
    };

    const setValue = value => {
      const commands = [];
      const businessObject = getBusinessObject$1(element); // (1) ensure extension elements

      let extensionElements = businessObject.get('extensionElements');

      if (!extensionElements) {
        extensionElements = createElement('bpmn:ExtensionElements', {
          values: []
        }, businessObject, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: businessObject,
            properties: {
              extensionElements
            }
          }
        });
      } // (2) ensure zeebe:calledElement


      let calledElement = getCalledElement(businessObject);

      if (!calledElement) {
        calledElement = createElement('zeebe:CalledElement', {}, extensionElements, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), calledElement]
            }
          }
        });
      } // (3) Update propagateAllChildVariables attribute


      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: calledElement,
          properties: {
            propagateAllChildVariables: value
          }
        }
      }); // (4) Execute the commands

      commandStack.execute('properties-panel.multi-command-executor', commands);
    };

    return ToggleSwitchEntry({
      id: 'propagateAllChildVariables',
      label: translate('Propagate all child process variables'),
      switcherLabel: propagateAllChildVariables ? translate('On') : translate('Off'),
      description: propagateAllChildVariables ? translate('All variables from the child process instance will be propagated to the parent process instance') : translate('Only variables defined via output mappings will be propagated from the child to the parent process instance'),
      getValue,
      setValue
    });
  } // helper //////////////////////////

  /**
    * Determine default value for propagateAllChildVariables attribute
    * @param {Object} element representing a bpmn:CallActivity
    *
    * @returns {boolean}
    */


  function determinePropAllChildVariablesDefault(element) {
    const outputParameters = getOutputParameters$2(element);

    if (outputParameters) {
      return outputParameters.length > 0 ? false : true;
    }
  }
  /**
    * Check whether the propagateAllChildVariables attribute is set on an element.
    * Note that a default logic will be determine if it is not explicitly set.
    * @param {Object} element
    *
    * @returns {boolean}
    */


  function isPropagateAllChildVariables(element) {
    if (!is$4(element, 'bpmn:CallActivity')) {
      return undefined;
    }

    const bo = getBusinessObject$1(element),
          calledElement = getCalledElement(bo);
    return calledElement && has(calledElement, 'propagateAllChildVariables') ? calledElement.get('propagateAllChildVariables') : determinePropAllChildVariablesDefault(element);
  }

  function OutputProps$1({
    element,
    injector
  }) {
    if (!areOutputParametersSupported$1(element)) {
      return null;
    }

    const outputParameters = getOutputParameters$2(element) || [];
    const bpmnFactory = injector.get('bpmnFactory'),
          commandStack = injector.get('commandStack');
    const items = outputParameters.map((parameter, index) => {
      const id = element.id + '-output-' + index;
      return {
        id,
        label: parameter.get('target') || '',
        entries: InputOutputParameter$1({
          idPrefix: id,
          element,
          parameter
        }),
        autoFocusEntry: id + '-target',
        remove: removeFactory$a({
          commandStack,
          element,
          parameter
        })
      };
    });
    return {
      items,
      add: addFactory$7({
        element,
        bpmnFactory,
        commandStack
      })
    };
  }

  function removeFactory$a({
    commandStack,
    element,
    parameter
  }) {
    return function (event) {
      event.stopPropagation();
      let commands = [];
      const ioMapping = getIoMapping(element);

      if (!ioMapping) {
        return;
      }

      const outputParameters = without(ioMapping.get('outputParameters'), parameter);
      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: ioMapping,
          properties: {
            outputParameters
          }
        }
      }); // remove ioMapping if there are no input/output parameters anymore

      if (!ioMapping.get('inputParameters').length && !outputParameters.length) {
        const businessObject = getBusinessObject$1(element),
              extensionElements = businessObject.get('extensionElements'),
              values = without(extensionElements.get('values'), ioMapping);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values
            }
          }
        });
      }

      commandStack.execute('properties-panel.multi-command-executor', commands);
    };
  }

  function addFactory$7({
    element,
    bpmnFactory,
    commandStack
  }) {
    return function (event) {
      event.stopPropagation();
      let commands = [];
      const businessObject = getBusinessObject$1(element);
      let extensionElements = businessObject.get('extensionElements'); // (1) ensure extension elements

      if (!extensionElements) {
        extensionElements = createElement('bpmn:ExtensionElements', {
          values: []
        }, businessObject, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: businessObject,
            properties: {
              extensionElements
            }
          }
        });
      } // (2) ensure IoMapping


      let ioMapping = getIoMapping(element);

      if (!ioMapping) {
        const parent = extensionElements;
        ioMapping = createIOMapping({
          inputParameters: [],
          outputParameters: []
        }, parent, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), ioMapping]
            }
          }
        });
      } // (3) create parameter


      const newParameter = createElement('zeebe:Output', {
        source: '',
        target: nextId('OutputVariable_')
      }, ioMapping, bpmnFactory); // (4) add parameter to list

      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: ioMapping,
          properties: {
            outputParameters: [...ioMapping.get('outputParameters'), newParameter]
          }
        }
      });
      commandStack.execute('properties-panel.multi-command-executor', commands);
    };
  }

  function TargetProps(props) {
    const {
      element
    } = props;

    if (!is$4(element, 'bpmn:CallActivity')) {
      return [];
    }

    return [{
      id: 'targetProcessId',
      component: TargetProcessId,
      isEdited: isEdited$6
    }];
  }

  function TargetProcessId(props) {
    const {
      element,
      id
    } = props;
    const commandStack = useService('commandStack'),
          bpmnFactory = useService('bpmnFactory'),
          translate = useService('translate'),
          debounce = useService('debounceInput');

    const getValue = () => {
      return getProcessId(element);
    };

    const setValue = value => {
      const commands = [];
      const businessObject = getBusinessObject$1(element); // (1) ensure extension elements

      let extensionElements = businessObject.get('extensionElements');

      if (!extensionElements) {
        extensionElements = createElement('bpmn:ExtensionElements', {
          values: []
        }, businessObject, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: businessObject,
            properties: {
              extensionElements
            }
          }
        });
      } // (2) ensure zeebe:calledElement


      let calledElement = getCalledElement(businessObject);

      if (!calledElement) {
        calledElement = createElement('zeebe:CalledElement', {}, extensionElements, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), calledElement]
            }
          }
        });
      } // (3) Update processId attribute


      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: calledElement,
          properties: {
            processId: value
          }
        }
      }); // (4) Execute the commands

      commandStack.execute('properties-panel.multi-command-executor', commands);
    };

    return withVariableContext(FeelEntry)({
      element,
      id,
      label: translate('Process ID'),
      feel: 'optional',
      getValue,
      setValue,
      debounce
    });
  }

  function TaskDefinitionProps(props) {
    const {
      element
    } = props;

    if (!isZeebeServiceTask(element)) {
      return [];
    }

    return [{
      id: 'taskDefinitionType',
      component: TaskDefinitionType,
      isEdited: isEdited$6
    }, {
      id: 'taskDefinitionRetries',
      component: TaskDefinitionRetries,
      isEdited: isEdited$6
    }];
  }

  function TaskDefinitionType(props) {
    const {
      element,
      id
    } = props;
    const commandStack = useService('commandStack');
    const bpmnFactory = useService('bpmnFactory');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return (getTaskDefinition(element) || {}).type;
    };

    const setValue = value => {
      const commands = [];
      const businessObject = getBusinessObject$1(element);
      let extensionElements = businessObject.get('extensionElements'); // (1) ensure extension elements

      if (!extensionElements) {
        extensionElements = createElement('bpmn:ExtensionElements', {
          values: []
        }, businessObject, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: businessObject,
            properties: {
              extensionElements
            }
          }
        });
      } // (2) ensure task definition


      let taskDefinition = getTaskDefinition(element);

      if (!taskDefinition) {
        taskDefinition = createElement('zeebe:TaskDefinition', {}, extensionElements, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), taskDefinition]
            }
          }
        });
      } // (3) update task definition type


      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: taskDefinition,
          properties: {
            type: value
          }
        }
      }); // (4) commit all updates

      commandStack.execute('properties-panel.multi-command-executor', commands);
    };

    return withVariableContext(FeelEntry)({
      element,
      id,
      label: translate('Type'),
      feel: 'optional',
      getValue,
      setValue,
      debounce
    });
  }

  function TaskDefinitionRetries(props) {
    const {
      element,
      id
    } = props;
    const commandStack = useService('commandStack');
    const bpmnFactory = useService('bpmnFactory');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return (getTaskDefinition(element) || {}).retries;
    };

    const setValue = value => {
      let commands = [];
      const businessObject = getBusinessObject$1(element);
      let extensionElements = businessObject.get('extensionElements'); // (1) ensure extension elements

      if (!extensionElements) {
        extensionElements = createElement('bpmn:ExtensionElements', {
          values: []
        }, businessObject, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: businessObject,
            properties: {
              extensionElements
            }
          }
        });
      } // (2) ensure task definition


      let taskDefinition = getTaskDefinition(element);

      if (!taskDefinition) {
        taskDefinition = createElement('zeebe:TaskDefinition', {}, extensionElements, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), taskDefinition]
            }
          }
        });
      } // (3) update task definition retries


      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: taskDefinition,
          properties: {
            retries: value
          }
        }
      });
      commandStack.execute('properties-panel.multi-command-executor', commands);
    };

    return withVariableContext(FeelEntry)({
      element,
      id,
      label: translate('Retries'),
      feel: 'optional',
      getValue,
      setValue,
      debounce
    });
  } // helper ///////////////////////


  function getTaskDefinition(element) {
    const businessObject = getBusinessObject$1(element);
    return getExtensionElementsList(businessObject, 'zeebe:TaskDefinition')[0];
  }

  function TimerProps$1(props) {
    const {
      element,
      injector
    } = props;
    const translate = injector.get('translate');
    const businessObject = getBusinessObject$1(element),
          timerEventDefinition = getTimerEventDefinition(businessObject),
          timerEventDefinitionType = getTimerDefinitionType(timerEventDefinition); // (1) Only show for supported elements

    if (!isTimerSupported(element)) {
      return [];
    }

    const timerOptions = getTimerOptions(element, translate);
    const singleOption = timerOptions.length === 1;
    const entries = [];

    if (!singleOption) {
      entries.push({
        id: 'timerEventDefinitionType',
        component: TimerEventDefinitionType$1,
        isEdited: isEdited$4,
        options: timerOptions
      });
    }

    if (timerEventDefinitionType || singleOption) {
      entries.push({
        id: 'timerEventDefinitionValue',
        component: TimerEventDefinitionValue$1,
        isEdited: isEdited$6,
        label: singleOption ? timerOptions[0].label : undefined,
        timerEventDefinitionType: timerEventDefinitionType || timerOptions[0].value
      });
    }

    return entries;
  }

  function getTimerOptions(element, translate) {
    const options = [];

    if (isTimerDefinitionTypeSupported('timeDate', element)) {
      options.push({
        value: 'timeDate',
        label: translate('Date')
      });
    }

    if (isTimerDefinitionTypeSupported('timeDuration', element)) {
      options.push({
        value: 'timeDuration',
        label: translate('Duration')
      });
    }

    if (isTimerDefinitionTypeSupported('timeCycle', element)) {
      options.push({
        value: 'timeCycle',
        label: translate('Cycle')
      });
    }

    return options;
  }
  /**
   * TimerEventDefinitionType - Generic select entry allowing to select a specific
   * timerEventDefintionType. To be used together with timerEventDefinitionValue.
   *
   * @param  {type} props
   * @return {SelectEntry}
   */


  function TimerEventDefinitionType$1(props) {
    const {
      element,
      options
    } = props;
    const commandStack = useService('commandStack'),
          bpmnFactory = useService('bpmnFactory'),
          translate = useService('translate');
    const businessObject = getBusinessObject$1(element),
          timerEventDefinition = getTimerEventDefinition(businessObject),
          timerEventDefinitionType = getTimerDefinitionType(timerEventDefinition);

    const getValue = () => {
      return timerEventDefinitionType || '';
    };

    const setValue = value => {
      // (1) Check if value is different to current type
      if (value === timerEventDefinitionType) {
        return;
      } // (2) Create empty formalExpression element


      const formalExpression = createTimerFormalExpression(bpmnFactory, timerEventDefinition); // (3) Set the value for selected timerEventDefinitionType

      const newProps = {
        timeDuration: undefined,
        timeDate: undefined,
        timeCycle: undefined
      };

      if (value !== '') {
        newProps[value] = formalExpression;
      } // (4) Execute businessObject update


      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: timerEventDefinition,
        properties: newProps
      });
    };

    const getOptions = element => {
      return [{
        value: '',
        label: translate('<none>')
      }, ...options];
    };

    return SelectEntry({
      element,
      id: 'timerEventDefinitionType',
      label: translate('Type'),
      getValue,
      setValue,
      getOptions
    });
  }
  /**
   * TimerEventDefinitionValue - Generic textField entry allowing to specify the
   * timerEventDefintionValue based on the set timerEventDefintionType. To be used
   * together with timerEventDefinitionType.
   *
   * @param {object} props
   * @param {ModdleElement} props.element
   * @param {'timeCycle'|'timeDate'|'timeDuration'} props.timerEventDefinitionType?
   * @param {string} props.label?
   * @return {TextFieldEntry}
   */


  function TimerEventDefinitionValue$1(props) {
    const {
      element,
      label,
      timerEventDefinitionType
    } = props;
    const commandStack = useService('commandStack'),
          translate = useService('translate'),
          debounce = useService('debounceInput'),
          bpmnFactory = useService('bpmnFactory');
    const businessObject = getBusinessObject$1(element),
          timerEventDefinition = getTimerEventDefinition(businessObject),
          timerEventFormalExpression = timerEventDefinition.get(timerEventDefinitionType); // TODO(@barmac): remove with next major release
    // support `timerEventDefinitionDurationValue` for backwards compatibility

    const legacyId = getLegacyId(element);

    const getValue = () => {
      return timerEventFormalExpression && timerEventFormalExpression.get('body');
    };

    const setValue = value => {
      if (!timerEventFormalExpression) {
        const expression = createTimerFormalExpression(bpmnFactory, timerEventDefinition);
        expression.set('body', value);
        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: timerEventDefinition,
          properties: {
            [timerEventDefinitionType]: expression
          }
        });
        return;
      }

      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: timerEventFormalExpression,
        properties: {
          body: value
        }
      });
    };

    return withVariableContext(FeelEntry)({
      element,
      id: legacyId || 'timerEventDefinitionValue',
      label: label || translate('Value'),
      feel: 'optional',
      getValue,
      setValue,
      debounce,
      description: getTimerEventDefinitionValueDescription$1(timerEventDefinitionType, translate)
    });
  } // helper //////////////////////////

  /**
   * isTimerDefinitionTypeSupported - Checks whether a given timerDefinitionType
   * is supported for a given element
   *
   * @param  {string} timerDefinitionType
   * @param  {ModdleElement} element
   *
   * @return {boolean}
   */


  function isTimerDefinitionTypeSupported(timerDefinitionType, element) {
    const businessObject = getBusinessObject$1(element);

    switch (timerDefinitionType) {
      case 'timeDate':
        if (is$4(element, 'bpmn:StartEvent')) {
          return true;
        }

        return false;

      case 'timeCycle':
        if (is$4(element, 'bpmn:StartEvent') && !isInterruptingStartEvent(businessObject)) {
          return true;
        }

        if (is$4(element, 'bpmn:BoundaryEvent') && !businessObject.cancelActivity) {
          return true;
        }

        return false;

      case 'timeDuration':
        if (is$4(element, 'bpmn:IntermediateCatchEvent')) {
          return true;
        }

        if (is$4(element, 'bpmn:BoundaryEvent')) {
          return true;
        }

        return false;

      default:
        return undefined;
    }
  }

  function createTimerFormalExpression(bpmnFactory, eventDefinition) {
    const formalExpression = bpmnFactory.create('bpmn:FormalExpression', {
      body: undefined
    });
    formalExpression.$parent = eventDefinition;
    return formalExpression;
  }

  function getTimerEventDefinitionValueDescription$1(timerDefinitionType, translate) {
    switch (timerDefinitionType) {
      case 'timeDate':
        return o$1("div", {
          children: [o$1("p", {
            children: translate('A specific point in time defined as ISO 8601 combined date and time representation.')
          }), o$1("ul", {
            children: [o$1("li", {
              children: [o$1("code", {
                children: "2019-10-01T12:00:00Z"
              }), " - ", translate('UTC time')]
            }), o$1("li", {
              children: [o$1("code", {
                children: "2019-10-02T08:09:40+02:00"
              }), " - ", translate('UTC plus 2 hours zone offset')]
            })]
          }), o$1("a", {
            href: "https://docs.camunda.io/docs/reference/bpmn-processes/timer-events/timer-events#time-date",
            target: "_blank",
            rel: "noopener",
            title: translate('Timer documentation'),
            children: translate('How to configure a timer')
          })]
        });

      case 'timeCycle':
        return o$1("div", {
          children: [o$1("p", {
            children: translate('A cycle defined as ISO 8601 repeating intervals format, or a cron expression.')
          }), o$1("ul", {
            children: [o$1("li", {
              children: [o$1("code", {
                children: "R5/PT10S"
              }), " - ", translate('every 10 seconds, up to 5 times')]
            }), o$1("li", {
              children: [o$1("code", {
                children: "R/P1D"
              }), " - ", translate('every day, infinitely')]
            }), o$1("li", {
              children: [o$1("code", {
                children: "0 0 9-17 * * MON-FRI"
              }), " - ", translate('every hour on the hour from 9-5 p.m. UTC Monday-Friday')]
            })]
          }), o$1("a", {
            href: "https://docs.camunda.io/docs/reference/bpmn-processes/timer-events/timer-events#time-cycle",
            target: "_blank",
            rel: "noopener",
            title: translate('Timer documentation'),
            children: translate('How to configure a timer')
          })]
        });

      case 'timeDuration':
        return o$1("div", {
          children: [o$1("p", {
            children: translate('A time duration defined as ISO 8601 durations format.')
          }), o$1("ul", {
            children: [o$1("li", {
              children: [o$1("code", {
                children: "PT15S"
              }), " - ", translate('15 seconds')]
            }), o$1("li", {
              children: [o$1("code", {
                children: "PT1H30M"
              }), " - ", translate('1 hour and 30 minutes')]
            }), o$1("li", {
              children: [o$1("code", {
                children: "P14D"
              }), " - ", translate('14 days')]
            })]
          }), o$1("a", {
            href: "https://docs.camunda.io/docs/reference/bpmn-processes/timer-events/timer-events#time-duration",
            target: "_blank",
            rel: "noopener",
            title: translate('Timer documentation'),
            children: translate('How to configure a timer')
          })]
        });
    }
  }

  function isInterruptingStartEvent(bo) {
    return isInEventSubProcess$1(bo) && bo.get('isInterrupting') !== false;
  }

  function isInEventSubProcess$1(bo) {
    const parent = bo.$parent;
    return is$4(parent, 'bpmn:SubProcess') && parent.triggeredByEvent;
  }

  function getLegacyId(event) {
    if (is$4(event, 'bpmn:IntermediateCatchEvent') || isInterruptingBoundaryEvent(event)) {
      return 'timerEventDefinitionDurationValue';
    }
  }

  function isInterruptingBoundaryEvent(event) {
    const bo = getBusinessObject$1(event);
    return is$4(bo, 'bpmn:BoundaryEvent') && bo.get('cancelActivity') !== false;
  }

  function ExtensionProperty(props) {
    const {
      idPrefix,
      property
    } = props;
    const entries = [{
      id: idPrefix + '-name',
      component: NameProperty$1,
      idPrefix,
      property
    }, {
      id: idPrefix + '-value',
      component: ValueProperty$1,
      idPrefix,
      property
    }];
    return entries;
  }

  function NameProperty$1(props) {
    const {
      idPrefix,
      element,
      property
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: property,
        properties: {
          name: value
        }
      });
    };

    const getValue = () => {
      return property.name;
    };

    return TextfieldEntry({
      element: property,
      id: idPrefix + '-name',
      label: translate('Name'),
      getValue,
      setValue,
      debounce
    });
  }

  function ValueProperty$1(props) {
    const {
      idPrefix,
      element,
      property
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: property,
        properties: {
          value
        }
      });
    };

    const getValue = () => {
      return property.value;
    };

    return TextfieldEntry({
      element: property,
      id: idPrefix + '-value',
      label: translate('Value'),
      getValue,
      setValue,
      debounce
    });
  }

  function ExtensionPropertiesProps({
    element,
    injector,
    namespace = 'camunda'
  }) {
    if (namespace === 'zeebe' && !is$4(element, 'zeebe:PropertiesHolder')) {
      return [];
    }

    let businessObject = getRelevantBusinessObject(element); // do not offer for empty pools

    if (!businessObject) {
      return;
    }

    const properties = getPropertiesList(businessObject, namespace) || [];
    const bpmnFactory = injector.get('bpmnFactory'),
          commandStack = injector.get('commandStack');
    const items = properties.map((property, index) => {
      const id = element.id + '-extensionProperty-' + index;
      return {
        id,
        label: property.get('name') || '',
        entries: ExtensionProperty({
          idPrefix: id,
          element,
          property
        }),
        autoFocusEntry: id + '-name',
        remove: removeFactory$9({
          commandStack,
          element,
          property,
          namespace
        })
      };
    });
    return {
      items,
      add: addFactory$6({
        bpmnFactory,
        commandStack,
        element,
        namespace
      })
    };
  }

  function removeFactory$9({
    commandStack,
    element,
    property,
    namespace
  }) {
    return function (event) {
      event.stopPropagation();
      const commands = [];
      const businessObject = getRelevantBusinessObject(element);
      const properties = getProperties(businessObject, namespace);

      if (!properties) {
        return;
      }

      const propertyName = getPropertyName(namespace);
      const values = without(properties.get(propertyName), property);
      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: properties,
          properties: {
            [propertyName]: values
          }
        }
      }); // remove camunda:Properties if there are no properties anymore

      if (!values.length) {
        const businessObject = getBusinessObject$1(element),
              extensionElements = businessObject.get('extensionElements');
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: without(extensionElements.get('values'), properties)
            }
          }
        });
      }

      commandStack.execute('properties-panel.multi-command-executor', commands);
    };
  }

  function addFactory$6({
    bpmnFactory,
    commandStack,
    element,
    namespace
  }) {
    return function (event) {
      event.stopPropagation();
      let commands = [];
      const businessObject = getRelevantBusinessObject(element);
      let extensionElements = businessObject.get('extensionElements'); // (1) ensure extension elements

      if (!extensionElements) {
        extensionElements = createElement('bpmn:ExtensionElements', {
          values: []
        }, businessObject, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: businessObject,
            properties: {
              extensionElements
            }
          }
        });
      }

      const propertyName = getPropertyName(namespace); // (2) ensure camunda:Properties

      let properties = getProperties(businessObject, namespace);

      if (!properties) {
        const parent = extensionElements;
        properties = createElement(`${namespace}:Properties`, {
          [propertyName]: []
        }, parent, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), properties]
            }
          }
        });
      } // (3) create camunda:Property


      const property = createElement(`${namespace}:Property`, {}, properties, bpmnFactory); // (4) add property to list

      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: properties,
          properties: {
            [propertyName]: [...properties.get(propertyName), property]
          }
        }
      }); // (5) commit all updates

      commandStack.execute('properties-panel.multi-command-executor', commands);
    };
  } // helper //////////////////


  function getRelevantBusinessObject(element) {
    let businessObject = getBusinessObject$1(element);

    if (is$4(element, 'bpmn:Participant')) {
      return businessObject.get('processRef');
    }

    return businessObject;
  }

  function getPropertyName(namespace = 'camunda') {
    if (namespace === 'zeebe') {
      return 'properties';
    }

    return 'values';
  }

  function getProperties(element, namespace = 'camunda') {
    return getExtensionElementsList(getBusinessObject$1(element), `${namespace}:Properties`)[0];
  }
  function getPropertiesList(element, namespace = 'camunda') {
    const properties = getProperties(getBusinessObject$1(element), namespace);
    return properties && properties.get(getPropertyName(namespace));
  }

  const LOW_PRIORITY$1 = 500;
  const ZEEBE_GROUPS = [BusinessRuleImplementationGroup, CalledDecisionGroup, TaskDefinitionGroup, AssignmentDefinitionGroup, FormGroup$1, ConditionGroup$1, TargetGroup, InputGroup$1, OutputPropagationGroup, OutputGroup$1, HeaderGroup, ExtensionPropertiesGroup$1];
  class ZeebePropertiesProvider$1 {
    constructor(propertiesPanel, injector) {
      propertiesPanel.registerProvider(LOW_PRIORITY$1, this);
      this._injector = injector;
    }

    getGroups(element) {
      return groups => {
        // (1) add zeebe specific groups
        groups = groups.concat(this._getGroups(element)); // (2) update existing groups with zeebe specific properties

        updateMessageGroup(groups, element);
        updateTimerGroup$1(groups, element, this._injector);
        updateMultiInstanceGroup$1(groups, element); // (3) remove message group when not applicable

        groups = removeMessageGroup(groups, element);
        return groups;
      };
    }

    _getGroups(element) {
      const groups = ZEEBE_GROUPS.map(createGroup => createGroup(element, this._injector));
      return groups.filter(group => group !== null);
    }

  }
  ZeebePropertiesProvider$1.$inject = ['propertiesPanel', 'injector'];

  function CalledDecisionGroup(element) {
    const group = {
      id: 'calledDecision',
      label: 'Called decision',
      entries: [...CalledDecisionProps({
        element
      })],
      component: Group
    };
    return group.entries.length ? group : null;
  }

  function TaskDefinitionGroup(element) {
    const group = {
      id: 'taskDefinition',
      label: 'Task definition',
      entries: [...TaskDefinitionProps({
        element
      })],
      component: Group
    };
    return group.entries.length ? group : null;
  }

  function InputGroup$1(element, injector) {
    const group = {
      id: 'inputs',
      label: 'Inputs',
      component: ListGroup,
      ...InputProps$1({
        element,
        injector
      })
    };
    return group.items ? group : null;
  }

  function OutputGroup$1(element, injector) {
    const group = {
      id: 'outputs',
      label: 'Outputs',
      component: ListGroup,
      ...OutputProps$1({
        element,
        injector
      })
    };
    return group.items ? group : null;
  }

  function ConditionGroup$1(element) {
    const group = {
      id: 'condition',
      label: 'Condition',
      entries: [...ConditionProps$1({
        element
      })],
      component: Group
    };
    return group.entries.length ? group : null;
  }

  function FormGroup$1(element, injector) {
    const group = {
      id: 'form',
      label: 'Form',
      entries: [...FormProps$1({
        element,
        injector
      })],
      component: Group
    };
    return group.entries.length ? group : null;
  }

  function TargetGroup(element) {
    const group = {
      id: 'calledElement',
      label: 'Called element',
      entries: [...TargetProps({
        element
      })],
      component: Group
    };
    return group.entries.length ? group : null;
  }

  function HeaderGroup(element, injector) {
    const group = {
      id: 'headers',
      label: 'Headers',
      component: ListGroup,
      ...HeaderProps({
        element,
        injector
      })
    };
    return group.items ? group : null;
  }

  function OutputPropagationGroup(element) {
    const group = {
      id: 'outputPropagation',
      label: 'Output propagation',
      entries: [...OutputPropagationProps({
        element
      })],
      component: Group
    };
    return group.entries.length ? group : null;
  }

  function BusinessRuleImplementationGroup(element) {
    const group = {
      id: 'businessRuleImplementation',
      label: 'Implementation',
      entries: [...BusinessRuleImplementationProps({
        element
      })],
      component: Group
    };
    return group.entries.length ? group : null;
  }

  function AssignmentDefinitionGroup(element) {
    const group = {
      id: 'assignmentDefinition',
      label: 'Assignment',
      entries: [...AssignmentDefinitionProps({
        element
      })],
      component: Group
    };
    return group.entries.length ? group : null;
  }

  function ExtensionPropertiesGroup$1(element, injector) {
    const group = {
      label: 'Extension properties',
      id: 'Zeebe__ExtensionProperties',
      component: ListGroup,
      ...ExtensionPropertiesProps({
        element,
        injector,
        namespace: 'zeebe'
      })
    };

    if (group.items) {
      return group;
    }

    return null;
  }

  function updateMessageGroup(groups, element) {
    const messageGroup = findGroup$1(groups, 'message');

    if (!messageGroup) {
      return;
    }

    messageGroup.entries = overrideGenericEntries(messageGroup.entries, MessageProps({
      element
    }));
  } // overwrite bpmn generic timerEventDefinition group with zeebe-specific one


  function updateTimerGroup$1(groups, element, injector) {
    const timerEventGroup = findGroup$1(groups, 'timer');

    if (!timerEventGroup) {
      return;
    }

    timerEventGroup.entries = [...TimerProps$1({
      element,
      injector
    })];
  } // overwrite bpmn generic multiInstance group with zeebe-specific one


  function updateMultiInstanceGroup$1(groups, element) {
    const multiInstanceGroup = findGroup$1(groups, 'multiInstance');

    if (!multiInstanceGroup) {
      return;
    }

    multiInstanceGroup.entries = [...MultiInstanceProps$1({
      element
    })];
  } // remove message group from Message End Event & Message Throw Event


  function removeMessageGroup(groups, element) {
    const messageGroup = findGroup$1(groups, 'message');

    if (isMessageEndEvent(element) || isMessageThrowEvent(element)) {
      groups = groups.filter(g => g != messageGroup);
    }

    return groups;
  } // helper /////////////////////


  function findGroup$1(groups, id) {
    return groups.find(g => g.id === id);
  }
  /**
   * Replace generic bpmn components with specific zeebe ones.
   *
   * @param {Array} oldEntries
   * @param {Array} newEntries
   * @returns {Array} combined entries
   */


  function overrideGenericEntries(oldEntries, newEntries) {
    const filteredEntries = oldEntries.filter(oldEntry => !newEntries.find(newEntry => newEntry.id === oldEntry.id));
    return [...filteredEntries, ...newEntries];
  }

  var zeebePropertiesProviderModule = {
    __init__: ['zeebePropertiesProvider'],
    zeebePropertiesProvider: ['type', ZeebePropertiesProvider$1]
  };

  var arrayMove$1 = {exports: {}};

  const arrayMoveMutate = (array, from, to) => {
    const startIndex = from < 0 ? array.length + from : from;

    if (startIndex >= 0 && startIndex < array.length) {
      const endIndex = to < 0 ? array.length + to : to;
      const [item] = array.splice(from, 1);
      array.splice(endIndex, 0, item);
    }
  };

  const arrayMove = (array, from, to) => {
    array = [...array];
    arrayMoveMutate(array, from, to);
    return array;
  };

  arrayMove$1.exports = arrayMove;
  var mutate = arrayMove$1.exports.mutate = arrayMoveMutate;

  function AsynchronousContinuationsProps(props) {
    const {
      element
    } = props;

    const checkboxIsEditedInverted = node => {
      return node && !node.checked;
    };

    const businessObject = getBusinessObject$1(element);
    const entries = [];

    if (is$4(element, 'camunda:AsyncCapable')) {
      entries.push({
        id: 'asynchronousContinuationBefore',
        component: AsynchronousContinuationBefore,
        isEdited: isEdited$7
      }, {
        id: 'asynchronousContinuationAfter',
        component: AsynchronousContinuationAfter,
        isEdited: isEdited$7
      });

      if (isAsyncBefore$2(businessObject) || isAsyncAfter$2(businessObject)) {
        entries.push({
          id: 'exclusive',
          component: Exclusive,
          isEdited: checkboxIsEditedInverted
        });
      }
    }

    return entries;
  }

  function AsynchronousContinuationBefore(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack'),
          translate = useService('translate');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      return isAsyncBefore$2(businessObject);
    };

    const setValue = value => {
      // overwrite the legacy `async` property, we will use the more explicit `asyncBefore`
      const props = {
        'camunda:asyncBefore': value,
        'camunda:async': undefined
      };
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: props
      });
    };

    return CheckboxEntry({
      element,
      id: 'asynchronousContinuationBefore',
      label: translate('Before'),
      getValue,
      setValue
    });
  }

  function AsynchronousContinuationAfter(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack'),
          translate = useService('translate');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      return isAsyncAfter$2(businessObject);
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:asyncAfter': value
        }
      });
    };

    return CheckboxEntry({
      element,
      id: 'asynchronousContinuationAfter',
      label: translate('After'),
      getValue,
      setValue
    });
  }

  function Exclusive(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack'),
          translate = useService('translate');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      return isExclusive$1(businessObject);
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:exclusive': value
        }
      });
    };

    return CheckboxEntry({
      element,
      id: 'exclusive',
      label: translate('Exclusive'),
      getValue,
      setValue
    });
  } // helper //////////////////

  /**
   * Returns true if the attribute 'camunda:asyncBefore' is set
   * to true.
   *
   * @param  {ModdleElement} bo
   *
   * @return {boolean} a boolean value
   */


  function isAsyncBefore$2(bo) {
    return !!(bo.get('camunda:asyncBefore') || bo.get('camunda:async'));
  }
  /**
   * Returns true if the attribute 'camunda:asyncAfter' is set
   * to true.
   *
   * @param  {ModdleElement} bo
   *
   * @return {boolean} a boolean value
   */


  function isAsyncAfter$2(bo) {
    return !!bo.get('camunda:asyncAfter');
  }
  /**
   * Returns true if the attribute 'camunda:exclusive' is set
   * to true.
   *
   * @param  {ModdleElement} bo
   *
   * @return {boolean} a boolean value
   */


  function isExclusive$1(bo) {
    return !!bo.get('camunda:exclusive');
  }

  const EMPTY_OPTION$1 = '';
  function BusinessKeyProps$1(props) {
    const {
      element
    } = props;

    if (!is$4(element, 'bpmn:StartEvent') || !hasFormFields(element)) {
      return [];
    }

    return [{
      id: 'businessKey',
      component: BusinessKey$1,
      isEdited: isEdited$4
    }];
  }

  function BusinessKey$1(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const formData = getFormData$3(element);

    const getValue = () => {
      return formData.get('camunda:businessKey') || '';
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: formData,
        properties: {
          'camunda:businessKey': value
        }
      });
    };

    const getOptions = () => {
      const options = [{
        value: EMPTY_OPTION$1,
        label: translate('<none>')
      }];
      const fields = formData.get('fields');
      fields.forEach(field => {
        const id = field.get('camunda:id');

        if (id) {
          options.push({
            value: id,
            label: id
          });
        }
      });
      return options;
    };

    return SelectEntry({
      element,
      id: 'businessKey',
      label: translate('Key'),
      getValue,
      setValue,
      getOptions
    });
  } // helper ///////////////////


  function getFormData$3(element) {
    const businessObject = getBusinessObject$1(element);
    return getExtensionElementsList(businessObject, 'camunda:FormData')[0];
  }

  function hasFormFields(element) {
    const businessObject = getBusinessObject$1(element);
    const formData = getFormData$3(businessObject);
    return formData && formData.get('camunda:fields').length;
  }

  function CalledBpmnProps(props) {
    const {
      element
    } = props;
    const entries = [{
      id: 'calledElement',
      component: CalledElement,
      isEdited: isEdited$1
    }, {
      id: 'calledElementBinding',
      component: CalledElementBinding,
      isEdited: isEdited$4
    }, {
      id: 'calledElementTenantId',
      component: CalledElementTenantId,
      isEdited: isEdited$1
    }];
    const binding = getBusinessObject$1(element).get('camunda:calledElementBinding');

    if (binding === 'version') {
      entries.splice(-1, 0, {
        id: 'calledElementVersion',
        component: CalledElementVersion,
        isEdited: isEdited$1
      });
    } else if (binding === 'versionTag') {
      entries.splice(-1, 0, {
        id: 'calledElementVersionTag',
        component: CalledElementVersionTag,
        isEdited: isEdited$1
      });
    }

    return entries;
  }

  function CalledElement(props) {
    const {
      element
    } = props;
    const modeling = useService('modeling');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return getBusinessObject$1(element).get('calledElement');
    };

    const setValue = value => {
      modeling.updateProperties(element, {
        calledElement: value || ''
      });
    };

    return o$1(TextfieldEntry, {
      element: element,
      id: "calledElement",
      label: translate('Called element'),
      getValue: getValue,
      setValue: setValue,
      debounce: debounce
    });
  }

  function CalledElementBinding(props) {
    const {
      element
    } = props;
    const modeling = useService('modeling');
    const translate = useService('translate');

    const getValue = () => {
      return getBusinessObject$1(element).get('camunda:calledElementBinding') || 'latest';
    };

    const setValue = value => {
      modeling.updateProperties(element, {
        calledElementBinding: value === 'latest' ? undefined : value,
        calledElementVersion: undefined,
        calledElementVersionTag: undefined
      });
    };

    const getOptions = () => [{
      value: 'latest',
      label: translate('latest')
    }, {
      value: 'deployment',
      label: translate('deployment')
    }, {
      value: 'version',
      label: translate('version')
    }, {
      value: 'versionTag',
      label: translate('version tag')
    }];

    return o$1(SelectEntry, {
      element: element,
      id: "calledElementBinding",
      label: translate('Binding'),
      getValue: getValue,
      setValue: setValue,
      getOptions: getOptions
    });
  }

  function CalledElementVersion(props) {
    const {
      element
    } = props;
    const modeling = useService('modeling');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return getBusinessObject$1(element).get('camunda:calledElementVersion');
    };

    const setValue = value => {
      modeling.updateProperties(element, {
        calledElementVersion: value
      });
    };

    return o$1(TextfieldEntry, {
      element: element,
      id: "calledElementVersion",
      label: translate('Version'),
      getValue: getValue,
      setValue: setValue,
      debounce: debounce
    });
  }

  function CalledElementVersionTag(props) {
    const {
      element
    } = props;
    const modeling = useService('modeling');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return getBusinessObject$1(element).get('camunda:calledElementVersionTag');
    };

    const setValue = value => {
      modeling.updateProperties(element, {
        calledElementVersionTag: value
      });
    };

    return o$1(TextfieldEntry, {
      element: element,
      id: "calledElementVersionTag",
      label: translate('Version tag'),
      getValue: getValue,
      setValue: setValue,
      debounce: debounce
    });
  }

  function CalledElementTenantId(props) {
    const {
      element
    } = props;
    const modeling = useService('modeling');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return getBusinessObject$1(element).get('camunda:calledElementTenantId');
    };

    const setValue = value => {
      modeling.updateProperties(element, {
        calledElementTenantId: value
      });
    };

    return o$1(TextfieldEntry, {
      element: element,
      id: "calledElementTenantId",
      label: translate('Tenant ID'),
      getValue: getValue,
      setValue: setValue,
      debounce: debounce
    });
  }

  function CalledCmmnProps(props) {
    const {
      element
    } = props;
    const entries = [{
      id: 'calledElementCaseRef',
      component: CaseRef,
      isEdited: isEdited$1
    }, {
      id: 'calledElementCaseBinding',
      component: CaseBinding,
      isEdited: isEdited$4
    }, {
      id: 'calledElementCaseTenantId',
      component: CaseTenantId,
      isEdited: isEdited$1
    }];

    if (getBusinessObject$1(element).get('camunda:caseBinding') === 'version') {
      entries.splice(-1, 0, {
        id: 'calledElementCaseVersion',
        component: CaseVersion,
        isEdited: isEdited$1
      });
    }

    return entries;
  }

  function CaseRef(props) {
    const {
      element
    } = props;
    const modeling = useService('modeling');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return getBusinessObject$1(element).get('camunda:caseRef');
    };

    const setValue = value => {
      modeling.updateProperties(element, {
        caseRef: value || ''
      });
    };

    return o$1(TextfieldEntry, {
      element: element,
      id: "calledElementCaseRef",
      label: translate('Case ref'),
      getValue: getValue,
      setValue: setValue,
      debounce: debounce
    });
  }

  function CaseBinding(props) {
    const {
      element
    } = props;
    const modeling = useService('modeling');
    const translate = useService('translate');

    const getValue = () => {
      return getBusinessObject$1(element).get('camunda:caseBinding') || 'latest';
    };

    const setValue = value => {
      modeling.updateProperties(element, {
        caseBinding: value === 'latest' ? undefined : value,
        caseVersion: undefined
      });
    };

    const getOptions = () => [{
      value: 'latest',
      label: translate('latest')
    }, {
      value: 'deployment',
      label: translate('deployment')
    }, {
      value: 'version',
      label: translate('version')
    }];

    return o$1(SelectEntry, {
      element: element,
      id: "calledElementCaseBinding",
      label: translate('Binding'),
      getValue: getValue,
      setValue: setValue,
      getOptions: getOptions
    });
  }

  function CaseVersion(props) {
    const {
      element
    } = props;
    const modeling = useService('modeling');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return getBusinessObject$1(element).get('camunda:caseVersion');
    };

    const setValue = value => {
      modeling.updateProperties(element, {
        caseVersion: value
      });
    };

    return o$1(TextfieldEntry, {
      element: element,
      id: "calledElementCaseVersion",
      label: translate('Version'),
      getValue: getValue,
      setValue: setValue,
      debounce: debounce
    });
  }

  function CaseTenantId(props) {
    const {
      element
    } = props;
    const modeling = useService('modeling');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return getBusinessObject$1(element).get('camunda:caseTenantId');
    };

    const setValue = value => {
      modeling.updateProperties(element, {
        caseTenantId: value
      });
    };

    return o$1(TextfieldEntry, {
      element: element,
      id: "calledElementCaseTenantId",
      label: translate('Tenant ID'),
      getValue: getValue,
      setValue: setValue,
      debounce: debounce
    });
  }

  function DelegateVariableMappingProps(props) {
    const {
      element
    } = props;
    const entries = [{
      id: 'calledElementDelegateVariableMappingType',
      component: DelegateVariableMappingType,
      isEdited: isEdited$4
    }];
    const type = getDelegateVariableMappingType(element);

    if (type === 'class') {
      entries.push({
        id: 'calledElementVariableMappingClass',
        component: VariableMappingClass,
        isEdited: isEdited$1
      });
    } else if (type === 'delegateExpression') {
      entries.push({
        id: 'calledElementVariableMappingDelegateExpression',
        component: VariableMappingDelegateExpression,
        isEdited: isEdited$1
      });
    }

    return entries;
  }
  const DEFAULT_PROPS$5 = {
    'camunda:variableMappingClass': undefined,
    'camunda:variableMappingDelegateExpression': undefined
  };

  function DelegateVariableMappingType(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');

    const getValue = () => {
      return getDelegateVariableMappingType(element);
    };

    const setValue = value => {
      const properties = { ...DEFAULT_PROPS$5
      };

      if (value === 'class') {
        properties['camunda:variableMappingClass'] = '';
      } else if (value === 'delegateExpression') {
        properties['camunda:variableMappingDelegateExpression'] = '';
      }

      commandStack.execute('element.updateProperties', {
        element,
        properties
      });
    };

    const getOptions = () => [{
      value: 'none',
      label: translate('<none>')
    }, {
      value: 'class',
      label: translate('Class')
    }, {
      value: 'delegateExpression',
      label: translate('Delegate expression')
    }];

    return o$1(SelectEntry, {
      element: element,
      id: "calledElementDelegateVariableMappingType",
      label: translate('Delegate Variable Mapping'),
      getValue: getValue,
      setValue: setValue,
      getOptions: getOptions
    });
  }

  function VariableMappingDelegateExpression(props) {
    const {
      element
    } = props;
    const modeling = useService('modeling');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return getBusinessObject$1(element).get('camunda:variableMappingDelegateExpression');
    };

    const setValue = value => {
      modeling.updateProperties(element, {
        variableMappingDelegateExpression: value || '',
        variableMappingClass: undefined
      });
    };

    return o$1(TextfieldEntry, {
      element: element,
      id: "calledElementVariableMappingDelegateExpression",
      label: translate('Delegate Expression'),
      getValue: getValue,
      setValue: setValue,
      debounce: debounce
    });
  }

  function VariableMappingClass(props) {
    const {
      element
    } = props;
    const modeling = useService('modeling');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return getBusinessObject$1(element).get('camunda:variableMappingClass');
    };

    const setValue = value => {
      modeling.updateProperties(element, {
        variableMappingDelegateExpression: undefined,
        variableMappingClass: value || ''
      });
    };

    return o$1(TextfieldEntry, {
      element: element,
      id: "calledElementVariableMappingClass",
      label: translate('Delegate Class'),
      getValue: getValue,
      setValue: setValue,
      debounce: debounce
    });
  } // helper /////


  function getDelegateVariableMappingType(element) {
    const businessObject = getBusinessObject$1(element);

    if (businessObject.get('camunda:variableMappingClass') !== undefined) {
      return 'class';
    } else if (businessObject.get('camunda:variableMappingDelegateExpression') !== undefined) {
      return 'delegateExpression';
    }

    return 'none';
  }

  function CallActivityProps(props) {
    const {
      element
    } = props;

    if (!is$4(element, 'bpmn:CallActivity')) {
      return [];
    }

    const entries = [];
    entries.push({
      id: 'calledElementType',
      component: CalledElementType,
      isEdited: isEdited$4
    });
    const calledElementType = getCalledElementType(element);

    if (calledElementType === 'bpmn') {
      entries.push(...CalledBpmnProps({
        element
      }), ...BusinessKeyProps({
        element
      }), ...DelegateVariableMappingProps({
        element
      }));
    } else if (calledElementType === 'cmmn') {
      entries.push(...CalledCmmnProps({
        element
      }), ...BusinessKeyProps({
        element
      }));
    } else {
      entries.push(...BusinessKeyProps({
        element
      }));
    }

    return entries;
  }
  const DEFAULT_PROPS$4 = {
    calledElement: undefined,
    'camunda:calledElementBinding': undefined,
    'camunda:calledElementVersion': undefined,
    'camunda:calledElementTenantId': undefined,
    'camunda:variableMappingClass': undefined,
    'camunda:variableMappingDelegateExpression': undefined,
    'camunda:caseRef': undefined,
    'camunda:caseBinding': undefined,
    'camunda:caseVersion': undefined,
    'camunda:caseTenantId': undefined
  };
  const DEFAULT_BUSINESS_KEY = '#{execution.processBusinessKey}';

  function CalledElementType(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');

    const getValue = () => {
      return getCalledElementType(element);
    };

    const setValue = value => {
      const properties = { ...DEFAULT_PROPS$4
      };

      if (value === 'bpmn') {
        properties['calledElement'] = '';
      } else if (value === 'cmmn') {
        properties['camunda:caseRef'] = '';
      }

      commandStack.execute('element.updateProperties', {
        element,
        properties
      });
    };

    const getOptions = () => [{
      value: '',
      label: translate('<none>')
    }, {
      value: 'bpmn',
      label: translate('BPMN')
    }, {
      value: 'cmmn',
      label: translate('CMMN')
    }];

    return o$1(SelectEntry, {
      element: element,
      id: "calledElementType",
      label: translate('Type'),
      getValue: getValue,
      setValue: setValue,
      getOptions: getOptions
    });
  }

  function BusinessKeyProps(props) {
    const {
      element
    } = props;
    const entries = [{
      id: 'calledElementBusinessKey',
      component: BusinessKey,
      isEdited: isEdited$7
    }];

    if (hasBusinessKey(element)) {
      entries.push({
        id: 'calledElementBusinessKeyExpression',
        component: BusinessKeyExpression,
        isEdited: isEdited$1
      });
    }

    return entries;
  }

  function BusinessKey(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const modeling = useService('modeling');
    const bpmnFactory = useService('bpmnFactory');
    const translate = useService('translate');

    const getValue = () => {
      return hasBusinessKey(element);
    };

    const setValue = value => {
      if (value) {
        addBusinessKey();
      } else {
        removeBusinessKey();
      }
    };

    function addBusinessKey() {
      const businessObject = getBusinessObject$1(element);
      let extensionElements = businessObject.get('extensionElements'); // (1) If there are no extension elements, create camunda:In and update element's properties

      if (!extensionElements) {
        extensionElements = createElement('bpmn:ExtensionElements', {}, businessObject, bpmnFactory);
        const businessKeyItem = createBusinessKey(extensionElements);
        extensionElements.set('values', [businessKeyItem]);
        modeling.updateProperties(element, {
          extensionElements
        });
      } else {
        // (2) Otherwise, add camunda:In to the existing values
        const businessKeyItem = createBusinessKey(extensionElements);
        addExtensionElements(element, businessObject, businessKeyItem, bpmnFactory, commandStack);
      }
    }

    function createBusinessKey(parent) {
      return createElement('camunda:In', {
        businessKey: DEFAULT_BUSINESS_KEY
      }, parent, bpmnFactory);
    }

    function removeBusinessKey() {
      const businessObject = getBusinessObject$1(element);
      const camundaInList = getExtensionElementsList(businessObject, 'camunda:In');
      const businessKeyItems = camundaInList.filter(camundaIn => camundaIn.get('businessKey') !== undefined);
      removeExtensionElements(element, businessObject, businessKeyItems, commandStack);
    }

    return o$1(CheckboxEntry, {
      element: element,
      id: "calledElementBusinessKey",
      label: translate('Business key'),
      getValue: getValue,
      setValue: setValue
    });
  }

  function BusinessKeyExpression(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => getBusinessKey(element);

    const setValue = value => {
      const camundaIn = findCamundaInWithBusinessKey(element);
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: camundaIn,
        properties: {
          businessKey: value || ''
        }
      });
    };

    return o$1(TextfieldEntry, {
      element: element,
      id: "calledElementBusinessKeyExpression",
      label: translate('Business key expression'),
      getValue: getValue,
      setValue: setValue,
      debounce: debounce
    });
  } // helper //////


  function getCalledElementType(element) {
    const businessObject = getBusinessObject$1(element);

    if (businessObject.get('calledElement') !== undefined) {
      return 'bpmn';
    } else if (businessObject.get('camunda:caseRef') !== undefined) {
      return 'cmmn';
    }

    return '';
  }

  function hasBusinessKey(element) {
    return getBusinessKey(element) !== undefined;
  }

  function getBusinessKey(element) {
    const camundaIn = findCamundaInWithBusinessKey(element);

    if (camundaIn) {
      return camundaIn.get('businessKey');
    }
  }

  function findCamundaInWithBusinessKey(element) {
    const businessObject = getBusinessObject$1(element);
    const camundaInList = getExtensionElementsList(businessObject, 'camunda:In');

    for (const camundaIn of camundaInList) {
      const businessKey = camundaIn.get('businessKey');

      if (businessKey !== undefined) {
        return camundaIn;
      }
    }
  }

  function CandidateStarterProps(props) {
    const {
      element
    } = props;
    const businessObject = getBusinessObject$1(element);

    if (!is$4(element, 'bpmn:Process') && !(is$4(element, 'bpmn:Participant') && businessObject.get('processRef'))) {
      return [];
    }

    return [{
      id: 'candidateStarterGroups',
      component: CandidateStarterGroups,
      isEdited: isEdited$1
    }, {
      id: 'candidateStarterUsers',
      component: CandidateStarterUsers,
      isEdited: isEdited$1
    }];
  }

  function CandidateStarterGroups(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack'),
          translate = useService('translate'),
          debounce = useService('debounceInput');
    const process = getProcess$3(element);

    const getValue = () => {
      return process.get('camunda:candidateStarterGroups') || '';
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element: element,
        moddleElement: process,
        properties: {
          'camunda:candidateStarterGroups': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'candidateStarterGroups',
      label: translate('Candidate starter groups'),
      description: translate('Specify more than one group as a comma separated list.'),
      getValue,
      setValue,
      debounce
    });
  }

  function CandidateStarterUsers(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack'),
          translate = useService('translate'),
          debounce = useService('debounceInput');
    const process = getProcess$3(element);

    const getValue = () => {
      return process.get('camunda:candidateStarterUsers') || '';
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element: element,
        moddleElement: process,
        properties: {
          'camunda:candidateStarterUsers': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'candidateStarterUsers',
      label: translate('Candidate starter users'),
      description: translate('Specify more than one user as a comma separated list.'),
      getValue,
      setValue,
      debounce
    });
  } // helper //////////////////

  /**
   * getProcess - get the businessObject of the process referred to by a bpmn:Process
   * or by a bpmn:Participant
   *
   * @param  {ModdleElement} element either a bpmn:Process or a bpmn:Participant
   * @return {BusinessObject}
   */


  function getProcess$3(element) {
    return is$4(element, 'bpmn:Process') ? getBusinessObject$1(element) : getBusinessObject$1(element).get('processRef');
  }

  function ConditionProps(props) {
    const {
      element
    } = props;

    if (!(is$4(element, 'bpmn:SequenceFlow') && isConditionalSource(element.source)) && !getConditionalEventDefinition(element)) {
      return [];
    }

    const entries = [];

    if (getConditionalEventDefinition(element)) {
      entries.push(...VariableEventProps({
        element
      }));
    }

    entries.push({
      id: 'conditionType',
      component: ConditionType,
      isEdited: isEdited$4
    });
    const conditionType = getConditionType(element);

    if (conditionType === 'script') {
      entries.push(...ConditionScriptProps({
        element
      }));
    } else if (conditionType === 'expression') {
      entries.push({
        id: 'conditionExpression',
        component: ConditionExpression,
        isEdited: isEdited$1
      });
    }

    return entries;
  }

  function ConditionType(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const bpmnFactory = useService('bpmnFactory');
    const translate = useService('translate');

    const getValue = () => {
      return getConditionType(element);
    };

    const setValue = value => {
      // (1) Remove formalExpression if <none> is selected
      if (value === '') {
        updateCondition(element, commandStack, undefined);
      } else {
        // (2) Create and set formalExpression element containing the conditionExpression
        const attributes = {
          body: '',
          language: value === 'script' ? '' : undefined
        };
        const formalExpressionElement = createFormalExpression(element, attributes, bpmnFactory);
        updateCondition(element, commandStack, formalExpressionElement);
      }
    };

    const getOptions = () => [{
      value: '',
      label: translate('<none>')
    }, {
      value: 'script',
      label: translate('Script')
    }, {
      value: 'expression',
      label: translate('Expression')
    }];

    return o$1(SelectEntry, {
      element: element,
      id: "conditionType",
      label: translate('Type'),
      getValue: getValue,
      setValue: setValue,
      getOptions: getOptions
    });
  }

  function ConditionExpression(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack'),
          bpmnFactory = useService('bpmnFactory'),
          translate = useService('translate'),
          debounce = useService('debounceInput');

    const getValue = () => {
      return getConditionExpression(element).get('body');
    };

    const setValue = value => {
      const conditionExpression = createFormalExpression(element, {
        body: value
      }, bpmnFactory);
      updateCondition(element, commandStack, conditionExpression);
    };

    return o$1(TextfieldEntry, {
      element: element,
      id: "conditionExpression",
      label: translate('Condition Expression'),
      getValue: getValue,
      setValue: setValue,
      debounce: debounce
    });
  }

  function ConditionScriptProps(props) {
    const {
      element
    } = props;
    const entries = [];
    const scriptType = getScriptType$1(element); // (1) language

    entries.push({
      id: 'conditionScriptLanguage',
      component: Language,
      isEdited: isEdited$1
    }); // (2) type

    entries.push({
      id: 'conditionScriptType',
      component: ScriptType,
      isEdited: isEdited$4
    }); // (3) script

    if (scriptType === 'script') {
      entries.push({
        id: 'conditionScriptValue',
        component: Script$1,
        isEdited: isEdited$2
      });
    } else if (scriptType === 'resource') {
      // (4) resource
      entries.push({
        id: 'conditionScriptResource',
        component: Resource$1,
        isEdited: isEdited$1
      });
    }

    return entries;
  }

  function Language(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return getConditionExpression(element).get('language');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element: element,
        moddleElement: getConditionExpression(element),
        properties: {
          language: value || ''
        }
      });
    };

    return o$1(TextfieldEntry, {
      element: element,
      id: "conditionScriptLanguage",
      label: translate('Format'),
      getValue: getValue,
      setValue: setValue,
      debounce: debounce
    });
  }

  function ScriptType(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');

    const getValue = () => {
      return getScriptType$1(element);
    };

    const setValue = value => {
      // reset script properties on type change
      const updatedProperties = {
        'body': value === 'script' ? '' : undefined,
        'camunda:resource': value === 'resource' ? '' : undefined
      };
      commandStack.execute('element.updateModdleProperties', {
        element: element,
        moddleElement: getConditionExpression(element),
        properties: updatedProperties
      });
    };

    const getOptions = () => {
      const options = [{
        value: 'resource',
        label: translate('External resource')
      }, {
        value: 'script',
        label: translate('Inline script')
      }];
      return options;
    };

    return SelectEntry({
      element,
      id: 'conditionScriptType',
      label: translate('Script type'),
      getValue,
      setValue,
      getOptions
    });
  }

  function Script$1(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return getConditionExpression(element).get('body');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element: element,
        moddleElement: getConditionExpression(element),
        properties: {
          'body': value || ''
        }
      });
    };

    return o$1(TextAreaEntry, {
      element: element,
      id: "conditionScriptValue",
      label: translate('Script'),
      getValue: getValue,
      setValue: setValue,
      debounce: debounce,
      monospace: true
    });
  }

  function Resource$1(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return getConditionExpression(element).get('camunda:resource');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element: element,
        moddleElement: getConditionExpression(element),
        properties: {
          'camunda:resource': value || ''
        }
      });
    };

    return o$1(TextfieldEntry, {
      element: true,
      id: "conditionScriptResource",
      label: translate('Resource'),
      getValue: getValue,
      setValue: setValue,
      debounce: debounce
    });
  }

  function VariableEventProps(props) {
    const {
      element
    } = props;
    const entries = [];
    entries.push({
      id: 'conditionVariableName',
      component: VariableName,
      isEdited: isEdited$1
    });

    if (!is$4(element, 'bpmn:StartEvent')) {
      entries.push({
        id: 'conditionVariableEvents',
        component: VariableEvents,
        isEdited: isEdited$1
      });
    }

    return entries;
  }

  function VariableName(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return getConditionalEventDefinition(element).get('variableName');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element: element,
        moddleElement: getConditionalEventDefinition(element),
        properties: {
          variableName: value || ''
        }
      });
    };

    return o$1(TextfieldEntry, {
      element: element,
      id: "conditionVariableName",
      label: translate('Variable name'),
      getValue: getValue,
      setValue: setValue,
      debounce: debounce
    });
  }

  function VariableEvents(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return getConditionalEventDefinition(element).get('variableEvents');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element: element,
        moddleElement: getConditionalEventDefinition(element),
        properties: {
          variableEvents: value || ''
        }
      });
    };

    return o$1(TextfieldEntry, {
      element: element,
      id: "conditionVariableEvents",
      label: translate('Variable events'),
      description: translate('Specify more than one variable change event as a comma separated list.'),
      getValue: getValue,
      setValue: setValue,
      debounce: debounce
    });
  } // helper ////////////////////


  const CONDITIONAL_SOURCES = ['bpmn:Activity', 'bpmn:ExclusiveGateway', 'bpmn:InclusiveGateway', 'bpmn:ComplexGateway'];

  function isConditionalSource(element) {
    return isAny(element, CONDITIONAL_SOURCES);
  }

  function getConditionalEventDefinition(element) {
    if (!is$4(element, 'bpmn:Event')) {
      return false;
    }

    return getEventDefinition$1(element, 'bpmn:ConditionalEventDefinition');
  }

  function getConditionType(element) {
    const conditionExpression = getConditionExpression(element);

    if (!conditionExpression) {
      return '';
    } else {
      return conditionExpression.get('language') === undefined ? 'expression' : 'script';
    }
  }
  /**
   * getConditionExpression - get the body value of a condition expression for a given element
   *
   * @param  {ModdleElement} element
   *
   * @return {string|undefined}
   */


  function getConditionExpression(element) {
    const businessObject = getBusinessObject$1(element);

    if (is$4(businessObject, 'bpmn:SequenceFlow')) {
      return businessObject.get('conditionExpression');
    } else if (getConditionalEventDefinition(businessObject)) {
      return getConditionalEventDefinition(businessObject).get('condition');
    }
  }

  function getScriptType$1(element) {
    const conditionExpression = getConditionExpression(element);
    const resource = conditionExpression.get('camunda:resource');

    if (typeof resource !== 'undefined') {
      return 'resource';
    } else {
      return 'script';
    }
  }

  function updateCondition(element, commandStack, condition = undefined) {
    if (is$4(element, 'bpmn:SequenceFlow')) {
      commandStack.execute('element.updateProperties', {
        element,
        properties: {
          conditionExpression: condition
        }
      });
    } else {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: getConditionalEventDefinition(element),
        properties: {
          condition
        }
      });
    }
  }

  function createFormalExpression(parent, attributes, bpmnFactory) {
    return createElement('bpmn:FormalExpression', attributes, is$4(parent, 'bpmn:SequenceFlow') ? getBusinessObject$1(parent) : getConditionalEventDefinition(parent), bpmnFactory);
  }

  /**
   * Cf. https://docs.camunda.org/manual/latest/user-guide/process-engine/scripting/
   */

  function ScriptProps(props) {
    const {
      element,
      script,
      prefix
    } = props;
    const entries = [];
    const scriptType = getScriptType(script || element);
    const idPrefix = prefix || ''; // (1) scriptFormat

    entries.push({
      id: idPrefix + 'scriptFormat',
      component: Format,
      isEdited: isEdited$1,
      idPrefix,
      script
    }); // (2) type

    entries.push({
      id: idPrefix + 'scriptType',
      component: Type$3,
      isEdited: isEdited$4,
      idPrefix,
      script
    }); // (3) script

    if (scriptType === 'script') {
      entries.push({
        id: idPrefix + 'scriptValue',
        component: Script,
        isEdited: isEdited$2,
        idPrefix,
        script
      });
    } // (4) resource


    if (scriptType === 'resource') {
      entries.push({
        id: idPrefix + 'scriptResource',
        component: Resource,
        isEdited: isEdited$1,
        idPrefix,
        script
      });
    }

    return entries;
  }

  function Format(props) {
    const {
      element,
      idPrefix,
      script
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const businessObject = script || getBusinessObject$1(element);

    const getValue = () => {
      return businessObject.get('scriptFormat');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          scriptFormat: value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: idPrefix + 'scriptFormat',
      label: translate('Format'),
      getValue,
      setValue,
      debounce
    });
  }

  function Type$3(props) {
    const {
      element,
      idPrefix,
      script
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const businessObject = script || getBusinessObject$1(element);
    const scriptProperty = getScriptProperty(businessObject);

    const getValue = () => {
      return getScriptType(businessObject);
    };

    const setValue = value => {
      // reset script properties on type change
      const properties = {
        [scriptProperty]: value === 'script' ? '' : undefined,
        'camunda:resource': value === 'resource' ? '' : undefined
      };
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties
      });
    };

    const getOptions = () => {
      const options = [{
        value: '',
        label: translate('<none>')
      }, {
        value: 'resource',
        label: translate('External resource')
      }, {
        value: 'script',
        label: translate('Inline script')
      }];
      return options;
    };

    return SelectEntry({
      element,
      id: idPrefix + 'scriptType',
      label: translate('Type'),
      getValue,
      setValue,
      getOptions
    });
  }

  function Script(props) {
    const {
      element,
      idPrefix,
      script
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const businessObject = script || getBusinessObject$1(element);
    const scriptProperty = getScriptProperty(businessObject);

    const getValue = () => {
      return getScriptValue(businessObject);
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          [scriptProperty]: value || ''
        }
      });
    };

    return TextAreaEntry({
      element,
      id: idPrefix + 'scriptValue',
      label: translate('Script'),
      getValue,
      setValue,
      debounce,
      monospace: true
    });
  }

  function Resource(props) {
    const {
      element,
      idPrefix,
      script
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const businessObject = script || getBusinessObject$1(element);

    const getValue = () => {
      return businessObject.get('camunda:resource');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:resource': value || ''
        }
      });
    };

    return TextfieldEntry({
      element,
      id: idPrefix + 'scriptResource',
      label: translate('Resource'),
      getValue,
      setValue,
      debounce
    });
  } // helper ////////////////////


  function getScriptType(element) {
    const businessObject = getBusinessObject$1(element);
    const scriptValue = getScriptValue(businessObject);

    if (typeof scriptValue !== 'undefined') {
      return 'script';
    }

    const resource = businessObject.get('camunda:resource');

    if (typeof resource !== 'undefined') {
      return 'resource';
    }
  }

  function getScriptValue(businessObject) {
    return businessObject.get(getScriptProperty(businessObject));
  }

  function isScript$2(element) {
    return is$4(element, 'camunda:Script');
  }

  function getScriptProperty(businessObject) {
    return isScript$2(businessObject) ? 'value' : 'script';
  }

  function getElements$1(businessObject, type, property) {
    const elements = getExtensionElementsList(businessObject, type);
    return !property ? elements : (elements[0] || {})[property] || [];
  }

  function getParameters$1(element, prop) {
    const inputOutput = getInputOutput$1(element);
    return inputOutput && inputOutput.get(prop) || [];
  }
  /**
   * Get a camunda:inputOutput from the business object
   *
   * @param {djs.model.Base | ModdleElement} element
   *
   * @return {ModdleElement} the inputOutput object
   */


  function getInputOutput$1(element) {
    if (is$4(element, 'camunda:Connector')) {
      return element.get('inputOutput');
    }

    const businessObject = getBusinessObject$1(element);
    return (getElements$1(businessObject, 'camunda:InputOutput') || [])[0];
  }
  /**
   * Return all input parameters existing in the business object, and
   * an empty array if none exist.
   *
   * @param  {djs.model.Base} element
   *
   * @return {Array} a list of input parameter objects
   */

  function getInputParameters$1(element) {
    return getParameters$1(element, 'inputParameters');
  }
  /**
   * Return all output parameters existing in the business object, and
   * an empty array if none exist.
   *
   * @param  {djs.model.Base} element
   *
   * @return {Array} a list of output parameter objects
   */

  function getOutputParameters$1(element) {
    return getParameters$1(element, 'outputParameters');
  }
  function isInputOutputSupported(element) {
    const businessObject = getBusinessObject$1(element);
    return is$4(businessObject, 'bpmn:FlowNode') && !(isAny(businessObject, ['bpmn:StartEvent', 'bpmn:BoundaryEvent', 'bpmn:Gateway']) || is$4(businessObject, 'bpmn:SubProcess') && businessObject.get('triggeredByEvent'));
  }
  function areInputParametersSupported(element) {
    return isInputOutputSupported(element);
  }
  function areOutputParametersSupported(element) {
    const businessObject = getBusinessObject$1(element);
    return isInputOutputSupported(element) && !is$4(businessObject, 'bpmn:EndEvent') && !businessObject.loopCharacteristics;
  }
  function getInputOutputType(parameter) {
    const definitionTypes = {
      'camunda:Map': 'map',
      'camunda:List': 'list',
      'camunda:Script': 'script'
    };
    let type = 'stringOrExpression';
    const definition = parameter.get('definition');

    if (typeof definition !== 'undefined') {
      type = definitionTypes[definition.$type];
    }

    return type;
  }
  function CreateParameterCmd(element, type, parent, bpmnFactory) {
    const isInput = type === 'camunda:InputParameter';
    const newParameter = createElement(type, {
      name: nextId(isInput ? 'Input_' : 'Output_')
    }, parent, bpmnFactory);
    const propertyName = isInput ? 'inputParameters' : 'outputParameters';
    return {
      cmd: 'element.updateModdleProperties',
      context: {
        element,
        moddleElement: parent,
        properties: {
          [propertyName]: [...parent.get(propertyName), newParameter]
        }
      }
    };
  }
  function AddParameterCmd(element, type, bpmnFactory) {
    const commands = [];
    const businessObject = getBusinessObject$1(element);
    let extensionElements = businessObject.get('extensionElements'); // (1) ensure extension elements

    if (!extensionElements) {
      extensionElements = createElement('bpmn:ExtensionElements', {
        values: []
      }, businessObject, bpmnFactory);
      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: businessObject,
          properties: {
            extensionElements
          }
        }
      });
    } // (2) ensure inputOutput


    let inputOutput = getInputOutput$1(element);

    if (!inputOutput) {
      const parent = extensionElements;
      inputOutput = createElement('camunda:InputOutput', {
        inputParameters: [],
        outputParameters: []
      }, parent, bpmnFactory);
      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: extensionElements,
          properties: {
            values: [...extensionElements.get('values'), inputOutput]
          }
        }
      });
    } // (3) create + add parameter


    commands.push(CreateParameterCmd(element, type, inputOutput, bpmnFactory));
    return commands;
  }

  function ListProp(props) {
    const {
      element,
      id: idPrefix,
      index,
      item
    } = props;
    const id = `${idPrefix}-listItem-${index}`;
    return o$1(ListItem, {
      idPrefix: id,
      element: element,
      item: item
    });
  }

  function ListProps(props) {
    const {
      idPrefix,
      element,
      parameter
    } = props;
    const bpmnFactory = useService('bpmnFactory');
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const list = parameter.get('definition');
    const items = list.get('items');

    function addItem() {
      const value = createElement('camunda:Value', {}, parameter, bpmnFactory);
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: list,
        properties: {
          items: [...list.get('items'), value]
        }
      });
    }

    function removeItem(item) {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: list,
        properties: {
          items: without(list.get('items'), item)
        }
      });
    }

    function compareFn(item, anotherItem) {
      const [value = '', anotherValue = ''] = [item.value, anotherItem.value];
      return value === anotherValue ? 0 : value > anotherValue ? 1 : -1;
    }

    return List({
      element,
      autoFocusEntry: true,
      compareFn,
      id: idPrefix + '-list',
      items,
      label: translate('List values'),
      onAdd: addItem,
      onRemove: removeItem,
      component: ListProp
    });
  }

  function ListItem(props) {
    const {
      idPrefix,
      element,
      item
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const definitionLabels = {
      'camunda:Map': translate('Map'),
      'camunda:List': translate('List'),
      'camunda:Script': translate('Script')
    };

    const getValue = () => {
      if (isDefinitionType$1(item)) {
        return definitionLabels[item.$type];
      }

      return item.get('value');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: item,
        properties: {
          value
        }
      });
    };

    return ListValue({
      id: idPrefix + '-value',
      disabled: isDefinitionType$1(item),
      getValue,
      setValue
    });
  }

  function ListValue(props) {
    const {
      id,
      disabled,
      getValue,
      setValue
    } = props;
    const debounce = useService('debounceInput', true);
    return o$1(Simple, {
      id: id,
      getValue: getValue,
      setValue: setValue,
      disabled: disabled,
      debounce: debounce
    });
  } // helper //////////////////////


  function isScript$1(element) {
    return is$4(element, 'camunda:Script');
  }

  function isList$1(element) {
    return is$4(element, 'camunda:List');
  }

  function isMap$1(element) {
    return is$4(element, 'camunda:Map');
  }

  function isDefinitionType$1(element) {
    return isScript$1(element) || isList$1(element) || isMap$1(element);
  }

  function MapProp(props) {
    const {
      element,
      id: idPrefix,
      index,
      item: entry,
      open
    } = props;
    const id = `${idPrefix}-mapEntry-${index}`;
    const translate = useService('translate');
    return o$1(CollapsibleEntry, {
      id: id,
      element: element,
      entries: MapEntry({
        element,
        entry,
        idPrefix: id
      }),
      label: entry.get('key') || translate('<empty>'),
      open: open
    });
  }

  function MapProps(props) {
    const {
      idPrefix,
      element,
      parameter
    } = props;
    const bpmnFactory = useService('bpmnFactory');
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const map = parameter.get('definition');
    const entries = map.get('entries');

    function addEntry() {
      const entry = createElement('camunda:Entry', {}, parameter, bpmnFactory);
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: map,
        properties: {
          entries: [...map.get('entries'), entry]
        }
      });
    }

    function removeEntry(entry) {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: map,
        properties: {
          entries: without(map.get('entries'), entry)
        }
      });
    }

    function compareFn(entry, anotherEntry) {
      const [key = '', anotherKey = ''] = [entry.key, anotherEntry.key];
      return key === anotherKey ? 0 : key > anotherKey ? 1 : -1;
    }

    return List({
      element,
      autoFocusEntry: true,
      compareFn,
      id: idPrefix + '-map',
      items: entries,
      label: translate('Map entries'),
      onAdd: addEntry,
      onRemove: removeEntry,
      component: MapProp
    });
  }

  function MapEntry(props) {
    const {
      element,
      entry,
      idPrefix
    } = props;
    const entries = [{
      id: idPrefix + '-key',
      component: MapKey,
      entry,
      idPrefix,
      element
    }, {
      id: idPrefix + '-value',
      component: MapValue,
      entry,
      idPrefix,
      element
    }];
    return entries;
  }

  function MapKey(props) {
    const {
      element,
      entry,
      idPrefix
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: entry,
        properties: {
          key: value
        }
      });
    };

    const getValue = () => {
      return entry.get('key');
    };

    return TextfieldEntry({
      element: entry,
      id: idPrefix + '-key',
      label: translate('Key'),
      getValue,
      setValue,
      debounce
    });
  }

  function MapValue(props) {
    const {
      element,
      entry,
      idPrefix
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const definition = entry.get('definition');
    const definitionLabels = {
      'camunda:Map': translate('Map'),
      'camunda:List': translate('List'),
      'camunda:Script': translate('Script')
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: entry,
        properties: {
          value
        }
      });
    };

    const getValue = () => {
      if (isDefinitionType(definition)) {
        return definitionLabels[definition.$type];
      }

      return entry.get('value');
    };

    return TextfieldEntry({
      element: entry,
      id: idPrefix + '-value',
      label: translate('Value'),
      getValue,
      setValue,
      disabled: isDefinitionType(definition),
      debounce
    });
  } // helper ///////////////////


  function isScript(element) {
    return is$4(element, 'camunda:Script');
  }

  function isList(element) {
    return is$4(element, 'camunda:List');
  }

  function isMap(element) {
    return is$4(element, 'camunda:Map');
  }

  function isDefinitionType(element) {
    return isScript(element) || isList(element) || isMap(element);
  }

  const DEFAULT_PROPS$3 = {
    value: undefined,
    definition: undefined
  };
  function InputOutputParameter(props) {
    const {
      idPrefix,
      element,
      parameter
    } = props;
    const inputOutputType = getInputOutputType(parameter);
    let entries = [{
      id: idPrefix + '-name',
      component: Name$2,
      isEdited: isEdited$1,
      idPrefix,
      parameter
    }, {
      id: idPrefix + '-type',
      component: Type$2,
      isEdited: isEdited$4,
      idPrefix,
      parameter
    }]; // (1) String or expression

    if (inputOutputType === 'stringOrExpression') {
      entries.push({
        id: idPrefix + '-stringOrExpression',
        component: StringOrExpression,
        isEdited: isEdited$2,
        idPrefix,
        parameter
      }); // (2) Script
    } else if (inputOutputType === 'script') {
      const script = parameter.get('definition');
      entries = [...entries, ...ScriptProps({
        element,
        prefix: idPrefix + '-',
        script
      })]; // (3) List
    } else if (inputOutputType === 'list') {
      entries.push({
        id: `${idPrefix}-list`,
        component: ListProps,
        idPrefix,
        parameter
      }); // (4) Map
    } else if (inputOutputType === 'map') {
      entries.push({
        id: `${idPrefix}-map`,
        component: MapProps,
        idPrefix,
        parameter
      });
    }

    return entries;
  }

  function Name$2(props) {
    const {
      idPrefix,
      element,
      parameter
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: parameter,
        properties: {
          name: value
        }
      });
    };

    const getValue = parameter => {
      return parameter.get('name');
    };

    return TextfieldEntry({
      element: parameter,
      id: idPrefix + '-name',
      label: translate(isInput(parameter) ? 'Local variable name' : 'Process variable name'),
      getValue,
      setValue,
      debounce
    });
  }

  function Type$2(props) {
    const {
      idPrefix,
      element,
      parameter
    } = props;
    const bpmnFactory = useService('bpmnFactory');
    const commandStack = useService('commandStack');
    const translate = useService('translate');

    const createDefinitionElement = type => {
      return createElement(type, {}, parameter, bpmnFactory);
    };

    const getValue = mapping => {
      return getInputOutputType(mapping);
    };

    const setValue = value => {
      let properties = { ...DEFAULT_PROPS$3
      };

      if (value === 'script') {
        properties.definition = createDefinitionElement('camunda:Script');
      } else if (value === 'list') {
        properties.definition = createDefinitionElement('camunda:List');
      } else if (value === 'map') {
        properties.definition = createDefinitionElement('camunda:Map');
      }

      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: parameter,
        properties
      });
    };

    const getOptions = () => {
      const options = [{
        label: translate('List'),
        value: 'list'
      }, {
        label: translate('Map'),
        value: 'map'
      }, {
        label: translate('Script'),
        value: 'script'
      }, {
        label: translate('String or expression'),
        value: 'stringOrExpression'
      }];
      return options;
    };

    return SelectEntry({
      element: parameter,
      id: idPrefix + '-type',
      label: translate('Assignment type'),
      getValue,
      setValue,
      getOptions
    });
  }

  function StringOrExpression(props) {
    const {
      idPrefix,
      element,
      parameter
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: parameter,
        properties: {
          value
        }
      });
    };

    const getValue = parameter => {
      return parameter.get('value');
    };

    return TextAreaEntry({
      element: parameter,
      id: idPrefix + '-stringOrExpression',
      label: translate('Value'),
      description: translate('Start typing "${}" to create an expression.'),
      getValue,
      setValue,
      rows: 1,
      debounce
    });
  } // helper /////////////////////


  function isInput(parameter) {
    return is$4(parameter, 'camunda:InputParameter');
  }

  /**
   * Check whether an element is camunda:ServiceTaskLike
   *
   * @param {djs.model.Base} element
   *
   * @return {boolean} a boolean value
   */

  function isServiceTaskLike(element) {
    return is$4(element, 'camunda:ServiceTaskLike');
  }
  /**
   * Returns 'true' if the given element is 'camunda:DmnCapable'
   *
   * @param {djs.model.Base} element
   *
   * @return {boolean} a boolean value
   */

  function isDmnCapable(element) {
    return is$4(element, 'camunda:DmnCapable');
  }
  /**
   * Returns 'true' if the given element is 'camunda:ExternalCapable'
   *
   * @param {djs.model.Base} element
   *
   * @return {boolean} a boolean value
   */

  function isExternalCapable(element) {
    return is$4(element, 'camunda:ExternalCapable');
  }
  /**
   * getServiceTaskLikeBusinessObject - Get a 'camunda:ServiceTaskLike' business object.
   *
   * If the given element is not a 'camunda:ServiceTaskLike', then 'false'
   * is returned.
   *
   * @param {djs.model.Base} element
   * @return {ModdleElement} the 'camunda:ServiceTaskLike' business object
   */

  function getServiceTaskLikeBusinessObject(element) {
    if (is$4(element, 'bpmn:IntermediateThrowEvent') || is$4(element, 'bpmn:EndEvent')) {
      // change business object to 'messageEventDefinition' when
      // the element is a message intermediate throw event or message end event
      // because the camunda extensions (e.g. camunda:class) are in the message
      // event definition tag and not in the intermediate throw event or end event tag
      const messageEventDefinition = getMessageEventDefinition(element);

      if (messageEventDefinition) {
        element = messageEventDefinition;
      }
    }

    return isServiceTaskLike(element) && getBusinessObject$1(element);
  }
  /**
   * Returns the implementation type of the given element.
   *
   * Possible implementation types are:
   * - dmn
   * - connector
   * - external
   * - class
   * - expression
   * - delegateExpression
   * - script
   * - or undefined, when no matching implementation type is found
   *
   * @param  {djs.model.Base} element
   *
   * @return {String} the implementation type
   */

  function getImplementationType(element) {
    const businessObject = getListenerBusinessObject(element) || getServiceTaskLikeBusinessObject(element);

    if (!businessObject) {
      return;
    }

    if (isDmnCapable(businessObject)) {
      const decisionRef = businessObject.get('camunda:decisionRef');

      if (typeof decisionRef !== 'undefined') {
        return 'dmn';
      }
    }

    if (isServiceTaskLike(businessObject)) {
      const connectors = getExtensionElementsList(businessObject, 'camunda:Connector');

      if (connectors.length) {
        return 'connector';
      }
    }

    if (isExternalCapable(businessObject)) {
      const type = businessObject.get('camunda:type');

      if (type === 'external') {
        return 'external';
      }
    }

    const cls = businessObject.get('camunda:class');

    if (typeof cls !== 'undefined') {
      return 'class';
    }

    const expression = businessObject.get('camunda:expression');

    if (typeof expression !== 'undefined') {
      return 'expression';
    }

    const delegateExpression = businessObject.get('camunda:delegateExpression');

    if (typeof delegateExpression !== 'undefined') {
      return 'delegateExpression';
    }

    const script = businessObject.get('script');

    if (typeof script !== 'undefined') {
      return 'script';
    }
  }

  function getListenerBusinessObject(businessObject) {
    if (isAny(businessObject, ['camunda:ExecutionListener', 'camunda:TaskListener'])) {
      return businessObject;
    }
  }

  function areConnectorsSupported(element) {
    const businessObject = getServiceTaskLikeBusinessObject(element);
    return businessObject && getImplementationType(businessObject) === 'connector';
  }
  function getConnectors$2(businessObject) {
    return getExtensionElementsList(businessObject, 'camunda:Connector');
  }
  function getConnector$1(element) {
    const businessObject = getServiceTaskLikeBusinessObject(element);
    const connectors = getConnectors$2(businessObject);
    return connectors[0];
  }

  function ConnectorInputProps(props) {
    const {
      element,
      injector
    } = props;

    if (!areConnectorsSupported(element)) {
      return null;
    }

    const connector = getConnector$1(element);
    const commandStack = injector.get('commandStack'),
          bpmnFactory = injector.get('bpmnFactory');
    const inputParameters = getInputParameters$1(connector) || [];
    const items = inputParameters.map((parameter, index) => {
      const id = element.id + '-connector-inputParameter-' + index;
      return {
        id,
        label: parameter.get('name') || '',
        entries: InputOutputParameter({
          element,
          idPrefix: id,
          parameter
        }),
        autoFocusEntry: id + '-name',
        remove: removeFactory$8({
          connector,
          element,
          parameter,
          commandStack
        })
      };
    });

    function add(event) {
      event.stopPropagation();
      const commands = []; // (1) ensure inputOutput

      let inputOutput = getInputOutput$1(connector);

      if (!inputOutput) {
        inputOutput = createElement('camunda:InputOutput', {
          inputParameters: [],
          outputParameters: []
        }, connector, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element: element,
            moddleElement: connector,
            properties: {
              inputOutput
            }
          }
        });
      } // (2) create + add parameter


      commands.push(CreateParameterCmd(element, 'camunda:InputParameter', inputOutput, bpmnFactory)); // (3) commit all updates

      commandStack.execute('properties-panel.multi-command-executor', commands);
    }

    return {
      items,
      add
    };
  }

  function removeFactory$8(props) {
    const {
      commandStack,
      connector,
      element,
      parameter
    } = props;
    return function (event) {
      event.stopPropagation();
      const inputOutput = getInputOutput$1(connector);

      if (!inputOutput) {
        return;
      }

      commandStack.execute('element.updateModdleProperties', {
        element: element,
        moddleElement: inputOutput,
        properties: {
          inputParameters: without(inputOutput.get('inputParameters'), parameter)
        }
      });
    };
  }

  function ConnectorOutputProps(props) {
    const {
      element,
      injector
    } = props;

    if (!areConnectorsSupported(element)) {
      return null;
    }

    const connector = getConnector$1(element);
    const commandStack = injector.get('commandStack'),
          bpmnFactory = injector.get('bpmnFactory');
    const outputParameters = getOutputParameters$1(connector) || [];
    const items = outputParameters.map((parameter, index) => {
      const id = element.id + '-connector-outputParameter-' + index;
      return {
        id,
        label: parameter.get('name') || '',
        entries: InputOutputParameter({
          idPrefix: id,
          element,
          parameter
        }),
        autoFocusEntry: id + '-name',
        remove: removeFactory$7({
          connector,
          element,
          commandStack,
          parameter
        })
      };
    });

    function add(event) {
      event.stopPropagation();
      const commands = []; // (1) ensure inputOutput

      let inputOutput = getInputOutput$1(connector);

      if (!inputOutput) {
        inputOutput = createElement('camunda:InputOutput', {
          inputParameters: [],
          outputParameters: []
        }, connector, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element: element,
            moddleElement: connector,
            properties: {
              inputOutput
            }
          }
        });
      } // (2) create + add parameter


      commands.push(CreateParameterCmd(element, 'camunda:OutputParameter', inputOutput, bpmnFactory)); // (3) commit all updates

      commandStack.execute('properties-panel.multi-command-executor', commands);
    }

    return {
      items,
      add
    };
  }

  function removeFactory$7(props) {
    const {
      commandStack,
      connector,
      element,
      parameter
    } = props;
    return function (event) {
      event.stopPropagation();
      const inputOutput = getInputOutput$1(connector);

      if (!inputOutput) {
        return;
      }

      commandStack.execute('element.updateModdleProperties', {
        element: element,
        moddleElement: inputOutput,
        properties: {
          outputParameters: without(inputOutput.get('outputParameters'), parameter)
        }
      });
    };
  }

  function ErrorProps(props) {
    const {
      element,
      entries
    } = props;

    if (!isErrorSupported(element)) {
      return entries;
    }

    const error = getError(element); // (1) errorMessage (error)

    if (error) {
      const idx = findPlaceToInsert(entries, 'errorCode'); // place below errorCode

      entries.splice(idx, 0, {
        id: 'errorMessage',
        component: ErrorMessage$1,
        isEdited: isEdited$1
      });
    }

    if (!canHaveErrorVariables(element)) {
      return entries;
    } // (2) errorCodeVariable + errorMessageVariable (errorEventDefinition)


    entries.push({
      id: 'errorCodeVariable',
      component: ErrorCodeVariable,
      isEdited: isEdited$1
    }, {
      id: 'errorMessageVariable',
      component: ErrorMessageVariable,
      isEdited: isEdited$1
    });
    return entries;
  }

  function ErrorMessage$1(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const error = getError(element);

    const getValue = () => {
      return error.get('camunda:errorMessage');
    };

    const setValue = value => {
      return commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: error,
        properties: {
          'camunda:errorMessage': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'errorMessage',
      label: translate('Message'),
      getValue,
      setValue,
      debounce
    });
  }

  function ErrorCodeVariable(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const errorEventDefinition = getErrorEventDefinition(element);

    const getValue = () => {
      return errorEventDefinition.get('camunda:errorCodeVariable');
    };

    const setValue = value => {
      return commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: errorEventDefinition,
        properties: {
          'camunda:errorCodeVariable': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'errorCodeVariable',
      label: translate('Code variable'),
      description: translate('Define the name of the variable that will contain the error code.'),
      getValue,
      setValue,
      debounce
    });
  }

  function ErrorMessageVariable(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const errorEventDefinition = getErrorEventDefinition(element);

    const getValue = () => {
      return errorEventDefinition.get('camunda:errorMessageVariable');
    };

    const setValue = value => {
      return commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: errorEventDefinition,
        properties: {
          'camunda:errorMessageVariable': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'errorMessageVariable',
      label: translate('Message variable'),
      description: translate('Define the name of the variable that will contain the error message.'),
      getValue,
      setValue,
      debounce
    });
  } // helper ///////////////////////


  function canHaveErrorVariables(element) {
    return is$4(element, 'bpmn:StartEvent') || is$4(element, 'bpmn:BoundaryEvent');
  }

  function findPlaceToInsert(entries, idx) {
    const entryIndex = findIndex(entries, entry => entry.id === idx);
    return entryIndex >= 0 ? entryIndex + 1 : entries.length;
  }

  const EMPTY_OPTION = '';
  const CREATE_NEW_OPTION = 'create-new';
  function Error$1(props) {
    const {
      idPrefix,
      errorEventDefinition
    } = props;
    let entries = [{
      id: idPrefix + '-errorRef',
      component: ErrorRef,
      isEdited: isEdited$4,
      errorEventDefinition,
      idPrefix
    }];
    const error = errorEventDefinition.get('errorRef');

    if (error) {
      entries = [...entries, {
        id: idPrefix + '-errorName',
        component: ErrorName,
        isEdited: isEdited$1,
        error,
        errorEventDefinition,
        idPrefix
      }, {
        id: idPrefix + '-errorCode',
        component: ErrorCode,
        isEdited: isEdited$1,
        error,
        errorEventDefinition,
        idPrefix
      }, {
        id: idPrefix + '-errorMessage',
        component: ErrorMessage,
        isEdited: isEdited$1,
        error,
        errorEventDefinition,
        idPrefix
      }];
    }

    entries.push({
      id: idPrefix + '-expression',
      component: Expression$2,
      errorEventDefinition,
      idPrefix
    });
    return entries;
  }

  function ErrorRef(props) {
    const {
      element,
      errorEventDefinition,
      idPrefix
    } = props;
    const bpmnFactory = useService('bpmnFactory');
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      const error = errorEventDefinition.get('errorRef');

      if (error) {
        return error.get('id');
      }

      return EMPTY_OPTION;
    };

    const setValue = value => {
      const root = getRoot(businessObject);
      const commands = [];
      let error; // (1) create new error

      if (value === CREATE_NEW_OPTION) {
        error = createElement('bpmn:Error', {
          name: nextId('Error_')
        }, root, bpmnFactory);
        value = error.get('id');
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: root,
            properties: {
              rootElements: [...root.get('rootElements'), error]
            }
          }
        });
      } // (2) update (or remove) errorRef


      error = error || findRootElementById(businessObject, 'bpmn:Error', value);
      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: errorEventDefinition,
          properties: {
            errorRef: error
          }
        }
      }); // (3) commit all updates

      return commandStack.execute('properties-panel.multi-command-executor', commands);
    };

    const getOptions = () => {
      let options = [{
        value: EMPTY_OPTION,
        label: translate('<none>')
      }, {
        value: CREATE_NEW_OPTION,
        label: translate('Create new ...')
      }];
      const errors = findRootElementsByType(getBusinessObject$1(element), 'bpmn:Error');
      sortByName$1(errors).forEach(error => {
        options.push({
          value: error.get('id'),
          label: error.get('name') || error.get('id')
        });
      });
      return options;
    };

    return ReferenceSelectEntry({
      element,
      id: idPrefix + '-errorRef',
      label: translate('Global error reference'),
      autoFocusEntry: idPrefix + '-errorName',
      getValue,
      setValue,
      getOptions
    });
  }

  function ErrorName(props) {
    const {
      element,
      error,
      idPrefix
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return error.get('name');
    };

    const setValue = value => {
      return commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: error,
        properties: {
          name: value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: idPrefix + '-errorName',
      label: translate('Name'),
      getValue,
      setValue,
      debounce
    });
  }

  function ErrorCode(props) {
    const {
      element,
      error,
      idPrefix
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return error.get('errorCode');
    };

    const setValue = value => {
      return commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: error,
        properties: {
          errorCode: value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: idPrefix + '-errorCode',
      label: translate('Code'),
      getValue,
      setValue,
      debounce
    });
  }

  function ErrorMessage(props) {
    const {
      element,
      error,
      idPrefix
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return error.get('errorMessage');
    };

    const setValue = value => {
      return commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: error,
        properties: {
          errorMessage: value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: idPrefix + '-errorMessage',
      label: translate('Message'),
      getValue,
      setValue,
      debounce
    });
  }

  function Expression$2(props) {
    const {
      element,
      errorEventDefinition,
      idPrefix
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: errorEventDefinition,
        properties: {
          'camunda:expression': value
        }
      });
    };

    const getValue = () => {
      return errorEventDefinition.get('camunda:expression');
    };

    return TextfieldEntry({
      element: errorEventDefinition,
      id: idPrefix + '-expression',
      label: translate('Throw expression'),
      getValue,
      setValue,
      debounce
    });
  } // helpers //////////


  function sortByName$1(elements) {
    return sortBy(elements, e => (e.name || '').toLowerCase());
  }

  function ErrorsProps({
    element,
    injector
  }) {
    const businessObject = getBusinessObject$1(element);

    if (!is$4(element, 'bpmn:ServiceTask') || getImplementationType(element) !== 'external') {
      return null;
    }

    const errorEventDefinitions = getExtensionElementsList(businessObject, 'camunda:ErrorEventDefinition');
    const bpmnFactory = injector.get('bpmnFactory'),
          commandStack = injector.get('commandStack');
    const items = errorEventDefinitions.map((errorEventDefinition, index) => {
      const id = element.id + '-error-' + index;
      return {
        id,
        label: getErrorLabel(errorEventDefinition),
        entries: Error$1({
          idPrefix: id,
          element,
          errorEventDefinition
        }),
        autoFocusEntry: id + '-errorRef',
        remove: removeFactory$6({
          commandStack,
          element,
          errorEventDefinition
        })
      };
    });
    return {
      items,
      add: addFactory$5({
        bpmnFactory,
        commandStack,
        element
      }),
      shouldSort: false
    };
  }

  function removeFactory$6({
    commandStack,
    element,
    errorEventDefinition
  }) {
    return function (event) {
      event.stopPropagation();
      const businessObject = getBusinessObject$1(element);
      removeExtensionElements(element, businessObject, errorEventDefinition, commandStack);
    };
  }

  function addFactory$5({
    bpmnFactory,
    commandStack,
    element
  }) {
    return function (event) {
      event.stopPropagation();
      const businessObject = getBusinessObject$1(element);
      const error = createElement('camunda:ErrorEventDefinition', {}, undefined, bpmnFactory);
      addExtensionElements(element, businessObject, error, bpmnFactory, commandStack);
    };
  } // helpers //////////


  function getErrorLabel(errorEventDefinition) {
    const error = errorEventDefinition.get('errorRef');

    if (!error) {
      return '<no reference>';
    }

    const errorCode = error.get('errorCode'),
          name = error.get('name') || '<unnamed>';

    if (errorCode) {
      return `${name} (code = ${errorCode})`;
    }

    return name;
  }

  /**
   * @typedef { import('@bpmn-io/properties-panel').EntryDefinition } Entry
   */

  /**
   * @returns {Array<Entry>} entries
   */

  function EscalationProps(props) {
    const {
      element,
      entries
    } = props;

    if (!(isEscalationSupported(element) && canHaveEscalationVariables(element))) {
      return entries;
    }

    entries.push({
      id: 'escalationCodeVariable',
      component: EscalationCodeVariable,
      isEdited: isEdited$1
    });
    return entries;
  }

  function EscalationCodeVariable(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const escalationEventDefinition = getEscalationEventDefinition(element);

    const getValue = () => {
      return escalationEventDefinition.get('camunda:escalationCodeVariable');
    };

    const setValue = value => {
      return commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: escalationEventDefinition,
        properties: {
          'camunda:escalationCodeVariable': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'escalationCodeVariable',
      label: translate('Code variable'),
      description: translate('Define the name of the variable that will contain the escalation code.'),
      getValue,
      setValue,
      debounce
    });
  } // helper ///////////////////////


  function canHaveEscalationVariables(element) {
    return is$4(element, 'bpmn:StartEvent') || is$4(element, 'bpmn:BoundaryEvent');
  }

  function ExternalTaskPriorityProps(props) {
    const {
      element
    } = props;
    const businessObject = getBusinessObject$1(element);

    if (!is$4(element, 'bpmn:Process') && !(is$4(element, 'bpmn:Participant') && businessObject.get('processRef')) && !isExternalTaskLike(element)) {
      return [];
    }

    return [{
      id: 'externalTaskPriority',
      component: ExternalTaskPriority,
      isEdited: isEdited$1
    }];
  }

  function ExternalTaskPriority(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack'),
          translate = useService('translate'),
          debounce = useService('debounceInput');
    let businessObject;

    if (is$4(element, 'bpmn:Participant')) {
      businessObject = getBusinessObject$1(element).get('processRef');
    } else if (isExternalTaskLike(element)) {
      businessObject = getServiceTaskLikeBusinessObject(element);
    } else {
      businessObject = getBusinessObject$1(element);
    }

    const getValue = () => {
      return businessObject.get('camunda:taskPriority');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:taskPriority': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'externalTaskPriority',
      label: translate('Priority'),
      getValue,
      setValue,
      debounce
    });
  } // helper //////////////////


  function isExternalTaskLike(element) {
    const bo = getServiceTaskLikeBusinessObject(element),
          type = bo && bo.get('camunda:type');
    return is$4(bo, 'camunda:ServiceTaskLike') && type && type === 'external';
  }

  const DEFAULT_PROPS$2 = {
    'stringValue': undefined,
    'string': undefined,
    'expression': undefined
  };
  function FieldInjection(props) {
    const {
      element,
      idPrefix,
      field
    } = props;
    const entries = [{
      id: idPrefix + '-name',
      component: NameProperty,
      field,
      idPrefix,
      element
    }, {
      id: idPrefix + '-type',
      component: TypeProperty,
      field,
      idPrefix,
      element
    }, {
      id: idPrefix + '-value',
      component: ValueProperty,
      field,
      idPrefix,
      element
    }];
    return entries;
  }

  function NameProperty(props) {
    const {
      idPrefix,
      element,
      field
    } = props;
    const commandStack = useService('commandStack'),
          translate = useService('translate'),
          debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: field,
        properties: {
          name: value
        }
      });
    };

    const getValue = field => {
      return field.name;
    };

    return TextfieldEntry({
      element: field,
      id: idPrefix + '-name',
      label: translate('Name'),
      getValue,
      setValue,
      debounce
    });
  }

  function TypeProperty(props) {
    const {
      idPrefix,
      element,
      field
    } = props;
    const commandStack = useService('commandStack'),
          translate = useService('translate');

    const getValue = field => {
      return determineType(field);
    };

    const setValue = value => {
      const properties = Object.assign({}, DEFAULT_PROPS$2);
      properties[value] = '';
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: field,
        properties
      });
    };

    const getOptions = element => {
      const options = [{
        value: 'string',
        label: translate('String')
      }, {
        value: 'expression',
        label: translate('Expression')
      }];
      return options;
    };

    return SelectEntry({
      element: field,
      id: idPrefix + '-type',
      label: translate('Type'),
      getValue,
      setValue,
      getOptions
    });
  }

  function ValueProperty(props) {
    const {
      idPrefix,
      element,
      field
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const setValue = value => {
      // (1) determine which type we have set
      const type = determineType(field); // (2) set property accordingly

      const properties = Object.assign({}, DEFAULT_PROPS$2);
      properties[type] = value || ''; // (3) execute the update command

      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: field,
        properties
      });
    };

    const getValue = field => {
      return field.string || field.stringValue || field.expression;
    };

    return TextfieldEntry({
      element: field,
      id: idPrefix + '-value',
      label: translate('Value'),
      getValue,
      setValue,
      debounce
    });
  } // helper ///////////////////

  /**
   * determineType - get the type of a fieldInjection based on the attributes
   * set on it
   *
   * @param  {ModdleElement} field
   * @return {('string'|'expression')}
   */


  function determineType(field) {
    // string is the default type
    return 'string' in field && 'string' || 'expression' in field && 'expression' || 'stringValue' in field && 'string' || 'string';
  }

  function FieldInjectionProps({
    element,
    injector
  }) {
    const businessObject = getServiceTaskLikeBusinessObject(element);

    if (!businessObject) {
      return null;
    }

    const fieldInjections = getExtensionElementsList(businessObject, 'camunda:Field');
    const bpmnFactory = injector.get('bpmnFactory'),
          commandStack = injector.get('commandStack');
    const items = fieldInjections.map((field, index) => {
      const id = element.id + '-fieldInjection-' + index;
      return {
        id,
        label: getFieldLabel(field),
        entries: FieldInjection({
          idPrefix: id,
          element,
          field
        }),
        autoFocusEntry: id + '-name',
        remove: removeFactory$5({
          commandStack,
          element,
          field
        })
      };
    });
    return {
      items,
      add: addFactory$4({
        bpmnFactory,
        commandStack,
        element
      })
    };
  }

  function removeFactory$5({
    commandStack,
    element,
    field
  }) {
    return function (event) {
      event.stopPropagation();
      const businessObject = getServiceTaskLikeBusinessObject(element);
      removeExtensionElements(element, businessObject, field, commandStack);
    };
  }

  function addFactory$4({
    bpmnFactory,
    commandStack,
    element
  }) {
    return function (event) {
      event.stopPropagation();
      const businessObject = getServiceTaskLikeBusinessObject(element);
      const fieldInjection = createElement('camunda:Field', {
        name: undefined,
        string: '',
        // string is the default type
        stringValue: undefined
      }, null, bpmnFactory);
      addExtensionElements(element, businessObject, fieldInjection, bpmnFactory, commandStack);
    };
  } // helper ///////////////


  function getFieldLabel(field) {
    return field.name || '<empty>';
  }

  function FormFieldConstraint(props) {
    const {
      constraint,
      element,
      idPrefix
    } = props;
    const entries = [{
      id: idPrefix + '-name',
      component: Name$1,
      constraint,
      idPrefix,
      element
    }, {
      id: idPrefix + '-config',
      component: Config,
      constraint,
      idPrefix,
      element
    }];
    return entries;
  }

  function Name$1(props) {
    const {
      idPrefix,
      element,
      constraint
    } = props;
    const commandStack = useService('commandStack'),
          translate = useService('translate'),
          debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: constraint,
        properties: {
          name: value
        }
      });
    };

    const getValue = () => {
      return constraint.name;
    };

    return TextfieldEntry({
      element: constraint,
      id: idPrefix + '-name',
      label: translate('Name'),
      getValue,
      setValue,
      debounce
    });
  }

  function Config(props) {
    const {
      idPrefix,
      element,
      constraint
    } = props;
    const commandStack = useService('commandStack'),
          translate = useService('translate'),
          debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: constraint,
        properties: {
          config: value
        }
      });
    };

    const getValue = () => {
      return constraint.config;
    };

    return TextfieldEntry({
      element: constraint,
      id: idPrefix + '-config',
      label: translate('Config'),
      getValue,
      setValue,
      debounce
    });
  }

  function FormFieldProperty(props) {
    const {
      element,
      idPrefix,
      property
    } = props;
    const entries = [{
      id: idPrefix + '-id',
      component: Id$2,
      idPrefix,
      property,
      element
    }, {
      id: idPrefix + '-value',
      component: Value$1,
      idPrefix,
      property,
      element
    }];
    return entries;
  }

  function Id$2(props) {
    const {
      idPrefix,
      element,
      property
    } = props;
    const commandStack = useService('commandStack'),
          translate = useService('translate'),
          debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: property,
        properties: {
          id: value
        }
      });
    };

    const getValue = () => {
      return property.id;
    };

    return TextfieldEntry({
      element: property,
      id: idPrefix + '-id',
      label: translate('ID'),
      getValue,
      setValue,
      debounce
    });
  }

  function Value$1(props) {
    const {
      idPrefix,
      element,
      property
    } = props;
    const commandStack = useService('commandStack'),
          translate = useService('translate'),
          debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: property,
        properties: {
          value
        }
      });
    };

    const getValue = () => {
      return property.value;
    };

    return TextfieldEntry({
      element: property,
      id: idPrefix + '-value',
      label: translate('Value'),
      getValue,
      setValue,
      debounce
    });
  }

  function FormFieldValue(props) {
    const {
      element,
      idPrefix,
      value
    } = props;
    const entries = [{
      id: idPrefix + '-id',
      component: Id$1,
      idPrefix,
      value,
      element
    }, {
      id: idPrefix + '-name',
      component: Name,
      idPrefix,
      value,
      element
    }];
    return entries;
  }

  function Id$1(props) {
    const {
      idPrefix,
      element,
      value
    } = props;
    const commandStack = useService('commandStack'),
          translate = useService('translate'),
          debounce = useService('debounceInput');

    const setValue = val => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: value,
        properties: {
          id: val
        }
      });
    };

    const getValue = () => {
      return value.id;
    };

    return TextfieldEntry({
      element: value,
      id: idPrefix + '-id',
      label: translate('ID'),
      getValue,
      setValue,
      debounce
    });
  }

  function Name(props) {
    const {
      idPrefix,
      element,
      value
    } = props;
    const commandStack = useService('commandStack'),
          translate = useService('translate'),
          debounce = useService('debounceInput');

    const setValue = val => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: value,
        properties: {
          name: val
        }
      });
    };

    const getValue = () => {
      return value.name;
    };

    return TextfieldEntry({
      element: value,
      id: idPrefix + '-name',
      label: translate('Name'),
      getValue,
      setValue,
      debounce
    });
  }

  const CUSTOM_TYPE_VALUE = '',
        DEFINED_TYPE_VALUES = ['boolean', 'date', 'enum', 'long', 'string', undefined];
  function FormField(props) {
    const {
      idPrefix,
      formField
    } = props;
    const entries = [{
      id: idPrefix + '-formFieldID',
      component: Id,
      idPrefix,
      formField
    }, {
      id: idPrefix + '-formFieldLabel',
      component: Label,
      idPrefix,
      formField
    }, {
      id: idPrefix + '-formFieldType',
      component: Type$1,
      idPrefix,
      formField
    }];

    if (!DEFINED_TYPE_VALUES.includes(formField.get('type'))) {
      entries.push({
        id: idPrefix + '-formFieldCustomType',
        component: CustomType,
        idPrefix,
        formField
      });
    }

    entries.push({
      id: idPrefix + '-formFieldDefaultValue',
      component: DefaultValue,
      idPrefix,
      formField
    });

    if (formField.get('type') === 'enum') {
      entries.push({
        id: idPrefix + '-formFieldValues',
        component: ValueList,
        formField,
        idPrefix
      });
    }

    entries.push({
      id: idPrefix + '-formFieldConstraints',
      component: ConstraintList,
      formField,
      idPrefix
    }, {
      id: idPrefix + '-formFieldProperties',
      component: PropertiesList,
      formField,
      idPrefix
    });
    return entries;
  }

  function Id(props) {
    const {
      idPrefix,
      element,
      formField
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: formField,
        properties: {
          id: value
        }
      });
    };

    const getValue = () => {
      return formField.get('id');
    };

    return TextfieldEntry({
      element: formField,
      id: idPrefix + '-formFieldID',
      label: translate('ID'),
      description: translate('Refers to the process variable name'),
      getValue,
      setValue,
      debounce
    });
  }

  function Label(props) {
    const {
      idPrefix,
      element,
      formField
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: formField,
        properties: {
          label: value
        }
      });
    };

    const getValue = () => {
      return formField.get('label');
    };

    return TextfieldEntry({
      element: formField,
      id: idPrefix + '-formFieldLabel',
      label: translate('Label'),
      getValue,
      setValue,
      debounce
    });
  }

  function Type$1(props) {
    const {
      idPrefix,
      element,
      formField
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: formField,
        properties: {
          type: value
        }
      });
    };

    const getValue = () => {
      const type = formField.get('type');
      return DEFINED_TYPE_VALUES.includes(type) ? type : CUSTOM_TYPE_VALUE;
    };

    const getOptions = () => {
      const options = [{
        label: translate('boolean'),
        value: 'boolean'
      }, {
        label: translate('date'),
        value: 'date'
      }, {
        label: translate('enum'),
        value: 'enum'
      }, {
        label: translate('long'),
        value: 'long'
      }, {
        label: translate('string'),
        value: 'string'
      }, {
        label: translate('<custom type>'),
        value: CUSTOM_TYPE_VALUE
      }]; // for the initial state only, we want to show an empty state

      if (formField.get('type') === undefined) {
        options.unshift({
          label: translate('<none>'),
          value: ''
        });
      }

      return options;
    };

    return SelectEntry({
      element: formField,
      id: idPrefix + '-formFieldType',
      label: translate('Type'),
      getValue,
      setValue,
      getOptions
    });
  }

  function CustomType(props) {
    const {
      idPrefix,
      element,
      formField
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const setValue = value => {
      const type = value || '';
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: formField,
        properties: {
          type
        }
      });
    };

    const getValue = () => {
      return formField.get('type');
    };

    return TextfieldEntry({
      element: formField,
      id: idPrefix + '-formFieldCustomType',
      label: translate('Custom type'),
      getValue,
      setValue,
      debounce
    });
  }

  function DefaultValue(props) {
    const {
      idPrefix,
      element,
      formField
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: formField,
        properties: {
          defaultValue: value
        }
      });
    };

    const getValue = () => {
      return formField.get('defaultValue');
    };

    return TextfieldEntry({
      element: formField,
      id: idPrefix + '-formFieldDefaultValue',
      label: translate('Default value'),
      getValue,
      setValue,
      debounce
    });
  }

  function Value(props) {
    const {
      element,
      id: idPrefix,
      index,
      item: value,
      open
    } = props;
    const translate = useService('translate');
    const id = `${idPrefix}-value-${index}`;
    return o$1(CollapsibleEntry, {
      id: id,
      element: element,
      entries: FormFieldValue({
        idPrefix: id,
        element,
        value
      }),
      label: value.get('id') || translate('<empty>'),
      open: open
    });
  }

  function ValueList(props) {
    const {
      element,
      formField,
      idPrefix
    } = props;
    const id = `${idPrefix}-formFieldValues`;
    const bpmnFactory = useService('bpmnFactory');
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const values = formField.get('values') || [];

    function addValue() {
      const value = createElement('camunda:Value', {
        id: undefined,
        name: undefined
      }, formField, bpmnFactory);
      commandStack.execute('element.updateModdleProperties', {
        element: element,
        moddleElement: formField,
        properties: {
          values: [...formField.get('values'), value]
        }
      });
    }

    function removeValue(value) {
      commandStack.execute('element.updateModdleProperties', {
        element: element,
        moddleElement: formField,
        properties: {
          values: without(formField.get('values'), value)
        }
      });
    }

    return o$1(List, {
      element: element,
      autoFocusEntry: `[data-entry-id="${id}-value-${values.length - 1}"] input`,
      id: id,
      label: translate('Values'),
      items: values,
      component: Value,
      onAdd: addValue,
      onRemove: removeValue
    });
  }

  function Constraint(props) {
    const {
      element,
      id: idPrefix,
      index,
      item: constraint,
      open
    } = props;
    const translate = useService('translate');
    const id = `${idPrefix}-constraint-${index}`;
    return o$1(CollapsibleEntry, {
      id: id,
      element: element,
      entries: FormFieldConstraint({
        constraint,
        element,
        idPrefix: id
      }),
      label: constraint.get('name') || translate('<empty>'),
      open: open
    });
  }

  function ConstraintList(props) {
    const {
      element,
      formField,
      idPrefix
    } = props;
    const id = `${idPrefix}-formFieldConstraints`;
    const bpmnFactory = useService('bpmnFactory');
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const businessObject = getBusinessObject$1(element);
    let validation = formField.get('validation');
    const constraints = validation && validation.get('constraints') || [];

    function addConstraint() {
      const commands = []; // (1) ensure validation

      if (!validation) {
        validation = createElement('camunda:Validation', {}, businessObject, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: formField,
            properties: {
              validation
            }
          }
        });
      } // (2) add constraint


      const constraint = createElement('camunda:Constraint', {
        name: undefined,
        config: undefined
      }, validation, bpmnFactory);
      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: validation,
          properties: {
            constraints: [...validation.get('constraints'), constraint]
          }
        }
      }); // (3) commit updates

      commandStack.execute('properties-panel.multi-command-executor', commands);
    }

    function removeConstraint(constraint) {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: validation,
        properties: {
          constraints: without(validation.get('constraints'), constraint)
        }
      });
    }

    return o$1(List, {
      element: element,
      autoFocusEntry: `[data-entry-id="${id}-constraint-${constraints.length - 1}"] input`,
      id: id,
      label: translate('Constraints'),
      items: constraints,
      component: Constraint,
      onAdd: addConstraint,
      onRemove: removeConstraint
    });
  }

  function Property(props) {
    const {
      element,
      id: idPrefix,
      index,
      item: property,
      open
    } = props;
    const translate = useService('translate');
    const id = `${idPrefix}-property-${index}`;
    return o$1(CollapsibleEntry, {
      id: id,
      element: element,
      entries: FormFieldProperty({
        element,
        idPrefix: id,
        property
      }),
      label: property.get('id') || translate('<empty>'),
      open: open
    });
  }

  function PropertiesList(props) {
    const {
      element,
      formField,
      idPrefix
    } = props;
    const id = `${idPrefix}-formFieldProperties`;
    const bpmnFactory = useService('bpmnFactory');
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const businessObject = getBusinessObject$1(element);
    let properties = formField.get('properties');
    const propertyEntries = properties && properties.get('values') || [];

    function addProperty() {
      const commands = []; // (1) ensure properties

      if (!properties) {
        properties = createElement('camunda:Properties', {}, businessObject, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: formField,
            properties: {
              properties
            }
          }
        });
      } // (2) add property


      const property = createElement('camunda:Property', {
        id: undefined,
        value: undefined
      }, properties, bpmnFactory);
      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: properties,
          properties: {
            values: [...properties.get('values'), property]
          }
        }
      }); // (3) commit updates

      commandStack.execute('properties-panel.multi-command-executor', commands);
    }

    function removeProperty(property) {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: properties,
        properties: {
          values: without(properties.get('values'), property)
        }
      });
    }

    return o$1(List, {
      element: element,
      autoFocusEntry: true,
      id: id,
      compareFn: createAlphanumericCompare('id'),
      label: translate('Properties'),
      items: propertyEntries,
      component: Property,
      onAdd: addProperty,
      onRemove: removeProperty
    });
  } // helper //////////////////


  function createAlphanumericCompare(field) {
    return function (entry, anotherEntry) {
      const [key = '', anotherKey = ''] = [entry[field], anotherEntry[field]];
      return key === anotherKey ? 0 : key > anotherKey ? 1 : -1;
    };
  }

  function FormDataProps({
    element,
    injector
  }) {
    if (!isFormDataSupported(element)) {
      return;
    }

    const formFields = getFormFieldsList(element) || [];
    const bpmnFactory = injector.get('bpmnFactory'),
          commandStack = injector.get('commandStack');
    const items = formFields.map((formField, index) => {
      const id = element.id + '-formField-' + index;
      return {
        id,
        label: formField.get('id') || '',
        entries: FormField({
          idPrefix: id,
          element,
          formField
        }),
        autoFocusEntry: id + '-formFieldID',
        remove: removeFactory$4({
          commandStack,
          element,
          formField
        })
      };
    });
    return {
      items,
      add: addFactory$3({
        bpmnFactory,
        commandStack,
        element
      }),
      shouldSort: false
    };
  }

  function addFactory$3({
    bpmnFactory,
    commandStack,
    element
  }) {
    return function (event) {
      event.stopPropagation();
      const commands = []; // (1) get camunda:FormData

      const formData = getFormData$2(element); // (2) create camunda:FormField

      const formField = createElement('camunda:FormField', {}, formData, bpmnFactory); // (3) add formField to list

      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: formData,
          properties: {
            fields: [...formData.get('fields'), formField]
          }
        }
      }); // (4) commit all updates

      commandStack.execute('properties-panel.multi-command-executor', commands);
    };
  }

  function removeFactory$4({
    commandStack,
    element,
    formField
  }) {
    return function (event) {
      event.stopPropagation();
      const formData = getFormData$2(element),
            formFields = getFormFieldsList(element);

      if (!formFields || !formFields.length) {
        return;
      }

      const fields = without(formData.get('fields'), formField); // update formData

      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: formData,
        properties: {
          fields
        }
      });
    };
  } // helper ///////////////////////////////


  function isFormDataSupported(element) {
    const formData = getFormData$2(element);
    return (is$4(element, 'bpmn:StartEvent') && !is$4(element.parent, 'bpmn:SubProcess') || is$4(element, 'bpmn:UserTask')) && formData;
  }

  function getFormData$2(element) {
    const bo = getBusinessObject$1(element);
    return getExtensionElementsList(bo, 'camunda:FormData')[0];
  }

  function getFormFieldsList(element) {
    const businessObject = getBusinessObject$1(element);
    const formData = getFormData$2(businessObject);
    return formData && formData.fields;
  }

  const FORM_KEY_PROPS = {
    'camunda:formRef': undefined,
    'camunda:formRefBinding': undefined,
    'camunda:formRefVersion': undefined
  };
  const FORM_REF_PROPS = {
    'camunda:formKey': undefined
  };
  function FormTypeProps(props) {
    return [{
      id: 'formType',
      component: FormType,
      isEdited: isEdited$4
    }];
  }

  function FormType(props) {
    const {
      element
    } = props;
    const translate = useService('translate');
    const bpmnFactory = useService('bpmnFactory');
    const businessObject = getBusinessObject$1(element);
    const commandStack = useService('commandStack');
    let extensionElements = businessObject.get('extensionElements');

    const getValue = () => {
      if (isDefined(businessObject.get('camunda:formKey'))) {
        return 'formKey';
      } else if (isDefined(businessObject.get('camunda:formRef'))) {
        return 'formRef';
      } else if (getFormData$1(element)) {
        return 'formData';
      }

      return '';
    };

    const setValue = value => {
      const commands = removePropertiesCommands(element);

      if (value === 'formData') {
        // (1) ensure extension elements
        if (!extensionElements) {
          extensionElements = createElement('bpmn:ExtensionElements', {
            values: []
          }, businessObject, bpmnFactory);
          commands.push({
            cmd: 'element.updateModdleProperties',
            context: {
              element,
              moddleElement: businessObject,
              properties: {
                extensionElements
              }
            }
          });
        } // (2) create camunda:FormData


        const parent = extensionElements;
        const formData = createElement('camunda:FormData', {
          fields: []
        }, parent, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), formData]
            }
          }
        });
      } else if (value === 'formKey') {
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: businessObject,
            properties: {
              'camunda:formKey': ''
            }
          }
        });
      } else if (value === 'formRef') {
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: businessObject,
            properties: {
              'camunda:formRef': ''
            }
          }
        });
      }

      commandStack.execute('properties-panel.multi-command-executor', commands);
    };

    const getOptions = () => {
      return [{
        value: '',
        label: translate('<none>')
      }, {
        value: 'formRef',
        label: translate('Camunda Forms')
      }, {
        value: 'formKey',
        label: translate('Embedded or External Task Forms')
      }, {
        value: 'formData',
        label: translate('Generated Task Forms')
      }];
    };

    return SelectEntry({
      element,
      id: 'formType',
      label: translate('Type'),
      getValue,
      setValue,
      getOptions
    });
  }

  function getFormData$1(element) {
    const bo = getBusinessObject$1(element);
    return getExtensionElementsList(bo, 'camunda:FormData')[0];
  }

  function removePropertiesCommands(element, commandStack) {
    const businessObject = getBusinessObject$1(element);
    const extensionElements = businessObject.get('extensionElements');
    const commands = []; // (1) reset formKey and formRef

    commands.push({
      cmd: 'element.updateModdleProperties',
      context: {
        element,
        moddleElement: businessObject,
        properties: { ...FORM_KEY_PROPS,
          ...FORM_REF_PROPS
        }
      }
    }); // (2) remove formData if defined

    if (extensionElements && getFormData$1(element)) {
      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: extensionElements,
          properties: {
            values: without(extensionElements.get('values'), getFormData$1(element))
          }
        }
      });
    }

    return commands;
  }

  function getFormRefBinding(element) {
    const businessObject = getBusinessObject$1(element);
    return businessObject.get('camunda:formRefBinding') || 'latest';
  }
  function getFormType(element) {
    const businessObject = getBusinessObject$1(element);

    if (isDefined(businessObject.get('camunda:formKey'))) {
      return 'formKey';
    } else if (isDefined(businessObject.get('camunda:formRef'))) {
      return 'formRef';
    }
  }
  function isFormSupported(element) {
    return is$4(element, 'bpmn:StartEvent') && !is$4(element.parent, 'bpmn:SubProcess') || is$4(element, 'bpmn:UserTask');
  }

  function FormProps(props) {
    const {
      element
    } = props;

    if (!isFormSupported(element)) {
      return [];
    }

    const formType = getFormType(element),
          bindingType = getFormRefBinding(element); // (1) display form type select

    const entries = [...FormTypeProps()]; // (2) display form properties based on type

    if (formType === 'formKey') {
      entries.push({
        id: 'formKey',
        component: FormKey,
        isEdited: isEdited$1
      });
    } else if (formType === 'formRef') {
      entries.push({
        id: 'formRef',
        component: FormRef,
        isEdited: isEdited$1
      }, {
        id: 'formRefBinding',
        component: Binding$1,
        isEdited: isEdited$4
      });

      if (bindingType === 'version') {
        entries.push({
          id: 'formRefVersion',
          component: Version$1,
          isEdited: isEdited$1
        });
      }
    }

    return entries;
  }

  function FormKey(props) {
    const {
      element
    } = props;
    const debounce = useService('debounceInput');
    const modeling = useService('modeling');
    const translate = useService('translate');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      return businessObject.get('camunda:formKey');
    };

    const setValue = value => {
      modeling.updateProperties(element, {
        'camunda:formKey': value
      });
    };

    return TextfieldEntry({
      element,
      id: 'formKey',
      label: translate('Form key'),
      getValue,
      setValue,
      debounce
    });
  }

  function FormRef(props) {
    const {
      element
    } = props;
    const debounce = useService('debounceInput');
    const modeling = useService('modeling');
    const translate = useService('translate');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      return businessObject.get('camunda:formRef');
    };

    const setValue = value => {
      modeling.updateProperties(element, {
        'camunda:formRef': value
      });
    };

    return TextfieldEntry({
      element,
      id: 'formRef',
      label: translate('Form reference'),
      getValue,
      setValue,
      debounce
    });
  }

  function Binding$1(props) {
    const {
      element
    } = props;
    const modeling = useService('modeling');
    const translate = useService('translate');

    const getValue = () => {
      return getFormRefBinding(element);
    };

    const setValue = value => {
      modeling.updateProperties(element, {
        'camunda:formRefBinding': value
      });
    }; // Note: default is "latest",
    // cf. https://docs.camunda.org/manual/develop/reference/bpmn20/custom-extensions/extension-attributes/#formrefbinding


    const getOptions = () => {
      const options = [{
        value: 'deployment',
        label: translate('deployment')
      }, {
        value: 'latest',
        label: translate('latest')
      }, {
        value: 'version',
        label: translate('version')
      }];
      return options;
    };

    return SelectEntry({
      element,
      id: 'formRefBinding',
      label: translate('Binding'),
      getValue,
      setValue,
      getOptions
    });
  }

  function Version$1(props) {
    const {
      element
    } = props;
    const debounce = useService('debounceInput');
    const modeling = useService('modeling');
    const translate = useService('translate');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      return businessObject.get('camunda:formRefVersion');
    };

    const setValue = value => {
      modeling.updateProperties(element, {
        'camunda:formRefVersion': value
      });
    };

    return TextfieldEntry({
      element,
      id: 'formRefVersion',
      label: translate('Version'),
      getValue,
      setValue,
      debounce
    });
  }

  function HistoryCleanupProps(props) {
    const {
      element
    } = props;
    const businessObject = getBusinessObject$1(element);

    if (!is$4(element, 'bpmn:Process') && !(is$4(element, 'bpmn:Participant') && businessObject.get('processRef'))) {
      return [];
    }

    return [{
      id: 'historyTimeToLive',
      component: HistoryTimeToLive,
      isEdited: isEdited$1
    }];
  }

  function HistoryTimeToLive(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const process = getProcess$2(element);

    const getValue = () => {
      return process.get('camunda:historyTimeToLive') || '';
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: process,
        properties: {
          'camunda:historyTimeToLive': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'historyTimeToLive',
      label: translate('Time to live'),
      getValue,
      setValue,
      debounce
    });
  } // helper //////////////////


  function getProcess$2(element) {
    return is$4(element, 'bpmn:Process') ? getBusinessObject$1(element) : getBusinessObject$1(element).get('processRef');
  }

  function DmnImplementationProps(props) {
    const {
      element
    } = props;
    const entries = [];
    const implementationType = getImplementationType(element);
    const bindingType = getDecisionRefBinding(element);

    if (implementationType !== 'dmn') {
      return entries;
    } // (1) decisionRef


    entries.push({
      id: 'decisionRef',
      component: DecisionRef,
      isEdited: isEdited$1
    }); // (2) binding

    entries.push({
      id: 'decisionRefBinding',
      component: Binding,
      isEdited: isEdited$4
    }); // (3) version

    if (bindingType === 'version') {
      entries.push({
        id: 'decisionRefVersion',
        component: Version,
        isEdited: isEdited$1
      });
    } // (4) versionTag


    if (bindingType === 'versionTag') {
      entries.push({
        id: 'decisionRefVersionTag',
        component: VersionTag$1,
        isEdited: isEdited$1
      });
    } // (5) tenantId


    entries.push({
      id: 'decisionRefTenantId',
      component: TenantId,
      isEdited: isEdited$1
    }); // (6) resultVariable

    entries.push({
      id: 'decisionRefResultVariable',
      component: ResultVariable$2,
      isEdited: isEdited$1
    }); // (7) mapDecisionResult

    if (getResultVariable$1(element)) {
      entries.push({
        id: 'mapDecisionResult',
        component: MapDecisionResult,
        isEdited: isEdited$4
      });
    }

    return entries;
  }

  function DecisionRef(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      return businessObject.get('camunda:decisionRef');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:decisionRef': value || ''
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'decisionRef',
      label: translate('Decision reference'),
      getValue,
      setValue,
      debounce
    });
  }

  function Binding(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');

    const getValue = () => {
      return getDecisionRefBinding(element);
    };

    const setValue = value => {
      const businessObject = getBusinessObject$1(element); // reset version properties on binding type change

      const updatedProperties = {
        'camunda:decisionRefVersion': undefined,
        'camunda:decisionRefVersionTag': undefined,
        'camunda:decisionRefBinding': value
      };
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: updatedProperties
      });
    }; // Note: default is "latest",
    // cf. https://docs.camunda.org/manual/latest/reference/bpmn20/custom-extensions/extension-attributes/#decisionrefbinding


    const getOptions = () => {
      const options = [{
        value: 'deployment',
        label: translate('deployment')
      }, {
        value: 'latest',
        label: translate('latest')
      }, {
        value: 'version',
        label: translate('version')
      }, {
        value: 'versionTag',
        label: translate('versionTag')
      }];
      return options;
    };

    return SelectEntry({
      element,
      id: 'decisionRefBinding',
      label: translate('Binding'),
      getValue,
      setValue,
      getOptions
    });
  }

  function Version(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      return businessObject.get('camunda:decisionRefVersion');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:decisionRefVersion': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'decisionRefVersion',
      label: translate('Version'),
      getValue,
      setValue,
      debounce
    });
  }

  function VersionTag$1(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      return businessObject.get('camunda:decisionRefVersionTag');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:decisionRefVersionTag': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'decisionRefVersionTag',
      label: translate('Version tag'),
      getValue,
      setValue,
      debounce
    });
  }

  function TenantId(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      return businessObject.get('camunda:decisionRefTenantId');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:decisionRefTenantId': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'decisionRefTenantId',
      label: translate('Tenant ID'),
      getValue,
      setValue,
      debounce
    });
  }

  function ResultVariable$2(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      return getResultVariable$1(businessObject);
    }; // Note: camunda:mapDecisionResult got cleaned up in modeling behavior
    // cf. https://github.com/camunda/camunda-bpmn-js/blob/main/lib/camunda-platform/features/modeling/behavior/UpdateResultVariableBehavior.js


    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:resultVariable': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'decisionRefResultVariable',
      label: translate('Result variable'),
      getValue,
      setValue,
      debounce
    });
  }

  function MapDecisionResult(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      return businessObject.get('camunda:mapDecisionResult') || 'resultList';
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:mapDecisionResult': value
        }
      });
    }; // Note: default is "resultList",
    // cf. https://docs.camunda.org/manual/latest/reference/bpmn20/custom-extensions/extension-attributes/#mapdecisionresult


    const getOptions = () => {
      const options = [{
        value: 'collectEntries',
        label: translate('collectEntries (List<Object>)')
      }, {
        value: 'resultList',
        label: translate('resultList (List<Map<String, Object>>)')
      }, {
        value: 'singleEntry',
        label: translate('singleEntry (TypedValue)')
      }, {
        value: 'singleResult',
        label: translate('singleResult (Map<String, Object>)')
      }];
      return options;
    };

    return SelectEntry({
      element,
      id: 'mapDecisionResult',
      label: translate('Map decision result'),
      getValue,
      setValue,
      getOptions
    });
  } // helper ////////////////////


  function getDecisionRefBinding(element) {
    const businessObject = getBusinessObject$1(element);
    return businessObject.get('camunda:decisionRefBinding') || 'latest';
  }

  function getResultVariable$1(element) {
    const businessObject = getBusinessObject$1(element);
    return businessObject.get('camunda:resultVariable');
  }

  const DELEGATE_PROPS = {
    'camunda:class': undefined,
    'camunda:expression': undefined,
    'camunda:delegateExpression': undefined,
    'camunda:resultVariable': undefined
  };
  const DMN_CAPABLE_PROPS = {
    'camunda:decisionRef': undefined,
    'camunda:decisionRefBinding': 'latest',
    'camunda:decisionRefVersion': undefined,
    'camunda:mapDecisionResult': 'resultList',
    'camunda:decisionRefTenantId': undefined
  };
  const EXTERNAL_CAPABLE_PROPS = {
    'camunda:type': undefined,
    'camunda:topic': undefined
  };
  const IMPLEMENTATION_TYPE_NONE_LABEL = '<none>',
        IMPLEMENTATION_TYPE_JAVA_LABEL = 'Java class',
        IMPLEMENTATION_TYPE_EXPRESSION_LABEL = 'Expression',
        IMPLEMENTATION_TYPE_DELEGATE_LABEL = 'Delegate expression',
        IMPLEMENTATION_TYPE_DMN_LABEL = 'DMN',
        IMPLEMENTATION_TYPE_EXTERNAL_LABEL = 'External',
        IMPLEMENTATION_TYPE_CONNECTOR_LABEL = 'Connector';
  function ImplementationTypeProps(props) {
    return [{
      id: 'implementationType',
      component: ImplementationType,
      isEdited: isEdited$4
    }];
  }

  function ImplementationType(props) {
    const {
      element
    } = props;
    const bpmnFactory = useService('bpmnFactory');
    const commandStack = useService('commandStack');
    const translate = useService('translate');

    const getValue = () => {
      return getImplementationType(element) || '';
    };

    const setValue = value => {
      const oldType = getImplementationType(element);
      const businessObject = getServiceTaskLikeBusinessObject(element);
      const commands = [];
      let updatedProperties = DELEGATE_PROPS;
      let extensionElements = businessObject.get('extensionElements'); // (1) class, expression, delegateExpression

      if (isDelegateType(value)) {
        updatedProperties = { ...updatedProperties,
          [value]: isDelegateType(oldType) ? businessObject.get(`camunda:${oldType}`) : ''
        };
      } // (2) dmn


      if (isDmnCapable(businessObject)) {
        updatedProperties = { ...updatedProperties,
          ...DMN_CAPABLE_PROPS
        };

        if (value === 'dmn') {
          updatedProperties = { ...updatedProperties,
            'camunda:decisionRef': ''
          };
        }
      } // (3) external
      // Note: error event definition elements got cleaned up in modeling behavior
      // cf. https://github.com/camunda/camunda-bpmn-js/blob/main/lib/camunda-platform/features/modeling/behavior/DeleteErrorEventDefinitionBehavior.js


      if (isExternalCapable(businessObject)) {
        updatedProperties = { ...updatedProperties,
          ...EXTERNAL_CAPABLE_PROPS
        };

        if (value === 'external') {
          updatedProperties = { ...updatedProperties,
            'camunda:type': 'external',
            'camunda:topic': ''
          };
        }
      } // (4) connector


      if (isServiceTaskLike(businessObject)) {
        // (4.1) remove all connectors on type change
        const connectors = getConnectors$1(businessObject);

        if (connectors.length) {
          commands.push({
            cmd: 'element.updateModdleProperties',
            context: {
              element,
              moddleElement: extensionElements,
              properties: {
                values: without(extensionElements.get('values'), value => connectors.includes(value))
              }
            }
          });
        } // (4.2) create connector


        if (value === 'connector') {
          // ensure extension elements
          if (!extensionElements) {
            extensionElements = createElement('bpmn:ExtensionElements', {
              values: []
            }, businessObject, bpmnFactory);
            commands.push(UpdateModdlePropertiesCommand(element, businessObject, {
              extensionElements
            }));
          }

          const connector = createElement('camunda:Connector', {}, extensionElements, bpmnFactory);
          commands.push({
            cmd: 'element.updateModdleProperties',
            context: {
              element,
              moddleElement: extensionElements,
              properties: {
                values: [...extensionElements.get('values'), connector]
              }
            }
          });
        }
      } // (5) collect all property updates


      commands.push(UpdateModdlePropertiesCommand(element, businessObject, updatedProperties)); // (6) commit all updates

      commandStack.execute('properties-panel.multi-command-executor', commands);
    };

    const getOptions = () => {
      const businessObject = getServiceTaskLikeBusinessObject(element);
      const options = [{
        value: '',
        label: translate(IMPLEMENTATION_TYPE_NONE_LABEL)
      }, {
        value: 'class',
        label: translate(IMPLEMENTATION_TYPE_JAVA_LABEL)
      }, {
        value: 'expression',
        label: translate(IMPLEMENTATION_TYPE_EXPRESSION_LABEL)
      }, {
        value: 'delegateExpression',
        label: translate(IMPLEMENTATION_TYPE_DELEGATE_LABEL)
      }];

      if (isDmnCapable(businessObject)) {
        options.push({
          value: 'dmn',
          label: translate(IMPLEMENTATION_TYPE_DMN_LABEL)
        });
      }

      if (isExternalCapable(businessObject)) {
        options.push({
          value: 'external',
          label: translate(IMPLEMENTATION_TYPE_EXTERNAL_LABEL)
        });
      }

      if (isServiceTaskLike(businessObject)) {
        options.push({
          value: 'connector',
          label: translate(IMPLEMENTATION_TYPE_CONNECTOR_LABEL)
        });
      }

      return sortByPriority(options);
    };

    return SelectEntry({
      element,
      id: 'implementationType',
      label: translate('Type'),
      getValue,
      setValue,
      getOptions
    });
  } // helper ///////////////////////


  function isDelegateType(type) {
    return ['class', 'expression', 'delegateExpression'].includes(type);
  }

  function getConnectors$1(businessObject) {
    return getExtensionElementsList(businessObject, 'camunda:Connector');
  }

  function UpdateModdlePropertiesCommand(element, businessObject, newProperties) {
    return {
      cmd: 'element.updateModdleProperties',
      context: {
        element,
        moddleElement: businessObject,
        properties: newProperties
      }
    };
  }

  function sortByPriority(options) {
    const priorities = {
      [IMPLEMENTATION_TYPE_NONE_LABEL]: 0,
      [IMPLEMENTATION_TYPE_JAVA_LABEL]: 3,
      [IMPLEMENTATION_TYPE_EXPRESSION_LABEL]: 4,
      [IMPLEMENTATION_TYPE_DELEGATE_LABEL]: 5,
      [IMPLEMENTATION_TYPE_DMN_LABEL]: 1,
      [IMPLEMENTATION_TYPE_EXTERNAL_LABEL]: 2,
      [IMPLEMENTATION_TYPE_CONNECTOR_LABEL]: 6
    };
    return sortBy(options, o => priorities[o.label]);
  }

  function ImplementationProps(props) {
    const {
      element
    } = props;

    if (!getServiceTaskLikeBusinessObject(element)) {
      return [];
    }

    const implementationType = getImplementationType(element); // (1) display implementation type select

    const entries = [...ImplementationTypeProps()]; // (2) display implementation properties based on type

    if (implementationType === 'class') {
      entries.push({
        id: 'javaClass',
        component: JavaClass,
        isEdited: isEdited$1
      });
    } else if (implementationType === 'expression') {
      entries.push({
        id: 'expression',
        component: Expression$1,
        isEdited: isEdited$1
      }, {
        id: 'expressionResultVariable',
        component: ResultVariable$1,
        isEdited: isEdited$1
      });
    } else if (implementationType === 'delegateExpression') {
      entries.push({
        id: 'delegateExpression',
        component: DelegateExpression,
        isEdited: isEdited$1
      });
    } else if (implementationType === 'dmn') {
      entries.push(...DmnImplementationProps({
        element
      }));
    } else if (implementationType === 'external') {
      entries.push({
        id: 'externalTopic',
        component: Topic,
        isEdited: isEdited$1
      });
    } else if (implementationType === 'connector') {
      entries.push({
        id: 'connectorId',
        component: ConnectorId,
        isEdited: isEdited$1
      });
    }

    return entries;
  }
  function JavaClass(props) {
    const {
      element,
      businessObject = getServiceTaskLikeBusinessObject(element),
      id = 'javaClass'
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return businessObject.get('camunda:class');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:class': value || ''
        }
      });
    };

    return TextfieldEntry({
      element,
      id,
      label: translate('Java class'),
      getValue,
      setValue,
      debounce
    });
  }
  function Expression$1(props) {
    const {
      element,
      businessObject = getServiceTaskLikeBusinessObject(element),
      id = 'expression'
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return businessObject.get('camunda:expression');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:expression': value || ''
        }
      });
    };

    return TextfieldEntry({
      element,
      id,
      label: translate('Expression'),
      getValue,
      setValue,
      debounce
    });
  }

  function ResultVariable$1(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const businessObject = getServiceTaskLikeBusinessObject(element);

    const getValue = () => {
      return businessObject.get('camunda:resultVariable');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:resultVariable': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'expressionResultVariable',
      label: translate('Result variable'),
      getValue,
      setValue,
      debounce
    });
  }

  function DelegateExpression(props) {
    const {
      element,
      businessObject = getServiceTaskLikeBusinessObject(element),
      id = 'delegateExpression'
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const getValue = () => {
      return businessObject.get('camunda:delegateExpression');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:delegateExpression': value || ''
        }
      });
    };

    return TextfieldEntry({
      element,
      id,
      label: translate('Delegate expression'),
      getValue,
      setValue,
      debounce
    });
  }

  function Topic(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const businessObject = getServiceTaskLikeBusinessObject(element);

    const getValue = () => {
      return businessObject.get('camunda:topic');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:topic': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'externalTopic',
      label: translate('Topic'),
      getValue,
      setValue,
      debounce
    });
  }

  function ConnectorId(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const connector = getConnector(element);

    const getValue = () => {
      return connector.get('camunda:connectorId');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: connector,
        properties: {
          'camunda:connectorId': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'connectorId',
      label: translate('Connector ID'),
      getValue,
      setValue,
      debounce
    });
  } // helper //////////////////


  function getConnectors(businessObject) {
    return getExtensionElementsList(businessObject, 'camunda:Connector');
  }

  function getConnector(element) {
    const businessObject = getServiceTaskLikeBusinessObject(element);
    const connectors = getConnectors(businessObject);
    return connectors[0];
  }

  function InitiatorProps(props) {
    const {
      element
    } = props;

    if (!isInitiator(element)) {
      return [];
    }

    return [{
      id: 'initiator',
      component: Initiator,
      isEdited: isEdited$1
    }];
  }

  function Initiator(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      return businessObject.get('camunda:initiator');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:initiator': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'initiator',
      label: translate('Initiator'),
      getValue,
      setValue,
      debounce
    });
  } // helper ///////////////////


  function isInitiator(element) {
    return is$4(element, 'camunda:Initiator') && !is$4(element.parent, 'bpmn:SubProcess');
  }

  /**
   * Cf. https://docs.camunda.org/manual/7.15/reference/bpmn20/subprocesses/call-activity/#passing-variables
   */

  function InMappingPropagationProps(props) {
    const {
      element
    } = props;

    if (!areInMappingsSupported$1(element)) {
      return [];
    }

    const entries = [{
      id: 'inMapping-propagation',
      component: PropagateAll$1,
      isEdited: isEdited$7
    }];

    if (isPropagateAll$1(element)) {
      entries.push({
        id: 'inMapping-propagation-local',
        component: Local$2,
        isEdited: isEdited$7
      });
    }

    return entries;
  }

  function PropagateAll$1(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const bpmnFactory = useService('bpmnFactory');
    const translate = useService('translate');

    const getValue = () => {
      return isPropagateAll$1(element);
    };

    const setValue = value => {
      if (value) {
        addInMapping();
      } else {
        removeInMapping();
      }
    };

    function addInMapping() {
      const businessObject = getSignalEventDefinition(element) || getBusinessObject$1(element);
      const mapping = createElement('camunda:In', {
        variables: 'all'
      }, null, bpmnFactory);
      addExtensionElements(element, businessObject, mapping, bpmnFactory, commandStack);
    }

    function removeInMapping() {
      const businessObject = getSignalEventDefinition(element) || getBusinessObject$1(element);
      const mappings = findRelevantInMappings(element);
      removeExtensionElements(element, businessObject, mappings, commandStack);
    }

    return CheckboxEntry({
      id: 'inMapping-propagation',
      label: translate('Propagate all variables'),
      getValue,
      setValue
    });
  }

  function Local$2(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const mapping = findRelevantInMappings(element)[0];

    const getValue = () => {
      return mapping.get('camunda:local');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: mapping,
        properties: {
          local: value
        }
      });
    };

    return CheckboxEntry({
      element,
      id: 'inMapping-propagation-local',
      label: translate('Local'),
      getValue,
      setValue
    });
  } // helper //////////////////////////


  function areInMappingsSupported$1(element) {
    const signalEventDefinition = getSignalEventDefinition(element);

    if (signalEventDefinition) {
      return isAny(element, ['bpmn:IntermediateThrowEvent', 'bpmn:EndEvent']);
    }

    return is$4(element, 'bpmn:CallActivity');
  }

  function getInMappings$1(element) {
    const businessObject = getBusinessObject$1(element);
    const signalEventDefinition = getSignalEventDefinition(businessObject);
    return getExtensionElementsList(signalEventDefinition || businessObject, 'camunda:In');
  }

  function findRelevantInMappings(element) {
    const inMappings = getInMappings$1(element);
    return filter(inMappings, function (mapping) {
      const variables = mapping.get('variables');
      return variables && variables === 'all';
    });
  }

  function isPropagateAll$1(element) {
    const mappings = findRelevantInMappings(element);
    return !!mappings.length;
  }

  const DEFAULT_PROPS$1 = {
    'source': undefined,
    'sourceExpression': undefined
  };
  function InOutMapping(props) {
    const {
      idPrefix,
      mapping
    } = props;
    const type = getInOutType(mapping);
    const entries = []; // (1) Type

    entries.push({
      id: idPrefix + '-type',
      component: Type,
      idPrefix,
      mapping
    }); // (2) Source

    if (type === 'source') {
      entries.push({
        id: idPrefix + '-source',
        component: Source,
        idPrefix,
        mapping
      });
    } // (3) Source expression


    if (type === 'sourceExpression') {
      entries.push({
        id: idPrefix + '-sourceExpression',
        component: SourceExpression,
        idPrefix,
        mapping
      });
    } // (4) Target


    entries.push({
      id: idPrefix + '-target',
      component: Target,
      idPrefix,
      mapping
    }); // (5) Local

    entries.push({
      id: idPrefix + '-local',
      component: Local$1,
      idPrefix,
      mapping
    });
    return entries;
  }

  function Type(props) {
    const {
      idPrefix,
      element,
      mapping
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');

    const getValue = mapping => {
      return getInOutType(mapping);
    };

    const setValue = value => {
      const properties = { ...DEFAULT_PROPS$1,
        [value]: ''
      };
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: mapping,
        properties
      });
    };

    const getOptions = () => {
      const options = [{
        label: translate('Source'),
        value: 'source'
      }, {
        label: translate('Source expression'),
        value: 'sourceExpression'
      }];
      return options;
    };

    return SelectEntry({
      element: mapping,
      id: idPrefix + '-type',
      label: translate('Type'),
      getValue,
      setValue,
      getOptions
    });
  }

  function Source(props) {
    const {
      idPrefix,
      element,
      mapping
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: mapping,
        properties: {
          source: value
        }
      });
    };

    const getValue = mapping => {
      return mapping.get('camunda:source');
    };

    return TextfieldEntry({
      element: mapping,
      id: idPrefix + '-source',
      label: translate('Source'),
      getValue,
      setValue,
      debounce
    });
  }

  function SourceExpression(props) {
    const {
      idPrefix,
      element,
      mapping
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: mapping,
        properties: {
          sourceExpression: value
        }
      });
    };

    const getValue = mapping => {
      return mapping.get('camunda:sourceExpression');
    };

    return TextfieldEntry({
      element: mapping,
      id: idPrefix + '-sourceExpression',
      label: translate('Source expression'),
      getValue,
      setValue,
      debounce
    });
  }

  function Target(props) {
    const {
      idPrefix,
      element,
      mapping
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: mapping,
        properties: {
          target: value
        }
      });
    };

    const getValue = mapping => {
      return mapping.get('camunda:target');
    };

    return TextfieldEntry({
      element: mapping,
      id: idPrefix + '-target',
      label: translate('Target'),
      getValue,
      setValue,
      debounce
    });
  }

  function Local$1(props) {
    const {
      idPrefix,
      element,
      mapping
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');

    const getValue = () => {
      return mapping.get('camunda:local');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: mapping,
        properties: {
          local: value
        }
      });
    };

    return CheckboxEntry({
      element,
      id: idPrefix + '-local',
      label: translate('Local'),
      getValue,
      setValue
    });
  } // helper ///////////////////


  function getInOutType(mapping) {
    let inOutType = '';

    if (typeof mapping.source !== 'undefined') {
      inOutType = 'source';
    } else if (typeof mapping.sourceExpression !== 'undefined') {
      inOutType = 'sourceExpression';
    }

    return inOutType;
  }

  /**
   * Cf. https://docs.camunda.org/manual/latest/reference/bpmn20/custom-extensions/extension-elements/#in
   */

  function InMappingProps({
    element,
    injector
  }) {
    if (!areInMappingsSupported(element)) {
      return null;
    }

    const variableMappings = getInMappings(element) || [];
    const bpmnFactory = injector.get('bpmnFactory'),
          commandStack = injector.get('commandStack');
    const items = variableMappings.map((mapping, index) => {
      const id = element.id + '-inMapping-' + index;
      return {
        id,
        label: mapping.get('target') || '',
        entries: InOutMapping({
          idPrefix: id,
          element,
          mapping
        }),
        autoFocusEntry: id + '-target',
        remove: removeFactory$3({
          commandStack,
          element,
          mapping
        })
      };
    });
    return {
      items,
      add: addFactory$2({
        bpmnFactory,
        commandStack,
        element
      })
    };
  }

  function removeFactory$3({
    commandStack,
    element,
    mapping
  }) {
    return function (event) {
      event.stopPropagation();
      const businessObject = getSignalEventDefinition(element) || getBusinessObject$1(element);
      removeExtensionElements(element, businessObject, mapping, commandStack);
    };
  }

  function addFactory$2({
    bpmnFactory,
    commandStack,
    element
  }) {
    return function (event) {
      event.stopPropagation();
      const businessObject = getSignalEventDefinition(element) || getBusinessObject$1(element);
      const newMapping = createElement('camunda:In', {
        source: '' // source is the default type

      }, null, bpmnFactory);
      addExtensionElements(element, businessObject, newMapping, bpmnFactory, commandStack);
    };
  } // helper ///////////////


  function getInMappings(element) {
    const businessObject = getBusinessObject$1(element);
    const signalEventDefinition = getSignalEventDefinition(businessObject);
    const mappings = getExtensionElementsList(signalEventDefinition || businessObject, 'camunda:In'); // only retrieve relevant mappings here, others are handled in other groups
    // mapping.businessKey => camunda-platform/CallAvtivityProps
    // mapping.variables => camunda-platform/InMappingPropagationProps

    return filter(mappings, function (mapping) {
      return !mapping.businessKey && !(mapping.variables && mapping.variables === 'all');
    });
  }

  function areInMappingsSupported(element) {
    const signalEventDefinition = getSignalEventDefinition(element);

    if (signalEventDefinition) {
      return isAny(element, ['bpmn:IntermediateThrowEvent', 'bpmn:EndEvent']);
    }

    return is$4(element, 'bpmn:CallActivity');
  }

  function InputProps(props) {
    const {
      element,
      injector
    } = props;

    if (!areInputParametersSupported(element)) {
      return null;
    }

    const inputParameters = getInputParameters$1(element) || [];
    const bpmnFactory = injector.get('bpmnFactory'),
          commandStack = injector.get('commandStack');
    const items = inputParameters.map((parameter, index) => {
      const id = element.id + '-inputParameter-' + index;
      return {
        id,
        label: parameter.get('name') || '',
        entries: InputOutputParameter({
          idPrefix: id,
          element,
          parameter
        }),
        autoFocusEntry: id + '-name',
        remove: removeFactory$2({
          element,
          commandStack,
          parameter
        })
      };
    });

    function add(event) {
      event.stopPropagation();
      commandStack.execute('properties-panel.multi-command-executor', AddParameterCmd(element, 'camunda:InputParameter', bpmnFactory));
    }

    return {
      items,
      add
    };
  }

  function removeFactory$2(props) {
    const {
      commandStack,
      element,
      parameter
    } = props;
    return function (event) {
      event.stopPropagation();
      const inputOutput = getInputOutput$1(element);

      if (!inputOutput) {
        return;
      }

      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: inputOutput,
        properties: {
          inputParameters: without(inputOutput.get('inputParameters'), parameter)
        }
      });
    };
  }

  function JobExecutionProps(props) {
    const {
      element
    } = props;
    const businessObject = getBusinessObject$1(element);
    const entries = []; // (1) add retryTimeCycle field for camunda:asyncCapable enabled Elements
    // or TimerEvents

    if (is$4(element, 'camunda:AsyncCapable') && isAsync$1(businessObject) || isTimerEvent(element)) {
      entries.push({
        id: 'retryTimeCycle',
        component: RetryTimeCycle,
        isEdited: isEdited$1
      });
    } // (2) add jobPriority field for camunda:jobPriorized with async enabled
    //  or Processes
    //  or Processes referred to by participants
    //  or TimerEvents


    if (is$4(element, 'camunda:JobPriorized') && isAsync$1(businessObject) || is$4(element, 'bpmn:Process') || is$4(element, 'bpmn:Participant') && businessObject.get('processRef') || isTimerEvent(element)) {
      entries.push({
        id: 'jobPriority',
        component: JobPriority,
        isEdited: isEdited$1
      });
    }

    return entries;
  }

  function JobPriority(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack'),
          translate = useService('translate'),
          debounce = useService('debounceInput');
    const businessObject = is$4(element, 'bpmn:Participant') ? getBusinessObject$1(element).get('processRef') : getBusinessObject$1(element);

    const getValue = () => {
      return businessObject.get('camunda:jobPriority');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:jobPriority': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'jobPriority',
      label: translate('Priority'),
      getValue,
      setValue,
      debounce
    });
  }

  function RetryTimeCycle(props) {
    const {
      element
    } = props;
    const bpmnFactory = useService('bpmnFactory'),
          commandStack = useService('commandStack'),
          translate = useService('translate'),
          debounce = useService('debounceInput');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      const failedJobRetryTimeCycle = getExtensionElementsList(businessObject, 'camunda:FailedJobRetryTimeCycle')[0];
      return failedJobRetryTimeCycle && failedJobRetryTimeCycle.body;
    };

    const setValue = value => {
      const commands = [];
      let extensionElements = businessObject.get('extensionElements'); // (1) ensure extension elements

      if (!extensionElements) {
        extensionElements = createElement('bpmn:ExtensionElements', {
          values: []
        }, businessObject, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: businessObject,
            properties: {
              extensionElements
            }
          }
        });
      } // (2) ensure failedJobRetryTimeCycle


      let failedJobRetryTimeCycle = getExtensionElementsList(businessObject, 'camunda:FailedJobRetryTimeCycle')[0];

      if (!failedJobRetryTimeCycle) {
        failedJobRetryTimeCycle = createElement('camunda:FailedJobRetryTimeCycle', {}, extensionElements, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), failedJobRetryTimeCycle]
            }
          }
        });
      } // (3) update failedJobRetryTimeCycle value


      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: failedJobRetryTimeCycle,
          properties: {
            body: value
          }
        }
      }); // (4) commit all updates

      commandStack.execute('properties-panel.multi-command-executor', commands);
    };

    return TextfieldEntry({
      element,
      id: 'retryTimeCycle',
      label: translate('Retry time cycle'),
      getValue,
      setValue,
      debounce
    });
  } // helper //////////////////

  /**
   * @param  {ModdleElement} bo
   * @return {boolean} a boolean value
   */


  function isAsyncBefore$1(bo) {
    return !!(bo.get('camunda:asyncBefore') || bo.get('camunda:async'));
  }
  /**
   * @param  {ModdleElement} bo
   * @return {boolean}
   */


  function isAsyncAfter$1(bo) {
    return !!bo.get('camunda:asyncAfter');
  }
  /**
   * isAsync - returns true if the attribute 'camunda:asyncAfter' or 'camunda:asyncBefore'
   * is set to true.
   *
   * @param  {ModdleElement} bo
   * @return {boolean}
   */


  function isAsync$1(bo) {
    return isAsyncAfter$1(bo) || isAsyncBefore$1(bo);
  }
  /**
   * isTimerEvent - returns true if the element is a bpmn:Event with a timerEventDefinition
   *
   * @param  {ModdleElement} element
   * @return {boolean}
   */


  function isTimerEvent(element) {
    return is$4(element, 'bpmn:Event') && getTimerEventDefinition$1(element);
  }

  /**
   * @typedef { import('@bpmn-io/properties-panel').EntryDefinition } Entry
   */

  /**
   * @returns {Array<Entry>} entries
   */

  function MultiInstanceProps(props) {
    const {
      element
    } = props;
    const loopCharacteristics = getLoopCharacteristics(element);
    let entries = props.entries || [];

    if (!isMultiInstanceSupported(element)) {
      return entries;
    }

    entries.push({
      id: 'collection',
      component: Collection,
      isEdited: isEdited$1
    }, {
      id: 'elementVariable',
      component: ElementVariable,
      isEdited: isEdited$1
    }, {
      id: 'multiInstanceAsynchronousBefore',
      component: MultiInstanceAsynchronousBefore,
      isEdited: isEdited$7
    }, {
      id: 'multiInstanceAsynchronousAfter',
      component: MultiInstanceAsynchronousAfter,
      isEdited: isEdited$7
    });

    if (isAsync(loopCharacteristics)) {
      entries.push({
        id: 'multiInstanceExclusive',
        component: MultiInstanceExclusive,
        isEdited: checkboxIsEditedInverted
      }, {
        id: 'multiInstanceRetryTimeCycle',
        component: MultiInstanceRetryTimeCycle,
        isEdited: isEdited$1
      });
    }

    return entries;
  }

  function Collection(props) {
    const {
      element
    } = props;
    const debounce = useService('debounceInput');
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const loopCharacteristics = getLoopCharacteristics(element);

    const getValue = () => {
      return getCollection(element);
    };

    const setValue = value => {
      return commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: loopCharacteristics,
        properties: {
          'camunda:collection': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'collection',
      label: translate('Collection'),
      getValue,
      setValue,
      debounce
    });
  }

  function ElementVariable(props) {
    const {
      element
    } = props;
    const debounce = useService('debounceInput');
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const loopCharacteristics = getLoopCharacteristics(element);

    const getValue = () => {
      return getElementVariable(element);
    };

    const setValue = value => {
      return commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: loopCharacteristics,
        properties: {
          'camunda:elementVariable': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'elementVariable',
      label: translate('Element variable'),
      getValue,
      setValue,
      debounce
    });
  }

  function MultiInstanceAsynchronousBefore(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const loopCharacteristics = getLoopCharacteristics(element);

    const getValue = () => {
      return isAsyncBefore(loopCharacteristics);
    };

    const setValue = value => {
      // overwrite the legacy `async` property, we will use the more explicit `asyncBefore`
      const properties = {
        'camunda:asyncBefore': value,
        'camunda:async': undefined
      };
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: loopCharacteristics,
        properties
      });
    };

    return CheckboxEntry({
      element,
      id: 'multiInstanceAsynchronousBefore',
      label: translate('Asynchronous before'),
      getValue,
      setValue
    });
  }

  function MultiInstanceAsynchronousAfter(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const loopCharacteristics = getLoopCharacteristics(element);

    const getValue = () => {
      return isAsyncAfter(loopCharacteristics);
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: loopCharacteristics,
        properties: {
          'camunda:asyncAfter': value
        }
      });
    };

    return CheckboxEntry({
      element,
      id: 'multiInstanceAsynchronousAfter',
      label: translate('Asynchronous after'),
      getValue,
      setValue
    });
  }

  function MultiInstanceExclusive(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack'),
          translate = useService('translate');
    const loopCharacteristics = getLoopCharacteristics(element);

    const getValue = () => {
      return isExclusive(loopCharacteristics);
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: loopCharacteristics,
        properties: {
          'camunda:exclusive': value
        }
      });
    };

    return CheckboxEntry({
      element,
      id: 'multiInstanceExclusive',
      label: translate('Exclusive'),
      getValue,
      setValue
    });
  }

  function MultiInstanceRetryTimeCycle(props) {
    const {
      element
    } = props;
    const bpmnFactory = useService('bpmnFactory'),
          commandStack = useService('commandStack'),
          translate = useService('translate'),
          debounce = useService('debounceInput');
    const loopCharacteristics = getLoopCharacteristics(element);

    const getValue = () => {
      const failedJobRetryTimeCycle = getExtensionElementsList(loopCharacteristics, 'camunda:FailedJobRetryTimeCycle')[0];
      return failedJobRetryTimeCycle && failedJobRetryTimeCycle.body;
    };

    const setValue = value => {
      const commands = [];
      let extensionElements = loopCharacteristics.get('extensionElements'); // (1) ensure extension elements

      if (!extensionElements) {
        extensionElements = createElement('bpmn:ExtensionElements', {
          values: []
        }, loopCharacteristics, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: loopCharacteristics,
            properties: {
              extensionElements
            }
          }
        });
      } // (2) ensure failedJobRetryTimeCycle


      let failedJobRetryTimeCycle = getExtensionElementsList(loopCharacteristics, 'camunda:FailedJobRetryTimeCycle')[0];

      if (!failedJobRetryTimeCycle) {
        failedJobRetryTimeCycle = createElement('camunda:FailedJobRetryTimeCycle', {}, extensionElements, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element: loopCharacteristics,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), failedJobRetryTimeCycle]
            }
          }
        });
      } // (3) update failedJobRetryTimeCycle value


      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: failedJobRetryTimeCycle,
          properties: {
            body: value
          }
        }
      }); // (4) commit all updates

      commandStack.execute('properties-panel.multi-command-executor', commands);
    };

    return TextfieldEntry({
      element,
      id: 'multiInstanceRetryTimeCycle',
      label: translate('Retry time cycle'),
      getValue,
      setValue,
      debounce
    });
  } // helper ////////////////////////////
  // generic ///////////////////////////

  /**
   * isMultiInstanceSupported - check whether given element supports camunda specific props
   * for multiInstance (ref. <camunda:Cllectable>).
   *
   * @param {djs.model.Base} element
   * @return {boolean}
   */


  function isMultiInstanceSupported(element) {
    const loopCharacteristics = getLoopCharacteristics(element);
    return !!loopCharacteristics && is$4(loopCharacteristics, 'camunda:Collectable');
  }
  /**
   * getProperty - get a property value of the loop characteristics.
   *
   * @param {djs.model.Base} element
   * @param {string} propertyName
   *
   * @return {any} the property value
   */


  function getProperty(element, propertyName) {
    var loopCharacteristics = getLoopCharacteristics(element);
    return loopCharacteristics && loopCharacteristics.get(propertyName);
  }
  /**
   * getLoopCharacteristics - get loopCharacteristics of a given element.
   *
   * @param {djs.model.Base} element
   * @return {ModdleElement<bpmn:MultiInstanceLoopCharacteristics> | undefined}
   */


  function getLoopCharacteristics(element) {
    const bo = getBusinessObject$1(element);
    return bo.loopCharacteristics;
  } // collection

  /**
   * getCollection - get the 'camunda:collection' attribute value of the loop characteristics.
   *
   * @param {djs.model.Base} element
   *
   * @return {string} the 'camunda:collection' value
   */


  function getCollection(element) {
    return getProperty(element, 'camunda:collection');
  } // elementVariable

  /**
   * getElementVariable - get the 'camunda:elementVariable' attribute value of the loop characteristics.
   *
   * @param {djs.model.Base} element
   *
   * @return {string} the 'camunda:elementVariable' value
   */


  function getElementVariable(element) {
    return getProperty(element, 'camunda:elementVariable');
  } // asyncBefore asyncAfter

  /**
   * Returns true if the attribute 'camunda:asyncBefore' is set
   * to true.
   *
   * @param  {ModdleElement} bo
   *
   * @return {boolean} a boolean value
   */


  function isAsyncBefore(bo) {
    return !!(bo.get('camunda:asyncBefore') || bo.get('camunda:async'));
  }
  /**
   * Returns true if the attribute 'camunda:asyncAfter' is set
   * to true.
   *
   * @param  {ModdleElement} bo
   *
   * @return {boolean} a boolean value
   */


  function isAsyncAfter(bo) {
    return !!bo.get('camunda:asyncAfter');
  }
  /**
   * Returns true if the attribute 'camunda:exclusive' is set
   * to true.
   *
   * @param  {ModdleElement} bo
   *
   * @return {boolean} a boolean value
   */


  function isExclusive(bo) {
    return !!bo.get('camunda:exclusive');
  }
  /**
   * isAsync - returns true if the attribute 'camunda:asyncAfter' or 'camunda:asyncBefore'
   * is set to true.
   *
   * @param  {ModdleElement} bo
   * @return {boolean}
   */


  function isAsync(bo) {
    return isAsyncAfter(bo) || isAsyncBefore(bo);
  } // Checkbox


  function checkboxIsEditedInverted(node) {
    return node && !node.checked;
  }

  /**
   * Cf. https://docs.camunda.org/manual/7.15/reference/bpmn20/subprocesses/call-activity/#passing-variables
   */

  function OutMappingPropagationProps(props) {
    const {
      element
    } = props;

    if (!areOutMappingsSupported$1(element)) {
      return [];
    }

    const entries = [{
      id: 'outMapping-propagation',
      component: PropagateAll,
      isEdited: isEdited$7
    }];

    if (isPropagateAll(element)) {
      entries.push({
        id: 'outMapping-propagation-local',
        component: Local,
        isEdited: isEdited$7
      });
    }

    return entries;
  }

  function PropagateAll(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const bpmnFactory = useService('bpmnFactory');
    const translate = useService('translate');

    const getValue = () => {
      return isPropagateAll(element);
    };

    const setValue = value => {
      if (value) {
        addOutMapping();
      } else {
        removeOutMapping();
      }
    };

    function addOutMapping() {
      const businessObject = getBusinessObject$1(element);
      const mapping = createElement('camunda:Out', {
        variables: 'all'
      }, null, bpmnFactory);
      addExtensionElements(element, businessObject, mapping, bpmnFactory, commandStack);
    }

    function removeOutMapping() {
      const businessObject = getBusinessObject$1(element);
      const mappings = findRelevantOutMappings(element);
      removeExtensionElements(element, businessObject, mappings, commandStack);
    }

    return CheckboxEntry({
      id: 'outMapping-propagation',
      label: translate('Propagate all variables'),
      getValue,
      setValue
    });
  }

  function Local(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const mapping = findRelevantOutMappings(element)[0];

    const getValue = () => {
      return mapping.get('camunda:local');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: mapping,
        properties: {
          local: value
        }
      });
    };

    return CheckboxEntry({
      element,
      id: 'outMapping-propagation-local',
      label: translate('Local'),
      getValue,
      setValue
    });
  } // helper //////////////////////////


  function areOutMappingsSupported$1(element) {
    return is$4(element, 'bpmn:CallActivity');
  }

  function getOutMappings$2(element) {
    const businessObject = getBusinessObject$1(element);
    return getExtensionElementsList(businessObject, 'camunda:Out');
  }

  function findRelevantOutMappings(element) {
    const inMappings = getOutMappings$2(element);
    return filter(inMappings, function (mapping) {
      const variables = mapping.get('variables');
      return variables && variables === 'all';
    });
  }

  function isPropagateAll(element) {
    const mappings = findRelevantOutMappings(element);
    return !!mappings.length;
  }

  /**
   * Cf. https://docs.camunda.org/manual/latest/reference/bpmn20/custom-extensions/extension-elements/#out
   */

  function OutMappingProps({
    element,
    injector
  }) {
    if (!areOutMappingsSupported(element)) {
      return null;
    }

    const variableMappings = getOutMappings$1(element) || [];
    const bpmnFactory = injector.get('bpmnFactory'),
          commandStack = injector.get('commandStack');
    const items = variableMappings.map((mapping, index) => {
      const id = element.id + '-outMapping-' + index;
      return {
        id,
        label: mapping.get('target') || '',
        entries: InOutMapping({
          idPrefix: id,
          element,
          mapping
        }),
        autoFocusEntry: id + '-target',
        remove: removeFactory$1({
          commandStack,
          element,
          mapping
        })
      };
    });
    return {
      items,
      add: addFactory$1({
        bpmnFactory,
        commandStack,
        element
      })
    };
  }

  function removeFactory$1({
    commandStack,
    element,
    mapping
  }) {
    return function (event) {
      event.stopPropagation();
      const businessObject = getBusinessObject$1(element);
      removeExtensionElements(element, businessObject, mapping, commandStack);
    };
  }

  function addFactory$1({
    bpmnFactory,
    commandStack,
    element
  }) {
    return function (event) {
      event.stopPropagation();
      const businessObject = getBusinessObject$1(element);
      const newMapping = createElement('camunda:Out', {
        source: '' // source is the default type

      }, null, bpmnFactory);
      addExtensionElements(element, businessObject, newMapping, bpmnFactory, commandStack);
    };
  } // helper ///////////////


  function getOutMappings$1(element) {
    const businessObject = getBusinessObject$1(element);
    const mappings = getExtensionElementsList(businessObject, 'camunda:Out'); // only retrieve relevant mappings here, others are handled in other groups
    // mapping.businessKey => camunda-platform/CallAvtivityProps
    // mapping.variables => camunda-platform/OutMappingPropagationProps

    return filter(mappings, function (mapping) {
      return !mapping.businessKey && !(mapping.variables && mapping.variables === 'all');
    });
  }

  function areOutMappingsSupported(element) {
    return is$4(element, 'bpmn:CallActivity');
  }

  function OutputProps({
    element,
    injector
  }) {
    if (!areOutputParametersSupported(element)) {
      return null;
    }

    const outputParameters = getOutputParameters$1(element) || [];
    const bpmnFactory = injector.get('bpmnFactory'),
          commandStack = injector.get('commandStack');
    const items = outputParameters.map((parameter, index) => {
      const id = element.id + '-outputParameter-' + index;
      return {
        id,
        label: parameter.get('name') || '',
        entries: InputOutputParameter({
          idPrefix: id,
          element,
          parameter
        }),
        autoFocusEntry: id + '-name',
        remove: removeFactory({
          commandStack,
          element,
          parameter
        })
      };
    });
    return {
      items,
      add: addFactory({
        bpmnFactory,
        commandStack,
        element
      })
    };
  }

  function removeFactory({
    commandStack,
    element,
    parameter
  }) {
    return function (event) {
      event.stopPropagation();
      const inputOutput = getInputOutput$1(element);

      if (!inputOutput) {
        return;
      }

      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: inputOutput,
        properties: {
          outputParameters: without(inputOutput.get('outputParameters'), parameter)
        }
      });
    };
  }

  function addFactory({
    bpmnFactory,
    commandStack,
    element
  }) {
    return function (event) {
      event.stopPropagation();
      commandStack.execute('properties-panel.multi-command-executor', AddParameterCmd(element, 'camunda:OutputParameter', bpmnFactory));
    };
  }

  const LISTENER_ALLOWED_TYPES = ['bpmn:Activity', 'bpmn:Event', 'bpmn:Gateway', 'bpmn:SequenceFlow', 'bpmn:Process', 'bpmn:Participant'];
  const SCRIPT_PROPS = {
    'script': undefined,
    'resource': undefined,
    'scriptFormat': undefined
  };
  const CLASS_PROPS = {
    'class': undefined
  };
  const EXPRESSION_PROPS = {
    'expression': undefined
  };
  const DELEGATE_EXPRESSION_PROPS = {
    'delegateExpression': undefined
  };
  const DEFAULT_PROPS = { ...SCRIPT_PROPS,
    ...CLASS_PROPS,
    ...EXPRESSION_PROPS,
    ...DELEGATE_EXPRESSION_PROPS
  };
  const DEFAULT_EVENT_PROPS = {
    'eventDefinitions': undefined,
    'event': undefined
  };
  const IMPLEMENTATION_TYPE_TO_LABEL = {
    class: 'Java class',
    expression: 'Expression',
    delegateExpression: 'Delegate expression',
    script: 'Script'
  };
  const EVENT_TO_LABEL = {
    start: 'Start',
    end: 'End',
    take: 'Take',
    create: 'Create',
    assignment: 'Assignment',
    complete: 'Complete',
    delete: 'Delete',
    update: 'Update',
    timeout: 'Timeout'
  };
  /**
   * Cf. https://docs.camunda.org/manual/latest/user-guide/process-engine/delegation-code/#execution-listener
   */

  function ExecutionListenerProps({
    element,
    injector
  }) {
    if (!isAny(element, LISTENER_ALLOWED_TYPES)) {
      return;
    }

    const bpmnFactory = injector.get('bpmnFactory'),
          commandStack = injector.get('commandStack');

    if (is$4(element, 'bpmn:Participant') && !element.businessObject.processRef) {
      return;
    }

    const businessObject = getListenersContainer(element);
    const listeners = getExtensionElementsList(businessObject, 'camunda:ExecutionListener');
    return {
      items: listeners.map((listener, index) => {
        const id = `${element.id}-executionListener-${index}`; // @TODO(barmac): Find a way to pass translate for internationalized label.

        return {
          id,
          label: getListenerLabel(listener),
          entries: ExecutionListener({
            idPrefix: id,
            element,
            listener
          }),
          remove: removeListenerFactory({
            element,
            listener,
            commandStack
          })
        };
      }),
      add: addExecutionListenerFactory({
        bpmnFactory,
        commandStack,
        element
      })
    };
  }

  function ExecutionListener(props) {
    const {
      idPrefix,
      element,
      listener
    } = props;
    return [{
      id: `${idPrefix}-eventType`,
      component: EventType,
      listener
    }, {
      id: `${idPrefix}-listenerType`,
      component: ListenerType,
      listener
    }, ...ImplementationDetails({
      idPrefix,
      element,
      listener
    }), {
      id: `${idPrefix}-fields`,
      component: Fields,
      listener
    }];
  }

  function TaskListenerProps({
    element,
    injector
  }) {
    if (!is$4(element, 'bpmn:UserTask')) {
      return;
    }

    const bpmnFactory = injector.get('bpmnFactory'),
          commandStack = injector.get('commandStack');
    const businessObject = getListenersContainer(element);
    const listeners = getExtensionElementsList(businessObject, 'camunda:TaskListener');
    return {
      items: listeners.map((listener, index) => {
        const id = `${element.id}-taskListener-${index}`; // @TODO(barmac): Find a way to pass translate for internationalized label.

        return {
          id,
          label: getListenerLabel(listener),
          entries: TaskListener({
            idPrefix: id,
            element,
            listener
          }),
          remove: removeListenerFactory({
            element,
            listener,
            commandStack
          })
        };
      }),
      add: addTaskListenerFactory({
        bpmnFactory,
        commandStack,
        element
      })
    };
  }

  function TaskListener(props) {
    const {
      idPrefix,
      element,
      listener
    } = props;
    return [{
      id: `${idPrefix}-eventType`,
      component: EventType,
      listener
    }, {
      id: `${idPrefix}-listenerId`,
      component: ListenerId,
      listener
    }, {
      id: `${idPrefix}-listenerType`,
      component: ListenerType,
      listener
    }, ...ImplementationDetails({
      idPrefix,
      element,
      listener
    }), ...EventTypeDetails({
      idPrefix,
      element,
      listener
    }), {
      id: `${idPrefix}-fields`,
      component: Fields,
      listener
    }];
  }

  function removeListenerFactory({
    element,
    listener,
    commandStack
  }) {
    return function removeListener(event) {
      event.stopPropagation();
      removeExtensionElements(element, getListenersContainer(element), listener, commandStack);
    };
  }

  function EventType({
    id,
    element,
    listener
  }) {
    const translate = useService('translate');
    const bpmnFactory = useService('bpmnFactory');
    const commandStack = useService('commandStack');

    function getValue() {
      return listener.get('event');
    }

    function setValue(value) {
      const properties = getDefaultEventTypeProperties(value, bpmnFactory);
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: listener,
        properties
      });
    }

    function getOptions() {
      if (is$4(listener, 'camunda:TaskListener')) {
        return [{
          value: 'create',
          label: translate('create')
        }, {
          value: 'assignment',
          label: translate('assignment')
        }, {
          value: 'complete',
          label: translate('complete')
        }, {
          value: 'delete',
          label: translate('delete')
        }, {
          value: 'update',
          label: translate('update')
        }, {
          value: 'timeout',
          label: translate('timeout')
        }];
      }

      if (is$4(element, 'bpmn:SequenceFlow')) {
        return [{
          value: 'take',
          label: translate('take')
        }];
      }

      return [{
        value: 'start',
        label: translate('start')
      }, {
        value: 'end',
        label: translate('end')
      }];
    }

    return o$1(SelectEntry, {
      id: id,
      label: translate('Event type'),
      getValue: getValue,
      setValue: setValue,
      getOptions: getOptions
    });
  }

  function ListenerId({
    id,
    element,
    listener
  }) {
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const commandStack = useService('commandStack');
    let options = {
      element,
      id: id,
      label: translate('Listener ID'),
      debounce,
      isEdited: isEdited$1,
      setValue: value => {
        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: listener,
          properties: {
            'camunda:id': value
          }
        });
      },
      getValue: () => {
        return listener.get('camunda:id');
      }
    };
    return TextfieldEntry(options);
  }

  function ListenerType({
    id,
    element,
    listener
  }) {
    const modeling = useService('modeling');
    const translate = useService('translate');
    const bpmnFactory = useService('bpmnFactory');

    function getValue() {
      return getListenerType(listener);
    }

    function setValue(value) {
      const properties = getDefaultImplementationProperties(value, bpmnFactory);
      modeling.updateModdleProperties(element, listener, properties);
    }

    function getOptions() {
      return getListenerTypeOptions(translate);
    }

    return o$1(SelectEntry, {
      id: id,
      label: translate('Listener type'),
      getValue: getValue,
      setValue: setValue,
      getOptions: getOptions
    });
  }

  function ImplementationDetails(props) {
    const {
      idPrefix,
      element,
      listener
    } = props;
    const type = getListenerType(listener);

    if (type === 'class') {
      return [{
        id: getPrefixedId(idPrefix, 'javaClass'),
        component: JavaClass,
        businessObject: listener
      }];
    } else if (type === 'expression') {
      return [{
        id: getPrefixedId(idPrefix, 'expression'),
        component: Expression$1,
        businessObject: listener
      }];
    } else if (type === 'delegateExpression') {
      return [{
        id: getPrefixedId(idPrefix, 'delegateExpression'),
        component: DelegateExpression,
        businessObject: listener
      }];
    } else if (type === 'script') {
      return ScriptProps({
        element,
        script: listener.get('script'),
        prefix: idPrefix
      });
    } // should never happen


    return [];
  }

  function EventTypeDetails(props) {
    const {
      idPrefix,
      element,
      listener
    } = props;
    const type = listener.get('event');

    if (type === 'timeout') {
      return TimerProps$2({
        element,
        listener,
        timerEventDefinition: getTimerEventDefinition$1(listener),
        idPrefix: idPrefix
      });
    }

    return [];
  }

  function Field(props) {
    const {
      element,
      id: idPrefix,
      index,
      item: field,
      open
    } = props;
    const fieldId = `${idPrefix}-field-${index}`;
    return o$1(CollapsibleEntry, {
      id: fieldId,
      element: element,
      entries: FieldInjection({
        element,
        field,
        idPrefix: fieldId
      }),
      label: field.get('name') || '<empty>',
      open: open
    });
  }

  function Fields(props) {
    const {
      id,
      element,
      listener
    } = props;
    const bpmnFactory = useService('bpmnFactory');
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const fields = listener.get('fields');

    function addField() {
      const field = createElement('camunda:Field', {}, listener, bpmnFactory);
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: listener,
        properties: {
          fields: [...listener.get('fields'), field]
        }
      });
    }

    function removeField(field) {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: listener,
        properties: {
          fields: without(listener.get('fields'), field)
        }
      });
    }

    return o$1(List, {
      id: id,
      element: element,
      label: translate('Field injection'),
      items: fields,
      component: Field,
      onAdd: addField,
      onRemove: removeField,
      compareFn: compareName,
      autoFocusEntry: true
    });
  }

  function addListenerFactory({
    bpmnFactory,
    commandStack,
    element,
    listenerGroup
  }) {
    return function (event) {
      event.stopPropagation();
      const listener = bpmnFactory.create(listenerGroup, {
        event: getDefaultEvent(element, listenerGroup),
        class: ''
      });
      const businessObject = getListenersContainer(element);
      addExtensionElements(element, businessObject, listener, bpmnFactory, commandStack);
    };
  }

  function addTaskListenerFactory(props) {
    return addListenerFactory({ ...props,
      listenerGroup: 'camunda:TaskListener'
    });
  }

  function addExecutionListenerFactory(props) {
    return addListenerFactory({ ...props,
      listenerGroup: 'camunda:ExecutionListener'
    });
  } // helper

  /**
   * Get a readable label for a listener.
   *
   * @param {ModdleElement} listener
   * @param {string => string} [translate]
   */


  function getListenerLabel(listener, translate = value => value) {
    const event = listener.get('event');
    const implementationType = getListenerType(listener);
    return `${translate(EVENT_TO_LABEL[event])}: ${translate(IMPLEMENTATION_TYPE_TO_LABEL[implementationType])}`;
  }

  function getListenerTypeOptions(translate) {
    return Object.entries(IMPLEMENTATION_TYPE_TO_LABEL).map(([value, label]) => ({
      value,
      label: translate(label)
    }));
  }

  function getListenerType(listener) {
    return getImplementationType(listener);
  }

  function getDefaultEvent(element, listenerGroup) {
    if (listenerGroup === 'camunda:TaskListener') return 'create';
    return is$4(element, 'bpmn:SequenceFlow') ? 'take' : 'start';
  }

  function getDefaultImplementationProperties(type, bpmnFactory) {
    switch (type) {
      case 'class':
        return { ...DEFAULT_PROPS,
          'class': ''
        };

      case 'expression':
        return { ...DEFAULT_PROPS,
          'expression': ''
        };

      case 'delegateExpression':
        return { ...DEFAULT_PROPS,
          'delegateExpression': ''
        };

      case 'script':
        return { ...DEFAULT_PROPS,
          'script': bpmnFactory.create('camunda:Script')
        };
    }
  }

  function getDefaultEventTypeProperties(type, bpmnFactory) {
    switch (type) {
      case 'timeout':
        return { ...DEFAULT_EVENT_PROPS,
          eventDefinitions: [bpmnFactory.create('bpmn:TimerEventDefinition')],
          event: type
        };

      default:
        return { ...DEFAULT_EVENT_PROPS,
          event: type
        };
    }
  }

  function getPrefixedId(prefix, id) {
    return `${prefix}-${id}`;
  }

  function compareName(field, anotherField) {
    const [name = '', anotherName = ''] = [field.name, anotherField.name];
    return name === anotherName ? 0 : name > anotherName ? 1 : -1;
  }

  function getListenersContainer(element) {
    const businessObject = getBusinessObject$1(element);
    return businessObject.get('processRef') || businessObject;
  }

  var dist = {};

  Object.defineProperty(dist, '__esModule', {
    value: true
  });

  var minDash = require$$0;
  /**
   * Get a inputOutput from the business object
   *
   * @param {ModdleElement} element
   *
   * @return {ModdleElement} the inputOutput object
   */


  function getInputOutput(element) {
    return (getElements(element, 'camunda:InputOutput') || [])[0];
  }
  /**
   * Return all input parameters existing in the business object, and
   * an empty array if none exist.
   *
   * @param  {ModdleElement} element
   *
   * @return {Array<ModdleElement>} a list of input parameter objects
   */


  function getInputParameters(element) {
    return getParameters(element, 'inputParameters');
  }
  /**
   * Return all output parameters existing in the business object, and
   * an empty array if none exist.
   *
   * @param  {ModdleElement} element
   * @param  {boolean} insideConnector
   *
   * @return {Array<ModdleElement>} a list of output parameter objects
   */


  function getOutputParameters(element) {
    return getParameters(element, 'outputParameters');
  }
  /**
   * Return all form fields existing in the business object, and
   * an empty array if none exist.
   *
   * @param {ModdleElement} element
   *
   * @return {Array<ModdleElement>} a list of form fields
   */


  function getFormFields(element) {
    var formData = getFormData(element);
    return formData && formData.get('fields') || [];
  }
  /**
   * Return form data existing in the business object
   *
   * @param {ModdleElement} element
   *
   * @return {ModdleElement}
   */


  function getFormData(element) {
    return getElements(element, 'camunda:FormData')[0];
  }
  /**
   * Return out mappings existing in the business object
   *
   * @param {ModdleElement} element
   *
   * @return {Array<ModdleElement>}
   */


  function getOutMappings(element) {
    return getElements(element, 'camunda:Out');
  } // helpers //////////


  function getElements(element, type, property) {
    var elements = getExtensionElements$1(element, type);
    return !property ? elements : (elements[0] || {})[property] || [];
  }

  function getParameters(element, property) {
    var inputOutput = getInputOutput(element);
    return inputOutput && inputOutput.get(property) || [];
  }

  function getExtensionElements$1(element, type) {
    var elements = [];
    var extensionElements = element.get('extensionElements');

    if (typeof extensionElements !== 'undefined') {
      var extensionValues = extensionElements.get('values');

      if (typeof extensionValues !== 'undefined') {
        elements = minDash.filter(extensionValues, function (value) {
          return is$2(value, type);
        });
      }
    }

    return elements;
  }

  function is$2(element, type) {
    return element && typeof element.$instanceOf === 'function' && element.$instanceOf(type);
  }
  /**
   * Get all parent elements for a given element.
   *
   * @param {ModdleElement|string} element
   *
   * @returns {Array<ModdleElement>}
   */


  function getParents(element) {
    var parents = [];
    var current = element;

    while (current.$parent) {
      parents.push(current.$parent);
      current = current.$parent;
    }

    return parents;
  }
  /**
   * Iterate over each element in a collection, calling the iterator function `fn`
   * with (element, index, recursionDepth).
   *
   * Recurse into all elements that are returned by `fn`.
   *
   * @param  {Object|Array<Object>} elements
   * @param  {Function} fn iterator function called with (element, index, recursionDepth)
   * @param  {number} [depth] maximum recursion depth
   */


  function eachElement(elements, fn, depth) {
    depth = depth || 0;

    if (!minDash.isArray(elements)) {
      elements = [elements];
    }

    minDash.forEach(elements, function (s, i) {
      var filter = fn(s, i, depth);

      if (minDash.isArray(filter) && filter.length) {
        eachElement(filter, fn, depth + 1);
      }
    });
  }
  /**
   * Adds an element to a collection and returns true if the
   * element was added.
   *
   * @param {Array<Object>} elements
   * @param {Object} e
   * @param {boolean} unique
   */


  function add(elements, e, unique) {
    var canAdd = !unique || elements.indexOf(e) === -1;

    if (canAdd) {
      elements.push(e);
    }

    return canAdd;
  }
  /**
   * Collects self + flow elements up to a given depth from a list of elements.
   *
   * @param  {ModdleElement|Array<ModdleElement>} elements the elements to select the flowElements from
   * @param  {boolean} unique whether to return a unique result set (no duplicates)
   * @param  {number} maxDepth the depth to search through or -1 for infinite
   *
   * @return {Array<ModdleElement>} found elements
   */


  function selfAndFlowElements(elements, unique, maxDepth) {
    var result = [],
        processedFlowElements = [];
    eachElement(elements, function (element, i, depth) {
      add(result, element, unique);
      var flowElements = element.flowElements; // max traversal depth not reached yet

      if (maxDepth === -1 || depth < maxDepth) {
        // flowElements exist && flowElements not yet processed
        if (flowElements && add(processedFlowElements, flowElements, unique)) {
          return flowElements;
        }
      }
    });
    return result;
  }
  /**
   * Return self + ALL flowElements for a number of elements
   *
   * @param  {Array<ModdleElement>} elements to query
   * @param  {boolean} allowDuplicates to allow duplicates in the result set
   *
   * @return {Array<ModdleElement>} the collected elements
   */


  function selfAndAllFlowElements(elements, allowDuplicates) {
    return selfAndFlowElements(elements, !allowDuplicates, -1);
  }
  /**
   * Return full moddle element for given element id
   *
   * @param {string} elementId
   * @param {ModdleElement} rootElement
   *
   * @returns {ModdleElement}
   */


  function getElement(elementId, rootElement) {
    var allElements = selfAndAllFlowElements(rootElement);
    return minDash.find(allElements, function (element) {
      return element.id === elementId;
    });
  }

  function addVariableToList(variablesList, newVariable) {
    var foundIdx = minDash.findIndex(variablesList, function (variable) {
      return variable.name === newVariable.name && variable.scope === newVariable.scope;
    });

    if (foundIdx >= 0) {
      variablesList[foundIdx].origin = combineArrays$1(variablesList[foundIdx].origin, newVariable.origin);
    } else {
      variablesList.push(newVariable);
    }
  }
  /**
   * Creates new process variable definition object
   * Identifies correct (highest) scope, in which variable is available
   *
   * @param {ModdleElement} flowElement
   * @param {String} name
   * @param {ModdleElement} defaultScope
   *
   * @returns {ProcessVariable}
   */


  function createProcessVariable(flowElement, name, defaultScope) {
    var scope = getScope$1(flowElement, defaultScope, name);
    return {
      name: name,
      origin: [flowElement],
      scope: scope
    };
  } // helpers ////////////////////

  /**
   * Set parent container if it defines it's own scope for the variable, so
   * when it defines an input mapping for it. Otherwise returns the default global scope
   */


  function getScope$1(element, globalScope, variableName) {
    var parents = getParents(element);
    var scopedParent = minDash.find(parents, function (parent) {
      return is$1(parent, 'bpmn:SubProcess') && hasInputParameter(parent, variableName);
    });
    return scopedParent ? scopedParent : globalScope;
  }

  function is$1(element, type) {
    return element && typeof element.$instanceOf === 'function' && element.$instanceOf(type);
  }

  function hasInputParameter(element, name) {
    return minDash.find(getInputParameters(element), function (input) {
      return input.name === name;
    });
  }

  function combineArrays$1(a, b) {
    return a.concat(b);
  }
  /**
   * Retrieves process variables defined in output parameters, e.g.
   *
   * <camunda:inputOutput>
   *   <camunda:outputParameter name="variable1">200</camunda:outputParameter>
   *   <camunda:outputParameter name="variable2">${myLocalVar + 20}</camunda:outputParameter>
   * </camunda:inputOutput>
   *
   * => Adds two variables "variable1" & "variable2" to the list.
   *
   */


  function extractOutputParameters(options) {
    var elements = options.elements,
        containerElement = options.containerElement,
        processVariables = options.processVariables;

    if (!minDash.isArray(elements)) {
      elements = [elements];
    }

    minDash.forEach(elements, function (element) {
      // variables are created by output parameters
      var outputParameters = getOutputParameters(element); // extract all variables with correct scope

      minDash.forEach(outputParameters, function (parameter) {
        var newVariable = createProcessVariable(element, parameter.name, containerElement);
        addVariableToList(processVariables, newVariable);
      });
    });
    return processVariables;
  }
  /**
   * Retrieves process variables defined in result variables, e.g.
   *
   * <bpmn:sendTask
   *   id="SendTask_1"
   *   camunda:expression="${myBean.ready}"
   *   camunda:resultVariable="variable1"
   * />
   *
   * => Adds one variable "variable1"to the list.
   *
   */


  function extractResultVariables(options) {
    var elements = options.elements,
        containerElement = options.containerElement,
        processVariables = options.processVariables;

    if (!minDash.isArray(elements)) {
      elements = [elements];
    }

    minDash.forEach(elements, function (element) {
      var resultVariable = getResultVariable(element);

      if (resultVariable) {
        var newVariable = createProcessVariable(element, resultVariable, containerElement);
        addVariableToList(processVariables, newVariable);
      }
    });
    return processVariables;
  } // helpers ///////////////////////


  function getResultVariable(element) {
    return element.get('camunda:resultVariable');
  }
  /**
   * Retrieves process variables defined in form fields, e.g.
   *
   * <camunda:formData>
   *   <camunda:formField id="variable1" />
   *   <camunda:formField id="variable2" />
   * </camunda:formData>
   *
   * => Adds two variables "variable1" & "variable2" to the list.
   *
   */


  function extractFormFields(options) {
    var elements = options.elements,
        containerElement = options.containerElement,
        processVariables = options.processVariables;

    if (!minDash.isArray(elements)) {
      elements = [elements];
    }

    minDash.forEach(elements, function (element) {
      var formFields = getFormFields(element); // extract all variables with correct scope

      minDash.forEach(formFields, function (field) {
        var newVariable = createProcessVariable(element, field.id, containerElement);
        addVariableToList(processVariables, newVariable);
      });
    });
    return processVariables;
  }
  /**
   * Retrieves process variables defined in output mappings and
   * ignores local variables, e.g.
   *
   * <bpmn:extensionElements>
   *   <camunda:out sourceExpression="${myBean.ready}" target="variable1" />
   *   <camunda:out source="foo" target="variableLocal" local="true" />
   * </bpmn:extensionElements>
   *
   * => Adds one variable "variable1" to the list.
   *
   */


  function extractOutMappings(options) {
    var elements = options.elements,
        containerElement = options.containerElement,
        processVariables = options.processVariables;

    if (!minDash.isArray(elements)) {
      elements = [elements];
    }

    minDash.forEach(elements, function (element) {
      var outMappings = getOutMappings(element); // extract all variables with correct scope

      minDash.forEach(outMappings, function (mapping) {
        // do not use variables marked as <local>
        if (mapping.local) {
          return;
        }

        var newVariable = createProcessVariable(element, mapping.target, containerElement);
        addVariableToList(processVariables, newVariable);
      });
    });
    return processVariables;
  }
  /**
   *
   * @param {ModdleElement} element
   * @param {string} [type] - optional
   *
   * @return {Array<ModdleElement>|undefined} collection of event definitions or none
   */


  function getEventDefinitions(element, type) {
    var eventDefinitions = element.eventDefinitions;

    if (!eventDefinitions || !type) {
      return eventDefinitions;
    }

    return minDash.filter(eventDefinitions, function (definition) {
      return is(definition, type);
    });
  }
  /**
   * Returns error event definitions for a given element.
   *
   * @param {ModdleElement} element
   *
   * @return {Array<ModdleElement>} collection of error event definitions
   */


  function getErrorEventDefinitions(element) {
    return getEventDefinitions(element, 'bpmn:ErrorEventDefinition');
  }
  /**
   * Returns escalation event definitions for a given element.
   *
   * @param {ModdleElement} element
   *
   * @return {Array<ModdleElement>} collection of escalation event definitions
   */


  function getEscalationEventDefinitions(element) {
    return getEventDefinitions(element, 'bpmn:EscalationEventDefinition');
  } // helper ////////////////


  function is(element, type) {
    return element && typeof element.$instanceOf === 'function' && element.$instanceOf(type);
  }
  /**
   * Retrieves process variables defined in event definitions, e.g.
   *
   * <bpmn:escalationEventDefinition
   *   id="EscalationEventDefinition_1"
   *   escalationRef="Escalation_1"
   *   camunda:escalationCodeVariable="variable1"
   * />
   *
   * => Adds one variable "variable1" to the list.
   *
   * <bpmn:errorEventDefinition
   *   id="ErrorEventDefinition_1"
   *   errorRef="Error_1"
   *   camunda:errorCodeVariable="variable2"
   *   camunda:errorMessageVariable="variable3"
   * />
   *
   * => Adds two variables "variable2" & "variable3" to the list.
   *
   */


  function extractEventDefinitionVariables(options) {
    var elements = options.elements,
        containerElement = options.containerElement,
        processVariables = options.processVariables;

    var addVariable = function (element, name) {
      var newVariable = createProcessVariable(element, name, containerElement);
      addVariableToList(processVariables, newVariable);
    };

    if (!minDash.isArray(elements)) {
      elements = [elements];
    }

    minDash.forEach(elements, function (element) {
      // (1) error event code + message variable
      var errorEventDefinitions = getErrorEventDefinitions(element);
      minDash.forEach(errorEventDefinitions, function (definition) {
        var errorCodeVariable = definition.get('errorCodeVariable'),
            errorMessageVariable = definition.get('errorMessageVariable');

        if (errorCodeVariable) {
          addVariable(element, errorCodeVariable);
        }

        if (errorMessageVariable) {
          addVariable(element, errorMessageVariable);
        }
      }); // (2) escalation code variable

      var escalationEventDefinitions = getEscalationEventDefinitions(element);
      minDash.forEach(escalationEventDefinitions, function (definition) {
        var escalationCodeVariable = definition.get('escalationCodeVariable');

        if (escalationCodeVariable) {
          addVariable(element, escalationCodeVariable);
        }
      });
    });
    return processVariables;
  }

  var extractors = [extractOutputParameters, extractResultVariables, extractFormFields, extractOutMappings, extractEventDefinitionVariables];
  /**
   * @typedef {Object} ProcessVariable
   * @property {string} name
   * @property {Array<ModdleElement>} origin
   * @property {ModdleElement} scope
   */
  // api /////////////////////////

  /**
   * Retrieves all process variables for a given container element.
   * @param {ModdleElement} containerElement
   *
   * @returns {Array<ProcessVariable>}
   */

  function getProcessVariables(containerElement) {
    var processVariables = []; // (1) extract all flow elements inside the container

    var elements = selfAndAllFlowElements([containerElement], false); // (2) extract all variables from the extractors

    minDash.forEach(extractors, function (extractor) {
      extractor({
        elements: elements,
        containerElement: containerElement,
        processVariables: processVariables
      });
    });
    return processVariables;
  }
  /**
   * Retrieves all variables which are available in the given scope
   *
   * * Exclude variables which are only available in other scopes
   * * Exclude variables which are produced by the given element
   * * Include variables which are available in parent scopes
   *
   * @param {string} scope
   * @param {ModdleElement} rootElement element from where to extract all variables
   *
   * @returns {Array<ProcessVariable>}
   */


  function getVariablesForScope(scope, rootElement) {
    var allVariables = getProcessVariables(rootElement);
    var scopeElement = getElement(scope, rootElement); // (1) get variables for given scope

    var scopeVariables = minDash.filter(allVariables, function (variable) {
      return variable.scope.id === scopeElement.id;
    }); // (2) get variables for parent scopes

    var parents = getParents(scopeElement);
    var parentsScopeVariables = minDash.filter(allVariables, function (variable) {
      return minDash.find(parents, function (parent) {
        return parent.id === variable.scope.id;
      });
    });
    return combineArrays(scopeVariables, parentsScopeVariables);
  } // helpers ////////////////////


  function combineArrays(a, b) {
    return a.concat(b);
  }

  dist.getProcessVariables = getProcessVariables;
  var getVariablesForScope_1 = dist.getVariablesForScope = getVariablesForScope;

  function ProcessVariablesProps(props) {
    const {
      element
    } = props;

    if (!canHaveProcessVariables(element)) {
      return null;
    }

    const businessObject = getBusinessObject$1(element);
    const rootElement = getRootElement(businessObject);
    const scope = getScope(element); // (1) fetch available process variables for given scope

    const variables = getVariablesForScope_1(scope, rootElement);

    if (!variables.length) {
      return null;
    }

    const withNames = populateElementNames(sortByName(variables));
    const byScope = groupByScope(withNames);
    const multiScope = isMultiScope(byScope);
    let variableItems = []; // (2) get variables to display

    if (multiScope) {
      // (2a) multiple scopes, sub scopes first
      // assumption: variables extractor fetches parent variables first
      const reversed = map$1(reverse(keys(byScope)), scopeKey => byScope[scopeKey]);
      variableItems = flatten$1(reversed);
    } else {
      // (2b) single scope
      variableItems = withNames;
    }

    const items = variableItems.map((variable, index) => {
      const id = element.id + '-variable-' + index;
      return {
        id,
        label: variable.name,
        entries: [...ProcessVariableItem({
          idPrefix: id,
          multiScope,
          variable
        })]
      };
    });
    return {
      items,
      shouldSort: false
    };
  }

  function ProcessVariableItem(props) {
    const {
      idPrefix,
      multiScope,
      variable
    } = props;
    let entries = [];

    if (multiScope) {
      entries.push({
        id: idPrefix + '-scope',
        component: Scope,
        idPrefix,
        variable
      });
    }

    entries.push({
      id: idPrefix + '-createdIn',
      component: CreatedIn,
      idPrefix,
      variable
    });
    return entries;
  }

  function Scope(props) {
    const {
      idPrefix,
      variable
    } = props;
    const translate = useService('translate');
    const id = idPrefix + '-scope';
    return o$1("div", {
      "data-entry-id": id,
      class: "bio-properties-panel-entry",
      children: [o$1("b", {
        style: "font-weight: bold",
        class: "bio-properties-panel-label",
        children: translate('Scope')
      }), o$1("label", {
        id: prefixId(id),
        class: "bio-properties-panel-label",
        children: variable.scope
      })]
    });
  }

  function CreatedIn(props) {
    const {
      idPrefix,
      variable
    } = props;
    const translate = useService('translate');
    const id = idPrefix + '-createdIn';
    const origin = variable.origin.join(', ');
    return o$1("div", {
      "data-entry-id": id,
      class: "bio-properties-panel-entry",
      children: [o$1("b", {
        style: "font-weight: bold",
        class: "bio-properties-panel-label",
        children: translate('Created in')
      }), o$1("label", {
        id: prefixId(id),
        class: "bio-properties-panel-label",
        children: origin
      })]
    });
  } // helper //////////////////////


  function canHaveProcessVariables(element) {
    const businessObject = getBusinessObject$1(element);
    return isAny(element, ['bpmn:Process', 'bpmn:SubProcess']) || is$4(element, 'bpmn:Participant') && businessObject.get('processRef');
  }

  function getRootElement(element) {
    const businessObject = getBusinessObject$1(element);

    if (is$4(businessObject, 'bpmn:Participant')) {
      return businessObject.processRef;
    }

    if (is$4(businessObject, 'bpmn:Process')) {
      return businessObject;
    }

    let parent = businessObject;

    while (parent.$parent && !is$4(parent, 'bpmn:Process')) {
      parent = parent.$parent;
    }

    return parent;
  }

  function getScope(element) {
    const bo = getBusinessObject$1(element);

    if (is$4(element, 'bpmn:Participant')) {
      return bo.processRef.id;
    }

    return bo.id;
  }

  function sortByName(variables) {
    return sortBy(variables, function (variable) {
      return variable.name;
    });
  }

  function groupByScope(variables) {
    return groupBy(variables, 'scope');
  }

  function populateElementNames(variables) {
    forEach(variables, function (variable) {
      const names = map$1(variable.origin, function (element) {
        return element.name || element.id;
      });
      variable.origin = names;
      variable.scope = variable.scope.name || variable.scope.id;
    });
    return variables;
  }

  function isMultiScope(scopedVariables) {
    return keys(scopedVariables).length > 1;
  }

  function reverse(array) {
    return map$1(array, function (a, i) {
      return array[array.length - 1 - i];
    });
  }

  function prefixId(id) {
    return `bio-properties-panel-${id}`;
  }

  function ScriptTaskProps(props) {
    const {
      element
    } = props;

    if (!is$4(element, 'bpmn:ScriptTask')) {
      return [];
    }

    const entries = [...ScriptProps({
      element
    })];
    entries.push({
      id: 'scriptResultVariable',
      component: ResultVariable,
      isEdited: isEdited$1
    });
    return entries;
  }

  function ResultVariable(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      return businessObject.get('camunda:resultVariable');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:resultVariable': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'scriptResultVariable',
      label: translate('Result variable'),
      getValue,
      setValue,
      debounce
    });
  }

  function TasklistProps(props) {
    const {
      element
    } = props;
    const businessObject = getBusinessObject$1(element);

    const isEdited = node => {
      return node && !node.checked;
    };

    if (!is$4(element, 'bpmn:Process') && !(is$4(element, 'bpmn:Participant') && businessObject.get('processRef'))) {
      return [];
    }

    return [{
      id: 'isStartableInTasklist',
      component: Startable,
      isEdited
    }];
  }

  function Startable(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const process = getProcess$1(element);

    const getValue = () => {
      return process.get('camunda:isStartableInTasklist');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: process,
        properties: {
          'camunda:isStartableInTasklist': value
        }
      });
    };

    return CheckboxEntry({
      element,
      id: 'isStartableInTasklist',
      label: translate('Startable'),
      getValue,
      setValue
    });
  } // helper //////////////////


  function getProcess$1(element) {
    return is$4(element, 'bpmn:Process') ? getBusinessObject$1(element) : getBusinessObject$1(element).get('processRef');
  }

  /**
   * Cf. https://docs.camunda.org/manual/latest/reference/bpmn20/tasks/user-task/
   */

  function UserAssignmentProps(props) {
    const {
      element
    } = props;

    if (!is$4(element, 'camunda:Assignable')) {
      return [];
    }

    return [{
      id: 'assignee',
      component: Assignee,
      isEdited: isEdited$1
    }, {
      id: 'candidateGroups',
      component: CandidateGroups,
      isEdited: isEdited$1
    }, {
      id: 'candidateUsers',
      component: CandidateUsers,
      isEdited: isEdited$1
    }, {
      id: 'dueDate',
      component: DueDate,
      isEdited: isEdited$1
    }, {
      id: 'followUpDate',
      component: FollowUpDate,
      isEdited: isEdited$1
    }, {
      id: 'priority',
      component: Priority,
      isEdited: isEdited$1
    }];
  }

  function Assignee(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      return businessObject.get('camunda:assignee');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:assignee': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'assignee',
      label: translate('Assignee'),
      getValue,
      setValue,
      debounce
    });
  }

  function CandidateUsers(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      return businessObject.get('camunda:candidateUsers');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:candidateUsers': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'candidateUsers',
      label: translate('Candidate users'),
      getValue,
      setValue,
      debounce
    });
  }

  function CandidateGroups(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      return businessObject.get('camunda:candidateGroups');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:candidateGroups': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'candidateGroups',
      label: translate('Candidate groups'),
      getValue,
      setValue,
      debounce
    });
  }

  function DueDate(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      return businessObject.get('camunda:dueDate');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:dueDate': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'dueDate',
      label: translate('Due date'),
      description: translate('The due date as an EL expression (e.g. ${someDate}) or an ISO date (e.g. 2015-06-26T09:54:00).'),
      getValue,
      setValue,
      debounce
    });
  }

  function FollowUpDate(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      return businessObject.get('camunda:followUpDate');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:followUpDate': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'followUpDate',
      label: translate('Follow up date'),
      description: translate('The follow up date as an EL expression (e.g. ${someDate}) or an ' + 'ISO date (e.g. 2015-06-26T09:54:00).'),
      getValue,
      setValue,
      debounce
    });
  }

  function Priority(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const businessObject = getBusinessObject$1(element);

    const getValue = () => {
      return businessObject.get('camunda:priority');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: businessObject,
        properties: {
          'camunda:priority': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'priority',
      label: translate('Priority'),
      getValue,
      setValue,
      debounce
    });
  }

  function VersionTagProps(props) {
    const {
      element
    } = props;
    const businessObject = getBusinessObject$1(element);

    if (!is$4(element, 'bpmn:Process') && !(is$4(element, 'bpmn:Participant') && businessObject.get('processRef'))) {
      return [];
    }

    return [{
      id: 'versionTag',
      component: VersionTag,
      isEdited: isEdited$1
    }];
  }

  function VersionTag(props) {
    const {
      element
    } = props;
    const commandStack = useService('commandStack');
    const translate = useService('translate');
    const debounce = useService('debounceInput');
    const process = getProcess(element);

    const getValue = () => {
      return process.get('camunda:versionTag') || '';
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: process,
        properties: {
          'camunda:versionTag': value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'versionTag',
      label: translate('Version tag'),
      getValue,
      setValue,
      debounce
    });
  } // helper //////////////////


  function getProcess(element) {
    return is$4(element, 'bpmn:Process') ? getBusinessObject$1(element) : getBusinessObject$1(element).get('processRef');
  }

  function TimerProps(props) {
    const {
      element,
      listener,
      idPrefix
    } = props;
    let {
      timerEventDefinition
    } = props;

    if (!timerEventDefinition) {
      const businessObject = getBusinessObject$1(element);
      timerEventDefinition = getTimerEventDefinition(businessObject);
    }

    const timerEventDefinitionType = getTimerDefinitionType(timerEventDefinition); // (1) Only show for supported elements

    if (!isTimerSupported(element) && !isTimerSupportedOnListener(listener)) {
      return [];
    } // (2) Provide entries, have a value only if selection was made


    const entries = [];
    entries.push({
      id: getId(idPrefix, 'timerEventDefinitionType'),
      component: TimerEventDefinitionType,
      isEdited: isEdited$4,
      timerEventDefinition,
      timerEventDefinitionType
    });

    if (timerEventDefinitionType) {
      entries.push({
        id: getId(idPrefix, 'timerEventDefinitionValue'),
        component: TimerEventDefinitionValue,
        isEdited: isEdited$1,
        timerEventDefinition,
        timerEventDefinitionType
      });
    }

    return entries;
  }
  /**
   * TimerEventDefinitionType - Generic select entry allowing to select a specific
   * timerEventDefintionType. To be used together with timerEventDefinitionValue.
   *
   * @param  {type} props
   * @return {SelectEntry}
   */

  function TimerEventDefinitionType(props) {
    const {
      element,
      timerEventDefinition,
      timerEventDefinitionType
    } = props;
    const commandStack = useService('commandStack'),
          bpmnFactory = useService('bpmnFactory'),
          translate = useService('translate');

    const getValue = () => {
      return timerEventDefinitionType || '';
    };

    const setValue = value => {
      // (1) Check if value is different to current type
      if (value === timerEventDefinitionType) {
        return;
      } // (2) Create empty formalExpression element


      const formalExpression = bpmnFactory.create('bpmn:FormalExpression', {
        body: undefined
      });
      formalExpression.$parent = timerEventDefinition; // (3) Set the value for selected timerEventDefinitionType

      const newProps = {
        timeDuration: undefined,
        timeDate: undefined,
        timeCycle: undefined
      };

      if (value !== '') {
        newProps[value] = formalExpression;
      } // (4) Execute businessObject update


      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: timerEventDefinition,
        properties: newProps
      });
    };

    const getOptions = element => {
      return [{
        value: '',
        label: translate('<none>')
      }, {
        value: 'timeDate',
        label: translate('Date')
      }, {
        value: 'timeDuration',
        label: translate('Duration')
      }, {
        value: 'timeCycle',
        label: translate('Cycle')
      }];
    };

    return SelectEntry({
      element,
      id: 'timerEventDefinitionType',
      label: translate('Type'),
      getValue,
      setValue,
      getOptions
    });
  }
  /**
   * TimerEventDefinitionValue - Generic textField entry allowing to specify the
   * timerEventDefintionValue based on the set timerEventDefintionType. To be used
   * together with timerEventDefinitionType.
   *
   * @param  {type} props
   * @return {TextFieldEntry}
   */


  function TimerEventDefinitionValue(props) {
    const {
      element,
      timerEventDefinition,
      timerEventDefinitionType
    } = props;
    const commandStack = useService('commandStack'),
          translate = useService('translate'),
          debounce = useService('debounceInput');
    const timerEventFormalExpression = timerEventDefinition.get(timerEventDefinitionType);

    const getValue = () => {
      return timerEventFormalExpression && timerEventFormalExpression.get('body');
    };

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: timerEventFormalExpression,
        properties: {
          body: value
        }
      });
    };

    return TextfieldEntry({
      element,
      id: 'timerEventDefinitionValue',
      label: translate('Value'),
      getValue,
      setValue,
      debounce,
      description: getTimerEventDefinitionValueDescription(timerEventDefinitionType, translate)
    });
  } // helper //////////////////////////


  function getTimerEventDefinitionValueDescription(timerDefinitionType, translate) {
    switch (timerDefinitionType) {
      case 'timeDate':
        return o$1("div", {
          children: [o$1("p", {
            children: translate('A specific point in time defined as ISO 8601 combined date and time representation.')
          }), o$1("ul", {
            children: [o$1("li", {
              children: [o$1("code", {
                children: "2019-10-01T12:00:00Z"
              }), " - ", translate('UTC time')]
            }), o$1("li", {
              children: [o$1("code", {
                children: "2019-10-02T08:09:40+02:00"
              }), " - ", translate('UTC plus 2 hours zone offset')]
            })]
          }), o$1("a", {
            href: "https://docs.camunda.org/manual/latest/reference/bpmn20/events/timer-events/#time-date",
            target: "_blank",
            rel: "noopener",
            children: translate('Documentation: Timer events')
          })]
        });

      case 'timeCycle':
        return o$1("div", {
          children: [o$1("p", {
            children: translate('A cycle defined as ISO 8601 repeating intervals format, or a cron expression.')
          }), o$1("ul", {
            children: [o$1("li", {
              children: [o$1("code", {
                children: "R5/PT10S"
              }), " - ", translate('every 10 seconds, up to 5 times')]
            }), o$1("li", {
              children: [o$1("code", {
                children: "R/P1D"
              }), " - ", translate('every day, infinitely')]
            }), o$1("li", {
              children: [o$1("code", {
                children: "0 0 9-17 * * MON-FRI"
              }), " - ", translate('every hour on the hour from 9-5 p.m. UTC Monday-Friday')]
            })]
          }), o$1("a", {
            href: "https://docs.camunda.org/manual/latest/reference/bpmn20/events/timer-events/#time-cycle",
            target: "_blank",
            rel: "noopener",
            children: translate('Documentation: Timer events')
          })]
        });

      case 'timeDuration':
        return o$1("div", {
          children: [o$1("p", {
            children: translate('A time duration defined as ISO 8601 durations format.')
          }), o$1("ul", {
            children: [o$1("li", {
              children: [o$1("code", {
                children: "PT15S"
              }), " - ", translate('15 seconds')]
            }), o$1("li", {
              children: [o$1("code", {
                children: "PT1H30M"
              }), " - ", translate('1 hour and 30 minutes')]
            }), o$1("li", {
              children: [o$1("code", {
                children: "P14D"
              }), " - ", translate('14 days')]
            })]
          }), o$1("a", {
            href: "https://docs.camunda.org/manual/latest/reference/bpmn20/events/timer-events/#time-duration",
            target: "_blank",
            rel: "noopener",
            children: translate('Documentation: Timer events')
          })]
        });
    }
  }

  function isTimerSupportedOnListener(listener) {
    return listener && is$4(listener, 'camunda:TaskListener') && getTimerEventDefinition(listener);
  }

  function getId(idPrefix, id) {
    return idPrefix ? idPrefix + id : id;
  }

  const LOW_PRIORITY = 500;
  const CAMUNDA_PLATFORM_GROUPS = [HistoryCleanupGroup, TasklistGroup, CandidateStarterGroup, ImplementationGroup, ExternalTaskGroup, ProcessVariablesGroup, ErrorsGroup, UserAssignmentGroup, FormGroup, FormDataGroup, TaskListenerGroup, StartInitiatorGroup, ScriptGroup, ConditionGroup, CallActivityGroup, AsynchronousContinuationsGroup, JobExecutionGroup, InMappingPropagationGroup, InMappingGroup, InputGroup, ConnectorInputGroup, OutMappingPropagationGroup, OutMappingGroup, OutputGroup, ConnectorOutputGroup, ExecutionListenerGroup, ExtensionPropertiesGroup, FieldInjectionGroup, BusinessKeyGroup];
  /**
   * Provides `camunda` namespace properties.
   *
   * @example
   * ```javascript
   * import BpmnModeler from 'bpmn-js/lib/Modeler';
   * import {
   *   BpmnPropertiesPanelModule,
   *   BpmnPropertiesProviderModule,
   *   CamundaPlatformPropertiesProviderModule
   * } from 'bpmn-js-properties-panel';
   *
   * const modeler = new BpmnModeler({
   *   container: '#canvas',
   *   propertiesPanel: {
   *     parent: '#properties'
   *   },
   *   additionalModules: [
   *     BpmnPropertiesPanelModule,
   *     BpmnPropertiesProviderModule,
   *     CamundaPlatformPropertiesProviderModule
   *   ]
   * });
   * ```
   */

  class CamundaPlatformPropertiesProvider {
    constructor(propertiesPanel, injector) {
      propertiesPanel.registerProvider(LOW_PRIORITY, this);
      this._injector = injector;
    }

    getGroups(element) {
      return groups => {
        // (1) add Camunda Platform specific groups
        groups = groups.concat(this._getGroups(element)); // (2) update existing groups with Camunda Platform specific properties

        updateGeneralGroup(groups, element);
        updateErrorGroup(groups, element);
        updateEscalationGroup(groups, element);
        updateMultiInstanceGroup(groups, element);
        updateTimerGroup(groups, element); // (3) move groups given specific priorities

        moveImplementationGroup(groups);
        return groups;
      };
    }

    _getGroups(element) {
      const groups = CAMUNDA_PLATFORM_GROUPS.map(createGroup => createGroup(element, this._injector)); // contract: if a group returns null, it should not be displayed at all

      return groups.filter(group => group !== null);
    }

  }
  CamundaPlatformPropertiesProvider.$inject = ['propertiesPanel', 'injector'];
  /**
   * This ensures the <Implementation> group always locates after <Documentation>
   */

  function moveImplementationGroup(groups) {
    const documentationGroupIdx = findGroupIndex(groups, 'documentation');

    if (documentationGroupIdx < 0) {
      return;
    }

    return moveGroup(groups, 'CamundaPlatform__Implementation', documentationGroupIdx + 1);
  }

  function updateGeneralGroup(groups, element) {
    const generalGroup = findGroup(groups, 'general');

    if (!generalGroup) {
      return;
    }

    const {
      entries
    } = generalGroup; // (1) add version tag before executable (if existing)

    const executableEntry = findIndex(entries, entry => entry.id === 'isExecutable');
    const insertIndex = executableEntry >= 0 ? executableEntry : entries.length;
    entries.splice(insertIndex, 0, ...VersionTagProps({
      element
    }));
  }

  function updateErrorGroup(groups, element) {
    const errorGroup = findGroup(groups, 'error');

    if (!errorGroup) {
      return;
    }

    const {
      entries
    } = errorGroup;
    ErrorProps({
      element,
      entries
    });
  }

  function updateMultiInstanceGroup(groups, element) {
    const multiInstanceGroup = findGroup(groups, 'multiInstance');

    if (!multiInstanceGroup) {
      return;
    }

    const {
      entries
    } = multiInstanceGroup;
    MultiInstanceProps({
      element,
      entries
    });
  }

  function updateEscalationGroup(groups, element) {
    const escalationGroup = findGroup(groups, 'escalation');

    if (!escalationGroup) {
      return;
    }

    const {
      entries
    } = escalationGroup;
    EscalationProps({
      element,
      entries
    });
  }

  function updateTimerGroup(groups, element) {
    const timerEventGroup = findGroup(groups, 'timer');

    if (!timerEventGroup) {
      return;
    }

    timerEventGroup.entries = [...TimerProps({
      element
    })];
  }

  function ImplementationGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Implementation'),
      id: 'CamundaPlatform__Implementation',
      component: Group,
      entries: [...ImplementationProps({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function ErrorsGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Errors'),
      id: 'CamundaPlatform__Errors',
      component: ListGroup,
      ...ErrorsProps({
        element,
        injector
      })
    };

    if (group.items) {
      return group;
    }

    return null;
  }

  function UserAssignmentGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('User assignment'),
      id: 'CamundaPlatform__UserAssignment',
      component: Group,
      entries: [...UserAssignmentProps({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function ScriptGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Script'),
      id: 'CamundaPlatform__Script',
      component: Group,
      entries: [...ScriptTaskProps({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function CallActivityGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Called element'),
      id: 'CamundaPlatform__CallActivity',
      component: Group,
      entries: [...CallActivityProps({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function ConditionGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Condition'),
      id: 'CamundaPlatform__Condition',
      component: Group,
      entries: [...ConditionProps({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function StartInitiatorGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Start initiator'),
      id: 'CamundaPlatform__StartInitiator',
      component: Group,
      entries: [...InitiatorProps({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function ExternalTaskGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('External task'),
      id: 'CamundaPlatform__ExternalTask',
      component: Group,
      entries: [...ExternalTaskPriorityProps({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function AsynchronousContinuationsGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Asynchronous continuations'),
      id: 'CamundaPlatform__AsynchronousContinuations',
      component: Group,
      entries: [...AsynchronousContinuationsProps({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function JobExecutionGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Job execution'),
      id: 'CamundaPlatform__JobExecution',
      component: Group,
      entries: [...JobExecutionProps({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function CandidateStarterGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Candidate starter'),
      id: 'CamundaPlatform__CandidateStarter',
      component: Group,
      entries: [...CandidateStarterProps({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function FieldInjectionGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Field injections'),
      id: 'CamundaPlatform__FieldInjection',
      component: ListGroup,
      ...FieldInjectionProps({
        element,
        injector
      })
    };

    if (group.items) {
      return group;
    }

    return null;
  }

  function HistoryCleanupGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('History cleanup'),
      id: 'CamundaPlatform__HistoryCleanup',
      component: Group,
      entries: [...HistoryCleanupProps({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function TasklistGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Tasklist'),
      id: 'CamundaPlatform__Tasklist',
      component: Group,
      entries: [...TasklistProps({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function InMappingGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('In mappings'),
      id: 'CamundaPlatform__InMapping',
      component: ListGroup,
      ...InMappingProps({
        element,
        injector
      })
    };

    if (group.items) {
      return group;
    }

    return null;
  }

  function InMappingPropagationGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('In mapping propagation'),
      id: 'CamundaPlatform__InMappingPropagation',
      component: Group,
      entries: [...InMappingPropagationProps({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function OutMappingGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Out mappings'),
      id: 'CamundaPlatform__OutMapping',
      component: ListGroup,
      ...OutMappingProps({
        element,
        injector
      })
    };

    if (group.items) {
      return group;
    }

    return null;
  }

  function OutMappingPropagationGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Out mapping propagation'),
      id: 'CamundaPlatform__OutMappingPropagation',
      component: Group,
      entries: [...OutMappingPropagationProps({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function ProcessVariablesGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Process variables'),
      id: 'CamundaPlatform__ProcessVariables',
      component: ListGroup,
      ...ProcessVariablesProps({
        element,
        injector
      })
    };

    if (group.items) {
      return group;
    }

    return null;
  }

  function FormDataGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Form fields'),
      id: 'CamundaPlatform__FormData',
      component: ListGroup,
      ...FormDataProps({
        element,
        injector
      })
    };

    if (group.items) {
      return group;
    }

    return null;
  }

  function BusinessKeyGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Business key'),
      id: 'CamundaPlatform__BusinessKey',
      component: Group,
      entries: [...BusinessKeyProps$1({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function FormGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Forms'),
      id: 'CamundaPlatform__Form',
      component: Group,
      entries: [...FormProps({
        element
      })]
    };

    if (group.entries.length) {
      return group;
    }

    return null;
  }

  function ExecutionListenerGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Execution listeners'),
      id: 'CamundaPlatform__ExecutionListener',
      component: ListGroup,
      ...ExecutionListenerProps({
        element,
        injector
      })
    };

    if (group.items) {
      return group;
    }

    return null;
  }

  function TaskListenerGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Task listeners'),
      id: 'CamundaPlatform__TaskListener',
      component: ListGroup,
      ...TaskListenerProps({
        element,
        injector
      })
    };

    if (group.items) {
      return group;
    }

    return null;
  }

  function InputGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Inputs'),
      id: 'CamundaPlatform__Input',
      component: ListGroup,
      ...InputProps({
        element,
        injector
      })
    };

    if (group.items) {
      return group;
    }

    return null;
  }

  function OutputGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Outputs'),
      id: 'CamundaPlatform__Output',
      component: ListGroup,
      ...OutputProps({
        element,
        injector
      })
    };

    if (group.items) {
      return group;
    }

    return null;
  }

  function ConnectorInputGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Connector inputs'),
      id: 'CamundaPlatform__ConnectorInput',
      component: ListGroup,
      ...ConnectorInputProps({
        element,
        injector
      })
    };

    if (group.items) {
      return group;
    }

    return null;
  }

  function ConnectorOutputGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Connector outputs'),
      id: 'CamundaPlatform__ConnectorOutput',
      component: ListGroup,
      ...ConnectorOutputProps({
        element,
        injector
      })
    };

    if (group.items) {
      return group;
    }

    return null;
  }

  function ExtensionPropertiesGroup(element, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Extension properties'),
      id: 'CamundaPlatform__ExtensionProperties',
      component: ListGroup,
      ...ExtensionPropertiesProps({
        element,
        injector
      })
    };

    if (group.items) {
      return group;
    }

    return null;
  } // helper /////////////////////


  function findGroup(groups, id) {
    return groups.find(g => g.id === id);
  }

  function findGroupIndex(groups, id) {
    return findIndex(groups, g => g.id === id);
  }

  function moveGroup(groups, id, position) {
    const groupIndex = findGroupIndex(groups, id);

    if (position < 0 || groupIndex < 0) {
      return;
    }

    return mutate(groups, groupIndex, position);
  }

  var camundaPlatformPropertiesProviderModule = {
    __init__: ['camundaPlatformPropertiesProvider'],
    camundaPlatformPropertiesProvider: ['type', CamundaPlatformPropertiesProvider]
  };

  /**
   * A simple translation stub to be used for multi-language support
   * in diagrams. Can be easily replaced with a more sophisticated
   * solution.
   *
   * @example
   *
   * // use it inside any diagram component by injecting `translate`.
   *
   * function MyService(translate) {
   *   alert(translate('HELLO {you}', { you: 'You!' }));
   * }
   *
   * @param {string} template to interpolate
   * @param {Object} [replacements] a map with substitutes
   *
   * @return {string} the translated string
   */
  function translate(template, replacements) {
    replacements = replacements || {};
    return template.replace(/{([^}]+)}/g, function (_, key) {
      return replacements[key] || '{' + key + '}';
    });
  }

  var translateModule = {
    translate: ['value', translate]
  };

  const PROPERTY_TYPE$1 = 'property';
  const ZEBBE_PROPERTY_TYPE = 'zeebe:property';
  const ZEBBE_INPUT_TYPE = 'zeebe:input';
  const ZEEBE_OUTPUT_TYPE = 'zeebe:output';
  const ZEEBE_PROPERTY_TYPE = 'zeebe:property';
  const ZEEBE_TASK_DEFINITION_TYPE_TYPE = 'zeebe:taskDefinition:type';
  const ZEEBE_TASK_HEADER_TYPE = 'zeebe:taskHeader';
  const EXTENSION_BINDING_TYPES$1 = [ZEBBE_INPUT_TYPE, ZEEBE_OUTPUT_TYPE, ZEEBE_PROPERTY_TYPE, ZEEBE_TASK_DEFINITION_TYPE_TYPE, ZEEBE_TASK_HEADER_TYPE];
  const TASK_DEFINITION_TYPES = [ZEEBE_TASK_DEFINITION_TYPE_TYPE];
  const IO_BINDING_TYPES$1 = [ZEBBE_INPUT_TYPE, ZEEBE_OUTPUT_TYPE];

  /**
   * The BPMN 2.0 extension attribute name under
   * which the element template ID is stored.
   *
   * @type {String}
   */

  const TEMPLATE_ID_ATTR$1 = 'zeebe:modelerTemplate';
  /**
   * The BPMN 2.0 extension attribute name under
   * which the element template version is stored.
   *
   * @type {String}
   */

  const TEMPLATE_VERSION_ATTR$1 = 'zeebe:modelerTemplateVersion';
  /**
   * Get template id for a given diagram element.
   *
   * @param {djs.model.Base} element
   *
   * @return {String}
   */

  function getTemplateId$1(element) {
    const businessObject = getBusinessObject$1(element);

    if (businessObject) {
      return businessObject.get(TEMPLATE_ID_ATTR$1);
    }
  }
  /**
   * Get template version for a given diagram element.
   *
   * @param {djs.model.Base} element
   *
   * @return {String}
   */

  function getTemplateVersion$1(element) {
    const businessObject = getBusinessObject$1(element);

    if (businessObject) {
      return businessObject.get(TEMPLATE_VERSION_ATTR$1);
    }
  }
  /**
   * Find extension with given type in
   * BPMN element, diagram element or ExtensionElement.
   *
   * @param {ModdleElement|djs.model.Base} element
   * @param {String} type
   *
   * @return {ModdleElement} the extension
   */

  function findExtension$1(element, type) {
    const businessObject = getBusinessObject$1(element);
    let extensionElements;

    if (is$4(businessObject, 'bpmn:ExtensionElements')) {
      extensionElements = businessObject;
    } else {
      extensionElements = businessObject.get('extensionElements');
    }

    if (!extensionElements) {
      return null;
    }

    return extensionElements.get('values').find(value => {
      return is$4(value, type);
    });
  }
  function findZeebeProperty(zeebeProperties, binding) {
    return zeebeProperties.get('properties').find(value => {
      return value.name === binding.name;
    });
  }
  function findInputParameter$1(ioMapping, binding) {
    const parameters = ioMapping.get('inputParameters');
    return parameters.find(parameter => {
      return parameter.target === binding.name;
    });
  }
  function findOutputParameter$1(ioMapping, binding) {
    const parameters = ioMapping.get('outputParameters');
    return parameters.find(parameter => {
      return parameter.source === binding.source;
    });
  }
  function findTaskHeader(taskHeaders, binding) {
    const headers = taskHeaders.get('values');
    return headers.find(header => {
      return header.key === binding.key;
    });
  }

  /**
   * Create an input parameter representing the given
   * binding and value.
   *
   * @param {PropertyBinding} binding
   * @param {String} value
   * @param {BpmnFactory} bpmnFactory
   *
   * @return {ModdleElement}
   */

  function createInputParameter$1(binding, value, bpmnFactory) {
    const {
      name
    } = binding;
    return bpmnFactory.create('zeebe:Input', {
      source: value,
      target: name
    });
  }
  /**
   * Create an output parameter representing the given
   * binding and value.
   *
   * @param {PropertyBinding} binding
   * @param {String} value
   * @param {BpmnFactory} bpmnFactory
   *
   * @return {ModdleElement}
   */

  function createOutputParameter$1(binding, value, bpmnFactory) {
    const {
      source
    } = binding;
    return bpmnFactory.create('zeebe:Output', {
      source,
      target: value
    });
  }
  /**
   * Create a task header representing the given
   * binding and value.
   *
   * @param {PropertyBinding} binding
   * @param {String} value
   * @param {BpmnFactory} bpmnFactory
   *
   * @return {ModdleElement}
   */

  function createTaskHeader(binding, value, bpmnFactory) {
    const {
      key
    } = binding;
    return bpmnFactory.create('zeebe:Header', {
      key,
      value
    });
  }
  /**
   * Create a task definition representing the given value.
   *
   * @param {String} value
   * @param {BpmnFactory} bpmnFactory
   *
   * @return {ModdleElement}
   */

  function createTaskDefinitionWithType(value, bpmnFactory) {
    return bpmnFactory.create('zeebe:TaskDefinition', {
      type: value
    });
  }
  /**
   * Create zeebe:Property from the given binding.
   *
   * @param {PropertyBinding} binding
   * @param {String} value
   * @param {BpmnFactory} bpmnFactory
   *
   * @return {ModdleElement}
   */

  function createZeebeProperty(binding, value = '', bpmnFactory) {
    const {
      name
    } = binding;
    return bpmnFactory.create('zeebe:Property', {
      name,
      value
    });
  }
  /**
   * Retrieves whether an element should be updated for a given property.
   *
   * That matches once
   * a) the property value is not empty, or
   * b) the property is not optional
   *
   * @param {String} value
   * @param {Object} property
   * @returns {Boolean}
   */

  function shouldUpdate(value, property) {
    const {
      optional
    } = property;
    return value || !optional;
  }
  /**
   * Gets or, in case not existent, creates extension element for given element.
   *
   * @param {djs.model.Base} element
   * @param {String} type
   * @param {BpmnFactory} bpmnFactory
   * @returns {ModdleElement}
   */

  function ensureExtension(element, type, bpmnFactory) {
    const businessObject = getBusinessObject$1(element);
    const extensionElements = businessObject.get('extensionElements');
    let extension = findExtension$1(extensionElements, type);

    if (!extension) {
      extension = bpmnFactory.create(type);
      extension.$parent = extensionElements;
      extensionElements.get('values').push(extension);
    }

    return extension;
  }

  const PRIMITIVE_MODDLE_TYPES$1 = ['Boolean', 'Integer', 'String'];
  function getPropertyValue$1(element, property, scope) {
    let businessObject = getBusinessObject$1(element);
    const defaultValue = '';
    const {
      binding
    } = property;
    const {
      name,
      type
    } = binding; // property

    if (type === 'property') {
      const value = businessObject.get(name);

      if (!isUndefined(value)) {
        return value;
      }

      return defaultValue;
    } // zeebe:taskDefinition


    if (TASK_DEFINITION_TYPES.includes(type)) {
      const taskDefinition = findExtension$1(businessObject, 'zeebe:TaskDefinition');

      if (taskDefinition) {
        if (type === ZEEBE_TASK_DEFINITION_TYPE_TYPE) {
          return taskDefinition.get('type');
        }
      }

      return defaultValue;
    }

    if (IO_BINDING_TYPES$1.includes(type)) {
      const ioMapping = findExtension$1(businessObject, 'zeebe:IoMapping');

      if (!ioMapping) {
        return defaultValue;
      } // zeebe:Input


      if (type === ZEBBE_INPUT_TYPE) {
        const inputParameter = findInputParameter$1(ioMapping, binding);

        if (inputParameter) {
          return inputParameter.get('source');
        }

        return defaultValue;
      } // zeebe:Output


      if (type === ZEEBE_OUTPUT_TYPE) {
        const outputParameter = findOutputParameter$1(ioMapping, binding);

        if (outputParameter) {
          return outputParameter.get('target');
        }

        return defaultValue;
      }
    } // zeebe:taskHeaders


    if (type === ZEEBE_TASK_HEADER_TYPE) {
      const taskHeaders = findExtension$1(businessObject, 'zeebe:TaskHeaders');

      if (!taskHeaders) {
        return defaultValue;
      }

      const header = findTaskHeader(taskHeaders, binding);

      if (header) {
        return header.get('value');
      }

      return defaultValue;
    } // zeebe:Property


    if (type === ZEEBE_PROPERTY_TYPE) {
      const zeebeProperties = findExtension$1(businessObject, 'zeebe:Properties');

      if (zeebeProperties) {
        const zeebeProperty = findZeebeProperty(zeebeProperties, binding);

        if (zeebeProperty) {
          return zeebeProperty.get('value');
        }
      }

      return defaultValue;
    } // should never throw as templates are validated beforehand


    throw unknownBindingError$1(element, property);
  }
  const NO_OP = null;
  function setPropertyValue(bpmnFactory, commandStack, element, property, value) {
    let businessObject = getBusinessObject$1(element);
    const {
      binding
    } = property;
    const {
      name,
      type
    } = binding;
    let extensionElements;
    let propertyValue;
    const commands = [];
    const context = {
      element,
      property
    }; // ensure extension elements

    if (EXTENSION_BINDING_TYPES$1.includes(type)) {
      extensionElements = businessObject.get('extensionElements');

      if (!extensionElements) {
        extensionElements = createElement('bpmn:ExtensionElements', null, businessObject, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: { ...context,
            moddleElement: businessObject,
            properties: {
              extensionElements
            }
          }
        });
      } else {
        commands.push(NO_OP);
      }
    } // property


    if (type === PROPERTY_TYPE$1) {
      const propertyDescriptor = businessObject.$descriptor.propertiesByName[name]; // if property not created yet

      if (!propertyDescriptor) {
        // make sure we create the property
        propertyValue = value || '';
      } else {
        const {
          type: propertyType
        } = propertyDescriptor; // do not override non-primitive types

        if (!PRIMITIVE_MODDLE_TYPES$1.includes(propertyType)) {
          throw new Error(`cannot set property of type <${propertyType}>`);
        }

        if (propertyType === 'Boolean') {
          propertyValue = !!value;
        } else if (propertyType === 'Integer') {
          propertyValue = parseInt(value, 10);

          if (isNaN(propertyValue)) {
            // do not set NaN value
            propertyValue = undefined;
          }
        } else {
          // make sure we don't remove the property
          propertyValue = value || '';
        }
      }

      if (!isUndefined(propertyValue)) {
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: { ...context,
            moddleElement: businessObject,
            properties: {
              [name]: propertyValue
            }
          }
        });
      } else {
        commands.push(NO_OP);
      }
    } // zeebe:taskDefinition


    if (TASK_DEFINITION_TYPES.includes(type)) {
      const oldTaskDefinition = findExtension$1(extensionElements, 'zeebe:TaskDefinition');
      let newTaskDefinition;

      if (type === ZEEBE_TASK_DEFINITION_TYPE_TYPE) {
        newTaskDefinition = createTaskDefinitionWithType(value, bpmnFactory);
      } else {
        throw unknownBindingError$1(element, property);
      }

      const values = extensionElements.get('values').filter(value => value !== oldTaskDefinition);
      commands.push({
        cmd: 'element.updateModdleProperties',
        context: { ...context,
          moddleElement: extensionElements,
          properties: {
            values: [...values, newTaskDefinition]
          }
        }
      });
    }

    if (IO_BINDING_TYPES$1.includes(type)) {
      let ioMapping = findExtension$1(extensionElements, 'zeebe:IoMapping');

      if (!ioMapping) {
        ioMapping = createElement('zeebe:IoMapping', null, businessObject, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: { ...context,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), ioMapping]
            }
          }
        });
      } // zeebe:Input


      if (type === ZEBBE_INPUT_TYPE) {
        const oldZeebeInputParameter = findInputParameter$1(ioMapping, binding);
        const values = ioMapping.get('inputParameters').filter(value => value !== oldZeebeInputParameter); // do not persist empty parameters when configured as <optional>

        if (shouldUpdate(value, property)) {
          const newZeebeInputParameter = createInputParameter$1(binding, value, bpmnFactory);
          values.push(newZeebeInputParameter);
        }

        commands.push({
          cmd: 'element.updateModdleProperties',
          context: { ...context,
            moddleElement: ioMapping,
            properties: {
              inputParameters: [...values]
            }
          }
        });
      } // zeebe:Output


      if (type === ZEEBE_OUTPUT_TYPE) {
        const oldZeebeOutputParameter = findOutputParameter$1(ioMapping, binding);
        const values = ioMapping.get('outputParameters').filter(value => value !== oldZeebeOutputParameter); // do not persist empty parameters when configured as <optional>

        if (shouldUpdate(value, property)) {
          const newZeebeOutputParameter = createOutputParameter$1(binding, value, bpmnFactory);
          values.push(newZeebeOutputParameter);
        }

        commands.push({
          cmd: 'element.updateModdleProperties',
          context: { ...context,
            moddleElement: ioMapping,
            properties: {
              'outputParameters': [...values]
            }
          }
        });
      }
    } // zeebe:taskHeaders


    if (type === ZEEBE_TASK_HEADER_TYPE) {
      let taskHeaders = findExtension$1(extensionElements, 'zeebe:TaskHeaders');

      if (!taskHeaders) {
        taskHeaders = createElement('zeebe:TaskHeaders', null, businessObject, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: { ...context,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), taskHeaders]
            }
          }
        });
      }

      const oldTaskHeader = findTaskHeader(taskHeaders, binding);
      const values = taskHeaders.get('values').filter(value => value !== oldTaskHeader); // do not persist task headers with empty value

      if (!value) {
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: { ...context,
            moddleElement: taskHeaders,
            properties: {
              values
            }
          }
        });
      } else {
        const newTaskHeader = createTaskHeader(binding, value, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: { ...context,
            moddleElement: taskHeaders,
            properties: {
              values: [...values, newTaskHeader]
            }
          }
        });
      }
    } // zeebe:Property


    if (type === ZEEBE_PROPERTY_TYPE) {
      let zeebeProperties = findExtension$1(extensionElements, 'zeebe:Properties');

      if (!zeebeProperties) {
        zeebeProperties = createElement('zeebe:Properties', null, businessObject, bpmnFactory);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), zeebeProperties]
            }
          }
        });
      }

      const oldZeebeProperty = findZeebeProperty(zeebeProperties, binding);
      const properties = zeebeProperties.get('properties').filter(property => property !== oldZeebeProperty);

      if (shouldUpdate(value, property)) {
        const newZeebeProperty = createZeebeProperty(binding, value, bpmnFactory);
        properties.push(newZeebeProperty);
      }

      commands.push({
        cmd: 'element.updateModdleProperties',
        context: {
          element,
          moddleElement: zeebeProperties,
          properties: {
            properties
          }
        }
      });
    }

    if (commands.length) {
      const commandsToExecute = commands.filter(command => command !== NO_OP);
      commandsToExecute.length && commandStack.execute('properties-panel.multi-command-executor', commandsToExecute);
      return;
    } // should never throw as templates are validated beforehand


    throw unknownBindingError$1(element, property);
  }
  function unsetProperty(commandStack, element, property) {
    let businessObject = getBusinessObject$1(element);
    const {
      binding
    } = property;
    const {
      type
    } = binding;
    let extensionElements;
    const commands = [];
    const context = {
      element,
      property
    };

    if (EXTENSION_BINDING_TYPES$1.includes(type)) {
      extensionElements = businessObject.get('extensionElements');
      if (!extensionElements) return;
    } // zeebe:taskDefinition


    if (TASK_DEFINITION_TYPES.includes(type)) {
      const oldTaskDefinition = findExtension$1(extensionElements, 'zeebe:TaskDefinition');
      commands.push({
        cmd: 'element.updateModdleProperties',
        context: { ...context,
          moddleElement: extensionElements,
          properties: {
            values: without(extensionElements.get('values'), oldTaskDefinition)
          }
        }
      });
    } // zeebe:IoMapping


    if (IO_BINDING_TYPES$1.includes(type)) {
      let ioMapping = findExtension$1(extensionElements, 'zeebe:IoMapping');
      if (!ioMapping) return; // zeebe:Input

      if (type === ZEBBE_INPUT_TYPE) {
        const oldZeebeInputParameter = findInputParameter$1(ioMapping, binding);
        const values = ioMapping.get('inputParameters').filter(value => value !== oldZeebeInputParameter);

        if (ioMapping.get('outputParameters').length == 0 && values.length == 0) {
          commands.push({
            cmd: 'element.updateModdleProperties',
            context: { ...context,
              moddleElement: extensionElements,
              properties: {
                values: without(extensionElements.get('values'), ioMapping)
              }
            }
          });
        } else {
          commands.push({
            cmd: 'element.updateModdleProperties',
            context: { ...context,
              moddleElement: ioMapping,
              properties: {
                inputParameters: [...values]
              }
            }
          });
        }
      } // zeebe:Output


      if (type === ZEEBE_OUTPUT_TYPE) {
        const oldZeebeOutputParameter = findOutputParameter$1(ioMapping, binding);
        const values = ioMapping.get('outputParameters').filter(value => value !== oldZeebeOutputParameter);

        if (ioMapping.get('inputParameters').length == 0 && values.length == 0) {
          commands.push({
            cmd: 'element.updateModdleProperties',
            context: { ...context,
              moddleElement: extensionElements,
              properties: {
                values: without(extensionElements.get('values'), ioMapping)
              }
            }
          });
        }

        commands.push({
          cmd: 'element.updateModdleProperties',
          context: { ...context,
            moddleElement: ioMapping,
            properties: {
              'outputParameters': [...values]
            }
          }
        });
      }
    } // zeebe:taskHeaders


    if (type === ZEEBE_TASK_HEADER_TYPE) {
      let taskHeaders = findExtension$1(extensionElements, 'zeebe:TaskHeaders');
      if (!taskHeaders) return;
      const oldTaskHeader = findTaskHeader(taskHeaders, binding);
      const values = taskHeaders.get('values').filter(value => value !== oldTaskHeader);

      if (values.length === 0) {
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: { ...context,
            moddleElement: extensionElements,
            properties: {
              values: without(extensionElements.get('values'), taskHeaders)
            }
          }
        });
      } else {
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: { ...context,
            moddleElement: taskHeaders,
            properties: {
              values: [...values]
            }
          }
        });
      }
    } // zeebe:Property


    if (type === ZEEBE_PROPERTY_TYPE) {
      let zeebeProperties = findExtension$1(extensionElements, 'zeebe:Properties');
      if (!zeebeProperties) return;
      const oldZeebeProperty = findZeebeProperty(zeebeProperties, binding);
      const properties = zeebeProperties.get('properties').filter(property => property !== oldZeebeProperty);

      if (!properties.length) {
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: { ...context,
            moddleElement: extensionElements,
            properties: {
              values: without(extensionElements.get('values'), zeebeProperties)
            }
          }
        });
      } else {
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: { ...context,
            moddleElement: zeebeProperties,
            properties: {
              properties: [...properties]
            }
          }
        });
      }
    }

    if (commands.length) {
      commandStack.execute('properties-panel.multi-command-executor', commands);
      return;
    }
  } // helpers

  function unknownBindingError$1(element, property) {
    const businessObject = getBusinessObject$1(element);
    const id = businessObject.get('id');
    const {
      binding
    } = property;
    const {
      type
    } = binding;
    return new Error(`unknown binding <${type}> for element <${id}>, this should never happen`);
  }

  /**
   * Based on conditions, remove properties from the template.
   */

  function applyConditions(element, elementTemplate) {
    const {
      properties
    } = elementTemplate;
    const filteredProperties = properties.filter(property => {
      return isConditionMet(element, properties, property);
    });
    return { ...elementTemplate,
      properties: filteredProperties
    };
  }

  function isConditionMet(element, properties, property) {
    const {
      condition
    } = property; // If no condition is defined, return true.

    if (!condition) {
      return true;
    }

    return isSimpleConditionMet(element, properties, condition);
  }

  function isSimpleConditionMet(element, properties, condition) {
    const {
      property,
      equals,
      oneOf
    } = condition;
    const propertyValue = getValue(element, properties, property);

    if (equals) {
      return propertyValue === equals;
    }

    if (oneOf) {
      return oneOf.includes(propertyValue);
    }

    return false;
  }

  function getValue(element, properties, propertyId) {
    const property = properties.find(p => p.id === propertyId);

    if (!property) {
      return;
    }

    return getPropertyValue$1(element, property);
  }

  var DEFAULT_PRIORITY = 1000;
  /**
   * A utility that can be used to plug-in into the command execution for
   * extension and/or validation.
   *
   * @param {EventBus} eventBus
   *
   * @example
   *
   * import inherits from 'inherits-browser';
   *
   * import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
   *
   * function CommandLogger(eventBus) {
   *   CommandInterceptor.call(this, eventBus);
   *
   *   this.preExecute(function(event) {
   *     console.log('command pre-execute', event);
   *   });
   * }
   *
   * inherits(CommandLogger, CommandInterceptor);
   *
   */

  function CommandInterceptor(eventBus) {
    this._eventBus = eventBus;
  }
  CommandInterceptor.$inject = ['eventBus'];

  function unwrapEvent(fn, that) {
    return function (event) {
      return fn.call(that || null, event.context, event.command, event);
    };
  }
  /**
   * Register an interceptor for a command execution
   *
   * @param {string|Array<string>} [events] list of commands to register on
   * @param {string} [hook] command hook, i.e. preExecute, executed to listen on
   * @param {number} [priority] the priority on which to hook into the execution
   * @param {Function} handlerFn interceptor to be invoked with (event)
   * @param {boolean} unwrap if true, unwrap the event and pass (context, command, event) to the
   *                          listener instead
   * @param {Object} [that] Pass context (`this`) to the handler function
   */


  CommandInterceptor.prototype.on = function (events, hook, priority, handlerFn, unwrap, that) {
    if (isFunction(hook) || isNumber(hook)) {
      that = unwrap;
      unwrap = handlerFn;
      handlerFn = priority;
      priority = hook;
      hook = null;
    }

    if (isFunction(priority)) {
      that = unwrap;
      unwrap = handlerFn;
      handlerFn = priority;
      priority = DEFAULT_PRIORITY;
    }

    if (isObject(unwrap)) {
      that = unwrap;
      unwrap = false;
    }

    if (!isFunction(handlerFn)) {
      throw new Error('handlerFn must be a function');
    }

    if (!isArray(events)) {
      events = [events];
    }

    var eventBus = this._eventBus;
    forEach(events, function (event) {
      // concat commandStack(.event)?(.hook)?
      var fullEvent = ['commandStack', event, hook].filter(function (e) {
        return e;
      }).join('.');
      eventBus.on(fullEvent, priority, unwrap ? unwrapEvent(handlerFn, that) : handlerFn, that);
    });
  };

  var hooks = ['canExecute', 'preExecute', 'preExecuted', 'execute', 'executed', 'postExecute', 'postExecuted', 'revert', 'reverted'];
  /*
   * Install hook shortcuts
   *
   * This will generate the CommandInterceptor#(preExecute|...|reverted) methods
   * which will in term forward to CommandInterceptor#on.
   */

  forEach(hooks, function (hook) {
    /**
     * {canExecute|preExecute|preExecuted|execute|executed|postExecute|postExecuted|revert|reverted}
     *
     * A named hook for plugging into the command execution
     *
     * @param {string|Array<string>} [events] list of commands to register on
     * @param {number} [priority] the priority on which to hook into the execution
     * @param {Function} handlerFn interceptor to be invoked with (event)
     * @param {boolean} [unwrap=false] if true, unwrap the event and pass (context, command, event) to the
     *                          listener instead
     * @param {Object} [that] Pass context (`this`) to the handler function
     */
    CommandInterceptor.prototype[hook] = function (events, priority, handlerFn, unwrap, that) {
      if (isFunction(events) || isNumber(events)) {
        that = unwrap;
        unwrap = handlerFn;
        handlerFn = priority;
        priority = events;
        events = null;
      }

      this.on(events, hook, priority, handlerFn, unwrap, that);
    };
  });

  /**
   * Applies an element template to an element. Sets `zeebe:modelerTemplate` and
   * `zeebe:modelerTemplateVersion`.
   */

  class ChangeElementTemplateHandler$1 {
    constructor(bpmnFactory, bpmnReplace, commandStack, modeling) {
      this._bpmnFactory = bpmnFactory;
      this._bpmnReplace = bpmnReplace;
      this._commandStack = commandStack;
      this._modeling = modeling;
    }
    /**
     * Change an element's template and update its properties as specified in `newTemplate`. Specify
     * `oldTemplate` to update from one template to another. If `newTemplate` isn't specified the
     * `zeebe:modelerTemplate` and `zeebe:modelerTemplateVersion` properties will be removed from
     * the element.
     *
     * @param {Object} context
     * @param {Object} context.element
     * @param {Object} [context.oldTemplate]
     * @param {Object} [context.newTemplate]
     */


    preExecute(context) {
      let newTemplate = context.newTemplate,
          oldTemplate = context.oldTemplate;
      let element = context.element; // update zeebe:modelerTemplate attribute

      this._updateZeebeModelerTemplate(element, newTemplate); // update zeebe:modelerTemplateIcon


      this._updateZeebeModelerTemplateIcon(element, newTemplate);

      if (newTemplate) {
        // do not apply properties that don't meet conditions
        newTemplate = applyConditions(element, newTemplate); // update task type

        element = context.element = this._updateTaskType(element, newTemplate); // update properties

        this._updateProperties(element, oldTemplate, newTemplate); // update zeebe:TaskDefinition


        this._updateZeebeTaskDefinition(element, oldTemplate, newTemplate); // update zeebe:Input and zeebe:Output properties


        this._updateZeebeInputOutputParameterProperties(element, oldTemplate, newTemplate); // update zeebe:Header properties


        this._updateZeebeTaskHeaderProperties(element, oldTemplate, newTemplate); // update zeebe:Property properties


        this._updateZeebePropertyProperties(element, oldTemplate, newTemplate);
      }
    }

    _getOrCreateExtensionElements(element) {
      const bpmnFactory = this._bpmnFactory,
            modeling = this._modeling;
      const businessObject = getBusinessObject$1(element);
      let extensionElements = businessObject.get('extensionElements');

      if (!extensionElements) {
        extensionElements = bpmnFactory.create('bpmn:ExtensionElements', {
          values: []
        });
        extensionElements.$parent = businessObject;
        modeling.updateProperties(element, {
          extensionElements: extensionElements
        });
      }

      return extensionElements;
    }

    _updateZeebeModelerTemplate(element, newTemplate) {
      const modeling = this._modeling;
      modeling.updateProperties(element, {
        'zeebe:modelerTemplate': newTemplate && newTemplate.id,
        'zeebe:modelerTemplateVersion': newTemplate && newTemplate.version
      });
    }

    _updateZeebeModelerTemplateIcon(element, newTemplate) {
      const modeling = this._modeling;
      const icon = newTemplate && newTemplate.icon;
      modeling.updateProperties(element, {
        'zeebe:modelerTemplateIcon': icon && icon.contents
      });
    }

    _updateProperties(element, oldTemplate, newTemplate) {
      const commandStack = this._commandStack;
      const newProperties = newTemplate.properties.filter(newProperty => {
        const newBinding = newProperty.binding,
              newBindingType = newBinding.type;
        return newBindingType === 'property';
      });

      if (!newProperties.length) {
        return;
      }

      const businessObject = getBusinessObject$1(element);
      newProperties.forEach(newProperty => {
        const oldProperty = findOldProperty$1(oldTemplate, newProperty),
              newBinding = newProperty.binding,
              newBindingName = newBinding.name,
              newPropertyValue = newProperty.value,
              changedElement = businessObject;
        let properties = {};

        if (shouldKeepValue(changedElement, oldProperty, newProperty)) {
          return;
        }

        properties[newBindingName] = newPropertyValue;
        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: businessObject,
          properties
        });
      });
    }
    /**
     * Update `zeebe:TaskDefinition` properties of specified business object. This
     * can only exist in `bpmn:ExtensionElements`.
     *
     * @param {djs.model.Base} element
     * @param {Object} oldTemplate
     * @param {Object} newTemplate
     */


    _updateZeebeTaskDefinition(element, oldTemplate, newTemplate) {
      const bpmnFactory = this._bpmnFactory,
            commandStack = this._commandStack;
      const newProperties = newTemplate.properties.filter(newProperty => {
        const newBinding = newProperty.binding,
              newBindingType = newBinding.type;
        return newBindingType === 'zeebe:taskDefinition:type';
      }); // (1) do not override old task definition if no new properties specified

      if (!newProperties.length) {
        return;
      }

      const businessObject = this._getOrCreateExtensionElements(element);

      newProperties.forEach(newProperty => {
        const oldProperty = findOldProperty$1(oldTemplate, newProperty),
              oldBinding = oldProperty && oldProperty.binding,
              oldBindingType = oldBinding && oldBinding.type,
              oldTaskDefinition = findBusinessObject(businessObject, newProperty),
              newPropertyValue = newProperty.value,
              newBinding = newProperty.binding,
              newBindingType = newBinding.type; // (2) update old task definition

        if (oldTaskDefinition) {
          if (!shouldKeepValue(oldTaskDefinition, oldProperty, newProperty)) {
            // TODO(pinussilvestrus): for now we only support <type>
            // this needs to be adjusted once we support more
            let properties = {};

            if (oldBindingType === 'zeebe:taskDefinition:type' || !oldBindingType) {
              properties = {
                type: newPropertyValue
              };
            }

            commandStack.execute('element.updateModdleProperties', {
              element,
              moddleElement: oldTaskDefinition,
              properties
            });
          }
        } // (3) add new task definition
        else {
          let newTaskDefinition; // TODO(pinussilvestrus): for now we only support <type>
          // this needs to be adjusted once we support more

          if (newBindingType === 'zeebe:taskDefinition:type') {
            newTaskDefinition = createTaskDefinitionWithType(newPropertyValue, bpmnFactory);
          }

          commandStack.execute('element.updateModdleProperties', {
            element,
            moddleElement: businessObject,
            properties: {
              values: [...businessObject.get('values'), newTaskDefinition]
            }
          });
        }
      });
    }
    /**
     * Update `zeebe:Input` and `zeebe:Output` properties of specified business
     * object. Both can only exist in `zeebe:ioMapping` which can exist in `bpmn:ExtensionElements`.
     *
     * @param {djs.model.Base} element
     * @param {Object} oldTemplate
     * @param {Object} newTemplate
     */


    _updateZeebeInputOutputParameterProperties(element, oldTemplate, newTemplate) {
      const bpmnFactory = this._bpmnFactory,
            commandStack = this._commandStack;
      const newProperties = newTemplate.properties.filter(newProperty => {
        const newBinding = newProperty.binding,
              newBindingType = newBinding.type;
        return newBindingType === 'zeebe:input' || newBindingType === 'zeebe:output';
      });

      const businessObject = this._getOrCreateExtensionElements(element);

      let ioMapping = findExtension$1(businessObject, 'zeebe:IoMapping'); // (1) remove old mappings if no new specified

      if (!newProperties.length) {
        if (!ioMapping) {
          return;
        }

        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: businessObject,
          properties: {
            values: without(businessObject.get('values'), ioMapping)
          }
        });
      }

      if (!ioMapping) {
        ioMapping = bpmnFactory.create('zeebe:IoMapping');
        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: businessObject,
          properties: {
            values: [...businessObject.get('values'), ioMapping]
          }
        });
      }

      const oldInputs = ioMapping.get('zeebe:inputParameters') ? ioMapping.get('zeebe:inputParameters').slice() : [];
      const oldOutputs = ioMapping.get('zeebe:outputParameters') ? ioMapping.get('zeebe:outputParameters').slice() : [];
      let propertyName;
      newProperties.forEach(newProperty => {
        const oldProperty = findOldProperty$1(oldTemplate, newProperty),
              inputOrOutput = findBusinessObject(businessObject, newProperty),
              newPropertyValue = newProperty.value,
              newBinding = newProperty.binding,
              newBindingType = newBinding.type;
        let newInputOrOutput, properties; // (2) update old inputs and outputs

        if (inputOrOutput) {
          // (2a) exclude old inputs and outputs from cleanup, unless
          // a) optional and has empty value, and
          // b) not changed
          if (shouldUpdate(newPropertyValue, newProperty) || shouldKeepValue(inputOrOutput, oldProperty, newProperty)) {
            if (is$4(inputOrOutput, 'zeebe:Input')) {
              remove$1(oldInputs, inputOrOutput);
            } else {
              remove$1(oldOutputs, inputOrOutput);
            }
          } // (2a) do updates (unless changed)


          if (!shouldKeepValue(inputOrOutput, oldProperty, newProperty)) {
            if (is$4(inputOrOutput, 'zeebe:Input')) {
              properties = {
                source: newPropertyValue
              };
            } else {
              properties = {
                target: newPropertyValue
              };
            }

            commandStack.execute('element.updateModdleProperties', {
              element,
              moddleElement: inputOrOutput,
              properties
            });
          }
        } // (3) add new inputs and outputs (unless optional)
        else if (shouldUpdate(newPropertyValue, newProperty)) {
          if (newBindingType === 'zeebe:input') {
            propertyName = 'inputParameters';
            newInputOrOutput = createInputParameter$1(newBinding, newPropertyValue, bpmnFactory);
          } else {
            propertyName = 'outputParameters';
            newInputOrOutput = createOutputParameter$1(newBinding, newPropertyValue, bpmnFactory);
          }

          commandStack.execute('element.updateModdleProperties', {
            element,
            moddleElement: ioMapping,
            properties: {
              [propertyName]: [...ioMapping.get(propertyName), newInputOrOutput]
            }
          });
        }
      }); // (4) remove old inputs and outputs

      if (oldInputs.length) {
        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: ioMapping,
          properties: {
            inputParameters: without(ioMapping.get('inputParameters'), inputParameter => oldInputs.includes(inputParameter))
          }
        });
      }

      if (oldOutputs.length) {
        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: ioMapping,
          properties: {
            outputParameters: without(ioMapping.get('outputParameters'), outputParameter => oldOutputs.includes(outputParameter))
          }
        });
      }
    }
    /**
     * Update `zeebe:Header` properties of specified business
     * object. Those can only exist in `zeebe:taskHeaders` which can exist in `bpmn:ExtensionElements`.
     *
     * @param {djs.model.Base} element
     * @param {Object} oldTemplate
     * @param {Object} newTemplate
     */


    _updateZeebeTaskHeaderProperties(element, oldTemplate, newTemplate) {
      const bpmnFactory = this._bpmnFactory,
            commandStack = this._commandStack;
      const newProperties = newTemplate.properties.filter(newProperty => {
        const newBinding = newProperty.binding,
              newBindingType = newBinding.type;
        return newBindingType === 'zeebe:taskHeader';
      });

      const businessObject = this._getOrCreateExtensionElements(element);

      let taskHeaders = findExtension$1(businessObject, 'zeebe:TaskHeaders'); // (1) remove old headers if no new specified

      if (!newProperties.length) {
        if (!taskHeaders) {
          return;
        }

        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: businessObject,
          properties: {
            values: without(businessObject.get('values'), taskHeaders)
          }
        });
      }

      if (!taskHeaders) {
        taskHeaders = bpmnFactory.create('zeebe:TaskHeaders');
        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: businessObject,
          properties: {
            values: [...businessObject.get('values'), taskHeaders]
          }
        });
      }

      const oldHeaders = taskHeaders.get('zeebe:values') ? taskHeaders.get('zeebe:values').slice() : [];
      newProperties.forEach(newProperty => {
        const oldProperty = findOldProperty$1(oldTemplate, newProperty),
              oldHeader = findBusinessObject(businessObject, newProperty),
              newPropertyValue = newProperty.value,
              newBinding = newProperty.binding; // (2) update old headers

        if (oldHeader) {
          if (!shouldKeepValue(oldHeader, oldProperty, newProperty)) {
            const properties = {
              value: newPropertyValue
            };
            commandStack.execute('element.updateModdleProperties', {
              element,
              moddleElement: oldHeader,
              properties
            });
          }

          remove$1(oldHeaders, oldHeader);
        } // (3) add new (non-empty) headers
        else if (newPropertyValue) {
          const newHeader = createTaskHeader(newBinding, newPropertyValue, bpmnFactory);
          commandStack.execute('element.updateModdleProperties', {
            element,
            moddleElement: taskHeaders,
            properties: {
              values: [...taskHeaders.get('values'), newHeader]
            }
          });
        }
      }); // (4) remove old headers

      if (oldHeaders.length) {
        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: taskHeaders,
          properties: {
            values: without(taskHeaders.get('values'), header => oldHeaders.includes(header))
          }
        });
      }
    }
    /**
     * Update zeebe:Property properties of zeebe:Properties extension element.
     *
     * @param {djs.model.Base} element
     * @param {Object} oldTemplate
     * @param {Object} newTemplate
     */


    _updateZeebePropertyProperties(element, oldTemplate, newTemplate) {
      const bpmnFactory = this._bpmnFactory,
            commandStack = this._commandStack;
      const newProperties = newTemplate.properties.filter(newProperty => {
        const newBinding = newProperty.binding,
              newBindingType = newBinding.type;
        return newBindingType === 'zeebe:property';
      });

      const businessObject = this._getOrCreateExtensionElements(element);

      let zeebeProperties = findExtension$1(businessObject, 'zeebe:Properties'); // (1) remove old zeebe:Properties if no new zeebe:Property properties

      if (!newProperties.length) {
        if (!zeebeProperties) {
          return;
        }

        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: businessObject,
          properties: {
            values: without(businessObject.get('values'), zeebeProperties)
          }
        });
      }

      if (!zeebeProperties) {
        zeebeProperties = bpmnFactory.create('zeebe:Properties');
        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: businessObject,
          properties: {
            values: [...businessObject.get('values'), zeebeProperties]
          }
        });
      }

      const oldZeebeProperties = zeebeProperties.get('properties') ? zeebeProperties.get('properties').slice() : [];
      newProperties.forEach(newProperty => {
        const oldProperty = findOldProperty$1(oldTemplate, newProperty),
              oldZeebeProperty = findBusinessObject(businessObject, newProperty),
              newPropertyValue = newProperty.value,
              newBinding = newProperty.binding; // (2) update old zeebe:Property

        if (oldZeebeProperty) {
          if (shouldUpdate(newPropertyValue, newProperty) || shouldKeepValue(oldZeebeProperty, oldProperty, newProperty)) {
            remove$1(oldZeebeProperties, oldZeebeProperty);
          }

          if (!shouldKeepValue(oldZeebeProperty, oldProperty, newProperty)) {
            commandStack.execute('element.updateModdleProperties', {
              element,
              moddleElement: oldZeebeProperty,
              properties: {
                value: newPropertyValue
              }
            });
          }
        } // (3) add new zeebe:Property
        else if (shouldUpdate(newPropertyValue, newProperty)) {
          const newProperty = createZeebeProperty(newBinding, newPropertyValue, bpmnFactory);
          commandStack.execute('element.updateModdleProperties', {
            element,
            moddleElement: zeebeProperties,
            properties: {
              properties: [...zeebeProperties.get('properties'), newProperty]
            }
          });
        }
      }); // (4) remove old zeebe:Property

      if (oldZeebeProperties.length) {
        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: zeebeProperties,
          properties: {
            properties: without(zeebeProperties.get('properties'), zeebeProperty => oldZeebeProperties.includes(zeebeProperty))
          }
        });
      }
    }
    /**
     * Replaces the element with the specified elementType
     *
     * @param {djs.model.Base} element
     * @param {Object} newTemplate
     */


    _updateTaskType(element, newTemplate) {
      // determine new task type
      const newType = newTemplate.elementType;

      if (!newType) {
        return element;
      } // don't replace Task that is already the correct type


      if (element.$type === newType.value) {
        return element;
      }

      return this._bpmnReplace.replaceElement(element, {
        type: newType.value
      });
    }

  }
  ChangeElementTemplateHandler$1.$inject = ['bpmnFactory', 'bpmnReplace', 'commandStack', 'modeling']; // helpers //////////

  /**
   * Find business object matching specified property.
   *
   * @param {djs.model.Base|ModdleElement} element
   * @param {Object} property
   *
   * @returns {ModdleElement}
   */

  function findBusinessObject(element, property) {
    const businessObject = getBusinessObject$1(element);
    const binding = property.binding,
          bindingType = binding.type;

    if (bindingType === 'zeebe:taskDefinition:type') {
      return findExtension$1(businessObject, 'zeebe:TaskDefinition');
    }

    if (bindingType === 'zeebe:input' || bindingType === 'zeebe:output') {
      const extensionElements = findExtension$1(businessObject, 'zeebe:IoMapping');

      if (!extensionElements) {
        return;
      }

      if (bindingType === 'zeebe:input') {
        return find$1(extensionElements.get('zeebe:inputParameters'), function (input) {
          return input.get('zeebe:target') === binding.name;
        });
      } else {
        return find$1(extensionElements.get('zeebe:outputParameters'), function (output) {
          return output.get('zeebe:source') === binding.source;
        });
      }
    }

    if (bindingType === 'zeebe:taskHeader') {
      const extensionElements = findExtension$1(businessObject, 'zeebe:TaskHeaders');

      if (!extensionElements) {
        return;
      }

      return find$1(extensionElements.get('zeebe:values'), function (value) {
        return value.get('zeebe:key') === binding.key;
      });
    }

    if (bindingType === 'zeebe:property') {
      const zeebeProperties = findExtension$1(businessObject, 'zeebe:Properties');

      if (!zeebeProperties) {
        return;
      }

      return zeebeProperties.get('properties').find(value => {
        return value.get('name') === binding.name;
      });
    }
  }
  /**
   * Find old property matching specified new property.
   *
   * @param {Object} oldTemplate
   * @param {Object} newProperty
   *
   * @returns {Object}
   */


  function findOldProperty$1(oldTemplate, newProperty) {
    if (!oldTemplate) {
      return;
    }

    const oldProperties = oldTemplate.properties,
          newBinding = newProperty.binding,
          newBindingName = newBinding.name,
          newBindingType = newBinding.type;

    if (newBindingType === 'property') {
      return find$1(oldProperties, function (oldProperty) {
        const oldBinding = oldProperty.binding,
              oldBindingName = oldBinding.name,
              oldBindingType = oldBinding.type;
        return oldBindingType === 'property' && oldBindingName === newBindingName;
      });
    }

    if (newBindingType === 'zeebe:taskDefinition:type') {
      return find$1(oldProperties, function (oldProperty) {
        const oldBinding = oldProperty.binding,
              oldBindingType = oldBinding.type;
        return oldBindingType === 'zeebe:taskDefinition:type';
      });
    }

    if (newBindingType === 'zeebe:input') {
      return find$1(oldProperties, function (oldProperty) {
        const oldBinding = oldProperty.binding,
              oldBindingName = oldBinding.name,
              oldBindingType = oldBinding.type;

        if (oldBindingType !== 'zeebe:input') {
          return;
        }

        return oldBindingName === newBindingName;
      });
    }

    if (newBindingType === 'zeebe:output') {
      return find$1(oldProperties, function (oldProperty) {
        const oldBinding = oldProperty.binding,
              oldBindingType = oldBinding.type;

        if (oldBindingType !== 'zeebe:output') {
          return;
        }

        return oldBinding.source === newBinding.source;
      });
    }

    if (newBindingType === 'zeebe:taskHeader') {
      return find$1(oldProperties, function (oldProperty) {
        const oldBinding = oldProperty.binding,
              oldBindingType = oldBinding.type;

        if (oldBindingType !== 'zeebe:taskHeader') {
          return;
        }

        return oldBinding.key === newBinding.key;
      });
    }

    if (newBindingType === 'zeebe:property') {
      return oldProperties.find(oldProperty => {
        const oldBinding = oldProperty.binding,
              oldBindingType = oldBinding.type;

        if (oldBindingType !== 'zeebe:property') {
          return;
        }

        return oldBinding.name === newBinding.name;
      });
    }
  }
  /**
   * Check whether the existing property should be keept. This is the case if
   *  - an old template was set and the value differs from the default
   *  - no template was set but the property was set manually
   *
   * @param {djs.model.Base|ModdleElement} element
   * @param {Object} oldProperty
   * @param {Object} newProperty
   *
   * @returns {boolean}
   */

  function shouldKeepValue(element, oldProperty, newProperty) {
    // "Hidden" values are treated as a constant
    if (newProperty.type === 'Hidden') {
      return false;
    } // Dropdowns should keep existing configuration
    // cf. https://github.com/bpmn-io/bpmn-js-properties-panel/issues/767


    if (newProperty.type === 'Dropdown') {
      const currentValue = getPropertyValue(element, newProperty); // only keep value if old value is a valid option

      return newProperty.choices && newProperty.choices.some(choice => choice.value === currentValue);
    }

    if (oldProperty) {
      return propertyChanged$1(element, oldProperty);
    } else {
      return !!getPropertyValue(element, newProperty);
    }
  }
  /**
   * Check whether property was changed after being set by template.
   *
   * @param {djs.model.Base|ModdleElement} element
   * @param {Object} oldProperty
   *
   * @returns {boolean}
   */


  function propertyChanged$1(element, oldProperty) {
    const oldPropertyValue = oldProperty.value;
    return getPropertyValue(element, oldProperty) !== oldPropertyValue;
  }

  function getPropertyValue(element, property) {
    const businessObject = getBusinessObject$1(element);
    const binding = property.binding,
          bindingName = binding.name,
          bindingType = binding.type;

    if (bindingType === 'property') {
      return businessObject.get(bindingName);
    }

    if (bindingType === 'zeebe:taskDefinition:type') {
      return businessObject.get('zeebe:type');
    }

    if (bindingType === 'zeebe:input') {
      return businessObject.get('zeebe:source');
    }

    if (bindingType === 'zeebe:output') {
      return businessObject.get('zeebe:target');
    }

    if (bindingType === 'zeebe:taskHeader') {
      return businessObject.get('zeebe:value');
    }

    if (bindingType === 'zeebe:property') {
      return businessObject.get('zeebe:value');
    }
  }

  function remove$1(array, item) {
    const index = array.indexOf(item);

    if (isUndefined(index)) {
      return array;
    }

    array.splice(index, 1);
    return array;
  }

  /**
   * Checks the conditions of an element template and sets/resets the
   * corresponding properties on the element.
   */

  class ElementTemplatesConditionChecker extends CommandInterceptor {
    constructor(eventBus, elementTemplates, commandStack, bpmnFactory) {
      super(eventBus);
      this._eventBus = eventBus;
      this._elementTemplates = elementTemplates;
      this._commandStack = commandStack;
      this._bpmnFactory = bpmnFactory;
      this.preExecute(['element.updateProperties', 'element.updateModdleProperties'], this._saveConditionalState, true, this);
      this.postExecute(['element.updateProperties', 'element.updateModdleProperties', 'propertiesPanel.zeebe.changeTemplate'], this._applyConditions, true, this);
    }

    _saveConditionalState(context) {
      const {
        element
      } = context;

      const template = this._elementTemplates.get(element);

      if (!template) {
        return;
      }

      context.oldTemplate = applyConditions(element, template);
    }

    _applyConditions(context) {
      const {
        element,
        oldTemplate
      } = context;

      const template = this._elementTemplates.get(element);

      if (!template || !oldTemplate || template.id !== oldTemplate.id) {
        return;
      }

      const newTemplate = applyConditions(element, template);
      const propertiesToAdd = getMissingProperties(oldTemplate, newTemplate);
      const propertiesToRemove = getMissingProperties(newTemplate, oldTemplate);
      propertiesToAdd.forEach(property => setPropertyValue(this._bpmnFactory, this._commandStack, element, property, property.value));
      propertiesToRemove.forEach(property => unsetProperty(this._commandStack, element, property));
    }

  }
  ElementTemplatesConditionChecker.$inject = ['eventBus', 'elementTemplates', 'commandStack', 'bpmnFactory']; // helpers

  function getMissingProperties(sourceTemplate, targetTemplate) {
    let properties = targetTemplate.properties;
    return properties.filter(targetProp => !findOldProperty$1(sourceTemplate, targetProp));
  }

  /**
   * The BPMN 2.0 extension attribute name under
   * which the element template ID is stored.
   *
   * @type {String}
   */

  const TEMPLATE_ID_ATTR = 'camunda:modelerTemplate';
  /**
   * The BPMN 2.0 extension attribute name under
   * which the element template version is stored.
   *
   * @type {String}
   */

  const TEMPLATE_VERSION_ATTR = 'camunda:modelerTemplateVersion';
  /**
   * Get template id for a given diagram element.
   *
   * @param {djs.model.Base} element
   *
   * @return {String}
   */

  function getTemplateId(element) {
    const businessObject = getBusinessObject$1(element);

    if (businessObject) {
      return businessObject.get(TEMPLATE_ID_ATTR);
    }
  }
  /**
   * Get template version for a given diagram element.
   *
   * @param {djs.model.Base} element
   *
   * @return {String}
   */

  function getTemplateVersion(element) {
    const businessObject = getBusinessObject$1(element);

    if (businessObject) {
      return businessObject.get(TEMPLATE_VERSION_ATTR);
    }
  }
  /**
   * Find extension with given type in
   * BPMN element, diagram element or ExtensionElement.
   *
   * @param {ModdleElement|djs.model.Base} element
   * @param {String} type
   *
   * @return {ModdleElement} the extension
   */

  function findExtension(element, type) {
    const businessObject = getBusinessObject$1(element);
    let extensionElements;

    if (is$4(businessObject, 'bpmn:ExtensionElements')) {
      extensionElements = businessObject;
    } else {
      extensionElements = businessObject.get('extensionElements');
    }

    if (!extensionElements) {
      return null;
    }

    return extensionElements.get('values').find(value => {
      return is$4(value, type);
    });
  }
  function findExtensions(element, types) {
    const extensionElements = getExtensionElements(element);

    if (!extensionElements) {
      return [];
    }

    return extensionElements.get('values').filter(value => {
      return isAny(value, types);
    });
  }
  function findCamundaInOut(element, binding) {
    const extensionElements = getExtensionElements(element);

    if (!extensionElements) {
      return;
    }

    const {
      type
    } = binding;
    let matcher;

    if (type === 'camunda:in') {
      matcher = element => {
        return is$4(element, 'camunda:In') && isInOut(element, binding);
      };
    } else if (type === 'camunda:out') {
      matcher = element => {
        return is$4(element, 'camunda:Out') && isInOut(element, binding);
      };
    } else if (type === 'camunda:in:businessKey') {
      matcher = element => {
        return is$4(element, 'camunda:In') && 'businessKey' in element;
      };
    }

    return extensionElements.get('values').find(matcher);
  }
  function findCamundaProperty(camundaProperties, binding) {
    return camundaProperties.get('values').find(value => {
      return value.name === binding.name;
    });
  }
  function findInputParameter(inputOutput, binding) {
    const parameters = inputOutput.get('inputParameters');
    return parameters.find(parameter => {
      return parameter.name === binding.name;
    });
  }
  function findOutputParameter(inputOutput, binding) {
    const parameters = inputOutput.get('outputParameters');
    return parameters.find(function (parameter) {
      const {
        value
      } = parameter;

      if (!binding.scriptFormat) {
        return value === binding.source;
      }

      const definition = parameter.get('camunda:definition');

      if (!definition || binding.scriptFormat !== definition.get('camunda:scriptFormat')) {
        return false;
      }

      return definition.get('camunda:value') === binding.source;
    });
  }
  function findCamundaErrorEventDefinition(element, errorRef) {
    const errorEventDefinitions = findExtensions(element, ['camunda:ErrorEventDefinition']);
    let error; // error ID has to start with <Error_${ errorRef }_>

    return errorEventDefinitions.find(definition => {
      error = definition.get('bpmn:errorRef');

      if (error) {
        return error.get('bpmn:id').startsWith(`Error_${errorRef}`);
      }
    });
  }

  function getExtensionElements(element) {
    const businessObject = getBusinessObject$1(element);

    if (is$4(businessObject, 'bpmn:ExtensionElements')) {
      return businessObject;
    } else {
      return businessObject.get('extensionElements');
    }
  }

  function isInOut(element, binding) {
    if (binding.type === 'camunda:in') {
      // find based on target attribute
      if (binding.target) {
        return element.target === binding.target;
      }
    }

    if (binding.type === 'camunda:out') {
      // find based on source / sourceExpression
      if (binding.source) {
        return element.source === binding.source;
      }

      if (binding.sourceExpression) {
        return element.sourceExpression === binding.sourceExpression;
      }
    } // find based variables / local combination


    if (binding.variables) {
      return element.variables === 'all' && (binding.variables !== 'local' || element.local);
    }
  }

  /**
   * Registry for element templates.
   */

  class ElementTemplates$1 {
    constructor(commandStack) {
      this._commandStack = commandStack;
      this._templates = {};
    }
    /**
     * Get template with given ID and optional version or for element.
     *
     * @param {String|djs.model.Base} id
     * @param {number} [version]
     *
     * @return {ElementTemplate}
     */


    get(id, version) {
      const templates = this._templates;
      let element;

      if (isUndefined(id)) {
        return null;
      } else if (isString(id)) {
        if (isUndefined(version)) {
          version = '_';
        }

        if (templates[id] && templates[id][version]) {
          return templates[id][version];
        } else {
          return null;
        }
      } else {
        element = id;
        return this.get(this._getTemplateId(element), this._getTemplateVersion(element));
      }
    }
    /**
     * Get default template for given element.
     *
     * @param {djs.model.Base} element
     *
     * @return {ElementTemplate}
     */


    getDefault(element) {
      return find$1(this.getAll(element), function (template) {
        return template.isDefault;
      }) || null;
    }
    /**
     * Get all templates (with given ID or applicable to element).
     *
     * @param {string|djs.model.Base} [id]
     * @return {Array<ElementTemplate>}
     */


    getAll(id) {
      return this._getTemplateVerions(id, {
        includeDeprecated: true
      });
    }
    /**
     * Get all templates (with given ID or applicable to element) with the latest
     * version.
     *
     * @param {String|djs.model.Base} [id]
     * @param {{ deprecated?: boolean }} [options]
     *
     * @return {Array<ElementTemplate>}
     */


    getLatest(id, options = {}) {
      return this._getTemplateVerions(id, { ...options,
        latest: true
      });
    }
    /**
     * Set templates.
     *
     * @param {Array<ElementTemplate>} templates
     */


    set(templates) {
      this._templates = {};
      templates.forEach(template => {
        const id = template.id,
              version = isUndefined(template.version) ? '_' : template.version;

        if (!this._templates[id]) {
          this._templates[id] = {
            latest: template
          };
        }

        this._templates[id][version] = template;
        const latestVerions = this._templates[id].latest.version;

        if (isUndefined(latestVerions) || template.version > latestVerions) {
          this._templates[id].latest = template;
        }
      });
    }
    /**
     * @param {object|string|null} id
     * @param { { latest?: boolean, deprecated?: boolean } [options]
     *
     * @return {Array<ElementTemplate>}
     */


    _getTemplateVerions(id, options = {}) {
      const {
        latest: latestOnly,
        deprecated: includeDeprecated
      } = options;
      const templates = this._templates;

      const getVersions = template => {
        const {
          latest,
          ...versions
        } = template;
        return latestOnly ? !includeDeprecated && latest.deprecated ? [] : [latest] : values(versions);
      };

      if (isNil(id)) {
        return flatten$1(values(templates).map(getVersions));
      }

      if (isObject(id)) {
        const element = id;
        return filter(this._getTemplateVerions(null, options), function (template) {
          return isAny(element, template.appliesTo);
        }) || [];
      }

      if (isString(id)) {
        return templates[id] && getVersions(templates[id]);
      }

      throw new Error('argument must be of type {string|djs.model.Base|undefined}');
    }

    _getTemplateId(element) {
      return getTemplateId(element);
    }

    _getTemplateVersion(element) {
      return getTemplateVersion(element);
    }
    /**
     * Apply element template to a given element.
     *
     * @param {djs.model.Base} element
     * @param {ElementTemplate} newTemplate
     *
     * @return {djs.model.Base} the updated element
     */


    applyTemplate(element, newTemplate) {
      const oldTemplate = this.get(element);
      const context = {
        element,
        newTemplate,
        oldTemplate
      };

      this._commandStack.execute('propertiesPanel.camunda.changeTemplate', context);

      return context.element;
    }

  }
  ElementTemplates$1.$inject = ['commandStack'];

  /**
   * Registry for element templates.
   */

  class ElementTemplates extends ElementTemplates$1 {
    constructor(templateElementFactory, commandStack) {
      super(commandStack);
      this._commandStack = commandStack;
      this._templateElementFactory = templateElementFactory;
    }

    _getTemplateId(element) {
      return getTemplateId$1(element);
    }

    _getTemplateVersion(element) {
      return getTemplateVersion$1(element);
    }
    /**
     * Create an element based on an element template.
     *
     * @param {ElementTemplate} template
     * @returns {djs.model.Base}
     */


    createElement(template) {
      if (!template) {
        throw new Error('template is missing');
      }

      const element = this._templateElementFactory.create(template);

      return element;
    }
    /**
     * Apply element template to a given element.
     *
     * @param {djs.model.Base} element
     * @param {ElementTemplate} newTemplate
     *
     * @return {djs.model.Base} the updated element
     */


    applyTemplate(element, newTemplate) {
      const oldTemplate = this.get(element);
      const context = {
        element,
        newTemplate,
        oldTemplate
      };

      this._commandStack.execute('propertiesPanel.zeebe.changeTemplate', context);

      return context.element;
    }

  }
  ElementTemplates.$inject = ['templateElementFactory', 'commandStack'];

  var semverCompare = function cmp(a, b) {
    var pa = a.split('.');
    var pb = b.split('.');

    for (var i = 0; i < 3; i++) {
      var na = Number(pa[i]);
      var nb = Number(pb[i]);
      if (na > nb) return 1;
      if (nb > na) return -1;
      if (!isNaN(na) && isNaN(nb)) return 1;
      if (isNaN(na) && !isNaN(nb)) return -1;
    }

    return 0;
  };

  var version$1 = "0.10.1";
  var standaloneValidator = {
    exports: {}
  };
  var equal = {
    exports: {}
  }; // do not edit .js files directly - edit src/index.jst

  var fastDeepEqual = function equal(a, b) {
    if (a === b) return true;

    if (a && b && typeof a == 'object' && typeof b == 'object') {
      if (a.constructor !== b.constructor) return false;
      var length, i, keys;

      if (Array.isArray(a)) {
        length = a.length;
        if (length != b.length) return false;

        for (i = length; i-- !== 0;) if (!equal(a[i], b[i])) return false;

        return true;
      }

      if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
      if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
      if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
      keys = Object.keys(a);
      length = keys.length;
      if (length !== Object.keys(b).length) return false;

      for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;

      for (i = length; i-- !== 0;) {
        var key = keys[i];
        if (!equal(a[key], b[key])) return false;
      }

      return true;
    } // true if both NaN, false otherwise


    return a !== a && b !== b;
  };

  (function (module) {
    // do NOT remove this file - it would break pre-compiled schemas
    // https://github.com/ajv-validator/ajv/issues/889
    module.exports = fastDeepEqual;
  })(equal);

  standaloneValidator.exports = validate14$1;
  standaloneValidator.exports.default = validate14$1;
  const schema17$1 = {
    "type": "object",
    "allOf": [{
      "required": ["name", "id", "appliesTo", "properties"],
      "properties": {
        "name": {
          "$id": "#/name",
          "type": "string",
          "description": "The name of the element template."
        },
        "id": {
          "$id": "#/id",
          "type": "string",
          "description": "The identifier of the element template."
        },
        "description": {
          "$id": "#/description",
          "type": "string",
          "description": "The description of the element template."
        },
        "version": {
          "$id": "#/version",
          "type": "integer",
          "description": "Optional version of the template. If you add a version to a template it will be considered unique based on its ID and version. Two templates can have the same ID if their version is different."
        },
        "isDefault": {
          "$id": "#/isDefault",
          "type": "boolean",
          "description": "Indicates whether the element template is a default template."
        },
        "appliesTo": {
          "$id": "#/appliesTo",
          "type": "array",
          "description": "List of BPMN types the template can be applied to.",
          "default": [],
          "items": {
            "$id": "#/appliesTo/items",
            "type": "string",
            "pattern": "^[\\w\\d]+:[\\w\\d]+$",
            "allOf": [{
              "examples": ["bpmn:Task", "bpmn:ServiceTask", "bpmn:SequenceFlow", "bpmn:Process", "bpmn:StartEvent", "bpmn:Gateway"]
            }],
            "errorMessage": {
              "pattern": "invalid item for \"appliesTo\", should contain namespaced property, example: \"bpmn:Task\""
            }
          }
        },
        "elementType": {
          "$id": "#/elementType",
          "type": "object",
          "description": "The BPMN type the element will be transformed into.",
          "default": {},
          "required": ["value"],
          "properties": {
            "value": {
              "$id": "#/elementType/value",
              "type": "string",
              "pattern": "^[\\w\\d]+:[\\w\\d]+$",
              "allOf": [{
                "examples": ["bpmn:ServiceTask", "bpmn:UserTask", "bpmn:StartEvent", "bpmn:ExclusiveGateway", "bpmn:ParallelGateway"]
              }],
              "errorMessage": {
                "pattern": "invalid item for \"elementType\", should contain namespaced property, example: \"bpmn:Task\""
              }
            }
          },
          "errorMessage": {
            "required": {
              "value": "missing elementType value"
            }
          }
        },
        "metadata": {
          "$id": "#/metadata",
          "type": "object",
          "description": "Some custom properties for further configuration.",
          "default": {}
        },
        "entriesVisible": {
          "$id": "#/entriesVisible",
          "type": "boolean",
          "description": "Select whether non-template entries are visible in the properties panel."
        },
        "groups": {
          "$id": "#/groups",
          "type": "array",
          "description": "Custom fields can be ordered together via groups.",
          "allOf": [{
            "examples": [[{
              "id": "group-1",
              "label": "My Group"
            }]]
          }],
          "items": {
            "$id": "#/groups/group",
            "type": "object",
            "default": {},
            "required": ["id", "label"],
            "properties": {
              "id": {
                "$id": "#/groups/group/id",
                "type": "string",
                "description": "The id of the custom group"
              },
              "label": {
                "$id": "#/groups/group/label",
                "type": "string",
                "description": "The label of the custom group"
              }
            },
            "errorMessage": {
              "required": {
                "id": "missing id for group \"${0#}\"",
                "label": "missing label for group \"${0#}\""
              }
            }
          }
        },
        "documentationRef": {
          "$id": "#/documentationRef",
          "type": "string",
          "pattern": "^(https|http)://.*",
          "errorMessage": {
            "pattern": "Malformed documentation URL, must match \"^(https|http)://.*\""
          }
        }
      },
      "errorMessage": {
        "required": {
          "name": "missing template name",
          "id": "missing template id",
          "appliesTo": "missing appliesTo=[]",
          "properties": "missing properties=[]"
        }
      }
    }],
    "properties": {
      "properties": {
        "$ref": "#/definitions/properties",
        "$id": "#/properties"
      },
      "scopes": {
        "$id": "#/scopes",
        "type": "array",
        "description": "Special scoped bindings that allow you to configure nested elements.",
        "allOf": [{
          "examples": [[{
            "type": "bpmn:Error",
            "id": "Error_1",
            "properties": [{
              "value": "error-code",
              "binding": {
                "type": "property",
                "name": "errorCode"
              }
            }, {
              "value": "error-message",
              "binding": {
                "type": "property",
                "name": "camunda:errorMessage"
              }
            }, {
              "value": "error-name",
              "binding": {
                "type": "property",
                "name": "name"
              }
            }]
          }]]
        }],
        "items": {
          "$id": "#/scopes/item",
          "type": "object",
          "default": {},
          "properties": {
            "type": {
              "$id": "#scopes/item/type",
              "type": "string",
              "description": "The type of a scope.",
              "enum": ["camunda:Connector", "bpmn:Error"],
              "errorMessage": "invalid scope type ${0}; must be any of { camunda:Connector, bpmn:Error }"
            },
            "properties": {
              "$id": "#/scopes/properties",
              "description": "List of properties of a scope.",
              "default": [],
              "allOf": [{
                "$ref": "#/definitions/properties/allOf/0"
              }, {
                "$ref": "#/definitions/properties/allOf/1"
              }]
            }
          },
          "required": ["type", "properties"],
          "allOf": [{
            "if": {
              "properties": {
                "type": {
                  "enum": ["bpmn:Error"]
                }
              },
              "required": ["type"]
            },
            "then": {
              "required": ["id"],
              "errorMessage": "invalid scope ${0/type}, missing id"
            }
          }],
          "errorMessage": {
            "required": {
              "type": "invalid scope, missing type",
              "properties": "invalid scope ${0/type}, missing properties=[]"
            }
          }
        }
      }
    }
  };
  const schema18$1 = {
    "allOf": [{
      "type": "array",
      "description": "List of properties of the element template.",
      "allOf": [{
        "examples": [[{
          "label": "Name",
          "type": "String",
          "binding": {
            "type": "property",
            "name": "name"
          }
        }]]
      }],
      "items": {
        "type": "object",
        "default": {},
        "allOf": [{
          "if": {
            "properties": {
              "type": {
                "const": "Dropdown"
              }
            },
            "required": ["type"]
          },
          "then": {
            "required": ["choices"],
            "errorMessage": "must provide choices=[] with \"Dropdown\" type"
          }
        }],
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier of the property."
          },
          "value": {
            "$id": "#/properties/property/value",
            "type": ["string", "boolean"],
            "description": "The value of a control field."
          },
          "description": {
            "$id": "#/properties/property/description",
            "type": "string",
            "description": "The description of a control field."
          },
          "label": {
            "$id": "#/properties/property/label",
            "type": "string",
            "description": "The label of a control field."
          },
          "type": {
            "$id": "#/properties/property/type",
            "type": "string",
            "description": "The type of a control field."
          },
          "editable": {
            "$id": "#/properties/property/editable",
            "type": "boolean",
            "description": "Indicates whether a control field is editable or not."
          },
          "choices": {
            "$id": "#/properties/property/choices",
            "type": "array",
            "description": "The choices for dropdown fields.",
            "default": [],
            "items": {
              "$id": "#/properties/property/choices/item",
              "type": "object",
              "default": {},
              "properties": {
                "name": {
                  "$id": "#/properties/property/choices/item/name",
                  "type": "string",
                  "description": "The name of a choice."
                },
                "value": {
                  "$id": "#/properties/property/choices/item/value",
                  "type": "string",
                  "description": "The value of a choice."
                }
              },
              "required": ["value", "name"],
              "errorMessage": {
                "required": "{ name, value } must be specified for \"Dropdown\" choices"
              }
            }
          },
          "constraints": {
            "$id": "#/properties/property/constraints",
            "type": "object",
            "description": "The validation constraints of a control field.",
            "allOf": [{
              "examples": [{
                "notEmpty": true
              }]
            }],
            "properties": {
              "notEmpty": {
                "$id": "#/properties/property/constraints/notEmpty",
                "type": "boolean",
                "description": "The control field must not be empty."
              },
              "minLength": {
                "$id": "#/properties/property/constraints/minLength",
                "type": "number",
                "description": "The minimal length of a control field value."
              },
              "maxLength": {
                "$id": "#/properties/property/constraints/maxLength",
                "type": "number",
                "description": "The maximal length for a control field value."
              },
              "pattern": {
                "$id": "#/properties/property/constraints/pattern",
                "description": "A regular expression pattern for a constraint.",
                "oneOf": [{
                  "type": "object",
                  "default": {},
                  "properties": {
                    "value": {
                      "$id": "#/properties/property/constraints/pattern/value",
                      "type": "string",
                      "description": "The regular expression of a pattern."
                    },
                    "message": {
                      "$id": "#/properties/property/constraints/pattern/message",
                      "type": "string",
                      "description": "The validation message of a pattern."
                    }
                  }
                }, {
                  "type": "string"
                }]
              }
            }
          },
          "group": {
            "$id": "#/properties/property/group",
            "type": "string",
            "description": "The custom group of a control field."
          },
          "condition": {
            "$id": "#/condition",
            "type": "object",
            "description": "Condition to activate the binding.",
            "allOf": [{
              "examples": [{
                "type": "simple",
                "property": "httpMethod",
                "equals": "GET"
              }, {
                "type": "simple",
                "property": "httpMethod",
                "oneOf": ["POST", "PUT", "DELETE"]
              }]
            }],
            "required": ["property"],
            "properties": {
              "type": {
                "$id": "#/condition/type",
                "const": "simple",
                "description": "The type of the condition.",
                "default": "simple"
              },
              "property": {
                "$id": "#/condition/property",
                "type": "string",
                "description": "The id of the property to check."
              }
            },
            "oneOf": [{
              "properties": {
                "equals": {
                  "type": ["string", "number", "boolean"]
                }
              },
              "required": ["equals"]
            }, {
              "properties": {
                "oneOf": {
                  "type": "array",
                  "items": {
                    "type": ["string", "number"]
                  }
                }
              },
              "required": ["oneOf"]
            }],
            "errorMessage": {
              "required": {
                "property": "missing property name for condition"
              }
            }
          }
        }
      }
    }, {
      "$schema": "http://json-schema.org/draft-07/schema",
      "type": "array",
      "description": "List of properties of the element template.",
      "items": {
        "type": "object",
        "default": {},
        "required": ["binding"],
        "allOf": [{
          "if": {
            "properties": {
              "binding": {
                "properties": {
                  "type": {
                    "const": "property"
                  }
                },
                "required": ["type"]
              }
            },
            "required": ["binding"]
          },
          "then": {
            "properties": {
              "type": {
                "enum": ["String", "Text", "Hidden", "Dropdown", "Boolean"],
                "errorMessage": "invalid property type ${0} for binding type \"property\"; must be any of { String, Text, Hidden, Dropdown, Boolean }"
              }
            }
          }
        }, {
          "if": {
            "properties": {
              "binding": {
                "properties": {
                  "type": {
                    "const": "camunda:executionListener"
                  }
                },
                "required": ["type"]
              }
            },
            "required": ["binding"]
          },
          "then": {
            "properties": {
              "type": {
                "enum": ["Hidden"],
                "errorMessage": "invalid property type ${1/type} for binding type \"camunda:executionListener\"; must be \"Hidden\""
              }
            }
          }
        }, {
          "if": {
            "properties": {
              "binding": {
                "properties": {
                  "type": {
                    "enum": ["camunda:property", "camunda:outputParameter", "camunda:in", "camunda:in:businessKey", "camunda:out", "camunda:errorEventDefinition"]
                  }
                },
                "required": ["type"]
              }
            },
            "required": ["binding"]
          },
          "then": {
            "properties": {
              "type": {
                "enum": ["String", "Hidden", "Dropdown"],
                "errorMessage": "invalid property type ${0} for binding type ${1/binding/type}; must be any of { String, Hidden, Dropdown }"
              }
            }
          }
        }, {
          "if": {
            "properties": {
              "binding": {
                "properties": {
                  "type": {
                    "enum": ["camunda:inputParameter", "camunda:field"]
                  }
                },
                "required": ["type"]
              }
            },
            "required": ["binding"]
          },
          "then": {
            "properties": {
              "type": {
                "enum": ["String", "Text", "Hidden", "Dropdown"],
                "errorMessage": "invalid property type ${0} for binding type ${1/binding/type}; must be any of { String, Text, Hidden, Dropdown }"
              }
            }
          }
        }],
        "properties": {
          "binding": {
            "$id": "#/properties/property/binding",
            "type": "object",
            "description": "Specifying how the property is mapped to BPMN or Camunda extension elements and attributes.",
            "required": ["type"],
            "allOf": [{
              "if": {
                "properties": {
                  "type": {
                    "enum": ["property", "camunda:property", "camunda:inputParameter", "camunda:field"]
                  }
                },
                "required": ["type"]
              },
              "then": {
                "required": ["name"],
                "errorMessage": "property.binding ${0/type} requires name"
              }
            }, {
              "if": {
                "properties": {
                  "type": {
                    "const": "camunda:outputParameter"
                  }
                },
                "required": ["type"]
              },
              "then": {
                "required": ["source"],
                "errorMessage": "property.binding ${0/type} requires source"
              }
            }, {
              "if": {
                "properties": {
                  "type": {
                    "const": "camunda:in"
                  }
                },
                "required": ["type"]
              },
              "then": {
                "anyOf": [{
                  "required": ["variables"]
                }, {
                  "required": ["target"]
                }],
                "errorMessage": "property.binding ${0/type} requires variables, target, or both"
              }
            }, {
              "if": {
                "properties": {
                  "type": {
                    "const": "camunda:out"
                  }
                },
                "required": ["type"]
              },
              "then": {
                "oneOf": [{
                  "required": ["variables"],
                  "not": {
                    "anyOf": [{
                      "required": ["source"]
                    }, {
                      "required": ["sourceExpression"]
                    }]
                  }
                }, {
                  "required": ["source"],
                  "not": {
                    "anyOf": [{
                      "required": ["variables"]
                    }, {
                      "required": ["sourceExpression"]
                    }]
                  }
                }, {
                  "required": ["sourceExpression"],
                  "not": {
                    "anyOf": [{
                      "required": ["variables"]
                    }, {
                      "required": ["source"]
                    }]
                  }
                }, {
                  "required": ["variables", "sourceExpression"],
                  "not": {
                    "required": ["source"]
                  }
                }, {
                  "required": ["variables", "source"],
                  "not": {
                    "required": ["sourceExpression"]
                  }
                }],
                "errorMessage": "property.binding ${0/type} requires one of the following: variables, sourceExpression, source, (sourceExpression and variables), or (source and variables)"
              }
            }, {
              "if": {
                "properties": {
                  "type": {
                    "const": "camunda:errorEventDefinition"
                  }
                },
                "required": ["type"]
              },
              "then": {
                "oneOf": [{
                  "required": ["errorRef"]
                }],
                "errorMessage": "property.binding ${0/type} requires errorRef"
              }
            }, {
              "examples": [{
                "type": "property",
                "name": "name"
              }, {
                "type": "camunda:property",
                "name": "property"
              }, {
                "type": "camunda:inputParameter",
                "name": "input"
              }, {
                "type": "camunda:outputParameter",
                "source": "output"
              }, {
                "type": "camunda:in",
                "target": "target"
              }, {
                "type": "camunda:in:businessKey"
              }, {
                "type": "camunda:out",
                "source": "output"
              }, {
                "type": "camunda:executionListener",
                "event": "start"
              }, {
                "type": "camunda:field",
                "name": "field"
              }, {
                "type": "camunda:errorEventDefinition",
                "errorRef": "error"
              }, {
                "type": "camunda:errorEventDefinition",
                "errorRef": "error"
              }]
            }],
            "properties": {
              "type": {
                "$id": "#/properties/property/binding/type",
                "type": "string",
                "enum": ["property", "camunda:property", "camunda:inputParameter", "camunda:outputParameter", "camunda:in", "camunda:out", "camunda:in:businessKey", "camunda:executionListener", "camunda:field", "camunda:errorEventDefinition"],
                "description": "The type of a property binding.",
                "errorMessage": "invalid property.binding type ${0}; must be any of { property, camunda:property, camunda:inputParameter, camunda:outputParameter, camunda:in, camunda:out, camunda:in:businessKey, camunda:executionListener, camunda:field, camunda:errorEventDefinition }"
              },
              "name": {
                "$id": "#/properties/property/binding/name",
                "type": "string",
                "description": "The name of a property binding."
              },
              "event": {
                "$id": "#/properties/property/binding/event",
                "type": "string",
                "description": "The event type of a property binding (camunda:executionListener)."
              },
              "scriptFormat": {
                "$id": "#/properties/property/binding/scriptFormat",
                "type": "string",
                "description": "The script format of a property binding (camunda:outputParameter, camunda:inputParameter)."
              },
              "source": {
                "$id": "#/properties/property/binding/source",
                "type": "string",
                "description": "The source value of a property binding (camunda:outputParameter, camunda:out)."
              },
              "target": {
                "$id": "#/properties/property/binding/target",
                "type": "string",
                "description": "The target value of a property binding (camunda:in)."
              },
              "expression": {
                "$id": "#/properties/property/binding/expression",
                "type": "boolean",
                "description": "Indicates whether the control field value is an expression (camunda:in, camunda:field)."
              },
              "variables": {
                "$id": "#/properties/property/binding/variables",
                "type": "string",
                "enum": ["all", "local"],
                "description": "The variable mapping of a property binding (camunda:in)."
              },
              "sourceExpression": {
                "$id": "#/properties/property/binding/sourceExpression",
                "type": "string",
                "description": "The string containing the expression for the source attribute (camunda:out)."
              }
            }
          }
        },
        "errorMessage": {
          "required": "missing binding for property \"${0#}\""
        }
      }
    }]
  };
  const schema19 = {
    "type": "array",
    "description": "List of properties of the element template.",
    "allOf": [{
      "examples": [[{
        "label": "Name",
        "type": "String",
        "binding": {
          "type": "property",
          "name": "name"
        }
      }]]
    }],
    "items": {
      "type": "object",
      "default": {},
      "allOf": [{
        "if": {
          "properties": {
            "type": {
              "const": "Dropdown"
            }
          },
          "required": ["type"]
        },
        "then": {
          "required": ["choices"],
          "errorMessage": "must provide choices=[] with \"Dropdown\" type"
        }
      }],
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique identifier of the property."
        },
        "value": {
          "$id": "#/properties/property/value",
          "type": ["string", "boolean"],
          "description": "The value of a control field."
        },
        "description": {
          "$id": "#/properties/property/description",
          "type": "string",
          "description": "The description of a control field."
        },
        "label": {
          "$id": "#/properties/property/label",
          "type": "string",
          "description": "The label of a control field."
        },
        "type": {
          "$id": "#/properties/property/type",
          "type": "string",
          "description": "The type of a control field."
        },
        "editable": {
          "$id": "#/properties/property/editable",
          "type": "boolean",
          "description": "Indicates whether a control field is editable or not."
        },
        "choices": {
          "$id": "#/properties/property/choices",
          "type": "array",
          "description": "The choices for dropdown fields.",
          "default": [],
          "items": {
            "$id": "#/properties/property/choices/item",
            "type": "object",
            "default": {},
            "properties": {
              "name": {
                "$id": "#/properties/property/choices/item/name",
                "type": "string",
                "description": "The name of a choice."
              },
              "value": {
                "$id": "#/properties/property/choices/item/value",
                "type": "string",
                "description": "The value of a choice."
              }
            },
            "required": ["value", "name"],
            "errorMessage": {
              "required": "{ name, value } must be specified for \"Dropdown\" choices"
            }
          }
        },
        "constraints": {
          "$id": "#/properties/property/constraints",
          "type": "object",
          "description": "The validation constraints of a control field.",
          "allOf": [{
            "examples": [{
              "notEmpty": true
            }]
          }],
          "properties": {
            "notEmpty": {
              "$id": "#/properties/property/constraints/notEmpty",
              "type": "boolean",
              "description": "The control field must not be empty."
            },
            "minLength": {
              "$id": "#/properties/property/constraints/minLength",
              "type": "number",
              "description": "The minimal length of a control field value."
            },
            "maxLength": {
              "$id": "#/properties/property/constraints/maxLength",
              "type": "number",
              "description": "The maximal length for a control field value."
            },
            "pattern": {
              "$id": "#/properties/property/constraints/pattern",
              "description": "A regular expression pattern for a constraint.",
              "oneOf": [{
                "type": "object",
                "default": {},
                "properties": {
                  "value": {
                    "$id": "#/properties/property/constraints/pattern/value",
                    "type": "string",
                    "description": "The regular expression of a pattern."
                  },
                  "message": {
                    "$id": "#/properties/property/constraints/pattern/message",
                    "type": "string",
                    "description": "The validation message of a pattern."
                  }
                }
              }, {
                "type": "string"
              }]
            }
          }
        },
        "group": {
          "$id": "#/properties/property/group",
          "type": "string",
          "description": "The custom group of a control field."
        },
        "condition": {
          "$id": "#/condition",
          "type": "object",
          "description": "Condition to activate the binding.",
          "allOf": [{
            "examples": [{
              "type": "simple",
              "property": "httpMethod",
              "equals": "GET"
            }, {
              "type": "simple",
              "property": "httpMethod",
              "oneOf": ["POST", "PUT", "DELETE"]
            }]
          }],
          "required": ["property"],
          "properties": {
            "type": {
              "$id": "#/condition/type",
              "const": "simple",
              "description": "The type of the condition.",
              "default": "simple"
            },
            "property": {
              "$id": "#/condition/property",
              "type": "string",
              "description": "The id of the property to check."
            }
          },
          "oneOf": [{
            "properties": {
              "equals": {
                "type": ["string", "number", "boolean"]
              }
            },
            "required": ["equals"]
          }, {
            "properties": {
              "oneOf": {
                "type": "array",
                "items": {
                  "type": ["string", "number"]
                }
              }
            },
            "required": ["oneOf"]
          }],
          "errorMessage": {
            "required": {
              "property": "missing property name for condition"
            }
          }
        }
      }
    }
  };
  const schema20 = {
    "$schema": "http://json-schema.org/draft-07/schema",
    "type": "array",
    "description": "List of properties of the element template.",
    "items": {
      "type": "object",
      "default": {},
      "required": ["binding"],
      "allOf": [{
        "if": {
          "properties": {
            "binding": {
              "properties": {
                "type": {
                  "const": "property"
                }
              },
              "required": ["type"]
            }
          },
          "required": ["binding"]
        },
        "then": {
          "properties": {
            "type": {
              "enum": ["String", "Text", "Hidden", "Dropdown", "Boolean"],
              "errorMessage": "invalid property type ${0} for binding type \"property\"; must be any of { String, Text, Hidden, Dropdown, Boolean }"
            }
          }
        }
      }, {
        "if": {
          "properties": {
            "binding": {
              "properties": {
                "type": {
                  "const": "camunda:executionListener"
                }
              },
              "required": ["type"]
            }
          },
          "required": ["binding"]
        },
        "then": {
          "properties": {
            "type": {
              "enum": ["Hidden"],
              "errorMessage": "invalid property type ${1/type} for binding type \"camunda:executionListener\"; must be \"Hidden\""
            }
          }
        }
      }, {
        "if": {
          "properties": {
            "binding": {
              "properties": {
                "type": {
                  "enum": ["camunda:property", "camunda:outputParameter", "camunda:in", "camunda:in:businessKey", "camunda:out", "camunda:errorEventDefinition"]
                }
              },
              "required": ["type"]
            }
          },
          "required": ["binding"]
        },
        "then": {
          "properties": {
            "type": {
              "enum": ["String", "Hidden", "Dropdown"],
              "errorMessage": "invalid property type ${0} for binding type ${1/binding/type}; must be any of { String, Hidden, Dropdown }"
            }
          }
        }
      }, {
        "if": {
          "properties": {
            "binding": {
              "properties": {
                "type": {
                  "enum": ["camunda:inputParameter", "camunda:field"]
                }
              },
              "required": ["type"]
            }
          },
          "required": ["binding"]
        },
        "then": {
          "properties": {
            "type": {
              "enum": ["String", "Text", "Hidden", "Dropdown"],
              "errorMessage": "invalid property type ${0} for binding type ${1/binding/type}; must be any of { String, Text, Hidden, Dropdown }"
            }
          }
        }
      }],
      "properties": {
        "binding": {
          "$id": "#/properties/property/binding",
          "type": "object",
          "description": "Specifying how the property is mapped to BPMN or Camunda extension elements and attributes.",
          "required": ["type"],
          "allOf": [{
            "if": {
              "properties": {
                "type": {
                  "enum": ["property", "camunda:property", "camunda:inputParameter", "camunda:field"]
                }
              },
              "required": ["type"]
            },
            "then": {
              "required": ["name"],
              "errorMessage": "property.binding ${0/type} requires name"
            }
          }, {
            "if": {
              "properties": {
                "type": {
                  "const": "camunda:outputParameter"
                }
              },
              "required": ["type"]
            },
            "then": {
              "required": ["source"],
              "errorMessage": "property.binding ${0/type} requires source"
            }
          }, {
            "if": {
              "properties": {
                "type": {
                  "const": "camunda:in"
                }
              },
              "required": ["type"]
            },
            "then": {
              "anyOf": [{
                "required": ["variables"]
              }, {
                "required": ["target"]
              }],
              "errorMessage": "property.binding ${0/type} requires variables, target, or both"
            }
          }, {
            "if": {
              "properties": {
                "type": {
                  "const": "camunda:out"
                }
              },
              "required": ["type"]
            },
            "then": {
              "oneOf": [{
                "required": ["variables"],
                "not": {
                  "anyOf": [{
                    "required": ["source"]
                  }, {
                    "required": ["sourceExpression"]
                  }]
                }
              }, {
                "required": ["source"],
                "not": {
                  "anyOf": [{
                    "required": ["variables"]
                  }, {
                    "required": ["sourceExpression"]
                  }]
                }
              }, {
                "required": ["sourceExpression"],
                "not": {
                  "anyOf": [{
                    "required": ["variables"]
                  }, {
                    "required": ["source"]
                  }]
                }
              }, {
                "required": ["variables", "sourceExpression"],
                "not": {
                  "required": ["source"]
                }
              }, {
                "required": ["variables", "source"],
                "not": {
                  "required": ["sourceExpression"]
                }
              }],
              "errorMessage": "property.binding ${0/type} requires one of the following: variables, sourceExpression, source, (sourceExpression and variables), or (source and variables)"
            }
          }, {
            "if": {
              "properties": {
                "type": {
                  "const": "camunda:errorEventDefinition"
                }
              },
              "required": ["type"]
            },
            "then": {
              "oneOf": [{
                "required": ["errorRef"]
              }],
              "errorMessage": "property.binding ${0/type} requires errorRef"
            }
          }, {
            "examples": [{
              "type": "property",
              "name": "name"
            }, {
              "type": "camunda:property",
              "name": "property"
            }, {
              "type": "camunda:inputParameter",
              "name": "input"
            }, {
              "type": "camunda:outputParameter",
              "source": "output"
            }, {
              "type": "camunda:in",
              "target": "target"
            }, {
              "type": "camunda:in:businessKey"
            }, {
              "type": "camunda:out",
              "source": "output"
            }, {
              "type": "camunda:executionListener",
              "event": "start"
            }, {
              "type": "camunda:field",
              "name": "field"
            }, {
              "type": "camunda:errorEventDefinition",
              "errorRef": "error"
            }, {
              "type": "camunda:errorEventDefinition",
              "errorRef": "error"
            }]
          }],
          "properties": {
            "type": {
              "$id": "#/properties/property/binding/type",
              "type": "string",
              "enum": ["property", "camunda:property", "camunda:inputParameter", "camunda:outputParameter", "camunda:in", "camunda:out", "camunda:in:businessKey", "camunda:executionListener", "camunda:field", "camunda:errorEventDefinition"],
              "description": "The type of a property binding.",
              "errorMessage": "invalid property.binding type ${0}; must be any of { property, camunda:property, camunda:inputParameter, camunda:outputParameter, camunda:in, camunda:out, camunda:in:businessKey, camunda:executionListener, camunda:field, camunda:errorEventDefinition }"
            },
            "name": {
              "$id": "#/properties/property/binding/name",
              "type": "string",
              "description": "The name of a property binding."
            },
            "event": {
              "$id": "#/properties/property/binding/event",
              "type": "string",
              "description": "The event type of a property binding (camunda:executionListener)."
            },
            "scriptFormat": {
              "$id": "#/properties/property/binding/scriptFormat",
              "type": "string",
              "description": "The script format of a property binding (camunda:outputParameter, camunda:inputParameter)."
            },
            "source": {
              "$id": "#/properties/property/binding/source",
              "type": "string",
              "description": "The source value of a property binding (camunda:outputParameter, camunda:out)."
            },
            "target": {
              "$id": "#/properties/property/binding/target",
              "type": "string",
              "description": "The target value of a property binding (camunda:in)."
            },
            "expression": {
              "$id": "#/properties/property/binding/expression",
              "type": "boolean",
              "description": "Indicates whether the control field value is an expression (camunda:in, camunda:field)."
            },
            "variables": {
              "$id": "#/properties/property/binding/variables",
              "type": "string",
              "enum": ["all", "local"],
              "description": "The variable mapping of a property binding (camunda:in)."
            },
            "sourceExpression": {
              "$id": "#/properties/property/binding/sourceExpression",
              "type": "string",
              "description": "The string containing the expression for the source attribute (camunda:out)."
            }
          }
        }
      },
      "errorMessage": {
        "required": "missing binding for property \"${0#}\""
      }
    }
  };
  const pattern0$1 = new RegExp("^[\\w\\d]+:[\\w\\d]+$", "u");
  const pattern2$1 = new RegExp("^(https|http)://.*", "u");
  const obj0$1 = {
    "required": "missingProperty",
    "dependencies": "property",
    "dependentRequired": "property"
  };
  const func0$1 = equal.exports;

  function validate15$1(data, {
    dataPath = "",
    parentData,
    parentDataProperty,
    rootData = data
  } = {}) {
    let vErrors = null;
    let errors = 0;

    if (data && typeof data == "object" && !Array.isArray(data)) {
      if (data.name === undefined) {
        const err0 = {
          keyword: "required",
          dataPath,
          schemaPath: "#/allOf/0/required",
          params: {
            missingProperty: "name"
          },
          message: "should have required property '" + "name" + "'"
        };

        if (vErrors === null) {
          vErrors = [err0];
        } else {
          vErrors.push(err0);
        }

        errors++;
      }

      if (data.id === undefined) {
        const err1 = {
          keyword: "required",
          dataPath,
          schemaPath: "#/allOf/0/required",
          params: {
            missingProperty: "id"
          },
          message: "should have required property '" + "id" + "'"
        };

        if (vErrors === null) {
          vErrors = [err1];
        } else {
          vErrors.push(err1);
        }

        errors++;
      }

      if (data.appliesTo === undefined) {
        const err2 = {
          keyword: "required",
          dataPath,
          schemaPath: "#/allOf/0/required",
          params: {
            missingProperty: "appliesTo"
          },
          message: "should have required property '" + "appliesTo" + "'"
        };

        if (vErrors === null) {
          vErrors = [err2];
        } else {
          vErrors.push(err2);
        }

        errors++;
      }

      if (data.properties === undefined) {
        const err3 = {
          keyword: "required",
          dataPath,
          schemaPath: "#/allOf/0/required",
          params: {
            missingProperty: "properties"
          },
          message: "should have required property '" + "properties" + "'"
        };

        if (vErrors === null) {
          vErrors = [err3];
        } else {
          vErrors.push(err3);
        }

        errors++;
      }

      if (data.name !== undefined) {
        if (typeof data.name !== "string") {
          const err4 = {
            keyword: "type",
            dataPath: dataPath + "/name",
            schemaPath: "#/allOf/0/properties/name/type",
            params: {
              type: "string"
            },
            message: "should be string"
          };

          if (vErrors === null) {
            vErrors = [err4];
          } else {
            vErrors.push(err4);
          }

          errors++;
        }
      }

      if (data.id !== undefined) {
        if (typeof data.id !== "string") {
          const err5 = {
            keyword: "type",
            dataPath: dataPath + "/id",
            schemaPath: "#/allOf/0/properties/id/type",
            params: {
              type: "string"
            },
            message: "should be string"
          };

          if (vErrors === null) {
            vErrors = [err5];
          } else {
            vErrors.push(err5);
          }

          errors++;
        }
      }

      if (data.description !== undefined) {
        if (typeof data.description !== "string") {
          const err6 = {
            keyword: "type",
            dataPath: dataPath + "/description",
            schemaPath: "#/allOf/0/properties/description/type",
            params: {
              type: "string"
            },
            message: "should be string"
          };

          if (vErrors === null) {
            vErrors = [err6];
          } else {
            vErrors.push(err6);
          }

          errors++;
        }
      }

      if (data.version !== undefined) {
        let data3 = data.version;

        if (!(typeof data3 == "number" && !(data3 % 1) && !isNaN(data3))) {
          const err7 = {
            keyword: "type",
            dataPath: dataPath + "/version",
            schemaPath: "#/allOf/0/properties/version/type",
            params: {
              type: "integer"
            },
            message: "should be integer"
          };

          if (vErrors === null) {
            vErrors = [err7];
          } else {
            vErrors.push(err7);
          }

          errors++;
        }
      }

      if (data.isDefault !== undefined) {
        if (typeof data.isDefault !== "boolean") {
          const err8 = {
            keyword: "type",
            dataPath: dataPath + "/isDefault",
            schemaPath: "#/allOf/0/properties/isDefault/type",
            params: {
              type: "boolean"
            },
            message: "should be boolean"
          };

          if (vErrors === null) {
            vErrors = [err8];
          } else {
            vErrors.push(err8);
          }

          errors++;
        }
      }

      if (data.appliesTo !== undefined) {
        let data5 = data.appliesTo;

        if (Array.isArray(data5)) {
          const len0 = data5.length;

          for (let i0 = 0; i0 < len0; i0++) {
            let data6 = data5[i0];

            if (typeof data6 === "string") {
              if (!pattern0$1.test(data6)) {
                const err9 = {
                  keyword: "pattern",
                  dataPath: dataPath + "/appliesTo/" + i0,
                  schemaPath: "#/allOf/0/properties/appliesTo/items/pattern",
                  params: {
                    pattern: "^[\\w\\d]+:[\\w\\d]+$"
                  },
                  message: "should match pattern \"" + "^[\\w\\d]+:[\\w\\d]+$" + "\""
                };

                if (vErrors === null) {
                  vErrors = [err9];
                } else {
                  vErrors.push(err9);
                }

                errors++;
              }
            } else {
              const err10 = {
                keyword: "type",
                dataPath: dataPath + "/appliesTo/" + i0,
                schemaPath: "#/allOf/0/properties/appliesTo/items/type",
                params: {
                  type: "string"
                },
                message: "should be string"
              };

              if (vErrors === null) {
                vErrors = [err10];
              } else {
                vErrors.push(err10);
              }

              errors++;
            }

            if (errors > 0) {
              const emErrors0 = {
                "pattern": []
              };
              const templates0 = {};

              for (const err11 of vErrors) {
                if (err11.keyword !== "errorMessage" && !err11.emUsed && err11.dataPath === dataPath + "/appliesTo/" + i0 && err11.keyword in emErrors0 && err11.schemaPath.indexOf("#/allOf/0/properties/appliesTo/items") === 0 && /^\/[^\/]*$/.test(err11.schemaPath.slice(36))) {
                  emErrors0[err11.keyword].push(err11);
                  err11.emUsed = true;
                }
              }

              for (const key0 in emErrors0) {
                if (emErrors0[key0].length) {
                  const err12 = {
                    keyword: "errorMessage",
                    dataPath: dataPath + "/appliesTo/" + i0,
                    schemaPath: "#/allOf/0/properties/appliesTo/items/errorMessage",
                    params: {
                      errors: emErrors0[key0]
                    },
                    message: key0 in templates0 ? templates0[key0]() : schema17$1.allOf[0].properties.appliesTo.items.errorMessage[key0]
                  };

                  if (vErrors === null) {
                    vErrors = [err12];
                  } else {
                    vErrors.push(err12);
                  }

                  errors++;
                }
              }

              const emErrs0 = [];

              for (const err13 of vErrors) {
                if (!err13.emUsed) {
                  emErrs0.push(err13);
                }
              }

              vErrors = emErrs0;
              errors = emErrs0.length;
            }
          }
        } else {
          const err14 = {
            keyword: "type",
            dataPath: dataPath + "/appliesTo",
            schemaPath: "#/allOf/0/properties/appliesTo/type",
            params: {
              type: "array"
            },
            message: "should be array"
          };

          if (vErrors === null) {
            vErrors = [err14];
          } else {
            vErrors.push(err14);
          }

          errors++;
        }
      }

      if (data.elementType !== undefined) {
        let data7 = data.elementType;

        if (data7 && typeof data7 == "object" && !Array.isArray(data7)) {
          if (data7.value === undefined) {
            const err15 = {
              keyword: "required",
              dataPath: dataPath + "/elementType",
              schemaPath: "#/allOf/0/properties/elementType/required",
              params: {
                missingProperty: "value"
              },
              message: "should have required property '" + "value" + "'"
            };

            if (vErrors === null) {
              vErrors = [err15];
            } else {
              vErrors.push(err15);
            }

            errors++;
          }

          if (data7.value !== undefined) {
            let data8 = data7.value;

            if (typeof data8 === "string") {
              if (!pattern0$1.test(data8)) {
                const err16 = {
                  keyword: "pattern",
                  dataPath: dataPath + "/elementType/value",
                  schemaPath: "#/allOf/0/properties/elementType/properties/value/pattern",
                  params: {
                    pattern: "^[\\w\\d]+:[\\w\\d]+$"
                  },
                  message: "should match pattern \"" + "^[\\w\\d]+:[\\w\\d]+$" + "\""
                };

                if (vErrors === null) {
                  vErrors = [err16];
                } else {
                  vErrors.push(err16);
                }

                errors++;
              }
            } else {
              const err17 = {
                keyword: "type",
                dataPath: dataPath + "/elementType/value",
                schemaPath: "#/allOf/0/properties/elementType/properties/value/type",
                params: {
                  type: "string"
                },
                message: "should be string"
              };

              if (vErrors === null) {
                vErrors = [err17];
              } else {
                vErrors.push(err17);
              }

              errors++;
            }

            if (errors > 0) {
              const emErrors1 = {
                "pattern": []
              };
              const templates1 = {};

              for (const err18 of vErrors) {
                if (err18.keyword !== "errorMessage" && !err18.emUsed && err18.dataPath === dataPath + "/elementType/value" && err18.keyword in emErrors1 && err18.schemaPath.indexOf("#/allOf/0/properties/elementType/properties/value") === 0 && /^\/[^\/]*$/.test(err18.schemaPath.slice(49))) {
                  emErrors1[err18.keyword].push(err18);
                  err18.emUsed = true;
                }
              }

              for (const key1 in emErrors1) {
                if (emErrors1[key1].length) {
                  const err19 = {
                    keyword: "errorMessage",
                    dataPath: dataPath + "/elementType/value",
                    schemaPath: "#/allOf/0/properties/elementType/properties/value/errorMessage",
                    params: {
                      errors: emErrors1[key1]
                    },
                    message: key1 in templates1 ? templates1[key1]() : schema17$1.allOf[0].properties.elementType.properties.value.errorMessage[key1]
                  };

                  if (vErrors === null) {
                    vErrors = [err19];
                  } else {
                    vErrors.push(err19);
                  }

                  errors++;
                }
              }

              const emErrs1 = [];

              for (const err20 of vErrors) {
                if (!err20.emUsed) {
                  emErrs1.push(err20);
                }
              }

              vErrors = emErrs1;
              errors = emErrs1.length;
            }
          }
        } else {
          const err21 = {
            keyword: "type",
            dataPath: dataPath + "/elementType",
            schemaPath: "#/allOf/0/properties/elementType/type",
            params: {
              type: "object"
            },
            message: "should be object"
          };

          if (vErrors === null) {
            vErrors = [err21];
          } else {
            vErrors.push(err21);
          }

          errors++;
        }

        if (errors > 0) {
          const emErrors2 = {
            "required": {
              "value": []
            }
          };
          const templates2 = {
            required: {}
          };
          let emPropParams0;
          let emParamsErrors0;

          for (const err22 of vErrors) {
            if (err22.keyword !== "errorMessage" && !err22.emUsed && err22.dataPath === dataPath + "/elementType" && err22.keyword in emErrors2 && err22.schemaPath.indexOf("#/allOf/0/properties/elementType") === 0 && /^\/[^\/]*$/.test(err22.schemaPath.slice(32))) {
              emPropParams0 = obj0$1[err22.keyword];
              emParamsErrors0 = emErrors2[err22.keyword][err22.params[emPropParams0]];

              if (emParamsErrors0) {
                emParamsErrors0.push(err22);
                err22.emUsed = true;
              }
            }
          }

          for (const key2 in emErrors2) {
            for (const keyProp0 in emErrors2[key2]) {
              emParamsErrors0 = emErrors2[key2][keyProp0];

              if (emParamsErrors0.length) {
                const tmpl0 = templates2[key2] && templates2[key2][keyProp0];
                const err23 = {
                  keyword: "errorMessage",
                  dataPath: dataPath + "/elementType",
                  schemaPath: "#/allOf/0/properties/elementType/errorMessage",
                  params: {
                    errors: emParamsErrors0
                  },
                  message: tmpl0 ? tmpl0() : schema17$1.allOf[0].properties.elementType.errorMessage[key2][keyProp0]
                };

                if (vErrors === null) {
                  vErrors = [err23];
                } else {
                  vErrors.push(err23);
                }

                errors++;
              }
            }
          }

          const emErrs2 = [];

          for (const err24 of vErrors) {
            if (!err24.emUsed) {
              emErrs2.push(err24);
            }
          }

          vErrors = emErrs2;
          errors = emErrs2.length;
        }
      }

      if (data.metadata !== undefined) {
        let data9 = data.metadata;

        if (!(data9 && typeof data9 == "object" && !Array.isArray(data9))) {
          const err25 = {
            keyword: "type",
            dataPath: dataPath + "/metadata",
            schemaPath: "#/allOf/0/properties/metadata/type",
            params: {
              type: "object"
            },
            message: "should be object"
          };

          if (vErrors === null) {
            vErrors = [err25];
          } else {
            vErrors.push(err25);
          }

          errors++;
        }
      }

      if (data.entriesVisible !== undefined) {
        if (typeof data.entriesVisible !== "boolean") {
          const err26 = {
            keyword: "type",
            dataPath: dataPath + "/entriesVisible",
            schemaPath: "#/allOf/0/properties/entriesVisible/type",
            params: {
              type: "boolean"
            },
            message: "should be boolean"
          };

          if (vErrors === null) {
            vErrors = [err26];
          } else {
            vErrors.push(err26);
          }

          errors++;
        }
      }

      if (data.groups !== undefined) {
        let data11 = data.groups;

        if (Array.isArray(data11)) {
          const len1 = data11.length;

          for (let i1 = 0; i1 < len1; i1++) {
            let data12 = data11[i1];

            if (data12 && typeof data12 == "object" && !Array.isArray(data12)) {
              if (data12.id === undefined) {
                const err27 = {
                  keyword: "required",
                  dataPath: dataPath + "/groups/" + i1,
                  schemaPath: "#/allOf/0/properties/groups/items/required",
                  params: {
                    missingProperty: "id"
                  },
                  message: "should have required property '" + "id" + "'"
                };

                if (vErrors === null) {
                  vErrors = [err27];
                } else {
                  vErrors.push(err27);
                }

                errors++;
              }

              if (data12.label === undefined) {
                const err28 = {
                  keyword: "required",
                  dataPath: dataPath + "/groups/" + i1,
                  schemaPath: "#/allOf/0/properties/groups/items/required",
                  params: {
                    missingProperty: "label"
                  },
                  message: "should have required property '" + "label" + "'"
                };

                if (vErrors === null) {
                  vErrors = [err28];
                } else {
                  vErrors.push(err28);
                }

                errors++;
              }

              if (data12.id !== undefined) {
                if (typeof data12.id !== "string") {
                  const err29 = {
                    keyword: "type",
                    dataPath: dataPath + "/groups/" + i1 + "/id",
                    schemaPath: "#/allOf/0/properties/groups/items/properties/id/type",
                    params: {
                      type: "string"
                    },
                    message: "should be string"
                  };

                  if (vErrors === null) {
                    vErrors = [err29];
                  } else {
                    vErrors.push(err29);
                  }

                  errors++;
                }
              }

              if (data12.label !== undefined) {
                if (typeof data12.label !== "string") {
                  const err30 = {
                    keyword: "type",
                    dataPath: dataPath + "/groups/" + i1 + "/label",
                    schemaPath: "#/allOf/0/properties/groups/items/properties/label/type",
                    params: {
                      type: "string"
                    },
                    message: "should be string"
                  };

                  if (vErrors === null) {
                    vErrors = [err30];
                  } else {
                    vErrors.push(err30);
                  }

                  errors++;
                }
              }
            } else {
              const err31 = {
                keyword: "type",
                dataPath: dataPath + "/groups/" + i1,
                schemaPath: "#/allOf/0/properties/groups/items/type",
                params: {
                  type: "object"
                },
                message: "should be object"
              };

              if (vErrors === null) {
                vErrors = [err31];
              } else {
                vErrors.push(err31);
              }

              errors++;
            }

            if (errors > 0) {
              const emErrors3 = {
                "required": {
                  "id": [],
                  "label": []
                }
              };
              const templates3 = {
                required: {
                  id: function () {
                    return "missing id for group \"" + JSON.stringify(i1) + "\"";
                  },
                  label: function () {
                    return "missing label for group \"" + JSON.stringify(i1) + "\"";
                  }
                }
              };
              let emPropParams1;
              let emParamsErrors1;

              for (const err32 of vErrors) {
                if (err32.keyword !== "errorMessage" && !err32.emUsed && err32.dataPath === dataPath + "/groups/" + i1 && err32.keyword in emErrors3 && err32.schemaPath.indexOf("#/allOf/0/properties/groups/items") === 0 && /^\/[^\/]*$/.test(err32.schemaPath.slice(33))) {
                  emPropParams1 = obj0$1[err32.keyword];
                  emParamsErrors1 = emErrors3[err32.keyword][err32.params[emPropParams1]];

                  if (emParamsErrors1) {
                    emParamsErrors1.push(err32);
                    err32.emUsed = true;
                  }
                }
              }

              for (const key3 in emErrors3) {
                for (const keyProp1 in emErrors3[key3]) {
                  emParamsErrors1 = emErrors3[key3][keyProp1];

                  if (emParamsErrors1.length) {
                    const tmpl1 = templates3[key3] && templates3[key3][keyProp1];
                    const err33 = {
                      keyword: "errorMessage",
                      dataPath: dataPath + "/groups/" + i1,
                      schemaPath: "#/allOf/0/properties/groups/items/errorMessage",
                      params: {
                        errors: emParamsErrors1
                      },
                      message: tmpl1 ? tmpl1() : schema17$1.allOf[0].properties.groups.items.errorMessage[key3][keyProp1]
                    };

                    if (vErrors === null) {
                      vErrors = [err33];
                    } else {
                      vErrors.push(err33);
                    }

                    errors++;
                  }
                }
              }

              const emErrs3 = [];

              for (const err34 of vErrors) {
                if (!err34.emUsed) {
                  emErrs3.push(err34);
                }
              }

              vErrors = emErrs3;
              errors = emErrs3.length;
            }
          }
        } else {
          const err35 = {
            keyword: "type",
            dataPath: dataPath + "/groups",
            schemaPath: "#/allOf/0/properties/groups/type",
            params: {
              type: "array"
            },
            message: "should be array"
          };

          if (vErrors === null) {
            vErrors = [err35];
          } else {
            vErrors.push(err35);
          }

          errors++;
        }
      }

      if (data.documentationRef !== undefined) {
        let data15 = data.documentationRef;

        if (typeof data15 === "string") {
          if (!pattern2$1.test(data15)) {
            const err36 = {
              keyword: "pattern",
              dataPath: dataPath + "/documentationRef",
              schemaPath: "#/allOf/0/properties/documentationRef/pattern",
              params: {
                pattern: "^(https|http)://.*"
              },
              message: "should match pattern \"" + "^(https|http)://.*" + "\""
            };

            if (vErrors === null) {
              vErrors = [err36];
            } else {
              vErrors.push(err36);
            }

            errors++;
          }
        } else {
          const err37 = {
            keyword: "type",
            dataPath: dataPath + "/documentationRef",
            schemaPath: "#/allOf/0/properties/documentationRef/type",
            params: {
              type: "string"
            },
            message: "should be string"
          };

          if (vErrors === null) {
            vErrors = [err37];
          } else {
            vErrors.push(err37);
          }

          errors++;
        }

        if (errors > 0) {
          const emErrors4 = {
            "pattern": []
          };
          const templates4 = {};

          for (const err38 of vErrors) {
            if (err38.keyword !== "errorMessage" && !err38.emUsed && err38.dataPath === dataPath + "/documentationRef" && err38.keyword in emErrors4 && err38.schemaPath.indexOf("#/allOf/0/properties/documentationRef") === 0 && /^\/[^\/]*$/.test(err38.schemaPath.slice(37))) {
              emErrors4[err38.keyword].push(err38);
              err38.emUsed = true;
            }
          }

          for (const key4 in emErrors4) {
            if (emErrors4[key4].length) {
              const err39 = {
                keyword: "errorMessage",
                dataPath: dataPath + "/documentationRef",
                schemaPath: "#/allOf/0/properties/documentationRef/errorMessage",
                params: {
                  errors: emErrors4[key4]
                },
                message: key4 in templates4 ? templates4[key4]() : schema17$1.allOf[0].properties.documentationRef.errorMessage[key4]
              };

              if (vErrors === null) {
                vErrors = [err39];
              } else {
                vErrors.push(err39);
              }

              errors++;
            }
          }

          const emErrs4 = [];

          for (const err40 of vErrors) {
            if (!err40.emUsed) {
              emErrs4.push(err40);
            }
          }

          vErrors = emErrs4;
          errors = emErrs4.length;
        }
      }
    }

    if (errors > 0) {
      const emErrors5 = {
        "required": {
          "name": [],
          "id": [],
          "appliesTo": [],
          "properties": []
        }
      };
      const templates5 = {
        required: {}
      };
      let emPropParams2;
      let emParamsErrors2;

      for (const err41 of vErrors) {
        if (err41.keyword !== "errorMessage" && !err41.emUsed && err41.dataPath === dataPath && err41.keyword in emErrors5 && err41.schemaPath.indexOf("#/allOf/0") === 0 && /^\/[^\/]*$/.test(err41.schemaPath.slice(9))) {
          emPropParams2 = obj0$1[err41.keyword];
          emParamsErrors2 = emErrors5[err41.keyword][err41.params[emPropParams2]];

          if (emParamsErrors2) {
            emParamsErrors2.push(err41);
            err41.emUsed = true;
          }
        }
      }

      for (const key5 in emErrors5) {
        for (const keyProp2 in emErrors5[key5]) {
          emParamsErrors2 = emErrors5[key5][keyProp2];

          if (emParamsErrors2.length) {
            const tmpl2 = templates5[key5] && templates5[key5][keyProp2];
            const err42 = {
              keyword: "errorMessage",
              dataPath,
              schemaPath: "#/allOf/0/errorMessage",
              params: {
                errors: emParamsErrors2
              },
              message: tmpl2 ? tmpl2() : schema17$1.allOf[0].errorMessage[key5][keyProp2]
            };

            if (vErrors === null) {
              vErrors = [err42];
            } else {
              vErrors.push(err42);
            }

            errors++;
          }
        }
      }

      const emErrs5 = [];

      for (const err43 of vErrors) {
        if (!err43.emUsed) {
          emErrs5.push(err43);
        }
      }

      vErrors = emErrs5;
      errors = emErrs5.length;
    }

    if (data && typeof data == "object" && !Array.isArray(data)) {
      if (data.properties !== undefined) {
        let data16 = data.properties;

        if (Array.isArray(data16)) {
          const len2 = data16.length;

          for (let i2 = 0; i2 < len2; i2++) {
            let data17 = data16[i2];
            const _errs41 = errors;
            let valid18 = true;
            const _errs42 = errors;

            if (data17 && typeof data17 == "object" && !Array.isArray(data17)) {
              if (data17.type === undefined && "type") {
                const err44 = {};

                if (vErrors === null) {
                  vErrors = [err44];
                } else {
                  vErrors.push(err44);
                }

                errors++;
              } else {
                if (data17.type !== undefined) {
                  if (!func0$1(data17.type, "Dropdown")) {
                    const err45 = {};

                    if (vErrors === null) {
                      vErrors = [err45];
                    } else {
                      vErrors.push(err45);
                    }

                    errors++;
                  }
                }
              }
            }

            var _valid0 = _errs42 === errors;

            errors = _errs41;

            if (vErrors !== null) {
              if (_errs41) {
                vErrors.length = _errs41;
              } else {
                vErrors = null;
              }
            }

            if (_valid0) {
              const _errs44 = errors;

              if (data17 && typeof data17 == "object" && !Array.isArray(data17)) {
                if (data17.choices === undefined) {
                  const err46 = {
                    keyword: "required",
                    dataPath: dataPath + "/properties/" + i2,
                    schemaPath: "#/definitions/properties/allOf/0/items/allOf/0/then/required",
                    params: {
                      missingProperty: "choices"
                    },
                    message: "should have required property '" + "choices" + "'"
                  };

                  if (vErrors === null) {
                    vErrors = [err46];
                  } else {
                    vErrors.push(err46);
                  }

                  errors++;
                }
              }

              if (errors > 0) {
                const emErrs6 = [];

                for (const err47 of vErrors) {
                  if (err47.keyword !== "errorMessage" && !err47.emUsed && (err47.dataPath === dataPath + "/properties/" + i2 || err47.dataPath.indexOf(dataPath + "/properties/" + i2) === 0 && err47.dataPath[dataPath + "/properties/" + i2.length] === "/") && err47.schemaPath.indexOf("#/definitions/properties/allOf/0/items/allOf/0/then") === 0 && err47.schemaPath["#/definitions/properties/allOf/0/items/allOf/0/then".length] === "/") {
                    emErrs6.push(err47);
                    err47.emUsed = true;
                  }
                }

                if (emErrs6.length) {
                  const err48 = {
                    keyword: "errorMessage",
                    dataPath: dataPath + "/properties/" + i2,
                    schemaPath: "#/definitions/properties/allOf/0/items/allOf/0/then/errorMessage",
                    params: {
                      errors: emErrs6
                    },
                    message: "must provide choices=[] with \"Dropdown\" type"
                  };

                  if (vErrors === null) {
                    vErrors = [err48];
                  } else {
                    vErrors.push(err48);
                  }

                  errors++;
                }

                const emErrs7 = [];

                for (const err49 of vErrors) {
                  if (!err49.emUsed) {
                    emErrs7.push(err49);
                  }
                }

                vErrors = emErrs7;
                errors = emErrs7.length;
              }

              var _valid0 = _errs44 === errors;

              valid18 = _valid0;
            }

            if (!valid18) {
              const err50 = {
                keyword: "if",
                dataPath: dataPath + "/properties/" + i2,
                schemaPath: "#/definitions/properties/allOf/0/items/allOf/0/if",
                params: {
                  failingKeyword: "then"
                },
                message: "should match \"then\" schema"
              };

              if (vErrors === null) {
                vErrors = [err50];
              } else {
                vErrors.push(err50);
              }

              errors++;
            }

            if (data17 && typeof data17 == "object" && !Array.isArray(data17)) {
              if (data17.id !== undefined) {
                if (typeof data17.id !== "string") {
                  const err51 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i2 + "/id",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/id/type",
                    params: {
                      type: "string"
                    },
                    message: "should be string"
                  };

                  if (vErrors === null) {
                    vErrors = [err51];
                  } else {
                    vErrors.push(err51);
                  }

                  errors++;
                }
              }

              if (data17.value !== undefined) {
                let data20 = data17.value;

                if (typeof data20 !== "string" && typeof data20 !== "boolean") {
                  const err52 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i2 + "/value",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/value/type",
                    params: {
                      type: schema18$1.allOf[0].items.properties.value.type
                    },
                    message: "should be string,boolean"
                  };

                  if (vErrors === null) {
                    vErrors = [err52];
                  } else {
                    vErrors.push(err52);
                  }

                  errors++;
                }
              }

              if (data17.description !== undefined) {
                if (typeof data17.description !== "string") {
                  const err53 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i2 + "/description",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/description/type",
                    params: {
                      type: "string"
                    },
                    message: "should be string"
                  };

                  if (vErrors === null) {
                    vErrors = [err53];
                  } else {
                    vErrors.push(err53);
                  }

                  errors++;
                }
              }

              if (data17.label !== undefined) {
                if (typeof data17.label !== "string") {
                  const err54 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i2 + "/label",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/label/type",
                    params: {
                      type: "string"
                    },
                    message: "should be string"
                  };

                  if (vErrors === null) {
                    vErrors = [err54];
                  } else {
                    vErrors.push(err54);
                  }

                  errors++;
                }
              }

              if (data17.type !== undefined) {
                if (typeof data17.type !== "string") {
                  const err55 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i2 + "/type",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/type/type",
                    params: {
                      type: "string"
                    },
                    message: "should be string"
                  };

                  if (vErrors === null) {
                    vErrors = [err55];
                  } else {
                    vErrors.push(err55);
                  }

                  errors++;
                }
              }

              if (data17.editable !== undefined) {
                if (typeof data17.editable !== "boolean") {
                  const err56 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i2 + "/editable",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/editable/type",
                    params: {
                      type: "boolean"
                    },
                    message: "should be boolean"
                  };

                  if (vErrors === null) {
                    vErrors = [err56];
                  } else {
                    vErrors.push(err56);
                  }

                  errors++;
                }
              }

              if (data17.choices !== undefined) {
                let data25 = data17.choices;

                if (Array.isArray(data25)) {
                  const len3 = data25.length;

                  for (let i3 = 0; i3 < len3; i3++) {
                    let data26 = data25[i3];

                    if (data26 && typeof data26 == "object" && !Array.isArray(data26)) {
                      if (data26.value === undefined) {
                        const err57 = {
                          keyword: "required",
                          dataPath: dataPath + "/properties/" + i2 + "/choices/" + i3,
                          schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/items/required",
                          params: {
                            missingProperty: "value"
                          },
                          message: "should have required property '" + "value" + "'"
                        };

                        if (vErrors === null) {
                          vErrors = [err57];
                        } else {
                          vErrors.push(err57);
                        }

                        errors++;
                      }

                      if (data26.name === undefined) {
                        const err58 = {
                          keyword: "required",
                          dataPath: dataPath + "/properties/" + i2 + "/choices/" + i3,
                          schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/items/required",
                          params: {
                            missingProperty: "name"
                          },
                          message: "should have required property '" + "name" + "'"
                        };

                        if (vErrors === null) {
                          vErrors = [err58];
                        } else {
                          vErrors.push(err58);
                        }

                        errors++;
                      }

                      if (data26.name !== undefined) {
                        if (typeof data26.name !== "string") {
                          const err59 = {
                            keyword: "type",
                            dataPath: dataPath + "/properties/" + i2 + "/choices/" + i3 + "/name",
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/items/properties/name/type",
                            params: {
                              type: "string"
                            },
                            message: "should be string"
                          };

                          if (vErrors === null) {
                            vErrors = [err59];
                          } else {
                            vErrors.push(err59);
                          }

                          errors++;
                        }
                      }

                      if (data26.value !== undefined) {
                        if (typeof data26.value !== "string") {
                          const err60 = {
                            keyword: "type",
                            dataPath: dataPath + "/properties/" + i2 + "/choices/" + i3 + "/value",
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/items/properties/value/type",
                            params: {
                              type: "string"
                            },
                            message: "should be string"
                          };

                          if (vErrors === null) {
                            vErrors = [err60];
                          } else {
                            vErrors.push(err60);
                          }

                          errors++;
                        }
                      }
                    } else {
                      const err61 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i2 + "/choices/" + i3,
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/items/type",
                        params: {
                          type: "object"
                        },
                        message: "should be object"
                      };

                      if (vErrors === null) {
                        vErrors = [err61];
                      } else {
                        vErrors.push(err61);
                      }

                      errors++;
                    }

                    if (errors > 0) {
                      const emErrors6 = {
                        "required": []
                      };
                      const templates6 = {};

                      for (const err62 of vErrors) {
                        if (err62.keyword !== "errorMessage" && !err62.emUsed && err62.dataPath === dataPath + "/properties/" + i2 + "/choices/" + i3 && err62.keyword in emErrors6 && err62.schemaPath.indexOf("#/definitions/properties/allOf/0/items/properties/choices/items") === 0 && /^\/[^\/]*$/.test(err62.schemaPath.slice(63))) {
                          emErrors6[err62.keyword].push(err62);
                          err62.emUsed = true;
                        }
                      }

                      for (const key6 in emErrors6) {
                        if (emErrors6[key6].length) {
                          const err63 = {
                            keyword: "errorMessage",
                            dataPath: dataPath + "/properties/" + i2 + "/choices/" + i3,
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/items/errorMessage",
                            params: {
                              errors: emErrors6[key6]
                            },
                            message: key6 in templates6 ? templates6[key6]() : schema18$1.allOf[0].items.properties.choices.items.errorMessage[key6]
                          };

                          if (vErrors === null) {
                            vErrors = [err63];
                          } else {
                            vErrors.push(err63);
                          }

                          errors++;
                        }
                      }

                      const emErrs8 = [];

                      for (const err64 of vErrors) {
                        if (!err64.emUsed) {
                          emErrs8.push(err64);
                        }
                      }

                      vErrors = emErrs8;
                      errors = emErrs8.length;
                    }
                  }
                } else {
                  const err65 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i2 + "/choices",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/type",
                    params: {
                      type: "array"
                    },
                    message: "should be array"
                  };

                  if (vErrors === null) {
                    vErrors = [err65];
                  } else {
                    vErrors.push(err65);
                  }

                  errors++;
                }
              }

              if (data17.constraints !== undefined) {
                let data29 = data17.constraints;

                if (data29 && typeof data29 == "object" && !Array.isArray(data29)) {
                  if (data29.notEmpty !== undefined) {
                    if (typeof data29.notEmpty !== "boolean") {
                      const err66 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i2 + "/constraints/notEmpty",
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/notEmpty/type",
                        params: {
                          type: "boolean"
                        },
                        message: "should be boolean"
                      };

                      if (vErrors === null) {
                        vErrors = [err66];
                      } else {
                        vErrors.push(err66);
                      }

                      errors++;
                    }
                  }

                  if (data29.minLength !== undefined) {
                    if (!(typeof data29.minLength == "number")) {
                      const err67 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i2 + "/constraints/minLength",
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/minLength/type",
                        params: {
                          type: "number"
                        },
                        message: "should be number"
                      };

                      if (vErrors === null) {
                        vErrors = [err67];
                      } else {
                        vErrors.push(err67);
                      }

                      errors++;
                    }
                  }

                  if (data29.maxLength !== undefined) {
                    if (!(typeof data29.maxLength == "number")) {
                      const err68 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i2 + "/constraints/maxLength",
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/maxLength/type",
                        params: {
                          type: "number"
                        },
                        message: "should be number"
                      };

                      if (vErrors === null) {
                        vErrors = [err68];
                      } else {
                        vErrors.push(err68);
                      }

                      errors++;
                    }
                  }

                  if (data29.pattern !== undefined) {
                    let data33 = data29.pattern;
                    const _errs74 = errors;
                    let valid26 = false;
                    let passing0 = null;
                    const _errs75 = errors;

                    if (data33 && typeof data33 == "object" && !Array.isArray(data33)) {
                      if (data33.value !== undefined) {
                        if (typeof data33.value !== "string") {
                          const err69 = {
                            keyword: "type",
                            dataPath: dataPath + "/properties/" + i2 + "/constraints/pattern/value",
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/pattern/oneOf/0/properties/value/type",
                            params: {
                              type: "string"
                            },
                            message: "should be string"
                          };

                          if (vErrors === null) {
                            vErrors = [err69];
                          } else {
                            vErrors.push(err69);
                          }

                          errors++;
                        }
                      }

                      if (data33.message !== undefined) {
                        if (typeof data33.message !== "string") {
                          const err70 = {
                            keyword: "type",
                            dataPath: dataPath + "/properties/" + i2 + "/constraints/pattern/message",
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/pattern/oneOf/0/properties/message/type",
                            params: {
                              type: "string"
                            },
                            message: "should be string"
                          };

                          if (vErrors === null) {
                            vErrors = [err70];
                          } else {
                            vErrors.push(err70);
                          }

                          errors++;
                        }
                      }
                    } else {
                      const err71 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i2 + "/constraints/pattern",
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/pattern/oneOf/0/type",
                        params: {
                          type: "object"
                        },
                        message: "should be object"
                      };

                      if (vErrors === null) {
                        vErrors = [err71];
                      } else {
                        vErrors.push(err71);
                      }

                      errors++;
                    }

                    var _valid1 = _errs75 === errors;

                    if (_valid1) {
                      valid26 = true;
                      passing0 = 0;
                    }

                    const _errs81 = errors;

                    if (typeof data33 !== "string") {
                      const err72 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i2 + "/constraints/pattern",
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/pattern/oneOf/1/type",
                        params: {
                          type: "string"
                        },
                        message: "should be string"
                      };

                      if (vErrors === null) {
                        vErrors = [err72];
                      } else {
                        vErrors.push(err72);
                      }

                      errors++;
                    }

                    var _valid1 = _errs81 === errors;

                    if (_valid1 && valid26) {
                      valid26 = false;
                      passing0 = [passing0, 1];
                    } else {
                      if (_valid1) {
                        valid26 = true;
                        passing0 = 1;
                      }
                    }

                    if (!valid26) {
                      const err73 = {
                        keyword: "oneOf",
                        dataPath: dataPath + "/properties/" + i2 + "/constraints/pattern",
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/pattern/oneOf",
                        params: {
                          passingSchemas: passing0
                        },
                        message: "should match exactly one schema in oneOf"
                      };

                      if (vErrors === null) {
                        vErrors = [err73];
                      } else {
                        vErrors.push(err73);
                      }

                      errors++;
                    } else {
                      errors = _errs74;

                      if (vErrors !== null) {
                        if (_errs74) {
                          vErrors.length = _errs74;
                        } else {
                          vErrors = null;
                        }
                      }
                    }
                  }
                } else {
                  const err74 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i2 + "/constraints",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/type",
                    params: {
                      type: "object"
                    },
                    message: "should be object"
                  };

                  if (vErrors === null) {
                    vErrors = [err74];
                  } else {
                    vErrors.push(err74);
                  }

                  errors++;
                }
              }

              if (data17.group !== undefined) {
                if (typeof data17.group !== "string") {
                  const err75 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i2 + "/group",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/group/type",
                    params: {
                      type: "string"
                    },
                    message: "should be string"
                  };

                  if (vErrors === null) {
                    vErrors = [err75];
                  } else {
                    vErrors.push(err75);
                  }

                  errors++;
                }
              }

              if (data17.condition !== undefined) {
                let data37 = data17.condition;
                const _errs87 = errors;
                let valid28 = false;
                let passing1 = null;
                const _errs88 = errors;

                if (data37 && typeof data37 == "object" && !Array.isArray(data37)) {
                  if (data37.equals === undefined) {
                    const err76 = {
                      keyword: "required",
                      dataPath: dataPath + "/properties/" + i2 + "/condition",
                      schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/oneOf/0/required",
                      params: {
                        missingProperty: "equals"
                      },
                      message: "should have required property '" + "equals" + "'"
                    };

                    if (vErrors === null) {
                      vErrors = [err76];
                    } else {
                      vErrors.push(err76);
                    }

                    errors++;
                  }

                  if (data37.equals !== undefined) {
                    let data38 = data37.equals;

                    if (typeof data38 !== "string" && !(typeof data38 == "number") && typeof data38 !== "boolean") {
                      const err77 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i2 + "/condition/equals",
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/oneOf/0/properties/equals/type",
                        params: {
                          type: schema18$1.allOf[0].items.properties.condition.oneOf[0].properties.equals.type
                        },
                        message: "should be string,number,boolean"
                      };

                      if (vErrors === null) {
                        vErrors = [err77];
                      } else {
                        vErrors.push(err77);
                      }

                      errors++;
                    }
                  }
                }

                var _valid2 = _errs88 === errors;

                if (_valid2) {
                  valid28 = true;
                  passing1 = 0;
                }

                const _errs91 = errors;

                if (data37 && typeof data37 == "object" && !Array.isArray(data37)) {
                  if (data37.oneOf === undefined) {
                    const err78 = {
                      keyword: "required",
                      dataPath: dataPath + "/properties/" + i2 + "/condition",
                      schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/oneOf/1/required",
                      params: {
                        missingProperty: "oneOf"
                      },
                      message: "should have required property '" + "oneOf" + "'"
                    };

                    if (vErrors === null) {
                      vErrors = [err78];
                    } else {
                      vErrors.push(err78);
                    }

                    errors++;
                  }

                  if (data37.oneOf !== undefined) {
                    let data39 = data37.oneOf;

                    if (Array.isArray(data39)) {
                      const len4 = data39.length;

                      for (let i4 = 0; i4 < len4; i4++) {
                        let data40 = data39[i4];

                        if (typeof data40 !== "string" && !(typeof data40 == "number")) {
                          const err79 = {
                            keyword: "type",
                            dataPath: dataPath + "/properties/" + i2 + "/condition/oneOf/" + i4,
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/oneOf/1/properties/oneOf/items/type",
                            params: {
                              type: schema18$1.allOf[0].items.properties.condition.oneOf[1].properties.oneOf.items.type
                            },
                            message: "should be string,number"
                          };

                          if (vErrors === null) {
                            vErrors = [err79];
                          } else {
                            vErrors.push(err79);
                          }

                          errors++;
                        }
                      }
                    } else {
                      const err80 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i2 + "/condition/oneOf",
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/oneOf/1/properties/oneOf/type",
                        params: {
                          type: "array"
                        },
                        message: "should be array"
                      };

                      if (vErrors === null) {
                        vErrors = [err80];
                      } else {
                        vErrors.push(err80);
                      }

                      errors++;
                    }
                  }
                }

                var _valid2 = _errs91 === errors;

                if (_valid2 && valid28) {
                  valid28 = false;
                  passing1 = [passing1, 1];
                } else {
                  if (_valid2) {
                    valid28 = true;
                    passing1 = 1;
                  }
                }

                if (!valid28) {
                  const err81 = {
                    keyword: "oneOf",
                    dataPath: dataPath + "/properties/" + i2 + "/condition",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/oneOf",
                    params: {
                      passingSchemas: passing1
                    },
                    message: "should match exactly one schema in oneOf"
                  };

                  if (vErrors === null) {
                    vErrors = [err81];
                  } else {
                    vErrors.push(err81);
                  }

                  errors++;
                } else {
                  errors = _errs87;

                  if (vErrors !== null) {
                    if (_errs87) {
                      vErrors.length = _errs87;
                    } else {
                      vErrors = null;
                    }
                  }
                }

                if (data37 && typeof data37 == "object" && !Array.isArray(data37)) {
                  if (data37.property === undefined) {
                    const err82 = {
                      keyword: "required",
                      dataPath: dataPath + "/properties/" + i2 + "/condition",
                      schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/required",
                      params: {
                        missingProperty: "property"
                      },
                      message: "should have required property '" + "property" + "'"
                    };

                    if (vErrors === null) {
                      vErrors = [err82];
                    } else {
                      vErrors.push(err82);
                    }

                    errors++;
                  }

                  if (data37.type !== undefined) {
                    if (!func0$1(data37.type, "simple")) {
                      const err83 = {
                        keyword: "const",
                        dataPath: dataPath + "/properties/" + i2 + "/condition/type",
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/properties/type/const",
                        params: {
                          allowedValue: "simple"
                        },
                        message: "should be equal to constant"
                      };

                      if (vErrors === null) {
                        vErrors = [err83];
                      } else {
                        vErrors.push(err83);
                      }

                      errors++;
                    }
                  }

                  if (data37.property !== undefined) {
                    if (typeof data37.property !== "string") {
                      const err84 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i2 + "/condition/property",
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/properties/property/type",
                        params: {
                          type: "string"
                        },
                        message: "should be string"
                      };

                      if (vErrors === null) {
                        vErrors = [err84];
                      } else {
                        vErrors.push(err84);
                      }

                      errors++;
                    }
                  }
                } else {
                  const err85 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i2 + "/condition",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/type",
                    params: {
                      type: "object"
                    },
                    message: "should be object"
                  };

                  if (vErrors === null) {
                    vErrors = [err85];
                  } else {
                    vErrors.push(err85);
                  }

                  errors++;
                }

                if (errors > 0) {
                  const emErrors7 = {
                    "required": {
                      "property": []
                    }
                  };
                  const templates7 = {
                    required: {}
                  };
                  let emPropParams3;
                  let emParamsErrors3;

                  for (const err86 of vErrors) {
                    if (err86.keyword !== "errorMessage" && !err86.emUsed && err86.dataPath === dataPath + "/properties/" + i2 + "/condition" && err86.keyword in emErrors7 && err86.schemaPath.indexOf("#/definitions/properties/allOf/0/items/properties/condition") === 0 && /^\/[^\/]*$/.test(err86.schemaPath.slice(59))) {
                      emPropParams3 = obj0$1[err86.keyword];
                      emParamsErrors3 = emErrors7[err86.keyword][err86.params[emPropParams3]];

                      if (emParamsErrors3) {
                        emParamsErrors3.push(err86);
                        err86.emUsed = true;
                      }
                    }
                  }

                  for (const key7 in emErrors7) {
                    for (const keyProp3 in emErrors7[key7]) {
                      emParamsErrors3 = emErrors7[key7][keyProp3];

                      if (emParamsErrors3.length) {
                        const tmpl3 = templates7[key7] && templates7[key7][keyProp3];
                        const err87 = {
                          keyword: "errorMessage",
                          dataPath: dataPath + "/properties/" + i2 + "/condition",
                          schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/errorMessage",
                          params: {
                            errors: emParamsErrors3
                          },
                          message: tmpl3 ? tmpl3() : schema18$1.allOf[0].items.properties.condition.errorMessage[key7][keyProp3]
                        };

                        if (vErrors === null) {
                          vErrors = [err87];
                        } else {
                          vErrors.push(err87);
                        }

                        errors++;
                      }
                    }
                  }

                  const emErrs9 = [];

                  for (const err88 of vErrors) {
                    if (!err88.emUsed) {
                      emErrs9.push(err88);
                    }
                  }

                  vErrors = emErrs9;
                  errors = emErrs9.length;
                }
              }
            } else {
              const err89 = {
                keyword: "type",
                dataPath: dataPath + "/properties/" + i2,
                schemaPath: "#/definitions/properties/allOf/0/items/type",
                params: {
                  type: "object"
                },
                message: "should be object"
              };

              if (vErrors === null) {
                vErrors = [err89];
              } else {
                vErrors.push(err89);
              }

              errors++;
            }
          }
        } else {
          const err90 = {
            keyword: "type",
            dataPath: dataPath + "/properties",
            schemaPath: "#/definitions/properties/allOf/0/type",
            params: {
              type: "array"
            },
            message: "should be array"
          };

          if (vErrors === null) {
            vErrors = [err90];
          } else {
            vErrors.push(err90);
          }

          errors++;
        }

        if (Array.isArray(data16)) {
          const len5 = data16.length;

          for (let i5 = 0; i5 < len5; i5++) {
            let data43 = data16[i5];
            const _errs104 = errors;
            let valid38 = true;
            const _errs105 = errors;

            if (data43 && typeof data43 == "object" && !Array.isArray(data43)) {
              if (data43.binding === undefined && "binding") {
                const err91 = {};

                if (vErrors === null) {
                  vErrors = [err91];
                } else {
                  vErrors.push(err91);
                }

                errors++;
              } else {
                if (data43.binding !== undefined) {
                  let data44 = data43.binding;

                  if (data44 && typeof data44 == "object" && !Array.isArray(data44)) {
                    if (data44.type === undefined && "type") {
                      const err92 = {};

                      if (vErrors === null) {
                        vErrors = [err92];
                      } else {
                        vErrors.push(err92);
                      }

                      errors++;
                    } else {
                      if (data44.type !== undefined) {
                        if (!func0$1(data44.type, "property")) {
                          const err93 = {};

                          if (vErrors === null) {
                            vErrors = [err93];
                          } else {
                            vErrors.push(err93);
                          }

                          errors++;
                        }
                      }
                    }
                  }
                }
              }
            }

            var _valid3 = _errs105 === errors;

            errors = _errs104;

            if (vErrors !== null) {
              if (_errs104) {
                vErrors.length = _errs104;
              } else {
                vErrors = null;
              }
            }

            if (_valid3) {
              const _errs108 = errors;

              if (data43 && typeof data43 == "object" && !Array.isArray(data43)) {
                if (data43.type !== undefined) {
                  let data46 = data43.type;

                  if (!(data46 === "String" || data46 === "Text" || data46 === "Hidden" || data46 === "Dropdown" || data46 === "Boolean")) {
                    const err94 = {
                      keyword: "enum",
                      dataPath: dataPath + "/properties/" + i5 + "/type",
                      schemaPath: "#/definitions/properties/allOf/1/items/allOf/0/then/properties/type/enum",
                      params: {
                        allowedValues: schema18$1.allOf[1].items.allOf[0].then.properties.type.enum
                      },
                      message: "should be equal to one of the allowed values"
                    };

                    if (vErrors === null) {
                      vErrors = [err94];
                    } else {
                      vErrors.push(err94);
                    }

                    errors++;
                  }

                  if (errors > 0) {
                    const emErrs10 = [];

                    for (const err95 of vErrors) {
                      if (err95.keyword !== "errorMessage" && !err95.emUsed && (err95.dataPath === dataPath + "/properties/" + i5 + "/type" || err95.dataPath.indexOf(dataPath + "/properties/" + i5 + "/type") === 0 && err95.dataPath[dataPath + "/properties/" + i5 + "/type".length] === "/") && err95.schemaPath.indexOf("#/definitions/properties/allOf/1/items/allOf/0/then/properties/type") === 0 && err95.schemaPath["#/definitions/properties/allOf/1/items/allOf/0/then/properties/type".length] === "/") {
                        emErrs10.push(err95);
                        err95.emUsed = true;
                      }
                    }

                    if (emErrs10.length) {
                      const err96 = {
                        keyword: "errorMessage",
                        dataPath: dataPath + "/properties/" + i5 + "/type",
                        schemaPath: "#/definitions/properties/allOf/1/items/allOf/0/then/properties/type/errorMessage",
                        params: {
                          errors: emErrs10
                        },
                        message: "invalid property type " + JSON.stringify(data46) + " for binding type \"property\"; must be any of { String, Text, Hidden, Dropdown, Boolean }"
                      };

                      if (vErrors === null) {
                        vErrors = [err96];
                      } else {
                        vErrors.push(err96);
                      }

                      errors++;
                    }

                    const emErrs11 = [];

                    for (const err97 of vErrors) {
                      if (!err97.emUsed) {
                        emErrs11.push(err97);
                      }
                    }

                    vErrors = emErrs11;
                    errors = emErrs11.length;
                  }
                }
              }

              var _valid3 = _errs108 === errors;

              valid38 = _valid3;
            }

            if (!valid38) {
              const err98 = {
                keyword: "if",
                dataPath: dataPath + "/properties/" + i5,
                schemaPath: "#/definitions/properties/allOf/1/items/allOf/0/if",
                params: {
                  failingKeyword: "then"
                },
                message: "should match \"then\" schema"
              };

              if (vErrors === null) {
                vErrors = [err98];
              } else {
                vErrors.push(err98);
              }

              errors++;
            }

            const _errs111 = errors;
            let valid42 = true;
            const _errs112 = errors;

            if (data43 && typeof data43 == "object" && !Array.isArray(data43)) {
              if (data43.binding === undefined && "binding") {
                const err99 = {};

                if (vErrors === null) {
                  vErrors = [err99];
                } else {
                  vErrors.push(err99);
                }

                errors++;
              } else {
                if (data43.binding !== undefined) {
                  let data47 = data43.binding;

                  if (data47 && typeof data47 == "object" && !Array.isArray(data47)) {
                    if (data47.type === undefined && "type") {
                      const err100 = {};

                      if (vErrors === null) {
                        vErrors = [err100];
                      } else {
                        vErrors.push(err100);
                      }

                      errors++;
                    } else {
                      if (data47.type !== undefined) {
                        if (!func0$1(data47.type, "camunda:executionListener")) {
                          const err101 = {};

                          if (vErrors === null) {
                            vErrors = [err101];
                          } else {
                            vErrors.push(err101);
                          }

                          errors++;
                        }
                      }
                    }
                  }
                }
              }
            }

            var _valid4 = _errs112 === errors;

            errors = _errs111;

            if (vErrors !== null) {
              if (_errs111) {
                vErrors.length = _errs111;
              } else {
                vErrors = null;
              }
            }

            if (_valid4) {
              const _errs115 = errors;

              if (data43 && typeof data43 == "object" && !Array.isArray(data43)) {
                if (data43.type !== undefined) {
                  if (!(data43.type === "Hidden")) {
                    const err102 = {
                      keyword: "enum",
                      dataPath: dataPath + "/properties/" + i5 + "/type",
                      schemaPath: "#/definitions/properties/allOf/1/items/allOf/1/then/properties/type/enum",
                      params: {
                        allowedValues: schema18$1.allOf[1].items.allOf[1].then.properties.type.enum
                      },
                      message: "should be equal to one of the allowed values"
                    };

                    if (vErrors === null) {
                      vErrors = [err102];
                    } else {
                      vErrors.push(err102);
                    }

                    errors++;
                  }

                  if (errors > 0) {
                    const emErrs12 = [];

                    for (const err103 of vErrors) {
                      if (err103.keyword !== "errorMessage" && !err103.emUsed && (err103.dataPath === dataPath + "/properties/" + i5 + "/type" || err103.dataPath.indexOf(dataPath + "/properties/" + i5 + "/type") === 0 && err103.dataPath[dataPath + "/properties/" + i5 + "/type".length] === "/") && err103.schemaPath.indexOf("#/definitions/properties/allOf/1/items/allOf/1/then/properties/type") === 0 && err103.schemaPath["#/definitions/properties/allOf/1/items/allOf/1/then/properties/type".length] === "/") {
                        emErrs12.push(err103);
                        err103.emUsed = true;
                      }
                    }

                    if (emErrs12.length) {
                      const err104 = {
                        keyword: "errorMessage",
                        dataPath: dataPath + "/properties/" + i5 + "/type",
                        schemaPath: "#/definitions/properties/allOf/1/items/allOf/1/then/properties/type/errorMessage",
                        params: {
                          errors: emErrs12
                        },
                        message: "invalid property type " + JSON.stringify(data43 && data43.type) + " for binding type \"camunda:executionListener\"; must be \"Hidden\""
                      };

                      if (vErrors === null) {
                        vErrors = [err104];
                      } else {
                        vErrors.push(err104);
                      }

                      errors++;
                    }

                    const emErrs13 = [];

                    for (const err105 of vErrors) {
                      if (!err105.emUsed) {
                        emErrs13.push(err105);
                      }
                    }

                    vErrors = emErrs13;
                    errors = emErrs13.length;
                  }
                }
              }

              var _valid4 = _errs115 === errors;

              valid42 = _valid4;
            }

            if (!valid42) {
              const err106 = {
                keyword: "if",
                dataPath: dataPath + "/properties/" + i5,
                schemaPath: "#/definitions/properties/allOf/1/items/allOf/1/if",
                params: {
                  failingKeyword: "then"
                },
                message: "should match \"then\" schema"
              };

              if (vErrors === null) {
                vErrors = [err106];
              } else {
                vErrors.push(err106);
              }

              errors++;
            }

            const _errs118 = errors;
            let valid46 = true;
            const _errs119 = errors;

            if (data43 && typeof data43 == "object" && !Array.isArray(data43)) {
              if (data43.binding === undefined && "binding") {
                const err107 = {};

                if (vErrors === null) {
                  vErrors = [err107];
                } else {
                  vErrors.push(err107);
                }

                errors++;
              } else {
                if (data43.binding !== undefined) {
                  let data50 = data43.binding;

                  if (data50 && typeof data50 == "object" && !Array.isArray(data50)) {
                    if (data50.type === undefined && "type") {
                      const err108 = {};

                      if (vErrors === null) {
                        vErrors = [err108];
                      } else {
                        vErrors.push(err108);
                      }

                      errors++;
                    } else {
                      if (data50.type !== undefined) {
                        let data51 = data50.type;

                        if (!(data51 === "camunda:property" || data51 === "camunda:outputParameter" || data51 === "camunda:in" || data51 === "camunda:in:businessKey" || data51 === "camunda:out" || data51 === "camunda:errorEventDefinition")) {
                          const err109 = {};

                          if (vErrors === null) {
                            vErrors = [err109];
                          } else {
                            vErrors.push(err109);
                          }

                          errors++;
                        }
                      }
                    }
                  }
                }
              }
            }

            var _valid5 = _errs119 === errors;

            errors = _errs118;

            if (vErrors !== null) {
              if (_errs118) {
                vErrors.length = _errs118;
              } else {
                vErrors = null;
              }
            }

            if (_valid5) {
              const _errs122 = errors;

              if (data43 && typeof data43 == "object" && !Array.isArray(data43)) {
                if (data43.type !== undefined) {
                  let data52 = data43.type;

                  if (!(data52 === "String" || data52 === "Hidden" || data52 === "Dropdown")) {
                    const err110 = {
                      keyword: "enum",
                      dataPath: dataPath + "/properties/" + i5 + "/type",
                      schemaPath: "#/definitions/properties/allOf/1/items/allOf/2/then/properties/type/enum",
                      params: {
                        allowedValues: schema18$1.allOf[1].items.allOf[2].then.properties.type.enum
                      },
                      message: "should be equal to one of the allowed values"
                    };

                    if (vErrors === null) {
                      vErrors = [err110];
                    } else {
                      vErrors.push(err110);
                    }

                    errors++;
                  }

                  if (errors > 0) {
                    const emErrs14 = [];

                    for (const err111 of vErrors) {
                      if (err111.keyword !== "errorMessage" && !err111.emUsed && (err111.dataPath === dataPath + "/properties/" + i5 + "/type" || err111.dataPath.indexOf(dataPath + "/properties/" + i5 + "/type") === 0 && err111.dataPath[dataPath + "/properties/" + i5 + "/type".length] === "/") && err111.schemaPath.indexOf("#/definitions/properties/allOf/1/items/allOf/2/then/properties/type") === 0 && err111.schemaPath["#/definitions/properties/allOf/1/items/allOf/2/then/properties/type".length] === "/") {
                        emErrs14.push(err111);
                        err111.emUsed = true;
                      }
                    }

                    if (emErrs14.length) {
                      const err112 = {
                        keyword: "errorMessage",
                        dataPath: dataPath + "/properties/" + i5 + "/type",
                        schemaPath: "#/definitions/properties/allOf/1/items/allOf/2/then/properties/type/errorMessage",
                        params: {
                          errors: emErrs14
                        },
                        message: "invalid property type " + JSON.stringify(data52) + " for binding type " + JSON.stringify(data43 && data43.binding && data43.binding.type) + "; must be any of { String, Hidden, Dropdown }"
                      };

                      if (vErrors === null) {
                        vErrors = [err112];
                      } else {
                        vErrors.push(err112);
                      }

                      errors++;
                    }

                    const emErrs15 = [];

                    for (const err113 of vErrors) {
                      if (!err113.emUsed) {
                        emErrs15.push(err113);
                      }
                    }

                    vErrors = emErrs15;
                    errors = emErrs15.length;
                  }
                }
              }

              var _valid5 = _errs122 === errors;

              valid46 = _valid5;
            }

            if (!valid46) {
              const err114 = {
                keyword: "if",
                dataPath: dataPath + "/properties/" + i5,
                schemaPath: "#/definitions/properties/allOf/1/items/allOf/2/if",
                params: {
                  failingKeyword: "then"
                },
                message: "should match \"then\" schema"
              };

              if (vErrors === null) {
                vErrors = [err114];
              } else {
                vErrors.push(err114);
              }

              errors++;
            }

            const _errs125 = errors;
            let valid50 = true;
            const _errs126 = errors;

            if (data43 && typeof data43 == "object" && !Array.isArray(data43)) {
              if (data43.binding === undefined && "binding") {
                const err115 = {};

                if (vErrors === null) {
                  vErrors = [err115];
                } else {
                  vErrors.push(err115);
                }

                errors++;
              } else {
                if (data43.binding !== undefined) {
                  let data53 = data43.binding;

                  if (data53 && typeof data53 == "object" && !Array.isArray(data53)) {
                    if (data53.type === undefined && "type") {
                      const err116 = {};

                      if (vErrors === null) {
                        vErrors = [err116];
                      } else {
                        vErrors.push(err116);
                      }

                      errors++;
                    } else {
                      if (data53.type !== undefined) {
                        let data54 = data53.type;

                        if (!(data54 === "camunda:inputParameter" || data54 === "camunda:field")) {
                          const err117 = {};

                          if (vErrors === null) {
                            vErrors = [err117];
                          } else {
                            vErrors.push(err117);
                          }

                          errors++;
                        }
                      }
                    }
                  }
                }
              }
            }

            var _valid6 = _errs126 === errors;

            errors = _errs125;

            if (vErrors !== null) {
              if (_errs125) {
                vErrors.length = _errs125;
              } else {
                vErrors = null;
              }
            }

            if (_valid6) {
              const _errs129 = errors;

              if (data43 && typeof data43 == "object" && !Array.isArray(data43)) {
                if (data43.type !== undefined) {
                  let data55 = data43.type;

                  if (!(data55 === "String" || data55 === "Text" || data55 === "Hidden" || data55 === "Dropdown")) {
                    const err118 = {
                      keyword: "enum",
                      dataPath: dataPath + "/properties/" + i5 + "/type",
                      schemaPath: "#/definitions/properties/allOf/1/items/allOf/3/then/properties/type/enum",
                      params: {
                        allowedValues: schema18$1.allOf[1].items.allOf[3].then.properties.type.enum
                      },
                      message: "should be equal to one of the allowed values"
                    };

                    if (vErrors === null) {
                      vErrors = [err118];
                    } else {
                      vErrors.push(err118);
                    }

                    errors++;
                  }

                  if (errors > 0) {
                    const emErrs16 = [];

                    for (const err119 of vErrors) {
                      if (err119.keyword !== "errorMessage" && !err119.emUsed && (err119.dataPath === dataPath + "/properties/" + i5 + "/type" || err119.dataPath.indexOf(dataPath + "/properties/" + i5 + "/type") === 0 && err119.dataPath[dataPath + "/properties/" + i5 + "/type".length] === "/") && err119.schemaPath.indexOf("#/definitions/properties/allOf/1/items/allOf/3/then/properties/type") === 0 && err119.schemaPath["#/definitions/properties/allOf/1/items/allOf/3/then/properties/type".length] === "/") {
                        emErrs16.push(err119);
                        err119.emUsed = true;
                      }
                    }

                    if (emErrs16.length) {
                      const err120 = {
                        keyword: "errorMessage",
                        dataPath: dataPath + "/properties/" + i5 + "/type",
                        schemaPath: "#/definitions/properties/allOf/1/items/allOf/3/then/properties/type/errorMessage",
                        params: {
                          errors: emErrs16
                        },
                        message: "invalid property type " + JSON.stringify(data55) + " for binding type " + JSON.stringify(data43 && data43.binding && data43.binding.type) + "; must be any of { String, Text, Hidden, Dropdown }"
                      };

                      if (vErrors === null) {
                        vErrors = [err120];
                      } else {
                        vErrors.push(err120);
                      }

                      errors++;
                    }

                    const emErrs17 = [];

                    for (const err121 of vErrors) {
                      if (!err121.emUsed) {
                        emErrs17.push(err121);
                      }
                    }

                    vErrors = emErrs17;
                    errors = emErrs17.length;
                  }
                }
              }

              var _valid6 = _errs129 === errors;

              valid50 = _valid6;
            }

            if (!valid50) {
              const err122 = {
                keyword: "if",
                dataPath: dataPath + "/properties/" + i5,
                schemaPath: "#/definitions/properties/allOf/1/items/allOf/3/if",
                params: {
                  failingKeyword: "then"
                },
                message: "should match \"then\" schema"
              };

              if (vErrors === null) {
                vErrors = [err122];
              } else {
                vErrors.push(err122);
              }

              errors++;
            }

            if (data43 && typeof data43 == "object" && !Array.isArray(data43)) {
              if (data43.binding === undefined) {
                const err123 = {
                  keyword: "required",
                  dataPath: dataPath + "/properties/" + i5,
                  schemaPath: "#/definitions/properties/allOf/1/items/required",
                  params: {
                    missingProperty: "binding"
                  },
                  message: "should have required property '" + "binding" + "'"
                };

                if (vErrors === null) {
                  vErrors = [err123];
                } else {
                  vErrors.push(err123);
                }

                errors++;
              }

              if (data43.binding !== undefined) {
                let data56 = data43.binding;
                const _errs134 = errors;
                let valid56 = true;
                const _errs135 = errors;

                if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                  if (data56.type === undefined && "type") {
                    const err124 = {};

                    if (vErrors === null) {
                      vErrors = [err124];
                    } else {
                      vErrors.push(err124);
                    }

                    errors++;
                  } else {
                    if (data56.type !== undefined) {
                      let data57 = data56.type;

                      if (!(data57 === "property" || data57 === "camunda:property" || data57 === "camunda:inputParameter" || data57 === "camunda:field")) {
                        const err125 = {};

                        if (vErrors === null) {
                          vErrors = [err125];
                        } else {
                          vErrors.push(err125);
                        }

                        errors++;
                      }
                    }
                  }
                }

                var _valid7 = _errs135 === errors;

                errors = _errs134;

                if (vErrors !== null) {
                  if (_errs134) {
                    vErrors.length = _errs134;
                  } else {
                    vErrors = null;
                  }
                }

                if (_valid7) {
                  const _errs137 = errors;

                  if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                    if (data56.name === undefined) {
                      const err126 = {
                        keyword: "required",
                        dataPath: dataPath + "/properties/" + i5 + "/binding",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/0/then/required",
                        params: {
                          missingProperty: "name"
                        },
                        message: "should have required property '" + "name" + "'"
                      };

                      if (vErrors === null) {
                        vErrors = [err126];
                      } else {
                        vErrors.push(err126);
                      }

                      errors++;
                    }
                  }

                  if (errors > 0) {
                    const emErrs18 = [];

                    for (const err127 of vErrors) {
                      if (err127.keyword !== "errorMessage" && !err127.emUsed && (err127.dataPath === dataPath + "/properties/" + i5 + "/binding" || err127.dataPath.indexOf(dataPath + "/properties/" + i5 + "/binding") === 0 && err127.dataPath[dataPath + "/properties/" + i5 + "/binding".length] === "/") && err127.schemaPath.indexOf("#/definitions/properties/allOf/1/items/properties/binding/allOf/0/then") === 0 && err127.schemaPath["#/definitions/properties/allOf/1/items/properties/binding/allOf/0/then".length] === "/") {
                        emErrs18.push(err127);
                        err127.emUsed = true;
                      }
                    }

                    if (emErrs18.length) {
                      const err128 = {
                        keyword: "errorMessage",
                        dataPath: dataPath + "/properties/" + i5 + "/binding",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/0/then/errorMessage",
                        params: {
                          errors: emErrs18
                        },
                        message: "property.binding " + JSON.stringify(data56 && data56.type) + " requires name"
                      };

                      if (vErrors === null) {
                        vErrors = [err128];
                      } else {
                        vErrors.push(err128);
                      }

                      errors++;
                    }

                    const emErrs19 = [];

                    for (const err129 of vErrors) {
                      if (!err129.emUsed) {
                        emErrs19.push(err129);
                      }
                    }

                    vErrors = emErrs19;
                    errors = emErrs19.length;
                  }

                  var _valid7 = _errs137 === errors;

                  valid56 = _valid7;
                }

                if (!valid56) {
                  const err130 = {
                    keyword: "if",
                    dataPath: dataPath + "/properties/" + i5 + "/binding",
                    schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/0/if",
                    params: {
                      failingKeyword: "then"
                    },
                    message: "should match \"then\" schema"
                  };

                  if (vErrors === null) {
                    vErrors = [err130];
                  } else {
                    vErrors.push(err130);
                  }

                  errors++;
                }

                const _errs139 = errors;
                let valid58 = true;
                const _errs140 = errors;

                if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                  if (data56.type === undefined && "type") {
                    const err131 = {};

                    if (vErrors === null) {
                      vErrors = [err131];
                    } else {
                      vErrors.push(err131);
                    }

                    errors++;
                  } else {
                    if (data56.type !== undefined) {
                      if (!func0$1(data56.type, "camunda:outputParameter")) {
                        const err132 = {};

                        if (vErrors === null) {
                          vErrors = [err132];
                        } else {
                          vErrors.push(err132);
                        }

                        errors++;
                      }
                    }
                  }
                }

                var _valid8 = _errs140 === errors;

                errors = _errs139;

                if (vErrors !== null) {
                  if (_errs139) {
                    vErrors.length = _errs139;
                  } else {
                    vErrors = null;
                  }
                }

                if (_valid8) {
                  const _errs142 = errors;

                  if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                    if (data56.source === undefined) {
                      const err133 = {
                        keyword: "required",
                        dataPath: dataPath + "/properties/" + i5 + "/binding",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/1/then/required",
                        params: {
                          missingProperty: "source"
                        },
                        message: "should have required property '" + "source" + "'"
                      };

                      if (vErrors === null) {
                        vErrors = [err133];
                      } else {
                        vErrors.push(err133);
                      }

                      errors++;
                    }
                  }

                  if (errors > 0) {
                    const emErrs20 = [];

                    for (const err134 of vErrors) {
                      if (err134.keyword !== "errorMessage" && !err134.emUsed && (err134.dataPath === dataPath + "/properties/" + i5 + "/binding" || err134.dataPath.indexOf(dataPath + "/properties/" + i5 + "/binding") === 0 && err134.dataPath[dataPath + "/properties/" + i5 + "/binding".length] === "/") && err134.schemaPath.indexOf("#/definitions/properties/allOf/1/items/properties/binding/allOf/1/then") === 0 && err134.schemaPath["#/definitions/properties/allOf/1/items/properties/binding/allOf/1/then".length] === "/") {
                        emErrs20.push(err134);
                        err134.emUsed = true;
                      }
                    }

                    if (emErrs20.length) {
                      const err135 = {
                        keyword: "errorMessage",
                        dataPath: dataPath + "/properties/" + i5 + "/binding",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/1/then/errorMessage",
                        params: {
                          errors: emErrs20
                        },
                        message: "property.binding " + JSON.stringify(data56 && data56.type) + " requires source"
                      };

                      if (vErrors === null) {
                        vErrors = [err135];
                      } else {
                        vErrors.push(err135);
                      }

                      errors++;
                    }

                    const emErrs21 = [];

                    for (const err136 of vErrors) {
                      if (!err136.emUsed) {
                        emErrs21.push(err136);
                      }
                    }

                    vErrors = emErrs21;
                    errors = emErrs21.length;
                  }

                  var _valid8 = _errs142 === errors;

                  valid58 = _valid8;
                }

                if (!valid58) {
                  const err137 = {
                    keyword: "if",
                    dataPath: dataPath + "/properties/" + i5 + "/binding",
                    schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/1/if",
                    params: {
                      failingKeyword: "then"
                    },
                    message: "should match \"then\" schema"
                  };

                  if (vErrors === null) {
                    vErrors = [err137];
                  } else {
                    vErrors.push(err137);
                  }

                  errors++;
                }

                const _errs144 = errors;
                let valid60 = true;
                const _errs145 = errors;

                if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                  if (data56.type === undefined && "type") {
                    const err138 = {};

                    if (vErrors === null) {
                      vErrors = [err138];
                    } else {
                      vErrors.push(err138);
                    }

                    errors++;
                  } else {
                    if (data56.type !== undefined) {
                      if (!func0$1(data56.type, "camunda:in")) {
                        const err139 = {};

                        if (vErrors === null) {
                          vErrors = [err139];
                        } else {
                          vErrors.push(err139);
                        }

                        errors++;
                      }
                    }
                  }
                }

                var _valid9 = _errs145 === errors;

                errors = _errs144;

                if (vErrors !== null) {
                  if (_errs144) {
                    vErrors.length = _errs144;
                  } else {
                    vErrors = null;
                  }
                }

                if (_valid9) {
                  const _errs147 = errors;
                  const _errs148 = errors;
                  let valid62 = false;
                  const _errs149 = errors;

                  if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                    if (data56.variables === undefined) {
                      const err140 = {
                        keyword: "required",
                        dataPath: dataPath + "/properties/" + i5 + "/binding",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/2/then/anyOf/0/required",
                        params: {
                          missingProperty: "variables"
                        },
                        message: "should have required property '" + "variables" + "'"
                      };

                      if (vErrors === null) {
                        vErrors = [err140];
                      } else {
                        vErrors.push(err140);
                      }

                      errors++;
                    }
                  }

                  var _valid10 = _errs149 === errors;

                  valid62 = valid62 || _valid10;

                  if (!valid62) {
                    const _errs150 = errors;

                    if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                      if (data56.target === undefined) {
                        const err141 = {
                          keyword: "required",
                          dataPath: dataPath + "/properties/" + i5 + "/binding",
                          schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/2/then/anyOf/1/required",
                          params: {
                            missingProperty: "target"
                          },
                          message: "should have required property '" + "target" + "'"
                        };

                        if (vErrors === null) {
                          vErrors = [err141];
                        } else {
                          vErrors.push(err141);
                        }

                        errors++;
                      }
                    }

                    var _valid10 = _errs150 === errors;

                    valid62 = valid62 || _valid10;
                  }

                  if (!valid62) {
                    const err142 = {
                      keyword: "anyOf",
                      dataPath: dataPath + "/properties/" + i5 + "/binding",
                      schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/2/then/anyOf",
                      params: {},
                      message: "should match some schema in anyOf"
                    };

                    if (vErrors === null) {
                      vErrors = [err142];
                    } else {
                      vErrors.push(err142);
                    }

                    errors++;
                  } else {
                    errors = _errs148;

                    if (vErrors !== null) {
                      if (_errs148) {
                        vErrors.length = _errs148;
                      } else {
                        vErrors = null;
                      }
                    }
                  }

                  if (errors > 0) {
                    const emErrs22 = [];

                    for (const err143 of vErrors) {
                      if (err143.keyword !== "errorMessage" && !err143.emUsed && (err143.dataPath === dataPath + "/properties/" + i5 + "/binding" || err143.dataPath.indexOf(dataPath + "/properties/" + i5 + "/binding") === 0 && err143.dataPath[dataPath + "/properties/" + i5 + "/binding".length] === "/") && err143.schemaPath.indexOf("#/definitions/properties/allOf/1/items/properties/binding/allOf/2/then") === 0 && err143.schemaPath["#/definitions/properties/allOf/1/items/properties/binding/allOf/2/then".length] === "/") {
                        emErrs22.push(err143);
                        err143.emUsed = true;
                      }
                    }

                    if (emErrs22.length) {
                      const err144 = {
                        keyword: "errorMessage",
                        dataPath: dataPath + "/properties/" + i5 + "/binding",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/2/then/errorMessage",
                        params: {
                          errors: emErrs22
                        },
                        message: "property.binding " + JSON.stringify(data56 && data56.type) + " requires variables, target, or both"
                      };

                      if (vErrors === null) {
                        vErrors = [err144];
                      } else {
                        vErrors.push(err144);
                      }

                      errors++;
                    }

                    const emErrs23 = [];

                    for (const err145 of vErrors) {
                      if (!err145.emUsed) {
                        emErrs23.push(err145);
                      }
                    }

                    vErrors = emErrs23;
                    errors = emErrs23.length;
                  }

                  var _valid9 = _errs147 === errors;

                  valid60 = _valid9;
                }

                if (!valid60) {
                  const err146 = {
                    keyword: "if",
                    dataPath: dataPath + "/properties/" + i5 + "/binding",
                    schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/2/if",
                    params: {
                      failingKeyword: "then"
                    },
                    message: "should match \"then\" schema"
                  };

                  if (vErrors === null) {
                    vErrors = [err146];
                  } else {
                    vErrors.push(err146);
                  }

                  errors++;
                }

                const _errs152 = errors;
                let valid63 = true;
                const _errs153 = errors;

                if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                  if (data56.type === undefined && "type") {
                    const err147 = {};

                    if (vErrors === null) {
                      vErrors = [err147];
                    } else {
                      vErrors.push(err147);
                    }

                    errors++;
                  } else {
                    if (data56.type !== undefined) {
                      if (!func0$1(data56.type, "camunda:out")) {
                        const err148 = {};

                        if (vErrors === null) {
                          vErrors = [err148];
                        } else {
                          vErrors.push(err148);
                        }

                        errors++;
                      }
                    }
                  }
                }

                var _valid11 = _errs153 === errors;

                errors = _errs152;

                if (vErrors !== null) {
                  if (_errs152) {
                    vErrors.length = _errs152;
                  } else {
                    vErrors = null;
                  }
                }

                if (_valid11) {
                  const _errs155 = errors;
                  const _errs156 = errors;
                  let valid65 = false;
                  let passing2 = null;
                  const _errs157 = errors;
                  const _errs158 = errors;
                  const _errs159 = errors;
                  const _errs160 = errors;
                  let valid67 = false;
                  const _errs161 = errors;

                  if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                    if (data56.source === undefined && "source") {
                      const err149 = {};

                      if (vErrors === null) {
                        vErrors = [err149];
                      } else {
                        vErrors.push(err149);
                      }

                      errors++;
                    }
                  }

                  var _valid13 = _errs161 === errors;

                  valid67 = valid67 || _valid13;

                  if (!valid67) {
                    const _errs162 = errors;

                    if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                      if (data56.sourceExpression === undefined && "sourceExpression") {
                        const err150 = {};

                        if (vErrors === null) {
                          vErrors = [err150];
                        } else {
                          vErrors.push(err150);
                        }

                        errors++;
                      }
                    }

                    var _valid13 = _errs162 === errors;

                    valid67 = valid67 || _valid13;
                  }

                  if (!valid67) {
                    const err151 = {};

                    if (vErrors === null) {
                      vErrors = [err151];
                    } else {
                      vErrors.push(err151);
                    }

                    errors++;
                  } else {
                    errors = _errs160;

                    if (vErrors !== null) {
                      if (_errs160) {
                        vErrors.length = _errs160;
                      } else {
                        vErrors = null;
                      }
                    }
                  }

                  var valid66 = _errs159 === errors;

                  if (!valid66) {
                    errors = _errs158;

                    if (vErrors !== null) {
                      if (_errs158) {
                        vErrors.length = _errs158;
                      } else {
                        vErrors = null;
                      }
                    }
                  } else {
                    const err152 = {
                      keyword: "not",
                      dataPath: dataPath + "/properties/" + i5 + "/binding",
                      schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/0/not",
                      params: {},
                      message: "should NOT be valid"
                    };

                    if (vErrors === null) {
                      vErrors = [err152];
                    } else {
                      vErrors.push(err152);
                    }

                    errors++;
                  }

                  if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                    if (data56.variables === undefined) {
                      const err153 = {
                        keyword: "required",
                        dataPath: dataPath + "/properties/" + i5 + "/binding",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/0/required",
                        params: {
                          missingProperty: "variables"
                        },
                        message: "should have required property '" + "variables" + "'"
                      };

                      if (vErrors === null) {
                        vErrors = [err153];
                      } else {
                        vErrors.push(err153);
                      }

                      errors++;
                    }
                  }

                  var _valid12 = _errs157 === errors;

                  if (_valid12) {
                    valid65 = true;
                    passing2 = 0;
                  }

                  const _errs163 = errors;
                  const _errs164 = errors;
                  const _errs165 = errors;
                  const _errs166 = errors;
                  let valid69 = false;
                  const _errs167 = errors;

                  if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                    if (data56.variables === undefined && "variables") {
                      const err154 = {};

                      if (vErrors === null) {
                        vErrors = [err154];
                      } else {
                        vErrors.push(err154);
                      }

                      errors++;
                    }
                  }

                  var _valid14 = _errs167 === errors;

                  valid69 = valid69 || _valid14;

                  if (!valid69) {
                    const _errs168 = errors;

                    if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                      if (data56.sourceExpression === undefined && "sourceExpression") {
                        const err155 = {};

                        if (vErrors === null) {
                          vErrors = [err155];
                        } else {
                          vErrors.push(err155);
                        }

                        errors++;
                      }
                    }

                    var _valid14 = _errs168 === errors;

                    valid69 = valid69 || _valid14;
                  }

                  if (!valid69) {
                    const err156 = {};

                    if (vErrors === null) {
                      vErrors = [err156];
                    } else {
                      vErrors.push(err156);
                    }

                    errors++;
                  } else {
                    errors = _errs166;

                    if (vErrors !== null) {
                      if (_errs166) {
                        vErrors.length = _errs166;
                      } else {
                        vErrors = null;
                      }
                    }
                  }

                  var valid68 = _errs165 === errors;

                  if (!valid68) {
                    errors = _errs164;

                    if (vErrors !== null) {
                      if (_errs164) {
                        vErrors.length = _errs164;
                      } else {
                        vErrors = null;
                      }
                    }
                  } else {
                    const err157 = {
                      keyword: "not",
                      dataPath: dataPath + "/properties/" + i5 + "/binding",
                      schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/1/not",
                      params: {},
                      message: "should NOT be valid"
                    };

                    if (vErrors === null) {
                      vErrors = [err157];
                    } else {
                      vErrors.push(err157);
                    }

                    errors++;
                  }

                  if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                    if (data56.source === undefined) {
                      const err158 = {
                        keyword: "required",
                        dataPath: dataPath + "/properties/" + i5 + "/binding",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/1/required",
                        params: {
                          missingProperty: "source"
                        },
                        message: "should have required property '" + "source" + "'"
                      };

                      if (vErrors === null) {
                        vErrors = [err158];
                      } else {
                        vErrors.push(err158);
                      }

                      errors++;
                    }
                  }

                  var _valid12 = _errs163 === errors;

                  if (_valid12 && valid65) {
                    valid65 = false;
                    passing2 = [passing2, 1];
                  } else {
                    if (_valid12) {
                      valid65 = true;
                      passing2 = 1;
                    }

                    const _errs169 = errors;
                    const _errs170 = errors;
                    const _errs171 = errors;
                    const _errs172 = errors;
                    let valid71 = false;
                    const _errs173 = errors;

                    if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                      if (data56.variables === undefined && "variables") {
                        const err159 = {};

                        if (vErrors === null) {
                          vErrors = [err159];
                        } else {
                          vErrors.push(err159);
                        }

                        errors++;
                      }
                    }

                    var _valid15 = _errs173 === errors;

                    valid71 = valid71 || _valid15;

                    if (!valid71) {
                      const _errs174 = errors;

                      if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                        if (data56.source === undefined && "source") {
                          const err160 = {};

                          if (vErrors === null) {
                            vErrors = [err160];
                          } else {
                            vErrors.push(err160);
                          }

                          errors++;
                        }
                      }

                      var _valid15 = _errs174 === errors;

                      valid71 = valid71 || _valid15;
                    }

                    if (!valid71) {
                      const err161 = {};

                      if (vErrors === null) {
                        vErrors = [err161];
                      } else {
                        vErrors.push(err161);
                      }

                      errors++;
                    } else {
                      errors = _errs172;

                      if (vErrors !== null) {
                        if (_errs172) {
                          vErrors.length = _errs172;
                        } else {
                          vErrors = null;
                        }
                      }
                    }

                    var valid70 = _errs171 === errors;

                    if (!valid70) {
                      errors = _errs170;

                      if (vErrors !== null) {
                        if (_errs170) {
                          vErrors.length = _errs170;
                        } else {
                          vErrors = null;
                        }
                      }
                    } else {
                      const err162 = {
                        keyword: "not",
                        dataPath: dataPath + "/properties/" + i5 + "/binding",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/2/not",
                        params: {},
                        message: "should NOT be valid"
                      };

                      if (vErrors === null) {
                        vErrors = [err162];
                      } else {
                        vErrors.push(err162);
                      }

                      errors++;
                    }

                    if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                      if (data56.sourceExpression === undefined) {
                        const err163 = {
                          keyword: "required",
                          dataPath: dataPath + "/properties/" + i5 + "/binding",
                          schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/2/required",
                          params: {
                            missingProperty: "sourceExpression"
                          },
                          message: "should have required property '" + "sourceExpression" + "'"
                        };

                        if (vErrors === null) {
                          vErrors = [err163];
                        } else {
                          vErrors.push(err163);
                        }

                        errors++;
                      }
                    }

                    var _valid12 = _errs169 === errors;

                    if (_valid12 && valid65) {
                      valid65 = false;
                      passing2 = [passing2, 2];
                    } else {
                      if (_valid12) {
                        valid65 = true;
                        passing2 = 2;
                      }

                      const _errs175 = errors;
                      const _errs176 = errors;
                      const _errs177 = errors;

                      if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                        if (data56.source === undefined && "source") {
                          const err164 = {};

                          if (vErrors === null) {
                            vErrors = [err164];
                          } else {
                            vErrors.push(err164);
                          }

                          errors++;
                        }
                      }

                      var valid72 = _errs177 === errors;

                      if (!valid72) {
                        errors = _errs176;

                        if (vErrors !== null) {
                          if (_errs176) {
                            vErrors.length = _errs176;
                          } else {
                            vErrors = null;
                          }
                        }
                      } else {
                        const err165 = {
                          keyword: "not",
                          dataPath: dataPath + "/properties/" + i5 + "/binding",
                          schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/3/not",
                          params: {},
                          message: "should NOT be valid"
                        };

                        if (vErrors === null) {
                          vErrors = [err165];
                        } else {
                          vErrors.push(err165);
                        }

                        errors++;
                      }

                      if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                        if (data56.variables === undefined) {
                          const err166 = {
                            keyword: "required",
                            dataPath: dataPath + "/properties/" + i5 + "/binding",
                            schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/3/required",
                            params: {
                              missingProperty: "variables"
                            },
                            message: "should have required property '" + "variables" + "'"
                          };

                          if (vErrors === null) {
                            vErrors = [err166];
                          } else {
                            vErrors.push(err166);
                          }

                          errors++;
                        }

                        if (data56.sourceExpression === undefined) {
                          const err167 = {
                            keyword: "required",
                            dataPath: dataPath + "/properties/" + i5 + "/binding",
                            schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/3/required",
                            params: {
                              missingProperty: "sourceExpression"
                            },
                            message: "should have required property '" + "sourceExpression" + "'"
                          };

                          if (vErrors === null) {
                            vErrors = [err167];
                          } else {
                            vErrors.push(err167);
                          }

                          errors++;
                        }
                      }

                      var _valid12 = _errs175 === errors;

                      if (_valid12 && valid65) {
                        valid65 = false;
                        passing2 = [passing2, 3];
                      } else {
                        if (_valid12) {
                          valid65 = true;
                          passing2 = 3;
                        }

                        const _errs178 = errors;
                        const _errs179 = errors;
                        const _errs180 = errors;

                        if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                          if (data56.sourceExpression === undefined && "sourceExpression") {
                            const err168 = {};

                            if (vErrors === null) {
                              vErrors = [err168];
                            } else {
                              vErrors.push(err168);
                            }

                            errors++;
                          }
                        }

                        var valid73 = _errs180 === errors;

                        if (!valid73) {
                          errors = _errs179;

                          if (vErrors !== null) {
                            if (_errs179) {
                              vErrors.length = _errs179;
                            } else {
                              vErrors = null;
                            }
                          }
                        } else {
                          const err169 = {
                            keyword: "not",
                            dataPath: dataPath + "/properties/" + i5 + "/binding",
                            schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/4/not",
                            params: {},
                            message: "should NOT be valid"
                          };

                          if (vErrors === null) {
                            vErrors = [err169];
                          } else {
                            vErrors.push(err169);
                          }

                          errors++;
                        }

                        if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                          if (data56.variables === undefined) {
                            const err170 = {
                              keyword: "required",
                              dataPath: dataPath + "/properties/" + i5 + "/binding",
                              schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/4/required",
                              params: {
                                missingProperty: "variables"
                              },
                              message: "should have required property '" + "variables" + "'"
                            };

                            if (vErrors === null) {
                              vErrors = [err170];
                            } else {
                              vErrors.push(err170);
                            }

                            errors++;
                          }

                          if (data56.source === undefined) {
                            const err171 = {
                              keyword: "required",
                              dataPath: dataPath + "/properties/" + i5 + "/binding",
                              schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/4/required",
                              params: {
                                missingProperty: "source"
                              },
                              message: "should have required property '" + "source" + "'"
                            };

                            if (vErrors === null) {
                              vErrors = [err171];
                            } else {
                              vErrors.push(err171);
                            }

                            errors++;
                          }
                        }

                        var _valid12 = _errs178 === errors;

                        if (_valid12 && valid65) {
                          valid65 = false;
                          passing2 = [passing2, 4];
                        } else {
                          if (_valid12) {
                            valid65 = true;
                            passing2 = 4;
                          }
                        }
                      }
                    }
                  }

                  if (!valid65) {
                    const err172 = {
                      keyword: "oneOf",
                      dataPath: dataPath + "/properties/" + i5 + "/binding",
                      schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf",
                      params: {
                        passingSchemas: passing2
                      },
                      message: "should match exactly one schema in oneOf"
                    };

                    if (vErrors === null) {
                      vErrors = [err172];
                    } else {
                      vErrors.push(err172);
                    }

                    errors++;
                  } else {
                    errors = _errs156;

                    if (vErrors !== null) {
                      if (_errs156) {
                        vErrors.length = _errs156;
                      } else {
                        vErrors = null;
                      }
                    }
                  }

                  if (errors > 0) {
                    const emErrs24 = [];

                    for (const err173 of vErrors) {
                      if (err173.keyword !== "errorMessage" && !err173.emUsed && (err173.dataPath === dataPath + "/properties/" + i5 + "/binding" || err173.dataPath.indexOf(dataPath + "/properties/" + i5 + "/binding") === 0 && err173.dataPath[dataPath + "/properties/" + i5 + "/binding".length] === "/") && err173.schemaPath.indexOf("#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then") === 0 && err173.schemaPath["#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then".length] === "/") {
                        emErrs24.push(err173);
                        err173.emUsed = true;
                      }
                    }

                    if (emErrs24.length) {
                      const err174 = {
                        keyword: "errorMessage",
                        dataPath: dataPath + "/properties/" + i5 + "/binding",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/errorMessage",
                        params: {
                          errors: emErrs24
                        },
                        message: "property.binding " + JSON.stringify(data56 && data56.type) + " requires one of the following: variables, sourceExpression, source, (sourceExpression and variables), or (source and variables)"
                      };

                      if (vErrors === null) {
                        vErrors = [err174];
                      } else {
                        vErrors.push(err174);
                      }

                      errors++;
                    }

                    const emErrs25 = [];

                    for (const err175 of vErrors) {
                      if (!err175.emUsed) {
                        emErrs25.push(err175);
                      }
                    }

                    vErrors = emErrs25;
                    errors = emErrs25.length;
                  }

                  var _valid11 = _errs155 === errors;

                  valid63 = _valid11;
                }

                if (!valid63) {
                  const err176 = {
                    keyword: "if",
                    dataPath: dataPath + "/properties/" + i5 + "/binding",
                    schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/if",
                    params: {
                      failingKeyword: "then"
                    },
                    message: "should match \"then\" schema"
                  };

                  if (vErrors === null) {
                    vErrors = [err176];
                  } else {
                    vErrors.push(err176);
                  }

                  errors++;
                }

                const _errs182 = errors;
                let valid74 = true;
                const _errs183 = errors;

                if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                  if (data56.type === undefined && "type") {
                    const err177 = {};

                    if (vErrors === null) {
                      vErrors = [err177];
                    } else {
                      vErrors.push(err177);
                    }

                    errors++;
                  } else {
                    if (data56.type !== undefined) {
                      if (!func0$1(data56.type, "camunda:errorEventDefinition")) {
                        const err178 = {};

                        if (vErrors === null) {
                          vErrors = [err178];
                        } else {
                          vErrors.push(err178);
                        }

                        errors++;
                      }
                    }
                  }
                }

                var _valid16 = _errs183 === errors;

                errors = _errs182;

                if (vErrors !== null) {
                  if (_errs182) {
                    vErrors.length = _errs182;
                  } else {
                    vErrors = null;
                  }
                }

                if (_valid16) {
                  const _errs185 = errors;
                  const _errs186 = errors;
                  let valid76 = false;
                  let passing3 = null;
                  const _errs187 = errors;

                  if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                    if (data56.errorRef === undefined) {
                      const err179 = {
                        keyword: "required",
                        dataPath: dataPath + "/properties/" + i5 + "/binding",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/4/then/oneOf/0/required",
                        params: {
                          missingProperty: "errorRef"
                        },
                        message: "should have required property '" + "errorRef" + "'"
                      };

                      if (vErrors === null) {
                        vErrors = [err179];
                      } else {
                        vErrors.push(err179);
                      }

                      errors++;
                    }
                  }

                  var _valid17 = _errs187 === errors;

                  if (_valid17) {
                    valid76 = true;
                    passing3 = 0;
                  }

                  if (!valid76) {
                    const err180 = {
                      keyword: "oneOf",
                      dataPath: dataPath + "/properties/" + i5 + "/binding",
                      schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/4/then/oneOf",
                      params: {
                        passingSchemas: passing3
                      },
                      message: "should match exactly one schema in oneOf"
                    };

                    if (vErrors === null) {
                      vErrors = [err180];
                    } else {
                      vErrors.push(err180);
                    }

                    errors++;
                  } else {
                    errors = _errs186;

                    if (vErrors !== null) {
                      if (_errs186) {
                        vErrors.length = _errs186;
                      } else {
                        vErrors = null;
                      }
                    }
                  }

                  if (errors > 0) {
                    const emErrs26 = [];

                    for (const err181 of vErrors) {
                      if (err181.keyword !== "errorMessage" && !err181.emUsed && (err181.dataPath === dataPath + "/properties/" + i5 + "/binding" || err181.dataPath.indexOf(dataPath + "/properties/" + i5 + "/binding") === 0 && err181.dataPath[dataPath + "/properties/" + i5 + "/binding".length] === "/") && err181.schemaPath.indexOf("#/definitions/properties/allOf/1/items/properties/binding/allOf/4/then") === 0 && err181.schemaPath["#/definitions/properties/allOf/1/items/properties/binding/allOf/4/then".length] === "/") {
                        emErrs26.push(err181);
                        err181.emUsed = true;
                      }
                    }

                    if (emErrs26.length) {
                      const err182 = {
                        keyword: "errorMessage",
                        dataPath: dataPath + "/properties/" + i5 + "/binding",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/4/then/errorMessage",
                        params: {
                          errors: emErrs26
                        },
                        message: "property.binding " + JSON.stringify(data56 && data56.type) + " requires errorRef"
                      };

                      if (vErrors === null) {
                        vErrors = [err182];
                      } else {
                        vErrors.push(err182);
                      }

                      errors++;
                    }

                    const emErrs27 = [];

                    for (const err183 of vErrors) {
                      if (!err183.emUsed) {
                        emErrs27.push(err183);
                      }
                    }

                    vErrors = emErrs27;
                    errors = emErrs27.length;
                  }

                  var _valid16 = _errs185 === errors;

                  valid74 = _valid16;
                }

                if (!valid74) {
                  const err184 = {
                    keyword: "if",
                    dataPath: dataPath + "/properties/" + i5 + "/binding",
                    schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/4/if",
                    params: {
                      failingKeyword: "then"
                    },
                    message: "should match \"then\" schema"
                  };

                  if (vErrors === null) {
                    vErrors = [err184];
                  } else {
                    vErrors.push(err184);
                  }

                  errors++;
                }

                if (data56 && typeof data56 == "object" && !Array.isArray(data56)) {
                  if (data56.type === undefined) {
                    const err185 = {
                      keyword: "required",
                      dataPath: dataPath + "/properties/" + i5 + "/binding",
                      schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/required",
                      params: {
                        missingProperty: "type"
                      },
                      message: "should have required property '" + "type" + "'"
                    };

                    if (vErrors === null) {
                      vErrors = [err185];
                    } else {
                      vErrors.push(err185);
                    }

                    errors++;
                  }

                  if (data56.type !== undefined) {
                    let data62 = data56.type;

                    if (typeof data62 !== "string") {
                      const err186 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i5 + "/binding/type",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/type/type",
                        params: {
                          type: "string"
                        },
                        message: "should be string"
                      };

                      if (vErrors === null) {
                        vErrors = [err186];
                      } else {
                        vErrors.push(err186);
                      }

                      errors++;
                    }

                    if (!(data62 === "property" || data62 === "camunda:property" || data62 === "camunda:inputParameter" || data62 === "camunda:outputParameter" || data62 === "camunda:in" || data62 === "camunda:out" || data62 === "camunda:in:businessKey" || data62 === "camunda:executionListener" || data62 === "camunda:field" || data62 === "camunda:errorEventDefinition")) {
                      const err187 = {
                        keyword: "enum",
                        dataPath: dataPath + "/properties/" + i5 + "/binding/type",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/type/enum",
                        params: {
                          allowedValues: schema18$1.allOf[1].items.properties.binding.properties.type.enum
                        },
                        message: "should be equal to one of the allowed values"
                      };

                      if (vErrors === null) {
                        vErrors = [err187];
                      } else {
                        vErrors.push(err187);
                      }

                      errors++;
                    }

                    if (errors > 0) {
                      const emErrs28 = [];

                      for (const err188 of vErrors) {
                        if (err188.keyword !== "errorMessage" && !err188.emUsed && (err188.dataPath === dataPath + "/properties/" + i5 + "/binding/type" || err188.dataPath.indexOf(dataPath + "/properties/" + i5 + "/binding/type") === 0 && err188.dataPath[dataPath + "/properties/" + i5 + "/binding/type".length] === "/") && err188.schemaPath.indexOf("#/definitions/properties/allOf/1/items/properties/binding/properties/type") === 0 && err188.schemaPath["#/definitions/properties/allOf/1/items/properties/binding/properties/type".length] === "/") {
                          emErrs28.push(err188);
                          err188.emUsed = true;
                        }
                      }

                      if (emErrs28.length) {
                        const err189 = {
                          keyword: "errorMessage",
                          dataPath: dataPath + "/properties/" + i5 + "/binding/type",
                          schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/type/errorMessage",
                          params: {
                            errors: emErrs28
                          },
                          message: "invalid property.binding type " + JSON.stringify(data62) + "; must be any of { property, camunda:property, camunda:inputParameter, camunda:outputParameter, camunda:in, camunda:out, camunda:in:businessKey, camunda:executionListener, camunda:field, camunda:errorEventDefinition }"
                        };

                        if (vErrors === null) {
                          vErrors = [err189];
                        } else {
                          vErrors.push(err189);
                        }

                        errors++;
                      }

                      const emErrs29 = [];

                      for (const err190 of vErrors) {
                        if (!err190.emUsed) {
                          emErrs29.push(err190);
                        }
                      }

                      vErrors = emErrs29;
                      errors = emErrs29.length;
                    }
                  }

                  if (data56.name !== undefined) {
                    if (typeof data56.name !== "string") {
                      const err191 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i5 + "/binding/name",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/name/type",
                        params: {
                          type: "string"
                        },
                        message: "should be string"
                      };

                      if (vErrors === null) {
                        vErrors = [err191];
                      } else {
                        vErrors.push(err191);
                      }

                      errors++;
                    }
                  }

                  if (data56.event !== undefined) {
                    if (typeof data56.event !== "string") {
                      const err192 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i5 + "/binding/event",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/event/type",
                        params: {
                          type: "string"
                        },
                        message: "should be string"
                      };

                      if (vErrors === null) {
                        vErrors = [err192];
                      } else {
                        vErrors.push(err192);
                      }

                      errors++;
                    }
                  }

                  if (data56.scriptFormat !== undefined) {
                    if (typeof data56.scriptFormat !== "string") {
                      const err193 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i5 + "/binding/scriptFormat",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/scriptFormat/type",
                        params: {
                          type: "string"
                        },
                        message: "should be string"
                      };

                      if (vErrors === null) {
                        vErrors = [err193];
                      } else {
                        vErrors.push(err193);
                      }

                      errors++;
                    }
                  }

                  if (data56.source !== undefined) {
                    if (typeof data56.source !== "string") {
                      const err194 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i5 + "/binding/source",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/source/type",
                        params: {
                          type: "string"
                        },
                        message: "should be string"
                      };

                      if (vErrors === null) {
                        vErrors = [err194];
                      } else {
                        vErrors.push(err194);
                      }

                      errors++;
                    }
                  }

                  if (data56.target !== undefined) {
                    if (typeof data56.target !== "string") {
                      const err195 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i5 + "/binding/target",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/target/type",
                        params: {
                          type: "string"
                        },
                        message: "should be string"
                      };

                      if (vErrors === null) {
                        vErrors = [err195];
                      } else {
                        vErrors.push(err195);
                      }

                      errors++;
                    }
                  }

                  if (data56.expression !== undefined) {
                    if (typeof data56.expression !== "boolean") {
                      const err196 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i5 + "/binding/expression",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/expression/type",
                        params: {
                          type: "boolean"
                        },
                        message: "should be boolean"
                      };

                      if (vErrors === null) {
                        vErrors = [err196];
                      } else {
                        vErrors.push(err196);
                      }

                      errors++;
                    }
                  }

                  if (data56.variables !== undefined) {
                    let data69 = data56.variables;

                    if (typeof data69 !== "string") {
                      const err197 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i5 + "/binding/variables",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/variables/type",
                        params: {
                          type: "string"
                        },
                        message: "should be string"
                      };

                      if (vErrors === null) {
                        vErrors = [err197];
                      } else {
                        vErrors.push(err197);
                      }

                      errors++;
                    }

                    if (!(data69 === "all" || data69 === "local")) {
                      const err198 = {
                        keyword: "enum",
                        dataPath: dataPath + "/properties/" + i5 + "/binding/variables",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/variables/enum",
                        params: {
                          allowedValues: schema18$1.allOf[1].items.properties.binding.properties.variables.enum
                        },
                        message: "should be equal to one of the allowed values"
                      };

                      if (vErrors === null) {
                        vErrors = [err198];
                      } else {
                        vErrors.push(err198);
                      }

                      errors++;
                    }
                  }

                  if (data56.sourceExpression !== undefined) {
                    if (typeof data56.sourceExpression !== "string") {
                      const err199 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i5 + "/binding/sourceExpression",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/sourceExpression/type",
                        params: {
                          type: "string"
                        },
                        message: "should be string"
                      };

                      if (vErrors === null) {
                        vErrors = [err199];
                      } else {
                        vErrors.push(err199);
                      }

                      errors++;
                    }
                  }
                } else {
                  const err200 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i5 + "/binding",
                    schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/type",
                    params: {
                      type: "object"
                    },
                    message: "should be object"
                  };

                  if (vErrors === null) {
                    vErrors = [err200];
                  } else {
                    vErrors.push(err200);
                  }

                  errors++;
                }
              }
            } else {
              const err201 = {
                keyword: "type",
                dataPath: dataPath + "/properties/" + i5,
                schemaPath: "#/definitions/properties/allOf/1/items/type",
                params: {
                  type: "object"
                },
                message: "should be object"
              };

              if (vErrors === null) {
                vErrors = [err201];
              } else {
                vErrors.push(err201);
              }

              errors++;
            }

            if (errors > 0) {
              const emErrors8 = {
                "required": []
              };
              const templates8 = {
                required: function () {
                  return "missing binding for property \"" + JSON.stringify(i5) + "\"";
                }
              };

              for (const err202 of vErrors) {
                if (err202.keyword !== "errorMessage" && !err202.emUsed && err202.dataPath === dataPath + "/properties/" + i5 && err202.keyword in emErrors8 && err202.schemaPath.indexOf("#/definitions/properties/allOf/1/items") === 0 && /^\/[^\/]*$/.test(err202.schemaPath.slice(38))) {
                  emErrors8[err202.keyword].push(err202);
                  err202.emUsed = true;
                }
              }

              for (const key8 in emErrors8) {
                if (emErrors8[key8].length) {
                  const err203 = {
                    keyword: "errorMessage",
                    dataPath: dataPath + "/properties/" + i5,
                    schemaPath: "#/definitions/properties/allOf/1/items/errorMessage",
                    params: {
                      errors: emErrors8[key8]
                    },
                    message: key8 in templates8 ? templates8[key8]() : schema18$1.allOf[1].items.errorMessage[key8]
                  };

                  if (vErrors === null) {
                    vErrors = [err203];
                  } else {
                    vErrors.push(err203);
                  }

                  errors++;
                }
              }

              const emErrs30 = [];

              for (const err204 of vErrors) {
                if (!err204.emUsed) {
                  emErrs30.push(err204);
                }
              }

              vErrors = emErrs30;
              errors = emErrs30.length;
            }
          }
        } else {
          const err205 = {
            keyword: "type",
            dataPath: dataPath + "/properties",
            schemaPath: "#/definitions/properties/allOf/1/type",
            params: {
              type: "array"
            },
            message: "should be array"
          };

          if (vErrors === null) {
            vErrors = [err205];
          } else {
            vErrors.push(err205);
          }

          errors++;
        }
      }

      if (data.scopes !== undefined) {
        let data71 = data.scopes;

        if (Array.isArray(data71)) {
          const len6 = data71.length;

          for (let i6 = 0; i6 < len6; i6++) {
            let data72 = data71[i6];
            const _errs211 = errors;
            let valid82 = true;
            const _errs212 = errors;

            if (data72 && typeof data72 == "object" && !Array.isArray(data72)) {
              if (data72.type === undefined && "type") {
                const err206 = {};

                if (vErrors === null) {
                  vErrors = [err206];
                } else {
                  vErrors.push(err206);
                }

                errors++;
              } else {
                if (data72.type !== undefined) {
                  if (!(data72.type === "bpmn:Error")) {
                    const err207 = {};

                    if (vErrors === null) {
                      vErrors = [err207];
                    } else {
                      vErrors.push(err207);
                    }

                    errors++;
                  }
                }
              }
            }

            var _valid18 = _errs212 === errors;

            errors = _errs211;

            if (vErrors !== null) {
              if (_errs211) {
                vErrors.length = _errs211;
              } else {
                vErrors = null;
              }
            }

            if (_valid18) {
              const _errs214 = errors;

              if (data72 && typeof data72 == "object" && !Array.isArray(data72)) {
                if (data72.id === undefined) {
                  const err208 = {
                    keyword: "required",
                    dataPath: dataPath + "/scopes/" + i6,
                    schemaPath: "#/properties/scopes/items/allOf/0/then/required",
                    params: {
                      missingProperty: "id"
                    },
                    message: "should have required property '" + "id" + "'"
                  };

                  if (vErrors === null) {
                    vErrors = [err208];
                  } else {
                    vErrors.push(err208);
                  }

                  errors++;
                }
              }

              if (errors > 0) {
                const emErrs31 = [];

                for (const err209 of vErrors) {
                  if (err209.keyword !== "errorMessage" && !err209.emUsed && (err209.dataPath === dataPath + "/scopes/" + i6 || err209.dataPath.indexOf(dataPath + "/scopes/" + i6) === 0 && err209.dataPath[dataPath + "/scopes/" + i6.length] === "/") && err209.schemaPath.indexOf("#/properties/scopes/items/allOf/0/then") === 0 && err209.schemaPath["#/properties/scopes/items/allOf/0/then".length] === "/") {
                    emErrs31.push(err209);
                    err209.emUsed = true;
                  }
                }

                if (emErrs31.length) {
                  const err210 = {
                    keyword: "errorMessage",
                    dataPath: dataPath + "/scopes/" + i6,
                    schemaPath: "#/properties/scopes/items/allOf/0/then/errorMessage",
                    params: {
                      errors: emErrs31
                    },
                    message: "invalid scope " + JSON.stringify(data72 && data72.type) + ", missing id"
                  };

                  if (vErrors === null) {
                    vErrors = [err210];
                  } else {
                    vErrors.push(err210);
                  }

                  errors++;
                }

                const emErrs32 = [];

                for (const err211 of vErrors) {
                  if (!err211.emUsed) {
                    emErrs32.push(err211);
                  }
                }

                vErrors = emErrs32;
                errors = emErrs32.length;
              }

              var _valid18 = _errs214 === errors;

              valid82 = _valid18;
            }

            if (!valid82) {
              const err212 = {
                keyword: "if",
                dataPath: dataPath + "/scopes/" + i6,
                schemaPath: "#/properties/scopes/items/allOf/0/if",
                params: {
                  failingKeyword: "then"
                },
                message: "should match \"then\" schema"
              };

              if (vErrors === null) {
                vErrors = [err212];
              } else {
                vErrors.push(err212);
              }

              errors++;
            }

            if (data72 && typeof data72 == "object" && !Array.isArray(data72)) {
              if (data72.type === undefined) {
                const err213 = {
                  keyword: "required",
                  dataPath: dataPath + "/scopes/" + i6,
                  schemaPath: "#/properties/scopes/items/required",
                  params: {
                    missingProperty: "type"
                  },
                  message: "should have required property '" + "type" + "'"
                };

                if (vErrors === null) {
                  vErrors = [err213];
                } else {
                  vErrors.push(err213);
                }

                errors++;
              }

              if (data72.properties === undefined) {
                const err214 = {
                  keyword: "required",
                  dataPath: dataPath + "/scopes/" + i6,
                  schemaPath: "#/properties/scopes/items/required",
                  params: {
                    missingProperty: "properties"
                  },
                  message: "should have required property '" + "properties" + "'"
                };

                if (vErrors === null) {
                  vErrors = [err214];
                } else {
                  vErrors.push(err214);
                }

                errors++;
              }

              if (data72.type !== undefined) {
                let data74 = data72.type;

                if (typeof data74 !== "string") {
                  const err215 = {
                    keyword: "type",
                    dataPath: dataPath + "/scopes/" + i6 + "/type",
                    schemaPath: "#/properties/scopes/items/properties/type/type",
                    params: {
                      type: "string"
                    },
                    message: "should be string"
                  };

                  if (vErrors === null) {
                    vErrors = [err215];
                  } else {
                    vErrors.push(err215);
                  }

                  errors++;
                }

                if (!(data74 === "camunda:Connector" || data74 === "bpmn:Error")) {
                  const err216 = {
                    keyword: "enum",
                    dataPath: dataPath + "/scopes/" + i6 + "/type",
                    schemaPath: "#/properties/scopes/items/properties/type/enum",
                    params: {
                      allowedValues: schema17$1.properties.scopes.items.properties.type.enum
                    },
                    message: "should be equal to one of the allowed values"
                  };

                  if (vErrors === null) {
                    vErrors = [err216];
                  } else {
                    vErrors.push(err216);
                  }

                  errors++;
                }

                if (errors > 0) {
                  const emErrs33 = [];

                  for (const err217 of vErrors) {
                    if (err217.keyword !== "errorMessage" && !err217.emUsed && (err217.dataPath === dataPath + "/scopes/" + i6 + "/type" || err217.dataPath.indexOf(dataPath + "/scopes/" + i6 + "/type") === 0 && err217.dataPath[dataPath + "/scopes/" + i6 + "/type".length] === "/") && err217.schemaPath.indexOf("#/properties/scopes/items/properties/type") === 0 && err217.schemaPath["#/properties/scopes/items/properties/type".length] === "/") {
                      emErrs33.push(err217);
                      err217.emUsed = true;
                    }
                  }

                  if (emErrs33.length) {
                    const err218 = {
                      keyword: "errorMessage",
                      dataPath: dataPath + "/scopes/" + i6 + "/type",
                      schemaPath: "#/properties/scopes/items/properties/type/errorMessage",
                      params: {
                        errors: emErrs33
                      },
                      message: "invalid scope type " + JSON.stringify(data74) + "; must be any of { camunda:Connector, bpmn:Error }"
                    };

                    if (vErrors === null) {
                      vErrors = [err218];
                    } else {
                      vErrors.push(err218);
                    }

                    errors++;
                  }

                  const emErrs34 = [];

                  for (const err219 of vErrors) {
                    if (!err219.emUsed) {
                      emErrs34.push(err219);
                    }
                  }

                  vErrors = emErrs34;
                  errors = emErrs34.length;
                }
              }

              if (data72.properties !== undefined) {
                let data75 = data72.properties;

                if (Array.isArray(data75)) {
                  const len7 = data75.length;

                  for (let i7 = 0; i7 < len7; i7++) {
                    let data76 = data75[i7];
                    const _errs224 = errors;
                    let valid91 = true;
                    const _errs225 = errors;

                    if (data76 && typeof data76 == "object" && !Array.isArray(data76)) {
                      if (data76.type === undefined && "type") {
                        const err220 = {};

                        if (vErrors === null) {
                          vErrors = [err220];
                        } else {
                          vErrors.push(err220);
                        }

                        errors++;
                      } else {
                        if (data76.type !== undefined) {
                          if (!func0$1(data76.type, "Dropdown")) {
                            const err221 = {};

                            if (vErrors === null) {
                              vErrors = [err221];
                            } else {
                              vErrors.push(err221);
                            }

                            errors++;
                          }
                        }
                      }
                    }

                    var _valid19 = _errs225 === errors;

                    errors = _errs224;

                    if (vErrors !== null) {
                      if (_errs224) {
                        vErrors.length = _errs224;
                      } else {
                        vErrors = null;
                      }
                    }

                    if (_valid19) {
                      const _errs227 = errors;

                      if (data76 && typeof data76 == "object" && !Array.isArray(data76)) {
                        if (data76.choices === undefined) {
                          const err222 = {
                            keyword: "required",
                            dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7,
                            schemaPath: "#/definitions/properties/allOf/0/items/allOf/0/then/required",
                            params: {
                              missingProperty: "choices"
                            },
                            message: "should have required property '" + "choices" + "'"
                          };

                          if (vErrors === null) {
                            vErrors = [err222];
                          } else {
                            vErrors.push(err222);
                          }

                          errors++;
                        }
                      }

                      if (errors > 0) {
                        const emErrs35 = [];

                        for (const err223 of vErrors) {
                          if (err223.keyword !== "errorMessage" && !err223.emUsed && (err223.dataPath === dataPath + "/scopes/" + i6 + "/properties/" + i7 || err223.dataPath.indexOf(dataPath + "/scopes/" + i6 + "/properties/" + i7) === 0 && err223.dataPath[dataPath + "/scopes/" + i6 + "/properties/" + i7.length] === "/") && err223.schemaPath.indexOf("#/definitions/properties/allOf/0/items/allOf/0/then") === 0 && err223.schemaPath["#/definitions/properties/allOf/0/items/allOf/0/then".length] === "/") {
                            emErrs35.push(err223);
                            err223.emUsed = true;
                          }
                        }

                        if (emErrs35.length) {
                          const err224 = {
                            keyword: "errorMessage",
                            dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7,
                            schemaPath: "#/definitions/properties/allOf/0/items/allOf/0/then/errorMessage",
                            params: {
                              errors: emErrs35
                            },
                            message: "must provide choices=[] with \"Dropdown\" type"
                          };

                          if (vErrors === null) {
                            vErrors = [err224];
                          } else {
                            vErrors.push(err224);
                          }

                          errors++;
                        }

                        const emErrs36 = [];

                        for (const err225 of vErrors) {
                          if (!err225.emUsed) {
                            emErrs36.push(err225);
                          }
                        }

                        vErrors = emErrs36;
                        errors = emErrs36.length;
                      }

                      var _valid19 = _errs227 === errors;

                      valid91 = _valid19;
                    }

                    if (!valid91) {
                      const err226 = {
                        keyword: "if",
                        dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7,
                        schemaPath: "#/definitions/properties/allOf/0/items/allOf/0/if",
                        params: {
                          failingKeyword: "then"
                        },
                        message: "should match \"then\" schema"
                      };

                      if (vErrors === null) {
                        vErrors = [err226];
                      } else {
                        vErrors.push(err226);
                      }

                      errors++;
                    }

                    if (data76 && typeof data76 == "object" && !Array.isArray(data76)) {
                      if (data76.id !== undefined) {
                        if (typeof data76.id !== "string") {
                          const err227 = {
                            keyword: "type",
                            dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/id",
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/id/type",
                            params: {
                              type: "string"
                            },
                            message: "should be string"
                          };

                          if (vErrors === null) {
                            vErrors = [err227];
                          } else {
                            vErrors.push(err227);
                          }

                          errors++;
                        }
                      }

                      if (data76.value !== undefined) {
                        let data79 = data76.value;

                        if (typeof data79 !== "string" && typeof data79 !== "boolean") {
                          const err228 = {
                            keyword: "type",
                            dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/value",
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/value/type",
                            params: {
                              type: schema19.items.properties.value.type
                            },
                            message: "should be string,boolean"
                          };

                          if (vErrors === null) {
                            vErrors = [err228];
                          } else {
                            vErrors.push(err228);
                          }

                          errors++;
                        }
                      }

                      if (data76.description !== undefined) {
                        if (typeof data76.description !== "string") {
                          const err229 = {
                            keyword: "type",
                            dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/description",
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/description/type",
                            params: {
                              type: "string"
                            },
                            message: "should be string"
                          };

                          if (vErrors === null) {
                            vErrors = [err229];
                          } else {
                            vErrors.push(err229);
                          }

                          errors++;
                        }
                      }

                      if (data76.label !== undefined) {
                        if (typeof data76.label !== "string") {
                          const err230 = {
                            keyword: "type",
                            dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/label",
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/label/type",
                            params: {
                              type: "string"
                            },
                            message: "should be string"
                          };

                          if (vErrors === null) {
                            vErrors = [err230];
                          } else {
                            vErrors.push(err230);
                          }

                          errors++;
                        }
                      }

                      if (data76.type !== undefined) {
                        if (typeof data76.type !== "string") {
                          const err231 = {
                            keyword: "type",
                            dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/type",
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/type/type",
                            params: {
                              type: "string"
                            },
                            message: "should be string"
                          };

                          if (vErrors === null) {
                            vErrors = [err231];
                          } else {
                            vErrors.push(err231);
                          }

                          errors++;
                        }
                      }

                      if (data76.editable !== undefined) {
                        if (typeof data76.editable !== "boolean") {
                          const err232 = {
                            keyword: "type",
                            dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/editable",
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/editable/type",
                            params: {
                              type: "boolean"
                            },
                            message: "should be boolean"
                          };

                          if (vErrors === null) {
                            vErrors = [err232];
                          } else {
                            vErrors.push(err232);
                          }

                          errors++;
                        }
                      }

                      if (data76.choices !== undefined) {
                        let data84 = data76.choices;

                        if (Array.isArray(data84)) {
                          const len8 = data84.length;

                          for (let i8 = 0; i8 < len8; i8++) {
                            let data85 = data84[i8];

                            if (data85 && typeof data85 == "object" && !Array.isArray(data85)) {
                              if (data85.value === undefined) {
                                const err233 = {
                                  keyword: "required",
                                  dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/choices/" + i8,
                                  schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/items/required",
                                  params: {
                                    missingProperty: "value"
                                  },
                                  message: "should have required property '" + "value" + "'"
                                };

                                if (vErrors === null) {
                                  vErrors = [err233];
                                } else {
                                  vErrors.push(err233);
                                }

                                errors++;
                              }

                              if (data85.name === undefined) {
                                const err234 = {
                                  keyword: "required",
                                  dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/choices/" + i8,
                                  schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/items/required",
                                  params: {
                                    missingProperty: "name"
                                  },
                                  message: "should have required property '" + "name" + "'"
                                };

                                if (vErrors === null) {
                                  vErrors = [err234];
                                } else {
                                  vErrors.push(err234);
                                }

                                errors++;
                              }

                              if (data85.name !== undefined) {
                                if (typeof data85.name !== "string") {
                                  const err235 = {
                                    keyword: "type",
                                    dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/choices/" + i8 + "/name",
                                    schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/items/properties/name/type",
                                    params: {
                                      type: "string"
                                    },
                                    message: "should be string"
                                  };

                                  if (vErrors === null) {
                                    vErrors = [err235];
                                  } else {
                                    vErrors.push(err235);
                                  }

                                  errors++;
                                }
                              }

                              if (data85.value !== undefined) {
                                if (typeof data85.value !== "string") {
                                  const err236 = {
                                    keyword: "type",
                                    dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/choices/" + i8 + "/value",
                                    schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/items/properties/value/type",
                                    params: {
                                      type: "string"
                                    },
                                    message: "should be string"
                                  };

                                  if (vErrors === null) {
                                    vErrors = [err236];
                                  } else {
                                    vErrors.push(err236);
                                  }

                                  errors++;
                                }
                              }
                            } else {
                              const err237 = {
                                keyword: "type",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/choices/" + i8,
                                schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/items/type",
                                params: {
                                  type: "object"
                                },
                                message: "should be object"
                              };

                              if (vErrors === null) {
                                vErrors = [err237];
                              } else {
                                vErrors.push(err237);
                              }

                              errors++;
                            }

                            if (errors > 0) {
                              const emErrors9 = {
                                "required": []
                              };
                              const templates9 = {};

                              for (const err238 of vErrors) {
                                if (err238.keyword !== "errorMessage" && !err238.emUsed && err238.dataPath === dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/choices/" + i8 && err238.keyword in emErrors9 && err238.schemaPath.indexOf("#/definitions/properties/allOf/0/items/properties/choices/items") === 0 && /^\/[^\/]*$/.test(err238.schemaPath.slice(63))) {
                                  emErrors9[err238.keyword].push(err238);
                                  err238.emUsed = true;
                                }
                              }

                              for (const key9 in emErrors9) {
                                if (emErrors9[key9].length) {
                                  const err239 = {
                                    keyword: "errorMessage",
                                    dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/choices/" + i8,
                                    schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/items/errorMessage",
                                    params: {
                                      errors: emErrors9[key9]
                                    },
                                    message: key9 in templates9 ? templates9[key9]() : schema19.items.properties.choices.items.errorMessage[key9]
                                  };

                                  if (vErrors === null) {
                                    vErrors = [err239];
                                  } else {
                                    vErrors.push(err239);
                                  }

                                  errors++;
                                }
                              }

                              const emErrs37 = [];

                              for (const err240 of vErrors) {
                                if (!err240.emUsed) {
                                  emErrs37.push(err240);
                                }
                              }

                              vErrors = emErrs37;
                              errors = emErrs37.length;
                            }
                          }
                        } else {
                          const err241 = {
                            keyword: "type",
                            dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/choices",
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/type",
                            params: {
                              type: "array"
                            },
                            message: "should be array"
                          };

                          if (vErrors === null) {
                            vErrors = [err241];
                          } else {
                            vErrors.push(err241);
                          }

                          errors++;
                        }
                      }

                      if (data76.constraints !== undefined) {
                        let data88 = data76.constraints;

                        if (data88 && typeof data88 == "object" && !Array.isArray(data88)) {
                          if (data88.notEmpty !== undefined) {
                            if (typeof data88.notEmpty !== "boolean") {
                              const err242 = {
                                keyword: "type",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/constraints/notEmpty",
                                schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/notEmpty/type",
                                params: {
                                  type: "boolean"
                                },
                                message: "should be boolean"
                              };

                              if (vErrors === null) {
                                vErrors = [err242];
                              } else {
                                vErrors.push(err242);
                              }

                              errors++;
                            }
                          }

                          if (data88.minLength !== undefined) {
                            if (!(typeof data88.minLength == "number")) {
                              const err243 = {
                                keyword: "type",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/constraints/minLength",
                                schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/minLength/type",
                                params: {
                                  type: "number"
                                },
                                message: "should be number"
                              };

                              if (vErrors === null) {
                                vErrors = [err243];
                              } else {
                                vErrors.push(err243);
                              }

                              errors++;
                            }
                          }

                          if (data88.maxLength !== undefined) {
                            if (!(typeof data88.maxLength == "number")) {
                              const err244 = {
                                keyword: "type",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/constraints/maxLength",
                                schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/maxLength/type",
                                params: {
                                  type: "number"
                                },
                                message: "should be number"
                              };

                              if (vErrors === null) {
                                vErrors = [err244];
                              } else {
                                vErrors.push(err244);
                              }

                              errors++;
                            }
                          }

                          if (data88.pattern !== undefined) {
                            let data92 = data88.pattern;
                            const _errs257 = errors;
                            let valid99 = false;
                            let passing4 = null;
                            const _errs258 = errors;

                            if (data92 && typeof data92 == "object" && !Array.isArray(data92)) {
                              if (data92.value !== undefined) {
                                if (typeof data92.value !== "string") {
                                  const err245 = {
                                    keyword: "type",
                                    dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/constraints/pattern/value",
                                    schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/pattern/oneOf/0/properties/value/type",
                                    params: {
                                      type: "string"
                                    },
                                    message: "should be string"
                                  };

                                  if (vErrors === null) {
                                    vErrors = [err245];
                                  } else {
                                    vErrors.push(err245);
                                  }

                                  errors++;
                                }
                              }

                              if (data92.message !== undefined) {
                                if (typeof data92.message !== "string") {
                                  const err246 = {
                                    keyword: "type",
                                    dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/constraints/pattern/message",
                                    schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/pattern/oneOf/0/properties/message/type",
                                    params: {
                                      type: "string"
                                    },
                                    message: "should be string"
                                  };

                                  if (vErrors === null) {
                                    vErrors = [err246];
                                  } else {
                                    vErrors.push(err246);
                                  }

                                  errors++;
                                }
                              }
                            } else {
                              const err247 = {
                                keyword: "type",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/constraints/pattern",
                                schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/pattern/oneOf/0/type",
                                params: {
                                  type: "object"
                                },
                                message: "should be object"
                              };

                              if (vErrors === null) {
                                vErrors = [err247];
                              } else {
                                vErrors.push(err247);
                              }

                              errors++;
                            }

                            var _valid20 = _errs258 === errors;

                            if (_valid20) {
                              valid99 = true;
                              passing4 = 0;
                            }

                            const _errs264 = errors;

                            if (typeof data92 !== "string") {
                              const err248 = {
                                keyword: "type",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/constraints/pattern",
                                schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/pattern/oneOf/1/type",
                                params: {
                                  type: "string"
                                },
                                message: "should be string"
                              };

                              if (vErrors === null) {
                                vErrors = [err248];
                              } else {
                                vErrors.push(err248);
                              }

                              errors++;
                            }

                            var _valid20 = _errs264 === errors;

                            if (_valid20 && valid99) {
                              valid99 = false;
                              passing4 = [passing4, 1];
                            } else {
                              if (_valid20) {
                                valid99 = true;
                                passing4 = 1;
                              }
                            }

                            if (!valid99) {
                              const err249 = {
                                keyword: "oneOf",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/constraints/pattern",
                                schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/pattern/oneOf",
                                params: {
                                  passingSchemas: passing4
                                },
                                message: "should match exactly one schema in oneOf"
                              };

                              if (vErrors === null) {
                                vErrors = [err249];
                              } else {
                                vErrors.push(err249);
                              }

                              errors++;
                            } else {
                              errors = _errs257;

                              if (vErrors !== null) {
                                if (_errs257) {
                                  vErrors.length = _errs257;
                                } else {
                                  vErrors = null;
                                }
                              }
                            }
                          }
                        } else {
                          const err250 = {
                            keyword: "type",
                            dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/constraints",
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/type",
                            params: {
                              type: "object"
                            },
                            message: "should be object"
                          };

                          if (vErrors === null) {
                            vErrors = [err250];
                          } else {
                            vErrors.push(err250);
                          }

                          errors++;
                        }
                      }

                      if (data76.group !== undefined) {
                        if (typeof data76.group !== "string") {
                          const err251 = {
                            keyword: "type",
                            dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/group",
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/group/type",
                            params: {
                              type: "string"
                            },
                            message: "should be string"
                          };

                          if (vErrors === null) {
                            vErrors = [err251];
                          } else {
                            vErrors.push(err251);
                          }

                          errors++;
                        }
                      }

                      if (data76.condition !== undefined) {
                        let data96 = data76.condition;
                        const _errs270 = errors;
                        let valid101 = false;
                        let passing5 = null;
                        const _errs271 = errors;

                        if (data96 && typeof data96 == "object" && !Array.isArray(data96)) {
                          if (data96.equals === undefined) {
                            const err252 = {
                              keyword: "required",
                              dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/condition",
                              schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/oneOf/0/required",
                              params: {
                                missingProperty: "equals"
                              },
                              message: "should have required property '" + "equals" + "'"
                            };

                            if (vErrors === null) {
                              vErrors = [err252];
                            } else {
                              vErrors.push(err252);
                            }

                            errors++;
                          }

                          if (data96.equals !== undefined) {
                            let data97 = data96.equals;

                            if (typeof data97 !== "string" && !(typeof data97 == "number") && typeof data97 !== "boolean") {
                              const err253 = {
                                keyword: "type",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/condition/equals",
                                schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/oneOf/0/properties/equals/type",
                                params: {
                                  type: schema19.items.properties.condition.oneOf[0].properties.equals.type
                                },
                                message: "should be string,number,boolean"
                              };

                              if (vErrors === null) {
                                vErrors = [err253];
                              } else {
                                vErrors.push(err253);
                              }

                              errors++;
                            }
                          }
                        }

                        var _valid21 = _errs271 === errors;

                        if (_valid21) {
                          valid101 = true;
                          passing5 = 0;
                        }

                        const _errs274 = errors;

                        if (data96 && typeof data96 == "object" && !Array.isArray(data96)) {
                          if (data96.oneOf === undefined) {
                            const err254 = {
                              keyword: "required",
                              dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/condition",
                              schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/oneOf/1/required",
                              params: {
                                missingProperty: "oneOf"
                              },
                              message: "should have required property '" + "oneOf" + "'"
                            };

                            if (vErrors === null) {
                              vErrors = [err254];
                            } else {
                              vErrors.push(err254);
                            }

                            errors++;
                          }

                          if (data96.oneOf !== undefined) {
                            let data98 = data96.oneOf;

                            if (Array.isArray(data98)) {
                              const len9 = data98.length;

                              for (let i9 = 0; i9 < len9; i9++) {
                                let data99 = data98[i9];

                                if (typeof data99 !== "string" && !(typeof data99 == "number")) {
                                  const err255 = {
                                    keyword: "type",
                                    dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/condition/oneOf/" + i9,
                                    schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/oneOf/1/properties/oneOf/items/type",
                                    params: {
                                      type: schema19.items.properties.condition.oneOf[1].properties.oneOf.items.type
                                    },
                                    message: "should be string,number"
                                  };

                                  if (vErrors === null) {
                                    vErrors = [err255];
                                  } else {
                                    vErrors.push(err255);
                                  }

                                  errors++;
                                }
                              }
                            } else {
                              const err256 = {
                                keyword: "type",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/condition/oneOf",
                                schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/oneOf/1/properties/oneOf/type",
                                params: {
                                  type: "array"
                                },
                                message: "should be array"
                              };

                              if (vErrors === null) {
                                vErrors = [err256];
                              } else {
                                vErrors.push(err256);
                              }

                              errors++;
                            }
                          }
                        }

                        var _valid21 = _errs274 === errors;

                        if (_valid21 && valid101) {
                          valid101 = false;
                          passing5 = [passing5, 1];
                        } else {
                          if (_valid21) {
                            valid101 = true;
                            passing5 = 1;
                          }
                        }

                        if (!valid101) {
                          const err257 = {
                            keyword: "oneOf",
                            dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/condition",
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/oneOf",
                            params: {
                              passingSchemas: passing5
                            },
                            message: "should match exactly one schema in oneOf"
                          };

                          if (vErrors === null) {
                            vErrors = [err257];
                          } else {
                            vErrors.push(err257);
                          }

                          errors++;
                        } else {
                          errors = _errs270;

                          if (vErrors !== null) {
                            if (_errs270) {
                              vErrors.length = _errs270;
                            } else {
                              vErrors = null;
                            }
                          }
                        }

                        if (data96 && typeof data96 == "object" && !Array.isArray(data96)) {
                          if (data96.property === undefined) {
                            const err258 = {
                              keyword: "required",
                              dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/condition",
                              schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/required",
                              params: {
                                missingProperty: "property"
                              },
                              message: "should have required property '" + "property" + "'"
                            };

                            if (vErrors === null) {
                              vErrors = [err258];
                            } else {
                              vErrors.push(err258);
                            }

                            errors++;
                          }

                          if (data96.type !== undefined) {
                            if (!func0$1(data96.type, "simple")) {
                              const err259 = {
                                keyword: "const",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/condition/type",
                                schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/properties/type/const",
                                params: {
                                  allowedValue: "simple"
                                },
                                message: "should be equal to constant"
                              };

                              if (vErrors === null) {
                                vErrors = [err259];
                              } else {
                                vErrors.push(err259);
                              }

                              errors++;
                            }
                          }

                          if (data96.property !== undefined) {
                            if (typeof data96.property !== "string") {
                              const err260 = {
                                keyword: "type",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/condition/property",
                                schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/properties/property/type",
                                params: {
                                  type: "string"
                                },
                                message: "should be string"
                              };

                              if (vErrors === null) {
                                vErrors = [err260];
                              } else {
                                vErrors.push(err260);
                              }

                              errors++;
                            }
                          }
                        } else {
                          const err261 = {
                            keyword: "type",
                            dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/condition",
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/type",
                            params: {
                              type: "object"
                            },
                            message: "should be object"
                          };

                          if (vErrors === null) {
                            vErrors = [err261];
                          } else {
                            vErrors.push(err261);
                          }

                          errors++;
                        }

                        if (errors > 0) {
                          const emErrors10 = {
                            "required": {
                              "property": []
                            }
                          };
                          const templates10 = {
                            required: {}
                          };
                          let emPropParams4;
                          let emParamsErrors4;

                          for (const err262 of vErrors) {
                            if (err262.keyword !== "errorMessage" && !err262.emUsed && err262.dataPath === dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/condition" && err262.keyword in emErrors10 && err262.schemaPath.indexOf("#/definitions/properties/allOf/0/items/properties/condition") === 0 && /^\/[^\/]*$/.test(err262.schemaPath.slice(59))) {
                              emPropParams4 = obj0$1[err262.keyword];
                              emParamsErrors4 = emErrors10[err262.keyword][err262.params[emPropParams4]];

                              if (emParamsErrors4) {
                                emParamsErrors4.push(err262);
                                err262.emUsed = true;
                              }
                            }
                          }

                          for (const key10 in emErrors10) {
                            for (const keyProp4 in emErrors10[key10]) {
                              emParamsErrors4 = emErrors10[key10][keyProp4];

                              if (emParamsErrors4.length) {
                                const tmpl4 = templates10[key10] && templates10[key10][keyProp4];
                                const err263 = {
                                  keyword: "errorMessage",
                                  dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7 + "/condition",
                                  schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/errorMessage",
                                  params: {
                                    errors: emParamsErrors4
                                  },
                                  message: tmpl4 ? tmpl4() : schema19.items.properties.condition.errorMessage[key10][keyProp4]
                                };

                                if (vErrors === null) {
                                  vErrors = [err263];
                                } else {
                                  vErrors.push(err263);
                                }

                                errors++;
                              }
                            }
                          }

                          const emErrs38 = [];

                          for (const err264 of vErrors) {
                            if (!err264.emUsed) {
                              emErrs38.push(err264);
                            }
                          }

                          vErrors = emErrs38;
                          errors = emErrs38.length;
                        }
                      }
                    } else {
                      const err265 = {
                        keyword: "type",
                        dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i7,
                        schemaPath: "#/definitions/properties/allOf/0/items/type",
                        params: {
                          type: "object"
                        },
                        message: "should be object"
                      };

                      if (vErrors === null) {
                        vErrors = [err265];
                      } else {
                        vErrors.push(err265);
                      }

                      errors++;
                    }
                  }
                } else {
                  const err266 = {
                    keyword: "type",
                    dataPath: dataPath + "/scopes/" + i6 + "/properties",
                    schemaPath: "#/definitions/properties/allOf/0/type",
                    params: {
                      type: "array"
                    },
                    message: "should be array"
                  };

                  if (vErrors === null) {
                    vErrors = [err266];
                  } else {
                    vErrors.push(err266);
                  }

                  errors++;
                }

                if (Array.isArray(data75)) {
                  const len10 = data75.length;

                  for (let i10 = 0; i10 < len10; i10++) {
                    let data102 = data75[i10];
                    const _errs288 = errors;
                    let valid112 = true;
                    const _errs289 = errors;

                    if (data102 && typeof data102 == "object" && !Array.isArray(data102)) {
                      if (data102.binding === undefined && "binding") {
                        const err267 = {};

                        if (vErrors === null) {
                          vErrors = [err267];
                        } else {
                          vErrors.push(err267);
                        }

                        errors++;
                      } else {
                        if (data102.binding !== undefined) {
                          let data103 = data102.binding;

                          if (data103 && typeof data103 == "object" && !Array.isArray(data103)) {
                            if (data103.type === undefined && "type") {
                              const err268 = {};

                              if (vErrors === null) {
                                vErrors = [err268];
                              } else {
                                vErrors.push(err268);
                              }

                              errors++;
                            } else {
                              if (data103.type !== undefined) {
                                if (!func0$1(data103.type, "property")) {
                                  const err269 = {};

                                  if (vErrors === null) {
                                    vErrors = [err269];
                                  } else {
                                    vErrors.push(err269);
                                  }

                                  errors++;
                                }
                              }
                            }
                          }
                        }
                      }
                    }

                    var _valid22 = _errs289 === errors;

                    errors = _errs288;

                    if (vErrors !== null) {
                      if (_errs288) {
                        vErrors.length = _errs288;
                      } else {
                        vErrors = null;
                      }
                    }

                    if (_valid22) {
                      const _errs292 = errors;

                      if (data102 && typeof data102 == "object" && !Array.isArray(data102)) {
                        if (data102.type !== undefined) {
                          let data105 = data102.type;

                          if (!(data105 === "String" || data105 === "Text" || data105 === "Hidden" || data105 === "Dropdown" || data105 === "Boolean")) {
                            const err270 = {
                              keyword: "enum",
                              dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/type",
                              schemaPath: "#/definitions/properties/allOf/1/items/allOf/0/then/properties/type/enum",
                              params: {
                                allowedValues: schema20.items.allOf[0].then.properties.type.enum
                              },
                              message: "should be equal to one of the allowed values"
                            };

                            if (vErrors === null) {
                              vErrors = [err270];
                            } else {
                              vErrors.push(err270);
                            }

                            errors++;
                          }

                          if (errors > 0) {
                            const emErrs39 = [];

                            for (const err271 of vErrors) {
                              if (err271.keyword !== "errorMessage" && !err271.emUsed && (err271.dataPath === dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/type" || err271.dataPath.indexOf(dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/type") === 0 && err271.dataPath[dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/type".length] === "/") && err271.schemaPath.indexOf("#/definitions/properties/allOf/1/items/allOf/0/then/properties/type") === 0 && err271.schemaPath["#/definitions/properties/allOf/1/items/allOf/0/then/properties/type".length] === "/") {
                                emErrs39.push(err271);
                                err271.emUsed = true;
                              }
                            }

                            if (emErrs39.length) {
                              const err272 = {
                                keyword: "errorMessage",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/type",
                                schemaPath: "#/definitions/properties/allOf/1/items/allOf/0/then/properties/type/errorMessage",
                                params: {
                                  errors: emErrs39
                                },
                                message: "invalid property type " + JSON.stringify(data105) + " for binding type \"property\"; must be any of { String, Text, Hidden, Dropdown, Boolean }"
                              };

                              if (vErrors === null) {
                                vErrors = [err272];
                              } else {
                                vErrors.push(err272);
                              }

                              errors++;
                            }

                            const emErrs40 = [];

                            for (const err273 of vErrors) {
                              if (!err273.emUsed) {
                                emErrs40.push(err273);
                              }
                            }

                            vErrors = emErrs40;
                            errors = emErrs40.length;
                          }
                        }
                      }

                      var _valid22 = _errs292 === errors;

                      valid112 = _valid22;
                    }

                    if (!valid112) {
                      const err274 = {
                        keyword: "if",
                        dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10,
                        schemaPath: "#/definitions/properties/allOf/1/items/allOf/0/if",
                        params: {
                          failingKeyword: "then"
                        },
                        message: "should match \"then\" schema"
                      };

                      if (vErrors === null) {
                        vErrors = [err274];
                      } else {
                        vErrors.push(err274);
                      }

                      errors++;
                    }

                    const _errs295 = errors;
                    let valid116 = true;
                    const _errs296 = errors;

                    if (data102 && typeof data102 == "object" && !Array.isArray(data102)) {
                      if (data102.binding === undefined && "binding") {
                        const err275 = {};

                        if (vErrors === null) {
                          vErrors = [err275];
                        } else {
                          vErrors.push(err275);
                        }

                        errors++;
                      } else {
                        if (data102.binding !== undefined) {
                          let data106 = data102.binding;

                          if (data106 && typeof data106 == "object" && !Array.isArray(data106)) {
                            if (data106.type === undefined && "type") {
                              const err276 = {};

                              if (vErrors === null) {
                                vErrors = [err276];
                              } else {
                                vErrors.push(err276);
                              }

                              errors++;
                            } else {
                              if (data106.type !== undefined) {
                                if (!func0$1(data106.type, "camunda:executionListener")) {
                                  const err277 = {};

                                  if (vErrors === null) {
                                    vErrors = [err277];
                                  } else {
                                    vErrors.push(err277);
                                  }

                                  errors++;
                                }
                              }
                            }
                          }
                        }
                      }
                    }

                    var _valid23 = _errs296 === errors;

                    errors = _errs295;

                    if (vErrors !== null) {
                      if (_errs295) {
                        vErrors.length = _errs295;
                      } else {
                        vErrors = null;
                      }
                    }

                    if (_valid23) {
                      const _errs299 = errors;

                      if (data102 && typeof data102 == "object" && !Array.isArray(data102)) {
                        if (data102.type !== undefined) {
                          if (!(data102.type === "Hidden")) {
                            const err278 = {
                              keyword: "enum",
                              dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/type",
                              schemaPath: "#/definitions/properties/allOf/1/items/allOf/1/then/properties/type/enum",
                              params: {
                                allowedValues: schema20.items.allOf[1].then.properties.type.enum
                              },
                              message: "should be equal to one of the allowed values"
                            };

                            if (vErrors === null) {
                              vErrors = [err278];
                            } else {
                              vErrors.push(err278);
                            }

                            errors++;
                          }

                          if (errors > 0) {
                            const emErrs41 = [];

                            for (const err279 of vErrors) {
                              if (err279.keyword !== "errorMessage" && !err279.emUsed && (err279.dataPath === dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/type" || err279.dataPath.indexOf(dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/type") === 0 && err279.dataPath[dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/type".length] === "/") && err279.schemaPath.indexOf("#/definitions/properties/allOf/1/items/allOf/1/then/properties/type") === 0 && err279.schemaPath["#/definitions/properties/allOf/1/items/allOf/1/then/properties/type".length] === "/") {
                                emErrs41.push(err279);
                                err279.emUsed = true;
                              }
                            }

                            if (emErrs41.length) {
                              const err280 = {
                                keyword: "errorMessage",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/type",
                                schemaPath: "#/definitions/properties/allOf/1/items/allOf/1/then/properties/type/errorMessage",
                                params: {
                                  errors: emErrs41
                                },
                                message: "invalid property type " + JSON.stringify(data102 && data102.type) + " for binding type \"camunda:executionListener\"; must be \"Hidden\""
                              };

                              if (vErrors === null) {
                                vErrors = [err280];
                              } else {
                                vErrors.push(err280);
                              }

                              errors++;
                            }

                            const emErrs42 = [];

                            for (const err281 of vErrors) {
                              if (!err281.emUsed) {
                                emErrs42.push(err281);
                              }
                            }

                            vErrors = emErrs42;
                            errors = emErrs42.length;
                          }
                        }
                      }

                      var _valid23 = _errs299 === errors;

                      valid116 = _valid23;
                    }

                    if (!valid116) {
                      const err282 = {
                        keyword: "if",
                        dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10,
                        schemaPath: "#/definitions/properties/allOf/1/items/allOf/1/if",
                        params: {
                          failingKeyword: "then"
                        },
                        message: "should match \"then\" schema"
                      };

                      if (vErrors === null) {
                        vErrors = [err282];
                      } else {
                        vErrors.push(err282);
                      }

                      errors++;
                    }

                    const _errs302 = errors;
                    let valid120 = true;
                    const _errs303 = errors;

                    if (data102 && typeof data102 == "object" && !Array.isArray(data102)) {
                      if (data102.binding === undefined && "binding") {
                        const err283 = {};

                        if (vErrors === null) {
                          vErrors = [err283];
                        } else {
                          vErrors.push(err283);
                        }

                        errors++;
                      } else {
                        if (data102.binding !== undefined) {
                          let data109 = data102.binding;

                          if (data109 && typeof data109 == "object" && !Array.isArray(data109)) {
                            if (data109.type === undefined && "type") {
                              const err284 = {};

                              if (vErrors === null) {
                                vErrors = [err284];
                              } else {
                                vErrors.push(err284);
                              }

                              errors++;
                            } else {
                              if (data109.type !== undefined) {
                                let data110 = data109.type;

                                if (!(data110 === "camunda:property" || data110 === "camunda:outputParameter" || data110 === "camunda:in" || data110 === "camunda:in:businessKey" || data110 === "camunda:out" || data110 === "camunda:errorEventDefinition")) {
                                  const err285 = {};

                                  if (vErrors === null) {
                                    vErrors = [err285];
                                  } else {
                                    vErrors.push(err285);
                                  }

                                  errors++;
                                }
                              }
                            }
                          }
                        }
                      }
                    }

                    var _valid24 = _errs303 === errors;

                    errors = _errs302;

                    if (vErrors !== null) {
                      if (_errs302) {
                        vErrors.length = _errs302;
                      } else {
                        vErrors = null;
                      }
                    }

                    if (_valid24) {
                      const _errs306 = errors;

                      if (data102 && typeof data102 == "object" && !Array.isArray(data102)) {
                        if (data102.type !== undefined) {
                          let data111 = data102.type;

                          if (!(data111 === "String" || data111 === "Hidden" || data111 === "Dropdown")) {
                            const err286 = {
                              keyword: "enum",
                              dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/type",
                              schemaPath: "#/definitions/properties/allOf/1/items/allOf/2/then/properties/type/enum",
                              params: {
                                allowedValues: schema20.items.allOf[2].then.properties.type.enum
                              },
                              message: "should be equal to one of the allowed values"
                            };

                            if (vErrors === null) {
                              vErrors = [err286];
                            } else {
                              vErrors.push(err286);
                            }

                            errors++;
                          }

                          if (errors > 0) {
                            const emErrs43 = [];

                            for (const err287 of vErrors) {
                              if (err287.keyword !== "errorMessage" && !err287.emUsed && (err287.dataPath === dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/type" || err287.dataPath.indexOf(dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/type") === 0 && err287.dataPath[dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/type".length] === "/") && err287.schemaPath.indexOf("#/definitions/properties/allOf/1/items/allOf/2/then/properties/type") === 0 && err287.schemaPath["#/definitions/properties/allOf/1/items/allOf/2/then/properties/type".length] === "/") {
                                emErrs43.push(err287);
                                err287.emUsed = true;
                              }
                            }

                            if (emErrs43.length) {
                              const err288 = {
                                keyword: "errorMessage",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/type",
                                schemaPath: "#/definitions/properties/allOf/1/items/allOf/2/then/properties/type/errorMessage",
                                params: {
                                  errors: emErrs43
                                },
                                message: "invalid property type " + JSON.stringify(data111) + " for binding type " + JSON.stringify(data102 && data102.binding && data102.binding.type) + "; must be any of { String, Hidden, Dropdown }"
                              };

                              if (vErrors === null) {
                                vErrors = [err288];
                              } else {
                                vErrors.push(err288);
                              }

                              errors++;
                            }

                            const emErrs44 = [];

                            for (const err289 of vErrors) {
                              if (!err289.emUsed) {
                                emErrs44.push(err289);
                              }
                            }

                            vErrors = emErrs44;
                            errors = emErrs44.length;
                          }
                        }
                      }

                      var _valid24 = _errs306 === errors;

                      valid120 = _valid24;
                    }

                    if (!valid120) {
                      const err290 = {
                        keyword: "if",
                        dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10,
                        schemaPath: "#/definitions/properties/allOf/1/items/allOf/2/if",
                        params: {
                          failingKeyword: "then"
                        },
                        message: "should match \"then\" schema"
                      };

                      if (vErrors === null) {
                        vErrors = [err290];
                      } else {
                        vErrors.push(err290);
                      }

                      errors++;
                    }

                    const _errs309 = errors;
                    let valid124 = true;
                    const _errs310 = errors;

                    if (data102 && typeof data102 == "object" && !Array.isArray(data102)) {
                      if (data102.binding === undefined && "binding") {
                        const err291 = {};

                        if (vErrors === null) {
                          vErrors = [err291];
                        } else {
                          vErrors.push(err291);
                        }

                        errors++;
                      } else {
                        if (data102.binding !== undefined) {
                          let data112 = data102.binding;

                          if (data112 && typeof data112 == "object" && !Array.isArray(data112)) {
                            if (data112.type === undefined && "type") {
                              const err292 = {};

                              if (vErrors === null) {
                                vErrors = [err292];
                              } else {
                                vErrors.push(err292);
                              }

                              errors++;
                            } else {
                              if (data112.type !== undefined) {
                                let data113 = data112.type;

                                if (!(data113 === "camunda:inputParameter" || data113 === "camunda:field")) {
                                  const err293 = {};

                                  if (vErrors === null) {
                                    vErrors = [err293];
                                  } else {
                                    vErrors.push(err293);
                                  }

                                  errors++;
                                }
                              }
                            }
                          }
                        }
                      }
                    }

                    var _valid25 = _errs310 === errors;

                    errors = _errs309;

                    if (vErrors !== null) {
                      if (_errs309) {
                        vErrors.length = _errs309;
                      } else {
                        vErrors = null;
                      }
                    }

                    if (_valid25) {
                      const _errs313 = errors;

                      if (data102 && typeof data102 == "object" && !Array.isArray(data102)) {
                        if (data102.type !== undefined) {
                          let data114 = data102.type;

                          if (!(data114 === "String" || data114 === "Text" || data114 === "Hidden" || data114 === "Dropdown")) {
                            const err294 = {
                              keyword: "enum",
                              dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/type",
                              schemaPath: "#/definitions/properties/allOf/1/items/allOf/3/then/properties/type/enum",
                              params: {
                                allowedValues: schema20.items.allOf[3].then.properties.type.enum
                              },
                              message: "should be equal to one of the allowed values"
                            };

                            if (vErrors === null) {
                              vErrors = [err294];
                            } else {
                              vErrors.push(err294);
                            }

                            errors++;
                          }

                          if (errors > 0) {
                            const emErrs45 = [];

                            for (const err295 of vErrors) {
                              if (err295.keyword !== "errorMessage" && !err295.emUsed && (err295.dataPath === dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/type" || err295.dataPath.indexOf(dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/type") === 0 && err295.dataPath[dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/type".length] === "/") && err295.schemaPath.indexOf("#/definitions/properties/allOf/1/items/allOf/3/then/properties/type") === 0 && err295.schemaPath["#/definitions/properties/allOf/1/items/allOf/3/then/properties/type".length] === "/") {
                                emErrs45.push(err295);
                                err295.emUsed = true;
                              }
                            }

                            if (emErrs45.length) {
                              const err296 = {
                                keyword: "errorMessage",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/type",
                                schemaPath: "#/definitions/properties/allOf/1/items/allOf/3/then/properties/type/errorMessage",
                                params: {
                                  errors: emErrs45
                                },
                                message: "invalid property type " + JSON.stringify(data114) + " for binding type " + JSON.stringify(data102 && data102.binding && data102.binding.type) + "; must be any of { String, Text, Hidden, Dropdown }"
                              };

                              if (vErrors === null) {
                                vErrors = [err296];
                              } else {
                                vErrors.push(err296);
                              }

                              errors++;
                            }

                            const emErrs46 = [];

                            for (const err297 of vErrors) {
                              if (!err297.emUsed) {
                                emErrs46.push(err297);
                              }
                            }

                            vErrors = emErrs46;
                            errors = emErrs46.length;
                          }
                        }
                      }

                      var _valid25 = _errs313 === errors;

                      valid124 = _valid25;
                    }

                    if (!valid124) {
                      const err298 = {
                        keyword: "if",
                        dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10,
                        schemaPath: "#/definitions/properties/allOf/1/items/allOf/3/if",
                        params: {
                          failingKeyword: "then"
                        },
                        message: "should match \"then\" schema"
                      };

                      if (vErrors === null) {
                        vErrors = [err298];
                      } else {
                        vErrors.push(err298);
                      }

                      errors++;
                    }

                    if (data102 && typeof data102 == "object" && !Array.isArray(data102)) {
                      if (data102.binding === undefined) {
                        const err299 = {
                          keyword: "required",
                          dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10,
                          schemaPath: "#/definitions/properties/allOf/1/items/required",
                          params: {
                            missingProperty: "binding"
                          },
                          message: "should have required property '" + "binding" + "'"
                        };

                        if (vErrors === null) {
                          vErrors = [err299];
                        } else {
                          vErrors.push(err299);
                        }

                        errors++;
                      }

                      if (data102.binding !== undefined) {
                        let data115 = data102.binding;
                        const _errs318 = errors;
                        let valid130 = true;
                        const _errs319 = errors;

                        if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                          if (data115.type === undefined && "type") {
                            const err300 = {};

                            if (vErrors === null) {
                              vErrors = [err300];
                            } else {
                              vErrors.push(err300);
                            }

                            errors++;
                          } else {
                            if (data115.type !== undefined) {
                              let data116 = data115.type;

                              if (!(data116 === "property" || data116 === "camunda:property" || data116 === "camunda:inputParameter" || data116 === "camunda:field")) {
                                const err301 = {};

                                if (vErrors === null) {
                                  vErrors = [err301];
                                } else {
                                  vErrors.push(err301);
                                }

                                errors++;
                              }
                            }
                          }
                        }

                        var _valid26 = _errs319 === errors;

                        errors = _errs318;

                        if (vErrors !== null) {
                          if (_errs318) {
                            vErrors.length = _errs318;
                          } else {
                            vErrors = null;
                          }
                        }

                        if (_valid26) {
                          const _errs321 = errors;

                          if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                            if (data115.name === undefined) {
                              const err302 = {
                                keyword: "required",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/0/then/required",
                                params: {
                                  missingProperty: "name"
                                },
                                message: "should have required property '" + "name" + "'"
                              };

                              if (vErrors === null) {
                                vErrors = [err302];
                              } else {
                                vErrors.push(err302);
                              }

                              errors++;
                            }
                          }

                          if (errors > 0) {
                            const emErrs47 = [];

                            for (const err303 of vErrors) {
                              if (err303.keyword !== "errorMessage" && !err303.emUsed && (err303.dataPath === dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding" || err303.dataPath.indexOf(dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding") === 0 && err303.dataPath[dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding".length] === "/") && err303.schemaPath.indexOf("#/definitions/properties/allOf/1/items/properties/binding/allOf/0/then") === 0 && err303.schemaPath["#/definitions/properties/allOf/1/items/properties/binding/allOf/0/then".length] === "/") {
                                emErrs47.push(err303);
                                err303.emUsed = true;
                              }
                            }

                            if (emErrs47.length) {
                              const err304 = {
                                keyword: "errorMessage",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/0/then/errorMessage",
                                params: {
                                  errors: emErrs47
                                },
                                message: "property.binding " + JSON.stringify(data115 && data115.type) + " requires name"
                              };

                              if (vErrors === null) {
                                vErrors = [err304];
                              } else {
                                vErrors.push(err304);
                              }

                              errors++;
                            }

                            const emErrs48 = [];

                            for (const err305 of vErrors) {
                              if (!err305.emUsed) {
                                emErrs48.push(err305);
                              }
                            }

                            vErrors = emErrs48;
                            errors = emErrs48.length;
                          }

                          var _valid26 = _errs321 === errors;

                          valid130 = _valid26;
                        }

                        if (!valid130) {
                          const err306 = {
                            keyword: "if",
                            dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                            schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/0/if",
                            params: {
                              failingKeyword: "then"
                            },
                            message: "should match \"then\" schema"
                          };

                          if (vErrors === null) {
                            vErrors = [err306];
                          } else {
                            vErrors.push(err306);
                          }

                          errors++;
                        }

                        const _errs323 = errors;
                        let valid132 = true;
                        const _errs324 = errors;

                        if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                          if (data115.type === undefined && "type") {
                            const err307 = {};

                            if (vErrors === null) {
                              vErrors = [err307];
                            } else {
                              vErrors.push(err307);
                            }

                            errors++;
                          } else {
                            if (data115.type !== undefined) {
                              if (!func0$1(data115.type, "camunda:outputParameter")) {
                                const err308 = {};

                                if (vErrors === null) {
                                  vErrors = [err308];
                                } else {
                                  vErrors.push(err308);
                                }

                                errors++;
                              }
                            }
                          }
                        }

                        var _valid27 = _errs324 === errors;

                        errors = _errs323;

                        if (vErrors !== null) {
                          if (_errs323) {
                            vErrors.length = _errs323;
                          } else {
                            vErrors = null;
                          }
                        }

                        if (_valid27) {
                          const _errs326 = errors;

                          if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                            if (data115.source === undefined) {
                              const err309 = {
                                keyword: "required",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/1/then/required",
                                params: {
                                  missingProperty: "source"
                                },
                                message: "should have required property '" + "source" + "'"
                              };

                              if (vErrors === null) {
                                vErrors = [err309];
                              } else {
                                vErrors.push(err309);
                              }

                              errors++;
                            }
                          }

                          if (errors > 0) {
                            const emErrs49 = [];

                            for (const err310 of vErrors) {
                              if (err310.keyword !== "errorMessage" && !err310.emUsed && (err310.dataPath === dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding" || err310.dataPath.indexOf(dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding") === 0 && err310.dataPath[dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding".length] === "/") && err310.schemaPath.indexOf("#/definitions/properties/allOf/1/items/properties/binding/allOf/1/then") === 0 && err310.schemaPath["#/definitions/properties/allOf/1/items/properties/binding/allOf/1/then".length] === "/") {
                                emErrs49.push(err310);
                                err310.emUsed = true;
                              }
                            }

                            if (emErrs49.length) {
                              const err311 = {
                                keyword: "errorMessage",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/1/then/errorMessage",
                                params: {
                                  errors: emErrs49
                                },
                                message: "property.binding " + JSON.stringify(data115 && data115.type) + " requires source"
                              };

                              if (vErrors === null) {
                                vErrors = [err311];
                              } else {
                                vErrors.push(err311);
                              }

                              errors++;
                            }

                            const emErrs50 = [];

                            for (const err312 of vErrors) {
                              if (!err312.emUsed) {
                                emErrs50.push(err312);
                              }
                            }

                            vErrors = emErrs50;
                            errors = emErrs50.length;
                          }

                          var _valid27 = _errs326 === errors;

                          valid132 = _valid27;
                        }

                        if (!valid132) {
                          const err313 = {
                            keyword: "if",
                            dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                            schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/1/if",
                            params: {
                              failingKeyword: "then"
                            },
                            message: "should match \"then\" schema"
                          };

                          if (vErrors === null) {
                            vErrors = [err313];
                          } else {
                            vErrors.push(err313);
                          }

                          errors++;
                        }

                        const _errs328 = errors;
                        let valid134 = true;
                        const _errs329 = errors;

                        if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                          if (data115.type === undefined && "type") {
                            const err314 = {};

                            if (vErrors === null) {
                              vErrors = [err314];
                            } else {
                              vErrors.push(err314);
                            }

                            errors++;
                          } else {
                            if (data115.type !== undefined) {
                              if (!func0$1(data115.type, "camunda:in")) {
                                const err315 = {};

                                if (vErrors === null) {
                                  vErrors = [err315];
                                } else {
                                  vErrors.push(err315);
                                }

                                errors++;
                              }
                            }
                          }
                        }

                        var _valid28 = _errs329 === errors;

                        errors = _errs328;

                        if (vErrors !== null) {
                          if (_errs328) {
                            vErrors.length = _errs328;
                          } else {
                            vErrors = null;
                          }
                        }

                        if (_valid28) {
                          const _errs331 = errors;
                          const _errs332 = errors;
                          let valid136 = false;
                          const _errs333 = errors;

                          if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                            if (data115.variables === undefined) {
                              const err316 = {
                                keyword: "required",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/2/then/anyOf/0/required",
                                params: {
                                  missingProperty: "variables"
                                },
                                message: "should have required property '" + "variables" + "'"
                              };

                              if (vErrors === null) {
                                vErrors = [err316];
                              } else {
                                vErrors.push(err316);
                              }

                              errors++;
                            }
                          }

                          var _valid29 = _errs333 === errors;

                          valid136 = valid136 || _valid29;

                          if (!valid136) {
                            const _errs334 = errors;

                            if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                              if (data115.target === undefined) {
                                const err317 = {
                                  keyword: "required",
                                  dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                                  schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/2/then/anyOf/1/required",
                                  params: {
                                    missingProperty: "target"
                                  },
                                  message: "should have required property '" + "target" + "'"
                                };

                                if (vErrors === null) {
                                  vErrors = [err317];
                                } else {
                                  vErrors.push(err317);
                                }

                                errors++;
                              }
                            }

                            var _valid29 = _errs334 === errors;

                            valid136 = valid136 || _valid29;
                          }

                          if (!valid136) {
                            const err318 = {
                              keyword: "anyOf",
                              dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                              schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/2/then/anyOf",
                              params: {},
                              message: "should match some schema in anyOf"
                            };

                            if (vErrors === null) {
                              vErrors = [err318];
                            } else {
                              vErrors.push(err318);
                            }

                            errors++;
                          } else {
                            errors = _errs332;

                            if (vErrors !== null) {
                              if (_errs332) {
                                vErrors.length = _errs332;
                              } else {
                                vErrors = null;
                              }
                            }
                          }

                          if (errors > 0) {
                            const emErrs51 = [];

                            for (const err319 of vErrors) {
                              if (err319.keyword !== "errorMessage" && !err319.emUsed && (err319.dataPath === dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding" || err319.dataPath.indexOf(dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding") === 0 && err319.dataPath[dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding".length] === "/") && err319.schemaPath.indexOf("#/definitions/properties/allOf/1/items/properties/binding/allOf/2/then") === 0 && err319.schemaPath["#/definitions/properties/allOf/1/items/properties/binding/allOf/2/then".length] === "/") {
                                emErrs51.push(err319);
                                err319.emUsed = true;
                              }
                            }

                            if (emErrs51.length) {
                              const err320 = {
                                keyword: "errorMessage",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/2/then/errorMessage",
                                params: {
                                  errors: emErrs51
                                },
                                message: "property.binding " + JSON.stringify(data115 && data115.type) + " requires variables, target, or both"
                              };

                              if (vErrors === null) {
                                vErrors = [err320];
                              } else {
                                vErrors.push(err320);
                              }

                              errors++;
                            }

                            const emErrs52 = [];

                            for (const err321 of vErrors) {
                              if (!err321.emUsed) {
                                emErrs52.push(err321);
                              }
                            }

                            vErrors = emErrs52;
                            errors = emErrs52.length;
                          }

                          var _valid28 = _errs331 === errors;

                          valid134 = _valid28;
                        }

                        if (!valid134) {
                          const err322 = {
                            keyword: "if",
                            dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                            schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/2/if",
                            params: {
                              failingKeyword: "then"
                            },
                            message: "should match \"then\" schema"
                          };

                          if (vErrors === null) {
                            vErrors = [err322];
                          } else {
                            vErrors.push(err322);
                          }

                          errors++;
                        }

                        const _errs336 = errors;
                        let valid137 = true;
                        const _errs337 = errors;

                        if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                          if (data115.type === undefined && "type") {
                            const err323 = {};

                            if (vErrors === null) {
                              vErrors = [err323];
                            } else {
                              vErrors.push(err323);
                            }

                            errors++;
                          } else {
                            if (data115.type !== undefined) {
                              if (!func0$1(data115.type, "camunda:out")) {
                                const err324 = {};

                                if (vErrors === null) {
                                  vErrors = [err324];
                                } else {
                                  vErrors.push(err324);
                                }

                                errors++;
                              }
                            }
                          }
                        }

                        var _valid30 = _errs337 === errors;

                        errors = _errs336;

                        if (vErrors !== null) {
                          if (_errs336) {
                            vErrors.length = _errs336;
                          } else {
                            vErrors = null;
                          }
                        }

                        if (_valid30) {
                          const _errs339 = errors;
                          const _errs340 = errors;
                          let valid139 = false;
                          let passing6 = null;
                          const _errs341 = errors;
                          const _errs342 = errors;
                          const _errs343 = errors;
                          const _errs344 = errors;
                          let valid141 = false;
                          const _errs345 = errors;

                          if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                            if (data115.source === undefined && "source") {
                              const err325 = {};

                              if (vErrors === null) {
                                vErrors = [err325];
                              } else {
                                vErrors.push(err325);
                              }

                              errors++;
                            }
                          }

                          var _valid32 = _errs345 === errors;

                          valid141 = valid141 || _valid32;

                          if (!valid141) {
                            const _errs346 = errors;

                            if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                              if (data115.sourceExpression === undefined && "sourceExpression") {
                                const err326 = {};

                                if (vErrors === null) {
                                  vErrors = [err326];
                                } else {
                                  vErrors.push(err326);
                                }

                                errors++;
                              }
                            }

                            var _valid32 = _errs346 === errors;

                            valid141 = valid141 || _valid32;
                          }

                          if (!valid141) {
                            const err327 = {};

                            if (vErrors === null) {
                              vErrors = [err327];
                            } else {
                              vErrors.push(err327);
                            }

                            errors++;
                          } else {
                            errors = _errs344;

                            if (vErrors !== null) {
                              if (_errs344) {
                                vErrors.length = _errs344;
                              } else {
                                vErrors = null;
                              }
                            }
                          }

                          var valid140 = _errs343 === errors;

                          if (!valid140) {
                            errors = _errs342;

                            if (vErrors !== null) {
                              if (_errs342) {
                                vErrors.length = _errs342;
                              } else {
                                vErrors = null;
                              }
                            }
                          } else {
                            const err328 = {
                              keyword: "not",
                              dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                              schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/0/not",
                              params: {},
                              message: "should NOT be valid"
                            };

                            if (vErrors === null) {
                              vErrors = [err328];
                            } else {
                              vErrors.push(err328);
                            }

                            errors++;
                          }

                          if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                            if (data115.variables === undefined) {
                              const err329 = {
                                keyword: "required",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/0/required",
                                params: {
                                  missingProperty: "variables"
                                },
                                message: "should have required property '" + "variables" + "'"
                              };

                              if (vErrors === null) {
                                vErrors = [err329];
                              } else {
                                vErrors.push(err329);
                              }

                              errors++;
                            }
                          }

                          var _valid31 = _errs341 === errors;

                          if (_valid31) {
                            valid139 = true;
                            passing6 = 0;
                          }

                          const _errs347 = errors;
                          const _errs348 = errors;
                          const _errs349 = errors;
                          const _errs350 = errors;
                          let valid143 = false;
                          const _errs351 = errors;

                          if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                            if (data115.variables === undefined && "variables") {
                              const err330 = {};

                              if (vErrors === null) {
                                vErrors = [err330];
                              } else {
                                vErrors.push(err330);
                              }

                              errors++;
                            }
                          }

                          var _valid33 = _errs351 === errors;

                          valid143 = valid143 || _valid33;

                          if (!valid143) {
                            const _errs352 = errors;

                            if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                              if (data115.sourceExpression === undefined && "sourceExpression") {
                                const err331 = {};

                                if (vErrors === null) {
                                  vErrors = [err331];
                                } else {
                                  vErrors.push(err331);
                                }

                                errors++;
                              }
                            }

                            var _valid33 = _errs352 === errors;

                            valid143 = valid143 || _valid33;
                          }

                          if (!valid143) {
                            const err332 = {};

                            if (vErrors === null) {
                              vErrors = [err332];
                            } else {
                              vErrors.push(err332);
                            }

                            errors++;
                          } else {
                            errors = _errs350;

                            if (vErrors !== null) {
                              if (_errs350) {
                                vErrors.length = _errs350;
                              } else {
                                vErrors = null;
                              }
                            }
                          }

                          var valid142 = _errs349 === errors;

                          if (!valid142) {
                            errors = _errs348;

                            if (vErrors !== null) {
                              if (_errs348) {
                                vErrors.length = _errs348;
                              } else {
                                vErrors = null;
                              }
                            }
                          } else {
                            const err333 = {
                              keyword: "not",
                              dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                              schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/1/not",
                              params: {},
                              message: "should NOT be valid"
                            };

                            if (vErrors === null) {
                              vErrors = [err333];
                            } else {
                              vErrors.push(err333);
                            }

                            errors++;
                          }

                          if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                            if (data115.source === undefined) {
                              const err334 = {
                                keyword: "required",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/1/required",
                                params: {
                                  missingProperty: "source"
                                },
                                message: "should have required property '" + "source" + "'"
                              };

                              if (vErrors === null) {
                                vErrors = [err334];
                              } else {
                                vErrors.push(err334);
                              }

                              errors++;
                            }
                          }

                          var _valid31 = _errs347 === errors;

                          if (_valid31 && valid139) {
                            valid139 = false;
                            passing6 = [passing6, 1];
                          } else {
                            if (_valid31) {
                              valid139 = true;
                              passing6 = 1;
                            }

                            const _errs353 = errors;
                            const _errs354 = errors;
                            const _errs355 = errors;
                            const _errs356 = errors;
                            let valid145 = false;
                            const _errs357 = errors;

                            if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                              if (data115.variables === undefined && "variables") {
                                const err335 = {};

                                if (vErrors === null) {
                                  vErrors = [err335];
                                } else {
                                  vErrors.push(err335);
                                }

                                errors++;
                              }
                            }

                            var _valid34 = _errs357 === errors;

                            valid145 = valid145 || _valid34;

                            if (!valid145) {
                              const _errs358 = errors;

                              if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                                if (data115.source === undefined && "source") {
                                  const err336 = {};

                                  if (vErrors === null) {
                                    vErrors = [err336];
                                  } else {
                                    vErrors.push(err336);
                                  }

                                  errors++;
                                }
                              }

                              var _valid34 = _errs358 === errors;

                              valid145 = valid145 || _valid34;
                            }

                            if (!valid145) {
                              const err337 = {};

                              if (vErrors === null) {
                                vErrors = [err337];
                              } else {
                                vErrors.push(err337);
                              }

                              errors++;
                            } else {
                              errors = _errs356;

                              if (vErrors !== null) {
                                if (_errs356) {
                                  vErrors.length = _errs356;
                                } else {
                                  vErrors = null;
                                }
                              }
                            }

                            var valid144 = _errs355 === errors;

                            if (!valid144) {
                              errors = _errs354;

                              if (vErrors !== null) {
                                if (_errs354) {
                                  vErrors.length = _errs354;
                                } else {
                                  vErrors = null;
                                }
                              }
                            } else {
                              const err338 = {
                                keyword: "not",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/2/not",
                                params: {},
                                message: "should NOT be valid"
                              };

                              if (vErrors === null) {
                                vErrors = [err338];
                              } else {
                                vErrors.push(err338);
                              }

                              errors++;
                            }

                            if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                              if (data115.sourceExpression === undefined) {
                                const err339 = {
                                  keyword: "required",
                                  dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                                  schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/2/required",
                                  params: {
                                    missingProperty: "sourceExpression"
                                  },
                                  message: "should have required property '" + "sourceExpression" + "'"
                                };

                                if (vErrors === null) {
                                  vErrors = [err339];
                                } else {
                                  vErrors.push(err339);
                                }

                                errors++;
                              }
                            }

                            var _valid31 = _errs353 === errors;

                            if (_valid31 && valid139) {
                              valid139 = false;
                              passing6 = [passing6, 2];
                            } else {
                              if (_valid31) {
                                valid139 = true;
                                passing6 = 2;
                              }

                              const _errs359 = errors;
                              const _errs360 = errors;
                              const _errs361 = errors;

                              if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                                if (data115.source === undefined && "source") {
                                  const err340 = {};

                                  if (vErrors === null) {
                                    vErrors = [err340];
                                  } else {
                                    vErrors.push(err340);
                                  }

                                  errors++;
                                }
                              }

                              var valid146 = _errs361 === errors;

                              if (!valid146) {
                                errors = _errs360;

                                if (vErrors !== null) {
                                  if (_errs360) {
                                    vErrors.length = _errs360;
                                  } else {
                                    vErrors = null;
                                  }
                                }
                              } else {
                                const err341 = {
                                  keyword: "not",
                                  dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                                  schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/3/not",
                                  params: {},
                                  message: "should NOT be valid"
                                };

                                if (vErrors === null) {
                                  vErrors = [err341];
                                } else {
                                  vErrors.push(err341);
                                }

                                errors++;
                              }

                              if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                                if (data115.variables === undefined) {
                                  const err342 = {
                                    keyword: "required",
                                    dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                                    schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/3/required",
                                    params: {
                                      missingProperty: "variables"
                                    },
                                    message: "should have required property '" + "variables" + "'"
                                  };

                                  if (vErrors === null) {
                                    vErrors = [err342];
                                  } else {
                                    vErrors.push(err342);
                                  }

                                  errors++;
                                }

                                if (data115.sourceExpression === undefined) {
                                  const err343 = {
                                    keyword: "required",
                                    dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                                    schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/3/required",
                                    params: {
                                      missingProperty: "sourceExpression"
                                    },
                                    message: "should have required property '" + "sourceExpression" + "'"
                                  };

                                  if (vErrors === null) {
                                    vErrors = [err343];
                                  } else {
                                    vErrors.push(err343);
                                  }

                                  errors++;
                                }
                              }

                              var _valid31 = _errs359 === errors;

                              if (_valid31 && valid139) {
                                valid139 = false;
                                passing6 = [passing6, 3];
                              } else {
                                if (_valid31) {
                                  valid139 = true;
                                  passing6 = 3;
                                }

                                const _errs362 = errors;
                                const _errs363 = errors;
                                const _errs364 = errors;

                                if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                                  if (data115.sourceExpression === undefined && "sourceExpression") {
                                    const err344 = {};

                                    if (vErrors === null) {
                                      vErrors = [err344];
                                    } else {
                                      vErrors.push(err344);
                                    }

                                    errors++;
                                  }
                                }

                                var valid147 = _errs364 === errors;

                                if (!valid147) {
                                  errors = _errs363;

                                  if (vErrors !== null) {
                                    if (_errs363) {
                                      vErrors.length = _errs363;
                                    } else {
                                      vErrors = null;
                                    }
                                  }
                                } else {
                                  const err345 = {
                                    keyword: "not",
                                    dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                                    schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/4/not",
                                    params: {},
                                    message: "should NOT be valid"
                                  };

                                  if (vErrors === null) {
                                    vErrors = [err345];
                                  } else {
                                    vErrors.push(err345);
                                  }

                                  errors++;
                                }

                                if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                                  if (data115.variables === undefined) {
                                    const err346 = {
                                      keyword: "required",
                                      dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                                      schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/4/required",
                                      params: {
                                        missingProperty: "variables"
                                      },
                                      message: "should have required property '" + "variables" + "'"
                                    };

                                    if (vErrors === null) {
                                      vErrors = [err346];
                                    } else {
                                      vErrors.push(err346);
                                    }

                                    errors++;
                                  }

                                  if (data115.source === undefined) {
                                    const err347 = {
                                      keyword: "required",
                                      dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                                      schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf/4/required",
                                      params: {
                                        missingProperty: "source"
                                      },
                                      message: "should have required property '" + "source" + "'"
                                    };

                                    if (vErrors === null) {
                                      vErrors = [err347];
                                    } else {
                                      vErrors.push(err347);
                                    }

                                    errors++;
                                  }
                                }

                                var _valid31 = _errs362 === errors;

                                if (_valid31 && valid139) {
                                  valid139 = false;
                                  passing6 = [passing6, 4];
                                } else {
                                  if (_valid31) {
                                    valid139 = true;
                                    passing6 = 4;
                                  }
                                }
                              }
                            }
                          }

                          if (!valid139) {
                            const err348 = {
                              keyword: "oneOf",
                              dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                              schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/oneOf",
                              params: {
                                passingSchemas: passing6
                              },
                              message: "should match exactly one schema in oneOf"
                            };

                            if (vErrors === null) {
                              vErrors = [err348];
                            } else {
                              vErrors.push(err348);
                            }

                            errors++;
                          } else {
                            errors = _errs340;

                            if (vErrors !== null) {
                              if (_errs340) {
                                vErrors.length = _errs340;
                              } else {
                                vErrors = null;
                              }
                            }
                          }

                          if (errors > 0) {
                            const emErrs53 = [];

                            for (const err349 of vErrors) {
                              if (err349.keyword !== "errorMessage" && !err349.emUsed && (err349.dataPath === dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding" || err349.dataPath.indexOf(dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding") === 0 && err349.dataPath[dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding".length] === "/") && err349.schemaPath.indexOf("#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then") === 0 && err349.schemaPath["#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then".length] === "/") {
                                emErrs53.push(err349);
                                err349.emUsed = true;
                              }
                            }

                            if (emErrs53.length) {
                              const err350 = {
                                keyword: "errorMessage",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/then/errorMessage",
                                params: {
                                  errors: emErrs53
                                },
                                message: "property.binding " + JSON.stringify(data115 && data115.type) + " requires one of the following: variables, sourceExpression, source, (sourceExpression and variables), or (source and variables)"
                              };

                              if (vErrors === null) {
                                vErrors = [err350];
                              } else {
                                vErrors.push(err350);
                              }

                              errors++;
                            }

                            const emErrs54 = [];

                            for (const err351 of vErrors) {
                              if (!err351.emUsed) {
                                emErrs54.push(err351);
                              }
                            }

                            vErrors = emErrs54;
                            errors = emErrs54.length;
                          }

                          var _valid30 = _errs339 === errors;

                          valid137 = _valid30;
                        }

                        if (!valid137) {
                          const err352 = {
                            keyword: "if",
                            dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                            schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/3/if",
                            params: {
                              failingKeyword: "then"
                            },
                            message: "should match \"then\" schema"
                          };

                          if (vErrors === null) {
                            vErrors = [err352];
                          } else {
                            vErrors.push(err352);
                          }

                          errors++;
                        }

                        const _errs366 = errors;
                        let valid148 = true;
                        const _errs367 = errors;

                        if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                          if (data115.type === undefined && "type") {
                            const err353 = {};

                            if (vErrors === null) {
                              vErrors = [err353];
                            } else {
                              vErrors.push(err353);
                            }

                            errors++;
                          } else {
                            if (data115.type !== undefined) {
                              if (!func0$1(data115.type, "camunda:errorEventDefinition")) {
                                const err354 = {};

                                if (vErrors === null) {
                                  vErrors = [err354];
                                } else {
                                  vErrors.push(err354);
                                }

                                errors++;
                              }
                            }
                          }
                        }

                        var _valid35 = _errs367 === errors;

                        errors = _errs366;

                        if (vErrors !== null) {
                          if (_errs366) {
                            vErrors.length = _errs366;
                          } else {
                            vErrors = null;
                          }
                        }

                        if (_valid35) {
                          const _errs369 = errors;
                          const _errs370 = errors;
                          let valid150 = false;
                          let passing7 = null;
                          const _errs371 = errors;

                          if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                            if (data115.errorRef === undefined) {
                              const err355 = {
                                keyword: "required",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/4/then/oneOf/0/required",
                                params: {
                                  missingProperty: "errorRef"
                                },
                                message: "should have required property '" + "errorRef" + "'"
                              };

                              if (vErrors === null) {
                                vErrors = [err355];
                              } else {
                                vErrors.push(err355);
                              }

                              errors++;
                            }
                          }

                          var _valid36 = _errs371 === errors;

                          if (_valid36) {
                            valid150 = true;
                            passing7 = 0;
                          }

                          if (!valid150) {
                            const err356 = {
                              keyword: "oneOf",
                              dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                              schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/4/then/oneOf",
                              params: {
                                passingSchemas: passing7
                              },
                              message: "should match exactly one schema in oneOf"
                            };

                            if (vErrors === null) {
                              vErrors = [err356];
                            } else {
                              vErrors.push(err356);
                            }

                            errors++;
                          } else {
                            errors = _errs370;

                            if (vErrors !== null) {
                              if (_errs370) {
                                vErrors.length = _errs370;
                              } else {
                                vErrors = null;
                              }
                            }
                          }

                          if (errors > 0) {
                            const emErrs55 = [];

                            for (const err357 of vErrors) {
                              if (err357.keyword !== "errorMessage" && !err357.emUsed && (err357.dataPath === dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding" || err357.dataPath.indexOf(dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding") === 0 && err357.dataPath[dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding".length] === "/") && err357.schemaPath.indexOf("#/definitions/properties/allOf/1/items/properties/binding/allOf/4/then") === 0 && err357.schemaPath["#/definitions/properties/allOf/1/items/properties/binding/allOf/4/then".length] === "/") {
                                emErrs55.push(err357);
                                err357.emUsed = true;
                              }
                            }

                            if (emErrs55.length) {
                              const err358 = {
                                keyword: "errorMessage",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/4/then/errorMessage",
                                params: {
                                  errors: emErrs55
                                },
                                message: "property.binding " + JSON.stringify(data115 && data115.type) + " requires errorRef"
                              };

                              if (vErrors === null) {
                                vErrors = [err358];
                              } else {
                                vErrors.push(err358);
                              }

                              errors++;
                            }

                            const emErrs56 = [];

                            for (const err359 of vErrors) {
                              if (!err359.emUsed) {
                                emErrs56.push(err359);
                              }
                            }

                            vErrors = emErrs56;
                            errors = emErrs56.length;
                          }

                          var _valid35 = _errs369 === errors;

                          valid148 = _valid35;
                        }

                        if (!valid148) {
                          const err360 = {
                            keyword: "if",
                            dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                            schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/4/if",
                            params: {
                              failingKeyword: "then"
                            },
                            message: "should match \"then\" schema"
                          };

                          if (vErrors === null) {
                            vErrors = [err360];
                          } else {
                            vErrors.push(err360);
                          }

                          errors++;
                        }

                        if (data115 && typeof data115 == "object" && !Array.isArray(data115)) {
                          if (data115.type === undefined) {
                            const err361 = {
                              keyword: "required",
                              dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                              schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/required",
                              params: {
                                missingProperty: "type"
                              },
                              message: "should have required property '" + "type" + "'"
                            };

                            if (vErrors === null) {
                              vErrors = [err361];
                            } else {
                              vErrors.push(err361);
                            }

                            errors++;
                          }

                          if (data115.type !== undefined) {
                            let data121 = data115.type;

                            if (typeof data121 !== "string") {
                              const err362 = {
                                keyword: "type",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding/type",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/type/type",
                                params: {
                                  type: "string"
                                },
                                message: "should be string"
                              };

                              if (vErrors === null) {
                                vErrors = [err362];
                              } else {
                                vErrors.push(err362);
                              }

                              errors++;
                            }

                            if (!(data121 === "property" || data121 === "camunda:property" || data121 === "camunda:inputParameter" || data121 === "camunda:outputParameter" || data121 === "camunda:in" || data121 === "camunda:out" || data121 === "camunda:in:businessKey" || data121 === "camunda:executionListener" || data121 === "camunda:field" || data121 === "camunda:errorEventDefinition")) {
                              const err363 = {
                                keyword: "enum",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding/type",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/type/enum",
                                params: {
                                  allowedValues: schema20.items.properties.binding.properties.type.enum
                                },
                                message: "should be equal to one of the allowed values"
                              };

                              if (vErrors === null) {
                                vErrors = [err363];
                              } else {
                                vErrors.push(err363);
                              }

                              errors++;
                            }

                            if (errors > 0) {
                              const emErrs57 = [];

                              for (const err364 of vErrors) {
                                if (err364.keyword !== "errorMessage" && !err364.emUsed && (err364.dataPath === dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding/type" || err364.dataPath.indexOf(dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding/type") === 0 && err364.dataPath[dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding/type".length] === "/") && err364.schemaPath.indexOf("#/definitions/properties/allOf/1/items/properties/binding/properties/type") === 0 && err364.schemaPath["#/definitions/properties/allOf/1/items/properties/binding/properties/type".length] === "/") {
                                  emErrs57.push(err364);
                                  err364.emUsed = true;
                                }
                              }

                              if (emErrs57.length) {
                                const err365 = {
                                  keyword: "errorMessage",
                                  dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding/type",
                                  schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/type/errorMessage",
                                  params: {
                                    errors: emErrs57
                                  },
                                  message: "invalid property.binding type " + JSON.stringify(data121) + "; must be any of { property, camunda:property, camunda:inputParameter, camunda:outputParameter, camunda:in, camunda:out, camunda:in:businessKey, camunda:executionListener, camunda:field, camunda:errorEventDefinition }"
                                };

                                if (vErrors === null) {
                                  vErrors = [err365];
                                } else {
                                  vErrors.push(err365);
                                }

                                errors++;
                              }

                              const emErrs58 = [];

                              for (const err366 of vErrors) {
                                if (!err366.emUsed) {
                                  emErrs58.push(err366);
                                }
                              }

                              vErrors = emErrs58;
                              errors = emErrs58.length;
                            }
                          }

                          if (data115.name !== undefined) {
                            if (typeof data115.name !== "string") {
                              const err367 = {
                                keyword: "type",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding/name",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/name/type",
                                params: {
                                  type: "string"
                                },
                                message: "should be string"
                              };

                              if (vErrors === null) {
                                vErrors = [err367];
                              } else {
                                vErrors.push(err367);
                              }

                              errors++;
                            }
                          }

                          if (data115.event !== undefined) {
                            if (typeof data115.event !== "string") {
                              const err368 = {
                                keyword: "type",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding/event",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/event/type",
                                params: {
                                  type: "string"
                                },
                                message: "should be string"
                              };

                              if (vErrors === null) {
                                vErrors = [err368];
                              } else {
                                vErrors.push(err368);
                              }

                              errors++;
                            }
                          }

                          if (data115.scriptFormat !== undefined) {
                            if (typeof data115.scriptFormat !== "string") {
                              const err369 = {
                                keyword: "type",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding/scriptFormat",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/scriptFormat/type",
                                params: {
                                  type: "string"
                                },
                                message: "should be string"
                              };

                              if (vErrors === null) {
                                vErrors = [err369];
                              } else {
                                vErrors.push(err369);
                              }

                              errors++;
                            }
                          }

                          if (data115.source !== undefined) {
                            if (typeof data115.source !== "string") {
                              const err370 = {
                                keyword: "type",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding/source",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/source/type",
                                params: {
                                  type: "string"
                                },
                                message: "should be string"
                              };

                              if (vErrors === null) {
                                vErrors = [err370];
                              } else {
                                vErrors.push(err370);
                              }

                              errors++;
                            }
                          }

                          if (data115.target !== undefined) {
                            if (typeof data115.target !== "string") {
                              const err371 = {
                                keyword: "type",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding/target",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/target/type",
                                params: {
                                  type: "string"
                                },
                                message: "should be string"
                              };

                              if (vErrors === null) {
                                vErrors = [err371];
                              } else {
                                vErrors.push(err371);
                              }

                              errors++;
                            }
                          }

                          if (data115.expression !== undefined) {
                            if (typeof data115.expression !== "boolean") {
                              const err372 = {
                                keyword: "type",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding/expression",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/expression/type",
                                params: {
                                  type: "boolean"
                                },
                                message: "should be boolean"
                              };

                              if (vErrors === null) {
                                vErrors = [err372];
                              } else {
                                vErrors.push(err372);
                              }

                              errors++;
                            }
                          }

                          if (data115.variables !== undefined) {
                            let data128 = data115.variables;

                            if (typeof data128 !== "string") {
                              const err373 = {
                                keyword: "type",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding/variables",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/variables/type",
                                params: {
                                  type: "string"
                                },
                                message: "should be string"
                              };

                              if (vErrors === null) {
                                vErrors = [err373];
                              } else {
                                vErrors.push(err373);
                              }

                              errors++;
                            }

                            if (!(data128 === "all" || data128 === "local")) {
                              const err374 = {
                                keyword: "enum",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding/variables",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/variables/enum",
                                params: {
                                  allowedValues: schema20.items.properties.binding.properties.variables.enum
                                },
                                message: "should be equal to one of the allowed values"
                              };

                              if (vErrors === null) {
                                vErrors = [err374];
                              } else {
                                vErrors.push(err374);
                              }

                              errors++;
                            }
                          }

                          if (data115.sourceExpression !== undefined) {
                            if (typeof data115.sourceExpression !== "string") {
                              const err375 = {
                                keyword: "type",
                                dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding/sourceExpression",
                                schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/sourceExpression/type",
                                params: {
                                  type: "string"
                                },
                                message: "should be string"
                              };

                              if (vErrors === null) {
                                vErrors = [err375];
                              } else {
                                vErrors.push(err375);
                              }

                              errors++;
                            }
                          }
                        } else {
                          const err376 = {
                            keyword: "type",
                            dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10 + "/binding",
                            schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/type",
                            params: {
                              type: "object"
                            },
                            message: "should be object"
                          };

                          if (vErrors === null) {
                            vErrors = [err376];
                          } else {
                            vErrors.push(err376);
                          }

                          errors++;
                        }
                      }
                    } else {
                      const err377 = {
                        keyword: "type",
                        dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10,
                        schemaPath: "#/definitions/properties/allOf/1/items/type",
                        params: {
                          type: "object"
                        },
                        message: "should be object"
                      };

                      if (vErrors === null) {
                        vErrors = [err377];
                      } else {
                        vErrors.push(err377);
                      }

                      errors++;
                    }

                    if (errors > 0) {
                      const emErrors11 = {
                        "required": []
                      };
                      const templates11 = {
                        required: function () {
                          return "missing binding for property \"" + JSON.stringify(i10) + "\"";
                        }
                      };

                      for (const err378 of vErrors) {
                        if (err378.keyword !== "errorMessage" && !err378.emUsed && err378.dataPath === dataPath + "/scopes/" + i6 + "/properties/" + i10 && err378.keyword in emErrors11 && err378.schemaPath.indexOf("#/definitions/properties/allOf/1/items") === 0 && /^\/[^\/]*$/.test(err378.schemaPath.slice(38))) {
                          emErrors11[err378.keyword].push(err378);
                          err378.emUsed = true;
                        }
                      }

                      for (const key11 in emErrors11) {
                        if (emErrors11[key11].length) {
                          const err379 = {
                            keyword: "errorMessage",
                            dataPath: dataPath + "/scopes/" + i6 + "/properties/" + i10,
                            schemaPath: "#/definitions/properties/allOf/1/items/errorMessage",
                            params: {
                              errors: emErrors11[key11]
                            },
                            message: key11 in templates11 ? templates11[key11]() : schema20.items.errorMessage[key11]
                          };

                          if (vErrors === null) {
                            vErrors = [err379];
                          } else {
                            vErrors.push(err379);
                          }

                          errors++;
                        }
                      }

                      const emErrs59 = [];

                      for (const err380 of vErrors) {
                        if (!err380.emUsed) {
                          emErrs59.push(err380);
                        }
                      }

                      vErrors = emErrs59;
                      errors = emErrs59.length;
                    }
                  }
                } else {
                  const err381 = {
                    keyword: "type",
                    dataPath: dataPath + "/scopes/" + i6 + "/properties",
                    schemaPath: "#/definitions/properties/allOf/1/type",
                    params: {
                      type: "array"
                    },
                    message: "should be array"
                  };

                  if (vErrors === null) {
                    vErrors = [err381];
                  } else {
                    vErrors.push(err381);
                  }

                  errors++;
                }
              }
            } else {
              const err382 = {
                keyword: "type",
                dataPath: dataPath + "/scopes/" + i6,
                schemaPath: "#/properties/scopes/items/type",
                params: {
                  type: "object"
                },
                message: "should be object"
              };

              if (vErrors === null) {
                vErrors = [err382];
              } else {
                vErrors.push(err382);
              }

              errors++;
            }

            if (errors > 0) {
              const emErrors12 = {
                "required": {
                  "type": [],
                  "properties": []
                }
              };
              const templates12 = {
                required: {
                  properties: function () {
                    return "invalid scope " + JSON.stringify(data72 && data72.type) + ", missing properties=[]";
                  }
                }
              };
              let emPropParams5;
              let emParamsErrors5;

              for (const err383 of vErrors) {
                if (err383.keyword !== "errorMessage" && !err383.emUsed && err383.dataPath === dataPath + "/scopes/" + i6 && err383.keyword in emErrors12 && err383.schemaPath.indexOf("#/properties/scopes/items") === 0 && /^\/[^\/]*$/.test(err383.schemaPath.slice(25))) {
                  emPropParams5 = obj0$1[err383.keyword];
                  emParamsErrors5 = emErrors12[err383.keyword][err383.params[emPropParams5]];

                  if (emParamsErrors5) {
                    emParamsErrors5.push(err383);
                    err383.emUsed = true;
                  }
                }
              }

              for (const key12 in emErrors12) {
                for (const keyProp5 in emErrors12[key12]) {
                  emParamsErrors5 = emErrors12[key12][keyProp5];

                  if (emParamsErrors5.length) {
                    const tmpl5 = templates12[key12] && templates12[key12][keyProp5];
                    const err384 = {
                      keyword: "errorMessage",
                      dataPath: dataPath + "/scopes/" + i6,
                      schemaPath: "#/properties/scopes/items/errorMessage",
                      params: {
                        errors: emParamsErrors5
                      },
                      message: tmpl5 ? tmpl5() : schema17$1.properties.scopes.items.errorMessage[key12][keyProp5]
                    };

                    if (vErrors === null) {
                      vErrors = [err384];
                    } else {
                      vErrors.push(err384);
                    }

                    errors++;
                  }
                }
              }

              const emErrs60 = [];

              for (const err385 of vErrors) {
                if (!err385.emUsed) {
                  emErrs60.push(err385);
                }
              }

              vErrors = emErrs60;
              errors = emErrs60.length;
            }
          }
        } else {
          const err386 = {
            keyword: "type",
            dataPath: dataPath + "/scopes",
            schemaPath: "#/properties/scopes/type",
            params: {
              type: "array"
            },
            message: "should be array"
          };

          if (vErrors === null) {
            vErrors = [err386];
          } else {
            vErrors.push(err386);
          }

          errors++;
        }
      }
    } else {
      const err387 = {
        keyword: "type",
        dataPath,
        schemaPath: "#/type",
        params: {
          type: "object"
        },
        message: "should be object"
      };

      if (vErrors === null) {
        vErrors = [err387];
      } else {
        vErrors.push(err387);
      }

      errors++;
    }

    validate15$1.errors = vErrors;
    return errors === 0;
  }

  function validate14$1(data, {
    dataPath = "",
    parentData,
    parentDataProperty,
    rootData = data
  } = {}) {
    let vErrors = null;
    let errors = 0;
    const _errs0 = errors;
    let valid0 = false;
    let passing0 = null;
    const _errs1 = errors;

    if (!validate15$1(data, {
      dataPath,
      parentData,
      parentDataProperty,
      rootData
    })) {
      vErrors = vErrors === null ? validate15$1.errors : vErrors.concat(validate15$1.errors);
      errors = vErrors.length;
    }

    var _valid0 = _errs1 === errors;

    if (_valid0) {
      valid0 = true;
      passing0 = 0;
    }

    const _errs2 = errors;

    if (Array.isArray(data)) {
      const len0 = data.length;

      for (let i0 = 0; i0 < len0; i0++) {
        if (!validate15$1(data[i0], {
          dataPath: dataPath + "/" + i0,
          parentData: data,
          parentDataProperty: i0,
          rootData
        })) {
          vErrors = vErrors === null ? validate15$1.errors : vErrors.concat(validate15$1.errors);
          errors = vErrors.length;
        }
      }
    } else {
      const err0 = {
        keyword: "type",
        dataPath,
        schemaPath: "#/oneOf/1/type",
        params: {
          type: "array"
        },
        message: "should be array"
      };

      if (vErrors === null) {
        vErrors = [err0];
      } else {
        vErrors.push(err0);
      }

      errors++;
    }

    var _valid0 = _errs2 === errors;

    if (_valid0 && valid0) {
      valid0 = false;
      passing0 = [passing0, 1];
    } else {
      if (_valid0) {
        valid0 = true;
        passing0 = 1;
      }
    }

    if (!valid0) {
      const err1 = {
        keyword: "oneOf",
        dataPath,
        schemaPath: "#/oneOf",
        params: {
          passingSchemas: passing0
        },
        message: "should match exactly one schema in oneOf"
      };

      if (vErrors === null) {
        vErrors = [err1];
      } else {
        vErrors.push(err1);
      }

      errors++;
    } else {
      errors = _errs0;

      if (vErrors !== null) {
        if (_errs0) {
          vErrors.length = _errs0;
        } else {
          vErrors = null;
        }
      }
    }

    validate14$1.errors = vErrors;
    return errors === 0;
  }

  var jsonSourceMap = {};
  var escapedChars = {
    'b': '\b',
    'f': '\f',
    'n': '\n',
    'r': '\r',
    't': '\t',
    '"': '"',
    '/': '/',
    '\\': '\\'
  };
  var A_CODE = 'a'.charCodeAt();

  jsonSourceMap.parse = function (source, _, options) {
    var pointers = {};
    var line = 0;
    var column = 0;
    var pos = 0;
    var bigint = options && options.bigint && typeof BigInt != 'undefined';
    return {
      data: _parse('', true),
      pointers: pointers
    };

    function _parse(ptr, topLevel) {
      whitespace();
      var data;
      map(ptr, 'value');
      var char = getChar();

      switch (char) {
        case 't':
          read('rue');
          data = true;
          break;

        case 'f':
          read('alse');
          data = false;
          break;

        case 'n':
          read('ull');
          data = null;
          break;

        case '"':
          data = parseString();
          break;

        case '[':
          data = parseArray(ptr);
          break;

        case '{':
          data = parseObject(ptr);
          break;

        default:
          backChar();
          if ('-0123456789'.indexOf(char) >= 0) data = parseNumber();else unexpectedToken();
      }

      map(ptr, 'valueEnd');
      whitespace();
      if (topLevel && pos < source.length) unexpectedToken();
      return data;
    }

    function whitespace() {
      loop: while (pos < source.length) {
        switch (source[pos]) {
          case ' ':
            column++;
            break;

          case '\t':
            column += 4;
            break;

          case '\r':
            column = 0;
            break;

          case '\n':
            column = 0;
            line++;
            break;

          default:
            break loop;
        }

        pos++;
      }
    }

    function parseString() {
      var str = '';
      var char;

      while (true) {
        char = getChar();

        if (char == '"') {
          break;
        } else if (char == '\\') {
          char = getChar();
          if (char in escapedChars) str += escapedChars[char];else if (char == 'u') str += getCharCode();else wasUnexpectedToken();
        } else {
          str += char;
        }
      }

      return str;
    }

    function parseNumber() {
      var numStr = '';
      var integer = true;
      if (source[pos] == '-') numStr += getChar();
      numStr += source[pos] == '0' ? getChar() : getDigits();

      if (source[pos] == '.') {
        numStr += getChar() + getDigits();
        integer = false;
      }

      if (source[pos] == 'e' || source[pos] == 'E') {
        numStr += getChar();
        if (source[pos] == '+' || source[pos] == '-') numStr += getChar();
        numStr += getDigits();
        integer = false;
      }

      var result = +numStr;
      return bigint && integer && (result > Number.MAX_SAFE_INTEGER || result < Number.MIN_SAFE_INTEGER) ? BigInt(numStr) : result;
    }

    function parseArray(ptr) {
      whitespace();
      var arr = [];
      var i = 0;
      if (getChar() == ']') return arr;
      backChar();

      while (true) {
        var itemPtr = ptr + '/' + i;
        arr.push(_parse(itemPtr));
        whitespace();
        var char = getChar();
        if (char == ']') break;
        if (char != ',') wasUnexpectedToken();
        whitespace();
        i++;
      }

      return arr;
    }

    function parseObject(ptr) {
      whitespace();
      var obj = {};
      if (getChar() == '}') return obj;
      backChar();

      while (true) {
        var loc = getLoc();
        if (getChar() != '"') wasUnexpectedToken();
        var key = parseString();
        var propPtr = ptr + '/' + escapeJsonPointer(key);
        mapLoc(propPtr, 'key', loc);
        map(propPtr, 'keyEnd');
        whitespace();
        if (getChar() != ':') wasUnexpectedToken();
        whitespace();
        obj[key] = _parse(propPtr);
        whitespace();
        var char = getChar();
        if (char == '}') break;
        if (char != ',') wasUnexpectedToken();
        whitespace();
      }

      return obj;
    }

    function read(str) {
      for (var i = 0; i < str.length; i++) if (getChar() !== str[i]) wasUnexpectedToken();
    }

    function getChar() {
      checkUnexpectedEnd();
      var char = source[pos];
      pos++;
      column++; // new line?

      return char;
    }

    function backChar() {
      pos--;
      column--;
    }

    function getCharCode() {
      var count = 4;
      var code = 0;

      while (count--) {
        code <<= 4;
        var char = getChar().toLowerCase();
        if (char >= 'a' && char <= 'f') code += char.charCodeAt() - A_CODE + 10;else if (char >= '0' && char <= '9') code += +char;else wasUnexpectedToken();
      }

      return String.fromCharCode(code);
    }

    function getDigits() {
      var digits = '';

      while (source[pos] >= '0' && source[pos] <= '9') digits += getChar();

      if (digits.length) return digits;
      checkUnexpectedEnd();
      unexpectedToken();
    }

    function map(ptr, prop) {
      mapLoc(ptr, prop, getLoc());
    }

    function mapLoc(ptr, prop, loc) {
      pointers[ptr] = pointers[ptr] || {};
      pointers[ptr][prop] = loc;
    }

    function getLoc() {
      return {
        line: line,
        column: column,
        pos: pos
      };
    }

    function unexpectedToken() {
      throw new SyntaxError('Unexpected token ' + source[pos] + ' in JSON at position ' + pos);
    }

    function wasUnexpectedToken() {
      backChar();
      unexpectedToken();
    }

    function checkUnexpectedEnd() {
      if (pos >= source.length) throw new SyntaxError('Unexpected end of JSON input');
    }
  };

  jsonSourceMap.stringify = function (data, _, options) {
    if (!validType(data)) return;
    var wsLine = 0;
    var wsPos, wsColumn;
    var whitespace = typeof options == 'object' ? options.space : options;

    switch (typeof whitespace) {
      case 'number':
        var len = whitespace > 10 ? 10 : whitespace < 0 ? 0 : Math.floor(whitespace);
        whitespace = len && repeat(len, ' ');
        wsPos = len;
        wsColumn = len;
        break;

      case 'string':
        whitespace = whitespace.slice(0, 10);
        wsPos = 0;
        wsColumn = 0;

        for (var j = 0; j < whitespace.length; j++) {
          var char = whitespace[j];

          switch (char) {
            case ' ':
              wsColumn++;
              break;

            case '\t':
              wsColumn += 4;
              break;

            case '\r':
              wsColumn = 0;
              break;

            case '\n':
              wsColumn = 0;
              wsLine++;
              break;

            default:
              throw new Error('whitespace characters not allowed in JSON');
          }

          wsPos++;
        }

        break;

      default:
        whitespace = undefined;
    }

    var json = '';
    var pointers = {};
    var line = 0;
    var column = 0;
    var pos = 0;
    var es6 = options && options.es6 && typeof Map == 'function';

    _stringify(data, 0, '');

    return {
      json: json,
      pointers: pointers
    };

    function _stringify(_data, lvl, ptr) {
      map(ptr, 'value');

      switch (typeof _data) {
        case 'number':
        case 'bigint':
        case 'boolean':
          out('' + _data);
          break;

        case 'string':
          out(quoted(_data));
          break;

        case 'object':
          if (_data === null) {
            out('null');
          } else if (typeof _data.toJSON == 'function') {
            out(quoted(_data.toJSON()));
          } else if (Array.isArray(_data)) {
            stringifyArray();
          } else if (es6) {
            if (_data.constructor.BYTES_PER_ELEMENT) stringifyArray();else if (_data instanceof Map) stringifyMapSet();else if (_data instanceof Set) stringifyMapSet(true);else stringifyObject();
          } else {
            stringifyObject();
          }

      }

      map(ptr, 'valueEnd');

      function stringifyArray() {
        if (_data.length) {
          out('[');
          var itemLvl = lvl + 1;

          for (var i = 0; i < _data.length; i++) {
            if (i) out(',');
            indent(itemLvl);
            var item = validType(_data[i]) ? _data[i] : null;
            var itemPtr = ptr + '/' + i;

            _stringify(item, itemLvl, itemPtr);
          }

          indent(lvl);
          out(']');
        } else {
          out('[]');
        }
      }

      function stringifyObject() {
        var keys = Object.keys(_data);

        if (keys.length) {
          out('{');
          var propLvl = lvl + 1;

          for (var i = 0; i < keys.length; i++) {
            var key = keys[i];
            var value = _data[key];

            if (validType(value)) {
              if (i) out(',');
              var propPtr = ptr + '/' + escapeJsonPointer(key);
              indent(propLvl);
              map(propPtr, 'key');
              out(quoted(key));
              map(propPtr, 'keyEnd');
              out(':');
              if (whitespace) out(' ');

              _stringify(value, propLvl, propPtr);
            }
          }

          indent(lvl);
          out('}');
        } else {
          out('{}');
        }
      }

      function stringifyMapSet(isSet) {
        if (_data.size) {
          out('{');
          var propLvl = lvl + 1;
          var first = true;

          var entries = _data.entries();

          var entry = entries.next();

          while (!entry.done) {
            var item = entry.value;
            var key = item[0];
            var value = isSet ? true : item[1];

            if (validType(value)) {
              if (!first) out(',');
              first = false;
              var propPtr = ptr + '/' + escapeJsonPointer(key);
              indent(propLvl);
              map(propPtr, 'key');
              out(quoted(key));
              map(propPtr, 'keyEnd');
              out(':');
              if (whitespace) out(' ');

              _stringify(value, propLvl, propPtr);
            }

            entry = entries.next();
          }

          indent(lvl);
          out('}');
        } else {
          out('{}');
        }
      }
    }

    function out(str) {
      column += str.length;
      pos += str.length;
      json += str;
    }

    function indent(lvl) {
      if (whitespace) {
        json += '\n' + repeat(lvl, whitespace);
        line++;
        column = 0;

        while (lvl--) {
          if (wsLine) {
            line += wsLine;
            column = wsColumn;
          } else {
            column += wsColumn;
          }

          pos += wsPos;
        }

        pos += 1; // \n character
      }
    }

    function map(ptr, prop) {
      pointers[ptr] = pointers[ptr] || {};
      pointers[ptr][prop] = {
        line: line,
        column: column,
        pos: pos
      };
    }

    function repeat(n, str) {
      return Array(n + 1).join(str);
    }
  };

  var VALID_TYPES = ['number', 'bigint', 'boolean', 'string', 'object'];

  function validType(data) {
    return VALID_TYPES.indexOf(typeof data) >= 0;
  }

  var ESC_QUOTE = /"|\\/g;
  var ESC_B = /[\b]/g;
  var ESC_F = /\f/g;
  var ESC_N = /\n/g;
  var ESC_R = /\r/g;
  var ESC_T = /\t/g;

  function quoted(str) {
    str = str.replace(ESC_QUOTE, '\\$&').replace(ESC_F, '\\f').replace(ESC_B, '\\b').replace(ESC_N, '\\n').replace(ESC_R, '\\r').replace(ESC_T, '\\t');
    return '"' + str + '"';
  }

  var ESC_0 = /~/g;
  var ESC_1 = /\//g;

  function escapeJsonPointer(str) {
    return str.replace(ESC_0, '~0').replace(ESC_1, '~1');
  }

  function _validate(object, validateFn) {
    const dataPointerMap = generateDataPointerMap(object);
    const valid = validateFn(object);
    let errors = validateFn.errors;

    if (errors && errors.length) {
      // @pinussilvestrus: the <ajv-errors> extensions produces a couple of
      // unnecessary errors when using an <errorMessage> attribute.
      // Therefore, we should flatten the produced errors a bit to not
      // confuse the consumer of this library.
      // (1) wrap raw errors in case of custom errorMessage attribute
      forEach(errors, wrapRawErrors); // (2) ignore supportive error messages (e.g. "if-then-rules")

      errors = ignoreSupportiveErrors(errors); // (3) set data pointer for each error

      forEach(errors, function (error) {
        setDataPointer(error, dataPointerMap);
      });
    }

    return {
      valid: valid,
      object: object,
      errors: errors
    };
  }


  function wrapRawErrors(error) {
    const params = error.params;

    if (params && params.errors) {
      params.rawErrors = params.errors;
      delete params.errors;
    }
  }

  function setDataPointer(error, dataPointerMap) {
    const dataPath = error.dataPath;
    const pointer = dataPointerMap[dataPath];
    error.dataPointer = pointer;
  }

  function ignoreSupportiveErrors(errors) {
    return filter(errors, function (error) {
      return error.keyword !== 'if';
    });
  }
  /**
   * Generates a key-pointer map for the object.
   *
   * Example:
   *
   * {
   *  foo: 'bar'
   * }
   *
   * =>
   *
   * {
   *  '': {
   *    value: { line: 0, column: 0, pos: 0 },
   *    valueEnd: { line: 2, column: 1, pos: 18 }
   *  },
   *  '/foo': {
   *    key: { line: 1, column: 2, pos: 4 },
   *    keyEnd: { line: 1, column: 7, pos: 9 },
   *    value: { line: 1, column: 9, pos: 11 },
   *    valueEnd: { line: 1, column: 14, pos: 16 }
   *  }
   * }
   *
   * @param {Object} object
   * @return {Object}
   */


  function generateDataPointerMap(object) {
    return jsonSourceMap.stringify(object, null, 2).pointers;
  }

  function getSchemaVersion$1() {
    return version$1;
  }
  /**
   * Validate a single object.
   *
   * @param {Object} object
   * @return {Object} single object validation result
   */


  function validate$1(object) {
    return _validate(object, standaloneValidator.exports);
  }

  var name = "@camunda/zeebe-element-templates-json-schema";
  var version = "0.6.0";
  var standaloneZeebeValidator = {
    exports: {}
  };
  standaloneZeebeValidator.exports = validate14;
  standaloneZeebeValidator.exports.default = validate14;
  const schema17 = {
    "type": "object",
    "allOf": [{
      "required": ["name", "id", "appliesTo", "properties"],
      "properties": {
        "name": {
          "$id": "#/name",
          "type": "string",
          "description": "The name of the element template."
        },
        "id": {
          "$id": "#/id",
          "type": "string",
          "description": "The identifier of the element template."
        },
        "description": {
          "$id": "#/description",
          "type": "string",
          "description": "The description of the element template."
        },
        "version": {
          "$id": "#/version",
          "type": "integer",
          "description": "Optional version of the template. If you add a version to a template it will be considered unique based on its ID and version. Two templates can have the same ID if their version is different."
        },
        "isDefault": {
          "$id": "#/isDefault",
          "type": "boolean",
          "description": "Indicates whether the element template is a default template."
        },
        "appliesTo": {
          "$id": "#/appliesTo",
          "type": "array",
          "description": "List of BPMN types the template can be applied to.",
          "default": [],
          "items": {
            "$id": "#/appliesTo/items",
            "type": "string",
            "pattern": "^[\\w\\d]+:[\\w\\d]+$",
            "allOf": [{
              "examples": ["bpmn:Task", "bpmn:ServiceTask", "bpmn:SequenceFlow", "bpmn:Process", "bpmn:StartEvent", "bpmn:Gateway"]
            }],
            "errorMessage": {
              "pattern": "invalid item for \"appliesTo\", should contain namespaced property, example: \"bpmn:Task\""
            }
          }
        },
        "elementType": {
          "$id": "#/elementType",
          "type": "object",
          "description": "The BPMN type the element will be transformed into.",
          "default": {},
          "required": ["value"],
          "properties": {
            "value": {
              "$id": "#/elementType/value",
              "type": "string",
              "pattern": "^[\\w\\d]+:[\\w\\d]+$",
              "allOf": [{
                "examples": ["bpmn:ServiceTask", "bpmn:UserTask", "bpmn:StartEvent", "bpmn:ExclusiveGateway", "bpmn:ParallelGateway"]
              }],
              "errorMessage": {
                "pattern": "invalid item for \"elementType\", should contain namespaced property, example: \"bpmn:Task\""
              }
            }
          },
          "errorMessage": {
            "required": {
              "value": "missing elementType value"
            }
          }
        },
        "metadata": {
          "$id": "#/metadata",
          "type": "object",
          "description": "Some custom properties for further configuration.",
          "default": {}
        },
        "entriesVisible": {
          "$id": "#/entriesVisible",
          "type": "boolean",
          "description": "Select whether non-template entries are visible in the properties panel."
        },
        "groups": {
          "$id": "#/groups",
          "type": "array",
          "description": "Custom fields can be ordered together via groups.",
          "allOf": [{
            "examples": [[{
              "id": "group-1",
              "label": "My Group"
            }]]
          }],
          "items": {
            "$id": "#/groups/group",
            "type": "object",
            "default": {},
            "required": ["id", "label"],
            "properties": {
              "id": {
                "$id": "#/groups/group/id",
                "type": "string",
                "description": "The id of the custom group"
              },
              "label": {
                "$id": "#/groups/group/label",
                "type": "string",
                "description": "The label of the custom group"
              }
            },
            "errorMessage": {
              "required": {
                "id": "missing id for group \"${0#}\"",
                "label": "missing label for group \"${0#}\""
              }
            }
          }
        },
        "documentationRef": {
          "$id": "#/documentationRef",
          "type": "string",
          "pattern": "^(https|http)://.*",
          "errorMessage": {
            "pattern": "Malformed documentation URL, must match \"^(https|http)://.*\""
          }
        }
      },
      "errorMessage": {
        "required": {
          "name": "missing template name",
          "id": "missing template id",
          "appliesTo": "missing appliesTo=[]",
          "properties": "missing properties=[]"
        }
      }
    }],
    "properties": {
      "properties": {
        "$ref": "#/definitions/properties",
        "$id": "#/properties"
      },
      "icon": {
        "$id": "#/icon",
        "type": "object",
        "description": "Custom icon to be shown on the element",
        "default": {},
        "properties": {
          "contents": {
            "$id": "#/icon/contents",
            "type": "string",
            "description": "The URL of an icon.",
            "pattern": "^(https?|data):.*",
            "errorMessage": {
              "pattern": "Malformed icon source, must be a valid HTTP(s) or data URL"
            }
          }
        },
        "required": ["contents"],
        "errorMessage": {
          "required": {
            "contents": "missing icon contents"
          }
        }
      }
    }
  };
  const schema18 = {
    "allOf": [{
      "type": "array",
      "description": "List of properties of the element template.",
      "allOf": [{
        "examples": [[{
          "label": "Name",
          "type": "String",
          "binding": {
            "type": "property",
            "name": "name"
          }
        }]]
      }],
      "items": {
        "type": "object",
        "default": {},
        "allOf": [{
          "if": {
            "properties": {
              "type": {
                "const": "Dropdown"
              }
            },
            "required": ["type"]
          },
          "then": {
            "required": ["choices"],
            "errorMessage": "must provide choices=[] with \"Dropdown\" type"
          }
        }],
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier of the property."
          },
          "value": {
            "$id": "#/properties/property/value",
            "type": ["string", "boolean"],
            "description": "The value of a control field."
          },
          "description": {
            "$id": "#/properties/property/description",
            "type": "string",
            "description": "The description of a control field."
          },
          "label": {
            "$id": "#/properties/property/label",
            "type": "string",
            "description": "The label of a control field."
          },
          "type": {
            "$id": "#/properties/property/type",
            "type": "string",
            "description": "The type of a control field."
          },
          "editable": {
            "$id": "#/properties/property/editable",
            "type": "boolean",
            "description": "Indicates whether a control field is editable or not."
          },
          "choices": {
            "$id": "#/properties/property/choices",
            "type": "array",
            "description": "The choices for dropdown fields.",
            "default": [],
            "items": {
              "$id": "#/properties/property/choices/item",
              "type": "object",
              "default": {},
              "properties": {
                "name": {
                  "$id": "#/properties/property/choices/item/name",
                  "type": "string",
                  "description": "The name of a choice."
                },
                "value": {
                  "$id": "#/properties/property/choices/item/value",
                  "type": "string",
                  "description": "The value of a choice."
                }
              },
              "required": ["value", "name"],
              "errorMessage": {
                "required": "{ name, value } must be specified for \"Dropdown\" choices"
              }
            }
          },
          "constraints": {
            "$id": "#/properties/property/constraints",
            "type": "object",
            "description": "The validation constraints of a control field.",
            "allOf": [{
              "examples": [{
                "notEmpty": true
              }]
            }],
            "properties": {
              "notEmpty": {
                "$id": "#/properties/property/constraints/notEmpty",
                "type": "boolean",
                "description": "The control field must not be empty."
              },
              "minLength": {
                "$id": "#/properties/property/constraints/minLength",
                "type": "number",
                "description": "The minimal length of a control field value."
              },
              "maxLength": {
                "$id": "#/properties/property/constraints/maxLength",
                "type": "number",
                "description": "The maximal length for a control field value."
              },
              "pattern": {
                "$id": "#/properties/property/constraints/pattern",
                "description": "A regular expression pattern for a constraint.",
                "oneOf": [{
                  "type": "object",
                  "default": {},
                  "properties": {
                    "value": {
                      "$id": "#/properties/property/constraints/pattern/value",
                      "type": "string",
                      "description": "The regular expression of a pattern."
                    },
                    "message": {
                      "$id": "#/properties/property/constraints/pattern/message",
                      "type": "string",
                      "description": "The validation message of a pattern."
                    }
                  }
                }, {
                  "type": "string"
                }]
              }
            }
          },
          "group": {
            "$id": "#/properties/property/group",
            "type": "string",
            "description": "The custom group of a control field."
          },
          "condition": {
            "$id": "#/condition",
            "type": "object",
            "description": "Condition to activate the binding.",
            "allOf": [{
              "examples": [{
                "type": "simple",
                "property": "httpMethod",
                "equals": "GET"
              }, {
                "type": "simple",
                "property": "httpMethod",
                "oneOf": ["POST", "PUT", "DELETE"]
              }]
            }],
            "required": ["property"],
            "properties": {
              "type": {
                "$id": "#/condition/type",
                "const": "simple",
                "description": "The type of the condition.",
                "default": "simple"
              },
              "property": {
                "$id": "#/condition/property",
                "type": "string",
                "description": "The id of the property to check."
              }
            },
            "oneOf": [{
              "properties": {
                "equals": {
                  "type": ["string", "number", "boolean"]
                }
              },
              "required": ["equals"]
            }, {
              "properties": {
                "oneOf": {
                  "type": "array",
                  "items": {
                    "type": ["string", "number"]
                  }
                }
              },
              "required": ["oneOf"]
            }],
            "errorMessage": {
              "required": {
                "property": "missing property name for condition"
              }
            }
          }
        }
      }
    }, {
      "$schema": "http://json-schema.org/draft-07/schema",
      "type": "array",
      "description": "List of properties of the element template.",
      "items": {
        "type": "object",
        "default": {},
        "required": ["binding"],
        "allOf": [{
          "if": {
            "properties": {
              "binding": {
                "properties": {
                  "type": {
                    "const": "property"
                  }
                },
                "required": ["type"]
              }
            },
            "required": ["binding"]
          },
          "then": {
            "properties": {
              "type": {
                "enum": ["String", "Text", "Hidden", "Dropdown", "Boolean"],
                "errorMessage": "invalid property type ${0} for binding type \"property\"; must be any of { String, Text, Hidden, Dropdown, Boolean }"
              }
            }
          }
        }, {
          "if": {
            "properties": {
              "binding": {
                "properties": {
                  "type": {
                    "enum": ["zeebe:input", "zeebe:output", "zeebe:property", "zeebe:taskHeader", "zeebe:taskDefinition:type"]
                  }
                },
                "required": ["type"]
              }
            },
            "required": ["binding"]
          },
          "then": {
            "properties": {
              "type": {
                "enum": ["String", "Text", "Hidden", "Dropdown"],
                "errorMessage": "invalid property type ${0} for binding type ${1/binding/type}; must be any of { String, Text, Hidden, Dropdown }"
              }
            }
          }
        }, {
          "if": {
            "properties": {
              "optional": {
                "const": true
              }
            },
            "required": ["optional"]
          },
          "then": {
            "properties": {
              "binding": {
                "properties": {
                  "type": {
                    "enum": ["zeebe:input", "zeebe:output", "zeebe:property"],
                    "errorMessage": "optional is not supported for binding type ${0}; must be any of { zeebe:input, zeebe:output, zeebe:property }"
                  }
                },
                "required": ["type"]
              }
            }
          }
        }, {
          "if": {
            "properties": {
              "optional": {
                "const": true
              }
            },
            "required": ["optional"]
          },
          "then": {
            "properties": {
              "constraints": {
                "properties": {
                  "notEmpty": {
                    "const": false,
                    "errorMessage": "optional is not allowed for truthy \"notEmpty\" constraint"
                  }
                },
                "required": ["notEmpty"]
              }
            }
          }
        }, {
          "if": {
            "properties": {
              "feel": {
                "not": {
                  "const": null
                }
              }
            },
            "required": ["feel"]
          },
          "then": {
            "properties": {
              "type": {
                "enum": ["String", "Text"],
                "errorMessage": "feel is only supported for \"String\" and \"Text\" type"
              }
            },
            "required": ["type"]
          }
        }],
        "properties": {
          "binding": {
            "$id": "#/properties/property/binding",
            "type": "object",
            "description": "Specifying how the property is mapped to BPMN or Zeebe extension elements and attributes.",
            "required": ["type"],
            "allOf": [{
              "if": {
                "properties": {
                  "type": {
                    "enum": ["property", "zeebe:property", "zeebe:input"]
                  }
                },
                "required": ["type"]
              },
              "then": {
                "required": ["name"],
                "errorMessage": "property.binding ${0/type} requires name"
              }
            }, {
              "if": {
                "properties": {
                  "type": {
                    "const": "zeebe:output"
                  }
                },
                "required": ["type"]
              },
              "then": {
                "required": ["source"],
                "errorMessage": "property.binding ${0/type} requires source"
              }
            }, {
              "if": {
                "properties": {
                  "type": {
                    "const": "zeebe:taskHeader"
                  }
                },
                "required": ["type"]
              },
              "then": {
                "required": ["key"],
                "errorMessage": "property.binding ${0/type} requires key"
              }
            }, {
              "examples": [{
                "type": "property",
                "name": "name"
              }, {
                "type": "zeebe:input",
                "name": "input"
              }, {
                "type": "zeebe:output",
                "source": "output"
              }, {
                "type": "zeebe:property",
                "name": "property"
              }, {
                "type": "zeebe:taskDefinition:type"
              }, {
                "type": "zeebe:taskHeader",
                "key": "key"
              }]
            }],
            "properties": {
              "type": {
                "$id": "#/properties/property/binding/type",
                "type": "string",
                "description": "The type of a property binding.",
                "enum": ["property", "zeebe:taskDefinition:type", "zeebe:input", "zeebe:output", "zeebe:property", "zeebe:taskHeader"],
                "errorMessage": "invalid property.binding type ${0}; must be any of { property, zeebe:taskDefinition:type, zeebe:input, zeebe:output, zeebe:property, zeebe:taskHeader }"
              },
              "name": {
                "$id": "#/properties/property/binding/name",
                "type": "string",
                "description": "The name of a property binding."
              },
              "source": {
                "$id": "#/properties/property/binding/source",
                "type": "string",
                "description": "The source value of a property binding (zeebe:output)."
              },
              "key": {
                "$id": "#/properties/property/binding/key",
                "type": "string",
                "description": "The key value of a property binding (zeebe:taskHeader)."
              }
            }
          },
          "optional": {
            "$id": "#/optional",
            "type": "boolean",
            "description": "Indicates whether a property is optional. Optional bindings do not persist empty values in the underlying BPMN 2.0 XML."
          },
          "feel": {
            "$id": "#/properties/property/feel",
            "type": "string",
            "default": null,
            "description": "Indicates whether the property can be a feel expression",
            "enum": [null, "optional", "required"]
          }
        },
        "errorMessage": {
          "required": {
            "binding": "missing binding for property \"${0#}\""
          }
        }
      }
    }]
  };
  const pattern0 = new RegExp("^[\\w\\d]+:[\\w\\d]+$", "u");
  const pattern2 = new RegExp("^(https|http)://.*", "u");
  const pattern3 = new RegExp("^(https?|data):.*", "u");
  const obj0 = {
    "required": "missingProperty",
    "dependencies": "property",
    "dependentRequired": "property"
  };
  const func0 = equal.exports;

  function validate15(data, {
    dataPath = "",
    parentData,
    parentDataProperty,
    rootData = data
  } = {}) {
    let vErrors = null;
    let errors = 0;

    if (data && typeof data == "object" && !Array.isArray(data)) {
      if (data.name === undefined) {
        const err0 = {
          keyword: "required",
          dataPath,
          schemaPath: "#/allOf/0/required",
          params: {
            missingProperty: "name"
          },
          message: "should have required property '" + "name" + "'"
        };

        if (vErrors === null) {
          vErrors = [err0];
        } else {
          vErrors.push(err0);
        }

        errors++;
      }

      if (data.id === undefined) {
        const err1 = {
          keyword: "required",
          dataPath,
          schemaPath: "#/allOf/0/required",
          params: {
            missingProperty: "id"
          },
          message: "should have required property '" + "id" + "'"
        };

        if (vErrors === null) {
          vErrors = [err1];
        } else {
          vErrors.push(err1);
        }

        errors++;
      }

      if (data.appliesTo === undefined) {
        const err2 = {
          keyword: "required",
          dataPath,
          schemaPath: "#/allOf/0/required",
          params: {
            missingProperty: "appliesTo"
          },
          message: "should have required property '" + "appliesTo" + "'"
        };

        if (vErrors === null) {
          vErrors = [err2];
        } else {
          vErrors.push(err2);
        }

        errors++;
      }

      if (data.properties === undefined) {
        const err3 = {
          keyword: "required",
          dataPath,
          schemaPath: "#/allOf/0/required",
          params: {
            missingProperty: "properties"
          },
          message: "should have required property '" + "properties" + "'"
        };

        if (vErrors === null) {
          vErrors = [err3];
        } else {
          vErrors.push(err3);
        }

        errors++;
      }

      if (data.name !== undefined) {
        if (typeof data.name !== "string") {
          const err4 = {
            keyword: "type",
            dataPath: dataPath + "/name",
            schemaPath: "#/allOf/0/properties/name/type",
            params: {
              type: "string"
            },
            message: "should be string"
          };

          if (vErrors === null) {
            vErrors = [err4];
          } else {
            vErrors.push(err4);
          }

          errors++;
        }
      }

      if (data.id !== undefined) {
        if (typeof data.id !== "string") {
          const err5 = {
            keyword: "type",
            dataPath: dataPath + "/id",
            schemaPath: "#/allOf/0/properties/id/type",
            params: {
              type: "string"
            },
            message: "should be string"
          };

          if (vErrors === null) {
            vErrors = [err5];
          } else {
            vErrors.push(err5);
          }

          errors++;
        }
      }

      if (data.description !== undefined) {
        if (typeof data.description !== "string") {
          const err6 = {
            keyword: "type",
            dataPath: dataPath + "/description",
            schemaPath: "#/allOf/0/properties/description/type",
            params: {
              type: "string"
            },
            message: "should be string"
          };

          if (vErrors === null) {
            vErrors = [err6];
          } else {
            vErrors.push(err6);
          }

          errors++;
        }
      }

      if (data.version !== undefined) {
        let data3 = data.version;

        if (!(typeof data3 == "number" && !(data3 % 1) && !isNaN(data3))) {
          const err7 = {
            keyword: "type",
            dataPath: dataPath + "/version",
            schemaPath: "#/allOf/0/properties/version/type",
            params: {
              type: "integer"
            },
            message: "should be integer"
          };

          if (vErrors === null) {
            vErrors = [err7];
          } else {
            vErrors.push(err7);
          }

          errors++;
        }
      }

      if (data.isDefault !== undefined) {
        if (typeof data.isDefault !== "boolean") {
          const err8 = {
            keyword: "type",
            dataPath: dataPath + "/isDefault",
            schemaPath: "#/allOf/0/properties/isDefault/type",
            params: {
              type: "boolean"
            },
            message: "should be boolean"
          };

          if (vErrors === null) {
            vErrors = [err8];
          } else {
            vErrors.push(err8);
          }

          errors++;
        }
      }

      if (data.appliesTo !== undefined) {
        let data5 = data.appliesTo;

        if (Array.isArray(data5)) {
          const len0 = data5.length;

          for (let i0 = 0; i0 < len0; i0++) {
            let data6 = data5[i0];

            if (typeof data6 === "string") {
              if (!pattern0.test(data6)) {
                const err9 = {
                  keyword: "pattern",
                  dataPath: dataPath + "/appliesTo/" + i0,
                  schemaPath: "#/allOf/0/properties/appliesTo/items/pattern",
                  params: {
                    pattern: "^[\\w\\d]+:[\\w\\d]+$"
                  },
                  message: "should match pattern \"" + "^[\\w\\d]+:[\\w\\d]+$" + "\""
                };

                if (vErrors === null) {
                  vErrors = [err9];
                } else {
                  vErrors.push(err9);
                }

                errors++;
              }
            } else {
              const err10 = {
                keyword: "type",
                dataPath: dataPath + "/appliesTo/" + i0,
                schemaPath: "#/allOf/0/properties/appliesTo/items/type",
                params: {
                  type: "string"
                },
                message: "should be string"
              };

              if (vErrors === null) {
                vErrors = [err10];
              } else {
                vErrors.push(err10);
              }

              errors++;
            }

            if (errors > 0) {
              const emErrors0 = {
                "pattern": []
              };
              const templates0 = {};

              for (const err11 of vErrors) {
                if (err11.keyword !== "errorMessage" && !err11.emUsed && err11.dataPath === dataPath + "/appliesTo/" + i0 && err11.keyword in emErrors0 && err11.schemaPath.indexOf("#/allOf/0/properties/appliesTo/items") === 0 && /^\/[^\/]*$/.test(err11.schemaPath.slice(36))) {
                  emErrors0[err11.keyword].push(err11);
                  err11.emUsed = true;
                }
              }

              for (const key0 in emErrors0) {
                if (emErrors0[key0].length) {
                  const err12 = {
                    keyword: "errorMessage",
                    dataPath: dataPath + "/appliesTo/" + i0,
                    schemaPath: "#/allOf/0/properties/appliesTo/items/errorMessage",
                    params: {
                      errors: emErrors0[key0]
                    },
                    message: key0 in templates0 ? templates0[key0]() : schema17.allOf[0].properties.appliesTo.items.errorMessage[key0]
                  };

                  if (vErrors === null) {
                    vErrors = [err12];
                  } else {
                    vErrors.push(err12);
                  }

                  errors++;
                }
              }

              const emErrs0 = [];

              for (const err13 of vErrors) {
                if (!err13.emUsed) {
                  emErrs0.push(err13);
                }
              }

              vErrors = emErrs0;
              errors = emErrs0.length;
            }
          }
        } else {
          const err14 = {
            keyword: "type",
            dataPath: dataPath + "/appliesTo",
            schemaPath: "#/allOf/0/properties/appliesTo/type",
            params: {
              type: "array"
            },
            message: "should be array"
          };

          if (vErrors === null) {
            vErrors = [err14];
          } else {
            vErrors.push(err14);
          }

          errors++;
        }
      }

      if (data.elementType !== undefined) {
        let data7 = data.elementType;

        if (data7 && typeof data7 == "object" && !Array.isArray(data7)) {
          if (data7.value === undefined) {
            const err15 = {
              keyword: "required",
              dataPath: dataPath + "/elementType",
              schemaPath: "#/allOf/0/properties/elementType/required",
              params: {
                missingProperty: "value"
              },
              message: "should have required property '" + "value" + "'"
            };

            if (vErrors === null) {
              vErrors = [err15];
            } else {
              vErrors.push(err15);
            }

            errors++;
          }

          if (data7.value !== undefined) {
            let data8 = data7.value;

            if (typeof data8 === "string") {
              if (!pattern0.test(data8)) {
                const err16 = {
                  keyword: "pattern",
                  dataPath: dataPath + "/elementType/value",
                  schemaPath: "#/allOf/0/properties/elementType/properties/value/pattern",
                  params: {
                    pattern: "^[\\w\\d]+:[\\w\\d]+$"
                  },
                  message: "should match pattern \"" + "^[\\w\\d]+:[\\w\\d]+$" + "\""
                };

                if (vErrors === null) {
                  vErrors = [err16];
                } else {
                  vErrors.push(err16);
                }

                errors++;
              }
            } else {
              const err17 = {
                keyword: "type",
                dataPath: dataPath + "/elementType/value",
                schemaPath: "#/allOf/0/properties/elementType/properties/value/type",
                params: {
                  type: "string"
                },
                message: "should be string"
              };

              if (vErrors === null) {
                vErrors = [err17];
              } else {
                vErrors.push(err17);
              }

              errors++;
            }

            if (errors > 0) {
              const emErrors1 = {
                "pattern": []
              };
              const templates1 = {};

              for (const err18 of vErrors) {
                if (err18.keyword !== "errorMessage" && !err18.emUsed && err18.dataPath === dataPath + "/elementType/value" && err18.keyword in emErrors1 && err18.schemaPath.indexOf("#/allOf/0/properties/elementType/properties/value") === 0 && /^\/[^\/]*$/.test(err18.schemaPath.slice(49))) {
                  emErrors1[err18.keyword].push(err18);
                  err18.emUsed = true;
                }
              }

              for (const key1 in emErrors1) {
                if (emErrors1[key1].length) {
                  const err19 = {
                    keyword: "errorMessage",
                    dataPath: dataPath + "/elementType/value",
                    schemaPath: "#/allOf/0/properties/elementType/properties/value/errorMessage",
                    params: {
                      errors: emErrors1[key1]
                    },
                    message: key1 in templates1 ? templates1[key1]() : schema17.allOf[0].properties.elementType.properties.value.errorMessage[key1]
                  };

                  if (vErrors === null) {
                    vErrors = [err19];
                  } else {
                    vErrors.push(err19);
                  }

                  errors++;
                }
              }

              const emErrs1 = [];

              for (const err20 of vErrors) {
                if (!err20.emUsed) {
                  emErrs1.push(err20);
                }
              }

              vErrors = emErrs1;
              errors = emErrs1.length;
            }
          }
        } else {
          const err21 = {
            keyword: "type",
            dataPath: dataPath + "/elementType",
            schemaPath: "#/allOf/0/properties/elementType/type",
            params: {
              type: "object"
            },
            message: "should be object"
          };

          if (vErrors === null) {
            vErrors = [err21];
          } else {
            vErrors.push(err21);
          }

          errors++;
        }

        if (errors > 0) {
          const emErrors2 = {
            "required": {
              "value": []
            }
          };
          const templates2 = {
            required: {}
          };
          let emPropParams0;
          let emParamsErrors0;

          for (const err22 of vErrors) {
            if (err22.keyword !== "errorMessage" && !err22.emUsed && err22.dataPath === dataPath + "/elementType" && err22.keyword in emErrors2 && err22.schemaPath.indexOf("#/allOf/0/properties/elementType") === 0 && /^\/[^\/]*$/.test(err22.schemaPath.slice(32))) {
              emPropParams0 = obj0[err22.keyword];
              emParamsErrors0 = emErrors2[err22.keyword][err22.params[emPropParams0]];

              if (emParamsErrors0) {
                emParamsErrors0.push(err22);
                err22.emUsed = true;
              }
            }
          }

          for (const key2 in emErrors2) {
            for (const keyProp0 in emErrors2[key2]) {
              emParamsErrors0 = emErrors2[key2][keyProp0];

              if (emParamsErrors0.length) {
                const tmpl0 = templates2[key2] && templates2[key2][keyProp0];
                const err23 = {
                  keyword: "errorMessage",
                  dataPath: dataPath + "/elementType",
                  schemaPath: "#/allOf/0/properties/elementType/errorMessage",
                  params: {
                    errors: emParamsErrors0
                  },
                  message: tmpl0 ? tmpl0() : schema17.allOf[0].properties.elementType.errorMessage[key2][keyProp0]
                };

                if (vErrors === null) {
                  vErrors = [err23];
                } else {
                  vErrors.push(err23);
                }

                errors++;
              }
            }
          }

          const emErrs2 = [];

          for (const err24 of vErrors) {
            if (!err24.emUsed) {
              emErrs2.push(err24);
            }
          }

          vErrors = emErrs2;
          errors = emErrs2.length;
        }
      }

      if (data.metadata !== undefined) {
        let data9 = data.metadata;

        if (!(data9 && typeof data9 == "object" && !Array.isArray(data9))) {
          const err25 = {
            keyword: "type",
            dataPath: dataPath + "/metadata",
            schemaPath: "#/allOf/0/properties/metadata/type",
            params: {
              type: "object"
            },
            message: "should be object"
          };

          if (vErrors === null) {
            vErrors = [err25];
          } else {
            vErrors.push(err25);
          }

          errors++;
        }
      }

      if (data.entriesVisible !== undefined) {
        if (typeof data.entriesVisible !== "boolean") {
          const err26 = {
            keyword: "type",
            dataPath: dataPath + "/entriesVisible",
            schemaPath: "#/allOf/0/properties/entriesVisible/type",
            params: {
              type: "boolean"
            },
            message: "should be boolean"
          };

          if (vErrors === null) {
            vErrors = [err26];
          } else {
            vErrors.push(err26);
          }

          errors++;
        }
      }

      if (data.groups !== undefined) {
        let data11 = data.groups;

        if (Array.isArray(data11)) {
          const len1 = data11.length;

          for (let i1 = 0; i1 < len1; i1++) {
            let data12 = data11[i1];

            if (data12 && typeof data12 == "object" && !Array.isArray(data12)) {
              if (data12.id === undefined) {
                const err27 = {
                  keyword: "required",
                  dataPath: dataPath + "/groups/" + i1,
                  schemaPath: "#/allOf/0/properties/groups/items/required",
                  params: {
                    missingProperty: "id"
                  },
                  message: "should have required property '" + "id" + "'"
                };

                if (vErrors === null) {
                  vErrors = [err27];
                } else {
                  vErrors.push(err27);
                }

                errors++;
              }

              if (data12.label === undefined) {
                const err28 = {
                  keyword: "required",
                  dataPath: dataPath + "/groups/" + i1,
                  schemaPath: "#/allOf/0/properties/groups/items/required",
                  params: {
                    missingProperty: "label"
                  },
                  message: "should have required property '" + "label" + "'"
                };

                if (vErrors === null) {
                  vErrors = [err28];
                } else {
                  vErrors.push(err28);
                }

                errors++;
              }

              if (data12.id !== undefined) {
                if (typeof data12.id !== "string") {
                  const err29 = {
                    keyword: "type",
                    dataPath: dataPath + "/groups/" + i1 + "/id",
                    schemaPath: "#/allOf/0/properties/groups/items/properties/id/type",
                    params: {
                      type: "string"
                    },
                    message: "should be string"
                  };

                  if (vErrors === null) {
                    vErrors = [err29];
                  } else {
                    vErrors.push(err29);
                  }

                  errors++;
                }
              }

              if (data12.label !== undefined) {
                if (typeof data12.label !== "string") {
                  const err30 = {
                    keyword: "type",
                    dataPath: dataPath + "/groups/" + i1 + "/label",
                    schemaPath: "#/allOf/0/properties/groups/items/properties/label/type",
                    params: {
                      type: "string"
                    },
                    message: "should be string"
                  };

                  if (vErrors === null) {
                    vErrors = [err30];
                  } else {
                    vErrors.push(err30);
                  }

                  errors++;
                }
              }
            } else {
              const err31 = {
                keyword: "type",
                dataPath: dataPath + "/groups/" + i1,
                schemaPath: "#/allOf/0/properties/groups/items/type",
                params: {
                  type: "object"
                },
                message: "should be object"
              };

              if (vErrors === null) {
                vErrors = [err31];
              } else {
                vErrors.push(err31);
              }

              errors++;
            }

            if (errors > 0) {
              const emErrors3 = {
                "required": {
                  "id": [],
                  "label": []
                }
              };
              const templates3 = {
                required: {
                  id: function () {
                    return "missing id for group \"" + JSON.stringify(i1) + "\"";
                  },
                  label: function () {
                    return "missing label for group \"" + JSON.stringify(i1) + "\"";
                  }
                }
              };
              let emPropParams1;
              let emParamsErrors1;

              for (const err32 of vErrors) {
                if (err32.keyword !== "errorMessage" && !err32.emUsed && err32.dataPath === dataPath + "/groups/" + i1 && err32.keyword in emErrors3 && err32.schemaPath.indexOf("#/allOf/0/properties/groups/items") === 0 && /^\/[^\/]*$/.test(err32.schemaPath.slice(33))) {
                  emPropParams1 = obj0[err32.keyword];
                  emParamsErrors1 = emErrors3[err32.keyword][err32.params[emPropParams1]];

                  if (emParamsErrors1) {
                    emParamsErrors1.push(err32);
                    err32.emUsed = true;
                  }
                }
              }

              for (const key3 in emErrors3) {
                for (const keyProp1 in emErrors3[key3]) {
                  emParamsErrors1 = emErrors3[key3][keyProp1];

                  if (emParamsErrors1.length) {
                    const tmpl1 = templates3[key3] && templates3[key3][keyProp1];
                    const err33 = {
                      keyword: "errorMessage",
                      dataPath: dataPath + "/groups/" + i1,
                      schemaPath: "#/allOf/0/properties/groups/items/errorMessage",
                      params: {
                        errors: emParamsErrors1
                      },
                      message: tmpl1 ? tmpl1() : schema17.allOf[0].properties.groups.items.errorMessage[key3][keyProp1]
                    };

                    if (vErrors === null) {
                      vErrors = [err33];
                    } else {
                      vErrors.push(err33);
                    }

                    errors++;
                  }
                }
              }

              const emErrs3 = [];

              for (const err34 of vErrors) {
                if (!err34.emUsed) {
                  emErrs3.push(err34);
                }
              }

              vErrors = emErrs3;
              errors = emErrs3.length;
            }
          }
        } else {
          const err35 = {
            keyword: "type",
            dataPath: dataPath + "/groups",
            schemaPath: "#/allOf/0/properties/groups/type",
            params: {
              type: "array"
            },
            message: "should be array"
          };

          if (vErrors === null) {
            vErrors = [err35];
          } else {
            vErrors.push(err35);
          }

          errors++;
        }
      }

      if (data.documentationRef !== undefined) {
        let data15 = data.documentationRef;

        if (typeof data15 === "string") {
          if (!pattern2.test(data15)) {
            const err36 = {
              keyword: "pattern",
              dataPath: dataPath + "/documentationRef",
              schemaPath: "#/allOf/0/properties/documentationRef/pattern",
              params: {
                pattern: "^(https|http)://.*"
              },
              message: "should match pattern \"" + "^(https|http)://.*" + "\""
            };

            if (vErrors === null) {
              vErrors = [err36];
            } else {
              vErrors.push(err36);
            }

            errors++;
          }
        } else {
          const err37 = {
            keyword: "type",
            dataPath: dataPath + "/documentationRef",
            schemaPath: "#/allOf/0/properties/documentationRef/type",
            params: {
              type: "string"
            },
            message: "should be string"
          };

          if (vErrors === null) {
            vErrors = [err37];
          } else {
            vErrors.push(err37);
          }

          errors++;
        }

        if (errors > 0) {
          const emErrors4 = {
            "pattern": []
          };
          const templates4 = {};

          for (const err38 of vErrors) {
            if (err38.keyword !== "errorMessage" && !err38.emUsed && err38.dataPath === dataPath + "/documentationRef" && err38.keyword in emErrors4 && err38.schemaPath.indexOf("#/allOf/0/properties/documentationRef") === 0 && /^\/[^\/]*$/.test(err38.schemaPath.slice(37))) {
              emErrors4[err38.keyword].push(err38);
              err38.emUsed = true;
            }
          }

          for (const key4 in emErrors4) {
            if (emErrors4[key4].length) {
              const err39 = {
                keyword: "errorMessage",
                dataPath: dataPath + "/documentationRef",
                schemaPath: "#/allOf/0/properties/documentationRef/errorMessage",
                params: {
                  errors: emErrors4[key4]
                },
                message: key4 in templates4 ? templates4[key4]() : schema17.allOf[0].properties.documentationRef.errorMessage[key4]
              };

              if (vErrors === null) {
                vErrors = [err39];
              } else {
                vErrors.push(err39);
              }

              errors++;
            }
          }

          const emErrs4 = [];

          for (const err40 of vErrors) {
            if (!err40.emUsed) {
              emErrs4.push(err40);
            }
          }

          vErrors = emErrs4;
          errors = emErrs4.length;
        }
      }
    }

    if (errors > 0) {
      const emErrors5 = {
        "required": {
          "name": [],
          "id": [],
          "appliesTo": [],
          "properties": []
        }
      };
      const templates5 = {
        required: {}
      };
      let emPropParams2;
      let emParamsErrors2;

      for (const err41 of vErrors) {
        if (err41.keyword !== "errorMessage" && !err41.emUsed && err41.dataPath === dataPath && err41.keyword in emErrors5 && err41.schemaPath.indexOf("#/allOf/0") === 0 && /^\/[^\/]*$/.test(err41.schemaPath.slice(9))) {
          emPropParams2 = obj0[err41.keyword];
          emParamsErrors2 = emErrors5[err41.keyword][err41.params[emPropParams2]];

          if (emParamsErrors2) {
            emParamsErrors2.push(err41);
            err41.emUsed = true;
          }
        }
      }

      for (const key5 in emErrors5) {
        for (const keyProp2 in emErrors5[key5]) {
          emParamsErrors2 = emErrors5[key5][keyProp2];

          if (emParamsErrors2.length) {
            const tmpl2 = templates5[key5] && templates5[key5][keyProp2];
            const err42 = {
              keyword: "errorMessage",
              dataPath,
              schemaPath: "#/allOf/0/errorMessage",
              params: {
                errors: emParamsErrors2
              },
              message: tmpl2 ? tmpl2() : schema17.allOf[0].errorMessage[key5][keyProp2]
            };

            if (vErrors === null) {
              vErrors = [err42];
            } else {
              vErrors.push(err42);
            }

            errors++;
          }
        }
      }

      const emErrs5 = [];

      for (const err43 of vErrors) {
        if (!err43.emUsed) {
          emErrs5.push(err43);
        }
      }

      vErrors = emErrs5;
      errors = emErrs5.length;
    }

    if (data && typeof data == "object" && !Array.isArray(data)) {
      if (data.properties !== undefined) {
        let data16 = data.properties;

        if (Array.isArray(data16)) {
          const len2 = data16.length;

          for (let i2 = 0; i2 < len2; i2++) {
            let data17 = data16[i2];
            const _errs41 = errors;
            let valid18 = true;
            const _errs42 = errors;

            if (data17 && typeof data17 == "object" && !Array.isArray(data17)) {
              if (data17.type === undefined && "type") {
                const err44 = {};

                if (vErrors === null) {
                  vErrors = [err44];
                } else {
                  vErrors.push(err44);
                }

                errors++;
              } else {
                if (data17.type !== undefined) {
                  if (!func0(data17.type, "Dropdown")) {
                    const err45 = {};

                    if (vErrors === null) {
                      vErrors = [err45];
                    } else {
                      vErrors.push(err45);
                    }

                    errors++;
                  }
                }
              }
            }

            var _valid0 = _errs42 === errors;

            errors = _errs41;

            if (vErrors !== null) {
              if (_errs41) {
                vErrors.length = _errs41;
              } else {
                vErrors = null;
              }
            }

            if (_valid0) {
              const _errs44 = errors;

              if (data17 && typeof data17 == "object" && !Array.isArray(data17)) {
                if (data17.choices === undefined) {
                  const err46 = {
                    keyword: "required",
                    dataPath: dataPath + "/properties/" + i2,
                    schemaPath: "#/definitions/properties/allOf/0/items/allOf/0/then/required",
                    params: {
                      missingProperty: "choices"
                    },
                    message: "should have required property '" + "choices" + "'"
                  };

                  if (vErrors === null) {
                    vErrors = [err46];
                  } else {
                    vErrors.push(err46);
                  }

                  errors++;
                }
              }

              if (errors > 0) {
                const emErrs6 = [];

                for (const err47 of vErrors) {
                  if (err47.keyword !== "errorMessage" && !err47.emUsed && (err47.dataPath === dataPath + "/properties/" + i2 || err47.dataPath.indexOf(dataPath + "/properties/" + i2) === 0 && err47.dataPath[dataPath + "/properties/" + i2.length] === "/") && err47.schemaPath.indexOf("#/definitions/properties/allOf/0/items/allOf/0/then") === 0 && err47.schemaPath["#/definitions/properties/allOf/0/items/allOf/0/then".length] === "/") {
                    emErrs6.push(err47);
                    err47.emUsed = true;
                  }
                }

                if (emErrs6.length) {
                  const err48 = {
                    keyword: "errorMessage",
                    dataPath: dataPath + "/properties/" + i2,
                    schemaPath: "#/definitions/properties/allOf/0/items/allOf/0/then/errorMessage",
                    params: {
                      errors: emErrs6
                    },
                    message: "must provide choices=[] with \"Dropdown\" type"
                  };

                  if (vErrors === null) {
                    vErrors = [err48];
                  } else {
                    vErrors.push(err48);
                  }

                  errors++;
                }

                const emErrs7 = [];

                for (const err49 of vErrors) {
                  if (!err49.emUsed) {
                    emErrs7.push(err49);
                  }
                }

                vErrors = emErrs7;
                errors = emErrs7.length;
              }

              var _valid0 = _errs44 === errors;

              valid18 = _valid0;
            }

            if (!valid18) {
              const err50 = {
                keyword: "if",
                dataPath: dataPath + "/properties/" + i2,
                schemaPath: "#/definitions/properties/allOf/0/items/allOf/0/if",
                params: {
                  failingKeyword: "then"
                },
                message: "should match \"then\" schema"
              };

              if (vErrors === null) {
                vErrors = [err50];
              } else {
                vErrors.push(err50);
              }

              errors++;
            }

            if (data17 && typeof data17 == "object" && !Array.isArray(data17)) {
              if (data17.id !== undefined) {
                if (typeof data17.id !== "string") {
                  const err51 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i2 + "/id",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/id/type",
                    params: {
                      type: "string"
                    },
                    message: "should be string"
                  };

                  if (vErrors === null) {
                    vErrors = [err51];
                  } else {
                    vErrors.push(err51);
                  }

                  errors++;
                }
              }

              if (data17.value !== undefined) {
                let data20 = data17.value;

                if (typeof data20 !== "string" && typeof data20 !== "boolean") {
                  const err52 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i2 + "/value",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/value/type",
                    params: {
                      type: schema18.allOf[0].items.properties.value.type
                    },
                    message: "should be string,boolean"
                  };

                  if (vErrors === null) {
                    vErrors = [err52];
                  } else {
                    vErrors.push(err52);
                  }

                  errors++;
                }
              }

              if (data17.description !== undefined) {
                if (typeof data17.description !== "string") {
                  const err53 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i2 + "/description",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/description/type",
                    params: {
                      type: "string"
                    },
                    message: "should be string"
                  };

                  if (vErrors === null) {
                    vErrors = [err53];
                  } else {
                    vErrors.push(err53);
                  }

                  errors++;
                }
              }

              if (data17.label !== undefined) {
                if (typeof data17.label !== "string") {
                  const err54 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i2 + "/label",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/label/type",
                    params: {
                      type: "string"
                    },
                    message: "should be string"
                  };

                  if (vErrors === null) {
                    vErrors = [err54];
                  } else {
                    vErrors.push(err54);
                  }

                  errors++;
                }
              }

              if (data17.type !== undefined) {
                if (typeof data17.type !== "string") {
                  const err55 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i2 + "/type",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/type/type",
                    params: {
                      type: "string"
                    },
                    message: "should be string"
                  };

                  if (vErrors === null) {
                    vErrors = [err55];
                  } else {
                    vErrors.push(err55);
                  }

                  errors++;
                }
              }

              if (data17.editable !== undefined) {
                if (typeof data17.editable !== "boolean") {
                  const err56 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i2 + "/editable",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/editable/type",
                    params: {
                      type: "boolean"
                    },
                    message: "should be boolean"
                  };

                  if (vErrors === null) {
                    vErrors = [err56];
                  } else {
                    vErrors.push(err56);
                  }

                  errors++;
                }
              }

              if (data17.choices !== undefined) {
                let data25 = data17.choices;

                if (Array.isArray(data25)) {
                  const len3 = data25.length;

                  for (let i3 = 0; i3 < len3; i3++) {
                    let data26 = data25[i3];

                    if (data26 && typeof data26 == "object" && !Array.isArray(data26)) {
                      if (data26.value === undefined) {
                        const err57 = {
                          keyword: "required",
                          dataPath: dataPath + "/properties/" + i2 + "/choices/" + i3,
                          schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/items/required",
                          params: {
                            missingProperty: "value"
                          },
                          message: "should have required property '" + "value" + "'"
                        };

                        if (vErrors === null) {
                          vErrors = [err57];
                        } else {
                          vErrors.push(err57);
                        }

                        errors++;
                      }

                      if (data26.name === undefined) {
                        const err58 = {
                          keyword: "required",
                          dataPath: dataPath + "/properties/" + i2 + "/choices/" + i3,
                          schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/items/required",
                          params: {
                            missingProperty: "name"
                          },
                          message: "should have required property '" + "name" + "'"
                        };

                        if (vErrors === null) {
                          vErrors = [err58];
                        } else {
                          vErrors.push(err58);
                        }

                        errors++;
                      }

                      if (data26.name !== undefined) {
                        if (typeof data26.name !== "string") {
                          const err59 = {
                            keyword: "type",
                            dataPath: dataPath + "/properties/" + i2 + "/choices/" + i3 + "/name",
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/items/properties/name/type",
                            params: {
                              type: "string"
                            },
                            message: "should be string"
                          };

                          if (vErrors === null) {
                            vErrors = [err59];
                          } else {
                            vErrors.push(err59);
                          }

                          errors++;
                        }
                      }

                      if (data26.value !== undefined) {
                        if (typeof data26.value !== "string") {
                          const err60 = {
                            keyword: "type",
                            dataPath: dataPath + "/properties/" + i2 + "/choices/" + i3 + "/value",
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/items/properties/value/type",
                            params: {
                              type: "string"
                            },
                            message: "should be string"
                          };

                          if (vErrors === null) {
                            vErrors = [err60];
                          } else {
                            vErrors.push(err60);
                          }

                          errors++;
                        }
                      }
                    } else {
                      const err61 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i2 + "/choices/" + i3,
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/items/type",
                        params: {
                          type: "object"
                        },
                        message: "should be object"
                      };

                      if (vErrors === null) {
                        vErrors = [err61];
                      } else {
                        vErrors.push(err61);
                      }

                      errors++;
                    }

                    if (errors > 0) {
                      const emErrors6 = {
                        "required": []
                      };
                      const templates6 = {};

                      for (const err62 of vErrors) {
                        if (err62.keyword !== "errorMessage" && !err62.emUsed && err62.dataPath === dataPath + "/properties/" + i2 + "/choices/" + i3 && err62.keyword in emErrors6 && err62.schemaPath.indexOf("#/definitions/properties/allOf/0/items/properties/choices/items") === 0 && /^\/[^\/]*$/.test(err62.schemaPath.slice(63))) {
                          emErrors6[err62.keyword].push(err62);
                          err62.emUsed = true;
                        }
                      }

                      for (const key6 in emErrors6) {
                        if (emErrors6[key6].length) {
                          const err63 = {
                            keyword: "errorMessage",
                            dataPath: dataPath + "/properties/" + i2 + "/choices/" + i3,
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/items/errorMessage",
                            params: {
                              errors: emErrors6[key6]
                            },
                            message: key6 in templates6 ? templates6[key6]() : schema18.allOf[0].items.properties.choices.items.errorMessage[key6]
                          };

                          if (vErrors === null) {
                            vErrors = [err63];
                          } else {
                            vErrors.push(err63);
                          }

                          errors++;
                        }
                      }

                      const emErrs8 = [];

                      for (const err64 of vErrors) {
                        if (!err64.emUsed) {
                          emErrs8.push(err64);
                        }
                      }

                      vErrors = emErrs8;
                      errors = emErrs8.length;
                    }
                  }
                } else {
                  const err65 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i2 + "/choices",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/choices/type",
                    params: {
                      type: "array"
                    },
                    message: "should be array"
                  };

                  if (vErrors === null) {
                    vErrors = [err65];
                  } else {
                    vErrors.push(err65);
                  }

                  errors++;
                }
              }

              if (data17.constraints !== undefined) {
                let data29 = data17.constraints;

                if (data29 && typeof data29 == "object" && !Array.isArray(data29)) {
                  if (data29.notEmpty !== undefined) {
                    if (typeof data29.notEmpty !== "boolean") {
                      const err66 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i2 + "/constraints/notEmpty",
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/notEmpty/type",
                        params: {
                          type: "boolean"
                        },
                        message: "should be boolean"
                      };

                      if (vErrors === null) {
                        vErrors = [err66];
                      } else {
                        vErrors.push(err66);
                      }

                      errors++;
                    }
                  }

                  if (data29.minLength !== undefined) {
                    if (!(typeof data29.minLength == "number")) {
                      const err67 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i2 + "/constraints/minLength",
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/minLength/type",
                        params: {
                          type: "number"
                        },
                        message: "should be number"
                      };

                      if (vErrors === null) {
                        vErrors = [err67];
                      } else {
                        vErrors.push(err67);
                      }

                      errors++;
                    }
                  }

                  if (data29.maxLength !== undefined) {
                    if (!(typeof data29.maxLength == "number")) {
                      const err68 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i2 + "/constraints/maxLength",
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/maxLength/type",
                        params: {
                          type: "number"
                        },
                        message: "should be number"
                      };

                      if (vErrors === null) {
                        vErrors = [err68];
                      } else {
                        vErrors.push(err68);
                      }

                      errors++;
                    }
                  }

                  if (data29.pattern !== undefined) {
                    let data33 = data29.pattern;
                    const _errs74 = errors;
                    let valid26 = false;
                    let passing0 = null;
                    const _errs75 = errors;

                    if (data33 && typeof data33 == "object" && !Array.isArray(data33)) {
                      if (data33.value !== undefined) {
                        if (typeof data33.value !== "string") {
                          const err69 = {
                            keyword: "type",
                            dataPath: dataPath + "/properties/" + i2 + "/constraints/pattern/value",
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/pattern/oneOf/0/properties/value/type",
                            params: {
                              type: "string"
                            },
                            message: "should be string"
                          };

                          if (vErrors === null) {
                            vErrors = [err69];
                          } else {
                            vErrors.push(err69);
                          }

                          errors++;
                        }
                      }

                      if (data33.message !== undefined) {
                        if (typeof data33.message !== "string") {
                          const err70 = {
                            keyword: "type",
                            dataPath: dataPath + "/properties/" + i2 + "/constraints/pattern/message",
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/pattern/oneOf/0/properties/message/type",
                            params: {
                              type: "string"
                            },
                            message: "should be string"
                          };

                          if (vErrors === null) {
                            vErrors = [err70];
                          } else {
                            vErrors.push(err70);
                          }

                          errors++;
                        }
                      }
                    } else {
                      const err71 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i2 + "/constraints/pattern",
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/pattern/oneOf/0/type",
                        params: {
                          type: "object"
                        },
                        message: "should be object"
                      };

                      if (vErrors === null) {
                        vErrors = [err71];
                      } else {
                        vErrors.push(err71);
                      }

                      errors++;
                    }

                    var _valid1 = _errs75 === errors;

                    if (_valid1) {
                      valid26 = true;
                      passing0 = 0;
                    }

                    const _errs81 = errors;

                    if (typeof data33 !== "string") {
                      const err72 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i2 + "/constraints/pattern",
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/pattern/oneOf/1/type",
                        params: {
                          type: "string"
                        },
                        message: "should be string"
                      };

                      if (vErrors === null) {
                        vErrors = [err72];
                      } else {
                        vErrors.push(err72);
                      }

                      errors++;
                    }

                    var _valid1 = _errs81 === errors;

                    if (_valid1 && valid26) {
                      valid26 = false;
                      passing0 = [passing0, 1];
                    } else {
                      if (_valid1) {
                        valid26 = true;
                        passing0 = 1;
                      }
                    }

                    if (!valid26) {
                      const err73 = {
                        keyword: "oneOf",
                        dataPath: dataPath + "/properties/" + i2 + "/constraints/pattern",
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/properties/pattern/oneOf",
                        params: {
                          passingSchemas: passing0
                        },
                        message: "should match exactly one schema in oneOf"
                      };

                      if (vErrors === null) {
                        vErrors = [err73];
                      } else {
                        vErrors.push(err73);
                      }

                      errors++;
                    } else {
                      errors = _errs74;

                      if (vErrors !== null) {
                        if (_errs74) {
                          vErrors.length = _errs74;
                        } else {
                          vErrors = null;
                        }
                      }
                    }
                  }
                } else {
                  const err74 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i2 + "/constraints",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/constraints/type",
                    params: {
                      type: "object"
                    },
                    message: "should be object"
                  };

                  if (vErrors === null) {
                    vErrors = [err74];
                  } else {
                    vErrors.push(err74);
                  }

                  errors++;
                }
              }

              if (data17.group !== undefined) {
                if (typeof data17.group !== "string") {
                  const err75 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i2 + "/group",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/group/type",
                    params: {
                      type: "string"
                    },
                    message: "should be string"
                  };

                  if (vErrors === null) {
                    vErrors = [err75];
                  } else {
                    vErrors.push(err75);
                  }

                  errors++;
                }
              }

              if (data17.condition !== undefined) {
                let data37 = data17.condition;
                const _errs87 = errors;
                let valid28 = false;
                let passing1 = null;
                const _errs88 = errors;

                if (data37 && typeof data37 == "object" && !Array.isArray(data37)) {
                  if (data37.equals === undefined) {
                    const err76 = {
                      keyword: "required",
                      dataPath: dataPath + "/properties/" + i2 + "/condition",
                      schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/oneOf/0/required",
                      params: {
                        missingProperty: "equals"
                      },
                      message: "should have required property '" + "equals" + "'"
                    };

                    if (vErrors === null) {
                      vErrors = [err76];
                    } else {
                      vErrors.push(err76);
                    }

                    errors++;
                  }

                  if (data37.equals !== undefined) {
                    let data38 = data37.equals;

                    if (typeof data38 !== "string" && !(typeof data38 == "number") && typeof data38 !== "boolean") {
                      const err77 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i2 + "/condition/equals",
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/oneOf/0/properties/equals/type",
                        params: {
                          type: schema18.allOf[0].items.properties.condition.oneOf[0].properties.equals.type
                        },
                        message: "should be string,number,boolean"
                      };

                      if (vErrors === null) {
                        vErrors = [err77];
                      } else {
                        vErrors.push(err77);
                      }

                      errors++;
                    }
                  }
                }

                var _valid2 = _errs88 === errors;

                if (_valid2) {
                  valid28 = true;
                  passing1 = 0;
                }

                const _errs91 = errors;

                if (data37 && typeof data37 == "object" && !Array.isArray(data37)) {
                  if (data37.oneOf === undefined) {
                    const err78 = {
                      keyword: "required",
                      dataPath: dataPath + "/properties/" + i2 + "/condition",
                      schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/oneOf/1/required",
                      params: {
                        missingProperty: "oneOf"
                      },
                      message: "should have required property '" + "oneOf" + "'"
                    };

                    if (vErrors === null) {
                      vErrors = [err78];
                    } else {
                      vErrors.push(err78);
                    }

                    errors++;
                  }

                  if (data37.oneOf !== undefined) {
                    let data39 = data37.oneOf;

                    if (Array.isArray(data39)) {
                      const len4 = data39.length;

                      for (let i4 = 0; i4 < len4; i4++) {
                        let data40 = data39[i4];

                        if (typeof data40 !== "string" && !(typeof data40 == "number")) {
                          const err79 = {
                            keyword: "type",
                            dataPath: dataPath + "/properties/" + i2 + "/condition/oneOf/" + i4,
                            schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/oneOf/1/properties/oneOf/items/type",
                            params: {
                              type: schema18.allOf[0].items.properties.condition.oneOf[1].properties.oneOf.items.type
                            },
                            message: "should be string,number"
                          };

                          if (vErrors === null) {
                            vErrors = [err79];
                          } else {
                            vErrors.push(err79);
                          }

                          errors++;
                        }
                      }
                    } else {
                      const err80 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i2 + "/condition/oneOf",
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/oneOf/1/properties/oneOf/type",
                        params: {
                          type: "array"
                        },
                        message: "should be array"
                      };

                      if (vErrors === null) {
                        vErrors = [err80];
                      } else {
                        vErrors.push(err80);
                      }

                      errors++;
                    }
                  }
                }

                var _valid2 = _errs91 === errors;

                if (_valid2 && valid28) {
                  valid28 = false;
                  passing1 = [passing1, 1];
                } else {
                  if (_valid2) {
                    valid28 = true;
                    passing1 = 1;
                  }
                }

                if (!valid28) {
                  const err81 = {
                    keyword: "oneOf",
                    dataPath: dataPath + "/properties/" + i2 + "/condition",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/oneOf",
                    params: {
                      passingSchemas: passing1
                    },
                    message: "should match exactly one schema in oneOf"
                  };

                  if (vErrors === null) {
                    vErrors = [err81];
                  } else {
                    vErrors.push(err81);
                  }

                  errors++;
                } else {
                  errors = _errs87;

                  if (vErrors !== null) {
                    if (_errs87) {
                      vErrors.length = _errs87;
                    } else {
                      vErrors = null;
                    }
                  }
                }

                if (data37 && typeof data37 == "object" && !Array.isArray(data37)) {
                  if (data37.property === undefined) {
                    const err82 = {
                      keyword: "required",
                      dataPath: dataPath + "/properties/" + i2 + "/condition",
                      schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/required",
                      params: {
                        missingProperty: "property"
                      },
                      message: "should have required property '" + "property" + "'"
                    };

                    if (vErrors === null) {
                      vErrors = [err82];
                    } else {
                      vErrors.push(err82);
                    }

                    errors++;
                  }

                  if (data37.type !== undefined) {
                    if (!func0(data37.type, "simple")) {
                      const err83 = {
                        keyword: "const",
                        dataPath: dataPath + "/properties/" + i2 + "/condition/type",
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/properties/type/const",
                        params: {
                          allowedValue: "simple"
                        },
                        message: "should be equal to constant"
                      };

                      if (vErrors === null) {
                        vErrors = [err83];
                      } else {
                        vErrors.push(err83);
                      }

                      errors++;
                    }
                  }

                  if (data37.property !== undefined) {
                    if (typeof data37.property !== "string") {
                      const err84 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i2 + "/condition/property",
                        schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/properties/property/type",
                        params: {
                          type: "string"
                        },
                        message: "should be string"
                      };

                      if (vErrors === null) {
                        vErrors = [err84];
                      } else {
                        vErrors.push(err84);
                      }

                      errors++;
                    }
                  }
                } else {
                  const err85 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i2 + "/condition",
                    schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/type",
                    params: {
                      type: "object"
                    },
                    message: "should be object"
                  };

                  if (vErrors === null) {
                    vErrors = [err85];
                  } else {
                    vErrors.push(err85);
                  }

                  errors++;
                }

                if (errors > 0) {
                  const emErrors7 = {
                    "required": {
                      "property": []
                    }
                  };
                  const templates7 = {
                    required: {}
                  };
                  let emPropParams3;
                  let emParamsErrors3;

                  for (const err86 of vErrors) {
                    if (err86.keyword !== "errorMessage" && !err86.emUsed && err86.dataPath === dataPath + "/properties/" + i2 + "/condition" && err86.keyword in emErrors7 && err86.schemaPath.indexOf("#/definitions/properties/allOf/0/items/properties/condition") === 0 && /^\/[^\/]*$/.test(err86.schemaPath.slice(59))) {
                      emPropParams3 = obj0[err86.keyword];
                      emParamsErrors3 = emErrors7[err86.keyword][err86.params[emPropParams3]];

                      if (emParamsErrors3) {
                        emParamsErrors3.push(err86);
                        err86.emUsed = true;
                      }
                    }
                  }

                  for (const key7 in emErrors7) {
                    for (const keyProp3 in emErrors7[key7]) {
                      emParamsErrors3 = emErrors7[key7][keyProp3];

                      if (emParamsErrors3.length) {
                        const tmpl3 = templates7[key7] && templates7[key7][keyProp3];
                        const err87 = {
                          keyword: "errorMessage",
                          dataPath: dataPath + "/properties/" + i2 + "/condition",
                          schemaPath: "#/definitions/properties/allOf/0/items/properties/condition/errorMessage",
                          params: {
                            errors: emParamsErrors3
                          },
                          message: tmpl3 ? tmpl3() : schema18.allOf[0].items.properties.condition.errorMessage[key7][keyProp3]
                        };

                        if (vErrors === null) {
                          vErrors = [err87];
                        } else {
                          vErrors.push(err87);
                        }

                        errors++;
                      }
                    }
                  }

                  const emErrs9 = [];

                  for (const err88 of vErrors) {
                    if (!err88.emUsed) {
                      emErrs9.push(err88);
                    }
                  }

                  vErrors = emErrs9;
                  errors = emErrs9.length;
                }
              }
            } else {
              const err89 = {
                keyword: "type",
                dataPath: dataPath + "/properties/" + i2,
                schemaPath: "#/definitions/properties/allOf/0/items/type",
                params: {
                  type: "object"
                },
                message: "should be object"
              };

              if (vErrors === null) {
                vErrors = [err89];
              } else {
                vErrors.push(err89);
              }

              errors++;
            }
          }
        } else {
          const err90 = {
            keyword: "type",
            dataPath: dataPath + "/properties",
            schemaPath: "#/definitions/properties/allOf/0/type",
            params: {
              type: "array"
            },
            message: "should be array"
          };

          if (vErrors === null) {
            vErrors = [err90];
          } else {
            vErrors.push(err90);
          }

          errors++;
        }

        if (Array.isArray(data16)) {
          const len5 = data16.length;

          for (let i5 = 0; i5 < len5; i5++) {
            let data43 = data16[i5];
            const _errs104 = errors;
            let valid38 = true;
            const _errs105 = errors;

            if (data43 && typeof data43 == "object" && !Array.isArray(data43)) {
              if (data43.binding === undefined && "binding") {
                const err91 = {};

                if (vErrors === null) {
                  vErrors = [err91];
                } else {
                  vErrors.push(err91);
                }

                errors++;
              } else {
                if (data43.binding !== undefined) {
                  let data44 = data43.binding;

                  if (data44 && typeof data44 == "object" && !Array.isArray(data44)) {
                    if (data44.type === undefined && "type") {
                      const err92 = {};

                      if (vErrors === null) {
                        vErrors = [err92];
                      } else {
                        vErrors.push(err92);
                      }

                      errors++;
                    } else {
                      if (data44.type !== undefined) {
                        if (!func0(data44.type, "property")) {
                          const err93 = {};

                          if (vErrors === null) {
                            vErrors = [err93];
                          } else {
                            vErrors.push(err93);
                          }

                          errors++;
                        }
                      }
                    }
                  }
                }
              }
            }

            var _valid3 = _errs105 === errors;

            errors = _errs104;

            if (vErrors !== null) {
              if (_errs104) {
                vErrors.length = _errs104;
              } else {
                vErrors = null;
              }
            }

            if (_valid3) {
              const _errs108 = errors;

              if (data43 && typeof data43 == "object" && !Array.isArray(data43)) {
                if (data43.type !== undefined) {
                  let data46 = data43.type;

                  if (!(data46 === "String" || data46 === "Text" || data46 === "Hidden" || data46 === "Dropdown" || data46 === "Boolean")) {
                    const err94 = {
                      keyword: "enum",
                      dataPath: dataPath + "/properties/" + i5 + "/type",
                      schemaPath: "#/definitions/properties/allOf/1/items/allOf/0/then/properties/type/enum",
                      params: {
                        allowedValues: schema18.allOf[1].items.allOf[0].then.properties.type.enum
                      },
                      message: "should be equal to one of the allowed values"
                    };

                    if (vErrors === null) {
                      vErrors = [err94];
                    } else {
                      vErrors.push(err94);
                    }

                    errors++;
                  }

                  if (errors > 0) {
                    const emErrs10 = [];

                    for (const err95 of vErrors) {
                      if (err95.keyword !== "errorMessage" && !err95.emUsed && (err95.dataPath === dataPath + "/properties/" + i5 + "/type" || err95.dataPath.indexOf(dataPath + "/properties/" + i5 + "/type") === 0 && err95.dataPath[dataPath + "/properties/" + i5 + "/type".length] === "/") && err95.schemaPath.indexOf("#/definitions/properties/allOf/1/items/allOf/0/then/properties/type") === 0 && err95.schemaPath["#/definitions/properties/allOf/1/items/allOf/0/then/properties/type".length] === "/") {
                        emErrs10.push(err95);
                        err95.emUsed = true;
                      }
                    }

                    if (emErrs10.length) {
                      const err96 = {
                        keyword: "errorMessage",
                        dataPath: dataPath + "/properties/" + i5 + "/type",
                        schemaPath: "#/definitions/properties/allOf/1/items/allOf/0/then/properties/type/errorMessage",
                        params: {
                          errors: emErrs10
                        },
                        message: "invalid property type " + JSON.stringify(data46) + " for binding type \"property\"; must be any of { String, Text, Hidden, Dropdown, Boolean }"
                      };

                      if (vErrors === null) {
                        vErrors = [err96];
                      } else {
                        vErrors.push(err96);
                      }

                      errors++;
                    }

                    const emErrs11 = [];

                    for (const err97 of vErrors) {
                      if (!err97.emUsed) {
                        emErrs11.push(err97);
                      }
                    }

                    vErrors = emErrs11;
                    errors = emErrs11.length;
                  }
                }
              }

              var _valid3 = _errs108 === errors;

              valid38 = _valid3;
            }

            if (!valid38) {
              const err98 = {
                keyword: "if",
                dataPath: dataPath + "/properties/" + i5,
                schemaPath: "#/definitions/properties/allOf/1/items/allOf/0/if",
                params: {
                  failingKeyword: "then"
                },
                message: "should match \"then\" schema"
              };

              if (vErrors === null) {
                vErrors = [err98];
              } else {
                vErrors.push(err98);
              }

              errors++;
            }

            const _errs111 = errors;
            let valid42 = true;
            const _errs112 = errors;

            if (data43 && typeof data43 == "object" && !Array.isArray(data43)) {
              if (data43.binding === undefined && "binding") {
                const err99 = {};

                if (vErrors === null) {
                  vErrors = [err99];
                } else {
                  vErrors.push(err99);
                }

                errors++;
              } else {
                if (data43.binding !== undefined) {
                  let data47 = data43.binding;

                  if (data47 && typeof data47 == "object" && !Array.isArray(data47)) {
                    if (data47.type === undefined && "type") {
                      const err100 = {};

                      if (vErrors === null) {
                        vErrors = [err100];
                      } else {
                        vErrors.push(err100);
                      }

                      errors++;
                    } else {
                      if (data47.type !== undefined) {
                        let data48 = data47.type;

                        if (!(data48 === "zeebe:input" || data48 === "zeebe:output" || data48 === "zeebe:property" || data48 === "zeebe:taskHeader" || data48 === "zeebe:taskDefinition:type")) {
                          const err101 = {};

                          if (vErrors === null) {
                            vErrors = [err101];
                          } else {
                            vErrors.push(err101);
                          }

                          errors++;
                        }
                      }
                    }
                  }
                }
              }
            }

            var _valid4 = _errs112 === errors;

            errors = _errs111;

            if (vErrors !== null) {
              if (_errs111) {
                vErrors.length = _errs111;
              } else {
                vErrors = null;
              }
            }

            if (_valid4) {
              const _errs115 = errors;

              if (data43 && typeof data43 == "object" && !Array.isArray(data43)) {
                if (data43.type !== undefined) {
                  let data49 = data43.type;

                  if (!(data49 === "String" || data49 === "Text" || data49 === "Hidden" || data49 === "Dropdown")) {
                    const err102 = {
                      keyword: "enum",
                      dataPath: dataPath + "/properties/" + i5 + "/type",
                      schemaPath: "#/definitions/properties/allOf/1/items/allOf/1/then/properties/type/enum",
                      params: {
                        allowedValues: schema18.allOf[1].items.allOf[1].then.properties.type.enum
                      },
                      message: "should be equal to one of the allowed values"
                    };

                    if (vErrors === null) {
                      vErrors = [err102];
                    } else {
                      vErrors.push(err102);
                    }

                    errors++;
                  }

                  if (errors > 0) {
                    const emErrs12 = [];

                    for (const err103 of vErrors) {
                      if (err103.keyword !== "errorMessage" && !err103.emUsed && (err103.dataPath === dataPath + "/properties/" + i5 + "/type" || err103.dataPath.indexOf(dataPath + "/properties/" + i5 + "/type") === 0 && err103.dataPath[dataPath + "/properties/" + i5 + "/type".length] === "/") && err103.schemaPath.indexOf("#/definitions/properties/allOf/1/items/allOf/1/then/properties/type") === 0 && err103.schemaPath["#/definitions/properties/allOf/1/items/allOf/1/then/properties/type".length] === "/") {
                        emErrs12.push(err103);
                        err103.emUsed = true;
                      }
                    }

                    if (emErrs12.length) {
                      const err104 = {
                        keyword: "errorMessage",
                        dataPath: dataPath + "/properties/" + i5 + "/type",
                        schemaPath: "#/definitions/properties/allOf/1/items/allOf/1/then/properties/type/errorMessage",
                        params: {
                          errors: emErrs12
                        },
                        message: "invalid property type " + JSON.stringify(data49) + " for binding type " + JSON.stringify(data43 && data43.binding && data43.binding.type) + "; must be any of { String, Text, Hidden, Dropdown }"
                      };

                      if (vErrors === null) {
                        vErrors = [err104];
                      } else {
                        vErrors.push(err104);
                      }

                      errors++;
                    }

                    const emErrs13 = [];

                    for (const err105 of vErrors) {
                      if (!err105.emUsed) {
                        emErrs13.push(err105);
                      }
                    }

                    vErrors = emErrs13;
                    errors = emErrs13.length;
                  }
                }
              }

              var _valid4 = _errs115 === errors;

              valid42 = _valid4;
            }

            if (!valid42) {
              const err106 = {
                keyword: "if",
                dataPath: dataPath + "/properties/" + i5,
                schemaPath: "#/definitions/properties/allOf/1/items/allOf/1/if",
                params: {
                  failingKeyword: "then"
                },
                message: "should match \"then\" schema"
              };

              if (vErrors === null) {
                vErrors = [err106];
              } else {
                vErrors.push(err106);
              }

              errors++;
            }

            const _errs118 = errors;
            let valid46 = true;
            const _errs119 = errors;

            if (data43 && typeof data43 == "object" && !Array.isArray(data43)) {
              if (data43.optional === undefined && "optional") {
                const err107 = {};

                if (vErrors === null) {
                  vErrors = [err107];
                } else {
                  vErrors.push(err107);
                }

                errors++;
              } else {
                if (data43.optional !== undefined) {
                  if (!func0(data43.optional, true)) {
                    const err108 = {};

                    if (vErrors === null) {
                      vErrors = [err108];
                    } else {
                      vErrors.push(err108);
                    }

                    errors++;
                  }
                }
              }
            }

            var _valid5 = _errs119 === errors;

            errors = _errs118;

            if (vErrors !== null) {
              if (_errs118) {
                vErrors.length = _errs118;
              } else {
                vErrors = null;
              }
            }

            if (_valid5) {
              const _errs121 = errors;

              if (data43 && typeof data43 == "object" && !Array.isArray(data43)) {
                if (data43.binding !== undefined) {
                  let data51 = data43.binding;

                  if (data51 && typeof data51 == "object" && !Array.isArray(data51)) {
                    if (data51.type === undefined) {
                      const err109 = {
                        keyword: "required",
                        dataPath: dataPath + "/properties/" + i5 + "/binding",
                        schemaPath: "#/definitions/properties/allOf/1/items/allOf/2/then/properties/binding/required",
                        params: {
                          missingProperty: "type"
                        },
                        message: "should have required property '" + "type" + "'"
                      };

                      if (vErrors === null) {
                        vErrors = [err109];
                      } else {
                        vErrors.push(err109);
                      }

                      errors++;
                    }

                    if (data51.type !== undefined) {
                      let data52 = data51.type;

                      if (!(data52 === "zeebe:input" || data52 === "zeebe:output" || data52 === "zeebe:property")) {
                        const err110 = {
                          keyword: "enum",
                          dataPath: dataPath + "/properties/" + i5 + "/binding/type",
                          schemaPath: "#/definitions/properties/allOf/1/items/allOf/2/then/properties/binding/properties/type/enum",
                          params: {
                            allowedValues: schema18.allOf[1].items.allOf[2].then.properties.binding.properties.type.enum
                          },
                          message: "should be equal to one of the allowed values"
                        };

                        if (vErrors === null) {
                          vErrors = [err110];
                        } else {
                          vErrors.push(err110);
                        }

                        errors++;
                      }

                      if (errors > 0) {
                        const emErrs14 = [];

                        for (const err111 of vErrors) {
                          if (err111.keyword !== "errorMessage" && !err111.emUsed && (err111.dataPath === dataPath + "/properties/" + i5 + "/binding/type" || err111.dataPath.indexOf(dataPath + "/properties/" + i5 + "/binding/type") === 0 && err111.dataPath[dataPath + "/properties/" + i5 + "/binding/type".length] === "/") && err111.schemaPath.indexOf("#/definitions/properties/allOf/1/items/allOf/2/then/properties/binding/properties/type") === 0 && err111.schemaPath["#/definitions/properties/allOf/1/items/allOf/2/then/properties/binding/properties/type".length] === "/") {
                            emErrs14.push(err111);
                            err111.emUsed = true;
                          }
                        }

                        if (emErrs14.length) {
                          const err112 = {
                            keyword: "errorMessage",
                            dataPath: dataPath + "/properties/" + i5 + "/binding/type",
                            schemaPath: "#/definitions/properties/allOf/1/items/allOf/2/then/properties/binding/properties/type/errorMessage",
                            params: {
                              errors: emErrs14
                            },
                            message: "optional is not supported for binding type " + JSON.stringify(data52) + "; must be any of { zeebe:input, zeebe:output, zeebe:property }"
                          };

                          if (vErrors === null) {
                            vErrors = [err112];
                          } else {
                            vErrors.push(err112);
                          }

                          errors++;
                        }

                        const emErrs15 = [];

                        for (const err113 of vErrors) {
                          if (!err113.emUsed) {
                            emErrs15.push(err113);
                          }
                        }

                        vErrors = emErrs15;
                        errors = emErrs15.length;
                      }
                    }
                  }
                }
              }

              var _valid5 = _errs121 === errors;

              valid46 = _valid5;
            }

            if (!valid46) {
              const err114 = {
                keyword: "if",
                dataPath: dataPath + "/properties/" + i5,
                schemaPath: "#/definitions/properties/allOf/1/items/allOf/2/if",
                params: {
                  failingKeyword: "then"
                },
                message: "should match \"then\" schema"
              };

              if (vErrors === null) {
                vErrors = [err114];
              } else {
                vErrors.push(err114);
              }

              errors++;
            }

            const _errs125 = errors;
            let valid50 = true;
            const _errs126 = errors;

            if (data43 && typeof data43 == "object" && !Array.isArray(data43)) {
              if (data43.optional === undefined && "optional") {
                const err115 = {};

                if (vErrors === null) {
                  vErrors = [err115];
                } else {
                  vErrors.push(err115);
                }

                errors++;
              } else {
                if (data43.optional !== undefined) {
                  if (!func0(data43.optional, true)) {
                    const err116 = {};

                    if (vErrors === null) {
                      vErrors = [err116];
                    } else {
                      vErrors.push(err116);
                    }

                    errors++;
                  }
                }
              }
            }

            var _valid6 = _errs126 === errors;

            errors = _errs125;

            if (vErrors !== null) {
              if (_errs125) {
                vErrors.length = _errs125;
              } else {
                vErrors = null;
              }
            }

            if (_valid6) {
              const _errs128 = errors;

              if (data43 && typeof data43 == "object" && !Array.isArray(data43)) {
                if (data43.constraints !== undefined) {
                  let data54 = data43.constraints;

                  if (data54 && typeof data54 == "object" && !Array.isArray(data54)) {
                    if (data54.notEmpty === undefined) {
                      const err117 = {
                        keyword: "required",
                        dataPath: dataPath + "/properties/" + i5 + "/constraints",
                        schemaPath: "#/definitions/properties/allOf/1/items/allOf/3/then/properties/constraints/required",
                        params: {
                          missingProperty: "notEmpty"
                        },
                        message: "should have required property '" + "notEmpty" + "'"
                      };

                      if (vErrors === null) {
                        vErrors = [err117];
                      } else {
                        vErrors.push(err117);
                      }

                      errors++;
                    }

                    if (data54.notEmpty !== undefined) {
                      if (!func0(data54.notEmpty, false)) {
                        const err118 = {
                          keyword: "const",
                          dataPath: dataPath + "/properties/" + i5 + "/constraints/notEmpty",
                          schemaPath: "#/definitions/properties/allOf/1/items/allOf/3/then/properties/constraints/properties/notEmpty/const",
                          params: {
                            allowedValue: false
                          },
                          message: "should be equal to constant"
                        };

                        if (vErrors === null) {
                          vErrors = [err118];
                        } else {
                          vErrors.push(err118);
                        }

                        errors++;
                      }

                      if (errors > 0) {
                        const emErrs16 = [];

                        for (const err119 of vErrors) {
                          if (err119.keyword !== "errorMessage" && !err119.emUsed && (err119.dataPath === dataPath + "/properties/" + i5 + "/constraints/notEmpty" || err119.dataPath.indexOf(dataPath + "/properties/" + i5 + "/constraints/notEmpty") === 0 && err119.dataPath[dataPath + "/properties/" + i5 + "/constraints/notEmpty".length] === "/") && err119.schemaPath.indexOf("#/definitions/properties/allOf/1/items/allOf/3/then/properties/constraints/properties/notEmpty") === 0 && err119.schemaPath["#/definitions/properties/allOf/1/items/allOf/3/then/properties/constraints/properties/notEmpty".length] === "/") {
                            emErrs16.push(err119);
                            err119.emUsed = true;
                          }
                        }

                        if (emErrs16.length) {
                          const err120 = {
                            keyword: "errorMessage",
                            dataPath: dataPath + "/properties/" + i5 + "/constraints/notEmpty",
                            schemaPath: "#/definitions/properties/allOf/1/items/allOf/3/then/properties/constraints/properties/notEmpty/errorMessage",
                            params: {
                              errors: emErrs16
                            },
                            message: "optional is not allowed for truthy \"notEmpty\" constraint"
                          };

                          if (vErrors === null) {
                            vErrors = [err120];
                          } else {
                            vErrors.push(err120);
                          }

                          errors++;
                        }

                        const emErrs17 = [];

                        for (const err121 of vErrors) {
                          if (!err121.emUsed) {
                            emErrs17.push(err121);
                          }
                        }

                        vErrors = emErrs17;
                        errors = emErrs17.length;
                      }
                    }
                  }
                }
              }

              var _valid6 = _errs128 === errors;

              valid50 = _valid6;
            }

            if (!valid50) {
              const err122 = {
                keyword: "if",
                dataPath: dataPath + "/properties/" + i5,
                schemaPath: "#/definitions/properties/allOf/1/items/allOf/3/if",
                params: {
                  failingKeyword: "then"
                },
                message: "should match \"then\" schema"
              };

              if (vErrors === null) {
                vErrors = [err122];
              } else {
                vErrors.push(err122);
              }

              errors++;
            }

            const _errs132 = errors;
            let valid54 = true;
            const _errs133 = errors;

            if (data43 && typeof data43 == "object" && !Array.isArray(data43)) {
              if (data43.feel === undefined && "feel") {
                const err123 = {};

                if (vErrors === null) {
                  vErrors = [err123];
                } else {
                  vErrors.push(err123);
                }

                errors++;
              } else {
                if (data43.feel !== undefined) {
                  const _errs135 = errors;
                  const _errs136 = errors;

                  if (!func0(data43.feel, schema18.allOf[1].items.allOf[4].if.properties.feel.not.const)) {
                    const err124 = {};

                    if (vErrors === null) {
                      vErrors = [err124];
                    } else {
                      vErrors.push(err124);
                    }

                    errors++;
                  }

                  var valid56 = _errs136 === errors;

                  if (!valid56) {
                    errors = _errs135;

                    if (vErrors !== null) {
                      if (_errs135) {
                        vErrors.length = _errs135;
                      } else {
                        vErrors = null;
                      }
                    }
                  } else {
                    const err125 = {};

                    if (vErrors === null) {
                      vErrors = [err125];
                    } else {
                      vErrors.push(err125);
                    }

                    errors++;
                  }
                }
              }
            }

            var _valid7 = _errs133 === errors;

            errors = _errs132;

            if (vErrors !== null) {
              if (_errs132) {
                vErrors.length = _errs132;
              } else {
                vErrors = null;
              }
            }

            if (_valid7) {
              const _errs137 = errors;

              if (data43 && typeof data43 == "object" && !Array.isArray(data43)) {
                if (data43.type === undefined) {
                  const err126 = {
                    keyword: "required",
                    dataPath: dataPath + "/properties/" + i5,
                    schemaPath: "#/definitions/properties/allOf/1/items/allOf/4/then/required",
                    params: {
                      missingProperty: "type"
                    },
                    message: "should have required property '" + "type" + "'"
                  };

                  if (vErrors === null) {
                    vErrors = [err126];
                  } else {
                    vErrors.push(err126);
                  }

                  errors++;
                }

                if (data43.type !== undefined) {
                  let data57 = data43.type;

                  if (!(data57 === "String" || data57 === "Text")) {
                    const err127 = {
                      keyword: "enum",
                      dataPath: dataPath + "/properties/" + i5 + "/type",
                      schemaPath: "#/definitions/properties/allOf/1/items/allOf/4/then/properties/type/enum",
                      params: {
                        allowedValues: schema18.allOf[1].items.allOf[4].then.properties.type.enum
                      },
                      message: "should be equal to one of the allowed values"
                    };

                    if (vErrors === null) {
                      vErrors = [err127];
                    } else {
                      vErrors.push(err127);
                    }

                    errors++;
                  }

                  if (errors > 0) {
                    const emErrs18 = [];

                    for (const err128 of vErrors) {
                      if (err128.keyword !== "errorMessage" && !err128.emUsed && (err128.dataPath === dataPath + "/properties/" + i5 + "/type" || err128.dataPath.indexOf(dataPath + "/properties/" + i5 + "/type") === 0 && err128.dataPath[dataPath + "/properties/" + i5 + "/type".length] === "/") && err128.schemaPath.indexOf("#/definitions/properties/allOf/1/items/allOf/4/then/properties/type") === 0 && err128.schemaPath["#/definitions/properties/allOf/1/items/allOf/4/then/properties/type".length] === "/") {
                        emErrs18.push(err128);
                        err128.emUsed = true;
                      }
                    }

                    if (emErrs18.length) {
                      const err129 = {
                        keyword: "errorMessage",
                        dataPath: dataPath + "/properties/" + i5 + "/type",
                        schemaPath: "#/definitions/properties/allOf/1/items/allOf/4/then/properties/type/errorMessage",
                        params: {
                          errors: emErrs18
                        },
                        message: "feel is only supported for \"String\" and \"Text\" type"
                      };

                      if (vErrors === null) {
                        vErrors = [err129];
                      } else {
                        vErrors.push(err129);
                      }

                      errors++;
                    }

                    const emErrs19 = [];

                    for (const err130 of vErrors) {
                      if (!err130.emUsed) {
                        emErrs19.push(err130);
                      }
                    }

                    vErrors = emErrs19;
                    errors = emErrs19.length;
                  }
                }
              }

              var _valid7 = _errs137 === errors;

              valid54 = _valid7;
            }

            if (!valid54) {
              const err131 = {
                keyword: "if",
                dataPath: dataPath + "/properties/" + i5,
                schemaPath: "#/definitions/properties/allOf/1/items/allOf/4/if",
                params: {
                  failingKeyword: "then"
                },
                message: "should match \"then\" schema"
              };

              if (vErrors === null) {
                vErrors = [err131];
              } else {
                vErrors.push(err131);
              }

              errors++;
            }

            if (data43 && typeof data43 == "object" && !Array.isArray(data43)) {
              if (data43.binding === undefined) {
                const err132 = {
                  keyword: "required",
                  dataPath: dataPath + "/properties/" + i5,
                  schemaPath: "#/definitions/properties/allOf/1/items/required",
                  params: {
                    missingProperty: "binding"
                  },
                  message: "should have required property '" + "binding" + "'"
                };

                if (vErrors === null) {
                  vErrors = [err132];
                } else {
                  vErrors.push(err132);
                }

                errors++;
              }

              if (data43.binding !== undefined) {
                let data58 = data43.binding;
                const _errs142 = errors;
                let valid60 = true;
                const _errs143 = errors;

                if (data58 && typeof data58 == "object" && !Array.isArray(data58)) {
                  if (data58.type === undefined && "type") {
                    const err133 = {};

                    if (vErrors === null) {
                      vErrors = [err133];
                    } else {
                      vErrors.push(err133);
                    }

                    errors++;
                  } else {
                    if (data58.type !== undefined) {
                      let data59 = data58.type;

                      if (!(data59 === "property" || data59 === "zeebe:property" || data59 === "zeebe:input")) {
                        const err134 = {};

                        if (vErrors === null) {
                          vErrors = [err134];
                        } else {
                          vErrors.push(err134);
                        }

                        errors++;
                      }
                    }
                  }
                }

                var _valid8 = _errs143 === errors;

                errors = _errs142;

                if (vErrors !== null) {
                  if (_errs142) {
                    vErrors.length = _errs142;
                  } else {
                    vErrors = null;
                  }
                }

                if (_valid8) {
                  const _errs145 = errors;

                  if (data58 && typeof data58 == "object" && !Array.isArray(data58)) {
                    if (data58.name === undefined) {
                      const err135 = {
                        keyword: "required",
                        dataPath: dataPath + "/properties/" + i5 + "/binding",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/0/then/required",
                        params: {
                          missingProperty: "name"
                        },
                        message: "should have required property '" + "name" + "'"
                      };

                      if (vErrors === null) {
                        vErrors = [err135];
                      } else {
                        vErrors.push(err135);
                      }

                      errors++;
                    }
                  }

                  if (errors > 0) {
                    const emErrs20 = [];

                    for (const err136 of vErrors) {
                      if (err136.keyword !== "errorMessage" && !err136.emUsed && (err136.dataPath === dataPath + "/properties/" + i5 + "/binding" || err136.dataPath.indexOf(dataPath + "/properties/" + i5 + "/binding") === 0 && err136.dataPath[dataPath + "/properties/" + i5 + "/binding".length] === "/") && err136.schemaPath.indexOf("#/definitions/properties/allOf/1/items/properties/binding/allOf/0/then") === 0 && err136.schemaPath["#/definitions/properties/allOf/1/items/properties/binding/allOf/0/then".length] === "/") {
                        emErrs20.push(err136);
                        err136.emUsed = true;
                      }
                    }

                    if (emErrs20.length) {
                      const err137 = {
                        keyword: "errorMessage",
                        dataPath: dataPath + "/properties/" + i5 + "/binding",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/0/then/errorMessage",
                        params: {
                          errors: emErrs20
                        },
                        message: "property.binding " + JSON.stringify(data58 && data58.type) + " requires name"
                      };

                      if (vErrors === null) {
                        vErrors = [err137];
                      } else {
                        vErrors.push(err137);
                      }

                      errors++;
                    }

                    const emErrs21 = [];

                    for (const err138 of vErrors) {
                      if (!err138.emUsed) {
                        emErrs21.push(err138);
                      }
                    }

                    vErrors = emErrs21;
                    errors = emErrs21.length;
                  }

                  var _valid8 = _errs145 === errors;

                  valid60 = _valid8;
                }

                if (!valid60) {
                  const err139 = {
                    keyword: "if",
                    dataPath: dataPath + "/properties/" + i5 + "/binding",
                    schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/0/if",
                    params: {
                      failingKeyword: "then"
                    },
                    message: "should match \"then\" schema"
                  };

                  if (vErrors === null) {
                    vErrors = [err139];
                  } else {
                    vErrors.push(err139);
                  }

                  errors++;
                }

                const _errs147 = errors;
                let valid62 = true;
                const _errs148 = errors;

                if (data58 && typeof data58 == "object" && !Array.isArray(data58)) {
                  if (data58.type === undefined && "type") {
                    const err140 = {};

                    if (vErrors === null) {
                      vErrors = [err140];
                    } else {
                      vErrors.push(err140);
                    }

                    errors++;
                  } else {
                    if (data58.type !== undefined) {
                      if (!func0(data58.type, "zeebe:output")) {
                        const err141 = {};

                        if (vErrors === null) {
                          vErrors = [err141];
                        } else {
                          vErrors.push(err141);
                        }

                        errors++;
                      }
                    }
                  }
                }

                var _valid9 = _errs148 === errors;

                errors = _errs147;

                if (vErrors !== null) {
                  if (_errs147) {
                    vErrors.length = _errs147;
                  } else {
                    vErrors = null;
                  }
                }

                if (_valid9) {
                  const _errs150 = errors;

                  if (data58 && typeof data58 == "object" && !Array.isArray(data58)) {
                    if (data58.source === undefined) {
                      const err142 = {
                        keyword: "required",
                        dataPath: dataPath + "/properties/" + i5 + "/binding",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/1/then/required",
                        params: {
                          missingProperty: "source"
                        },
                        message: "should have required property '" + "source" + "'"
                      };

                      if (vErrors === null) {
                        vErrors = [err142];
                      } else {
                        vErrors.push(err142);
                      }

                      errors++;
                    }
                  }

                  if (errors > 0) {
                    const emErrs22 = [];

                    for (const err143 of vErrors) {
                      if (err143.keyword !== "errorMessage" && !err143.emUsed && (err143.dataPath === dataPath + "/properties/" + i5 + "/binding" || err143.dataPath.indexOf(dataPath + "/properties/" + i5 + "/binding") === 0 && err143.dataPath[dataPath + "/properties/" + i5 + "/binding".length] === "/") && err143.schemaPath.indexOf("#/definitions/properties/allOf/1/items/properties/binding/allOf/1/then") === 0 && err143.schemaPath["#/definitions/properties/allOf/1/items/properties/binding/allOf/1/then".length] === "/") {
                        emErrs22.push(err143);
                        err143.emUsed = true;
                      }
                    }

                    if (emErrs22.length) {
                      const err144 = {
                        keyword: "errorMessage",
                        dataPath: dataPath + "/properties/" + i5 + "/binding",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/1/then/errorMessage",
                        params: {
                          errors: emErrs22
                        },
                        message: "property.binding " + JSON.stringify(data58 && data58.type) + " requires source"
                      };

                      if (vErrors === null) {
                        vErrors = [err144];
                      } else {
                        vErrors.push(err144);
                      }

                      errors++;
                    }

                    const emErrs23 = [];

                    for (const err145 of vErrors) {
                      if (!err145.emUsed) {
                        emErrs23.push(err145);
                      }
                    }

                    vErrors = emErrs23;
                    errors = emErrs23.length;
                  }

                  var _valid9 = _errs150 === errors;

                  valid62 = _valid9;
                }

                if (!valid62) {
                  const err146 = {
                    keyword: "if",
                    dataPath: dataPath + "/properties/" + i5 + "/binding",
                    schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/1/if",
                    params: {
                      failingKeyword: "then"
                    },
                    message: "should match \"then\" schema"
                  };

                  if (vErrors === null) {
                    vErrors = [err146];
                  } else {
                    vErrors.push(err146);
                  }

                  errors++;
                }

                const _errs152 = errors;
                let valid64 = true;
                const _errs153 = errors;

                if (data58 && typeof data58 == "object" && !Array.isArray(data58)) {
                  if (data58.type === undefined && "type") {
                    const err147 = {};

                    if (vErrors === null) {
                      vErrors = [err147];
                    } else {
                      vErrors.push(err147);
                    }

                    errors++;
                  } else {
                    if (data58.type !== undefined) {
                      if (!func0(data58.type, "zeebe:taskHeader")) {
                        const err148 = {};

                        if (vErrors === null) {
                          vErrors = [err148];
                        } else {
                          vErrors.push(err148);
                        }

                        errors++;
                      }
                    }
                  }
                }

                var _valid10 = _errs153 === errors;

                errors = _errs152;

                if (vErrors !== null) {
                  if (_errs152) {
                    vErrors.length = _errs152;
                  } else {
                    vErrors = null;
                  }
                }

                if (_valid10) {
                  const _errs155 = errors;

                  if (data58 && typeof data58 == "object" && !Array.isArray(data58)) {
                    if (data58.key === undefined) {
                      const err149 = {
                        keyword: "required",
                        dataPath: dataPath + "/properties/" + i5 + "/binding",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/2/then/required",
                        params: {
                          missingProperty: "key"
                        },
                        message: "should have required property '" + "key" + "'"
                      };

                      if (vErrors === null) {
                        vErrors = [err149];
                      } else {
                        vErrors.push(err149);
                      }

                      errors++;
                    }
                  }

                  if (errors > 0) {
                    const emErrs24 = [];

                    for (const err150 of vErrors) {
                      if (err150.keyword !== "errorMessage" && !err150.emUsed && (err150.dataPath === dataPath + "/properties/" + i5 + "/binding" || err150.dataPath.indexOf(dataPath + "/properties/" + i5 + "/binding") === 0 && err150.dataPath[dataPath + "/properties/" + i5 + "/binding".length] === "/") && err150.schemaPath.indexOf("#/definitions/properties/allOf/1/items/properties/binding/allOf/2/then") === 0 && err150.schemaPath["#/definitions/properties/allOf/1/items/properties/binding/allOf/2/then".length] === "/") {
                        emErrs24.push(err150);
                        err150.emUsed = true;
                      }
                    }

                    if (emErrs24.length) {
                      const err151 = {
                        keyword: "errorMessage",
                        dataPath: dataPath + "/properties/" + i5 + "/binding",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/2/then/errorMessage",
                        params: {
                          errors: emErrs24
                        },
                        message: "property.binding " + JSON.stringify(data58 && data58.type) + " requires key"
                      };

                      if (vErrors === null) {
                        vErrors = [err151];
                      } else {
                        vErrors.push(err151);
                      }

                      errors++;
                    }

                    const emErrs25 = [];

                    for (const err152 of vErrors) {
                      if (!err152.emUsed) {
                        emErrs25.push(err152);
                      }
                    }

                    vErrors = emErrs25;
                    errors = emErrs25.length;
                  }

                  var _valid10 = _errs155 === errors;

                  valid64 = _valid10;
                }

                if (!valid64) {
                  const err153 = {
                    keyword: "if",
                    dataPath: dataPath + "/properties/" + i5 + "/binding",
                    schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/allOf/2/if",
                    params: {
                      failingKeyword: "then"
                    },
                    message: "should match \"then\" schema"
                  };

                  if (vErrors === null) {
                    vErrors = [err153];
                  } else {
                    vErrors.push(err153);
                  }

                  errors++;
                }

                if (data58 && typeof data58 == "object" && !Array.isArray(data58)) {
                  if (data58.type === undefined) {
                    const err154 = {
                      keyword: "required",
                      dataPath: dataPath + "/properties/" + i5 + "/binding",
                      schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/required",
                      params: {
                        missingProperty: "type"
                      },
                      message: "should have required property '" + "type" + "'"
                    };

                    if (vErrors === null) {
                      vErrors = [err154];
                    } else {
                      vErrors.push(err154);
                    }

                    errors++;
                  }

                  if (data58.type !== undefined) {
                    let data62 = data58.type;

                    if (typeof data62 !== "string") {
                      const err155 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i5 + "/binding/type",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/type/type",
                        params: {
                          type: "string"
                        },
                        message: "should be string"
                      };

                      if (vErrors === null) {
                        vErrors = [err155];
                      } else {
                        vErrors.push(err155);
                      }

                      errors++;
                    }

                    if (!(data62 === "property" || data62 === "zeebe:taskDefinition:type" || data62 === "zeebe:input" || data62 === "zeebe:output" || data62 === "zeebe:property" || data62 === "zeebe:taskHeader")) {
                      const err156 = {
                        keyword: "enum",
                        dataPath: dataPath + "/properties/" + i5 + "/binding/type",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/type/enum",
                        params: {
                          allowedValues: schema18.allOf[1].items.properties.binding.properties.type.enum
                        },
                        message: "should be equal to one of the allowed values"
                      };

                      if (vErrors === null) {
                        vErrors = [err156];
                      } else {
                        vErrors.push(err156);
                      }

                      errors++;
                    }

                    if (errors > 0) {
                      const emErrs26 = [];

                      for (const err157 of vErrors) {
                        if (err157.keyword !== "errorMessage" && !err157.emUsed && (err157.dataPath === dataPath + "/properties/" + i5 + "/binding/type" || err157.dataPath.indexOf(dataPath + "/properties/" + i5 + "/binding/type") === 0 && err157.dataPath[dataPath + "/properties/" + i5 + "/binding/type".length] === "/") && err157.schemaPath.indexOf("#/definitions/properties/allOf/1/items/properties/binding/properties/type") === 0 && err157.schemaPath["#/definitions/properties/allOf/1/items/properties/binding/properties/type".length] === "/") {
                          emErrs26.push(err157);
                          err157.emUsed = true;
                        }
                      }

                      if (emErrs26.length) {
                        const err158 = {
                          keyword: "errorMessage",
                          dataPath: dataPath + "/properties/" + i5 + "/binding/type",
                          schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/type/errorMessage",
                          params: {
                            errors: emErrs26
                          },
                          message: "invalid property.binding type " + JSON.stringify(data62) + "; must be any of { property, zeebe:taskDefinition:type, zeebe:input, zeebe:output, zeebe:property, zeebe:taskHeader }"
                        };

                        if (vErrors === null) {
                          vErrors = [err158];
                        } else {
                          vErrors.push(err158);
                        }

                        errors++;
                      }

                      const emErrs27 = [];

                      for (const err159 of vErrors) {
                        if (!err159.emUsed) {
                          emErrs27.push(err159);
                        }
                      }

                      vErrors = emErrs27;
                      errors = emErrs27.length;
                    }
                  }

                  if (data58.name !== undefined) {
                    if (typeof data58.name !== "string") {
                      const err160 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i5 + "/binding/name",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/name/type",
                        params: {
                          type: "string"
                        },
                        message: "should be string"
                      };

                      if (vErrors === null) {
                        vErrors = [err160];
                      } else {
                        vErrors.push(err160);
                      }

                      errors++;
                    }
                  }

                  if (data58.source !== undefined) {
                    if (typeof data58.source !== "string") {
                      const err161 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i5 + "/binding/source",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/source/type",
                        params: {
                          type: "string"
                        },
                        message: "should be string"
                      };

                      if (vErrors === null) {
                        vErrors = [err161];
                      } else {
                        vErrors.push(err161);
                      }

                      errors++;
                    }
                  }

                  if (data58.key !== undefined) {
                    if (typeof data58.key !== "string") {
                      const err162 = {
                        keyword: "type",
                        dataPath: dataPath + "/properties/" + i5 + "/binding/key",
                        schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/properties/key/type",
                        params: {
                          type: "string"
                        },
                        message: "should be string"
                      };

                      if (vErrors === null) {
                        vErrors = [err162];
                      } else {
                        vErrors.push(err162);
                      }

                      errors++;
                    }
                  }
                } else {
                  const err163 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i5 + "/binding",
                    schemaPath: "#/definitions/properties/allOf/1/items/properties/binding/type",
                    params: {
                      type: "object"
                    },
                    message: "should be object"
                  };

                  if (vErrors === null) {
                    vErrors = [err163];
                  } else {
                    vErrors.push(err163);
                  }

                  errors++;
                }
              }

              if (data43.optional !== undefined) {
                if (typeof data43.optional !== "boolean") {
                  const err164 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i5 + "/optional",
                    schemaPath: "#/definitions/properties/allOf/1/items/properties/optional/type",
                    params: {
                      type: "boolean"
                    },
                    message: "should be boolean"
                  };

                  if (vErrors === null) {
                    vErrors = [err164];
                  } else {
                    vErrors.push(err164);
                  }

                  errors++;
                }
              }

              if (data43.feel !== undefined) {
                let data67 = data43.feel;

                if (typeof data67 !== "string") {
                  const err165 = {
                    keyword: "type",
                    dataPath: dataPath + "/properties/" + i5 + "/feel",
                    schemaPath: "#/definitions/properties/allOf/1/items/properties/feel/type",
                    params: {
                      type: "string"
                    },
                    message: "should be string"
                  };

                  if (vErrors === null) {
                    vErrors = [err165];
                  } else {
                    vErrors.push(err165);
                  }

                  errors++;
                }

                if (!(data67 === null || data67 === "optional" || data67 === "required")) {
                  const err166 = {
                    keyword: "enum",
                    dataPath: dataPath + "/properties/" + i5 + "/feel",
                    schemaPath: "#/definitions/properties/allOf/1/items/properties/feel/enum",
                    params: {
                      allowedValues: schema18.allOf[1].items.properties.feel.enum
                    },
                    message: "should be equal to one of the allowed values"
                  };

                  if (vErrors === null) {
                    vErrors = [err166];
                  } else {
                    vErrors.push(err166);
                  }

                  errors++;
                }
              }
            } else {
              const err167 = {
                keyword: "type",
                dataPath: dataPath + "/properties/" + i5,
                schemaPath: "#/definitions/properties/allOf/1/items/type",
                params: {
                  type: "object"
                },
                message: "should be object"
              };

              if (vErrors === null) {
                vErrors = [err167];
              } else {
                vErrors.push(err167);
              }

              errors++;
            }

            if (errors > 0) {
              const emErrors8 = {
                "required": {
                  "binding": []
                }
              };
              const templates8 = {
                required: {
                  binding: function () {
                    return "missing binding for property \"" + JSON.stringify(i5) + "\"";
                  }
                }
              };
              let emPropParams4;
              let emParamsErrors4;

              for (const err168 of vErrors) {
                if (err168.keyword !== "errorMessage" && !err168.emUsed && err168.dataPath === dataPath + "/properties/" + i5 && err168.keyword in emErrors8 && err168.schemaPath.indexOf("#/definitions/properties/allOf/1/items") === 0 && /^\/[^\/]*$/.test(err168.schemaPath.slice(38))) {
                  emPropParams4 = obj0[err168.keyword];
                  emParamsErrors4 = emErrors8[err168.keyword][err168.params[emPropParams4]];

                  if (emParamsErrors4) {
                    emParamsErrors4.push(err168);
                    err168.emUsed = true;
                  }
                }
              }

              for (const key8 in emErrors8) {
                for (const keyProp4 in emErrors8[key8]) {
                  emParamsErrors4 = emErrors8[key8][keyProp4];

                  if (emParamsErrors4.length) {
                    const tmpl4 = templates8[key8] && templates8[key8][keyProp4];
                    const err169 = {
                      keyword: "errorMessage",
                      dataPath: dataPath + "/properties/" + i5,
                      schemaPath: "#/definitions/properties/allOf/1/items/errorMessage",
                      params: {
                        errors: emParamsErrors4
                      },
                      message: tmpl4 ? tmpl4() : schema18.allOf[1].items.errorMessage[key8][keyProp4]
                    };

                    if (vErrors === null) {
                      vErrors = [err169];
                    } else {
                      vErrors.push(err169);
                    }

                    errors++;
                  }
                }
              }

              const emErrs28 = [];

              for (const err170 of vErrors) {
                if (!err170.emUsed) {
                  emErrs28.push(err170);
                }
              }

              vErrors = emErrs28;
              errors = emErrs28.length;
            }
          }
        } else {
          const err171 = {
            keyword: "type",
            dataPath: dataPath + "/properties",
            schemaPath: "#/definitions/properties/allOf/1/type",
            params: {
              type: "array"
            },
            message: "should be array"
          };

          if (vErrors === null) {
            vErrors = [err171];
          } else {
            vErrors.push(err171);
          }

          errors++;
        }
      }

      if (data.icon !== undefined) {
        let data68 = data.icon;

        if (data68 && typeof data68 == "object" && !Array.isArray(data68)) {
          if (data68.contents === undefined) {
            const err172 = {
              keyword: "required",
              dataPath: dataPath + "/icon",
              schemaPath: "#/properties/icon/required",
              params: {
                missingProperty: "contents"
              },
              message: "should have required property '" + "contents" + "'"
            };

            if (vErrors === null) {
              vErrors = [err172];
            } else {
              vErrors.push(err172);
            }

            errors++;
          }

          if (data68.contents !== undefined) {
            let data69 = data68.contents;

            if (typeof data69 === "string") {
              if (!pattern3.test(data69)) {
                const err173 = {
                  keyword: "pattern",
                  dataPath: dataPath + "/icon/contents",
                  schemaPath: "#/properties/icon/properties/contents/pattern",
                  params: {
                    pattern: "^(https?|data):.*"
                  },
                  message: "should match pattern \"" + "^(https?|data):.*" + "\""
                };

                if (vErrors === null) {
                  vErrors = [err173];
                } else {
                  vErrors.push(err173);
                }

                errors++;
              }
            } else {
              const err174 = {
                keyword: "type",
                dataPath: dataPath + "/icon/contents",
                schemaPath: "#/properties/icon/properties/contents/type",
                params: {
                  type: "string"
                },
                message: "should be string"
              };

              if (vErrors === null) {
                vErrors = [err174];
              } else {
                vErrors.push(err174);
              }

              errors++;
            }

            if (errors > 0) {
              const emErrors9 = {
                "pattern": []
              };
              const templates9 = {};

              for (const err175 of vErrors) {
                if (err175.keyword !== "errorMessage" && !err175.emUsed && err175.dataPath === dataPath + "/icon/contents" && err175.keyword in emErrors9 && err175.schemaPath.indexOf("#/properties/icon/properties/contents") === 0 && /^\/[^\/]*$/.test(err175.schemaPath.slice(37))) {
                  emErrors9[err175.keyword].push(err175);
                  err175.emUsed = true;
                }
              }

              for (const key9 in emErrors9) {
                if (emErrors9[key9].length) {
                  const err176 = {
                    keyword: "errorMessage",
                    dataPath: dataPath + "/icon/contents",
                    schemaPath: "#/properties/icon/properties/contents/errorMessage",
                    params: {
                      errors: emErrors9[key9]
                    },
                    message: key9 in templates9 ? templates9[key9]() : schema17.properties.icon.properties.contents.errorMessage[key9]
                  };

                  if (vErrors === null) {
                    vErrors = [err176];
                  } else {
                    vErrors.push(err176);
                  }

                  errors++;
                }
              }

              const emErrs29 = [];

              for (const err177 of vErrors) {
                if (!err177.emUsed) {
                  emErrs29.push(err177);
                }
              }

              vErrors = emErrs29;
              errors = emErrs29.length;
            }
          }
        } else {
          const err178 = {
            keyword: "type",
            dataPath: dataPath + "/icon",
            schemaPath: "#/properties/icon/type",
            params: {
              type: "object"
            },
            message: "should be object"
          };

          if (vErrors === null) {
            vErrors = [err178];
          } else {
            vErrors.push(err178);
          }

          errors++;
        }

        if (errors > 0) {
          const emErrors10 = {
            "required": {
              "contents": []
            }
          };
          const templates10 = {
            required: {}
          };
          let emPropParams5;
          let emParamsErrors5;

          for (const err179 of vErrors) {
            if (err179.keyword !== "errorMessage" && !err179.emUsed && err179.dataPath === dataPath + "/icon" && err179.keyword in emErrors10 && err179.schemaPath.indexOf("#/properties/icon") === 0 && /^\/[^\/]*$/.test(err179.schemaPath.slice(17))) {
              emPropParams5 = obj0[err179.keyword];
              emParamsErrors5 = emErrors10[err179.keyword][err179.params[emPropParams5]];

              if (emParamsErrors5) {
                emParamsErrors5.push(err179);
                err179.emUsed = true;
              }
            }
          }

          for (const key10 in emErrors10) {
            for (const keyProp5 in emErrors10[key10]) {
              emParamsErrors5 = emErrors10[key10][keyProp5];

              if (emParamsErrors5.length) {
                const tmpl5 = templates10[key10] && templates10[key10][keyProp5];
                const err180 = {
                  keyword: "errorMessage",
                  dataPath: dataPath + "/icon",
                  schemaPath: "#/properties/icon/errorMessage",
                  params: {
                    errors: emParamsErrors5
                  },
                  message: tmpl5 ? tmpl5() : schema17.properties.icon.errorMessage[key10][keyProp5]
                };

                if (vErrors === null) {
                  vErrors = [err180];
                } else {
                  vErrors.push(err180);
                }

                errors++;
              }
            }
          }

          const emErrs30 = [];

          for (const err181 of vErrors) {
            if (!err181.emUsed) {
              emErrs30.push(err181);
            }
          }

          vErrors = emErrs30;
          errors = emErrs30.length;
        }
      }
    } else {
      const err182 = {
        keyword: "type",
        dataPath,
        schemaPath: "#/type",
        params: {
          type: "object"
        },
        message: "should be object"
      };

      if (vErrors === null) {
        vErrors = [err182];
      } else {
        vErrors.push(err182);
      }

      errors++;
    }

    validate15.errors = vErrors;
    return errors === 0;
  }

  function validate14(data, {
    dataPath = "",
    parentData,
    parentDataProperty,
    rootData = data
  } = {}) {
    let vErrors = null;
    let errors = 0;
    const _errs0 = errors;
    let valid0 = false;
    let passing0 = null;
    const _errs1 = errors;

    if (!validate15(data, {
      dataPath,
      parentData,
      parentDataProperty,
      rootData
    })) {
      vErrors = vErrors === null ? validate15.errors : vErrors.concat(validate15.errors);
      errors = vErrors.length;
    }

    var _valid0 = _errs1 === errors;

    if (_valid0) {
      valid0 = true;
      passing0 = 0;
    }

    const _errs2 = errors;

    if (Array.isArray(data)) {
      const len0 = data.length;

      for (let i0 = 0; i0 < len0; i0++) {
        if (!validate15(data[i0], {
          dataPath: dataPath + "/" + i0,
          parentData: data,
          parentDataProperty: i0,
          rootData
        })) {
          vErrors = vErrors === null ? validate15.errors : vErrors.concat(validate15.errors);
          errors = vErrors.length;
        }
      }
    } else {
      const err0 = {
        keyword: "type",
        dataPath,
        schemaPath: "#/oneOf/1/type",
        params: {
          type: "array"
        },
        message: "should be array"
      };

      if (vErrors === null) {
        vErrors = [err0];
      } else {
        vErrors.push(err0);
      }

      errors++;
    }

    var _valid0 = _errs2 === errors;

    if (_valid0 && valid0) {
      valid0 = false;
      passing0 = [passing0, 1];
    } else {
      if (_valid0) {
        valid0 = true;
        passing0 = 1;
      }
    }

    if (!valid0) {
      const err1 = {
        keyword: "oneOf",
        dataPath,
        schemaPath: "#/oneOf",
        params: {
          passingSchemas: passing0
        },
        message: "should match exactly one schema in oneOf"
      };

      if (vErrors === null) {
        vErrors = [err1];
      } else {
        vErrors.push(err1);
      }

      errors++;
    } else {
      errors = _errs0;

      if (vErrors !== null) {
        if (_errs0) {
          vErrors.length = _errs0;
        } else {
          vErrors = null;
        }
      }
    }

    validate14.errors = vErrors;
    return errors === 0;
  }

  function getZeebeSchemaPackage() {
    return name;
  }

  function getZeebeSchemaVersion() {
    return version;
  }
  /**
   * Validate a single object.
   *
   * @param {Object} object
   * @return {Object} single object validation result
   */


  function validateZeebe(object) {
    return _validate(object, standaloneZeebeValidator.exports);
  }

  const SUPPORTED_SCHEMA_VERSION$1 = getSchemaVersion$1();
  const MORPHABLE_TYPES = ['bpmn:Activity', 'bpmn:Event', 'bpmn:Gateway'];
  /**
   * A element template validator.
   */

  class Validator$1 {
    constructor(moddle) {
      this._templatesById = {};
      this._validTemplates = [];
      this._errors = [];
      this._moddle = moddle;
    }
    /**
     * Adds the templates.
     *
     * @param {Array<TemplateDescriptor>} templates
     *
     * @return {Validator}
     */


    addAll(templates) {
      if (!isArray(templates)) {
        this._logError('templates must be []');
      } else {
        templates.forEach(this.add, this);
      }

      return this;
    }
    /**
     * Add the given element template, if it is valid.
     *
     * @param {TemplateDescriptor} template
     *
     * @return {Validator}
     */


    add(template) {
      const err = this._validateTemplate(template);

      let id, version;

      if (!err) {
        id = template.id;
        version = template.version || '_';

        if (!this._templatesById[id]) {
          this._templatesById[id] = {};
        }

        this._templatesById[id][version] = template;

        this._validTemplates.push(template);
      }

      return this;
    }
    /**
     * Validate given template and return error (if any).
     *
     * @param {TemplateDescriptor} template
     *
     * @return {Error} validation error, if any
     */


    _validateTemplate(template) {
      let err;
      const id = template.id,
            version = template.version || '_',
            schemaVersion = template.$schema && getSchemaVersion(template.$schema); // (1) compatibility

      if (schemaVersion && semverCompare(SUPPORTED_SCHEMA_VERSION$1, schemaVersion) < 0) {
        return this._logError(`unsupported element template schema version <${schemaVersion}>. Your installation only supports up to version <${SUPPORTED_SCHEMA_VERSION$1}>. Please update your installation`, template);
      } // (2) versioning


      if (this._templatesById[id] && this._templatesById[id][version]) {
        if (version === '_') {
          return this._logError(`template id <${id}> already used`, template);
        } else {
          return this._logError(`template id <${id}> and version <${version}> already used`, template);
        }
      } // (3) elementType validation


      const elementTypeError = this._validateElementType(template);

      if (elementTypeError) {
        return elementTypeError;
      } // (4) JSON schema compliance


      const validationResult = validate$1(template);
      const {
        errors,
        valid
      } = validationResult;

      if (!valid) {
        err = new Error('invalid template');
        filteredSchemaErrors(errors).forEach(error => {
          this._logError(error.message, template);
        });
      }

      return err;
    }
    /**
     * Validate elementType for given template and return error (if any).
     *
     * @param {TemplateDescriptor} template
     *
     * @return {Error} validation error, if any
     */


    _validateElementType(template) {
      if (template.elementType && template.appliesTo) {
        const elementType = template.elementType.value,
              appliesTo = template.appliesTo; // (3.1) template can be applied to elementType
        // prevents cases where the elementType is not part of appliesTo

        if (!appliesTo.find(type => this._isType(elementType, type))) {
          return this._logError(`template does not apply to requested element type <${elementType}>`, template);
        } // (3.2) template only applies to same type of element
        // prevent elementTemplates to morph into incompatible types, e.g. Task -> SequenceFlow


        for (const sourceType of appliesTo) {
          if (!this._canMorph(sourceType, elementType)) {
            return this._logError(`can not morph <${sourceType}> into <${elementType}>`, template);
          }
        }
      }
    }
    /**
     * Check if given type is a subtype of given base type.
     *
     * @param {String} type
     * @param {String} baseType
     * @returns {Boolean}
     */


    _isType(type, baseType) {
      const moddleType = this._moddle.getType(type);

      return moddleType && baseType in this._moddle.getElementDescriptor(moddleType).allTypesByName;
    }
    /**
     * Checks if a given type can be morphed into another type.
     *
     * @param {String} sourceType
     * @param {String} targetType
     * @returns {Boolean}
     */


    _canMorph(sourceType, targetType) {
      if (sourceType === targetType) {
        return true;
      }

      const baseType = MORPHABLE_TYPES.find(type => this._isType(sourceType, type));

      if (!baseType) {
        return false;
      }

      return this._isType(targetType, baseType);
    }
    /**
     * Log an error for the given template
     *
     * @param {(String|Error)} err
     * @param {TemplateDescriptor} template
     *
     * @return {Error} logged validation errors
     */


    _logError(err, template) {
      if (isString(err)) {
        if (template) {
          const {
            id,
            name
          } = template;
          err = `template(id: <${id}>, name: <${name}>): ${err}`;
        }

        err = new Error(err);
      }

      this._errors.push(err);

      return err;
    }

    getErrors() {
      return this._errors;
    }

    getValidTemplates() {
      return this._validTemplates;
    }

  } // helpers //////////

  /**
   * Extract schema version from schema URI
   *
   * @param {String} schemaUri - for example https://unpkg.com/@camunda/element-templates-json-schema@99.99.99/resources/schema.json
   *
   * @return {String} for example '99.99.99'
   */

  function getSchemaVersion(schemaUri) {
    const re = /\d+\.\d+\.\d+/g;
    const match = schemaUri.match(re);
    return match === null ? undefined : match[0];
  }
  /**
   * Extract only relevant errors of the validation result.
   *
   * The JSON Schema we use under the hood produces more errors than we need for a
   * detected schema violation (for example, unmatched sub-schemas, if-then-rules,
   * `oneOf`-definitions ...).
   *
   * We call these errors "relevant" that have a custom error message defined by us OR
   * are basic data type errors.
   *
   * @param {Array} schemaErrors
   *
   * @return {Array}
   */

  function filteredSchemaErrors(schemaErrors) {
    return filter(schemaErrors, err => {
      const {
        dataPath,
        keyword
      } = err; // (1) regular errors are customized from the schema

      if (keyword === 'errorMessage') {
        return true;
      } // (2) data type errors
      // ignore type errors nested in scopes


      if (keyword === 'type' && dataPath && !dataPath.startsWith('/scopes/')) {
        return true;
      }

      return false;
    });
  }

  const SUPPORTED_SCHEMA_VERSION = getZeebeSchemaVersion();
  const SUPPORTED_SCHEMA_PACKAGE = getZeebeSchemaPackage();
  /**
   * A Camunda Cloud element template validator.
   */

  class Validator extends Validator$1 {
    constructor(moddle) {
      super(moddle);
    }
    /**
     * Validate given template and return error (if any).
     *
     * @param {TemplateDescriptor} template
     *
     * @return {Error} validation error, if any
     */


    _validateTemplate(template) {
      let err;
      const id = template.id,
            version = template.version || '_',
            schema = template.$schema,
            schemaVersion = schema && getSchemaVersion(schema); // (1) $schema attribute defined

      if (!schema) {
        return this._logError('missing $schema attribute.', template);
      }

      if (!this.isSchemaValid(schema)) {
        return this._logError(`unsupported $schema attribute <${schema}>.`, template);
      } // (2) compatibility


      if (schemaVersion && semverCompare(SUPPORTED_SCHEMA_VERSION, schemaVersion) < 0) {
        return this._logError(`unsupported element template schema version <${schemaVersion}>. Your installation only supports up to version <${SUPPORTED_SCHEMA_VERSION}>. Please update your installation`, template);
      } // (3) versioning


      if (this._templatesById[id] && this._templatesById[id][version]) {
        if (version === '_') {
          return this._logError(`template id <${id}> already used`, template);
        } else {
          return this._logError(`template id <${id}> and version <${version}> already used`, template);
        }
      } // (4) elementType validation


      const elementTypeError = this._validateElementType(template);

      if (elementTypeError) {
        return elementTypeError;
      } // (5) JSON schema compliance


      const validationResult = validateZeebe(template);
      const {
        errors,
        valid
      } = validationResult;

      if (!valid) {
        err = new Error('invalid template');
        filteredSchemaErrors(errors).forEach(error => {
          this._logError(error.message, template);
        });
      }

      return err;
    }

    isSchemaValid(schema) {
      return schema && schema.includes(SUPPORTED_SCHEMA_PACKAGE);
    }

  }

  /**
   * The guy responsible for template loading.
   *
   * Provide the actual templates via the `config.elementTemplates`.
   *
   * That configuration can either be an array of template
   * descriptors or a node style callback to retrieve
   * the templates asynchronously.
   *
   * @param {Array<TemplateDescriptor>|Function} loadTemplates
   * @param {EventBus} eventBus
   * @param {ElementTemplates} elementTemplates
   * @param {Moddle} moddle
   */

  class ElementTemplatesLoader$1 {
    constructor(loadTemplates, eventBus, elementTemplates, moddle) {
      this._loadTemplates = loadTemplates;
      this._eventBus = eventBus;
      this._elementTemplates = elementTemplates;
      this._moddle = moddle;
      eventBus.on('diagram.init', () => {
        this.reload();
      });
    }

    reload() {
      const loadTemplates = this._loadTemplates; // no templates specified

      if (isUndefined(loadTemplates)) {
        return;
      } // template loader function specified


      if (isFunction(loadTemplates)) {
        return loadTemplates((err, templates) => {
          if (err) {
            return this.templateErrors([err]);
          }

          this.setTemplates(templates);
        });
      } // templates array specified


      if (loadTemplates.length) {
        return this.setTemplates(loadTemplates);
      }
    }

    setTemplates(templates) {
      const elementTemplates = this._elementTemplates,
            moddle = this._moddle;
      const validator = new Validator$1(moddle).addAll(templates);
      const errors = validator.getErrors(),
            validTemplates = validator.getValidTemplates();
      elementTemplates.set(validTemplates);

      if (errors.length) {
        this.templateErrors(errors);
      }

      this.templatesChanged();
    }

    templatesChanged() {
      this._eventBus.fire('elementTemplates.changed');
    }

    templateErrors(errors) {
      this._eventBus.fire('elementTemplates.errors', {
        errors: errors
      });
    }

  }
  ElementTemplatesLoader$1.$inject = ['config.elementTemplates', 'eventBus', 'elementTemplates', 'moddle'];

  class ElementTemplatesLoader extends ElementTemplatesLoader$1 {
    constructor(loadTemplates, eventBus, elementTemplates, moddle) {
      super(loadTemplates, eventBus, elementTemplates, moddle);
      this._elementTemplates = elementTemplates;
    }

    setTemplates(templates) {
      const elementTemplates = this._elementTemplates,
            moddle = this._moddle;
      const validator = new Validator(moddle).addAll(templates);
      const errors = validator.getErrors(),
            validTemplates = validator.getValidTemplates();
      elementTemplates.set(validTemplates);

      if (errors.length) {
        this.templateErrors(errors);
      }

      this.templatesChanged();
    }

  }
  ElementTemplatesLoader.$inject = ['config.elementTemplates', 'eventBus', 'elementTemplates', 'moddle'];

  function unlinkTemplate$1(element, injector) {
    const modeling = injector.get('modeling');
    modeling.updateProperties(element, {
      'camunda:modelerTemplate': null,
      'camunda:modelerTemplateVersion': null
    });
  }
  function removeTemplate(element, injector) {
    const replace = injector.get('replace'),
          selection = injector.get('selection');
    const businessObject = getBusinessObject$1(element);
    const type = businessObject.$type,
          eventDefinitionType = getEventDefinitionType(businessObject);
    const newBusinessObject = createBlankBusinessObject(element, injector);
    const newElement = replace.replaceElement(element, {
      type: type,
      businessObject: newBusinessObject,
      eventDefinitionType: eventDefinitionType
    });
    selection.select(newElement);
  }
  function updateTemplate$1(element, newTemplate, injector) {
    const elementTemplates = injector.get('elementTemplates');
    return elementTemplates.applyTemplate(element, newTemplate);
  }
  function getVersionOrDateFromTemplate(template) {
    const metadata = template.metadata,
          version = template.version;

    if (metadata) {
      if (!isUndefined(metadata.created)) {
        return toDateString(metadata.created);
      } else if (!isUndefined(metadata.updated)) {
        return toDateString(metadata.updated);
      }
    }

    if (isUndefined(version)) {
      return null;
    }

    return version;
  } // helper ///////////

  function getEventDefinitionType(businessObject) {
    if (!businessObject.eventDefinitions) {
      return null;
    }

    const eventDefinition = businessObject.eventDefinitions[0];

    if (!eventDefinition) {
      return null;
    }

    return eventDefinition.$type;
  }
  /**
   * Example: 01.01.1900 01:01
   *
   * @param {number} timestamp
   * @returns {string}
   */


  function toDateString(timestamp) {
    const date = new Date(timestamp);
    const year = date.getFullYear();
    const month = withLeadingZeros(String(date.getMonth() + 1));
    const day = withLeadingZeros(String(date.getDate()));
    const hours = withLeadingZeros(String(date.getHours()));
    const minutes = withLeadingZeros(String(date.getMinutes()));
    return day + '.' + month + '.' + year + ' ' + hours + ':' + minutes;
  }

  function withLeadingZeros(string) {
    return leftPad(string, 2, '0');
  }

  function leftPad(string, length, character) {
    while (string.length < length) {
      string = character + string;
    }

    return string;
  }

  function createBlankBusinessObject(element, injector) {
    const bpmnFactory = injector.get('bpmnFactory');
    const bo = getBusinessObject$1(element),
          newBo = bpmnFactory.create(bo.$type),
          label = getLabel(element);

    if (!label) {
      return newBo;
    }

    if (is$4(element, 'bpmn:Group')) {
      newBo.categoryValueRef = bpmnFactory.create('bpmn:CategoryValue');
    }

    setLabel({
      businessObject: newBo
    }, label);
    return newBo;
  }

  function unlinkTemplate(element, injector) {
    const modeling = injector.get('modeling'); // remove template attributes

    modeling.updateProperties(element, {
      'zeebe:modelerTemplate': null,
      'zeebe:modelerTemplateVersion': null,
      'zeebe:modelerTemplateIcon': null
    });
  }
  function updateTemplate(element, newTemplate, injector) {
    const elementTemplates = injector.get('elementTemplates');
    return elementTemplates.applyTemplate(element, newTemplate);
  }

  /**
   * This Behavior checks if the new element's type is in
   * the list of elements the template applies to and unlinks
   * it if not.
   */

  class ReplaceBehavior$1 extends CommandInterceptor {
    constructor(elementTemplates, injector) {
      super(injector.get('eventBus'));
      this.postExecuted('shape.replace', function (e) {
        var context = e.context,
            oldShape = context.oldShape,
            oldBo = getBusinessObject$1(oldShape),
            newShape = context.newShape,
            newBo = getBusinessObject$1(newShape);

        if (!oldBo.modelerTemplate) {
          return;
        }

        const template = newBo.modelerTemplate;
        const version = newBo.modelerTemplateVersion;
        const elementTemplate = elementTemplates.get(template, version);

        if (!elementTemplate) {
          unlinkTemplate(newShape, injector);
          return;
        }

        const {
          appliesTo,
          elementType
        } = elementTemplate;

        if (elementType) {
          if (!is$4(newShape, elementType.value)) {
            unlinkTemplate(newShape, injector);
          }

          return;
        }

        const allowed = appliesTo.reduce((allowed, type) => {
          return allowed || is$4(newBo, type);
        }, false);

        if (!allowed) {
          unlinkTemplate(newShape, injector);
        }
      });
    }

  }
  ReplaceBehavior$1.$inject = ['elementTemplates', 'injector'];

  function registerHandlers$1(commandStack, elementTemplates, eventBus) {
    commandStack.registerHandler('propertiesPanel.zeebe.changeTemplate', ChangeElementTemplateHandler$1); // apply default element templates on shape creation

    eventBus.on(['commandStack.shape.create.postExecuted'], function (context) {
      applyDefaultTemplate$1(context.context.shape, elementTemplates, commandStack);
    }); // apply default element templates on connection creation

    eventBus.on(['commandStack.connection.create.postExecuted'], function (context) {
      applyDefaultTemplate$1(context.context.connection, elementTemplates, commandStack);
    });
  }

  registerHandlers$1.$inject = ['commandStack', 'elementTemplates', 'eventBus'];
  var commandsModule$1 = {
    __init__: [registerHandlers$1]
  };

  function applyDefaultTemplate$1(element, elementTemplates, commandStack) {
    if (!elementTemplates.get(element) && elementTemplates.getDefault(element)) {
      const command = 'propertiesPanel.zeebe.changeTemplate';
      const commandContext = {
        element: element,
        newTemplate: elementTemplates.getDefault(element)
      };
      commandStack.execute(command, commandContext);
    }
  }

  /**
   * Validate the given template descriptors and
   * return a list of errors.
   *
   * @param {Array<TemplateDescriptor>} descriptors
   * @param {Moddle} moddle
   *
   * @return {Array<Error>}
   */

  function validate(descriptors, moddle) {
    return new Validator(moddle).addAll(descriptors).getErrors();
  }

  class PropertyBindingProvider {
    static create(element, options) {
      const {
        property
      } = options;
      const {
        binding,
        value
      } = property;
      const {
        name
      } = binding;
      const businessObject = getBusinessObject$1(element);
      businessObject[name] = value;
    }

  }

  class TaskDefinitionTypeBindingProvider {
    static create(element, options) {
      const {
        property,
        bpmnFactory
      } = options;
      const {
        value
      } = property;
      const extensionElements = getBusinessObject$1(element).get('extensionElements');
      const taskDefinition = createTaskDefinitionWithType(value, bpmnFactory);
      taskDefinition.$parent = extensionElements;
      extensionElements.get('values').push(taskDefinition);
    }

  }

  class InputBindingProvider {
    static create(element, options) {
      const {
        property,
        bpmnFactory
      } = options;
      const {
        binding,
        value
      } = property;
      const ioMapping = ensureExtension(element, 'zeebe:IoMapping', bpmnFactory);

      if (!shouldUpdate(value, property)) {
        return;
      }

      const input = createInputParameter$1(binding, value, bpmnFactory);
      input.$parent = ioMapping;
      ioMapping.get('inputParameters').push(input);
    }

  }

  class OutputBindingProvider {
    static create(element, options) {
      const {
        property,
        bpmnFactory
      } = options;
      const {
        binding,
        value
      } = property;
      const ioMapping = ensureExtension(element, 'zeebe:IoMapping', bpmnFactory);

      if (!shouldUpdate(value, property)) {
        return;
      }

      const output = createOutputParameter$1(binding, value, bpmnFactory);
      output.$parent = ioMapping;
      ioMapping.get('outputParameters').push(output);
    }

  }

  class TaskHeaderBindingProvider {
    static create(element, options) {
      const {
        property,
        bpmnFactory
      } = options;
      const {
        binding,
        value
      } = property;
      const taskHeaders = ensureExtension(element, 'zeebe:TaskHeaders', bpmnFactory);
      const header = createTaskHeader(binding, value, bpmnFactory);
      header.$parent = taskHeaders;
      taskHeaders.get('values').push(header);
    }

  }

  class ZeebePropertiesProvider {
    static create(element, options) {
      const {
        property,
        bpmnFactory
      } = options;
      const {
        binding,
        value
      } = property;
      const zeebeProperties = ensureExtension(element, 'zeebe:Properties', bpmnFactory);

      if (!shouldUpdate(value, property)) {
        return;
      }

      const zeebeProperty = createZeebeProperty(binding, value, bpmnFactory);
      zeebeProperty.$parent = zeebeProperties;
      zeebeProperties.get('properties').push(zeebeProperty);
    }

  }

  class TemplateElementFactory {
    constructor(bpmnFactory, elementFactory, moddle) {
      this._bpmnFactory = bpmnFactory;
      this._elementFactory = elementFactory;
      this._moddle = moddle;
      this._providers = {
        [PROPERTY_TYPE$1]: PropertyBindingProvider,
        [ZEEBE_TASK_DEFINITION_TYPE_TYPE]: TaskDefinitionTypeBindingProvider,
        [ZEBBE_PROPERTY_TYPE]: ZeebePropertiesProvider,
        [ZEBBE_INPUT_TYPE]: InputBindingProvider,
        [ZEEBE_OUTPUT_TYPE]: OutputBindingProvider,
        [ZEEBE_TASK_HEADER_TYPE]: TaskHeaderBindingProvider
      };
    }
    /**
     * Create an element based on an element template.
     *
     * @param {ElementTemplate} template
     * @returns {djs.model.Base}
     */


    create(template) {
      const {
        appliesTo,
        elementType
      } = template;
      const elementFactory = this._elementFactory;
      const bpmnFactory = this._bpmnFactory;
      const moddle = this._moddle;
      const providers = this._providers; // (0) make sure template is valid

      const errors = validate([template], moddle); // todo(pinussilvestrus): return validation errors

      if (errors && errors.length) {
        throw new Error('template is invalid');
      }

      const type = elementType && elementType.value || appliesTo[0]; // (1) create element from appliesTo

      const element = elementFactory.createShape({
        type
      }); // (2) ensure extension elements

      if (hasExtensionBindings(template)) {
        this._ensureExtensionElements(element);
      } // (3) apply template


      this._setModelerTemplate(element, template); // (4) apply icon


      if (hasIcon(template)) {
        this._setModelerTemplateIcon(element, template);
      }

      const {
        properties
      } = applyConditions(element, template); // (5) apply properties

      properties.forEach(function (property) {
        const {
          binding
        } = property;
        const {
          type: bindingType
        } = binding;
        const bindingProvider = providers[bindingType];
        bindingProvider.create(element, {
          property,
          bpmnFactory
        });
      });
      return element;
    }

    _ensureExtensionElements(element) {
      const bpmnFactory = this._bpmnFactory;
      const businessObject = getBusinessObject$1(element);
      let extensionElements = businessObject.get('extensionElements');

      if (!extensionElements) {
        extensionElements = bpmnFactory.create('bpmn:ExtensionElements', {
          values: []
        });
        extensionElements.$parent = businessObject;
        businessObject.set('extensionElements', extensionElements);
      }

      return extensionElements;
    }

    _setModelerTemplate(element, template) {
      const {
        id,
        version
      } = template;
      const businessObject = getBusinessObject$1(element);
      businessObject.set('zeebe:modelerTemplate', id);
      businessObject.set('zeebe:modelerTemplateVersion', version);
    }

    _setModelerTemplateIcon(element, template) {
      const {
        icon
      } = template;
      const {
        contents
      } = icon;
      const businessObject = getBusinessObject$1(element);
      businessObject.set('zeebe:modelerTemplateIcon', contents);
    }

  }
  TemplateElementFactory.$inject = ['bpmnFactory', 'elementFactory', 'moddle']; // helper ////////////////

  function hasExtensionBindings(template) {
    const {
      properties
    } = template; // find icon first

    if (hasIcon(template)) {
      return true;
    }

    return find$1(properties, function (property) {
      const {
        binding
      } = property;
      return EXTENSION_BINDING_TYPES$1.includes(binding.type);
    });
  }

  function hasIcon(template) {
    const {
      icon
    } = template;
    return !!(icon && icon.contents);
  }

  var templateElementFactoryModule = {
    __init__: ['templateElementFactory'],
    templateElementFactory: ['type', TemplateElementFactory]
  };

  function createElementTemplatesGroup(props = {}) {
    const {
      getTemplateId: getTemplateId$1 = getTemplateId,
      unlinkTemplate = unlinkTemplate$1,
      updateTemplate = updateTemplate$1
    } = props;
    return function ElementTemplatesGroup(props) {
      const {
        id,
        label,
        element,
        entries = []
      } = props;
      const [open, setOpen] = useLayoutState(['groups', id, 'open'], false);
      const empty = !entries.length;

      const toggleOpen = () => !empty && setOpen(!open);

      return o$1("div", {
        class: "bio-properties-panel-group bio-properties-panel-templates-group",
        "data-group-id": 'group-' + id,
        children: [o$1("div", {
          class: classnames('bio-properties-panel-group-header', {
            empty,
            open: open && !empty
          }),
          onClick: toggleOpen,
          children: [o$1("div", {
            title: label,
            class: "bio-properties-panel-group-header-title",
            children: label
          }), o$1("div", {
            class: "bio-properties-panel-group-header-buttons",
            children: [o$1(TemplateGroupButtons, {
              element: element,
              getTemplateId: getTemplateId$1,
              unlinkTemplate: unlinkTemplate,
              updateTemplate: updateTemplate
            }), !empty && o$1(SectionToggle, {
              open: open
            })]
          })]
        }), o$1("div", {
          class: classnames('bio-properties-panel-group-entries', {
            open: open && !empty
          }),
          children: entries.map(entry => {
            const {
              component: Component,
              id
            } = entry;
            return a$2(Component, { ...entry,
              key: id,
              element: element
            });
          })
        })]
      });
    };
  }

  function SectionToggle({
    open
  }) {
    return o$1(HeaderButton, {
      title: "Toggle section",
      class: "bio-properties-panel-arrow",
      children: o$1(ArrowIcon, {
        class: open ? 'bio-properties-panel-arrow-down' : 'bio-properties-panel-arrow-right'
      })
    });
  }
  /**
   *
   * @param {object} props
   * @param {object} props.element
   * @param {function} props.getTemplateId
   * @param {function} props.unlinkTemplate
   * @param {function} props.updateTemplate
   */


  function TemplateGroupButtons({
    element,
    getTemplateId,
    unlinkTemplate,
    updateTemplate
  }) {
    const elementTemplates = useService('elementTemplates');
    const templateState = getTemplateState(elementTemplates, element, getTemplateId);

    if (templateState.type === 'NO_TEMPLATE') {
      return o$1(SelectEntryTemplate, {
        element: element
      });
    } else if (templateState.type === 'KNOWN_TEMPLATE') {
      return o$1(AppliedTemplate, {
        element: element,
        unlinkTemplate: unlinkTemplate
      });
    } else if (templateState.type === 'UNKNOWN_TEMPLATE') {
      return o$1(UnknownTemplate, {
        element: element,
        unlinkTemplate: unlinkTemplate
      });
    } else if (templateState.type === 'OUTDATED_TEMPLATE') {
      return o$1(OutdatedTemplate, {
        element: element,
        templateState: templateState,
        unlinkTemplate: unlinkTemplate,
        updateTemplate: updateTemplate
      });
    }
  }

  function SelectEntryTemplate({
    element
  }) {
    const translate = useService('translate');
    const eventBus = useService('eventBus');

    const selectTemplate = () => eventBus.fire('elementTemplates.select', {
      element
    });

    return o$1(HeaderButton, {
      title: "Select a template",
      class: "bio-properties-panel-select-template-button",
      onClick: selectTemplate,
      children: [o$1(CreateIcon, {}), o$1("span", {
        children: translate('Select')
      })]
    });
  }

  function AppliedTemplate({
    element,
    unlinkTemplate
  }) {
    const translate = useService('translate'),
          injector = useService('injector');
    const menuItems = [{
      entry: translate('Unlink'),
      action: () => unlinkTemplate(element, injector)
    }, {
      entry: o$1(RemoveTemplate, {}),
      action: () => removeTemplate(element, injector)
    }];
    return o$1(DropdownButton, {
      menuItems: menuItems,
      class: "bio-properties-panel-applied-template-button",
      children: o$1(HeaderButton, {
        children: [o$1("span", {
          children: translate('Applied')
        }), o$1(ArrowIcon, {
          class: "bio-properties-panel-arrow-down"
        })]
      })
    });
  }

  function RemoveTemplate() {
    const translate = useService('translate');
    return o$1("span", {
      class: "bio-properties-panel-remove-template",
      children: translate('Remove')
    });
  }

  function UnknownTemplate({
    element,
    unlinkTemplate
  }) {
    const translate = useService('translate'),
          injector = useService('injector');
    const menuItems = [{
      entry: o$1(NotFoundText, {})
    }, {
      separator: true
    }, {
      entry: translate('Unlink'),
      action: () => unlinkTemplate(element, injector)
    }, {
      entry: o$1(RemoveTemplate, {}),
      action: () => removeTemplate(element, injector)
    }];
    return o$1(DropdownButton, {
      menuItems: menuItems,
      class: "bio-properties-panel-template-not-found",
      children: o$1(HeaderButton, {
        children: [o$1("span", {
          children: translate('Not found')
        }), o$1(ArrowIcon, {
          class: "bio-properties-panel-arrow-down"
        })]
      })
    });
  }

  function NotFoundText() {
    const translate = useService('translate');
    return o$1("div", {
      class: "bio-properties-panel-template-not-found-text",
      children: translate('The template applied was not found. Therefore, its properties cannot be shown. Unlink to access the data.')
    });
  }
  /**
   *
   * @param {object} props
   * @param {object} element
   * @param {UnknownTemplate} templateState
   * @param {function} unlinkTemplate
   * @param {function} updateTemplate
   */


  function OutdatedTemplate({
    element,
    templateState,
    unlinkTemplate,
    updateTemplate
  }) {
    const {
      newerTemplate
    } = templateState;
    const translate = useService('translate'),
          injector = useService('injector');
    const menuItems = [{
      entry: o$1(UpdateAvailableText, {
        newerTemplate: newerTemplate
      })
    }, {
      separator: true
    }, {
      entry: translate('Update'),
      action: () => updateTemplate(element, newerTemplate, injector)
    }, {
      entry: translate('Unlink'),
      action: () => unlinkTemplate(element, injector)
    }, {
      entry: o$1(RemoveTemplate, {}),
      action: () => removeTemplate(element, injector)
    }];
    return o$1(DropdownButton, {
      menuItems: menuItems,
      class: "bio-properties-panel-template-update-available",
      children: o$1(HeaderButton, {
        children: [o$1("span", {
          children: translate('Update available')
        }), o$1(ArrowIcon, {
          class: "bio-properties-panel-arrow-down"
        })]
      })
    });
  }

  function UpdateAvailableText({
    newerTemplate
  }) {
    const translate = useService('translate');
    const text = translate('A new version of the template is available: {templateVersion}', {
      templateVersion: getVersionOrDateFromTemplate(newerTemplate)
    });
    return o$1("div", {
      class: "bio-properties-panel-template-update-available-text",
      children: text
    });
  } // helper //////

  /**
   * Determine template state in the current element.
   *
   * @param {object} elementTemplates
   * @param {object} element
   * @param {function} getTemplateId
   * @returns {TemplateState}
   */


  function getTemplateState(elementTemplates, element, getTemplateId) {
    const templateId = getTemplateId(element),
          template = elementTemplates.get(element);

    if (!templateId) {
      return {
        type: 'NO_TEMPLATE'
      };
    }

    if (!template) {
      return {
        type: 'UNKNOWN_TEMPLATE',
        templateId
      };
    }

    const newerTemplate = elementTemplates.getLatest(templateId, {
      deprecated: true
    })[0];

    if (newerTemplate !== template) {
      return {
        type: 'OUTDATED_TEMPLATE',
        template,
        newerTemplate
      };
    }

    return {
      type: 'KNOWN_TEMPLATE',
      template
    };
  }

  function TemplateProps({
    element,
    elementTemplates
  }) {
    const template = elementTemplates.get(element);

    if (!template) {
      return [];
    }

    return [{
      id: 'template-name',
      component: TemplateName,
      template
    }, {
      id: 'template-version',
      component: TemplateVersion,
      template
    }, {
      id: 'template-description',
      component: TemplateDescription,
      template
    }].filter(entry => !!entry.component);
  }

  function TemplateName({
    id,
    template
  }) {
    const translate = useService('translate');
    return o$1(TextEntry, {
      id: id,
      label: translate('Name'),
      content: template.name
    });
  }

  function TemplateVersion({
    id,
    template
  }) {
    const translate = useService('translate');
    const version = getVersionOrDateFromTemplate(template);
    return version ? o$1(TextEntry, {
      id: id,
      label: translate('Version'),
      content: version
    }) : null;
  }

  function TemplateDescription({
    id,
    template
  }) {
    const translate = useService('translate');
    const {
      description
    } = template;
    return description ? o$1(TextEntry, {
      id: id,
      label: translate('Description'),
      content: template.description
    }) : null;
  }

  function TextEntry({
    id,
    label,
    content
  }) {
    return o$1("div", {
      "data-entry-id": id,
      class: "bio-properties-panel-entry bio-properties-panel-text-entry",
      children: [o$1("span", {
        class: "bio-properties-panel-label",
        children: label
      }), o$1("span", {
        class: "bio-properties-panel-text-entry__content",
        children: content
      })]
    });
  }

  var e,
      o = {};

  function n(r, t, e) {
    if (3 === r.nodeType) {
      var o = "textContent" in r ? r.textContent : r.nodeValue || "";

      if (!1 !== n.options.trim) {
        var a = 0 === t || t === e.length - 1;
        if ((!(o = o.match(/^[\s\n]+$/g) && "all" !== n.options.trim ? " " : o.replace(/(^[\s\n]+|[\s\n]+$)/g, "all" === n.options.trim || a ? "" : " ")) || " " === o) && e.length > 1 && a) return null;
      }

      return o;
    }

    if (1 !== r.nodeType) return null;
    var p = String(r.nodeName).toLowerCase();
    if ("script" === p && !n.options.allowScripts) return null;
    var l,
        s,
        u = n.h(p, function (r) {
      var t = r && r.length;
      if (!t) return null;

      for (var e = {}, o = 0; o < t; o++) {
        var a = r[o],
            i = a.name,
            p = a.value;
        "on" === i.substring(0, 2) && n.options.allowEvents && (p = new Function(p)), e[i] = p;
      }

      return e;
    }(r.attributes), (s = (l = r.childNodes) && Array.prototype.map.call(l, n).filter(i)) && s.length ? s : null);
    return n.visitor && n.visitor(u), u;
  }

  var a,
      i = function (r) {
    return r;
  },
      p = {};

  function l(r) {
    var t = (r.type || "").toLowerCase(),
        e = l.map;
    e && e.hasOwnProperty(t) ? (r.type = e[t], r.props = Object.keys(r.props || {}).reduce(function (t, e) {
      var o;
      return t[(o = e, o.replace(/-(.)/g, function (r, t) {
        return t.toUpperCase();
      }))] = r.props[e], t;
    }, {})) : r.type = t.replace(/[^a-z0-9-]/i, "");
  }

  var Markup = (function (t) {
    function i() {
      t.apply(this, arguments);
    }

    return t && (i.__proto__ = t), (i.prototype = Object.create(t && t.prototype)).constructor = i, i.setReviver = function (r) {
      a = r;
    }, i.prototype.shouldComponentUpdate = function (r) {
      var t = this.props;
      return r.wrap !== t.wrap || r.type !== t.type || r.markup !== t.markup;
    }, i.prototype.setComponents = function (r) {
      if (this.map = {}, r) for (var t in r) if (r.hasOwnProperty(t)) {
        var e = t.replace(/([A-Z]+)([A-Z][a-z0-9])|([a-z0-9]+)([A-Z])/g, "$1$3-$2$4").toLowerCase();
        this.map[e] = r[t];
      }
    }, i.prototype.render = function (t) {
      var i = t.wrap;
      void 0 === i && (i = !0);

      var s,
          u = t.type,
          c = t.markup,
          m = t.components,
          v = t.reviver,
          f = t.onError,
          d = t["allow-scripts"],
          h = t["allow-events"],
          y = t.trim,
          w = function (r, t) {
        var e = {};

        for (var o in r) Object.prototype.hasOwnProperty.call(r, o) && -1 === t.indexOf(o) && (e[o] = r[o]);

        return e;
      }(t, ["wrap", "type", "markup", "components", "reviver", "onError", "allow-scripts", "allow-events", "trim"]),
          C = v || this.reviver || this.constructor.prototype.reviver || a || a$2;

      this.setComponents(m);
      var g = {
        allowScripts: d,
        allowEvents: h,
        trim: y
      };

      try {
        s = function (r, t, a, i, s) {
          var u = function (r, t) {
            var o,
                n,
                a,
                i,
                p = "html" === t ? "text/html" : "application/xml";
            "html" === t ? (i = "body", a = "<!DOCTYPE html>\n<html><body>" + r + "</body></html>") : (i = "xml", a = '<?xml version="1.0" encoding="UTF-8"?>\n<xml>' + r + "</xml>");

            try {
              o = new DOMParser().parseFromString(a, p);
            } catch (r) {
              n = r;
            }

            if (o || "html" !== t || ((o = e || (e = function () {
              if (document.implementation && document.implementation.createHTMLDocument) return document.implementation.createHTMLDocument("");
              var r = document.createElement("iframe");
              return r.style.cssText = "position:absolute; left:0; top:-999em; width:1px; height:1px; overflow:hidden;", r.setAttribute("sandbox", "allow-forms"), document.body.appendChild(r), r.contentWindow.document;
            }())).open(), o.write(a), o.close()), o) {
              var l = o.getElementsByTagName(i)[0],
                  s = l.firstChild;
              return r && !s && (l.error = "Document parse failed."), s && "parsererror" === String(s.nodeName).toLowerCase() && (s.removeChild(s.firstChild), s.removeChild(s.lastChild), l.error = s.textContent || s.nodeValue || n || "Unknown error", l.removeChild(s)), l;
            }
          }(r, t);

          if (u && u.error) throw new Error(u.error);
          var c = u && u.body || u;
          l.map = i || p;

          var m = c && function (r, t, e, a) {
            return n.visitor = t, n.h = e, n.options = a || o, n(r);
          }(c, l, a, s);

          return l.map = null, m && m.props && m.props.children || null;
        }(c, u, C, this.map, g);
      } catch (r) {
        f ? f({
          error: r
        }) : "undefined" != typeof console && console.error && console.error("preact-markup: " + r);
      }

      if (!1 === i) return s || null;
      var x = w.hasOwnProperty("className") ? "className" : "class",
          b = w[x];
      return b ? b.splice ? b.splice(0, 0, "markup") : "string" == typeof b ? w[x] += " markup" : "object" == typeof b && (b.markup = !0) : w[x] = "markup", C("div", w, s || null);
    }, i;
  })(p$2);

  /**
   * Copied from existing form-js#Sanitizer
   * cf. https://github.com/bpmn-io/form-js/blob/master/packages/form-js-viewer/src/render/components/Sanitizer.js
   */
  const NODE_TYPE_TEXT = 3,
        NODE_TYPE_ELEMENT = 1;
  const ALLOWED_NODES = ['h1', 'h2', 'h3', 'h4', 'h5', 'span', 'em', 'a', 'p', 'div', 'ul', 'ol', 'li', 'hr', 'blockquote', 'img', 'pre', 'code', 'br', 'strong'];
  const ALLOWED_ATTRIBUTES = ['align', 'alt', 'class', 'href', 'id', 'name', 'rel', 'target', 'src'];
  const ALLOWED_URI_PATTERN = /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i; // eslint-disable-line no-useless-escape

  const ATTR_WHITESPACE_PATTERN = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g; // eslint-disable-line no-control-regex

  const FORM_ELEMENT = document.createElement('form');
  /**
   * Sanitize a HTML string and return the cleaned, safe version.
   *
   * @param {string} html
   * @return {string}
   */

  function sanitizeHTML(html) {
    const doc = new DOMParser().parseFromString(`<!DOCTYPE html>\n<html><body><div>${html}`, 'text/html');
    doc.normalize();
    const element = doc.body.firstChild;

    if (element) {
      sanitizeNode(
      /** @type Element */
      element);
      return new XMLSerializer().serializeToString(element);
    } else {
      // handle the case that document parsing
      // does not work at all, due to HTML gibberish
      return '';
    }
  }
  /**
   * Recursively sanitize a HTML node, potentially
   * removing it, its children or attributes.
   *
   * Inspired by https://github.com/developit/snarkdown/issues/70
   * and https://github.com/cure53/DOMPurify. Simplified
   * for our use-case.
   *
   * @param {Element} node
   */

  function sanitizeNode(node) {
    // allow text nodes
    if (node.nodeType === NODE_TYPE_TEXT) {
      return;
    } // disallow all other nodes but Element


    if (node.nodeType !== NODE_TYPE_ELEMENT) {
      return node.remove();
    }

    const lcTag = node.tagName.toLowerCase(); // disallow non-whitelisted tags

    if (!ALLOWED_NODES.includes(lcTag)) {
      return node.remove();
    }

    const attributes = node.attributes; // clean attributes

    for (let i = attributes.length; i--;) {
      const attribute = attributes[i];
      const name = attribute.name;
      const lcName = name.toLowerCase(); // normalize node value

      const value = attribute.value.trim();
      node.removeAttribute(name);
      const valid = isValidAttribute(lcTag, lcName, value);

      if (valid) {
        node.setAttribute(name, value);
      }
    } // force noopener on target="_blank" links


    if (lcTag === 'a' && node.getAttribute('target') === '_blank' && node.getAttribute('rel') !== 'noopener') {
      node.setAttribute('rel', 'noopener');
    }

    for (let i = node.childNodes.length; i--;) {
      sanitizeNode(
      /** @type Element */
      node.childNodes[i]);
    }
  }
  /**
   * Validates attributes for validity.
   *
   * @param {string} lcTag
   * @param {string} lcName
   * @param {string} value
   * @return {boolean}
   */


  function isValidAttribute(lcTag, lcName, value) {
    // disallow most attributes based on whitelist
    if (!ALLOWED_ATTRIBUTES.includes(lcName)) {
      return false;
    } // disallow "DOM clobbering" / polution of document and wrapping form elements


    if ((lcName === 'id' || lcName === 'name') && (value in document || value in FORM_ELEMENT)) {
      return false;
    }

    if (lcName === 'target' && value !== '_blank') {
      return false;
    } // allow valid url links only


    if (lcName === 'href' && !ALLOWED_URI_PATTERN.test(value.replace(ATTR_WHITESPACE_PATTERN, ''))) {
      return false;
    }

    return true;
  }

  function PropertyDescription(props) {
    const {
      description
    } = props;
    return description && o$1(Markup, {
      markup: sanitizeHTML(description),
      trim: false
    });
  }

  const DEFAULT_CUSTOM_GROUP$1 = {
    id: 'ElementTemplates__CustomProperties',
    label: 'Custom properties'
  };
  function CustomProperties$1(props) {
    const {
      element,
      elementTemplate
    } = props;
    const groups = [];
    const {
      id,
      properties,
      groups: propertyGroups
    } = elementTemplate; // (1) group properties by group id

    const groupedProperties = groupByGroupId$1(properties);
    const defaultProps = [];
    forEach(groupedProperties, (properties, groupId) => {
      const group = findCustomGroup$1(propertyGroups, groupId);

      if (!group) {
        return defaultProps.push(...properties);
      }

      addCustomGroup$1(groups, {
        element,
        id: `ElementTemplates__CustomProperties-${groupId}`,
        label: group.label,
        properties: properties,
        templateId: `${id}-${groupId}`
      });
    }); // (2) add default custom props

    if (defaultProps.length) {
      addCustomGroup$1(groups, { ...DEFAULT_CUSTOM_GROUP$1,
        element,
        properties: defaultProps,
        templateId: id
      });
    }

    return groups;
  }

  function addCustomGroup$1(groups, props) {
    const {
      element,
      id,
      label,
      properties,
      templateId
    } = props;
    const customPropertiesGroup = {
      id,
      label,
      component: Group,
      entries: [],
      shouldOpen: true
    };
    properties.forEach((property, index) => {
      const entry = createCustomEntry$1(`custom-entry-${templateId}-${index}`, element, property);

      if (entry) {
        customPropertiesGroup.entries.push(entry);
      }
    });

    if (customPropertiesGroup.entries.length) {
      groups.push(customPropertiesGroup);
    }
  }

  function createCustomEntry$1(id, element, property) {
    let {
      type,
      feel
    } = property;

    if (!type) {
      type = getDefaultType$1(property);
    }

    if (type === 'Boolean') {
      return {
        id,
        component: BooleanProperty$1,
        isEdited: isEdited$7,
        property
      };
    }

    if (type === 'Dropdown') {
      return {
        id,
        component: DropdownProperty$1,
        isEdited: isEdited$4,
        property
      };
    }

    if (type === 'String') {
      if (feel) {
        return {
          id,
          component: FeelProperty,
          isEdited: isEdited$6,
          property
        };
      }

      return {
        id,
        component: StringProperty$1,
        isEdited: isEdited$1,
        property
      };
    }

    if (type === 'Text') {
      if (feel) {
        return {
          id,
          component: FeelTextAreaProperty,
          isEdited: isEdited$6,
          property
        };
      }

      return {
        id,
        component: TextAreaProperty$1,
        isEdited: isEdited$2,
        property
      };
    }
  }

  function getDefaultType$1(property) {
    const {
      binding
    } = property;
    const {
      type
    } = binding;

    if ([PROPERTY_TYPE$1, ZEEBE_TASK_DEFINITION_TYPE_TYPE, ZEBBE_INPUT_TYPE, ZEEBE_OUTPUT_TYPE, ZEEBE_PROPERTY_TYPE, ZEEBE_TASK_HEADER_TYPE].includes(type)) {
      return 'String';
    }
  }

  function BooleanProperty$1(props) {
    const {
      element,
      id,
      property
    } = props;
    const {
      description,
      editable,
      label
    } = property;
    const bpmnFactory = useService('bpmnFactory'),
          commandStack = useService('commandStack');
    return CheckboxEntry({
      element,
      getValue: propertyGetter$1(element, property),
      id,
      label,
      description: PropertyDescription({
        description
      }),
      setValue: propertySetter$1(bpmnFactory, commandStack, element, property),
      disabled: editable === false
    });
  }

  function DropdownProperty$1(props) {
    const {
      element,
      id,
      property
    } = props;
    const {
      description,
      editable,
      label
    } = property;
    const bpmnFactory = useService('bpmnFactory'),
          commandStack = useService('commandStack');

    const getOptions = () => {
      const {
        choices
      } = property;
      return choices.map(({
        name,
        value
      }) => {
        return {
          label: name,
          value
        };
      });
    };

    return SelectEntry({
      element,
      id,
      label,
      getOptions,
      description: PropertyDescription({
        description
      }),
      getValue: propertyGetter$1(element, property),
      setValue: propertySetter$1(bpmnFactory, commandStack, element, property),
      disabled: editable === false
    });
  }

  function FeelTextAreaProperty(props) {
    const {
      element,
      id,
      property
    } = props;
    const {
      description,
      editable,
      label,
      feel
    } = property;
    const bpmnFactory = useService('bpmnFactory'),
          commandStack = useService('commandStack'),
          debounce = useService('debounceInput'),
          translate = useService('translate');
    return withVariableContext(FeelTextArea)({
      debounce,
      element,
      getValue: propertyGetter$1(element, property),
      id,
      label,
      feel,
      description: PropertyDescription({
        description
      }),
      setValue: propertySetter$1(bpmnFactory, commandStack, element, property),
      validate: propertyValidator$1(translate, property),
      disabled: editable === false
    });
  }

  function FeelProperty(props) {
    const {
      element,
      id,
      property
    } = props;
    const {
      description,
      editable,
      label,
      feel
    } = property;
    const bpmnFactory = useService('bpmnFactory'),
          commandStack = useService('commandStack'),
          debounce = useService('debounceInput'),
          translate = useService('translate');
    return withVariableContext(FeelEntry)({
      debounce,
      element,
      getValue: propertyGetter$1(element, property),
      id,
      label,
      feel,
      description: PropertyDescription({
        description
      }),
      setValue: propertySetter$1(bpmnFactory, commandStack, element, property),
      validate: propertyValidator$1(translate, property),
      disabled: editable === false
    });
  }

  function StringProperty$1(props) {
    const {
      element,
      id,
      property
    } = props;
    const {
      description,
      editable,
      label,
      feel
    } = property;
    const bpmnFactory = useService('bpmnFactory'),
          commandStack = useService('commandStack'),
          debounce = useService('debounceInput'),
          translate = useService('translate');
    return TextfieldEntry({
      debounce,
      element,
      getValue: propertyGetter$1(element, property),
      id,
      label,
      feel,
      description: PropertyDescription({
        description
      }),
      setValue: propertySetter$1(bpmnFactory, commandStack, element, property),
      validate: propertyValidator$1(translate, property),
      disabled: editable === false
    });
  }

  function TextAreaProperty$1(props) {
    const {
      element,
      id,
      property
    } = props;
    const {
      description,
      editable,
      label,
      feel
    } = property;
    const bpmnFactory = useService('bpmnFactory'),
          commandStack = useService('commandStack'),
          debounce = useService('debounceInput');
    return TextAreaEntry({
      debounce,
      element,
      id,
      label,
      feel,
      description: PropertyDescription({
        description
      }),
      getValue: propertyGetter$1(element, property),
      setValue: propertySetter$1(bpmnFactory, commandStack, element, property),
      disabled: editable === false
    });
  }

  function propertyGetter$1(element, property) {
    return function getValue() {
      return getPropertyValue$1(element, property);
    };
  }

  function propertySetter$1(bpmnFactory, commandStack, element, property) {
    return function getValue(value) {
      return setPropertyValue(bpmnFactory, commandStack, element, property, value);
    };
  }

  function propertyValidator$1(translate, property) {
    return function validate(value) {
      const {
        constraints = {}
      } = property;
      const {
        maxLength,
        minLength,
        notEmpty
      } = constraints;

      if (notEmpty && isEmptyString$1(value)) {
        return translate('Must not be empty.');
      }

      if (maxLength && value.length > maxLength) {
        return translate('Must have max length {maxLength}.', {
          maxLength
        });
      }

      if (minLength && value.length < minLength) {
        return translate('Must have min length {minLength}.', {
          minLength
        });
      }

      let {
        pattern
      } = constraints;

      if (pattern) {
        let message;

        if (!isString(pattern)) {
          message = pattern.message;
          pattern = pattern.value;
        }

        if (!matchesPattern$1(value, pattern)) {
          return message || translate('Must match pattern {pattern}.', {
            pattern
          });
        }
      }
    };
  }

  function isEmptyString$1(string) {
    return !string || !string.trim().length;
  }

  function matchesPattern$1(string, pattern) {
    return new RegExp(pattern).test(string);
  }

  function groupByGroupId$1(properties) {
    return groupBy(properties, 'group');
  }

  function findCustomGroup$1(groups, id) {
    return find$1(groups, g => g.id === id);
  }

  const LOWER_PRIORITY$1 = 300;
  class ElementTemplatesPropertiesProvider$1 {
    constructor(elementTemplates, propertiesPanel, injector) {
      propertiesPanel.registerProvider(LOWER_PRIORITY$1, this);
      this._elementTemplates = elementTemplates;
      this._injector = injector;
    }

    getGroups(element) {
      return groups => {
        if (!this._shouldShowTemplateProperties(element)) {
          return groups;
        } // (0) Copy provided groups


        groups = groups.slice();
        const templatesGroup = {
          element,
          id: 'ElementTemplates__Template',
          label: 'Template',
          component: createElementTemplatesGroup({
            getTemplateId: getTemplateId$1,
            unlinkTemplate,
            updateTemplate
          }),
          entries: TemplateProps({
            element,
            elementTemplates: this._elementTemplates
          })
        }; // (1) Add templates group

        addGroupsAfter$1('documentation', groups, [templatesGroup]);

        let elementTemplate = this._elementTemplates.get(element);

        if (elementTemplate) {
          elementTemplate = applyConditions(element, elementTemplate);
          const templateSpecificGroups = [].concat(CustomProperties$1({
            element,
            elementTemplate
          })); // (2) add template-specific properties groups

          addGroupsAfter$1('ElementTemplates__Template', groups, templateSpecificGroups);
        } // (3) apply entries visible


        if (getTemplateId$1(element)) {
          groups = filterWithEntriesVisible$1(elementTemplate || {}, groups);
        }

        return groups;
      };
    }

    _shouldShowTemplateProperties(element) {
      return getTemplateId$1(element) || this._elementTemplates.getAll(element).length;
    }

  }
  ElementTemplatesPropertiesProvider$1.$inject = ['elementTemplates', 'propertiesPanel', 'injector']; // helper /////////////////////

  /**
   *
   * @param {string} id
   * @param {Array<{ id: string }} groups
   * @param {Array<{ id: string }>} groupsToAdd
   */

  function addGroupsAfter$1(id, groups, groupsToAdd) {
    const index = groups.findIndex(group => group.id === id);

    if (index !== -1) {
      groups.splice(index + 1, 0, ...groupsToAdd);
    } else {
      // add in the beginning if group with provided id is missing
      groups.unshift(...groupsToAdd);
    }
  }

  function filterWithEntriesVisible$1(template, groups) {
    if (!template.entriesVisible) {
      return groups.filter(group => {
        return group.id === 'general' || group.id.startsWith('ElementTemplates__');
      });
    }

    return groups;
  }

  var index$1 = {
    __depends__: [commandsModule$1, templateElementFactoryModule, translateModule, zeebePropertiesProviderModule],
    __init__: ['elementTemplatesLoader', 'replaceBehavior', 'elementTemplatesPropertiesProvider', 'elementTemplatesConditionChecker'],
    elementTemplates: ['type', ElementTemplates],
    elementTemplatesLoader: ['type', ElementTemplatesLoader],
    replaceBehavior: ['type', ReplaceBehavior$1],
    elementTemplatesPropertiesProvider: ['type', ElementTemplatesPropertiesProvider$1],
    elementTemplatesConditionChecker: ['type', ElementTemplatesConditionChecker]
  };

  /**
   * This Behavior checks if the new element's type is in
   * the list of elements the template applies to and unlinks
   * it if not.
   */

  class ReplaceBehavior extends CommandInterceptor {
    constructor(elementTemplates, injector) {
      super(injector.get('eventBus'));
      this.postExecuted('shape.replace', function (e) {
        var context = e.context,
            oldShape = context.oldShape,
            oldBo = getBusinessObject$1(oldShape),
            newShape = context.newShape,
            newBo = getBusinessObject$1(newShape);

        if (!oldBo.modelerTemplate) {
          return;
        }

        const template = newBo.modelerTemplate;
        const version = newBo.modelerTemplateVersion;
        const elementTemplate = elementTemplates.get(template, version);

        if (!elementTemplate) {
          unlinkTemplate$1(newShape, injector);
          return;
        }

        const {
          appliesTo,
          elementType
        } = elementTemplate;

        if (elementType) {
          if (!is$4(newShape, elementType.value)) {
            unlinkTemplate$1(newShape, injector);
          }

          return;
        }

        const allowed = appliesTo.reduce((allowed, type) => {
          return allowed || is$4(newBo, type);
        }, false);

        if (!allowed) {
          unlinkTemplate$1(newShape, injector);
        }
      });
    }

  }
  ReplaceBehavior.$inject = ['elementTemplates', 'injector'];

  /**
   * Converts legacy scopes descriptor to newer supported array structure.
   *
   * For example, it transforms
   *
   * scopes: {
   *   'camunda:Connector':
   *     { properties: []
   *   }
   * }
   *
   * to
   *
   * scopes: [
   *   {
   *     type: 'camunda:Connector',
   *     properties: []
   *   }
   * ]
   *
   * @param {ScopesDescriptor} scopes
   *
   * @returns {Array}
   */

  function handleLegacyScopes(scopes = []) {
    const scopesAsArray = [];

    if (!isObject(scopes)) {
      return scopes;
    }

    forEach(keys(scopes), function (scopeName) {
      scopesAsArray.push(assign({
        type: scopeName
      }, scopes[scopeName]));
    });
    return scopesAsArray;
  }

  /**
   * Create an input parameter representing the given
   * binding and value.
   *
   * @param {PropertyBinding} binding
   * @param {String} value
   * @param {BpmnFactory} bpmnFactory
   *
   * @return {ModdleElement}
   */

  function createInputParameter(binding, value, bpmnFactory) {
    const {
      name,
      scriptFormat
    } = binding;
    let parameterValue, parameterDefinition;

    if (scriptFormat) {
      parameterDefinition = bpmnFactory.create('camunda:Script', {
        scriptFormat,
        value
      });
    } else {
      parameterValue = value;
    }

    return bpmnFactory.create('camunda:InputParameter', {
      name,
      value: parameterValue,
      definition: parameterDefinition
    });
  }
  /**
   * Create an output parameter representing the given
   * binding and value.
   *
   * @param {PropertyBinding} binding
   * @param {String} value
   * @param {BpmnFactory} bpmnFactory
   *
   * @return {ModdleElement}
   */

  function createOutputParameter(binding, value, bpmnFactory) {
    const {
      scriptFormat,
      source
    } = binding;
    let parameterValue, parameterDefinition;

    if (scriptFormat) {
      parameterDefinition = bpmnFactory.create('camunda:Script', {
        scriptFormat,
        value: source
      });
    } else {
      parameterValue = source;
    }

    return bpmnFactory.create('camunda:OutputParameter', {
      name: value,
      value: parameterValue,
      definition: parameterDefinition
    });
  }
  /**
   * Create camunda property from the given binding.
   *
   * @param {PropertyBinding} binding
   * @param {String} value
   * @param {BpmnFactory} bpmnFactory
   *
   * @return {ModdleElement}
   */

  function createCamundaProperty(binding, value = '', bpmnFactory) {
    const {
      name
    } = binding;
    return bpmnFactory.create('camunda:Property', {
      name,
      value
    });
  }
  /**
   * Create camunda:in element from given binding.
   *
   * @param {PropertyBinding} binding
   * @param {String} value
   * @param {BpmnFactory} bpmnFactory
   *
   * @return {ModdleElement}
   */

  function createCamundaIn(binding, value, bpmnFactory) {
    const attrs = createCamundaInOutAttrs(binding, value);
    return bpmnFactory.create('camunda:In', attrs);
  }
  /**
   * Create camunda:in with businessKey element from given binding.
   *
   * @param {String} value
   * @param {BpmnFactory} bpmnFactory
   *
   * @return {ModdleElement}
   */

  function createCamundaInWithBusinessKey(value, bpmnFactory) {
    return bpmnFactory.create('camunda:In', {
      businessKey: value
    });
  }
  /**
   * Create camunda:out element from given binding.
   *
   * @param {PropertyBinding} binding
   * @param {String} value
   * @param {BpmnFactory} bpmnFactory
   *
   * @return {ModdleElement}
   */

  function createCamundaOut(binding, value, bpmnFactory) {
    const attrs = createCamundaInOutAttrs(binding, value);
    return bpmnFactory.create('camunda:Out', attrs);
  }
  /**
   * Create camunda:executionListener element containing an inline script from given binding.
   *
   * @param {PropertyBinding} binding
   * @param {String} value
   * @param {BpmnFactory} bpmnFactory
   *
   * @return {ModdleElement}
   */

  function createCamundaExecutionListenerScript(binding, value, bpmnFactory) {
    const {
      event,
      scriptFormat
    } = binding;
    let parameterValue, parameterDefinition;

    if (scriptFormat) {
      parameterDefinition = bpmnFactory.create('camunda:Script', {
        scriptFormat,
        value
      });
    } else {
      parameterValue = value;
    }

    return bpmnFactory.create('camunda:ExecutionListener', {
      event,
      value: parameterValue,
      script: parameterDefinition
    });
  }
  /**
   * Create camunda:field element containing string or expression from given binding.
   *
   * @param {PropertyBinding} binding
   * @param {String} value
   * @param {BpmnFactory} bpmnFactory
   *
   * @return {ModdleElement}
   */

  function createCamundaFieldInjection(binding, value, bpmnFactory) {
    const DEFAULT_PROPS = {
      'string': undefined,
      'expression': undefined,
      'name': undefined
    };
    const props = assign({}, DEFAULT_PROPS);
    const {
      expression,
      name
    } = binding;

    if (!expression) {
      props.string = value;
    } else {
      props.expression = value;
    }

    props.name = name;
    return bpmnFactory.create('camunda:Field', props);
  }
  /**
   * Create camunda:errorEventDefinition element containing expression and errorRef
   * from given binding.
   *
   * @param {String} expression
   * @param {ModdleElement} errorRef
   * @param {ModdleElement} parent
   * @param {BpmnFactory} bpmnFactory
   *
   * @return {ModdleElement}
   */

  function createCamundaErrorEventDefinition(expression, errorRef, parent, bpmnFactory) {
    const errorEventDefinition = bpmnFactory.create('camunda:ErrorEventDefinition', {
      errorRef,
      expression
    });
    errorEventDefinition.$parent = parent;
    return errorEventDefinition;
  }
  /**
   * Create bpmn:error element containing a specific error id given by a binding.
   *
   * @param {String} bindingErrorRef
   * @param {ModdleElement} parent
   * @param {BpmnFactory} bpmnFactory
   *
   * @return { ModdleElement }
   */

  function createError(bindingErrorRef, parent, bpmnFactory) {
    const error = bpmnFactory.create('bpmn:Error', {
      // we need to later retrieve the error from a binding
      id: nextId('Error_' + bindingErrorRef + '_')
    });
    error.$parent = parent;
    return error;
  } // helpers //////////

  /**
   * Create properties for camunda:in and camunda:out types.
   */

  function createCamundaInOutAttrs(binding, value) {
    const properties = {};
    const {
      expression,
      source,
      sourceExpression,
      target,
      type,
      variables
    } = binding; // explicitly cover all conditions as specified here:
    // https://github.com/camunda/camunda-modeler/blob/develop/docs/element-templates/README.md#camundain

    if (type === 'camunda:in') {
      if (target && !expression && !variables) {
        properties.target = target;
        properties.source = value;
      } else if (target && expression === true && !variables) {
        properties.target = target;
        properties.sourceExpression = value;
      } else if (!target && !expression && variables === 'local') {
        properties.local = true;
        properties.variables = 'all';
      } else if (target && !expression && variables === 'local') {
        properties.local = true;
        properties.source = value;
        properties.target = target;
      } else if (target && expression && variables === 'local') {
        properties.local = true;
        properties.sourceExpression = value;
        properties.target = target;
      } else if (!target && !expression && variables === 'all') {
        properties.variables = 'all';
      } else {
        throw new Error('invalid configuration for camunda:in element template binding');
      }
    } // explicitly cover all conditions as specified here:
    // https://github.com/camunda/camunda-modeler/blob/develop/docs/element-templates/README.md#camundaout


    if (type === 'camunda:out') {
      if (source && !sourceExpression && !variables) {
        properties.target = value;
        properties.source = source;
      } else if (!source && sourceExpression && !variables) {
        properties.target = value;
        properties.sourceExpression = sourceExpression;
      } else if (!source && !sourceExpression && variables === 'all') {
        properties.variables = 'all';
      } else if (source && !sourceExpression && variables === 'local') {
        properties.local = true;
        properties.source = source;
        properties.target = value;
      } else if (!source && sourceExpression && variables === 'local') {
        properties.local = true;
        properties.sourceExpression = sourceExpression;
        properties.target = value;
      } else if (!source && !sourceExpression && variables === 'local') {
        properties.local = true;
        properties.variables = 'all';
      } else {
        throw new Error('invalid configuration for camunda:out element template binding');
      }
    }

    return properties;
  }

  const CAMUNDA_SERVICE_TASK_LIKE = ['camunda:class', 'camunda:delegateExpression', 'camunda:expression'];
  /**
   * Applies an element template to an element. Sets `camunda:modelerTemplate` and
   * `camunda:modelerTemplateVersion`.
   */

  class ChangeElementTemplateHandler {
    constructor(bpmnFactory, bpmnReplace, commandStack, modeling) {
      this._bpmnFactory = bpmnFactory;
      this._bpmnReplace = bpmnReplace;
      this._commandStack = commandStack;
      this._modeling = modeling;
    }
    /**
     * Change an element's template and update its properties as specified in `newTemplate`. Specify
     * `oldTemplate` to update from one template to another. If `newTemplate` isn't specified the
     * `camunda:modelerTemplate` and `camunda:modelerTemplateVersion` properties will be removed from
     * the element.
     *
     * @param {Object} context
     * @param {Object} context.element
     * @param {Object} [context.oldTemplate]
     * @param {Object} [context.newTemplate]
     */


    preExecute(context) {
      const newTemplate = context.newTemplate,
            oldTemplate = context.oldTemplate;
      let element = context.element; // update camunda:modelerTemplate attribute

      this._updateCamundaModelerTemplate(element, newTemplate);

      if (newTemplate) {
        element = context.element = this._updateTaskType(element, newTemplate); // update properties

        this._updateProperties(element, oldTemplate, newTemplate); // update camunda:ExecutionListener properties


        this._updateCamundaExecutionListenerProperties(element, newTemplate); // update camunda:Field properties


        this._updateCamundaFieldProperties(element, oldTemplate, newTemplate); // update camunda:In and camunda:Out properties


        this._updateCamundaInOutProperties(element, oldTemplate, newTemplate); // update camunda:InputParameter and camunda:OutputParameter properties


        this._updateCamundaInputOutputParameterProperties(element, oldTemplate, newTemplate); // update camunda:Property properties


        this._updateCamundaPropertyProperties(element, oldTemplate, newTemplate); // update camunda:ErrorEventDefinition properties


        this._updateCamundaErrorEventDefinitionProperties(element, oldTemplate, newTemplate); // update properties for each scope


        handleLegacyScopes(newTemplate.scopes).forEach(newScopeTemplate => {
          this._updateScopeProperties(element, oldTemplate, newScopeTemplate, newTemplate);
        });
      }
    }

    _getOrCreateExtensionElements(element) {
      const bpmnFactory = this._bpmnFactory,
            modeling = this._modeling;
      const businessObject = getBusinessObject$1(element);
      let extensionElements = businessObject.get('extensionElements');

      if (!extensionElements) {
        extensionElements = bpmnFactory.create('bpmn:ExtensionElements', {
          values: []
        });
        extensionElements.$parent = businessObject;
        modeling.updateProperties(element, {
          extensionElements: extensionElements
        });
      }

      return extensionElements;
    }
    /**
     * Update `camunda:ErrorEventDefinition` properties of specified business object. Event
     * definitions can only exist in `bpmn:ExtensionElements`.
     *
     * Ensures an bpmn:Error exists for the event definition.
     *
     * @param {djs.model.Base} element
     * @param {Object} oldTemplate
     * @param {Object} newTemplate
     */


    _updateCamundaErrorEventDefinitionProperties(element, oldTemplate, newTemplate) {
      const bpmnFactory = this._bpmnFactory,
            commandStack = this._commandStack;
      const newProperties = newTemplate.properties.filter(newProperty => {
        const newBinding = newProperty.binding,
              newBindingType = newBinding.type;
        return newBindingType === 'camunda:errorEventDefinition';
      }); // (1) do not override if no updates

      if (!newProperties.length) {
        return;
      }

      const extensionElements = this._getOrCreateExtensionElements(element);

      const oldErrorEventDefinitions = findExtensions(element, ['camunda:ErrorEventDefinition']);
      newProperties.forEach(newProperty => {
        const oldProperty = findOldProperty(oldTemplate, newProperty),
              oldEventDefinition = oldProperty && findOldBusinessObject(extensionElements, oldProperty),
              newBinding = newProperty.binding; // (2) update old event definitions

        if (oldProperty && oldEventDefinition) {
          if (!propertyChanged(oldEventDefinition, oldProperty)) {
            commandStack.execute('element.updateModdleProperties', {
              element,
              moddleElement: oldEventDefinition,
              properties: {
                expression: newProperty.value
              }
            });
          }

          remove(oldErrorEventDefinitions, oldEventDefinition);
        } // (3) create new event definition + error
        else {
          const rootElement = getRoot(getBusinessObject$1(element)),
                newError = createError(newBinding.errorRef, rootElement, bpmnFactory),
                newEventDefinition = createCamundaErrorEventDefinition(newProperty.value, newError, extensionElements, bpmnFactory);
          commandStack.execute('element.updateModdleProperties', {
            element,
            moddleElement: rootElement,
            properties: {
              rootElements: [...rootElement.get('rootElements'), newError]
            }
          });
          commandStack.execute('element.updateModdleProperties', {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), newEventDefinition]
            }
          });
        }
      }); // (4) remove old event definitions

      if (oldErrorEventDefinitions.length) {
        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: extensionElements,
          properties: {
            values: without(extensionElements.get('values'), value => oldErrorEventDefinitions.includes(value))
          }
        });
      }
    }
    /**
     * Update `camunda:ExecutionListener` properties of specified business object. Execution listeners
     * will always be overridden. Execution listeners can only exist in `bpmn:ExtensionElements`.
     *
     * @param {djs.model.Base} element
     * @param {Object} newTemplate
     */


    _updateCamundaExecutionListenerProperties(element, newTemplate) {
      const bpmnFactory = this._bpmnFactory,
            commandStack = this._commandStack;
      const newProperties = newTemplate.properties.filter(newProperty => {
        const newBinding = newProperty.binding,
              newBindingType = newBinding.type;
        return newBindingType === 'camunda:executionListener';
      }); // (1) do not override old execution listeners if no new execution listeners specified

      if (!newProperties.length) {
        return;
      }

      const extensionElements = this._getOrCreateExtensionElements(element); // (2) remove old execution listeners


      const oldExecutionListeners = findExtensions(element, ['camunda:ExecutionListener']); // (3) add new execution listeners

      const newExecutionListeners = newProperties.map(newProperty => {
        const newBinding = newProperty.binding,
              propertyValue = newProperty.value;
        return createCamundaExecutionListenerScript(newBinding, propertyValue, bpmnFactory);
      });
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: extensionElements,
        properties: {
          values: [...without(extensionElements.get('values'), value => oldExecutionListeners.includes(value)), ...newExecutionListeners]
        }
      });
    }
    /**
     * Update `camunda:Field` properties of specified business object.
     * If business object is `camunda:ExecutionListener` or `camunda:TaskListener` `fields` property
     * will be updated. Otherwise `extensionElements.values` property will be updated.
     *
     * @param {djs.model.Base} element
     * @param {Object} oldTemplate
     * @param {Object} newTemplate
     * @param {ModdleElement} businessObject
     */


    _updateCamundaFieldProperties(element, oldTemplate, newTemplate, businessObject) {
      const bpmnFactory = this._bpmnFactory,
            commandStack = this._commandStack;
      const newProperties = newTemplate.properties.filter(newProperty => {
        const newBinding = newProperty.binding,
              newBindingType = newBinding.type;
        return newBindingType === 'camunda:field';
      }); // (1) do not override old fields if no new fields specified

      if (!newProperties.length) {
        return;
      }

      if (!businessObject) {
        businessObject = this._getOrCreateExtensionElements(element);
      }

      const propertyName = isAny(businessObject, ['camunda:ExecutionListener', 'camunda:TaskListener']) ? 'fields' : 'values';
      const oldFields = findExtensions(element, ['camunda:Field']);
      newProperties.forEach(newProperty => {
        const oldProperty = findOldProperty(oldTemplate, newProperty),
              oldField = oldProperty && findOldBusinessObject(businessObject, oldProperty),
              newBinding = newProperty.binding; // (2) update old fields

        if (oldProperty && oldField) {
          if (!propertyChanged(oldField, oldProperty)) {
            commandStack.execute('element.updateModdleProperties', {
              element,
              moddleElement: oldField,
              properties: {
                string: newProperty.value
              }
            });
          }

          remove(oldFields, oldField);
        } // (3) add new fields
        else {
          const newCamundaFieldInjection = createCamundaFieldInjection(newBinding, newProperty.value, bpmnFactory);
          commandStack.execute('element.updateModdleProperties', {
            element,
            moddleElement: businessObject,
            properties: {
              [propertyName]: [...businessObject.get(propertyName), newCamundaFieldInjection]
            }
          });
        }
      }); // (4) remove old fields

      if (oldFields.length) {
        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: businessObject,
          properties: {
            [propertyName]: without(businessObject.get(propertyName), value => oldFields.includes(value))
          }
        });
      }
    }
    /**
     * Update `camunda:In` and `camunda:Out` properties of specified business object. Only
     * `bpmn:CallActivity` and events with `bpmn:SignalEventDefinition` can have ins. Only
     * `camunda:CallActivity` can have outs.
     *
     * @param {djs.model.Base} element
     * @param {Object} oldTemplate
     * @param {Object} newTemplate
     */


    _updateCamundaInOutProperties(element, oldTemplate, newTemplate) {
      const bpmnFactory = this._bpmnFactory,
            commandStack = this._commandStack;
      const newProperties = newTemplate.properties.filter(newProperty => {
        const newBinding = newProperty.binding,
              newBindingType = newBinding.type;
        return newBindingType === 'camunda:in' || newBindingType === 'camunda:in:businessKey' || newBindingType === 'camunda:out';
      }); // (1) do not override old fields if no new fields specified

      if (!newProperties.length) {
        return;
      } // get extension elements of either signal event definition or call activity


      const extensionElements = this._getOrCreateExtensionElements(getSignalEventDefinition(element) || element);

      const oldInsAndOuts = findExtensions(extensionElements, ['camunda:In', 'camunda:Out']);
      newProperties.forEach(newProperty => {
        const oldProperty = findOldProperty(oldTemplate, newProperty),
              oldBinding = oldProperty && oldProperty.binding,
              oldInOurOut = oldProperty && findOldBusinessObject(extensionElements, oldProperty),
              newPropertyValue = newProperty.value,
              newBinding = newProperty.binding,
              newBindingType = newBinding.type,
              properties = {};
        let newInOrOut; // (2) update old ins and outs

        if (oldProperty && oldInOurOut) {
          if (!propertyChanged(oldInOurOut, oldProperty)) {
            if (newBindingType === 'camunda:in') {
              if (newBinding.expression) {
                properties['camunda:sourceExpression'] = newPropertyValue;
              } else {
                properties['camunda:source'] = newPropertyValue;
              }
            } else if (newBindingType === 'camunda:in:businessKey') {
              properties['camunda:businessKey'] = newPropertyValue;
            } else if (newBindingType === 'camunda:out') {
              properties['camunda:target'] = newPropertyValue;
            }
          } // update camunda:local property if it changed


          if (oldBinding.local && !newBinding.local || !oldBinding.local && newBinding.local) {
            properties.local = newBinding.local;
          }

          if (keys(properties)) {
            commandStack.execute('element.updateModdleProperties', {
              element,
              moddleElement: oldInOurOut,
              properties
            });
          }

          remove(oldInsAndOuts, oldInOurOut);
        } // (3) add new ins and outs
        else {
          if (newBindingType === 'camunda:in') {
            newInOrOut = createCamundaIn(newBinding, newPropertyValue, bpmnFactory);
          } else if (newBindingType === 'camunda:out') {
            newInOrOut = createCamundaOut(newBinding, newPropertyValue, bpmnFactory);
          } else if (newBindingType === 'camunda:in:businessKey') {
            newInOrOut = createCamundaInWithBusinessKey(newPropertyValue, bpmnFactory);
          }

          commandStack.execute('element.updateModdleProperties', {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...extensionElements.get('values'), newInOrOut]
            }
          });
        }
      }); // (4) remove old ins and outs

      if (oldInsAndOuts.length) {
        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: extensionElements,
          properties: {
            values: without(extensionElements.get('values'), value => oldInsAndOuts.includes(value))
          }
        });
      }
    }
    /**
     * Update `camunda:InputParameter` and `camunda:OutputParameter` properties of specified business
     * object. Both can only exist in `camunda:InputOutput` which can exist in `bpmn:ExtensionElements`
     * or `camunda:Connector`.
     *
     * @param {djs.model.Base} element
     * @param {Object} oldTemplate
     * @param {Object} newTemplate
     */


    _updateCamundaInputOutputParameterProperties(element, oldTemplate, newTemplate, businessObject) {
      const bpmnFactory = this._bpmnFactory,
            commandStack = this._commandStack;
      const newProperties = newTemplate.properties.filter(newProperty => {
        const newBinding = newProperty.binding,
              newBindingType = newBinding.type;
        return newBindingType === 'camunda:inputParameter' || newBindingType === 'camunda:outputParameter';
      }); // (1) do not override old inputs and outputs if no new inputs and outputs specified

      if (!newProperties.length) {
        return;
      }

      if (!businessObject) {
        businessObject = this._getOrCreateExtensionElements(element);
      }

      let inputOutput;

      if (is$4(businessObject, 'camunda:Connector')) {
        inputOutput = businessObject.get('camunda:inputOutput');

        if (!inputOutput) {
          inputOutput = bpmnFactory.create('camunda:InputOutput');
          commandStack.execute('element.updateModdleProperties', {
            element,
            moddleElement: businessObject,
            properties: {
              inputOutput
            }
          });
        }
      } else {
        inputOutput = findExtension(businessObject, 'camunda:InputOutput');

        if (!inputOutput) {
          inputOutput = bpmnFactory.create('camunda:InputOutput');
          commandStack.execute('element.updateModdleProperties', {
            element,
            moddleElement: businessObject,
            properties: {
              values: [...businessObject.get('values'), inputOutput]
            }
          });
        }
      }

      const oldInputs = inputOutput.get('camunda:inputParameters') ? inputOutput.get('camunda:inputParameters').slice() : [];
      const oldOutputs = inputOutput.get('camunda:outputParameters') ? inputOutput.get('camunda:outputParameters').slice() : [];
      let propertyName;
      newProperties.forEach(newProperty => {
        const oldProperty = findOldProperty(oldTemplate, newProperty),
              oldInputOrOutput = oldProperty && findOldBusinessObject(businessObject, oldProperty),
              newPropertyValue = newProperty.value,
              newBinding = newProperty.binding,
              newBindingType = newBinding.type;
        let newInputOrOutput, properties; // (2) update old inputs and outputs

        if (oldProperty && oldInputOrOutput) {
          if (!propertyChanged(oldInputOrOutput, oldProperty)) {
            if (is$4(oldInputOrOutput, 'camunda:InputParameter')) {
              properties = {
                value: newPropertyValue
              };
            } else {
              properties = {
                name: newPropertyValue
              };
            }

            commandStack.execute('element.updateModdleProperties', {
              element,
              moddleElement: oldInputOrOutput,
              properties
            });
          }

          if (is$4(oldInputOrOutput, 'camunda:InputParameter')) {
            remove(oldInputs, oldInputOrOutput);
          } else {
            remove(oldOutputs, oldInputOrOutput);
          }
        } // (3) add new inputs and outputs
        else {
          if (newBindingType === 'camunda:inputParameter') {
            propertyName = 'inputParameters';
            newInputOrOutput = createInputParameter(newBinding, newPropertyValue, bpmnFactory);
          } else {
            propertyName = 'outputParameters';
            newInputOrOutput = createOutputParameter(newBinding, newPropertyValue, bpmnFactory);
          }

          commandStack.execute('element.updateModdleProperties', {
            element,
            moddleElement: inputOutput,
            properties: {
              [propertyName]: [...inputOutput.get(propertyName), newInputOrOutput]
            }
          });
        }
      }); // (4) remove old inputs and outputs

      if (oldInputs.length) {
        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: inputOutput,
          properties: {
            inputParameters: without(inputOutput.get('inputParameters'), inputParameter => oldInputs.includes(inputParameter))
          }
        });
      }

      if (oldOutputs.length) {
        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: inputOutput,
          properties: {
            outputParameters: without(inputOutput.get('outputParameters'), outputParameter => oldOutputs.includes(outputParameter))
          }
        });
      }
    }

    _updateCamundaModelerTemplate(element, newTemplate) {
      const modeling = this._modeling;
      modeling.updateProperties(element, {
        'camunda:modelerTemplate': newTemplate && newTemplate.id,
        'camunda:modelerTemplateVersion': newTemplate && newTemplate.version
      });
    }
    /**
     * Update `camunda:Property` properties of specified business object. `camunda:Property` can only
     * exist in `camunda:Properties`.
     *
     * @param {djs.model.Base} element
     * @param {Object} oldTemplate
     * @param {Object} newTemplate
     * @param {ModdleElement} businessObject
     */


    _updateCamundaPropertyProperties(element, oldTemplate, newTemplate, businessObject) {
      const bpmnFactory = this._bpmnFactory,
            commandStack = this._commandStack;
      const newProperties = newTemplate.properties.filter(newProperty => {
        const newBinding = newProperty.binding,
              newBindingType = newBinding.type;
        return newBindingType === 'camunda:property';
      }); // (1) do not override old properties if no new properties specified

      if (!newProperties.length) {
        return;
      }

      if (businessObject) {
        businessObject = this._getOrCreateExtensionElements(businessObject);
      } else {
        businessObject = this._getOrCreateExtensionElements(element);
      }

      let camundaProperties = findExtension(businessObject, 'camunda:Properties');

      if (!camundaProperties) {
        camundaProperties = bpmnFactory.create('camunda:Properties');
        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: businessObject,
          properties: {
            values: [...businessObject.get('values'), camundaProperties]
          }
        });
      }

      const oldCamundaProperties = camundaProperties.get('camunda:values') ? camundaProperties.get('camunda:values').slice() : [];
      newProperties.forEach(newProperty => {
        const oldProperty = findOldProperty(oldTemplate, newProperty),
              oldCamundaProperty = oldProperty && findOldBusinessObject(businessObject, oldProperty),
              newPropertyValue = newProperty.value,
              newBinding = newProperty.binding; // (2) update old properties

        if (oldProperty && oldCamundaProperty) {
          if (!propertyChanged(oldCamundaProperty, oldProperty)) {
            commandStack.execute('element.updateModdleProperties', {
              element,
              moddleElement: oldCamundaProperty,
              properties: {
                value: newPropertyValue
              }
            });
          }

          remove(oldCamundaProperties, oldCamundaProperty);
        } // (3) add new properties
        else {
          const newCamundaProperty = createCamundaProperty(newBinding, newPropertyValue, bpmnFactory);
          commandStack.execute('element.updateModdleProperties', {
            element,
            moddleElement: camundaProperties,
            properties: {
              values: [...camundaProperties.get('values'), newCamundaProperty]
            }
          });
        }
      }); // (4) remove old properties

      if (oldCamundaProperties.length) {
        commandStack.execute('element.updateModdleProperties', {
          element,
          moddleElement: camundaProperties,
          properties: {
            values: without(camundaProperties.get('values'), value => oldCamundaProperties.includes(value))
          }
        });
      }
    }
    /**
     * Update `bpmn:conditionExpression` property of specified element. Since condition expression is
     * is not primitive it needs special handling.
     *
     * @param {djs.model.Base} element
     * @param {Object} oldProperty
     * @param {Object} newProperty
     */


    _updateConditionExpression(element, oldProperty, newProperty) {
      const bpmnFactory = this._bpmnFactory,
            commandStack = this._commandStack,
            modeling = this._modeling;
      const newBinding = newProperty.binding,
            newPropertyValue = newProperty.value;

      if (!oldProperty) {
        modeling.updateProperties(element, {
          conditionExpression: bpmnFactory.create('bpmn:FormalExpression', {
            body: newPropertyValue,
            language: newBinding.scriptFormat
          })
        });
        return;
      }

      const oldBinding = oldProperty.binding,
            oldPropertyValue = oldProperty.value;
      const businessObject = getBusinessObject$1(element),
            conditionExpression = businessObject.get('bpmn:conditionExpression');
      const properties = {};

      if (conditionExpression.get('body') === oldPropertyValue) {
        properties.body = newPropertyValue;
      }

      if (conditionExpression.get('language') === oldBinding.scriptFormat) {
        properties.language = newBinding.scriptFormat;
      }

      if (!keys(properties).length) {
        return;
      }

      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: conditionExpression,
        properties
      });
    }

    _updateProperties(element, oldTemplate, newTemplate, businessObject) {
      const commandStack = this._commandStack;
      const newProperties = newTemplate.properties.filter(newProperty => {
        const newBinding = newProperty.binding,
              newBindingType = newBinding.type;
        return newBindingType === 'property';
      });

      if (!newProperties.length) {
        return;
      }

      if (!businessObject) {
        businessObject = getBusinessObject$1(element);
      }

      newProperties.forEach(newProperty => {
        const oldProperty = findOldProperty(oldTemplate, newProperty),
              newBinding = newProperty.binding,
              newBindingName = newBinding.name,
              newPropertyValue = newProperty.value;
        let changedElement, properties;

        if (newBindingName === 'conditionExpression') {
          this._updateConditionExpression(element, oldProperty, newProperty);
        } else {
          if (is$4(businessObject, 'bpmn:Error')) {
            changedElement = businessObject;
          } else {
            changedElement = element;
          }

          if (oldProperty && propertyChanged(changedElement, oldProperty)) {
            return;
          }

          properties = {};
          properties[newBindingName] = newPropertyValue; // only one of `camunda:class`, `camunda:delegateExpression` and `camunda:expression` can be set
          // TODO(philippfromme): ensuring only one of these properties is set at a time should be
          // implemented in a behavior and not in this handler and properties panel UI

          if (CAMUNDA_SERVICE_TASK_LIKE.indexOf(newBindingName) !== -1) {
            CAMUNDA_SERVICE_TASK_LIKE.forEach(camundaServiceTaskLikeProperty => {
              if (camundaServiceTaskLikeProperty !== newBindingName) {
                properties[camundaServiceTaskLikeProperty] = undefined;
              }
            });
          }

          commandStack.execute('element.updateModdleProperties', {
            element,
            moddleElement: businessObject,
            properties
          });
        }
      });
    }
    /**
     * Update properties for a specified scope.
     *
     * @param {djs.model.Base} element
     * @param {Object} oldTemplate
     * @param {Object} newScopeTemplate
     * @param {Object} newTemplate
     */


    _updateScopeProperties(element, oldTemplate, newScopeTemplate, newTemplate) {
      const bpmnFactory = this._bpmnFactory,
            commandStack = this._commandStack;
      const scopeName = newScopeTemplate.type;
      let scopeElement;
      scopeElement = findOldScopeElement(element, newScopeTemplate, newTemplate);

      if (!scopeElement) {
        scopeElement = bpmnFactory.create(scopeName);
      }

      const oldScopeTemplate = findOldScopeTemplate(newScopeTemplate, oldTemplate); // update properties

      this._updateProperties(element, oldScopeTemplate, newScopeTemplate, scopeElement); // update camunda:ExecutionListener properties


      this._updateCamundaExecutionListenerProperties(element, newScopeTemplate); // update camunda:In and camunda:Out properties


      this._updateCamundaInOutProperties(element, oldScopeTemplate, newScopeTemplate); // update camunda:InputParameter and camunda:OutputParameter properties


      this._updateCamundaInputOutputParameterProperties(element, oldScopeTemplate, newScopeTemplate, scopeElement); // update camunda:Field properties


      this._updateCamundaFieldProperties(element, oldScopeTemplate, newScopeTemplate, scopeElement); // update camunda:Property properties


      this._updateCamundaPropertyProperties(element, oldScopeTemplate, newScopeTemplate, scopeElement); // assume that root elements were already created in root by referenced event definition binding


      if (isRootElementScope(scopeName)) {
        return;
      }

      const extensionElements = this._getOrCreateExtensionElements(element);

      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: extensionElements,
        properties: {
          values: [...extensionElements.get('values'), scopeElement]
        }
      });
    }
    /**
     * Replaces the element with the specified elementType
     *
     * @param {djs.model.Base} element
     * @param {Object} newTemplate
     */


    _updateTaskType(element, newTemplate) {
      // determine new task type
      const newType = newTemplate.elementType;

      if (!newType) {
        return element;
      } // don't replace Task that is already the correct type


      if (element.$type === newType.value) {
        return element;
      }

      return this._bpmnReplace.replaceElement(element, {
        type: newType.value
      });
    }

  }
  ChangeElementTemplateHandler.$inject = ['bpmnFactory', 'bpmnReplace', 'commandStack', 'modeling']; // helpers //////////

  /**
   * Find old business object matching specified old property.
   *
   * @param {djs.model.Base|ModdleElement} element
   * @param {Object} oldProperty
   *
   * @returns {ModdleElement}
   */

  function findOldBusinessObject(element, oldProperty) {
    let businessObject = getBusinessObject$1(element),
        propertyName;
    const oldBinding = oldProperty.binding,
          oldBindingType = oldBinding.type;

    if (oldBindingType === 'camunda:field') {
      if (isAny(businessObject, ['camunda:ExecutionListener', 'camunda:TaskListener'])) {
        propertyName = 'camunda:fields';
      } else {
        propertyName = 'bpmn:values';
      }

      if (!businessObject || !businessObject.get(propertyName) || !businessObject.get(propertyName).length) {
        return;
      }

      return find$1(businessObject.get(propertyName), function (oldBusinessObject) {
        return oldBusinessObject.get('camunda:name') === oldBinding.name;
      });
    }

    if (oldBindingType === 'camunda:in') {
      return find$1(businessObject.get('values'), function (oldBusinessObject) {
        return oldBusinessObject.get('target') === oldBinding.target;
      });
    }

    if (oldBindingType === 'camunda:in:businessKey') {
      return find$1(businessObject.get('values'), function (oldBusinessObject) {
        return isString(oldBusinessObject.get('businessKey'));
      });
    }

    if (oldBindingType === 'camunda:out') {
      return find$1(businessObject.get('values'), function (oldBusinessObject) {
        return oldBusinessObject.get('source') === oldBinding.source || oldBusinessObject.get('sourceExpression') || oldBinding.sourceExpression;
      });
    }

    if (oldBindingType === 'camunda:inputParameter' || oldBindingType === 'camunda:outputParameter') {
      if (is$4(businessObject, 'camunda:Connector')) {
        businessObject = businessObject.get('camunda:inputOutput');

        if (!businessObject) {
          return;
        }
      } else {
        businessObject = findExtension(businessObject, 'camunda:InputOutput');

        if (!businessObject) {
          return;
        }
      }

      if (oldBindingType === 'camunda:inputParameter') {
        return find$1(businessObject.get('camunda:inputParameters'), function (oldBusinessObject) {
          return oldBusinessObject.get('camunda:name') === oldBinding.name;
        });
      } else {
        return find$1(businessObject.get('camunda:outputParameters'), function (oldBusinessObject) {
          if (oldBinding.scriptFormat) {
            const definition = oldBusinessObject.get('camunda:definition');
            return definition && definition.get('camunda:value') === oldBinding.source;
          } else {
            return oldBusinessObject.get('camunda:value') === oldBinding.source;
          }
        });
      }
    }

    if (oldBindingType === 'camunda:property') {
      if (!businessObject || !businessObject.get('values') || !businessObject.get('values').length) {
        return;
      }

      businessObject = findExtension(businessObject, 'camunda:Properties');

      if (!businessObject) {
        return;
      }

      return find$1(businessObject.get('values'), function (oldBusinessObject) {
        return oldBusinessObject.get('camunda:name') === oldBinding.name;
      });
    }

    if (oldBindingType === 'camunda:errorEventDefinition') {
      return findCamundaErrorEventDefinition(element, oldBinding.errorRef);
    }
  }
  /**
   * Find old property matching specified new property.
   *
   * @param {Object} oldTemplate
   * @param {Object} newProperty
   *
   * @returns {Object}
   */


  function findOldProperty(oldTemplate, newProperty) {
    if (!oldTemplate) {
      return;
    }

    const oldProperties = oldTemplate.properties,
          newBinding = newProperty.binding,
          newBindingName = newBinding.name,
          newBindingType = newBinding.type;

    if (newBindingType === 'property') {
      return find$1(oldProperties, function (oldProperty) {
        const oldBinding = oldProperty.binding,
              oldBindingName = oldBinding.name,
              oldBindingType = oldBinding.type;
        return oldBindingType === 'property' && oldBindingName === newBindingName;
      });
    }

    if (newBindingType === 'camunda:field') {
      return find$1(oldProperties, function (oldProperty) {
        const oldBinding = oldProperty.binding,
              oldBindingName = oldBinding.name,
              oldBindingType = oldBinding.type;
        return oldBindingType === 'camunda:field' && oldBindingName === newBindingName;
      });
    }

    if (newBindingType === 'camunda:in') {
      return find$1(oldProperties, function (oldProperty) {
        const oldBinding = oldProperty.binding,
              oldBindingType = oldBinding.type;

        if (oldBindingType !== 'camunda:in') {
          return;
        } // always override if change from source to source expression or vice versa


        if (oldBinding.expression && !newBinding.expression || !oldBinding.expression && newBinding.expression) {
          return;
        }

        return oldBinding.target === newBinding.target;
      });
    }

    if (newBindingType === 'camunda:in:businessKey') {
      return find$1(oldProperties, function (oldProperty) {
        const oldBinding = oldProperty.binding,
              oldBindingType = oldBinding.type;
        return oldBindingType === 'camunda:in:businessKey';
      });
    }

    if (newBindingType === 'camunda:out') {
      return find$1(oldProperties, function (oldProperty) {
        const oldBinding = oldProperty.binding,
              oldBindingType = oldBinding.type;
        return oldBindingType === 'camunda:out' && (oldBinding.source === newBinding.source || oldBinding.sourceExpression === newBinding.sourceExpression);
      });
    }

    if (newBindingType === 'camunda:inputParameter') {
      return find$1(oldProperties, function (oldProperty) {
        const oldBinding = oldProperty.binding,
              oldBindingName = oldBinding.name,
              oldBindingType = oldBinding.type;

        if (oldBindingType !== 'camunda:inputParameter') {
          return;
        }

        return oldBindingName === newBindingName && oldBinding.scriptFormat === newBinding.scriptFormat;
      });
    }

    if (newBindingType === 'camunda:outputParameter') {
      return find$1(oldProperties, function (oldProperty) {
        const oldBinding = oldProperty.binding,
              oldBindingType = oldBinding.type;

        if (oldBindingType !== 'camunda:outputParameter') {
          return;
        }

        return oldBinding.source === newBinding.source && oldBinding.scriptFormat === newBinding.scriptFormat;
      });
    }

    if (newBindingType === 'camunda:property') {
      return find$1(oldProperties, function (oldProperty) {
        const oldBinding = oldProperty.binding,
              oldBindingName = oldBinding.name,
              oldBindingType = oldBinding.type;
        return oldBindingType === 'camunda:property' && oldBindingName === newBindingName;
      });
    }

    if (newBindingType === 'camunda:errorEventDefinition') {
      return find$1(oldProperties, function (oldProperty) {
        const newBindingRef = newBinding.errorRef,
              oldBinding = oldProperty.binding,
              oldBindingRef = oldBinding.errorRef,
              oldBindingType = oldBinding.type;
        return oldBindingType === 'camunda:errorEventDefinition' && oldBindingRef === newBindingRef;
      });
    }
  }

  function findOldScopeElement(element, scopeTemplate, template) {
    const scopeName = scopeTemplate.type,
          id = scopeTemplate.id;

    if (scopeName === 'camunda:Connector') {
      return findExtension(element, 'camunda:Connector');
    }

    if (scopeName === 'bpmn:Error') {
      // (1) find by error event definition binding
      const errorEventDefinitionBinding = findErrorEventDefinitionBinding(template, id);

      if (!errorEventDefinitionBinding) {
        return;
      } // (2) find error event definition


      const errorEventDefinition = findOldBusinessObject(element, errorEventDefinitionBinding);

      if (!errorEventDefinition) {
        return;
      } // (3) retrieve referenced error


      return errorEventDefinition.errorRef;
    }
  }

  function isRootElementScope(scopeName) {
    return ['bpmn:Error'].includes(scopeName);
  }

  function findOldScopeTemplate(scopeTemplate, oldTemplate) {
    const scopeName = scopeTemplate.type,
          scopeId = scopeTemplate.id,
          scopes = oldTemplate && handleLegacyScopes(oldTemplate.scopes);
    return scopes && find$1(scopes, function (scope) {
      if (isRootElementScope(scopeName)) {
        return scope.id === scopeId;
      }

      return scope.type === scopeName;
    });
  }

  function findErrorEventDefinitionBinding(template, templateErrorId) {
    return find$1(template.properties, function (property) {
      return property.binding.errorRef === templateErrorId;
    });
  }
  /**
   * Check whether property was changed after being set by template.
   *
   * @param {djs.model.Base|ModdleElement} element
   * @param {Object} oldProperty
   *
   * @returns {boolean}
   */


  function propertyChanged(element, oldProperty) {
    const businessObject = getBusinessObject$1(element);
    const oldBinding = oldProperty.binding,
          oldBindingName = oldBinding.name,
          oldBindingType = oldBinding.type,
          oldPropertyValue = oldProperty.value;
    let conditionExpression, definition;

    if (oldBindingType === 'property') {
      if (oldBindingName === 'conditionExpression') {
        conditionExpression = businessObject.get('bpmn:conditionExpression');
        return conditionExpression.get('bpmn:body') !== oldPropertyValue;
      }

      return businessObject.get(oldBindingName) !== oldPropertyValue;
    }

    if (oldBindingType === 'camunda:field') {
      return businessObject.get('camunda:string') !== oldPropertyValue;
    }

    if (oldBindingType === 'camunda:in') {
      if (oldBinding.expression) {
        return businessObject.get('sourceExpression') !== oldPropertyValue;
      } else {
        return businessObject.get('camunda:source') !== oldPropertyValue;
      }
    }

    if (oldBindingType === 'camunda:in:businessKey') {
      return businessObject.get('camunda:businessKey') !== oldPropertyValue;
    }

    if (oldBindingType === 'camunda:out') {
      return businessObject.get('camunda:target') !== oldPropertyValue;
    }

    if (oldBindingType === 'camunda:inputParameter') {
      if (oldBinding.scriptFormat) {
        definition = businessObject.get('camunda:definition');
        return definition && definition.get('camunda:value') !== oldPropertyValue;
      } else {
        return businessObject.get('camunda:value') !== oldPropertyValue;
      }
    }

    if (oldBindingType === 'camunda:outputParameter') {
      return businessObject.get('camunda:name') !== oldPropertyValue;
    }

    if (oldBindingType === 'camunda:property') {
      return businessObject.get('camunda:value') !== oldPropertyValue;
    }

    if (oldBindingType === 'camunda:errorEventDefinition') {
      return businessObject.get('expression') !== oldPropertyValue;
    }
  }

  function remove(array, item) {
    const index = array.indexOf(item);

    if (isUndefined(index)) {
      return array;
    }

    array.splice(index, 1);
    return array;
  }

  function registerHandlers(commandStack, elementTemplates, eventBus) {
    commandStack.registerHandler('propertiesPanel.camunda.changeTemplate', ChangeElementTemplateHandler); // apply default element templates on shape creation

    eventBus.on(['commandStack.shape.create.postExecuted'], function (context) {
      applyDefaultTemplate(context.context.shape, elementTemplates, commandStack);
    }); // apply default element templates on connection creation

    eventBus.on(['commandStack.connection.create.postExecuted'], function (context) {
      applyDefaultTemplate(context.context.connection, elementTemplates, commandStack);
    });
  }

  registerHandlers.$inject = ['commandStack', 'elementTemplates', 'eventBus'];
  var commandsModule = {
    __init__: [registerHandlers]
  };

  function applyDefaultTemplate(element, elementTemplates, commandStack) {
    if (!elementTemplates.get(element) && elementTemplates.getDefault(element)) {
      const command = 'propertiesPanel.camunda.changeTemplate';
      const commandContext = {
        element: element,
        newTemplate: elementTemplates.getDefault(element)
      };
      commandStack.execute(command, commandContext);
    }
  }

  const CAMUNDA_ERROR_EVENT_DEFINITION_TYPE$1 = 'camunda:errorEventDefinition';
  const CAMUNDA_EXECUTION_LISTENER_TYPE = 'camunda:executionListener';
  const CAMUNDA_FIELD_TYPE = 'camunda:field';
  const CAMUNDA_IN_BUSINESS_KEY_TYPE = 'camunda:in:businessKey';
  const CAMUNDA_IN_TYPE = 'camunda:in';
  const CAMUNDA_INPUT_PARAMETER_TYPE$1 = 'camunda:inputParameter';
  const CAMUNDA_OUT_TYPE = 'camunda:out';
  const CAMUNDA_OUTPUT_PARAMETER_TYPE$1 = 'camunda:outputParameter';
  const CAMUNDA_PROPERTY_TYPE = 'camunda:property';
  const PROPERTY_TYPE = 'property';
  const EXTENSION_BINDING_TYPES = [CAMUNDA_ERROR_EVENT_DEFINITION_TYPE$1, CAMUNDA_FIELD_TYPE, CAMUNDA_IN_TYPE, CAMUNDA_IN_BUSINESS_KEY_TYPE, CAMUNDA_INPUT_PARAMETER_TYPE$1, CAMUNDA_OUT_TYPE, CAMUNDA_OUTPUT_PARAMETER_TYPE$1, CAMUNDA_PROPERTY_TYPE];
  const IO_BINDING_TYPES = [CAMUNDA_INPUT_PARAMETER_TYPE$1, CAMUNDA_OUTPUT_PARAMETER_TYPE$1];
  const IN_OUT_BINDING_TYPES = [CAMUNDA_IN_BUSINESS_KEY_TYPE, CAMUNDA_IN_TYPE, CAMUNDA_OUT_TYPE];

  const PRIMITIVE_MODDLE_TYPES = ['Boolean', 'Integer', 'String'];
  const DEFAULT_CUSTOM_GROUP = {
    id: 'ElementTemplates__CustomProperties',
    label: 'Custom properties'
  };
  function CustomProperties(props) {
    const {
      element,
      elementTemplate
    } = props;
    const groups = [];
    const {
      id,
      properties,
      groups: propertyGroups,
      scopes
    } = elementTemplate; // (1) group properties by group id

    const groupedProperties = groupByGroupId(properties);
    const defaultProps = [];
    forEach(groupedProperties, (properties, groupId) => {
      const group = findCustomGroup(propertyGroups, groupId);

      if (!group) {
        return defaultProps.push(...properties);
      }

      addCustomGroup(groups, {
        element,
        id: `ElementTemplates__CustomProperties-${groupId}`,
        label: group.label,
        properties: properties,
        templateId: `${id}-${groupId}`
      });
    }); // (2) add default custom props

    if (defaultProps.length) {
      addCustomGroup(groups, { ...DEFAULT_CUSTOM_GROUP,
        element,
        properties: defaultProps,
        templateId: id
      });
    } // (3) add custom scopes props


    if (isArray(scopes)) {
      scopes.forEach(scope => {
        const {
          properties,
          type
        } = scope;
        const id = type.replace(/:/g, '-');
        addCustomGroup(groups, {
          element,
          id: `ElementTemplates__CustomGroup-${id}`,
          label: `Custom properties for scope <${type}>`,
          properties,
          templateId: id,
          scope
        });
      });
    }

    return groups;
  }

  function addCustomGroup(groups, props) {
    const {
      element,
      id,
      label,
      properties,
      scope,
      templateId
    } = props;
    const customPropertiesGroup = {
      id,
      label,
      component: Group,
      entries: [],
      shouldOpen: true
    };
    properties.forEach((property, index) => {
      const entry = createCustomEntry(`custom-entry-${templateId}-${index}`, element, property, scope);

      if (entry) {
        customPropertiesGroup.entries.push(entry);
      }
    });

    if (customPropertiesGroup.entries.length) {
      groups.push(customPropertiesGroup);
    }
  }

  function createCustomEntry(id, element, property, scope) {
    let {
      type
    } = property;

    if (!type) {
      type = getDefaultType(property);
    }

    if (type === 'Boolean') {
      return {
        id,
        component: BooleanProperty,
        isEdited: isEdited$7,
        property,
        scope
      };
    }

    if (type === 'Dropdown') {
      return {
        id,
        component: DropdownProperty,
        isEdited: isEdited$4,
        property,
        scope
      };
    }

    if (type === 'String') {
      return {
        id,
        component: StringProperty,
        isEdited: isEdited$1,
        property,
        scope
      };
    }

    if (type === 'Text') {
      return {
        id,
        component: TextAreaProperty,
        isEdited: isEdited$2,
        property,
        scope
      };
    }
  }

  function getDefaultType(property) {
    const {
      binding
    } = property;
    const {
      type
    } = binding;

    if ([PROPERTY_TYPE, CAMUNDA_PROPERTY_TYPE, CAMUNDA_IN_TYPE, CAMUNDA_IN_BUSINESS_KEY_TYPE, CAMUNDA_OUT_TYPE, CAMUNDA_FIELD_TYPE].includes(type)) {
      return 'String';
    }

    if (type === CAMUNDA_EXECUTION_LISTENER_TYPE) {
      return 'Hidden';
    }
  }

  function BooleanProperty(props) {
    const {
      element,
      id,
      property,
      scope
    } = props;
    const {
      description,
      editable,
      label
    } = property;
    const bpmnFactory = useService('bpmnFactory'),
          commandStack = useService('commandStack');
    return CheckboxEntry({
      element,
      getValue: propertyGetter(element, property, scope),
      id,
      label,
      description: PropertyDescription({
        description
      }),
      setValue: propertySetter(bpmnFactory, commandStack, element, property, scope),
      disabled: editable === false
    });
  }

  function DropdownProperty(props) {
    const {
      element,
      id,
      property,
      scope
    } = props;
    const {
      description,
      editable,
      label
    } = property;
    const bpmnFactory = useService('bpmnFactory'),
          commandStack = useService('commandStack');

    const getOptions = () => {
      const {
        choices
      } = property;
      return choices.map(({
        name,
        value
      }) => {
        return {
          label: name,
          value
        };
      });
    };

    return SelectEntry({
      element,
      id,
      label,
      getOptions,
      description: PropertyDescription({
        description
      }),
      getValue: propertyGetter(element, property, scope),
      setValue: propertySetter(bpmnFactory, commandStack, element, property, scope),
      disabled: editable === false
    });
  }

  function StringProperty(props) {
    const {
      element,
      id,
      property,
      scope
    } = props;
    const {
      description,
      editable,
      label
    } = property;
    const bpmnFactory = useService('bpmnFactory'),
          commandStack = useService('commandStack'),
          debounce = useService('debounceInput'),
          translate = useService('translate');
    return TextfieldEntry({
      debounce,
      element,
      getValue: propertyGetter(element, property, scope),
      id,
      label,
      description: PropertyDescription({
        description
      }),
      setValue: propertySetter(bpmnFactory, commandStack, element, property, scope),
      validate: propertyValidator(translate, property),
      disabled: editable === false
    });
  }

  function TextAreaProperty(props) {
    const {
      element,
      id,
      property,
      scope
    } = props;
    const {
      description,
      editable,
      label
    } = property;
    const bpmnFactory = useService('bpmnFactory'),
          commandStack = useService('commandStack'),
          debounce = useService('debounceInput');
    return TextAreaEntry({
      debounce,
      element,
      id,
      label,
      description: PropertyDescription({
        description
      }),
      getValue: propertyGetter(element, property, scope),
      setValue: propertySetter(bpmnFactory, commandStack, element, property, scope),
      disabled: editable === false
    });
  }

  function propertyGetter(element, property, scope) {
    return function getValue() {
      let businessObject = getBusinessObject$1(element);
      const {
        binding,
        value: defaultValue = ''
      } = property;
      const {
        name,
        type
      } = binding;

      if (scope) {
        businessObject = getScopeBusinessObject(businessObject, scope);

        if (!businessObject) {
          return defaultValue;
        }
      } // property


      if (type === 'property') {
        const value = businessObject.get(name);

        if (name === 'conditionExpression') {
          if (value) {
            return value.get('body');
          }

          return defaultValue;
        } else {
          if (!isUndefined(value)) {
            return value;
          }

          return defaultValue;
        }
      } // camunda:ErrorEventDefinition


      if (type === CAMUNDA_ERROR_EVENT_DEFINITION_TYPE$1) {
        const {
          errorRef
        } = binding;
        const errorEventDefinition = findCamundaErrorEventDefinition(businessObject, errorRef);

        if (errorEventDefinition) {
          return errorEventDefinition.get('camunda:expression');
        } else {
          return '';
        }
      } // camunda:Field


      if (type === CAMUNDA_FIELD_TYPE) {
        const camundaFields = findExtensions(businessObject, ['camunda:Field']);
        const camundaField = camundaFields.find(camundaField => {
          return camundaField.get('camunda:name') === name;
        });

        if (camundaField) {
          return camundaField.get('camunda:string') || camundaField.get('camunda:expression');
        } else {
          return '';
        }
      } // camunda:Property


      if (type === CAMUNDA_PROPERTY_TYPE) {
        let camundaProperties;

        if (scope) {
          // TODO(philippfromme): as only bpmn:Error and camunda:Connector are supported this code is practically dead
          camundaProperties = businessObject.get('properties');
        } else {
          camundaProperties = findExtension(businessObject, 'camunda:Properties');
        }

        if (camundaProperties) {
          const camundaProperty = findCamundaProperty(camundaProperties, binding);

          if (camundaProperty) {
            return camundaProperty.get('camunda:value');
          }
        }

        return defaultValue;
      }

      if (IO_BINDING_TYPES.includes(type)) {
        let inputOutput;

        if (scope) {
          inputOutput = businessObject.get('inputOutput');
        } else {
          inputOutput = findExtension(businessObject, 'camunda:InputOutput');
        }

        if (!inputOutput) {
          return defaultValue;
        } // camunda:InputParameter


        if (type === CAMUNDA_INPUT_PARAMETER_TYPE$1) {
          const inputParameter = findInputParameter(inputOutput, binding);

          if (inputParameter) {
            const {
              scriptFormat
            } = binding;

            if (scriptFormat) {
              const definition = inputParameter.get('camunda:definition');

              if (definition) {
                return definition.get('camunda:value');
              }
            } else {
              return inputParameter.get('value') || '';
            }
          }

          return defaultValue;
        } // camunda:OutputParameter


        if (type === CAMUNDA_OUTPUT_PARAMETER_TYPE$1) {
          const outputParameter = findOutputParameter(inputOutput, binding);

          if (outputParameter) {
            return outputParameter.get('camunda:name');
          }

          return defaultValue;
        }
      } // camunda:In and camunda:Out


      if (IN_OUT_BINDING_TYPES.includes(type)) {
        const camundaInOut = findCamundaInOut(businessObject, binding);

        if (camundaInOut) {
          if (type === CAMUNDA_IN_BUSINESS_KEY_TYPE) {
            return camundaInOut.get('camunda:businessKey');
          } else if (type === CAMUNDA_OUT_TYPE) {
            return camundaInOut.get('camunda:target');
          } else if (type === CAMUNDA_IN_TYPE) {
            const {
              expression
            } = binding;

            if (expression) {
              return camundaInOut.get('camunda:sourceExpression');
            } else {
              return camundaInOut.get('camunda:source');
            }
          }
        }

        return defaultValue;
      } // should never throw as templates are validated beforehand


      throw unknownBindingError(element, property);
    };
  }

  function propertySetter(bpmnFactory, commandStack, element, property, scope) {
    return function setValue(value) {
      let businessObject = getBusinessObject$1(element);
      const {
        binding
      } = property;
      const {
        name,
        type
      } = binding;
      const rootElement = getRoot(businessObject);
      let extensionElements;
      let propertyValue;
      const commands = [];

      if (EXTENSION_BINDING_TYPES.includes(type)) {
        extensionElements = businessObject.get('extensionElements');

        if (!extensionElements) {
          extensionElements = createElement('bpmn:ExtensionElements', null, businessObject, bpmnFactory);
          commands.push({
            cmd: 'element.updateModdleProperties',
            context: {
              element,
              moddleElement: businessObject,
              properties: {
                extensionElements
              }
            }
          });
        }
      }

      if (scope) {
        businessObject = getScopeBusinessObject(businessObject, scope);

        if (!businessObject) {
          // bpmn:Error
          if (scope.type === 'bpmn:Error') {
            businessObject = createError(scope.id, rootElement, bpmnFactory);
            commands.push({
              cmd: 'element.updateModdleProperties',
              context: {
                element,
                moddleElement: rootElement,
                properties: {
                  rootElements: [...rootElement.get('rootElements'), businessObject]
                }
              }
            });
          } else {
            businessObject = createElement(scope.type, null, element, bpmnFactory);
            commands.push({
              cmd: 'element.updateModdleProperties',
              context: {
                element,
                moddleElement: extensionElements,
                properties: {
                  values: [...extensionElements.get('values'), businessObject]
                }
              }
            });
          }
        }
      } // property


      if (type === 'property') {
        if (name === 'conditionExpression') {
          const {
            scriptFormat
          } = binding;
          propertyValue = createElement('bpmn:FormalExpression', {
            body: value,
            language: scriptFormat
          }, businessObject, bpmnFactory);
        } else {
          const propertyDescriptor = businessObject.$descriptor.propertiesByName[name];
          const {
            type: propertyType
          } = propertyDescriptor; // do not override non-primitive types

          if (!PRIMITIVE_MODDLE_TYPES.includes(propertyType)) {
            throw new Error(`cannot set property of type <${propertyType}>`);
          }

          if (propertyType === 'Boolean') {
            propertyValue = !!value;
          } else if (propertyType === 'Integer') {
            propertyValue = parseInt(value, 10);

            if (isNaN(propertyValue)) {
              // do not set NaN value
              propertyValue = undefined;
            }
          } else {
            // make sure we don't remove the property
            propertyValue = value || '';
          }
        }

        if (!isUndefined(propertyValue)) {
          commands.push({
            cmd: 'element.updateModdleProperties',
            context: {
              element,
              moddleElement: businessObject,
              properties: {
                [name]: propertyValue
              }
            }
          });
        }
      } // camunda:ErrorEventDefinition


      if (type === CAMUNDA_ERROR_EVENT_DEFINITION_TYPE$1) {
        const {
          errorRef
        } = binding;
        const oldCamundaErrorEventDefinition = findCamundaErrorEventDefinition(businessObject, errorRef);

        if (oldCamundaErrorEventDefinition) {
          commands.push({
            cmd: 'element.updateModdleProperties',
            context: {
              element,
              moddleElement: oldCamundaErrorEventDefinition,
              properties: {
                'camunda:expression': value
              }
            }
          });
        } else {
          const newError = createError(binding.errorRef, rootElement, bpmnFactory),
                newCamundaErrorEventDefinition = createCamundaErrorEventDefinition(value, newError, extensionElements, bpmnFactory);
          commands.push({
            cmd: 'element.updateModdleProperties',
            context: {
              element,
              moddleElement: rootElement,
              properties: {
                rootElements: [...rootElement.get('rootElements'), newError]
              }
            }
          });
          commands.push({
            cmd: 'element.updateModdleProperties',
            context: {
              element,
              moddleElement: extensionElements,
              properties: {
                values: [...extensionElements.get('values'), newCamundaErrorEventDefinition]
              }
            }
          });
        }
      } // camunda:Field


      if (type === CAMUNDA_FIELD_TYPE) {
        const oldCamundaFields = findExtensions(businessObject, ['camunda:Field']);
        const newCamundaFields = [];

        if (oldCamundaFields.length) {
          oldCamundaFields.forEach(camundaField => {
            if (camundaField.name === name) {
              newCamundaFields.push(createCamundaFieldInjection(binding, value, bpmnFactory));
            } else {
              newCamundaFields.push(camundaField);
            }
          });
        } else {
          newCamundaFields.push(createCamundaFieldInjection(binding, value, bpmnFactory));
        }

        const values = extensionElements.get('values').filter(value => !oldCamundaFields.includes(value));
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...values, ...newCamundaFields]
            }
          }
        });
      } // camunda:Property


      if (type === CAMUNDA_PROPERTY_TYPE) {
        let camundaProperties;

        if (scope) {
          camundaProperties = businessObject.get('properties');
        } else {
          camundaProperties = findExtension(extensionElements, 'camunda:Properties');
        }

        if (!camundaProperties) {
          camundaProperties = createElement('camunda:Properties', null, businessObject, bpmnFactory);

          if (scope) {
            commands.push({
              cmd: 'element.updateModdleProperties',
              context: {
                element,
                moddleElement: businessObject,
                properties: {
                  properties: camundaProperties
                }
              }
            });
          } else {
            commands.push({
              cmd: 'element.updateModdleProperties',
              context: {
                element,
                moddleElement: extensionElements,
                properties: {
                  values: [...extensionElements.get('values'), camundaProperties]
                }
              }
            });
          }
        }

        const oldCamundaProperty = findCamundaProperty(camundaProperties, binding);
        const newCamundaProperty = createCamundaProperty(binding, value, bpmnFactory);
        const values = camundaProperties.get('values').filter(value => value !== oldCamundaProperty);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: camundaProperties,
            properties: {
              values: [...values, newCamundaProperty]
            }
          }
        });
      }

      if (IO_BINDING_TYPES.includes(type)) {
        let inputOutput;

        if (scope) {
          inputOutput = businessObject.get('inputOutput');
        } else {
          inputOutput = findExtension(extensionElements, 'camunda:InputOutput');
        }

        if (!inputOutput) {
          inputOutput = createElement('camunda:InputOutput', null, businessObject, bpmnFactory);

          if (scope) {
            commands.push({
              cmd: 'element.updateModdleProperties',
              context: {
                element,
                moddleElement: businessObject,
                properties: {
                  inputOutput
                }
              }
            });
          } else {
            commands.push({
              cmd: 'element.updateModdleProperties',
              context: {
                element,
                moddleElement: extensionElements,
                properties: {
                  values: [...extensionElements.get('values'), inputOutput]
                }
              }
            });
          }
        } // camunda:InputParameter


        if (type === CAMUNDA_INPUT_PARAMETER_TYPE$1) {
          const oldCamundaInputParameter = findInputParameter(inputOutput, binding);
          const newCamundaInputParameter = createInputParameter(binding, value, bpmnFactory);
          const values = inputOutput.get('camunda:inputParameters').filter(value => value !== oldCamundaInputParameter);
          commands.push({
            cmd: 'element.updateModdleProperties',
            context: {
              element,
              moddleElement: inputOutput,
              properties: {
                'camunda:inputParameters': [...values, newCamundaInputParameter]
              }
            }
          });
        } // camunda:OutputParameter


        if (type === CAMUNDA_OUTPUT_PARAMETER_TYPE$1) {
          const oldCamundaOutputParameter = findOutputParameter(inputOutput, binding);
          const newCamundaOutputParameter = createOutputParameter(binding, value, bpmnFactory);
          const values = inputOutput.get('camunda:outputParameters').filter(value => value !== oldCamundaOutputParameter);
          commands.push({
            cmd: 'element.updateModdleProperties',
            context: {
              element,
              moddleElement: inputOutput,
              properties: {
                'camunda:outputParameters': [...values, newCamundaOutputParameter]
              }
            }
          });
        }
      } // camunda:In and camunda:Out


      if (IN_OUT_BINDING_TYPES.includes(type)) {
        const oldCamundaInOut = findCamundaInOut(businessObject, binding);
        let newCamundaInOut;

        if (type === CAMUNDA_IN_TYPE) {
          newCamundaInOut = createCamundaIn(binding, value, bpmnFactory);
        } else if (type === CAMUNDA_OUT_TYPE) {
          newCamundaInOut = createCamundaOut(binding, value, bpmnFactory);
        } else {
          newCamundaInOut = createCamundaInWithBusinessKey(value, bpmnFactory);
        }

        const values = extensionElements.get('values').filter(value => value !== oldCamundaInOut);
        commands.push({
          cmd: 'element.updateModdleProperties',
          context: {
            element,
            moddleElement: extensionElements,
            properties: {
              values: [...values, newCamundaInOut]
            }
          }
        });
      }

      if (commands.length) {
        commandStack.execute('properties-panel.multi-command-executor', commands);
        return;
      } // should never throw as templates are validated beforehand


      throw unknownBindingError(element, property);
    };
  }

  function propertyValidator(translate, property) {
    return function validate(value) {
      const {
        constraints = {}
      } = property;
      const {
        maxLength,
        minLength,
        notEmpty
      } = constraints;

      if (notEmpty && isEmptyString(value)) {
        return translate('Must not be empty.');
      }

      if (maxLength && value.length > maxLength) {
        return translate('Must have max length {maxLength}.', {
          maxLength
        });
      }

      if (minLength && value.length < minLength) {
        return translate('Must have min length {minLength}.', {
          minLength
        });
      }

      let {
        pattern
      } = constraints;

      if (pattern) {
        let message;

        if (!isString(pattern)) {
          message = pattern.message;
          pattern = pattern.value;
        }

        if (!matchesPattern(value, pattern)) {
          return message || translate('Must match pattern {pattern}.', {
            pattern
          });
        }
      }
    };
  }

  function getScopeBusinessObject(businessObject, scope) {
    const {
      id,
      type
    } = scope;

    if (type === 'bpmn:Error') {
      // retrieve error through referenced error event definition
      const errorEventDefinition = findCamundaErrorEventDefinition(businessObject, id);

      if (errorEventDefinition) {
        return errorEventDefinition.get('errorRef');
      }
    }

    return findExtension(businessObject, type);
  }

  function unknownBindingError(element, property) {
    const businessObject = getBusinessObject$1(element);
    const id = businessObject.get('id');
    const {
      binding
    } = property;
    const {
      type
    } = binding;
    return new Error(`unknown binding <${type}> for element <${id}>, this should never happen`);
  }

  function isEmptyString(string) {
    return !string || !string.trim().length;
  }

  function matchesPattern(string, pattern) {
    return new RegExp(pattern).test(string);
  }

  function groupByGroupId(properties) {
    return groupBy(properties, 'group');
  }

  function findCustomGroup(groups, id) {
    return find$1(groups, g => g.id === id);
  }

  function ErrorProperties(props) {
    const {
      element,
      index,
      property
    } = props;
    const {
      binding,
      label
    } = property;
    const {
      errorRef
    } = binding;
    const businessObject = getBusinessObject$1(element),
          errorEventDefinitions = findExtensions(businessObject, ['camunda:ErrorEventDefinition']);

    if (!errorEventDefinitions.length) {
      return;
    }

    const errorEventDefinition = findCamundaErrorEventDefinition(element, errorRef);
    const id = `${element.id}-errorEventDefinition-${index}`;
    let entries = [];
    entries = Error$1({
      idPrefix: id,
      element,
      errorEventDefinition
    }); // (1) remove global error referenced entry
    // entries.shift();

    entries = removeEntry$1(entries, '-errorRef'); // (2) remove throw expression input
    // entries.pop();

    entries = removeEntry$1(entries, '-expression'); // (3) add disabled throw expression input

    entries.push({
      id: `${id}-expression`,
      component: Expression,
      errorEventDefinition,
      property
    });
    const item = {
      id,
      label: label || getErrorLabel(errorEventDefinition),
      entries
    };
    return item;
  }

  function Expression(props) {
    const {
      errorEventDefinition,
      id
    } = props;
    const translate = useService('translate');
    const debounce = useService('debounceInput');

    const setValue = () => {};

    const getValue = () => {
      return errorEventDefinition.get('camunda:expression');
    };

    return TextfieldEntry({
      element: errorEventDefinition,
      id,
      label: translate('Throw expression'),
      getValue,
      setValue,
      debounce,
      disabled: true
    });
  }

  function removeEntry$1(entries, suffix) {
    const entry = entries.find(({
      id
    }) => id.endsWith(suffix));
    return without(entries, entry);
  }

  function InputProperties(props) {
    const {
      element,
      index,
      property
    } = props;
    const {
      binding,
      description,
      label
    } = property;
    const {
      name
    } = binding;
    const businessObject = getBusinessObject$1(element),
          inputOutput = findExtension(businessObject, 'camunda:InputOutput');
    const inputParameter = inputOutput && findInputParameter(inputOutput, binding);
    const id = `${element.id}-inputParameter-${index}`;
    let entries = [];

    if (inputParameter) {
      entries = InputOutputParameter({
        idPrefix: id,
        element,
        parameter: inputParameter
      }); // (1) remove name entry

      entries = removeEntry(entries, '-name');
    } // (2) add local variable assignment entry


    entries.unshift({
      id: `${id}-local-variable-assignment`,
      component: LocalVariableAssignment,
      inputParameter,
      property
    }); // (3) add description entry

    if (description) {
      entries.unshift({
        id: `${id}-description`,
        component: Description$1,
        text: description
      });
    } // @barmac: binding#name is required so there is no third option


    const item = {
      id,
      label: label || name,
      entries
    };
    return item;
  } // TODO(philippfromme): add text entry to properties-panel

  function Description$1(props) {
    const {
      id,
      text
    } = props;
    return o$1("div", {
      class: "bio-properties-panel-entry",
      "data-entry-id": id,
      children: o$1("div", {
        class: "bio-properties-panel-description",
        children: o$1(PropertyDescription, {
          description: text
        })
      })
    });
  }

  function LocalVariableAssignment(props) {
    const {
      element,
      id,
      property,
      inputParameter
    } = props;
    const {
      binding
    } = property;
    const bpmnFactory = useService('bpmnFactory'),
          modeling = useService('modeling'),
          translate = useService('translate');

    const getValue = () => {
      return inputParameter;
    };

    const setValue = value => {
      if (value) {
        addInputParameter(element, property, bpmnFactory, modeling);
      } else {
        removeInputParameter(element, binding, modeling);
      }
    };

    return ToggleSwitchEntry({
      id,
      label: translate('Local variable assignment'),
      switcherLabel: inputParameter ? translate('On') : translate('Off'),
      description: inputParameter ? '' : translate('Parameter won\'t be created as local variable.'),
      getValue,
      setValue
    });
  }

  function addInputParameter(element, property, bpmnFactory, modeling) {
    const {
      binding,
      value
    } = property;
    const businessObject = getBusinessObject$1(element);
    const extensionElements = businessObject.get('extensionElements');
    const inputOutput = findExtension(businessObject, 'camunda:InputOutput');
    let updatedBusinessObject, update;

    if (!extensionElements) {
      updatedBusinessObject = businessObject;
      const extensionElements = createExtensionElements$1(businessObject, bpmnFactory),
            inputOutput = createInputOutput$1(binding, value, bpmnFactory, extensionElements);
      extensionElements.values.push(inputOutput);
      update = {
        extensionElements
      };
    } else if (!inputOutput) {
      updatedBusinessObject = extensionElements;
      const inputOutput = createInputOutput$1(binding, value, bpmnFactory, extensionElements);
      update = {
        values: extensionElements.get('values').concat(inputOutput)
      };
    } else {
      updatedBusinessObject = inputOutput;
      const inputParameter = createInputParameter(binding, value, bpmnFactory);
      inputParameter.$parent = inputOutput;
      update = {
        inputParameters: inputOutput.get('camunda:inputParameters').concat(inputParameter)
      };
    }

    modeling.updateModdleProperties(element, updatedBusinessObject, update);
  }

  function removeInputParameter(element, binding, modeling) {
    const businessObject = getBusinessObject$1(element);
    const inputOutput = findExtension(businessObject, 'camunda:InputOutput'),
          inputParameters = inputOutput.get('camunda:inputParameters');
    const inputParameter = findInputParameter(inputOutput, binding);
    modeling.updateModdleProperties(element, inputOutput, {
      inputParameters: without(inputParameters, inputParameter)
    });
  }

  function removeEntry(entries, suffix) {
    const entry = entries.find(({
      id
    }) => id.endsWith(suffix));
    return without(entries, entry);
  }

  function createExtensionElements$1(businessObject, bpmnFactory) {
    return createElement('bpmn:ExtensionElements', {
      values: []
    }, businessObject, bpmnFactory);
  }

  function createInputOutput$1(binding, value, bpmnFactory, extensionElements) {
    const inputParameter = createInputParameter(binding, value, bpmnFactory);
    const inputOutput = createElement('camunda:InputOutput', {
      inputParameters: [inputParameter],
      outputParameters: []
    }, extensionElements, bpmnFactory);
    inputParameter.$parent = inputOutput;
    return inputOutput;
  }

  function OutputProperties(props) {
    const {
      element,
      index,
      injector,
      property
    } = props;
    const {
      binding,
      description,
      label
    } = property;
    const {
      name
    } = binding;
    const businessObject = getBusinessObject$1(element),
          inputOutput = findExtension(businessObject, 'camunda:InputOutput');
    const translate = injector.get('translate');
    const outputParameter = inputOutput && findOutputParameter(inputOutput, binding);
    const id = `${element.id}-outputParameter-${index}`;
    let entries = []; // (1) add description entry

    if (description) {
      entries.push({
        id: `${id}-description`,
        component: Description,
        text: description
      });
    } // (2) add local variable assignment entry


    entries.push({
      id: `${id}-local-variable-assignment`,
      component: ProcessVariableAssignment,
      outputParameter,
      property
    });

    if (outputParameter) {
      // (3) add assign to process variable entry
      entries.push({
        id: `${id}-assign-to-process-variable`,
        component: AssignToProcessVariable,
        property
      });
    }

    const item = {
      id,
      label: label || name || translate('<unnamed>'),
      entries
    };
    return item;
  } // TODO(philippfromme): add text entry to properties-panel

  function Description(props) {
    const {
      id,
      text
    } = props;
    return o$1("div", {
      class: "bio-properties-panel-entry",
      "data-entry-id": id,
      children: o$1("div", {
        class: "bio-properties-panel-description",
        children: o$1(PropertyDescription, {
          description: text
        })
      })
    });
  }

  function ProcessVariableAssignment(props) {
    const {
      element,
      id,
      property,
      outputParameter
    } = props;
    const {
      binding
    } = property;
    const bpmnFactory = useService('bpmnFactory'),
          modeling = useService('modeling'),
          translate = useService('translate');

    const getValue = () => {
      return outputParameter;
    };

    const setValue = value => {
      if (value) {
        addOutputParameter(element, property, bpmnFactory, modeling);
      } else {
        removeOutputParameter(element, binding, modeling);
      }
    };

    return ToggleSwitchEntry({
      id,
      label: translate('Process variable assignment'),
      switcherLabel: outputParameter ? translate('On') : translate('Off'),
      description: outputParameter ? '' : translate('Parameter won\'t be available in process scope.'),
      getValue,
      setValue
    });
  }

  function AssignToProcessVariable(props) {
    const {
      element,
      id,
      property
    } = props;
    const {
      binding
    } = property;
    const inputOutput = findExtension(element, 'camunda:InputOutput'),
          outputParameter = findOutputParameter(inputOutput, binding);
    const commandStack = useService('commandStack'),
          debounce = useService('debounceInput'),
          translate = useService('translate');

    const setValue = value => {
      commandStack.execute('element.updateModdleProperties', {
        element,
        moddleElement: outputParameter,
        properties: {
          name: value
        }
      });
    };

    const getValue = () => {
      return outputParameter.get('camunda:name');
    };

    const validate = value => {
      if (!value) {
        return translate('Process variable name must not be empty.');
      } else if (containsSpace(value)) {
        return translate('Process variable name must not contain spaces.');
      }
    };

    return TextfieldEntry({
      debounce,
      element: outputParameter,
      id,
      label: translate('Assign to process variable'),
      getValue,
      setValue,
      validate
    });
  }

  function addOutputParameter(element, property, bpmnFactory, modeling) {
    const {
      binding,
      value
    } = property;
    const businessObject = getBusinessObject$1(element);
    const extensionElements = businessObject.get('extensionElements');
    const inputOutput = findExtension(businessObject, 'camunda:InputOutput');
    let updatedBusinessObject, update;

    if (!extensionElements) {
      updatedBusinessObject = businessObject;
      const extensionElements = createExtensionElements(businessObject, bpmnFactory),
            inputOutput = createInputOutput(binding, value, bpmnFactory, extensionElements);
      extensionElements.values.push(inputOutput);
      update = {
        extensionElements
      };
    } else if (!inputOutput) {
      updatedBusinessObject = extensionElements;
      const inputOutput = createInputOutput(binding, value, bpmnFactory, extensionElements);
      update = {
        values: extensionElements.get('values').concat(inputOutput)
      };
    } else {
      updatedBusinessObject = inputOutput;
      const outputParameter = createOutputParameter(binding, value, bpmnFactory);
      outputParameter.$parent = inputOutput;
      update = {
        outputParameters: inputOutput.get('camunda:outputParameters').concat(outputParameter)
      };
    }

    modeling.updateModdleProperties(element, updatedBusinessObject, update);
  }

  function removeOutputParameter(element, binding, modeling) {
    const businessObject = getBusinessObject$1(element);
    const inputOutput = findExtension(businessObject, 'camunda:InputOutput'),
          outputParameters = inputOutput.get('camunda:outputParameters');
    const outputParameter = findOutputParameter(inputOutput, binding);
    modeling.updateModdleProperties(element, inputOutput, {
      outputParameters: without(outputParameters, outputParameter)
    });
  }

  function createExtensionElements(businessObject, bpmnFactory) {
    return createElement('bpmn:ExtensionElements', {
      values: []
    }, businessObject, bpmnFactory);
  }

  function createInputOutput(binding, value, bpmnFactory, extensionElements) {
    const outputParameter = createOutputParameter(binding, value, bpmnFactory);
    const inputOutput = createElement('camunda:InputOutput', {
      inputParameters: [],
      outputParameters: [outputParameter]
    }, extensionElements, bpmnFactory);
    outputParameter.$parent = inputOutput;
    return inputOutput;
  }

  const CAMUNDA_ERROR_EVENT_DEFINITION_TYPE = 'camunda:errorEventDefinition',
        CAMUNDA_INPUT_PARAMETER_TYPE = 'camunda:inputParameter',
        CAMUNDA_OUTPUT_PARAMETER_TYPE = 'camunda:outputParameter';
  const LOWER_PRIORITY = 300;
  class ElementTemplatesPropertiesProvider {
    constructor(elementTemplates, propertiesPanel, injector) {
      propertiesPanel.registerProvider(LOWER_PRIORITY, this);
      this._elementTemplates = elementTemplates;
      this._injector = injector;
    }

    getGroups(element) {
      return groups => {
        const injector = this._injector;

        if (!this._shouldShowTemplateProperties(element)) {
          return groups;
        } // (0) Copy provided groups


        groups = groups.slice();
        const templatesGroup = {
          element,
          id: 'ElementTemplates__Template',
          label: 'Template',
          component: createElementTemplatesGroup(),
          entries: TemplateProps({
            element,
            elementTemplates: this._elementTemplates
          })
        }; // (1) Add templates group

        addGroupsAfter('documentation', groups, [templatesGroup]);

        const elementTemplate = this._elementTemplates.get(element);

        if (elementTemplate) {
          const templateSpecificGroups = [].concat(createInputGroup(element, elementTemplate, injector) || [], createOutputGroup(element, elementTemplate, injector) || [], createErrorGroup(element, elementTemplate, injector) || [], CustomProperties({
            element,
            elementTemplate
          })); // (2) add template-specific properties groups

          addGroupsAfter('ElementTemplates__Template', groups, templateSpecificGroups);
        } // (3) apply entries visible


        if (getTemplateId(element)) {
          groups = filterWithEntriesVisible(elementTemplate || {}, groups);
        }

        return groups;
      };
    }

    _shouldShowTemplateProperties(element) {
      return getTemplateId(element) || this._elementTemplates.getAll(element).length;
    }

  }
  ElementTemplatesPropertiesProvider.$inject = ['elementTemplates', 'propertiesPanel', 'injector']; // helper /////////////////////

  function createInputGroup(element, elementTemplate, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Inputs'),
      id: 'ElementTemplates__Input',
      component: ListGroup,
      items: []
    };
    const properties = elementTemplate.properties.filter(({
      binding,
      type
    }) => {
      return !type && binding.type === CAMUNDA_INPUT_PARAMETER_TYPE;
    });
    properties.forEach((property, index) => {
      const item = InputProperties({
        element,
        index,
        property
      });

      if (item) {
        group.items.push(item);
      }
    }); // remove if empty

    if (!group.items.length) {
      return null;
    }

    return group;
  }

  function createOutputGroup(element, elementTemplate, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Outputs'),
      id: 'ElementTemplates__Output',
      component: ListGroup,
      items: []
    };
    const properties = elementTemplate.properties.filter(({
      binding,
      type
    }) => {
      return !type && binding.type === CAMUNDA_OUTPUT_PARAMETER_TYPE;
    });
    properties.forEach((property, index) => {
      const item = OutputProperties({
        element,
        index,
        property,
        injector
      });

      if (item) {
        group.items.push(item);
      }
    }); // remove if empty

    if (!group.items.length) {
      return null;
    }

    return group;
  }

  function createErrorGroup(element, elementTemplate, injector) {
    const translate = injector.get('translate');
    const group = {
      label: translate('Errors'),
      id: 'ElementTemplates__Error',
      component: ListGroup,
      items: []
    };
    const properties = elementTemplate.properties.filter(({
      binding,
      type
    }) => {
      return !type && binding.type === CAMUNDA_ERROR_EVENT_DEFINITION_TYPE;
    });
    properties.forEach((property, index) => {
      const item = ErrorProperties({
        element,
        index,
        property
      });

      if (item) {
        group.items.push(item);
      }
    }); // remove if empty

    if (!group.items.length) {
      return null;
    }

    return group;
  }
  /**
   *
   * @param {string} id
   * @param {Array<{ id: string }} groups
   * @param {Array<{ id: string }>} groupsToAdd
   */


  function addGroupsAfter(id, groups, groupsToAdd) {
    const index = groups.findIndex(group => group.id === id);

    if (index !== -1) {
      groups.splice(index + 1, 0, ...groupsToAdd);
    } else {
      // add in the beginning if group with provided id is missing
      groups.unshift(...groupsToAdd);
    }
  }

  function filterWithEntriesVisible(template, groups) {
    if (!template.entriesVisible) {
      return groups.filter(group => {
        return group.id === 'general' || group.id.startsWith('ElementTemplates__');
      });
    }

    return groups;
  }

  var index = {
    __depends__: [commandsModule, translateModule, camundaPlatformPropertiesProviderModule],
    __init__: ['elementTemplatesLoader', 'replaceBehavior', 'elementTemplatesPropertiesProvider'],
    elementTemplates: ['type', ElementTemplates$1],
    elementTemplatesLoader: ['type', ElementTemplatesLoader$1],
    replaceBehavior: ['type', ReplaceBehavior],
    elementTemplatesPropertiesProvider: ['type', ElementTemplatesPropertiesProvider]
  };

  /* eslint-disable react-hooks/rules-of-hooks */
  const DescriptionProvider = {
    assignmentDefinitionAssignee: element => {
      const translate = useService('translate');
      return o$1("a", {
        href: "https://docs.camunda.io/docs/components/modeler/bpmn/user-tasks/#assignments",
        target: "_blank",
        rel: "noopener",
        title: translate('User task documentation'),
        children: translate('How to configure a user task')
      });
    },
    conditionExpression: element => {
      const translate = useService('translate');
      return o$1("a", {
        href: "https://docs.camunda.io/docs/components/modeler/bpmn/exclusive-gateways/#conditions",
        target: "_blank",
        rel: "noopener",
        title: translate('Conditions documentation'),
        children: translate('How to define conditions')
      });
    },
    decisionId: element => {
      const translate = useService('translate');
      return o$1("a", {
        href: "https://docs.camunda.io/docs/components/modeler/bpmn/business-rule-tasks/#defining-a-task",
        target: "_blank",
        rel: "noopener",
        title: translate('Business rule task documentation'),
        children: translate('How to configure a business rule task')
      });
    },
    formType: element => {
      const translate = useService('translate');
      return o$1("a", {
        href: "https://docs.camunda.io/docs/guides/utilizing-forms/#connect-your-form-to-a-bpmn-diagram",
        target: "_blank",
        rel: "noopener",
        title: translate('User task form documentation'),
        children: translate('How to link a form')
      });
    },
    messageSubscriptionCorrelationKey: element => {
      const translate = useService('translate');

      if (is$4(element, 'bpmn:ReceiveTask')) {
        return o$1("a", {
          href: "https://docs.camunda.io/docs/components/modeler/bpmn/receive-tasks/#messages",
          target: "_blank",
          rel: "noopener",
          title: translate('Receive task documentation'),
          children: translate('How to configure a receive task')
        });
      }

      return o$1("a", {
        href: "https://docs.camunda.io/docs/components/modeler/bpmn/message-events/#messages",
        target: "_blank",
        rel: "noopener",
        title: translate('Message event documentation'),
        children: translate('How to configure a message event')
      });
    },
    messageName: element => {
      const translate = useService('translate');

      if (is$4(element, 'bpmn:StartEvent') && !isInEventSubProcess(element)) {
        return o$1("a", {
          href: "https://docs.camunda.io/docs/components/modeler/bpmn/message-events/#messages",
          target: "_blank",
          rel: "noopener",
          title: translate('Message event documentation'),
          children: translate('How to configure a message event')
        });
      }
    },
    targetProcessId: element => {
      const translate = useService('translate');
      return o$1("a", {
        href: "https://docs.camunda.io/docs/components/modeler/bpmn/call-activities/",
        target: "_blank",
        rel: "noopener",
        title: translate('Call activity documentation'),
        children: translate('How to call another process')
      });
    },
    taskDefinitionType: element => {
      const translate = useService('translate');

      if (is$4(element, 'bpmn:ServiceTask')) {
        return o$1("a", {
          href: "https://docs.camunda.io/docs/components/modeler/bpmn/service-tasks/#task-definition",
          target: "_blank",
          rel: "noopener",
          title: translate('Service task documentation'),
          children: translate('How to configure a service task')
        });
      }

      if (is$4(element, 'bpmn:BusinessRuleTask')) {
        return o$1("a", {
          href: "https://docs.camunda.io/docs/components/modeler/bpmn/business-rule-tasks/#defining-a-task",
          target: "_blank",
          rel: "noopener",
          title: translate('Business rule task documentation'),
          children: translate('How to configure a business rule task')
        });
      }

      if (is$4(element, 'bpmn:ScriptTask')) {
        return o$1("a", {
          href: "https://docs.camunda.io/docs/components/modeler/bpmn/script-tasks/#defining-a-task",
          target: "_blank",
          rel: "noopener",
          title: translate('Script task documentation'),
          children: translate('How to configure a script task')
        });
      }

      if (is$4(element, 'bpmn:SendTask')) {
        return o$1("a", {
          href: "https://docs.camunda.io/docs/components/modeler/bpmn/send-tasks/#defining-a-task",
          target: "_blank",
          rel: "noopener",
          title: translate('Send task documentation'),
          children: translate('How to configure a send task')
        });
      }

      if (is$4(element, 'bpmn:ThrowEvent')) {
        return o$1("a", {
          href: "https://docs.camunda.io/docs/components/modeler/bpmn/message-events/#message-throw-events",
          target: "_blank",
          rel: "noopener",
          title: translate('Message throw event documentation'),
          children: translate('How to configure a message throw event')
        });
      }
    },
    'multiInstance-inputCollection': element => {
      const translate = useService('translate');
      return o$1("a", {
        href: "https://docs.camunda.io/docs/components/modeler/bpmn/multi-instance/#defining-the-collection-to-iterate-over",
        target: "_blank",
        rel: "noopener",
        title: translate('Multi instance documentation'),
        children: translate('How to configure a multi instance activity')
      });
    },
    errorCode: element => {
      const translate = useService('translate');
      return o$1("a", {
        href: "https://docs.camunda.io/docs/components/modeler/bpmn/error-events/#defining-the-error",
        target: "_blank",
        rel: "noopener",
        title: translate('Error event documentation'),
        children: translate('How to configure an error event')
      });
    }
  };

  function isInEventSubProcess(element) {
    const bo = getBusinessObject$1(element),
          parent = bo.$parent;
    return is$4(parent, 'bpmn:SubProcess') && parent.triggeredByEvent;
  }

  exports.BpmnPropertiesPanelModule = index$3;
  exports.BpmnPropertiesProviderModule = index$2;
  exports.CamundaPlatformPropertiesProviderModule = camundaPlatformPropertiesProviderModule;
  exports.CloudElementTemplatesPropertiesProviderModule = index$1;
  exports.CloudElementTemplatesValidator = Validator;
  exports.ElementTemplatesPropertiesProviderModule = index;
  exports.ZeebeDescriptionProvider = DescriptionProvider;
  exports.ZeebePropertiesProviderModule = zeebePropertiesProviderModule;
  exports.useService = useService;

  Object.defineProperty(exports, '__esModule', { value: true });

}));
//# sourceMappingURL=bpmn-js-properties-panel.umd.js.map
