sproutjs-core 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/sprout-core.js ADDED
@@ -0,0 +1,2475 @@
1
+ /******/ (() => { // webpackBootstrap
2
+ /******/ "use strict";
3
+ /******/ var __webpack_modules__ = ({
4
+
5
+ /***/ "./src/build/index.js":
6
+ /*!****************************!*\
7
+ !*** ./src/build/index.js ***!
8
+ \****************************/
9
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
10
+
11
+ __webpack_require__.r(__webpack_exports__);
12
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13
+ /* harmony export */ "default": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__)
14
+ /* harmony export */ });
15
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
16
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
17
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
18
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
19
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
20
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
21
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
22
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
23
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
24
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
25
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
26
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
27
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
28
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
29
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
30
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
31
+ // This is the script that takes Template elements from the page and defines Reactive Custom Elements
32
+ /* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(appScope, appName) {
33
+ // Create custom elements from templates
34
+ function defineElementFromTemplate(_x, _x2, _x3) {
35
+ return _defineElementFromTemplate.apply(this, arguments);
36
+ }
37
+ function _defineElementFromTemplate() {
38
+ _defineElementFromTemplate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(template, elemName, globalStylesheet) {
39
+ var templateContent, style, runtime;
40
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
41
+ while (1) switch (_context.prev = _context.next) {
42
+ case 0:
43
+ templateContent = document.importNode(template.content, true);
44
+ style = templateContent.querySelector('style');
45
+ if (style) templateContent.removeChild(style);
46
+ runtime = templateContent.querySelector('script');
47
+ if (runtime) templateContent.removeChild(runtime);
48
+ customElements.define(elemName, /*#__PURE__*/function (_appScope$ReactiveEle) {
49
+ function _class() {
50
+ _classCallCheck(this, _class);
51
+ return _callSuper(this, _class, [templateContent, runtime, style === null || style === void 0 ? void 0 : style.textContent, globalStylesheet]);
52
+ }
53
+ _inherits(_class, _appScope$ReactiveEle);
54
+ return _createClass(_class);
55
+ }(appScope.ReactiveElement));
56
+ case 6:
57
+ case "end":
58
+ return _context.stop();
59
+ }
60
+ }, _callee);
61
+ }));
62
+ return _defineElementFromTemplate.apply(this, arguments);
63
+ }
64
+ function build() {
65
+ var globalStylesheet;
66
+ var globalStyle = document.querySelector("head > style[app=\"".concat(appName, "\"]"));
67
+ if (globalStyle) {
68
+ globalStylesheet = new CSSStyleSheet();
69
+ globalStylesheet.replaceSync(globalStyle.textContent);
70
+ }
71
+ Array.prototype.forEach.call(document.querySelectorAll("template[app=\"".concat(appName, "\"]")), function (template) {
72
+ defineElementFromTemplate(template, template.getAttribute('for'), globalStylesheet);
73
+ });
74
+ if (typeof globalThis["".concat(appName, "_runtime")] === 'function') {
75
+ var globalRuntimeFunction = globalThis["".concat(appName, "_runtime")];
76
+ globalRuntimeFunction.call(appScope);
77
+ }
78
+ }
79
+ build();
80
+ }
81
+
82
+ /***/ }),
83
+
84
+ /***/ "./src/core/DOM_utils.js":
85
+ /*!*******************************!*\
86
+ !*** ./src/core/DOM_utils.js ***!
87
+ \*******************************/
88
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
89
+
90
+ __webpack_require__.r(__webpack_exports__);
91
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
92
+ /* harmony export */ isElementAList: () => (/* binding */ isElementAList)
93
+ /* harmony export */ });
94
+ function isElementAList(element) {
95
+ return element.tagName === "OL" || element.tagName === "UL";
96
+ }
97
+
98
+ /***/ }),
99
+
100
+ /***/ "./src/core/ReactiveElement.js":
101
+ /*!*************************************!*\
102
+ !*** ./src/core/ReactiveElement.js ***!
103
+ \*************************************/
104
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
105
+
106
+ __webpack_require__.r(__webpack_exports__);
107
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
108
+ /* harmony export */ extendElementClassWithReactiveElementClass: () => (/* binding */ extendElementClassWithReactiveElementClass)
109
+ /* harmony export */ });
110
+ /* harmony import */ var _commands_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./commands.js */ "./src/core/commands.js");
111
+ /* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts.js */ "./src/core/consts.js");
112
+ /* harmony import */ var _state_utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./state_utils.js */ "./src/core/state_utils.js");
113
+ /* harmony import */ var _StateManager_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./StateManager.js */ "./src/core/StateManager.js");
114
+ /* harmony import */ var _paint_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./paint_utils.js */ "./src/core/paint_utils.js");
115
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
116
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
117
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
118
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
119
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
120
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
121
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
122
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
123
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
124
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
125
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
126
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
127
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
128
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
129
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
130
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
131
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
132
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
133
+ function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
134
+ function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
135
+ function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
136
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
137
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
138
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
139
+ function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
140
+ function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
141
+ function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+ function extendElementClassWithReactiveElementClass(elementClass) {
150
+ var appScope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window;
151
+ var noRender = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
152
+ var _onMount = /*#__PURE__*/new WeakMap();
153
+ var _wasMounted = /*#__PURE__*/new WeakMap();
154
+ var _boundAttributesToState = /*#__PURE__*/new WeakMap();
155
+ var _templateContent = /*#__PURE__*/new WeakMap();
156
+ var _stylesheet = /*#__PURE__*/new WeakMap();
157
+ var _globalStylesheet = /*#__PURE__*/new WeakMap();
158
+ var _events = /*#__PURE__*/new WeakMap();
159
+ var _boundEventNames = /*#__PURE__*/new WeakMap();
160
+ var _eventHandler = /*#__PURE__*/new WeakMap();
161
+ var _changeEventHandler = /*#__PURE__*/new WeakMap();
162
+ var _ReactiveElement_brand = /*#__PURE__*/new WeakSet();
163
+ var ReactiveElement = /*#__PURE__*/function (_elementClass) {
164
+ function ReactiveElement() {
165
+ var _this;
166
+ var template = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
167
+ var runtimeScript = arguments.length > 1 ? arguments[1] : undefined;
168
+ var style = arguments.length > 2 ? arguments[2] : undefined;
169
+ var globalStylesheet = arguments.length > 3 ? arguments[3] : undefined;
170
+ _classCallCheck(this, ReactiveElement);
171
+ _this = _callSuper(this, ReactiveElement);
172
+ _classPrivateMethodInitSpec(_this, _ReactiveElement_brand);
173
+ // Should contain the "root" DOM element containing this element
174
+ _defineProperty(_this, "host", null);
175
+ // Callback function for when the element is connected to a DOM tree on the page
176
+ _classPrivateFieldInitSpec(_this, _onMount, void 0);
177
+ _classPrivateFieldInitSpec(_this, _wasMounted, false);
178
+ // Used for the _bind command, which allows "reverse-binding" attribute values to state props,
179
+ // keys are attribute names, values are state prop names
180
+ _classPrivateFieldInitSpec(_this, _boundAttributesToState, {});
181
+ // Should only be used on non native custom elements
182
+ _classPrivateFieldInitSpec(_this, _templateContent, void 0);
183
+ _classPrivateFieldInitSpec(_this, _stylesheet, void 0);
184
+ _classPrivateFieldInitSpec(_this, _globalStylesheet, void 0);
185
+ // This will be an object where keys are element "ref" names,
186
+ // and the value is either a "click" event handler (if it's a function),
187
+ // or an object with DOM event names as keys and event handlers as functions.
188
+ // Only relevant for non native custom elements - event bubbling from child elements will be used
189
+ _classPrivateFieldInitSpec(_this, _events, void 0);
190
+ // Name of events that are bound to the main event handler function
191
+ _classPrivateFieldInitSpec(_this, _boundEventNames, []);
192
+ // Main event handler function
193
+ _classPrivateFieldInitSpec(_this, _eventHandler, void 0);
194
+ // Special case to handle input change events (to make them bubble up from shadow DOM)
195
+ _classPrivateFieldInitSpec(_this, _changeEventHandler, void 0);
196
+ _this.isReactiveElement = true;
197
+ _this.isNativeElement = _this.hasAttribute("is");
198
+ if (!_this.isNativeElement) {
199
+ if (runtimeScript) {
200
+ var dynamicRuntimeFn = new Function(runtimeScript.textContent);
201
+ var runtime = dynamicRuntimeFn();
202
+ _assertClassBrand(_ReactiveElement_brand, _this, _setRuntime).call(_this, runtime);
203
+ }
204
+ // Should already be a DocumentFragment of the template
205
+ if (template) {
206
+ _classPrivateFieldSet(_templateContent, _this, template.cloneNode(true));
207
+ } else {
208
+ _classPrivateFieldSet(_templateContent, _this, _consts_js__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_TEMPLATE_DOM.cloneNode());
209
+ }
210
+ if (style) {
211
+ var stylesheet = new CSSStyleSheet();
212
+ stylesheet.replaceSync(style);
213
+ _classPrivateFieldSet(_stylesheet, _this, stylesheet);
214
+ }
215
+ if (globalStylesheet) {
216
+ _classPrivateFieldSet(_globalStylesheet, _this, globalStylesheet);
217
+ }
218
+ // Maps "ref names" to actual elements in the component DOM tree,
219
+ // for fast access.
220
+ _this.ref = {};
221
+ }
222
+ return _this;
223
+ }
224
+ _inherits(ReactiveElement, _elementClass);
225
+ return _createClass(ReactiveElement, [{
226
+ key: "setInitialState",
227
+ value: function setInitialState(initState) {
228
+ if (this.initialState) {
229
+ Object.assign(this.initialState, initState);
230
+ } else {
231
+ this.initialState = initState;
232
+ }
233
+ }
234
+ }, {
235
+ key: "bindAttributeToState",
236
+ value: function bindAttributeToState(attrName, statePropName) {
237
+ _classPrivateFieldGet(_boundAttributesToState, this)[attrName] = statePropName;
238
+ }
239
+ }, {
240
+ key: "unbindAttributeToState",
241
+ value: function unbindAttributeToState(attrName) {
242
+ delete _classPrivateFieldGet(_boundAttributesToState, this)[attrName];
243
+ }
244
+
245
+ // For input elements
246
+ }, {
247
+ key: "updateStateFromProperty",
248
+ value: function updateStateFromProperty(propertyName) {
249
+ var newValue = this[propertyName];
250
+ var stateProp = _classPrivateFieldGet(_boundAttributesToState, this)[propertyName];
251
+ var _this$getState = this.getState(stateProp, true),
252
+ _this$getState2 = _slicedToArray(_this$getState, 2),
253
+ stateValue = _this$getState2[0],
254
+ theState = _this$getState2[1];
255
+ if (stateValue !== newValue) theState[stateProp] = newValue;
256
+ }
257
+ }, {
258
+ key: "disconnectedCallback",
259
+ value: function disconnectedCallback() {
260
+ var _this$host;
261
+ var host = (_this$host = this.host) !== null && _this$host !== void 0 ? _this$host : this;
262
+ if (host.ref) {
263
+ var thisRefName = this.getAttribute('ref');
264
+ if (thisRefName) delete host.ref[thisRefName];
265
+ }
266
+ _classPrivateFieldSet(_boundAttributesToState, this, {});
267
+ _assertClassBrand(_ReactiveElement_brand, this, _unbindEvents).call(this);
268
+ }
269
+ }, {
270
+ key: "connectedCallback",
271
+ value: function connectedCallback() {
272
+ var _this2 = this;
273
+ if (_classPrivateFieldGet(_wasMounted, this)) return;
274
+ if (!this.isNativeElement) {
275
+ _assertClassBrand(_ReactiveElement_brand, this, _setActiveStateFromInitialState).call(this);
276
+ }
277
+
278
+ // IMPORTANT: THIS *CAN* be NULL, DO NOT CHANGE IT!
279
+ // It is part of the way a check is made to see if an element is part of ShadowDOM!
280
+ // host will be null if the element is part of the DOM === the "root" custom element will have null in .host
281
+ this.host = this.getRootNode().host;
282
+
283
+ // Keep it here and not in bindEvents!
284
+ if ((this === null || this === void 0 ? void 0 : this.tagName) === "INPUT") {
285
+ _classPrivateFieldSet(_changeEventHandler, this, function () {
286
+ var changeEvent = new Event('inputChange', {
287
+ bubbles: true,
288
+ composed: true
289
+ });
290
+ this.dispatchEvent(changeEvent);
291
+ });
292
+ // Change events does not automatically bubbles, we need to listen and bubble up a new event
293
+ this.addEventListener('change', _classPrivateFieldGet(_changeEventHandler, this), false);
294
+ }
295
+ if (!this.isNativeElement && !noRender) {
296
+ _assertClassBrand(_ReactiveElement_brand, this, _renderTemplate).call(this);
297
+ }
298
+ var commands = [];
299
+ var _iterator = _createForOfIteratorHelper(this.getAttributeNames()),
300
+ _step;
301
+ try {
302
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
303
+ var attrName = _step.value;
304
+ var attrValue = this.getAttribute(attrName);
305
+ // This also resolves "State attributes"
306
+ this.initialSetAttribute(attrName, attrValue);
307
+
308
+ // Save "Command attributes"
309
+ if (attrName.indexOf('_') === 0) {
310
+ var command = attrName.substring(1);
311
+ commands.push({
312
+ command: command,
313
+ args: attrValue
314
+ });
315
+ // COMMAND_ATTRIBUTES[command]?.call(this, attrValue);
316
+ }
317
+ }
318
+ } catch (err) {
319
+ _iterator.e(err);
320
+ } finally {
321
+ _iterator.f();
322
+ }
323
+ commands.forEach(function (_ref) {
324
+ var _COMMAND_ATTRIBUTES$c;
325
+ var command = _ref.command,
326
+ args = _ref.args;
327
+ (_COMMAND_ATTRIBUTES$c = _commands_js__WEBPACK_IMPORTED_MODULE_1__.COMMANDS[command]) === null || _COMMAND_ATTRIBUTES$c === void 0 || _COMMAND_ATTRIBUTES$c.call(_this2, args);
328
+ });
329
+ if (!this.isNativeElement) {
330
+ (0,_paint_utils_js__WEBPACK_IMPORTED_MODULE_2__.queueBindEvents)(this, function () {
331
+ return _assertClassBrand(_ReactiveElement_brand, _this2, _bindEvents).call(_this2);
332
+ });
333
+ if (_classPrivateFieldGet(_onMount, this)) queueMicrotask(function () {
334
+ return _classPrivateFieldGet(_onMount, _this2).call(_this2, appScope[_consts_js__WEBPACK_IMPORTED_MODULE_0__.GLOBAL_STATE_FUNCTION_NAME]());
335
+ });
336
+ }
337
+ _classPrivateFieldSet(_wasMounted, this, true);
338
+ }
339
+ }, {
340
+ key: "attributeChangedCallback",
341
+ value: function attributeChangedCallback(attributeName, oldValue, newValue) {
342
+ if (oldValue === newValue) return;
343
+ if (!this.isConnected) return;
344
+ if (attributeName === "ref") {
345
+ var host = this.isNativeElement ? this.host : this;
346
+ var refValue = newValue;
347
+ host.ref[refValue] = this;
348
+ }
349
+ if (attributeName in _classPrivateFieldGet(_boundAttributesToState, this)) {
350
+ _assertClassBrand(_ReactiveElement_brand, this, _updateStateFromAttribute).call(this, attributeName);
351
+ }
352
+ }
353
+
354
+ // Gets state value of stateProp,
355
+ // tries to resolve from local state(s) first,
356
+ // and then from global. If the second argument is true, returns both the state value and the state objec
357
+ }, {
358
+ key: "getState",
359
+ value: function getState(stateProp) {
360
+ var returnStateObject = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
361
+ var theState;
362
+ // If this is a reactive element inside a reactive web component - the host should be the containing web component -
363
+ // we should reference its state, if host is null - it is most likely the host web component
364
+ var thisInstance = this.isNativeElement && this.host ? this.host : this;
365
+ // if (!thisInstance) return returnStateObject ? [undefined, undefined] : undefined;
366
+
367
+ var stateVal;
368
+ if (thisInstance && thisInstance.state) {
369
+ var _thisInstance$state;
370
+ stateVal = (_thisInstance$state = thisInstance.state) === null || _thisInstance$state === void 0 ? void 0 : _thisInstance$state[stateProp];
371
+ }
372
+ var globalState = false;
373
+ while (stateVal === undefined && typeof thisInstance.host !== 'undefined' && thisInstance.host !== null) {
374
+ var _thisInstance$state2;
375
+ thisInstance = thisInstance.host;
376
+ stateVal = (_thisInstance$state2 = thisInstance.state) === null || _thisInstance$state2 === void 0 ? void 0 : _thisInstance$state2[stateProp];
377
+ }
378
+ if (stateVal !== undefined) theState = thisInstance.state;else {
379
+ var _globalState;
380
+ globalState = appScope[_consts_js__WEBPACK_IMPORTED_MODULE_0__.GLOBAL_STATE_FUNCTION_NAME]();
381
+ stateVal = (_globalState = globalState) === null || _globalState === void 0 ? void 0 : _globalState[stateProp];
382
+ if (stateVal !== undefined) theState = globalState;
383
+ }
384
+ if (returnStateObject) {
385
+ return [stateVal, theState];
386
+ }
387
+ return stateVal;
388
+ }
389
+ }, {
390
+ key: "findElement",
391
+ value: function findElement(refName) {
392
+ var host = this.isNativeElement ? this.host : this;
393
+ // if Shadow DOM is used, the "root" element is shadowRoot, otherwise it is the
394
+ // web component itself
395
+ var root = host;
396
+ if (appScope.SPROUT_CONFIG.useShadow) {
397
+ root = host.shadowRoot;
398
+ }
399
+ return host.ref.hasOwnProperty(refName) ? host.ref[refName] : root.querySelector("[ref=\"".concat(refName, "\"]"));
400
+ }
401
+ //static get observedAttributes() { return ["todo-name"]; }
402
+ }]);
403
+ }(elementClass); // The "initialSetX" functions are called:
404
+ // 1. When a custom element instance is first created (before it's connected) -
405
+ // state attribute values are set to their state prop names (e.g: '$name').
406
+ // 2. When a custom element instance becomes connected (added to the DOM) - state attribute values are actually resolved to the
407
+ // value of their respective state prop values, and binding between them occurs.
408
+ function _setRuntime(runtime) {
409
+ var _this3 = this;
410
+ if (runtime.events) {
411
+ _classPrivateFieldSet(_events, this, runtime.events);
412
+ if (this.isConnected) {
413
+ (0,_paint_utils_js__WEBPACK_IMPORTED_MODULE_2__.queueBindEvents)(this, function () {
414
+ return _assertClassBrand(_ReactiveElement_brand, _this3, _bindEvents).call(_this3);
415
+ });
416
+ }
417
+ }
418
+ if (runtime.state) {
419
+ this.setInitialState(runtime.state);
420
+ // If this is not mounted yet, #setStateFromInitialState will be called from onConnected callback
421
+ if (this.isConnected) _assertClassBrand(_ReactiveElement_brand, this, _setActiveStateFromInitialState).call(this);
422
+ }
423
+ if (runtime.onMount) {
424
+ _classPrivateFieldSet(_onMount, this, runtime.onMount);
425
+ }
426
+ }
427
+ function _setActiveStateFromInitialState() {
428
+ if (!this.initialState) return;
429
+ var initialState = this.initialState;
430
+ if (initialState._stateManager) {
431
+ this.state = initialState._stateManager.state;
432
+ } else {
433
+ this.state = new _StateManager_js__WEBPACK_IMPORTED_MODULE_3__["default"](initialState, undefined, undefined, false, appScope).state;
434
+ }
435
+ delete this.initialState;
436
+ }
437
+ function _renderTemplate() {
438
+ if (appScope.SPROUT_CONFIG.useShadow) {
439
+ var shadowRoot = this.attachShadow({
440
+ mode: "open",
441
+ slotAssignment: "manual"
442
+ });
443
+ this.shadowRoot.adoptedStyleSheets = [];
444
+ if (_classPrivateFieldGet(_globalStylesheet, this)) this.shadowRoot.adoptedStyleSheets.push(_classPrivateFieldGet(_globalStylesheet, this));
445
+ if (_classPrivateFieldGet(_stylesheet, this)) this.shadowRoot.adoptedStyleSheets.push(_classPrivateFieldGet(_stylesheet, this));
446
+ shadowRoot.appendChild(_classPrivateFieldGet(_templateContent, this));
447
+ } else {
448
+ var fragment = new DocumentFragment();
449
+ fragment.appendChild(_classPrivateFieldGet(_templateContent, this));
450
+ this.appendChild(fragment);
451
+ }
452
+ }
453
+ function _unbindEvents() {
454
+ var _this4 = this;
455
+ if (_classPrivateFieldGet(_changeEventHandler, this)) this.removeEventListener('change', _classPrivateFieldGet(_changeEventHandler, this));
456
+ if (!_classPrivateFieldGet(_boundEventNames, this).length) return;
457
+ var thiselement = this;
458
+ _classPrivateFieldGet(_boundEventNames, this).forEach(function (eventName) {
459
+ thiselement.removeEventListener(eventName, _classPrivateFieldGet(_eventHandler, _this4), false);
460
+ });
461
+ }
462
+ function _bindEvents() {
463
+ var _this5 = this,
464
+ _classPrivateFieldGet2;
465
+ if (!_classPrivateFieldGet(_events, this)) return;
466
+ var eventRefNames = Object.keys(_classPrivateFieldGet(_events, this));
467
+ var clickActions = {};
468
+ var otherActions = {};
469
+ eventRefNames.forEach(function (refName) {
470
+ var value = _classPrivateFieldGet(_events, _this5)[refName];
471
+ if (typeof value === 'function') {
472
+ clickActions[refName] = value;
473
+ } else if (_typeof(value) === 'object') {
474
+ var _eventNames = Object.keys(value);
475
+ _eventNames.forEach(function (eventName) {
476
+ if (eventName === 'click') {
477
+ clickActions[refName] = value[eventName];
478
+ } else {
479
+ if (!otherActions[eventName]) otherActions[eventName] = {};
480
+ otherActions[eventName][refName] = value[eventName];
481
+ }
482
+ });
483
+ }
484
+ });
485
+ var globalState = appScope[_consts_js__WEBPACK_IMPORTED_MODULE_0__.GLOBAL_STATE_FUNCTION_NAME]();
486
+ _classPrivateFieldSet(_eventHandler, this, function (event, eventsObject) {
487
+ var elementsPath = event.composedPath();
488
+ var target;
489
+ if (elementsPath) {
490
+ target = elementsPath.find(function (element) {
491
+ return element.hasAttribute && element.hasAttribute('ref') && element.getAttribute('ref') in eventsObject;
492
+ });
493
+ } else {
494
+ target = event.target.hasAttribute && event.target.hasAttribute('ref') && event.target.getAttribute('ref') in eventsObject ? event.target : null;
495
+ }
496
+ if (target) {
497
+ var _eventsObject$ref;
498
+ var ref = target.getAttribute('ref');
499
+ (_eventsObject$ref = eventsObject[ref]) === null || _eventsObject$ref === void 0 || _eventsObject$ref.call(target, event, event.target, globalState);
500
+ }
501
+ });
502
+ var thiselement = this;
503
+ if (Object.keys(clickActions).length) {
504
+ thiselement.addEventListener('click', function (event) {
505
+ _classPrivateFieldGet(_eventHandler, _this5).call(_this5, event, clickActions);
506
+ }, false);
507
+ _classPrivateFieldGet(_boundEventNames, this).push('click');
508
+ }
509
+ var eventNames = Object.keys(otherActions);
510
+ var _loop = function _loop() {
511
+ var eventName = _eventNames2[_i];
512
+ thiselement.addEventListener(eventName, function (event) {
513
+ _classPrivateFieldGet(_eventHandler, _this5).call(_this5, event, otherActions[eventName]);
514
+ }, false);
515
+ };
516
+ for (var _i = 0, _eventNames2 = eventNames; _i < _eventNames2.length; _i++) {
517
+ _loop();
518
+ }
519
+ (_classPrivateFieldGet2 = _classPrivateFieldGet(_boundEventNames, this)).push.apply(_classPrivateFieldGet2, eventNames);
520
+ }
521
+ function _updateStateFromAttribute(attributeName) {
522
+ var newValue = this.getAttribute(attributeName);
523
+ if (_consts_js__WEBPACK_IMPORTED_MODULE_0__.BOOLEAN_ATTRIBUTES.includes(attributeName)) {
524
+ if (newValue === null) newValue = false;else newValue = true;
525
+ }
526
+ var stateProp = _classPrivateFieldGet(_boundAttributesToState, this)[attributeName];
527
+ var _this$getState3 = this.getState(stateProp, true),
528
+ _this$getState4 = _slicedToArray(_this$getState3, 2),
529
+ stateValue = _this$getState4[0],
530
+ theState = _this$getState4[1];
531
+ if (stateValue !== newValue) theState[stateProp] = newValue;
532
+ }
533
+ _defineProperty(ReactiveElement, "observedAttributes", ["ref"].concat(_consts_js__WEBPACK_IMPORTED_MODULE_0__.SUPPORTED_ATTRIBUTES_FOR_BINDING).concat(Object.keys(_commands_js__WEBPACK_IMPORTED_MODULE_1__.COMMANDS).map(function (command) {
534
+ return '_' + command.toLowerCase();
535
+ })));
536
+ ReactiveElement.prototype.initialSetText = function (stateProp) {
537
+ _state_utils_js__WEBPACK_IMPORTED_MODULE_4__.setStateText.call(this, stateProp);
538
+ };
539
+ ReactiveElement.prototype.initialSetAttribute = function (attributeName, attributeValue) {
540
+ attributeValue = String(attributeValue);
541
+ var valueToSet = attributeValue;
542
+ // "State attribute"
543
+ if (attributeValue.indexOf('$') === 0 && attributeName.indexOf('_') !== 0 && this.isConnected) {
544
+ var stateProp = attributeValue.substring(1);
545
+ _state_utils_js__WEBPACK_IMPORTED_MODULE_4__.setStateAttribute.call(this, attributeName, stateProp);
546
+ }
547
+ // normal attribute
548
+ else {
549
+ _state_utils_js__WEBPACK_IMPORTED_MODULE_4__.setAttribute.call(this, attributeName, valueToSet);
550
+ }
551
+ };
552
+
553
+ /*
554
+ if (DEBUG_MODE) {
555
+ const descriptors = Object.getOwnPropertyDescriptors(ReactiveElement.prototype);
556
+ for (const key in descriptors) {
557
+ const descrp = descriptors[key];
558
+ Object.defineProperty(ReactiveElement.prototype, key, {
559
+ writable: descrp.writable,
560
+ configurable: descrp.configurable,
561
+ enumerable: descrp.enumerable,
562
+ value: ()=> {
563
+ `Calling ${key} on ReactiveElement for ${elementClass.toString()}`;
564
+ descrp.value();
565
+ }
566
+ });
567
+ }
568
+ }
569
+ */
570
+
571
+ return ReactiveElement;
572
+ }
573
+
574
+ /***/ }),
575
+
576
+ /***/ "./src/core/ReactiveSlot.js":
577
+ /*!**********************************!*\
578
+ !*** ./src/core/ReactiveSlot.js ***!
579
+ \**********************************/
580
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
581
+
582
+ __webpack_require__.r(__webpack_exports__);
583
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
584
+ /* harmony export */ getReactiveSlotClass: () => (/* binding */ getReactiveSlotClass)
585
+ /* harmony export */ });
586
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
587
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
588
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
589
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
590
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
591
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
592
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
593
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
594
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
595
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
596
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
597
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
598
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
599
+ function getReactiveSlotClass(ReactiveElementClass) {
600
+ var ReactiveSlot = /*#__PURE__*/function (_ReactiveElementClass) {
601
+ function ReactiveSlot() {
602
+ _classCallCheck(this, ReactiveSlot);
603
+ return _callSuper(this, ReactiveSlot, arguments);
604
+ }
605
+ _inherits(ReactiveSlot, _ReactiveElementClass);
606
+ return _createClass(ReactiveSlot, [{
607
+ key: "renderSlot",
608
+ value: function renderSlot(statePropName) {
609
+ if (this.tagName !== "SLOT") return;
610
+ var stateValue = this.getState(statePropName);
611
+ if (typeof stateValue === "undefined") {
612
+ throw Error("State property ".concat(statePropName, " not defined for conditional slot rendering!"));
613
+ }
614
+ var children = this === null || this === void 0 ? void 0 : this.slotChildren;
615
+ if (children) {
616
+ var nodesToAssign = [];
617
+ children.forEach(function (slotChildElement) {
618
+ var _if = slotChildElement.getAttribute('_if');
619
+ if (_if) {
620
+ var expectedValue = Boolean(_if === "true");
621
+ if (stateValue == expectedValue) {
622
+ nodesToAssign.push(slotChildElement);
623
+ }
624
+ }
625
+ });
626
+ if (nodesToAssign.length) {
627
+ this.assign.apply(this, nodesToAssign);
628
+ }
629
+ }
630
+ }
631
+ }]);
632
+ }(ReactiveElementClass);
633
+ return ReactiveSlot;
634
+ }
635
+
636
+ /***/ }),
637
+
638
+ /***/ "./src/core/StateManager.js":
639
+ /*!**********************************!*\
640
+ !*** ./src/core/StateManager.js ***!
641
+ \**********************************/
642
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
643
+
644
+ __webpack_require__.r(__webpack_exports__);
645
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
646
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
647
+ /* harmony export */ });
648
+ /* harmony import */ var _state_utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./state_utils.js */ "./src/core/state_utils.js");
649
+ /* harmony import */ var _proxy_handlers_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./proxy_handlers.js */ "./src/core/proxy_handlers.js");
650
+ /* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./consts.js */ "./src/core/consts.js");
651
+ /* harmony import */ var _debug_utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./debug_utils.js */ "./src/core/debug_utils.js");
652
+ /* harmony import */ var _prop_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./prop_utils.js */ "./src/core/prop_utils.js");
653
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
654
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
655
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
656
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
657
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
658
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
659
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
660
+
661
+
662
+
663
+
664
+
665
+
666
+
667
+ // This class actually handles "State". It returns a proxied "state" object,
668
+ // while handling all state changes and triggers behind the scenes
669
+ var StateManager = /*#__PURE__*/function () {
670
+ // parentStatePropName is used if the state object is e.g. an item of an array on a state object,
671
+ // or a value in an object on a state object - any change on the child state object should trigger state
672
+ // changes on the parentStateProp
673
+ // host is the host element that the state is attached to
674
+ function StateManager(initialState, parentStateProp, parentStateManager) {
675
+ var _this = this;
676
+ var isGlobal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
677
+ var appScope = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : window;
678
+ _classCallCheck(this, StateManager);
679
+ // The privateState is used to actually contain values to read from,
680
+ // as custom getters and setters are defined
681
+ _defineProperty(this, "privateState", {});
682
+ // This represents the "publicly" exposed state object
683
+ _defineProperty(this, "state", {});
684
+ // Saves "map" connections between a state array value and a custom element name,
685
+ // this will enable creating/removing new custom elements when items of a state array change
686
+ _defineProperty(this, "stateArrayMaps", {});
687
+ // conditionallyRenderingElements = {};
688
+ // A map that maps state props to "dependencies", each time a stateProp which is a key here,
689
+ // is changed, a state change is triggered for its dependencies as well
690
+ _defineProperty(this, "stateDependencies", {});
691
+ _defineProperty(this, "conditionallyRenderingElements", {});
692
+ // Maps state props to state nodes,
693
+ // Keys are state props, and values are sets of Nodes
694
+ _defineProperty(this, "stateNodes", {});
695
+ // These are used when the state object is part of Stateful Array
696
+ _defineProperty(this, "parentStateProp", void 0);
697
+ _defineProperty(this, "parentStateManager", void 0);
698
+ this.parentStateProp = parentStateProp;
699
+ this.parentStateManager = parentStateManager;
700
+
701
+ // Saves the actual state manager instance to a readonly _stateManager
702
+ (0,_prop_utils_js__WEBPACK_IMPORTED_MODULE_0__.setHiddenProperty)(this.state, "_stateManager", this, true);
703
+
704
+ // Initialize a proxy on the "public state"
705
+ this.state = new Proxy(this.state, (0,_proxy_handlers_js__WEBPACK_IMPORTED_MODULE_1__.StateHandler)(this.state, appScope));
706
+ if (!isGlobal) (0,_prop_utils_js__WEBPACK_IMPORTED_MODULE_0__.setHiddenProperty)(this.state, "_global", appScope[_consts_js__WEBPACK_IMPORTED_MODULE_2__.GLOBAL_STATE_FUNCTION_NAME](), true);else {
707
+ // This maps depencdies between "local" state properties to global state changes
708
+ // The difference between the normal dependencies object, is that each depenency
709
+ // also includes a state object (which is the state context of the property),
710
+ // in other words, if a local state "relies" on a global state change - we save this
711
+ // mapping here.
712
+ // The keys are global state properties, where each value is a Map,
713
+ // in the map, the keys are local state manager objects, and the values are sets with
714
+ // local property names
715
+ this.globalStateDependencies = {};
716
+ this.addGlobalStateDependency = function (stateProp, depStateProp, stateManager) {
717
+ if (!_this.globalStateDependencies.hasOwnProperty(stateProp)) {
718
+ _this.globalStateDependencies[stateProp] = new Map();
719
+ }
720
+ if (!_this.globalStateDependencies[stateProp].has(stateManager)) {
721
+ _this.globalStateDependencies[stateProp].set(stateManager, new Set());
722
+ }
723
+ _this.globalStateDependencies[stateProp].get(stateManager).add(depStateProp);
724
+ };
725
+ }
726
+ if (initialState) {
727
+ (0,_state_utils_js__WEBPACK_IMPORTED_MODULE_3__.populateStateFromInitialState)(this.state, initialState);
728
+ }
729
+ }
730
+ return _createClass(StateManager, [{
731
+ key: "addStateDependency",
732
+ value: function addStateDependency(stateProp, depStateProp) {
733
+ if (!this.stateDependencies.hasOwnProperty(stateProp)) {
734
+ this.stateDependencies[stateProp] = new Set();
735
+ }
736
+ this.stateDependencies[stateProp].add(depStateProp);
737
+ }
738
+ }, {
739
+ key: "addStateMap",
740
+ value: function addStateMap(stateProp, customElementName, parentElement) {
741
+ if (!this.stateArrayMaps.hasOwnProperty(stateProp)) {
742
+ this.stateArrayMaps[stateProp] = [];
743
+ }
744
+ this.stateArrayMaps[stateProp].push({
745
+ customElementName: customElementName,
746
+ parentElement: parentElement
747
+ });
748
+ }
749
+ }, {
750
+ key: "addConditionallyRenderingElements",
751
+ value: function addConditionallyRenderingElements(stateProp, element) {
752
+ var _element$host;
753
+ if (!this.conditionallyRenderingElements.hasOwnProperty(stateProp)) {
754
+ this.conditionallyRenderingElements[stateProp] = new Set();
755
+ }
756
+ element.originalParentElement = element.parentElement || ((_element$host = element.host) === null || _element$host === void 0 ? void 0 : _element$host.shadowRoot);
757
+ this.conditionallyRenderingElements[stateProp].add(element);
758
+ }
759
+
760
+ // Node here is either an Attribute Node or a Text Node
761
+ }, {
762
+ key: "addStateNode",
763
+ value: function addStateNode(stateProp, stateNode) {
764
+ var isBooleanStateProp = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
765
+ if (!this.stateNodes.hasOwnProperty(stateProp)) {
766
+ this.stateNodes[stateProp] = new Set();
767
+ this.setAndBindStateProperty(stateProp, isBooleanStateProp);
768
+ }
769
+ this.stateNodes[stateProp].add(stateNode);
770
+ }
771
+ }, {
772
+ key: "setAndBindStateProperty",
773
+ value: function setAndBindStateProperty(stateProp) {
774
+ var isBooleanStateProp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
775
+ var stateObj = this.state;
776
+ if (stateProp.indexOf('!') === 0) {
777
+ var originalStateProp = stateProp.substring(1);
778
+ var _descriptor = Object.getOwnPropertyDescriptor(stateObj, originalStateProp);
779
+ if (!_descriptor) {
780
+ stateObj = stateObj._global;
781
+ _descriptor = Object.getOwnPropertyDescriptor(stateObj, originalStateProp);
782
+ if (!_descriptor) {
783
+ throw Error("Could not bind state prop ".concat(stateProp, ". State prop ").concat(originalStateProp, " not defined!"));
784
+ }
785
+ }
786
+ // Negate prop: (!something) - add a dependency between the negate prop to the original prop,
787
+ // So anytime the original prop change, things that are dependant on the negate prop will react
788
+ // return stateObj._stateManager.addStateDependency(originalStateProp, stateProp);
789
+ return;
790
+ }
791
+ var descriptor = Object.getOwnPropertyDescriptor(stateObj, stateProp);
792
+ if (!descriptor) {
793
+ stateObj = stateObj._global;
794
+ descriptor = Object.getOwnPropertyDescriptor(stateObj, stateProp);
795
+ if (!descriptor) {
796
+ throw Error("Could not bind state prop ".concat(stateProp, ". State prop not defined!"));
797
+ }
798
+ }
799
+ // Some state props can be getters (which usually references other state values)
800
+ // These should be treated differently: should not be saved in privateState, and should not have a setter defined
801
+ var isValueProp = descriptor.hasOwnProperty('value');
802
+ var stateManager = stateObj._stateManager;
803
+ if (isValueProp) {
804
+ if (!stateManager.privateState.hasOwnProperty(stateProp)) {
805
+ stateManager.privateState[stateProp] = stateObj[stateProp];
806
+ }
807
+ stateObj._binding = true;
808
+ Object.defineProperty(stateObj, stateProp, {
809
+ set: function set(value) {
810
+ var currentVal = stateManager.privateState[stateProp];
811
+ if (value === currentVal) return;
812
+ // Sets value to "private state"
813
+ stateManager.privateState[stateProp] = value;
814
+ (0,_state_utils_js__WEBPACK_IMPORTED_MODULE_3__.handleStateChange)(stateManager, stateProp);
815
+ // If this is an item in a Stateful Array, also trigger a state change for the state prop that contains the array
816
+ if (stateManager.parentStateManager) {
817
+ (0,_state_utils_js__WEBPACK_IMPORTED_MODULE_3__.handleStateChange)(stateManager.parentStateManager, stateManager.parentStateProp);
818
+ }
819
+ },
820
+ get: function get() {
821
+ // Value is always retrieved from the "private" state
822
+ return stateManager.privateState[stateProp];
823
+ }
824
+ });
825
+ }
826
+
827
+ // Boolean state props will also have "negate props" available (![stateProp])
828
+ if (isBooleanStateProp && stateProp.indexOf('!') !== 0) {
829
+ var negateStateProp = "!".concat(stateProp);
830
+ if (isValueProp) {
831
+ if (!stateManager.privateState.hasOwnProperty(negateStateProp)) {
832
+ Object.defineProperty(stateObj, negateStateProp, {
833
+ get: function get() {
834
+ return !stateManager.privateState[stateProp];
835
+ },
836
+ set: function set() {
837
+ throw Error("Cannot directly set a negation State property!");
838
+ },
839
+ enumerable: true
840
+ });
841
+ stateManager.addStateDependency(stateProp, negateStateProp);
842
+ }
843
+ } else {
844
+ if (!stateManager.state.hasOwnProperty(negateStateProp)) {
845
+ Object.defineProperty(stateObj, negateStateProp, {
846
+ get: function get() {
847
+ return !stateManager.state[stateProp];
848
+ },
849
+ set: function set() {
850
+ throw Error("Cannot directly set a negation State property!");
851
+ },
852
+ enumerable: true
853
+ });
854
+ stateManager.addStateDependency(stateProp, negateStateProp);
855
+ }
856
+ }
857
+ }
858
+ delete this.state._binding;
859
+ }
860
+ }]);
861
+ }();
862
+ if (_consts_js__WEBPACK_IMPORTED_MODULE_2__.DEBUG_MODE) {
863
+ StateManager = (0,_debug_utils_js__WEBPACK_IMPORTED_MODULE_4__.putObjectInDebugMode)(StateManager, 'StateManager');
864
+ }
865
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (StateManager);
866
+
867
+ /***/ }),
868
+
869
+ /***/ "./src/core/StatefulArray.js":
870
+ /*!***********************************!*\
871
+ !*** ./src/core/StatefulArray.js ***!
872
+ \***********************************/
873
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
874
+
875
+ __webpack_require__.r(__webpack_exports__);
876
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
877
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
878
+ /* harmony export */ });
879
+ /* harmony import */ var _StateManager_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./StateManager.js */ "./src/core/StateManager.js");
880
+ /* harmony import */ var _proxy_handlers_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./proxy_handlers.js */ "./src/core/proxy_handlers.js");
881
+ /* harmony import */ var _state_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./state_utils.js */ "./src/core/state_utils.js");
882
+ /* harmony import */ var _debug_utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./debug_utils.js */ "./src/core/debug_utils.js");
883
+ /* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./consts.js */ "./src/core/consts.js");
884
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
885
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
886
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
887
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
888
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
889
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
890
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
891
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
892
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
893
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
894
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
895
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
896
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
897
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
898
+ function _get() { return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }
899
+ function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }
900
+ function _wrapNativeSuper(t) { var r = "function" == typeof Map ? new Map() : void 0; return _wrapNativeSuper = function _wrapNativeSuper(t) { if (null === t || !_isNativeFunction(t)) return t; if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== r) { if (r.has(t)) return r.get(t); r.set(t, Wrapper); } function Wrapper() { return _construct(t, arguments, _getPrototypeOf(this).constructor); } return Wrapper.prototype = Object.create(t.prototype, { constructor: { value: Wrapper, enumerable: !1, writable: !0, configurable: !0 } }), _setPrototypeOf(Wrapper, t); }, _wrapNativeSuper(t); }
901
+ function _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; }
902
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
903
+ function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).indexOf("[native code]"); } catch (n) { return "function" == typeof t; } }
904
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
905
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
906
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
907
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
908
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
909
+
910
+
911
+
912
+
913
+
914
+ var StatefulArray = /*#__PURE__*/function (_Array) {
915
+ // noConvertToStateItems can be used in internal methods where a normal array is returned and you just want to recreate a StatefulArray,
916
+ // with the same state items
917
+
918
+ // NOTE: original Array constructor can get a series of arguments to build an array from, OR a single number,
919
+ // to create an array with that number as a length
920
+ function StatefulArray(initialArray, parentStateObject, arrayStateProp) {
921
+ var _this;
922
+ var noConvertToStateItems = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
923
+ var appScope = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : window;
924
+ _classCallCheck(this, StatefulArray);
925
+ if (!Array.isArray(initialArray)) {
926
+ throw Error("Argument for StateFulArray constructor must be an array!");
927
+ }
928
+ var rawArray = initialArray;
929
+ var statefulArray;
930
+ if (!noConvertToStateItems) {
931
+ statefulArray = rawArray.map(function (item, index) {
932
+ if (item !== null && item !== void 0 && item.hasOwnProperty('state')) return item;
933
+ if (Array.isArray(item)) return item; // return new StatefulArray(item, this[index].state, index, false, appScope);
934
+ if (_typeof(item) === 'object') return new _StateManager_js__WEBPACK_IMPORTED_MODULE_0__["default"](item, arrayStateProp, parentStateObject._stateManager, false, appScope);
935
+ return item;
936
+ });
937
+ }
938
+ _this = _callSuper(this, StatefulArray, _toConsumableArray(statefulArray));
939
+ // If any of these are "set" - handle state change in the value
940
+ _defineProperty(_this, "dependencyProps", new Map());
941
+ _this.parentStateObject = parentStateObject;
942
+ _this.arrayStateProp = arrayStateProp;
943
+ _this.rawArray = rawArray;
944
+ statefulArray = new Proxy(_this, (0,_proxy_handlers_js__WEBPACK_IMPORTED_MODULE_1__.StatefulArrayHandler)(parentStateObject === null || parentStateObject === void 0 ? void 0 : parentStateObject._stateManager, arrayStateProp, appScope));
945
+ return _possibleConstructorReturn(_this, statefulArray);
946
+ }
947
+ _inherits(StatefulArray, _Array);
948
+ return _createClass(StatefulArray, [{
949
+ key: "splice",
950
+ value:
951
+ // We set the $$operation property on functions that manipulates the array in a way that can change its length,
952
+ // to prevent redundant calls for handleStateChange.
953
+ // The call will be made when the "length" property of the array will be changed
954
+ function splice() {
955
+ var _get2;
956
+ this.$$operation = "splice";
957
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
958
+ args[_key] = arguments[_key];
959
+ }
960
+ var result = (_get2 = _get(_getPrototypeOf(StatefulArray.prototype), "splice", this)).call.apply(_get2, [this].concat(args));
961
+ delete this.$$operation;
962
+ return result;
963
+ }
964
+ }, {
965
+ key: "shift",
966
+ value: function shift() {
967
+ var _get3;
968
+ this.$$operation = "shift";
969
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
970
+ args[_key2] = arguments[_key2];
971
+ }
972
+ var result = (_get3 = _get(_getPrototypeOf(StatefulArray.prototype), "shift", this)).call.apply(_get3, [this].concat(args));
973
+ delete this.$$operation;
974
+ return result;
975
+ }
976
+ }, {
977
+ key: "unshift",
978
+ value: function unshift() {
979
+ var _get4;
980
+ this.$$operation = "splice";
981
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
982
+ args[_key3] = arguments[_key3];
983
+ }
984
+ var result = (_get4 = _get(_getPrototypeOf(StatefulArray.prototype), "unshift", this)).call.apply(_get4, [this].concat(args));
985
+ delete this.$$operation;
986
+ return result;
987
+ }
988
+ }, {
989
+ key: "sort",
990
+ value: function sort() {
991
+ var _get5;
992
+ this.$$operation = "sort";
993
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
994
+ args[_key4] = arguments[_key4];
995
+ }
996
+ var result = (_get5 = _get(_getPrototypeOf(StatefulArray.prototype), "sort", this)).call.apply(_get5, [this].concat(args));
997
+ delete this.$$operation;
998
+ (0,_state_utils_js__WEBPACK_IMPORTED_MODULE_2__.handleStateChange)(this.parentStateObject._stateManager, this.arrayStateProp);
999
+ return result;
1000
+ }
1001
+ }, {
1002
+ key: "reverse",
1003
+ value: function reverse() {
1004
+ var _get6;
1005
+ this.$$operation = "reverse";
1006
+ for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
1007
+ args[_key5] = arguments[_key5];
1008
+ }
1009
+ var result = (_get6 = _get(_getPrototypeOf(StatefulArray.prototype), "reverse", this)).call.apply(_get6, [this].concat(args));
1010
+ delete this.$$operation;
1011
+ (0,_state_utils_js__WEBPACK_IMPORTED_MODULE_2__.handleStateChange)(this.parentStateObject._stateManager, this.arrayStateProp);
1012
+ return result;
1013
+ }
1014
+ }, {
1015
+ key: "fill",
1016
+ value: function fill() {
1017
+ var _get7;
1018
+ this.$$operation = "fill";
1019
+ for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
1020
+ args[_key6] = arguments[_key6];
1021
+ }
1022
+ var result = (_get7 = _get(_getPrototypeOf(StatefulArray.prototype), "fill", this)).call.apply(_get7, [this].concat(args));
1023
+ delete this.$$operation;
1024
+ (0,_state_utils_js__WEBPACK_IMPORTED_MODULE_2__.handleStateChange)(this.parentStateObject._stateManager, this.arrayStateProp);
1025
+ return result;
1026
+ }
1027
+ }, {
1028
+ key: "copyWithin",
1029
+ value: function copyWithin() {
1030
+ var _get8;
1031
+ this.$$operation = "copyWithin";
1032
+ for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
1033
+ args[_key7] = arguments[_key7];
1034
+ }
1035
+ var result = (_get8 = _get(_getPrototypeOf(StatefulArray.prototype), "sort", this)).call.apply(_get8, [this].concat(args));
1036
+ delete this.$$operation;
1037
+ (0,_state_utils_js__WEBPACK_IMPORTED_MODULE_2__.handleStateChange)(this.parentStateObject._stateManager, this.arrayStateProp);
1038
+ return result;
1039
+ }
1040
+ }, {
1041
+ key: "slice",
1042
+ value: function slice() {
1043
+ var _get9;
1044
+ this.$$operation = "slice";
1045
+ for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
1046
+ args[_key8] = arguments[_key8];
1047
+ }
1048
+ var result = (_get9 = _get(_getPrototypeOf(StatefulArray.prototype), "slice", this)).call.apply(_get9, [this].concat(args));
1049
+ delete this.$$operation;
1050
+ return result;
1051
+ }
1052
+
1053
+ /*
1054
+ clone() {
1055
+ this.$$operation = "clone";
1056
+ const result = this.map(item=> item);
1057
+ delete this.$$operation;
1058
+ return result;
1059
+ }
1060
+ */
1061
+ }, {
1062
+ key: "toArray",
1063
+ value: function toArray() {
1064
+ this.$$operation = "toArray";
1065
+ /*
1066
+ const result = [];
1067
+ for (let i = 0, len=this.length; i<len; i++) {
1068
+ result.push(Object.assign({}, this[i]));
1069
+ }
1070
+ */
1071
+ var result = this.rawArray;
1072
+ delete this.$$operation;
1073
+ return result;
1074
+ }
1075
+ }], [{
1076
+ key: Symbol.species,
1077
+ get:
1078
+ // This will define which "constructor" JS calls whenever it needs to construct a new array while calling some Array native functions
1079
+ function get() {
1080
+ return Array;
1081
+ }
1082
+ }]);
1083
+ }( /*#__PURE__*/_wrapNativeSuper(Array));
1084
+ if (_consts_js__WEBPACK_IMPORTED_MODULE_3__.DEBUG_MODE) {
1085
+ StatefulArray = (0,_debug_utils_js__WEBPACK_IMPORTED_MODULE_4__.putObjectInDebugMode)(StatefulArray, "StatefulArray");
1086
+ }
1087
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (StatefulArray);
1088
+
1089
+ /***/ }),
1090
+
1091
+ /***/ "./src/core/commands.js":
1092
+ /*!******************************!*\
1093
+ !*** ./src/core/commands.js ***!
1094
+ \******************************/
1095
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1096
+
1097
+ __webpack_require__.r(__webpack_exports__);
1098
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1099
+ /* harmony export */ COMMANDS: () => (/* binding */ COMMANDS)
1100
+ /* harmony export */ });
1101
+ /* harmony import */ var _state_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./state_utils.js */ "./src/core/state_utils.js");
1102
+ /* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./consts.js */ "./src/core/consts.js");
1103
+ /* harmony import */ var _DOM_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./DOM_utils.js */ "./src/core/DOM_utils.js");
1104
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
1105
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1106
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
1107
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
1108
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
1109
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1110
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
1111
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
1112
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
1113
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
1114
+
1115
+
1116
+
1117
+
1118
+ function mapStateToElements(stateItemsPropertyName, customElementName, parentElement) {
1119
+ var _parentElement$getSta = parentElement.getState(stateItemsPropertyName, true),
1120
+ _parentElement$getSta2 = _slicedToArray(_parentElement$getSta, 2),
1121
+ stateItemsArray = _parentElement$getSta2[0],
1122
+ theState = _parentElement$getSta2[1];
1123
+ if (!stateItemsArray || !Array.isArray(stateItemsArray)) {
1124
+ console.warn("state value for _map is not an array, in state property: " + stateItemsPropertyName);
1125
+ return null;
1126
+ }
1127
+ var wrapInElement = (0,_DOM_utils_js__WEBPACK_IMPORTED_MODULE_0__.isElementAList)(parentElement) ? "li" : undefined;
1128
+ var elements = (0,_state_utils_js__WEBPACK_IMPORTED_MODULE_1__.mapStateArrayToElements)(stateItemsArray, customElementName, wrapInElement);
1129
+ parentElement.innerHTML = "";
1130
+ if (elements.length) {
1131
+ parentElement.append.apply(parentElement, _toConsumableArray(elements));
1132
+ }
1133
+ return theState;
1134
+ }
1135
+
1136
+ // Functions that run and handles "Command" attributes. Note, they should always be called
1137
+ // with the "this" context set to the custom element the command is defined on
1138
+ var COMMANDS = {
1139
+ map: function map(commandValue) {
1140
+ // The command value ("argument") is "<stateProp>:<custom element name>"
1141
+ var _commandValue$split = commandValue.split(':'),
1142
+ _commandValue$split2 = _slicedToArray(_commandValue$split, 2),
1143
+ stateItemsPropertyName = _commandValue$split2[0],
1144
+ customElementName = _commandValue$split2[1];
1145
+ var thiselement = this;
1146
+ var theState = mapStateToElements(stateItemsPropertyName, customElementName, thiselement);
1147
+ if (!theState) {
1148
+ console.warn("Mapping ".concat(stateItemsPropertyName, " to ").concat(customElementName, " failed!"));
1149
+ return;
1150
+ }
1151
+ theState._stateManager.addStateMap(stateItemsPropertyName, customElementName, thiselement);
1152
+ },
1153
+ text: function text(commandValue) {
1154
+ var stateProp = commandValue;
1155
+ this.initialSetText(stateProp);
1156
+ // DO NOT CALL .normalize()! It might change the Text Nodes!
1157
+ },
1158
+ bind: function bind(commandValue) {
1159
+ var _this = this;
1160
+ var _commandValue$split3 = commandValue.split(':'),
1161
+ _commandValue$split4 = _slicedToArray(_commandValue$split3, 2),
1162
+ attributeName = _commandValue$split4[0],
1163
+ statePropName = _commandValue$split4[1];
1164
+ if (!attributeName || !statePropName) {
1165
+ console.warn("Incorrect usage of _bind command! Please pass <attribute-name>:<state-prop-name>");
1166
+ return;
1167
+ }
1168
+ if (!attributeName in _consts_js__WEBPACK_IMPORTED_MODULE_2__.SUPPORTED_ATTRIBUTES_FOR_BINDING) {
1169
+ console.warn("Attribute ".concat(attributeName, " is not supported for _bind command!"));
1170
+ return;
1171
+ }
1172
+ this.bindAttributeToState(attributeName, statePropName);
1173
+ if (_consts_js__WEBPACK_IMPORTED_MODULE_2__.SUPPORTED_PROPERTIES_FOR_BINDING.includes(attributeName)) {
1174
+ if (attributeName === "value" && this.tagName === "INPUT" && _consts_js__WEBPACK_IMPORTED_MODULE_2__.SUPPORTED_INPUT_TYPES_FOR_VALUE_BINDING.includes(this.getAttribute('type'))) {
1175
+ this.addEventListener("input", function () {
1176
+ return _this.updateStateFromProperty("value");
1177
+ });
1178
+ } else if (attributeName === "checked" && this.tagName === "INPUT" && this.getAttribute('type') === "checkbox") {
1179
+ this.addEventListener("change", function () {
1180
+ return _this.updateStateFromProperty("checked");
1181
+ });
1182
+ }
1183
+ }
1184
+ },
1185
+ condition: function condition(commandValue) {
1186
+ var _this$host;
1187
+ if (this.tagName !== "SLOT") {
1188
+ throw Error("condition command can only be used on a slot element!");
1189
+ }
1190
+ var statePropName = commandValue;
1191
+ var _this$getState = this.getState(statePropName, true),
1192
+ _this$getState2 = _slicedToArray(_this$getState, 2),
1193
+ stateValue = _this$getState2[0],
1194
+ stateObject = _this$getState2[1];
1195
+ if (typeof stateValue === "undefined") {
1196
+ throw Error("State property ".concat(statePropName, " not defined for _condition command!"));
1197
+ }
1198
+ this.slotChildren = _toConsumableArray(this.children);
1199
+ (_this$host = this.host).append.apply(_this$host, _toConsumableArray(this.slotChildren));
1200
+ this.innerHTML = "";
1201
+ this.renderSlot(statePropName);
1202
+ stateObject._stateManager.addConditionallyRenderingElements(statePropName, this);
1203
+ }
1204
+ };
1205
+
1206
+ /***/ }),
1207
+
1208
+ /***/ "./src/core/consts.js":
1209
+ /*!****************************!*\
1210
+ !*** ./src/core/consts.js ***!
1211
+ \****************************/
1212
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1213
+
1214
+ __webpack_require__.r(__webpack_exports__);
1215
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1216
+ /* harmony export */ BOOLEAN_ATTRIBUTES: () => (/* binding */ BOOLEAN_ATTRIBUTES),
1217
+ /* harmony export */ BUILT_IN_STATE_PROPS: () => (/* binding */ BUILT_IN_STATE_PROPS),
1218
+ /* harmony export */ DEBUG_MODE: () => (/* binding */ DEBUG_MODE),
1219
+ /* harmony export */ DEFAULT_TEMPLATE_DOM: () => (/* binding */ DEFAULT_TEMPLATE_DOM),
1220
+ /* harmony export */ ERROR_MESSAGES: () => (/* binding */ ERROR_MESSAGES),
1221
+ /* harmony export */ GLOBAL_STATE_FUNCTION_NAME: () => (/* binding */ GLOBAL_STATE_FUNCTION_NAME),
1222
+ /* harmony export */ GLOBAL_STATE_VAR_NAME: () => (/* binding */ GLOBAL_STATE_VAR_NAME),
1223
+ /* harmony export */ HTML_ELEMENTS_CLASSES_MAP: () => (/* binding */ HTML_ELEMENTS_CLASSES_MAP),
1224
+ /* harmony export */ NODES_STATE: () => (/* binding */ NODES_STATE),
1225
+ /* harmony export */ SUPPORTED_ATTRIBUTES_FOR_BINDING: () => (/* binding */ SUPPORTED_ATTRIBUTES_FOR_BINDING),
1226
+ /* harmony export */ SUPPORTED_INPUT_TYPES_FOR_VALUE_BINDING: () => (/* binding */ SUPPORTED_INPUT_TYPES_FOR_VALUE_BINDING),
1227
+ /* harmony export */ SUPPORTED_PROPERTIES_FOR_BINDING: () => (/* binding */ SUPPORTED_PROPERTIES_FOR_BINDING)
1228
+ /* harmony export */ });
1229
+ var BOOLEAN_ATTRIBUTES = ['hidden', 'checked'];
1230
+ var SUPPORTED_ATTRIBUTES_FOR_BINDING = ['hidden', 'value', 'checked'];
1231
+
1232
+ // Some elements like inputs has certain properties that can be used in _bind command, like: 'value', or 'checked
1233
+ var SUPPORTED_PROPERTIES_FOR_BINDING = ['value', 'checked'];
1234
+ var SUPPORTED_INPUT_TYPES_FOR_VALUE_BINDING = ['text', 'color', 'date', 'datetime-local', 'email', 'month', 'number', 'password', 'range', 'search', 'tel', 'time', 'url', 'week'];
1235
+
1236
+ // These are "built-in" state props that are automatically added to state objects,
1237
+ // and should not be included in the normal state change/check flow
1238
+ var BUILT_IN_STATE_PROPS = ['_global', '_gettingDependenciesFor', '_localStateManager', '_stateManager', '_binding', '_populate'];
1239
+ var GLOBAL_STATE_VAR_NAME = "SproutGlobalState";
1240
+ var GLOBAL_STATE_FUNCTION_NAME = "getGlobalState";
1241
+ var ERROR_MESSAGES = {
1242
+ NO_DEPENDENCIES_ARRAY_IN_SET_HOOK: function NO_DEPENDENCIES_ARRAY_IN_SET_HOOK(stateProp) {
1243
+ return "State set hook, must include a dependencies array! None was found for ".concat(stateProp);
1244
+ }
1245
+ };
1246
+ var HTML_ELEMENTS_CLASSES_MAP = [{
1247
+ "class": HTMLAnchorElement,
1248
+ element: "a"
1249
+ }, {
1250
+ "class": HTMLAreaElement,
1251
+ element: "area"
1252
+ }, {
1253
+ "class": HTMLAudioElement,
1254
+ element: "audio"
1255
+ }, {
1256
+ "class": HTMLBaseElement,
1257
+ element: "base"
1258
+ }, {
1259
+ "class": HTMLBodyElement,
1260
+ element: "body"
1261
+ }, {
1262
+ "class": HTMLBRElement,
1263
+ element: "br"
1264
+ }, {
1265
+ "class": HTMLButtonElement,
1266
+ element: "button"
1267
+ }, {
1268
+ "class": HTMLCanvasElement,
1269
+ element: "canvas"
1270
+ }, {
1271
+ "class": HTMLDataElement,
1272
+ element: "data"
1273
+ }, {
1274
+ "class": HTMLDataListElement,
1275
+ element: "datalist"
1276
+ }, {
1277
+ "class": HTMLDetailsElement,
1278
+ element: "details"
1279
+ }, {
1280
+ "class": HTMLDialogElement,
1281
+ element: "dialog"
1282
+ }, {
1283
+ "class": HTMLDivElement,
1284
+ element: "div"
1285
+ }, {
1286
+ "class": HTMLDListElement,
1287
+ element: "dl"
1288
+ }, {
1289
+ "class": HTMLEmbedElement,
1290
+ element: "embed"
1291
+ }, {
1292
+ "class": HTMLFieldSetElement,
1293
+ element: "fieldset"
1294
+ }, {
1295
+ "class": HTMLFormElement,
1296
+ element: "form"
1297
+ }, {
1298
+ "class": HTMLHeadingElement,
1299
+ element: "h1"
1300
+ }, {
1301
+ "class": HTMLHeadingElement,
1302
+ element: "h2"
1303
+ }, {
1304
+ "class": HTMLHeadingElement,
1305
+ element: "h3"
1306
+ }, {
1307
+ "class": HTMLHeadingElement,
1308
+ element: "h4"
1309
+ }, {
1310
+ "class": HTMLHeadingElement,
1311
+ element: "h5"
1312
+ }, {
1313
+ "class": HTMLHeadingElement,
1314
+ element: "h6"
1315
+ }, {
1316
+ "class": HTMLHRElement,
1317
+ element: "hr"
1318
+ }, {
1319
+ "class": HTMLHtmlElement,
1320
+ element: "html"
1321
+ }, {
1322
+ "class": HTMLIFrameElement,
1323
+ element: "iframe"
1324
+ }, {
1325
+ "class": HTMLImageElement,
1326
+ element: "img"
1327
+ }, {
1328
+ "class": HTMLInputElement,
1329
+ element: "input"
1330
+ }, {
1331
+ "class": HTMLLabelElement,
1332
+ element: "label"
1333
+ }, {
1334
+ "class": HTMLLegendElement,
1335
+ element: "legend"
1336
+ }, {
1337
+ "class": HTMLLIElement,
1338
+ element: "li"
1339
+ }, {
1340
+ "class": HTMLLinkElement,
1341
+ element: "link"
1342
+ }, {
1343
+ "class": HTMLMapElement,
1344
+ element: "map"
1345
+ }, {
1346
+ "class": HTMLMetaElement,
1347
+ element: "meta"
1348
+ }, {
1349
+ "class": HTMLMeterElement,
1350
+ element: "meter"
1351
+ }, {
1352
+ "class": HTMLObjectElement,
1353
+ element: "object"
1354
+ }, {
1355
+ "class": HTMLOListElement,
1356
+ element: "ol"
1357
+ }, {
1358
+ "class": HTMLOptGroupElement,
1359
+ element: "optgroup"
1360
+ }, {
1361
+ "class": HTMLOptionElement,
1362
+ element: "option"
1363
+ }, {
1364
+ "class": HTMLOutputElement,
1365
+ element: "output"
1366
+ }, {
1367
+ "class": HTMLParagraphElement,
1368
+ element: "p"
1369
+ }, {
1370
+ "class": HTMLParamElement,
1371
+ element: "param"
1372
+ }, {
1373
+ "class": HTMLPictureElement,
1374
+ element: "picture"
1375
+ }, {
1376
+ "class": HTMLPreElement,
1377
+ element: "pre"
1378
+ }, {
1379
+ "class": HTMLProgressElement,
1380
+ element: "progress"
1381
+ }, {
1382
+ "class": HTMLQuoteElement,
1383
+ element: "blockquote"
1384
+ }, {
1385
+ "class": HTMLQuoteElement,
1386
+ element: "q"
1387
+ }, {
1388
+ "class": HTMLScriptElement,
1389
+ element: "script"
1390
+ }, {
1391
+ "class": HTMLSelectElement,
1392
+ element: "select"
1393
+ }, {
1394
+ "class": HTMLSourceElement,
1395
+ element: "source"
1396
+ }, {
1397
+ "class": HTMLSpanElement,
1398
+ element: "span"
1399
+ }, {
1400
+ "class": HTMLStyleElement,
1401
+ element: "style"
1402
+ }, {
1403
+ "class": HTMLTableElement,
1404
+ element: "table"
1405
+ }, {
1406
+ "class": HTMLTableCellElement,
1407
+ element: "td"
1408
+ }, {
1409
+ "class": HTMLTableCellElement,
1410
+ element: "th"
1411
+ }, {
1412
+ "class": HTMLTableRowElement,
1413
+ element: "tr"
1414
+ }, {
1415
+ "class": HTMLTableSectionElement,
1416
+ element: "thead"
1417
+ }, {
1418
+ "class": HTMLTableSectionElement,
1419
+ element: "tbody"
1420
+ }, {
1421
+ "class": HTMLTableSectionElement,
1422
+ element: "tfoot"
1423
+ }, {
1424
+ "class": HTMLTextAreaElement,
1425
+ element: "textarea"
1426
+ }, {
1427
+ "class": HTMLTimeElement,
1428
+ element: "time"
1429
+ }, {
1430
+ "class": HTMLTitleElement,
1431
+ element: "title"
1432
+ }, {
1433
+ "class": HTMLTrackElement,
1434
+ element: "track"
1435
+ }, {
1436
+ "class": HTMLUListElement,
1437
+ element: "ul"
1438
+ }, {
1439
+ "class": HTMLVideoElement,
1440
+ element: "video"
1441
+ }
1442
+ // { class: HTMLSlotElement, element: "slot" } Has a different extended class for conditional rendering
1443
+ ];
1444
+ // For development purposes only,
1445
+ // turn this on to see exactly which functions in each entity are called and when.
1446
+ var DEBUG_MODE = false;
1447
+ var DEFAULT_TEMPLATE_DOM = document.createElement('div');
1448
+ var NODES_STATE = {
1449
+ // This is a global object that maps abstract "DOM actions" to nodes (the nodes can be elements, text nodes, attribute nodes)
1450
+ // It is resolved to actual DOM API functions on RequestAnimationFrame calls, and then is RESET.
1451
+ // it is a "singleton" object
1452
+ nodeActionsMap: new Map(),
1453
+ // Maps events binding functions to (custom) elements
1454
+ eventBindingFunctions: new Map(),
1455
+ conditionalRenders: new Map(),
1456
+ // Save requestAnimationFrame Id, to cancel if the rAF wasn't called yet on the same frame, so DOM operations will be batched to a single frame,
1457
+ // preventing several rAFs running for the same frame
1458
+ paintRafId: null,
1459
+ // Similar as above but for event bindings
1460
+ eventBindRafId: null,
1461
+ // Same for conditional renders
1462
+ conditionalRenderRafId: null
1463
+ };
1464
+
1465
+ /***/ }),
1466
+
1467
+ /***/ "./src/core/debug_utils.js":
1468
+ /*!*********************************!*\
1469
+ !*** ./src/core/debug_utils.js ***!
1470
+ \*********************************/
1471
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1472
+
1473
+ __webpack_require__.r(__webpack_exports__);
1474
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1475
+ /* harmony export */ putObjectInDebugMode: () => (/* binding */ putObjectInDebugMode)
1476
+ /* harmony export */ });
1477
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
1478
+ function debugGetProxyHandler(scopeName, originalObject) {
1479
+ return {
1480
+ get: function get(target, property, receiver) {
1481
+ if (_typeof(property) === "symbol") return Reflect.get.apply(Reflect, arguments);
1482
+ console.debug("Property ".concat(property, " called on ").concat(scopeName));
1483
+ if (property === "prototype") {
1484
+ // return Object.getPrototypeOf(originalObject.prototype);
1485
+ return originalObject.prototype;
1486
+ }
1487
+ if (typeof target[property] === "function") {
1488
+ return new Proxy(target[property], debugApplyProxyHandler(property, "".concat(scopeName, ".").concat(property)));
1489
+ } else if (_typeof(target[property]) === "object") {
1490
+ if (!target[property].hasOwnProperty("_stateManager")) {
1491
+ return new Proxy(target[property], debugGetProxyHandler("".concat(scopeName, ".").concat(property)));
1492
+ }
1493
+ }
1494
+ return Reflect.get.apply(Reflect, arguments);
1495
+ }
1496
+ };
1497
+ }
1498
+ function debugApplyProxyHandler(funcName, scopeName) {
1499
+ return {
1500
+ construct: function construct(target, args, newTarget) {
1501
+ console.debug("Constructing ".concat(funcName));
1502
+ return Reflect.construct(target, args, newTarget);
1503
+ },
1504
+ apply: function apply(target, thisArg, argumentsList) {
1505
+ console.debug("Function: ".concat(funcName, " with arguments: ").concat(argumentsList, " called on ").concat(scopeName));
1506
+ return Reflect.apply.apply(Reflect, arguments);
1507
+ }
1508
+ };
1509
+ }
1510
+ function putObjectInDebugMode(obj, name) {
1511
+ return new Proxy(obj, debugGetProxyHandler(name, obj));
1512
+ }
1513
+
1514
+ /***/ }),
1515
+
1516
+ /***/ "./src/core/node_actions.js":
1517
+ /*!**********************************!*\
1518
+ !*** ./src/core/node_actions.js ***!
1519
+ \**********************************/
1520
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1521
+
1522
+ __webpack_require__.r(__webpack_exports__);
1523
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1524
+ /* harmony export */ addAppendAction: () => (/* binding */ addAppendAction),
1525
+ /* harmony export */ addAppendActionToNode: () => (/* binding */ addAppendActionToNode),
1526
+ /* harmony export */ addRemoveAction: () => (/* binding */ addRemoveAction),
1527
+ /* harmony export */ addReplaceAction: () => (/* binding */ addReplaceAction),
1528
+ /* harmony export */ addStateAttributeToNode: () => (/* binding */ addStateAttributeToNode),
1529
+ /* harmony export */ doUpdateDOM: () => (/* binding */ doUpdateDOM),
1530
+ /* harmony export */ generateStateNodeActions: () => (/* binding */ generateStateNodeActions),
1531
+ /* harmony export */ getNewNodeActionsObject: () => (/* binding */ getNewNodeActionsObject),
1532
+ /* harmony export */ logNodeActions: () => (/* binding */ logNodeActions),
1533
+ /* harmony export */ setStateNodeAction: () => (/* binding */ setStateNodeAction)
1534
+ /* harmony export */ });
1535
+ /* harmony import */ var _state_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./state_utils.js */ "./src/core/state_utils.js");
1536
+ /* harmony import */ var _DOM_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./DOM_utils.js */ "./src/core/DOM_utils.js");
1537
+ /* harmony import */ var _paint_utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./paint_utils.js */ "./src/core/paint_utils.js");
1538
+ /* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts.js */ "./src/core/consts.js");
1539
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
1540
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1541
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
1542
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
1543
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
1544
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1545
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
1546
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
1547
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
1548
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
1549
+
1550
+
1551
+
1552
+
1553
+
1554
+ // Also, if doesn't exist - create it
1555
+ function getNodeActionsForNode(node) {
1556
+ var nodeActionsMap = _consts_js__WEBPACK_IMPORTED_MODULE_0__.NODES_STATE.nodeActionsMap;
1557
+ if (!nodeActionsMap.has(node)) nodeActionsMap.set(node, getNewNodeActionsObject());
1558
+ var nodeActions = nodeActionsMap.get(node);
1559
+ return nodeActions;
1560
+ }
1561
+ function setStateNodeAction(node, nodeActionsObject, value) {
1562
+ if (node.nodeType === Node.ATTRIBUTE_NODE) nodeActionsObject["setAttribute"] = value;else if (node.nodeType === Node.TEXT_NODE) nodeActionsObject["textContent"] = value;
1563
+ }
1564
+ function addRemoveAction(nodeActions, elementToRemove, stateIdentifier) {
1565
+ if (!nodeActions.remove.has(stateIdentifier)) {
1566
+ nodeActions.remove.set(stateIdentifier, new Set());
1567
+ }
1568
+ nodeActions.remove.get(stateIdentifier).add(elementToRemove);
1569
+ }
1570
+ function addReplaceAction(nodeActions, oldElement, newElement) {
1571
+ nodeActions.replace.set(oldElement, newElement);
1572
+ }
1573
+ // stateIdentifier can be a State object (for state maps),
1574
+ // or a State property (for conditionally rendered elements)
1575
+ function addAppendAction(nodeActions, nodeToAppend, stateIdentifier) {
1576
+ if (!nodeActions.append.has(stateIdentifier)) {
1577
+ nodeActions.append.set(stateIdentifier, new Set());
1578
+ }
1579
+ nodeActions.append.get(stateIdentifier).add(nodeToAppend);
1580
+ }
1581
+ function addStateAttributeToNode(attributeNode, value) {
1582
+ var nodeActions = getNodeActionsForNode(attributeNode);
1583
+ setStateNodeAction(attributeNode, nodeActions, value);
1584
+ }
1585
+ function addAppendActionToNode(node, nodeToAppend, stateIdentifier) {
1586
+ var nodeActions = getNodeActionsForNode(node);
1587
+ addAppendAction(nodeActions, nodeToAppend, stateIdentifier);
1588
+ }
1589
+
1590
+ // This is an object used to represent pending node actions,
1591
+ // that are batched and executed in reflows (requestAnimationFrame)
1592
+ function getNewNodeActionsObject() {
1593
+ return {
1594
+ // Nodes to append to the end of node's children,
1595
+ // keys are state objects, or state props (string)
1596
+ // to prevent duplicate pending
1597
+ append: new Map(),
1598
+ // Replace each key node on Map, with value node
1599
+ replace: new Map(),
1600
+ // Insert value node after key node in parent node's children
1601
+ after: new Map(),
1602
+ // Remove these nodes from the DOM
1603
+ // keys are state objects, or state props (string)
1604
+ // to prevent duplicate pending
1605
+ remove: new Map(),
1606
+ get hasPendingActions() {
1607
+ return this.append.size || this.replace.size || this.after.size || this.remove.size;
1608
+ }
1609
+ };
1610
+ }
1611
+
1612
+ // This *updates*/*"fills"* the nodeActionsMap!
1613
+ function generateStateNodeActions(stateManager, stateProp) {
1614
+ var _this = this;
1615
+ var nodeActionsMap = _consts_js__WEBPACK_IMPORTED_MODULE_0__.NODES_STATE.nodeActionsMap;
1616
+ var value = stateManager.state[stateProp];
1617
+ var stateNodes = stateManager.stateNodes[stateProp];
1618
+ var stateMaps = stateManager.stateArrayMaps[stateProp];
1619
+ var conditionallyRenderingElements = stateManager.conditionallyRenderingElements[stateProp];
1620
+
1621
+ // Note, since the value change is handled by a custom setter - that setter checks if the set value is the same -
1622
+ // if it is - it won't call handleStateChange, and it won't reach here.
1623
+ if (stateNodes) {
1624
+ stateNodes.forEach(function (node) {
1625
+ if (!nodeActionsMap.has(node)) nodeActionsMap.set(node, {});
1626
+ var nodeActionsObject = nodeActionsMap.get(node);
1627
+ setStateNodeAction(node, nodeActionsObject, value);
1628
+ });
1629
+ }
1630
+ if (stateMaps) {
1631
+ var stateMapArray = value;
1632
+ stateMaps.forEach(function (_ref) {
1633
+ var customElementName = _ref.customElementName,
1634
+ parentElement = _ref.parentElement;
1635
+ var stateMapNodeActions = getNewNodeActionsObject();
1636
+ var currentStateMapArrayIndex = -1;
1637
+ var isParentAList = (0,_DOM_utils_js__WEBPACK_IMPORTED_MODULE_1__.isElementAList)(parentElement);
1638
+ // Compares state map arrays to actual DOM elements (by comparing state objects)
1639
+ if (parentElement.children.length) {
1640
+ Array.prototype.forEach.call(parentElement.children, function (childElement, currentIndex) {
1641
+ var _stateItem;
1642
+ var customElement = childElement;
1643
+ // State map elements inside Lists are wrapped with a <li>
1644
+ if (isParentAList) customElement = childElement.firstElementChild;
1645
+ var stateItem = stateMapArray[currentIndex];
1646
+ if ((_stateItem = stateItem) !== null && _stateItem !== void 0 && _stateItem.hasOwnProperty('state')) stateItem = stateItem.state;
1647
+ if (!stateItem) {
1648
+ addRemoveAction(stateMapNodeActions, childElement);
1649
+ } else if (customElement.state !== stateItem) {
1650
+ var replaceWithChild = (0,_state_utils_js__WEBPACK_IMPORTED_MODULE_2__.stateToElement)(stateItem, customElementName, (0,_DOM_utils_js__WEBPACK_IMPORTED_MODULE_1__.isElementAList)(parentElement) ? "li" : undefined);
1651
+ addReplaceAction(stateMapNodeActions, childElement, replaceWithChild);
1652
+ }
1653
+ currentStateMapArrayIndex = currentIndex;
1654
+ });
1655
+ }
1656
+
1657
+ // If there are more state objects in the stateMapArray - append equivalent child elements
1658
+ currentStateMapArrayIndex++;
1659
+ for (var i = currentStateMapArrayIndex, len = stateMapArray.length; i < len; i++) {
1660
+ var stateItem = stateMapArray[i];
1661
+ // New state item === new child element to append
1662
+ if (stateItem) {
1663
+ // Make sure we don't already have a pending append action for the same state object
1664
+ var newChild = (0,_state_utils_js__WEBPACK_IMPORTED_MODULE_2__.stateToElement)(stateItem, customElementName, (0,_DOM_utils_js__WEBPACK_IMPORTED_MODULE_1__.isElementAList)(parentElement) ? "li" : undefined);
1665
+ addAppendAction(stateMapNodeActions, newChild, stateItem);
1666
+ }
1667
+ }
1668
+ if (stateMapNodeActions.hasPendingActions) {
1669
+ nodeActionsMap.set(parentElement, stateMapNodeActions);
1670
+ }
1671
+ });
1672
+ }
1673
+ if (conditionallyRenderingElements) {
1674
+ // Should be slot element
1675
+ conditionallyRenderingElements.forEach(function (element) {
1676
+ (0,_paint_utils_js__WEBPACK_IMPORTED_MODULE_3__.queueConditionalRender)(_this, function () {
1677
+ return element.renderSlot(stateProp);
1678
+ });
1679
+ });
1680
+ }
1681
+ }
1682
+ function resolveNodeActionsMapToDOMActions() {
1683
+ var batchActions = [];
1684
+ var nodeActionsMap = _consts_js__WEBPACK_IMPORTED_MODULE_0__.NODES_STATE.nodeActionsMap;
1685
+ nodeActionsMap.forEach(function (nodeActions, node) {
1686
+ // Attribute change
1687
+ if (nodeActions.hasOwnProperty("setAttribute")) {
1688
+ var value = nodeActions.setAttribute;
1689
+ if (typeof value === "boolean") {
1690
+ if (!node.hasOwnProperty("originalOwnerElement")) {
1691
+ console.error("originalOwnerElement not found on boolean attribute node! Should never happen!");
1692
+ }
1693
+ if (value === false) {
1694
+ // Remove attribute if it exists, otherwise - do nothing
1695
+ if (node.originalOwnerElement.hasAttribute(node.name)) {
1696
+ batchActions.push(function () {
1697
+ node.originalOwnerElement.removeAttributeNode(node);
1698
+ });
1699
+ }
1700
+ }
1701
+ // state changed to true
1702
+ else {
1703
+ if (!node.originalOwnerElement.hasAttribute(node.name)) {
1704
+ batchActions.push(function () {
1705
+ node.originalOwnerElement.setAttributeNode(node);
1706
+ });
1707
+ }
1708
+ }
1709
+ } else {
1710
+ if (typeof value === "string" && node.nodeValue !== value) {
1711
+ batchActions.push(function () {
1712
+ return node.nodeValue = value;
1713
+ });
1714
+ }
1715
+ }
1716
+ }
1717
+
1718
+ // Text change
1719
+ else if (nodeActions.hasOwnProperty("textContent")) {
1720
+ var _value = String(nodeActions.textContent);
1721
+ if (node.nodeValue === _value) return;
1722
+ batchActions.push(function () {
1723
+ return node.nodeValue = _value;
1724
+ });
1725
+ }
1726
+
1727
+ // DOM change
1728
+ else {
1729
+ nodeActions.replace.forEach(function (newNode, oldNode) {
1730
+ batchActions.push(function () {
1731
+ return (
1732
+ //oldNode.replaceWith(newNode));
1733
+ node.replaceChild(newNode, oldNode)
1734
+ );
1735
+ });
1736
+ });
1737
+ nodeActions.remove.values().forEach(function (removes) {
1738
+ removes.forEach(function (nodeToRemove) {
1739
+ if (nodeToRemove.parentNode && nodeToRemove.parentNode === node) {
1740
+ batchActions.push(function () {
1741
+ return node.removeChild(nodeToRemove);
1742
+ });
1743
+ }
1744
+ });
1745
+ });
1746
+ nodeActions.append.values().forEach(function (appends) {
1747
+ appends.forEach(function (newChildElement) {
1748
+ batchActions.push(function () {
1749
+ return node.appendChild(newChildElement);
1750
+ });
1751
+ });
1752
+ });
1753
+ }
1754
+ });
1755
+ return batchActions;
1756
+ }
1757
+
1758
+ // For debugging purposes
1759
+ function logNodeActions() {
1760
+ var nodeActionsMap = _consts_js__WEBPACK_IMPORTED_MODULE_0__.NODES_STATE.nodeActionsMap;
1761
+ _toConsumableArray(nodeActionsMap.entries()).map(function (_ref2) {
1762
+ var _ref3 = _slicedToArray(_ref2, 2),
1763
+ node = _ref3[0],
1764
+ actions = _ref3[1];
1765
+ switch (node.nodeType) {
1766
+ case Node.ELEMENT_NODE:
1767
+ {
1768
+ console.log("Actions for", node);
1769
+ var appendElements = _toConsumableArray(actions.append.values());
1770
+ if (appendElements.length) {
1771
+ console.log("Append", appendElements);
1772
+ }
1773
+ var replaceElements = _toConsumableArray(actions.replace.entries());
1774
+ if (replaceElements.length) {
1775
+ console.log("Append", replaceElements);
1776
+ }
1777
+ if (actions.remove.size) {
1778
+ console.log("Remove", actions.remove);
1779
+ }
1780
+ break;
1781
+ }
1782
+ case Node.ATTRIBUTE_NODE:
1783
+ {
1784
+ console.log("Set Attribute", node.nodeName, "on", node.originalOwnerElement, "to", actions.setAttribute);
1785
+ break;
1786
+ }
1787
+ case Node.TEXT_NODE:
1788
+ {
1789
+ console.log("Set text content for", node.parentNode, "to", actions.textContent);
1790
+ break;
1791
+ }
1792
+ }
1793
+ });
1794
+ }
1795
+ // This function runs on requestAnimationFrame to run pending Node actions
1796
+ function doUpdateDOM() {
1797
+ var nodeActionsMap = _consts_js__WEBPACK_IMPORTED_MODULE_0__.NODES_STATE.nodeActionsMap;
1798
+ if (nodeActionsMap.size) {
1799
+ var DOMActions = resolveNodeActionsMapToDOMActions(nodeActionsMap);
1800
+ DOMActions.forEach(function (DOMAction) {
1801
+ return DOMAction();
1802
+ });
1803
+ _consts_js__WEBPACK_IMPORTED_MODULE_0__.NODES_STATE.nodeActionsMap = new Map();
1804
+ }
1805
+ // requestAnimationFrame(doUpdateDOM);
1806
+ }
1807
+
1808
+ /***/ }),
1809
+
1810
+ /***/ "./src/core/paint_utils.js":
1811
+ /*!*********************************!*\
1812
+ !*** ./src/core/paint_utils.js ***!
1813
+ \*********************************/
1814
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1815
+
1816
+ __webpack_require__.r(__webpack_exports__);
1817
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1818
+ /* harmony export */ queueBindEvents: () => (/* binding */ queueBindEvents),
1819
+ /* harmony export */ queueConditionalRender: () => (/* binding */ queueConditionalRender),
1820
+ /* harmony export */ queuePaint: () => (/* binding */ queuePaint)
1821
+ /* harmony export */ });
1822
+ /* harmony import */ var _node_actions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./node_actions */ "./src/core/node_actions.js");
1823
+ /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./src/core/consts.js");
1824
+
1825
+
1826
+ var paintRafId = _consts__WEBPACK_IMPORTED_MODULE_0__.NODES_STATE.paintRafId,
1827
+ eventBindingFunctions = _consts__WEBPACK_IMPORTED_MODULE_0__.NODES_STATE.eventBindingFunctions,
1828
+ eventBindRafId = _consts__WEBPACK_IMPORTED_MODULE_0__.NODES_STATE.eventBindRafId,
1829
+ conditionalRenderRafId = _consts__WEBPACK_IMPORTED_MODULE_0__.NODES_STATE.conditionalRenderRafId,
1830
+ conditionalRenders = _consts__WEBPACK_IMPORTED_MODULE_0__.NODES_STATE.conditionalRenders;
1831
+ function queueBindEvents(element, bindFunction) {
1832
+ if (eventBindRafId) cancelAnimationFrame(eventBindRafId);
1833
+ eventBindingFunctions.set(element, bindFunction);
1834
+ eventBindRafId = requestAnimationFrame(function () {
1835
+ eventBindRafId = null;
1836
+ eventBindingFunctions.forEach(function (bindFn) {
1837
+ return bindFn();
1838
+ });
1839
+ eventBindingFunctions = new Map();
1840
+ });
1841
+ }
1842
+ function queuePaint() {
1843
+ if (paintRafId) cancelAnimationFrame(paintRafId);
1844
+ paintRafId = requestAnimationFrame(function () {
1845
+ paintRafId = null;
1846
+ (0,_node_actions__WEBPACK_IMPORTED_MODULE_1__.doUpdateDOM)();
1847
+ });
1848
+ }
1849
+ function queueConditionalRender(element, renderFunction) {
1850
+ if (conditionalRenderRafId) cancelAnimationFrame(conditionalRenderRafId);
1851
+ conditionalRenders.set(element, renderFunction);
1852
+ conditionalRenderRafId = requestAnimationFrame(function () {
1853
+ conditionalRenderRafId = null;
1854
+ conditionalRenders.forEach(function (renderFn) {
1855
+ return renderFn();
1856
+ });
1857
+ conditionalRenders = new Map();
1858
+ });
1859
+ }
1860
+
1861
+ /***/ }),
1862
+
1863
+ /***/ "./src/core/prop_utils.js":
1864
+ /*!********************************!*\
1865
+ !*** ./src/core/prop_utils.js ***!
1866
+ \********************************/
1867
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1868
+
1869
+ __webpack_require__.r(__webpack_exports__);
1870
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1871
+ /* harmony export */ setHiddenProperty: () => (/* binding */ setHiddenProperty)
1872
+ /* harmony export */ });
1873
+ // Sets an internal read-only "hidden" property on an object:
1874
+ function setHiddenProperty(obj, propName, propValue) {
1875
+ var enumerable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
1876
+ Object.defineProperty(obj, propName, {
1877
+ value: propValue,
1878
+ configurable: false,
1879
+ writable: false,
1880
+ enumerable: enumerable
1881
+ });
1882
+ }
1883
+
1884
+ /***/ }),
1885
+
1886
+ /***/ "./src/core/proxy_handlers.js":
1887
+ /*!************************************!*\
1888
+ !*** ./src/core/proxy_handlers.js ***!
1889
+ \************************************/
1890
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1891
+
1892
+ __webpack_require__.r(__webpack_exports__);
1893
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1894
+ /* harmony export */ StateHandler: () => (/* binding */ StateHandler),
1895
+ /* harmony export */ StatefulArrayHandler: () => (/* binding */ StatefulArrayHandler)
1896
+ /* harmony export */ });
1897
+ /* harmony import */ var _StateManager_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./StateManager.js */ "./src/core/StateManager.js");
1898
+ /* harmony import */ var _state_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./state_utils.js */ "./src/core/state_utils.js");
1899
+ /* harmony import */ var _StatefulArray_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./StatefulArray.js */ "./src/core/StatefulArray.js");
1900
+ /* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./consts.js */ "./src/core/consts.js");
1901
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
1902
+
1903
+
1904
+
1905
+
1906
+ var StatefulArrayHandler = function StatefulArrayHandler(parentStateManager, arrayStateProp) {
1907
+ var appScope = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : window;
1908
+ return {
1909
+ set: function set(targetArray, property, value) {
1910
+ // Return if the value is the same
1911
+ // A change in array length triggers state change in the array state prop
1912
+ if (property === "length") {
1913
+ var setResult = Reflect.set(targetArray, property, value);
1914
+ (0,_state_utils_js__WEBPACK_IMPORTED_MODULE_0__.handleStateChange)(parentStateManager, arrayStateProp);
1915
+ return setResult;
1916
+ }
1917
+ if (targetArray[property] === value) return true;
1918
+ var index = Number(property);
1919
+ if (!isNaN(index)) {
1920
+ // Check if the property is a numeric index
1921
+ // If we set it to a new object, convert it to a state object
1922
+ if (_typeof(value) === 'object' && !value.hasOwnProperty('_stateManager') && !value.hasOwnProperty('state')) {
1923
+ value = new _StateManager_js__WEBPACK_IMPORTED_MODULE_1__["default"](value, arrayStateProp, parentStateManager, false, appScope);
1924
+ }
1925
+ // Make sure state values are always state manager values
1926
+ // Sometimes they can be state objects (because of the custom get handler in the Proxy)
1927
+ if (value.hasOwnProperty('_stateManager')) {
1928
+ value = value._stateManager;
1929
+ }
1930
+ // This means the object actions are part of a native array function ('splice' etc.), and that we should NOT
1931
+ // mark $$mapAction on values
1932
+ if (!targetArray.hasOwnProperty('$$operation')) {
1933
+ var doStateChangeHandle = false;
1934
+ if (index < targetArray.length) {
1935
+ doStateChangeHandle = true;
1936
+ }
1937
+ var _setResult = Reflect.set(targetArray, property, value);
1938
+ // Only handle state change if this is a change for an existing array item,
1939
+ // if it's a new item, it will already be handled on the "length" property set
1940
+ // Without this check we will have a redundant state check
1941
+ if (doStateChangeHandle) {
1942
+ (0,_state_utils_js__WEBPACK_IMPORTED_MODULE_0__.handleStateChange)(parentStateManager, arrayStateProp);
1943
+ }
1944
+ return _setResult;
1945
+ }
1946
+ }
1947
+ return Reflect.set(targetArray, property, value);
1948
+ },
1949
+ get: function get(targetArray, property, receiver) {
1950
+ if (_typeof(property) === 'symbol') return Reflect.get.apply(Reflect, arguments);
1951
+ if (property === 'hasOwnProperty') return Reflect.get.apply(Reflect, arguments);
1952
+ var index = Number(property);
1953
+ if (!isNaN(index)) {
1954
+ if (!targetArray[index]) return undefined;
1955
+ if (targetArray[index].hasOwnProperty('state')) return targetArray[index].state;
1956
+ // Could be another array
1957
+ return targetArray[index];
1958
+ }
1959
+
1960
+ /*
1961
+ // If this property is set on the array, it means the get is part of a "dependency check"
1962
+ if (targetArray.hasOwnProperty("_gettingDependenciesFor")) {
1963
+ targetArray.dependencyProps.set(property, targetArray._gettingDependenciesFor);
1964
+ delete targetArray._gettingDependenciesFor;
1965
+ }
1966
+ */
1967
+
1968
+ return Reflect.get.apply(Reflect, arguments);
1969
+ }
1970
+ };
1971
+ };
1972
+ var StateHandler = function StateHandler(stateObj) {
1973
+ var appScope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window;
1974
+ return {
1975
+ defineProperty: function defineProperty(targetState, stateProp, descriptor) {
1976
+ var _targetState;
1977
+ if (_consts_js__WEBPACK_IMPORTED_MODULE_2__.BUILT_IN_STATE_PROPS.includes(stateProp) || (_targetState = targetState) !== null && _targetState !== void 0 && _targetState._binding) {
1978
+ return Reflect.defineProperty.apply(Reflect, arguments);
1979
+ }
1980
+ var origTargetState = targetState;
1981
+ var dependencies = new Set();
1982
+ // Will be the actual prop name if this is a state hook setter
1983
+ var setStateProp;
1984
+ targetState = new Proxy(targetState, {
1985
+ get: function get(target, property, receiver) {
1986
+ if (property === "_global") {
1987
+ target._global._gettingDependenciesFor = stateProp;
1988
+ target._global._localStateManager = target._stateManager;
1989
+ }
1990
+ if (_consts_js__WEBPACK_IMPORTED_MODULE_2__.BUILT_IN_STATE_PROPS.includes(property)) {
1991
+ return Reflect.get.apply(Reflect, arguments);
1992
+ }
1993
+ if (Array.isArray(target[property])) {
1994
+ target[property]._gettingDependenciesFor = stateProp;
1995
+ }
1996
+ dependencies.add(property);
1997
+ return Reflect.get.apply(Reflect, arguments);
1998
+ }
1999
+ });
2000
+ if (typeof (descriptor === null || descriptor === void 0 ? void 0 : descriptor.value) !== "undefined") {
2001
+ var value = descriptor.value;
2002
+ // Could already be a StatefulArray (needs to find better way to detect this)
2003
+ if (Array.isArray(value)) {
2004
+ var _value$;
2005
+ // Setter Hook
2006
+ if (stateProp.indexOf('set_') === 0) {
2007
+ var deps = value === null || value === void 0 ? void 0 : value[1];
2008
+ if (!deps) throw Error(_consts_js__WEBPACK_IMPORTED_MODULE_2__.ERROR_MESSAGES.NO_DEPENDENCIES_ARRAY_IN_SET_HOOK(stateProp));
2009
+ // Second item should be an array of dependencies
2010
+ value === null || value === void 0 || value[1].forEach(function (depProp) {
2011
+ dependencies.add(depProp);
2012
+ });
2013
+ // Third item can be a boolean stating if to run the setter on initialization
2014
+ if ((value === null || value === void 0 ? void 0 : value[2]) === true) {
2015
+ setStateProp = stateProp.substring(4);
2016
+ var func = value === null || value === void 0 ? void 0 : value[0];
2017
+ if (func && typeof func === "function") {
2018
+ stateObj[setStateProp] = func.call(stateObj);
2019
+ }
2020
+ } else {
2021
+ if (value !== null && value !== void 0 && value[3]) {
2022
+ stateObj[setStateProp] = value[3];
2023
+ }
2024
+ }
2025
+ } else if (!(value !== null && value !== void 0 && (_value$ = value[0]) !== null && _value$ !== void 0 && _value$._stateManager)) {
2026
+ descriptor.value = new _StatefulArray_js__WEBPACK_IMPORTED_MODULE_3__["default"](descriptor.value, stateObj, stateProp, false, appScope);
2027
+ }
2028
+ }
2029
+ } else if (typeof (descriptor === null || descriptor === void 0 ? void 0 : descriptor.get) === "function") {
2030
+ descriptor.get.call(targetState);
2031
+ }
2032
+ if (dependencies.size) {
2033
+ dependencies.forEach(function (dep) {
2034
+ return stateObj._stateManager.addStateDependency(dep, stateProp);
2035
+ });
2036
+ }
2037
+
2038
+ // Don't use "arguments" here - they are not linked to argument changes in 'strict'
2039
+ var definePropertyResult = Reflect.defineProperty(origTargetState, stateProp, descriptor);
2040
+ var stateManager = stateObj._stateManager;
2041
+ if (setStateProp) stateProp = setStateProp;
2042
+ if (!origTargetState.hasOwnProperty("_populate")) (0,_state_utils_js__WEBPACK_IMPORTED_MODULE_0__.handleStateChange)(stateManager, stateProp);
2043
+ return definePropertyResult;
2044
+ },
2045
+ get: function get(targetState, property, receiver) {
2046
+ if (property === 'hasOwnProperty') return Reflect.get.apply(Reflect, arguments);
2047
+ // Global state access
2048
+ if (!targetState.hasOwnProperty('_global')) {
2049
+ if (targetState.hasOwnProperty("_gettingDependenciesFor")) {
2050
+ targetState._stateManager.addGlobalStateDependency(property, targetState._gettingDependenciesFor, targetState._localStateManager);
2051
+ delete targetState._gettingDependenciesFor;
2052
+ delete targetState._localStateManager;
2053
+ return Reflect.get.apply(Reflect, arguments);
2054
+ }
2055
+ }
2056
+ // property can be a Symbol on rare occasions, then indexOf will be undefined (that's the reason for the question mark)
2057
+ // This handles using the negate operator on state properties
2058
+ if (typeof (property === null || property === void 0 ? void 0 : property.indexOf) === 'function' && (property === null || property === void 0 ? void 0 : property.indexOf('!')) === 0) {
2059
+ var originalProperty = property.substring(1);
2060
+ if (targetState.hasOwnProperty(originalProperty)) {
2061
+ return !targetState[originalProperty];
2062
+ }
2063
+ }
2064
+ return Reflect.get.apply(Reflect, arguments);
2065
+ }
2066
+ };
2067
+ };
2068
+
2069
+ /***/ }),
2070
+
2071
+ /***/ "./src/core/state_utils.js":
2072
+ /*!*********************************!*\
2073
+ !*** ./src/core/state_utils.js ***!
2074
+ \*********************************/
2075
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2076
+
2077
+ __webpack_require__.r(__webpack_exports__);
2078
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2079
+ /* harmony export */ handleStateChange: () => (/* binding */ handleStateChange),
2080
+ /* harmony export */ mapStateArrayToElements: () => (/* binding */ mapStateArrayToElements),
2081
+ /* harmony export */ populateStateFromInitialState: () => (/* binding */ populateStateFromInitialState),
2082
+ /* harmony export */ setAttribute: () => (/* binding */ setAttribute),
2083
+ /* harmony export */ setStateAttribute: () => (/* binding */ setStateAttribute),
2084
+ /* harmony export */ setStateText: () => (/* binding */ setStateText),
2085
+ /* harmony export */ stateToElement: () => (/* binding */ stateToElement)
2086
+ /* harmony export */ });
2087
+ /* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts.js */ "./src/core/consts.js");
2088
+ /* harmony import */ var _node_actions_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./node_actions.js */ "./src/core/node_actions.js");
2089
+ /* harmony import */ var _prop_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./prop_utils.js */ "./src/core/prop_utils.js");
2090
+ /* harmony import */ var _paint_utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./paint_utils.js */ "./src/core/paint_utils.js");
2091
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2092
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2093
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
2094
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
2095
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
2096
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
2097
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
2098
+
2099
+
2100
+
2101
+
2102
+
2103
+ var nodeActionsMap = _consts_js__WEBPACK_IMPORTED_MODULE_0__.NODES_STATE.nodeActionsMap;
2104
+ if (typeof HTMLElement === 'undefined') {
2105
+ console.warn("HTMLElement was not found! This probably means you are running in a non-browser environment, and can lead to unexpected results");
2106
+ } else {
2107
+ // Make sure "setAttribute" is not overridable
2108
+ Object.defineProperty(globalThis, "elementSetAttribute", {
2109
+ value: HTMLElement.prototype.setAttribute,
2110
+ writable: false,
2111
+ configurable: false
2112
+ });
2113
+ }
2114
+ var setAttribute = function setAttribute(attrName, attrValue) {
2115
+ if (_consts_js__WEBPACK_IMPORTED_MODULE_0__.BOOLEAN_ATTRIBUTES.includes(attrName)) {
2116
+ if (attrValue === "false") {
2117
+ this.removeAttribute(attrName);
2118
+ } else {
2119
+ elementSetAttribute.call(this, attrName, "");
2120
+ }
2121
+ } else {
2122
+ elementSetAttribute.call(this, attrName, attrValue);
2123
+ }
2124
+ };
2125
+
2126
+ // This creates the binding to state props on "State attributes".
2127
+ // This function is called when a custom element instance ic connected to the DOM
2128
+ var setStateAttribute = function setStateAttribute(attrName, stateProp) {
2129
+ var equalityValue = null;
2130
+ if (stateProp.indexOf(':') !== -1) {
2131
+ if (stateProp.indexOf('is_') === 0) {
2132
+ var colonIndex = stateProp.indexOf(':');
2133
+ if (colonIndex === -1) {
2134
+ throw Error("When using conditional equality state attribute, you must include a colon character followed by an equality value!");
2135
+ }
2136
+ equalityValue = stateProp.substring(colonIndex + 1);
2137
+ stateProp = stateProp.substring(3, colonIndex);
2138
+ }
2139
+ }
2140
+ var _this$getState = this.getState(stateProp, true),
2141
+ _this$getState2 = _slicedToArray(_this$getState, 2),
2142
+ stateVal = _this$getState2[0],
2143
+ theState = _this$getState2[1];
2144
+ if (stateVal === undefined) {
2145
+ console.warn("State value for ".concat(stateProp, " is undefined. State values should never be undefined."));
2146
+ return;
2147
+ }
2148
+ if (!theState) {
2149
+ console.warn("No State object with state prop: " + stateProp);
2150
+ return;
2151
+ }
2152
+ if (equalityValue) {
2153
+ var conditionalStateProp = "is_" + stateProp + equalityValue;
2154
+ var originalStateProp = stateProp;
2155
+ Object.defineProperty(theState, conditionalStateProp, {
2156
+ get: function get() {
2157
+ return this[originalStateProp] === equalityValue;
2158
+ },
2159
+ enumerable: false
2160
+ });
2161
+ theState._stateManager.addStateDependency(stateProp, conditionalStateProp);
2162
+ stateVal = theState[conditionalStateProp];
2163
+ stateProp = conditionalStateProp;
2164
+ }
2165
+ var valueToSet = stateVal;
2166
+ this.removeAttribute(attrName);
2167
+ // Create an "Attribute Node"
2168
+ var stateAttrNode = document.createAttribute(attrName);
2169
+ stateAttrNode.nodeValue = valueToSet;
2170
+ // Saves a readonly boolean that marks this as a "state attribute node"
2171
+ (0,_prop_utils_js__WEBPACK_IMPORTED_MODULE_1__.setHiddenProperty)(stateAttrNode, "isStateAttribute", true);
2172
+ // Save ownerElement to a different property,
2173
+ // so if the attribute is removed (in case of a boolean attribute),
2174
+ // and later re-attached, we would know which element to add it back to.
2175
+ (0,_prop_utils_js__WEBPACK_IMPORTED_MODULE_1__.setHiddenProperty)(stateAttrNode, "originalOwnerElement", this);
2176
+ /*
2177
+ Object.defineProperty(stateAttrNode, "stateValue", {
2178
+ value: valueToSet,
2179
+ writeable: true,
2180
+ configurable: false,
2181
+ enumerable: true
2182
+ });
2183
+ */
2184
+ if (typeof valueToSet === "boolean") {
2185
+ // A boolean attribute value should ALWAYS be an empty string,
2186
+ // the value itself never changes, it is removed fron the element if false,
2187
+ // and added if true
2188
+ stateAttrNode.nodeValue = "";
2189
+ }
2190
+
2191
+ // Adds the attribute to the element
2192
+ if (valueToSet !== false) {
2193
+ this.setAttributeNode(stateAttrNode);
2194
+ }
2195
+ theState._stateManager.addStateNode(stateProp, stateAttrNode, typeof valueToSet === "boolean");
2196
+ };
2197
+ var setStateText = function setStateText(stateProp) {
2198
+ var _this$getState3 = this.getState(stateProp, true),
2199
+ _this$getState4 = _slicedToArray(_this$getState3, 2),
2200
+ stateVal = _this$getState4[0],
2201
+ theState = _this$getState4[1];
2202
+ if (stateVal === undefined || stateVal === null) {
2203
+ console.warn("State value for ".concat(stateProp, " is undefined or null for _text command"));
2204
+ return;
2205
+ }
2206
+ if (!theState) {
2207
+ console.warn("No State object with state prop: " + stateProp);
2208
+ return;
2209
+ }
2210
+ var valueToSet = stateVal;
2211
+ var textNode = document.createTextNode(valueToSet);
2212
+ (0,_prop_utils_js__WEBPACK_IMPORTED_MODULE_1__.setHiddenProperty)(textNode, "isStateAttribute", true);
2213
+ this.appendChild(textNode);
2214
+ theState._stateManager.addStateNode(stateProp, textNode);
2215
+ };
2216
+
2217
+ // Convert a stateObject to a custom element, used in State Map Arrays
2218
+ function stateToElement(stateObject, elemName, wrapInElement) {
2219
+ var customElementInstance = document.createElement(elemName);
2220
+ customElementInstance.setInitialState(stateObject);
2221
+ var returnElement;
2222
+ if (wrapInElement) {
2223
+ returnElement = document.createElement(wrapInElement);
2224
+ returnElement.appendChild(customElementInstance);
2225
+ } else {
2226
+ returnElement = customElementInstance;
2227
+ }
2228
+ return returnElement;
2229
+ }
2230
+ function mapStateArrayToElements(stateItems, elemName, wrapInElement) {
2231
+ // Each state item should be a stateManager
2232
+ return stateItems.map(function (stateItem) {
2233
+ if (stateItem.hasOwnProperty('state')) stateItem = stateItem.state;
2234
+ if (_typeof(stateItem) !== 'object') {
2235
+ console.warn("item in State array for _map is not an object: ", stateItem);
2236
+ return {};
2237
+ }
2238
+ return stateToElement(stateItem, elemName, wrapInElement);
2239
+ });
2240
+ }
2241
+
2242
+ // Main function that handles all state changes in a state object
2243
+ function handleStateChange(stateManager, stateProp) {
2244
+ if (_consts_js__WEBPACK_IMPORTED_MODULE_0__.BUILT_IN_STATE_PROPS.includes(stateProp)) return;
2245
+ // Populate the next Node Actions to perform
2246
+ (0,_node_actions_js__WEBPACK_IMPORTED_MODULE_2__.generateStateNodeActions)(stateManager, stateProp);
2247
+ var state = stateManager.state;
2248
+
2249
+ // Run on[stateProp]Change hooks
2250
+ if (state.hasOwnProperty("on_".concat(stateProp, "Change"))) {
2251
+ if (typeof state["on_".concat(stateProp, "Change")] === "function") state["on_".concat(stateProp, "Change")].call(state);
2252
+ }
2253
+ var stateDependencies = stateManager.stateDependencies[stateProp];
2254
+ if (stateDependencies) {
2255
+ stateDependencies.forEach(function (depStateProp) {
2256
+ // A "Setter" hook
2257
+ if (depStateProp.indexOf('set_') === 0) {
2258
+ var setStateProp = depStateProp.substring(4);
2259
+ var func = state[depStateProp][0];
2260
+ if (func && typeof func === "function") {
2261
+ state[setStateProp] = func.call(state);
2262
+ return;
2263
+ }
2264
+ }
2265
+ (0,_node_actions_js__WEBPACK_IMPORTED_MODULE_2__.generateStateNodeActions)(stateManager, depStateProp);
2266
+ if (state.hasOwnProperty("on".concat(depStateProp, "Change"))) {
2267
+ if (typeof state["on".concat(depStateProp, "Change")] === "function") state["on".concat(depStateProp, "Change")].call(state);
2268
+ }
2269
+ });
2270
+ }
2271
+
2272
+ // Global state
2273
+ if (!state._global) {
2274
+ var globalStateDependencies = stateManager.globalStateDependencies[stateProp];
2275
+ globalStateDependencies === null || globalStateDependencies === void 0 || globalStateDependencies.forEach(function (depStateProps, depStateManager) {
2276
+ var depState = depStateManager.state;
2277
+ depStateProps.forEach(function (depStateProp) {
2278
+ // A "Setter" hook
2279
+ if (depStateProp.indexOf('set_') === 0) {
2280
+ var setStateProp = depStateProp.substring(4);
2281
+ var func = state[depStateProp][0];
2282
+ if (func && typeof func === "function") {
2283
+ depState[setStateProp] = func.call(depState);
2284
+ return;
2285
+ }
2286
+ }
2287
+ (0,_node_actions_js__WEBPACK_IMPORTED_MODULE_2__.generateStateNodeActions)(depStateManager, depStateProp);
2288
+ if (state.hasOwnProperty("on".concat(depStateProp, "Change"))) {
2289
+ if (typeof state["on".concat(depStateProp, "Change")] === "function") depState["on".concat(depStateProp, "Change")].call(depState);
2290
+ }
2291
+ });
2292
+ });
2293
+ }
2294
+ if (nodeActionsMap.size) {
2295
+ (0,_paint_utils_js__WEBPACK_IMPORTED_MODULE_3__.queuePaint)();
2296
+ }
2297
+ }
2298
+ function populateStateFromInitialState(state, initialState) {
2299
+ state._populate = true;
2300
+ var descriptors = Object.getOwnPropertyDescriptors(initialState);
2301
+ var descrp;
2302
+ for (var key in descriptors) {
2303
+ if (_consts_js__WEBPACK_IMPORTED_MODULE_0__.BUILT_IN_STATE_PROPS.includes(key)) {
2304
+ delete descriptors[key];
2305
+ continue;
2306
+ }
2307
+ descrp = descriptors[key];
2308
+ if (descrp.hasOwnProperty('get') && typeof descrp.get === "function") {
2309
+ descrp.get.bind(state);
2310
+ }
2311
+ if (descrp.hasOwnProperty('value')) {
2312
+ var value = descrp.value;
2313
+ if (typeof value === "function") {
2314
+ descrp.value.bind(state);
2315
+ } else if (Array.isArray(value) && key.indexOf("set_") === 0) {
2316
+ var func = value === null || value === void 0 ? void 0 : value[0];
2317
+ if (func && typeof func === "function") {
2318
+ func.bind(state);
2319
+ }
2320
+ }
2321
+ }
2322
+ }
2323
+
2324
+ // If state set hooks should run on initialization -
2325
+ // they should run by the proxy handler for "defineProperty"
2326
+ Object.defineProperties(state, descriptors);
2327
+ delete state._populate;
2328
+ }
2329
+
2330
+ /***/ })
2331
+
2332
+ /******/ });
2333
+ /************************************************************************/
2334
+ /******/ // The module cache
2335
+ /******/ var __webpack_module_cache__ = {};
2336
+ /******/
2337
+ /******/ // The require function
2338
+ /******/ function __webpack_require__(moduleId) {
2339
+ /******/ // Check if module is in cache
2340
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
2341
+ /******/ if (cachedModule !== undefined) {
2342
+ /******/ return cachedModule.exports;
2343
+ /******/ }
2344
+ /******/ // Create a new module (and put it into the cache)
2345
+ /******/ var module = __webpack_module_cache__[moduleId] = {
2346
+ /******/ // no module.id needed
2347
+ /******/ // no module.loaded needed
2348
+ /******/ exports: {}
2349
+ /******/ };
2350
+ /******/
2351
+ /******/ // Execute the module function
2352
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
2353
+ /******/
2354
+ /******/ // Return the exports of the module
2355
+ /******/ return module.exports;
2356
+ /******/ }
2357
+ /******/
2358
+ /************************************************************************/
2359
+ /******/ /* webpack/runtime/define property getters */
2360
+ /******/ (() => {
2361
+ /******/ // define getter functions for harmony exports
2362
+ /******/ __webpack_require__.d = (exports, definition) => {
2363
+ /******/ for(var key in definition) {
2364
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
2365
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
2366
+ /******/ }
2367
+ /******/ }
2368
+ /******/ };
2369
+ /******/ })();
2370
+ /******/
2371
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
2372
+ /******/ (() => {
2373
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
2374
+ /******/ })();
2375
+ /******/
2376
+ /******/ /* webpack/runtime/make namespace object */
2377
+ /******/ (() => {
2378
+ /******/ // define __esModule on exports
2379
+ /******/ __webpack_require__.r = (exports) => {
2380
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
2381
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2382
+ /******/ }
2383
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
2384
+ /******/ };
2385
+ /******/ })();
2386
+ /******/
2387
+ /************************************************************************/
2388
+ var __webpack_exports__ = {};
2389
+ /*!***************************!*\
2390
+ !*** ./src/core/index.js ***!
2391
+ \***************************/
2392
+ __webpack_require__.r(__webpack_exports__);
2393
+ /* harmony import */ var _ReactiveElement_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ReactiveElement.js */ "./src/core/ReactiveElement.js");
2394
+ /* harmony import */ var _StateManager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./StateManager.js */ "./src/core/StateManager.js");
2395
+ /* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts.js */ "./src/core/consts.js");
2396
+ /* harmony import */ var _build__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../build */ "./src/build/index.js");
2397
+ /* harmony import */ var _prop_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./prop_utils.js */ "./src/core/prop_utils.js");
2398
+ /* harmony import */ var _ReactiveSlot_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ReactiveSlot.js */ "./src/core/ReactiveSlot.js");
2399
+
2400
+
2401
+
2402
+
2403
+
2404
+
2405
+
2406
+
2407
+
2408
+ var allowAppScopeAccess = document.currentScript.hasAttribute("allowappscopeaccess");
2409
+ globalThis.SproutInitApp = function (appName) {
2410
+ var appScope = function () {
2411
+ var _window;
2412
+ return {
2413
+ window: window,
2414
+ document: (_window = window) === null || _window === void 0 ? void 0 : _window.document
2415
+ };
2416
+ }(window);
2417
+ var config = {
2418
+ useShadow: true,
2419
+ // Always use shadow DOM for now, may add configurability later
2420
+ allowAppScopeAccess: allowAppScopeAccess
2421
+ };
2422
+ if (config.allowAppScopeAccess) {
2423
+ Object.defineProperty(globalThis, "sproutApps", {
2424
+ value: {},
2425
+ writable: false
2426
+ });
2427
+ Object.defineProperty(globalThis.sproutApps, appName, {
2428
+ value: appScope,
2429
+ writable: false
2430
+ });
2431
+ }
2432
+ appScope.SPROUT_CONFIG = Object.seal(config);
2433
+
2434
+ // Prevent "hasOwnProperty" shenanigans
2435
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
2436
+ (0,_prop_utils_js__WEBPACK_IMPORTED_MODULE_0__.setHiddenProperty)(Object.prototype, "hasOwnProperty", hasOwnProperty);
2437
+ appScope[_consts_js__WEBPACK_IMPORTED_MODULE_1__.GLOBAL_STATE_FUNCTION_NAME] = function () {
2438
+ return {};
2439
+ };
2440
+ // If initialState is passed - also sets it to global state
2441
+ appScope.setGlobalState = function () {
2442
+ var initialState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2443
+ var globalState = new _StateManager_js__WEBPACK_IMPORTED_MODULE_2__["default"](initialState, undefined, undefined, true, appScope).state;
2444
+ var globalStateVarName = _consts_js__WEBPACK_IMPORTED_MODULE_1__.GLOBAL_STATE_VAR_NAME;
2445
+ Object.defineProperty(appScope, globalStateVarName, {
2446
+ value: globalState,
2447
+ writable: _consts_js__WEBPACK_IMPORTED_MODULE_1__.DEBUG_MODE ? true : false,
2448
+ configurable: false
2449
+ });
2450
+ Object.defineProperty(appScope, _consts_js__WEBPACK_IMPORTED_MODULE_1__.GLOBAL_STATE_FUNCTION_NAME, {
2451
+ value: function value() {
2452
+ return appScope[globalStateVarName];
2453
+ }
2454
+ });
2455
+ };
2456
+ appScope.ReactiveElement = (0,_ReactiveElement_js__WEBPACK_IMPORTED_MODULE_3__.extendElementClassWithReactiveElementClass)(HTMLElement, appScope);
2457
+
2458
+ // Extend specific HTMLElement classes to enable reactivity (use it by adding an "is" attribute to an element)
2459
+ _consts_js__WEBPACK_IMPORTED_MODULE_1__.HTML_ELEMENTS_CLASSES_MAP.forEach(function (itemDefinition) {
2460
+ return customElements.define("reactive-".concat(itemDefinition.element), (0,_ReactiveElement_js__WEBPACK_IMPORTED_MODULE_3__.extendElementClassWithReactiveElementClass)(itemDefinition["class"], appScope, true), {
2461
+ "extends": itemDefinition.element
2462
+ });
2463
+ });
2464
+ var ReactiveSlotElementClass = (0,_ReactiveElement_js__WEBPACK_IMPORTED_MODULE_3__.extendElementClassWithReactiveElementClass)(HTMLSlotElement, appScope, true);
2465
+ var ReactiveSlotClass = (0,_ReactiveSlot_js__WEBPACK_IMPORTED_MODULE_4__.getReactiveSlotClass)(ReactiveSlotElementClass);
2466
+ customElements.define('reactive-slot', ReactiveSlotClass, {
2467
+ "extends": "slot"
2468
+ });
2469
+ return function () {
2470
+ (0,_build__WEBPACK_IMPORTED_MODULE_5__["default"])(appScope, appName);
2471
+ }.bind(appScope);
2472
+ };
2473
+ /******/ })()
2474
+ ;
2475
+ //# sourceMappingURL=sprout-core.js.map