@tko/builder 4.0.0-beta1.5 → 4.0.0

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/dist/index.cjs CHANGED
@@ -1,9 +1,14 @@
1
+ // @tko/builder 🥊 4.0.0 CommonJS
1
2
  "use strict";
2
- // @tko/builder 🥊 4.0.0-beta1.5 CommonJS
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
8
+ var __typeError = (msg) => {
9
+ throw TypeError(msg);
10
+ };
11
+ var __pow = Math.pow;
7
12
  var __export = (target, all) => {
8
13
  for (var name in all)
9
14
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -17,19 +22,75 @@ var __copyProps = (to, from, except, desc) => {
17
22
  return to;
18
23
  };
19
24
  var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
25
+ var __accessCheck = (obj, member2, msg) => member2.has(obj) || __typeError("Cannot " + msg);
26
+ var __privateGet = (obj, member2, getter) => (__accessCheck(obj, member2, "read from private field"), getter ? getter.call(obj) : member2.get(obj));
27
+ var __privateAdd = (obj, member2, value) => member2.has(obj) ? __typeError("Cannot add the same private member more than once") : member2 instanceof WeakSet ? member2.add(obj) : member2.set(obj, value);
28
+ var __privateSet = (obj, member2, value, setter) => (__accessCheck(obj, member2, "write to private field"), setter ? setter.call(obj, value) : member2.set(obj, value), value);
29
+ var __async = (__this, __arguments, generator) => {
30
+ return new Promise((resolve, reject) => {
31
+ var fulfilled = (value) => {
32
+ try {
33
+ step(generator.next(value));
34
+ } catch (e) {
35
+ reject(e);
36
+ }
37
+ };
38
+ var rejected = (value) => {
39
+ try {
40
+ step(generator.throw(value));
41
+ } catch (e) {
42
+ reject(e);
43
+ }
44
+ };
45
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
46
+ step((generator = generator.apply(__this, __arguments)).next());
47
+ });
48
+ };
49
+ var __await = function(promise, isYieldStar) {
50
+ this[0] = promise;
51
+ this[1] = isYieldStar;
52
+ };
53
+ var __yieldStar = (value) => {
54
+ var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {};
55
+ if (obj == null) {
56
+ obj = value[__knownSymbol("iterator")]();
57
+ method = (k) => it[k] = (x) => obj[k](x);
58
+ } else {
59
+ obj = obj.call(value);
60
+ method = (k) => it[k] = (v) => {
61
+ if (isAwait) {
62
+ isAwait = false;
63
+ if (k === "throw") throw v;
64
+ return v;
65
+ }
66
+ isAwait = true;
67
+ return {
68
+ done: false,
69
+ value: new __await(new Promise((resolve) => {
70
+ var x = obj[k](v);
71
+ if (!(x instanceof Object)) __typeError("Object expected");
72
+ resolve(x);
73
+ }), 1)
74
+ };
75
+ };
76
+ }
77
+ return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => {
78
+ throw x;
79
+ }, "return" in obj && method("return"), it;
80
+ };
20
81
 
21
82
  // index.ts
22
- var builder_exports = {};
23
- __export(builder_exports, {
83
+ var index_exports = {};
84
+ __export(index_exports, {
24
85
  Builder: () => Builder
25
86
  });
26
- module.exports = __toCommonJS(builder_exports);
87
+ module.exports = __toCommonJS(index_exports);
27
88
 
28
89
  // ../utils/dist/array.js
29
90
  var { isArray } = Array;
30
- function arrayForEach(array, action, thisArg) {
91
+ function arrayForEach(array, action, actionOwner) {
31
92
  if (arguments.length > 2) {
32
- action = action.bind(thisArg);
93
+ action = action.bind(actionOwner);
33
94
  }
34
95
  for (let i = 0, j = array.length; i < j; ++i) {
35
96
  action(array[i], i, array);
@@ -41,30 +102,30 @@ function arrayIndexOf(array, item) {
41
102
  function arrayFirst(array, predicate, predicateOwner) {
42
103
  return (isArray(array) ? array : [...array]).find(predicate, predicateOwner);
43
104
  }
44
- function arrayMap(array = [], mapping, thisArg) {
105
+ function arrayMap(array, mapping, thisArg) {
45
106
  if (arguments.length > 2) {
46
107
  mapping = mapping.bind(thisArg);
47
108
  }
48
109
  return array === null ? [] : Array.from(array, mapping);
49
110
  }
50
111
  function arrayRemoveItem(array, itemToRemove) {
51
- var index = arrayIndexOf(array, itemToRemove);
112
+ const index = arrayIndexOf(array, itemToRemove);
52
113
  if (index > 0) {
53
114
  array.splice(index, 1);
54
115
  } else if (index === 0) {
55
116
  array.shift();
56
117
  }
57
118
  }
58
- function arrayGetDistinctValues(array = []) {
119
+ function arrayGetDistinctValues(array) {
59
120
  const seen = /* @__PURE__ */ new Set();
60
121
  if (array === null) {
61
122
  return [];
62
123
  }
63
124
  return (isArray(array) ? array : [...array]).filter((item) => seen.has(item) ? false : seen.add(item));
64
125
  }
65
- function arrayFilter(array, predicate, thisArg) {
126
+ function arrayFilter(array, predicate, predicateOwner) {
66
127
  if (arguments.length > 2) {
67
- predicate = predicate.bind(thisArg);
128
+ predicate = predicate.bind(predicateOwner);
68
129
  }
69
130
  return array === null ? [] : (isArray(array) ? array : [...array]).filter(predicate);
70
131
  }
@@ -72,14 +133,14 @@ function arrayPushAll(array, valuesToPush) {
72
133
  if (isArray(valuesToPush)) {
73
134
  array.push.apply(array, valuesToPush);
74
135
  } else {
75
- for (var i = 0, j = valuesToPush.length; i < j; i++) {
136
+ for (let i = 0, j = valuesToPush.length; i < j; i++) {
76
137
  array.push(valuesToPush[i]);
77
138
  }
78
139
  }
79
140
  return array;
80
141
  }
81
142
  function addOrRemoveItem(array, value, included) {
82
- var existingEntryIndex = arrayIndexOf(typeof array.peek === "function" ? array.peek() : array, value);
143
+ const existingEntryIndex = arrayIndexOf(typeof array.peek === "function" ? array.peek() : array, value);
83
144
  if (existingEntryIndex < 0) {
84
145
  if (included) {
85
146
  array.push(value);
@@ -94,17 +155,17 @@ function makeArray(arrayLikeObject) {
94
155
  return Array.from(arrayLikeObject);
95
156
  }
96
157
  function range(min, max) {
97
- min = typeof min === "function" ? min() : min;
98
- max = typeof max === "function" ? max() : max;
99
- var result = [];
100
- for (var i = min; i <= max; i++) {
158
+ const minimum = typeof min === "function" ? min() : min;
159
+ const maximum = typeof max === "function" ? max() : max;
160
+ const result = [];
161
+ for (let i = minimum; i <= maximum; i++) {
101
162
  result.push(i);
102
163
  }
103
164
  return result;
104
165
  }
105
166
  function findMovesInArrayComparison(left, right, limitFailedCompares) {
106
167
  if (left.length && right.length) {
107
- var failedCompares, l, r, leftItem, rightItem;
168
+ let failedCompares, l, r, leftItem, rightItem;
108
169
  for (failedCompares = l = 0; (!limitFailedCompares || failedCompares < limitFailedCompares) && (leftItem = left[l]); ++l) {
109
170
  for (r = 0; rightItem = right[r]; ++r) {
110
171
  if (leftItem.value === rightItem.value) {
@@ -132,10 +193,10 @@ function compareArrays(oldArray, newArray, options2) {
132
193
  }
133
194
  }
134
195
  function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusNotInBig, options2) {
135
- var myMin = Math.min, myMax = Math.max, editDistanceMatrix = [], smlIndex, smlIndexMax = smlArray.length, bigIndex, bigIndexMax = bigArray.length, compareRange = bigIndexMax - smlIndexMax || 1, maxDistance = smlIndexMax + bigIndexMax + 1, thisRow, lastRow, bigIndexMaxForRow, bigIndexMinForRow;
196
+ let myMin = Math.min, myMax = Math.max, editDistanceMatrix = new Array(), smlIndex, smlIndexMax = smlArray.length, bigIndex, bigIndexMax = bigArray.length, compareRange = bigIndexMax - smlIndexMax || 1, maxDistance = smlIndexMax + bigIndexMax + 1, thisRow, lastRow, bigIndexMaxForRow, bigIndexMinForRow;
136
197
  for (smlIndex = 0; smlIndex <= smlIndexMax; smlIndex++) {
137
198
  lastRow = thisRow;
138
- editDistanceMatrix.push(thisRow = []);
199
+ editDistanceMatrix.push(thisRow = new Array());
139
200
  bigIndexMaxForRow = myMin(bigIndexMax, smlIndex + compareRange);
140
201
  bigIndexMinForRow = myMax(0, smlIndex - 1);
141
202
  for (bigIndex = bigIndexMinForRow; bigIndex <= bigIndexMaxForRow; bigIndex++) {
@@ -146,35 +207,38 @@ function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusN
146
207
  } else if (smlArray[smlIndex - 1] === bigArray[bigIndex - 1]) {
147
208
  thisRow[bigIndex] = lastRow[bigIndex - 1];
148
209
  } else {
149
- var northDistance = lastRow[bigIndex] || maxDistance;
150
- var westDistance = thisRow[bigIndex - 1] || maxDistance;
210
+ const northDistance = lastRow[bigIndex] || maxDistance;
211
+ const westDistance = thisRow[bigIndex - 1] || maxDistance;
151
212
  thisRow[bigIndex] = myMin(northDistance, westDistance) + 1;
152
213
  }
153
214
  }
154
215
  }
155
- var editScript = [], meMinusOne, notInSml = [], notInBig = [];
216
+ let editScript = new Array(), meMinusOne, notInSml = new Array(), notInBig = new Array();
156
217
  for (smlIndex = smlIndexMax, bigIndex = bigIndexMax; smlIndex || bigIndex; ) {
157
218
  meMinusOne = editDistanceMatrix[smlIndex][bigIndex] - 1;
158
219
  if (bigIndex && meMinusOne === editDistanceMatrix[smlIndex][bigIndex - 1]) {
159
- notInSml.push(editScript[editScript.length] = {
160
- "status": statusNotInSml,
161
- "value": bigArray[--bigIndex],
162
- "index": bigIndex
163
- });
220
+ notInSml.push(
221
+ editScript[editScript.length] = {
222
+ // added
223
+ status: statusNotInSml,
224
+ value: bigArray[--bigIndex],
225
+ index: bigIndex
226
+ }
227
+ );
164
228
  } else if (smlIndex && meMinusOne === editDistanceMatrix[smlIndex - 1][bigIndex]) {
165
- notInBig.push(editScript[editScript.length] = {
166
- "status": statusNotInBig,
167
- "value": smlArray[--smlIndex],
168
- "index": smlIndex
169
- });
229
+ notInBig.push(
230
+ editScript[editScript.length] = {
231
+ // deleted
232
+ status: statusNotInBig,
233
+ value: smlArray[--smlIndex],
234
+ index: smlIndex
235
+ }
236
+ );
170
237
  } else {
171
238
  --bigIndex;
172
239
  --smlIndex;
173
- if (!options2.sparse) {
174
- editScript.push({
175
- "status": "retained",
176
- "value": bigArray[bigIndex]
177
- });
240
+ if (!(options2 == null ? void 0 : options2.sparse)) {
241
+ editScript.push({ status: "retained", value: bigArray[bigIndex] });
178
242
  }
179
243
  }
180
244
  }
@@ -183,40 +247,79 @@ function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusN
183
247
  }
184
248
 
185
249
  // ../utils/dist/options.js
186
- var options = {
187
- deferUpdates: false,
188
- useOnlyNativeEvents: false,
189
- protoProperty: "__ko_proto__",
190
- defaultBindingAttribute: "data-bind",
191
- allowVirtualElements: true,
192
- bindingGlobals: /* @__PURE__ */ Object.create(null),
193
- bindingProviderInstance: null,
194
- createChildContextWithAs: false,
195
- jQuery: globalThis.jQuery,
196
- Promise: globalThis.Promise,
197
- taskScheduler: null,
198
- debug: false,
199
- global: globalThis,
200
- document: globalThis.document,
201
- filters: {},
202
- includeDestroyed: false,
203
- foreachHidesDestroyed: false,
204
- onError: function(e) {
205
- throw e;
206
- },
207
- set: function(name, value) {
208
- options[name] = value;
209
- },
210
- getBindingHandler() {
211
- },
212
- cleanExternalData() {
250
+ var Options = class {
251
+ constructor() {
252
+ this.bindingStringPreparsers = [];
253
+ this.knockoutInstance = null;
254
+ this.deferUpdates = false;
255
+ this.useOnlyNativeEvents = true;
256
+ this.useTemplateTag = true;
257
+ this.protoProperty = "__ko_proto__";
258
+ this.defaultBindingAttribute = "data-bind";
259
+ this.allowVirtualElements = true;
260
+ this.bindingGlobals = /* @__PURE__ */ Object.create(null);
261
+ this.createChildContextWithAs = false;
262
+ this.disableJQueryUsage = false;
263
+ this.Promise = globalThis.Promise;
264
+ this.taskScheduler = null;
265
+ this.debug = false;
266
+ this.templateSizeLimit = 4096;
267
+ this.allowScriptTagsInTemplates = false;
268
+ this._sanitizeWarningLogged = false;
269
+ this.global = globalThis;
270
+ this.document = globalThis.document;
271
+ this.filters = {};
272
+ this.includeDestroyed = false;
273
+ this.foreachHidesDestroyed = false;
274
+ }
275
+ get jQuery() {
276
+ var _a;
277
+ if (this.disableJQueryUsage) return;
278
+ return (_a = this._jQuery) != null ? _a : globalThis.jQuery;
279
+ }
280
+ /**
281
+ * Set jQuery manuall to be used by TKO.
282
+ * @param jQuery If jQuery set to undefined, TKO will not use jQuery and this.disableJQueryUsage to true.
283
+ */
284
+ set jQuery(jQuery) {
285
+ if (!jQuery) {
286
+ this.disableJQueryUsage = true;
287
+ this._jQuery = void 0;
288
+ } else {
289
+ this._jQuery = jQuery;
290
+ this.disableJQueryUsage = false;
291
+ }
292
+ }
293
+ /**
294
+ * Sanitize HTML templates before parsing them. Default is a no-op.
295
+ * Please configure something like DOMPurify or validator.js for your environment.
296
+ * @param html HTML string to be sanitized
297
+ * @returns Sanitized HTML string
298
+ */
299
+ sanitizeHtmlTemplate(html) {
300
+ if (!this._sanitizeWarningLogged) {
301
+ console.warn(
302
+ "WARNING -- You don't have a HTML sanitizer configured. Please configure options.sanitizeHtmlTemplate to avoid XSS vulnerabilities."
303
+ );
304
+ this._sanitizeWarningLogged = true;
305
+ }
306
+ return html;
213
307
  }
214
- };
215
- Object.defineProperty(options, "$", {
216
- get: function() {
217
- return options.jQuery;
308
+ onError(e, throws = true) {
309
+ if (throws) throw e;
310
+ return e;
218
311
  }
219
- });
312
+ set(name, value) {
313
+ this[name] = value;
314
+ }
315
+ // Overload getBindingHandler to have a custom lookup function.
316
+ getBindingHandler(key) {
317
+ return null;
318
+ }
319
+ cleanExternalData(node, callback) {
320
+ }
321
+ };
322
+ var options = new Options();
220
323
  var options_default = options;
221
324
 
222
325
  // ../utils/dist/error.js
@@ -243,7 +346,7 @@ function safeSetTimeout(handler, timeout) {
243
346
 
244
347
  // ../utils/dist/async.js
245
348
  function throttle(callback, timeout) {
246
- var timeoutInstance;
349
+ let timeoutInstance;
247
350
  return function(...args) {
248
351
  if (!timeoutInstance) {
249
352
  timeoutInstance = safeSetTimeout(function() {
@@ -254,25 +357,13 @@ function throttle(callback, timeout) {
254
357
  };
255
358
  }
256
359
  function debounce(callback, timeout) {
257
- var timeoutInstance;
360
+ let timeoutInstance;
258
361
  return function(...args) {
259
362
  clearTimeout(timeoutInstance);
260
363
  timeoutInstance = safeSetTimeout(() => callback(...args), timeout);
261
364
  };
262
365
  }
263
366
 
264
- // ../utils/dist/ie.js
265
- var ieVersion = options_default.document && function() {
266
- var version = 3, div2 = options_default.document.createElement("div"), iElems = div2.getElementsByTagName("i");
267
- while (div2.innerHTML = "<!--[if gt IE " + ++version + "]><i></i><![endif]-->", iElems[0]) {
268
- }
269
- if (!version) {
270
- const userAgent = window.navigator.userAgent;
271
- return ua.match(/MSIE ([^ ]+)/) || ua.match(/rv:([^ )]+)/);
272
- }
273
- return version > 4 ? version : void 0;
274
- }();
275
-
276
367
  // ../utils/dist/object.js
277
368
  function hasOwnProperty(obj, propName) {
278
369
  return Object.prototype.hasOwnProperty.call(obj, propName);
@@ -285,8 +376,9 @@ function isObjectLike(obj) {
285
376
  }
286
377
  function extend(target, source) {
287
378
  if (source) {
288
- for (var prop in source) {
379
+ for (const prop of Object.keys(source)) {
289
380
  if (hasOwnProperty(source, prop)) {
381
+ ;
290
382
  target[prop] = source[prop];
291
383
  }
292
384
  }
@@ -294,7 +386,7 @@ function extend(target, source) {
294
386
  return target;
295
387
  }
296
388
  function objectForEach(obj, action) {
297
- for (var prop in obj) {
389
+ for (const prop in obj) {
298
390
  if (hasOwnProperty(obj, prop)) {
299
391
  action(prop, obj[prop]);
300
392
  }
@@ -307,8 +399,8 @@ function objectMap(source, mapping, thisArg) {
307
399
  if (arguments.length > 2) {
308
400
  mapping = mapping.bind(thisArg);
309
401
  }
310
- var target = {};
311
- for (var prop in source) {
402
+ const target = {};
403
+ for (const prop in source) {
312
404
  if (hasOwnProperty(source, prop)) {
313
405
  target[prop] = mapping(source[prop], prop, source);
314
406
  }
@@ -341,10 +433,7 @@ function parseJson(jsonString) {
341
433
  if (typeof jsonString === "string") {
342
434
  jsonString = stringTrim(jsonString);
343
435
  if (jsonString) {
344
- if (JSON && JSON.parse) {
345
- return JSON.parse(jsonString);
346
- }
347
- return new Function("return " + jsonString)();
436
+ return JSON.parse(jsonString);
348
437
  }
349
438
  }
350
439
  return null;
@@ -359,7 +448,7 @@ function createSymbolOrString(identifier) {
359
448
  // ../utils/dist/css.js
360
449
  var cssClassNameRegex = /\S+/g;
361
450
  function toggleDomNodeCssClass(node, classNames, shouldHaveClass) {
362
- var addOrRemoveFn;
451
+ let addOrRemoveFn;
363
452
  if (!classNames) {
364
453
  return;
365
454
  }
@@ -375,34 +464,32 @@ function toggleDomNodeCssClass(node, classNames, shouldHaveClass) {
375
464
  }
376
465
  }
377
466
  function toggleObjectClassPropertyString(obj, prop, classNames, shouldHaveClass) {
378
- var currentClassNames = obj[prop].match(cssClassNameRegex) || [];
467
+ const currentClassNames = obj[prop].match(cssClassNameRegex) || [];
379
468
  arrayForEach(classNames.match(cssClassNameRegex), function(className) {
380
469
  addOrRemoveItem(currentClassNames, className, shouldHaveClass);
381
470
  });
382
471
  obj[prop] = currentClassNames.join(" ");
383
472
  }
384
473
 
385
- // ../utils/dist/jquery.js
386
- var jQueryInstance = options_default.global && options_default.global.jQuery;
387
-
388
474
  // ../utils/dist/dom/info.js
389
475
  function domNodeIsContainedBy(node, containedByNode) {
390
476
  if (node === containedByNode) {
391
477
  return true;
392
478
  }
393
- if (node.nodeType === 11) {
479
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
394
480
  return false;
395
481
  }
396
482
  if (containedByNode.contains) {
397
- return containedByNode.contains(node.nodeType !== 1 ? node.parentNode : node);
483
+ return containedByNode.contains(node.nodeType !== Node.ELEMENT_NODE ? node.parentNode : node);
398
484
  }
399
485
  if (containedByNode.compareDocumentPosition) {
400
486
  return (containedByNode.compareDocumentPosition(node) & 16) == 16;
401
487
  }
402
- while (node && node != containedByNode) {
403
- node = node.parentNode;
488
+ let parentNode = node;
489
+ while (parentNode && parentNode != containedByNode) {
490
+ parentNode = parentNode.parentNode;
404
491
  }
405
- return !!node;
492
+ return !!parentNode;
406
493
  }
407
494
  function domNodeIsAttachedToDocument(node) {
408
495
  return domNodeIsContainedBy(node, node.ownerDocument.documentElement);
@@ -414,6 +501,88 @@ function tagNameLower(element) {
414
501
  return element && element.tagName && element.tagName.toLowerCase();
415
502
  }
416
503
 
504
+ // ../utils/dist/dom/event.js
505
+ var knownEvents = {};
506
+ var knownEventTypesByEventName = {};
507
+ knownEvents["UIEvents"] = ["keyup", "keydown", "keypress"];
508
+ knownEvents["MouseEvents"] = [
509
+ "click",
510
+ "dblclick",
511
+ "mousedown",
512
+ "mouseup",
513
+ "mousemove",
514
+ "mouseover",
515
+ "mouseout",
516
+ "mouseenter",
517
+ "mouseleave"
518
+ ];
519
+ objectForEach(knownEvents, function(eventType, knownEventsForType) {
520
+ if (knownEventsForType.length) {
521
+ for (let i = 0, j = knownEventsForType.length; i < j; i++) {
522
+ knownEventTypesByEventName[knownEventsForType[i]] = eventType;
523
+ }
524
+ }
525
+ });
526
+ function isClickOnCheckableElement(element, eventType) {
527
+ if (tagNameLower(element) !== "input" || !element.type) return false;
528
+ if (eventType.toLowerCase() != "click") return false;
529
+ const inputType = element.type;
530
+ return inputType == "checkbox" || inputType == "radio";
531
+ }
532
+ function registerEventHandler(element, eventType, handler, eventOptions = false) {
533
+ const wrappedHandler = catchFunctionErrors(handler);
534
+ const mustUseNative = Boolean(eventOptions);
535
+ const jQuery = options_default.jQuery;
536
+ if (!options_default.useOnlyNativeEvents && !mustUseNative && jQuery) {
537
+ jQuery(element).on(eventType, wrappedHandler);
538
+ } else if (typeof element.addEventListener === "function") {
539
+ element.addEventListener(eventType, wrappedHandler, eventOptions);
540
+ } else {
541
+ throw new Error("Browser doesn't support addEventListener");
542
+ }
543
+ }
544
+ function hasClick(element) {
545
+ return typeof element.click === "function";
546
+ }
547
+ function triggerEvent(element, eventType) {
548
+ if (!(element && element.nodeType)) {
549
+ throw new Error("element must be a DOM node when calling triggerEvent");
550
+ }
551
+ const useClickWorkaround = isClickOnCheckableElement(element, eventType);
552
+ if (!options_default.useOnlyNativeEvents && options_default.jQuery && !useClickWorkaround) {
553
+ options_default.jQuery(element).trigger(eventType);
554
+ } else if (typeof document.createEvent === "function") {
555
+ if (typeof element.dispatchEvent === "function") {
556
+ const eventCategory = knownEventTypesByEventName[eventType] || "HTMLEvents";
557
+ const event = document.createEvent(eventCategory);
558
+ event.initEvent(
559
+ eventType,
560
+ true,
561
+ true,
562
+ options_default.global,
563
+ 0,
564
+ 0,
565
+ 0,
566
+ 0,
567
+ 0,
568
+ false,
569
+ false,
570
+ false,
571
+ false,
572
+ 0,
573
+ element
574
+ );
575
+ element.dispatchEvent(event);
576
+ } else {
577
+ throw new Error("The supplied element doesn't support dispatchEvent");
578
+ }
579
+ } else if (useClickWorkaround && hasClick(element)) {
580
+ element.click();
581
+ } else {
582
+ throw new Error("Browser doesn't support triggering events");
583
+ }
584
+ }
585
+
417
586
  // ../utils/dist/dom/data.js
418
587
  var data_exports = {};
419
588
  __export(data_exports, {
@@ -423,64 +592,53 @@ __export(data_exports, {
423
592
  nextKey: () => nextKey,
424
593
  set: () => set
425
594
  });
426
- var datastoreTime = new Date().getTime();
595
+ var datastoreTime = (/* @__PURE__ */ new Date()).getTime();
427
596
  var dataStoreKeyExpandoPropertyName = `__ko__${datastoreTime}`;
428
- var dataStoreSymbol = Symbol("Knockout data");
429
- var dataStore;
597
+ var dataStoreSymbol = /* @__PURE__ */ Symbol("Knockout data");
430
598
  var uniqueId = 0;
431
- var modern = {
432
- getDataForNode(node, createIfNotFound) {
433
- let dataForNode = node[dataStoreSymbol];
434
- if (!dataForNode && createIfNotFound) {
435
- dataForNode = node[dataStoreSymbol] = {};
436
- }
437
- return dataForNode;
438
- },
439
- clear(node) {
440
- if (node[dataStoreSymbol]) {
441
- delete node[dataStoreSymbol];
442
- return true;
443
- }
444
- return false;
599
+ function isSafeKey(key) {
600
+ return key !== "__proto__" && key !== "constructor" && key !== "prototype";
601
+ }
602
+ function getDataForNode(node, createIfNotFound) {
603
+ let dataForNode = node[dataStoreSymbol];
604
+ if (!dataForNode && createIfNotFound) {
605
+ dataForNode = node[dataStoreSymbol] = {};
445
606
  }
446
- };
447
- var IE = {
448
- getDataforNode(node, createIfNotFound) {
449
- let dataStoreKey = node[dataStoreKeyExpandoPropertyName];
450
- const hasExistingDataStore = dataStoreKey && dataStoreKey !== "null" && dataStore[dataStoreKey];
451
- if (!hasExistingDataStore) {
452
- if (!createIfNotFound) {
453
- return void 0;
454
- }
455
- dataStoreKey = node[dataStoreKeyExpandoPropertyName] = "ko" + uniqueId++;
456
- dataStore[dataStoreKey] = {};
457
- }
458
- return dataStore[dataStoreKey];
459
- },
460
- clear(node) {
461
- const dataStoreKey = node[dataStoreKeyExpandoPropertyName];
462
- if (dataStoreKey) {
463
- delete dataStore[dataStoreKey];
464
- node[dataStoreKeyExpandoPropertyName] = null;
465
- return true;
466
- }
467
- return false;
607
+ return dataForNode;
608
+ }
609
+ function clear(node) {
610
+ if (node[dataStoreSymbol]) {
611
+ delete node[dataStoreSymbol];
612
+ return true;
468
613
  }
469
- };
470
- var { getDataForNode, clear } = ieVersion ? IE : modern;
614
+ return false;
615
+ }
471
616
  function nextKey() {
472
617
  return uniqueId++ + dataStoreKeyExpandoPropertyName;
473
618
  }
474
619
  function get(node, key) {
620
+ if (!isSafeKey(key)) throw new Error("Unsafe key for DOM data: " + key);
475
621
  const dataForNode = getDataForNode(node, false);
476
622
  return dataForNode && dataForNode[key];
477
623
  }
478
624
  function set(node, key, value) {
479
- var dataForNode = getDataForNode(node, value !== void 0);
480
- dataForNode && (dataForNode[key] = value);
625
+ if (!isSafeKey(key)) throw new Error("Unsafe key for DOM data: " + key);
626
+ const dataForNode = getDataForNode(
627
+ node,
628
+ value !== void 0
629
+ /* createIfNotFound */
630
+ );
631
+ if (dataForNode) {
632
+ dataForNode[key] = value;
633
+ }
481
634
  }
482
635
  function getOrSet(node, key, value) {
483
- const dataForNode = getDataForNode(node, true);
636
+ if (!isSafeKey(key)) throw new Error("Unsafe key for DOM data: " + key);
637
+ const dataForNode = getDataForNode(
638
+ node,
639
+ true
640
+ /* createIfNotFound */
641
+ );
484
642
  return dataForNode[key] || (dataForNode[key] = value);
485
643
  }
486
644
 
@@ -489,9 +647,9 @@ var domDataKey = nextKey();
489
647
  var cleanableNodeTypes = { 1: true, 8: true, 9: true };
490
648
  var cleanableNodeTypesWithDescendants = { 1: true, 9: true };
491
649
  function getDisposeCallbacksCollection(node, createIfNotFound) {
492
- var allDisposeCallbacks = get(node, domDataKey);
650
+ let allDisposeCallbacks = get(node, domDataKey);
493
651
  if (allDisposeCallbacks === void 0 && createIfNotFound) {
494
- allDisposeCallbacks = [];
652
+ allDisposeCallbacks = new Array();
495
653
  set(node, domDataKey, allDisposeCallbacks);
496
654
  }
497
655
  return allDisposeCallbacks;
@@ -500,7 +658,7 @@ function destroyCallbacksCollection(node) {
500
658
  set(node, domDataKey, void 0);
501
659
  }
502
660
  function cleanSingleNode(node) {
503
- var callbacks = getDisposeCallbacksCollection(node, false);
661
+ let callbacks = getDisposeCallbacksCollection(node, false);
504
662
  if (callbacks) {
505
663
  callbacks = callbacks.slice(0);
506
664
  for (let i = 0; i < callbacks.length; i++) {
@@ -515,14 +673,18 @@ function cleanSingleNode(node) {
515
673
  options_default.cleanExternalData(node);
516
674
  }
517
675
  if (cleanableNodeTypesWithDescendants[node.nodeType]) {
518
- cleanNodesInList(node.childNodes, true);
676
+ cleanNodesInList(
677
+ node.childNodes,
678
+ true
679
+ /* onlyComments */
680
+ );
519
681
  }
520
682
  }
521
683
  function cleanNodesInList(nodeList, onlyComments) {
522
- const cleanedNodes = [];
684
+ const cleanedNodes = new Array();
523
685
  let lastCleanedNode;
524
- for (var i = 0; i < nodeList.length; i++) {
525
- if (!onlyComments || nodeList[i].nodeType === 8) {
686
+ for (let i = 0; i < nodeList.length; i++) {
687
+ if (!onlyComments || nodeList[i].nodeType === Node.COMMENT_NODE) {
526
688
  cleanSingleNode(cleanedNodes[cleanedNodes.length] = lastCleanedNode = nodeList[i]);
527
689
  if (nodeList[i] !== lastCleanedNode) {
528
690
  while (i-- && arrayIndexOf(cleanedNodes, nodeList[i]) === -1) {
@@ -538,7 +700,7 @@ function addDisposeCallback(node, callback) {
538
700
  getDisposeCallbacksCollection(node, true).push(callback);
539
701
  }
540
702
  function removeDisposeCallback(node, callback) {
541
- var callbacksCollection = getDisposeCallbacksCollection(node, false);
703
+ const callbacksCollection = getDisposeCallbacksCollection(node, false);
542
704
  if (callbacksCollection) {
543
705
  arrayRemoveItem(callbacksCollection, callback);
544
706
  if (callbacksCollection.length === 0) {
@@ -549,19 +711,22 @@ function removeDisposeCallback(node, callback) {
549
711
  function cleanNode(node) {
550
712
  if (cleanableNodeTypes[node.nodeType]) {
551
713
  cleanSingleNode(node);
552
- if (cleanableNodeTypesWithDescendants[node.nodeType]) {
714
+ if (cleanableNodeTypesWithDescendants[node.nodeType] && node instanceof Element) {
553
715
  cleanNodesInList(node.getElementsByTagName("*"));
554
716
  }
555
717
  }
556
718
  return node;
557
719
  }
558
720
  function removeNode(node) {
721
+ if (!node) {
722
+ return;
723
+ }
559
724
  cleanNode(node);
560
725
  if (node.parentNode) {
561
726
  node.parentNode.removeChild(node);
562
727
  }
563
728
  }
564
- var otherNodeCleanerFunctions = [];
729
+ var otherNodeCleanerFunctions = new Array();
565
730
  function addCleaner(fn) {
566
731
  otherNodeCleanerFunctions.push(fn);
567
732
  }
@@ -572,108 +737,27 @@ function removeCleaner(fn) {
572
737
  }
573
738
  }
574
739
  function cleanjQueryData(node) {
575
- var jQueryCleanNodeFn = jQueryInstance ? jQueryInstance.cleanData : null;
740
+ const jQueryCleanNodeFn = options_default.jQuery ? options_default.jQuery.cleanData : null;
576
741
  if (jQueryCleanNodeFn) {
577
742
  jQueryCleanNodeFn([node]);
578
743
  }
579
744
  }
580
745
  otherNodeCleanerFunctions.push(cleanjQueryData);
581
746
 
582
- // ../utils/dist/dom/event.js
583
- var knownEvents = {};
584
- var knownEventTypesByEventName = {};
585
- var keyEventTypeName = options_default.global.navigator && /Firefox\/2/i.test(options_default.global.navigator.userAgent) ? "KeyboardEvent" : "UIEvents";
586
- knownEvents[keyEventTypeName] = ["keyup", "keydown", "keypress"];
587
- knownEvents["MouseEvents"] = [
588
- "click",
589
- "dblclick",
590
- "mousedown",
591
- "mouseup",
592
- "mousemove",
593
- "mouseover",
594
- "mouseout",
595
- "mouseenter",
596
- "mouseleave"
597
- ];
598
- objectForEach(knownEvents, function(eventType, knownEventsForType) {
599
- if (knownEventsForType.length) {
600
- for (var i = 0, j = knownEventsForType.length; i < j; i++) {
601
- knownEventTypesByEventName[knownEventsForType[i]] = eventType;
602
- }
603
- }
604
- });
605
- function isClickOnCheckableElement(element, eventType) {
606
- if (tagNameLower(element) !== "input" || !element.type)
607
- return false;
608
- if (eventType.toLowerCase() != "click")
609
- return false;
610
- var inputType = element.type;
611
- return inputType == "checkbox" || inputType == "radio";
612
- }
613
- var eventsThatMustBeRegisteredUsingAttachEvent = { "propertychange": true };
614
- var jQueryEventAttachName;
615
- function registerEventHandler(element, eventType, handler, eventOptions = false) {
616
- const wrappedHandler = catchFunctionErrors(handler);
617
- const mustUseAttachEvent = ieVersion && eventsThatMustBeRegisteredUsingAttachEvent[eventType];
618
- const mustUseNative = Boolean(eventOptions);
619
- if (!options_default.useOnlyNativeEvents && !mustUseAttachEvent && !mustUseNative && jQueryInstance) {
620
- if (!jQueryEventAttachName) {
621
- jQueryEventAttachName = typeof jQueryInstance(element).on === "function" ? "on" : "bind";
622
- }
623
- jQueryInstance(element)[jQueryEventAttachName](eventType, wrappedHandler);
624
- } else if (!mustUseAttachEvent && typeof element.addEventListener === "function") {
625
- element.addEventListener(eventType, wrappedHandler, eventOptions);
626
- } else if (typeof element.attachEvent !== "undefined") {
627
- const attachEventHandler = function(event) {
628
- wrappedHandler.call(element, event);
629
- };
630
- const attachEventName = "on" + eventType;
631
- element.attachEvent(attachEventName, attachEventHandler);
632
- addDisposeCallback(element, function() {
633
- element.detachEvent(attachEventName, attachEventHandler);
634
- });
635
- } else {
636
- throw new Error("Browser doesn't support addEventListener or attachEvent");
637
- }
638
- }
639
- function triggerEvent(element, eventType) {
640
- if (!(element && element.nodeType)) {
641
- throw new Error("element must be a DOM node when calling triggerEvent");
642
- }
643
- var useClickWorkaround = isClickOnCheckableElement(element, eventType);
644
- if (!options_default.useOnlyNativeEvents && jQueryInstance && !useClickWorkaround) {
645
- jQueryInstance(element).trigger(eventType);
646
- } else if (typeof document.createEvent === "function") {
647
- if (typeof element.dispatchEvent === "function") {
648
- var eventCategory = knownEventTypesByEventName[eventType] || "HTMLEvents";
649
- var event = document.createEvent(eventCategory);
650
- event.initEvent(eventType, true, true, options_default.global, 0, 0, 0, 0, 0, false, false, false, false, 0, element);
651
- element.dispatchEvent(event);
652
- } else {
653
- throw new Error("The supplied element doesn't support dispatchEvent");
654
- }
655
- } else if (useClickWorkaround && element.click) {
656
- element.click();
657
- } else if (typeof element.fireEvent !== "undefined") {
658
- element.fireEvent("on" + eventType);
659
- } else {
660
- throw new Error("Browser doesn't support triggering events");
661
- }
662
- }
663
-
664
747
  // ../utils/dist/dom/manipulation.js
665
748
  function moveCleanedNodesToContainerElement(nodes) {
666
- var nodesArray = makeArray(nodes);
667
- var templateDocument = nodesArray[0] && nodesArray[0].ownerDocument || document;
668
- var container = templateDocument.createElement("div");
669
- for (var i = 0, j = nodesArray.length; i < j; i++) {
749
+ const nodesArray = makeArray(nodes);
750
+ const templateDocument = nodesArray[0] && nodesArray[0].ownerDocument || document;
751
+ const container = templateDocument.createElement("div");
752
+ for (let i = 0, j = nodesArray.length; i < j; i++) {
670
753
  container.appendChild(cleanNode(nodesArray[i]));
671
754
  }
672
755
  return container;
673
756
  }
674
757
  function cloneNodes(nodesArray, shouldCleanNodes) {
675
- for (var i = 0, j = nodesArray.length, newNodesArray = []; i < j; i++) {
676
- var clonedNode = nodesArray[i].cloneNode(true);
758
+ const newNodesArray = new Array();
759
+ for (let i = 0; i < nodesArray.length; i++) {
760
+ const clonedNode = nodesArray[i].cloneNode(true);
677
761
  newNodesArray.push(shouldCleanNodes ? cleanNode(clonedNode) : clonedNode);
678
762
  }
679
763
  return newNodesArray;
@@ -681,20 +765,20 @@ function cloneNodes(nodesArray, shouldCleanNodes) {
681
765
  function setDomNodeChildren(domNode, childNodes2) {
682
766
  emptyDomNode(domNode);
683
767
  if (childNodes2) {
684
- for (var i = 0, j = childNodes2.length; i < j; i++) {
768
+ for (let i = 0; i < childNodes2.length; i++) {
685
769
  domNode.appendChild(childNodes2[i]);
686
770
  }
687
771
  }
688
772
  }
689
773
  function replaceDomNodes(nodeToReplaceOrNodeArray, newNodesArray) {
690
- var nodesToReplaceArray = nodeToReplaceOrNodeArray.nodeType ? [nodeToReplaceOrNodeArray] : nodeToReplaceOrNodeArray;
774
+ const nodesToReplaceArray = Array.isArray(nodeToReplaceOrNodeArray) ? nodeToReplaceOrNodeArray : [nodeToReplaceOrNodeArray];
691
775
  if (nodesToReplaceArray.length > 0) {
692
- var insertionPoint = nodesToReplaceArray[0];
693
- var parent = insertionPoint.parentNode;
694
- for (var i = 0, j = newNodesArray.length; i < j; i++) {
695
- parent.insertBefore(newNodesArray[i], insertionPoint);
776
+ const insertionPoint = nodesToReplaceArray[0];
777
+ const parent = insertionPoint.parentNode;
778
+ for (let i = 0; i < newNodesArray.length; i++) {
779
+ parent == null ? void 0 : parent.insertBefore(newNodesArray[i], insertionPoint);
696
780
  }
697
- for (i = 0, j = nodesToReplaceArray.length; i < j; i++) {
781
+ for (let i = 0; i < nodesToReplaceArray.length; i++) {
698
782
  removeNode(nodesToReplaceArray[i]);
699
783
  }
700
784
  }
@@ -708,7 +792,7 @@ function emptyDomNode(domNode) {
708
792
  // ../utils/dist/dom/fixes.js
709
793
  function fixUpContinuousNodeArray(continuousNodeArray, parentNode) {
710
794
  if (continuousNodeArray.length) {
711
- parentNode = parentNode.nodeType === 8 && parentNode.parentNode || parentNode;
795
+ parentNode = parentNode.nodeType === Node.COMMENT_NODE && parentNode.parentNode || parentNode;
712
796
  while (continuousNodeArray.length && continuousNodeArray[0].parentNode !== parentNode) {
713
797
  continuousNodeArray.splice(0, 1);
714
798
  }
@@ -716,7 +800,7 @@ function fixUpContinuousNodeArray(continuousNodeArray, parentNode) {
716
800
  continuousNodeArray.length--;
717
801
  }
718
802
  if (continuousNodeArray.length > 1) {
719
- var current = continuousNodeArray[0], last = continuousNodeArray[continuousNodeArray.length - 1];
803
+ let current = continuousNodeArray[0], last = continuousNodeArray[continuousNodeArray.length - 1];
720
804
  continuousNodeArray.length = 0;
721
805
  while (current !== last) {
722
806
  continuousNodeArray.push(current);
@@ -727,14 +811,6 @@ function fixUpContinuousNodeArray(continuousNodeArray, parentNode) {
727
811
  }
728
812
  return continuousNodeArray;
729
813
  }
730
- function forceRefresh(node) {
731
- if (ieVersion >= 9) {
732
- var elem = node.nodeType == 1 ? node : node.parentNode;
733
- if (elem.style) {
734
- elem.style.zoom = elem.style.zoom;
735
- }
736
- }
737
- }
738
814
 
739
815
  // ../utils/dist/dom/virtualElements.js
740
816
  var virtualElements_exports = {};
@@ -758,24 +834,23 @@ __export(virtualElements_exports, {
758
834
  startCommentRegex: () => startCommentRegex,
759
835
  virtualNodeBindingValue: () => virtualNodeBindingValue
760
836
  });
761
- var commentNodesHaveTextProperty = options_default.document && options_default.document.createComment("test").text === "<!--test-->";
762
- var startCommentRegex = commentNodesHaveTextProperty ? /^<!--\s*ko(?:\s+([\s\S]+))?\s*-->$/ : /^\s*ko(?:\s+([\s\S]+))?\s*$/;
763
- var endCommentRegex = commentNodesHaveTextProperty ? /^<!--\s*\/ko\s*-->$/ : /^\s*\/ko\s*$/;
764
- var htmlTagsWithOptionallyClosingChildren = { "ul": true, "ol": true };
837
+ var startCommentRegex = /^\s*ko(?:\s+([\s\S]+))?\s*$/;
838
+ var endCommentRegex = /^\s*\/ko\s*$/;
839
+ var htmlTagsWithOptionallyClosingChildren = { ul: true, ol: true };
765
840
  function isStartComment(node) {
766
- return node.nodeType == 8 && startCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);
841
+ return node.nodeType === Node.COMMENT_NODE && startCommentRegex.test(node.nodeValue);
767
842
  }
768
843
  function isEndComment(node) {
769
- return node.nodeType == 8 && endCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);
844
+ return node.nodeType === Node.COMMENT_NODE && endCommentRegex.test(node.nodeValue);
770
845
  }
771
846
  function isUnmatchedEndComment(node) {
772
847
  return isEndComment(node) && !get(node, matchedEndCommentDataKey);
773
848
  }
774
849
  var matchedEndCommentDataKey = "__ko_matchedEndComment__";
775
850
  function getVirtualChildren(startComment, allowUnbalanced) {
776
- var currentNode = startComment;
777
- var depth = 1;
778
- var children = [];
851
+ let currentNode = startComment;
852
+ let depth = 1;
853
+ const children = new Array();
779
854
  while (currentNode = currentNode.nextSibling) {
780
855
  if (isEndComment(currentNode)) {
781
856
  set(currentNode, matchedEndCommentDataKey, true);
@@ -795,7 +870,7 @@ function getVirtualChildren(startComment, allowUnbalanced) {
795
870
  return null;
796
871
  }
797
872
  function getMatchingEndComment(startComment, allowUnbalanced) {
798
- var allVirtualChildren = getVirtualChildren(startComment, allowUnbalanced);
873
+ const allVirtualChildren = getVirtualChildren(startComment, allowUnbalanced);
799
874
  if (allVirtualChildren) {
800
875
  if (allVirtualChildren.length > 0) {
801
876
  return allVirtualChildren[allVirtualChildren.length - 1].nextSibling;
@@ -806,13 +881,17 @@ function getMatchingEndComment(startComment, allowUnbalanced) {
806
881
  }
807
882
  }
808
883
  function getUnbalancedChildTags(node) {
809
- var childNode = node.firstChild, captureRemaining = null;
884
+ let childNode = node.firstChild, captureRemaining = null;
810
885
  if (childNode) {
811
886
  do {
812
887
  if (captureRemaining) {
813
888
  captureRemaining.push(childNode);
814
889
  } else if (isStartComment(childNode)) {
815
- var matchingEndComment = getMatchingEndComment(childNode, true);
890
+ const matchingEndComment = getMatchingEndComment(
891
+ childNode,
892
+ /* allowUnbalanced: */
893
+ true
894
+ );
816
895
  if (matchingEndComment) {
817
896
  childNode = matchingEndComment;
818
897
  } else {
@@ -825,7 +904,7 @@ function getUnbalancedChildTags(node) {
825
904
  }
826
905
  return captureRemaining;
827
906
  }
828
- var allowedBindings = {};
907
+ var allowedBindings = /* @__PURE__ */ Object.create(null);
829
908
  var hasBindingValue = isStartComment;
830
909
  function childNodes(node) {
831
910
  return isStartComment(node) ? getVirtualChildren(node) : node.childNodes;
@@ -834,8 +913,8 @@ function emptyNode(node) {
834
913
  if (!isStartComment(node)) {
835
914
  emptyDomNode(node);
836
915
  } else {
837
- var virtualChildren = childNodes(node);
838
- for (var i = 0, j = virtualChildren.length; i < j; i++) {
916
+ const virtualChildren = childNodes(node);
917
+ for (let i = 0, j = virtualChildren.length; i < j; i++) {
839
918
  removeNode(virtualChildren[i]);
840
919
  }
841
920
  }
@@ -846,13 +925,16 @@ function setDomNodeChildren2(node, childNodes2) {
846
925
  } else {
847
926
  emptyNode(node);
848
927
  const endCommentNode = node.nextSibling;
849
- const parentNode = endCommentNode.parentNode;
850
- for (var i = 0, j = childNodes2.length; i < j; ++i) {
851
- parentNode.insertBefore(childNodes2[i], endCommentNode);
928
+ if (endCommentNode && endCommentNode.parentNode) {
929
+ const parentNode = endCommentNode.parentNode;
930
+ for (let i = 0, j = childNodes2.length; i < j; ++i) {
931
+ parentNode.insertBefore(childNodes2[i], endCommentNode);
932
+ }
852
933
  }
853
934
  }
854
935
  }
855
936
  function prepend(containerNode, nodeToPrepend) {
937
+ var _a;
856
938
  if (!isStartComment(containerNode)) {
857
939
  if (containerNode.firstChild) {
858
940
  containerNode.insertBefore(nodeToPrepend, containerNode.firstChild);
@@ -860,10 +942,11 @@ function prepend(containerNode, nodeToPrepend) {
860
942
  containerNode.appendChild(nodeToPrepend);
861
943
  }
862
944
  } else {
863
- containerNode.parentNode.insertBefore(nodeToPrepend, containerNode.nextSibling);
945
+ (_a = containerNode.parentNode) == null ? void 0 : _a.insertBefore(nodeToPrepend, containerNode.nextSibling);
864
946
  }
865
947
  }
866
948
  function insertAfter(containerNode, nodeToInsert, insertAfterNode) {
949
+ var _a;
867
950
  if (!insertAfterNode) {
868
951
  prepend(containerNode, nodeToInsert);
869
952
  } else if (!isStartComment(containerNode)) {
@@ -873,7 +956,7 @@ function insertAfter(containerNode, nodeToInsert, insertAfterNode) {
873
956
  containerNode.appendChild(nodeToInsert);
874
957
  }
875
958
  } else {
876
- containerNode.parentNode.insertBefore(nodeToInsert, insertAfterNode.nextSibling);
959
+ (_a = containerNode.parentNode) == null ? void 0 : _a.insertBefore(nodeToInsert, insertAfterNode.nextSibling);
877
960
  }
878
961
  }
879
962
  function firstChild(node) {
@@ -890,6 +973,7 @@ function firstChild(node) {
890
973
  }
891
974
  function lastChild(node) {
892
975
  let nextChild = firstChild(node);
976
+ if (!nextChild) return null;
893
977
  let lastChildNode;
894
978
  do {
895
979
  lastChildNode = nextChild;
@@ -902,7 +986,9 @@ function nextSibling(node) {
902
986
  }
903
987
  if (node.nextSibling && isEndComment(node.nextSibling)) {
904
988
  if (isUnmatchedEndComment(node.nextSibling)) {
905
- throw Error("Found end comment without a matching opening comment, as next sibling of " + node.outerHTML);
989
+ throw Error(
990
+ "Found end comment without a matching opening comment, as next sibling of " + node.outerHTML
991
+ );
906
992
  }
907
993
  return null;
908
994
  } else {
@@ -910,9 +996,9 @@ function nextSibling(node) {
910
996
  }
911
997
  }
912
998
  function previousSibling(node) {
913
- var depth = 0;
999
+ let depth = 0;
914
1000
  do {
915
- if (node.nodeType === 8) {
1001
+ if (node.nodeType === Node.COMMENT_NODE) {
916
1002
  if (isStartComment(node)) {
917
1003
  if (--depth === 0) {
918
1004
  return node;
@@ -928,21 +1014,21 @@ function previousSibling(node) {
928
1014
  } while (node = node.previousSibling);
929
1015
  }
930
1016
  function virtualNodeBindingValue(node) {
931
- var regexMatch = (commentNodesHaveTextProperty ? node.text : node.nodeValue).match(startCommentRegex);
1017
+ const regexMatch = node.nodeValue.match(startCommentRegex);
932
1018
  return regexMatch ? regexMatch[1] : null;
933
1019
  }
934
1020
  function normaliseVirtualElementDomStructure(elementVerified) {
935
1021
  if (!htmlTagsWithOptionallyClosingChildren[tagNameLower(elementVerified)]) {
936
1022
  return;
937
1023
  }
938
- var childNode = elementVerified.firstChild;
1024
+ let childNode = elementVerified.firstChild;
939
1025
  if (childNode) {
940
1026
  do {
941
- if (childNode.nodeType === 1) {
942
- var unbalancedTags = getUnbalancedChildTags(childNode);
1027
+ if (childNode.nodeType === Node.ELEMENT_NODE) {
1028
+ const unbalancedTags = getUnbalancedChildTags(childNode);
943
1029
  if (unbalancedTags) {
944
- var nodeToInsertBefore = childNode.nextSibling;
945
- for (var i = 0; i < unbalancedTags.length; i++) {
1030
+ const nodeToInsertBefore = childNode.nextSibling;
1031
+ for (let i = 0; i < unbalancedTags.length; i++) {
946
1032
  if (nodeToInsertBefore) {
947
1033
  elementVerified.insertBefore(unbalancedTags[i], nodeToInsertBefore);
948
1034
  } else {
@@ -956,78 +1042,48 @@ function normaliseVirtualElementDomStructure(elementVerified) {
956
1042
  }
957
1043
 
958
1044
  // ../utils/dist/dom/html.js
959
- var none = [0, "", ""];
960
- var table = [1, "<table>", "</table>"];
961
- var tbody = [2, "<table><tbody>", "</tbody></table>"];
962
- var colgroup = [2, "<table><tbody></tbody><colgroup>", "</colgroup></table>"];
963
- var tr = [3, "<table><tbody><tr>", "</tr></tbody></table>"];
964
- var select = [1, "<select multiple='multiple'>", "</select>"];
965
- var fieldset = [1, "<fieldset>", "</fieldset>"];
966
- var map = [1, "<map>", "</map>"];
967
- var object = [1, "<object>", "</object>"];
968
- var lookup = {
969
- "area": map,
970
- "col": colgroup,
971
- "colgroup": table,
972
- "caption": table,
973
- "legend": fieldset,
974
- "thead": table,
975
- "tbody": table,
976
- "tfoot": table,
977
- "tr": tbody,
978
- "td": tr,
979
- "th": tr,
980
- "option": select,
981
- "optgroup": select,
982
- "param": object
983
- };
984
- var supportsTemplateTag = options_default.document && "content" in options_default.document.createElement("template");
985
- function getWrap(tags) {
986
- const m = tags.match(/^(?:<!--.*?-->\s*?)*?<([a-z]+)[\s>]/);
987
- return m && lookup[m[1]] || none;
988
- }
1045
+ var supportsTemplateTag = options_default.useTemplateTag && options_default.document && "content" in options_default.document.createElement("template");
989
1046
  function simpleHtmlParse(html, documentContext) {
990
- documentContext || (documentContext = document);
991
- var windowContext = documentContext["parentWindow"] || documentContext["defaultView"] || window;
992
- var tags = stringTrim(html).toLowerCase(), div2 = documentContext.createElement("div"), wrap = getWrap(tags), depth = wrap[0];
993
- var markup = "ignored<div>" + wrap[1] + html + wrap[2] + "</div>";
994
- if (typeof windowContext["innerShiv"] === "function") {
995
- div2.appendChild(windowContext["innerShiv"](markup));
996
- } else {
997
- div2.innerHTML = markup;
998
- }
999
- while (depth--) {
1000
- div2 = div2.lastChild;
1047
+ if (!documentContext) {
1048
+ documentContext = document;
1001
1049
  }
1002
- return makeArray(div2.lastChild.childNodes);
1050
+ const div2 = documentContext.createElement("div");
1051
+ div2.innerHTML = html;
1052
+ return makeArray(div2.childNodes);
1003
1053
  }
1004
1054
  function templateHtmlParse(html, documentContext) {
1005
1055
  if (!documentContext) {
1006
1056
  documentContext = document;
1007
1057
  }
1008
- var template = documentContext.createElement("template");
1058
+ const template = documentContext.createElement("template");
1009
1059
  template.innerHTML = html;
1010
1060
  return makeArray(template.content.childNodes);
1011
1061
  }
1012
1062
  function jQueryHtmlParse(html, documentContext) {
1013
- if (jQueryInstance.parseHTML) {
1014
- return jQueryInstance.parseHTML(html, documentContext) || [];
1015
- } else {
1016
- var elems = jQueryInstance.clean([html], documentContext);
1017
- if (elems && elems[0]) {
1018
- var elem = elems[0];
1019
- while (elem.parentNode && elem.parentNode.nodeType !== 11) {
1020
- elem = elem.parentNode;
1021
- }
1022
- if (elem.parentNode) {
1023
- elem.parentNode.removeChild(elem);
1024
- }
1025
- }
1026
- return elems;
1063
+ const jQuery = options_default.jQuery;
1064
+ if (jQuery) {
1065
+ return jQuery.parseHTML(html, documentContext) || [];
1027
1066
  }
1067
+ return [];
1028
1068
  }
1029
1069
  function parseHtmlFragment(html, documentContext) {
1030
- return supportsTemplateTag ? templateHtmlParse(html, documentContext) : jQueryInstance ? jQueryHtmlParse(html, documentContext) : simpleHtmlParse(html, documentContext);
1070
+ const saferHtml = validateHTMLInput(html);
1071
+ if (supportsTemplateTag) return templateHtmlParse(saferHtml, documentContext);
1072
+ if (options_default.jQuery) {
1073
+ return jQueryHtmlParse(saferHtml, documentContext);
1074
+ }
1075
+ return simpleHtmlParse(saferHtml, documentContext);
1076
+ }
1077
+ var scriptTagPattern = /<script\b[^>]*>([\s\S]*?)<\/script[^>]*>/i;
1078
+ function validateHTMLInput(html) {
1079
+ if (!html) return "";
1080
+ if (options_default.templateSizeLimit > 0 && html.length > options_default.templateSizeLimit) {
1081
+ throw new Error("Template is too long. Please configure the 'templateSizeLimit'");
1082
+ }
1083
+ if (!options_default.allowScriptTagsInTemplates && scriptTagPattern.test(html)) {
1084
+ throw new Error("Script-tag in template detected.");
1085
+ }
1086
+ return options_default.sanitizeHtmlTemplate(html);
1031
1087
  }
1032
1088
  function parseHtmlForTemplateNodes(html, documentContext) {
1033
1089
  const nodes = parseHtmlFragment(html, documentContext);
@@ -1042,18 +1098,25 @@ function setHtml(node, html) {
1042
1098
  if (typeof html !== "string") {
1043
1099
  html = html.toString();
1044
1100
  }
1045
- if (jQueryInstance && !supportsTemplateTag) {
1046
- jQueryInstance(node).html(html);
1101
+ const jQuery = options_default.jQuery;
1102
+ if (jQuery && !supportsTemplateTag) {
1103
+ const saferHtml = validateHTMLInput(html);
1104
+ jQuery(node).html(saferHtml);
1047
1105
  } else {
1048
- var parsedNodes = parseHtmlFragment(html, node.ownerDocument);
1049
- if (node.nodeType === 8) {
1106
+ let parsedNodes;
1107
+ if (node.ownerDocument) {
1108
+ parsedNodes = parseHtmlFragment(html, node.ownerDocument);
1109
+ } else {
1110
+ parsedNodes = parseHtmlFragment(html);
1111
+ }
1112
+ if (node.nodeType === Node.COMMENT_NODE) {
1050
1113
  if (html === null) {
1051
1114
  emptyNode(node);
1052
1115
  } else {
1053
1116
  setDomNodeChildren2(node, parsedNodes);
1054
1117
  }
1055
1118
  } else {
1056
- for (var i = 0; i < parsedNodes.length; i++) {
1119
+ for (let i = 0; i < parsedNodes.length; i++) {
1057
1120
  node.appendChild(parsedNodes[i]);
1058
1121
  }
1059
1122
  }
@@ -1061,32 +1124,35 @@ function setHtml(node, html) {
1061
1124
  }
1062
1125
  }
1063
1126
  function setTextContent(element, textContent) {
1064
- var value = typeof textContent === "function" ? textContent() : textContent;
1127
+ let value = typeof textContent === "function" ? textContent() : textContent;
1065
1128
  if (value === null || value === void 0) {
1066
1129
  value = "";
1067
1130
  }
1068
- var innerTextNode = firstChild(element);
1069
- if (!innerTextNode || innerTextNode.nodeType != 3 || nextSibling(innerTextNode)) {
1131
+ const innerTextNode = firstChild(element);
1132
+ if (!innerTextNode || innerTextNode.nodeType !== Node.TEXT_NODE || nextSibling(innerTextNode)) {
1070
1133
  setDomNodeChildren2(element, [element.ownerDocument.createTextNode(value)]);
1071
1134
  } else {
1135
+ ;
1072
1136
  innerTextNode.data = value;
1073
1137
  }
1074
- forceRefresh(element);
1075
1138
  }
1076
1139
 
1077
1140
  // ../utils/dist/dom/selectExtensions.js
1078
- var hasDomDataExpandoProperty = Symbol("Knockout selectExtensions hasDomDataProperty");
1141
+ var hasDomDataExpandoProperty = /* @__PURE__ */ Symbol("Knockout selectExtensions hasDomDataProperty");
1079
1142
  var selectExtensions = {
1080
1143
  optionValueDomDataKey: nextKey(),
1081
1144
  readValue: function(element) {
1082
1145
  switch (tagNameLower(element)) {
1083
- case "option":
1146
+ case "option": {
1084
1147
  if (element[hasDomDataExpandoProperty] === true) {
1085
1148
  return get(element, selectExtensions.optionValueDomDataKey);
1086
1149
  }
1087
1150
  return element.value;
1088
- case "select":
1089
- return element.selectedIndex >= 0 ? selectExtensions.readValue(element.options[element.selectedIndex]) : void 0;
1151
+ }
1152
+ case "select": {
1153
+ const selectElement = element;
1154
+ return selectElement.selectedIndex >= 0 ? selectExtensions.readValue(selectElement.options[selectElement.selectedIndex]) : void 0;
1155
+ }
1090
1156
  default:
1091
1157
  return element.value;
1092
1158
  }
@@ -1099,36 +1165,42 @@ var selectExtensions = {
1099
1165
  if (hasDomDataExpandoProperty in element) {
1100
1166
  delete element[hasDomDataExpandoProperty];
1101
1167
  }
1168
+ ;
1102
1169
  element.value = value;
1103
1170
  } else {
1171
+ const el = element;
1104
1172
  set(element, selectExtensions.optionValueDomDataKey, value);
1105
- element[hasDomDataExpandoProperty] = true;
1106
- element.value = typeof value === "number" ? value : "";
1173
+ el[hasDomDataExpandoProperty] = true;
1174
+ el.value = typeof value === "number" ? value : "";
1107
1175
  }
1108
1176
  break;
1109
1177
  case "select":
1110
- if (value === "" || value === null) {
1111
- value = void 0;
1112
- }
1113
- var selection = -1;
1114
- for (let i = 0, n = element.options.length, optionValue; i < n; ++i) {
1115
- optionValue = selectExtensions.readValue(element.options[i]);
1116
- const strictEqual = optionValue === value;
1117
- const blankEqual = optionValue === "" && value === void 0;
1118
- const numericEqual = typeof value === "number" && Number(optionValue) === value;
1119
- if (strictEqual || blankEqual || numericEqual) {
1120
- selection = i;
1121
- break;
1178
+ {
1179
+ if (value === "" || value === null) {
1180
+ value = void 0;
1181
+ }
1182
+ let selection = -1;
1183
+ const selectElement = element;
1184
+ for (let i = 0, n = selectElement.options.length, optionValue; i < n; ++i) {
1185
+ optionValue = selectExtensions.readValue(selectElement.options[i]);
1186
+ const strictEqual = optionValue === value;
1187
+ const blankEqual = optionValue === "" && value === void 0;
1188
+ const numericEqual = typeof value === "number" && Number(optionValue) === value;
1189
+ if (strictEqual || blankEqual || numericEqual) {
1190
+ selection = i;
1191
+ break;
1192
+ }
1193
+ }
1194
+ if (allowUnset || selection >= 0 || value === void 0 && selectElement.size > 1) {
1195
+ selectElement.selectedIndex = selection;
1122
1196
  }
1123
- }
1124
- if (allowUnset || selection >= 0 || value === void 0 && element.size > 1) {
1125
- element.selectedIndex = selection;
1126
1197
  }
1127
1198
  break;
1128
1199
  default:
1129
1200
  if (value === null || value === void 0) {
1130
1201
  value = "";
1131
1202
  }
1203
+ ;
1132
1204
  element.value = value;
1133
1205
  break;
1134
1206
  }
@@ -1154,13 +1226,14 @@ function findMemoNodes(rootNode, appendToArray) {
1154
1226
  if (!rootNode) {
1155
1227
  return;
1156
1228
  }
1157
- if (rootNode.nodeType == 8) {
1158
- var memoId = parseMemoText(rootNode.nodeValue);
1229
+ if (rootNode.nodeType === Node.COMMENT_NODE) {
1230
+ const comment = rootNode;
1231
+ const memoId = parseMemoText(comment.nodeValue);
1159
1232
  if (memoId != null) {
1160
1233
  appendToArray.push({ domNode: rootNode, memoId });
1161
1234
  }
1162
- } else if (rootNode.nodeType == 1) {
1163
- for (var i = 0, childNodes2 = rootNode.childNodes, j = childNodes2.length; i < j; i++) {
1235
+ } else if (rootNode.nodeType === Node.ELEMENT_NODE) {
1236
+ for (let i = 0, childNodes2 = rootNode.childNodes, j = childNodes2.length; i < j; i++) {
1164
1237
  findMemoNodes(childNodes2[i], appendToArray);
1165
1238
  }
1166
1239
  }
@@ -1169,12 +1242,12 @@ function memoize(callback) {
1169
1242
  if (typeof callback !== "function") {
1170
1243
  throw new Error("You can only pass a function to memoization.memoize()");
1171
1244
  }
1172
- var memoId = generateRandomId();
1245
+ const memoId = generateRandomId();
1173
1246
  memos[memoId] = callback;
1174
1247
  return "<!--[ko_memo:" + memoId + "]-->";
1175
1248
  }
1176
1249
  function unmemoize(memoId, callbackParams) {
1177
- var callback = memos[memoId];
1250
+ const callback = memos[memoId];
1178
1251
  if (callback === void 0) {
1179
1252
  throw new Error("Couldn't find any memo with ID " + memoId + ". Perhaps it's already been unmemoized.");
1180
1253
  }
@@ -1186,11 +1259,11 @@ function unmemoize(memoId, callbackParams) {
1186
1259
  }
1187
1260
  }
1188
1261
  function unmemoizeDomNodeAndDescendants(domNode, extraCallbackParamsArray) {
1189
- var memos2 = [];
1262
+ const memos2 = new Array();
1190
1263
  findMemoNodes(domNode, memos2);
1191
- for (var i = 0, j = memos2.length; i < j; i++) {
1192
- var node = memos2[i].domNode;
1193
- var combinedParams = [node];
1264
+ for (let i = 0, j = memos2.length; i < j; i++) {
1265
+ const node = memos2[i].domNode;
1266
+ const combinedParams = [node];
1194
1267
  if (extraCallbackParamsArray) {
1195
1268
  arrayPushAll(combinedParams, extraCallbackParamsArray);
1196
1269
  }
@@ -1202,7 +1275,10 @@ function unmemoizeDomNodeAndDescendants(domNode, extraCallbackParamsArray) {
1202
1275
  }
1203
1276
  }
1204
1277
  function parseMemoText(memoText) {
1205
- var match = memoText.match(/^\[ko_memo\:(.*?)\]$/);
1278
+ if (!memoText) {
1279
+ return null;
1280
+ }
1281
+ const match = memoText.match(/^\[ko_memo\:(.*?)\]$/);
1206
1282
  return match ? match[1] : null;
1207
1283
  }
1208
1284
 
@@ -1214,30 +1290,19 @@ __export(tasks_exports, {
1214
1290
  runEarly: () => processTasks,
1215
1291
  schedule: () => schedule
1216
1292
  });
1217
- var taskQueue = [];
1293
+ var taskQueue = new Array();
1218
1294
  var taskQueueLength = 0;
1219
1295
  var nextHandle = 1;
1220
1296
  var nextIndexToProcess = 0;
1221
1297
  var w = options_default.global;
1222
1298
  if (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {
1223
- options_default.taskScheduler = function(callback) {
1224
- var div2 = w.document.createElement("div");
1299
+ options_default.taskScheduler = (function(callback) {
1300
+ const div2 = w.document.createElement("div");
1225
1301
  new w.MutationObserver(callback).observe(div2, { attributes: true });
1226
1302
  return function() {
1227
1303
  div2.classList.toggle("foo");
1228
1304
  };
1229
- }(scheduledProcess);
1230
- } else if (w && w.document && "onreadystatechange" in w.document.createElement("script")) {
1231
- options_default.taskScheduler = function(callback) {
1232
- var script = document.createElement("script");
1233
- script.onreadystatechange = function() {
1234
- script.onreadystatechange = null;
1235
- document.documentElement.removeChild(script);
1236
- script = null;
1237
- callback();
1238
- };
1239
- document.documentElement.appendChild(script);
1240
- };
1305
+ })(scheduledProcess);
1241
1306
  } else {
1242
1307
  options_default.taskScheduler = function(callback) {
1243
1308
  setTimeout(callback, 0);
@@ -1245,8 +1310,8 @@ if (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {
1245
1310
  }
1246
1311
  function processTasks() {
1247
1312
  if (taskQueueLength) {
1248
- var mark = taskQueueLength, countMarks = 0;
1249
- for (var task; nextIndexToProcess < taskQueueLength; ) {
1313
+ let mark = taskQueueLength, countMarks = 0;
1314
+ for (let task; nextIndexToProcess < taskQueueLength; ) {
1250
1315
  if (task = taskQueue[nextIndexToProcess++]) {
1251
1316
  if (nextIndexToProcess > mark) {
1252
1317
  if (++countMarks >= 5e3) {
@@ -1280,13 +1345,13 @@ function schedule(func) {
1280
1345
  return nextHandle++;
1281
1346
  }
1282
1347
  function cancel(handle) {
1283
- var index = handle - (nextHandle - taskQueueLength);
1348
+ const index = handle - (nextHandle - taskQueueLength);
1284
1349
  if (index >= nextIndexToProcess && index < taskQueueLength) {
1285
1350
  taskQueue[index] = null;
1286
1351
  }
1287
1352
  }
1288
1353
  function resetForTesting() {
1289
- var length = taskQueueLength - nextIndexToProcess;
1354
+ const length = taskQueueLength - nextIndexToProcess;
1290
1355
  nextIndexToProcess = taskQueueLength = taskQueue.length = 0;
1291
1356
  return length;
1292
1357
  }
@@ -1305,13 +1370,13 @@ __export(dependencyDetection_exports, {
1305
1370
  });
1306
1371
 
1307
1372
  // ../observable/dist/subscribableSymbol.js
1308
- var SUBSCRIBABLE_SYM = Symbol("Knockout Subscribable");
1373
+ var SUBSCRIBABLE_SYM = /* @__PURE__ */ Symbol("Knockout Subscribable");
1309
1374
  function isSubscribable(instance) {
1310
1375
  return instance && instance[SUBSCRIBABLE_SYM] || false;
1311
1376
  }
1312
1377
 
1313
1378
  // ../observable/dist/dependencyDetection.js
1314
- var outerFrames = [];
1379
+ var outerFrames = new Array();
1315
1380
  var currentFrame;
1316
1381
  var lastId = 0;
1317
1382
  function getId() {
@@ -1329,7 +1394,11 @@ function registerDependency(subscribable2) {
1329
1394
  if (!isSubscribable(subscribable2)) {
1330
1395
  throw new Error("Only subscribable things can act as dependencies");
1331
1396
  }
1332
- currentFrame.callback.call(currentFrame.callbackTarget, subscribable2, subscribable2._id || (subscribable2._id = getId()));
1397
+ currentFrame.callback.call(
1398
+ currentFrame.callbackTarget,
1399
+ subscribable2,
1400
+ subscribable2._id || (subscribable2._id = getId())
1401
+ );
1333
1402
  }
1334
1403
  }
1335
1404
  function ignore(callback, callbackTarget, callbackArgs) {
@@ -1344,16 +1413,19 @@ function getDependenciesCount() {
1344
1413
  if (currentFrame) {
1345
1414
  return currentFrame.computed.getDependenciesCount();
1346
1415
  }
1416
+ return void 0;
1347
1417
  }
1348
1418
  function getDependencies() {
1349
1419
  if (currentFrame) {
1350
1420
  return currentFrame.computed.getDependencies();
1351
1421
  }
1422
+ return void 0;
1352
1423
  }
1353
1424
  function isInitial() {
1354
1425
  if (currentFrame) {
1355
1426
  return currentFrame.isInitial;
1356
1427
  }
1428
+ return void 0;
1357
1429
  }
1358
1430
 
1359
1431
  // ../observable/dist/defer.js
@@ -1400,6 +1472,7 @@ var Subscription = class {
1400
1472
  this._node = node;
1401
1473
  addDisposeCallback(node, this._domNodeDisposalCallback = this.dispose.bind(this));
1402
1474
  }
1475
+ // TC39 Observable API
1403
1476
  unsubscribe() {
1404
1477
  this.dispose();
1405
1478
  }
@@ -1409,21 +1482,16 @@ var Subscription = class {
1409
1482
  };
1410
1483
 
1411
1484
  // ../observable/dist/extenders.js
1412
- var primitiveTypes = {
1413
- "undefined": 1,
1414
- "boolean": 1,
1415
- "number": 1,
1416
- "string": 1
1417
- };
1485
+ var primitiveTypes = { undefined: 1, boolean: 1, number: 1, string: 1 };
1418
1486
  function valuesArePrimitiveAndEqual(a, b) {
1419
- var oldValueIsPrimitive = a === null || typeof a in primitiveTypes;
1487
+ const oldValueIsPrimitive = a === null || typeof a in primitiveTypes;
1420
1488
  return oldValueIsPrimitive ? a === b : false;
1421
1489
  }
1422
1490
  function applyExtenders(requestedExtenders) {
1423
- var target = this;
1491
+ let target = this;
1424
1492
  if (requestedExtenders) {
1425
1493
  objectForEach(requestedExtenders, function(key, value) {
1426
- var extenderHandler = extenders[key];
1494
+ const extenderHandler = extenders[key];
1427
1495
  if (typeof extenderHandler === "function") {
1428
1496
  target = extenderHandler(target, value) || target;
1429
1497
  } else {
@@ -1438,12 +1506,14 @@ function notify(target, notifyWhen) {
1438
1506
  }
1439
1507
  function deferred(target, option) {
1440
1508
  if (option !== true) {
1441
- throw new Error("The 'deferred' extender only accepts the value 'true', because it is not supported to turn deferral off once enabled.");
1509
+ throw new Error(
1510
+ "The 'deferred' extender only accepts the value 'true', because it is not supported to turn deferral off once enabled."
1511
+ );
1442
1512
  }
1443
1513
  deferUpdates(target);
1444
1514
  }
1445
1515
  function rateLimit(target, options2) {
1446
- var timeout, method, limitFunction;
1516
+ let timeout, method, limitFunction;
1447
1517
  if (typeof options2 === "number") {
1448
1518
  timeout = options2;
1449
1519
  } else {
@@ -1456,21 +1526,17 @@ function rateLimit(target, options2) {
1456
1526
  return limitFunction(callback, timeout);
1457
1527
  });
1458
1528
  }
1459
- var extenders = {
1460
- notify,
1461
- deferred,
1462
- rateLimit
1463
- };
1529
+ var extenders = { notify, deferred, rateLimit };
1464
1530
 
1465
1531
  // ../observable/dist/subscribable.js
1466
- var LATEST_VALUE = Symbol("Knockout latest value");
1532
+ var LATEST_VALUE = /* @__PURE__ */ Symbol("Knockout latest value");
1467
1533
  if (!Symbol.observable) {
1468
- Symbol.observable = Symbol.for("@tko/Symbol.observable");
1534
+ Symbol.observable = /* @__PURE__ */ Symbol.for("@tko/Symbol.observable");
1469
1535
  }
1470
- function subscribable() {
1536
+ var subscribable = function subscribableFactory() {
1471
1537
  Object.setPrototypeOf(this, ko_subscribable_fn);
1472
1538
  ko_subscribable_fn.init(this);
1473
- }
1539
+ };
1474
1540
  var defaultEvent = "change";
1475
1541
  var ko_subscribable_fn = {
1476
1542
  [SUBSCRIBABLE_SYM]: true,
@@ -1484,9 +1550,7 @@ var ko_subscribable_fn = {
1484
1550
  subscribe(callback, callbackTarget, event) {
1485
1551
  const isTC39Callback = typeof callback === "object" && callback.next;
1486
1552
  event = event || defaultEvent;
1487
- const observer = isTC39Callback ? callback : {
1488
- next: callbackTarget ? callback.bind(callbackTarget) : callback
1489
- };
1553
+ const observer = isTC39Callback ? callback : { next: callbackTarget ? callback.bind(callbackTarget) : callback };
1490
1554
  const subscriptionInstance = new Subscription(this, observer, () => {
1491
1555
  arrayRemoveItem(this._subscriptions[event], subscriptionInstance);
1492
1556
  if (this.afterSubscriptionRemove) {
@@ -1497,7 +1561,7 @@ var ko_subscribable_fn = {
1497
1561
  this.beforeSubscriptionAdd(event);
1498
1562
  }
1499
1563
  if (!this._subscriptions[event]) {
1500
- this._subscriptions[event] = [];
1564
+ this._subscriptions[event] = new Array();
1501
1565
  }
1502
1566
  this._subscriptions[event].push(subscriptionInstance);
1503
1567
  if (isTC39Callback && LATEST_VALUE in this) {
@@ -1540,7 +1604,7 @@ var ko_subscribable_fn = {
1540
1604
  if (event) {
1541
1605
  return this._subscriptions[event] && this._subscriptions[event].length || 0;
1542
1606
  } else {
1543
- var total = 0;
1607
+ let total = 0;
1544
1608
  objectForEach(this._subscriptions, function(eventName, subscriptions) {
1545
1609
  if (eventName !== "dirty") {
1546
1610
  total += subscriptions.length;
@@ -1595,6 +1659,7 @@ function observable(initialValue) {
1595
1659
  function Observable() {
1596
1660
  if (arguments.length > 0) {
1597
1661
  if (Observable.isDifferent(Observable[LATEST_VALUE], arguments[0])) {
1662
+ ;
1598
1663
  Observable.valueWillMutate();
1599
1664
  Observable[LATEST_VALUE] = arguments[0];
1600
1665
  Observable.valueHasMutated();
@@ -1615,20 +1680,43 @@ function observable(initialValue) {
1615
1680
  return Observable;
1616
1681
  }
1617
1682
  observable.fn = {
1683
+ /**
1684
+ * Compares two values for equality.
1685
+ * @param a The first value.
1686
+ * @param b The second value.
1687
+ * @returns True if the values are equal, otherwise false.
1688
+ */
1618
1689
  equalityComparer: valuesArePrimitiveAndEqual,
1690
+ /**
1691
+ * Returns the current value of the observable without creating a dependency.
1692
+ * @returns The current value.
1693
+ */
1619
1694
  peek() {
1620
1695
  return this[LATEST_VALUE];
1621
1696
  },
1697
+ /**
1698
+ * Notifies subscribers that the value has changed.
1699
+ */
1622
1700
  valueHasMutated() {
1623
1701
  this.notifySubscribers(this[LATEST_VALUE], "spectate");
1624
1702
  this.notifySubscribers(this[LATEST_VALUE]);
1625
1703
  },
1704
+ /**
1705
+ * Notifies subscribers that the value is about to change.
1706
+ */
1626
1707
  valueWillMutate() {
1627
1708
  this.notifySubscribers(this[LATEST_VALUE], "beforeChange");
1628
1709
  },
1710
+ /**
1711
+ * Modifies the value of the observable using a function.
1712
+ * @param fn The function to modify the value.
1713
+ * @param peek Whether to use the current value without creating a dependency.
1714
+ * @returns The modified observable.
1715
+ */
1629
1716
  modify(fn, peek22 = true) {
1630
- return this(fn(peek22 ? this.peek() : this()));
1717
+ this(fn(peek22 ? this.peek() : this()));
1631
1718
  },
1719
+ // Some observables may not always be writeable, notably computeds.
1632
1720
  isWriteable: true
1633
1721
  };
1634
1722
  function limitNotifySubscribers(value, event) {
@@ -1641,15 +1729,15 @@ function limitNotifySubscribers(value, event) {
1641
1729
  }
1642
1730
  }
1643
1731
  subscribable.fn.limit = function limit(limitFunction) {
1644
- var self = this;
1645
- var selfIsObservable = isObservable(self);
1646
- var beforeChange = "beforeChange";
1647
- var ignoreBeforeChange, notifyNextChange, previousValue, pendingValue, didUpdate;
1732
+ const self = this;
1733
+ const selfIsObservable = isObservable(self);
1734
+ const beforeChange = "beforeChange";
1735
+ let ignoreBeforeChange, notifyNextChange, previousValue, pendingValue, didUpdate;
1648
1736
  if (!self._origNotifySubscribers) {
1649
1737
  self._origNotifySubscribers = self.notifySubscribers;
1650
1738
  self.notifySubscribers = limitNotifySubscribers;
1651
1739
  }
1652
- var finish = limitFunction(function() {
1740
+ const finish = limitFunction(function() {
1653
1741
  self._notificationIsPending = false;
1654
1742
  if (selfIsObservable && pendingValue === self) {
1655
1743
  pendingValue = self._evalIfChanged ? self._evalIfChanged() : self();
@@ -1677,7 +1765,10 @@ subscribable.fn.limit = function limit(limitFunction) {
1677
1765
  }
1678
1766
  },
1679
1767
  _notifyNextChangeIfValueIsDifferent() {
1680
- if (self.isDifferent(previousValue, self.peek(true))) {
1768
+ if (self.isDifferent(previousValue, self.peek(
1769
+ true
1770
+ /* evaluate */
1771
+ ))) {
1681
1772
  notifyNextChange = true;
1682
1773
  }
1683
1774
  },
@@ -1723,8 +1814,8 @@ function trackArrayChanges(target, options2) {
1723
1814
  let arrayChangeSubscription;
1724
1815
  let pendingNotifications = 0;
1725
1816
  let underlyingNotifySubscribersFunction;
1726
- let underlyingBeforeSubscriptionAddFunction = target.beforeSubscriptionAdd;
1727
- let underlyingAfterSubscriptionRemoveFunction = target.afterSubscriptionRemove;
1817
+ const underlyingBeforeSubscriptionAddFunction = target.beforeSubscriptionAdd;
1818
+ const underlyingAfterSubscriptionRemoveFunction = target.afterSubscriptionRemove;
1728
1819
  target.beforeSubscriptionAdd = function(event) {
1729
1820
  if (underlyingBeforeSubscriptionAddFunction) {
1730
1821
  underlyingBeforeSubscriptionAddFunction.call(target, event);
@@ -1761,11 +1852,11 @@ function trackArrayChanges(target, options2) {
1761
1852
  }
1762
1853
  return underlyingNotifySubscribersFunction.apply(this, arguments);
1763
1854
  };
1764
- var previousContents = [].concat(target.peek() === void 0 ? [] : target.peek());
1855
+ let previousContents = new Array().concat(target.peek() === void 0 ? [] : target.peek());
1765
1856
  cachedDiff = null;
1766
1857
  arrayChangeSubscription = target.subscribe(function(currentContents) {
1767
1858
  let changes;
1768
- currentContents = [].concat(currentContents || []);
1859
+ currentContents = new Array().concat(currentContents || []);
1769
1860
  if (target.hasSubscriptionsForEvent(arrayChangeEventName)) {
1770
1861
  changes = getChanges(previousContents, currentContents);
1771
1862
  }
@@ -1787,9 +1878,9 @@ function trackArrayChanges(target, options2) {
1787
1878
  if (!trackingChanges || pendingNotifications) {
1788
1879
  return;
1789
1880
  }
1790
- var diff = [], arrayLength = rawArray.length, argsLength = args.length, offset = 0;
1881
+ let diff = new Array(), arrayLength = rawArray.length, argsLength = args.length, offset = 0;
1791
1882
  function pushDiff(status, value, index) {
1792
- return diff[diff.length] = { "status": status, "value": value, "index": index };
1883
+ return diff[diff.length] = { status, value, index };
1793
1884
  }
1794
1885
  switch (operationName) {
1795
1886
  case "push":
@@ -1807,16 +1898,18 @@ function trackArrayChanges(target, options2) {
1807
1898
  }
1808
1899
  break;
1809
1900
  case "splice":
1810
- var startIndex = Math.min(Math.max(0, args[0] < 0 ? arrayLength + args[0] : args[0]), arrayLength), endDeleteIndex = argsLength === 1 ? arrayLength : Math.min(startIndex + (args[1] || 0), arrayLength), endAddIndex = startIndex + argsLength - 2, endIndex = Math.max(endDeleteIndex, endAddIndex), additions = [], deletions = [];
1811
- for (let index = startIndex, argsIndex = 2; index < endIndex; ++index, ++argsIndex) {
1812
- if (index < endDeleteIndex) {
1813
- deletions.push(pushDiff("deleted", rawArray[index], index));
1814
- }
1815
- if (index < endAddIndex) {
1816
- additions.push(pushDiff("added", args[argsIndex], index));
1901
+ {
1902
+ const startIndex = Math.min(Math.max(0, args[0] < 0 ? arrayLength + args[0] : args[0]), arrayLength), endDeleteIndex = argsLength === 1 ? arrayLength : Math.min(startIndex + (args[1] || 0), arrayLength), endAddIndex = startIndex + argsLength - 2, endIndex = Math.max(endDeleteIndex, endAddIndex), additions = new Array(), deletions = new Array();
1903
+ for (let index = startIndex, argsIndex = 2; index < endIndex; ++index, ++argsIndex) {
1904
+ if (index < endDeleteIndex) {
1905
+ deletions.push(pushDiff("deleted", rawArray[index], index));
1906
+ }
1907
+ if (index < endAddIndex) {
1908
+ additions.push(pushDiff("added", args[argsIndex], index));
1909
+ }
1817
1910
  }
1911
+ findMovesInArrayComparison(deletions, additions);
1818
1912
  }
1819
- findMovesInArrayComparison(deletions, additions);
1820
1913
  break;
1821
1914
  default:
1822
1915
  return;
@@ -1831,12 +1924,16 @@ extenders.trackArrayChanges = trackArrayChanges;
1831
1924
  function observableArray(initialValues) {
1832
1925
  initialValues = initialValues || [];
1833
1926
  if (typeof initialValues !== "object" || !("length" in initialValues)) {
1834
- throw new Error("The argument passed when initializing an observable array must be an array, or null, or undefined.");
1927
+ throw new Error(
1928
+ "The argument passed when initializing an observable array must be an array, or null, or undefined."
1929
+ );
1835
1930
  }
1836
- var result = observable(initialValues);
1837
- Object.setPrototypeOf(result, observableArray.fn);
1931
+ const result = Object.setPrototypeOf(observable(initialValues), observableArray.fn);
1838
1932
  trackArrayChanges(result);
1839
- overwriteLengthPropertyIfSupported(result, { get: () => result().length });
1933
+ overwriteLengthPropertyIfSupported(result, { get: () => {
1934
+ var _a;
1935
+ return (_a = result()) == null ? void 0 : _a.length;
1936
+ } });
1840
1937
  return result;
1841
1938
  }
1842
1939
  function isObservableArray(instance) {
@@ -1844,13 +1941,13 @@ function isObservableArray(instance) {
1844
1941
  }
1845
1942
  observableArray.fn = {
1846
1943
  remove(valueOrPredicate) {
1847
- var underlyingArray = this.peek();
1848
- var removedValues = [];
1849
- var predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value2) {
1850
- return value2 === valueOrPredicate;
1944
+ const underlyingArray = this.peek();
1945
+ const removedValues = new Array();
1946
+ const predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value) {
1947
+ return value === valueOrPredicate;
1851
1948
  };
1852
- for (var i = 0; i < underlyingArray.length; i++) {
1853
- var value = underlyingArray[i];
1949
+ for (let i = 0; i < underlyingArray.length; i++) {
1950
+ const value = underlyingArray[i];
1854
1951
  if (predicate(value)) {
1855
1952
  if (removedValues.length === 0) {
1856
1953
  this.valueWillMutate();
@@ -1870,8 +1967,8 @@ observableArray.fn = {
1870
1967
  },
1871
1968
  removeAll(arrayOfValues) {
1872
1969
  if (arrayOfValues === void 0) {
1873
- var underlyingArray = this.peek();
1874
- var allValues = underlyingArray.slice(0);
1970
+ const underlyingArray = this.peek();
1971
+ const allValues = underlyingArray.slice(0);
1875
1972
  this.valueWillMutate();
1876
1973
  underlyingArray.splice(0, underlyingArray.length);
1877
1974
  this.valueHasMutated();
@@ -1885,13 +1982,13 @@ observableArray.fn = {
1885
1982
  });
1886
1983
  },
1887
1984
  destroy(valueOrPredicate) {
1888
- var underlyingArray = this.peek();
1889
- var predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value2) {
1890
- return value2 === valueOrPredicate;
1985
+ const underlyingArray = this.peek();
1986
+ const predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value) {
1987
+ return value === valueOrPredicate;
1891
1988
  };
1892
1989
  this.valueWillMutate();
1893
- for (var i = underlyingArray.length - 1; i >= 0; i--) {
1894
- var value = underlyingArray[i];
1990
+ for (let i = underlyingArray.length - 1; i >= 0; i--) {
1991
+ const value = underlyingArray[i];
1895
1992
  if (predicate(value)) {
1896
1993
  value["_destroy"] = true;
1897
1994
  }
@@ -1915,7 +2012,7 @@ observableArray.fn = {
1915
2012
  return arrayIndexOf(this(), item);
1916
2013
  },
1917
2014
  replace(oldItem, newItem) {
1918
- var index = this.indexOf(oldItem);
2015
+ const index = this.indexOf(oldItem);
1919
2016
  if (index >= 0) {
1920
2017
  this.valueWillMutate();
1921
2018
  this.peek()[index] = newItem;
@@ -1929,23 +2026,23 @@ observableArray.fn = {
1929
2026
  return [...this()].reverse();
1930
2027
  },
1931
2028
  [Symbol.iterator]: function* () {
1932
- yield* this();
2029
+ yield* __yieldStar(this());
1933
2030
  }
1934
2031
  };
1935
2032
  Object.setPrototypeOf(observableArray.fn, observable.fn);
1936
2033
  arrayForEach(["pop", "push", "reverse", "shift", "sort", "splice", "unshift"], function(methodName) {
1937
2034
  observableArray.fn[methodName] = function() {
1938
- var underlyingArray = this.peek();
2035
+ const underlyingArray = this.peek();
1939
2036
  this.valueWillMutate();
1940
2037
  this.cacheDiffForKnownOperation(underlyingArray, methodName, arguments);
1941
- var methodCallResult = underlyingArray[methodName].apply(underlyingArray, arguments);
2038
+ const methodCallResult = underlyingArray[methodName].apply(underlyingArray, arguments);
1942
2039
  this.valueHasMutated();
1943
2040
  return methodCallResult === underlyingArray ? this : methodCallResult;
1944
2041
  };
1945
2042
  });
1946
2043
  arrayForEach(["slice"], function(methodName) {
1947
2044
  observableArray.fn[methodName] = function() {
1948
- var underlyingArray = this();
2045
+ const underlyingArray = this();
1949
2046
  return underlyingArray[methodName].apply(underlyingArray, arguments);
1950
2047
  };
1951
2048
  });
@@ -1958,26 +2055,26 @@ function toJS(rootObject) {
1958
2055
  throw new Error("When calling ko.toJS, pass the object you want to convert.");
1959
2056
  }
1960
2057
  return mapJsObjectGraph(rootObject, function(valueToMap) {
1961
- for (var i = 0; isObservable(valueToMap) && i < maxNestedObservableDepth; i++) {
2058
+ for (let i = 0; isObservable(valueToMap) && i < maxNestedObservableDepth; i++) {
1962
2059
  valueToMap = valueToMap();
1963
2060
  }
1964
2061
  return valueToMap;
1965
2062
  });
1966
2063
  }
1967
2064
  function toJSON(rootObject, replacer, space) {
1968
- var plainJavaScriptObject = toJS(rootObject);
2065
+ const plainJavaScriptObject = toJS(rootObject);
1969
2066
  return JSON.stringify(plainJavaScriptObject, replacer, space);
1970
2067
  }
1971
2068
  function mapJsObjectGraph(rootObject, mapInputCallback, visitedObjects = /* @__PURE__ */ new Map()) {
1972
2069
  rootObject = mapInputCallback(rootObject);
1973
- var canHaveProperties = typeof rootObject === "object" && rootObject !== null && rootObject !== void 0 && !(rootObject instanceof RegExp) && !(rootObject instanceof Date) && !(rootObject instanceof String) && !(rootObject instanceof Number) && !(rootObject instanceof Boolean);
2070
+ const canHaveProperties = typeof rootObject === "object" && rootObject !== null && rootObject !== void 0 && !(rootObject instanceof RegExp) && !(rootObject instanceof Date) && !(rootObject instanceof String) && !(rootObject instanceof Number) && !(rootObject instanceof Boolean);
1974
2071
  if (!canHaveProperties) {
1975
2072
  return rootObject;
1976
2073
  }
1977
- var outputProperties = rootObject instanceof Array ? [] : {};
2074
+ const outputProperties = rootObject instanceof Array ? [] : {};
1978
2075
  visitedObjects.set(rootObject, outputProperties);
1979
2076
  visitPropertiesOrArrayEntries(rootObject, function(indexer) {
1980
- var propertyValue = mapInputCallback(rootObject[indexer]);
2077
+ const propertyValue = mapInputCallback(rootObject[indexer]);
1981
2078
  switch (typeof propertyValue) {
1982
2079
  case "boolean":
1983
2080
  case "number":
@@ -1987,8 +2084,10 @@ function mapJsObjectGraph(rootObject, mapInputCallback, visitedObjects = /* @__P
1987
2084
  break;
1988
2085
  case "object":
1989
2086
  case "undefined":
1990
- var previouslyMappedValue = visitedObjects.get(propertyValue);
1991
- outputProperties[indexer] = previouslyMappedValue !== void 0 ? previouslyMappedValue : mapJsObjectGraph(propertyValue, mapInputCallback, visitedObjects);
2087
+ {
2088
+ const previouslyMappedValue = visitedObjects.get(propertyValue);
2089
+ outputProperties[indexer] = previouslyMappedValue !== void 0 ? previouslyMappedValue : mapJsObjectGraph(propertyValue, mapInputCallback, visitedObjects);
2090
+ }
1992
2091
  break;
1993
2092
  }
1994
2093
  });
@@ -1996,21 +2095,20 @@ function mapJsObjectGraph(rootObject, mapInputCallback, visitedObjects = /* @__P
1996
2095
  }
1997
2096
  function visitPropertiesOrArrayEntries(rootObject, visitorCallback) {
1998
2097
  if (rootObject instanceof Array) {
1999
- for (var i = 0; i < rootObject.length; i++) {
2098
+ for (let i = 0; i < rootObject.length; i++) {
2000
2099
  visitorCallback(i);
2001
2100
  }
2002
2101
  if (typeof rootObject["toJSON"] === "function") {
2003
2102
  visitorCallback("toJSON");
2004
2103
  }
2005
2104
  } else {
2006
- for (var propertyName in rootObject) {
2105
+ for (const propertyName in rootObject) {
2007
2106
  visitorCallback(propertyName);
2008
2107
  }
2009
2108
  }
2010
2109
  }
2011
2110
 
2012
2111
  // ../utils.parser/dist/operators.js
2013
- var __pow = Math.pow;
2014
2112
  function LAMBDA() {
2015
2113
  }
2016
2114
  function unwrapOrCall(a, b) {
@@ -2020,8 +2118,10 @@ function unwrapOrCall(a, b) {
2020
2118
  return b;
2021
2119
  }
2022
2120
  var operators = {
2121
+ // unary
2023
2122
  "@": unwrapOrCall,
2024
2123
  "#": (a, b) => () => unwrap(b),
2124
+ // Convert to read-only.
2025
2125
  "=>": LAMBDA,
2026
2126
  "!": function not(a, b) {
2027
2127
  return !b;
@@ -2035,9 +2135,11 @@ var operators = {
2035
2135
  "--": function preinc2(a, b) {
2036
2136
  return --b;
2037
2137
  },
2138
+ // exponent
2038
2139
  "**": function exp(a, b) {
2039
2140
  return __pow(a, b);
2040
2141
  },
2142
+ // mul/div
2041
2143
  "*": function mul(a, b) {
2042
2144
  return a * b;
2043
2145
  },
@@ -2047,6 +2149,7 @@ var operators = {
2047
2149
  "%": function mod(a, b) {
2048
2150
  return a % b;
2049
2151
  },
2152
+ // sub/add
2050
2153
  "+": function add(a, b) {
2051
2154
  return a + b;
2052
2155
  },
@@ -2056,6 +2159,8 @@ var operators = {
2056
2159
  "&-": function neg(a, b) {
2057
2160
  return -1 * b;
2058
2161
  },
2162
+ // unary -
2163
+ // relational
2059
2164
  "<": function lt(a, b) {
2060
2165
  return a < b;
2061
2166
  },
@@ -2068,11 +2173,15 @@ var operators = {
2068
2173
  ">=": function ge(a, b) {
2069
2174
  return a >= b;
2070
2175
  },
2176
+ // TODO: 'in': function (a, b) { return a in b; },
2177
+ // TODO: 'instanceof': function (a, b) { return a instanceof b; },
2178
+ // TODO: 'typeof': function (a, b) { return typeof b; },
2179
+ // equality
2071
2180
  "==": function equal(a, b) {
2072
- return a === b;
2181
+ return a == b;
2073
2182
  },
2074
2183
  "!=": function ne(a, b) {
2075
- return a !== b;
2184
+ return a != b;
2076
2185
  },
2077
2186
  "===": function sequal(a, b) {
2078
2187
  return a === b;
@@ -2080,6 +2189,7 @@ var operators = {
2080
2189
  "!==": function sne(a, b) {
2081
2190
  return a !== b;
2082
2191
  },
2192
+ // bitwise
2083
2193
  "&": function bitAnd(a, b) {
2084
2194
  return a & b;
2085
2195
  },
@@ -2089,6 +2199,7 @@ var operators = {
2089
2199
  "|": function bitOr(a, b) {
2090
2200
  return a | b;
2091
2201
  },
2202
+ // logic
2092
2203
  "&&": function logicAnd(a, b) {
2093
2204
  return a && b;
2094
2205
  },
@@ -2098,6 +2209,7 @@ var operators = {
2098
2209
  "??": function nullishCoalesce(a, b) {
2099
2210
  return a != null ? a : b;
2100
2211
  },
2212
+ // Access
2101
2213
  ".": function member(a, b) {
2102
2214
  return a == null ? void 0 : a[b];
2103
2215
  },
@@ -2110,7 +2222,10 @@ var operators = {
2110
2222
  ",": function comma(a, b) {
2111
2223
  return b;
2112
2224
  },
2113
- "call": function callOp(a, b) {
2225
+ // conditional/ternary
2226
+ // '?': ternary See Node.js
2227
+ // Function-Call
2228
+ call: function callOp(a, b) {
2114
2229
  return a.apply(null, b);
2115
2230
  }
2116
2231
  };
@@ -2124,7 +2239,7 @@ operators["!!"].precedence = 16;
2124
2239
  operators["++"].precedence = 16;
2125
2240
  operators["--"].precedence = 16;
2126
2241
  operators["&-"].precedence = 16;
2127
- operators["**"].precedent = 15;
2242
+ operators["**"].precedence = 15;
2128
2243
  operators["%"].precedence = 14;
2129
2244
  operators["*"].precedence = 14;
2130
2245
  operators["/"].precedence = 14;
@@ -2152,8 +2267,8 @@ operators["call"].precedence = 1;
2152
2267
  operators["=>"].precedence = 1;
2153
2268
 
2154
2269
  // ../utils.parser/dist/Node.js
2155
- var IS_EXPR_OR_IDENT = Symbol("Node - Is Expression Or Identifier");
2156
- var Node = class {
2270
+ var IS_EXPR_OR_IDENT = /* @__PURE__ */ Symbol("Node - Is Expression Or Identifier");
2271
+ var Node2 = class _Node {
2157
2272
  constructor(lhs, op, rhs) {
2158
2273
  this.lhs = lhs;
2159
2274
  this.op = op;
@@ -2169,11 +2284,20 @@ var Node = class {
2169
2284
  if (typeof leaf !== "object" || leaf === null) {
2170
2285
  return leaf;
2171
2286
  }
2172
- if (leaf[Node.isExpressionOrIdentifierSymbol]) {
2287
+ if (leaf[_Node.isExpressionOrIdentifierSymbol]) {
2173
2288
  return unwrap(leaf.get_value(void 0, context, globals, node));
2174
2289
  }
2175
2290
  return leaf;
2176
2291
  }
2292
+ /**
2293
+ * Return a function that calculates and returns an expression's value
2294
+ * when called.
2295
+ * @param {array} ops The operations to perform
2296
+ * @return {function} The function that calculates the expression.
2297
+ *
2298
+ * Note that for a lambda, we do not evaluate the RHS expression until
2299
+ * the lambda is called.
2300
+ */
2177
2301
  get_value(notused, context, globals, node) {
2178
2302
  var node = this;
2179
2303
  if (node.op === LAMBDA) {
@@ -2193,6 +2317,9 @@ var Node = class {
2193
2317
  const rhv = node.get_leaf_value(node.rhs, context, globals, node);
2194
2318
  return node.op(lhv, rhv, context, globals);
2195
2319
  }
2320
+ //
2321
+ // Class variables.
2322
+ //
2196
2323
  static get isExpressionOrIdentifierSymbol() {
2197
2324
  return IS_EXPR_OR_IDENT;
2198
2325
  }
@@ -2200,14 +2327,20 @@ var Node = class {
2200
2327
  return true;
2201
2328
  }
2202
2329
  static value_of(item, context, globals, node) {
2203
- if (item && item[Node.isExpressionOrIdentifierSymbol]) {
2330
+ if (item && item[_Node.isExpressionOrIdentifierSymbol]) {
2204
2331
  return item.get_value(item, context, globals, node);
2205
2332
  }
2206
2333
  return item;
2207
2334
  }
2335
+ /**
2336
+ * Convert an array of nodes to an executable tree.
2337
+ * @return {object} An object with a `lhs`, `rhs` and `op` key, corresponding
2338
+ * to the left hand side, right hand side, and
2339
+ * operation function.
2340
+ */
2208
2341
  static create_root(nodes, debug = false) {
2209
- const out = [];
2210
- const ops = [];
2342
+ const out = new Array();
2343
+ const ops = new Array();
2211
2344
  for (let i = 0; i < nodes.length; i += 2) {
2212
2345
  out.push(nodes[i]);
2213
2346
  const op = nodes[i + 1];
@@ -2215,7 +2348,7 @@ var Node = class {
2215
2348
  while (ops.length && prec <= ops[ops.length - 1].precedence) {
2216
2349
  const rhs = out.pop();
2217
2350
  const lhs = out.pop();
2218
- out.push(new Node(lhs, ops.pop(), rhs));
2351
+ out.push(new _Node(lhs, ops.pop(), rhs));
2219
2352
  }
2220
2353
  ops.push(op);
2221
2354
  }
@@ -2226,7 +2359,7 @@ var Node = class {
2226
2359
  }
2227
2360
  };
2228
2361
  operators["?"] = function ternary(a, b, context, globals, node) {
2229
- return Node.value_of(a ? b.yes : b.no, context, globals, node);
2362
+ return Node2.value_of(a ? b.yes : b.no, context, globals, node);
2230
2363
  };
2231
2364
  operators["?"].precedence = 4;
2232
2365
 
@@ -2234,16 +2367,19 @@ operators["?"].precedence = 4;
2234
2367
  var Expression = class {
2235
2368
  constructor(nodes) {
2236
2369
  this.nodes = nodes;
2237
- this.root = Node.create_root(nodes);
2370
+ this.root = Node2.create_root(nodes);
2238
2371
  }
2372
+ /**
2373
+ * Return the value of `this` Expression instance.
2374
+ */
2239
2375
  get_value(parent, context, globals, node) {
2240
2376
  if (!this.root) {
2241
- this.root = Node.create_root(this.nodes);
2377
+ this.root = Node2.create_root(this.nodes);
2242
2378
  }
2243
2379
  return this.root.get_value(parent, context, globals, node);
2244
2380
  }
2245
2381
  };
2246
- Expression.prototype[Node.isExpressionOrIdentifierSymbol] = true;
2382
+ Expression.prototype[Node2.isExpressionOrIdentifierSymbol] = true;
2247
2383
 
2248
2384
  // ../utils.parser/dist/Arguments.js
2249
2385
  var Arguments = class {
@@ -2252,13 +2388,13 @@ var Arguments = class {
2252
2388
  this.args = args;
2253
2389
  }
2254
2390
  get_value(parent, context, globals, node) {
2255
- var deReffedArgs = [];
2256
- for (var i = 0, j = this.args.length; i < j; ++i) {
2257
- deReffedArgs.push(Node.value_of(this.args[i], context, globals, node));
2391
+ const deReffedArgs = new Array();
2392
+ for (let i = 0, j = this.args.length; i < j; ++i) {
2393
+ deReffedArgs.push(Node2.value_of(this.args[i], context, globals, node));
2258
2394
  }
2259
2395
  return deReffedArgs;
2260
2396
  }
2261
- get [Node.isExpressionOrIdentifierSymbol]() {
2397
+ get [Node2.isExpressionOrIdentifierSymbol]() {
2262
2398
  return true;
2263
2399
  }
2264
2400
  };
@@ -2268,20 +2404,41 @@ var IDStart = /[\$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\
2268
2404
  var IDContinue = /[\$0-9A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/;
2269
2405
 
2270
2406
  // ../utils.parser/dist/Identifier.js
2271
- var Identifier = class {
2407
+ var Identifier = class _Identifier {
2272
2408
  constructor(parser, token, dereferences) {
2273
2409
  this.token = token;
2274
2410
  this.dereferences = dereferences;
2275
2411
  this.parser = parser;
2276
2412
  }
2413
+ /**
2414
+ * Apply all () and [] functions on the identifier to the lhs value e.g.
2415
+ * a()[3] has deref functions that are essentially this:
2416
+ * [_deref_call, _deref_this where this=3]
2417
+ *
2418
+ * @param {mixed} value Should be an object.
2419
+ * @return {mixed} The dereferenced value.
2420
+ *
2421
+ * [1] We want to bind any function that is a method of an object, but not
2422
+ * corrupt any values (e.g. computed()s). e.g. Running x.bind(obj) where
2423
+ * we're given `data-bind='binding: obj.x'` and x is a computed will
2424
+ * break the computed's `this` and it will stop working as expected.
2425
+ *
2426
+ * The test `!last_value.hasOwnProperty(member)`
2427
+ * distinguishes between functions on the prototype chain (prototypal
2428
+ * members) and value-members added directly to the object. This may
2429
+ * not be the canonical test for this relationship, but it succeeds
2430
+ * in the known test cases.
2431
+ *
2432
+ * See: `this` tests of our dereference function.
2433
+ */
2277
2434
  dereference(value, $context, globals, node) {
2278
2435
  let member2;
2279
- let refs = this.dereferences || [];
2436
+ const refs = this.dereferences || [];
2280
2437
  const $data = $context.$data || {};
2281
2438
  let lastValue;
2282
2439
  let i, n;
2283
2440
  for (i = 0, n = refs.length; i < n; ++i) {
2284
- member2 = Node.value_of(refs[i], $context, globals, node);
2441
+ member2 = Node2.value_of(refs[i], $context, globals, node);
2285
2442
  if (typeof value === "function" && refs[i] instanceof Arguments) {
2286
2443
  value = value.apply(lastValue || $data, member2);
2287
2444
  lastValue = value;
@@ -2289,7 +2446,7 @@ var Identifier = class {
2289
2446
  return value;
2290
2447
  } else {
2291
2448
  lastValue = value;
2292
- value = Node.value_of(value[member2], $context, globals, node);
2449
+ value = Node2.value_of(value[member2], $context, globals, node);
2293
2450
  }
2294
2451
  }
2295
2452
  if (typeof value === "function" && n > 0 && lastValue !== value && !hasOwnProperty(lastValue, member2)) {
@@ -2297,17 +2454,32 @@ var Identifier = class {
2297
2454
  }
2298
2455
  return value;
2299
2456
  }
2457
+ /**
2458
+ * Return the value as one would get it from the top-level i.e.
2459
+ * $data.token/$context.token/globals.token; this does not return intermediate
2460
+ * values on a chain of members i.e. $data.hello.there -- requesting the
2461
+ * Identifier('there').value will return $data/$context/globals.there.
2462
+ *
2463
+ * This will dereference using () or [arg] member.
2464
+ * @param {object | Identifier | Expression} parent
2465
+ * @return {mixed} Return the primitive or an accessor.
2466
+ */
2300
2467
  get_value(parent, context, globals, node) {
2301
- const intermediate = parent && !(parent instanceof Identifier) ? Node.value_of(parent, context, globals, node)[this.token] : context.lookup(this.token, globals, node);
2468
+ const intermediate = parent && !(parent instanceof _Identifier) ? Node2.value_of(parent, context, globals, node)[this.token] : context.lookup(this.token, globals, node);
2302
2469
  return this.dereference(intermediate, context, globals, node);
2303
2470
  }
2304
- assign(object2, property, value) {
2305
- if (isWriteableObservable(object2[property])) {
2306
- object2[property](value);
2307
- } else if (!isObservable(object2[property])) {
2308
- object2[property] = value;
2471
+ assign(object, property, value) {
2472
+ if (isWriteableObservable(object[property])) {
2473
+ object[property](value);
2474
+ } else if (!isObservable(object[property])) {
2475
+ object[property] = value;
2309
2476
  }
2310
2477
  }
2478
+ /**
2479
+ * Set the value of the Identifier.
2480
+ *
2481
+ * @param {Mixed} new_value The value that Identifier is to be set to.
2482
+ */
2311
2483
  set_value(new_value, $context, globals) {
2312
2484
  const $data = $context.$data || {};
2313
2485
  const refs = this.dereferences || [];
@@ -2320,7 +2492,9 @@ var Identifier = class {
2320
2492
  } else if (leaf in globals) {
2321
2493
  root = globals;
2322
2494
  } else {
2323
- throw new Error("Identifier::set_value -- The property '" + leaf + "' does not exist on the $data, $context, or globals.");
2495
+ throw new Error(
2496
+ "Identifier::set_value -- The property '" + leaf + "' does not exist on the $data, $context, or globals."
2497
+ );
2324
2498
  }
2325
2499
  n = refs.length;
2326
2500
  if (n === 0) {
@@ -2333,55 +2507,72 @@ var Identifier = class {
2333
2507
  if (leaf instanceof Arguments) {
2334
2508
  root = root();
2335
2509
  } else {
2336
- root = root[Node.value_of(leaf)];
2510
+ root = root[Node2.value_of(leaf)];
2337
2511
  }
2338
2512
  }
2339
2513
  if (refs[i] === true) {
2340
2514
  throw new Error("Cannot assign a value to a function.");
2341
2515
  }
2342
2516
  if (refs[i]) {
2343
- this.assign(root, Node.value_of(refs[i]), new_value);
2344
- }
2345
- }
2517
+ this.assign(root, Node2.value_of(refs[i]), new_value);
2518
+ }
2519
+ }
2520
+ /**
2521
+ * Determine if a character is a valid item in an identifier.
2522
+ * Note that we do not check whether the first item is a number, nor do we
2523
+ * support unicode identifiers here.
2524
+ *
2525
+ * From: http://stackoverflow.com/a/9337047
2526
+ * @param {String} ch The character
2527
+ * @return {Boolean} True if this is a valid identifier
2528
+ */
2529
+ // function is_identifier_char(ch) {
2530
+ // return (ch >= 'A' && ch <= 'Z') ||
2531
+ // (ch >= 'a' && ch <= 'z') ||
2532
+ // (ch >= '0' && ch <= 9) ||
2533
+ // ch === '_' || ch === '$';
2534
+ // }
2346
2535
  static is_valid_start_char(ch) {
2347
2536
  return IDStart.test(ch);
2348
2537
  }
2349
2538
  static is_valid_continue_char(ch) {
2350
2539
  return IDContinue.test(ch);
2351
2540
  }
2352
- get [Node.isExpressionOrIdentifierSymbol]() {
2541
+ get [Node2.isExpressionOrIdentifierSymbol]() {
2353
2542
  return true;
2354
2543
  }
2355
2544
  };
2356
2545
 
2357
2546
  // ../utils.parser/dist/Parameters.js
2358
- var Parameters = class {
2547
+ var _names;
2548
+ var _Parameters = class _Parameters {
2359
2549
  constructor(parser, node) {
2550
+ __privateAdd(this, _names);
2360
2551
  if (node instanceof Expression) {
2361
2552
  node = node.root;
2362
2553
  }
2363
2554
  try {
2364
- this.names = Parameters.nodeTreeToNames(node);
2555
+ __privateSet(this, _names, _Parameters.nodeTreeToNames(node));
2365
2556
  } catch (e) {
2366
2557
  parser.error(e);
2367
2558
  }
2368
2559
  }
2369
2560
  extendContext(context, args) {
2370
- if (!this.names) {
2561
+ if (!__privateGet(this, _names)) {
2371
2562
  return context;
2372
2563
  } else {
2373
2564
  const newValues = {};
2374
- this.names.forEach((name, index) => {
2565
+ __privateGet(this, _names).forEach((name, index) => {
2375
2566
  newValues[name] = args[index];
2376
2567
  });
2377
2568
  return context.extend(newValues);
2378
2569
  }
2379
2570
  }
2380
- get [Node.isExpressionOrIdentifierSymbol]() {
2571
+ get [Node2.isExpressionOrIdentifierSymbol]() {
2381
2572
  return true;
2382
2573
  }
2383
2574
  static nodeTreeToNames(node) {
2384
- const names = [];
2575
+ const names = new Array();
2385
2576
  while (node) {
2386
2577
  if (node instanceof Identifier) {
2387
2578
  names.push(node.token);
@@ -2390,16 +2581,20 @@ var Parameters = class {
2390
2581
  names.push(node.rhs.token);
2391
2582
  node = node.lhs;
2392
2583
  } else {
2393
- throw new Error(`only simple identifiers allowed in lambda parameter list but found ${JSON.stringify(node, null, 2)}`);
2584
+ throw new Error(
2585
+ `only simple identifiers allowed in lambda parameter list but found ${JSON.stringify(node, null, 2)}`
2586
+ );
2394
2587
  }
2395
2588
  }
2396
2589
  names.reverse();
2397
2590
  return names;
2398
2591
  }
2399
2592
  static isCommaNode(node) {
2400
- return node instanceof Node && node.op === operators[","] && node.rhs instanceof Identifier;
2593
+ return node instanceof Node2 && node.op === operators[","] && node.rhs instanceof Identifier;
2401
2594
  }
2402
2595
  };
2596
+ _names = new WeakMap();
2597
+ var Parameters = _Parameters;
2403
2598
 
2404
2599
  // ../utils.parser/dist/Ternary.js
2405
2600
  var Ternary = class {
@@ -2409,50 +2604,58 @@ var Ternary = class {
2409
2604
  get_value() {
2410
2605
  return this;
2411
2606
  }
2412
- get [Node.isExpressionOrIdentifierSymbol]() {
2607
+ get [Node2.isExpressionOrIdentifierSymbol]() {
2413
2608
  return true;
2414
2609
  }
2415
2610
  };
2416
2611
 
2417
2612
  // ../utils.parser/dist/preparse.js
2418
2613
  var specials = ",\"'`{}()/:[\\]";
2419
- var bindingToken = RegExp([
2420
- '"(?:\\\\.|[^"])*"',
2421
- "'(?:\\\\.|[^'])*'",
2422
- "`(?:\\\\.|[^`])*`",
2423
- "/\\*(?:[^*]|\\*+[^*/])*\\*+/",
2424
- "//.*\n",
2425
- "/(?:\\\\.|[^/])+/\\w*",
2426
- "[^\\s:,/][^" + specials + "]*[^\\s" + specials + "]",
2427
- "[^\\s]"
2428
- ].join("|"), "g");
2614
+ var bindingToken = RegExp(
2615
+ [
2616
+ // These match strings, either with double quotes, single quotes, or backticks
2617
+ '"(?:\\\\.|[^"])*"',
2618
+ "'(?:\\\\.|[^'])*'",
2619
+ "`(?:\\\\.|[^`])*`",
2620
+ // Match C style comments
2621
+ "/\\*(?:[^*]|\\*+[^*/])*\\*+/",
2622
+ // Match C++ style comments
2623
+ "//.*\n",
2624
+ // Match a regular expression (text enclosed by slashes), but will also match sets of divisions
2625
+ // as a regular expression (this is handled by the parsing loop below).
2626
+ "/(?:\\\\.|[^/])+/\\w*",
2627
+ // Match text (at least two characters) that does not contain any of the above special characters,
2628
+ // although some of the special characters are allowed to start it (all but the colon and comma).
2629
+ // The text can contain spaces, but leading or trailing spaces are skipped.
2630
+ "[^\\s:,/][^" + specials + "]*[^\\s" + specials + "]",
2631
+ // Match any non-space character not matched already. This will match colons and commas, since they're
2632
+ // not matched by "everyThingElse", but will also match any other single character that wasn't already
2633
+ // matched (for example: in "a: 1, b: 2", each of the non-space characters will be matched by oneNotSpace).
2634
+ "[^\\s]"
2635
+ ].join("|"),
2636
+ "g"
2637
+ );
2429
2638
  var divisionLookBehind = /[\])"'A-Za-z0-9_$]+$/;
2430
- var keywordRegexLookBehind = { "in": 1, "return": 1, "typeof": 1 };
2639
+ var keywordRegexLookBehind = { in: 1, return: 1, typeof: 1 };
2431
2640
  function parseObjectLiteral(objectLiteralString) {
2432
- var str = stringTrim(objectLiteralString);
2433
- if (str.charCodeAt(0) === 123)
2434
- str = str.slice(1, -1);
2641
+ let str = stringTrim(objectLiteralString);
2642
+ if (str.charCodeAt(0) === 123) str = str.slice(1, -1);
2435
2643
  str += "\n,";
2436
- var result = [];
2437
- var toks = str.match(bindingToken);
2438
- var key;
2439
- var values = [];
2440
- var depth = 0;
2644
+ const result = new Array();
2645
+ let toks = str.match(bindingToken);
2646
+ let key;
2647
+ let values = new Array();
2648
+ let depth = 0;
2441
2649
  if (toks.length <= 1) {
2442
2650
  return [];
2443
2651
  }
2444
- for (var i = 0, tok; tok = toks[i]; ++i) {
2445
- var c = tok.charCodeAt(0);
2652
+ for (let i = 0, tok; tok = toks[i]; ++i) {
2653
+ const c = tok.charCodeAt(0);
2446
2654
  if (c === 44) {
2447
2655
  if (depth <= 0) {
2448
- result.push(key && values.length ? {
2449
- key,
2450
- value: values.join("")
2451
- } : {
2452
- "unknown": key || values.join("")
2453
- });
2656
+ result.push(key && values.length ? { key, value: values.join("") } : { unknown: key || values.join("") });
2454
2657
  key = depth = 0;
2455
- values = [];
2658
+ values = new Array();
2456
2659
  continue;
2457
2660
  }
2458
2661
  } else if (c === 58) {
@@ -2463,7 +2666,7 @@ function parseObjectLiteral(objectLiteralString) {
2463
2666
  } else if (c === 47 && tok.length > 1 && (tok.charCodeAt(1) === 47 || tok.charCodeAt(1) === 42)) {
2464
2667
  continue;
2465
2668
  } else if (c === 47 && i && tok.length > 1) {
2466
- var match = toks[i - 1].match(divisionLookBehind);
2669
+ const match = toks[i - 1].match(divisionLookBehind);
2467
2670
  if (match && !keywordRegexLookBehind[match[0]]) {
2468
2671
  str = str.substr(str.indexOf(tok) + 1);
2469
2672
  toks = str.match(bindingToken);
@@ -2504,11 +2707,11 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2)
2504
2707
  options2.read = evaluatorFunctionOrOptions;
2505
2708
  }
2506
2709
  }
2507
- if (typeof options2.read !== "function") {
2710
+ if (typeof (options2 == null ? void 0 : options2.read) !== "function") {
2508
2711
  throw Error("Pass a function that returns the value of the computed");
2509
2712
  }
2510
- var writeFunction = options2.write;
2511
- var state = {
2713
+ const writeFunction = options2.write;
2714
+ const state = {
2512
2715
  latestValue: void 0,
2513
2716
  isStale: true,
2514
2717
  isDirty: true,
@@ -2519,8 +2722,8 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2)
2519
2722
  isSleeping: false,
2520
2723
  readFunction: options2.read,
2521
2724
  evaluatorFunctionTarget: evaluatorFunctionTarget || options2.owner,
2522
- disposeWhenNodeIsRemoved: options2.disposeWhenNodeIsRemoved || options2.disposeWhenNodeIsRemoved || null,
2523
- disposeWhen: options2.disposeWhen || options2.disposeWhen,
2725
+ disposeWhenNodeIsRemoved: options2.disposeWhenNodeIsRemoved || null,
2726
+ disposeWhen: options2.disposeWhen,
2524
2727
  domNodeDisposalCallback: null,
2525
2728
  dependencyTracking: {},
2526
2729
  dependenciesCount: 0,
@@ -2531,7 +2734,9 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2)
2531
2734
  if (typeof writeFunction === "function") {
2532
2735
  writeFunction.apply(state.evaluatorFunctionTarget, arguments);
2533
2736
  } else {
2534
- throw new Error("Cannot write a value to a computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.");
2737
+ throw new Error(
2738
+ "Cannot write a value to a computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters."
2739
+ );
2535
2740
  }
2536
2741
  return this;
2537
2742
  } else {
@@ -2539,6 +2744,7 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2)
2539
2744
  dependencyDetection_exports.registerDependency(computedObservable);
2540
2745
  }
2541
2746
  if (state.isDirty || state.isSleeping && computedObservable.haveDependenciesChanged()) {
2747
+ ;
2542
2748
  computedObservable.evaluateImmediate();
2543
2749
  }
2544
2750
  return state.latestValue;
@@ -2568,12 +2774,17 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2)
2568
2774
  }
2569
2775
  }
2570
2776
  if (!state.isSleeping && !options2.deferEvaluation) {
2777
+ ;
2571
2778
  computedObservable.evaluateImmediate();
2572
2779
  }
2573
2780
  if (state.disposeWhenNodeIsRemoved && computedObservable.isActive()) {
2574
- addDisposeCallback(state.disposeWhenNodeIsRemoved, state.domNodeDisposalCallback = function() {
2575
- computedObservable.dispose();
2576
- });
2781
+ addDisposeCallback(
2782
+ state.disposeWhenNodeIsRemoved,
2783
+ state.domNodeDisposalCallback = function() {
2784
+ ;
2785
+ computedObservable.dispose();
2786
+ }
2787
+ );
2577
2788
  }
2578
2789
  return computedObservable;
2579
2790
  }
@@ -2583,14 +2794,18 @@ function computedDisposeDependencyCallback(id, entryToDispose) {
2583
2794
  }
2584
2795
  }
2585
2796
  function computedBeginDependencyDetectionCallback(subscribable2, id) {
2586
- var computedObservable = this.computedObservable, state = computedObservable[computedState];
2797
+ const computedObservable = this.computedObservable, state = computedObservable[computedState];
2587
2798
  if (!state.isDisposed) {
2588
2799
  if (this.disposalCount && this.disposalCandidates[id]) {
2589
2800
  computedObservable.addDependencyTracking(id, subscribable2, this.disposalCandidates[id]);
2590
2801
  this.disposalCandidates[id] = null;
2591
2802
  --this.disposalCount;
2592
2803
  } else if (!state.dependencyTracking[id]) {
2593
- computedObservable.addDependencyTracking(id, subscribable2, state.isSleeping ? { _target: subscribable2 } : computedObservable.subscribeToDependency(subscribable2));
2804
+ computedObservable.addDependencyTracking(
2805
+ id,
2806
+ subscribable2,
2807
+ state.isSleeping ? { _target: subscribable2 } : computedObservable.subscribeToDependency(subscribable2)
2808
+ );
2594
2809
  }
2595
2810
  if (subscribable2._notificationIsPending) {
2596
2811
  subscribable2._notifyNextChangeIfValueIsDifferent();
@@ -2604,7 +2819,7 @@ computed.fn = {
2604
2819
  },
2605
2820
  getDependencies() {
2606
2821
  const dependencyTracking = this[computedState].dependencyTracking;
2607
- const dependentObservables = [];
2822
+ const dependentObservables = new Array();
2608
2823
  objectForEach(dependencyTracking, function(id, dependency) {
2609
2824
  dependentObservables[dependency._order] = dependency._target;
2610
2825
  });
@@ -2619,7 +2834,7 @@ computed.fn = {
2619
2834
  trackingObj._version = target.getVersion();
2620
2835
  },
2621
2836
  haveDependenciesChanged() {
2622
- var id, dependency, dependencyTracking = this[computedState].dependencyTracking;
2837
+ let id, dependency, dependencyTracking = this[computedState].dependencyTracking;
2623
2838
  for (id in dependencyTracking) {
2624
2839
  if (hasOwnProperty(dependencyTracking, id)) {
2625
2840
  dependency = dependencyTracking[id];
@@ -2628,10 +2843,14 @@ computed.fn = {
2628
2843
  }
2629
2844
  }
2630
2845
  }
2846
+ return false;
2631
2847
  },
2632
2848
  markDirty() {
2633
2849
  if (this._evalDelayed && !this[computedState].isBeingEvaluated) {
2634
- this._evalDelayed(false);
2850
+ this._evalDelayed(
2851
+ false
2852
+ /* notifyChange */
2853
+ );
2635
2854
  }
2636
2855
  },
2637
2856
  isActive() {
@@ -2647,7 +2866,7 @@ computed.fn = {
2647
2866
  },
2648
2867
  subscribeToDependency(target) {
2649
2868
  if (target._deferUpdates) {
2650
- var dirtySub = target.subscribe(this.markDirty, this, "dirty"), changeSub = target.subscribe(this.respondToChange, this);
2869
+ const dirtySub = target.subscribe(this.markDirty, this, "dirty"), changeSub = target.subscribe(this.respondToChange, this);
2651
2870
  return {
2652
2871
  _target: target,
2653
2872
  dispose() {
@@ -2660,20 +2879,29 @@ computed.fn = {
2660
2879
  }
2661
2880
  },
2662
2881
  evaluatePossiblyAsync() {
2663
- var computedObservable = this, throttleEvaluationTimeout = computedObservable.throttleEvaluation;
2882
+ const computedObservable = this, throttleEvaluationTimeout = computedObservable.throttleEvaluation;
2664
2883
  if (throttleEvaluationTimeout && throttleEvaluationTimeout >= 0) {
2665
2884
  clearTimeout(this[computedState].evaluationTimeoutInstance);
2666
2885
  this[computedState].evaluationTimeoutInstance = safeSetTimeout(function() {
2667
- computedObservable.evaluateImmediate(true);
2886
+ computedObservable.evaluateImmediate(
2887
+ true
2888
+ /* notifyChange */
2889
+ );
2668
2890
  }, throttleEvaluationTimeout);
2669
2891
  } else if (computedObservable._evalDelayed) {
2670
- computedObservable._evalDelayed(true);
2892
+ computedObservable._evalDelayed(
2893
+ true
2894
+ /* notifyChange */
2895
+ );
2671
2896
  } else {
2672
- computedObservable.evaluateImmediate(true);
2897
+ computedObservable.evaluateImmediate(
2898
+ true
2899
+ /* notifyChange */
2900
+ );
2673
2901
  }
2674
2902
  },
2675
2903
  evaluateImmediate(notifyChange) {
2676
- var computedObservable = this, state = computedObservable[computedState], disposeWhen = state.disposeWhen, changed = false;
2904
+ let computedObservable = this, state = computedObservable[computedState], disposeWhen = state.disposeWhen, changed = false;
2677
2905
  if (state.isBeingEvaluated) {
2678
2906
  return;
2679
2907
  }
@@ -2697,8 +2925,8 @@ computed.fn = {
2697
2925
  return changed;
2698
2926
  },
2699
2927
  evaluateImmediate_CallReadWithDependencyDetection(notifyChange) {
2700
- var computedObservable = this, state = computedObservable[computedState], changed = false;
2701
- var isInitial2 = state.pure ? void 0 : !state.dependenciesCount, dependencyDetectionContext = {
2928
+ let computedObservable = this, state = computedObservable[computedState], changed = false;
2929
+ const isInitial2 = state.pure ? void 0 : !state.dependenciesCount, dependencyDetectionContext = {
2702
2930
  computedObservable,
2703
2931
  disposalCandidates: state.dependencyTracking,
2704
2932
  disposalCount: state.dependenciesCount
@@ -2711,7 +2939,7 @@ computed.fn = {
2711
2939
  });
2712
2940
  state.dependencyTracking = {};
2713
2941
  state.dependenciesCount = 0;
2714
- var newValue = this.evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext);
2942
+ const newValue = this.evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext);
2715
2943
  if (!state.dependenciesCount) {
2716
2944
  computedObservable.dispose();
2717
2945
  changed = true;
@@ -2743,7 +2971,7 @@ computed.fn = {
2743
2971
  },
2744
2972
  evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext) {
2745
2973
  try {
2746
- var readFunction = state.readFunction;
2974
+ const readFunction = state.readFunction;
2747
2975
  return state.evaluatorFunctionTarget ? readFunction.call(state.evaluatorFunctionTarget) : readFunction();
2748
2976
  } finally {
2749
2977
  dependencyDetection_exports.end();
@@ -2783,12 +3011,16 @@ computed.fn = {
2783
3011
  if (isChange) {
2784
3012
  state.isStale = true;
2785
3013
  }
2786
- this._limitChange(this, !isChange);
3014
+ this._limitChange(
3015
+ this,
3016
+ !isChange
3017
+ /* isDirty */
3018
+ );
2787
3019
  }
2788
3020
  });
2789
3021
  },
2790
3022
  dispose() {
2791
- var state = this[computedState];
3023
+ const state = this[computedState];
2792
3024
  if (!state.isSleeping && state.dependencyTracking) {
2793
3025
  objectForEach(state.dependencyTracking, function(id, dependency) {
2794
3026
  if (dependency.dispose) {
@@ -2804,7 +3036,7 @@ computed.fn = {
2804
3036
  };
2805
3037
  var pureComputedOverrides = {
2806
3038
  beforeSubscriptionAdd(event) {
2807
- var computedObservable = this, state = computedObservable[computedState];
3039
+ const computedObservable = this, state = computedObservable[computedState];
2808
3040
  if (!state.isDisposed && state.isSleeping && event === "change") {
2809
3041
  state.isSleeping = false;
2810
3042
  if (state.isStale || computedObservable.haveDependenciesChanged()) {
@@ -2814,12 +3046,12 @@ var pureComputedOverrides = {
2814
3046
  computedObservable.updateVersion();
2815
3047
  }
2816
3048
  } else {
2817
- var dependenciesOrder = [];
3049
+ const dependenciesOrder = new Array();
2818
3050
  objectForEach(state.dependencyTracking, function(id, dependency) {
2819
3051
  dependenciesOrder[dependency._order] = id;
2820
3052
  });
2821
3053
  arrayForEach(dependenciesOrder, function(id, order) {
2822
- var dependency = state.dependencyTracking[id], subscription = computedObservable.subscribeToDependency(dependency._target);
3054
+ const dependency = state.dependencyTracking[id], subscription = computedObservable.subscribeToDependency(dependency._target);
2823
3055
  subscription._order = order;
2824
3056
  subscription._version = dependency._version;
2825
3057
  state.dependencyTracking[id] = subscription;
@@ -2836,7 +3068,7 @@ var pureComputedOverrides = {
2836
3068
  }
2837
3069
  },
2838
3070
  afterSubscriptionRemove(event) {
2839
- var state = this[computedState];
3071
+ const state = this[computedState];
2840
3072
  if (!state.isDisposed && event === "change" && !this.hasSubscriptionsForEvent("change")) {
2841
3073
  objectForEach(state.dependencyTracking, function(id, dependency) {
2842
3074
  if (dependency.dispose) {
@@ -2853,7 +3085,7 @@ var pureComputedOverrides = {
2853
3085
  }
2854
3086
  },
2855
3087
  getVersion() {
2856
- var state = this[computedState];
3088
+ const state = this[computedState];
2857
3089
  if (state.isSleeping && (state.isStale || this.haveDependenciesChanged())) {
2858
3090
  this.evaluateImmediate();
2859
3091
  }
@@ -2879,18 +3111,20 @@ function isPureComputed(instance) {
2879
3111
  }
2880
3112
  function pureComputed(evaluatorFunctionOrOptions, evaluatorFunctionTarget) {
2881
3113
  if (typeof evaluatorFunctionOrOptions === "function") {
2882
- return computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, { "pure": true });
3114
+ const evaluator = evaluatorFunctionOrOptions;
3115
+ return computed(evaluator, evaluatorFunctionTarget, { pure: true });
2883
3116
  } else {
2884
- evaluatorFunctionOrOptions = extend({}, evaluatorFunctionOrOptions);
2885
- evaluatorFunctionOrOptions.pure = true;
2886
- return computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget);
3117
+ let options2 = evaluatorFunctionOrOptions;
3118
+ options2 = extend({}, options2);
3119
+ options2.pure = true;
3120
+ return computed(options2, evaluatorFunctionTarget);
2887
3121
  }
2888
3122
  }
2889
3123
 
2890
3124
  // ../computed/dist/throttleExtender.js
2891
3125
  function throttleExtender(target, timeout) {
2892
3126
  target.throttleEvaluation = timeout;
2893
- var writeTimeoutInstance = null;
3127
+ let writeTimeoutInstance = void 0;
2894
3128
  return computed({
2895
3129
  read: target,
2896
3130
  write: function(value) {
@@ -2901,11 +3135,12 @@ function throttleExtender(target, timeout) {
2901
3135
  }
2902
3136
  });
2903
3137
  }
2904
- extenders.throttle = throttleExtender;
3138
+ var extenders2 = extenders;
3139
+ extenders2.throttle = throttleExtender;
2905
3140
 
2906
3141
  // ../computed/dist/proxy.js
2907
- var PROXY_SYM = Symbol("Knockout Proxied Object");
2908
- var MIRROR_SYM = Symbol("Knockout Proxied Observables");
3142
+ var PROXY_SYM = /* @__PURE__ */ Symbol("Knockout Proxied Object");
3143
+ var MIRROR_SYM = /* @__PURE__ */ Symbol("Knockout Proxied Observables");
2909
3144
  function makeComputed(proxy2, fn) {
2910
3145
  return computed({
2911
3146
  owner: proxy2,
@@ -2923,14 +3158,14 @@ function setOrCreate(mirror, prop, value, proxy2) {
2923
3158
  mirror[prop](value);
2924
3159
  }
2925
3160
  }
2926
- function assignOrUpdate(mirror, object2, proxy2) {
2927
- for (const key of Object.keys(object2)) {
2928
- setOrCreate(mirror, key, object2[key], proxy2);
3161
+ function assignOrUpdate(mirror, object, proxy2) {
3162
+ for (const key of Object.keys(object)) {
3163
+ setOrCreate(mirror, key, object[key], proxy2);
2929
3164
  }
2930
- return object2;
3165
+ return object;
2931
3166
  }
2932
- function proxy(object2) {
2933
- const mirror = { [PROXY_SYM]: object2 };
3167
+ function proxy(object) {
3168
+ const mirror = { [PROXY_SYM]: object };
2934
3169
  mirror[MIRROR_SYM] = mirror;
2935
3170
  const proxy2 = new Proxy(function() {
2936
3171
  }, {
@@ -2942,43 +3177,40 @@ function proxy(object2) {
2942
3177
  },
2943
3178
  set(target, prop, value, receiver) {
2944
3179
  setOrCreate(mirror, prop, value, proxy2);
2945
- object2[prop] = value;
3180
+ object[prop] = value;
2946
3181
  return true;
2947
3182
  },
2948
3183
  deleteProperty(property) {
2949
3184
  delete mirror[property];
2950
- return delete object2[property];
3185
+ return delete object[property];
2951
3186
  },
2952
3187
  apply(target, thisArg, [props]) {
2953
3188
  if (props) {
2954
3189
  assignOrUpdate(mirror, props, proxy2);
2955
- return Object.assign(object2, props);
3190
+ return Object.assign(object, props);
2956
3191
  }
2957
- return object2;
3192
+ return object;
2958
3193
  },
2959
3194
  getPrototypeOf() {
2960
- return Object.getPrototypeOf(object2);
3195
+ return Object.getPrototypeOf(object);
2961
3196
  },
2962
3197
  setPrototypeOf(target, proto) {
2963
- return Object.setPrototypeOf(object2, proto);
3198
+ return Object.setPrototypeOf(object, proto);
2964
3199
  },
2965
3200
  defineProperty(target, prop, desc) {
2966
- return Object.defineProperty(object2, prop, desc);
3201
+ return Object.defineProperty(object, prop, desc);
2967
3202
  },
2968
3203
  preventExtensions() {
2969
- return Object.preventExtensions(object2);
3204
+ return Object.preventExtensions(object);
2970
3205
  },
2971
3206
  isExtensible() {
2972
- return Object.isExtensible(object2);
3207
+ return Object.isExtensible(object);
2973
3208
  },
2974
3209
  ownKeys() {
2975
- return [
2976
- ...Object.getOwnPropertyNames(object2),
2977
- ...Object.getOwnPropertySymbols(object2)
2978
- ];
3210
+ return [...Object.getOwnPropertyNames(object), ...Object.getOwnPropertySymbols(object)];
2979
3211
  }
2980
3212
  });
2981
- assignOrUpdate(mirror, object2, proxy2);
3213
+ assignOrUpdate(mirror, object, proxy2);
2982
3214
  return proxy2;
2983
3215
  }
2984
3216
  function getObservable(proxied, prop) {
@@ -3012,11 +3244,18 @@ function when(predicate, callback, context) {
3012
3244
  // ../lifecycle/dist/LifeCycle.js
3013
3245
  var SUBSCRIPTIONS = createSymbolOrString("LifeCycle Subscriptions List");
3014
3246
  var ANCHOR_NODE = createSymbolOrString("LifeCycle Anchor Node");
3015
- var LifeCycle = class {
3247
+ var LifeCycle = class _LifeCycle {
3248
+ // NOTE: For more advanced integration as an ES6 mixin, see e.g.:
3249
+ // http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/
3250
+ /**
3251
+ * Copy the properties of the LifeCycle class to the target (or its prototype)
3252
+ *
3253
+ * NOTE: getOwnPropertyNames is needed to copy the non-enumerable properties.
3254
+ */
3016
3255
  static mixInto(Constructor) {
3017
3256
  const target = Constructor.prototype || Constructor;
3018
- const mixin = LifeCycle.prototype;
3019
- for (let prop of Object.getOwnPropertyNames(mixin)) {
3257
+ const mixin = _LifeCycle.prototype;
3258
+ for (const prop of Object.getOwnPropertyNames(mixin)) {
3020
3259
  target[prop] = mixin[prop];
3021
3260
  }
3022
3261
  }
@@ -3044,6 +3283,13 @@ var LifeCycle = class {
3044
3283
  params.disposeWhenNodeIsRemoved = this[ANCHOR_NODE];
3045
3284
  return this.addDisposable(computed(params));
3046
3285
  }
3286
+ /**
3287
+ * Add an event listener for the given or anchored node.
3288
+ * @param {node} [node] (optional) The target node (otherwise the anchored node)
3289
+ * @param {string} [type] Event type
3290
+ * @param {function|string} [action] Either call the given function or `this[action]`
3291
+ * @param {object} [options] (optional) Passed as `options` to `node.addEventListener`
3292
+ */
3047
3293
  addEventListener(...args) {
3048
3294
  const node = args[0].nodeType ? args.shift() : this[ANCHOR_NODE];
3049
3295
  const [type, act, options2] = args;
@@ -3070,7 +3316,7 @@ var LifeCycle = class {
3070
3316
  dispose() {
3071
3317
  const subscriptions = this[SUBSCRIPTIONS] || [];
3072
3318
  subscriptions.forEach((s) => s.dispose());
3073
- this[SUBSCRIPTIONS] = [];
3319
+ this[SUBSCRIPTIONS] = new Array();
3074
3320
  this[ANCHOR_NODE] = null;
3075
3321
  }
3076
3322
  addDisposable(subscription) {
@@ -3087,22 +3333,24 @@ var LifeCycle = class {
3087
3333
  };
3088
3334
 
3089
3335
  // ../bind/dist/bindingEvent.js
3090
- var contextAncestorBindingInfo = Symbol("_ancestorBindingInfo");
3336
+ var contextAncestorBindingInfo = /* @__PURE__ */ Symbol("_ancestorBindingInfo");
3091
3337
  var boundElementDomDataKey = data_exports.nextKey();
3092
3338
  var bindingEvent = {
3339
+ //TODO better: String-Enum "BindingEventEnum"
3093
3340
  childrenComplete: "childrenComplete",
3094
3341
  descendantsComplete: "descendantsComplete",
3095
- subscribe(node, event, callback, context) {
3342
+ subscribe(node, event, callback, callbackContext) {
3096
3343
  const bindingInfo = data_exports.getOrSet(node, boundElementDomDataKey, {});
3097
3344
  if (!bindingInfo.eventSubscribable) {
3098
3345
  bindingInfo.eventSubscribable = new subscribable();
3099
3346
  }
3100
- return bindingInfo.eventSubscribable.subscribe(callback, context, event);
3347
+ return bindingInfo.eventSubscribable.subscribe(callback, callbackContext, event);
3101
3348
  },
3102
3349
  notify(node, event) {
3103
3350
  const bindingInfo = data_exports.get(node, boundElementDomDataKey);
3104
3351
  if (bindingInfo) {
3105
3352
  if (bindingInfo.eventSubscribable) {
3353
+ ;
3106
3354
  bindingInfo.eventSubscribable.notifySubscribers(node, event);
3107
3355
  }
3108
3356
  }
@@ -3111,15 +3359,14 @@ var bindingEvent = {
3111
3359
 
3112
3360
  // ../bind/dist/bindingContext.js
3113
3361
  var boundElementDomDataKey2 = data_exports.nextKey();
3114
- var contextSubscribeSymbol = Symbol("Knockout Context Subscription");
3115
- var inheritParentIndicator = Symbol("Knockout Parent Indicator");
3116
- function bindingContext(dataItemOrAccessor, parentContext, dataItemAlias, extendCallback, settings) {
3362
+ var contextSubscribeSymbol = /* @__PURE__ */ Symbol("Knockout Context Subscription");
3363
+ var inheritParentIndicator = /* @__PURE__ */ Symbol("Knockout Parent Indicator");
3364
+ var bindingContext = function bindingContextFactory(dataItemOrAccessor, parentContext, dataItemAlias, extendCallback, settings) {
3117
3365
  const self = this;
3118
3366
  const shouldInheritData = dataItemOrAccessor === inheritParentIndicator;
3119
3367
  const realDataItemOrAccessor = shouldInheritData ? void 0 : dataItemOrAccessor;
3120
3368
  const isFunc = typeof realDataItemOrAccessor === "function" && !isObservable(realDataItemOrAccessor);
3121
3369
  self.ko = options_default.knockoutInstance;
3122
- let nodes;
3123
3370
  let subscribable2;
3124
3371
  function updateContext() {
3125
3372
  const dataItemOrObservable = isFunc ? realDataItemOrAccessor() : realDataItemOrAccessor;
@@ -3133,7 +3380,7 @@ function bindingContext(dataItemOrAccessor, parentContext, dataItemAlias, extend
3133
3380
  self[contextAncestorBindingInfo] = parentContext[contextAncestorBindingInfo];
3134
3381
  }
3135
3382
  } else {
3136
- self.$parents = [];
3383
+ self.$parents = new Array();
3137
3384
  self.$root = dataItem;
3138
3385
  }
3139
3386
  self[contextSubscribeSymbol] = subscribable2;
@@ -3163,7 +3410,7 @@ function bindingContext(dataItemOrAccessor, parentContext, dataItemAlias, extend
3163
3410
  self[contextSubscribeSymbol] = void 0;
3164
3411
  }
3165
3412
  }
3166
- }
3413
+ };
3167
3414
  Object.assign(bindingContext.prototype, {
3168
3415
  lookup(token, globals, node) {
3169
3416
  switch (token) {
@@ -3187,24 +3434,39 @@ Object.assign(bindingContext.prototype, {
3187
3434
  }
3188
3435
  throw new Error(`The variable "${token}" was not found on $data, $context, or globals.`);
3189
3436
  },
3437
+ // Extend the binding context hierarchy with a new view model object. If the parent context is watching
3438
+ // any observables, the new child context will automatically get a dependency on the parent context.
3439
+ // But this does not mean that the $data value of the child context will also get updated. If the child
3440
+ // view model also depends on the parent view model, you must provide a function that returns the correct
3441
+ // view model on each update.
3190
3442
  createChildContext(dataItemOrAccessor, dataItemAlias, extendCallback, settings) {
3191
- return new bindingContext(dataItemOrAccessor, this, dataItemAlias, function(self, parentContext) {
3192
- self.$parentContext = parentContext;
3193
- self.$parent = parentContext.$data;
3194
- self.$parents = (parentContext.$parents || []).slice(0);
3195
- self.$parents.unshift(self.$parent);
3196
- if (extendCallback) {
3197
- extendCallback(self);
3198
- }
3199
- }, settings);
3443
+ return new bindingContext(
3444
+ dataItemOrAccessor,
3445
+ this,
3446
+ dataItemAlias,
3447
+ function(self, parentContext) {
3448
+ var _a;
3449
+ self.$parentContext = parentContext;
3450
+ self.$parent = parentContext == null ? void 0 : parentContext.$data;
3451
+ self.$parents = ((_a = parentContext == null ? void 0 : parentContext.$parents) != null ? _a : []).slice(0);
3452
+ self.$parents.unshift(self.$parent);
3453
+ if (extendCallback) {
3454
+ extendCallback(self);
3455
+ }
3456
+ },
3457
+ settings
3458
+ );
3200
3459
  },
3460
+ // Extend the binding context with new custom properties. This doesn't change the context hierarchy.
3461
+ // Similarly to "child" contexts, provide a function here to make sure that the correct values are set
3462
+ // when an observable view model is updated.
3201
3463
  extend(properties) {
3202
- return new bindingContext(inheritParentIndicator, this, null, function(self, parentContext) {
3464
+ return new bindingContext(inheritParentIndicator, this, void 0, function(self, parentContext) {
3203
3465
  extend(self, typeof properties === "function" ? properties.call(self) : properties);
3204
3466
  });
3205
3467
  },
3206
3468
  createStaticChildContext(dataItemOrAccessor, dataItemAlias) {
3207
- return this.createChildContext(dataItemOrAccessor, dataItemAlias, null, { "exportDependencies": true });
3469
+ return this.createChildContext(dataItemOrAccessor, dataItemAlias, null, { exportDependencies: true });
3208
3470
  }
3209
3471
  });
3210
3472
  function storedBindingContextForNode(node) {
@@ -3212,44 +3474,22 @@ function storedBindingContextForNode(node) {
3212
3474
  return bindingInfo && bindingInfo.context;
3213
3475
  }
3214
3476
  function contextFor(node) {
3215
- if (node && (node.nodeType === 1 || node.nodeType === 8)) {
3477
+ if (node && (node.nodeType === Node.ELEMENT_NODE || node.nodeType === Node.COMMENT_NODE)) {
3216
3478
  return storedBindingContextForNode(node);
3217
3479
  }
3218
3480
  }
3219
3481
  function dataFor(node) {
3220
- var context = contextFor(node);
3482
+ const context = contextFor(node);
3221
3483
  return context ? context.$data : void 0;
3222
3484
  }
3223
3485
 
3224
3486
  // ../bind/dist/BindingResult.js
3225
- var __async = (__this, __arguments, generator) => {
3226
- return new Promise((resolve, reject) => {
3227
- var fulfilled = (value) => {
3228
- try {
3229
- step(generator.next(value));
3230
- } catch (e) {
3231
- reject(e);
3232
- }
3233
- };
3234
- var rejected = (value) => {
3235
- try {
3236
- step(generator.throw(value));
3237
- } catch (e) {
3238
- reject(e);
3239
- }
3240
- };
3241
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
3242
- step((generator = generator.apply(__this, __arguments)).next());
3243
- });
3244
- };
3245
3487
  var BindingResult = class {
3246
3488
  constructor({ asyncBindingsApplied, rootNode, bindingContext: bindingContext2 }) {
3247
- Object.assign(this, {
3248
- rootNode,
3249
- bindingContext: bindingContext2,
3250
- isSync: asyncBindingsApplied.size === 0,
3251
- isComplete: this.isSync
3252
- });
3489
+ this.rootNode = rootNode;
3490
+ this.bindingContext = bindingContext2;
3491
+ this.isSync = asyncBindingsApplied.size === 0;
3492
+ this.isComplete = this.isSync;
3253
3493
  if (!this.isSync) {
3254
3494
  this.completionPromise = this.completeWhenBindingsFinish(asyncBindingsApplied);
3255
3495
  }
@@ -3268,13 +3508,11 @@ var BindingHandler = class extends LifeCycle {
3268
3508
  constructor(params) {
3269
3509
  super();
3270
3510
  const { $element, valueAccessor, allBindings, $context } = params;
3271
- Object.assign(this, {
3272
- valueAccessor,
3273
- allBindings,
3274
- $element,
3275
- $context,
3276
- $data: $context.$data
3277
- });
3511
+ this.$element = $element;
3512
+ this.valueAccessor = valueAccessor;
3513
+ this.allBindings = allBindings;
3514
+ this.$context = $context;
3515
+ this.$data = $context.$data;
3278
3516
  this.anchorTo($element);
3279
3517
  }
3280
3518
  get value() {
@@ -3297,14 +3535,23 @@ var BindingHandler = class extends LifeCycle {
3297
3535
  static get isBindingHandlerClass() {
3298
3536
  return true;
3299
3537
  }
3538
+ /* Overload this for asynchronous bindings or bindings that recursively
3539
+ apply bindings (e.g. components, foreach, template).
3540
+
3541
+ A binding should be complete when it has run through once, notably
3542
+ in server-side bindings for pre-rendering.
3543
+ */
3300
3544
  get bindingCompleted() {
3301
3545
  return true;
3302
3546
  }
3303
3547
  static registerAs(name, provider = options_default.bindingProviderInstance) {
3304
3548
  provider.bindingHandlers.set(name, this);
3305
3549
  }
3550
+ static registerBindingHandler(handler, name, provider = options_default.bindingProviderInstance) {
3551
+ provider.bindingHandlers.set(name, handler);
3552
+ }
3306
3553
  };
3307
- var ResolveSymbol = Symbol("Async Binding Resolved");
3554
+ var ResolveSymbol = /* @__PURE__ */ Symbol("Async Binding Resolved");
3308
3555
  var AsyncBindingHandler = class extends BindingHandler {
3309
3556
  constructor(params) {
3310
3557
  super(params);
@@ -3321,7 +3568,10 @@ var AsyncBindingHandler = class extends BindingHandler {
3321
3568
  // ../bind/dist/LegacyBindingHandler.js
3322
3569
  var PossibleWeakMap = options_default.global.WeakMap || Map;
3323
3570
  var legacyBindingMap = new PossibleWeakMap();
3324
- var LegacyBindingHandler = class extends BindingHandler {
3571
+ var LegacyBindingHandler = class _LegacyBindingHandler extends BindingHandler {
3572
+ get handler() {
3573
+ return void 0;
3574
+ }
3325
3575
  constructor(params) {
3326
3576
  super(params);
3327
3577
  const handler = this.handler;
@@ -3347,18 +3597,21 @@ var LegacyBindingHandler = class extends BindingHandler {
3347
3597
  }
3348
3598
  }
3349
3599
  get legacyArgs() {
3350
- return [
3351
- this.$element,
3352
- this.valueAccessor,
3353
- this.allBindings,
3354
- this.$data,
3355
- this.$context
3356
- ];
3600
+ return [this.$element, this.valueAccessor, this.allBindings, this.$data, this.$context];
3357
3601
  }
3358
3602
  get controlsDescendants() {
3359
3603
  const objectToTest = this.initReturn || this.handler || {};
3360
3604
  return objectToTest.controlsDescendantBindings;
3361
3605
  }
3606
+ /**
3607
+ * Create a handler instance from the `origin`, which may be:
3608
+ *
3609
+ * 1. an object (becomes LegacyBindingHandler)
3610
+ * 2. a function (becomes LegacyBindingHandler with `init: function`)
3611
+ *
3612
+ * If given an object (the only kind supported in knockout 3.x and before), it
3613
+ * shall draw the `init`, `update`, and `allowVirtualElements` properties
3614
+ */
3362
3615
  static getOrCreateFor(key, handler) {
3363
3616
  if (legacyBindingMap.has(handler)) {
3364
3617
  return legacyBindingMap.get(handler);
@@ -3370,7 +3623,7 @@ var LegacyBindingHandler = class extends BindingHandler {
3370
3623
  static createFor(key, handler) {
3371
3624
  if (typeof handler === "function") {
3372
3625
  const [initFn, disposeFn] = [handler, handler.dispose];
3373
- return class extends LegacyBindingHandler {
3626
+ return class extends _LegacyBindingHandler {
3374
3627
  get handler() {
3375
3628
  const init = initFn.bind(this);
3376
3629
  const dispose = disposeFn ? disposeFn.bind(this) : null;
@@ -3385,7 +3638,7 @@ var LegacyBindingHandler = class extends BindingHandler {
3385
3638
  };
3386
3639
  }
3387
3640
  if (typeof handler === "object") {
3388
- return class extends LegacyBindingHandler {
3641
+ return class extends _LegacyBindingHandler {
3389
3642
  get handler() {
3390
3643
  return handler;
3391
3644
  }
@@ -3403,15 +3656,20 @@ var LegacyBindingHandler = class extends BindingHandler {
3403
3656
 
3404
3657
  // ../bind/dist/applyBindings.js
3405
3658
  var bindingDoesNotRecurseIntoElementTypes = {
3406
- "script": true,
3407
- "textarea": true,
3408
- "template": true
3659
+ // Don't want bindings that operate on text nodes to mutate <script> and <textarea> contents,
3660
+ // because it's unexpected and a potential XSS issue.
3661
+ // Also bindings should not operate on <template> elements since this breaks in Internet Explorer
3662
+ // and because such elements' contents are always intended to be bound in a different context
3663
+ // from where they appear in the document.
3664
+ script: true,
3665
+ textarea: true,
3666
+ template: true
3409
3667
  };
3410
3668
  function getBindingProvider() {
3411
3669
  return options_default.bindingProviderInstance.instance || options_default.bindingProviderInstance;
3412
3670
  }
3413
3671
  function isProviderForNode(provider, node) {
3414
- const nodeTypes = provider.FOR_NODE_TYPES || [1, 3, 8];
3672
+ const nodeTypes = provider.FOR_NODE_TYPES || [Node.ELEMENT_NODE, Node.TEXT_NODE, Node.COMMENT_NODE];
3415
3673
  return nodeTypes.includes(node.nodeType);
3416
3674
  }
3417
3675
  function asProperHandlerClass(handler, bindingKey) {
@@ -3462,11 +3720,11 @@ function nodeOrChildHasBindings(node) {
3462
3720
  return hasBindings(node) || [...node.childNodes].some((c) => nodeOrChildHasBindings(c));
3463
3721
  }
3464
3722
  function applyBindingsToNodeAndDescendantsInternal(bindingContext2, nodeVerified, asyncBindingsApplied) {
3465
- var isElement = nodeVerified.nodeType === 1;
3723
+ const isElement = nodeVerified.nodeType === Node.ELEMENT_NODE;
3466
3724
  if (isElement) {
3467
3725
  virtualElements_exports.normaliseVirtualElementDomStructure(nodeVerified);
3468
3726
  }
3469
- let shouldApplyBindings = isElement || hasBindings(nodeVerified);
3727
+ const shouldApplyBindings = isElement || hasBindings(nodeVerified);
3470
3728
  const { shouldBindDescendants } = shouldApplyBindings ? applyBindingsToNodeInternal(nodeVerified, null, bindingContext2, asyncBindingsApplied) : { shouldBindDescendants: true };
3471
3729
  if (shouldBindDescendants && !bindingDoesNotRecurseIntoElementTypes[tagNameLower(nodeVerified)]) {
3472
3730
  applyBindingsToDescendantsInternal(bindingContext2, nodeVerified, asyncBindingsApplied);
@@ -3475,7 +3733,7 @@ function applyBindingsToNodeAndDescendantsInternal(bindingContext2, nodeVerified
3475
3733
  function* topologicalSortBindings(bindings, $component) {
3476
3734
  const results = [];
3477
3735
  const bindingsConsidered = {};
3478
- const cyclicDependencyStack = [];
3736
+ const cyclicDependencyStack = new Array();
3479
3737
  objectForEach(bindings, function pushBinding(bindingKey) {
3480
3738
  if (!bindingsConsidered[bindingKey]) {
3481
3739
  const binding = getBindingHandlerFromComponent(bindingKey, $component) || getBindingHandler(bindingKey);
@@ -3489,7 +3747,9 @@ function* topologicalSortBindings(bindings, $component) {
3489
3747
  return;
3490
3748
  }
3491
3749
  if (arrayIndexOf(cyclicDependencyStack, bindingDependencyKey) !== -1) {
3492
- throw Error("Cannot combine the following bindings, because they have a cyclic dependency: " + cyclicDependencyStack.join(", "));
3750
+ throw Error(
3751
+ "Cannot combine the following bindings, because they have a cyclic dependency: " + cyclicDependencyStack.join(", ")
3752
+ );
3493
3753
  } else {
3494
3754
  pushBinding(bindingDependencyKey);
3495
3755
  }
@@ -3525,14 +3785,15 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext2, asyn
3525
3785
  if (!alreadyBound) {
3526
3786
  bindingInfo.context = bindingContext2;
3527
3787
  }
3528
- var bindings;
3788
+ let bindings = null;
3789
+ let bindingsUpdater = null;
3529
3790
  if (sourceBindings && typeof sourceBindings !== "function") {
3530
3791
  bindings = sourceBindings;
3531
3792
  } else {
3532
3793
  const provider = getBindingProvider();
3533
3794
  const getBindings = provider.getBindingAccessors;
3534
3795
  if (isProviderForNode(provider, node)) {
3535
- var bindingsUpdater = computed(
3796
+ bindingsUpdater = computed(
3536
3797
  function() {
3537
3798
  bindings = sourceBindings ? sourceBindings(bindingContext2, node) : getBindings.call(provider, node, bindingContext2);
3538
3799
  if (bindings && bindingContext2[contextSubscribeSymbol]) {
@@ -3548,12 +3809,8 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext2, asyn
3548
3809
  }
3549
3810
  }
3550
3811
  }
3551
- var bindingHandlerThatControlsDescendantBindings;
3812
+ let bindingHandlerThatControlsDescendantBindings;
3552
3813
  if (bindings) {
3553
- let allBindings2 = function() {
3554
- return objectMap(bindingsUpdater ? bindingsUpdater() : bindings, evaluateValueAccessor);
3555
- };
3556
- var allBindings = allBindings2;
3557
3814
  const $component = bindingContext2.$component || {};
3558
3815
  const allBindingHandlers = {};
3559
3816
  data_exports.set(node, "bindingHandlers", allBindingHandlers);
@@ -3565,60 +3822,67 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext2, asyn
3565
3822
  return valueAccessor(optionalValue);
3566
3823
  }
3567
3824
  } : (bindingKey) => bindings[bindingKey];
3568
- allBindings2.has = (key) => key in bindings;
3569
- allBindings2.get = (key) => bindings[key] && evaluateValueAccessor(getValueAccessor(key));
3825
+ const allBindings = function() {
3826
+ return objectMap(bindingsUpdater ? bindingsUpdater() : bindings, evaluateValueAccessor);
3827
+ };
3828
+ allBindings.has = (key) => key in bindings;
3829
+ allBindings.get = (key) => bindings[key] && evaluateValueAccessor(getValueAccessor(key));
3570
3830
  if (bindingEvent.childrenComplete in bindings) {
3571
- bindingEvent.subscribe(node, bindingEvent.childrenComplete, () => {
3572
- const callback = evaluateValueAccessor(bindings[bindingEvent.childrenComplete]);
3573
- if (!callback) {
3574
- return;
3575
- }
3576
- const nodes = virtualElements_exports.childNodes(node);
3577
- if (nodes.length) {
3578
- callback(nodes, dataFor(nodes[0]));
3579
- }
3580
- });
3831
+ bindingEvent.subscribe(
3832
+ node,
3833
+ bindingEvent.childrenComplete,
3834
+ () => {
3835
+ const callback = evaluateValueAccessor(bindings[bindingEvent.childrenComplete]);
3836
+ if (!callback) {
3837
+ return;
3838
+ }
3839
+ const nodes = virtualElements_exports.childNodes(node);
3840
+ if (nodes.length) {
3841
+ callback(nodes, dataFor(nodes[0]));
3842
+ }
3843
+ },
3844
+ null
3845
+ );
3581
3846
  }
3582
3847
  const bindingsGenerated = topologicalSortBindings(bindings, $component);
3583
3848
  const nodeAsyncBindingPromises = /* @__PURE__ */ new Set();
3584
3849
  for (const [key, BindingHandlerClass] of bindingsGenerated) {
3585
- let reportBindingError2 = function(during, errorCaptured) {
3850
+ const reportBindingError = function(during, errorCaptured) {
3586
3851
  onBindingError({
3587
3852
  during,
3588
3853
  errorCaptured,
3589
3854
  bindings,
3590
- allBindings: allBindings2,
3855
+ allBindings,
3591
3856
  bindingKey: key,
3592
3857
  bindingContext: bindingContext2,
3593
3858
  element: node,
3594
3859
  valueAccessor: getValueAccessor(key)
3595
3860
  });
3596
3861
  };
3597
- var reportBindingError = reportBindingError2;
3598
- if (node.nodeType === 8 && !BindingHandlerClass.allowVirtualElements) {
3862
+ if (node.nodeType === Node.COMMENT_NODE && !BindingHandlerClass.allowVirtualElements) {
3599
3863
  throw new Error(`The binding '${key}' cannot be used with virtual elements`);
3600
3864
  }
3601
3865
  try {
3602
3866
  const bindingHandler = dependencyDetection_exports.ignore(
3603
3867
  () => new BindingHandlerClass({
3604
- allBindings: allBindings2,
3868
+ allBindings,
3605
3869
  $element: node,
3606
3870
  $context: bindingContext2,
3607
- onError: reportBindingError2,
3871
+ onError: reportBindingError,
3608
3872
  valueAccessor(...v) {
3609
3873
  return getValueAccessor(key)(...v);
3610
3874
  }
3611
3875
  })
3612
3876
  );
3613
3877
  if (bindingHandler.onValueChange) {
3614
- dependencyDetection_exports.ignore(
3615
- () => bindingHandler.computed("onValueChange")
3616
- );
3878
+ dependencyDetection_exports.ignore(() => bindingHandler.computed("onValueChange"));
3617
3879
  }
3618
3880
  allBindingHandlers[key] = bindingHandler;
3619
3881
  if (bindingHandler.controlsDescendants) {
3620
3882
  if (bindingHandlerThatControlsDescendantBindings !== void 0) {
3621
- throw new Error("Multiple bindings (" + bindingHandlerThatControlsDescendantBindings + " and " + key + ") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");
3883
+ throw new Error(
3884
+ "Multiple bindings (" + bindingHandlerThatControlsDescendantBindings + " and " + key + ") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element."
3885
+ );
3622
3886
  }
3623
3887
  bindingHandlerThatControlsDescendantBindings = key;
3624
3888
  }
@@ -3627,7 +3891,8 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext2, asyn
3627
3891
  nodeAsyncBindingPromises.add(bindingHandler.bindingCompleted);
3628
3892
  }
3629
3893
  } catch (err) {
3630
- reportBindingError2("creation", err);
3894
+ const error = err instanceof Error ? err : new Error(String(err));
3895
+ reportBindingError("creation", error);
3631
3896
  }
3632
3897
  }
3633
3898
  triggerDescendantsComplete(node, bindings, nodeAsyncBindingPromises);
@@ -3655,10 +3920,15 @@ function getBindingContext(viewModelOrBindingContext, extendContextCallback) {
3655
3920
  return viewModelOrBindingContext && viewModelOrBindingContext instanceof bindingContext ? viewModelOrBindingContext : new bindingContext(viewModelOrBindingContext, void 0, void 0, extendContextCallback);
3656
3921
  }
3657
3922
  function applyBindingAccessorsToNode(node, bindings, viewModelOrBindingContext, asyncBindingsApplied) {
3658
- if (node.nodeType === 1) {
3923
+ if (node.nodeType === Node.ELEMENT_NODE) {
3659
3924
  virtualElements_exports.normaliseVirtualElementDomStructure(node);
3660
3925
  }
3661
- return applyBindingsToNodeInternal(node, bindings, getBindingContext(viewModelOrBindingContext), asyncBindingsApplied);
3926
+ return applyBindingsToNodeInternal(
3927
+ node,
3928
+ bindings,
3929
+ getBindingContext(viewModelOrBindingContext),
3930
+ asyncBindingsApplied
3931
+ );
3662
3932
  }
3663
3933
  function applyBindingsToNode(node, bindings, viewModelOrBindingContext) {
3664
3934
  const asyncBindingsApplied = /* @__PURE__ */ new Set();
@@ -3669,24 +3939,21 @@ function applyBindingsToNode(node, bindings, viewModelOrBindingContext) {
3669
3939
  }
3670
3940
  function applyBindingsToDescendants(viewModelOrBindingContext, rootNode) {
3671
3941
  const asyncBindingsApplied = /* @__PURE__ */ new Set();
3672
- if (rootNode.nodeType === 1 || rootNode.nodeType === 8) {
3673
- const bindingContext2 = getBindingContext(viewModelOrBindingContext);
3942
+ const bindingContext2 = getBindingContext(viewModelOrBindingContext);
3943
+ if (rootNode.nodeType === Node.ELEMENT_NODE || rootNode.nodeType === Node.COMMENT_NODE) {
3674
3944
  applyBindingsToDescendantsInternal(bindingContext2, rootNode, asyncBindingsApplied);
3675
3945
  return new BindingResult({ asyncBindingsApplied, rootNode, bindingContext: bindingContext2 });
3676
3946
  }
3677
- return new BindingResult({ asyncBindingsApplied, rootNode });
3947
+ return new BindingResult({ asyncBindingsApplied, rootNode, bindingContext: bindingContext2 });
3678
3948
  }
3679
3949
  function applyBindings(viewModelOrBindingContext, rootNode, extendContextCallback) {
3680
3950
  const asyncBindingsApplied = /* @__PURE__ */ new Set();
3681
- if (!options_default.jQuery === void 0 && options_default.jQuery) {
3682
- options_default.jQuery = options_default.jQuery;
3683
- }
3684
3951
  if (!rootNode) {
3685
3952
  rootNode = window.document.body;
3686
3953
  if (!rootNode) {
3687
3954
  throw Error("ko.applyBindings: could not find window.document.body; has the document been loaded?");
3688
3955
  }
3689
- } else if (rootNode.nodeType !== 1 && rootNode.nodeType !== 8) {
3956
+ } else if (rootNode.nodeType !== Node.ELEMENT_NODE && rootNode.nodeType !== Node.COMMENT_NODE) {
3690
3957
  throw Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node");
3691
3958
  }
3692
3959
  const rootContext = getBindingContext(viewModelOrBindingContext, extendContextCallback);
@@ -3694,7 +3961,7 @@ function applyBindings(viewModelOrBindingContext, rootNode, extendContextCallbac
3694
3961
  return Promise.all(asyncBindingsApplied);
3695
3962
  }
3696
3963
  function onBindingError(spec) {
3697
- var error, bindingText;
3964
+ let error;
3698
3965
  if (spec.bindingKey) {
3699
3966
  error = spec.errorCaptured;
3700
3967
  spec.message = 'Unable to process binding "' + spec.bindingKey + '" in binding "' + spec.bindingKey + '"\nMessage: ' + (error.message ? error.message : error);
@@ -3705,7 +3972,12 @@ function onBindingError(spec) {
3705
3972
  extend(error, spec);
3706
3973
  } catch (e) {
3707
3974
  spec.stack = error.stack;
3708
- error = new Error(error.message ? error.message : error);
3975
+ const message = error.message || String(error);
3976
+ const originalName = error.name;
3977
+ error = new Error(message);
3978
+ if (originalName && originalName !== "Error") {
3979
+ error.name = originalName;
3980
+ }
3709
3981
  extend(error, spec);
3710
3982
  }
3711
3983
  options_default.onError(error);
@@ -3713,21 +3985,31 @@ function onBindingError(spec) {
3713
3985
 
3714
3986
  // ../bind/dist/arrayToDomNodeChildren.js
3715
3987
  function mapNodeAndRefreshWhenChanged(containerNode, mapping, valueToMap, callbackAfterAddingNodes, index) {
3716
- var mappedNodes = [];
3717
- var dependentObservable = computed(function() {
3718
- var newMappedNodes = mapping(valueToMap, index, fixUpContinuousNodeArray(mappedNodes, containerNode)) || [];
3719
- if (mappedNodes.length > 0) {
3720
- replaceDomNodes(mappedNodes, newMappedNodes);
3721
- if (callbackAfterAddingNodes) {
3722
- dependencyDetection_exports.ignore(callbackAfterAddingNodes, null, [valueToMap, newMappedNodes, index]);
3988
+ const mappedNodes = [];
3989
+ const dependentObservable = computed(
3990
+ function() {
3991
+ const newMappedNodes = mapping(valueToMap, index, fixUpContinuousNodeArray(mappedNodes, containerNode)) || [];
3992
+ if (mappedNodes.length > 0) {
3993
+ replaceDomNodes(mappedNodes, newMappedNodes);
3994
+ if (callbackAfterAddingNodes) {
3995
+ dependencyDetection_exports.ignore(callbackAfterAddingNodes, null, [valueToMap, newMappedNodes, index]);
3996
+ }
3997
+ }
3998
+ mappedNodes.length = 0;
3999
+ arrayPushAll(mappedNodes, newMappedNodes);
4000
+ },
4001
+ null,
4002
+ {
4003
+ disposeWhenNodeIsRemoved: containerNode,
4004
+ disposeWhen: function() {
4005
+ return !anyDomNodeIsAttachedToDocument(mappedNodes);
3723
4006
  }
3724
4007
  }
3725
- mappedNodes.length = 0;
3726
- arrayPushAll(mappedNodes, newMappedNodes);
3727
- }, null, { disposeWhenNodeIsRemoved: containerNode, disposeWhen: function() {
3728
- return !anyDomNodeIsAttachedToDocument(mappedNodes);
3729
- } });
3730
- return { mappedNodes, dependentObservable: dependentObservable.isActive() ? dependentObservable : void 0 };
4008
+ );
4009
+ return {
4010
+ mappedNodes,
4011
+ dependentObservable: dependentObservable.isActive() ? dependentObservable : void 0
4012
+ };
3731
4013
  }
3732
4014
  var lastMappingResultDomDataKey = data_exports.nextKey();
3733
4015
  var deletedItemDummyValue = data_exports.nextKey();
@@ -3737,17 +4019,17 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options2, c
3737
4019
  array = [array];
3738
4020
  }
3739
4021
  options2 = options2 || {};
3740
- let lastMappingResult = data_exports.get(domNode, lastMappingResultDomDataKey);
3741
- let isFirstExecution = !lastMappingResult;
3742
- var newMappingResult = [];
3743
- var lastMappingResultIndex = 0;
3744
- var newMappingResultIndex = 0;
3745
- var nodesToDelete = [];
3746
- var itemsToProcess = [];
3747
- var itemsForBeforeRemoveCallbacks = [];
3748
- var itemsForMoveCallbacks = [];
3749
- var itemsForAfterAddCallbacks = [];
3750
- var mapData;
4022
+ const lastMappingResult = data_exports.get(domNode, lastMappingResultDomDataKey);
4023
+ const isFirstExecution = !lastMappingResult;
4024
+ const newMappingResult = new Array();
4025
+ let lastMappingResultIndex = 0;
4026
+ let newMappingResultIndex = 0;
4027
+ const nodesToDelete = [];
4028
+ const itemsToProcess = [];
4029
+ const itemsForBeforeRemoveCallbacks = [];
4030
+ const itemsForMoveCallbacks = [];
4031
+ const itemsForAfterAddCallbacks = [];
4032
+ let mapData;
3751
4033
  let countWaitingForRemove = 0;
3752
4034
  function itemAdded(value) {
3753
4035
  mapData = { arrayEntry: value, indexObservable: observable(newMappingResultIndex++) };
@@ -3769,9 +4051,9 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options2, c
3769
4051
  }
3770
4052
  function callCallback(callback, items) {
3771
4053
  if (callback) {
3772
- for (var i2 = 0, n = items.length; i2 < n; i2++) {
3773
- arrayForEach(items[i2].mappedNodes, function(node2) {
3774
- callback(node2, i2, items[i2].arrayEntry);
4054
+ for (let i = 0, n = items.length; i < n; i++) {
4055
+ arrayForEach(items[i].mappedNodes, function(node) {
4056
+ callback(node, i, items[i].arrayEntry);
3775
4057
  });
3776
4058
  }
3777
4059
  }
@@ -3780,16 +4062,13 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options2, c
3780
4062
  arrayForEach(array, itemAdded);
3781
4063
  } else {
3782
4064
  if (!editScript || lastMappingResult && lastMappingResult["_countWaitingForRemove"]) {
3783
- var lastArray = isFirstExecution ? [] : arrayMap(lastMappingResult, function(x) {
4065
+ const lastArray = arrayMap(lastMappingResult, function(x) {
3784
4066
  return x.arrayEntry;
3785
4067
  });
3786
- var compareOptions = {
3787
- "dontLimitMoves": options2["dontLimitMoves"],
3788
- "sparse": true
3789
- };
4068
+ const compareOptions = { dontLimitMoves: options2.dontLimitMoves, sparse: true };
3790
4069
  editScript = compareArrays(lastArray, array, compareOptions);
3791
4070
  }
3792
- for (var i = 0, editScriptItem, movedIndex, itemIndex; editScriptItem = editScript[i]; i++) {
4071
+ for (let i = 0, editScriptItem, movedIndex, itemIndex; editScriptItem = editScript[i]; i++) {
3793
4072
  movedIndex = editScriptItem["moved"];
3794
4073
  itemIndex = editScriptItem["index"];
3795
4074
  switch (editScriptItem["status"]) {
@@ -3804,7 +4083,7 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options2, c
3804
4083
  mapData.dependentObservable = void 0;
3805
4084
  }
3806
4085
  if (fixUpContinuousNodeArray(mapData.mappedNodes, domNode).length) {
3807
- if (options2["beforeRemove"]) {
4086
+ if (options2.beforeRemove) {
3808
4087
  newMappingResult.push(mapData);
3809
4088
  itemsToProcess.push(mapData);
3810
4089
  countWaitingForRemove++;
@@ -3814,7 +4093,7 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options2, c
3814
4093
  itemsForBeforeRemoveCallbacks.push(mapData);
3815
4094
  }
3816
4095
  }
3817
- if (mapData) {
4096
+ if (mapData == null ? void 0 : mapData.mappedNodes) {
3818
4097
  nodesToDelete.push.apply(nodesToDelete, mapData.mappedNodes);
3819
4098
  }
3820
4099
  }
@@ -3839,14 +4118,22 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options2, c
3839
4118
  newMappingResult["_countWaitingForRemove"] = countWaitingForRemove;
3840
4119
  }
3841
4120
  data_exports.set(domNode, lastMappingResultDomDataKey, newMappingResult);
3842
- callCallback(options2["beforeMove"], itemsForMoveCallbacks);
3843
- arrayForEach(nodesToDelete, options2["beforeRemove"] ? cleanNode : removeNode);
3844
- i = 0;
3845
- for (var nextNode = virtualElements_exports.firstChild(domNode), lastNode, node; mapData = itemsToProcess[i]; i++) {
4121
+ callCallback(options2.beforeMove, itemsForMoveCallbacks);
4122
+ arrayForEach(nodesToDelete, options2.beforeRemove ? cleanNode : removeNode);
4123
+ for (let k = 0, nextNode = virtualElements_exports.firstChild(domNode), lastNode, node; mapData = itemsToProcess[k]; k++) {
3846
4124
  if (!mapData.mappedNodes) {
3847
- extend(mapData, mapNodeAndRefreshWhenChanged(domNode, mapping, mapData.arrayEntry, callbackAfterAddingNodes, mapData.indexObservable));
4125
+ extend(
4126
+ mapData,
4127
+ mapNodeAndRefreshWhenChanged(
4128
+ domNode,
4129
+ mapping,
4130
+ mapData.arrayEntry,
4131
+ callbackAfterAddingNodes,
4132
+ mapData.indexObservable
4133
+ )
4134
+ );
3848
4135
  }
3849
- for (var j = 0; node = mapData.mappedNodes[j]; nextNode = node.nextSibling, lastNode = node, j++) {
4136
+ for (let j = 0; node = mapData.mappedNodes[j]; nextNode = node.nextSibling, lastNode = node, j++) {
3850
4137
  if (node !== nextNode) {
3851
4138
  virtualElements_exports.insertAfter(domNode, node, lastNode);
3852
4139
  }
@@ -3856,12 +4143,12 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options2, c
3856
4143
  mapData.initialized = true;
3857
4144
  }
3858
4145
  }
3859
- callCallback(options2["beforeRemove"], itemsForBeforeRemoveCallbacks);
3860
- for (i = 0; i < itemsForBeforeRemoveCallbacks.length; ++i) {
3861
- itemsForBeforeRemoveCallbacks[i].arrayEntry = deletedItemDummyValue;
4146
+ callCallback(options2.beforeRemove, itemsForBeforeRemoveCallbacks);
4147
+ for (let x = 0; x < itemsForBeforeRemoveCallbacks.length; ++x) {
4148
+ itemsForBeforeRemoveCallbacks[x].arrayEntry = deletedItemDummyValue;
3862
4149
  }
3863
- callCallback(options2["afterMove"], itemsForMoveCallbacks);
3864
- callCallback(options2["afterAdd"], itemsForAfterAddCallbacks);
4150
+ callCallback(options2.afterMove, itemsForMoveCallbacks);
4151
+ callCallback(options2.afterAdd, itemsForAfterAddCallbacks);
3865
4152
  }
3866
4153
 
3867
4154
  // ../binding.template/dist/templateSources.js
@@ -3869,35 +4156,8 @@ var templateScript = 1;
3869
4156
  var templateTextArea = 2;
3870
4157
  var templateTemplate = 3;
3871
4158
  var templateElement = 4;
3872
- function domElement(element) {
3873
- this.domElement = element;
3874
- if (!element) {
3875
- return;
3876
- }
3877
- var tagNameLower2 = tagNameLower(element);
3878
- this.templateType = tagNameLower2 === "script" ? templateScript : tagNameLower2 === "textarea" ? templateTextArea : tagNameLower2 == "template" && element.content && element.content.nodeType === 11 ? templateTemplate : templateElement;
3879
- }
3880
- domElement.prototype.text = function() {
3881
- var elemContentsProperty = this.templateType === templateScript ? "text" : this.templateType === templateTextArea ? "value" : "innerHTML";
3882
- if (arguments.length == 0) {
3883
- return this.domElement[elemContentsProperty];
3884
- } else {
3885
- var valueToWrite = arguments[0];
3886
- if (elemContentsProperty === "innerHTML") {
3887
- setHtml(this.domElement, valueToWrite);
3888
- } else {
3889
- this.domElement[elemContentsProperty] = valueToWrite;
3890
- }
3891
- }
3892
- };
4159
+ var templateAnonymous = 5;
3893
4160
  var dataDomDataPrefix = data_exports.nextKey() + "_";
3894
- domElement.prototype.data = function(key) {
3895
- if (arguments.length === 1) {
3896
- return data_exports.get(this.domElement, dataDomDataPrefix + key);
3897
- } else {
3898
- data_exports.set(this.domElement, dataDomDataPrefix + key, arguments[1]);
3899
- }
3900
- };
3901
4161
  var templatesDomDataKey = data_exports.nextKey();
3902
4162
  function getTemplateDomData(element) {
3903
4163
  return data_exports.get(element, templatesDomDataKey) || {};
@@ -3905,40 +4165,73 @@ function getTemplateDomData(element) {
3905
4165
  function setTemplateDomData(element, data) {
3906
4166
  data_exports.set(element, templatesDomDataKey, data);
3907
4167
  }
3908
- domElement.prototype.nodes = function() {
3909
- var element = this.domElement;
3910
- if (arguments.length == 0) {
3911
- const templateData = getTemplateDomData(element);
3912
- let nodes = templateData.containerData || (this.templateType === templateTemplate ? element.content : this.templateType === templateElement ? element : void 0);
3913
- if (!nodes || templateData.alwaysCheckText) {
3914
- const text = this["text"]();
3915
- if (text) {
3916
- nodes = parseHtmlForTemplateNodes(text, element.ownerDocument);
3917
- this["text"]("");
3918
- setTemplateDomData(element, { containerData: nodes, alwaysCheckText: true });
4168
+ var domElement = class {
4169
+ constructor(element) {
4170
+ this.domElement = element;
4171
+ if (element.nodeType === Node.COMMENT_NODE) {
4172
+ this.templateType = templateElement;
4173
+ } else {
4174
+ const tagNameLower2 = tagNameLower(this.domElement);
4175
+ this.templateType = tagNameLower2 === "script" ? templateScript : tagNameLower2 === "textarea" ? templateTextArea : (
4176
+ // For browsers with proper <template> element support, where the .content property gives a document fragment
4177
+ tagNameLower2 == "template" && element.content && element.content.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? templateTemplate : templateElement
4178
+ );
4179
+ }
4180
+ }
4181
+ text(valueToWrite) {
4182
+ const elemContentsProperty = this.templateType === templateScript ? "text" : this.templateType === templateTextArea ? "value" : "innerHTML";
4183
+ if (arguments.length == 0) {
4184
+ return this.domElement[elemContentsProperty];
4185
+ } else {
4186
+ if (elemContentsProperty === "innerHTML") {
4187
+ setHtml(this.domElement, valueToWrite);
4188
+ } else {
4189
+ this.domElement[elemContentsProperty] = valueToWrite;
3919
4190
  }
3920
4191
  }
3921
- return nodes;
3922
- } else {
3923
- var valueToWrite = arguments[0];
3924
- setTemplateDomData(element, { containerData: valueToWrite });
4192
+ }
4193
+ data(key, valueToWrite) {
4194
+ if (arguments.length === 1) {
4195
+ return data_exports.get(this.domElement, dataDomDataPrefix + key);
4196
+ } else {
4197
+ data_exports.set(this.domElement, dataDomDataPrefix + key, valueToWrite);
4198
+ }
4199
+ }
4200
+ nodes(valueToWrite) {
4201
+ const element = this.domElement;
4202
+ if (arguments.length == 0) {
4203
+ const templateData = getTemplateDomData(element);
4204
+ let nodes = templateData.containerData || (this.templateType === templateTemplate ? element.content : this.templateType === templateElement ? element : void 0);
4205
+ if (!nodes || templateData.alwaysCheckText) {
4206
+ const text = this.text();
4207
+ if (text) {
4208
+ nodes = parseHtmlForTemplateNodes(text, element.ownerDocument);
4209
+ this.text("");
4210
+ setTemplateDomData(element, { containerData: nodes, alwaysCheckText: true });
4211
+ }
4212
+ }
4213
+ return nodes;
4214
+ } else {
4215
+ setTemplateDomData(element, { containerData: valueToWrite });
4216
+ }
4217
+ return void 0;
3925
4218
  }
3926
4219
  };
3927
- function anonymousTemplate(element) {
3928
- this.domElement = element;
3929
- }
3930
- anonymousTemplate.prototype = new domElement();
3931
- anonymousTemplate.prototype.constructor = anonymousTemplate;
3932
- anonymousTemplate.prototype.text = function() {
3933
- if (arguments.length == 0) {
3934
- var templateData = getTemplateDomData(this.domElement);
3935
- if (templateData.textData === void 0 && templateData.containerData) {
3936
- templateData.textData = templateData.containerData.innerHTML;
4220
+ var anonymousTemplate = class extends domElement {
4221
+ constructor(element) {
4222
+ super(element);
4223
+ this.templateType = templateAnonymous;
4224
+ }
4225
+ text(valueToWrite) {
4226
+ if (arguments.length == 0) {
4227
+ const templateData = getTemplateDomData(this.domElement);
4228
+ if (templateData.textData === void 0 && templateData.containerData) {
4229
+ templateData.textData = templateData.containerData.innerHTML;
4230
+ }
4231
+ return templateData.textData;
4232
+ } else {
4233
+ setTemplateDomData(this.domElement, { textData: valueToWrite });
3937
4234
  }
3938
- return templateData.textData;
3939
- } else {
3940
- var valueToWrite = arguments[0];
3941
- setTemplateDomData(this.domElement, { textData: valueToWrite });
3942
4235
  }
3943
4236
  };
3944
4237
 
@@ -3946,28 +4239,30 @@ anonymousTemplate.prototype.text = function() {
3946
4239
  function templateEngine() {
3947
4240
  }
3948
4241
  extend(templateEngine.prototype, {
3949
- renderTemplateSource: function(templateSource, bindingContext2, options2, templateDocument) {
4242
+ renderTemplateSource(templateSource, bindingContext2, options2, templateDocument) {
3950
4243
  options2.onError("Override renderTemplateSource");
3951
4244
  },
3952
- createJavaScriptEvaluatorBlock: function(script) {
3953
- options_default.onError("Override createJavaScriptEvaluatorBlock");
4245
+ createJavaScriptEvaluatorBlock(script) {
4246
+ options_default.onError(new Error("Override createJavaScriptEvaluatorBlock"));
3954
4247
  },
3955
- makeTemplateSource: function(template, templateDocument) {
4248
+ makeTemplateSource(template, templateDocument) {
3956
4249
  if (typeof template === "string") {
3957
4250
  templateDocument = templateDocument || document;
3958
- var elem = templateDocument.getElementById(template);
4251
+ const elem = templateDocument.getElementById(template);
3959
4252
  if (!elem) {
3960
- options_default.onError("Cannot find template with ID " + template);
4253
+ throw options_default.onError(new Error("Cannot find template with ID " + template), false);
3961
4254
  }
3962
4255
  return new domElement(elem);
3963
- } else if (template.nodeType == 1 || template.nodeType == 8) {
4256
+ } else if (template.nodeType === Node.ELEMENT_NODE) {
4257
+ return new anonymousTemplate(template);
4258
+ } else if (template.nodeType === Node.COMMENT_NODE) {
3964
4259
  return new anonymousTemplate(template);
3965
4260
  } else {
3966
- options_default.onError("Unknown template type: " + template);
4261
+ throw options_default.onError(new Error("Unknown template type: " + template), false);
3967
4262
  }
3968
4263
  },
3969
- renderTemplate: function(template, bindingContext2, options2, templateDocument) {
3970
- var templateSource = this["makeTemplateSource"](template, templateDocument);
4264
+ renderTemplate(template, bindingContext2, options2, templateDocument) {
4265
+ const templateSource = this.makeTemplateSource(template, templateDocument);
3971
4266
  return this.renderTemplateSource(templateSource, bindingContext2, options2, templateDocument);
3972
4267
  }
3973
4268
  });
@@ -3984,7 +4279,7 @@ function setTemplateEngine(tEngine) {
3984
4279
  function invokeForEachNodeInContinuousRange(firstNode, lastNode, action) {
3985
4280
  let node;
3986
4281
  let nextInQueue = firstNode;
3987
- let firstOutOfRangeNode = virtualElements_exports.nextSibling(lastNode);
4282
+ const firstOutOfRangeNode = virtualElements_exports.nextSibling(lastNode);
3988
4283
  while (nextInQueue && (node = nextInQueue) !== firstOutOfRangeNode) {
3989
4284
  nextInQueue = virtualElements_exports.nextSibling(node);
3990
4285
  action(node, nextInQueue);
@@ -3992,15 +4287,15 @@ function invokeForEachNodeInContinuousRange(firstNode, lastNode, action) {
3992
4287
  }
3993
4288
  function activateBindingsOnContinuousNodeArray(continuousNodeArray, bindingContext2, afterBindingCallback) {
3994
4289
  if (continuousNodeArray.length) {
3995
- var firstNode = continuousNodeArray[0];
3996
- var lastNode = continuousNodeArray[continuousNodeArray.length - 1];
3997
- var parentNode = firstNode.parentNode;
3998
- var provider = options_default.bindingProviderInstance;
3999
- var preprocessNode = provider.preprocessNode;
4290
+ let firstNode = continuousNodeArray[0];
4291
+ let lastNode = continuousNodeArray[continuousNodeArray.length - 1];
4292
+ const parentNode = firstNode.parentNode;
4293
+ const provider = options_default.bindingProviderInstance;
4294
+ const preprocessNode = provider.preprocessNode;
4000
4295
  if (preprocessNode) {
4001
4296
  invokeForEachNodeInContinuousRange(firstNode, lastNode, function(node, nextNodeInRange) {
4002
- var nodePreviousSibling = node.previousSibling;
4003
- var newNodes = preprocessNode.call(provider, node);
4297
+ const nodePreviousSibling = node.previousSibling;
4298
+ const newNodes = preprocessNode.call(provider, node);
4004
4299
  if (newNodes) {
4005
4300
  if (node === firstNode) {
4006
4301
  firstNode = newNodes[0] || nextNodeInRange;
@@ -4022,12 +4317,12 @@ function activateBindingsOnContinuousNodeArray(continuousNodeArray, bindingConte
4022
4317
  }
4023
4318
  }
4024
4319
  invokeForEachNodeInContinuousRange(firstNode, lastNode, function(node) {
4025
- if (node.nodeType === 1 || node.nodeType === 8) {
4320
+ if (node.nodeType === Node.ELEMENT_NODE || node.nodeType === Node.COMMENT_NODE) {
4026
4321
  applyBindings(bindingContext2, node).then(afterBindingCallback);
4027
4322
  }
4028
4323
  });
4029
4324
  invokeForEachNodeInContinuousRange(firstNode, lastNode, function(node) {
4030
- if (node.nodeType === 1 || node.nodeType === 8) {
4325
+ if (node.nodeType === Node.ELEMENT_NODE || node.nodeType === Node.COMMENT_NODE) {
4031
4326
  memoization_exports.unmemoizeDomNodeAndDescendants(node, [bindingContext2]);
4032
4327
  }
4033
4328
  });
@@ -4039,14 +4334,14 @@ function getFirstNodeFromPossibleArray(nodeOrNodeArray) {
4039
4334
  }
4040
4335
  function executeTemplate(targetNodeOrNodeArray, renderMode, template, bindingContext2, options2, afterBindingCallback) {
4041
4336
  options2 = options2 || {};
4042
- var firstTargetNode = targetNodeOrNodeArray && getFirstNodeFromPossibleArray(targetNodeOrNodeArray);
4043
- var templateDocument = (firstTargetNode || template || {}).ownerDocument;
4044
- var templateEngineToUse = options2.templateEngine || _templateEngine;
4045
- var renderedNodesArray = templateEngineToUse.renderTemplate(template, bindingContext2, options2, templateDocument);
4337
+ const firstTargetNode = targetNodeOrNodeArray && getFirstNodeFromPossibleArray(targetNodeOrNodeArray);
4338
+ const templateDocument = (firstTargetNode || template || {}).ownerDocument;
4339
+ const templateEngineToUse = options2.templateEngine || _templateEngine;
4340
+ const renderedNodesArray = templateEngineToUse.renderTemplate(template, bindingContext2, options2, templateDocument);
4046
4341
  if (typeof renderedNodesArray.length !== "number" || renderedNodesArray.length > 0 && typeof renderedNodesArray[0].nodeType !== "number") {
4047
4342
  throw new Error("Template engine must return an array of DOM nodes");
4048
4343
  }
4049
- var haveAddedNodesToParent = false;
4344
+ let haveAddedNodesToParent = false;
4050
4345
  switch (renderMode) {
4051
4346
  case "replaceChildren":
4052
4347
  virtualElements_exports.setDomNodeChildren(targetNodeOrNodeArray, renderedNodesArray);
@@ -4088,16 +4383,26 @@ function renderTemplate(template, dataOrBindingContext, options2, targetNodeOrNo
4088
4383
  }
4089
4384
  renderMode = renderMode || "replaceChildren";
4090
4385
  if (targetNodeOrNodeArray) {
4091
- var firstTargetNode = getFirstNodeFromPossibleArray(targetNodeOrNodeArray);
4092
- var whenToDispose = function() {
4386
+ let firstTargetNode = getFirstNodeFromPossibleArray(targetNodeOrNodeArray);
4387
+ const whenToDispose = function() {
4093
4388
  return !firstTargetNode || !domNodeIsAttachedToDocument(firstTargetNode);
4094
4389
  };
4095
- var activelyDisposeWhenNodeIsRemoved = firstTargetNode && renderMode === "replaceNode" ? firstTargetNode.parentNode : firstTargetNode;
4390
+ const activelyDisposeWhenNodeIsRemoved = firstTargetNode && renderMode === "replaceNode" ? firstTargetNode.parentNode : firstTargetNode;
4096
4391
  return computed(
4392
+ // So the DOM is automatically updated when any dependency changes
4097
4393
  function() {
4098
- var bindingContext2 = dataOrBindingContext && dataOrBindingContext instanceof bindingContext ? dataOrBindingContext : new bindingContext(dataOrBindingContext, null, null, null, { "exportDependencies": true });
4099
- var templateName = resolveTemplateName(template, bindingContext2.$data, bindingContext2);
4100
- const renderedNodesArray = executeTemplate(targetNodeOrNodeArray, renderMode, templateName, bindingContext2, options2, afterBindingCallback);
4394
+ const bindingContext2 = dataOrBindingContext && dataOrBindingContext instanceof bindingContext ? dataOrBindingContext : new bindingContext(dataOrBindingContext, void 0, void 0, void 0, {
4395
+ exportDependencies: true
4396
+ });
4397
+ const templateName = resolveTemplateName(template, bindingContext2.$data, bindingContext2);
4398
+ const renderedNodesArray = executeTemplate(
4399
+ targetNodeOrNodeArray,
4400
+ renderMode,
4401
+ templateName,
4402
+ bindingContext2,
4403
+ options2,
4404
+ afterBindingCallback
4405
+ );
4101
4406
  if (renderMode === "replaceNode") {
4102
4407
  targetNodeOrNodeArray = renderedNodesArray;
4103
4408
  firstTargetNode = getFirstNodeFromPossibleArray(targetNodeOrNodeArray);
@@ -4120,11 +4425,11 @@ function nativeTemplateEngine() {
4120
4425
  nativeTemplateEngine.prototype = new templateEngine();
4121
4426
  nativeTemplateEngine.prototype.constructor = nativeTemplateEngine;
4122
4427
  nativeTemplateEngine.prototype.renderTemplateSource = function(templateSource, bindingContext2, options2, templateDocument) {
4123
- var useNodesIfAvailable = !(ieVersion < 9), templateNodesFunc = useNodesIfAvailable ? templateSource.nodes : null, templateNodes = templateNodesFunc ? templateSource.nodes() : null;
4428
+ const templateNodes = templateSource.nodes ? templateSource.nodes() : null;
4124
4429
  if (templateNodes) {
4125
4430
  return makeArray(templateNodes.cloneNode(true).childNodes);
4126
4431
  } else {
4127
- var templateText = templateSource.text();
4432
+ const templateText = templateSource.text();
4128
4433
  return parseHtmlFragment(templateText, templateDocument);
4129
4434
  }
4130
4435
  };
@@ -4145,7 +4450,7 @@ var domNodeDisposal = {
4145
4450
  options_default.set("cleanExternalData", cleanerFn);
4146
4451
  }
4147
4452
  };
4148
- var utils = Object.assign({
4453
+ var utils = {
4149
4454
  addOrRemoveItem,
4150
4455
  arrayFilter,
4151
4456
  arrayFirst,
@@ -4176,8 +4481,9 @@ var utils = Object.assign({
4176
4481
  toggleDomNodeCssClass,
4177
4482
  triggerEvent,
4178
4483
  unwrapObservable: unwrap
4179
- });
4484
+ };
4180
4485
  var knockout = {
4486
+ // --- Utilities ---
4181
4487
  cleanNode,
4182
4488
  dependencyDetection: dependencyDetection_exports,
4183
4489
  computedContext: dependencyDetection_exports,
@@ -4190,6 +4496,7 @@ var knockout = {
4190
4496
  tasks: tasks_exports,
4191
4497
  utils,
4192
4498
  LifeCycle,
4499
+ // -- Observable ---
4193
4500
  isObservable,
4194
4501
  isSubscribable,
4195
4502
  isWriteableObservable,
@@ -4203,17 +4510,20 @@ var knockout = {
4203
4510
  toJS,
4204
4511
  toJSON,
4205
4512
  proxy,
4513
+ // ... Computed ...
4206
4514
  computed,
4207
4515
  dependentObservable: computed,
4208
4516
  isComputed,
4209
4517
  isPureComputed,
4210
4518
  pureComputed,
4211
4519
  when,
4520
+ // --- Templates ---
4212
4521
  nativeTemplateEngine,
4213
4522
  renderTemplate,
4214
4523
  setTemplateEngine,
4215
4524
  templateEngine,
4216
4525
  templateSources: { domElement, anonymousTemplate },
4526
+ // --- Binding ---
4217
4527
  applyBindingAccessorsToNode,
4218
4528
  applyBindings,
4219
4529
  applyBindingsToDescendants,
@@ -4227,11 +4537,8 @@ var knockout = {
4227
4537
  bindingEvent
4228
4538
  };
4229
4539
  var Builder = class {
4230
- constructor({ provider, bindings, extenders: extenders2, filters, options: options2 }) {
4231
- Object.assign(knockout.options, options2, {
4232
- filters,
4233
- bindingProviderInstance: provider
4234
- });
4540
+ constructor({ provider, bindings, extenders: extenders3, filters, options: options2 }) {
4541
+ Object.assign(knockout.options, options2, { filters, bindingProviderInstance: provider });
4235
4542
  provider.setGlobals(knockout.options.bindingGlobals);
4236
4543
  if (Array.isArray(bindings)) {
4237
4544
  for (const bindingsObject of bindings) {
@@ -4241,11 +4548,14 @@ var Builder = class {
4241
4548
  provider.bindingHandlers.set(bindings);
4242
4549
  }
4243
4550
  this.providedProperties = {
4244
- extenders: Object.assign(extenders, extenders2),
4551
+ extenders: Object.assign(extenders, extenders3),
4245
4552
  bindingHandlers: provider.bindingHandlers,
4246
4553
  bindingProvider: provider
4247
4554
  };
4248
4555
  }
4556
+ /**
4557
+ * @return {KnockoutInstance} An instance of Knockout.
4558
+ */
4249
4559
  create(...additionalProperties) {
4250
4560
  const instance = Object.assign(
4251
4561
  {
@@ -4257,6 +4567,7 @@ var Builder = class {
4257
4567
  }
4258
4568
  },
4259
4569
  knockout,
4570
+ //never change the order of these
4260
4571
  this.providedProperties,
4261
4572
  ...additionalProperties
4262
4573
  );