ingenious-flow-designer
Version:
[演示地址](http://antd-vben5-pro.madong.tech/)
1,151 lines (1,147 loc) • 3.16 MB
JavaScript
(function(global2, factory) {
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory(require("vue")) : typeof define === "function" && define.amd ? define(["vue"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, global2.FlowDesigner = factory(global2.e$4));
})(this, function(e$4) {
"use strict";var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
function _interopNamespaceDefault(e2) {
const n2 = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
if (e2) {
for (const k2 in e2) {
if (k2 !== "default") {
const d2 = Object.getOwnPropertyDescriptor(e2, k2);
Object.defineProperty(n2, k2, d2.get ? d2 : {
enumerable: true,
get: () => e2[k2]
});
}
}
}
n2.default = e2;
return Object.freeze(n2);
}
const e__namespace = /* @__PURE__ */ _interopNamespaceDefault(e$4);
var n$3, l$3, u$4, i$4, r$4, o$2, e$3, f$4, c$3, s$3, a$3, p$2 = {}, v$3 = [], y$2 = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, d$2 = Array.isArray;
function w$3(n2, l2) {
for (var u2 in l2) n2[u2] = l2[u2];
return n2;
}
function _$1(n2) {
n2 && n2.parentNode && n2.parentNode.removeChild(n2);
}
function g$4(l2, u2, t2) {
var i2, r2, o2, e2 = {};
for (o2 in u2) "key" == o2 ? i2 = u2[o2] : "ref" == o2 ? r2 = u2[o2] : e2[o2] = u2[o2];
if (arguments.length > 2 && (e2.children = arguments.length > 3 ? n$3.call(arguments, 2) : t2), "function" == typeof l2 && null != l2.defaultProps) for (o2 in l2.defaultProps) void 0 === e2[o2] && (e2[o2] = l2.defaultProps[o2]);
return m$3(l2, e2, i2, r2, null);
}
function m$3(n2, t2, i2, r2, o2) {
var e2 = { type: n2, props: t2, key: i2, ref: r2, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: null == o2 ? ++u$4 : o2, __i: -1, __u: 0 };
return null == o2 && null != l$3.vnode && l$3.vnode(e2), e2;
}
function b$2() {
return { current: null };
}
function k$3(n2) {
return n2.children;
}
function x$1(n2, l2) {
this.props = n2, this.context = l2;
}
function C$2(n2, l2) {
if (null == l2) return n2.__ ? C$2(n2.__, n2.__i + 1) : null;
for (var u2; l2 < n2.__k.length; l2++) if (null != (u2 = n2.__k[l2]) && null != u2.__e) return u2.__e;
return "function" == typeof n2.type ? C$2(n2) : null;
}
function S$2(n2) {
var l2, u2;
if (null != (n2 = n2.__) && null != n2.__c) {
for (n2.__e = n2.__c.base = null, l2 = 0; l2 < n2.__k.length; l2++) if (null != (u2 = n2.__k[l2]) && null != u2.__e) {
n2.__e = n2.__c.base = u2.__e;
break;
}
return S$2(n2);
}
}
function M$1(n2) {
(!n2.__d && (n2.__d = true) && i$4.push(n2) && !P$3.__r++ || r$4 !== l$3.debounceRendering) && ((r$4 = l$3.debounceRendering) || o$2)(P$3);
}
function P$3() {
var n2, u2, t2, r2, o2, f2, c2, s2;
for (i$4.sort(e$3); n2 = i$4.shift(); ) n2.__d && (u2 = i$4.length, r2 = void 0, f2 = (o2 = (t2 = n2).__v).__e, c2 = [], s2 = [], t2.__P && ((r2 = w$3({}, o2)).__v = o2.__v + 1, l$3.vnode && l$3.vnode(r2), j$4(t2.__P, r2, o2, t2.__n, t2.__P.namespaceURI, 32 & o2.__u ? [f2] : null, c2, null == f2 ? C$2(o2) : f2, !!(32 & o2.__u), s2), r2.__v = o2.__v, r2.__.__k[r2.__i] = r2, z$2(c2, r2, s2), r2.__e != f2 && S$2(r2)), i$4.length > u2 && i$4.sort(e$3));
P$3.__r = 0;
}
function $$2(n2, l2, u2, t2, i2, r2, o2, e2, f2, c2, s2) {
var a2, h2, y2, d2, w2, _2, g2 = t2 && t2.__k || v$3, m2 = l2.length;
for (f2 = I$2(u2, l2, g2, f2, m2), a2 = 0; a2 < m2; a2++) null != (y2 = u2.__k[a2]) && (h2 = -1 === y2.__i ? p$2 : g2[y2.__i] || p$2, y2.__i = a2, _2 = j$4(n2, y2, h2, i2, r2, o2, e2, f2, c2, s2), d2 = y2.__e, y2.ref && h2.ref != y2.ref && (h2.ref && V$2(h2.ref, null, y2), s2.push(y2.ref, y2.__c || d2, y2)), null == w2 && null != d2 && (w2 = d2), 4 & y2.__u || h2.__k === y2.__k ? f2 = A$1(y2, f2, n2) : "function" == typeof y2.type && void 0 !== _2 ? f2 = _2 : d2 && (f2 = d2.nextSibling), y2.__u &= -7);
return u2.__e = w2, f2;
}
function I$2(n2, l2, u2, t2, i2) {
var r2, o2, e2, f2, c2, s2 = u2.length, a2 = s2, h2 = 0;
for (n2.__k = new Array(i2), r2 = 0; r2 < i2; r2++) null != (o2 = l2[r2]) && "boolean" != typeof o2 && "function" != typeof o2 ? (f2 = r2 + h2, (o2 = n2.__k[r2] = "string" == typeof o2 || "number" == typeof o2 || "bigint" == typeof o2 || o2.constructor == String ? m$3(null, o2, null, null, null) : d$2(o2) ? m$3(k$3, { children: o2 }, null, null, null) : void 0 === o2.constructor && o2.__b > 0 ? m$3(o2.type, o2.props, o2.key, o2.ref ? o2.ref : null, o2.__v) : o2).__ = n2, o2.__b = n2.__b + 1, e2 = null, -1 !== (c2 = o2.__i = L$1(o2, u2, f2, a2)) && (a2--, (e2 = u2[c2]) && (e2.__u |= 2)), null == e2 || null === e2.__v ? (-1 == c2 && h2--, "function" != typeof o2.type && (o2.__u |= 4)) : c2 != f2 && (c2 == f2 - 1 ? h2-- : c2 == f2 + 1 ? h2++ : (c2 > f2 ? h2-- : h2++, o2.__u |= 4))) : n2.__k[r2] = null;
if (a2) for (r2 = 0; r2 < s2; r2++) null != (e2 = u2[r2]) && 0 == (2 & e2.__u) && (e2.__e == t2 && (t2 = C$2(e2)), q$3(e2, e2));
return t2;
}
function A$1(n2, l2, u2) {
var t2, i2;
if ("function" == typeof n2.type) {
for (t2 = n2.__k, i2 = 0; t2 && i2 < t2.length; i2++) t2[i2] && (t2[i2].__ = n2, l2 = A$1(t2[i2], l2, u2));
return l2;
}
n2.__e != l2 && (l2 && n2.type && !u2.contains(l2) && (l2 = C$2(n2)), u2.insertBefore(n2.__e, l2 || null), l2 = n2.__e);
do {
l2 = l2 && l2.nextSibling;
} while (null != l2 && 8 == l2.nodeType);
return l2;
}
function H$2(n2, l2) {
return l2 = l2 || [], null == n2 || "boolean" == typeof n2 || (d$2(n2) ? n2.some(function(n3) {
H$2(n3, l2);
}) : l2.push(n2)), l2;
}
function L$1(n2, l2, u2, t2) {
var i2, r2, o2 = n2.key, e2 = n2.type, f2 = l2[u2];
if (null === f2 || f2 && o2 == f2.key && e2 === f2.type && 0 == (2 & f2.__u)) return u2;
if (t2 > (null != f2 && 0 == (2 & f2.__u) ? 1 : 0)) for (i2 = u2 - 1, r2 = u2 + 1; i2 >= 0 || r2 < l2.length; ) {
if (i2 >= 0) {
if ((f2 = l2[i2]) && 0 == (2 & f2.__u) && o2 == f2.key && e2 === f2.type) return i2;
i2--;
}
if (r2 < l2.length) {
if ((f2 = l2[r2]) && 0 == (2 & f2.__u) && o2 == f2.key && e2 === f2.type) return r2;
r2++;
}
}
return -1;
}
function T$2(n2, l2, u2) {
"-" == l2[0] ? n2.setProperty(l2, null == u2 ? "" : u2) : n2[l2] = null == u2 ? "" : "number" != typeof u2 || y$2.test(l2) ? u2 : u2 + "px";
}
function F$2(n2, l2, u2, t2, i2) {
var r2;
n: if ("style" == l2) if ("string" == typeof u2) n2.style.cssText = u2;
else {
if ("string" == typeof t2 && (n2.style.cssText = t2 = ""), t2) for (l2 in t2) u2 && l2 in u2 || T$2(n2.style, l2, "");
if (u2) for (l2 in u2) t2 && u2[l2] === t2[l2] || T$2(n2.style, l2, u2[l2]);
}
else if ("o" == l2[0] && "n" == l2[1]) r2 = l2 != (l2 = l2.replace(f$4, "$1")), l2 = l2.toLowerCase() in n2 || "onFocusOut" == l2 || "onFocusIn" == l2 ? l2.toLowerCase().slice(2) : l2.slice(2), n2.l || (n2.l = {}), n2.l[l2 + r2] = u2, u2 ? t2 ? u2.u = t2.u : (u2.u = c$3, n2.addEventListener(l2, r2 ? a$3 : s$3, r2)) : n2.removeEventListener(l2, r2 ? a$3 : s$3, r2);
else {
if ("http://www.w3.org/2000/svg" == i2) l2 = l2.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
else if ("width" != l2 && "height" != l2 && "href" != l2 && "list" != l2 && "form" != l2 && "tabIndex" != l2 && "download" != l2 && "rowSpan" != l2 && "colSpan" != l2 && "role" != l2 && "popover" != l2 && l2 in n2) try {
n2[l2] = null == u2 ? "" : u2;
break n;
} catch (n3) {
}
"function" == typeof u2 || (null == u2 || false === u2 && "-" != l2[4] ? n2.removeAttribute(l2) : n2.setAttribute(l2, "popover" == l2 && 1 == u2 ? "" : u2));
}
}
function O$1(n2) {
return function(u2) {
if (this.l) {
var t2 = this.l[u2.type + n2];
if (null == u2.t) u2.t = c$3++;
else if (u2.t < t2.u) return;
return t2(l$3.event ? l$3.event(u2) : u2);
}
};
}
function j$4(n2, u2, t2, i2, r2, o2, e2, f2, c2, s2) {
var a2, h2, p2, v2, y2, g2, m2, b2, C2, S2, M2, P2, I2, A2, H2, L2, T2, F2 = u2.type;
if (void 0 !== u2.constructor) return null;
128 & t2.__u && (c2 = !!(32 & t2.__u), o2 = [f2 = u2.__e = t2.__e]), (a2 = l$3.__b) && a2(u2);
n: if ("function" == typeof F2) try {
if (b2 = u2.props, C2 = "prototype" in F2 && F2.prototype.render, S2 = (a2 = F2.contextType) && i2[a2.__c], M2 = a2 ? S2 ? S2.props.value : a2.__ : i2, t2.__c ? m2 = (h2 = u2.__c = t2.__c).__ = h2.__E : (C2 ? u2.__c = h2 = new F2(b2, M2) : (u2.__c = h2 = new x$1(b2, M2), h2.constructor = F2, h2.render = B$4), S2 && S2.sub(h2), h2.props = b2, h2.state || (h2.state = {}), h2.context = M2, h2.__n = i2, p2 = h2.__d = true, h2.__h = [], h2._sb = []), C2 && null == h2.__s && (h2.__s = h2.state), C2 && null != F2.getDerivedStateFromProps && (h2.__s == h2.state && (h2.__s = w$3({}, h2.__s)), w$3(h2.__s, F2.getDerivedStateFromProps(b2, h2.__s))), v2 = h2.props, y2 = h2.state, h2.__v = u2, p2) C2 && null == F2.getDerivedStateFromProps && null != h2.componentWillMount && h2.componentWillMount(), C2 && null != h2.componentDidMount && h2.__h.push(h2.componentDidMount);
else {
if (C2 && null == F2.getDerivedStateFromProps && b2 !== v2 && null != h2.componentWillReceiveProps && h2.componentWillReceiveProps(b2, M2), !h2.__e && (null != h2.shouldComponentUpdate && false === h2.shouldComponentUpdate(b2, h2.__s, M2) || u2.__v == t2.__v)) {
for (u2.__v != t2.__v && (h2.props = b2, h2.state = h2.__s, h2.__d = false), u2.__e = t2.__e, u2.__k = t2.__k, u2.__k.some(function(n3) {
n3 && (n3.__ = u2);
}), P2 = 0; P2 < h2._sb.length; P2++) h2.__h.push(h2._sb[P2]);
h2._sb = [], h2.__h.length && e2.push(h2);
break n;
}
null != h2.componentWillUpdate && h2.componentWillUpdate(b2, h2.__s, M2), C2 && null != h2.componentDidUpdate && h2.__h.push(function() {
h2.componentDidUpdate(v2, y2, g2);
});
}
if (h2.context = M2, h2.props = b2, h2.__P = n2, h2.__e = false, I2 = l$3.__r, A2 = 0, C2) {
for (h2.state = h2.__s, h2.__d = false, I2 && I2(u2), a2 = h2.render(h2.props, h2.state, h2.context), H2 = 0; H2 < h2._sb.length; H2++) h2.__h.push(h2._sb[H2]);
h2._sb = [];
} else do {
h2.__d = false, I2 && I2(u2), a2 = h2.render(h2.props, h2.state, h2.context), h2.state = h2.__s;
} while (h2.__d && ++A2 < 25);
h2.state = h2.__s, null != h2.getChildContext && (i2 = w$3(w$3({}, i2), h2.getChildContext())), C2 && !p2 && null != h2.getSnapshotBeforeUpdate && (g2 = h2.getSnapshotBeforeUpdate(v2, y2)), f2 = $$2(n2, d$2(L2 = null != a2 && a2.type === k$3 && null == a2.key ? a2.props.children : a2) ? L2 : [L2], u2, t2, i2, r2, o2, e2, f2, c2, s2), h2.base = u2.__e, u2.__u &= -161, h2.__h.length && e2.push(h2), m2 && (h2.__E = h2.__ = null);
} catch (n3) {
if (u2.__v = null, c2 || null != o2) if (n3.then) {
for (u2.__u |= c2 ? 160 : 128; f2 && 8 == f2.nodeType && f2.nextSibling; ) f2 = f2.nextSibling;
o2[o2.indexOf(f2)] = null, u2.__e = f2;
} else for (T2 = o2.length; T2--; ) _$1(o2[T2]);
else u2.__e = t2.__e, u2.__k = t2.__k;
l$3.__e(n3, u2, t2);
}
else null == o2 && u2.__v == t2.__v ? (u2.__k = t2.__k, u2.__e = t2.__e) : f2 = u2.__e = N$4(t2.__e, u2, t2, i2, r2, o2, e2, c2, s2);
return (a2 = l$3.diffed) && a2(u2), 128 & u2.__u ? void 0 : f2;
}
function z$2(n2, u2, t2) {
for (var i2 = 0; i2 < t2.length; i2++) V$2(t2[i2], t2[++i2], t2[++i2]);
l$3.__c && l$3.__c(u2, n2), n2.some(function(u3) {
try {
n2 = u3.__h, u3.__h = [], n2.some(function(n3) {
n3.call(u3);
});
} catch (n3) {
l$3.__e(n3, u3.__v);
}
});
}
function N$4(u2, t2, i2, r2, o2, e2, f2, c2, s2) {
var a2, h2, v2, y2, w2, g2, m2, b2 = i2.props, k2 = t2.props, x2 = t2.type;
if ("svg" == x2 ? o2 = "http://www.w3.org/2000/svg" : "math" == x2 ? o2 = "http://www.w3.org/1998/Math/MathML" : o2 || (o2 = "http://www.w3.org/1999/xhtml"), null != e2) {
for (a2 = 0; a2 < e2.length; a2++) if ((w2 = e2[a2]) && "setAttribute" in w2 == !!x2 && (x2 ? w2.localName == x2 : 3 == w2.nodeType)) {
u2 = w2, e2[a2] = null;
break;
}
}
if (null == u2) {
if (null == x2) return document.createTextNode(k2);
u2 = document.createElementNS(o2, x2, k2.is && k2), c2 && (l$3.__m && l$3.__m(t2, e2), c2 = false), e2 = null;
}
if (null === x2) b2 === k2 || c2 && u2.data === k2 || (u2.data = k2);
else {
if (e2 = e2 && n$3.call(u2.childNodes), b2 = i2.props || p$2, !c2 && null != e2) for (b2 = {}, a2 = 0; a2 < u2.attributes.length; a2++) b2[(w2 = u2.attributes[a2]).name] = w2.value;
for (a2 in b2) if (w2 = b2[a2], "children" == a2) ;
else if ("dangerouslySetInnerHTML" == a2) v2 = w2;
else if (!(a2 in k2)) {
if ("value" == a2 && "defaultValue" in k2 || "checked" == a2 && "defaultChecked" in k2) continue;
F$2(u2, a2, null, w2, o2);
}
for (a2 in k2) w2 = k2[a2], "children" == a2 ? y2 = w2 : "dangerouslySetInnerHTML" == a2 ? h2 = w2 : "value" == a2 ? g2 = w2 : "checked" == a2 ? m2 = w2 : c2 && "function" != typeof w2 || b2[a2] === w2 || F$2(u2, a2, w2, b2[a2], o2);
if (h2) c2 || v2 && (h2.__html === v2.__html || h2.__html === u2.innerHTML) || (u2.innerHTML = h2.__html), t2.__k = [];
else if (v2 && (u2.innerHTML = ""), $$2(u2, d$2(y2) ? y2 : [y2], t2, i2, r2, "foreignObject" == x2 ? "http://www.w3.org/1999/xhtml" : o2, e2, f2, e2 ? e2[0] : i2.__k && C$2(i2, 0), c2, s2), null != e2) for (a2 = e2.length; a2--; ) _$1(e2[a2]);
c2 || (a2 = "value", "progress" == x2 && null == g2 ? u2.removeAttribute("value") : void 0 !== g2 && (g2 !== u2[a2] || "progress" == x2 && !g2 || "option" == x2 && g2 !== b2[a2]) && F$2(u2, a2, g2, b2[a2], o2), a2 = "checked", void 0 !== m2 && m2 !== u2[a2] && F$2(u2, a2, m2, b2[a2], o2));
}
return u2;
}
function V$2(n2, u2, t2) {
try {
if ("function" == typeof n2) {
var i2 = "function" == typeof n2.__u;
i2 && n2.__u(), i2 && null == u2 || (n2.__u = n2(u2));
} else n2.current = u2;
} catch (n3) {
l$3.__e(n3, t2);
}
}
function q$3(n2, u2, t2) {
var i2, r2;
if (l$3.unmount && l$3.unmount(n2), (i2 = n2.ref) && (i2.current && i2.current !== n2.__e || V$2(i2, null, u2)), null != (i2 = n2.__c)) {
if (i2.componentWillUnmount) try {
i2.componentWillUnmount();
} catch (n3) {
l$3.__e(n3, u2);
}
i2.base = i2.__P = null;
}
if (i2 = n2.__k) for (r2 = 0; r2 < i2.length; r2++) i2[r2] && q$3(i2[r2], u2, t2 || "function" != typeof n2.type);
t2 || _$1(n2.__e), n2.__c = n2.__ = n2.__e = void 0;
}
function B$4(n2, l2, u2) {
return this.constructor(n2, u2);
}
function D$1(u2, t2, i2) {
var r2, o2, e2, f2;
t2 == document && (t2 = document.documentElement), l$3.__ && l$3.__(u2, t2), o2 = (r2 = "function" == typeof i2) ? null : t2.__k, e2 = [], f2 = [], j$4(t2, u2 = (!r2 && i2 || t2).__k = g$4(k$3, null, [u2]), o2 || p$2, p$2, t2.namespaceURI, !r2 && i2 ? [i2] : o2 ? null : t2.firstChild ? n$3.call(t2.childNodes) : null, e2, !r2 && i2 ? i2 : o2 ? o2.__e : t2.firstChild, r2, f2), z$2(e2, u2, f2);
}
n$3 = v$3.slice, l$3 = { __e: function(n2, l2, u2, t2) {
for (var i2, r2, o2; l2 = l2.__; ) if ((i2 = l2.__c) && !i2.__) try {
if ((r2 = i2.constructor) && null != r2.getDerivedStateFromError && (i2.setState(r2.getDerivedStateFromError(n2)), o2 = i2.__d), null != i2.componentDidCatch && (i2.componentDidCatch(n2, t2 || {}), o2 = i2.__d), o2) return i2.__E = i2;
} catch (l3) {
n2 = l3;
}
throw n2;
} }, u$4 = 0, x$1.prototype.setState = function(n2, l2) {
var u2;
u2 = null != this.__s && this.__s !== this.state ? this.__s : this.__s = w$3({}, this.state), "function" == typeof n2 && (n2 = n2(w$3({}, u2), this.props)), n2 && w$3(u2, n2), null != n2 && this.__v && (l2 && this._sb.push(l2), M$1(this));
}, x$1.prototype.forceUpdate = function(n2) {
this.__v && (this.__e = true, n2 && this.__h.push(n2), M$1(this));
}, x$1.prototype.render = k$3, i$4 = [], o$2 = "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, e$3 = function(n2, l2) {
return n2.__v.__b - l2.__v.__b;
}, P$3.__r = 0, f$4 = /(PointerCapture)$|Capture$/i, c$3 = 0, s$3 = O$1(false), a$3 = O$1(true);
var OBFUSCATED_ERROR = "An invariant failed, however the error is obfuscated because this is a production build.";
var EMPTY_ARRAY = [];
Object.freeze(EMPTY_ARRAY);
var EMPTY_OBJECT = {};
Object.freeze(EMPTY_OBJECT);
function getNextId() {
return ++globalState.mobxGuid;
}
function fail(message2) {
invariant$1(false, message2);
throw "X";
}
function invariant$1(check, message2) {
if (!check)
throw new Error("[mobx] " + (message2 || OBFUSCATED_ERROR));
}
var deprecatedMessages = [];
function deprecated(msg, thing) {
if (process.env.NODE_ENV === "production")
return false;
if (deprecatedMessages.indexOf(msg) !== -1)
return false;
deprecatedMessages.push(msg);
console.error("[mobx] Deprecated: " + msg);
return true;
}
function once$1(func2) {
var invoked = false;
return function() {
if (invoked)
return;
invoked = true;
return func2.apply(this, arguments);
};
}
var noop$6 = function() {
};
function unique(list) {
var res = [];
list.forEach(function(item) {
if (res.indexOf(item) === -1)
res.push(item);
});
return res;
}
function isObject$4(value) {
return value !== null && typeof value === "object";
}
function isPlainObject$2(value) {
if (value === null || typeof value !== "object")
return false;
var proto = Object.getPrototypeOf(value);
return proto === Object.prototype || proto === null;
}
function convertToMap(dataStructure) {
if (isES6Map(dataStructure) || isObservableMap(dataStructure)) {
return dataStructure;
} else if (Array.isArray(dataStructure)) {
return new Map(dataStructure);
} else if (isPlainObject$2(dataStructure)) {
var map2 = /* @__PURE__ */ new Map();
for (var key2 in dataStructure) {
map2.set(key2, dataStructure[key2]);
}
return map2;
} else {
return fail("Cannot convert to map from '" + dataStructure + "'");
}
}
function addHiddenProp(object2, propName, value) {
Object.defineProperty(object2, propName, {
enumerable: false,
writable: true,
configurable: true,
value
});
}
function addHiddenFinalProp(object2, propName, value) {
Object.defineProperty(object2, propName, {
enumerable: false,
writable: false,
configurable: true,
value
});
}
function isPropertyConfigurable(object2, prop) {
var descriptor = Object.getOwnPropertyDescriptor(object2, prop);
return !descriptor || descriptor.configurable !== false && descriptor.writable !== false;
}
function assertPropertyConfigurable(object2, prop) {
if (process.env.NODE_ENV !== "production" && !isPropertyConfigurable(object2, prop))
fail("Cannot make property '" + prop.toString() + "' observable, it is not configurable and writable in the target object");
}
function createInstanceofPredicate(name, clazz) {
var propName = "isMobX" + name;
clazz.prototype[propName] = true;
return function(x2) {
return isObject$4(x2) && x2[propName] === true;
};
}
function isES6Map(thing) {
return thing instanceof Map;
}
function isES6Set(thing) {
return thing instanceof Set;
}
function getPlainObjectKeys(object2) {
var enumerables = /* @__PURE__ */ new Set();
for (var key2 in object2)
enumerables.add(key2);
Object.getOwnPropertySymbols(object2).forEach(function(k2) {
if (Object.getOwnPropertyDescriptor(object2, k2).enumerable)
enumerables.add(k2);
});
return Array.from(enumerables);
}
function stringifyKey(key2) {
if (key2 && key2.toString)
return key2.toString();
else
return new String(key2).toString();
}
function toPrimitive$1(value) {
return value === null ? null : typeof value === "object" ? "" + value : value;
}
var ownKeys$2 = typeof Reflect !== "undefined" && Reflect.ownKeys ? Reflect.ownKeys : Object.getOwnPropertySymbols ? function(obj) {
return Object.getOwnPropertyNames(obj).concat(Object.getOwnPropertySymbols(obj));
} : (
/* istanbul ignore next */
Object.getOwnPropertyNames
);
var $mobx = Symbol("mobx administration");
var Atom = (
/** @class */
function() {
function Atom2(name) {
if (name === void 0) {
name = "Atom@" + getNextId();
}
this.name = name;
this.isPendingUnobservation = false;
this.isBeingObserved = false;
this.observers = /* @__PURE__ */ new Set();
this.diffValue = 0;
this.lastAccessedBy = 0;
this.lowestObserverState = IDerivationState.NOT_TRACKING;
}
Atom2.prototype.onBecomeObserved = function() {
if (this.onBecomeObservedListeners) {
this.onBecomeObservedListeners.forEach(function(listener) {
return listener();
});
}
};
Atom2.prototype.onBecomeUnobserved = function() {
if (this.onBecomeUnobservedListeners) {
this.onBecomeUnobservedListeners.forEach(function(listener) {
return listener();
});
}
};
Atom2.prototype.reportObserved = function() {
return reportObserved(this);
};
Atom2.prototype.reportChanged = function() {
startBatch();
propagateChanged(this);
endBatch();
};
Atom2.prototype.toString = function() {
return this.name;
};
return Atom2;
}()
);
var isAtom = createInstanceofPredicate("Atom", Atom);
function createAtom(name, onBecomeObservedHandler, onBecomeUnobservedHandler) {
if (onBecomeObservedHandler === void 0) {
onBecomeObservedHandler = noop$6;
}
if (onBecomeUnobservedHandler === void 0) {
onBecomeUnobservedHandler = noop$6;
}
var atom = new Atom(name);
if (onBecomeObservedHandler !== noop$6) {
onBecomeObserved(atom, onBecomeObservedHandler);
}
if (onBecomeUnobservedHandler !== noop$6) {
onBecomeUnobserved(atom, onBecomeUnobservedHandler);
}
return atom;
}
function identityComparer(a2, b2) {
return a2 === b2;
}
function structuralComparer(a2, b2) {
return deepEqual(a2, b2);
}
function shallowComparer(a2, b2) {
return deepEqual(a2, b2, 1);
}
function defaultComparer(a2, b2) {
return Object.is(a2, b2);
}
var comparer = {
identity: identityComparer,
structural: structuralComparer,
default: defaultComparer,
shallow: shallowComparer
};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var extendStatics = function(d2, b2) {
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d3, b3) {
d3.__proto__ = b3;
} || function(d3, b3) {
for (var p2 in b3) if (b3.hasOwnProperty(p2)) d3[p2] = b3[p2];
};
return extendStatics(d2, b2);
};
function __extends$12(d2, b2) {
extendStatics(d2, b2);
function __() {
this.constructor = d2;
}
d2.prototype = b2 === null ? Object.create(b2) : (__.prototype = b2.prototype, new __());
}
var __assign$1k = function() {
__assign$1k = Object.assign || function __assign2(t2) {
for (var s2, i2 = 1, n2 = arguments.length; i2 < n2; i2++) {
s2 = arguments[i2];
for (var p2 in s2) if (Object.prototype.hasOwnProperty.call(s2, p2)) t2[p2] = s2[p2];
}
return t2;
};
return __assign$1k.apply(this, arguments);
};
function __values$3(o2) {
var m2 = typeof Symbol === "function" && o2[Symbol.iterator], i2 = 0;
if (m2) return m2.call(o2);
return {
next: function() {
if (o2 && i2 >= o2.length) o2 = void 0;
return { value: o2 && o2[i2++], done: !o2 };
}
};
}
function __read$M(o2, n2) {
var m2 = typeof Symbol === "function" && o2[Symbol.iterator];
if (!m2) return o2;
var i2 = m2.call(o2), r2, ar = [], e2;
try {
while ((n2 === void 0 || n2-- > 0) && !(r2 = i2.next()).done) ar.push(r2.value);
} catch (error) {
e2 = { error };
} finally {
try {
if (r2 && !r2.done && (m2 = i2["return"])) m2.call(i2);
} finally {
if (e2) throw e2.error;
}
}
return ar;
}
function __spread() {
for (var ar = [], i2 = 0; i2 < arguments.length; i2++)
ar = ar.concat(__read$M(arguments[i2]));
return ar;
}
var mobxDidRunLazyInitializersSymbol = Symbol("mobx did run lazy initializers");
var mobxPendingDecorators = Symbol("mobx pending decorators");
var enumerableDescriptorCache = {};
var nonEnumerableDescriptorCache = {};
function createPropertyInitializerDescriptor(prop, enumerable2) {
var cache2 = enumerable2 ? enumerableDescriptorCache : nonEnumerableDescriptorCache;
return cache2[prop] || (cache2[prop] = {
configurable: true,
enumerable: enumerable2,
get: function() {
initializeInstance(this);
return this[prop];
},
set: function(value) {
initializeInstance(this);
this[prop] = value;
}
});
}
function initializeInstance(target) {
var e_1, _a2;
if (target[mobxDidRunLazyInitializersSymbol] === true)
return;
var decorators = target[mobxPendingDecorators];
if (decorators) {
addHiddenProp(target, mobxDidRunLazyInitializersSymbol, true);
var keys2 = __spread(Object.getOwnPropertySymbols(decorators), Object.keys(decorators));
try {
for (var keys_1 = __values$3(keys2), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
var key2 = keys_1_1.value;
var d2 = decorators[key2];
d2.propertyCreator(target, d2.prop, d2.descriptor, d2.decoratorTarget, d2.decoratorArguments);
}
} catch (e_1_1) {
e_1 = { error: e_1_1 };
} finally {
try {
if (keys_1_1 && !keys_1_1.done && (_a2 = keys_1.return)) _a2.call(keys_1);
} finally {
if (e_1) throw e_1.error;
}
}
}
}
function createPropDecorator(propertyInitiallyEnumerable, propertyCreator) {
return function decoratorFactory() {
var decoratorArguments;
var decorator = function decorate(target, prop, descriptor, applyImmediately) {
if (applyImmediately === true) {
propertyCreator(target, prop, descriptor, target, decoratorArguments);
return null;
}
if (process.env.NODE_ENV !== "production" && !quacksLikeADecorator(arguments))
fail("This function is a decorator, but it wasn't invoked like a decorator");
if (!Object.prototype.hasOwnProperty.call(target, mobxPendingDecorators)) {
var inheritedDecorators = target[mobxPendingDecorators];
addHiddenProp(target, mobxPendingDecorators, __assign$1k({}, inheritedDecorators));
}
target[mobxPendingDecorators][prop] = {
prop,
propertyCreator,
descriptor,
decoratorTarget: target,
decoratorArguments
};
return createPropertyInitializerDescriptor(prop, propertyInitiallyEnumerable);
};
if (quacksLikeADecorator(arguments)) {
decoratorArguments = EMPTY_ARRAY;
return decorator.apply(null, arguments);
} else {
decoratorArguments = Array.prototype.slice.call(arguments);
return decorator;
}
};
}
function quacksLikeADecorator(args) {
return (args.length === 2 || args.length === 3) && (typeof args[1] === "string" || typeof args[1] === "symbol") || args.length === 4 && args[3] === true;
}
function deepEnhancer(v2, _2, name) {
if (isObservable(v2))
return v2;
if (Array.isArray(v2))
return observable.array(v2, { name });
if (isPlainObject$2(v2))
return observable.object(v2, void 0, { name });
if (isES6Map(v2))
return observable.map(v2, { name });
if (isES6Set(v2))
return observable.set(v2, { name });
return v2;
}
function shallowEnhancer(v2, _2, name) {
if (v2 === void 0 || v2 === null)
return v2;
if (isObservableObject(v2) || isObservableArray(v2) || isObservableMap(v2) || isObservableSet(v2))
return v2;
if (Array.isArray(v2))
return observable.array(v2, { name, deep: false });
if (isPlainObject$2(v2))
return observable.object(v2, void 0, { name, deep: false });
if (isES6Map(v2))
return observable.map(v2, { name, deep: false });
if (isES6Set(v2))
return observable.set(v2, { name, deep: false });
return fail(process.env.NODE_ENV !== "production" && "The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets");
}
function referenceEnhancer(newValue) {
return newValue;
}
function refStructEnhancer(v2, oldValue, name) {
if (process.env.NODE_ENV !== "production" && isObservable(v2))
throw "observable.struct should not be used with observable values";
if (deepEqual(v2, oldValue))
return oldValue;
return v2;
}
function createDecoratorForEnhancer(enhancer) {
invariant$1(enhancer);
var decorator = createPropDecorator(true, function(target, propertyName, descriptor, _decoratorTarget, decoratorArgs) {
if (process.env.NODE_ENV !== "production") {
invariant$1(!descriptor || !descriptor.get, '@observable cannot be used on getter (property "' + stringifyKey(propertyName) + '"), use @computed instead.');
}
var initialValue = descriptor ? descriptor.initializer ? descriptor.initializer.call(target) : descriptor.value : void 0;
asObservableObject(target).addObservableProp(propertyName, initialValue, enhancer);
});
var res = (
// Extra process checks, as this happens during module initialization
typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" ? function observableDecorator() {
if (arguments.length < 2)
return fail("Incorrect decorator invocation. @observable decorator doesn't expect any arguments");
return decorator.apply(null, arguments);
} : decorator
);
res.enhancer = enhancer;
return res;
}
var defaultCreateObservableOptions = {
deep: true,
name: void 0,
defaultDecorator: void 0,
proxy: true
};
Object.freeze(defaultCreateObservableOptions);
function assertValidOption(key2) {
if (!/^(deep|name|equals|defaultDecorator|proxy)$/.test(key2))
fail("invalid option for (extend)observable: " + key2);
}
function asCreateObservableOptions(thing) {
if (thing === null || thing === void 0)
return defaultCreateObservableOptions;
if (typeof thing === "string")
return { name: thing, deep: true, proxy: true };
if (process.env.NODE_ENV !== "production") {
if (typeof thing !== "object")
return fail("expected options object");
Object.keys(thing).forEach(assertValidOption);
}
return thing;
}
var deepDecorator = createDecoratorForEnhancer(deepEnhancer);
var shallowDecorator = createDecoratorForEnhancer(shallowEnhancer);
var refDecorator = createDecoratorForEnhancer(referenceEnhancer);
var refStructDecorator = createDecoratorForEnhancer(refStructEnhancer);
function getEnhancerFromOptions(options) {
return options.defaultDecorator ? options.defaultDecorator.enhancer : options.deep === false ? referenceEnhancer : deepEnhancer;
}
function createObservable(v2, arg2, arg3) {
if (typeof arguments[1] === "string" || typeof arguments[1] === "symbol") {
return deepDecorator.apply(null, arguments);
}
if (isObservable(v2))
return v2;
var res = isPlainObject$2(v2) ? observable.object(v2, arg2, arg3) : Array.isArray(v2) ? observable.array(v2, arg2) : isES6Map(v2) ? observable.map(v2, arg2) : isES6Set(v2) ? observable.set(v2, arg2) : v2;
if (res !== v2)
return res;
fail(process.env.NODE_ENV !== "production" && "The provided value could not be converted into an observable. If you want just create an observable reference to the object use 'observable.box(value)'");
}
var observableFactories = {
box: function(value, options) {
if (arguments.length > 2)
incorrectlyUsedAsDecorator("box");
var o2 = asCreateObservableOptions(options);
return new ObservableValue(value, getEnhancerFromOptions(o2), o2.name, true, o2.equals);
},
array: function(initialValues, options) {
if (arguments.length > 2)
incorrectlyUsedAsDecorator("array");
var o2 = asCreateObservableOptions(options);
return createObservableArray(initialValues, getEnhancerFromOptions(o2), o2.name);
},
map: function(initialValues, options) {
if (arguments.length > 2)
incorrectlyUsedAsDecorator("map");
var o2 = asCreateObservableOptions(options);
return new ObservableMap(initialValues, getEnhancerFromOptions(o2), o2.name);
},
set: function(initialValues, options) {
if (arguments.length > 2)
incorrectlyUsedAsDecorator("set");
var o2 = asCreateObservableOptions(options);
return new ObservableSet(initialValues, getEnhancerFromOptions(o2), o2.name);
},
object: function(props2, decorators, options) {
if (typeof arguments[1] === "string")
incorrectlyUsedAsDecorator("object");
var o2 = asCreateObservableOptions(options);
if (o2.proxy === false) {
return extendObservable({}, props2, decorators, o2);
} else {
var defaultDecorator = getDefaultDecoratorFromObjectOptions(o2);
var base = extendObservable({}, void 0, void 0, o2);
var proxy = createDynamicObservableObject(base);
extendObservableObjectWithProperties(proxy, props2, decorators, defaultDecorator);
return proxy;
}
},
ref: refDecorator,
shallow: shallowDecorator,
deep: deepDecorator,
struct: refStructDecorator
};
var observable = createObservable;
Object.keys(observableFactories).forEach(function(name) {
return observable[name] = observableFactories[name];
});
function incorrectlyUsedAsDecorator(methodName) {
fail(
// process.env.NODE_ENV !== "production" &&
"Expected one or two arguments to observable." + methodName + ". Did you accidentally try to use observable." + methodName + " as decorator?"
);
}
var computedDecorator = createPropDecorator(false, function(instance, propertyName, descriptor, decoratorTarget, decoratorArgs) {
if (process.env.NODE_ENV !== "production") {
invariant$1(descriptor && descriptor.get, "Trying to declare a computed value for unspecified getter '" + stringifyKey(propertyName) + "'");
}
var get2 = descriptor.get, set2 = descriptor.set;
var options = decoratorArgs[0] || {};
asObservableObject(instance).addComputedProp(instance, propertyName, __assign$1k({
get: get2,
set: set2,
context: instance
}, options));
});
var computedStructDecorator = computedDecorator({ equals: comparer.structural });
var computed = function computed2(arg1, arg2, arg3) {
if (typeof arg2 === "string") {
return computedDecorator.apply(null, arguments);
}
if (arg1 !== null && typeof arg1 === "object" && arguments.length === 1) {
return computedDecorator.apply(null, arguments);
}
if (process.env.NODE_ENV !== "production") {
invariant$1(typeof arg1 === "function", "First argument to `computed` should be an expression.");
invariant$1(arguments.length < 3, "Computed takes one or two arguments if used as function");
}
var opts = typeof arg2 === "object" ? arg2 : {};
opts.get = arg1;
opts.set = typeof arg2 === "function" ? arg2 : opts.set;
opts.name = opts.name || arg1.name || "";
return new ComputedValue(opts);
};
computed.struct = computedStructDecorator;
var IDerivationState;
(function(IDerivationState2) {
IDerivationState2[IDerivationState2["NOT_TRACKING"] = -1] = "NOT_TRACKING";
IDerivationState2[IDerivationState2["UP_TO_DATE"] = 0] = "UP_TO_DATE";
IDerivationState2[IDerivationState2["POSSIBLY_STALE"] = 1] = "POSSIBLY_STALE";
IDerivationState2[IDerivationState2["STALE"] = 2] = "STALE";
})(IDerivationState || (IDerivationState = {}));
var TraceMode;
(function(TraceMode2) {
TraceMode2[TraceMode2["NONE"] = 0] = "NONE";
TraceMode2[TraceMode2["LOG"] = 1] = "LOG";
TraceMode2[TraceMode2["BREAK"] = 2] = "BREAK";
})(TraceMode || (TraceMode = {}));
var CaughtException = (
/** @class */
/* @__PURE__ */ function() {
function CaughtException2(cause) {
this.cause = cause;
}
return CaughtException2;
}()
);
function isCaughtException(e2) {
return e2 instanceof CaughtException;
}
function shouldCompute(derivation) {
switch (derivation.dependenciesState) {
case IDerivationState.UP_TO_DATE:
return false;
case IDerivationState.NOT_TRACKING:
case IDerivationState.STALE:
return true;
case IDerivationState.POSSIBLY_STALE: {
var prevAllowStateReads = allowStateReadsStart(true);
var prevUntracked = untrackedStart();
var obs = derivation.observing, l2 = obs.length;
for (var i2 = 0; i2 < l2; i2++) {
var obj = obs[i2];
if (isComputedValue(obj)) {
if (globalState.disableErrorBoundaries) {
obj.get();
} else {
try {
obj.get();
} catch (e2) {
untrackedEnd(prevUntracked);
allowStateReadsEnd(prevAllowStateReads);
return true;
}
}
if (derivation.dependenciesState === IDerivationState.STALE) {
untrackedEnd(prevUntracked);
allowStateReadsEnd(prevAllowStateReads);
return true;
}
}
}
changeDependenciesStateTo0(derivation);
untrackedEnd(prevUntracked);
allowStateReadsEnd(prevAllowStateReads);
return false;
}
}
}
function checkIfStateModificationsAreAllowed(atom) {
var hasObservers = atom.observers.size > 0;
if (globalState.computationDepth > 0 && hasObservers)
fail(process.env.NODE_ENV !== "production" && "Computed values are not allowed to cause side effects by changing observables that are already being observed. Tried to modify: " + atom.name);
if (!globalState.allowStateChanges && (hasObservers || globalState.enforceActions === "strict"))
fail(process.env.NODE_ENV !== "production" && (globalState.enforceActions ? "Since strict-mode is enabled, changing observed observable values outside actions is not allowed. Please wrap the code in an `action` if this change is intended. Tried to modify: " : "Side effects like changing state are not allowed at this point. Are you trying to modify state from, for example, the render function of a React component? Tried to modify: ") + atom.name);
}
function checkIfStateReadsAreAllowed(observable2) {
if (process.env.NODE_ENV !== "production" && !globalState.allowStateReads && globalState.observableRequiresReaction) {
console.warn("[mobx] Observable " + observable2.name + " being read outside a reactive context");
}
}
function trackDerivedFunction(derivation, f2, context) {
var prevAllowStateReads = allowStateReadsStart(true);
changeDependenciesStateTo0(derivation);
derivation.newObserving = new Array(derivation.observing.length + 100);
derivation.unboundDepsCount = 0;
derivation.runId = ++globalState.runId;
var prevTracking = globalState.trackingDerivation;
globalState.trackingDerivation = derivation;
var result2;
if (globalState.disableErrorBoundaries === true) {
result2 = f2.call(context);
} else {
try {
result2 = f2.call(context);
} catch (e2) {
result2 = new CaughtException(e2);
}
}
globalState.trackingDerivation = prevTracking;
bindDependencies(derivation);
warnAboutDerivationWithoutDependencies(derivation);
allowStateReadsEnd(prevAllowStateReads);
return result2;
}
function warnAboutDerivationWithoutDependencies(derivation) {
if (process.env.NODE_ENV === "production")
return;
if (derivation.observing.length !== 0)
return;
if (globalState.reactionRequiresObservable || derivation.requiresObservable) {
console.warn("[mobx] Derivation " + derivation.name + " is created/updated without reading any observable value");
}
}
function bindDependencies(derivation) {
var prevObserving = derivation.observing;
var observing = derivation.observing = derivation.newObserving;
var lowestNewObservingDerivationState = IDerivationState.UP_TO_DATE;
var i0 = 0, l2 = derivation.unboundDepsCount;
for (var i2 = 0; i2 < l2; i2++) {
var dep = observing[i2];
if (dep.diffValue === 0) {
dep.diffValue = 1;
if (i0 !== i2)
observing[i0] = dep;
i0++;
}
if (dep.dependenciesState > lowestNewObservingDerivationState) {
lowestNewObservingDerivationState = dep.dependenciesState;
}
}
observing.length = i0;
derivation.newObserving = null;
l2 = prevObserving.length;
while (l2--) {
var dep = prevObserving[l2];
if (dep.diffValue === 0) {
removeObserver(dep, derivation);
}
dep.diffValue = 0;
}
while (i0--) {
var dep = observing[i0];
if (dep.diffValue === 1) {
dep.diffValue = 0;
addObserver(dep, derivation);
}
}
if (lowestNewObservingDerivationState !== IDerivationState.UP_TO_DATE) {
derivation.dependenciesState = lowestNewObservingDerivationState;
derivation.onBecomeStale();
}
}
function clearObserving(derivation) {
var obs = derivation.observing;
derivation.observing = [];
var i2 = obs.length;
while (i2--)
removeObserver(obs[i2], derivation);
derivation.dependenciesState = IDerivationState.NOT_TRACKING;
}
function untracked(action2) {
var prev2 = untrackedStart();
try {
return action2();
} finally {
untrackedEnd(prev2);
}
}
function untrackedStart() {
var prev2 = globalState.trackingDerivation;
globalState.trackingDerivation = null;
return prev2;
}
function untrackedEnd(prev2) {
globalState.trackingDerivation = prev2;
}
function allowStateReadsStart(allowStateReads) {
var prev2 = globalState.allowStateReads;
globalState.allowStateReads = allowStateReads;
return prev2;
}
function allowStateReadsEnd(prev2) {
globalState.allowStateReads = prev2;
}
function changeDependenciesStateTo0(derivation) {
if (derivation.dependenciesState === IDerivationState.UP_TO_DATE)
return;
derivation.dependenciesState = IDerivationState.UP_TO_DATE;
var obs = derivation.observing;
var i2 = obs.length;
while (i2--)
obs[i2].lowestObserverState = IDerivationState.UP_TO_DATE;
}
var currentActionId = 0;
var nextActionId = 1;
var functionNameDescriptor = Object.getOwnPropertyDescriptor(function() {
}, "name");
var isFunctionNameConfigurable = functionNameDescriptor && functionNameDescriptor.configurable;
function createAction(actionName, fn2, ref) {
if (process.env.NODE_ENV !== "production") {
invariant$1(typeof fn2 === "function", "`action` can only be invoked on functions");
if (typeof actionName !== "string" || !actionName)
fail("actions should have valid names, got: '" + actionName + "'");
}
var res = function() {
return executeAction(actionName, fn2, ref || this, arguments);
};
res.isMobxAction = true;
if (process.env.NODE_ENV !== "production") {
if (isFunctionNameConfigurable) {
Object.defineProperty(res, "name", { value: actionName });
}
}
return res;
}
function executeAction(actionName, fn2, scope, args) {
var runInfo = _startAction(actionName, scope, args);
try {
return fn2.apply(scope, args);
} catch (err) {
runInfo.error = err;
throw err;
} finally {
_endAction(runInfo);
}
}
function _startAction(actionName, scope, args) {
var notifySpy = isSpyEnabled() && !!actionName;
var startTime = 0;
if (notifySpy && process.env.NODE_ENV !== "production") {
startTime = Date.now();
var l2 = args && args.length || 0;
var flattendArgs = new Array(l2);
if (l2 > 0)
for (var i2 = 0; i2 < l2; i2++)
flattendArgs[i2] = args[i2];
spyReportStart({
type: "action",
name: actionName,
object: scope,
arguments: flattendArgs
});
}
var prevDerivation = untrackedStart();
startBatch();
var prevAllowStateChanges = allowStateChangesStart$1(true);
var prevAllowStateReads = allowStateReadsStart(true);
var runInfo = {
prevDerivation,
prevAllowStateChanges,
prevAllowStateReads,
notifySpy,
startTime,
actionId: nextActionId++,
parentActionId: currentActionId
};
currentActionId = runInfo.actionId;
return runInfo;
}
function _endAction(runInfo) {
if (currentActionId !== runInfo.actionId) {
fail("invalid action stack. did you forget to finish an action?");
}
currentActionId = runInfo.parentActionId;
if (runInfo.error !== void 0) {
globalState.suppressReactionErrors = true;
}
allowStateChangesEnd$1(runInfo.prevAllowStateChanges);
allowStateReadsEnd(runInfo.prevAllowStateReads);
endBatch();
untrackedEnd(runInfo.prevDerivation);
if (runInfo.notifySpy && process.env.NODE_ENV !== "production") {
spyReportEnd({ time: Date.now() - runInfo.startTime });
}
globalState.suppressReactionErrors = false;
}
function allowStateChangesStart$1(allowStateChanges2) {
var prev2 = globalState.allowStateChanges;
globalState.allowStateChanges = allowStateChanges2;
return prev2;
}
function allowStateChangesEnd$1(prev2) {
globalState.allowStateChanges = prev2;
}
var ObservableValue = (
/** @class */
function(_super) {
__extends$12(ObservableValue2, _super);
function ObservableValue2(value, enhancer, name, notifySpy, equals) {
if (name === void 0) {
name = "ObservableValue@" + getNextId();
}
if (notifySpy === void 0) {
notifySpy = true;
}
if (equals === void 0) {
equals = comparer.default;
}
var _this = _super.call(this, name) || this;
_this.enhancer = enhancer;
_this.name = name;
_this.equals = equals;
_this.hasUnreportedChange = false;
_this.value = enhancer(value, void 0, name);
if (notifySpy && isSpyEnabled() && process.env.NODE_ENV !== "production") {
spyReport({ type: "create", name: _this.name, newValue: "" + _this.value });
}
return _this;
}
ObservableValue2.prototype.dehanceValue = function(value) {
if (this.dehancer !== void 0)
return this.dehancer(value);
return value;
};
ObservableValue2.prototype.set = function(newValue) {
var oldValue = this.value;
newValue = this.prepareNewValue(newValue);
if (newValue !== globalState.UNCHANGED) {
var notifySpy = isSpyEnabled();
if (notifySpy && process.env.NODE_ENV !== "production") {
spyReportStart({
type: "update",
name: this.name,
newValue,
oldValue
});
}
this.setNewValue(newValue);
if (notifySpy && process.env.NODE_ENV !== "production")
spyReportEnd();
}
};
ObservableValue2.prototype.prepareNewValue = function(newValue) {
checkIfStateModificationsAreAllowed(this);
if (hasInterceptors(this)) {
var change = interceptChange(this, {
object: this,
type: "update",
newValue
});
if (!change)