@tko/binding.template 4.0.0-beta1.0 → 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,8 +1,13 @@
1
- // @tko/binding.template 🥊 4.0.0-beta1.0 CommonJS
1
+ // @tko/binding.template 🥊 4.0.0 CommonJS
2
+ "use strict";
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
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
+ };
6
11
  var __export = (target, all) => {
7
12
  for (var name in all)
8
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -16,10 +21,42 @@ var __copyProps = (to, from, except, desc) => {
16
21
  return to;
17
22
  };
18
23
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var __await = function(promise, isYieldStar) {
25
+ this[0] = promise;
26
+ this[1] = isYieldStar;
27
+ };
28
+ var __yieldStar = (value) => {
29
+ var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {};
30
+ if (obj == null) {
31
+ obj = value[__knownSymbol("iterator")]();
32
+ method = (k) => it[k] = (x) => obj[k](x);
33
+ } else {
34
+ obj = obj.call(value);
35
+ method = (k) => it[k] = (v) => {
36
+ if (isAwait) {
37
+ isAwait = false;
38
+ if (k === "throw") throw v;
39
+ return v;
40
+ }
41
+ isAwait = true;
42
+ return {
43
+ done: false,
44
+ value: new __await(new Promise((resolve) => {
45
+ var x = obj[k](v);
46
+ if (!(x instanceof Object)) __typeError("Object expected");
47
+ resolve(x);
48
+ }), 1)
49
+ };
50
+ };
51
+ }
52
+ return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => {
53
+ throw x;
54
+ }, "return" in obj && method("return"), it;
55
+ };
19
56
 
20
57
  // index.ts
21
- var binding_exports = {};
22
- __export(binding_exports, {
58
+ var index_exports = {};
59
+ __export(index_exports, {
23
60
  TemplateBindingHandler: () => TemplateBindingHandler,
24
61
  anonymousTemplate: () => anonymousTemplate,
25
62
  bindings: () => bindings,
@@ -29,13 +66,13 @@ __export(binding_exports, {
29
66
  setTemplateEngine: () => setTemplateEngine,
30
67
  templateEngine: () => templateEngine
31
68
  });
32
- module.exports = __toCommonJS(binding_exports);
69
+ module.exports = __toCommonJS(index_exports);
33
70
 
34
71
  // ../utils/dist/array.js
35
72
  var { isArray } = Array;
36
- function arrayForEach(array, action, thisArg) {
73
+ function arrayForEach(array, action, actionOwner) {
37
74
  if (arguments.length > 2) {
38
- action = action.bind(thisArg);
75
+ action = action.bind(actionOwner);
39
76
  }
40
77
  for (let i = 0, j = array.length; i < j; ++i) {
41
78
  action(array[i], i, array);
@@ -47,23 +84,23 @@ function arrayIndexOf(array, item) {
47
84
  function arrayFirst(array, predicate, predicateOwner) {
48
85
  return (isArray(array) ? array : [...array]).find(predicate, predicateOwner);
49
86
  }
50
- function arrayMap(array = [], mapping, thisArg) {
87
+ function arrayMap(array, mapping, thisArg) {
51
88
  if (arguments.length > 2) {
52
89
  mapping = mapping.bind(thisArg);
53
90
  }
54
91
  return array === null ? [] : Array.from(array, mapping);
55
92
  }
56
93
  function arrayRemoveItem(array, itemToRemove) {
57
- var index = arrayIndexOf(array, itemToRemove);
94
+ const index = arrayIndexOf(array, itemToRemove);
58
95
  if (index > 0) {
59
96
  array.splice(index, 1);
60
97
  } else if (index === 0) {
61
98
  array.shift();
62
99
  }
63
100
  }
64
- function arrayFilter(array, predicate, thisArg) {
101
+ function arrayFilter(array, predicate, predicateOwner) {
65
102
  if (arguments.length > 2) {
66
- predicate = predicate.bind(thisArg);
103
+ predicate = predicate.bind(predicateOwner);
67
104
  }
68
105
  return array === null ? [] : (isArray(array) ? array : [...array]).filter(predicate);
69
106
  }
@@ -71,7 +108,7 @@ function arrayPushAll(array, valuesToPush) {
71
108
  if (isArray(valuesToPush)) {
72
109
  array.push.apply(array, valuesToPush);
73
110
  } else {
74
- for (var i = 0, j = valuesToPush.length; i < j; i++) {
111
+ for (let i = 0, j = valuesToPush.length; i < j; i++) {
75
112
  array.push(valuesToPush[i]);
76
113
  }
77
114
  }
@@ -82,7 +119,7 @@ function makeArray(arrayLikeObject) {
82
119
  }
83
120
  function findMovesInArrayComparison(left, right, limitFailedCompares) {
84
121
  if (left.length && right.length) {
85
- var failedCompares, l, r, leftItem, rightItem;
122
+ let failedCompares, l, r, leftItem, rightItem;
86
123
  for (failedCompares = l = 0; (!limitFailedCompares || failedCompares < limitFailedCompares) && (leftItem = left[l]); ++l) {
87
124
  for (r = 0; rightItem = right[r]; ++r) {
88
125
  if (leftItem.value === rightItem.value) {
@@ -99,21 +136,21 @@ function findMovesInArrayComparison(left, right, limitFailedCompares) {
99
136
  }
100
137
  var statusNotInOld = "added";
101
138
  var statusNotInNew = "deleted";
102
- function compareArrays(oldArray, newArray, options3) {
103
- options3 = typeof options3 === "boolean" ? { dontLimitMoves: options3 } : options3 || {};
139
+ function compareArrays(oldArray, newArray, options2) {
140
+ options2 = typeof options2 === "boolean" ? { dontLimitMoves: options2 } : options2 || {};
104
141
  oldArray = oldArray || [];
105
142
  newArray = newArray || [];
106
143
  if (oldArray.length < newArray.length) {
107
- return compareSmallArrayToBigArray(oldArray, newArray, statusNotInOld, statusNotInNew, options3);
144
+ return compareSmallArrayToBigArray(oldArray, newArray, statusNotInOld, statusNotInNew, options2);
108
145
  } else {
109
- return compareSmallArrayToBigArray(newArray, oldArray, statusNotInNew, statusNotInOld, options3);
146
+ return compareSmallArrayToBigArray(newArray, oldArray, statusNotInNew, statusNotInOld, options2);
110
147
  }
111
148
  }
112
- function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusNotInBig, options3) {
113
- 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;
149
+ function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusNotInBig, options2) {
150
+ 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;
114
151
  for (smlIndex = 0; smlIndex <= smlIndexMax; smlIndex++) {
115
152
  lastRow = thisRow;
116
- editDistanceMatrix.push(thisRow = []);
153
+ editDistanceMatrix.push(thisRow = new Array());
117
154
  bigIndexMaxForRow = myMin(bigIndexMax, smlIndex + compareRange);
118
155
  bigIndexMinForRow = myMax(0, smlIndex - 1);
119
156
  for (bigIndex = bigIndexMinForRow; bigIndex <= bigIndexMaxForRow; bigIndex++) {
@@ -124,77 +161,119 @@ function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusN
124
161
  } else if (smlArray[smlIndex - 1] === bigArray[bigIndex - 1]) {
125
162
  thisRow[bigIndex] = lastRow[bigIndex - 1];
126
163
  } else {
127
- var northDistance = lastRow[bigIndex] || maxDistance;
128
- var westDistance = thisRow[bigIndex - 1] || maxDistance;
164
+ const northDistance = lastRow[bigIndex] || maxDistance;
165
+ const westDistance = thisRow[bigIndex - 1] || maxDistance;
129
166
  thisRow[bigIndex] = myMin(northDistance, westDistance) + 1;
130
167
  }
131
168
  }
132
169
  }
133
- var editScript = [], meMinusOne, notInSml = [], notInBig = [];
170
+ let editScript = new Array(), meMinusOne, notInSml = new Array(), notInBig = new Array();
134
171
  for (smlIndex = smlIndexMax, bigIndex = bigIndexMax; smlIndex || bigIndex; ) {
135
172
  meMinusOne = editDistanceMatrix[smlIndex][bigIndex] - 1;
136
173
  if (bigIndex && meMinusOne === editDistanceMatrix[smlIndex][bigIndex - 1]) {
137
- notInSml.push(editScript[editScript.length] = {
138
- "status": statusNotInSml,
139
- "value": bigArray[--bigIndex],
140
- "index": bigIndex
141
- });
174
+ notInSml.push(
175
+ editScript[editScript.length] = {
176
+ // added
177
+ status: statusNotInSml,
178
+ value: bigArray[--bigIndex],
179
+ index: bigIndex
180
+ }
181
+ );
142
182
  } else if (smlIndex && meMinusOne === editDistanceMatrix[smlIndex - 1][bigIndex]) {
143
- notInBig.push(editScript[editScript.length] = {
144
- "status": statusNotInBig,
145
- "value": smlArray[--smlIndex],
146
- "index": smlIndex
147
- });
183
+ notInBig.push(
184
+ editScript[editScript.length] = {
185
+ // deleted
186
+ status: statusNotInBig,
187
+ value: smlArray[--smlIndex],
188
+ index: smlIndex
189
+ }
190
+ );
148
191
  } else {
149
192
  --bigIndex;
150
193
  --smlIndex;
151
- if (!options3.sparse) {
152
- editScript.push({
153
- "status": "retained",
154
- "value": bigArray[bigIndex]
155
- });
194
+ if (!(options2 == null ? void 0 : options2.sparse)) {
195
+ editScript.push({ status: "retained", value: bigArray[bigIndex] });
156
196
  }
157
197
  }
158
198
  }
159
- findMovesInArrayComparison(notInBig, notInSml, !options3.dontLimitMoves && smlIndexMax * 10);
199
+ findMovesInArrayComparison(notInBig, notInSml, !options2.dontLimitMoves && smlIndexMax * 10);
160
200
  return editScript.reverse();
161
201
  }
162
202
 
163
203
  // ../utils/dist/options.js
164
- var options = {
165
- deferUpdates: false,
166
- useOnlyNativeEvents: false,
167
- protoProperty: "__ko_proto__",
168
- defaultBindingAttribute: "data-bind",
169
- allowVirtualElements: true,
170
- bindingGlobals: /* @__PURE__ */ Object.create(null),
171
- bindingProviderInstance: null,
172
- createChildContextWithAs: false,
173
- jQuery: globalThis.jQuery,
174
- Promise: globalThis.Promise,
175
- taskScheduler: null,
176
- debug: false,
177
- global: globalThis,
178
- document: globalThis.document,
179
- filters: {},
180
- includeDestroyed: false,
181
- foreachHidesDestroyed: false,
182
- onError: function(e) {
183
- throw e;
184
- },
185
- set: function(name, value) {
186
- options[name] = value;
187
- },
188
- getBindingHandler() {
189
- },
190
- cleanExternalData() {
204
+ var Options = class {
205
+ constructor() {
206
+ this.bindingStringPreparsers = [];
207
+ this.knockoutInstance = null;
208
+ this.deferUpdates = false;
209
+ this.useOnlyNativeEvents = true;
210
+ this.useTemplateTag = true;
211
+ this.protoProperty = "__ko_proto__";
212
+ this.defaultBindingAttribute = "data-bind";
213
+ this.allowVirtualElements = true;
214
+ this.bindingGlobals = /* @__PURE__ */ Object.create(null);
215
+ this.createChildContextWithAs = false;
216
+ this.disableJQueryUsage = false;
217
+ this.Promise = globalThis.Promise;
218
+ this.taskScheduler = null;
219
+ this.debug = false;
220
+ this.templateSizeLimit = 4096;
221
+ this.allowScriptTagsInTemplates = false;
222
+ this._sanitizeWarningLogged = false;
223
+ this.global = globalThis;
224
+ this.document = globalThis.document;
225
+ this.filters = {};
226
+ this.includeDestroyed = false;
227
+ this.foreachHidesDestroyed = false;
228
+ }
229
+ get jQuery() {
230
+ var _a;
231
+ if (this.disableJQueryUsage) return;
232
+ return (_a = this._jQuery) != null ? _a : globalThis.jQuery;
233
+ }
234
+ /**
235
+ * Set jQuery manuall to be used by TKO.
236
+ * @param jQuery If jQuery set to undefined, TKO will not use jQuery and this.disableJQueryUsage to true.
237
+ */
238
+ set jQuery(jQuery) {
239
+ if (!jQuery) {
240
+ this.disableJQueryUsage = true;
241
+ this._jQuery = void 0;
242
+ } else {
243
+ this._jQuery = jQuery;
244
+ this.disableJQueryUsage = false;
245
+ }
246
+ }
247
+ /**
248
+ * Sanitize HTML templates before parsing them. Default is a no-op.
249
+ * Please configure something like DOMPurify or validator.js for your environment.
250
+ * @param html HTML string to be sanitized
251
+ * @returns Sanitized HTML string
252
+ */
253
+ sanitizeHtmlTemplate(html) {
254
+ if (!this._sanitizeWarningLogged) {
255
+ console.warn(
256
+ "WARNING -- You don't have a HTML sanitizer configured. Please configure options.sanitizeHtmlTemplate to avoid XSS vulnerabilities."
257
+ );
258
+ this._sanitizeWarningLogged = true;
259
+ }
260
+ return html;
261
+ }
262
+ onError(e, throws = true) {
263
+ if (throws) throw e;
264
+ return e;
265
+ }
266
+ set(name, value) {
267
+ this[name] = value;
268
+ }
269
+ // Overload getBindingHandler to have a custom lookup function.
270
+ getBindingHandler(key) {
271
+ return null;
191
272
  }
192
- };
193
- Object.defineProperty(options, "$", {
194
- get: function() {
195
- return options.jQuery;
273
+ cleanExternalData(node, callback) {
196
274
  }
197
- });
275
+ };
276
+ var options = new Options();
198
277
  var options_default = options;
199
278
 
200
279
  // ../utils/dist/error.js
@@ -221,7 +300,7 @@ function safeSetTimeout(handler, timeout) {
221
300
 
222
301
  // ../utils/dist/async.js
223
302
  function throttle(callback, timeout) {
224
- var timeoutInstance;
303
+ let timeoutInstance;
225
304
  return function(...args) {
226
305
  if (!timeoutInstance) {
227
306
  timeoutInstance = safeSetTimeout(function() {
@@ -232,25 +311,13 @@ function throttle(callback, timeout) {
232
311
  };
233
312
  }
234
313
  function debounce(callback, timeout) {
235
- var timeoutInstance;
314
+ let timeoutInstance;
236
315
  return function(...args) {
237
316
  clearTimeout(timeoutInstance);
238
317
  timeoutInstance = safeSetTimeout(() => callback(...args), timeout);
239
318
  };
240
319
  }
241
320
 
242
- // ../utils/dist/ie.js
243
- var ieVersion = options_default.document && function() {
244
- var version = 3, div = options_default.document.createElement("div"), iElems = div.getElementsByTagName("i");
245
- while (div.innerHTML = "<!--[if gt IE " + ++version + "]><i></i><![endif]-->", iElems[0]) {
246
- }
247
- if (!version) {
248
- const userAgent = window.navigator.userAgent;
249
- return ua.match(/MSIE ([^ ]+)/) || ua.match(/rv:([^ )]+)/);
250
- }
251
- return version > 4 ? version : void 0;
252
- }();
253
-
254
321
  // ../utils/dist/object.js
255
322
  function hasOwnProperty(obj, propName) {
256
323
  return Object.prototype.hasOwnProperty.call(obj, propName);
@@ -263,8 +330,9 @@ function isObjectLike(obj) {
263
330
  }
264
331
  function extend(target, source) {
265
332
  if (source) {
266
- for (var prop in source) {
333
+ for (const prop of Object.keys(source)) {
267
334
  if (hasOwnProperty(source, prop)) {
335
+ ;
268
336
  target[prop] = source[prop];
269
337
  }
270
338
  }
@@ -272,7 +340,7 @@ function extend(target, source) {
272
340
  return target;
273
341
  }
274
342
  function objectForEach(obj, action) {
275
- for (var prop in obj) {
343
+ for (const prop in obj) {
276
344
  if (hasOwnProperty(obj, prop)) {
277
345
  action(prop, obj[prop]);
278
346
  }
@@ -285,8 +353,8 @@ function objectMap(source, mapping, thisArg) {
285
353
  if (arguments.length > 2) {
286
354
  mapping = mapping.bind(thisArg);
287
355
  }
288
- var target = {};
289
- for (var prop in source) {
356
+ const target = {};
357
+ for (const prop in source) {
290
358
  if (hasOwnProperty(source, prop)) {
291
359
  target[prop] = mapping(source[prop], prop, source);
292
360
  }
@@ -311,38 +379,31 @@ function overwriteLengthPropertyIfSupported(fn, descriptor) {
311
379
  }
312
380
  }
313
381
 
314
- // ../utils/dist/string.js
315
- function stringTrim(string) {
316
- return string === null || string === void 0 ? "" : string.trim ? string.trim() : string.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g, "");
317
- }
318
-
319
382
  // ../utils/dist/symbol.js
320
383
  var useSymbols = typeof Symbol === "function";
321
384
  function createSymbolOrString(identifier) {
322
385
  return useSymbols ? Symbol(identifier) : identifier;
323
386
  }
324
387
 
325
- // ../utils/dist/jquery.js
326
- var jQueryInstance = options_default.global && options_default.global.jQuery;
327
-
328
388
  // ../utils/dist/dom/info.js
329
389
  function domNodeIsContainedBy(node, containedByNode) {
330
390
  if (node === containedByNode) {
331
391
  return true;
332
392
  }
333
- if (node.nodeType === 11) {
393
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
334
394
  return false;
335
395
  }
336
396
  if (containedByNode.contains) {
337
- return containedByNode.contains(node.nodeType !== 1 ? node.parentNode : node);
397
+ return containedByNode.contains(node.nodeType !== Node.ELEMENT_NODE ? node.parentNode : node);
338
398
  }
339
399
  if (containedByNode.compareDocumentPosition) {
340
400
  return (containedByNode.compareDocumentPosition(node) & 16) == 16;
341
401
  }
342
- while (node && node != containedByNode) {
343
- node = node.parentNode;
402
+ let parentNode = node;
403
+ while (parentNode && parentNode != containedByNode) {
404
+ parentNode = parentNode.parentNode;
344
405
  }
345
- return !!node;
406
+ return !!parentNode;
346
407
  }
347
408
  function domNodeIsAttachedToDocument(node) {
348
409
  return domNodeIsContainedBy(node, node.ownerDocument.documentElement);
@@ -354,6 +415,29 @@ function tagNameLower(element) {
354
415
  return element && element.tagName && element.tagName.toLowerCase();
355
416
  }
356
417
 
418
+ // ../utils/dist/dom/event.js
419
+ var knownEvents = {};
420
+ var knownEventTypesByEventName = {};
421
+ knownEvents["UIEvents"] = ["keyup", "keydown", "keypress"];
422
+ knownEvents["MouseEvents"] = [
423
+ "click",
424
+ "dblclick",
425
+ "mousedown",
426
+ "mouseup",
427
+ "mousemove",
428
+ "mouseover",
429
+ "mouseout",
430
+ "mouseenter",
431
+ "mouseleave"
432
+ ];
433
+ objectForEach(knownEvents, function(eventType, knownEventsForType) {
434
+ if (knownEventsForType.length) {
435
+ for (let i = 0, j = knownEventsForType.length; i < j; i++) {
436
+ knownEventTypesByEventName[knownEventsForType[i]] = eventType;
437
+ }
438
+ }
439
+ });
440
+
357
441
  // ../utils/dist/dom/data.js
358
442
  var data_exports = {};
359
443
  __export(data_exports, {
@@ -363,64 +447,53 @@ __export(data_exports, {
363
447
  nextKey: () => nextKey,
364
448
  set: () => set
365
449
  });
366
- var datastoreTime = new Date().getTime();
450
+ var datastoreTime = (/* @__PURE__ */ new Date()).getTime();
367
451
  var dataStoreKeyExpandoPropertyName = `__ko__${datastoreTime}`;
368
- var dataStoreSymbol = Symbol("Knockout data");
369
- var dataStore;
452
+ var dataStoreSymbol = /* @__PURE__ */ Symbol("Knockout data");
370
453
  var uniqueId = 0;
371
- var modern = {
372
- getDataForNode(node, createIfNotFound) {
373
- let dataForNode = node[dataStoreSymbol];
374
- if (!dataForNode && createIfNotFound) {
375
- dataForNode = node[dataStoreSymbol] = {};
376
- }
377
- return dataForNode;
378
- },
379
- clear(node) {
380
- if (node[dataStoreSymbol]) {
381
- delete node[dataStoreSymbol];
382
- return true;
383
- }
384
- return false;
454
+ function isSafeKey(key) {
455
+ return key !== "__proto__" && key !== "constructor" && key !== "prototype";
456
+ }
457
+ function getDataForNode(node, createIfNotFound) {
458
+ let dataForNode = node[dataStoreSymbol];
459
+ if (!dataForNode && createIfNotFound) {
460
+ dataForNode = node[dataStoreSymbol] = {};
385
461
  }
386
- };
387
- var IE = {
388
- getDataforNode(node, createIfNotFound) {
389
- let dataStoreKey = node[dataStoreKeyExpandoPropertyName];
390
- const hasExistingDataStore = dataStoreKey && dataStoreKey !== "null" && dataStore[dataStoreKey];
391
- if (!hasExistingDataStore) {
392
- if (!createIfNotFound) {
393
- return void 0;
394
- }
395
- dataStoreKey = node[dataStoreKeyExpandoPropertyName] = "ko" + uniqueId++;
396
- dataStore[dataStoreKey] = {};
397
- }
398
- return dataStore[dataStoreKey];
399
- },
400
- clear(node) {
401
- const dataStoreKey = node[dataStoreKeyExpandoPropertyName];
402
- if (dataStoreKey) {
403
- delete dataStore[dataStoreKey];
404
- node[dataStoreKeyExpandoPropertyName] = null;
405
- return true;
406
- }
407
- return false;
462
+ return dataForNode;
463
+ }
464
+ function clear(node) {
465
+ if (node[dataStoreSymbol]) {
466
+ delete node[dataStoreSymbol];
467
+ return true;
408
468
  }
409
- };
410
- var { getDataForNode, clear } = ieVersion ? IE : modern;
469
+ return false;
470
+ }
411
471
  function nextKey() {
412
472
  return uniqueId++ + dataStoreKeyExpandoPropertyName;
413
473
  }
414
474
  function get(node, key) {
475
+ if (!isSafeKey(key)) throw new Error("Unsafe key for DOM data: " + key);
415
476
  const dataForNode = getDataForNode(node, false);
416
477
  return dataForNode && dataForNode[key];
417
478
  }
418
479
  function set(node, key, value) {
419
- var dataForNode = getDataForNode(node, value !== void 0);
420
- dataForNode && (dataForNode[key] = value);
480
+ if (!isSafeKey(key)) throw new Error("Unsafe key for DOM data: " + key);
481
+ const dataForNode = getDataForNode(
482
+ node,
483
+ value !== void 0
484
+ /* createIfNotFound */
485
+ );
486
+ if (dataForNode) {
487
+ dataForNode[key] = value;
488
+ }
421
489
  }
422
490
  function getOrSet(node, key, value) {
423
- const dataForNode = getDataForNode(node, true);
491
+ if (!isSafeKey(key)) throw new Error("Unsafe key for DOM data: " + key);
492
+ const dataForNode = getDataForNode(
493
+ node,
494
+ true
495
+ /* createIfNotFound */
496
+ );
424
497
  return dataForNode[key] || (dataForNode[key] = value);
425
498
  }
426
499
 
@@ -429,9 +502,9 @@ var domDataKey = nextKey();
429
502
  var cleanableNodeTypes = { 1: true, 8: true, 9: true };
430
503
  var cleanableNodeTypesWithDescendants = { 1: true, 9: true };
431
504
  function getDisposeCallbacksCollection(node, createIfNotFound) {
432
- var allDisposeCallbacks = get(node, domDataKey);
505
+ let allDisposeCallbacks = get(node, domDataKey);
433
506
  if (allDisposeCallbacks === void 0 && createIfNotFound) {
434
- allDisposeCallbacks = [];
507
+ allDisposeCallbacks = new Array();
435
508
  set(node, domDataKey, allDisposeCallbacks);
436
509
  }
437
510
  return allDisposeCallbacks;
@@ -440,7 +513,7 @@ function destroyCallbacksCollection(node) {
440
513
  set(node, domDataKey, void 0);
441
514
  }
442
515
  function cleanSingleNode(node) {
443
- var callbacks = getDisposeCallbacksCollection(node, false);
516
+ let callbacks = getDisposeCallbacksCollection(node, false);
444
517
  if (callbacks) {
445
518
  callbacks = callbacks.slice(0);
446
519
  for (let i = 0; i < callbacks.length; i++) {
@@ -455,14 +528,18 @@ function cleanSingleNode(node) {
455
528
  options_default.cleanExternalData(node);
456
529
  }
457
530
  if (cleanableNodeTypesWithDescendants[node.nodeType]) {
458
- cleanNodesInList(node.childNodes, true);
531
+ cleanNodesInList(
532
+ node.childNodes,
533
+ true
534
+ /* onlyComments */
535
+ );
459
536
  }
460
537
  }
461
538
  function cleanNodesInList(nodeList, onlyComments) {
462
- const cleanedNodes = [];
539
+ const cleanedNodes = new Array();
463
540
  let lastCleanedNode;
464
- for (var i = 0; i < nodeList.length; i++) {
465
- if (!onlyComments || nodeList[i].nodeType === 8) {
541
+ for (let i = 0; i < nodeList.length; i++) {
542
+ if (!onlyComments || nodeList[i].nodeType === Node.COMMENT_NODE) {
466
543
  cleanSingleNode(cleanedNodes[cleanedNodes.length] = lastCleanedNode = nodeList[i]);
467
544
  if (nodeList[i] !== lastCleanedNode) {
468
545
  while (i-- && arrayIndexOf(cleanedNodes, nodeList[i]) === -1) {
@@ -478,7 +555,7 @@ function addDisposeCallback(node, callback) {
478
555
  getDisposeCallbacksCollection(node, true).push(callback);
479
556
  }
480
557
  function removeDisposeCallback(node, callback) {
481
- var callbacksCollection = getDisposeCallbacksCollection(node, false);
558
+ const callbacksCollection = getDisposeCallbacksCollection(node, false);
482
559
  if (callbacksCollection) {
483
560
  arrayRemoveItem(callbacksCollection, callback);
484
561
  if (callbacksCollection.length === 0) {
@@ -489,57 +566,36 @@ function removeDisposeCallback(node, callback) {
489
566
  function cleanNode(node) {
490
567
  if (cleanableNodeTypes[node.nodeType]) {
491
568
  cleanSingleNode(node);
492
- if (cleanableNodeTypesWithDescendants[node.nodeType]) {
569
+ if (cleanableNodeTypesWithDescendants[node.nodeType] && node instanceof Element) {
493
570
  cleanNodesInList(node.getElementsByTagName("*"));
494
571
  }
495
572
  }
496
573
  return node;
497
574
  }
498
575
  function removeNode(node) {
576
+ if (!node) {
577
+ return;
578
+ }
499
579
  cleanNode(node);
500
580
  if (node.parentNode) {
501
581
  node.parentNode.removeChild(node);
502
582
  }
503
583
  }
504
- var otherNodeCleanerFunctions = [];
584
+ var otherNodeCleanerFunctions = new Array();
505
585
  function cleanjQueryData(node) {
506
- var jQueryCleanNodeFn = jQueryInstance ? jQueryInstance.cleanData : null;
586
+ const jQueryCleanNodeFn = options_default.jQuery ? options_default.jQuery.cleanData : null;
507
587
  if (jQueryCleanNodeFn) {
508
588
  jQueryCleanNodeFn([node]);
509
589
  }
510
590
  }
511
591
  otherNodeCleanerFunctions.push(cleanjQueryData);
512
592
 
513
- // ../utils/dist/dom/event.js
514
- var knownEvents = {};
515
- var knownEventTypesByEventName = {};
516
- var keyEventTypeName = options_default.global.navigator && /Firefox\/2/i.test(options_default.global.navigator.userAgent) ? "KeyboardEvent" : "UIEvents";
517
- knownEvents[keyEventTypeName] = ["keyup", "keydown", "keypress"];
518
- knownEvents["MouseEvents"] = [
519
- "click",
520
- "dblclick",
521
- "mousedown",
522
- "mouseup",
523
- "mousemove",
524
- "mouseover",
525
- "mouseout",
526
- "mouseenter",
527
- "mouseleave"
528
- ];
529
- objectForEach(knownEvents, function(eventType, knownEventsForType) {
530
- if (knownEventsForType.length) {
531
- for (var i = 0, j = knownEventsForType.length; i < j; i++) {
532
- knownEventTypesByEventName[knownEventsForType[i]] = eventType;
533
- }
534
- }
535
- });
536
-
537
593
  // ../utils/dist/dom/manipulation.js
538
594
  function moveCleanedNodesToContainerElement(nodes) {
539
- var nodesArray = makeArray(nodes);
540
- var templateDocument = nodesArray[0] && nodesArray[0].ownerDocument || document;
541
- var container = templateDocument.createElement("div");
542
- for (var i = 0, j = nodesArray.length; i < j; i++) {
595
+ const nodesArray = makeArray(nodes);
596
+ const templateDocument = nodesArray[0] && nodesArray[0].ownerDocument || document;
597
+ const container = templateDocument.createElement("div");
598
+ for (let i = 0, j = nodesArray.length; i < j; i++) {
543
599
  container.appendChild(cleanNode(nodesArray[i]));
544
600
  }
545
601
  return container;
@@ -547,20 +603,20 @@ function moveCleanedNodesToContainerElement(nodes) {
547
603
  function setDomNodeChildren(domNode, childNodes2) {
548
604
  emptyDomNode(domNode);
549
605
  if (childNodes2) {
550
- for (var i = 0, j = childNodes2.length; i < j; i++) {
606
+ for (let i = 0; i < childNodes2.length; i++) {
551
607
  domNode.appendChild(childNodes2[i]);
552
608
  }
553
609
  }
554
610
  }
555
611
  function replaceDomNodes(nodeToReplaceOrNodeArray, newNodesArray) {
556
- var nodesToReplaceArray = nodeToReplaceOrNodeArray.nodeType ? [nodeToReplaceOrNodeArray] : nodeToReplaceOrNodeArray;
612
+ const nodesToReplaceArray = Array.isArray(nodeToReplaceOrNodeArray) ? nodeToReplaceOrNodeArray : [nodeToReplaceOrNodeArray];
557
613
  if (nodesToReplaceArray.length > 0) {
558
- var insertionPoint = nodesToReplaceArray[0];
559
- var parent = insertionPoint.parentNode;
560
- for (var i = 0, j = newNodesArray.length; i < j; i++) {
561
- parent.insertBefore(newNodesArray[i], insertionPoint);
614
+ const insertionPoint = nodesToReplaceArray[0];
615
+ const parent = insertionPoint.parentNode;
616
+ for (let i = 0; i < newNodesArray.length; i++) {
617
+ parent == null ? void 0 : parent.insertBefore(newNodesArray[i], insertionPoint);
562
618
  }
563
- for (i = 0, j = nodesToReplaceArray.length; i < j; i++) {
619
+ for (let i = 0; i < nodesToReplaceArray.length; i++) {
564
620
  removeNode(nodesToReplaceArray[i]);
565
621
  }
566
622
  }
@@ -574,7 +630,7 @@ function emptyDomNode(domNode) {
574
630
  // ../utils/dist/dom/fixes.js
575
631
  function fixUpContinuousNodeArray(continuousNodeArray, parentNode) {
576
632
  if (continuousNodeArray.length) {
577
- parentNode = parentNode.nodeType === 8 && parentNode.parentNode || parentNode;
633
+ parentNode = parentNode.nodeType === Node.COMMENT_NODE && parentNode.parentNode || parentNode;
578
634
  while (continuousNodeArray.length && continuousNodeArray[0].parentNode !== parentNode) {
579
635
  continuousNodeArray.splice(0, 1);
580
636
  }
@@ -582,7 +638,7 @@ function fixUpContinuousNodeArray(continuousNodeArray, parentNode) {
582
638
  continuousNodeArray.length--;
583
639
  }
584
640
  if (continuousNodeArray.length > 1) {
585
- var current = continuousNodeArray[0], last = continuousNodeArray[continuousNodeArray.length - 1];
641
+ let current = continuousNodeArray[0], last = continuousNodeArray[continuousNodeArray.length - 1];
586
642
  continuousNodeArray.length = 0;
587
643
  while (current !== last) {
588
644
  continuousNodeArray.push(current);
@@ -616,24 +672,23 @@ __export(virtualElements_exports, {
616
672
  startCommentRegex: () => startCommentRegex,
617
673
  virtualNodeBindingValue: () => virtualNodeBindingValue
618
674
  });
619
- var commentNodesHaveTextProperty = options_default.document && options_default.document.createComment("test").text === "<!--test-->";
620
- var startCommentRegex = commentNodesHaveTextProperty ? /^<!--\s*ko(?:\s+([\s\S]+))?\s*-->$/ : /^\s*ko(?:\s+([\s\S]+))?\s*$/;
621
- var endCommentRegex = commentNodesHaveTextProperty ? /^<!--\s*\/ko\s*-->$/ : /^\s*\/ko\s*$/;
622
- var htmlTagsWithOptionallyClosingChildren = { "ul": true, "ol": true };
675
+ var startCommentRegex = /^\s*ko(?:\s+([\s\S]+))?\s*$/;
676
+ var endCommentRegex = /^\s*\/ko\s*$/;
677
+ var htmlTagsWithOptionallyClosingChildren = { ul: true, ol: true };
623
678
  function isStartComment(node) {
624
- return node.nodeType == 8 && startCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);
679
+ return node.nodeType === Node.COMMENT_NODE && startCommentRegex.test(node.nodeValue);
625
680
  }
626
681
  function isEndComment(node) {
627
- return node.nodeType == 8 && endCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);
682
+ return node.nodeType === Node.COMMENT_NODE && endCommentRegex.test(node.nodeValue);
628
683
  }
629
684
  function isUnmatchedEndComment(node) {
630
685
  return isEndComment(node) && !get(node, matchedEndCommentDataKey);
631
686
  }
632
687
  var matchedEndCommentDataKey = "__ko_matchedEndComment__";
633
688
  function getVirtualChildren(startComment, allowUnbalanced) {
634
- var currentNode = startComment;
635
- var depth = 1;
636
- var children = [];
689
+ let currentNode = startComment;
690
+ let depth = 1;
691
+ const children = new Array();
637
692
  while (currentNode = currentNode.nextSibling) {
638
693
  if (isEndComment(currentNode)) {
639
694
  set(currentNode, matchedEndCommentDataKey, true);
@@ -653,7 +708,7 @@ function getVirtualChildren(startComment, allowUnbalanced) {
653
708
  return null;
654
709
  }
655
710
  function getMatchingEndComment(startComment, allowUnbalanced) {
656
- var allVirtualChildren = getVirtualChildren(startComment, allowUnbalanced);
711
+ const allVirtualChildren = getVirtualChildren(startComment, allowUnbalanced);
657
712
  if (allVirtualChildren) {
658
713
  if (allVirtualChildren.length > 0) {
659
714
  return allVirtualChildren[allVirtualChildren.length - 1].nextSibling;
@@ -664,13 +719,17 @@ function getMatchingEndComment(startComment, allowUnbalanced) {
664
719
  }
665
720
  }
666
721
  function getUnbalancedChildTags(node) {
667
- var childNode = node.firstChild, captureRemaining = null;
722
+ let childNode = node.firstChild, captureRemaining = null;
668
723
  if (childNode) {
669
724
  do {
670
725
  if (captureRemaining) {
671
726
  captureRemaining.push(childNode);
672
727
  } else if (isStartComment(childNode)) {
673
- var matchingEndComment = getMatchingEndComment(childNode, true);
728
+ const matchingEndComment = getMatchingEndComment(
729
+ childNode,
730
+ /* allowUnbalanced: */
731
+ true
732
+ );
674
733
  if (matchingEndComment) {
675
734
  childNode = matchingEndComment;
676
735
  } else {
@@ -683,7 +742,7 @@ function getUnbalancedChildTags(node) {
683
742
  }
684
743
  return captureRemaining;
685
744
  }
686
- var allowedBindings = {};
745
+ var allowedBindings = /* @__PURE__ */ Object.create(null);
687
746
  var hasBindingValue = isStartComment;
688
747
  function childNodes(node) {
689
748
  return isStartComment(node) ? getVirtualChildren(node) : node.childNodes;
@@ -692,8 +751,8 @@ function emptyNode(node) {
692
751
  if (!isStartComment(node)) {
693
752
  emptyDomNode(node);
694
753
  } else {
695
- var virtualChildren = childNodes(node);
696
- for (var i = 0, j = virtualChildren.length; i < j; i++) {
754
+ const virtualChildren = childNodes(node);
755
+ for (let i = 0, j = virtualChildren.length; i < j; i++) {
697
756
  removeNode(virtualChildren[i]);
698
757
  }
699
758
  }
@@ -704,13 +763,16 @@ function setDomNodeChildren2(node, childNodes2) {
704
763
  } else {
705
764
  emptyNode(node);
706
765
  const endCommentNode = node.nextSibling;
707
- const parentNode = endCommentNode.parentNode;
708
- for (var i = 0, j = childNodes2.length; i < j; ++i) {
709
- parentNode.insertBefore(childNodes2[i], endCommentNode);
766
+ if (endCommentNode && endCommentNode.parentNode) {
767
+ const parentNode = endCommentNode.parentNode;
768
+ for (let i = 0, j = childNodes2.length; i < j; ++i) {
769
+ parentNode.insertBefore(childNodes2[i], endCommentNode);
770
+ }
710
771
  }
711
772
  }
712
773
  }
713
774
  function prepend(containerNode, nodeToPrepend) {
775
+ var _a;
714
776
  if (!isStartComment(containerNode)) {
715
777
  if (containerNode.firstChild) {
716
778
  containerNode.insertBefore(nodeToPrepend, containerNode.firstChild);
@@ -718,10 +780,11 @@ function prepend(containerNode, nodeToPrepend) {
718
780
  containerNode.appendChild(nodeToPrepend);
719
781
  }
720
782
  } else {
721
- containerNode.parentNode.insertBefore(nodeToPrepend, containerNode.nextSibling);
783
+ (_a = containerNode.parentNode) == null ? void 0 : _a.insertBefore(nodeToPrepend, containerNode.nextSibling);
722
784
  }
723
785
  }
724
786
  function insertAfter(containerNode, nodeToInsert, insertAfterNode) {
787
+ var _a;
725
788
  if (!insertAfterNode) {
726
789
  prepend(containerNode, nodeToInsert);
727
790
  } else if (!isStartComment(containerNode)) {
@@ -731,7 +794,7 @@ function insertAfter(containerNode, nodeToInsert, insertAfterNode) {
731
794
  containerNode.appendChild(nodeToInsert);
732
795
  }
733
796
  } else {
734
- containerNode.parentNode.insertBefore(nodeToInsert, insertAfterNode.nextSibling);
797
+ (_a = containerNode.parentNode) == null ? void 0 : _a.insertBefore(nodeToInsert, insertAfterNode.nextSibling);
735
798
  }
736
799
  }
737
800
  function firstChild(node) {
@@ -748,6 +811,7 @@ function firstChild(node) {
748
811
  }
749
812
  function lastChild(node) {
750
813
  let nextChild = firstChild(node);
814
+ if (!nextChild) return null;
751
815
  let lastChildNode;
752
816
  do {
753
817
  lastChildNode = nextChild;
@@ -760,7 +824,9 @@ function nextSibling(node) {
760
824
  }
761
825
  if (node.nextSibling && isEndComment(node.nextSibling)) {
762
826
  if (isUnmatchedEndComment(node.nextSibling)) {
763
- throw Error("Found end comment without a matching opening comment, as next sibling of " + node.outerHTML);
827
+ throw Error(
828
+ "Found end comment without a matching opening comment, as next sibling of " + node.outerHTML
829
+ );
764
830
  }
765
831
  return null;
766
832
  } else {
@@ -768,9 +834,9 @@ function nextSibling(node) {
768
834
  }
769
835
  }
770
836
  function previousSibling(node) {
771
- var depth = 0;
837
+ let depth = 0;
772
838
  do {
773
- if (node.nodeType === 8) {
839
+ if (node.nodeType === Node.COMMENT_NODE) {
774
840
  if (isStartComment(node)) {
775
841
  if (--depth === 0) {
776
842
  return node;
@@ -786,21 +852,21 @@ function previousSibling(node) {
786
852
  } while (node = node.previousSibling);
787
853
  }
788
854
  function virtualNodeBindingValue(node) {
789
- var regexMatch = (commentNodesHaveTextProperty ? node.text : node.nodeValue).match(startCommentRegex);
855
+ const regexMatch = node.nodeValue.match(startCommentRegex);
790
856
  return regexMatch ? regexMatch[1] : null;
791
857
  }
792
858
  function normaliseVirtualElementDomStructure(elementVerified) {
793
859
  if (!htmlTagsWithOptionallyClosingChildren[tagNameLower(elementVerified)]) {
794
860
  return;
795
861
  }
796
- var childNode = elementVerified.firstChild;
862
+ let childNode = elementVerified.firstChild;
797
863
  if (childNode) {
798
864
  do {
799
- if (childNode.nodeType === 1) {
800
- var unbalancedTags = getUnbalancedChildTags(childNode);
865
+ if (childNode.nodeType === Node.ELEMENT_NODE) {
866
+ const unbalancedTags = getUnbalancedChildTags(childNode);
801
867
  if (unbalancedTags) {
802
- var nodeToInsertBefore = childNode.nextSibling;
803
- for (var i = 0; i < unbalancedTags.length; i++) {
868
+ const nodeToInsertBefore = childNode.nextSibling;
869
+ for (let i = 0; i < unbalancedTags.length; i++) {
804
870
  if (nodeToInsertBefore) {
805
871
  elementVerified.insertBefore(unbalancedTags[i], nodeToInsertBefore);
806
872
  } else {
@@ -814,78 +880,48 @@ function normaliseVirtualElementDomStructure(elementVerified) {
814
880
  }
815
881
 
816
882
  // ../utils/dist/dom/html.js
817
- var none = [0, "", ""];
818
- var table = [1, "<table>", "</table>"];
819
- var tbody = [2, "<table><tbody>", "</tbody></table>"];
820
- var colgroup = [2, "<table><tbody></tbody><colgroup>", "</colgroup></table>"];
821
- var tr = [3, "<table><tbody><tr>", "</tr></tbody></table>"];
822
- var select = [1, "<select multiple='multiple'>", "</select>"];
823
- var fieldset = [1, "<fieldset>", "</fieldset>"];
824
- var map = [1, "<map>", "</map>"];
825
- var object = [1, "<object>", "</object>"];
826
- var lookup = {
827
- "area": map,
828
- "col": colgroup,
829
- "colgroup": table,
830
- "caption": table,
831
- "legend": fieldset,
832
- "thead": table,
833
- "tbody": table,
834
- "tfoot": table,
835
- "tr": tbody,
836
- "td": tr,
837
- "th": tr,
838
- "option": select,
839
- "optgroup": select,
840
- "param": object
841
- };
842
- var supportsTemplateTag = options_default.document && "content" in options_default.document.createElement("template");
843
- function getWrap(tags) {
844
- const m = tags.match(/^(?:<!--.*?-->\s*?)*?<([a-z]+)[\s>]/);
845
- return m && lookup[m[1]] || none;
846
- }
883
+ var supportsTemplateTag = options_default.useTemplateTag && options_default.document && "content" in options_default.document.createElement("template");
847
884
  function simpleHtmlParse(html, documentContext) {
848
- documentContext || (documentContext = document);
849
- var windowContext = documentContext["parentWindow"] || documentContext["defaultView"] || window;
850
- var tags = stringTrim(html).toLowerCase(), div = documentContext.createElement("div"), wrap = getWrap(tags), depth = wrap[0];
851
- var markup = "ignored<div>" + wrap[1] + html + wrap[2] + "</div>";
852
- if (typeof windowContext["innerShiv"] === "function") {
853
- div.appendChild(windowContext["innerShiv"](markup));
854
- } else {
855
- div.innerHTML = markup;
856
- }
857
- while (depth--) {
858
- div = div.lastChild;
885
+ if (!documentContext) {
886
+ documentContext = document;
859
887
  }
860
- return makeArray(div.lastChild.childNodes);
888
+ const div = documentContext.createElement("div");
889
+ div.innerHTML = html;
890
+ return makeArray(div.childNodes);
861
891
  }
862
892
  function templateHtmlParse(html, documentContext) {
863
893
  if (!documentContext) {
864
894
  documentContext = document;
865
895
  }
866
- var template = documentContext.createElement("template");
896
+ const template = documentContext.createElement("template");
867
897
  template.innerHTML = html;
868
898
  return makeArray(template.content.childNodes);
869
899
  }
870
900
  function jQueryHtmlParse(html, documentContext) {
871
- if (jQueryInstance.parseHTML) {
872
- return jQueryInstance.parseHTML(html, documentContext) || [];
873
- } else {
874
- var elems = jQueryInstance.clean([html], documentContext);
875
- if (elems && elems[0]) {
876
- var elem = elems[0];
877
- while (elem.parentNode && elem.parentNode.nodeType !== 11) {
878
- elem = elem.parentNode;
879
- }
880
- if (elem.parentNode) {
881
- elem.parentNode.removeChild(elem);
882
- }
883
- }
884
- return elems;
901
+ const jQuery = options_default.jQuery;
902
+ if (jQuery) {
903
+ return jQuery.parseHTML(html, documentContext) || [];
885
904
  }
905
+ return [];
886
906
  }
887
907
  function parseHtmlFragment(html, documentContext) {
888
- return supportsTemplateTag ? templateHtmlParse(html, documentContext) : jQueryInstance ? jQueryHtmlParse(html, documentContext) : simpleHtmlParse(html, documentContext);
908
+ const saferHtml = validateHTMLInput(html);
909
+ if (supportsTemplateTag) return templateHtmlParse(saferHtml, documentContext);
910
+ if (options_default.jQuery) {
911
+ return jQueryHtmlParse(saferHtml, documentContext);
912
+ }
913
+ return simpleHtmlParse(saferHtml, documentContext);
914
+ }
915
+ var scriptTagPattern = /<script\b[^>]*>([\s\S]*?)<\/script[^>]*>/i;
916
+ function validateHTMLInput(html) {
917
+ if (!html) return "";
918
+ if (options_default.templateSizeLimit > 0 && html.length > options_default.templateSizeLimit) {
919
+ throw new Error("Template is too long. Please configure the 'templateSizeLimit'");
920
+ }
921
+ if (!options_default.allowScriptTagsInTemplates && scriptTagPattern.test(html)) {
922
+ throw new Error("Script-tag in template detected.");
923
+ }
924
+ return options_default.sanitizeHtmlTemplate(html);
889
925
  }
890
926
  function parseHtmlForTemplateNodes(html, documentContext) {
891
927
  const nodes = parseHtmlFragment(html, documentContext);
@@ -900,18 +936,25 @@ function setHtml(node, html) {
900
936
  if (typeof html !== "string") {
901
937
  html = html.toString();
902
938
  }
903
- if (jQueryInstance && !supportsTemplateTag) {
904
- jQueryInstance(node).html(html);
939
+ const jQuery = options_default.jQuery;
940
+ if (jQuery && !supportsTemplateTag) {
941
+ const saferHtml = validateHTMLInput(html);
942
+ jQuery(node).html(saferHtml);
905
943
  } else {
906
- var parsedNodes = parseHtmlFragment(html, node.ownerDocument);
907
- if (node.nodeType === 8) {
944
+ let parsedNodes;
945
+ if (node.ownerDocument) {
946
+ parsedNodes = parseHtmlFragment(html, node.ownerDocument);
947
+ } else {
948
+ parsedNodes = parseHtmlFragment(html);
949
+ }
950
+ if (node.nodeType === Node.COMMENT_NODE) {
908
951
  if (html === null) {
909
952
  emptyNode(node);
910
953
  } else {
911
954
  setDomNodeChildren2(node, parsedNodes);
912
955
  }
913
956
  } else {
914
- for (var i = 0; i < parsedNodes.length; i++) {
957
+ for (let i = 0; i < parsedNodes.length; i++) {
915
958
  node.appendChild(parsedNodes[i]);
916
959
  }
917
960
  }
@@ -920,18 +963,21 @@ function setHtml(node, html) {
920
963
  }
921
964
 
922
965
  // ../utils/dist/dom/selectExtensions.js
923
- var hasDomDataExpandoProperty = Symbol("Knockout selectExtensions hasDomDataProperty");
966
+ var hasDomDataExpandoProperty = /* @__PURE__ */ Symbol("Knockout selectExtensions hasDomDataProperty");
924
967
  var selectExtensions = {
925
968
  optionValueDomDataKey: nextKey(),
926
969
  readValue: function(element) {
927
970
  switch (tagNameLower(element)) {
928
- case "option":
971
+ case "option": {
929
972
  if (element[hasDomDataExpandoProperty] === true) {
930
973
  return get(element, selectExtensions.optionValueDomDataKey);
931
974
  }
932
975
  return element.value;
933
- case "select":
934
- return element.selectedIndex >= 0 ? selectExtensions.readValue(element.options[element.selectedIndex]) : void 0;
976
+ }
977
+ case "select": {
978
+ const selectElement = element;
979
+ return selectElement.selectedIndex >= 0 ? selectExtensions.readValue(selectElement.options[selectElement.selectedIndex]) : void 0;
980
+ }
935
981
  default:
936
982
  return element.value;
937
983
  }
@@ -944,36 +990,42 @@ var selectExtensions = {
944
990
  if (hasDomDataExpandoProperty in element) {
945
991
  delete element[hasDomDataExpandoProperty];
946
992
  }
993
+ ;
947
994
  element.value = value;
948
995
  } else {
996
+ const el = element;
949
997
  set(element, selectExtensions.optionValueDomDataKey, value);
950
- element[hasDomDataExpandoProperty] = true;
951
- element.value = typeof value === "number" ? value : "";
998
+ el[hasDomDataExpandoProperty] = true;
999
+ el.value = typeof value === "number" ? value : "";
952
1000
  }
953
1001
  break;
954
1002
  case "select":
955
- if (value === "" || value === null) {
956
- value = void 0;
957
- }
958
- var selection = -1;
959
- for (let i = 0, n = element.options.length, optionValue; i < n; ++i) {
960
- optionValue = selectExtensions.readValue(element.options[i]);
961
- const strictEqual = optionValue === value;
962
- const blankEqual = optionValue === "" && value === void 0;
963
- const numericEqual = typeof value === "number" && Number(optionValue) === value;
964
- if (strictEqual || blankEqual || numericEqual) {
965
- selection = i;
966
- break;
1003
+ {
1004
+ if (value === "" || value === null) {
1005
+ value = void 0;
1006
+ }
1007
+ let selection = -1;
1008
+ const selectElement = element;
1009
+ for (let i = 0, n = selectElement.options.length, optionValue; i < n; ++i) {
1010
+ optionValue = selectExtensions.readValue(selectElement.options[i]);
1011
+ const strictEqual = optionValue === value;
1012
+ const blankEqual = optionValue === "" && value === void 0;
1013
+ const numericEqual = typeof value === "number" && Number(optionValue) === value;
1014
+ if (strictEqual || blankEqual || numericEqual) {
1015
+ selection = i;
1016
+ break;
1017
+ }
1018
+ }
1019
+ if (allowUnset || selection >= 0 || value === void 0 && selectElement.size > 1) {
1020
+ selectElement.selectedIndex = selection;
967
1021
  }
968
- }
969
- if (allowUnset || selection >= 0 || value === void 0 && element.size > 1) {
970
- element.selectedIndex = selection;
971
1022
  }
972
1023
  break;
973
1024
  default:
974
1025
  if (value === null || value === void 0) {
975
1026
  value = "";
976
1027
  }
1028
+ ;
977
1029
  element.value = value;
978
1030
  break;
979
1031
  }
@@ -999,13 +1051,14 @@ function findMemoNodes(rootNode, appendToArray) {
999
1051
  if (!rootNode) {
1000
1052
  return;
1001
1053
  }
1002
- if (rootNode.nodeType == 8) {
1003
- var memoId = parseMemoText(rootNode.nodeValue);
1054
+ if (rootNode.nodeType === Node.COMMENT_NODE) {
1055
+ const comment = rootNode;
1056
+ const memoId = parseMemoText(comment.nodeValue);
1004
1057
  if (memoId != null) {
1005
1058
  appendToArray.push({ domNode: rootNode, memoId });
1006
1059
  }
1007
- } else if (rootNode.nodeType == 1) {
1008
- for (var i = 0, childNodes2 = rootNode.childNodes, j = childNodes2.length; i < j; i++) {
1060
+ } else if (rootNode.nodeType === Node.ELEMENT_NODE) {
1061
+ for (let i = 0, childNodes2 = rootNode.childNodes, j = childNodes2.length; i < j; i++) {
1009
1062
  findMemoNodes(childNodes2[i], appendToArray);
1010
1063
  }
1011
1064
  }
@@ -1014,12 +1067,12 @@ function memoize(callback) {
1014
1067
  if (typeof callback !== "function") {
1015
1068
  throw new Error("You can only pass a function to memoization.memoize()");
1016
1069
  }
1017
- var memoId = generateRandomId();
1070
+ const memoId = generateRandomId();
1018
1071
  memos[memoId] = callback;
1019
1072
  return "<!--[ko_memo:" + memoId + "]-->";
1020
1073
  }
1021
1074
  function unmemoize(memoId, callbackParams) {
1022
- var callback = memos[memoId];
1075
+ const callback = memos[memoId];
1023
1076
  if (callback === void 0) {
1024
1077
  throw new Error("Couldn't find any memo with ID " + memoId + ". Perhaps it's already been unmemoized.");
1025
1078
  }
@@ -1031,11 +1084,11 @@ function unmemoize(memoId, callbackParams) {
1031
1084
  }
1032
1085
  }
1033
1086
  function unmemoizeDomNodeAndDescendants(domNode, extraCallbackParamsArray) {
1034
- var memos2 = [];
1087
+ const memos2 = new Array();
1035
1088
  findMemoNodes(domNode, memos2);
1036
- for (var i = 0, j = memos2.length; i < j; i++) {
1037
- var node = memos2[i].domNode;
1038
- var combinedParams = [node];
1089
+ for (let i = 0, j = memos2.length; i < j; i++) {
1090
+ const node = memos2[i].domNode;
1091
+ const combinedParams = [node];
1039
1092
  if (extraCallbackParamsArray) {
1040
1093
  arrayPushAll(combinedParams, extraCallbackParamsArray);
1041
1094
  }
@@ -1047,7 +1100,10 @@ function unmemoizeDomNodeAndDescendants(domNode, extraCallbackParamsArray) {
1047
1100
  }
1048
1101
  }
1049
1102
  function parseMemoText(memoText) {
1050
- var match = memoText.match(/^\[ko_memo\:(.*?)\]$/);
1103
+ if (!memoText) {
1104
+ return null;
1105
+ }
1106
+ const match = memoText.match(/^\[ko_memo\:(.*?)\]$/);
1051
1107
  return match ? match[1] : null;
1052
1108
  }
1053
1109
 
@@ -1059,30 +1115,19 @@ __export(tasks_exports, {
1059
1115
  runEarly: () => processTasks,
1060
1116
  schedule: () => schedule
1061
1117
  });
1062
- var taskQueue = [];
1118
+ var taskQueue = new Array();
1063
1119
  var taskQueueLength = 0;
1064
1120
  var nextHandle = 1;
1065
1121
  var nextIndexToProcess = 0;
1066
1122
  var w = options_default.global;
1067
1123
  if (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {
1068
- options_default.taskScheduler = function(callback) {
1069
- var div = w.document.createElement("div");
1124
+ options_default.taskScheduler = (function(callback) {
1125
+ const div = w.document.createElement("div");
1070
1126
  new w.MutationObserver(callback).observe(div, { attributes: true });
1071
1127
  return function() {
1072
1128
  div.classList.toggle("foo");
1073
1129
  };
1074
- }(scheduledProcess);
1075
- } else if (w && w.document && "onreadystatechange" in w.document.createElement("script")) {
1076
- options_default.taskScheduler = function(callback) {
1077
- var script = document.createElement("script");
1078
- script.onreadystatechange = function() {
1079
- script.onreadystatechange = null;
1080
- document.documentElement.removeChild(script);
1081
- script = null;
1082
- callback();
1083
- };
1084
- document.documentElement.appendChild(script);
1085
- };
1130
+ })(scheduledProcess);
1086
1131
  } else {
1087
1132
  options_default.taskScheduler = function(callback) {
1088
1133
  setTimeout(callback, 0);
@@ -1090,8 +1135,8 @@ if (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {
1090
1135
  }
1091
1136
  function processTasks() {
1092
1137
  if (taskQueueLength) {
1093
- var mark = taskQueueLength, countMarks = 0;
1094
- for (var task; nextIndexToProcess < taskQueueLength; ) {
1138
+ let mark = taskQueueLength, countMarks = 0;
1139
+ for (let task; nextIndexToProcess < taskQueueLength; ) {
1095
1140
  if (task = taskQueue[nextIndexToProcess++]) {
1096
1141
  if (nextIndexToProcess > mark) {
1097
1142
  if (++countMarks >= 5e3) {
@@ -1125,13 +1170,13 @@ function schedule(func) {
1125
1170
  return nextHandle++;
1126
1171
  }
1127
1172
  function cancel(handle) {
1128
- var index = handle - (nextHandle - taskQueueLength);
1173
+ const index = handle - (nextHandle - taskQueueLength);
1129
1174
  if (index >= nextIndexToProcess && index < taskQueueLength) {
1130
1175
  taskQueue[index] = null;
1131
1176
  }
1132
1177
  }
1133
1178
  function resetForTesting() {
1134
- var length = taskQueueLength - nextIndexToProcess;
1179
+ const length = taskQueueLength - nextIndexToProcess;
1135
1180
  nextIndexToProcess = taskQueueLength = taskQueue.length = 0;
1136
1181
  return length;
1137
1182
  }
@@ -1150,21 +1195,21 @@ __export(dependencyDetection_exports, {
1150
1195
  });
1151
1196
 
1152
1197
  // ../observable/dist/subscribableSymbol.js
1153
- var SUBSCRIBABLE_SYM = Symbol("Knockout Subscribable");
1198
+ var SUBSCRIBABLE_SYM = /* @__PURE__ */ Symbol("Knockout Subscribable");
1154
1199
  function isSubscribable(instance) {
1155
1200
  return instance && instance[SUBSCRIBABLE_SYM] || false;
1156
1201
  }
1157
1202
 
1158
1203
  // ../observable/dist/dependencyDetection.js
1159
- var outerFrames = [];
1204
+ var outerFrames = new Array();
1160
1205
  var currentFrame;
1161
1206
  var lastId = 0;
1162
1207
  function getId() {
1163
1208
  return ++lastId;
1164
1209
  }
1165
- function begin(options3) {
1210
+ function begin(options2) {
1166
1211
  outerFrames.push(currentFrame);
1167
- currentFrame = options3;
1212
+ currentFrame = options2;
1168
1213
  }
1169
1214
  function end() {
1170
1215
  currentFrame = outerFrames.pop();
@@ -1174,7 +1219,11 @@ function registerDependency(subscribable2) {
1174
1219
  if (!isSubscribable(subscribable2)) {
1175
1220
  throw new Error("Only subscribable things can act as dependencies");
1176
1221
  }
1177
- currentFrame.callback.call(currentFrame.callbackTarget, subscribable2, subscribable2._id || (subscribable2._id = getId()));
1222
+ currentFrame.callback.call(
1223
+ currentFrame.callbackTarget,
1224
+ subscribable2,
1225
+ subscribable2._id || (subscribable2._id = getId())
1226
+ );
1178
1227
  }
1179
1228
  }
1180
1229
  function ignore(callback, callbackTarget, callbackArgs) {
@@ -1189,16 +1238,19 @@ function getDependenciesCount() {
1189
1238
  if (currentFrame) {
1190
1239
  return currentFrame.computed.getDependenciesCount();
1191
1240
  }
1241
+ return void 0;
1192
1242
  }
1193
1243
  function getDependencies() {
1194
1244
  if (currentFrame) {
1195
1245
  return currentFrame.computed.getDependencies();
1196
1246
  }
1247
+ return void 0;
1197
1248
  }
1198
1249
  function isInitial() {
1199
1250
  if (currentFrame) {
1200
1251
  return currentFrame.isInitial;
1201
1252
  }
1253
+ return void 0;
1202
1254
  }
1203
1255
 
1204
1256
  // ../observable/dist/defer.js
@@ -1245,6 +1297,7 @@ var Subscription = class {
1245
1297
  this._node = node;
1246
1298
  addDisposeCallback(node, this._domNodeDisposalCallback = this.dispose.bind(this));
1247
1299
  }
1300
+ // TC39 Observable API
1248
1301
  unsubscribe() {
1249
1302
  this.dispose();
1250
1303
  }
@@ -1254,21 +1307,16 @@ var Subscription = class {
1254
1307
  };
1255
1308
 
1256
1309
  // ../observable/dist/extenders.js
1257
- var primitiveTypes = {
1258
- "undefined": 1,
1259
- "boolean": 1,
1260
- "number": 1,
1261
- "string": 1
1262
- };
1310
+ var primitiveTypes = { undefined: 1, boolean: 1, number: 1, string: 1 };
1263
1311
  function valuesArePrimitiveAndEqual(a, b) {
1264
- var oldValueIsPrimitive = a === null || typeof a in primitiveTypes;
1312
+ const oldValueIsPrimitive = a === null || typeof a in primitiveTypes;
1265
1313
  return oldValueIsPrimitive ? a === b : false;
1266
1314
  }
1267
1315
  function applyExtenders(requestedExtenders) {
1268
- var target = this;
1316
+ let target = this;
1269
1317
  if (requestedExtenders) {
1270
1318
  objectForEach(requestedExtenders, function(key, value) {
1271
- var extenderHandler = extenders[key];
1319
+ const extenderHandler = extenders[key];
1272
1320
  if (typeof extenderHandler === "function") {
1273
1321
  target = extenderHandler(target, value) || target;
1274
1322
  } else {
@@ -1283,17 +1331,19 @@ function notify(target, notifyWhen) {
1283
1331
  }
1284
1332
  function deferred(target, option) {
1285
1333
  if (option !== true) {
1286
- throw new Error("The 'deferred' extender only accepts the value 'true', because it is not supported to turn deferral off once enabled.");
1334
+ throw new Error(
1335
+ "The 'deferred' extender only accepts the value 'true', because it is not supported to turn deferral off once enabled."
1336
+ );
1287
1337
  }
1288
1338
  deferUpdates(target);
1289
1339
  }
1290
- function rateLimit(target, options22) {
1291
- var timeout, method, limitFunction;
1292
- if (typeof options22 === "number") {
1293
- timeout = options22;
1340
+ function rateLimit(target, options2) {
1341
+ let timeout, method, limitFunction;
1342
+ if (typeof options2 === "number") {
1343
+ timeout = options2;
1294
1344
  } else {
1295
- timeout = options22.timeout;
1296
- method = options22.method;
1345
+ timeout = options2.timeout;
1346
+ method = options2.method;
1297
1347
  }
1298
1348
  target._deferUpdates = false;
1299
1349
  limitFunction = method === "notifyWhenChangesStop" ? debounce : throttle;
@@ -1301,21 +1351,17 @@ function rateLimit(target, options22) {
1301
1351
  return limitFunction(callback, timeout);
1302
1352
  });
1303
1353
  }
1304
- var extenders = {
1305
- notify,
1306
- deferred,
1307
- rateLimit
1308
- };
1354
+ var extenders = { notify, deferred, rateLimit };
1309
1355
 
1310
1356
  // ../observable/dist/subscribable.js
1311
- var LATEST_VALUE = Symbol("Knockout latest value");
1357
+ var LATEST_VALUE = /* @__PURE__ */ Symbol("Knockout latest value");
1312
1358
  if (!Symbol.observable) {
1313
- Symbol.observable = Symbol.for("@tko/Symbol.observable");
1359
+ Symbol.observable = /* @__PURE__ */ Symbol.for("@tko/Symbol.observable");
1314
1360
  }
1315
- function subscribable() {
1361
+ var subscribable = function subscribableFactory() {
1316
1362
  Object.setPrototypeOf(this, ko_subscribable_fn);
1317
1363
  ko_subscribable_fn.init(this);
1318
- }
1364
+ };
1319
1365
  var defaultEvent = "change";
1320
1366
  var ko_subscribable_fn = {
1321
1367
  [SUBSCRIBABLE_SYM]: true,
@@ -1329,9 +1375,7 @@ var ko_subscribable_fn = {
1329
1375
  subscribe(callback, callbackTarget, event) {
1330
1376
  const isTC39Callback = typeof callback === "object" && callback.next;
1331
1377
  event = event || defaultEvent;
1332
- const observer = isTC39Callback ? callback : {
1333
- next: callbackTarget ? callback.bind(callbackTarget) : callback
1334
- };
1378
+ const observer = isTC39Callback ? callback : { next: callbackTarget ? callback.bind(callbackTarget) : callback };
1335
1379
  const subscriptionInstance = new Subscription(this, observer, () => {
1336
1380
  arrayRemoveItem(this._subscriptions[event], subscriptionInstance);
1337
1381
  if (this.afterSubscriptionRemove) {
@@ -1342,7 +1386,7 @@ var ko_subscribable_fn = {
1342
1386
  this.beforeSubscriptionAdd(event);
1343
1387
  }
1344
1388
  if (!this._subscriptions[event]) {
1345
- this._subscriptions[event] = [];
1389
+ this._subscriptions[event] = new Array();
1346
1390
  }
1347
1391
  this._subscriptions[event].push(subscriptionInstance);
1348
1392
  if (isTC39Callback && LATEST_VALUE in this) {
@@ -1385,7 +1429,7 @@ var ko_subscribable_fn = {
1385
1429
  if (event) {
1386
1430
  return this._subscriptions[event] && this._subscriptions[event].length || 0;
1387
1431
  } else {
1388
- var total = 0;
1432
+ let total = 0;
1389
1433
  objectForEach(this._subscriptions, function(eventName, subscriptions) {
1390
1434
  if (eventName !== "dirty") {
1391
1435
  total += subscriptions.length;
@@ -1440,6 +1484,7 @@ function observable(initialValue) {
1440
1484
  function Observable() {
1441
1485
  if (arguments.length > 0) {
1442
1486
  if (Observable.isDifferent(Observable[LATEST_VALUE], arguments[0])) {
1487
+ ;
1443
1488
  Observable.valueWillMutate();
1444
1489
  Observable[LATEST_VALUE] = arguments[0];
1445
1490
  Observable.valueHasMutated();
@@ -1460,20 +1505,43 @@ function observable(initialValue) {
1460
1505
  return Observable;
1461
1506
  }
1462
1507
  observable.fn = {
1508
+ /**
1509
+ * Compares two values for equality.
1510
+ * @param a The first value.
1511
+ * @param b The second value.
1512
+ * @returns True if the values are equal, otherwise false.
1513
+ */
1463
1514
  equalityComparer: valuesArePrimitiveAndEqual,
1515
+ /**
1516
+ * Returns the current value of the observable without creating a dependency.
1517
+ * @returns The current value.
1518
+ */
1464
1519
  peek() {
1465
1520
  return this[LATEST_VALUE];
1466
1521
  },
1522
+ /**
1523
+ * Notifies subscribers that the value has changed.
1524
+ */
1467
1525
  valueHasMutated() {
1468
1526
  this.notifySubscribers(this[LATEST_VALUE], "spectate");
1469
1527
  this.notifySubscribers(this[LATEST_VALUE]);
1470
1528
  },
1529
+ /**
1530
+ * Notifies subscribers that the value is about to change.
1531
+ */
1471
1532
  valueWillMutate() {
1472
1533
  this.notifySubscribers(this[LATEST_VALUE], "beforeChange");
1473
1534
  },
1535
+ /**
1536
+ * Modifies the value of the observable using a function.
1537
+ * @param fn The function to modify the value.
1538
+ * @param peek Whether to use the current value without creating a dependency.
1539
+ * @returns The modified observable.
1540
+ */
1474
1541
  modify(fn, peek22 = true) {
1475
- return this(fn(peek22 ? this.peek() : this()));
1542
+ this(fn(peek22 ? this.peek() : this()));
1476
1543
  },
1544
+ // Some observables may not always be writeable, notably computeds.
1477
1545
  isWriteable: true
1478
1546
  };
1479
1547
  function limitNotifySubscribers(value, event) {
@@ -1486,15 +1554,15 @@ function limitNotifySubscribers(value, event) {
1486
1554
  }
1487
1555
  }
1488
1556
  subscribable.fn.limit = function limit(limitFunction) {
1489
- var self = this;
1490
- var selfIsObservable = isObservable(self);
1491
- var beforeChange = "beforeChange";
1492
- var ignoreBeforeChange, notifyNextChange, previousValue, pendingValue, didUpdate;
1557
+ const self = this;
1558
+ const selfIsObservable = isObservable(self);
1559
+ const beforeChange = "beforeChange";
1560
+ let ignoreBeforeChange, notifyNextChange, previousValue, pendingValue, didUpdate;
1493
1561
  if (!self._origNotifySubscribers) {
1494
1562
  self._origNotifySubscribers = self.notifySubscribers;
1495
1563
  self.notifySubscribers = limitNotifySubscribers;
1496
1564
  }
1497
- var finish = limitFunction(function() {
1565
+ const finish = limitFunction(function() {
1498
1566
  self._notificationIsPending = false;
1499
1567
  if (selfIsObservable && pendingValue === self) {
1500
1568
  pendingValue = self._evalIfChanged ? self._evalIfChanged() : self();
@@ -1522,7 +1590,10 @@ subscribable.fn.limit = function limit(limitFunction) {
1522
1590
  }
1523
1591
  },
1524
1592
  _notifyNextChangeIfValueIsDifferent() {
1525
- if (self.isDifferent(previousValue, self.peek(true))) {
1593
+ if (self.isDifferent(previousValue, self.peek(
1594
+ true
1595
+ /* evaluate */
1596
+ ))) {
1526
1597
  notifyNextChange = true;
1527
1598
  }
1528
1599
  },
@@ -1554,10 +1625,10 @@ function isWriteableObservable(instance) {
1554
1625
 
1555
1626
  // ../observable/dist/observableArray.changeTracking.js
1556
1627
  var arrayChangeEventName = "arrayChange";
1557
- function trackArrayChanges(target, options3) {
1628
+ function trackArrayChanges(target, options2) {
1558
1629
  target.compareArrayOptions = {};
1559
- if (options3 && typeof options3 === "object") {
1560
- extend(target.compareArrayOptions, options3);
1630
+ if (options2 && typeof options2 === "object") {
1631
+ extend(target.compareArrayOptions, options2);
1561
1632
  }
1562
1633
  target.compareArrayOptions.sparse = true;
1563
1634
  if (target.cacheDiffForKnownOperation) {
@@ -1568,8 +1639,8 @@ function trackArrayChanges(target, options3) {
1568
1639
  let arrayChangeSubscription;
1569
1640
  let pendingNotifications = 0;
1570
1641
  let underlyingNotifySubscribersFunction;
1571
- let underlyingBeforeSubscriptionAddFunction = target.beforeSubscriptionAdd;
1572
- let underlyingAfterSubscriptionRemoveFunction = target.afterSubscriptionRemove;
1642
+ const underlyingBeforeSubscriptionAddFunction = target.beforeSubscriptionAdd;
1643
+ const underlyingAfterSubscriptionRemoveFunction = target.afterSubscriptionRemove;
1573
1644
  target.beforeSubscriptionAdd = function(event) {
1574
1645
  if (underlyingBeforeSubscriptionAddFunction) {
1575
1646
  underlyingBeforeSubscriptionAddFunction.call(target, event);
@@ -1606,11 +1677,11 @@ function trackArrayChanges(target, options3) {
1606
1677
  }
1607
1678
  return underlyingNotifySubscribersFunction.apply(this, arguments);
1608
1679
  };
1609
- var previousContents = [].concat(target.peek() === void 0 ? [] : target.peek());
1680
+ let previousContents = new Array().concat(target.peek() === void 0 ? [] : target.peek());
1610
1681
  cachedDiff = null;
1611
1682
  arrayChangeSubscription = target.subscribe(function(currentContents) {
1612
1683
  let changes;
1613
- currentContents = [].concat(currentContents || []);
1684
+ currentContents = new Array().concat(currentContents || []);
1614
1685
  if (target.hasSubscriptionsForEvent(arrayChangeEventName)) {
1615
1686
  changes = getChanges(previousContents, currentContents);
1616
1687
  }
@@ -1632,9 +1703,9 @@ function trackArrayChanges(target, options3) {
1632
1703
  if (!trackingChanges || pendingNotifications) {
1633
1704
  return;
1634
1705
  }
1635
- var diff = [], arrayLength = rawArray.length, argsLength = args.length, offset = 0;
1706
+ let diff = new Array(), arrayLength = rawArray.length, argsLength = args.length, offset = 0;
1636
1707
  function pushDiff(status, value, index) {
1637
- return diff[diff.length] = { "status": status, "value": value, "index": index };
1708
+ return diff[diff.length] = { status, value, index };
1638
1709
  }
1639
1710
  switch (operationName) {
1640
1711
  case "push":
@@ -1652,16 +1723,18 @@ function trackArrayChanges(target, options3) {
1652
1723
  }
1653
1724
  break;
1654
1725
  case "splice":
1655
- 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 = [];
1656
- for (let index = startIndex, argsIndex = 2; index < endIndex; ++index, ++argsIndex) {
1657
- if (index < endDeleteIndex) {
1658
- deletions.push(pushDiff("deleted", rawArray[index], index));
1659
- }
1660
- if (index < endAddIndex) {
1661
- additions.push(pushDiff("added", args[argsIndex], index));
1726
+ {
1727
+ 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();
1728
+ for (let index = startIndex, argsIndex = 2; index < endIndex; ++index, ++argsIndex) {
1729
+ if (index < endDeleteIndex) {
1730
+ deletions.push(pushDiff("deleted", rawArray[index], index));
1731
+ }
1732
+ if (index < endAddIndex) {
1733
+ additions.push(pushDiff("added", args[argsIndex], index));
1734
+ }
1662
1735
  }
1736
+ findMovesInArrayComparison(deletions, additions);
1663
1737
  }
1664
- findMovesInArrayComparison(deletions, additions);
1665
1738
  break;
1666
1739
  default:
1667
1740
  return;
@@ -1676,12 +1749,16 @@ extenders.trackArrayChanges = trackArrayChanges;
1676
1749
  function observableArray(initialValues) {
1677
1750
  initialValues = initialValues || [];
1678
1751
  if (typeof initialValues !== "object" || !("length" in initialValues)) {
1679
- throw new Error("The argument passed when initializing an observable array must be an array, or null, or undefined.");
1752
+ throw new Error(
1753
+ "The argument passed when initializing an observable array must be an array, or null, or undefined."
1754
+ );
1680
1755
  }
1681
- var result = observable(initialValues);
1682
- Object.setPrototypeOf(result, observableArray.fn);
1756
+ const result = Object.setPrototypeOf(observable(initialValues), observableArray.fn);
1683
1757
  trackArrayChanges(result);
1684
- overwriteLengthPropertyIfSupported(result, { get: () => result().length });
1758
+ overwriteLengthPropertyIfSupported(result, { get: () => {
1759
+ var _a;
1760
+ return (_a = result()) == null ? void 0 : _a.length;
1761
+ } });
1685
1762
  return result;
1686
1763
  }
1687
1764
  function isObservableArray(instance) {
@@ -1689,13 +1766,13 @@ function isObservableArray(instance) {
1689
1766
  }
1690
1767
  observableArray.fn = {
1691
1768
  remove(valueOrPredicate) {
1692
- var underlyingArray = this.peek();
1693
- var removedValues = [];
1694
- var predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value2) {
1695
- return value2 === valueOrPredicate;
1769
+ const underlyingArray = this.peek();
1770
+ const removedValues = new Array();
1771
+ const predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value) {
1772
+ return value === valueOrPredicate;
1696
1773
  };
1697
- for (var i = 0; i < underlyingArray.length; i++) {
1698
- var value = underlyingArray[i];
1774
+ for (let i = 0; i < underlyingArray.length; i++) {
1775
+ const value = underlyingArray[i];
1699
1776
  if (predicate(value)) {
1700
1777
  if (removedValues.length === 0) {
1701
1778
  this.valueWillMutate();
@@ -1715,8 +1792,8 @@ observableArray.fn = {
1715
1792
  },
1716
1793
  removeAll(arrayOfValues) {
1717
1794
  if (arrayOfValues === void 0) {
1718
- var underlyingArray = this.peek();
1719
- var allValues = underlyingArray.slice(0);
1795
+ const underlyingArray = this.peek();
1796
+ const allValues = underlyingArray.slice(0);
1720
1797
  this.valueWillMutate();
1721
1798
  underlyingArray.splice(0, underlyingArray.length);
1722
1799
  this.valueHasMutated();
@@ -1730,13 +1807,13 @@ observableArray.fn = {
1730
1807
  });
1731
1808
  },
1732
1809
  destroy(valueOrPredicate) {
1733
- var underlyingArray = this.peek();
1734
- var predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value2) {
1735
- return value2 === valueOrPredicate;
1810
+ const underlyingArray = this.peek();
1811
+ const predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value) {
1812
+ return value === valueOrPredicate;
1736
1813
  };
1737
1814
  this.valueWillMutate();
1738
- for (var i = underlyingArray.length - 1; i >= 0; i--) {
1739
- var value = underlyingArray[i];
1815
+ for (let i = underlyingArray.length - 1; i >= 0; i--) {
1816
+ const value = underlyingArray[i];
1740
1817
  if (predicate(value)) {
1741
1818
  value["_destroy"] = true;
1742
1819
  }
@@ -1760,7 +1837,7 @@ observableArray.fn = {
1760
1837
  return arrayIndexOf(this(), item);
1761
1838
  },
1762
1839
  replace(oldItem, newItem) {
1763
- var index = this.indexOf(oldItem);
1840
+ const index = this.indexOf(oldItem);
1764
1841
  if (index >= 0) {
1765
1842
  this.valueWillMutate();
1766
1843
  this.peek()[index] = newItem;
@@ -1774,23 +1851,23 @@ observableArray.fn = {
1774
1851
  return [...this()].reverse();
1775
1852
  },
1776
1853
  [Symbol.iterator]: function* () {
1777
- yield* this();
1854
+ yield* __yieldStar(this());
1778
1855
  }
1779
1856
  };
1780
1857
  Object.setPrototypeOf(observableArray.fn, observable.fn);
1781
1858
  arrayForEach(["pop", "push", "reverse", "shift", "sort", "splice", "unshift"], function(methodName) {
1782
1859
  observableArray.fn[methodName] = function() {
1783
- var underlyingArray = this.peek();
1860
+ const underlyingArray = this.peek();
1784
1861
  this.valueWillMutate();
1785
1862
  this.cacheDiffForKnownOperation(underlyingArray, methodName, arguments);
1786
- var methodCallResult = underlyingArray[methodName].apply(underlyingArray, arguments);
1863
+ const methodCallResult = underlyingArray[methodName].apply(underlyingArray, arguments);
1787
1864
  this.valueHasMutated();
1788
1865
  return methodCallResult === underlyingArray ? this : methodCallResult;
1789
1866
  };
1790
1867
  });
1791
1868
  arrayForEach(["slice"], function(methodName) {
1792
1869
  observableArray.fn[methodName] = function() {
1793
- var underlyingArray = this();
1870
+ const underlyingArray = this();
1794
1871
  return underlyingArray[methodName].apply(underlyingArray, arguments);
1795
1872
  };
1796
1873
  });
@@ -1801,35 +1878,8 @@ var templateScript = 1;
1801
1878
  var templateTextArea = 2;
1802
1879
  var templateTemplate = 3;
1803
1880
  var templateElement = 4;
1804
- function domElement(element) {
1805
- this.domElement = element;
1806
- if (!element) {
1807
- return;
1808
- }
1809
- var tagNameLower2 = tagNameLower(element);
1810
- this.templateType = tagNameLower2 === "script" ? templateScript : tagNameLower2 === "textarea" ? templateTextArea : tagNameLower2 == "template" && element.content && element.content.nodeType === 11 ? templateTemplate : templateElement;
1811
- }
1812
- domElement.prototype.text = function() {
1813
- var elemContentsProperty = this.templateType === templateScript ? "text" : this.templateType === templateTextArea ? "value" : "innerHTML";
1814
- if (arguments.length == 0) {
1815
- return this.domElement[elemContentsProperty];
1816
- } else {
1817
- var valueToWrite = arguments[0];
1818
- if (elemContentsProperty === "innerHTML") {
1819
- setHtml(this.domElement, valueToWrite);
1820
- } else {
1821
- this.domElement[elemContentsProperty] = valueToWrite;
1822
- }
1823
- }
1824
- };
1881
+ var templateAnonymous = 5;
1825
1882
  var dataDomDataPrefix = data_exports.nextKey() + "_";
1826
- domElement.prototype.data = function(key) {
1827
- if (arguments.length === 1) {
1828
- return data_exports.get(this.domElement, dataDomDataPrefix + key);
1829
- } else {
1830
- data_exports.set(this.domElement, dataDomDataPrefix + key, arguments[1]);
1831
- }
1832
- };
1833
1883
  var templatesDomDataKey = data_exports.nextKey();
1834
1884
  function getTemplateDomData(element) {
1835
1885
  return data_exports.get(element, templatesDomDataKey) || {};
@@ -1837,40 +1887,73 @@ function getTemplateDomData(element) {
1837
1887
  function setTemplateDomData(element, data) {
1838
1888
  data_exports.set(element, templatesDomDataKey, data);
1839
1889
  }
1840
- domElement.prototype.nodes = function() {
1841
- var element = this.domElement;
1842
- if (arguments.length == 0) {
1843
- const templateData = getTemplateDomData(element);
1844
- let nodes = templateData.containerData || (this.templateType === templateTemplate ? element.content : this.templateType === templateElement ? element : void 0);
1845
- if (!nodes || templateData.alwaysCheckText) {
1846
- const text = this["text"]();
1847
- if (text) {
1848
- nodes = parseHtmlForTemplateNodes(text, element.ownerDocument);
1849
- this["text"]("");
1850
- setTemplateDomData(element, { containerData: nodes, alwaysCheckText: true });
1890
+ var domElement = class {
1891
+ constructor(element) {
1892
+ this.domElement = element;
1893
+ if (element.nodeType === Node.COMMENT_NODE) {
1894
+ this.templateType = templateElement;
1895
+ } else {
1896
+ const tagNameLower2 = tagNameLower(this.domElement);
1897
+ this.templateType = tagNameLower2 === "script" ? templateScript : tagNameLower2 === "textarea" ? templateTextArea : (
1898
+ // For browsers with proper <template> element support, where the .content property gives a document fragment
1899
+ tagNameLower2 == "template" && element.content && element.content.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? templateTemplate : templateElement
1900
+ );
1901
+ }
1902
+ }
1903
+ text(valueToWrite) {
1904
+ const elemContentsProperty = this.templateType === templateScript ? "text" : this.templateType === templateTextArea ? "value" : "innerHTML";
1905
+ if (arguments.length == 0) {
1906
+ return this.domElement[elemContentsProperty];
1907
+ } else {
1908
+ if (elemContentsProperty === "innerHTML") {
1909
+ setHtml(this.domElement, valueToWrite);
1910
+ } else {
1911
+ this.domElement[elemContentsProperty] = valueToWrite;
1851
1912
  }
1852
1913
  }
1853
- return nodes;
1854
- } else {
1855
- var valueToWrite = arguments[0];
1856
- setTemplateDomData(element, { containerData: valueToWrite });
1914
+ }
1915
+ data(key, valueToWrite) {
1916
+ if (arguments.length === 1) {
1917
+ return data_exports.get(this.domElement, dataDomDataPrefix + key);
1918
+ } else {
1919
+ data_exports.set(this.domElement, dataDomDataPrefix + key, valueToWrite);
1920
+ }
1921
+ }
1922
+ nodes(valueToWrite) {
1923
+ const element = this.domElement;
1924
+ if (arguments.length == 0) {
1925
+ const templateData = getTemplateDomData(element);
1926
+ let nodes = templateData.containerData || (this.templateType === templateTemplate ? element.content : this.templateType === templateElement ? element : void 0);
1927
+ if (!nodes || templateData.alwaysCheckText) {
1928
+ const text = this.text();
1929
+ if (text) {
1930
+ nodes = parseHtmlForTemplateNodes(text, element.ownerDocument);
1931
+ this.text("");
1932
+ setTemplateDomData(element, { containerData: nodes, alwaysCheckText: true });
1933
+ }
1934
+ }
1935
+ return nodes;
1936
+ } else {
1937
+ setTemplateDomData(element, { containerData: valueToWrite });
1938
+ }
1939
+ return void 0;
1857
1940
  }
1858
1941
  };
1859
- function anonymousTemplate(element) {
1860
- this.domElement = element;
1861
- }
1862
- anonymousTemplate.prototype = new domElement();
1863
- anonymousTemplate.prototype.constructor = anonymousTemplate;
1864
- anonymousTemplate.prototype.text = function() {
1865
- if (arguments.length == 0) {
1866
- var templateData = getTemplateDomData(this.domElement);
1867
- if (templateData.textData === void 0 && templateData.containerData) {
1868
- templateData.textData = templateData.containerData.innerHTML;
1869
- }
1870
- return templateData.textData;
1871
- } else {
1872
- var valueToWrite = arguments[0];
1873
- setTemplateDomData(this.domElement, { textData: valueToWrite });
1942
+ var anonymousTemplate = class extends domElement {
1943
+ constructor(element) {
1944
+ super(element);
1945
+ this.templateType = templateAnonymous;
1946
+ }
1947
+ text(valueToWrite) {
1948
+ if (arguments.length == 0) {
1949
+ const templateData = getTemplateDomData(this.domElement);
1950
+ if (templateData.textData === void 0 && templateData.containerData) {
1951
+ templateData.textData = templateData.containerData.innerHTML;
1952
+ }
1953
+ return templateData.textData;
1954
+ } else {
1955
+ setTemplateDomData(this.domElement, { textData: valueToWrite });
1956
+ }
1874
1957
  }
1875
1958
  };
1876
1959
 
@@ -1878,29 +1961,31 @@ anonymousTemplate.prototype.text = function() {
1878
1961
  function templateEngine() {
1879
1962
  }
1880
1963
  extend(templateEngine.prototype, {
1881
- renderTemplateSource: function(templateSource, bindingContext2, options3, templateDocument) {
1882
- options3.onError("Override renderTemplateSource");
1964
+ renderTemplateSource(templateSource, bindingContext2, options2, templateDocument) {
1965
+ options2.onError("Override renderTemplateSource");
1883
1966
  },
1884
- createJavaScriptEvaluatorBlock: function(script) {
1885
- options_default.onError("Override createJavaScriptEvaluatorBlock");
1967
+ createJavaScriptEvaluatorBlock(script) {
1968
+ options_default.onError(new Error("Override createJavaScriptEvaluatorBlock"));
1886
1969
  },
1887
- makeTemplateSource: function(template, templateDocument) {
1970
+ makeTemplateSource(template, templateDocument) {
1888
1971
  if (typeof template === "string") {
1889
1972
  templateDocument = templateDocument || document;
1890
- var elem = templateDocument.getElementById(template);
1973
+ const elem = templateDocument.getElementById(template);
1891
1974
  if (!elem) {
1892
- options_default.onError("Cannot find template with ID " + template);
1975
+ throw options_default.onError(new Error("Cannot find template with ID " + template), false);
1893
1976
  }
1894
1977
  return new domElement(elem);
1895
- } else if (template.nodeType == 1 || template.nodeType == 8) {
1978
+ } else if (template.nodeType === Node.ELEMENT_NODE) {
1979
+ return new anonymousTemplate(template);
1980
+ } else if (template.nodeType === Node.COMMENT_NODE) {
1896
1981
  return new anonymousTemplate(template);
1897
1982
  } else {
1898
- options_default.onError("Unknown template type: " + template);
1983
+ throw options_default.onError(new Error("Unknown template type: " + template), false);
1899
1984
  }
1900
1985
  },
1901
- renderTemplate: function(template, bindingContext2, options3, templateDocument) {
1902
- var templateSource = this["makeTemplateSource"](template, templateDocument);
1903
- return this.renderTemplateSource(templateSource, bindingContext2, options3, templateDocument);
1986
+ renderTemplate(template, bindingContext2, options2, templateDocument) {
1987
+ const templateSource = this.makeTemplateSource(template, templateDocument);
1988
+ return this.renderTemplateSource(templateSource, bindingContext2, options2, templateDocument);
1904
1989
  }
1905
1990
  });
1906
1991
 
@@ -1917,20 +2002,20 @@ var DISPOSED_STATE = {
1917
2002
  readFunction: null,
1918
2003
  _options: null
1919
2004
  };
1920
- function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options22) {
2005
+ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2) {
1921
2006
  if (typeof evaluatorFunctionOrOptions === "object") {
1922
- options22 = evaluatorFunctionOrOptions;
2007
+ options2 = evaluatorFunctionOrOptions;
1923
2008
  } else {
1924
- options22 = options22 || {};
2009
+ options2 = options2 || {};
1925
2010
  if (evaluatorFunctionOrOptions) {
1926
- options22.read = evaluatorFunctionOrOptions;
2011
+ options2.read = evaluatorFunctionOrOptions;
1927
2012
  }
1928
2013
  }
1929
- if (typeof options22.read !== "function") {
2014
+ if (typeof (options2 == null ? void 0 : options2.read) !== "function") {
1930
2015
  throw Error("Pass a function that returns the value of the computed");
1931
2016
  }
1932
- var writeFunction = options22.write;
1933
- var state = {
2017
+ const writeFunction = options2.write;
2018
+ const state = {
1934
2019
  latestValue: void 0,
1935
2020
  isStale: true,
1936
2021
  isDirty: true,
@@ -1939,10 +2024,10 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options22
1939
2024
  isDisposed: false,
1940
2025
  pure: false,
1941
2026
  isSleeping: false,
1942
- readFunction: options22.read,
1943
- evaluatorFunctionTarget: evaluatorFunctionTarget || options22.owner,
1944
- disposeWhenNodeIsRemoved: options22.disposeWhenNodeIsRemoved || options22.disposeWhenNodeIsRemoved || null,
1945
- disposeWhen: options22.disposeWhen || options22.disposeWhen,
2027
+ readFunction: options2.read,
2028
+ evaluatorFunctionTarget: evaluatorFunctionTarget || options2.owner,
2029
+ disposeWhenNodeIsRemoved: options2.disposeWhenNodeIsRemoved || null,
2030
+ disposeWhen: options2.disposeWhen,
1946
2031
  domNodeDisposalCallback: null,
1947
2032
  dependencyTracking: {},
1948
2033
  dependenciesCount: 0,
@@ -1953,7 +2038,9 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options22
1953
2038
  if (typeof writeFunction === "function") {
1954
2039
  writeFunction.apply(state.evaluatorFunctionTarget, arguments);
1955
2040
  } else {
1956
- 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.");
2041
+ throw new Error(
2042
+ "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."
2043
+ );
1957
2044
  }
1958
2045
  return this;
1959
2046
  } else {
@@ -1961,6 +2048,7 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options22
1961
2048
  dependencyDetection_exports.registerDependency(computedObservable);
1962
2049
  }
1963
2050
  if (state.isDirty || state.isSleeping && computedObservable.haveDependenciesChanged()) {
2051
+ ;
1964
2052
  computedObservable.evaluateImmediate();
1965
2053
  }
1966
2054
  return state.latestValue;
@@ -1970,18 +2058,18 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options22
1970
2058
  computedObservable.isWriteable = typeof writeFunction === "function";
1971
2059
  subscribable.fn.init(computedObservable);
1972
2060
  Object.setPrototypeOf(computedObservable, computed.fn);
1973
- if (options22.pure) {
2061
+ if (options2.pure) {
1974
2062
  state.pure = true;
1975
2063
  state.isSleeping = true;
1976
2064
  extend(computedObservable, pureComputedOverrides);
1977
- } else if (options22.deferEvaluation) {
2065
+ } else if (options2.deferEvaluation) {
1978
2066
  extend(computedObservable, deferEvaluationOverrides);
1979
2067
  }
1980
2068
  if (options_default.deferUpdates) {
1981
2069
  extenders.deferred(computedObservable, true);
1982
2070
  }
1983
2071
  if (options_default.debug) {
1984
- computedObservable._options = options22;
2072
+ computedObservable._options = options2;
1985
2073
  }
1986
2074
  if (state.disposeWhenNodeIsRemoved) {
1987
2075
  state.suppressDisposalUntilDisposeWhenReturnsFalse = true;
@@ -1989,13 +2077,18 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options22
1989
2077
  state.disposeWhenNodeIsRemoved = null;
1990
2078
  }
1991
2079
  }
1992
- if (!state.isSleeping && !options22.deferEvaluation) {
2080
+ if (!state.isSleeping && !options2.deferEvaluation) {
2081
+ ;
1993
2082
  computedObservable.evaluateImmediate();
1994
2083
  }
1995
2084
  if (state.disposeWhenNodeIsRemoved && computedObservable.isActive()) {
1996
- addDisposeCallback(state.disposeWhenNodeIsRemoved, state.domNodeDisposalCallback = function() {
1997
- computedObservable.dispose();
1998
- });
2085
+ addDisposeCallback(
2086
+ state.disposeWhenNodeIsRemoved,
2087
+ state.domNodeDisposalCallback = function() {
2088
+ ;
2089
+ computedObservable.dispose();
2090
+ }
2091
+ );
1999
2092
  }
2000
2093
  return computedObservable;
2001
2094
  }
@@ -2005,14 +2098,18 @@ function computedDisposeDependencyCallback(id, entryToDispose) {
2005
2098
  }
2006
2099
  }
2007
2100
  function computedBeginDependencyDetectionCallback(subscribable2, id) {
2008
- var computedObservable = this.computedObservable, state = computedObservable[computedState];
2101
+ const computedObservable = this.computedObservable, state = computedObservable[computedState];
2009
2102
  if (!state.isDisposed) {
2010
2103
  if (this.disposalCount && this.disposalCandidates[id]) {
2011
2104
  computedObservable.addDependencyTracking(id, subscribable2, this.disposalCandidates[id]);
2012
2105
  this.disposalCandidates[id] = null;
2013
2106
  --this.disposalCount;
2014
2107
  } else if (!state.dependencyTracking[id]) {
2015
- computedObservable.addDependencyTracking(id, subscribable2, state.isSleeping ? { _target: subscribable2 } : computedObservable.subscribeToDependency(subscribable2));
2108
+ computedObservable.addDependencyTracking(
2109
+ id,
2110
+ subscribable2,
2111
+ state.isSleeping ? { _target: subscribable2 } : computedObservable.subscribeToDependency(subscribable2)
2112
+ );
2016
2113
  }
2017
2114
  if (subscribable2._notificationIsPending) {
2018
2115
  subscribable2._notifyNextChangeIfValueIsDifferent();
@@ -2026,7 +2123,7 @@ computed.fn = {
2026
2123
  },
2027
2124
  getDependencies() {
2028
2125
  const dependencyTracking = this[computedState].dependencyTracking;
2029
- const dependentObservables = [];
2126
+ const dependentObservables = new Array();
2030
2127
  objectForEach(dependencyTracking, function(id, dependency) {
2031
2128
  dependentObservables[dependency._order] = dependency._target;
2032
2129
  });
@@ -2041,7 +2138,7 @@ computed.fn = {
2041
2138
  trackingObj._version = target.getVersion();
2042
2139
  },
2043
2140
  haveDependenciesChanged() {
2044
- var id, dependency, dependencyTracking = this[computedState].dependencyTracking;
2141
+ let id, dependency, dependencyTracking = this[computedState].dependencyTracking;
2045
2142
  for (id in dependencyTracking) {
2046
2143
  if (hasOwnProperty(dependencyTracking, id)) {
2047
2144
  dependency = dependencyTracking[id];
@@ -2050,10 +2147,14 @@ computed.fn = {
2050
2147
  }
2051
2148
  }
2052
2149
  }
2150
+ return false;
2053
2151
  },
2054
2152
  markDirty() {
2055
2153
  if (this._evalDelayed && !this[computedState].isBeingEvaluated) {
2056
- this._evalDelayed(false);
2154
+ this._evalDelayed(
2155
+ false
2156
+ /* notifyChange */
2157
+ );
2057
2158
  }
2058
2159
  },
2059
2160
  isActive() {
@@ -2069,7 +2170,7 @@ computed.fn = {
2069
2170
  },
2070
2171
  subscribeToDependency(target) {
2071
2172
  if (target._deferUpdates) {
2072
- var dirtySub = target.subscribe(this.markDirty, this, "dirty"), changeSub = target.subscribe(this.respondToChange, this);
2173
+ const dirtySub = target.subscribe(this.markDirty, this, "dirty"), changeSub = target.subscribe(this.respondToChange, this);
2073
2174
  return {
2074
2175
  _target: target,
2075
2176
  dispose() {
@@ -2082,20 +2183,29 @@ computed.fn = {
2082
2183
  }
2083
2184
  },
2084
2185
  evaluatePossiblyAsync() {
2085
- var computedObservable = this, throttleEvaluationTimeout = computedObservable.throttleEvaluation;
2186
+ const computedObservable = this, throttleEvaluationTimeout = computedObservable.throttleEvaluation;
2086
2187
  if (throttleEvaluationTimeout && throttleEvaluationTimeout >= 0) {
2087
2188
  clearTimeout(this[computedState].evaluationTimeoutInstance);
2088
2189
  this[computedState].evaluationTimeoutInstance = safeSetTimeout(function() {
2089
- computedObservable.evaluateImmediate(true);
2190
+ computedObservable.evaluateImmediate(
2191
+ true
2192
+ /* notifyChange */
2193
+ );
2090
2194
  }, throttleEvaluationTimeout);
2091
2195
  } else if (computedObservable._evalDelayed) {
2092
- computedObservable._evalDelayed(true);
2196
+ computedObservable._evalDelayed(
2197
+ true
2198
+ /* notifyChange */
2199
+ );
2093
2200
  } else {
2094
- computedObservable.evaluateImmediate(true);
2201
+ computedObservable.evaluateImmediate(
2202
+ true
2203
+ /* notifyChange */
2204
+ );
2095
2205
  }
2096
2206
  },
2097
2207
  evaluateImmediate(notifyChange) {
2098
- var computedObservable = this, state = computedObservable[computedState], disposeWhen = state.disposeWhen, changed = false;
2208
+ let computedObservable = this, state = computedObservable[computedState], disposeWhen = state.disposeWhen, changed = false;
2099
2209
  if (state.isBeingEvaluated) {
2100
2210
  return;
2101
2211
  }
@@ -2119,8 +2229,8 @@ computed.fn = {
2119
2229
  return changed;
2120
2230
  },
2121
2231
  evaluateImmediate_CallReadWithDependencyDetection(notifyChange) {
2122
- var computedObservable = this, state = computedObservable[computedState], changed = false;
2123
- var isInitial2 = state.pure ? void 0 : !state.dependenciesCount, dependencyDetectionContext = {
2232
+ let computedObservable = this, state = computedObservable[computedState], changed = false;
2233
+ const isInitial2 = state.pure ? void 0 : !state.dependenciesCount, dependencyDetectionContext = {
2124
2234
  computedObservable,
2125
2235
  disposalCandidates: state.dependencyTracking,
2126
2236
  disposalCount: state.dependenciesCount
@@ -2133,7 +2243,7 @@ computed.fn = {
2133
2243
  });
2134
2244
  state.dependencyTracking = {};
2135
2245
  state.dependenciesCount = 0;
2136
- var newValue = this.evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext);
2246
+ const newValue = this.evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext);
2137
2247
  if (!state.dependenciesCount) {
2138
2248
  computedObservable.dispose();
2139
2249
  changed = true;
@@ -2165,7 +2275,7 @@ computed.fn = {
2165
2275
  },
2166
2276
  evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext) {
2167
2277
  try {
2168
- var readFunction = state.readFunction;
2278
+ const readFunction = state.readFunction;
2169
2279
  return state.evaluatorFunctionTarget ? readFunction.call(state.evaluatorFunctionTarget) : readFunction();
2170
2280
  } finally {
2171
2281
  dependencyDetection_exports.end();
@@ -2205,12 +2315,16 @@ computed.fn = {
2205
2315
  if (isChange) {
2206
2316
  state.isStale = true;
2207
2317
  }
2208
- this._limitChange(this, !isChange);
2318
+ this._limitChange(
2319
+ this,
2320
+ !isChange
2321
+ /* isDirty */
2322
+ );
2209
2323
  }
2210
2324
  });
2211
2325
  },
2212
2326
  dispose() {
2213
- var state = this[computedState];
2327
+ const state = this[computedState];
2214
2328
  if (!state.isSleeping && state.dependencyTracking) {
2215
2329
  objectForEach(state.dependencyTracking, function(id, dependency) {
2216
2330
  if (dependency.dispose) {
@@ -2226,7 +2340,7 @@ computed.fn = {
2226
2340
  };
2227
2341
  var pureComputedOverrides = {
2228
2342
  beforeSubscriptionAdd(event) {
2229
- var computedObservable = this, state = computedObservable[computedState];
2343
+ const computedObservable = this, state = computedObservable[computedState];
2230
2344
  if (!state.isDisposed && state.isSleeping && event === "change") {
2231
2345
  state.isSleeping = false;
2232
2346
  if (state.isStale || computedObservable.haveDependenciesChanged()) {
@@ -2236,12 +2350,12 @@ var pureComputedOverrides = {
2236
2350
  computedObservable.updateVersion();
2237
2351
  }
2238
2352
  } else {
2239
- var dependenciesOrder = [];
2353
+ const dependenciesOrder = new Array();
2240
2354
  objectForEach(state.dependencyTracking, function(id, dependency) {
2241
2355
  dependenciesOrder[dependency._order] = id;
2242
2356
  });
2243
2357
  arrayForEach(dependenciesOrder, function(id, order) {
2244
- var dependency = state.dependencyTracking[id], subscription = computedObservable.subscribeToDependency(dependency._target);
2358
+ const dependency = state.dependencyTracking[id], subscription = computedObservable.subscribeToDependency(dependency._target);
2245
2359
  subscription._order = order;
2246
2360
  subscription._version = dependency._version;
2247
2361
  state.dependencyTracking[id] = subscription;
@@ -2258,7 +2372,7 @@ var pureComputedOverrides = {
2258
2372
  }
2259
2373
  },
2260
2374
  afterSubscriptionRemove(event) {
2261
- var state = this[computedState];
2375
+ const state = this[computedState];
2262
2376
  if (!state.isDisposed && event === "change" && !this.hasSubscriptionsForEvent("change")) {
2263
2377
  objectForEach(state.dependencyTracking, function(id, dependency) {
2264
2378
  if (dependency.dispose) {
@@ -2275,7 +2389,7 @@ var pureComputedOverrides = {
2275
2389
  }
2276
2390
  },
2277
2391
  getVersion() {
2278
- var state = this[computedState];
2392
+ const state = this[computedState];
2279
2393
  if (state.isSleeping && (state.isStale || this.haveDependenciesChanged())) {
2280
2394
  this.evaluateImmediate();
2281
2395
  }
@@ -2295,18 +2409,20 @@ computed.fn[protoProp] = computed;
2295
2409
  observable.observablePrototypes.add(computed);
2296
2410
  function pureComputed(evaluatorFunctionOrOptions, evaluatorFunctionTarget) {
2297
2411
  if (typeof evaluatorFunctionOrOptions === "function") {
2298
- return computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, { "pure": true });
2412
+ const evaluator = evaluatorFunctionOrOptions;
2413
+ return computed(evaluator, evaluatorFunctionTarget, { pure: true });
2299
2414
  } else {
2300
- evaluatorFunctionOrOptions = extend({}, evaluatorFunctionOrOptions);
2301
- evaluatorFunctionOrOptions.pure = true;
2302
- return computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget);
2415
+ let options2 = evaluatorFunctionOrOptions;
2416
+ options2 = extend({}, options2);
2417
+ options2.pure = true;
2418
+ return computed(options2, evaluatorFunctionTarget);
2303
2419
  }
2304
2420
  }
2305
2421
 
2306
2422
  // ../computed/dist/throttleExtender.js
2307
2423
  function throttleExtender(target, timeout) {
2308
2424
  target.throttleEvaluation = timeout;
2309
- var writeTimeoutInstance = null;
2425
+ let writeTimeoutInstance = void 0;
2310
2426
  return computed({
2311
2427
  read: target,
2312
2428
  write: function(value) {
@@ -2317,11 +2433,12 @@ function throttleExtender(target, timeout) {
2317
2433
  }
2318
2434
  });
2319
2435
  }
2320
- extenders.throttle = throttleExtender;
2436
+ var extenders2 = extenders;
2437
+ extenders2.throttle = throttleExtender;
2321
2438
 
2322
2439
  // ../computed/dist/proxy.js
2323
- var PROXY_SYM = Symbol("Knockout Proxied Object");
2324
- var MIRROR_SYM = Symbol("Knockout Proxied Observables");
2440
+ var PROXY_SYM = /* @__PURE__ */ Symbol("Knockout Proxied Object");
2441
+ var MIRROR_SYM = /* @__PURE__ */ Symbol("Knockout Proxied Observables");
2325
2442
  function makeComputed(proxy2, fn) {
2326
2443
  return computed({
2327
2444
  owner: proxy2,
@@ -2339,14 +2456,14 @@ function setOrCreate(mirror, prop, value, proxy2) {
2339
2456
  mirror[prop](value);
2340
2457
  }
2341
2458
  }
2342
- function assignOrUpdate(mirror, object2, proxy2) {
2343
- for (const key of Object.keys(object2)) {
2344
- setOrCreate(mirror, key, object2[key], proxy2);
2459
+ function assignOrUpdate(mirror, object, proxy2) {
2460
+ for (const key of Object.keys(object)) {
2461
+ setOrCreate(mirror, key, object[key], proxy2);
2345
2462
  }
2346
- return object2;
2463
+ return object;
2347
2464
  }
2348
- function proxy(object2) {
2349
- const mirror = { [PROXY_SYM]: object2 };
2465
+ function proxy(object) {
2466
+ const mirror = { [PROXY_SYM]: object };
2350
2467
  mirror[MIRROR_SYM] = mirror;
2351
2468
  const proxy2 = new Proxy(function() {
2352
2469
  }, {
@@ -2358,43 +2475,40 @@ function proxy(object2) {
2358
2475
  },
2359
2476
  set(target, prop, value, receiver) {
2360
2477
  setOrCreate(mirror, prop, value, proxy2);
2361
- object2[prop] = value;
2478
+ object[prop] = value;
2362
2479
  return true;
2363
2480
  },
2364
2481
  deleteProperty(property) {
2365
2482
  delete mirror[property];
2366
- return delete object2[property];
2483
+ return delete object[property];
2367
2484
  },
2368
2485
  apply(target, thisArg, [props]) {
2369
2486
  if (props) {
2370
2487
  assignOrUpdate(mirror, props, proxy2);
2371
- return Object.assign(object2, props);
2488
+ return Object.assign(object, props);
2372
2489
  }
2373
- return object2;
2490
+ return object;
2374
2491
  },
2375
2492
  getPrototypeOf() {
2376
- return Object.getPrototypeOf(object2);
2493
+ return Object.getPrototypeOf(object);
2377
2494
  },
2378
2495
  setPrototypeOf(target, proto) {
2379
- return Object.setPrototypeOf(object2, proto);
2496
+ return Object.setPrototypeOf(object, proto);
2380
2497
  },
2381
2498
  defineProperty(target, prop, desc) {
2382
- return Object.defineProperty(object2, prop, desc);
2499
+ return Object.defineProperty(object, prop, desc);
2383
2500
  },
2384
2501
  preventExtensions() {
2385
- return Object.preventExtensions(object2);
2502
+ return Object.preventExtensions(object);
2386
2503
  },
2387
2504
  isExtensible() {
2388
- return Object.isExtensible(object2);
2505
+ return Object.isExtensible(object);
2389
2506
  },
2390
2507
  ownKeys() {
2391
- return [
2392
- ...Object.getOwnPropertyNames(object2),
2393
- ...Object.getOwnPropertySymbols(object2)
2394
- ];
2508
+ return [...Object.getOwnPropertyNames(object), ...Object.getOwnPropertySymbols(object)];
2395
2509
  }
2396
2510
  });
2397
- assignOrUpdate(mirror, object2, proxy2);
2511
+ assignOrUpdate(mirror, object, proxy2);
2398
2512
  return proxy2;
2399
2513
  }
2400
2514
  function getObservable(proxied, prop) {
@@ -2409,22 +2523,24 @@ function isProxied(proxied) {
2409
2523
  Object.assign(proxy, { getObservable, peek: peek2, isProxied });
2410
2524
 
2411
2525
  // ../bind/dist/bindingEvent.js
2412
- var contextAncestorBindingInfo = Symbol("_ancestorBindingInfo");
2526
+ var contextAncestorBindingInfo = /* @__PURE__ */ Symbol("_ancestorBindingInfo");
2413
2527
  var boundElementDomDataKey = data_exports.nextKey();
2414
2528
  var bindingEvent = {
2529
+ //TODO better: String-Enum "BindingEventEnum"
2415
2530
  childrenComplete: "childrenComplete",
2416
2531
  descendantsComplete: "descendantsComplete",
2417
- subscribe(node, event, callback, context) {
2532
+ subscribe(node, event, callback, callbackContext) {
2418
2533
  const bindingInfo = data_exports.getOrSet(node, boundElementDomDataKey, {});
2419
2534
  if (!bindingInfo.eventSubscribable) {
2420
2535
  bindingInfo.eventSubscribable = new subscribable();
2421
2536
  }
2422
- return bindingInfo.eventSubscribable.subscribe(callback, context, event);
2537
+ return bindingInfo.eventSubscribable.subscribe(callback, callbackContext, event);
2423
2538
  },
2424
2539
  notify(node, event) {
2425
2540
  const bindingInfo = data_exports.get(node, boundElementDomDataKey);
2426
2541
  if (bindingInfo) {
2427
2542
  if (bindingInfo.eventSubscribable) {
2543
+ ;
2428
2544
  bindingInfo.eventSubscribable.notifySubscribers(node, event);
2429
2545
  }
2430
2546
  }
@@ -2433,15 +2549,14 @@ var bindingEvent = {
2433
2549
 
2434
2550
  // ../bind/dist/bindingContext.js
2435
2551
  var boundElementDomDataKey2 = data_exports.nextKey();
2436
- var contextSubscribeSymbol = Symbol("Knockout Context Subscription");
2437
- var inheritParentIndicator = Symbol("Knockout Parent Indicator");
2438
- function bindingContext(dataItemOrAccessor, parentContext, dataItemAlias, extendCallback, settings) {
2552
+ var contextSubscribeSymbol = /* @__PURE__ */ Symbol("Knockout Context Subscription");
2553
+ var inheritParentIndicator = /* @__PURE__ */ Symbol("Knockout Parent Indicator");
2554
+ var bindingContext = function bindingContextFactory(dataItemOrAccessor, parentContext, dataItemAlias, extendCallback, settings) {
2439
2555
  const self = this;
2440
2556
  const shouldInheritData = dataItemOrAccessor === inheritParentIndicator;
2441
2557
  const realDataItemOrAccessor = shouldInheritData ? void 0 : dataItemOrAccessor;
2442
2558
  const isFunc = typeof realDataItemOrAccessor === "function" && !isObservable(realDataItemOrAccessor);
2443
2559
  self.ko = options_default.knockoutInstance;
2444
- let nodes;
2445
2560
  let subscribable2;
2446
2561
  function updateContext() {
2447
2562
  const dataItemOrObservable = isFunc ? realDataItemOrAccessor() : realDataItemOrAccessor;
@@ -2455,7 +2570,7 @@ function bindingContext(dataItemOrAccessor, parentContext, dataItemAlias, extend
2455
2570
  self[contextAncestorBindingInfo] = parentContext[contextAncestorBindingInfo];
2456
2571
  }
2457
2572
  } else {
2458
- self.$parents = [];
2573
+ self.$parents = new Array();
2459
2574
  self.$root = dataItem;
2460
2575
  }
2461
2576
  self[contextSubscribeSymbol] = subscribable2;
@@ -2485,7 +2600,7 @@ function bindingContext(dataItemOrAccessor, parentContext, dataItemAlias, extend
2485
2600
  self[contextSubscribeSymbol] = void 0;
2486
2601
  }
2487
2602
  }
2488
- }
2603
+ };
2489
2604
  Object.assign(bindingContext.prototype, {
2490
2605
  lookup(token, globals, node) {
2491
2606
  switch (token) {
@@ -2509,24 +2624,39 @@ Object.assign(bindingContext.prototype, {
2509
2624
  }
2510
2625
  throw new Error(`The variable "${token}" was not found on $data, $context, or globals.`);
2511
2626
  },
2627
+ // Extend the binding context hierarchy with a new view model object. If the parent context is watching
2628
+ // any observables, the new child context will automatically get a dependency on the parent context.
2629
+ // But this does not mean that the $data value of the child context will also get updated. If the child
2630
+ // view model also depends on the parent view model, you must provide a function that returns the correct
2631
+ // view model on each update.
2512
2632
  createChildContext(dataItemOrAccessor, dataItemAlias, extendCallback, settings) {
2513
- return new bindingContext(dataItemOrAccessor, this, dataItemAlias, function(self, parentContext) {
2514
- self.$parentContext = parentContext;
2515
- self.$parent = parentContext.$data;
2516
- self.$parents = (parentContext.$parents || []).slice(0);
2517
- self.$parents.unshift(self.$parent);
2518
- if (extendCallback) {
2519
- extendCallback(self);
2520
- }
2521
- }, settings);
2633
+ return new bindingContext(
2634
+ dataItemOrAccessor,
2635
+ this,
2636
+ dataItemAlias,
2637
+ function(self, parentContext) {
2638
+ var _a;
2639
+ self.$parentContext = parentContext;
2640
+ self.$parent = parentContext == null ? void 0 : parentContext.$data;
2641
+ self.$parents = ((_a = parentContext == null ? void 0 : parentContext.$parents) != null ? _a : []).slice(0);
2642
+ self.$parents.unshift(self.$parent);
2643
+ if (extendCallback) {
2644
+ extendCallback(self);
2645
+ }
2646
+ },
2647
+ settings
2648
+ );
2522
2649
  },
2650
+ // Extend the binding context with new custom properties. This doesn't change the context hierarchy.
2651
+ // Similarly to "child" contexts, provide a function here to make sure that the correct values are set
2652
+ // when an observable view model is updated.
2523
2653
  extend(properties) {
2524
- return new bindingContext(inheritParentIndicator, this, null, function(self, parentContext) {
2654
+ return new bindingContext(inheritParentIndicator, this, void 0, function(self, parentContext) {
2525
2655
  extend(self, typeof properties === "function" ? properties.call(self) : properties);
2526
2656
  });
2527
2657
  },
2528
2658
  createStaticChildContext(dataItemOrAccessor, dataItemAlias) {
2529
- return this.createChildContext(dataItemOrAccessor, dataItemAlias, null, { "exportDependencies": true });
2659
+ return this.createChildContext(dataItemOrAccessor, dataItemAlias, null, { exportDependencies: true });
2530
2660
  }
2531
2661
  });
2532
2662
  function storedBindingContextForNode(node) {
@@ -2534,23 +2664,30 @@ function storedBindingContextForNode(node) {
2534
2664
  return bindingInfo && bindingInfo.context;
2535
2665
  }
2536
2666
  function contextFor(node) {
2537
- if (node && (node.nodeType === 1 || node.nodeType === 8)) {
2667
+ if (node && (node.nodeType === Node.ELEMENT_NODE || node.nodeType === Node.COMMENT_NODE)) {
2538
2668
  return storedBindingContextForNode(node);
2539
2669
  }
2540
2670
  }
2541
2671
  function dataFor(node) {
2542
- var context = contextFor(node);
2672
+ const context = contextFor(node);
2543
2673
  return context ? context.$data : void 0;
2544
2674
  }
2545
2675
 
2546
2676
  // ../lifecycle/dist/LifeCycle.js
2547
2677
  var SUBSCRIPTIONS = createSymbolOrString("LifeCycle Subscriptions List");
2548
2678
  var ANCHOR_NODE = createSymbolOrString("LifeCycle Anchor Node");
2549
- var LifeCycle = class {
2679
+ var LifeCycle = class _LifeCycle {
2680
+ // NOTE: For more advanced integration as an ES6 mixin, see e.g.:
2681
+ // http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/
2682
+ /**
2683
+ * Copy the properties of the LifeCycle class to the target (or its prototype)
2684
+ *
2685
+ * NOTE: getOwnPropertyNames is needed to copy the non-enumerable properties.
2686
+ */
2550
2687
  static mixInto(Constructor) {
2551
2688
  const target = Constructor.prototype || Constructor;
2552
- const mixin = LifeCycle.prototype;
2553
- for (let prop of Object.getOwnPropertyNames(mixin)) {
2689
+ const mixin = _LifeCycle.prototype;
2690
+ for (const prop of Object.getOwnPropertyNames(mixin)) {
2554
2691
  target[prop] = mixin[prop];
2555
2692
  }
2556
2693
  }
@@ -2578,14 +2715,21 @@ var LifeCycle = class {
2578
2715
  params.disposeWhenNodeIsRemoved = this[ANCHOR_NODE];
2579
2716
  return this.addDisposable(computed(params));
2580
2717
  }
2718
+ /**
2719
+ * Add an event listener for the given or anchored node.
2720
+ * @param {node} [node] (optional) The target node (otherwise the anchored node)
2721
+ * @param {string} [type] Event type
2722
+ * @param {function|string} [action] Either call the given function or `this[action]`
2723
+ * @param {object} [options] (optional) Passed as `options` to `node.addEventListener`
2724
+ */
2581
2725
  addEventListener(...args) {
2582
2726
  const node = args[0].nodeType ? args.shift() : this[ANCHOR_NODE];
2583
- const [type, act, options3] = args;
2727
+ const [type, act, options2] = args;
2584
2728
  const handler = typeof act === "string" ? this[act].bind(this) : act;
2585
- this.__addEventListener(node, type, handler, options3);
2729
+ this.__addEventListener(node, type, handler, options2);
2586
2730
  }
2587
- __addEventListener(node, eventType, handler, options3) {
2588
- node.addEventListener(eventType, handler, options3);
2731
+ __addEventListener(node, eventType, handler, options2) {
2732
+ node.addEventListener(eventType, handler, options2);
2589
2733
  function dispose() {
2590
2734
  node.removeEventListener(eventType, handler);
2591
2735
  }
@@ -2604,7 +2748,7 @@ var LifeCycle = class {
2604
2748
  dispose() {
2605
2749
  const subscriptions = this[SUBSCRIPTIONS] || [];
2606
2750
  subscriptions.forEach((s) => s.dispose());
2607
- this[SUBSCRIPTIONS] = [];
2751
+ this[SUBSCRIPTIONS] = new Array();
2608
2752
  this[ANCHOR_NODE] = null;
2609
2753
  }
2610
2754
  addDisposable(subscription) {
@@ -2625,13 +2769,11 @@ var BindingHandler = class extends LifeCycle {
2625
2769
  constructor(params) {
2626
2770
  super();
2627
2771
  const { $element, valueAccessor, allBindings, $context } = params;
2628
- Object.assign(this, {
2629
- valueAccessor,
2630
- allBindings,
2631
- $element,
2632
- $context,
2633
- $data: $context.$data
2634
- });
2772
+ this.$element = $element;
2773
+ this.valueAccessor = valueAccessor;
2774
+ this.allBindings = allBindings;
2775
+ this.$context = $context;
2776
+ this.$data = $context.$data;
2635
2777
  this.anchorTo($element);
2636
2778
  }
2637
2779
  get value() {
@@ -2654,14 +2796,23 @@ var BindingHandler = class extends LifeCycle {
2654
2796
  static get isBindingHandlerClass() {
2655
2797
  return true;
2656
2798
  }
2799
+ /* Overload this for asynchronous bindings or bindings that recursively
2800
+ apply bindings (e.g. components, foreach, template).
2801
+
2802
+ A binding should be complete when it has run through once, notably
2803
+ in server-side bindings for pre-rendering.
2804
+ */
2657
2805
  get bindingCompleted() {
2658
2806
  return true;
2659
2807
  }
2660
2808
  static registerAs(name, provider = options_default.bindingProviderInstance) {
2661
2809
  provider.bindingHandlers.set(name, this);
2662
2810
  }
2811
+ static registerBindingHandler(handler, name, provider = options_default.bindingProviderInstance) {
2812
+ provider.bindingHandlers.set(name, handler);
2813
+ }
2663
2814
  };
2664
- var ResolveSymbol = Symbol("Async Binding Resolved");
2815
+ var ResolveSymbol = /* @__PURE__ */ Symbol("Async Binding Resolved");
2665
2816
  var AsyncBindingHandler = class extends BindingHandler {
2666
2817
  constructor(params) {
2667
2818
  super(params);
@@ -2678,7 +2829,10 @@ var AsyncBindingHandler = class extends BindingHandler {
2678
2829
  // ../bind/dist/LegacyBindingHandler.js
2679
2830
  var PossibleWeakMap = options_default.global.WeakMap || Map;
2680
2831
  var legacyBindingMap = new PossibleWeakMap();
2681
- var LegacyBindingHandler = class extends BindingHandler {
2832
+ var LegacyBindingHandler = class _LegacyBindingHandler extends BindingHandler {
2833
+ get handler() {
2834
+ return void 0;
2835
+ }
2682
2836
  constructor(params) {
2683
2837
  super(params);
2684
2838
  const handler = this.handler;
@@ -2704,18 +2858,21 @@ var LegacyBindingHandler = class extends BindingHandler {
2704
2858
  }
2705
2859
  }
2706
2860
  get legacyArgs() {
2707
- return [
2708
- this.$element,
2709
- this.valueAccessor,
2710
- this.allBindings,
2711
- this.$data,
2712
- this.$context
2713
- ];
2861
+ return [this.$element, this.valueAccessor, this.allBindings, this.$data, this.$context];
2714
2862
  }
2715
2863
  get controlsDescendants() {
2716
2864
  const objectToTest = this.initReturn || this.handler || {};
2717
2865
  return objectToTest.controlsDescendantBindings;
2718
2866
  }
2867
+ /**
2868
+ * Create a handler instance from the `origin`, which may be:
2869
+ *
2870
+ * 1. an object (becomes LegacyBindingHandler)
2871
+ * 2. a function (becomes LegacyBindingHandler with `init: function`)
2872
+ *
2873
+ * If given an object (the only kind supported in knockout 3.x and before), it
2874
+ * shall draw the `init`, `update`, and `allowVirtualElements` properties
2875
+ */
2719
2876
  static getOrCreateFor(key, handler) {
2720
2877
  if (legacyBindingMap.has(handler)) {
2721
2878
  return legacyBindingMap.get(handler);
@@ -2727,7 +2884,7 @@ var LegacyBindingHandler = class extends BindingHandler {
2727
2884
  static createFor(key, handler) {
2728
2885
  if (typeof handler === "function") {
2729
2886
  const [initFn, disposeFn] = [handler, handler.dispose];
2730
- return class extends LegacyBindingHandler {
2887
+ return class extends _LegacyBindingHandler {
2731
2888
  get handler() {
2732
2889
  const init = initFn.bind(this);
2733
2890
  const dispose = disposeFn ? disposeFn.bind(this) : null;
@@ -2742,7 +2899,7 @@ var LegacyBindingHandler = class extends BindingHandler {
2742
2899
  };
2743
2900
  }
2744
2901
  if (typeof handler === "object") {
2745
- return class extends LegacyBindingHandler {
2902
+ return class extends _LegacyBindingHandler {
2746
2903
  get handler() {
2747
2904
  return handler;
2748
2905
  }
@@ -2760,15 +2917,20 @@ var LegacyBindingHandler = class extends BindingHandler {
2760
2917
 
2761
2918
  // ../bind/dist/applyBindings.js
2762
2919
  var bindingDoesNotRecurseIntoElementTypes = {
2763
- "script": true,
2764
- "textarea": true,
2765
- "template": true
2920
+ // Don't want bindings that operate on text nodes to mutate <script> and <textarea> contents,
2921
+ // because it's unexpected and a potential XSS issue.
2922
+ // Also bindings should not operate on <template> elements since this breaks in Internet Explorer
2923
+ // and because such elements' contents are always intended to be bound in a different context
2924
+ // from where they appear in the document.
2925
+ script: true,
2926
+ textarea: true,
2927
+ template: true
2766
2928
  };
2767
2929
  function getBindingProvider() {
2768
2930
  return options_default.bindingProviderInstance.instance || options_default.bindingProviderInstance;
2769
2931
  }
2770
2932
  function isProviderForNode(provider, node) {
2771
- const nodeTypes = provider.FOR_NODE_TYPES || [1, 3, 8];
2933
+ const nodeTypes = provider.FOR_NODE_TYPES || [Node.ELEMENT_NODE, Node.TEXT_NODE, Node.COMMENT_NODE];
2772
2934
  return nodeTypes.includes(node.nodeType);
2773
2935
  }
2774
2936
  function asProperHandlerClass(handler, bindingKey) {
@@ -2819,11 +2981,11 @@ function nodeOrChildHasBindings(node) {
2819
2981
  return hasBindings(node) || [...node.childNodes].some((c) => nodeOrChildHasBindings(c));
2820
2982
  }
2821
2983
  function applyBindingsToNodeAndDescendantsInternal(bindingContext2, nodeVerified, asyncBindingsApplied) {
2822
- var isElement = nodeVerified.nodeType === 1;
2984
+ const isElement = nodeVerified.nodeType === Node.ELEMENT_NODE;
2823
2985
  if (isElement) {
2824
2986
  virtualElements_exports.normaliseVirtualElementDomStructure(nodeVerified);
2825
2987
  }
2826
- let shouldApplyBindings = isElement || hasBindings(nodeVerified);
2988
+ const shouldApplyBindings = isElement || hasBindings(nodeVerified);
2827
2989
  const { shouldBindDescendants } = shouldApplyBindings ? applyBindingsToNodeInternal(nodeVerified, null, bindingContext2, asyncBindingsApplied) : { shouldBindDescendants: true };
2828
2990
  if (shouldBindDescendants && !bindingDoesNotRecurseIntoElementTypes[tagNameLower(nodeVerified)]) {
2829
2991
  applyBindingsToDescendantsInternal(bindingContext2, nodeVerified, asyncBindingsApplied);
@@ -2832,7 +2994,7 @@ function applyBindingsToNodeAndDescendantsInternal(bindingContext2, nodeVerified
2832
2994
  function* topologicalSortBindings(bindings2, $component) {
2833
2995
  const results = [];
2834
2996
  const bindingsConsidered = {};
2835
- const cyclicDependencyStack = [];
2997
+ const cyclicDependencyStack = new Array();
2836
2998
  objectForEach(bindings2, function pushBinding(bindingKey) {
2837
2999
  if (!bindingsConsidered[bindingKey]) {
2838
3000
  const binding = getBindingHandlerFromComponent(bindingKey, $component) || getBindingHandler(bindingKey);
@@ -2846,7 +3008,9 @@ function* topologicalSortBindings(bindings2, $component) {
2846
3008
  return;
2847
3009
  }
2848
3010
  if (arrayIndexOf(cyclicDependencyStack, bindingDependencyKey) !== -1) {
2849
- throw Error("Cannot combine the following bindings, because they have a cyclic dependency: " + cyclicDependencyStack.join(", "));
3011
+ throw Error(
3012
+ "Cannot combine the following bindings, because they have a cyclic dependency: " + cyclicDependencyStack.join(", ")
3013
+ );
2850
3014
  } else {
2851
3015
  pushBinding(bindingDependencyKey);
2852
3016
  }
@@ -2882,30 +3046,32 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext2, asyn
2882
3046
  if (!alreadyBound) {
2883
3047
  bindingInfo.context = bindingContext2;
2884
3048
  }
2885
- var bindings2;
3049
+ let bindings2 = null;
3050
+ let bindingsUpdater = null;
2886
3051
  if (sourceBindings && typeof sourceBindings !== "function") {
2887
3052
  bindings2 = sourceBindings;
2888
3053
  } else {
2889
3054
  const provider = getBindingProvider();
2890
3055
  const getBindings = provider.getBindingAccessors;
2891
3056
  if (isProviderForNode(provider, node)) {
2892
- var bindingsUpdater = computed(function() {
2893
- bindings2 = sourceBindings ? sourceBindings(bindingContext2, node) : getBindings.call(provider, node, bindingContext2);
2894
- if (bindings2 && bindingContext2[contextSubscribeSymbol]) {
2895
- bindingContext2[contextSubscribeSymbol]();
2896
- }
2897
- return bindings2;
2898
- }, null, { disposeWhenNodeIsRemoved: node });
3057
+ bindingsUpdater = computed(
3058
+ function() {
3059
+ bindings2 = sourceBindings ? sourceBindings(bindingContext2, node) : getBindings.call(provider, node, bindingContext2);
3060
+ if (bindings2 && bindingContext2[contextSubscribeSymbol]) {
3061
+ bindingContext2[contextSubscribeSymbol]();
3062
+ }
3063
+ return bindings2;
3064
+ },
3065
+ null,
3066
+ { disposeWhenNodeIsRemoved: node }
3067
+ );
2899
3068
  if (!bindings2 || !bindingsUpdater.isActive()) {
2900
3069
  bindingsUpdater = null;
2901
3070
  }
2902
3071
  }
2903
3072
  }
2904
- var bindingHandlerThatControlsDescendantBindings;
3073
+ let bindingHandlerThatControlsDescendantBindings;
2905
3074
  if (bindings2) {
2906
- let allBindings = function() {
2907
- return objectMap(bindingsUpdater ? bindingsUpdater() : bindings2, evaluateValueAccessor);
2908
- };
2909
3075
  const $component = bindingContext2.$component || {};
2910
3076
  const allBindingHandlers = {};
2911
3077
  data_exports.set(node, "bindingHandlers", allBindingHandlers);
@@ -2917,24 +3083,32 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext2, asyn
2917
3083
  return valueAccessor(optionalValue);
2918
3084
  }
2919
3085
  } : (bindingKey) => bindings2[bindingKey];
3086
+ const allBindings = function() {
3087
+ return objectMap(bindingsUpdater ? bindingsUpdater() : bindings2, evaluateValueAccessor);
3088
+ };
2920
3089
  allBindings.has = (key) => key in bindings2;
2921
3090
  allBindings.get = (key) => bindings2[key] && evaluateValueAccessor(getValueAccessor(key));
2922
3091
  if (bindingEvent.childrenComplete in bindings2) {
2923
- bindingEvent.subscribe(node, bindingEvent.childrenComplete, () => {
2924
- const callback = evaluateValueAccessor(bindings2[bindingEvent.childrenComplete]);
2925
- if (!callback) {
2926
- return;
2927
- }
2928
- const nodes = virtualElements_exports.childNodes(node);
2929
- if (nodes.length) {
2930
- callback(nodes, dataFor(nodes[0]));
2931
- }
2932
- });
3092
+ bindingEvent.subscribe(
3093
+ node,
3094
+ bindingEvent.childrenComplete,
3095
+ () => {
3096
+ const callback = evaluateValueAccessor(bindings2[bindingEvent.childrenComplete]);
3097
+ if (!callback) {
3098
+ return;
3099
+ }
3100
+ const nodes = virtualElements_exports.childNodes(node);
3101
+ if (nodes.length) {
3102
+ callback(nodes, dataFor(nodes[0]));
3103
+ }
3104
+ },
3105
+ null
3106
+ );
2933
3107
  }
2934
3108
  const bindingsGenerated = topologicalSortBindings(bindings2, $component);
2935
3109
  const nodeAsyncBindingPromises = /* @__PURE__ */ new Set();
2936
3110
  for (const [key, BindingHandlerClass] of bindingsGenerated) {
2937
- let reportBindingError = function(during, errorCaptured) {
3111
+ const reportBindingError = function(during, errorCaptured) {
2938
3112
  onBindingError({
2939
3113
  during,
2940
3114
  errorCaptured,
@@ -2946,26 +3120,30 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext2, asyn
2946
3120
  valueAccessor: getValueAccessor(key)
2947
3121
  });
2948
3122
  };
2949
- if (node.nodeType === 8 && !BindingHandlerClass.allowVirtualElements) {
3123
+ if (node.nodeType === Node.COMMENT_NODE && !BindingHandlerClass.allowVirtualElements) {
2950
3124
  throw new Error(`The binding '${key}' cannot be used with virtual elements`);
2951
3125
  }
2952
3126
  try {
2953
- const bindingHandler = dependencyDetection_exports.ignore(() => new BindingHandlerClass({
2954
- allBindings,
2955
- $element: node,
2956
- $context: bindingContext2,
2957
- onError: reportBindingError,
2958
- valueAccessor(...v) {
2959
- return getValueAccessor(key)(...v);
2960
- }
2961
- }));
3127
+ const bindingHandler = dependencyDetection_exports.ignore(
3128
+ () => new BindingHandlerClass({
3129
+ allBindings,
3130
+ $element: node,
3131
+ $context: bindingContext2,
3132
+ onError: reportBindingError,
3133
+ valueAccessor(...v) {
3134
+ return getValueAccessor(key)(...v);
3135
+ }
3136
+ })
3137
+ );
2962
3138
  if (bindingHandler.onValueChange) {
2963
3139
  dependencyDetection_exports.ignore(() => bindingHandler.computed("onValueChange"));
2964
3140
  }
2965
3141
  allBindingHandlers[key] = bindingHandler;
2966
3142
  if (bindingHandler.controlsDescendants) {
2967
3143
  if (bindingHandlerThatControlsDescendantBindings !== void 0) {
2968
- 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.");
3144
+ throw new Error(
3145
+ "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."
3146
+ );
2969
3147
  }
2970
3148
  bindingHandlerThatControlsDescendantBindings = key;
2971
3149
  }
@@ -2974,7 +3152,8 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext2, asyn
2974
3152
  nodeAsyncBindingPromises.add(bindingHandler.bindingCompleted);
2975
3153
  }
2976
3154
  } catch (err) {
2977
- reportBindingError("creation", err);
3155
+ const error = err instanceof Error ? err : new Error(String(err));
3156
+ reportBindingError("creation", error);
2978
3157
  }
2979
3158
  }
2980
3159
  triggerDescendantsComplete(node, bindings2, nodeAsyncBindingPromises);
@@ -3003,15 +3182,12 @@ function getBindingContext(viewModelOrBindingContext, extendContextCallback) {
3003
3182
  }
3004
3183
  function applyBindings(viewModelOrBindingContext, rootNode, extendContextCallback) {
3005
3184
  const asyncBindingsApplied = /* @__PURE__ */ new Set();
3006
- if (!options_default.jQuery === void 0 && options_default.jQuery) {
3007
- options_default.jQuery = options_default.jQuery;
3008
- }
3009
3185
  if (!rootNode) {
3010
3186
  rootNode = window.document.body;
3011
3187
  if (!rootNode) {
3012
3188
  throw Error("ko.applyBindings: could not find window.document.body; has the document been loaded?");
3013
3189
  }
3014
- } else if (rootNode.nodeType !== 1 && rootNode.nodeType !== 8) {
3190
+ } else if (rootNode.nodeType !== Node.ELEMENT_NODE && rootNode.nodeType !== Node.COMMENT_NODE) {
3015
3191
  throw Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node");
3016
3192
  }
3017
3193
  const rootContext = getBindingContext(viewModelOrBindingContext, extendContextCallback);
@@ -3019,7 +3195,7 @@ function applyBindings(viewModelOrBindingContext, rootNode, extendContextCallbac
3019
3195
  return Promise.all(asyncBindingsApplied);
3020
3196
  }
3021
3197
  function onBindingError(spec) {
3022
- var error, bindingText;
3198
+ let error;
3023
3199
  if (spec.bindingKey) {
3024
3200
  error = spec.errorCaptured;
3025
3201
  spec.message = 'Unable to process binding "' + spec.bindingKey + '" in binding "' + spec.bindingKey + '"\nMessage: ' + (error.message ? error.message : error);
@@ -3030,7 +3206,12 @@ function onBindingError(spec) {
3030
3206
  extend(error, spec);
3031
3207
  } catch (e) {
3032
3208
  spec.stack = error.stack;
3033
- error = new Error(error.message ? error.message : error);
3209
+ const message = error.message || String(error);
3210
+ const originalName = error.name;
3211
+ error = new Error(message);
3212
+ if (originalName && originalName !== "Error") {
3213
+ error.name = originalName;
3214
+ }
3034
3215
  extend(error, spec);
3035
3216
  }
3036
3217
  options_default.onError(error);
@@ -3038,41 +3219,51 @@ function onBindingError(spec) {
3038
3219
 
3039
3220
  // ../bind/dist/arrayToDomNodeChildren.js
3040
3221
  function mapNodeAndRefreshWhenChanged(containerNode, mapping, valueToMap, callbackAfterAddingNodes, index) {
3041
- var mappedNodes = [];
3042
- var dependentObservable = computed(function() {
3043
- var newMappedNodes = mapping(valueToMap, index, fixUpContinuousNodeArray(mappedNodes, containerNode)) || [];
3044
- if (mappedNodes.length > 0) {
3045
- replaceDomNodes(mappedNodes, newMappedNodes);
3046
- if (callbackAfterAddingNodes) {
3047
- dependencyDetection_exports.ignore(callbackAfterAddingNodes, null, [valueToMap, newMappedNodes, index]);
3048
- }
3049
- }
3050
- mappedNodes.length = 0;
3051
- arrayPushAll(mappedNodes, newMappedNodes);
3052
- }, null, { disposeWhenNodeIsRemoved: containerNode, disposeWhen: function() {
3053
- return !anyDomNodeIsAttachedToDocument(mappedNodes);
3054
- } });
3055
- return { mappedNodes, dependentObservable: dependentObservable.isActive() ? dependentObservable : void 0 };
3222
+ const mappedNodes = [];
3223
+ const dependentObservable = computed(
3224
+ function() {
3225
+ const newMappedNodes = mapping(valueToMap, index, fixUpContinuousNodeArray(mappedNodes, containerNode)) || [];
3226
+ if (mappedNodes.length > 0) {
3227
+ replaceDomNodes(mappedNodes, newMappedNodes);
3228
+ if (callbackAfterAddingNodes) {
3229
+ dependencyDetection_exports.ignore(callbackAfterAddingNodes, null, [valueToMap, newMappedNodes, index]);
3230
+ }
3231
+ }
3232
+ mappedNodes.length = 0;
3233
+ arrayPushAll(mappedNodes, newMappedNodes);
3234
+ },
3235
+ null,
3236
+ {
3237
+ disposeWhenNodeIsRemoved: containerNode,
3238
+ disposeWhen: function() {
3239
+ return !anyDomNodeIsAttachedToDocument(mappedNodes);
3240
+ }
3241
+ }
3242
+ );
3243
+ return {
3244
+ mappedNodes,
3245
+ dependentObservable: dependentObservable.isActive() ? dependentObservable : void 0
3246
+ };
3056
3247
  }
3057
3248
  var lastMappingResultDomDataKey = data_exports.nextKey();
3058
3249
  var deletedItemDummyValue = data_exports.nextKey();
3059
- function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options3, callbackAfterAddingNodes, editScript) {
3250
+ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options2, callbackAfterAddingNodes, editScript) {
3060
3251
  array = array || [];
3061
3252
  if (typeof array.length === "undefined") {
3062
3253
  array = [array];
3063
3254
  }
3064
- options3 = options3 || {};
3065
- let lastMappingResult = data_exports.get(domNode, lastMappingResultDomDataKey);
3066
- let isFirstExecution = !lastMappingResult;
3067
- var newMappingResult = [];
3068
- var lastMappingResultIndex = 0;
3069
- var newMappingResultIndex = 0;
3070
- var nodesToDelete = [];
3071
- var itemsToProcess = [];
3072
- var itemsForBeforeRemoveCallbacks = [];
3073
- var itemsForMoveCallbacks = [];
3074
- var itemsForAfterAddCallbacks = [];
3075
- var mapData;
3255
+ options2 = options2 || {};
3256
+ const lastMappingResult = data_exports.get(domNode, lastMappingResultDomDataKey);
3257
+ const isFirstExecution = !lastMappingResult;
3258
+ const newMappingResult = new Array();
3259
+ let lastMappingResultIndex = 0;
3260
+ let newMappingResultIndex = 0;
3261
+ const nodesToDelete = [];
3262
+ const itemsToProcess = [];
3263
+ const itemsForBeforeRemoveCallbacks = [];
3264
+ const itemsForMoveCallbacks = [];
3265
+ const itemsForAfterAddCallbacks = [];
3266
+ let mapData;
3076
3267
  let countWaitingForRemove = 0;
3077
3268
  function itemAdded(value) {
3078
3269
  mapData = { arrayEntry: value, indexObservable: observable(newMappingResultIndex++) };
@@ -3094,9 +3285,9 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options3, c
3094
3285
  }
3095
3286
  function callCallback(callback, items) {
3096
3287
  if (callback) {
3097
- for (var i2 = 0, n = items.length; i2 < n; i2++) {
3098
- arrayForEach(items[i2].mappedNodes, function(node2) {
3099
- callback(node2, i2, items[i2].arrayEntry);
3288
+ for (let i = 0, n = items.length; i < n; i++) {
3289
+ arrayForEach(items[i].mappedNodes, function(node) {
3290
+ callback(node, i, items[i].arrayEntry);
3100
3291
  });
3101
3292
  }
3102
3293
  }
@@ -3105,16 +3296,13 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options3, c
3105
3296
  arrayForEach(array, itemAdded);
3106
3297
  } else {
3107
3298
  if (!editScript || lastMappingResult && lastMappingResult["_countWaitingForRemove"]) {
3108
- var lastArray = isFirstExecution ? [] : arrayMap(lastMappingResult, function(x) {
3299
+ const lastArray = arrayMap(lastMappingResult, function(x) {
3109
3300
  return x.arrayEntry;
3110
3301
  });
3111
- var compareOptions = {
3112
- "dontLimitMoves": options3["dontLimitMoves"],
3113
- "sparse": true
3114
- };
3302
+ const compareOptions = { dontLimitMoves: options2.dontLimitMoves, sparse: true };
3115
3303
  editScript = compareArrays(lastArray, array, compareOptions);
3116
3304
  }
3117
- for (var i = 0, editScriptItem, movedIndex, itemIndex; editScriptItem = editScript[i]; i++) {
3305
+ for (let i = 0, editScriptItem, movedIndex, itemIndex; editScriptItem = editScript[i]; i++) {
3118
3306
  movedIndex = editScriptItem["moved"];
3119
3307
  itemIndex = editScriptItem["index"];
3120
3308
  switch (editScriptItem["status"]) {
@@ -3129,7 +3317,7 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options3, c
3129
3317
  mapData.dependentObservable = void 0;
3130
3318
  }
3131
3319
  if (fixUpContinuousNodeArray(mapData.mappedNodes, domNode).length) {
3132
- if (options3["beforeRemove"]) {
3320
+ if (options2.beforeRemove) {
3133
3321
  newMappingResult.push(mapData);
3134
3322
  itemsToProcess.push(mapData);
3135
3323
  countWaitingForRemove++;
@@ -3139,7 +3327,7 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options3, c
3139
3327
  itemsForBeforeRemoveCallbacks.push(mapData);
3140
3328
  }
3141
3329
  }
3142
- if (mapData) {
3330
+ if (mapData == null ? void 0 : mapData.mappedNodes) {
3143
3331
  nodesToDelete.push.apply(nodesToDelete, mapData.mappedNodes);
3144
3332
  }
3145
3333
  }
@@ -3164,14 +3352,22 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options3, c
3164
3352
  newMappingResult["_countWaitingForRemove"] = countWaitingForRemove;
3165
3353
  }
3166
3354
  data_exports.set(domNode, lastMappingResultDomDataKey, newMappingResult);
3167
- callCallback(options3["beforeMove"], itemsForMoveCallbacks);
3168
- arrayForEach(nodesToDelete, options3["beforeRemove"] ? cleanNode : removeNode);
3169
- i = 0;
3170
- for (var nextNode = virtualElements_exports.firstChild(domNode), lastNode, node; mapData = itemsToProcess[i]; i++) {
3355
+ callCallback(options2.beforeMove, itemsForMoveCallbacks);
3356
+ arrayForEach(nodesToDelete, options2.beforeRemove ? cleanNode : removeNode);
3357
+ for (let k = 0, nextNode = virtualElements_exports.firstChild(domNode), lastNode, node; mapData = itemsToProcess[k]; k++) {
3171
3358
  if (!mapData.mappedNodes) {
3172
- extend(mapData, mapNodeAndRefreshWhenChanged(domNode, mapping, mapData.arrayEntry, callbackAfterAddingNodes, mapData.indexObservable));
3173
- }
3174
- for (var j = 0; node = mapData.mappedNodes[j]; nextNode = node.nextSibling, lastNode = node, j++) {
3359
+ extend(
3360
+ mapData,
3361
+ mapNodeAndRefreshWhenChanged(
3362
+ domNode,
3363
+ mapping,
3364
+ mapData.arrayEntry,
3365
+ callbackAfterAddingNodes,
3366
+ mapData.indexObservable
3367
+ )
3368
+ );
3369
+ }
3370
+ for (let j = 0; node = mapData.mappedNodes[j]; nextNode = node.nextSibling, lastNode = node, j++) {
3175
3371
  if (node !== nextNode) {
3176
3372
  virtualElements_exports.insertAfter(domNode, node, lastNode);
3177
3373
  }
@@ -3181,12 +3377,12 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options3, c
3181
3377
  mapData.initialized = true;
3182
3378
  }
3183
3379
  }
3184
- callCallback(options3["beforeRemove"], itemsForBeforeRemoveCallbacks);
3185
- for (i = 0; i < itemsForBeforeRemoveCallbacks.length; ++i) {
3186
- itemsForBeforeRemoveCallbacks[i].arrayEntry = deletedItemDummyValue;
3380
+ callCallback(options2.beforeRemove, itemsForBeforeRemoveCallbacks);
3381
+ for (let x = 0; x < itemsForBeforeRemoveCallbacks.length; ++x) {
3382
+ itemsForBeforeRemoveCallbacks[x].arrayEntry = deletedItemDummyValue;
3187
3383
  }
3188
- callCallback(options3["afterMove"], itemsForMoveCallbacks);
3189
- callCallback(options3["afterAdd"], itemsForAfterAddCallbacks);
3384
+ callCallback(options2.afterMove, itemsForMoveCallbacks);
3385
+ callCallback(options2.afterAdd, itemsForAfterAddCallbacks);
3190
3386
  }
3191
3387
 
3192
3388
  // src/templating.ts
@@ -3201,7 +3397,7 @@ function setTemplateEngine(tEngine) {
3201
3397
  function invokeForEachNodeInContinuousRange(firstNode, lastNode, action) {
3202
3398
  let node;
3203
3399
  let nextInQueue = firstNode;
3204
- let firstOutOfRangeNode = virtualElements_exports.nextSibling(lastNode);
3400
+ const firstOutOfRangeNode = virtualElements_exports.nextSibling(lastNode);
3205
3401
  while (nextInQueue && (node = nextInQueue) !== firstOutOfRangeNode) {
3206
3402
  nextInQueue = virtualElements_exports.nextSibling(node);
3207
3403
  action(node, nextInQueue);
@@ -3209,15 +3405,15 @@ function invokeForEachNodeInContinuousRange(firstNode, lastNode, action) {
3209
3405
  }
3210
3406
  function activateBindingsOnContinuousNodeArray(continuousNodeArray, bindingContext2, afterBindingCallback) {
3211
3407
  if (continuousNodeArray.length) {
3212
- var firstNode = continuousNodeArray[0];
3213
- var lastNode = continuousNodeArray[continuousNodeArray.length - 1];
3214
- var parentNode = firstNode.parentNode;
3215
- var provider = options_default.bindingProviderInstance;
3216
- var preprocessNode = provider.preprocessNode;
3408
+ let firstNode = continuousNodeArray[0];
3409
+ let lastNode = continuousNodeArray[continuousNodeArray.length - 1];
3410
+ const parentNode = firstNode.parentNode;
3411
+ const provider = options_default.bindingProviderInstance;
3412
+ const preprocessNode = provider.preprocessNode;
3217
3413
  if (preprocessNode) {
3218
3414
  invokeForEachNodeInContinuousRange(firstNode, lastNode, function(node, nextNodeInRange) {
3219
- var nodePreviousSibling = node.previousSibling;
3220
- var newNodes = preprocessNode.call(provider, node);
3415
+ const nodePreviousSibling = node.previousSibling;
3416
+ const newNodes = preprocessNode.call(provider, node);
3221
3417
  if (newNodes) {
3222
3418
  if (node === firstNode) {
3223
3419
  firstNode = newNodes[0] || nextNodeInRange;
@@ -3239,12 +3435,12 @@ function activateBindingsOnContinuousNodeArray(continuousNodeArray, bindingConte
3239
3435
  }
3240
3436
  }
3241
3437
  invokeForEachNodeInContinuousRange(firstNode, lastNode, function(node) {
3242
- if (node.nodeType === 1 || node.nodeType === 8) {
3438
+ if (node.nodeType === Node.ELEMENT_NODE || node.nodeType === Node.COMMENT_NODE) {
3243
3439
  applyBindings(bindingContext2, node).then(afterBindingCallback);
3244
3440
  }
3245
3441
  });
3246
3442
  invokeForEachNodeInContinuousRange(firstNode, lastNode, function(node) {
3247
- if (node.nodeType === 1 || node.nodeType === 8) {
3443
+ if (node.nodeType === Node.ELEMENT_NODE || node.nodeType === Node.COMMENT_NODE) {
3248
3444
  memoization_exports.unmemoizeDomNodeAndDescendants(node, [bindingContext2]);
3249
3445
  }
3250
3446
  });
@@ -3254,16 +3450,16 @@ function activateBindingsOnContinuousNodeArray(continuousNodeArray, bindingConte
3254
3450
  function getFirstNodeFromPossibleArray(nodeOrNodeArray) {
3255
3451
  return nodeOrNodeArray.nodeType ? nodeOrNodeArray : nodeOrNodeArray.length > 0 ? nodeOrNodeArray[0] : null;
3256
3452
  }
3257
- function executeTemplate(targetNodeOrNodeArray, renderMode, template, bindingContext2, options3, afterBindingCallback) {
3258
- options3 = options3 || {};
3259
- var firstTargetNode = targetNodeOrNodeArray && getFirstNodeFromPossibleArray(targetNodeOrNodeArray);
3260
- var templateDocument = (firstTargetNode || template || {}).ownerDocument;
3261
- var templateEngineToUse = options3.templateEngine || _templateEngine;
3262
- var renderedNodesArray = templateEngineToUse.renderTemplate(template, bindingContext2, options3, templateDocument);
3453
+ function executeTemplate(targetNodeOrNodeArray, renderMode, template, bindingContext2, options2, afterBindingCallback) {
3454
+ options2 = options2 || {};
3455
+ const firstTargetNode = targetNodeOrNodeArray && getFirstNodeFromPossibleArray(targetNodeOrNodeArray);
3456
+ const templateDocument = (firstTargetNode || template || {}).ownerDocument;
3457
+ const templateEngineToUse = options2.templateEngine || _templateEngine;
3458
+ const renderedNodesArray = templateEngineToUse.renderTemplate(template, bindingContext2, options2, templateDocument);
3263
3459
  if (typeof renderedNodesArray.length !== "number" || renderedNodesArray.length > 0 && typeof renderedNodesArray[0].nodeType !== "number") {
3264
3460
  throw new Error("Template engine must return an array of DOM nodes");
3265
3461
  }
3266
- var haveAddedNodesToParent = false;
3462
+ let haveAddedNodesToParent = false;
3267
3463
  switch (renderMode) {
3268
3464
  case "replaceChildren":
3269
3465
  virtualElements_exports.setDomNodeChildren(targetNodeOrNodeArray, renderedNodesArray);
@@ -3280,8 +3476,8 @@ function executeTemplate(targetNodeOrNodeArray, renderMode, template, bindingCon
3280
3476
  }
3281
3477
  if (haveAddedNodesToParent) {
3282
3478
  activateBindingsOnContinuousNodeArray(renderedNodesArray, bindingContext2, afterBindingCallback);
3283
- if (options3.afterRender) {
3284
- dependencyDetection_exports.ignore(options3.afterRender, null, [renderedNodesArray, bindingContext2["$data"]]);
3479
+ if (options2.afterRender) {
3480
+ dependencyDetection_exports.ignore(options2.afterRender, null, [renderedNodesArray, bindingContext2["$data"]]);
3285
3481
  }
3286
3482
  if (renderMode === "replaceChildren") {
3287
3483
  bindingEvent.notify(targetNodeOrNodeArray, bindingEvent.childrenComplete);
@@ -3298,88 +3494,121 @@ function resolveTemplateName(template, data, context) {
3298
3494
  return template;
3299
3495
  }
3300
3496
  }
3301
- function renderTemplate(template, dataOrBindingContext, options3, targetNodeOrNodeArray, renderMode, afterBindingCallback) {
3302
- options3 = options3 || {};
3303
- if ((options3.templateEngine || _templateEngine) === void 0) {
3497
+ function renderTemplate(template, dataOrBindingContext, options2, targetNodeOrNodeArray, renderMode, afterBindingCallback) {
3498
+ options2 = options2 || {};
3499
+ if ((options2.templateEngine || _templateEngine) === void 0) {
3304
3500
  throw new Error("Set a template engine before calling renderTemplate");
3305
3501
  }
3306
3502
  renderMode = renderMode || "replaceChildren";
3307
3503
  if (targetNodeOrNodeArray) {
3308
- var firstTargetNode = getFirstNodeFromPossibleArray(targetNodeOrNodeArray);
3309
- var whenToDispose = function() {
3504
+ let firstTargetNode = getFirstNodeFromPossibleArray(targetNodeOrNodeArray);
3505
+ const whenToDispose = function() {
3310
3506
  return !firstTargetNode || !domNodeIsAttachedToDocument(firstTargetNode);
3311
3507
  };
3312
- var activelyDisposeWhenNodeIsRemoved = firstTargetNode && renderMode === "replaceNode" ? firstTargetNode.parentNode : firstTargetNode;
3313
- return computed(function() {
3314
- var bindingContext2 = dataOrBindingContext && dataOrBindingContext instanceof bindingContext ? dataOrBindingContext : new bindingContext(dataOrBindingContext, null, null, null, { "exportDependencies": true });
3315
- var templateName = resolveTemplateName(template, bindingContext2.$data, bindingContext2);
3316
- const renderedNodesArray = executeTemplate(targetNodeOrNodeArray, renderMode, templateName, bindingContext2, options3, afterBindingCallback);
3317
- if (renderMode === "replaceNode") {
3318
- targetNodeOrNodeArray = renderedNodesArray;
3319
- firstTargetNode = getFirstNodeFromPossibleArray(targetNodeOrNodeArray);
3320
- }
3321
- }, null, { disposeWhen: whenToDispose, disposeWhenNodeIsRemoved: activelyDisposeWhenNodeIsRemoved });
3508
+ const activelyDisposeWhenNodeIsRemoved = firstTargetNode && renderMode === "replaceNode" ? firstTargetNode.parentNode : firstTargetNode;
3509
+ return computed(
3510
+ // So the DOM is automatically updated when any dependency changes
3511
+ function() {
3512
+ const bindingContext2 = dataOrBindingContext && dataOrBindingContext instanceof bindingContext ? dataOrBindingContext : new bindingContext(dataOrBindingContext, void 0, void 0, void 0, {
3513
+ exportDependencies: true
3514
+ });
3515
+ const templateName = resolveTemplateName(template, bindingContext2.$data, bindingContext2);
3516
+ const renderedNodesArray = executeTemplate(
3517
+ targetNodeOrNodeArray,
3518
+ renderMode,
3519
+ templateName,
3520
+ bindingContext2,
3521
+ options2,
3522
+ afterBindingCallback
3523
+ );
3524
+ if (renderMode === "replaceNode") {
3525
+ targetNodeOrNodeArray = renderedNodesArray;
3526
+ firstTargetNode = getFirstNodeFromPossibleArray(targetNodeOrNodeArray);
3527
+ }
3528
+ },
3529
+ null,
3530
+ { disposeWhen: whenToDispose, disposeWhenNodeIsRemoved: activelyDisposeWhenNodeIsRemoved }
3531
+ );
3322
3532
  } else {
3323
3533
  return memoization_exports.memoize(function(domNode) {
3324
- renderTemplate(template, dataOrBindingContext, options3, domNode, "replaceNode");
3534
+ renderTemplate(template, dataOrBindingContext, options2, domNode, "replaceNode");
3325
3535
  });
3326
3536
  }
3327
3537
  }
3328
- function renderTemplateForEach(template, arrayOrObservableArray, options3, targetNode, parentBindingContext, afterBindingCallback) {
3329
- var arrayItemContext;
3538
+ function renderTemplateForEach(template, arrayOrObservableArray, options2, targetNode, parentBindingContext, afterBindingCallback) {
3539
+ let arrayItemContext;
3330
3540
  function executeTemplateForArrayItem(arrayValue, index) {
3331
- if (options3.as) {
3541
+ if (options2.as) {
3332
3542
  if (options_default.createChildContextWithAs) {
3333
- arrayItemContext = parentBindingContext.createChildContext(arrayValue, options3.as, (context) => {
3543
+ arrayItemContext = parentBindingContext.createChildContext(arrayValue, options2.as, (context) => {
3334
3544
  context.$index = index;
3335
3545
  });
3336
3546
  } else {
3337
- arrayItemContext = parentBindingContext.extend({
3338
- [options3.as]: arrayValue,
3339
- $index: index
3340
- });
3547
+ arrayItemContext = parentBindingContext.extend({ [options2.as]: arrayValue, $index: index });
3341
3548
  }
3342
3549
  } else {
3343
- arrayItemContext = parentBindingContext.createChildContext(arrayValue, options3.as, (context) => {
3550
+ arrayItemContext = parentBindingContext.createChildContext(arrayValue, options2.as, (context) => {
3344
3551
  context.$index = index;
3345
3552
  });
3346
3553
  }
3347
- var templateName = resolveTemplateName(template, arrayValue, arrayItemContext);
3348
- return executeTemplate(targetNode, "ignoreTargetNode", templateName, arrayItemContext, options3, afterBindingCallback);
3349
- }
3350
- var activateBindingsCallback = function(arrayValue, addedNodesArray) {
3554
+ const templateName = resolveTemplateName(template, arrayValue, arrayItemContext);
3555
+ return executeTemplate(
3556
+ targetNode,
3557
+ "ignoreTargetNode",
3558
+ templateName,
3559
+ arrayItemContext,
3560
+ options2,
3561
+ afterBindingCallback
3562
+ );
3563
+ }
3564
+ const activateBindingsCallback = function(arrayValue, addedNodesArray) {
3351
3565
  activateBindingsOnContinuousNodeArray(addedNodesArray, arrayItemContext, afterBindingCallback);
3352
- if (options3.afterRender) {
3353
- options3.afterRender(addedNodesArray, arrayValue);
3566
+ if (options2.afterRender) {
3567
+ options2.afterRender(addedNodesArray, arrayValue);
3354
3568
  }
3355
3569
  arrayItemContext = null;
3356
3570
  };
3357
3571
  function localSetDomNodeChildrenFromArrayMapping(newArray, changeList) {
3358
- dependencyDetection_exports.ignore(setDomNodeChildrenFromArrayMapping, null, [targetNode, newArray, executeTemplateForArrayItem, options3, activateBindingsCallback, changeList]);
3572
+ dependencyDetection_exports.ignore(setDomNodeChildrenFromArrayMapping, null, [
3573
+ targetNode,
3574
+ newArray,
3575
+ executeTemplateForArrayItem,
3576
+ options2,
3577
+ activateBindingsCallback,
3578
+ changeList
3579
+ ]);
3359
3580
  bindingEvent.notify(targetNode, bindingEvent.childrenComplete);
3360
3581
  }
3361
- const shouldHideDestroyed = options3.includeDestroyed === false || options_default.foreachHidesDestroyed && !options3.includeDestroyed;
3362
- if (!shouldHideDestroyed && !options3.beforeRemove && isObservableArray(arrayOrObservableArray)) {
3582
+ const shouldHideDestroyed = options2.includeDestroyed === false || options_default.foreachHidesDestroyed && !options2.includeDestroyed;
3583
+ if (!shouldHideDestroyed && !options2.beforeRemove && isObservableArray(arrayOrObservableArray)) {
3363
3584
  localSetDomNodeChildrenFromArrayMapping(arrayOrObservableArray.peek());
3364
- var subscription = arrayOrObservableArray.subscribe(function(changeList) {
3365
- localSetDomNodeChildrenFromArrayMapping(arrayOrObservableArray(), changeList);
3366
- }, null, "arrayChange");
3585
+ const subscription = arrayOrObservableArray.subscribe(
3586
+ function(changeList) {
3587
+ localSetDomNodeChildrenFromArrayMapping(arrayOrObservableArray(), changeList);
3588
+ },
3589
+ null,
3590
+ "arrayChange"
3591
+ );
3367
3592
  subscription.disposeWhenNodeIsRemoved(targetNode);
3368
3593
  return subscription;
3369
3594
  } else {
3370
- return computed(function() {
3371
- var unwrappedArray = unwrap(arrayOrObservableArray) || [];
3372
- const unwrappedIsIterable = Symbol.iterator in unwrappedArray;
3373
- if (!unwrappedIsIterable) {
3374
- unwrappedArray = [unwrappedArray];
3375
- }
3376
- if (shouldHideDestroyed) {
3377
- unwrappedArray = arrayFilter(unwrappedArray, function(item) {
3378
- return item === void 0 || item === null || !unwrap(item._destroy);
3379
- });
3380
- }
3381
- localSetDomNodeChildrenFromArrayMapping(unwrappedArray);
3382
- }, null, { disposeWhenNodeIsRemoved: targetNode });
3595
+ return computed(
3596
+ function() {
3597
+ let unwrappedArray = unwrap(arrayOrObservableArray) || [];
3598
+ const unwrappedIsIterable = Symbol.iterator in unwrappedArray;
3599
+ if (!unwrappedIsIterable) {
3600
+ unwrappedArray = [unwrappedArray];
3601
+ }
3602
+ if (shouldHideDestroyed) {
3603
+ unwrappedArray = arrayFilter(unwrappedArray, function(item) {
3604
+ return item === void 0 || item === null || !unwrap(item._destroy);
3605
+ });
3606
+ }
3607
+ localSetDomNodeChildrenFromArrayMapping(unwrappedArray);
3608
+ },
3609
+ null,
3610
+ { disposeWhenNodeIsRemoved: targetNode }
3611
+ );
3383
3612
  }
3384
3613
  }
3385
3614
  var templateComputedDomDataKey = data_exports.nextKey();
@@ -3388,9 +3617,7 @@ var TemplateBindingHandler = class extends AsyncBindingHandler {
3388
3617
  super(params);
3389
3618
  const element = this.$element;
3390
3619
  const bindingValue = unwrap(this.value);
3391
- data_exports.set(element, "conditional", {
3392
- elseChainSatisfied: observable(true)
3393
- });
3620
+ data_exports.set(element, "conditional", { elseChainSatisfied: observable(true) });
3394
3621
  if (typeof bindingValue === "string" || bindingValue.name) {
3395
3622
  this.bindNamedTemplate();
3396
3623
  } else if ("nodes" in bindingValue) {
@@ -3402,6 +3629,10 @@ var TemplateBindingHandler = class extends AsyncBindingHandler {
3402
3629
  bindNamedTemplate() {
3403
3630
  virtualElements_exports.emptyNode(this.$element);
3404
3631
  }
3632
+ // We've been given an array of DOM nodes. Save them as the template source.
3633
+ // There is no known use case for the node array being an observable array (if the output
3634
+ // varies, put that behavior *into* your template - that's what templates are for), and
3635
+ // the implementation would be a mess, so assert that it's not observable.
3405
3636
  bindNodeTemplate(nodes) {
3406
3637
  if (isObservable(nodes)) {
3407
3638
  throw new Error('The "nodes" option must be a plain, non-observable array.');
@@ -3424,31 +3655,45 @@ var TemplateBindingHandler = class extends AsyncBindingHandler {
3424
3655
  onValueChange() {
3425
3656
  const element = this.$element;
3426
3657
  const bindingContext2 = this.$context;
3427
- var value = this.value;
3428
- var options3 = unwrap(value);
3429
- var shouldDisplay = true;
3430
- var templateComputed = null;
3431
- var elseChainSatisfied = data_exports.get(element, "conditional").elseChainSatisfied;
3432
- var templateName;
3433
- if (typeof options3 === "string") {
3658
+ const value = this.value;
3659
+ let options2 = unwrap(value);
3660
+ let shouldDisplay = true;
3661
+ let templateComputed = null;
3662
+ const elseChainSatisfied = data_exports.get(element, "conditional").elseChainSatisfied;
3663
+ let templateName;
3664
+ if (typeof options2 === "string") {
3434
3665
  templateName = value;
3435
- options3 = {};
3666
+ options2 = {};
3436
3667
  } else {
3437
- templateName = options3.name;
3438
- if ("if" in options3) {
3439
- shouldDisplay = unwrap(options3.if);
3440
- }
3441
- if (shouldDisplay && "ifnot" in options3) {
3442
- shouldDisplay = !unwrap(options3.ifnot);
3443
- }
3444
- }
3445
- if ("foreach" in options3) {
3446
- var dataArray = shouldDisplay && options3.foreach || [];
3447
- templateComputed = renderTemplateForEach(templateName || element, dataArray, options3, element, bindingContext2, this.completeBinding);
3668
+ templateName = options2.name;
3669
+ if ("if" in options2) {
3670
+ shouldDisplay = unwrap(options2.if);
3671
+ }
3672
+ if (shouldDisplay && "ifnot" in options2) {
3673
+ shouldDisplay = !unwrap(options2.ifnot);
3674
+ }
3675
+ }
3676
+ if ("foreach" in options2) {
3677
+ const dataArray = shouldDisplay && options2.foreach || [];
3678
+ templateComputed = renderTemplateForEach(
3679
+ templateName || element,
3680
+ dataArray,
3681
+ options2,
3682
+ element,
3683
+ bindingContext2,
3684
+ this.completeBinding
3685
+ );
3448
3686
  elseChainSatisfied((unwrap(dataArray) || []).length !== 0);
3449
3687
  } else if (shouldDisplay) {
3450
- var innerBindingContext = "data" in options3 ? bindingContext2.createStaticChildContext(options3.data, options3.as) : bindingContext2;
3451
- templateComputed = renderTemplate(templateName || element, innerBindingContext, options3, element, void 0, this.completeBinding);
3688
+ const innerBindingContext = "data" in options2 ? bindingContext2.createStaticChildContext(options2.data, options2.as) : bindingContext2;
3689
+ templateComputed = renderTemplate(
3690
+ templateName || element,
3691
+ innerBindingContext,
3692
+ options2,
3693
+ element,
3694
+ void 0,
3695
+ this.completeBinding
3696
+ );
3452
3697
  elseChainSatisfied(true);
3453
3698
  } else {
3454
3699
  virtualElements_exports.emptyNode(element);
@@ -3457,11 +3702,15 @@ var TemplateBindingHandler = class extends AsyncBindingHandler {
3457
3702
  this.disposeOldComputedAndStoreNewOne(element, templateComputed);
3458
3703
  }
3459
3704
  disposeOldComputedAndStoreNewOne(element, newComputed) {
3460
- let oldComputed = data_exports.get(element, templateComputedDomDataKey);
3705
+ const oldComputed = data_exports.get(element, templateComputedDomDataKey);
3461
3706
  if (oldComputed && typeof oldComputed.dispose === "function") {
3462
3707
  oldComputed.dispose();
3463
3708
  }
3464
- data_exports.set(element, templateComputedDomDataKey, newComputed && (!newComputed.isActive || newComputed.isActive()) ? newComputed : void 0);
3709
+ data_exports.set(
3710
+ element,
3711
+ templateComputedDomDataKey,
3712
+ newComputed && (!newComputed.isActive || newComputed.isActive()) ? newComputed : void 0
3713
+ );
3465
3714
  }
3466
3715
  get controlsDescendants() {
3467
3716
  return true;
@@ -3476,12 +3725,12 @@ function nativeTemplateEngine() {
3476
3725
  }
3477
3726
  nativeTemplateEngine.prototype = new templateEngine();
3478
3727
  nativeTemplateEngine.prototype.constructor = nativeTemplateEngine;
3479
- nativeTemplateEngine.prototype.renderTemplateSource = function(templateSource, bindingContext2, options3, templateDocument) {
3480
- var useNodesIfAvailable = !(ieVersion < 9), templateNodesFunc = useNodesIfAvailable ? templateSource.nodes : null, templateNodes = templateNodesFunc ? templateSource.nodes() : null;
3728
+ nativeTemplateEngine.prototype.renderTemplateSource = function(templateSource, bindingContext2, options2, templateDocument) {
3729
+ const templateNodes = templateSource.nodes ? templateSource.nodes() : null;
3481
3730
  if (templateNodes) {
3482
3731
  return makeArray(templateNodes.cloneNode(true).childNodes);
3483
3732
  } else {
3484
- var templateText = templateSource.text();
3733
+ const templateText = templateSource.text();
3485
3734
  return parseHtmlFragment(templateText, templateDocument);
3486
3735
  }
3487
3736
  };
@@ -3512,7 +3761,4 @@ var TemplateForEachBindingHandler = class extends TemplateBindingHandler {
3512
3761
  };
3513
3762
 
3514
3763
  // src/index.ts
3515
- var bindings = {
3516
- foreach: TemplateForEachBindingHandler,
3517
- template: TemplateBindingHandler
3518
- };
3764
+ var bindings = { foreach: TemplateForEachBindingHandler, template: TemplateBindingHandler };