@tko/bind 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/bind 🥊 4.0.0-beta1.0 CommonJS
1
+ // @tko/bind 🥊 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 });
@@ -36,10 +41,42 @@ var __async = (__this, __arguments, generator) => {
36
41
  step((generator = generator.apply(__this, __arguments)).next());
37
42
  });
38
43
  };
44
+ var __await = function(promise, isYieldStar) {
45
+ this[0] = promise;
46
+ this[1] = isYieldStar;
47
+ };
48
+ var __yieldStar = (value) => {
49
+ var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {};
50
+ if (obj == null) {
51
+ obj = value[__knownSymbol("iterator")]();
52
+ method = (k) => it[k] = (x) => obj[k](x);
53
+ } else {
54
+ obj = obj.call(value);
55
+ method = (k) => it[k] = (v) => {
56
+ if (isAwait) {
57
+ isAwait = false;
58
+ if (k === "throw") throw v;
59
+ return v;
60
+ }
61
+ isAwait = true;
62
+ return {
63
+ done: false,
64
+ value: new __await(new Promise((resolve) => {
65
+ var x = obj[k](v);
66
+ if (!(x instanceof Object)) __typeError("Object expected");
67
+ resolve(x);
68
+ }), 1)
69
+ };
70
+ };
71
+ }
72
+ return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => {
73
+ throw x;
74
+ }, "return" in obj && method("return"), it;
75
+ };
39
76
 
40
77
  // index.ts
41
- var bind_exports = {};
42
- __export(bind_exports, {
78
+ var index_exports = {};
79
+ __export(index_exports, {
43
80
  AsyncBindingHandler: () => AsyncBindingHandler,
44
81
  BindingHandler: () => BindingHandler,
45
82
  DescendantBindingHandler: () => DescendantBindingHandler,
@@ -57,13 +94,13 @@ __export(bind_exports, {
57
94
  setDomNodeChildrenFromArrayMapping: () => setDomNodeChildrenFromArrayMapping,
58
95
  storedBindingContextForNode: () => storedBindingContextForNode
59
96
  });
60
- module.exports = __toCommonJS(bind_exports);
97
+ module.exports = __toCommonJS(index_exports);
61
98
 
62
99
  // ../utils/dist/array.js
63
100
  var { isArray } = Array;
64
- function arrayForEach(array, action, thisArg) {
101
+ function arrayForEach(array, action, actionOwner) {
65
102
  if (arguments.length > 2) {
66
- action = action.bind(thisArg);
103
+ action = action.bind(actionOwner);
67
104
  }
68
105
  for (let i = 0, j = array.length; i < j; ++i) {
69
106
  action(array[i], i, array);
@@ -75,14 +112,14 @@ function arrayIndexOf(array, item) {
75
112
  function arrayFirst(array, predicate, predicateOwner) {
76
113
  return (isArray(array) ? array : [...array]).find(predicate, predicateOwner);
77
114
  }
78
- function arrayMap(array = [], mapping, thisArg) {
115
+ function arrayMap(array, mapping, thisArg) {
79
116
  if (arguments.length > 2) {
80
117
  mapping = mapping.bind(thisArg);
81
118
  }
82
119
  return array === null ? [] : Array.from(array, mapping);
83
120
  }
84
121
  function arrayRemoveItem(array, itemToRemove) {
85
- var index = arrayIndexOf(array, itemToRemove);
122
+ const index = arrayIndexOf(array, itemToRemove);
86
123
  if (index > 0) {
87
124
  array.splice(index, 1);
88
125
  } else if (index === 0) {
@@ -93,7 +130,7 @@ function arrayPushAll(array, valuesToPush) {
93
130
  if (isArray(valuesToPush)) {
94
131
  array.push.apply(array, valuesToPush);
95
132
  } else {
96
- for (var i = 0, j = valuesToPush.length; i < j; i++) {
133
+ for (let i = 0, j = valuesToPush.length; i < j; i++) {
97
134
  array.push(valuesToPush[i]);
98
135
  }
99
136
  }
@@ -101,7 +138,7 @@ function arrayPushAll(array, valuesToPush) {
101
138
  }
102
139
  function findMovesInArrayComparison(left, right, limitFailedCompares) {
103
140
  if (left.length && right.length) {
104
- var failedCompares, l, r, leftItem, rightItem;
141
+ let failedCompares, l, r, leftItem, rightItem;
105
142
  for (failedCompares = l = 0; (!limitFailedCompares || failedCompares < limitFailedCompares) && (leftItem = left[l]); ++l) {
106
143
  for (r = 0; rightItem = right[r]; ++r) {
107
144
  if (leftItem.value === rightItem.value) {
@@ -129,10 +166,10 @@ function compareArrays(oldArray, newArray, options2) {
129
166
  }
130
167
  }
131
168
  function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusNotInBig, options2) {
132
- 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;
169
+ 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;
133
170
  for (smlIndex = 0; smlIndex <= smlIndexMax; smlIndex++) {
134
171
  lastRow = thisRow;
135
- editDistanceMatrix.push(thisRow = []);
172
+ editDistanceMatrix.push(thisRow = new Array());
136
173
  bigIndexMaxForRow = myMin(bigIndexMax, smlIndex + compareRange);
137
174
  bigIndexMinForRow = myMax(0, smlIndex - 1);
138
175
  for (bigIndex = bigIndexMinForRow; bigIndex <= bigIndexMaxForRow; bigIndex++) {
@@ -143,35 +180,38 @@ function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusN
143
180
  } else if (smlArray[smlIndex - 1] === bigArray[bigIndex - 1]) {
144
181
  thisRow[bigIndex] = lastRow[bigIndex - 1];
145
182
  } else {
146
- var northDistance = lastRow[bigIndex] || maxDistance;
147
- var westDistance = thisRow[bigIndex - 1] || maxDistance;
183
+ const northDistance = lastRow[bigIndex] || maxDistance;
184
+ const westDistance = thisRow[bigIndex - 1] || maxDistance;
148
185
  thisRow[bigIndex] = myMin(northDistance, westDistance) + 1;
149
186
  }
150
187
  }
151
188
  }
152
- var editScript = [], meMinusOne, notInSml = [], notInBig = [];
189
+ let editScript = new Array(), meMinusOne, notInSml = new Array(), notInBig = new Array();
153
190
  for (smlIndex = smlIndexMax, bigIndex = bigIndexMax; smlIndex || bigIndex; ) {
154
191
  meMinusOne = editDistanceMatrix[smlIndex][bigIndex] - 1;
155
192
  if (bigIndex && meMinusOne === editDistanceMatrix[smlIndex][bigIndex - 1]) {
156
- notInSml.push(editScript[editScript.length] = {
157
- "status": statusNotInSml,
158
- "value": bigArray[--bigIndex],
159
- "index": bigIndex
160
- });
193
+ notInSml.push(
194
+ editScript[editScript.length] = {
195
+ // added
196
+ status: statusNotInSml,
197
+ value: bigArray[--bigIndex],
198
+ index: bigIndex
199
+ }
200
+ );
161
201
  } else if (smlIndex && meMinusOne === editDistanceMatrix[smlIndex - 1][bigIndex]) {
162
- notInBig.push(editScript[editScript.length] = {
163
- "status": statusNotInBig,
164
- "value": smlArray[--smlIndex],
165
- "index": smlIndex
166
- });
202
+ notInBig.push(
203
+ editScript[editScript.length] = {
204
+ // deleted
205
+ status: statusNotInBig,
206
+ value: smlArray[--smlIndex],
207
+ index: smlIndex
208
+ }
209
+ );
167
210
  } else {
168
211
  --bigIndex;
169
212
  --smlIndex;
170
- if (!options2.sparse) {
171
- editScript.push({
172
- "status": "retained",
173
- "value": bigArray[bigIndex]
174
- });
213
+ if (!(options2 == null ? void 0 : options2.sparse)) {
214
+ editScript.push({ status: "retained", value: bigArray[bigIndex] });
175
215
  }
176
216
  }
177
217
  }
@@ -180,40 +220,79 @@ function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusN
180
220
  }
181
221
 
182
222
  // ../utils/dist/options.js
183
- var options = {
184
- deferUpdates: false,
185
- useOnlyNativeEvents: false,
186
- protoProperty: "__ko_proto__",
187
- defaultBindingAttribute: "data-bind",
188
- allowVirtualElements: true,
189
- bindingGlobals: /* @__PURE__ */ Object.create(null),
190
- bindingProviderInstance: null,
191
- createChildContextWithAs: false,
192
- jQuery: globalThis.jQuery,
193
- Promise: globalThis.Promise,
194
- taskScheduler: null,
195
- debug: false,
196
- global: globalThis,
197
- document: globalThis.document,
198
- filters: {},
199
- includeDestroyed: false,
200
- foreachHidesDestroyed: false,
201
- onError: function(e) {
202
- throw e;
203
- },
204
- set: function(name, value) {
205
- options[name] = value;
206
- },
207
- getBindingHandler() {
208
- },
209
- cleanExternalData() {
223
+ var Options = class {
224
+ constructor() {
225
+ this.bindingStringPreparsers = [];
226
+ this.knockoutInstance = null;
227
+ this.deferUpdates = false;
228
+ this.useOnlyNativeEvents = true;
229
+ this.useTemplateTag = true;
230
+ this.protoProperty = "__ko_proto__";
231
+ this.defaultBindingAttribute = "data-bind";
232
+ this.allowVirtualElements = true;
233
+ this.bindingGlobals = /* @__PURE__ */ Object.create(null);
234
+ this.createChildContextWithAs = false;
235
+ this.disableJQueryUsage = false;
236
+ this.Promise = globalThis.Promise;
237
+ this.taskScheduler = null;
238
+ this.debug = false;
239
+ this.templateSizeLimit = 4096;
240
+ this.allowScriptTagsInTemplates = false;
241
+ this._sanitizeWarningLogged = false;
242
+ this.global = globalThis;
243
+ this.document = globalThis.document;
244
+ this.filters = {};
245
+ this.includeDestroyed = false;
246
+ this.foreachHidesDestroyed = false;
247
+ }
248
+ get jQuery() {
249
+ var _a;
250
+ if (this.disableJQueryUsage) return;
251
+ return (_a = this._jQuery) != null ? _a : globalThis.jQuery;
252
+ }
253
+ /**
254
+ * Set jQuery manuall to be used by TKO.
255
+ * @param jQuery If jQuery set to undefined, TKO will not use jQuery and this.disableJQueryUsage to true.
256
+ */
257
+ set jQuery(jQuery) {
258
+ if (!jQuery) {
259
+ this.disableJQueryUsage = true;
260
+ this._jQuery = void 0;
261
+ } else {
262
+ this._jQuery = jQuery;
263
+ this.disableJQueryUsage = false;
264
+ }
265
+ }
266
+ /**
267
+ * Sanitize HTML templates before parsing them. Default is a no-op.
268
+ * Please configure something like DOMPurify or validator.js for your environment.
269
+ * @param html HTML string to be sanitized
270
+ * @returns Sanitized HTML string
271
+ */
272
+ sanitizeHtmlTemplate(html) {
273
+ if (!this._sanitizeWarningLogged) {
274
+ console.warn(
275
+ "WARNING -- You don't have a HTML sanitizer configured. Please configure options.sanitizeHtmlTemplate to avoid XSS vulnerabilities."
276
+ );
277
+ this._sanitizeWarningLogged = true;
278
+ }
279
+ return html;
280
+ }
281
+ onError(e, throws = true) {
282
+ if (throws) throw e;
283
+ return e;
284
+ }
285
+ set(name, value) {
286
+ this[name] = value;
287
+ }
288
+ // Overload getBindingHandler to have a custom lookup function.
289
+ getBindingHandler(key) {
290
+ return null;
210
291
  }
211
- };
212
- Object.defineProperty(options, "$", {
213
- get: function() {
214
- return options.jQuery;
292
+ cleanExternalData(node, callback) {
215
293
  }
216
- });
294
+ };
295
+ var options = new Options();
217
296
  var options_default = options;
218
297
 
219
298
  // ../utils/dist/error.js
@@ -240,7 +319,7 @@ function safeSetTimeout(handler, timeout) {
240
319
 
241
320
  // ../utils/dist/async.js
242
321
  function throttle(callback, timeout) {
243
- var timeoutInstance;
322
+ let timeoutInstance;
244
323
  return function(...args) {
245
324
  if (!timeoutInstance) {
246
325
  timeoutInstance = safeSetTimeout(function() {
@@ -251,25 +330,13 @@ function throttle(callback, timeout) {
251
330
  };
252
331
  }
253
332
  function debounce(callback, timeout) {
254
- var timeoutInstance;
333
+ let timeoutInstance;
255
334
  return function(...args) {
256
335
  clearTimeout(timeoutInstance);
257
336
  timeoutInstance = safeSetTimeout(() => callback(...args), timeout);
258
337
  };
259
338
  }
260
339
 
261
- // ../utils/dist/ie.js
262
- var ieVersion = options_default.document && function() {
263
- var version = 3, div = options_default.document.createElement("div"), iElems = div.getElementsByTagName("i");
264
- while (div.innerHTML = "<!--[if gt IE " + ++version + "]><i></i><![endif]-->", iElems[0]) {
265
- }
266
- if (!version) {
267
- const userAgent = window.navigator.userAgent;
268
- return ua.match(/MSIE ([^ ]+)/) || ua.match(/rv:([^ )]+)/);
269
- }
270
- return version > 4 ? version : void 0;
271
- }();
272
-
273
340
  // ../utils/dist/object.js
274
341
  function hasOwnProperty(obj, propName) {
275
342
  return Object.prototype.hasOwnProperty.call(obj, propName);
@@ -282,8 +349,9 @@ function isObjectLike(obj) {
282
349
  }
283
350
  function extend(target, source) {
284
351
  if (source) {
285
- for (var prop in source) {
352
+ for (const prop of Object.keys(source)) {
286
353
  if (hasOwnProperty(source, prop)) {
354
+ ;
287
355
  target[prop] = source[prop];
288
356
  }
289
357
  }
@@ -291,7 +359,7 @@ function extend(target, source) {
291
359
  return target;
292
360
  }
293
361
  function objectForEach(obj, action) {
294
- for (var prop in obj) {
362
+ for (const prop in obj) {
295
363
  if (hasOwnProperty(obj, prop)) {
296
364
  action(prop, obj[prop]);
297
365
  }
@@ -304,8 +372,8 @@ function objectMap(source, mapping, thisArg) {
304
372
  if (arguments.length > 2) {
305
373
  mapping = mapping.bind(thisArg);
306
374
  }
307
- var target = {};
308
- for (var prop in source) {
375
+ const target = {};
376
+ for (const prop in source) {
309
377
  if (hasOwnProperty(source, prop)) {
310
378
  target[prop] = mapping(source[prop], prop, source);
311
379
  }
@@ -336,27 +404,25 @@ function createSymbolOrString(identifier) {
336
404
  return useSymbols ? Symbol(identifier) : identifier;
337
405
  }
338
406
 
339
- // ../utils/dist/jquery.js
340
- var jQueryInstance = options_default.global && options_default.global.jQuery;
341
-
342
407
  // ../utils/dist/dom/info.js
343
408
  function domNodeIsContainedBy(node, containedByNode) {
344
409
  if (node === containedByNode) {
345
410
  return true;
346
411
  }
347
- if (node.nodeType === 11) {
412
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
348
413
  return false;
349
414
  }
350
415
  if (containedByNode.contains) {
351
- return containedByNode.contains(node.nodeType !== 1 ? node.parentNode : node);
416
+ return containedByNode.contains(node.nodeType !== Node.ELEMENT_NODE ? node.parentNode : node);
352
417
  }
353
418
  if (containedByNode.compareDocumentPosition) {
354
419
  return (containedByNode.compareDocumentPosition(node) & 16) == 16;
355
420
  }
356
- while (node && node != containedByNode) {
357
- node = node.parentNode;
421
+ let parentNode = node;
422
+ while (parentNode && parentNode != containedByNode) {
423
+ parentNode = parentNode.parentNode;
358
424
  }
359
- return !!node;
425
+ return !!parentNode;
360
426
  }
361
427
  function domNodeIsAttachedToDocument(node) {
362
428
  return domNodeIsContainedBy(node, node.ownerDocument.documentElement);
@@ -368,6 +434,29 @@ function tagNameLower(element) {
368
434
  return element && element.tagName && element.tagName.toLowerCase();
369
435
  }
370
436
 
437
+ // ../utils/dist/dom/event.js
438
+ var knownEvents = {};
439
+ var knownEventTypesByEventName = {};
440
+ knownEvents["UIEvents"] = ["keyup", "keydown", "keypress"];
441
+ knownEvents["MouseEvents"] = [
442
+ "click",
443
+ "dblclick",
444
+ "mousedown",
445
+ "mouseup",
446
+ "mousemove",
447
+ "mouseover",
448
+ "mouseout",
449
+ "mouseenter",
450
+ "mouseleave"
451
+ ];
452
+ objectForEach(knownEvents, function(eventType, knownEventsForType) {
453
+ if (knownEventsForType.length) {
454
+ for (let i = 0, j = knownEventsForType.length; i < j; i++) {
455
+ knownEventTypesByEventName[knownEventsForType[i]] = eventType;
456
+ }
457
+ }
458
+ });
459
+
371
460
  // ../utils/dist/dom/data.js
372
461
  var data_exports = {};
373
462
  __export(data_exports, {
@@ -377,64 +466,53 @@ __export(data_exports, {
377
466
  nextKey: () => nextKey,
378
467
  set: () => set
379
468
  });
380
- var datastoreTime = new Date().getTime();
469
+ var datastoreTime = (/* @__PURE__ */ new Date()).getTime();
381
470
  var dataStoreKeyExpandoPropertyName = `__ko__${datastoreTime}`;
382
- var dataStoreSymbol = Symbol("Knockout data");
383
- var dataStore;
471
+ var dataStoreSymbol = /* @__PURE__ */ Symbol("Knockout data");
384
472
  var uniqueId = 0;
385
- var modern = {
386
- getDataForNode(node, createIfNotFound) {
387
- let dataForNode = node[dataStoreSymbol];
388
- if (!dataForNode && createIfNotFound) {
389
- dataForNode = node[dataStoreSymbol] = {};
390
- }
391
- return dataForNode;
392
- },
393
- clear(node) {
394
- if (node[dataStoreSymbol]) {
395
- delete node[dataStoreSymbol];
396
- return true;
397
- }
398
- return false;
473
+ function isSafeKey(key) {
474
+ return key !== "__proto__" && key !== "constructor" && key !== "prototype";
475
+ }
476
+ function getDataForNode(node, createIfNotFound) {
477
+ let dataForNode = node[dataStoreSymbol];
478
+ if (!dataForNode && createIfNotFound) {
479
+ dataForNode = node[dataStoreSymbol] = {};
399
480
  }
400
- };
401
- var IE = {
402
- getDataforNode(node, createIfNotFound) {
403
- let dataStoreKey = node[dataStoreKeyExpandoPropertyName];
404
- const hasExistingDataStore = dataStoreKey && dataStoreKey !== "null" && dataStore[dataStoreKey];
405
- if (!hasExistingDataStore) {
406
- if (!createIfNotFound) {
407
- return void 0;
408
- }
409
- dataStoreKey = node[dataStoreKeyExpandoPropertyName] = "ko" + uniqueId++;
410
- dataStore[dataStoreKey] = {};
411
- }
412
- return dataStore[dataStoreKey];
413
- },
414
- clear(node) {
415
- const dataStoreKey = node[dataStoreKeyExpandoPropertyName];
416
- if (dataStoreKey) {
417
- delete dataStore[dataStoreKey];
418
- node[dataStoreKeyExpandoPropertyName] = null;
419
- return true;
420
- }
421
- return false;
481
+ return dataForNode;
482
+ }
483
+ function clear(node) {
484
+ if (node[dataStoreSymbol]) {
485
+ delete node[dataStoreSymbol];
486
+ return true;
422
487
  }
423
- };
424
- var { getDataForNode, clear } = ieVersion ? IE : modern;
488
+ return false;
489
+ }
425
490
  function nextKey() {
426
491
  return uniqueId++ + dataStoreKeyExpandoPropertyName;
427
492
  }
428
493
  function get(node, key) {
494
+ if (!isSafeKey(key)) throw new Error("Unsafe key for DOM data: " + key);
429
495
  const dataForNode = getDataForNode(node, false);
430
496
  return dataForNode && dataForNode[key];
431
497
  }
432
498
  function set(node, key, value) {
433
- var dataForNode = getDataForNode(node, value !== void 0);
434
- dataForNode && (dataForNode[key] = value);
499
+ if (!isSafeKey(key)) throw new Error("Unsafe key for DOM data: " + key);
500
+ const dataForNode = getDataForNode(
501
+ node,
502
+ value !== void 0
503
+ /* createIfNotFound */
504
+ );
505
+ if (dataForNode) {
506
+ dataForNode[key] = value;
507
+ }
435
508
  }
436
509
  function getOrSet(node, key, value) {
437
- const dataForNode = getDataForNode(node, true);
510
+ if (!isSafeKey(key)) throw new Error("Unsafe key for DOM data: " + key);
511
+ const dataForNode = getDataForNode(
512
+ node,
513
+ true
514
+ /* createIfNotFound */
515
+ );
438
516
  return dataForNode[key] || (dataForNode[key] = value);
439
517
  }
440
518
 
@@ -443,9 +521,9 @@ var domDataKey = nextKey();
443
521
  var cleanableNodeTypes = { 1: true, 8: true, 9: true };
444
522
  var cleanableNodeTypesWithDescendants = { 1: true, 9: true };
445
523
  function getDisposeCallbacksCollection(node, createIfNotFound) {
446
- var allDisposeCallbacks = get(node, domDataKey);
524
+ let allDisposeCallbacks = get(node, domDataKey);
447
525
  if (allDisposeCallbacks === void 0 && createIfNotFound) {
448
- allDisposeCallbacks = [];
526
+ allDisposeCallbacks = new Array();
449
527
  set(node, domDataKey, allDisposeCallbacks);
450
528
  }
451
529
  return allDisposeCallbacks;
@@ -454,7 +532,7 @@ function destroyCallbacksCollection(node) {
454
532
  set(node, domDataKey, void 0);
455
533
  }
456
534
  function cleanSingleNode(node) {
457
- var callbacks = getDisposeCallbacksCollection(node, false);
535
+ let callbacks = getDisposeCallbacksCollection(node, false);
458
536
  if (callbacks) {
459
537
  callbacks = callbacks.slice(0);
460
538
  for (let i = 0; i < callbacks.length; i++) {
@@ -469,14 +547,18 @@ function cleanSingleNode(node) {
469
547
  options_default.cleanExternalData(node);
470
548
  }
471
549
  if (cleanableNodeTypesWithDescendants[node.nodeType]) {
472
- cleanNodesInList(node.childNodes, true);
550
+ cleanNodesInList(
551
+ node.childNodes,
552
+ true
553
+ /* onlyComments */
554
+ );
473
555
  }
474
556
  }
475
557
  function cleanNodesInList(nodeList, onlyComments) {
476
- const cleanedNodes = [];
558
+ const cleanedNodes = new Array();
477
559
  let lastCleanedNode;
478
- for (var i = 0; i < nodeList.length; i++) {
479
- if (!onlyComments || nodeList[i].nodeType === 8) {
560
+ for (let i = 0; i < nodeList.length; i++) {
561
+ if (!onlyComments || nodeList[i].nodeType === Node.COMMENT_NODE) {
480
562
  cleanSingleNode(cleanedNodes[cleanedNodes.length] = lastCleanedNode = nodeList[i]);
481
563
  if (nodeList[i] !== lastCleanedNode) {
482
564
  while (i-- && arrayIndexOf(cleanedNodes, nodeList[i]) === -1) {
@@ -492,7 +574,7 @@ function addDisposeCallback(node, callback) {
492
574
  getDisposeCallbacksCollection(node, true).push(callback);
493
575
  }
494
576
  function removeDisposeCallback(node, callback) {
495
- var callbacksCollection = getDisposeCallbacksCollection(node, false);
577
+ const callbacksCollection = getDisposeCallbacksCollection(node, false);
496
578
  if (callbacksCollection) {
497
579
  arrayRemoveItem(callbacksCollection, callback);
498
580
  if (callbacksCollection.length === 0) {
@@ -503,69 +585,48 @@ function removeDisposeCallback(node, callback) {
503
585
  function cleanNode(node) {
504
586
  if (cleanableNodeTypes[node.nodeType]) {
505
587
  cleanSingleNode(node);
506
- if (cleanableNodeTypesWithDescendants[node.nodeType]) {
588
+ if (cleanableNodeTypesWithDescendants[node.nodeType] && node instanceof Element) {
507
589
  cleanNodesInList(node.getElementsByTagName("*"));
508
590
  }
509
591
  }
510
592
  return node;
511
593
  }
512
594
  function removeNode(node) {
595
+ if (!node) {
596
+ return;
597
+ }
513
598
  cleanNode(node);
514
599
  if (node.parentNode) {
515
600
  node.parentNode.removeChild(node);
516
601
  }
517
602
  }
518
- var otherNodeCleanerFunctions = [];
603
+ var otherNodeCleanerFunctions = new Array();
519
604
  function cleanjQueryData(node) {
520
- var jQueryCleanNodeFn = jQueryInstance ? jQueryInstance.cleanData : null;
605
+ const jQueryCleanNodeFn = options_default.jQuery ? options_default.jQuery.cleanData : null;
521
606
  if (jQueryCleanNodeFn) {
522
607
  jQueryCleanNodeFn([node]);
523
608
  }
524
609
  }
525
610
  otherNodeCleanerFunctions.push(cleanjQueryData);
526
611
 
527
- // ../utils/dist/dom/event.js
528
- var knownEvents = {};
529
- var knownEventTypesByEventName = {};
530
- var keyEventTypeName = options_default.global.navigator && /Firefox\/2/i.test(options_default.global.navigator.userAgent) ? "KeyboardEvent" : "UIEvents";
531
- knownEvents[keyEventTypeName] = ["keyup", "keydown", "keypress"];
532
- knownEvents["MouseEvents"] = [
533
- "click",
534
- "dblclick",
535
- "mousedown",
536
- "mouseup",
537
- "mousemove",
538
- "mouseover",
539
- "mouseout",
540
- "mouseenter",
541
- "mouseleave"
542
- ];
543
- objectForEach(knownEvents, function(eventType, knownEventsForType) {
544
- if (knownEventsForType.length) {
545
- for (var i = 0, j = knownEventsForType.length; i < j; i++) {
546
- knownEventTypesByEventName[knownEventsForType[i]] = eventType;
547
- }
548
- }
549
- });
550
-
551
612
  // ../utils/dist/dom/manipulation.js
552
613
  function setDomNodeChildren(domNode, childNodes2) {
553
614
  emptyDomNode(domNode);
554
615
  if (childNodes2) {
555
- for (var i = 0, j = childNodes2.length; i < j; i++) {
616
+ for (let i = 0; i < childNodes2.length; i++) {
556
617
  domNode.appendChild(childNodes2[i]);
557
618
  }
558
619
  }
559
620
  }
560
621
  function replaceDomNodes(nodeToReplaceOrNodeArray, newNodesArray) {
561
- var nodesToReplaceArray = nodeToReplaceOrNodeArray.nodeType ? [nodeToReplaceOrNodeArray] : nodeToReplaceOrNodeArray;
622
+ const nodesToReplaceArray = Array.isArray(nodeToReplaceOrNodeArray) ? nodeToReplaceOrNodeArray : [nodeToReplaceOrNodeArray];
562
623
  if (nodesToReplaceArray.length > 0) {
563
- var insertionPoint = nodesToReplaceArray[0];
564
- var parent = insertionPoint.parentNode;
565
- for (var i = 0, j = newNodesArray.length; i < j; i++) {
566
- parent.insertBefore(newNodesArray[i], insertionPoint);
624
+ const insertionPoint = nodesToReplaceArray[0];
625
+ const parent = insertionPoint.parentNode;
626
+ for (let i = 0; i < newNodesArray.length; i++) {
627
+ parent == null ? void 0 : parent.insertBefore(newNodesArray[i], insertionPoint);
567
628
  }
568
- for (i = 0, j = nodesToReplaceArray.length; i < j; i++) {
629
+ for (let i = 0; i < nodesToReplaceArray.length; i++) {
569
630
  removeNode(nodesToReplaceArray[i]);
570
631
  }
571
632
  }
@@ -579,7 +640,7 @@ function emptyDomNode(domNode) {
579
640
  // ../utils/dist/dom/fixes.js
580
641
  function fixUpContinuousNodeArray(continuousNodeArray, parentNode) {
581
642
  if (continuousNodeArray.length) {
582
- parentNode = parentNode.nodeType === 8 && parentNode.parentNode || parentNode;
643
+ parentNode = parentNode.nodeType === Node.COMMENT_NODE && parentNode.parentNode || parentNode;
583
644
  while (continuousNodeArray.length && continuousNodeArray[0].parentNode !== parentNode) {
584
645
  continuousNodeArray.splice(0, 1);
585
646
  }
@@ -587,7 +648,7 @@ function fixUpContinuousNodeArray(continuousNodeArray, parentNode) {
587
648
  continuousNodeArray.length--;
588
649
  }
589
650
  if (continuousNodeArray.length > 1) {
590
- var current = continuousNodeArray[0], last = continuousNodeArray[continuousNodeArray.length - 1];
651
+ let current = continuousNodeArray[0], last = continuousNodeArray[continuousNodeArray.length - 1];
591
652
  continuousNodeArray.length = 0;
592
653
  while (current !== last) {
593
654
  continuousNodeArray.push(current);
@@ -621,24 +682,23 @@ __export(virtualElements_exports, {
621
682
  startCommentRegex: () => startCommentRegex,
622
683
  virtualNodeBindingValue: () => virtualNodeBindingValue
623
684
  });
624
- var commentNodesHaveTextProperty = options_default.document && options_default.document.createComment("test").text === "<!--test-->";
625
- var startCommentRegex = commentNodesHaveTextProperty ? /^<!--\s*ko(?:\s+([\s\S]+))?\s*-->$/ : /^\s*ko(?:\s+([\s\S]+))?\s*$/;
626
- var endCommentRegex = commentNodesHaveTextProperty ? /^<!--\s*\/ko\s*-->$/ : /^\s*\/ko\s*$/;
627
- var htmlTagsWithOptionallyClosingChildren = { "ul": true, "ol": true };
685
+ var startCommentRegex = /^\s*ko(?:\s+([\s\S]+))?\s*$/;
686
+ var endCommentRegex = /^\s*\/ko\s*$/;
687
+ var htmlTagsWithOptionallyClosingChildren = { ul: true, ol: true };
628
688
  function isStartComment(node) {
629
- return node.nodeType == 8 && startCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);
689
+ return node.nodeType === Node.COMMENT_NODE && startCommentRegex.test(node.nodeValue);
630
690
  }
631
691
  function isEndComment(node) {
632
- return node.nodeType == 8 && endCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);
692
+ return node.nodeType === Node.COMMENT_NODE && endCommentRegex.test(node.nodeValue);
633
693
  }
634
694
  function isUnmatchedEndComment(node) {
635
695
  return isEndComment(node) && !get(node, matchedEndCommentDataKey);
636
696
  }
637
697
  var matchedEndCommentDataKey = "__ko_matchedEndComment__";
638
698
  function getVirtualChildren(startComment, allowUnbalanced) {
639
- var currentNode = startComment;
640
- var depth = 1;
641
- var children = [];
699
+ let currentNode = startComment;
700
+ let depth = 1;
701
+ const children = new Array();
642
702
  while (currentNode = currentNode.nextSibling) {
643
703
  if (isEndComment(currentNode)) {
644
704
  set(currentNode, matchedEndCommentDataKey, true);
@@ -658,7 +718,7 @@ function getVirtualChildren(startComment, allowUnbalanced) {
658
718
  return null;
659
719
  }
660
720
  function getMatchingEndComment(startComment, allowUnbalanced) {
661
- var allVirtualChildren = getVirtualChildren(startComment, allowUnbalanced);
721
+ const allVirtualChildren = getVirtualChildren(startComment, allowUnbalanced);
662
722
  if (allVirtualChildren) {
663
723
  if (allVirtualChildren.length > 0) {
664
724
  return allVirtualChildren[allVirtualChildren.length - 1].nextSibling;
@@ -669,13 +729,17 @@ function getMatchingEndComment(startComment, allowUnbalanced) {
669
729
  }
670
730
  }
671
731
  function getUnbalancedChildTags(node) {
672
- var childNode = node.firstChild, captureRemaining = null;
732
+ let childNode = node.firstChild, captureRemaining = null;
673
733
  if (childNode) {
674
734
  do {
675
735
  if (captureRemaining) {
676
736
  captureRemaining.push(childNode);
677
737
  } else if (isStartComment(childNode)) {
678
- var matchingEndComment = getMatchingEndComment(childNode, true);
738
+ const matchingEndComment = getMatchingEndComment(
739
+ childNode,
740
+ /* allowUnbalanced: */
741
+ true
742
+ );
679
743
  if (matchingEndComment) {
680
744
  childNode = matchingEndComment;
681
745
  } else {
@@ -688,7 +752,7 @@ function getUnbalancedChildTags(node) {
688
752
  }
689
753
  return captureRemaining;
690
754
  }
691
- var allowedBindings = {};
755
+ var allowedBindings = /* @__PURE__ */ Object.create(null);
692
756
  var hasBindingValue = isStartComment;
693
757
  function childNodes(node) {
694
758
  return isStartComment(node) ? getVirtualChildren(node) : node.childNodes;
@@ -697,8 +761,8 @@ function emptyNode(node) {
697
761
  if (!isStartComment(node)) {
698
762
  emptyDomNode(node);
699
763
  } else {
700
- var virtualChildren = childNodes(node);
701
- for (var i = 0, j = virtualChildren.length; i < j; i++) {
764
+ const virtualChildren = childNodes(node);
765
+ for (let i = 0, j = virtualChildren.length; i < j; i++) {
702
766
  removeNode(virtualChildren[i]);
703
767
  }
704
768
  }
@@ -709,13 +773,16 @@ function setDomNodeChildren2(node, childNodes2) {
709
773
  } else {
710
774
  emptyNode(node);
711
775
  const endCommentNode = node.nextSibling;
712
- const parentNode = endCommentNode.parentNode;
713
- for (var i = 0, j = childNodes2.length; i < j; ++i) {
714
- parentNode.insertBefore(childNodes2[i], endCommentNode);
776
+ if (endCommentNode && endCommentNode.parentNode) {
777
+ const parentNode = endCommentNode.parentNode;
778
+ for (let i = 0, j = childNodes2.length; i < j; ++i) {
779
+ parentNode.insertBefore(childNodes2[i], endCommentNode);
780
+ }
715
781
  }
716
782
  }
717
783
  }
718
784
  function prepend(containerNode, nodeToPrepend) {
785
+ var _a;
719
786
  if (!isStartComment(containerNode)) {
720
787
  if (containerNode.firstChild) {
721
788
  containerNode.insertBefore(nodeToPrepend, containerNode.firstChild);
@@ -723,10 +790,11 @@ function prepend(containerNode, nodeToPrepend) {
723
790
  containerNode.appendChild(nodeToPrepend);
724
791
  }
725
792
  } else {
726
- containerNode.parentNode.insertBefore(nodeToPrepend, containerNode.nextSibling);
793
+ (_a = containerNode.parentNode) == null ? void 0 : _a.insertBefore(nodeToPrepend, containerNode.nextSibling);
727
794
  }
728
795
  }
729
796
  function insertAfter(containerNode, nodeToInsert, insertAfterNode) {
797
+ var _a;
730
798
  if (!insertAfterNode) {
731
799
  prepend(containerNode, nodeToInsert);
732
800
  } else if (!isStartComment(containerNode)) {
@@ -736,7 +804,7 @@ function insertAfter(containerNode, nodeToInsert, insertAfterNode) {
736
804
  containerNode.appendChild(nodeToInsert);
737
805
  }
738
806
  } else {
739
- containerNode.parentNode.insertBefore(nodeToInsert, insertAfterNode.nextSibling);
807
+ (_a = containerNode.parentNode) == null ? void 0 : _a.insertBefore(nodeToInsert, insertAfterNode.nextSibling);
740
808
  }
741
809
  }
742
810
  function firstChild(node) {
@@ -753,6 +821,7 @@ function firstChild(node) {
753
821
  }
754
822
  function lastChild(node) {
755
823
  let nextChild = firstChild(node);
824
+ if (!nextChild) return null;
756
825
  let lastChildNode;
757
826
  do {
758
827
  lastChildNode = nextChild;
@@ -765,7 +834,9 @@ function nextSibling(node) {
765
834
  }
766
835
  if (node.nextSibling && isEndComment(node.nextSibling)) {
767
836
  if (isUnmatchedEndComment(node.nextSibling)) {
768
- throw Error("Found end comment without a matching opening comment, as next sibling of " + node.outerHTML);
837
+ throw Error(
838
+ "Found end comment without a matching opening comment, as next sibling of " + node.outerHTML
839
+ );
769
840
  }
770
841
  return null;
771
842
  } else {
@@ -773,9 +844,9 @@ function nextSibling(node) {
773
844
  }
774
845
  }
775
846
  function previousSibling(node) {
776
- var depth = 0;
847
+ let depth = 0;
777
848
  do {
778
- if (node.nodeType === 8) {
849
+ if (node.nodeType === Node.COMMENT_NODE) {
779
850
  if (isStartComment(node)) {
780
851
  if (--depth === 0) {
781
852
  return node;
@@ -791,21 +862,21 @@ function previousSibling(node) {
791
862
  } while (node = node.previousSibling);
792
863
  }
793
864
  function virtualNodeBindingValue(node) {
794
- var regexMatch = (commentNodesHaveTextProperty ? node.text : node.nodeValue).match(startCommentRegex);
865
+ const regexMatch = node.nodeValue.match(startCommentRegex);
795
866
  return regexMatch ? regexMatch[1] : null;
796
867
  }
797
868
  function normaliseVirtualElementDomStructure(elementVerified) {
798
869
  if (!htmlTagsWithOptionallyClosingChildren[tagNameLower(elementVerified)]) {
799
870
  return;
800
871
  }
801
- var childNode = elementVerified.firstChild;
872
+ let childNode = elementVerified.firstChild;
802
873
  if (childNode) {
803
874
  do {
804
- if (childNode.nodeType === 1) {
805
- var unbalancedTags = getUnbalancedChildTags(childNode);
875
+ if (childNode.nodeType === Node.ELEMENT_NODE) {
876
+ const unbalancedTags = getUnbalancedChildTags(childNode);
806
877
  if (unbalancedTags) {
807
- var nodeToInsertBefore = childNode.nextSibling;
808
- for (var i = 0; i < unbalancedTags.length; i++) {
878
+ const nodeToInsertBefore = childNode.nextSibling;
879
+ for (let i = 0; i < unbalancedTags.length; i++) {
809
880
  if (nodeToInsertBefore) {
810
881
  elementVerified.insertBefore(unbalancedTags[i], nodeToInsertBefore);
811
882
  } else {
@@ -819,21 +890,24 @@ function normaliseVirtualElementDomStructure(elementVerified) {
819
890
  }
820
891
 
821
892
  // ../utils/dist/dom/html.js
822
- var supportsTemplateTag = options_default.document && "content" in options_default.document.createElement("template");
893
+ var supportsTemplateTag = options_default.useTemplateTag && options_default.document && "content" in options_default.document.createElement("template");
823
894
 
824
895
  // ../utils/dist/dom/selectExtensions.js
825
- var hasDomDataExpandoProperty = Symbol("Knockout selectExtensions hasDomDataProperty");
896
+ var hasDomDataExpandoProperty = /* @__PURE__ */ Symbol("Knockout selectExtensions hasDomDataProperty");
826
897
  var selectExtensions = {
827
898
  optionValueDomDataKey: nextKey(),
828
899
  readValue: function(element) {
829
900
  switch (tagNameLower(element)) {
830
- case "option":
901
+ case "option": {
831
902
  if (element[hasDomDataExpandoProperty] === true) {
832
903
  return get(element, selectExtensions.optionValueDomDataKey);
833
904
  }
834
905
  return element.value;
835
- case "select":
836
- return element.selectedIndex >= 0 ? selectExtensions.readValue(element.options[element.selectedIndex]) : void 0;
906
+ }
907
+ case "select": {
908
+ const selectElement = element;
909
+ return selectElement.selectedIndex >= 0 ? selectExtensions.readValue(selectElement.options[selectElement.selectedIndex]) : void 0;
910
+ }
837
911
  default:
838
912
  return element.value;
839
913
  }
@@ -846,36 +920,42 @@ var selectExtensions = {
846
920
  if (hasDomDataExpandoProperty in element) {
847
921
  delete element[hasDomDataExpandoProperty];
848
922
  }
923
+ ;
849
924
  element.value = value;
850
925
  } else {
926
+ const el = element;
851
927
  set(element, selectExtensions.optionValueDomDataKey, value);
852
- element[hasDomDataExpandoProperty] = true;
853
- element.value = typeof value === "number" ? value : "";
928
+ el[hasDomDataExpandoProperty] = true;
929
+ el.value = typeof value === "number" ? value : "";
854
930
  }
855
931
  break;
856
932
  case "select":
857
- if (value === "" || value === null) {
858
- value = void 0;
859
- }
860
- var selection = -1;
861
- for (let i = 0, n = element.options.length, optionValue; i < n; ++i) {
862
- optionValue = selectExtensions.readValue(element.options[i]);
863
- const strictEqual = optionValue === value;
864
- const blankEqual = optionValue === "" && value === void 0;
865
- const numericEqual = typeof value === "number" && Number(optionValue) === value;
866
- if (strictEqual || blankEqual || numericEqual) {
867
- selection = i;
868
- break;
933
+ {
934
+ if (value === "" || value === null) {
935
+ value = void 0;
936
+ }
937
+ let selection = -1;
938
+ const selectElement = element;
939
+ for (let i = 0, n = selectElement.options.length, optionValue; i < n; ++i) {
940
+ optionValue = selectExtensions.readValue(selectElement.options[i]);
941
+ const strictEqual = optionValue === value;
942
+ const blankEqual = optionValue === "" && value === void 0;
943
+ const numericEqual = typeof value === "number" && Number(optionValue) === value;
944
+ if (strictEqual || blankEqual || numericEqual) {
945
+ selection = i;
946
+ break;
947
+ }
948
+ }
949
+ if (allowUnset || selection >= 0 || value === void 0 && selectElement.size > 1) {
950
+ selectElement.selectedIndex = selection;
869
951
  }
870
- }
871
- if (allowUnset || selection >= 0 || value === void 0 && element.size > 1) {
872
- element.selectedIndex = selection;
873
952
  }
874
953
  break;
875
954
  default:
876
955
  if (value === null || value === void 0) {
877
956
  value = "";
878
957
  }
958
+ ;
879
959
  element.value = value;
880
960
  break;
881
961
  }
@@ -890,30 +970,19 @@ __export(tasks_exports, {
890
970
  runEarly: () => processTasks,
891
971
  schedule: () => schedule
892
972
  });
893
- var taskQueue = [];
973
+ var taskQueue = new Array();
894
974
  var taskQueueLength = 0;
895
975
  var nextHandle = 1;
896
976
  var nextIndexToProcess = 0;
897
977
  var w = options_default.global;
898
978
  if (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {
899
- options_default.taskScheduler = function(callback) {
900
- var div = w.document.createElement("div");
979
+ options_default.taskScheduler = (function(callback) {
980
+ const div = w.document.createElement("div");
901
981
  new w.MutationObserver(callback).observe(div, { attributes: true });
902
982
  return function() {
903
983
  div.classList.toggle("foo");
904
984
  };
905
- }(scheduledProcess);
906
- } else if (w && w.document && "onreadystatechange" in w.document.createElement("script")) {
907
- options_default.taskScheduler = function(callback) {
908
- var script = document.createElement("script");
909
- script.onreadystatechange = function() {
910
- script.onreadystatechange = null;
911
- document.documentElement.removeChild(script);
912
- script = null;
913
- callback();
914
- };
915
- document.documentElement.appendChild(script);
916
- };
985
+ })(scheduledProcess);
917
986
  } else {
918
987
  options_default.taskScheduler = function(callback) {
919
988
  setTimeout(callback, 0);
@@ -921,8 +990,8 @@ if (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {
921
990
  }
922
991
  function processTasks() {
923
992
  if (taskQueueLength) {
924
- var mark = taskQueueLength, countMarks = 0;
925
- for (var task; nextIndexToProcess < taskQueueLength; ) {
993
+ let mark = taskQueueLength, countMarks = 0;
994
+ for (let task; nextIndexToProcess < taskQueueLength; ) {
926
995
  if (task = taskQueue[nextIndexToProcess++]) {
927
996
  if (nextIndexToProcess > mark) {
928
997
  if (++countMarks >= 5e3) {
@@ -956,13 +1025,13 @@ function schedule(func) {
956
1025
  return nextHandle++;
957
1026
  }
958
1027
  function cancel(handle) {
959
- var index = handle - (nextHandle - taskQueueLength);
1028
+ const index = handle - (nextHandle - taskQueueLength);
960
1029
  if (index >= nextIndexToProcess && index < taskQueueLength) {
961
1030
  taskQueue[index] = null;
962
1031
  }
963
1032
  }
964
1033
  function resetForTesting() {
965
- var length = taskQueueLength - nextIndexToProcess;
1034
+ const length = taskQueueLength - nextIndexToProcess;
966
1035
  nextIndexToProcess = taskQueueLength = taskQueue.length = 0;
967
1036
  return length;
968
1037
  }
@@ -981,13 +1050,13 @@ __export(dependencyDetection_exports, {
981
1050
  });
982
1051
 
983
1052
  // ../observable/dist/subscribableSymbol.js
984
- var SUBSCRIBABLE_SYM = Symbol("Knockout Subscribable");
1053
+ var SUBSCRIBABLE_SYM = /* @__PURE__ */ Symbol("Knockout Subscribable");
985
1054
  function isSubscribable(instance) {
986
1055
  return instance && instance[SUBSCRIBABLE_SYM] || false;
987
1056
  }
988
1057
 
989
1058
  // ../observable/dist/dependencyDetection.js
990
- var outerFrames = [];
1059
+ var outerFrames = new Array();
991
1060
  var currentFrame;
992
1061
  var lastId = 0;
993
1062
  function getId() {
@@ -1005,7 +1074,11 @@ function registerDependency(subscribable2) {
1005
1074
  if (!isSubscribable(subscribable2)) {
1006
1075
  throw new Error("Only subscribable things can act as dependencies");
1007
1076
  }
1008
- currentFrame.callback.call(currentFrame.callbackTarget, subscribable2, subscribable2._id || (subscribable2._id = getId()));
1077
+ currentFrame.callback.call(
1078
+ currentFrame.callbackTarget,
1079
+ subscribable2,
1080
+ subscribable2._id || (subscribable2._id = getId())
1081
+ );
1009
1082
  }
1010
1083
  }
1011
1084
  function ignore(callback, callbackTarget, callbackArgs) {
@@ -1020,16 +1093,19 @@ function getDependenciesCount() {
1020
1093
  if (currentFrame) {
1021
1094
  return currentFrame.computed.getDependenciesCount();
1022
1095
  }
1096
+ return void 0;
1023
1097
  }
1024
1098
  function getDependencies() {
1025
1099
  if (currentFrame) {
1026
1100
  return currentFrame.computed.getDependencies();
1027
1101
  }
1102
+ return void 0;
1028
1103
  }
1029
1104
  function isInitial() {
1030
1105
  if (currentFrame) {
1031
1106
  return currentFrame.isInitial;
1032
1107
  }
1108
+ return void 0;
1033
1109
  }
1034
1110
 
1035
1111
  // ../observable/dist/defer.js
@@ -1076,6 +1152,7 @@ var Subscription = class {
1076
1152
  this._node = node;
1077
1153
  addDisposeCallback(node, this._domNodeDisposalCallback = this.dispose.bind(this));
1078
1154
  }
1155
+ // TC39 Observable API
1079
1156
  unsubscribe() {
1080
1157
  this.dispose();
1081
1158
  }
@@ -1085,21 +1162,16 @@ var Subscription = class {
1085
1162
  };
1086
1163
 
1087
1164
  // ../observable/dist/extenders.js
1088
- var primitiveTypes = {
1089
- "undefined": 1,
1090
- "boolean": 1,
1091
- "number": 1,
1092
- "string": 1
1093
- };
1165
+ var primitiveTypes = { undefined: 1, boolean: 1, number: 1, string: 1 };
1094
1166
  function valuesArePrimitiveAndEqual(a, b) {
1095
- var oldValueIsPrimitive = a === null || typeof a in primitiveTypes;
1167
+ const oldValueIsPrimitive = a === null || typeof a in primitiveTypes;
1096
1168
  return oldValueIsPrimitive ? a === b : false;
1097
1169
  }
1098
1170
  function applyExtenders(requestedExtenders) {
1099
- var target = this;
1171
+ let target = this;
1100
1172
  if (requestedExtenders) {
1101
1173
  objectForEach(requestedExtenders, function(key, value) {
1102
- var extenderHandler = extenders[key];
1174
+ const extenderHandler = extenders[key];
1103
1175
  if (typeof extenderHandler === "function") {
1104
1176
  target = extenderHandler(target, value) || target;
1105
1177
  } else {
@@ -1114,12 +1186,14 @@ function notify(target, notifyWhen) {
1114
1186
  }
1115
1187
  function deferred(target, option) {
1116
1188
  if (option !== true) {
1117
- throw new Error("The 'deferred' extender only accepts the value 'true', because it is not supported to turn deferral off once enabled.");
1189
+ throw new Error(
1190
+ "The 'deferred' extender only accepts the value 'true', because it is not supported to turn deferral off once enabled."
1191
+ );
1118
1192
  }
1119
1193
  deferUpdates(target);
1120
1194
  }
1121
1195
  function rateLimit(target, options2) {
1122
- var timeout, method, limitFunction;
1196
+ let timeout, method, limitFunction;
1123
1197
  if (typeof options2 === "number") {
1124
1198
  timeout = options2;
1125
1199
  } else {
@@ -1132,21 +1206,17 @@ function rateLimit(target, options2) {
1132
1206
  return limitFunction(callback, timeout);
1133
1207
  });
1134
1208
  }
1135
- var extenders = {
1136
- notify,
1137
- deferred,
1138
- rateLimit
1139
- };
1209
+ var extenders = { notify, deferred, rateLimit };
1140
1210
 
1141
1211
  // ../observable/dist/subscribable.js
1142
- var LATEST_VALUE = Symbol("Knockout latest value");
1212
+ var LATEST_VALUE = /* @__PURE__ */ Symbol("Knockout latest value");
1143
1213
  if (!Symbol.observable) {
1144
- Symbol.observable = Symbol.for("@tko/Symbol.observable");
1214
+ Symbol.observable = /* @__PURE__ */ Symbol.for("@tko/Symbol.observable");
1145
1215
  }
1146
- function subscribable() {
1216
+ var subscribable = function subscribableFactory() {
1147
1217
  Object.setPrototypeOf(this, ko_subscribable_fn);
1148
1218
  ko_subscribable_fn.init(this);
1149
- }
1219
+ };
1150
1220
  var defaultEvent = "change";
1151
1221
  var ko_subscribable_fn = {
1152
1222
  [SUBSCRIBABLE_SYM]: true,
@@ -1160,9 +1230,7 @@ var ko_subscribable_fn = {
1160
1230
  subscribe(callback, callbackTarget, event) {
1161
1231
  const isTC39Callback = typeof callback === "object" && callback.next;
1162
1232
  event = event || defaultEvent;
1163
- const observer = isTC39Callback ? callback : {
1164
- next: callbackTarget ? callback.bind(callbackTarget) : callback
1165
- };
1233
+ const observer = isTC39Callback ? callback : { next: callbackTarget ? callback.bind(callbackTarget) : callback };
1166
1234
  const subscriptionInstance = new Subscription(this, observer, () => {
1167
1235
  arrayRemoveItem(this._subscriptions[event], subscriptionInstance);
1168
1236
  if (this.afterSubscriptionRemove) {
@@ -1173,7 +1241,7 @@ var ko_subscribable_fn = {
1173
1241
  this.beforeSubscriptionAdd(event);
1174
1242
  }
1175
1243
  if (!this._subscriptions[event]) {
1176
- this._subscriptions[event] = [];
1244
+ this._subscriptions[event] = new Array();
1177
1245
  }
1178
1246
  this._subscriptions[event].push(subscriptionInstance);
1179
1247
  if (isTC39Callback && LATEST_VALUE in this) {
@@ -1216,7 +1284,7 @@ var ko_subscribable_fn = {
1216
1284
  if (event) {
1217
1285
  return this._subscriptions[event] && this._subscriptions[event].length || 0;
1218
1286
  } else {
1219
- var total = 0;
1287
+ let total = 0;
1220
1288
  objectForEach(this._subscriptions, function(eventName, subscriptions) {
1221
1289
  if (eventName !== "dirty") {
1222
1290
  total += subscriptions.length;
@@ -1271,6 +1339,7 @@ function observable(initialValue) {
1271
1339
  function Observable() {
1272
1340
  if (arguments.length > 0) {
1273
1341
  if (Observable.isDifferent(Observable[LATEST_VALUE], arguments[0])) {
1342
+ ;
1274
1343
  Observable.valueWillMutate();
1275
1344
  Observable[LATEST_VALUE] = arguments[0];
1276
1345
  Observable.valueHasMutated();
@@ -1291,20 +1360,43 @@ function observable(initialValue) {
1291
1360
  return Observable;
1292
1361
  }
1293
1362
  observable.fn = {
1363
+ /**
1364
+ * Compares two values for equality.
1365
+ * @param a The first value.
1366
+ * @param b The second value.
1367
+ * @returns True if the values are equal, otherwise false.
1368
+ */
1294
1369
  equalityComparer: valuesArePrimitiveAndEqual,
1370
+ /**
1371
+ * Returns the current value of the observable without creating a dependency.
1372
+ * @returns The current value.
1373
+ */
1295
1374
  peek() {
1296
1375
  return this[LATEST_VALUE];
1297
1376
  },
1377
+ /**
1378
+ * Notifies subscribers that the value has changed.
1379
+ */
1298
1380
  valueHasMutated() {
1299
1381
  this.notifySubscribers(this[LATEST_VALUE], "spectate");
1300
1382
  this.notifySubscribers(this[LATEST_VALUE]);
1301
1383
  },
1384
+ /**
1385
+ * Notifies subscribers that the value is about to change.
1386
+ */
1302
1387
  valueWillMutate() {
1303
1388
  this.notifySubscribers(this[LATEST_VALUE], "beforeChange");
1304
1389
  },
1390
+ /**
1391
+ * Modifies the value of the observable using a function.
1392
+ * @param fn The function to modify the value.
1393
+ * @param peek Whether to use the current value without creating a dependency.
1394
+ * @returns The modified observable.
1395
+ */
1305
1396
  modify(fn, peek22 = true) {
1306
- return this(fn(peek22 ? this.peek() : this()));
1397
+ this(fn(peek22 ? this.peek() : this()));
1307
1398
  },
1399
+ // Some observables may not always be writeable, notably computeds.
1308
1400
  isWriteable: true
1309
1401
  };
1310
1402
  function limitNotifySubscribers(value, event) {
@@ -1317,15 +1409,15 @@ function limitNotifySubscribers(value, event) {
1317
1409
  }
1318
1410
  }
1319
1411
  subscribable.fn.limit = function limit(limitFunction) {
1320
- var self = this;
1321
- var selfIsObservable = isObservable(self);
1322
- var beforeChange = "beforeChange";
1323
- var ignoreBeforeChange, notifyNextChange, previousValue, pendingValue, didUpdate;
1412
+ const self = this;
1413
+ const selfIsObservable = isObservable(self);
1414
+ const beforeChange = "beforeChange";
1415
+ let ignoreBeforeChange, notifyNextChange, previousValue, pendingValue, didUpdate;
1324
1416
  if (!self._origNotifySubscribers) {
1325
1417
  self._origNotifySubscribers = self.notifySubscribers;
1326
1418
  self.notifySubscribers = limitNotifySubscribers;
1327
1419
  }
1328
- var finish = limitFunction(function() {
1420
+ const finish = limitFunction(function() {
1329
1421
  self._notificationIsPending = false;
1330
1422
  if (selfIsObservable && pendingValue === self) {
1331
1423
  pendingValue = self._evalIfChanged ? self._evalIfChanged() : self();
@@ -1353,7 +1445,10 @@ subscribable.fn.limit = function limit(limitFunction) {
1353
1445
  }
1354
1446
  },
1355
1447
  _notifyNextChangeIfValueIsDifferent() {
1356
- if (self.isDifferent(previousValue, self.peek(true))) {
1448
+ if (self.isDifferent(previousValue, self.peek(
1449
+ true
1450
+ /* evaluate */
1451
+ ))) {
1357
1452
  notifyNextChange = true;
1358
1453
  }
1359
1454
  },
@@ -1396,8 +1491,8 @@ function trackArrayChanges(target, options2) {
1396
1491
  let arrayChangeSubscription;
1397
1492
  let pendingNotifications = 0;
1398
1493
  let underlyingNotifySubscribersFunction;
1399
- let underlyingBeforeSubscriptionAddFunction = target.beforeSubscriptionAdd;
1400
- let underlyingAfterSubscriptionRemoveFunction = target.afterSubscriptionRemove;
1494
+ const underlyingBeforeSubscriptionAddFunction = target.beforeSubscriptionAdd;
1495
+ const underlyingAfterSubscriptionRemoveFunction = target.afterSubscriptionRemove;
1401
1496
  target.beforeSubscriptionAdd = function(event) {
1402
1497
  if (underlyingBeforeSubscriptionAddFunction) {
1403
1498
  underlyingBeforeSubscriptionAddFunction.call(target, event);
@@ -1434,11 +1529,11 @@ function trackArrayChanges(target, options2) {
1434
1529
  }
1435
1530
  return underlyingNotifySubscribersFunction.apply(this, arguments);
1436
1531
  };
1437
- var previousContents = [].concat(target.peek() === void 0 ? [] : target.peek());
1532
+ let previousContents = new Array().concat(target.peek() === void 0 ? [] : target.peek());
1438
1533
  cachedDiff = null;
1439
1534
  arrayChangeSubscription = target.subscribe(function(currentContents) {
1440
1535
  let changes;
1441
- currentContents = [].concat(currentContents || []);
1536
+ currentContents = new Array().concat(currentContents || []);
1442
1537
  if (target.hasSubscriptionsForEvent(arrayChangeEventName)) {
1443
1538
  changes = getChanges(previousContents, currentContents);
1444
1539
  }
@@ -1460,9 +1555,9 @@ function trackArrayChanges(target, options2) {
1460
1555
  if (!trackingChanges || pendingNotifications) {
1461
1556
  return;
1462
1557
  }
1463
- var diff = [], arrayLength = rawArray.length, argsLength = args.length, offset = 0;
1558
+ let diff = new Array(), arrayLength = rawArray.length, argsLength = args.length, offset = 0;
1464
1559
  function pushDiff(status, value, index) {
1465
- return diff[diff.length] = { "status": status, "value": value, "index": index };
1560
+ return diff[diff.length] = { status, value, index };
1466
1561
  }
1467
1562
  switch (operationName) {
1468
1563
  case "push":
@@ -1480,16 +1575,18 @@ function trackArrayChanges(target, options2) {
1480
1575
  }
1481
1576
  break;
1482
1577
  case "splice":
1483
- 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 = [];
1484
- for (let index = startIndex, argsIndex = 2; index < endIndex; ++index, ++argsIndex) {
1485
- if (index < endDeleteIndex) {
1486
- deletions.push(pushDiff("deleted", rawArray[index], index));
1487
- }
1488
- if (index < endAddIndex) {
1489
- additions.push(pushDiff("added", args[argsIndex], index));
1578
+ {
1579
+ 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();
1580
+ for (let index = startIndex, argsIndex = 2; index < endIndex; ++index, ++argsIndex) {
1581
+ if (index < endDeleteIndex) {
1582
+ deletions.push(pushDiff("deleted", rawArray[index], index));
1583
+ }
1584
+ if (index < endAddIndex) {
1585
+ additions.push(pushDiff("added", args[argsIndex], index));
1586
+ }
1490
1587
  }
1588
+ findMovesInArrayComparison(deletions, additions);
1491
1589
  }
1492
- findMovesInArrayComparison(deletions, additions);
1493
1590
  break;
1494
1591
  default:
1495
1592
  return;
@@ -1504,23 +1601,27 @@ extenders.trackArrayChanges = trackArrayChanges;
1504
1601
  function observableArray(initialValues) {
1505
1602
  initialValues = initialValues || [];
1506
1603
  if (typeof initialValues !== "object" || !("length" in initialValues)) {
1507
- throw new Error("The argument passed when initializing an observable array must be an array, or null, or undefined.");
1604
+ throw new Error(
1605
+ "The argument passed when initializing an observable array must be an array, or null, or undefined."
1606
+ );
1508
1607
  }
1509
- var result = observable(initialValues);
1510
- Object.setPrototypeOf(result, observableArray.fn);
1608
+ const result = Object.setPrototypeOf(observable(initialValues), observableArray.fn);
1511
1609
  trackArrayChanges(result);
1512
- overwriteLengthPropertyIfSupported(result, { get: () => result().length });
1610
+ overwriteLengthPropertyIfSupported(result, { get: () => {
1611
+ var _a;
1612
+ return (_a = result()) == null ? void 0 : _a.length;
1613
+ } });
1513
1614
  return result;
1514
1615
  }
1515
1616
  observableArray.fn = {
1516
1617
  remove(valueOrPredicate) {
1517
- var underlyingArray = this.peek();
1518
- var removedValues = [];
1519
- var predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value2) {
1520
- return value2 === valueOrPredicate;
1618
+ const underlyingArray = this.peek();
1619
+ const removedValues = new Array();
1620
+ const predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value) {
1621
+ return value === valueOrPredicate;
1521
1622
  };
1522
- for (var i = 0; i < underlyingArray.length; i++) {
1523
- var value = underlyingArray[i];
1623
+ for (let i = 0; i < underlyingArray.length; i++) {
1624
+ const value = underlyingArray[i];
1524
1625
  if (predicate(value)) {
1525
1626
  if (removedValues.length === 0) {
1526
1627
  this.valueWillMutate();
@@ -1540,8 +1641,8 @@ observableArray.fn = {
1540
1641
  },
1541
1642
  removeAll(arrayOfValues) {
1542
1643
  if (arrayOfValues === void 0) {
1543
- var underlyingArray = this.peek();
1544
- var allValues = underlyingArray.slice(0);
1644
+ const underlyingArray = this.peek();
1645
+ const allValues = underlyingArray.slice(0);
1545
1646
  this.valueWillMutate();
1546
1647
  underlyingArray.splice(0, underlyingArray.length);
1547
1648
  this.valueHasMutated();
@@ -1555,13 +1656,13 @@ observableArray.fn = {
1555
1656
  });
1556
1657
  },
1557
1658
  destroy(valueOrPredicate) {
1558
- var underlyingArray = this.peek();
1559
- var predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value2) {
1560
- return value2 === valueOrPredicate;
1659
+ const underlyingArray = this.peek();
1660
+ const predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value) {
1661
+ return value === valueOrPredicate;
1561
1662
  };
1562
1663
  this.valueWillMutate();
1563
- for (var i = underlyingArray.length - 1; i >= 0; i--) {
1564
- var value = underlyingArray[i];
1664
+ for (let i = underlyingArray.length - 1; i >= 0; i--) {
1665
+ const value = underlyingArray[i];
1565
1666
  if (predicate(value)) {
1566
1667
  value["_destroy"] = true;
1567
1668
  }
@@ -1585,7 +1686,7 @@ observableArray.fn = {
1585
1686
  return arrayIndexOf(this(), item);
1586
1687
  },
1587
1688
  replace(oldItem, newItem) {
1588
- var index = this.indexOf(oldItem);
1689
+ const index = this.indexOf(oldItem);
1589
1690
  if (index >= 0) {
1590
1691
  this.valueWillMutate();
1591
1692
  this.peek()[index] = newItem;
@@ -1599,23 +1700,23 @@ observableArray.fn = {
1599
1700
  return [...this()].reverse();
1600
1701
  },
1601
1702
  [Symbol.iterator]: function* () {
1602
- yield* this();
1703
+ yield* __yieldStar(this());
1603
1704
  }
1604
1705
  };
1605
1706
  Object.setPrototypeOf(observableArray.fn, observable.fn);
1606
1707
  arrayForEach(["pop", "push", "reverse", "shift", "sort", "splice", "unshift"], function(methodName) {
1607
1708
  observableArray.fn[methodName] = function() {
1608
- var underlyingArray = this.peek();
1709
+ const underlyingArray = this.peek();
1609
1710
  this.valueWillMutate();
1610
1711
  this.cacheDiffForKnownOperation(underlyingArray, methodName, arguments);
1611
- var methodCallResult = underlyingArray[methodName].apply(underlyingArray, arguments);
1712
+ const methodCallResult = underlyingArray[methodName].apply(underlyingArray, arguments);
1612
1713
  this.valueHasMutated();
1613
1714
  return methodCallResult === underlyingArray ? this : methodCallResult;
1614
1715
  };
1615
1716
  });
1616
1717
  arrayForEach(["slice"], function(methodName) {
1617
1718
  observableArray.fn[methodName] = function() {
1618
- var underlyingArray = this();
1719
+ const underlyingArray = this();
1619
1720
  return underlyingArray[methodName].apply(underlyingArray, arguments);
1620
1721
  };
1621
1722
  });
@@ -1643,11 +1744,11 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2)
1643
1744
  options2.read = evaluatorFunctionOrOptions;
1644
1745
  }
1645
1746
  }
1646
- if (typeof options2.read !== "function") {
1747
+ if (typeof (options2 == null ? void 0 : options2.read) !== "function") {
1647
1748
  throw Error("Pass a function that returns the value of the computed");
1648
1749
  }
1649
- var writeFunction = options2.write;
1650
- var state = {
1750
+ const writeFunction = options2.write;
1751
+ const state = {
1651
1752
  latestValue: void 0,
1652
1753
  isStale: true,
1653
1754
  isDirty: true,
@@ -1658,8 +1759,8 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2)
1658
1759
  isSleeping: false,
1659
1760
  readFunction: options2.read,
1660
1761
  evaluatorFunctionTarget: evaluatorFunctionTarget || options2.owner,
1661
- disposeWhenNodeIsRemoved: options2.disposeWhenNodeIsRemoved || options2.disposeWhenNodeIsRemoved || null,
1662
- disposeWhen: options2.disposeWhen || options2.disposeWhen,
1762
+ disposeWhenNodeIsRemoved: options2.disposeWhenNodeIsRemoved || null,
1763
+ disposeWhen: options2.disposeWhen,
1663
1764
  domNodeDisposalCallback: null,
1664
1765
  dependencyTracking: {},
1665
1766
  dependenciesCount: 0,
@@ -1670,7 +1771,9 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2)
1670
1771
  if (typeof writeFunction === "function") {
1671
1772
  writeFunction.apply(state.evaluatorFunctionTarget, arguments);
1672
1773
  } else {
1673
- 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.");
1774
+ throw new Error(
1775
+ "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."
1776
+ );
1674
1777
  }
1675
1778
  return this;
1676
1779
  } else {
@@ -1678,6 +1781,7 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2)
1678
1781
  dependencyDetection_exports.registerDependency(computedObservable);
1679
1782
  }
1680
1783
  if (state.isDirty || state.isSleeping && computedObservable.haveDependenciesChanged()) {
1784
+ ;
1681
1785
  computedObservable.evaluateImmediate();
1682
1786
  }
1683
1787
  return state.latestValue;
@@ -1707,12 +1811,17 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2)
1707
1811
  }
1708
1812
  }
1709
1813
  if (!state.isSleeping && !options2.deferEvaluation) {
1814
+ ;
1710
1815
  computedObservable.evaluateImmediate();
1711
1816
  }
1712
1817
  if (state.disposeWhenNodeIsRemoved && computedObservable.isActive()) {
1713
- addDisposeCallback(state.disposeWhenNodeIsRemoved, state.domNodeDisposalCallback = function() {
1714
- computedObservable.dispose();
1715
- });
1818
+ addDisposeCallback(
1819
+ state.disposeWhenNodeIsRemoved,
1820
+ state.domNodeDisposalCallback = function() {
1821
+ ;
1822
+ computedObservable.dispose();
1823
+ }
1824
+ );
1716
1825
  }
1717
1826
  return computedObservable;
1718
1827
  }
@@ -1722,14 +1831,18 @@ function computedDisposeDependencyCallback(id, entryToDispose) {
1722
1831
  }
1723
1832
  }
1724
1833
  function computedBeginDependencyDetectionCallback(subscribable2, id) {
1725
- var computedObservable = this.computedObservable, state = computedObservable[computedState];
1834
+ const computedObservable = this.computedObservable, state = computedObservable[computedState];
1726
1835
  if (!state.isDisposed) {
1727
1836
  if (this.disposalCount && this.disposalCandidates[id]) {
1728
1837
  computedObservable.addDependencyTracking(id, subscribable2, this.disposalCandidates[id]);
1729
1838
  this.disposalCandidates[id] = null;
1730
1839
  --this.disposalCount;
1731
1840
  } else if (!state.dependencyTracking[id]) {
1732
- computedObservable.addDependencyTracking(id, subscribable2, state.isSleeping ? { _target: subscribable2 } : computedObservable.subscribeToDependency(subscribable2));
1841
+ computedObservable.addDependencyTracking(
1842
+ id,
1843
+ subscribable2,
1844
+ state.isSleeping ? { _target: subscribable2 } : computedObservable.subscribeToDependency(subscribable2)
1845
+ );
1733
1846
  }
1734
1847
  if (subscribable2._notificationIsPending) {
1735
1848
  subscribable2._notifyNextChangeIfValueIsDifferent();
@@ -1743,7 +1856,7 @@ computed.fn = {
1743
1856
  },
1744
1857
  getDependencies() {
1745
1858
  const dependencyTracking = this[computedState].dependencyTracking;
1746
- const dependentObservables = [];
1859
+ const dependentObservables = new Array();
1747
1860
  objectForEach(dependencyTracking, function(id, dependency) {
1748
1861
  dependentObservables[dependency._order] = dependency._target;
1749
1862
  });
@@ -1758,7 +1871,7 @@ computed.fn = {
1758
1871
  trackingObj._version = target.getVersion();
1759
1872
  },
1760
1873
  haveDependenciesChanged() {
1761
- var id, dependency, dependencyTracking = this[computedState].dependencyTracking;
1874
+ let id, dependency, dependencyTracking = this[computedState].dependencyTracking;
1762
1875
  for (id in dependencyTracking) {
1763
1876
  if (hasOwnProperty(dependencyTracking, id)) {
1764
1877
  dependency = dependencyTracking[id];
@@ -1767,10 +1880,14 @@ computed.fn = {
1767
1880
  }
1768
1881
  }
1769
1882
  }
1883
+ return false;
1770
1884
  },
1771
1885
  markDirty() {
1772
1886
  if (this._evalDelayed && !this[computedState].isBeingEvaluated) {
1773
- this._evalDelayed(false);
1887
+ this._evalDelayed(
1888
+ false
1889
+ /* notifyChange */
1890
+ );
1774
1891
  }
1775
1892
  },
1776
1893
  isActive() {
@@ -1786,7 +1903,7 @@ computed.fn = {
1786
1903
  },
1787
1904
  subscribeToDependency(target) {
1788
1905
  if (target._deferUpdates) {
1789
- var dirtySub = target.subscribe(this.markDirty, this, "dirty"), changeSub = target.subscribe(this.respondToChange, this);
1906
+ const dirtySub = target.subscribe(this.markDirty, this, "dirty"), changeSub = target.subscribe(this.respondToChange, this);
1790
1907
  return {
1791
1908
  _target: target,
1792
1909
  dispose() {
@@ -1799,20 +1916,29 @@ computed.fn = {
1799
1916
  }
1800
1917
  },
1801
1918
  evaluatePossiblyAsync() {
1802
- var computedObservable = this, throttleEvaluationTimeout = computedObservable.throttleEvaluation;
1919
+ const computedObservable = this, throttleEvaluationTimeout = computedObservable.throttleEvaluation;
1803
1920
  if (throttleEvaluationTimeout && throttleEvaluationTimeout >= 0) {
1804
1921
  clearTimeout(this[computedState].evaluationTimeoutInstance);
1805
1922
  this[computedState].evaluationTimeoutInstance = safeSetTimeout(function() {
1806
- computedObservable.evaluateImmediate(true);
1923
+ computedObservable.evaluateImmediate(
1924
+ true
1925
+ /* notifyChange */
1926
+ );
1807
1927
  }, throttleEvaluationTimeout);
1808
1928
  } else if (computedObservable._evalDelayed) {
1809
- computedObservable._evalDelayed(true);
1929
+ computedObservable._evalDelayed(
1930
+ true
1931
+ /* notifyChange */
1932
+ );
1810
1933
  } else {
1811
- computedObservable.evaluateImmediate(true);
1934
+ computedObservable.evaluateImmediate(
1935
+ true
1936
+ /* notifyChange */
1937
+ );
1812
1938
  }
1813
1939
  },
1814
1940
  evaluateImmediate(notifyChange) {
1815
- var computedObservable = this, state = computedObservable[computedState], disposeWhen = state.disposeWhen, changed = false;
1941
+ let computedObservable = this, state = computedObservable[computedState], disposeWhen = state.disposeWhen, changed = false;
1816
1942
  if (state.isBeingEvaluated) {
1817
1943
  return;
1818
1944
  }
@@ -1836,8 +1962,8 @@ computed.fn = {
1836
1962
  return changed;
1837
1963
  },
1838
1964
  evaluateImmediate_CallReadWithDependencyDetection(notifyChange) {
1839
- var computedObservable = this, state = computedObservable[computedState], changed = false;
1840
- var isInitial2 = state.pure ? void 0 : !state.dependenciesCount, dependencyDetectionContext = {
1965
+ let computedObservable = this, state = computedObservable[computedState], changed = false;
1966
+ const isInitial2 = state.pure ? void 0 : !state.dependenciesCount, dependencyDetectionContext = {
1841
1967
  computedObservable,
1842
1968
  disposalCandidates: state.dependencyTracking,
1843
1969
  disposalCount: state.dependenciesCount
@@ -1850,7 +1976,7 @@ computed.fn = {
1850
1976
  });
1851
1977
  state.dependencyTracking = {};
1852
1978
  state.dependenciesCount = 0;
1853
- var newValue = this.evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext);
1979
+ const newValue = this.evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext);
1854
1980
  if (!state.dependenciesCount) {
1855
1981
  computedObservable.dispose();
1856
1982
  changed = true;
@@ -1882,7 +2008,7 @@ computed.fn = {
1882
2008
  },
1883
2009
  evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext) {
1884
2010
  try {
1885
- var readFunction = state.readFunction;
2011
+ const readFunction = state.readFunction;
1886
2012
  return state.evaluatorFunctionTarget ? readFunction.call(state.evaluatorFunctionTarget) : readFunction();
1887
2013
  } finally {
1888
2014
  dependencyDetection_exports.end();
@@ -1922,12 +2048,16 @@ computed.fn = {
1922
2048
  if (isChange) {
1923
2049
  state.isStale = true;
1924
2050
  }
1925
- this._limitChange(this, !isChange);
2051
+ this._limitChange(
2052
+ this,
2053
+ !isChange
2054
+ /* isDirty */
2055
+ );
1926
2056
  }
1927
2057
  });
1928
2058
  },
1929
2059
  dispose() {
1930
- var state = this[computedState];
2060
+ const state = this[computedState];
1931
2061
  if (!state.isSleeping && state.dependencyTracking) {
1932
2062
  objectForEach(state.dependencyTracking, function(id, dependency) {
1933
2063
  if (dependency.dispose) {
@@ -1943,7 +2073,7 @@ computed.fn = {
1943
2073
  };
1944
2074
  var pureComputedOverrides = {
1945
2075
  beforeSubscriptionAdd(event) {
1946
- var computedObservable = this, state = computedObservable[computedState];
2076
+ const computedObservable = this, state = computedObservable[computedState];
1947
2077
  if (!state.isDisposed && state.isSleeping && event === "change") {
1948
2078
  state.isSleeping = false;
1949
2079
  if (state.isStale || computedObservable.haveDependenciesChanged()) {
@@ -1953,12 +2083,12 @@ var pureComputedOverrides = {
1953
2083
  computedObservable.updateVersion();
1954
2084
  }
1955
2085
  } else {
1956
- var dependenciesOrder = [];
2086
+ const dependenciesOrder = new Array();
1957
2087
  objectForEach(state.dependencyTracking, function(id, dependency) {
1958
2088
  dependenciesOrder[dependency._order] = id;
1959
2089
  });
1960
2090
  arrayForEach(dependenciesOrder, function(id, order) {
1961
- var dependency = state.dependencyTracking[id], subscription = computedObservable.subscribeToDependency(dependency._target);
2091
+ const dependency = state.dependencyTracking[id], subscription = computedObservable.subscribeToDependency(dependency._target);
1962
2092
  subscription._order = order;
1963
2093
  subscription._version = dependency._version;
1964
2094
  state.dependencyTracking[id] = subscription;
@@ -1975,7 +2105,7 @@ var pureComputedOverrides = {
1975
2105
  }
1976
2106
  },
1977
2107
  afterSubscriptionRemove(event) {
1978
- var state = this[computedState];
2108
+ const state = this[computedState];
1979
2109
  if (!state.isDisposed && event === "change" && !this.hasSubscriptionsForEvent("change")) {
1980
2110
  objectForEach(state.dependencyTracking, function(id, dependency) {
1981
2111
  if (dependency.dispose) {
@@ -1992,7 +2122,7 @@ var pureComputedOverrides = {
1992
2122
  }
1993
2123
  },
1994
2124
  getVersion() {
1995
- var state = this[computedState];
2125
+ const state = this[computedState];
1996
2126
  if (state.isSleeping && (state.isStale || this.haveDependenciesChanged())) {
1997
2127
  this.evaluateImmediate();
1998
2128
  }
@@ -2012,18 +2142,20 @@ computed.fn[protoProp] = computed;
2012
2142
  observable.observablePrototypes.add(computed);
2013
2143
  function pureComputed(evaluatorFunctionOrOptions, evaluatorFunctionTarget) {
2014
2144
  if (typeof evaluatorFunctionOrOptions === "function") {
2015
- return computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, { "pure": true });
2145
+ const evaluator = evaluatorFunctionOrOptions;
2146
+ return computed(evaluator, evaluatorFunctionTarget, { pure: true });
2016
2147
  } else {
2017
- evaluatorFunctionOrOptions = extend({}, evaluatorFunctionOrOptions);
2018
- evaluatorFunctionOrOptions.pure = true;
2019
- return computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget);
2148
+ let options2 = evaluatorFunctionOrOptions;
2149
+ options2 = extend({}, options2);
2150
+ options2.pure = true;
2151
+ return computed(options2, evaluatorFunctionTarget);
2020
2152
  }
2021
2153
  }
2022
2154
 
2023
2155
  // ../computed/dist/throttleExtender.js
2024
2156
  function throttleExtender(target, timeout) {
2025
2157
  target.throttleEvaluation = timeout;
2026
- var writeTimeoutInstance = null;
2158
+ let writeTimeoutInstance = void 0;
2027
2159
  return computed({
2028
2160
  read: target,
2029
2161
  write: function(value) {
@@ -2034,11 +2166,12 @@ function throttleExtender(target, timeout) {
2034
2166
  }
2035
2167
  });
2036
2168
  }
2037
- extenders.throttle = throttleExtender;
2169
+ var extenders2 = extenders;
2170
+ extenders2.throttle = throttleExtender;
2038
2171
 
2039
2172
  // ../computed/dist/proxy.js
2040
- var PROXY_SYM = Symbol("Knockout Proxied Object");
2041
- var MIRROR_SYM = Symbol("Knockout Proxied Observables");
2173
+ var PROXY_SYM = /* @__PURE__ */ Symbol("Knockout Proxied Object");
2174
+ var MIRROR_SYM = /* @__PURE__ */ Symbol("Knockout Proxied Observables");
2042
2175
  function makeComputed(proxy2, fn) {
2043
2176
  return computed({
2044
2177
  owner: proxy2,
@@ -2105,10 +2238,7 @@ function proxy(object) {
2105
2238
  return Object.isExtensible(object);
2106
2239
  },
2107
2240
  ownKeys() {
2108
- return [
2109
- ...Object.getOwnPropertyNames(object),
2110
- ...Object.getOwnPropertySymbols(object)
2111
- ];
2241
+ return [...Object.getOwnPropertyNames(object), ...Object.getOwnPropertySymbols(object)];
2112
2242
  }
2113
2243
  });
2114
2244
  assignOrUpdate(mirror, object, proxy2);
@@ -2126,22 +2256,24 @@ function isProxied(proxied) {
2126
2256
  Object.assign(proxy, { getObservable, peek: peek2, isProxied });
2127
2257
 
2128
2258
  // src/bindingEvent.ts
2129
- var contextAncestorBindingInfo = Symbol("_ancestorBindingInfo");
2259
+ var contextAncestorBindingInfo = /* @__PURE__ */ Symbol("_ancestorBindingInfo");
2130
2260
  var boundElementDomDataKey = data_exports.nextKey();
2131
2261
  var bindingEvent = {
2262
+ //TODO better: String-Enum "BindingEventEnum"
2132
2263
  childrenComplete: "childrenComplete",
2133
2264
  descendantsComplete: "descendantsComplete",
2134
- subscribe(node, event, callback, context) {
2265
+ subscribe(node, event, callback, callbackContext) {
2135
2266
  const bindingInfo = data_exports.getOrSet(node, boundElementDomDataKey, {});
2136
2267
  if (!bindingInfo.eventSubscribable) {
2137
2268
  bindingInfo.eventSubscribable = new subscribable();
2138
2269
  }
2139
- return bindingInfo.eventSubscribable.subscribe(callback, context, event);
2270
+ return bindingInfo.eventSubscribable.subscribe(callback, callbackContext, event);
2140
2271
  },
2141
2272
  notify(node, event) {
2142
2273
  const bindingInfo = data_exports.get(node, boundElementDomDataKey);
2143
2274
  if (bindingInfo) {
2144
2275
  if (bindingInfo.eventSubscribable) {
2276
+ ;
2145
2277
  bindingInfo.eventSubscribable.notifySubscribers(node, event);
2146
2278
  }
2147
2279
  }
@@ -2150,15 +2282,14 @@ var bindingEvent = {
2150
2282
 
2151
2283
  // src/bindingContext.ts
2152
2284
  var boundElementDomDataKey2 = data_exports.nextKey();
2153
- var contextSubscribeSymbol = Symbol("Knockout Context Subscription");
2154
- var inheritParentIndicator = Symbol("Knockout Parent Indicator");
2155
- function bindingContext(dataItemOrAccessor, parentContext, dataItemAlias, extendCallback, settings) {
2285
+ var contextSubscribeSymbol = /* @__PURE__ */ Symbol("Knockout Context Subscription");
2286
+ var inheritParentIndicator = /* @__PURE__ */ Symbol("Knockout Parent Indicator");
2287
+ var bindingContext = function bindingContextFactory(dataItemOrAccessor, parentContext, dataItemAlias, extendCallback, settings) {
2156
2288
  const self = this;
2157
2289
  const shouldInheritData = dataItemOrAccessor === inheritParentIndicator;
2158
2290
  const realDataItemOrAccessor = shouldInheritData ? void 0 : dataItemOrAccessor;
2159
2291
  const isFunc = typeof realDataItemOrAccessor === "function" && !isObservable(realDataItemOrAccessor);
2160
2292
  self.ko = options_default.knockoutInstance;
2161
- let nodes;
2162
2293
  let subscribable2;
2163
2294
  function updateContext() {
2164
2295
  const dataItemOrObservable = isFunc ? realDataItemOrAccessor() : realDataItemOrAccessor;
@@ -2172,7 +2303,7 @@ function bindingContext(dataItemOrAccessor, parentContext, dataItemAlias, extend
2172
2303
  self[contextAncestorBindingInfo] = parentContext[contextAncestorBindingInfo];
2173
2304
  }
2174
2305
  } else {
2175
- self.$parents = [];
2306
+ self.$parents = new Array();
2176
2307
  self.$root = dataItem;
2177
2308
  }
2178
2309
  self[contextSubscribeSymbol] = subscribable2;
@@ -2202,7 +2333,7 @@ function bindingContext(dataItemOrAccessor, parentContext, dataItemAlias, extend
2202
2333
  self[contextSubscribeSymbol] = void 0;
2203
2334
  }
2204
2335
  }
2205
- }
2336
+ };
2206
2337
  Object.assign(bindingContext.prototype, {
2207
2338
  lookup(token, globals, node) {
2208
2339
  switch (token) {
@@ -2226,24 +2357,39 @@ Object.assign(bindingContext.prototype, {
2226
2357
  }
2227
2358
  throw new Error(`The variable "${token}" was not found on $data, $context, or globals.`);
2228
2359
  },
2360
+ // Extend the binding context hierarchy with a new view model object. If the parent context is watching
2361
+ // any observables, the new child context will automatically get a dependency on the parent context.
2362
+ // But this does not mean that the $data value of the child context will also get updated. If the child
2363
+ // view model also depends on the parent view model, you must provide a function that returns the correct
2364
+ // view model on each update.
2229
2365
  createChildContext(dataItemOrAccessor, dataItemAlias, extendCallback, settings) {
2230
- return new bindingContext(dataItemOrAccessor, this, dataItemAlias, function(self, parentContext) {
2231
- self.$parentContext = parentContext;
2232
- self.$parent = parentContext.$data;
2233
- self.$parents = (parentContext.$parents || []).slice(0);
2234
- self.$parents.unshift(self.$parent);
2235
- if (extendCallback) {
2236
- extendCallback(self);
2237
- }
2238
- }, settings);
2366
+ return new bindingContext(
2367
+ dataItemOrAccessor,
2368
+ this,
2369
+ dataItemAlias,
2370
+ function(self, parentContext) {
2371
+ var _a;
2372
+ self.$parentContext = parentContext;
2373
+ self.$parent = parentContext == null ? void 0 : parentContext.$data;
2374
+ self.$parents = ((_a = parentContext == null ? void 0 : parentContext.$parents) != null ? _a : []).slice(0);
2375
+ self.$parents.unshift(self.$parent);
2376
+ if (extendCallback) {
2377
+ extendCallback(self);
2378
+ }
2379
+ },
2380
+ settings
2381
+ );
2239
2382
  },
2383
+ // Extend the binding context with new custom properties. This doesn't change the context hierarchy.
2384
+ // Similarly to "child" contexts, provide a function here to make sure that the correct values are set
2385
+ // when an observable view model is updated.
2240
2386
  extend(properties) {
2241
- return new bindingContext(inheritParentIndicator, this, null, function(self, parentContext) {
2387
+ return new bindingContext(inheritParentIndicator, this, void 0, function(self, parentContext) {
2242
2388
  extend(self, typeof properties === "function" ? properties.call(self) : properties);
2243
2389
  });
2244
2390
  },
2245
2391
  createStaticChildContext(dataItemOrAccessor, dataItemAlias) {
2246
- return this.createChildContext(dataItemOrAccessor, dataItemAlias, null, { "exportDependencies": true });
2392
+ return this.createChildContext(dataItemOrAccessor, dataItemAlias, null, { exportDependencies: true });
2247
2393
  }
2248
2394
  });
2249
2395
  function storedBindingContextForNode(node) {
@@ -2251,24 +2397,22 @@ function storedBindingContextForNode(node) {
2251
2397
  return bindingInfo && bindingInfo.context;
2252
2398
  }
2253
2399
  function contextFor(node) {
2254
- if (node && (node.nodeType === 1 || node.nodeType === 8)) {
2400
+ if (node && (node.nodeType === Node.ELEMENT_NODE || node.nodeType === Node.COMMENT_NODE)) {
2255
2401
  return storedBindingContextForNode(node);
2256
2402
  }
2257
2403
  }
2258
2404
  function dataFor(node) {
2259
- var context = contextFor(node);
2405
+ const context = contextFor(node);
2260
2406
  return context ? context.$data : void 0;
2261
2407
  }
2262
2408
 
2263
2409
  // src/BindingResult.ts
2264
2410
  var BindingResult = class {
2265
2411
  constructor({ asyncBindingsApplied, rootNode, bindingContext: bindingContext2 }) {
2266
- Object.assign(this, {
2267
- rootNode,
2268
- bindingContext: bindingContext2,
2269
- isSync: asyncBindingsApplied.size === 0,
2270
- isComplete: this.isSync
2271
- });
2412
+ this.rootNode = rootNode;
2413
+ this.bindingContext = bindingContext2;
2414
+ this.isSync = asyncBindingsApplied.size === 0;
2415
+ this.isComplete = this.isSync;
2272
2416
  if (!this.isSync) {
2273
2417
  this.completionPromise = this.completeWhenBindingsFinish(asyncBindingsApplied);
2274
2418
  }
@@ -2285,11 +2429,18 @@ var BindingResult = class {
2285
2429
  // ../lifecycle/dist/LifeCycle.js
2286
2430
  var SUBSCRIPTIONS = createSymbolOrString("LifeCycle Subscriptions List");
2287
2431
  var ANCHOR_NODE = createSymbolOrString("LifeCycle Anchor Node");
2288
- var LifeCycle = class {
2432
+ var LifeCycle = class _LifeCycle {
2433
+ // NOTE: For more advanced integration as an ES6 mixin, see e.g.:
2434
+ // http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/
2435
+ /**
2436
+ * Copy the properties of the LifeCycle class to the target (or its prototype)
2437
+ *
2438
+ * NOTE: getOwnPropertyNames is needed to copy the non-enumerable properties.
2439
+ */
2289
2440
  static mixInto(Constructor) {
2290
2441
  const target = Constructor.prototype || Constructor;
2291
- const mixin = LifeCycle.prototype;
2292
- for (let prop of Object.getOwnPropertyNames(mixin)) {
2442
+ const mixin = _LifeCycle.prototype;
2443
+ for (const prop of Object.getOwnPropertyNames(mixin)) {
2293
2444
  target[prop] = mixin[prop];
2294
2445
  }
2295
2446
  }
@@ -2317,6 +2468,13 @@ var LifeCycle = class {
2317
2468
  params.disposeWhenNodeIsRemoved = this[ANCHOR_NODE];
2318
2469
  return this.addDisposable(computed(params));
2319
2470
  }
2471
+ /**
2472
+ * Add an event listener for the given or anchored node.
2473
+ * @param {node} [node] (optional) The target node (otherwise the anchored node)
2474
+ * @param {string} [type] Event type
2475
+ * @param {function|string} [action] Either call the given function or `this[action]`
2476
+ * @param {object} [options] (optional) Passed as `options` to `node.addEventListener`
2477
+ */
2320
2478
  addEventListener(...args) {
2321
2479
  const node = args[0].nodeType ? args.shift() : this[ANCHOR_NODE];
2322
2480
  const [type, act, options2] = args;
@@ -2343,7 +2501,7 @@ var LifeCycle = class {
2343
2501
  dispose() {
2344
2502
  const subscriptions = this[SUBSCRIPTIONS] || [];
2345
2503
  subscriptions.forEach((s) => s.dispose());
2346
- this[SUBSCRIPTIONS] = [];
2504
+ this[SUBSCRIPTIONS] = new Array();
2347
2505
  this[ANCHOR_NODE] = null;
2348
2506
  }
2349
2507
  addDisposable(subscription) {
@@ -2364,13 +2522,11 @@ var BindingHandler = class extends LifeCycle {
2364
2522
  constructor(params) {
2365
2523
  super();
2366
2524
  const { $element, valueAccessor, allBindings, $context } = params;
2367
- Object.assign(this, {
2368
- valueAccessor,
2369
- allBindings,
2370
- $element,
2371
- $context,
2372
- $data: $context.$data
2373
- });
2525
+ this.$element = $element;
2526
+ this.valueAccessor = valueAccessor;
2527
+ this.allBindings = allBindings;
2528
+ this.$context = $context;
2529
+ this.$data = $context.$data;
2374
2530
  this.anchorTo($element);
2375
2531
  }
2376
2532
  get value() {
@@ -2393,14 +2549,23 @@ var BindingHandler = class extends LifeCycle {
2393
2549
  static get isBindingHandlerClass() {
2394
2550
  return true;
2395
2551
  }
2552
+ /* Overload this for asynchronous bindings or bindings that recursively
2553
+ apply bindings (e.g. components, foreach, template).
2554
+
2555
+ A binding should be complete when it has run through once, notably
2556
+ in server-side bindings for pre-rendering.
2557
+ */
2396
2558
  get bindingCompleted() {
2397
2559
  return true;
2398
2560
  }
2399
2561
  static registerAs(name, provider = options_default.bindingProviderInstance) {
2400
2562
  provider.bindingHandlers.set(name, this);
2401
2563
  }
2564
+ static registerBindingHandler(handler, name, provider = options_default.bindingProviderInstance) {
2565
+ provider.bindingHandlers.set(name, handler);
2566
+ }
2402
2567
  };
2403
- var ResolveSymbol = Symbol("Async Binding Resolved");
2568
+ var ResolveSymbol = /* @__PURE__ */ Symbol("Async Binding Resolved");
2404
2569
  var AsyncBindingHandler = class extends BindingHandler {
2405
2570
  constructor(params) {
2406
2571
  super(params);
@@ -2417,7 +2582,10 @@ var AsyncBindingHandler = class extends BindingHandler {
2417
2582
  // src/LegacyBindingHandler.ts
2418
2583
  var PossibleWeakMap = options_default.global.WeakMap || Map;
2419
2584
  var legacyBindingMap = new PossibleWeakMap();
2420
- var LegacyBindingHandler = class extends BindingHandler {
2585
+ var LegacyBindingHandler = class _LegacyBindingHandler extends BindingHandler {
2586
+ get handler() {
2587
+ return void 0;
2588
+ }
2421
2589
  constructor(params) {
2422
2590
  super(params);
2423
2591
  const handler = this.handler;
@@ -2443,18 +2611,21 @@ var LegacyBindingHandler = class extends BindingHandler {
2443
2611
  }
2444
2612
  }
2445
2613
  get legacyArgs() {
2446
- return [
2447
- this.$element,
2448
- this.valueAccessor,
2449
- this.allBindings,
2450
- this.$data,
2451
- this.$context
2452
- ];
2614
+ return [this.$element, this.valueAccessor, this.allBindings, this.$data, this.$context];
2453
2615
  }
2454
2616
  get controlsDescendants() {
2455
2617
  const objectToTest = this.initReturn || this.handler || {};
2456
2618
  return objectToTest.controlsDescendantBindings;
2457
2619
  }
2620
+ /**
2621
+ * Create a handler instance from the `origin`, which may be:
2622
+ *
2623
+ * 1. an object (becomes LegacyBindingHandler)
2624
+ * 2. a function (becomes LegacyBindingHandler with `init: function`)
2625
+ *
2626
+ * If given an object (the only kind supported in knockout 3.x and before), it
2627
+ * shall draw the `init`, `update`, and `allowVirtualElements` properties
2628
+ */
2458
2629
  static getOrCreateFor(key, handler) {
2459
2630
  if (legacyBindingMap.has(handler)) {
2460
2631
  return legacyBindingMap.get(handler);
@@ -2466,7 +2637,7 @@ var LegacyBindingHandler = class extends BindingHandler {
2466
2637
  static createFor(key, handler) {
2467
2638
  if (typeof handler === "function") {
2468
2639
  const [initFn, disposeFn] = [handler, handler.dispose];
2469
- return class extends LegacyBindingHandler {
2640
+ return class extends _LegacyBindingHandler {
2470
2641
  get handler() {
2471
2642
  const init = initFn.bind(this);
2472
2643
  const dispose = disposeFn ? disposeFn.bind(this) : null;
@@ -2481,7 +2652,7 @@ var LegacyBindingHandler = class extends BindingHandler {
2481
2652
  };
2482
2653
  }
2483
2654
  if (typeof handler === "object") {
2484
- return class extends LegacyBindingHandler {
2655
+ return class extends _LegacyBindingHandler {
2485
2656
  get handler() {
2486
2657
  return handler;
2487
2658
  }
@@ -2499,15 +2670,20 @@ var LegacyBindingHandler = class extends BindingHandler {
2499
2670
 
2500
2671
  // src/applyBindings.ts
2501
2672
  var bindingDoesNotRecurseIntoElementTypes = {
2502
- "script": true,
2503
- "textarea": true,
2504
- "template": true
2673
+ // Don't want bindings that operate on text nodes to mutate <script> and <textarea> contents,
2674
+ // because it's unexpected and a potential XSS issue.
2675
+ // Also bindings should not operate on <template> elements since this breaks in Internet Explorer
2676
+ // and because such elements' contents are always intended to be bound in a different context
2677
+ // from where they appear in the document.
2678
+ script: true,
2679
+ textarea: true,
2680
+ template: true
2505
2681
  };
2506
2682
  function getBindingProvider() {
2507
2683
  return options_default.bindingProviderInstance.instance || options_default.bindingProviderInstance;
2508
2684
  }
2509
2685
  function isProviderForNode(provider, node) {
2510
- const nodeTypes = provider.FOR_NODE_TYPES || [1, 3, 8];
2686
+ const nodeTypes = provider.FOR_NODE_TYPES || [Node.ELEMENT_NODE, Node.TEXT_NODE, Node.COMMENT_NODE];
2511
2687
  return nodeTypes.includes(node.nodeType);
2512
2688
  }
2513
2689
  function asProperHandlerClass(handler, bindingKey) {
@@ -2558,11 +2734,11 @@ function nodeOrChildHasBindings(node) {
2558
2734
  return hasBindings(node) || [...node.childNodes].some((c) => nodeOrChildHasBindings(c));
2559
2735
  }
2560
2736
  function applyBindingsToNodeAndDescendantsInternal(bindingContext2, nodeVerified, asyncBindingsApplied) {
2561
- var isElement = nodeVerified.nodeType === 1;
2737
+ const isElement = nodeVerified.nodeType === Node.ELEMENT_NODE;
2562
2738
  if (isElement) {
2563
2739
  virtualElements_exports.normaliseVirtualElementDomStructure(nodeVerified);
2564
2740
  }
2565
- let shouldApplyBindings = isElement || hasBindings(nodeVerified);
2741
+ const shouldApplyBindings = isElement || hasBindings(nodeVerified);
2566
2742
  const { shouldBindDescendants } = shouldApplyBindings ? applyBindingsToNodeInternal(nodeVerified, null, bindingContext2, asyncBindingsApplied) : { shouldBindDescendants: true };
2567
2743
  if (shouldBindDescendants && !bindingDoesNotRecurseIntoElementTypes[tagNameLower(nodeVerified)]) {
2568
2744
  applyBindingsToDescendantsInternal(bindingContext2, nodeVerified, asyncBindingsApplied);
@@ -2571,7 +2747,7 @@ function applyBindingsToNodeAndDescendantsInternal(bindingContext2, nodeVerified
2571
2747
  function* topologicalSortBindings(bindings, $component) {
2572
2748
  const results = [];
2573
2749
  const bindingsConsidered = {};
2574
- const cyclicDependencyStack = [];
2750
+ const cyclicDependencyStack = new Array();
2575
2751
  objectForEach(bindings, function pushBinding(bindingKey) {
2576
2752
  if (!bindingsConsidered[bindingKey]) {
2577
2753
  const binding = getBindingHandlerFromComponent(bindingKey, $component) || getBindingHandler(bindingKey);
@@ -2585,7 +2761,9 @@ function* topologicalSortBindings(bindings, $component) {
2585
2761
  return;
2586
2762
  }
2587
2763
  if (arrayIndexOf(cyclicDependencyStack, bindingDependencyKey) !== -1) {
2588
- throw Error("Cannot combine the following bindings, because they have a cyclic dependency: " + cyclicDependencyStack.join(", "));
2764
+ throw Error(
2765
+ "Cannot combine the following bindings, because they have a cyclic dependency: " + cyclicDependencyStack.join(", ")
2766
+ );
2589
2767
  } else {
2590
2768
  pushBinding(bindingDependencyKey);
2591
2769
  }
@@ -2621,30 +2799,32 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext2, asyn
2621
2799
  if (!alreadyBound) {
2622
2800
  bindingInfo.context = bindingContext2;
2623
2801
  }
2624
- var bindings;
2802
+ let bindings = null;
2803
+ let bindingsUpdater = null;
2625
2804
  if (sourceBindings && typeof sourceBindings !== "function") {
2626
2805
  bindings = sourceBindings;
2627
2806
  } else {
2628
2807
  const provider = getBindingProvider();
2629
2808
  const getBindings = provider.getBindingAccessors;
2630
2809
  if (isProviderForNode(provider, node)) {
2631
- var bindingsUpdater = computed(function() {
2632
- bindings = sourceBindings ? sourceBindings(bindingContext2, node) : getBindings.call(provider, node, bindingContext2);
2633
- if (bindings && bindingContext2[contextSubscribeSymbol]) {
2634
- bindingContext2[contextSubscribeSymbol]();
2635
- }
2636
- return bindings;
2637
- }, null, { disposeWhenNodeIsRemoved: node });
2810
+ bindingsUpdater = computed(
2811
+ function() {
2812
+ bindings = sourceBindings ? sourceBindings(bindingContext2, node) : getBindings.call(provider, node, bindingContext2);
2813
+ if (bindings && bindingContext2[contextSubscribeSymbol]) {
2814
+ bindingContext2[contextSubscribeSymbol]();
2815
+ }
2816
+ return bindings;
2817
+ },
2818
+ null,
2819
+ { disposeWhenNodeIsRemoved: node }
2820
+ );
2638
2821
  if (!bindings || !bindingsUpdater.isActive()) {
2639
2822
  bindingsUpdater = null;
2640
2823
  }
2641
2824
  }
2642
2825
  }
2643
- var bindingHandlerThatControlsDescendantBindings;
2826
+ let bindingHandlerThatControlsDescendantBindings;
2644
2827
  if (bindings) {
2645
- let allBindings = function() {
2646
- return objectMap(bindingsUpdater ? bindingsUpdater() : bindings, evaluateValueAccessor);
2647
- };
2648
2828
  const $component = bindingContext2.$component || {};
2649
2829
  const allBindingHandlers = {};
2650
2830
  data_exports.set(node, "bindingHandlers", allBindingHandlers);
@@ -2656,24 +2836,32 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext2, asyn
2656
2836
  return valueAccessor(optionalValue);
2657
2837
  }
2658
2838
  } : (bindingKey) => bindings[bindingKey];
2839
+ const allBindings = function() {
2840
+ return objectMap(bindingsUpdater ? bindingsUpdater() : bindings, evaluateValueAccessor);
2841
+ };
2659
2842
  allBindings.has = (key) => key in bindings;
2660
2843
  allBindings.get = (key) => bindings[key] && evaluateValueAccessor(getValueAccessor(key));
2661
2844
  if (bindingEvent.childrenComplete in bindings) {
2662
- bindingEvent.subscribe(node, bindingEvent.childrenComplete, () => {
2663
- const callback = evaluateValueAccessor(bindings[bindingEvent.childrenComplete]);
2664
- if (!callback) {
2665
- return;
2666
- }
2667
- const nodes = virtualElements_exports.childNodes(node);
2668
- if (nodes.length) {
2669
- callback(nodes, dataFor(nodes[0]));
2670
- }
2671
- });
2845
+ bindingEvent.subscribe(
2846
+ node,
2847
+ bindingEvent.childrenComplete,
2848
+ () => {
2849
+ const callback = evaluateValueAccessor(bindings[bindingEvent.childrenComplete]);
2850
+ if (!callback) {
2851
+ return;
2852
+ }
2853
+ const nodes = virtualElements_exports.childNodes(node);
2854
+ if (nodes.length) {
2855
+ callback(nodes, dataFor(nodes[0]));
2856
+ }
2857
+ },
2858
+ null
2859
+ );
2672
2860
  }
2673
2861
  const bindingsGenerated = topologicalSortBindings(bindings, $component);
2674
2862
  const nodeAsyncBindingPromises = /* @__PURE__ */ new Set();
2675
2863
  for (const [key, BindingHandlerClass] of bindingsGenerated) {
2676
- let reportBindingError = function(during, errorCaptured) {
2864
+ const reportBindingError = function(during, errorCaptured) {
2677
2865
  onBindingError({
2678
2866
  during,
2679
2867
  errorCaptured,
@@ -2685,26 +2873,30 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext2, asyn
2685
2873
  valueAccessor: getValueAccessor(key)
2686
2874
  });
2687
2875
  };
2688
- if (node.nodeType === 8 && !BindingHandlerClass.allowVirtualElements) {
2876
+ if (node.nodeType === Node.COMMENT_NODE && !BindingHandlerClass.allowVirtualElements) {
2689
2877
  throw new Error(`The binding '${key}' cannot be used with virtual elements`);
2690
2878
  }
2691
2879
  try {
2692
- const bindingHandler = dependencyDetection_exports.ignore(() => new BindingHandlerClass({
2693
- allBindings,
2694
- $element: node,
2695
- $context: bindingContext2,
2696
- onError: reportBindingError,
2697
- valueAccessor(...v) {
2698
- return getValueAccessor(key)(...v);
2699
- }
2700
- }));
2880
+ const bindingHandler = dependencyDetection_exports.ignore(
2881
+ () => new BindingHandlerClass({
2882
+ allBindings,
2883
+ $element: node,
2884
+ $context: bindingContext2,
2885
+ onError: reportBindingError,
2886
+ valueAccessor(...v) {
2887
+ return getValueAccessor(key)(...v);
2888
+ }
2889
+ })
2890
+ );
2701
2891
  if (bindingHandler.onValueChange) {
2702
2892
  dependencyDetection_exports.ignore(() => bindingHandler.computed("onValueChange"));
2703
2893
  }
2704
2894
  allBindingHandlers[key] = bindingHandler;
2705
2895
  if (bindingHandler.controlsDescendants) {
2706
2896
  if (bindingHandlerThatControlsDescendantBindings !== void 0) {
2707
- 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.");
2897
+ throw new Error(
2898
+ "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."
2899
+ );
2708
2900
  }
2709
2901
  bindingHandlerThatControlsDescendantBindings = key;
2710
2902
  }
@@ -2713,7 +2905,8 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext2, asyn
2713
2905
  nodeAsyncBindingPromises.add(bindingHandler.bindingCompleted);
2714
2906
  }
2715
2907
  } catch (err) {
2716
- reportBindingError("creation", err);
2908
+ const error = err instanceof Error ? err : new Error(String(err));
2909
+ reportBindingError("creation", error);
2717
2910
  }
2718
2911
  }
2719
2912
  triggerDescendantsComplete(node, bindings, nodeAsyncBindingPromises);
@@ -2741,10 +2934,15 @@ function getBindingContext(viewModelOrBindingContext, extendContextCallback) {
2741
2934
  return viewModelOrBindingContext && viewModelOrBindingContext instanceof bindingContext ? viewModelOrBindingContext : new bindingContext(viewModelOrBindingContext, void 0, void 0, extendContextCallback);
2742
2935
  }
2743
2936
  function applyBindingAccessorsToNode(node, bindings, viewModelOrBindingContext, asyncBindingsApplied) {
2744
- if (node.nodeType === 1) {
2937
+ if (node.nodeType === Node.ELEMENT_NODE) {
2745
2938
  virtualElements_exports.normaliseVirtualElementDomStructure(node);
2746
2939
  }
2747
- return applyBindingsToNodeInternal(node, bindings, getBindingContext(viewModelOrBindingContext), asyncBindingsApplied);
2940
+ return applyBindingsToNodeInternal(
2941
+ node,
2942
+ bindings,
2943
+ getBindingContext(viewModelOrBindingContext),
2944
+ asyncBindingsApplied
2945
+ );
2748
2946
  }
2749
2947
  function applyBindingsToNode(node, bindings, viewModelOrBindingContext) {
2750
2948
  const asyncBindingsApplied = /* @__PURE__ */ new Set();
@@ -2755,24 +2953,21 @@ function applyBindingsToNode(node, bindings, viewModelOrBindingContext) {
2755
2953
  }
2756
2954
  function applyBindingsToDescendants(viewModelOrBindingContext, rootNode) {
2757
2955
  const asyncBindingsApplied = /* @__PURE__ */ new Set();
2758
- if (rootNode.nodeType === 1 || rootNode.nodeType === 8) {
2759
- const bindingContext2 = getBindingContext(viewModelOrBindingContext);
2956
+ const bindingContext2 = getBindingContext(viewModelOrBindingContext);
2957
+ if (rootNode.nodeType === Node.ELEMENT_NODE || rootNode.nodeType === Node.COMMENT_NODE) {
2760
2958
  applyBindingsToDescendantsInternal(bindingContext2, rootNode, asyncBindingsApplied);
2761
2959
  return new BindingResult({ asyncBindingsApplied, rootNode, bindingContext: bindingContext2 });
2762
2960
  }
2763
- return new BindingResult({ asyncBindingsApplied, rootNode });
2961
+ return new BindingResult({ asyncBindingsApplied, rootNode, bindingContext: bindingContext2 });
2764
2962
  }
2765
2963
  function applyBindings(viewModelOrBindingContext, rootNode, extendContextCallback) {
2766
2964
  const asyncBindingsApplied = /* @__PURE__ */ new Set();
2767
- if (!options_default.jQuery === void 0 && options_default.jQuery) {
2768
- options_default.jQuery = options_default.jQuery;
2769
- }
2770
2965
  if (!rootNode) {
2771
2966
  rootNode = window.document.body;
2772
2967
  if (!rootNode) {
2773
2968
  throw Error("ko.applyBindings: could not find window.document.body; has the document been loaded?");
2774
2969
  }
2775
- } else if (rootNode.nodeType !== 1 && rootNode.nodeType !== 8) {
2970
+ } else if (rootNode.nodeType !== Node.ELEMENT_NODE && rootNode.nodeType !== Node.COMMENT_NODE) {
2776
2971
  throw Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node");
2777
2972
  }
2778
2973
  const rootContext = getBindingContext(viewModelOrBindingContext, extendContextCallback);
@@ -2780,7 +2975,7 @@ function applyBindings(viewModelOrBindingContext, rootNode, extendContextCallbac
2780
2975
  return Promise.all(asyncBindingsApplied);
2781
2976
  }
2782
2977
  function onBindingError(spec) {
2783
- var error, bindingText;
2978
+ let error;
2784
2979
  if (spec.bindingKey) {
2785
2980
  error = spec.errorCaptured;
2786
2981
  spec.message = 'Unable to process binding "' + spec.bindingKey + '" in binding "' + spec.bindingKey + '"\nMessage: ' + (error.message ? error.message : error);
@@ -2791,7 +2986,12 @@ function onBindingError(spec) {
2791
2986
  extend(error, spec);
2792
2987
  } catch (e) {
2793
2988
  spec.stack = error.stack;
2794
- error = new Error(error.message ? error.message : error);
2989
+ const message = error.message || String(error);
2990
+ const originalName = error.name;
2991
+ error = new Error(message);
2992
+ if (originalName && originalName !== "Error") {
2993
+ error.name = originalName;
2994
+ }
2795
2995
  extend(error, spec);
2796
2996
  }
2797
2997
  options_default.onError(error);
@@ -2799,21 +2999,31 @@ function onBindingError(spec) {
2799
2999
 
2800
3000
  // src/arrayToDomNodeChildren.ts
2801
3001
  function mapNodeAndRefreshWhenChanged(containerNode, mapping, valueToMap, callbackAfterAddingNodes, index) {
2802
- var mappedNodes = [];
2803
- var dependentObservable = computed(function() {
2804
- var newMappedNodes = mapping(valueToMap, index, fixUpContinuousNodeArray(mappedNodes, containerNode)) || [];
2805
- if (mappedNodes.length > 0) {
2806
- replaceDomNodes(mappedNodes, newMappedNodes);
2807
- if (callbackAfterAddingNodes) {
2808
- dependencyDetection_exports.ignore(callbackAfterAddingNodes, null, [valueToMap, newMappedNodes, index]);
2809
- }
2810
- }
2811
- mappedNodes.length = 0;
2812
- arrayPushAll(mappedNodes, newMappedNodes);
2813
- }, null, { disposeWhenNodeIsRemoved: containerNode, disposeWhen: function() {
2814
- return !anyDomNodeIsAttachedToDocument(mappedNodes);
2815
- } });
2816
- return { mappedNodes, dependentObservable: dependentObservable.isActive() ? dependentObservable : void 0 };
3002
+ const mappedNodes = [];
3003
+ const dependentObservable = computed(
3004
+ function() {
3005
+ const newMappedNodes = mapping(valueToMap, index, fixUpContinuousNodeArray(mappedNodes, containerNode)) || [];
3006
+ if (mappedNodes.length > 0) {
3007
+ replaceDomNodes(mappedNodes, newMappedNodes);
3008
+ if (callbackAfterAddingNodes) {
3009
+ dependencyDetection_exports.ignore(callbackAfterAddingNodes, null, [valueToMap, newMappedNodes, index]);
3010
+ }
3011
+ }
3012
+ mappedNodes.length = 0;
3013
+ arrayPushAll(mappedNodes, newMappedNodes);
3014
+ },
3015
+ null,
3016
+ {
3017
+ disposeWhenNodeIsRemoved: containerNode,
3018
+ disposeWhen: function() {
3019
+ return !anyDomNodeIsAttachedToDocument(mappedNodes);
3020
+ }
3021
+ }
3022
+ );
3023
+ return {
3024
+ mappedNodes,
3025
+ dependentObservable: dependentObservable.isActive() ? dependentObservable : void 0
3026
+ };
2817
3027
  }
2818
3028
  var lastMappingResultDomDataKey = data_exports.nextKey();
2819
3029
  var deletedItemDummyValue = data_exports.nextKey();
@@ -2823,17 +3033,17 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options2, c
2823
3033
  array = [array];
2824
3034
  }
2825
3035
  options2 = options2 || {};
2826
- let lastMappingResult = data_exports.get(domNode, lastMappingResultDomDataKey);
2827
- let isFirstExecution = !lastMappingResult;
2828
- var newMappingResult = [];
2829
- var lastMappingResultIndex = 0;
2830
- var newMappingResultIndex = 0;
2831
- var nodesToDelete = [];
2832
- var itemsToProcess = [];
2833
- var itemsForBeforeRemoveCallbacks = [];
2834
- var itemsForMoveCallbacks = [];
2835
- var itemsForAfterAddCallbacks = [];
2836
- var mapData;
3036
+ const lastMappingResult = data_exports.get(domNode, lastMappingResultDomDataKey);
3037
+ const isFirstExecution = !lastMappingResult;
3038
+ const newMappingResult = new Array();
3039
+ let lastMappingResultIndex = 0;
3040
+ let newMappingResultIndex = 0;
3041
+ const nodesToDelete = [];
3042
+ const itemsToProcess = [];
3043
+ const itemsForBeforeRemoveCallbacks = [];
3044
+ const itemsForMoveCallbacks = [];
3045
+ const itemsForAfterAddCallbacks = [];
3046
+ let mapData;
2837
3047
  let countWaitingForRemove = 0;
2838
3048
  function itemAdded(value) {
2839
3049
  mapData = { arrayEntry: value, indexObservable: observable(newMappingResultIndex++) };
@@ -2855,9 +3065,9 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options2, c
2855
3065
  }
2856
3066
  function callCallback(callback, items) {
2857
3067
  if (callback) {
2858
- for (var i2 = 0, n = items.length; i2 < n; i2++) {
2859
- arrayForEach(items[i2].mappedNodes, function(node2) {
2860
- callback(node2, i2, items[i2].arrayEntry);
3068
+ for (let i = 0, n = items.length; i < n; i++) {
3069
+ arrayForEach(items[i].mappedNodes, function(node) {
3070
+ callback(node, i, items[i].arrayEntry);
2861
3071
  });
2862
3072
  }
2863
3073
  }
@@ -2866,16 +3076,13 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options2, c
2866
3076
  arrayForEach(array, itemAdded);
2867
3077
  } else {
2868
3078
  if (!editScript || lastMappingResult && lastMappingResult["_countWaitingForRemove"]) {
2869
- var lastArray = isFirstExecution ? [] : arrayMap(lastMappingResult, function(x) {
3079
+ const lastArray = arrayMap(lastMappingResult, function(x) {
2870
3080
  return x.arrayEntry;
2871
3081
  });
2872
- var compareOptions = {
2873
- "dontLimitMoves": options2["dontLimitMoves"],
2874
- "sparse": true
2875
- };
3082
+ const compareOptions = { dontLimitMoves: options2.dontLimitMoves, sparse: true };
2876
3083
  editScript = compareArrays(lastArray, array, compareOptions);
2877
3084
  }
2878
- for (var i = 0, editScriptItem, movedIndex, itemIndex; editScriptItem = editScript[i]; i++) {
3085
+ for (let i = 0, editScriptItem, movedIndex, itemIndex; editScriptItem = editScript[i]; i++) {
2879
3086
  movedIndex = editScriptItem["moved"];
2880
3087
  itemIndex = editScriptItem["index"];
2881
3088
  switch (editScriptItem["status"]) {
@@ -2890,7 +3097,7 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options2, c
2890
3097
  mapData.dependentObservable = void 0;
2891
3098
  }
2892
3099
  if (fixUpContinuousNodeArray(mapData.mappedNodes, domNode).length) {
2893
- if (options2["beforeRemove"]) {
3100
+ if (options2.beforeRemove) {
2894
3101
  newMappingResult.push(mapData);
2895
3102
  itemsToProcess.push(mapData);
2896
3103
  countWaitingForRemove++;
@@ -2900,7 +3107,7 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options2, c
2900
3107
  itemsForBeforeRemoveCallbacks.push(mapData);
2901
3108
  }
2902
3109
  }
2903
- if (mapData) {
3110
+ if (mapData == null ? void 0 : mapData.mappedNodes) {
2904
3111
  nodesToDelete.push.apply(nodesToDelete, mapData.mappedNodes);
2905
3112
  }
2906
3113
  }
@@ -2925,14 +3132,22 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options2, c
2925
3132
  newMappingResult["_countWaitingForRemove"] = countWaitingForRemove;
2926
3133
  }
2927
3134
  data_exports.set(domNode, lastMappingResultDomDataKey, newMappingResult);
2928
- callCallback(options2["beforeMove"], itemsForMoveCallbacks);
2929
- arrayForEach(nodesToDelete, options2["beforeRemove"] ? cleanNode : removeNode);
2930
- i = 0;
2931
- for (var nextNode = virtualElements_exports.firstChild(domNode), lastNode, node; mapData = itemsToProcess[i]; i++) {
3135
+ callCallback(options2.beforeMove, itemsForMoveCallbacks);
3136
+ arrayForEach(nodesToDelete, options2.beforeRemove ? cleanNode : removeNode);
3137
+ for (let k = 0, nextNode = virtualElements_exports.firstChild(domNode), lastNode, node; mapData = itemsToProcess[k]; k++) {
2932
3138
  if (!mapData.mappedNodes) {
2933
- extend(mapData, mapNodeAndRefreshWhenChanged(domNode, mapping, mapData.arrayEntry, callbackAfterAddingNodes, mapData.indexObservable));
2934
- }
2935
- for (var j = 0; node = mapData.mappedNodes[j]; nextNode = node.nextSibling, lastNode = node, j++) {
3139
+ extend(
3140
+ mapData,
3141
+ mapNodeAndRefreshWhenChanged(
3142
+ domNode,
3143
+ mapping,
3144
+ mapData.arrayEntry,
3145
+ callbackAfterAddingNodes,
3146
+ mapData.indexObservable
3147
+ )
3148
+ );
3149
+ }
3150
+ for (let j = 0; node = mapData.mappedNodes[j]; nextNode = node.nextSibling, lastNode = node, j++) {
2936
3151
  if (node !== nextNode) {
2937
3152
  virtualElements_exports.insertAfter(domNode, node, lastNode);
2938
3153
  }
@@ -2942,12 +3157,12 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options2, c
2942
3157
  mapData.initialized = true;
2943
3158
  }
2944
3159
  }
2945
- callCallback(options2["beforeRemove"], itemsForBeforeRemoveCallbacks);
2946
- for (i = 0; i < itemsForBeforeRemoveCallbacks.length; ++i) {
2947
- itemsForBeforeRemoveCallbacks[i].arrayEntry = deletedItemDummyValue;
3160
+ callCallback(options2.beforeRemove, itemsForBeforeRemoveCallbacks);
3161
+ for (let x = 0; x < itemsForBeforeRemoveCallbacks.length; ++x) {
3162
+ itemsForBeforeRemoveCallbacks[x].arrayEntry = deletedItemDummyValue;
2948
3163
  }
2949
- callCallback(options2["afterMove"], itemsForMoveCallbacks);
2950
- callCallback(options2["afterAdd"], itemsForAfterAddCallbacks);
3164
+ callCallback(options2.afterMove, itemsForMoveCallbacks);
3165
+ callCallback(options2.afterAdd, itemsForAfterAddCallbacks);
2951
3166
  }
2952
3167
 
2953
3168
  // src/DescendantBindingHandler.ts