More Optional chaining in Knockout.js

This commit is contained in:
the-djmaze 2022-09-13 22:00:31 +02:00
parent d18f93d87f
commit a566f6ed5a
10 changed files with 391 additions and 476 deletions

View file

@ -299,9 +299,8 @@ class koSubscription
dispose() {
var self = this;
if (!self._isDisposed) {
if (self._domNodeDisposalCallback) {
ko.utils.domNodeDisposal.removeDisposeCallback(self._node, self._domNodeDisposalCallback);
}
self._domNodeDisposalCallback
&& ko.utils.domNodeDisposal.removeDisposeCallback(self._node, self._domNodeDisposalCallback);
self._isDisposed = true;
self._disposeCallback();
@ -338,15 +337,12 @@ var ko_subscribable_fn = {
var subscription = new koSubscription(self, boundCallback, () => {
self._subscriptions.get(event).delete(subscription);
if (self.afterSubscriptionRemove)
self.afterSubscriptionRemove(event);
self.afterSubscriptionRemove?.(event);
});
if (self.beforeSubscriptionAdd)
self.beforeSubscriptionAdd(event);
self.beforeSubscriptionAdd?.(event);
if (!self._subscriptions.has(event))
self._subscriptions.set(event, new Set);
self._subscriptions.has(event) || self._subscriptions.set(event, new Set);
self._subscriptions.get(event).add(subscription);
return subscription;
@ -392,13 +388,13 @@ var ko_subscribable_fn = {
if (!self._origNotifySubscribers) {
self._origNotifySubscribers = self.notifySubscribers;
// Moved out of "limit" to avoid the extra closure
self.notifySubscribers = function(value, event) {
self.notifySubscribers = (value, event) => {
if (!event || event === defaultEvent) {
this._limitChange(value);
} else if (event === 'beforeChange') {
this._limitBeforeChange(value);
self._limitChange(value);
} else if (event === beforeChange) {
self._limitBeforeChange(value);
} else {
this._origNotifySubscribers(value, event);
self._origNotifySubscribers(value, event);
}
}
}
@ -701,25 +697,17 @@ ko.extenders['trackArrayChanges'] = (target, options) => {
// Watch "subscribe" calls, and for array change events, ensure change tracking is enabled
target.beforeSubscriptionAdd = event => {
if (underlyingBeforeSubscriptionAddFunction) {
underlyingBeforeSubscriptionAddFunction.call(target, event);
}
underlyingBeforeSubscriptionAddFunction?.call(target, event);
if (event === arrayChangeEventName) {
trackChanges();
}
};
// Watch "dispose" calls, and for array change events, ensure change tracking is disabled when all are disposed
target.afterSubscriptionRemove = event => {
if (underlyingAfterSubscriptionRemoveFunction) {
underlyingAfterSubscriptionRemoveFunction.call(target, event);
}
underlyingAfterSubscriptionRemoveFunction?.call(target, event);
if (event === arrayChangeEventName && !target.hasSubscriptionsForEvent(arrayChangeEventName)) {
if (changeSubscription) {
changeSubscription.dispose();
}
if (spectateSubscription) {
spectateSubscription.dispose();
}
changeSubscription?.dispose();
spectateSubscription?.dispose();
spectateSubscription = changeSubscription = null;
trackingChanges = false;
previousContents = undefined;
@ -727,23 +715,6 @@ ko.extenders['trackArrayChanges'] = (target, options) => {
};
function trackChanges() {
if (trackingChanges) {
// Whenever there's a new subscription and there are pending notifications, make sure all previous
// subscriptions are notified of the change so that all subscriptions are in sync.
notifyChanges();
return;
}
trackingChanges = true;
// Track how many times the array actually changed value
spectateSubscription = target.subscribe(() => ++pendingChanges, null, "spectate");
// Each time the array changes value, capture a clone so that on the next
// change it's possible to produce a diff
previousContents = [].concat(target.peek() || []);
cachedDiff = null;
changeSubscription = target.subscribe(notifyChanges);
function notifyChanges() {
if (pendingChanges) {
@ -765,6 +736,24 @@ ko.extenders['trackArrayChanges'] = (target, options) => {
}
}
}
if (trackingChanges) {
// Whenever there's a new subscription and there are pending notifications, make sure all previous
// subscriptions are notified of the change so that all subscriptions are in sync.
notifyChanges();
return;
}
trackingChanges = true;
// Track how many times the array actually changed value
spectateSubscription = target.subscribe(() => ++pendingChanges, null, "spectate");
// Each time the array changes value, capture a clone so that on the next
// change it's possible to produce a diff
previousContents = [].concat(target.peek() || []);
cachedDiff = null;
changeSubscription = target.subscribe(notifyChanges);
}
function getChanges(previousContents, currentContents) {
@ -805,20 +794,19 @@ ko.extenders['trackArrayChanges'] = (target, options) => {
case 'pop':
offset = arrayLength - 1;
case 'shift':
if (arrayLength) {
pushDiff('deleted', rawArray[offset], offset);
}
arrayLength && pushDiff('deleted', rawArray[offset], offset);
break;
case 'splice':
// Negative start index means 'from end of array'. After that we clamp to [0...arrayLength].
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
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,
var index = Math.min(Math.max(0, args[0] < 0 ? arrayLength + args[0] : args[0]), arrayLength),
endDeleteIndex = argsLength === 1 ? arrayLength : Math.min(index + (args[1] || 0), arrayLength),
endAddIndex = index + argsLength - 2,
endIndex = Math.max(endDeleteIndex, endAddIndex),
additions = [], deletions = [];
for (let index = startIndex, argsIndex = 2; index < endIndex; ++index, ++argsIndex) {
additions = [], deletions = [],
argsIndex = 2;
for (; index < endIndex; ++index, ++argsIndex) {
if (index < endDeleteIndex)
deletions.push(pushDiff('deleted', rawArray[index], index));
if (index < endAddIndex)
@ -898,8 +886,6 @@ ko.computed = (evaluatorFunctionOrOptions, options) => {
state.pure = true;
state.isSleeping = true; // Starts off sleeping; will awake on the first subscription
ko.utils.extend(computedObservable, pureComputedOverrides);
} else if (options['deferEvaluation']) {
ko.utils.extend(computedObservable, deferEvaluationOverrides);
}
if (state.disposeWhenNodeIsRemoved) {
@ -917,10 +903,8 @@ ko.computed = (evaluatorFunctionOrOptions, options) => {
}
}
// Evaluate, unless sleeping or deferEvaluation is true
if (!state.isSleeping && !options['deferEvaluation']) {
computedObservable.evaluateImmediate();
}
// Evaluate, unless sleeping
state.isSleeping || computedObservable.evaluateImmediate();
// Attach a DOM node disposal callback so that the computed will be proactively disposed as soon as the node is
// removed using ko.removeNode. But skip if isActive is false (there will never be any dependencies to dispose).
@ -1063,16 +1047,13 @@ var computedFn = {
disposeWhen = state.disposeWhen,
changed = false;
if (state.isBeingEvaluated) {
// If the evaluation of a ko.computed causes side effects, it's possible that it will trigger its own re-evaluation.
// This is not desirable (it's hard for a developer to realise a chain of dependencies might cause this, and they almost
// certainly didn't intend infinite re-evaluations). So, for predictability, we simply prevent ko.computeds from causing
// their own re-evaluation. Further discussion at https://github.com/SteveSanderson/knockout/pull/387
return;
}
// If the evaluation of a ko.computed causes side effects, it's possible that it will trigger its own re-evaluation.
// This is not desirable (it's hard for a developer to realise a chain of dependencies might cause this, and they almost
// certainly didn't intend infinite re-evaluations). So, for predictability, we simply prevent ko.computeds from causing
// their own re-evaluation. Further discussion at https://github.com/SteveSanderson/knockout/pull/387
if (state.isBeingEvaluated
// Do not evaluate (and possibly capture new dependencies) if disposed
if (state.isDisposed) {
|| state.isDisposed) {
return;
}
@ -1087,8 +1068,8 @@ var computedFn = {
state.suppressDisposalUntilDisposeWhenReturnsFalse = false;
}
state.isBeingEvaluated = true;
try {
state.isBeingEvaluated = true;
changed = this.evaluateImmediate_CallReadWithDependencyDetection(notifyChange);
} finally {
state.isBeingEvaluated = false;
@ -1159,7 +1140,7 @@ var computedFn = {
return changed;
},
peek: function (evaluate) {
// By default, peek won't re-evaluate, except while the computed is sleeping or to get the initial value when "deferEvaluation" is set.
// By default, peek won't re-evaluate, except while the computed is sleeping.
// Pass in true to evaluate if needed.
var state = this[computedState];
if ((state.isDirty && (evaluate || !state.dependenciesCount)) || (state.isSleeping && this.haveDependenciesChanged())) {
@ -1168,30 +1149,31 @@ var computedFn = {
return state.latestValue;
},
limit: function (limitFunction) {
var self = this;
// Override the limit function with one that delays evaluation as well
ko.subscribable['fn'].limit.call(this, limitFunction);
this._evalIfChanged = function () {
if (!this[computedState].isSleeping) {
if (this[computedState].isStale) {
this.evaluateImmediate();
ko.subscribable['fn'].limit.call(self, limitFunction);
self._evalIfChanged = () => {
if (!self[computedState].isSleeping) {
if (self[computedState].isStale) {
self.evaluateImmediate();
} else {
this[computedState].isDirty = false;
self[computedState].isDirty = false;
}
}
return this[computedState].latestValue;
return self[computedState].latestValue;
};
this._evalDelayed = function (isChange) {
this._limitBeforeChange(this[computedState].latestValue);
self._evalDelayed = isChange => {
self._limitBeforeChange(self[computedState].latestValue);
// Mark as dirty
this[computedState].isDirty = true;
self[computedState].isDirty = true;
if (isChange) {
this[computedState].isStale = true;
self[computedState].isStale = true;
}
// Pass the observable to the "limit" code, which will evaluate it when
// it's time to do the notification.
this._limitChange(this, !isChange /* isDirty */);
self._limitChange(self, !isChange /* isDirty */);
};
},
dispose: function () {
@ -1285,15 +1267,6 @@ var pureComputedOverrides = {
}
};
var deferEvaluationOverrides = {
beforeSubscriptionAdd: function (event) {
// This will force a computed with deferEvaluation to evaluate when the first subscription is registered.
if (event == 'change' || event == 'beforeChange') {
this.peek();
}
}
};
// Note that for browsers that don't support proto assignment, the
// inheritance chain is created manually in the ko.computed constructor
Object.setPrototypeOf(computedFn, ko.subscribable['fn']);
@ -1325,11 +1298,13 @@ ko.pureComputed = (evaluatorFunctionOrOptions) => {
readValue : element => {
switch (element.nodeName) {
case 'OPTION':
if (element[hasDomDataExpandoProperty] === true)
return ko.utils.domData.get(element, ko.bindingHandlers.options.optionValueDomDataKey);
return element.value;
return (element[hasDomDataExpandoProperty] === true)
? ko.utils.domData.get(element, ko.bindingHandlers.options.optionValueDomDataKey)
: element.value;
case 'SELECT':
return element.selectedIndex >= 0 ? ko.selectExtensions.readValue(element.options[element.selectedIndex]) : undefined;
return element.selectedIndex >= 0
? ko.selectExtensions.readValue(element.options[element.selectedIndex])
: undefined;
default:
return element.value;
}
@ -1354,8 +1329,9 @@ ko.pureComputed = (evaluatorFunctionOrOptions) => {
break;
case 'SELECT':
// A blank string or null value will select the caption
var selection = -1, noValue = ("" === value || null == value);
for (var i = 0, n = element.options.length, optionValue; i < n; ++i) {
var selection = -1, noValue = ("" === value || null == value),
i = element.options.length, optionValue;
while (i--) {
optionValue = ko.selectExtensions.readValue(element.options[i]);
// Include special check to handle selecting a caption with a blank string value
if (optionValue == value || (optionValue === "" && noValue)) {
@ -1552,9 +1528,7 @@ ko.expressionRewriting = (() => {
// it is !== existing value on that writable observable
writeValueToProperty: (property, allBindings, key, value, checkIfDifferent) => {
if (!property || !ko.isObservable(property)) {
var propWriters = allBindings.get('_ko_property_writers');
if (propWriters && propWriters[key])
propWriters[key](value);
allBindings.get('_ko_property_writers')?.[key]?.(value);
} else if (ko.isWriteableObservable(property) && (!checkIfDifferent || property.peek() !== value)) {
property(value);
}
@ -1761,7 +1735,7 @@ ko.expressionRewriting = (() => {
realDataItemOrAccessor = shouldInheritData ? undefined : dataItemOrAccessor,
isFunc = typeof(realDataItemOrAccessor) == "function" && !ko.isObservable(realDataItemOrAccessor),
subscribable,
dataDependency = options && options['dataDependency'],
dataDependency = options?.['dataDependency'],
// The binding context object includes static properties for the current, parent, and root view models.
// If a view model is actually stored in an observable, the corresponding binding context object, and
@ -1807,12 +1781,11 @@ ko.expressionRewriting = (() => {
// The extendCallback function is provided when creating a child context or extending a context.
// It handles the specific actions needed to finish setting up the binding context. Actions in this
// function could also add dependencies to this binding context.
if (extendCallback)
extendCallback(self, parentContext, dataItem);
extendCallback?.(self, parentContext, dataItem);
// When a "parent" context is given and we don't already have a dependency on its context, register a dependency on it.
// Thus whenever the parent context is updated, this context will also be updated.
if (parentContext && parentContext[contextSubscribable] && !ko.dependencyDetection.computed().hasAncestorDependency(parentContext[contextSubscribable])) {
if (parentContext?.[contextSubscribable] && !ko.dependencyDetection.computed().hasAncestorDependency(parentContext[contextSubscribable])) {
parentContext[contextSubscribable]();
}
@ -1823,7 +1796,7 @@ ko.expressionRewriting = (() => {
return self['$data'];
};
if (options && options['exportDependencies']) {
if (options?.['exportDependencies']) {
// The "exportDependencies" option means that the calling code will track any dependencies and re-create
// the binding context when they change.
updateContext();
@ -1881,7 +1854,7 @@ ko.expressionRewriting = (() => {
function asyncContextDispose(node) {
var bindingInfo = ko.utils.domData.get(node, boundElementDomDataKey),
asyncContext = bindingInfo && bindingInfo.asyncContext;
asyncContext = bindingInfo?.asyncContext;
if (asyncContext) {
bindingInfo.asyncContext = null;
asyncContext.notifyAncestor();
@ -1895,25 +1868,19 @@ ko.expressionRewriting = (() => {
this.asyncDescendants = new Set;
this.childrenComplete = false;
if (!bindingInfo.asyncContext) {
ko.utils.domNodeDisposal.addDisposeCallback(node, asyncContextDispose);
}
bindingInfo.asyncContext || ko.utils.domNodeDisposal.addDisposeCallback(node, asyncContextDispose);
if (ancestorBindingInfo && ancestorBindingInfo.asyncContext) {
if (ancestorBindingInfo?.asyncContext) {
ancestorBindingInfo.asyncContext.asyncDescendants.add(node);
this.ancestorBindingInfo = ancestorBindingInfo;
}
}
notifyAncestor() {
if (this.ancestorBindingInfo && this.ancestorBindingInfo.asyncContext) {
this.ancestorBindingInfo.asyncContext.descendantComplete(this.node);
}
this.ancestorBindingInfo?.asyncContext?.descendantComplete(this.node);
}
descendantComplete(node) {
this.asyncDescendants.delete(node);
if (!this.asyncDescendants.size && this.childrenComplete) {
this.completeChildren();
}
this.asyncDescendants.size || this.completeChildren?.();
}
completeChildren() {
this.childrenComplete = true;
@ -1935,7 +1902,7 @@ ko.expressionRewriting = (() => {
if (!bindingInfo.eventSubscribable) {
bindingInfo.eventSubscribable = new ko.subscribable;
}
if (options && options['notifyImmediately'] && bindingInfo.notifiedEvents[event]) {
if (options?.['notifyImmediately'] && bindingInfo.notifiedEvents[event]) {
ko.dependencyDetection.ignore(callback, context, [node]);
}
return bindingInfo.eventSubscribable.subscribe(callback, context, event);
@ -1945,13 +1912,11 @@ ko.expressionRewriting = (() => {
var bindingInfo = ko.utils.domData.get(node, boundElementDomDataKey);
if (bindingInfo) {
bindingInfo.notifiedEvents[event] = true;
if (bindingInfo.eventSubscribable) {
bindingInfo.eventSubscribable.notifySubscribers(node, event);
}
bindingInfo.eventSubscribable?.notifySubscribers(node, event);
if (event == ko.bindingEvent.childrenComplete) {
if (bindingInfo.asyncContext) {
bindingInfo.asyncContext.completeChildren();
} else if (bindingInfo.asyncContext === undefined && bindingInfo.eventSubscribable && bindingInfo.eventSubscribable.hasSubscriptionsForEvent(ko.bindingEvent.descendantsComplete)) {
} else if (bindingInfo.asyncContext === undefined && bindingInfo.eventSubscribable?.hasSubscriptionsForEvent(ko.bindingEvent.descendantsComplete)) {
// It's currently an error to register a descendantsComplete handler for a node that was never registered as completing asynchronously.
// That's because without the asyncContext, we don't have a way to know that all descendants have completed.
throw new Error("descendantsComplete event not supported for bindings on this node");
@ -2003,8 +1968,7 @@ ko.expressionRewriting = (() => {
// Perf optimisation: Apply bindings only if...
// (1) We need to store the binding info for the node (all element nodes)
// (2) It might have bindings (e.g., it has a data-bind attribute, or it's a marker for a containerless template)
var shouldApplyBindings = isElement || ko.bindingProvider.nodeHasBindings(nodeVerified);
if (shouldApplyBindings)
if (isElement || ko.bindingProvider.nodeHasBindings(nodeVerified))
bindingContextForDescendants = applyBindingsToNodeInternal(nodeVerified, null, bindingContext)['bindingContextForDescendants'];
// Don't want bindings that operate on text nodes to mutate <script> and <textarea> contents,
@ -2012,7 +1976,7 @@ ko.expressionRewriting = (() => {
// Also bindings should not operate on <template> elements since this breaks in Internet Explorer
// and because such elements' contents are always intended to be bound in a different context
// from where they appear in the document.
if (bindingContextForDescendants && nodeVerified.matches && !nodeVerified.matches('SCRIPT,TEXTAREA,TEMPLATE')) {
if (bindingContextForDescendants && !nodeVerified.matches?.('SCRIPT,TEXTAREA,TEMPLATE')) {
applyBindingsToDescendantsInternal(bindingContextForDescendants, nodeVerified);
}
}
@ -2079,12 +2043,8 @@ ko.expressionRewriting = (() => {
bindings = sourceBindings ? sourceBindings(bindingContext, node) : ko.bindingProvider.getBindingAccessors(node, bindingContext);
// Register a dependency on the binding context to support observable view models.
if (bindings) {
if (bindingContext[contextSubscribable]) {
bindingContext[contextSubscribable]();
}
if (bindingContext[contextDataDependency]) {
bindingContext[contextDataDependency]();
}
bindingContext[contextSubscribable]?.();
bindingContext[contextDataDependency]?.();
}
return bindings;
},
@ -2117,9 +2077,7 @@ ko.expressionRewriting = (() => {
var callback = bindings[ko.bindingEvent.childrenComplete]();
if (callback) {
var nodes = ko.virtualElements.childNodes(node);
if (nodes.length) {
callback(nodes, ko.dataFor(nodes[0]));
}
nodes.length && callback(nodes, ko.dataFor(nodes[0]));
}
});
}
@ -3439,21 +3397,20 @@ makeEventHandlerShortcut('click');
})();
// Go through the items that have been added and deleted and try to find matches between them.
ko.utils.findMovesInArrayComparison = (left, right, limitFailedCompares) => {
if (left.length && right.length) {
var failedCompares, l, r, leftItem, rightItem;
for (failedCompares = l = 0; (!limitFailedCompares || failedCompares < limitFailedCompares) && (leftItem = left[l]); ++l) {
for (r = 0; rightItem = right[r]; ++r) {
if (leftItem['value'] === rightItem['value']) {
leftItem['moved'] = rightItem['index'];
rightItem['moved'] = leftItem['index'];
right.splice(r, 1); // This item is marked as moved; so remove it from right list
failedCompares = r = 0; // Reset failed compares count because we're checking for consecutive failures
break;
}
}
failedCompares += r;
var failedCompares = 0, r, l = right.length;
l && left.every(leftItem => {
r = right.findIndex(rightItem => leftItem['value'] === rightItem['value']);
if (r >= 0) {
leftItem['moved'] = right[r]['index'];
right[r]['moved'] = leftItem['index'];
right.splice(r, 1); // This item is marked as moved; so remove it from right list
// right[r] = null;
failedCompares = r = 0; // Reset failed compares count because we're checking for consecutive failures
--l;
}
}
failedCompares += l;
return l && (!limitFailedCompares || failedCompares < limitFailedCompares);
});
};
ko.utils.compareArrays = (() => {
@ -3463,15 +3420,15 @@ ko.utils.compareArrays = (() => {
var myMin = Math.min,
myMax = Math.max,
editDistanceMatrix = [],
smlIndex, smlIndexMax = smlArray.length,
smlIndex = -1, smlIndexMax = smlArray.length,
bigIndex, bigIndexMax = bigArray.length,
compareRange = (bigIndexMax - smlIndexMax) || 1,
maxDistance = smlIndexMax + bigIndexMax + 1,
thisRow, lastRow,
thisRow, prevRow,
bigIndexMaxForRow, bigIndexMinForRow;
for (smlIndex = 0; smlIndex <= smlIndexMax; smlIndex++) {
lastRow = thisRow;
while (++smlIndex <= smlIndexMax) {
prevRow = thisRow;
editDistanceMatrix.push(thisRow = []);
bigIndexMaxForRow = myMin(bigIndexMax, smlIndex + compareRange);
bigIndexMinForRow = myMax(0, smlIndex - 1);
@ -3481,9 +3438,9 @@ ko.utils.compareArrays = (() => {
else if (!smlIndex) // Top row - transform empty array into new array via additions
thisRow[bigIndex] = bigIndex + 1;
else if (smlArray[smlIndex - 1] === bigArray[bigIndex - 1])
thisRow[bigIndex] = lastRow[bigIndex - 1]; // copy value (no edit)
thisRow[bigIndex] = prevRow[bigIndex - 1]; // copy value (no edit)
else {
var northDistance = lastRow[bigIndex] || maxDistance; // not in big (deletion)
var northDistance = prevRow[bigIndex] || maxDistance; // not in big (deletion)
var westDistance = thisRow[bigIndex - 1] || maxDistance; // not in small (addition)
thisRow[bigIndex] = myMin(northDistance, westDistance) + 1;
}
@ -3491,7 +3448,9 @@ ko.utils.compareArrays = (() => {
}
var editScript = [], meMinusOne, notInSml = [], notInBig = [];
for (smlIndex = smlIndexMax, bigIndex = bigIndexMax; smlIndex || bigIndex;) {
smlIndex = smlIndexMax;
bigIndex = bigIndexMax
while (smlIndex || bigIndex) {
meMinusOne = editDistanceMatrix[smlIndex][bigIndex] - 1;
if (bigIndex && meMinusOne === editDistanceMatrix[smlIndex][bigIndex-1]) {
notInSml.push(editScript[editScript.length] = { // added
@ -3585,55 +3544,57 @@ ko.utils.compareArrays = (() => {
array = [array];
options = options || {};
var lastMappingResult = ko.utils.domData.get(domNode, lastMappingResultDomDataKey);
var isFirstExecution = !lastMappingResult;
var lastMappingResult = ko.utils.domData.get(domNode, lastMappingResultDomDataKey),
isFirstExecution = !lastMappingResult,
// Build the new mapping result
var newMappingResult = [];
var lastMappingResultIndex = 0;
var currentArrayIndex = 0;
// Build the new mapping result
newMappingResult = [],
lastMappingResultIndex = 0,
currentArrayIndex = 0,
var nodesToDelete = [];
var itemsToMoveFirstIndexes = [];
var itemsForBeforeRemoveCallbacks = [];
var mapData;
var countWaitingForRemove = 0;
nodesToDelete = [],
itemsToMoveFirstIndexes = [],
itemsForBeforeRemoveCallbacks = [],
mapData,
countWaitingForRemove = 0,
function itemAdded(value) {
mapData = { arrayEntry: value, indexObservable: ko.observable(currentArrayIndex++) };
newMappingResult.push(mapData);
}
itemAdded = value => {
mapData = { arrayEntry: value, indexObservable: ko.observable(currentArrayIndex++) };
newMappingResult.push(mapData);
},
function itemMovedOrRetained(oldPosition) {
mapData = lastMappingResult[oldPosition];
// Since updating the index might change the nodes, do so before calling fixUpContinuousNodeArray
mapData.indexObservable(currentArrayIndex++);
ko.utils.fixUpContinuousNodeArray(mapData.mappedNodes, domNode);
newMappingResult.push(mapData);
}
itemMovedOrRetained = oldPosition => {
mapData = lastMappingResult[oldPosition];
// Since updating the index might change the nodes, do so before calling fixUpContinuousNodeArray
mapData.indexObservable(currentArrayIndex++);
ko.utils.fixUpContinuousNodeArray(mapData.mappedNodes, domNode);
newMappingResult.push(mapData);
},
function callCallback(callback, items) {
if (callback) {
for (var i = 0, n = items.length; i < n; i++) {
items[i] && items[i].mappedNodes.forEach(node => callback(node, i, items[i].arrayEntry));
callCallback = (callback, items) => {
if (callback) {
for (var i = 0, n = items.length; i < n; i++) {
items[i] && items[i].mappedNodes.forEach(node => callback(node, i, items[i].arrayEntry));
}
}
}
}
};
if (isFirstExecution) {
array.forEach(itemAdded);
} else {
if (!editScript || (lastMappingResult && lastMappingResult['_countWaitingForRemove'])) {
// Compare the provided array against the previous one
var lastArray = Array.prototype.map.call(lastMappingResult, x => x.arrayEntry),
compareOptions = {
editScript = ko.utils.compareArrays(
Array.prototype.map.call(lastMappingResult, x => x.arrayEntry),
array,
{
'dontLimitMoves': options['dontLimitMoves'],
'sparse': true
};
editScript = ko.utils.compareArrays(lastArray, array, compareOptions);
});
}
for (let i = 0, editScriptItem, movedIndex, itemIndex; editScriptItem = editScript[i]; i++) {
let movedIndex, itemIndex;
editScript.forEach(editScriptItem => {
movedIndex = editScriptItem['moved'];
itemIndex = editScriptItem['index'];
switch (editScriptItem['status']) {
@ -3681,7 +3642,7 @@ ko.utils.compareArrays = (() => {
}
break;
}
}
});
while (currentArrayIndex < array.length) {
itemMovedOrRetained(lastMappingResultIndex++);
@ -3698,7 +3659,11 @@ ko.utils.compareArrays = (() => {
// Next remove nodes for deleted items (or just clean if there's a beforeRemove callback)
nodesToDelete.forEach(options['beforeRemove'] ? ko.cleanNode : ko.removeNode);
var i, j, lastNode, nodeToInsert, mappedNodes, activeElement;
var i, lastNode, mappedNodes, activeElement,
insertNode = nodeToInsert => {
ko.virtualElements.insertAfter(domNode, nodeToInsert, lastNode);
lastNode = nodeToInsert;
};
// Since most browsers remove the focus from an element when it's moved to another location,
// save the focused element and try to restore it later.
@ -3714,22 +3679,18 @@ ko.utils.compareArrays = (() => {
break;
}
}
for (j = 0; nodeToInsert = mapData.mappedNodes[j]; lastNode = nodeToInsert, j++) {
ko.virtualElements.insertAfter(domNode, nodeToInsert, lastNode);
}
mapData.mappedNodes.forEach(insertNode);
}
}
// Next add/reorder the remaining items (will include deleted items if there's a beforeRemove callback)
for (i = 0; mapData = newMappingResult[i]; i++) {
newMappingResult.forEach(mapData => {
// Get nodes for newly added items
if (!mapData.mappedNodes)
ko.utils.extend(mapData, mapNodeAndRefreshWhenChanged(domNode, mapping, mapData.arrayEntry, callbackAfterAddingNodes, mapData.indexObservable));
mapData.mappedNodes
|| ko.utils.extend(mapData, mapNodeAndRefreshWhenChanged(domNode, mapping, mapData.arrayEntry, callbackAfterAddingNodes, mapData.indexObservable));
// Put nodes in the right place if they aren't there already
for (j = 0; nodeToInsert = mapData.mappedNodes[j]; lastNode = nodeToInsert, j++) {
ko.virtualElements.insertAfter(domNode, nodeToInsert, lastNode);
}
mapData.mappedNodes.forEach(insertNode);
// Run the callbacks for newly added nodes (for example, to apply bindings, etc.)
if (!mapData.initialized && callbackAfterAddingNodes) {
@ -3737,11 +3698,11 @@ ko.utils.compareArrays = (() => {
mapData.initialized = true;
lastNode = mapData.mappedNodes[mapData.mappedNodes.length - 1]; // get the last node again since it may have been changed by a preprocessor
}
}
});
// Restore the focused element if it had lost focus
if (activeElement && domNode.ownerDocument.activeElement != activeElement) {
activeElement.focus();
if (domNode.ownerDocument.activeElement != activeElement) {
activeElement?.focus();
}
// If there's a beforeRemove callback, call it after reordering.
@ -3754,11 +3715,7 @@ ko.utils.compareArrays = (() => {
// Replace the stored values of deleted items with a dummy value. This provides two benefits: it marks this item
// as already "removed" so we won't call beforeRemove for it again, and it ensures that the item won't match up
// with an actual item in the array and appear as "retained" or "moved".
for (i = 0; i < itemsForBeforeRemoveCallbacks.length; ++i) {
if (itemsForBeforeRemoveCallbacks[i]) {
itemsForBeforeRemoveCallbacks[i].arrayEntry = deletedItemDummyValue;
}
}
itemsForBeforeRemoveCallbacks.forEach(callback => callback && (callback.arrayEntry = deletedItemDummyValue));
}
})();
window['ko'] = koExports;

View file

@ -4,70 +4,70 @@
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
*/
(T=>{function O(a,c){return null===a||U[typeof a]?a===c:!1}function V(a,c){var d;return()=>{d||(d=setTimeout(()=>{d=0;a()},c))}}function W(a,c){var d;return()=>{clearTimeout(d);d=setTimeout(a,c)}}function X(a,c){c?.A?.()}function Y(a,c){var d=this.$b,f=d[A];f.aa||(this.Wa&&this.Ca[c]?(d.vb(c,a,this.Ca[c]),this.Ca[c]=null,--this.Wa):f.B[c]||d.vb(c,a,f.C?{X:a}:d.Sb(a)),a.la&&a.Wb())}var M=T.document,P={},b="undefined"!==typeof P?P:{};b.v=(a,c)=>{a=a.split(".");for(var d=b,f=0,k=a.length-1;f<k;f++)d=
d[a[f]];d[a[k]]=c};b.ja=(a,c,d)=>{a[c]=d};b.v("version","3.5.1-sm");b.g={extend:(a,c)=>c?Object.assign(a,c):a,P:(a,c)=>a&&Object.entries(a).forEach(d=>c(d[0],d[1])),$a:a=>[...a.childNodes].forEach(c=>b.removeNode(c)),Mb:a=>{a=[...a];var c=(a[0]?.ownerDocument||M).createElement("div");a.forEach(d=>c.append(b.ga(d)));return c},Ba:(a,c)=>Array.prototype.map.call(a,c?d=>b.ga(d.cloneNode(!0)):d=>d.cloneNode(!0)),wa:(a,c)=>{b.g.$a(a);c&&a.append(...c)},Da:(a,c)=>{if(a.length){for(c=8===c.nodeType&&c.parentNode||
c;a.length&&a[0].parentNode!==c;)a.splice(0,1);for(;1<a.length&&a[a.length-1].parentNode!==c;)--a.length;if(1<a.length){c=a[0];var d=a[a.length-1];for(a.length=0;c!==d;)a.push(c),c=c.nextSibling;a.push(d)}}return a},Rb:a=>null==a?"":a.trim?a.trim():a.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g,""),Za:a=>a.ownerDocument.documentElement.contains(1!==a.nodeType?a.parentNode:a),Tb:(a,c)=>{if(!a?.nodeType)throw Error("element must be a DOM node when calling triggerEvent");a.dispatchEvent(new Event(c))},
j:a=>b.T(a)?a():a,jb:(a,c)=>a.textContent=b.g.j(c)||""};b.v("utils",b.g);b.v("unwrap",b.g.j);(()=>{let a=0,c="__ko__"+Date.now(),d=new WeakMap;b.g.i={get:(f,k)=>(d.get(f)||{})[k],set:(f,k,n)=>{d.has(f)?d.get(f)[k]=n:d.set(f,{[k]:n});return n},bb:function(f,k,n){return this.get(f,k)||this.set(f,k,n)},clear:f=>d.delete(f),Z:()=>a++ +c}})();b.g.L=(()=>{var a=b.g.i.Z(),c={1:1,8:1,9:1},d={1:1,9:1};const f=(e,g)=>{var h=b.g.i.get(e,a);g&&!h&&(h=new Set,b.g.i.set(e,a,h));return h},k=e=>{var g=f(e);g&&(new Set(g)).forEach(h=>
h(e));b.g.i.clear(e);d[e.nodeType]&&n(e.childNodes,!0)},n=(e,g)=>{for(var h=[],r,t=0;t<e.length;t++)if(!g||8===e[t].nodeType)if(k(h[h.length]=r=e[t]),e[t]!==r)for(;t--&&!h.includes(e[t]););};return{oa:(e,g)=>{if("function"!=typeof g)throw Error("Callback must be a function");f(e,1).add(g)},ib:(e,g)=>{var h=f(e);h&&(h.delete(g),h.size||b.g.i.set(e,a,null))},ga:e=>{b.u.S(()=>{c[e.nodeType]&&(k(e),d[e.nodeType]&&n(e.getElementsByTagName("*")))});return e},removeNode:e=>{b.ga(e);e.parentNode&&e.parentNode.removeChild(e)}}})();
b.ga=b.g.L.ga;b.removeNode=b.g.L.removeNode;b.v("utils.domNodeDisposal",b.g.L);b.v("utils.domNodeDisposal.addDisposeCallback",b.g.L.oa);b.ab={debounce:(a,c)=>a.Ka(d=>W(d,c)),rateLimit:(a,c)=>{if("number"==typeof c)var d=c;else{d=c.timeout;var f=c.method}var k="function"==typeof f?f:V;a.Ka(n=>k(n,d,c))},notify:(a,c)=>{a.sa="always"==c?null:O}};var U={undefined:1,"boolean":1,number:1,string:1};b.v("extenders",b.ab);class Z{constructor(a,c,d){this.X=a;this.pb=c;this.va=d;this.Qa=!1;this.M=this.$=null;
b.ja(this,"dispose",this.A)}A(){this.Qa||(this.M&&b.g.L.ib(this.$,this.M),this.Qa=!0,this.va(),this.X=this.pb=this.va=this.$=this.M=null)}o(a){this.$=a;b.g.L.oa(a,this.M=this.A.bind(this))}}b.V=function(){Object.setPrototypeOf(this,G);G.Ha(this)};var G={Ha:a=>{a.W=new Map;a.W.set("change",new Set);a.ub=1},subscribe:function(a,c,d){var f=this;d=d||"change";var k=new Z(f,c?a.bind(c):a,()=>{f.W.get(d).delete(k);f.za&&f.za(d)});f.pa&&f.pa(d);f.W.has(d)||f.W.set(d,new Set);f.W.get(d).add(k);return k},
D:function(a,c){c=c||"change";"change"===c&&this.Na();if(this.ta(c)){c="change"===c&&this.Ub||new Set(this.W.get(c));try{b.u.zb(),c.forEach(d=>{d.Qa||d.pb(a)})}finally{b.u.end()}}},Fa:function(){return this.ub},fc:function(a){return this.Fa()!==a},Na:function(){++this.ub},Ka:function(a){var c=this,d=b.T(c),f,k,n,e,g;c.ya||(c.ya=c.D,c.D=function(r,t){t&&"change"!==t?"beforeChange"===t?this.rb(r):this.ya(r,t):this.sb(r)});var h=a(()=>{c.la=!1;d&&e===c&&(e=c.qb?c.qb():c());var r=k||g&&c.Ja(n,e);g=k=
f=!1;r&&c.ya(n=e)});c.sb=(r,t)=>{t&&c.la||(g=!t);c.Ub=new Set(c.W.get("change"));c.la=f=!0;e=r;h()};c.rb=r=>{f||(n=r,c.ya(r,"beforeChange"))};c.tb=()=>{g=!0};c.Wb=()=>{c.Ja(n,c.J(!0))&&(k=!0)}},ta:function(a){return(this.W.get(a)||[]).size},Ja:function(a,c){return!this.sa||!this.sa(a,c)},toString:()=>"[object Object]",extend:function(a){var c=this;a&&b.g.P(a,(d,f)=>{d=b.ab[d];"function"==typeof d&&(c=d(c,f)||c)});return c}};b.ja(G,"init",G.Ha);b.ja(G,"subscribe",G.subscribe);b.ja(G,"extend",G.extend);
Object.setPrototypeOf(G,Function.prototype);b.V.fn=G;b.jc=a=>"function"==typeof a?.subscribe&&"function"==typeof a.D;(()=>{var a=[],c,d=0;b.u={zb:f=>{a.push(c);c=f},end:()=>c=a.pop(),Pb:f=>{if(c){if(!b.jc(f))throw Error("Only subscribable things can act as dependencies");c.Yb.call(c.Zb,f,f.Vb||(f.Vb=++d))}},S:(f,k,n)=>{try{return a.push(c),c=void 0,f.apply(k,n||[])}finally{c=a.pop()}},Ea:()=>c?.s.Ea(),eb:()=>c?.eb,s:()=>c?.s}})();const F=Symbol("_latestValue");b.ca=a=>{function c(){if(0<arguments.length)return c.Ja(c[F],
arguments[0])&&(c.nb(),c[F]=arguments[0],c.Oa()),this;b.u.Pb(c);return c[F]}c[F]=a;Object.defineProperty(c,"length",{get:()=>null==c[F]?void 0:c[F].length});b.V.fn.Ha(c);Object.setPrototypeOf(c,I);return c};var I={toJSON:function(){let a=this[F];return a?.toJSON?.()||a},sa:O,J:function(){return this[F]},Oa:function(){this.D(this[F],"spectate");this.D(this[F])},nb:function(){this.D(this[F],"beforeChange")}};Object.setPrototypeOf(I,b.V.fn);var J=b.ca.pc="__ko_proto__";I[J]=b.ca;b.T=a=>{if((a="function"==
typeof a&&a[J])&&a!==I[J]&&a!==b.s.fn[J])throw Error("Invalid object that looks like an observable; possibly from another Knockout instance");return!!a};b.kc=a=>"function"==typeof a&&(a[J]===I[J]||a[J]===b.s.fn[J]&&a.hc);b.v("observable",b.ca);b.v("isObservable",b.T);b.v("observable.fn",I);b.ja(I,"valueHasMutated",I.Oa);b.ka=a=>{a=a||[];if("object"!=typeof a||!("length"in a))throw Error("The argument passed when initializing an observable array must be an array, or null, or undefined.");a=b.ca(a);
Object.setPrototypeOf(a,b.ka.fn);return a.extend({trackArrayChanges:!0})};b.ka.fn={remove:function(a){for(var c=this.J(),d=!1,f="function"!=typeof a||b.T(a)?e=>e===a:a,k=c.length;k--;){var n=c[k];if(f(n)){if(c[k]!==n)throw Error("Array modified during remove; cannot remove item");d||this.nb();d=!0;c.splice(k,1)}}d&&this.Oa()}};Object.setPrototypeOf(b.ka.fn,b.ca.fn);Object.getOwnPropertyNames(Array.prototype).forEach(a=>{"function"===typeof Array.prototype[a]&&"constructor"!=a&&("copyWithin fill pop push reverse shift sort splice unshift".split(" ").includes(a)?
b.ka.fn[a]=function(...c){var d=this.J();this.nb();this.Bb(d,a,c);c=d[a](...c);this.Oa();return c===d?this:c}:b.ka.fn[a]=function(...c){return this()[a](...c)})});b.Kb=a=>b.T(a)&&"function"==typeof a.remove&&"function"==typeof a.push;b.v("observableArray",b.ka);b.v("isObservableArray",b.Kb);b.ab.trackArrayChanges=(a,c)=>{function d(){function q(){if(g){var m=[].concat(a.J()||[]);if(a.ta("arrayChange")){if(!k||1<g)k=b.g.Cb(h,m,a.Ta);var l=k}h=m;k=null;g=0;l?.length&&a.D(l,"arrayChange")}}f?q():(f=
!0,e=a.subscribe(()=>++g,null,"spectate"),h=[].concat(a.J()||[]),k=null,n=a.subscribe(q))}a.Ta={};"object"==typeof c&&b.g.extend(a.Ta,c);a.Ta.sparse=!0;if(!a.Bb){var f=!1,k=null,n,e,g=0,h,r=a.pa,t=a.za;a.pa=q=>{r&&r.call(a,q);"arrayChange"===q&&d()};a.za=q=>{t&&t.call(a,q);"arrayChange"!==q||a.ta("arrayChange")||(n&&n.A(),e&&e.A(),e=n=null,f=!1,h=void 0)};a.Bb=(q,m,l)=>{function p(D,B,y){return u[u.length]={status:D,value:B,index:y}}if(f&&!g){var u=[],w=q.length,v=l.length,z=0;switch(m){case "push":z=
w;case "unshift":for(q=0;q<v;q++)p("added",l[q],z+q);break;case "pop":z=w-1;case "shift":w&&p("deleted",q[z],z);break;case "splice":z=Math.min(Math.max(0,0>l[0]?w+l[0]:l[0]),w);w=1===v?w:Math.min(z+(l[1]||0),w);v=z+v-2;m=Math.max(w,v);var x=[],E=[];for(let D=z,B=2;D<m;++D,++B)D<w&&E.push(p("deleted",q[D],D)),D<v&&x.push(p("added",l[B],D));b.g.Hb(E,x);break;default:return}k=u}}}};var A=Symbol("_state");b.s=(a,c)=>{function d(){if(0<arguments.length){if("function"!==typeof f)throw Error("Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.");
f(...arguments);return this}k.aa||b.u.Pb(d);(k.Y||k.C&&d.ua())&&d.U();return k.N}"object"===typeof a?c=a:(c=c||{},a&&(c.read=a));if("function"!=typeof c.read)throw Error("Pass a function that returns the value of the ko.computed");var f=c.write,k={N:void 0,ba:!0,Y:!0,Ia:!1,lb:!1,aa:!1,hb:!1,C:!1,Ob:c.read,o:c.disposeWhenNodeIsRemoved||c.o||null,qa:c.disposeWhen||c.qa,Ya:null,B:{},K:0,Gb:null};d[A]=k;d.hc="function"===typeof f;b.V.fn.Ha(d);Object.setPrototypeOf(d,L);c.pure?(k.hb=!0,k.C=!0,b.g.extend(d,
aa)):c.deferEvaluation&&b.g.extend(d,ba);k.o&&(k.lb=!0,k.o.nodeType||(k.o=null));k.C||c.deferEvaluation||d.U();k.o&&d.isActive()&&b.g.L.oa(k.o,k.Ya=()=>{d.A()});return d};var L={sa:O,Ea:function(){return this[A].K},dc:function(){var a=[];b.g.P(this[A].B,(c,d)=>a[d.ma]=d.X);return a},cb:function(a){if(!this[A].K)return!1;var c=this.dc();return c.includes(a)||!!c.find(d=>d.cb&&d.cb(a))},vb:function(a,c,d){if(this[A].hb&&c===this)throw Error("A 'pure' computed must not be called recursively");this[A].B[a]=
d;d.ma=this[A].K++;d.na=c.Fa()},ua:function(){var a,c=this[A].B;for(a in c)if(Object.prototype.hasOwnProperty.call(c,a)){var d=c[a];if(this.xa&&d.X.la||d.X.fc(d.na))return!0}},vc:function(){this[A].Ia||this.xa?.(!1)},isActive:function(){var a=this[A];return a.Y||0<a.K},wc:function(){this.la?this[A].Y&&(this[A].ba=!0):this.Fb()},Sb:function(a){return a.subscribe(this.Fb,this)},Fb:function(){var a=this,c=a.throttleEvaluation;0<=c?(clearTimeout(this[A].Gb),this[A].Gb=setTimeout(()=>a.U(!0),c)):a.xa?
a.xa(!0):a.U(!0)},U:function(a){var c=this[A],d=c.qa,f=!1;if(!c.Ia&&!c.aa){if(c.o&&!b.g.Za(c.o)||d?.()){if(!c.lb){this.A();return}}else c.lb=!1;c.Ia=!0;try{f=this.bc(a)}finally{c.Ia=!1}return f}},bc:function(a){var c=this[A],d=c.hb?void 0:!c.K;var f={$b:this,Ca:c.B,Wa:c.K};b.u.zb({Zb:f,Yb:Y,s:this,eb:d});c.B={};c.K=0;a:{try{var k=c.Ob();break a}finally{b.u.end(),f.Wa&&!c.C&&b.g.P(f.Ca,X),c.ba=c.Y=!1}k=void 0}c.K?f=this.Ja(c.N,k):(this.A(),f=!0);f&&(c.C?this.Na():this.D(c.N,"beforeChange"),c.N=k,this.D(c.N,
"spectate"),!c.C&&a&&this.D(c.N),this.tb&&this.tb());d&&this.D(c.N,"awake");return f},J:function(a){var c=this[A];(c.Y&&(a||!c.K)||c.C&&this.ua())&&this.U();return c.N},Ka:function(a){b.V.fn.Ka.call(this,a);this.qb=function(){this[A].C||(this[A].ba?this.U():this[A].Y=!1);return this[A].N};this.xa=function(c){this.rb(this[A].N);this[A].Y=!0;c&&(this[A].ba=!0);this.sb(this,!c)}},A:function(){var a=this[A];!a.C&&a.B&&b.g.P(a.B,(c,d)=>d.A?.());a.o&&a.Ya&&b.g.L.ib(a.o,a.Ya);a.B=void 0;a.K=0;a.aa=!0;a.ba=
!1;a.Y=!1;a.C=!1;a.o=void 0;a.qa=void 0;a.Ob=void 0}},aa={pa:function(a){var c=this,d=c[A];if(!d.aa&&d.C&&"change"==a){d.C=!1;if(d.ba||c.ua())d.B=null,d.K=0,c.U()&&c.Na();else{var f=[];b.g.P(d.B,(k,n)=>f[n.ma]=k);f.forEach((k,n)=>{var e=d.B[k],g=c.Sb(e.X);g.ma=n;g.na=e.na;d.B[k]=g});c.ua()&&c.U()&&c.Na()}d.aa||c.D(d.N,"awake")}},za:function(a){var c=this[A];c.aa||"change"!=a||this.ta("change")||(b.g.P(c.B,(d,f)=>{f.A&&(c.B[d]={X:f.X,ma:f.ma,na:f.na},f.A())}),c.C=!0,this.D(void 0,"asleep"))},Fa:function(){var a=
this[A];a.C&&(a.ba||this.ua())&&this.U();return b.V.fn.Fa.call(this)}},ba={pa:function(a){"change"!=a&&"beforeChange"!=a||this.J()}};Object.setPrototypeOf(L,b.V.fn);var Q=b.ca.pc;L[Q]=b.s;b.v("computed",b.s);b.v("isComputed",a=>"function"==typeof a&&a[Q]===L[Q]);b.v("computed.fn",L);b.ja(L,"dispose",L.A);b.qc=a=>{if("function"===typeof a)return b.s(a,{pure:!0});a={...a,pure:!0};return b.s(a)};(()=>{b.F={R:a=>{switch(a.nodeName){case "OPTION":return!0===a.__ko__hasDomDataOptionValue__?b.g.i.get(a,
b.h.options.gb):a.value;case "SELECT":return 0<=a.selectedIndex?b.F.R(a.options[a.selectedIndex]):void 0;default:return a.value}},Pa:(a,c,d)=>{switch(a.nodeName){case "OPTION":"string"===typeof c?(b.g.i.set(a,b.h.options.gb,void 0),delete a.__ko__hasDomDataOptionValue__,a.value=c):(b.g.i.set(a,b.h.options.gb,c),a.__ko__hasDomDataOptionValue__=!0,a.value="number"===typeof c?c:"");break;case "SELECT":for(var f=-1,k=""===c||null==c,n=0,e=a.options.length,g;n<e;++n)if(g=b.F.R(a.options[n]),g==c||""===
g&&k){f=n;break}if(d||0<=f||k&&1<a.size)a.selectedIndex=f;break;default:a.value=null==c?"":c}}}})();b.I=(()=>{function a(g){g=b.g.Rb(g);123===g.charCodeAt(0)&&(g=g.slice(1,-1));g+="\n,";var h=[],r=g.match(f),t=[],q=0;if(1<r.length){for(var m=0,l;l=r[m++];){var p=l.charCodeAt(0);if(44===p){if(0>=q){h.push(u&&t.length?{key:u,value:t.join("")}:{unknown:u||t.join("")});var u=q=0;t=[];continue}}else if(58===p){if(!q&&!u&&1===t.length){u=t.pop();continue}}else if(47===p&&1<l.length&&(47===l.charCodeAt(1)||
42===l.charCodeAt(1)))continue;else 47===p&&m&&1<l.length?(p=r[m-1].match(k))&&!n[p[0]]&&(g=g.slice(g.indexOf(l)+1),r=g.match(f),m=-1,l="/"):40===p||123===p||91===p?++q:41===p||125===p||93===p?--q:u||t.length||34!==p&&39!==p||(l=l.slice(1,-1));t.push(l)}if(0<q)throw Error("Unbalanced parentheses, braces, or brackets");}return h}var c=["true","false","null","undefined"],d=/^(?:[$_a-z][$\w]*|(.+)(\.\s*[$_a-z][$\w]*|\[.+\]))$/i,f=RegExp("\"(?:\\\\.|[^\"])*\"|'(?:\\\\.|[^'])*'|`(?:\\\\.|[^`])*`|/\\*(?:[^*]|\\*+[^*/])*\\*+/|//.*\n|/(?:\\\\.|[^/])+/w*|[^\\s:,/][^,\"'`{}()/:[\\]]*[^\\s,\"'`{}()/:[\\]]|[^\\s]",
"g"),k=/[\])"'A-Za-z0-9_$]+$/,n={"in":1,"return":1,"typeof":1},e=new Set;return{Sa:[],mb:e,nc:a,oc:function(g,h){function r(p,u){if(!l){var w=b.h[p];if(w&&w.preprocess&&!(u=w.preprocess(u,p,r)))return;if(w=e.has(p)){var v=u;c.includes(v)?v=!1:(w=v.match(d),v=null===w?!1:w[1]?"Object("+w[1]+")"+w[2]:v);w=v}w&&q.push("'"+p+"':function(_z){"+v+"=_z}")}m&&(u="function(){return "+u+" }");t.push("'"+p+"':"+u)}h=h||{};var t=[],q=[],m=h.valueAccessors,l=h.bindingParams;("string"===typeof g?a(g):g).forEach(p=>
r(p.key||p.unknown,p.value));q.length&&r("_ko_property_writers","{"+q.join(",")+" }");return t.join(",")},lc:(g,h)=>-1<g.findIndex(r=>r.key==h),ob:(g,h,r,t,q)=>{if(g&&b.T(g))!b.kc(g)||q&&g.J()===t||g(t);else if((g=h.get("_ko_property_writers"))&&g[r])g[r](t)}}})();(()=>{function a(e){return 8==e.nodeType&&f.test(e.nodeValue)}function c(e){return 8==e.nodeType&&k.test(e.nodeValue)}function d(e,g){for(var h=e,r=1,t=[];h=h.nextSibling;){if(c(h)&&(b.g.i.set(h,n,!0),!--r))return t;t.push(h);a(h)&&++r}if(!g)throw Error("Cannot find closing comment tag to match: "+
e.nodeValue);return null}var f=/^\s*ko(?:\s+([\s\S]+))?\s*$/,k=/^\s*\/ko\s*$/,n="__ko_matchedEndComment__";b.m={da:{},childNodes:e=>a(e)?d(e):e.childNodes,ra:e=>{a(e)?(e=d(e))&&[...e].forEach(g=>b.removeNode(g)):b.g.$a(e)},wa:(e,g)=>{a(e)?(b.m.ra(e),e.after(...g)):b.g.wa(e,g)},prepend:(e,g)=>{a(e)?e.nextSibling.before(g):e.prepend(g)},Jb:(e,g,h)=>{h?h.after(g):b.m.prepend(e,g)},firstChild:e=>{if(a(e))return e=e.nextSibling,!e||c(e)?null:e;let g=e.firstChild;if(g&&c(g))throw Error("Found invalid end comment, as the first child of "+
e);return g},nextSibling:e=>{if(a(e)){var g=d(e,void 0);e=g?(g.length?g[g.length-1]:e).nextSibling:null}if((g=e.nextSibling)&&c(g)){if(c(g)&&!b.g.i.get(g,n))throw Error("Found end comment without a matching opening comment, as child of "+e);return null}return g},ec:a,uc:e=>(e=e.nodeValue.match(f))?e[1]:null}})();(()=>{const a=new Map;b.Ab=new class{mc(c){switch(c.nodeType){case 1:return null!=c.getAttribute("data-bind");case 8:return b.m.ec(c);default:return!1}}cc(c,d){a:{switch(c.nodeType){case 1:var f=
c.getAttribute("data-bind");break a;case 8:f=b.m.uc(c);break a}f=null}if(f)try{let n={valueAccessors:!0},e=a.get(f);if(!e){var k="with($context){with($data||{}){return{"+b.I.oc(f,n)+"}}}";e=new Function("$context","$element",k);a.set(f,e)}return e(d,c)}catch(n){throw n.message="Unable to parse bindings.\nBindings value: "+f+"\nMessage: "+n.message,n;}return null}}})();(()=>{function a(m){var l=(m=b.g.i.get(m,t))&&m.H;l&&(m.H=null,l.Nb())}function c(m,l){for(var p,u=b.m.firstChild(l);p=u;)u=b.m.nextSibling(p),
d(m,p);b.l.notify(l,b.l.G)}function d(m,l){var p=m;if(1===l.nodeType||b.Ab.mc(l))p=k(l,null,m).bindingContextForDescendants;p&&l.matches&&!l.matches("SCRIPT,TEXTAREA,TEMPLATE")&&c(p,l)}function f(m){var l=[],p={},u=[];b.g.P(m,function z(v){if(!p[v]){var x=b.h[v];x&&(x.after&&(u.push(v),x.after.forEach(E=>{if(m[E]){if(u.includes(E))throw Error("Cannot combine the following bindings, because they have a cyclic dependency: "+u.join(", "));z(E)}}),u.length--),l.push({key:v,Ib:x}));p[v]=!0}});return l}
function k(m,l,p){var u=b.g.i.bb(m,t,{}),w=u.Xb;if(!l){if(w)throw Error("You cannot apply bindings multiple times to the same element.");u.Xb=!0}w||(u.context=p);u.fb||(u.fb={});if(l&&"function"!==typeof l)var v=l;else{var z=b.s(()=>{if(v=l?l(p,m):b.Ab.cc(m,p)){if(p[e])p[e]();if(p[h])p[h]()}return v},{o:m});v&&z.isActive()||(z=null)}var x=p,E;if(v){var D=z?y=>()=>z()[y]():y=>v[y],B={get:y=>v[y]&&D(y)(),has:y=>y in v};b.l.G in v&&b.l.subscribe(m,b.l.G,()=>{var y=v[b.l.G]();if(y){var C=b.m.childNodes(m);
C.length&&y(C,b.Eb(C[0]))}});b.l.ha in v&&(x=b.l.kb(m,p),b.l.subscribe(m,b.l.ha,()=>{var y=v[b.l.ha]();y&&b.m.firstChild(m)&&y(m)}));f(v).forEach(y=>{var C=y.Ib.init,K=y.Ib.update,H=y.key;if(8===m.nodeType&&!b.m.da[H])throw Error("The binding '"+H+"' cannot be used with virtual elements");try{"function"==typeof C&&b.u.S(()=>{var N=C(m,D(H),B,x.$data,x);if(N&&N.controlsDescendantBindings){if(void 0!==E)throw Error("Multiple bindings ("+E+" and "+H+") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");
E=H}}),"function"==typeof K&&b.s(()=>K(m,D(H),B,x.$data,x),{o:m})}catch(N){throw N.message='Unable to process binding "'+H+": "+v[H]+'"\nMessage: '+N.message,N;}})}u=void 0===E;return{shouldBindDescendants:u,bindingContextForDescendants:u&&x}}function n(m,l){return m&&m instanceof b.fa?m:new b.fa(m,void 0,void 0,l)}var e=Symbol("_subscribable"),g=Symbol("_ancestorBindingInfo"),h=Symbol("_dataDependency");b.h={};var r={};b.fa=class{constructor(m,l,p,u,w){var v=this,z=m===r,x=z?void 0:m,E="function"==
typeof x&&!b.T(x),D=w&&w.dataDependency;m=()=>{var y=E?x():x,C=b.g.j(y);l?(b.g.extend(v,l),g in l&&(v[g]=l[g])):(v.$parents=[],v.$root=C,v.ko=b);v[e]=B;z?C=v.$data:(v.$rawData=y,v.$data=C);p&&(v[p]=C);u&&u(v,l,C);if(l&&l[e]&&!b.u.s().cb(l[e]))l[e]();D&&(v[h]=D);return v.$data};if(w&&w.exportDependencies)m();else{var B=b.qc(m);B.J();B.isActive()?B.sa=null:v[e]=void 0}}createChildContext(m,l,p,u){!u&&l&&"object"==typeof l&&(u=l,l=u.as,p=u.extend);return new b.fa(m,this,l,(w,v)=>{w.$parentContext=v;
w.$parent=v.$data;w.$parents=(v.$parents||[]).slice(0);w.$parents.unshift(w.$parent);p&&p(w)},u)}extend(m,l){return new b.fa(r,this,null,p=>b.g.extend(p,"function"==typeof m?m(p):m),l)}};var t=b.g.i.Z();class q{constructor(m,l,p){this.M=m;this.va=l;this.Aa=new Set;this.G=!1;l.H||b.g.L.oa(m,a);p&&p.H&&(p.H.Aa.add(m),this.$=p)}Nb(){this.$&&this.$.H&&this.$.H.ac(this.M)}ac(m){this.Aa.delete(m);!this.Aa.size&&this.G&&this.Db()}Db(){this.G=!0;this.va.H&&!this.Aa.size&&(this.va.H=null,b.g.L.ib(this.M,a),
b.l.notify(this.M,b.l.ha),this.Nb())}}b.l={G:"childrenComplete",ha:"descendantsComplete",subscribe:(m,l,p,u,w)=>{var v=b.g.i.bb(m,t,{});v.ia||(v.ia=new b.V);w&&w.notifyImmediately&&v.fb[l]&&b.u.S(p,u,[m]);return v.ia.subscribe(p,u,l)},notify:(m,l)=>{var p=b.g.i.get(m,t);if(p&&(p.fb[l]=!0,p.ia&&p.ia.D(m,l),l==b.l.G))if(p.H)p.H.Db();else if(void 0===p.H&&p.ia&&p.ia.ta(b.l.ha))throw Error("descendantsComplete event not supported for bindings on this node");},kb:(m,l)=>{var p=b.g.i.bb(m,t,{});p.H||(p.H=
new q(m,p,l[g]));return l[g]==p?l:l.extend(u=>{u[g]=p})}};b.tc=m=>(m=b.g.i.get(m,t))&&m.context;b.wb=(m,l,p)=>k(m,l,n(p));b.yb=(m,l)=>{1!==l.nodeType&&8!==l.nodeType||c(n(m),l)};b.xb=function(m,l,p){if(2>arguments.length){if(l=M.body,!l)throw Error("ko.applyBindings: could not find document.body; has the document been loaded?");}else if(!l||1!==l.nodeType&&8!==l.nodeType)throw Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node");d(n(m,p),l)};
b.Eb=m=>(m=m&&[1,8].includes(m.nodeType)&&b.tc(m))?m.$data:void 0;b.v("bindingHandlers",b.h);b.v("applyBindings",b.xb);b.v("applyBindingAccessorsToNode",b.wb);b.v("dataFor",b.Eb)})();(()=>{var a=Object.create(null),c=new Map;b.Ua={get:(n,e)=>{if(c.has(n))e(c.get(n));else{var g=a[n];g?g.subscribe(e):(g=a[n]=new b.V,g.subscribe(e),k(n,h=>{c.set(n,h);delete a[n];g.D(h)}))}},register:(n,e)=>{if(!e)throw Error("Invalid configuration for "+n);if(d[n])throw Error("Component "+n+" is already registered");
d[n]=e}};var d=Object.create(null),f=(n,e)=>{throw Error(`Component '${n}': ${e}`);},k=(n,e)=>{var g={},h=d[n]||{},r=h.template;h=h.viewModel;if(r){r.element||f(n,"Unknown template value: "+r);r=r.element;var t=M.getElementById(r);t||f(n,"Cannot find element with ID "+r);t.matches("TEMPLATE")||f(n,"Template Source Element not a <template>");g.template=b.g.Ba(t.content.childNodes)}h&&("function"!==typeof h.createViewModel&&f(n,"Unknown viewModel value: "+h),g.createViewModel=h.createViewModel);e(g.template&&
g.createViewModel?g:null)};b.v("components",b.Ua);b.v("components.register",b.Ua.register)})();(()=>{var a=0;b.h.component={init:(c,d,f,k,n)=>{var e,g,h,r=()=>{var q=e&&e.dispose;"function"===typeof q&&q.call(e);h&&h.A();g=e=h=null},t=[...b.m.childNodes(c)];b.m.ra(c);b.g.L.oa(c,r);b.s(()=>{var q=b.g.j(d());if("string"!==typeof q){var m=b.g.j(q.params);q=b.g.j(q.name)}if(!q)throw Error("No component name specified");var l=b.l.kb(c,n),p=g=++a;b.Ua.get(q,u=>{if(g===p){r();if(!u)throw Error("Unknown component '"+
q+"'");var w=u.template;if(!w)throw Error("Component '"+q+"' has no template");b.m.wa(c,b.g.Ba(w));e=u.createViewModel(m,{element:c,templateNodes:t});b.yb(l.createChildContext(e,{extend:v=>{v.$component=e;v.$componentTemplateNodes=t}}),c)}})},{o:c});return{controlsDescendantBindings:!0}}};b.m.da.component=!0})();b.h.attr={update:(a,c)=>{c=b.g.j(c())||{};b.g.P(c,function(d,f){f=b.g.j(f);var k=d.indexOf(":");k="lookupNamespaceURI"in a&&0<k&&a.lookupNamespaceURI(d.slice(0,k));var n=!1===f||null==f;n?
k?a.removeAttributeNS(k,d):a.removeAttribute(d):(f=f.toString(),k?a.setAttributeNS(k,d,f):a.setAttribute(d,f));"name"===d&&(a.name=n?"":f)})}};var R=(a,c,d)=>c&&c.split(/\s+/).forEach(f=>a.classList.toggle(f,d));b.h.css={update:(a,c)=>{c=b.g.j(c());"object"==typeof c?b.g.P(c,(d,f)=>{f=b.g.j(f);R(a,d,!!f)}):(c=b.g.Rb(c),R(a,a.__ko__cssValue,!1),a.__ko__cssValue=c,R(a,c,!0))}};b.h.enable={update:(a,c)=>{(c=b.g.j(c()))&&a.disabled?a.removeAttribute("disabled"):c||a.disabled||(a.disabled=!0)}};b.h.disable=
{update:(a,c)=>b.h.enable.update(a,()=>!b.g.j(c()))};b.h.event={init:(a,c,d,f,k)=>{d=c()||{};b.g.P(d,n=>{"string"==typeof n&&a.addEventListener(n,(...e)=>{var g=c()[n];if(g)try{f=k.$data;var h=g.apply(f,[f,...e])}finally{!0!==h&&e[0].preventDefault()}})})}};b.h.foreach={Lb:a=>()=>{var c=a(),d=b.T(c)?c.J():c;if(!d||"number"==typeof d.length)return{foreach:c};b.g.j(c);return{foreach:d.data,as:d.as,beforeRemove:d.beforeRemove}},init:(a,c)=>b.h.template.init(a,b.h.foreach.Lb(c)),update:(a,c,d,f,k)=>b.h.template.update(a,
b.h.foreach.Lb(c),d,f,k)};b.I.Sa.foreach=!1;b.m.da.foreach=!0;b.h.hasfocus={init:(a,c,d)=>{var f=n=>{a.__ko_hasfocusUpdating=!0;n=a.ownerDocument.activeElement===a;var e=c();b.I.ob(e,d,"hasfocus",n,!0);a.__ko_hasfocusLastValue=n;a.__ko_hasfocusUpdating=!1},k=f.bind(null,!0);f=f.bind(null,!1);a.addEventListener("focus",k);a.addEventListener("focusin",k);a.addEventListener("blur",f);a.addEventListener("focusout",f);a.__ko_hasfocusLastValue=!1},update:(a,c)=>{c=!!b.g.j(c());a.__ko_hasfocusUpdating||
a.__ko_hasfocusLastValue===c||(c?a.focus():a.blur())}};b.I.mb.add("hasfocus");b.h.html={init:()=>({controlsDescendantBindings:!0}),update:(a,c)=>{b.g.$a(a);c=b.g.j(c());if(null!=c){const d=M.createElement("template");d.innerHTML="string"!=typeof c?c.toString():c;a.appendChild(d.content)}}};(()=>{function a(c,d,f){b.h[c]={init:(k,n,e,g,h)=>{var r,t={};d&&(t={as:e.get("as"),exportDependencies:!0});var q=e.has(b.l.ha);b.s(()=>{var m=b.g.j(n()),l=!f!==!m,p=!r;q&&(h=b.l.kb(k,h));if(l){t.dataDependency=
b.u.s();var u=d?h.createChildContext("function"==typeof m?m:n,t):b.u.Ea()?h.extend(null,t):h}p&&b.u.Ea()&&(r=b.g.Ba(b.m.childNodes(k),!0));l?(p||b.m.wa(k,b.g.Ba(r)),b.yb(u,k)):(b.m.ra(k),b.l.notify(k,b.l.G))},{o:k});return{controlsDescendantBindings:!0}}};b.I.Sa[c]=!1;b.m.da[c]=!0}a("if");a("ifnot",!1,!0);a("with",!0)})();var S={};b.h.options={init:a=>{if(!a.matches("SELECT"))throw Error("options binding applies only to SELECT elements");let c=a.length;for(;c--;)a.remove(c);return{controlsDescendantBindings:!0}},
update:(a,c,d)=>{var f=a.multiple,k=0!=a.length&&f?a.scrollTop:null,n=b.g.j(c()),e=d.get("valueAllowUnset")&&d.has("value"),g={},h=[];c=()=>Array.from(a.options).filter(l=>l.selected);var r=(l,p,u)=>{var w=typeof p;return"function"==w?p(l):"string"==w?l[p]:u},t=(l,p)=>{m&&e?b.l.notify(a,b.l.G):h.length&&(l=h.includes(b.F.R(p[0])),p[0].selected=l,m&&!l&&b.u.S(b.g.Tb,null,[a,"change"]))};e||(f?h=c().map(b.F.R):0<=a.selectedIndex&&h.push(b.F.R(a.options[a.selectedIndex])));if(n){"undefined"==typeof n.length&&
(n=[n]);var q=n.filter(l=>l||null==l);d.has("optionsCaption")&&(n=b.g.j(d.get("optionsCaption")),null!==n&&void 0!==n&&q.unshift(S))}var m=!1;g.beforeRemove=l=>a.removeChild(l);n=t;d.has("optionsAfterRender")&&"function"==typeof d.get("optionsAfterRender")&&(n=(l,p)=>{t(l,p);b.u.S(d.get("optionsAfterRender"),null,[p[0],l!==S?l:void 0])});b.g.Qb(a,q,(l,p,u)=>{u.length&&(h=!e&&u[0].selected?[b.F.R(u[0])]:[],m=!0);p=a.ownerDocument.createElement("option");l===S?(b.g.jb(p,d.get("optionsCaption")),b.F.Pa(p,
void 0)):(u=r(l,d.get("optionsValue"),l),b.F.Pa(p,b.g.j(u)),l=r(l,d.get("optionsText"),u),b.g.jb(p,l));return[p]},g,n);e||(q=h.length,(f?q&&c().length<q:q&&0<=a.selectedIndex?b.F.R(a.options[a.selectedIndex])!==h[0]:q||0<=a.selectedIndex)&&b.u.S(b.g.Tb,null,[a,"change"]));(e||b.u.eb())&&b.l.notify(a,b.l.G);k&&20<Math.abs(k-a.scrollTop)&&(a.scrollTop=k)}};b.h.options.gb=b.g.i.Z();b.h.style={update:(a,c)=>{c=b.g.j(c()||{});b.g.P(c,(d,f)=>{f=b.g.j(f);if(null==f||!1===f)f="";if(/^--/.test(d))a.style.setProperty(d,
f);else{d=d.replace(/-(\w)/g,(n,e)=>e.toUpperCase());var k=a.style[d];a.style[d]=f;f===k||a.style[d]!=k||isNaN(f)||(a.style[d]=f+"px")}})}};b.h.submit={init:(a,c,d,f,k)=>{if("function"!=typeof c())throw Error("The value for a submit binding must be a function");a.addEventListener("submit",n=>{var e=c();try{var g=e.call(k.$data,a)}finally{!0!==g&&n.preventDefault()}})}};b.h.text={init:()=>({controlsDescendantBindings:!0}),update:(a,c)=>{8===a.nodeType&&(a.text||a.after(a.text=M.createTextNode("")),
a=a.text);b.g.jb(a,c())}};b.m.da.text=!0;b.h.textInput={init:(a,c,d)=>{var f=a.value,k,n,e=()=>{clearTimeout(k);n=k=void 0;var h=a.value;f!==h&&(f=h,b.I.ob(c(),d,"textInput",h))},g=()=>{var h=b.g.j(c());null==h&&(h="");void 0!==n&&h===n?setTimeout(g,4):a.value!==h&&(a.value=h,f=a.value)};a.addEventListener("input",e);a.addEventListener("change",e);a.addEventListener("blur",e);b.s(g,{o:a})}};b.I.mb.add("textInput");b.h.textinput={preprocess:(a,c,d)=>d("textInput",a)};b.h.value={init:(a,c,d)=>{var f=
a.matches("SELECT"),k=a.matches("INPUT");if(!k||"checkbox"!=a.type&&"radio"!=a.type){var n=new Set,e=d.get("valueUpdate"),g=null;e&&("string"==typeof e?n.add(e):e.forEach(q=>n.add(q)),n.delete("change"));var h=()=>{g=null;var q=c(),m=b.F.R(a);b.I.ob(q,d,"value",m)};n.forEach(q=>{var m=h;(q||"").startsWith("after")&&(m=()=>{g=b.F.R(a);setTimeout(h,0)},q=q.slice(5));a.addEventListener(q,m)});var r=k&&"file"==a.type?()=>{var q=b.g.j(c());null==q||""===q?a.value="":b.u.S(h)}:()=>{var q=b.g.j(c()),m=b.F.R(a);
if(null!==g&&q===g)setTimeout(r,0);else if(q!==m||void 0===m)f?(m=d.get("valueAllowUnset"),b.F.Pa(a,q,m),m||q===b.F.R(a)||b.u.S(h)):b.F.Pa(a,q)};if(f){var t;b.l.subscribe(a,b.l.G,()=>{t?d.get("valueAllowUnset")?r():h():(a.addEventListener("change",h),t=b.s(r,{o:a}))},null,{notifyImmediately:!0})}else a.addEventListener("change",h),b.s(r,{o:a})}else b.wb(a,{checkedValue:c})},update:()=>{}};b.I.mb.add("value");b.h.visible={update:(a,c)=>{c=b.g.j(c());var d="none"!=a.style.display;c&&!d?a.style.display=
"":d&&!c&&(a.style.display="none")}};b.h.hidden={update:(a,c)=>a.hidden=!!b.g.j(c())};(function(a){b.h[a]={init:function(c,d,f,k,n){return b.h.event.init.call(this,c,()=>({[a]:d()}),f,k,n)}}})("click");(()=>{let a=b.g.i.Z();class c{constructor(f){this.Xa=f}La(...f){let k=this.Xa;if(!f.length)return b.g.i.get(k,a)||(11===this.M?k.content:1===this.M?k:void 0);b.g.i.set(k,a,f[0])}}class d extends c{constructor(f){super(f);f&&(this.M=f.matches("TEMPLATE")&&f.content?f.content.nodeType:1)}}b.Ma={Xa:d,
Ra:c}})();(()=>{var a=(e,g,h)=>{var r;for(g=b.m.nextSibling(g);e&&(r=e)!==g;)e=b.m.nextSibling(r),h(r,e)},c=(e,g)=>{if(e.length){var h=e[0],r=h.parentNode;a(h,e[e.length-1],t=>{1!==t.nodeType&&8!==t.nodeType||b.xb(g,t)});b.g.Da(e,r)}},d=(e,g,h,r)=>{var t=(e&&(e.nodeType?e:0<e.length?e[0]:null)||h||{}).ownerDocument;if("string"==typeof h){t=t||M;t=t.getElementById(h);if(!t)throw Error("Cannot find template with ID "+h);h=new b.Ma.Xa(t)}else if([1,8].includes(h.nodeType))h=new b.Ma.Ra(h);else throw Error("Unknown template type: "+
h);h=(h=h.La?h.La():null)?[...h.cloneNode(!0).childNodes]:null;if("number"!=typeof h.length||0<h.length&&"number"!=typeof h[0].nodeType)throw Error("Template engine must return an array of DOM nodes");t=!1;switch(g){case "replaceChildren":b.m.wa(e,h);t=!0;break;case "ignoreTargetNode":break;default:throw Error("Unknown renderMode: "+g);}t&&(c(h,r),"replaceChildren"==g&&b.l.notify(e,b.l.G));return h},f=(e,g,h)=>b.T(e)?e():"function"===typeof e?e(g,h):e;b.rc=function(e,g,h,r){h=h||{};var t=t||"replaceChildren";
if(r){var q=r.nodeType?r:0<r.length?r[0]:null;return b.s(()=>{var m=g instanceof b.fa?g:new b.fa(g,null,null,null,{exportDependencies:!0}),l=f(e,m.$data,m);d(r,t,l,m,h)},{qa:()=>!q||!b.g.Za(q),o:q})}console.log("no targetNodeOrNodeArray")};b.sc=(e,g,h,r,t)=>{function q(v,z){b.u.S(b.g.Qb,null,[r,v,p,h,u,z]);b.l.notify(r,b.l.G)}var m,l=h.as,p=(v,z)=>{m=t.createChildContext(v,{as:l,extend:x=>{x.$index=z;l&&(x[l+"Index"]=z)}});v=f(e,v,m);return d(r,"ignoreTargetNode",v,m,h)},u=(v,z)=>{c(z,m);m=null};
if(!h.beforeRemove&&b.Kb(g)){q(g.J());var w=g.subscribe(v=>{q(g(),v)},null,"arrayChange");w.o(r);return w}return b.s(()=>{var v=b.g.j(g)||[];"undefined"==typeof v.length&&(v=[v]);q(v)},{o:r})};var k=b.g.i.Z(),n=b.g.i.Z();b.h.template={init:(e,g)=>{g=b.g.j(g());if("string"==typeof g||"name"in g)b.m.ra(e);else if("nodes"in g){g=g.nodes||[];if(b.T(g))throw Error('The "nodes" option must be a plain, non-observable array.');let h=g[0]?.parentNode;h&&b.g.i.get(h,n)||(h=b.g.Mb(g),b.g.i.set(h,n,!0));(new b.Ma.Ra(e)).La(h)}else if(g=
b.m.childNodes(e),g.length)g=b.g.Mb(g),(new b.Ma.Ra(e)).La(g);else throw Error("Anonymous template defined, but no template content was provided");return{controlsDescendantBindings:!0}},update:(e,g,h,r,t)=>{var q=g();g=b.g.j(q);h=!0;r=null;"string"==typeof g?g={}:(q="name"in g?g.name:e,"if"in g&&(h=b.g.j(g["if"])),h&&"ifnot"in g&&(h=!b.g.j(g.ifnot)),h&&!q&&(h=!1));"foreach"in g?r=b.sc(q,h&&g.foreach||[],g,e,t):h?(h=t,"data"in g&&(h=t.createChildContext(g.data,{as:g.as,exportDependencies:!0})),r=b.rc(q,
h,g,e)):b.m.ra(e);t=r;b.g.i.get(e,k)?.A?.();b.g.i.set(e,k,!t||t.isActive&&!t.isActive()?void 0:t)}};b.I.Sa.template=e=>{e=b.I.nc(e);return 1==e.length&&e[0].unknown||b.I.lc(e,"name")?null:"This template engine does not support anonymous templates nested within its templates"};b.m.da.template=!0})();b.g.Hb=(a,c,d)=>{if(a.length&&c.length){var f,k,n,e,g;for(f=k=0;(!d||f<d)&&(e=a[k]);++k){for(n=0;g=c[n];++n)if(e.value===g.value){e.moved=g.index;g.moved=e.index;c.splice(n,1);f=n=0;break}f+=n}}};b.g.Cb=
(()=>{var a=(c,d,f,k,n)=>{var e=Math.min,g=Math.max,h=[],r,t=c.length,q,m=d.length,l=m-t||1,p=t+m+1,u;for(r=0;r<=t;r++){var w=u;h.push(u=[]);var v=e(m,r+l);for(q=g(0,r-1);q<=v;q++)u[q]=q?r?c[r-1]===d[q-1]?w[q-1]:e(w[q]||p,u[q-1]||p)+1:q+1:r+1}e=[];g=[];l=[];r=t;for(q=m;r||q;)m=h[r][q]-1,q&&m===h[r][q-1]?g.push(e[e.length]={status:f,value:d[--q],index:q}):r&&m===h[r-1][q]?l.push(e[e.length]={status:k,value:c[--r],index:r}):(--q,--r,n.sparse||e.push({status:"retained",value:d[q]}));b.g.Hb(l,g,!n.dontLimitMoves&&
10*t);return e.reverse()};return(c,d,f)=>{f="boolean"===typeof f?{dontLimitMoves:f}:f||{};c=c||[];d=d||[];return c.length<d.length?a(c,d,"added","deleted",f):a(d,c,"deleted","added",f)}})();(()=>{function a(f,k,n,e,g){var h=[],r=b.s(()=>{var t=k(n,g,b.g.Da(h,f))||[];if(0<h.length){var q=h.nodeType?[h]:h;if(0<q.length){var m=q[0],l=m.parentNode,p;var u=0;for(p=t.length;u<p;u++)l.insertBefore(t[u],m);u=0;for(p=q.length;u<p;u++)b.removeNode(q[u])}e&&b.u.S(e,null,[n,t,g])}h.length=0;h.push(...t)},{o:f,
qa:()=>!!h.find(b.g.Za)});return{O:h,Va:r.isActive()?r:void 0}}var c=b.g.i.Z(),d=b.g.i.Z();b.g.Qb=(f,k,n,e,g,h)=>{function r(B){x={ea:B,Ga:b.ca(p++)};m.push(x)}function t(B){x=q[B];x.Ga(p++);b.g.Da(x.O,f);m.push(x)}k=k||[];"undefined"==typeof k.length&&(k=[k]);e=e||{};var q=b.g.i.get(f,c),m=[],l=0,p=0,u=[],w=[],v=[],z=0;if(q){if(!h||q&&q._countWaitingForRemove)h=Array.prototype.map.call(q,B=>B.ea),h=b.g.Cb(h,k,{dontLimitMoves:e.dontLimitMoves,sparse:!0});for(let B=0,y,C,K;y=h[B];B++)switch(C=y.moved,
K=y.index,y.status){case "deleted":for(;l<K;)t(l++);if(void 0===C){var x=q[l];x.Va&&(x.Va.A(),x.Va=void 0);b.g.Da(x.O,f).length&&(e.beforeRemove&&(m.push(x),z++,x.ea===d?x=null:v[x.Ga.J()]=x),x&&u.push.apply(u,x.O))}l++;break;case "added":for(;p<K;)t(l++);void 0!==C?(w.push(m.length),t(C)):r(y.value)}for(;p<k.length;)t(l++);m._countWaitingForRemove=z}else k.forEach(r);b.g.i.set(f,c,m);u.forEach(e.beforeRemove?b.ga:b.removeNode);var E,D;z=f.ownerDocument.activeElement;if(w.length)for(;void 0!=(k=w.shift());){x=
m[k];for(E=void 0;k;)if((D=m[--k].O)&&D.length){E=D[D.length-1];break}for(l=0;u=x.O[l];E=u,l++)b.m.Jb(f,u,E)}for(k=0;x=m[k];k++){x.O||b.g.extend(x,a(f,n,x.ea,g,x.Ga));for(l=0;u=x.O[l];E=u,l++)b.m.Jb(f,u,E);!x.ic&&g&&(g(x.ea,x.O,x.Ga),x.ic=!0,E=x.O[x.O.length-1])}z&&f.ownerDocument.activeElement!=z&&z.focus();(function(B,y){if(B)for(var C=0,K=y.length;C<K;C++)y[C]&&y[C].O.forEach(H=>B(H,C,y[C].ea))})(e.beforeRemove,v);for(k=0;k<v.length;++k)v[k]&&(v[k].ea=d)}})();T.ko=P})(this);
(T=>{function O(a,c){return null===a||U[typeof a]?a===c:!1}function V(a,c){var d;return()=>{d||(d=setTimeout(()=>{d=0;a()},c))}}function W(a,c){var d;return()=>{clearTimeout(d);d=setTimeout(a,c)}}function X(a,c){c?.A?.()}function Y(a,c){var d=this.Zb,f=d[z];f.$||(this.Wa&&this.ya[c]?(d.vb(c,a,this.ya[c]),this.ya[c]=null,--this.Wa):f.B[c]||d.vb(c,a,f.C?{X:a}:d.Rb(a)),a.ka&&a.Vb())}var N=T.document,P={},b="undefined"!==typeof P?P:{};b.v=(a,c)=>{a=a.split(".");for(var d=b,f=0,k=a.length-1;f<k;f++)d=
d[a[f]];d[a[k]]=c};b.ha=(a,c,d)=>{a[c]=d};b.v("version","3.5.1-sm");b.g={extend:(a,c)=>c?Object.assign(a,c):a,O:(a,c)=>a&&Object.entries(a).forEach(d=>c(d[0],d[1])),$a:a=>[...a.childNodes].forEach(c=>b.removeNode(c)),Lb:a=>{a=[...a];var c=(a[0]?.ownerDocument||N).createElement("div");a.forEach(d=>c.append(b.fa(d)));return c},xa:(a,c)=>Array.prototype.map.call(a,c?d=>b.fa(d.cloneNode(!0)):d=>d.cloneNode(!0)),ta:(a,c)=>{b.g.$a(a);c&&a.append(...c)},Aa:(a,c)=>{if(a.length){for(c=8===c.nodeType&&c.parentNode||
c;a.length&&a[0].parentNode!==c;)a.splice(0,1);for(;1<a.length&&a[a.length-1].parentNode!==c;)--a.length;if(1<a.length){c=a[0];var d=a[a.length-1];for(a.length=0;c!==d;)a.push(c),c=c.nextSibling;a.push(d)}}return a},Qb:a=>null==a?"":a.trim?a.trim():a.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g,""),Za:a=>a.ownerDocument.documentElement.contains(1!==a.nodeType?a.parentNode:a),Sb:(a,c)=>{if(!a?.nodeType)throw Error("element must be a DOM node when calling triggerEvent");a.dispatchEvent(new Event(c))},
j:a=>b.T(a)?a():a,jb:(a,c)=>a.textContent=b.g.j(c)||""};b.v("utils",b.g);b.v("unwrap",b.g.j);(()=>{let a=0,c="__ko__"+Date.now(),d=new WeakMap;b.g.i={get:(f,k)=>(d.get(f)||{})[k],set:(f,k,n)=>{d.has(f)?d.get(f)[k]=n:d.set(f,{[k]:n});return n},bb:function(f,k,n){return this.get(f,k)||this.set(f,k,n)},clear:f=>d.delete(f),Z:()=>a++ +c}})();b.g.K=(()=>{var a=b.g.i.Z(),c={1:1,8:1,9:1},d={1:1,9:1};const f=(e,g)=>{var h=b.g.i.get(e,a);g&&!h&&(h=new Set,b.g.i.set(e,a,h));return h},k=e=>{var g=f(e);g&&(new Set(g)).forEach(h=>
h(e));b.g.i.clear(e);d[e.nodeType]&&n(e.childNodes,!0)},n=(e,g)=>{for(var h=[],t,r=0;r<e.length;r++)if(!g||8===e[r].nodeType)if(k(h[h.length]=t=e[r]),e[r]!==t)for(;r--&&!h.includes(e[r]););};return{na:(e,g)=>{if("function"!=typeof g)throw Error("Callback must be a function");f(e,1).add(g)},ib:(e,g)=>{var h=f(e);h&&(h.delete(g),h.size||b.g.i.set(e,a,null))},fa:e=>{b.u.S(()=>{c[e.nodeType]&&(k(e),d[e.nodeType]&&n(e.getElementsByTagName("*")))});return e},removeNode:e=>{b.fa(e);e.parentNode&&e.parentNode.removeChild(e)}}})();
b.fa=b.g.K.fa;b.removeNode=b.g.K.removeNode;b.v("utils.domNodeDisposal",b.g.K);b.v("utils.domNodeDisposal.addDisposeCallback",b.g.K.na);b.ab={debounce:(a,c)=>a.Ia(d=>W(d,c)),rateLimit:(a,c)=>{if("number"==typeof c)var d=c;else{d=c.timeout;var f=c.method}var k="function"==typeof f?f:V;a.Ia(n=>k(n,d,c))},notify:(a,c)=>{a.qa="always"==c?null:O}};var U={undefined:1,"boolean":1,number:1,string:1};b.v("extenders",b.ab);class Z{constructor(a,c,d){this.X=a;this.pb=c;this.Da=d;this.Oa=!1;this.L=this.ia=null;
b.ha(this,"dispose",this.A)}A(){this.Oa||(this.L&&b.g.K.ib(this.ia,this.L),this.Oa=!0,this.Da(),this.X=this.pb=this.Da=this.ia=this.L=null)}o(a){this.ia=a;b.g.K.na(a,this.L=this.A.bind(this))}}b.V=function(){Object.setPrototypeOf(this,H);H.Fa(this)};var H={Fa:a=>{a.W=new Map;a.W.set("change",new Set);a.ub=1},subscribe:function(a,c,d){var f=this;d=d||"change";var k=new Z(f,c?a.bind(c):a,()=>{f.W.get(d).delete(k);f.Pa?.(d)});f.Ra?.(d);f.W.has(d)||f.W.set(d,new Set);f.W.get(d).add(k);return k},D:function(a,
c){c=c||"change";"change"===c&&this.La();if(this.ra(c)){c="change"===c&&this.Tb||new Set(this.W.get(c));try{b.u.zb(),c.forEach(d=>{d.Oa||d.pb(a)})}finally{b.u.end()}}},Ca:function(){return this.ub},ec:function(a){return this.Ca()!==a},La:function(){++this.ub},Ia:function(a){var c=this,d=b.T(c),f,k,n,e,g;c.va||(c.va=c.D,c.D=(t,r)=>{r&&"change"!==r?"beforeChange"===r?c.rb(t):c.va(t,r):c.sb(t)});var h=a(()=>{c.ka=!1;d&&e===c&&(e=c.qb?c.qb():c());var t=k||g&&c.Ha(n,e);g=k=f=!1;t&&c.va(n=e)});c.sb=(t,
r)=>{r&&c.ka||(g=!r);c.Tb=new Set(c.W.get("change"));c.ka=f=!0;e=t;h()};c.rb=t=>{f||(n=t,c.va(t,"beforeChange"))};c.tb=()=>{g=!0};c.Vb=()=>{c.Ha(n,c.P(!0))&&(k=!0)}},ra:function(a){return(this.W.get(a)||[]).size},Ha:function(a,c){return!this.qa||!this.qa(a,c)},toString:()=>"[object Object]",extend:function(a){var c=this;a&&b.g.O(a,(d,f)=>{d=b.ab[d];"function"==typeof d&&(c=d(c,f)||c)});return c}};b.ha(H,"init",H.Fa);b.ha(H,"subscribe",H.subscribe);b.ha(H,"extend",H.extend);Object.setPrototypeOf(H,
Function.prototype);b.V.fn=H;b.jc=a=>"function"==typeof a?.subscribe&&"function"==typeof a.D;(()=>{var a=[],c,d=0;b.u={zb:f=>{a.push(c);c=f},end:()=>c=a.pop(),Ob:f=>{if(c){if(!b.jc(f))throw Error("Only subscribable things can act as dependencies");c.Xb.call(c.Yb,f,f.Ub||(f.Ub=++d))}},S:(f,k,n)=>{try{return a.push(c),c=void 0,f.apply(k,n||[])}finally{c=a.pop()}},Ba:()=>c?.s.Ba(),eb:()=>c?.eb,s:()=>c?.s}})();const G=Symbol("_latestValue");b.ba=a=>{function c(){if(0<arguments.length)return c.Ha(c[G],
arguments[0])&&(c.nb(),c[G]=arguments[0],c.Ma()),this;b.u.Ob(c);return c[G]}c[G]=a;Object.defineProperty(c,"length",{get:()=>null==c[G]?void 0:c[G].length});b.V.fn.Fa(c);Object.setPrototypeOf(c,J);return c};var J={toJSON:function(){let a=this[G];return a?.toJSON?.()||a},qa:O,P:function(){return this[G]},Ma:function(){this.D(this[G],"spectate");this.D(this[G])},nb:function(){this.D(this[G],"beforeChange")}};Object.setPrototypeOf(J,b.V.fn);var K=b.ba.pc="__ko_proto__";J[K]=b.ba;b.T=a=>{if((a="function"==
typeof a&&a[K])&&a!==J[K]&&a!==b.s.fn[K])throw Error("Invalid object that looks like an observable; possibly from another Knockout instance");return!!a};b.kc=a=>"function"==typeof a&&(a[K]===J[K]||a[K]===b.s.fn[K]&&a.fc);b.v("observable",b.ba);b.v("isObservable",b.T);b.v("observable.fn",J);b.ha(J,"valueHasMutated",J.Ma);b.ja=a=>{a=a||[];if("object"!=typeof a||!("length"in a))throw Error("The argument passed when initializing an observable array must be an array, or null, or undefined.");a=b.ba(a);
Object.setPrototypeOf(a,b.ja.fn);return a.extend({trackArrayChanges:!0})};b.ja.fn={remove:function(a){for(var c=this.P(),d=!1,f="function"!=typeof a||b.T(a)?e=>e===a:a,k=c.length;k--;){var n=c[k];if(f(n)){if(c[k]!==n)throw Error("Array modified during remove; cannot remove item");d||this.nb();d=!0;c.splice(k,1)}}d&&this.Ma()}};Object.setPrototypeOf(b.ja.fn,b.ba.fn);Object.getOwnPropertyNames(Array.prototype).forEach(a=>{"function"===typeof Array.prototype[a]&&"constructor"!=a&&("copyWithin fill pop push reverse shift sort splice unshift".split(" ").includes(a)?
b.ja.fn[a]=function(...c){var d=this.P();this.nb();this.Bb(d,a,c);c=d[a](...c);this.Ma();return c===d?this:c}:b.ja.fn[a]=function(...c){return this()[a](...c)})});b.Jb=a=>b.T(a)&&"function"==typeof a.remove&&"function"==typeof a.push;b.v("observableArray",b.ja);b.v("isObservableArray",b.Jb);b.ab.trackArrayChanges=(a,c)=>{function d(){function p(){if(g){var m=[].concat(a.P()||[]);if(a.ra("arrayChange")){if(!k||1<g)k=b.g.Cb(h,m,a.Ta);var l=k}h=m;k=null;g=0;l?.length&&a.D(l,"arrayChange")}}f?p():(f=
!0,e=a.subscribe(()=>++g,null,"spectate"),h=[].concat(a.P()||[]),k=null,n=a.subscribe(p))}a.Ta={};"object"==typeof c&&b.g.extend(a.Ta,c);a.Ta.sparse=!0;if(!a.Bb){var f=!1,k=null,n,e,g=0,h,t=a.Ra,r=a.Pa;a.Ra=p=>{t?.call(a,p);"arrayChange"===p&&d()};a.Pa=p=>{r?.call(a,p);"arrayChange"!==p||a.ra("arrayChange")||(n?.A(),e?.A(),e=n=null,f=!1,h=void 0)};a.Bb=(p,m,l)=>{function q(A,w,C){return v[v.length]={status:A,value:w,index:C}}if(f&&!g){var v=[],x=p.length,u=l.length,y=0;switch(m){case "push":y=x;case "unshift":for(p=
0;p<u;p++)q("added",l[p],y+p);break;case "pop":y=x-1;case "shift":x&&q("deleted",p[y],y);break;case "splice":y=Math.min(Math.max(0,0>l[0]?x+l[0]:l[0]),x);x=1===u?x:Math.min(y+(l[1]||0),x);u=y+u-2;m=Math.max(x,u);for(var B=[],D=[],F=2;y<m;++y,++F)y<x&&D.push(q("deleted",p[y],y)),y<u&&B.push(q("added",l[F],y));b.g.Hb(D,B);break;default:return}k=v}}}};var z=Symbol("_state");b.s=(a,c)=>{function d(){if(0<arguments.length){if("function"!==typeof f)throw Error("Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.");
f(...arguments);return this}k.$||b.u.Ob(d);(k.Y||k.C&&d.sa())&&d.U();return k.M}"object"===typeof a?c=a:(c=c||{},a&&(c.read=a));if("function"!=typeof c.read)throw Error("Pass a function that returns the value of the ko.computed");var f=c.write,k={M:void 0,aa:!0,Y:!0,Ga:!1,lb:!1,$:!1,hb:!1,C:!1,Nb:c.read,o:c.disposeWhenNodeIsRemoved||c.o||null,oa:c.disposeWhen||c.oa,Ya:null,B:{},J:0,Gb:null};d[z]=k;d.fc="function"===typeof f;b.V.fn.Fa(d);Object.setPrototypeOf(d,M);c.pure&&(k.hb=!0,k.C=!0,b.g.extend(d,
aa));k.o&&(k.lb=!0,k.o.nodeType||(k.o=null));k.C||d.U();k.o&&d.isActive()&&b.g.K.na(k.o,k.Ya=()=>{d.A()});return d};var M={qa:O,Ba:function(){return this[z].J},cc:function(){var a=[];b.g.O(this[z].B,(c,d)=>a[d.la]=d.X);return a},cb:function(a){if(!this[z].J)return!1;var c=this.cc();return c.includes(a)||!!c.find(d=>d.cb&&d.cb(a))},vb:function(a,c,d){if(this[z].hb&&c===this)throw Error("A 'pure' computed must not be called recursively");this[z].B[a]=d;d.la=this[z].J++;d.ma=c.Ca()},sa:function(){var a,
c=this[z].B;for(a in c)if(Object.prototype.hasOwnProperty.call(c,a)){var d=c[a];if(this.ua&&d.X.ka||d.X.ec(d.ma))return!0}},vc:function(){this[z].Ga||this.ua?.(!1)},isActive:function(){var a=this[z];return a.Y||0<a.J},wc:function(){this.ka?this[z].Y&&(this[z].aa=!0):this.Fb()},Rb:function(a){return a.subscribe(this.Fb,this)},Fb:function(){var a=this,c=a.throttleEvaluation;0<=c?(clearTimeout(this[z].Gb),this[z].Gb=setTimeout(()=>a.U(!0),c)):a.ua?a.ua(!0):a.U(!0)},U:function(a){var c=this[z],d=c.oa,
f=!1;if(!c.Ga&&!c.$){if(c.o&&!b.g.Za(c.o)||d?.()){if(!c.lb){this.A();return}}else c.lb=!1;try{c.Ga=!0,f=this.ac(a)}finally{c.Ga=!1}return f}},ac:function(a){var c=this[z],d=c.hb?void 0:!c.J;var f={Zb:this,ya:c.B,Wa:c.J};b.u.zb({Yb:f,Xb:Y,s:this,eb:d});c.B={};c.J=0;a:{try{var k=c.Nb();break a}finally{b.u.end(),f.Wa&&!c.C&&b.g.O(f.ya,X),c.aa=c.Y=!1}k=void 0}c.J?f=this.Ha(c.M,k):(this.A(),f=!0);f&&(c.C?this.La():this.D(c.M,"beforeChange"),c.M=k,this.D(c.M,"spectate"),!c.C&&a&&this.D(c.M),this.tb&&this.tb());
d&&this.D(c.M,"awake");return f},P:function(a){var c=this[z];(c.Y&&(a||!c.J)||c.C&&this.sa())&&this.U();return c.M},Ia:function(a){var c=this;b.V.fn.Ia.call(c,a);c.qb=()=>{c[z].C||(c[z].aa?c.U():c[z].Y=!1);return c[z].M};c.ua=d=>{c.rb(c[z].M);c[z].Y=!0;d&&(c[z].aa=!0);c.sb(c,!d)}},A:function(){var a=this[z];!a.C&&a.B&&b.g.O(a.B,(c,d)=>d.A?.());a.o&&a.Ya&&b.g.K.ib(a.o,a.Ya);a.B=void 0;a.J=0;a.$=!0;a.aa=!1;a.Y=!1;a.C=!1;a.o=void 0;a.oa=void 0;a.Nb=void 0}},aa={Ra:function(a){var c=this,d=c[z];if(!d.$&&
d.C&&"change"==a){d.C=!1;if(d.aa||c.sa())d.B=null,d.J=0,c.U()&&c.La();else{var f=[];b.g.O(d.B,(k,n)=>f[n.la]=k);f.forEach((k,n)=>{var e=d.B[k],g=c.Rb(e.X);g.la=n;g.ma=e.ma;d.B[k]=g});c.sa()&&c.U()&&c.La()}d.$||c.D(d.M,"awake")}},Pa:function(a){var c=this[z];c.$||"change"!=a||this.ra("change")||(b.g.O(c.B,(d,f)=>{f.A&&(c.B[d]={X:f.X,la:f.la,ma:f.ma},f.A())}),c.C=!0,this.D(void 0,"asleep"))},Ca:function(){var a=this[z];a.C&&(a.aa||this.sa())&&this.U();return b.V.fn.Ca.call(this)}};Object.setPrototypeOf(M,
b.V.fn);var Q=b.ba.pc;M[Q]=b.s;b.v("computed",b.s);b.v("isComputed",a=>"function"==typeof a&&a[Q]===M[Q]);b.v("computed.fn",M);b.ha(M,"dispose",M.A);b.qc=a=>{if("function"===typeof a)return b.s(a,{pure:!0});a={...a,pure:!0};return b.s(a)};(()=>{b.F={R:a=>{switch(a.nodeName){case "OPTION":return!0===a.__ko__hasDomDataOptionValue__?b.g.i.get(a,b.h.options.gb):a.value;case "SELECT":return 0<=a.selectedIndex?b.F.R(a.options[a.selectedIndex]):void 0;default:return a.value}},Na:(a,c,d)=>{switch(a.nodeName){case "OPTION":"string"===
typeof c?(b.g.i.set(a,b.h.options.gb,void 0),delete a.__ko__hasDomDataOptionValue__,a.value=c):(b.g.i.set(a,b.h.options.gb,c),a.__ko__hasDomDataOptionValue__=!0,a.value="number"===typeof c?c:"");break;case "SELECT":for(var f=-1,k=""===c||null==c,n=a.options.length,e;n--;)if(e=b.F.R(a.options[n]),e==c||""===e&&k){f=n;break}if(d||0<=f||k&&1<a.size)a.selectedIndex=f;break;default:a.value=null==c?"":c}}}})();b.I=(()=>{function a(g){g=b.g.Qb(g);123===g.charCodeAt(0)&&(g=g.slice(1,-1));g+="\n,";var h=[],
t=g.match(f),r=[],p=0;if(1<t.length){for(var m=0,l;l=t[m++];){var q=l.charCodeAt(0);if(44===q){if(0>=p){h.push(v&&r.length?{key:v,value:r.join("")}:{unknown:v||r.join("")});var v=p=0;r=[];continue}}else if(58===q){if(!p&&!v&&1===r.length){v=r.pop();continue}}else if(47===q&&1<l.length&&(47===l.charCodeAt(1)||42===l.charCodeAt(1)))continue;else 47===q&&m&&1<l.length?(q=t[m-1].match(k))&&!n[q[0]]&&(g=g.slice(g.indexOf(l)+1),t=g.match(f),m=-1,l="/"):40===q||123===q||91===q?++p:41===q||125===q||93===
q?--p:v||r.length||34!==q&&39!==q||(l=l.slice(1,-1));r.push(l)}if(0<p)throw Error("Unbalanced parentheses, braces, or brackets");}return h}var c=["true","false","null","undefined"],d=/^(?:[$_a-z][$\w]*|(.+)(\.\s*[$_a-z][$\w]*|\[.+\]))$/i,f=RegExp("\"(?:\\\\.|[^\"])*\"|'(?:\\\\.|[^'])*'|`(?:\\\\.|[^`])*`|/\\*(?:[^*]|\\*+[^*/])*\\*+/|//.*\n|/(?:\\\\.|[^/])+/w*|[^\\s:,/][^,\"'`{}()/:[\\]]*[^\\s,\"'`{}()/:[\\]]|[^\\s]","g"),k=/[\])"'A-Za-z0-9_$]+$/,n={"in":1,"return":1,"typeof":1},e=new Set;return{Sa:[],
mb:e,nc:a,oc:function(g,h){function t(q,v){if(!l){var x=b.h[q];if(x&&x.preprocess&&!(v=x.preprocess(v,q,t)))return;if(x=e.has(q)){var u=v;c.includes(u)?u=!1:(x=u.match(d),u=null===x?!1:x[1]?"Object("+x[1]+")"+x[2]:u);x=u}x&&p.push("'"+q+"':function(_z){"+u+"=_z}")}m&&(v="function(){return "+v+" }");r.push("'"+q+"':"+v)}h=h||{};var r=[],p=[],m=h.valueAccessors,l=h.bindingParams;("string"===typeof g?a(g):g).forEach(q=>t(q.key||q.unknown,q.value));p.length&&t("_ko_property_writers","{"+p.join(",")+" }");
return r.join(",")},lc:(g,h)=>-1<g.findIndex(t=>t.key==h),ob:(g,h,t,r,p)=>{if(g&&b.T(g))!b.kc(g)||p&&g.P()===r||g(r);else h.get("_ko_property_writers")?.[t]?.(r)}}})();(()=>{function a(e){return 8==e.nodeType&&f.test(e.nodeValue)}function c(e){return 8==e.nodeType&&k.test(e.nodeValue)}function d(e,g){for(var h=e,t=1,r=[];h=h.nextSibling;){if(c(h)&&(b.g.i.set(h,n,!0),!--t))return r;r.push(h);a(h)&&++t}if(!g)throw Error("Cannot find closing comment tag to match: "+e.nodeValue);return null}var f=/^\s*ko(?:\s+([\s\S]+))?\s*$/,
k=/^\s*\/ko\s*$/,n="__ko_matchedEndComment__";b.m={ca:{},childNodes:e=>a(e)?d(e):e.childNodes,pa:e=>{a(e)?(e=d(e))&&[...e].forEach(g=>b.removeNode(g)):b.g.$a(e)},ta:(e,g)=>{a(e)?(b.m.pa(e),e.after(...g)):b.g.ta(e,g)},prepend:(e,g)=>{a(e)?e.nextSibling.before(g):e.prepend(g)},ic:(e,g,h)=>{h?h.after(g):b.m.prepend(e,g)},firstChild:e=>{if(a(e))return e=e.nextSibling,!e||c(e)?null:e;let g=e.firstChild;if(g&&c(g))throw Error("Found invalid end comment, as the first child of "+e);return g},nextSibling:e=>
{if(a(e)){var g=d(e,void 0);e=g?(g.length?g[g.length-1]:e).nextSibling:null}if((g=e.nextSibling)&&c(g)){if(c(g)&&!b.g.i.get(g,n))throw Error("Found end comment without a matching opening comment, as child of "+e);return null}return g},dc:a,uc:e=>(e=e.nodeValue.match(f))?e[1]:null}})();(()=>{const a=new Map;b.Ab=new class{mc(c){switch(c.nodeType){case 1:return null!=c.getAttribute("data-bind");case 8:return b.m.dc(c);default:return!1}}bc(c,d){a:{switch(c.nodeType){case 1:var f=c.getAttribute("data-bind");
break a;case 8:f=b.m.uc(c);break a}f=null}if(f)try{let n={valueAccessors:!0},e=a.get(f);if(!e){var k="with($context){with($data||{}){return{"+b.I.oc(f,n)+"}}}";e=new Function("$context","$element",k);a.set(f,e)}return e(d,c)}catch(n){throw n.message="Unable to parse bindings.\nBindings value: "+f+"\nMessage: "+n.message,n;}return null}}})();(()=>{function a(m){m=b.g.i.get(m,r);var l=m?.H;l&&(m.H=null,l.Mb())}function c(m,l){for(var q,v=b.m.firstChild(l);q=v;)v=b.m.nextSibling(q),d(m,q);b.l.notify(l,
b.l.G)}function d(m,l){var q=m;if(1===l.nodeType||b.Ab.mc(l))q=k(l,null,m).bindingContextForDescendants;q&&!l.matches?.("SCRIPT,TEXTAREA,TEMPLATE")&&c(q,l)}function f(m){var l=[],q={},v=[];b.g.O(m,function y(u){if(!q[u]){var B=b.h[u];B&&(B.after&&(v.push(u),B.after.forEach(D=>{if(m[D]){if(v.includes(D))throw Error("Cannot combine the following bindings, because they have a cyclic dependency: "+v.join(", "));y(D)}}),v.length--),l.push({key:u,Ib:B}));q[u]=!0}});return l}function k(m,l,q){var v=b.g.i.bb(m,
r,{}),x=v.Wb;if(!l){if(x)throw Error("You cannot apply bindings multiple times to the same element.");v.Wb=!0}x||(v.context=q);v.fb||(v.fb={});if(l&&"function"!==typeof l)var u=l;else{var y=b.s(()=>{if(u=l?l(q,m):b.Ab.bc(m,q))q[e]?.(),q[h]?.();return u},{o:m});u&&y.isActive()||(y=null)}var B=q,D;if(u){var F=y?w=>()=>y()[w]():w=>u[w],A={get:w=>u[w]&&F(w)(),has:w=>w in u};b.l.G in u&&b.l.subscribe(m,b.l.G,()=>{var w=u[b.l.G]();if(w){var C=b.m.childNodes(m);C.length&&w(C,b.Eb(C[0]))}});b.l.ga in u&&
(B=b.l.kb(m,q),b.l.subscribe(m,b.l.ga,()=>{var w=u[b.l.ga]();w&&b.m.firstChild(m)&&w(m)}));f(u).forEach(w=>{var C=w.Ib.init,E=w.Ib.update,I=w.key;if(8===m.nodeType&&!b.m.ca[I])throw Error("The binding '"+I+"' cannot be used with virtual elements");try{"function"==typeof C&&b.u.S(()=>{var L=C(m,F(I),A,B.$data,B);if(L&&L.controlsDescendantBindings){if(void 0!==D)throw Error("Multiple bindings ("+D+" and "+I+") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");
D=I}}),"function"==typeof E&&b.s(()=>E(m,F(I),A,B.$data,B),{o:m})}catch(L){throw L.message='Unable to process binding "'+I+": "+u[I]+'"\nMessage: '+L.message,L;}})}v=void 0===D;return{shouldBindDescendants:v,bindingContextForDescendants:v&&B}}function n(m,l){return m&&m instanceof b.ea?m:new b.ea(m,void 0,void 0,l)}var e=Symbol("_subscribable"),g=Symbol("_ancestorBindingInfo"),h=Symbol("_dataDependency");b.h={};var t={};b.ea=class{constructor(m,l,q,v,x){var u=this,y=m===t,B=y?void 0:m,D="function"==
typeof B&&!b.T(B),F=x?.dataDependency;m=()=>{var w=D?B():B,C=b.g.j(w);l?(b.g.extend(u,l),g in l&&(u[g]=l[g])):(u.$parents=[],u.$root=C,u.ko=b);u[e]=A;y?C=u.$data:(u.$rawData=w,u.$data=C);q&&(u[q]=C);v?.(u,l,C);if(l?.[e]&&!b.u.s().cb(l[e]))l[e]();F&&(u[h]=F);return u.$data};if(x?.exportDependencies)m();else{var A=b.qc(m);A.P();A.isActive()?A.qa=null:u[e]=void 0}}createChildContext(m,l,q,v){!v&&l&&"object"==typeof l&&(v=l,l=v.as,q=v.extend);return new b.ea(m,this,l,(x,u)=>{x.$parentContext=u;x.$parent=
u.$data;x.$parents=(u.$parents||[]).slice(0);x.$parents.unshift(x.$parent);q&&q(x)},v)}extend(m,l){return new b.ea(t,this,null,q=>b.g.extend(q,"function"==typeof m?m(q):m),l)}};var r=b.g.i.Z();class p{constructor(m,l,q){this.L=m;this.ia=l;this.wa=new Set;this.G=!1;l.H||b.g.K.na(m,a);q?.H&&(q.H.wa.add(m),this.Da=q)}Mb(){this.Da?.H?.$b(this.L)}$b(m){this.wa.delete(m);this.wa.size||this.Db?.()}Db(){this.G=!0;this.ia.H&&!this.wa.size&&(this.ia.H=null,b.g.K.ib(this.L,a),b.l.notify(this.L,b.l.ga),this.Mb())}}
b.l={G:"childrenComplete",ga:"descendantsComplete",subscribe:(m,l,q,v,x)=>{var u=b.g.i.bb(m,r,{});u.za||(u.za=new b.V);x?.notifyImmediately&&u.fb[l]&&b.u.S(q,v,[m]);return u.za.subscribe(q,v,l)},notify:(m,l)=>{var q=b.g.i.get(m,r);if(q&&(q.fb[l]=!0,q.za?.D(m,l),l==b.l.G))if(q.H)q.H.Db();else if(void 0===q.H&&q.za?.ra(b.l.ga))throw Error("descendantsComplete event not supported for bindings on this node");},kb:(m,l)=>{var q=b.g.i.bb(m,r,{});q.H||(q.H=new p(m,q,l[g]));return l[g]==q?l:l.extend(v=>{v[g]=
q})}};b.tc=m=>(m=b.g.i.get(m,r))&&m.context;b.wb=(m,l,q)=>k(m,l,n(q));b.yb=(m,l)=>{1!==l.nodeType&&8!==l.nodeType||c(n(m),l)};b.xb=function(m,l,q){if(2>arguments.length){if(l=N.body,!l)throw Error("ko.applyBindings: could not find document.body; has the document been loaded?");}else if(!l||1!==l.nodeType&&8!==l.nodeType)throw Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node");d(n(m,q),l)};b.Eb=m=>(m=m&&[1,8].includes(m.nodeType)&&b.tc(m))?m.$data:
void 0;b.v("bindingHandlers",b.h);b.v("applyBindings",b.xb);b.v("applyBindingAccessorsToNode",b.wb);b.v("dataFor",b.Eb)})();(()=>{var a=Object.create(null),c=new Map;b.Ua={get:(n,e)=>{if(c.has(n))e(c.get(n));else{var g=a[n];g?g.subscribe(e):(g=a[n]=new b.V,g.subscribe(e),k(n,h=>{c.set(n,h);delete a[n];g.D(h)}))}},register:(n,e)=>{if(!e)throw Error("Invalid configuration for "+n);if(d[n])throw Error("Component "+n+" is already registered");d[n]=e}};var d=Object.create(null),f=(n,e)=>{throw Error(`Component '${n}': ${e}`);
},k=(n,e)=>{var g={},h=d[n]||{},t=h.template;h=h.viewModel;if(t){t.element||f(n,"Unknown template value: "+t);t=t.element;var r=N.getElementById(t);r||f(n,"Cannot find element with ID "+t);r.matches("TEMPLATE")||f(n,"Template Source Element not a <template>");g.template=b.g.xa(r.content.childNodes)}h&&("function"!==typeof h.createViewModel&&f(n,"Unknown viewModel value: "+h),g.createViewModel=h.createViewModel);e(g.template&&g.createViewModel?g:null)};b.v("components",b.Ua);b.v("components.register",
b.Ua.register)})();(()=>{var a=0;b.h.component={init:(c,d,f,k,n)=>{var e,g,h,t=()=>{var p=e&&e.dispose;"function"===typeof p&&p.call(e);h&&h.A();g=e=h=null},r=[...b.m.childNodes(c)];b.m.pa(c);b.g.K.na(c,t);b.s(()=>{var p=b.g.j(d());if("string"!==typeof p){var m=b.g.j(p.params);p=b.g.j(p.name)}if(!p)throw Error("No component name specified");var l=b.l.kb(c,n),q=g=++a;b.Ua.get(p,v=>{if(g===q){t();if(!v)throw Error("Unknown component '"+p+"'");var x=v.template;if(!x)throw Error("Component '"+p+"' has no template");
b.m.ta(c,b.g.xa(x));e=v.createViewModel(m,{element:c,templateNodes:r});b.yb(l.createChildContext(e,{extend:u=>{u.$component=e;u.$componentTemplateNodes=r}}),c)}})},{o:c});return{controlsDescendantBindings:!0}}};b.m.ca.component=!0})();b.h.attr={update:(a,c)=>{c=b.g.j(c())||{};b.g.O(c,function(d,f){f=b.g.j(f);var k=d.indexOf(":");k="lookupNamespaceURI"in a&&0<k&&a.lookupNamespaceURI(d.slice(0,k));var n=!1===f||null==f;n?k?a.removeAttributeNS(k,d):a.removeAttribute(d):(f=f.toString(),k?a.setAttributeNS(k,
d,f):a.setAttribute(d,f));"name"===d&&(a.name=n?"":f)})}};var R=(a,c,d)=>c&&c.split(/\s+/).forEach(f=>a.classList.toggle(f,d));b.h.css={update:(a,c)=>{c=b.g.j(c());"object"==typeof c?b.g.O(c,(d,f)=>{f=b.g.j(f);R(a,d,!!f)}):(c=b.g.Qb(c),R(a,a.__ko__cssValue,!1),a.__ko__cssValue=c,R(a,c,!0))}};b.h.enable={update:(a,c)=>{(c=b.g.j(c()))&&a.disabled?a.removeAttribute("disabled"):c||a.disabled||(a.disabled=!0)}};b.h.disable={update:(a,c)=>b.h.enable.update(a,()=>!b.g.j(c()))};b.h.event={init:(a,c,d,f,k)=>
{d=c()||{};b.g.O(d,n=>{"string"==typeof n&&a.addEventListener(n,(...e)=>{var g=c()[n];if(g)try{f=k.$data;var h=g.apply(f,[f,...e])}finally{!0!==h&&e[0].preventDefault()}})})}};b.h.foreach={Kb:a=>()=>{var c=a(),d=b.T(c)?c.P():c;if(!d||"number"==typeof d.length)return{foreach:c};b.g.j(c);return{foreach:d.data,as:d.as,beforeRemove:d.beforeRemove}},init:(a,c)=>b.h.template.init(a,b.h.foreach.Kb(c)),update:(a,c,d,f,k)=>b.h.template.update(a,b.h.foreach.Kb(c),d,f,k)};b.I.Sa.foreach=!1;b.m.ca.foreach=!0;
b.h.hasfocus={init:(a,c,d)=>{var f=n=>{a.__ko_hasfocusUpdating=!0;n=a.ownerDocument.activeElement===a;var e=c();b.I.ob(e,d,"hasfocus",n,!0);a.__ko_hasfocusLastValue=n;a.__ko_hasfocusUpdating=!1},k=f.bind(null,!0);f=f.bind(null,!1);a.addEventListener("focus",k);a.addEventListener("focusin",k);a.addEventListener("blur",f);a.addEventListener("focusout",f);a.__ko_hasfocusLastValue=!1},update:(a,c)=>{c=!!b.g.j(c());a.__ko_hasfocusUpdating||a.__ko_hasfocusLastValue===c||(c?a.focus():a.blur())}};b.I.mb.add("hasfocus");
b.h.html={init:()=>({controlsDescendantBindings:!0}),update:(a,c)=>{b.g.$a(a);c=b.g.j(c());if(null!=c){const d=N.createElement("template");d.innerHTML="string"!=typeof c?c.toString():c;a.appendChild(d.content)}}};(()=>{function a(c,d,f){b.h[c]={init:(k,n,e,g,h)=>{var t,r={};d&&(r={as:e.get("as"),exportDependencies:!0});var p=e.has(b.l.ga);b.s(()=>{var m=b.g.j(n()),l=!f!==!m,q=!t;p&&(h=b.l.kb(k,h));if(l){r.dataDependency=b.u.s();var v=d?h.createChildContext("function"==typeof m?m:n,r):b.u.Ba()?h.extend(null,
r):h}q&&b.u.Ba()&&(t=b.g.xa(b.m.childNodes(k),!0));l?(q||b.m.ta(k,b.g.xa(t)),b.yb(v,k)):(b.m.pa(k),b.l.notify(k,b.l.G))},{o:k});return{controlsDescendantBindings:!0}}};b.I.Sa[c]=!1;b.m.ca[c]=!0}a("if");a("ifnot",!1,!0);a("with",!0)})();var S={};b.h.options={init:a=>{if(!a.matches("SELECT"))throw Error("options binding applies only to SELECT elements");let c=a.length;for(;c--;)a.remove(c);return{controlsDescendantBindings:!0}},update:(a,c,d)=>{var f=a.multiple,k=0!=a.length&&f?a.scrollTop:null,n=b.g.j(c()),
e=d.get("valueAllowUnset")&&d.has("value"),g={},h=[];c=()=>Array.from(a.options).filter(l=>l.selected);var t=(l,q,v)=>{var x=typeof q;return"function"==x?q(l):"string"==x?l[q]:v},r=(l,q)=>{m&&e?b.l.notify(a,b.l.G):h.length&&(l=h.includes(b.F.R(q[0])),q[0].selected=l,m&&!l&&b.u.S(b.g.Sb,null,[a,"change"]))};e||(f?h=c().map(b.F.R):0<=a.selectedIndex&&h.push(b.F.R(a.options[a.selectedIndex])));if(n){"undefined"==typeof n.length&&(n=[n]);var p=n.filter(l=>l||null==l);d.has("optionsCaption")&&(n=b.g.j(d.get("optionsCaption")),
null!==n&&void 0!==n&&p.unshift(S))}var m=!1;g.beforeRemove=l=>a.removeChild(l);n=r;d.has("optionsAfterRender")&&"function"==typeof d.get("optionsAfterRender")&&(n=(l,q)=>{r(l,q);b.u.S(d.get("optionsAfterRender"),null,[q[0],l!==S?l:void 0])});b.g.Pb(a,p,(l,q,v)=>{v.length&&(h=!e&&v[0].selected?[b.F.R(v[0])]:[],m=!0);q=a.ownerDocument.createElement("option");l===S?(b.g.jb(q,d.get("optionsCaption")),b.F.Na(q,void 0)):(v=t(l,d.get("optionsValue"),l),b.F.Na(q,b.g.j(v)),l=t(l,d.get("optionsText"),v),b.g.jb(q,
l));return[q]},g,n);e||(p=h.length,(f?p&&c().length<p:p&&0<=a.selectedIndex?b.F.R(a.options[a.selectedIndex])!==h[0]:p||0<=a.selectedIndex)&&b.u.S(b.g.Sb,null,[a,"change"]));(e||b.u.eb())&&b.l.notify(a,b.l.G);k&&20<Math.abs(k-a.scrollTop)&&(a.scrollTop=k)}};b.h.options.gb=b.g.i.Z();b.h.style={update:(a,c)=>{c=b.g.j(c()||{});b.g.O(c,(d,f)=>{f=b.g.j(f);if(null==f||!1===f)f="";if(/^--/.test(d))a.style.setProperty(d,f);else{d=d.replace(/-(\w)/g,(n,e)=>e.toUpperCase());var k=a.style[d];a.style[d]=f;f===
k||a.style[d]!=k||isNaN(f)||(a.style[d]=f+"px")}})}};b.h.submit={init:(a,c,d,f,k)=>{if("function"!=typeof c())throw Error("The value for a submit binding must be a function");a.addEventListener("submit",n=>{var e=c();try{var g=e.call(k.$data,a)}finally{!0!==g&&n.preventDefault()}})}};b.h.text={init:()=>({controlsDescendantBindings:!0}),update:(a,c)=>{8===a.nodeType&&(a.text||a.after(a.text=N.createTextNode("")),a=a.text);b.g.jb(a,c())}};b.m.ca.text=!0;b.h.textInput={init:(a,c,d)=>{var f=a.value,k,
n,e=()=>{clearTimeout(k);n=k=void 0;var h=a.value;f!==h&&(f=h,b.I.ob(c(),d,"textInput",h))},g=()=>{var h=b.g.j(c());null==h&&(h="");void 0!==n&&h===n?setTimeout(g,4):a.value!==h&&(a.value=h,f=a.value)};a.addEventListener("input",e);a.addEventListener("change",e);a.addEventListener("blur",e);b.s(g,{o:a})}};b.I.mb.add("textInput");b.h.textinput={preprocess:(a,c,d)=>d("textInput",a)};b.h.value={init:(a,c,d)=>{var f=a.matches("SELECT"),k=a.matches("INPUT");if(!k||"checkbox"!=a.type&&"radio"!=a.type){var n=
new Set,e=d.get("valueUpdate"),g=null;e&&("string"==typeof e?n.add(e):e.forEach(p=>n.add(p)),n.delete("change"));var h=()=>{g=null;var p=c(),m=b.F.R(a);b.I.ob(p,d,"value",m)};n.forEach(p=>{var m=h;(p||"").startsWith("after")&&(m=()=>{g=b.F.R(a);setTimeout(h,0)},p=p.slice(5));a.addEventListener(p,m)});var t=k&&"file"==a.type?()=>{var p=b.g.j(c());null==p||""===p?a.value="":b.u.S(h)}:()=>{var p=b.g.j(c()),m=b.F.R(a);if(null!==g&&p===g)setTimeout(t,0);else if(p!==m||void 0===m)f?(m=d.get("valueAllowUnset"),
b.F.Na(a,p,m),m||p===b.F.R(a)||b.u.S(h)):b.F.Na(a,p)};if(f){var r;b.l.subscribe(a,b.l.G,()=>{r?d.get("valueAllowUnset")?t():h():(a.addEventListener("change",h),r=b.s(t,{o:a}))},null,{notifyImmediately:!0})}else a.addEventListener("change",h),b.s(t,{o:a})}else b.wb(a,{checkedValue:c})},update:()=>{}};b.I.mb.add("value");b.h.visible={update:(a,c)=>{c=b.g.j(c());var d="none"!=a.style.display;c&&!d?a.style.display="":d&&!c&&(a.style.display="none")}};b.h.hidden={update:(a,c)=>a.hidden=!!b.g.j(c())};(function(a){b.h[a]=
{init:function(c,d,f,k,n){return b.h.event.init.call(this,c,()=>({[a]:d()}),f,k,n)}}})("click");(()=>{let a=b.g.i.Z();class c{constructor(f){this.Xa=f}Ja(...f){let k=this.Xa;if(!f.length)return b.g.i.get(k,a)||(11===this.L?k.content:1===this.L?k:void 0);b.g.i.set(k,a,f[0])}}class d extends c{constructor(f){super(f);f&&(this.L=f.matches("TEMPLATE")&&f.content?f.content.nodeType:1)}}b.Ka={Xa:d,Qa:c}})();(()=>{var a=(e,g,h)=>{var t;for(g=b.m.nextSibling(g);e&&(t=e)!==g;)e=b.m.nextSibling(t),h(t,e)},
c=(e,g)=>{if(e.length){var h=e[0],t=h.parentNode;a(h,e[e.length-1],r=>{1!==r.nodeType&&8!==r.nodeType||b.xb(g,r)});b.g.Aa(e,t)}},d=(e,g,h,t)=>{var r=(e&&(e.nodeType?e:0<e.length?e[0]:null)||h||{}).ownerDocument;if("string"==typeof h){r=r||N;r=r.getElementById(h);if(!r)throw Error("Cannot find template with ID "+h);h=new b.Ka.Xa(r)}else if([1,8].includes(h.nodeType))h=new b.Ka.Qa(h);else throw Error("Unknown template type: "+h);h=(h=h.Ja?h.Ja():null)?[...h.cloneNode(!0).childNodes]:null;if("number"!=
typeof h.length||0<h.length&&"number"!=typeof h[0].nodeType)throw Error("Template engine must return an array of DOM nodes");r=!1;switch(g){case "replaceChildren":b.m.ta(e,h);r=!0;break;case "ignoreTargetNode":break;default:throw Error("Unknown renderMode: "+g);}r&&(c(h,t),"replaceChildren"==g&&b.l.notify(e,b.l.G));return h},f=(e,g,h)=>b.T(e)?e():"function"===typeof e?e(g,h):e;b.rc=function(e,g,h,t){h=h||{};var r=r||"replaceChildren";if(t){var p=t.nodeType?t:0<t.length?t[0]:null;return b.s(()=>{var m=
g instanceof b.ea?g:new b.ea(g,null,null,null,{exportDependencies:!0}),l=f(e,m.$data,m);d(t,r,l,m,h)},{oa:()=>!p||!b.g.Za(p),o:p})}console.log("no targetNodeOrNodeArray")};b.sc=(e,g,h,t,r)=>{function p(u,y){b.u.S(b.g.Pb,null,[t,u,q,h,v,y]);b.l.notify(t,b.l.G)}var m,l=h.as,q=(u,y)=>{m=r.createChildContext(u,{as:l,extend:B=>{B.$index=y;l&&(B[l+"Index"]=y)}});u=f(e,u,m);return d(t,"ignoreTargetNode",u,m,h)},v=(u,y)=>{c(y,m);m=null};if(!h.beforeRemove&&b.Jb(g)){p(g.P());var x=g.subscribe(u=>{p(g(),u)},
null,"arrayChange");x.o(t);return x}return b.s(()=>{var u=b.g.j(g)||[];"undefined"==typeof u.length&&(u=[u]);p(u)},{o:t})};var k=b.g.i.Z(),n=b.g.i.Z();b.h.template={init:(e,g)=>{g=b.g.j(g());if("string"==typeof g||"name"in g)b.m.pa(e);else if("nodes"in g){g=g.nodes||[];if(b.T(g))throw Error('The "nodes" option must be a plain, non-observable array.');let h=g[0]?.parentNode;h&&b.g.i.get(h,n)||(h=b.g.Lb(g),b.g.i.set(h,n,!0));(new b.Ka.Qa(e)).Ja(h)}else if(g=b.m.childNodes(e),g.length)g=b.g.Lb(g),(new b.Ka.Qa(e)).Ja(g);
else throw Error("Anonymous template defined, but no template content was provided");return{controlsDescendantBindings:!0}},update:(e,g,h,t,r)=>{var p=g();g=b.g.j(p);h=!0;t=null;"string"==typeof g?g={}:(p="name"in g?g.name:e,"if"in g&&(h=b.g.j(g["if"])),h&&"ifnot"in g&&(h=!b.g.j(g.ifnot)),h&&!p&&(h=!1));"foreach"in g?t=b.sc(p,h&&g.foreach||[],g,e,r):h?(h=r,"data"in g&&(h=r.createChildContext(g.data,{as:g.as,exportDependencies:!0})),t=b.rc(p,h,g,e)):b.m.pa(e);r=t;b.g.i.get(e,k)?.A?.();b.g.i.set(e,
k,!r||r.isActive&&!r.isActive()?void 0:r)}};b.I.Sa.template=e=>{e=b.I.nc(e);return 1==e.length&&e[0].unknown||b.I.lc(e,"name")?null:"This template engine does not support anonymous templates nested within its templates"};b.m.ca.template=!0})();b.g.Hb=(a,c,d)=>{var f=0,k,n=c.length;n&&a.every(e=>{k=c.findIndex(g=>e.value===g.value);0<=k&&(e.moved=c[k].index,c[k].moved=e.index,c.splice(k,1),f=k=0,--n);f+=n;return n&&(!d||f<d)})};b.g.Cb=(()=>{var a=(c,d,f,k,n)=>{for(var e=Math.min,g=Math.max,h=[],t=
-1,r=c.length,p,m=d.length,l=m-r||1,q=r+m+1,v,x,u;++t<=r;)for(x=v,h.push(v=[]),u=e(m,t+l),p=g(0,t-1);p<=u;p++)v[p]=p?t?c[t-1]===d[p-1]?x[p-1]:e(x[p]||q,v[p-1]||q)+1:p+1:t+1;e=[];g=[];l=[];t=r;for(p=m;t||p;)m=h[t][p]-1,p&&m===h[t][p-1]?g.push(e[e.length]={status:f,value:d[--p],index:p}):t&&m===h[t-1][p]?l.push(e[e.length]={status:k,value:c[--t],index:t}):(--p,--t,n.sparse||e.push({status:"retained",value:d[p]}));b.g.Hb(l,g,!n.dontLimitMoves&&10*r);return e.reverse()};return(c,d,f)=>{f="boolean"===
typeof f?{dontLimitMoves:f}:f||{};c=c||[];d=d||[];return c.length<d.length?a(c,d,"added","deleted",f):a(d,c,"deleted","added",f)}})();(()=>{function a(f,k,n,e,g){var h=[],t=b.s(()=>{var r=k(n,g,b.g.Aa(h,f))||[];if(0<h.length){var p=h.nodeType?[h]:h;if(0<p.length){var m=p[0],l=m.parentNode,q;var v=0;for(q=r.length;v<q;v++)l.insertBefore(r[v],m);v=0;for(q=p.length;v<q;v++)b.removeNode(p[v])}e&&b.u.S(e,null,[n,r,g])}h.length=0;h.push(...r)},{o:f,oa:()=>!!h.find(b.g.Za)});return{N:h,Va:t.isActive()?t:
void 0}}var c=b.g.i.Z(),d=b.g.i.Z();b.g.Pb=(f,k,n,e,g,h)=>{k=k||[];"undefined"==typeof k.length&&(k=[k]);e=e||{};var t=b.g.i.get(f,c),r=[],p=0,m=0,l=[],q=[],v=[],x=0,u=w=>{A={da:w,Ea:b.ba(m++)};r.push(A)},y=w=>{A=t[w];A.Ea(m++);b.g.Aa(A.N,f);r.push(A)};if(t){if(!h||t&&t._countWaitingForRemove)h=b.g.Cb(Array.prototype.map.call(t,E=>E.da),k,{dontLimitMoves:e.dontLimitMoves,sparse:!0});let w,C;for(h.forEach(E=>{w=E.moved;C=E.index;switch(E.status){case "deleted":for(;p<C;)y(p++);void 0===w&&(A=t[p],
A.Va&&(A.Va.A(),A.Va=void 0),b.g.Aa(A.N,f).length&&(e.beforeRemove&&(r.push(A),x++,A.da===d?A=null:v[A.Ea.P()]=A),A&&l.push.apply(l,A.N)));p++;break;case "added":for(;m<C;)y(p++);void 0!==w?(q.push(r.length),y(w)):u(E.value)}});m<k.length;)y(p++);r._countWaitingForRemove=x}else k.forEach(u);b.g.i.set(f,c,r);l.forEach(e.beforeRemove?b.fa:b.removeNode);var B,D,F=w=>{b.m.ic(f,w,B);B=w};h=f.ownerDocument.activeElement;if(q.length)for(;void 0!=(k=q.shift());){var A=r[k];for(B=void 0;k;)if((D=r[--k].N)&&
D.length){B=D[D.length-1];break}A.N.forEach(F)}r.forEach(w=>{w.N||b.g.extend(w,a(f,n,w.da,g,w.Ea));w.N.forEach(F);!w.hc&&g&&(g(w.da,w.N,w.Ea),w.hc=!0,B=w.N[w.N.length-1])});f.ownerDocument.activeElement!=h&&h?.focus();((w,C)=>{if(w)for(var E=0,I=C.length;E<I;E++)C[E]&&C[E].N.forEach(L=>w(L,E,C[E].da))})(e.beforeRemove,v);v.forEach(w=>w&&(w.da=d))}})();T.ko=P})(this);

View file

@ -18,7 +18,7 @@
realDataItemOrAccessor = shouldInheritData ? undefined : dataItemOrAccessor,
isFunc = typeof(realDataItemOrAccessor) == "function" && !ko.isObservable(realDataItemOrAccessor),
subscribable,
dataDependency = options && options['dataDependency'],
dataDependency = options?.['dataDependency'],
// The binding context object includes static properties for the current, parent, and root view models.
// If a view model is actually stored in an observable, the corresponding binding context object, and
@ -64,12 +64,11 @@
// The extendCallback function is provided when creating a child context or extending a context.
// It handles the specific actions needed to finish setting up the binding context. Actions in this
// function could also add dependencies to this binding context.
if (extendCallback)
extendCallback(self, parentContext, dataItem);
extendCallback?.(self, parentContext, dataItem);
// When a "parent" context is given and we don't already have a dependency on its context, register a dependency on it.
// Thus whenever the parent context is updated, this context will also be updated.
if (parentContext && parentContext[contextSubscribable] && !ko.dependencyDetection.computed().hasAncestorDependency(parentContext[contextSubscribable])) {
if (parentContext?.[contextSubscribable] && !ko.dependencyDetection.computed().hasAncestorDependency(parentContext[contextSubscribable])) {
parentContext[contextSubscribable]();
}
@ -80,7 +79,7 @@
return self['$data'];
};
if (options && options['exportDependencies']) {
if (options?.['exportDependencies']) {
// The "exportDependencies" option means that the calling code will track any dependencies and re-create
// the binding context when they change.
updateContext();
@ -138,7 +137,7 @@
function asyncContextDispose(node) {
var bindingInfo = ko.utils.domData.get(node, boundElementDomDataKey),
asyncContext = bindingInfo && bindingInfo.asyncContext;
asyncContext = bindingInfo?.asyncContext;
if (asyncContext) {
bindingInfo.asyncContext = null;
asyncContext.notifyAncestor();
@ -152,25 +151,19 @@
this.asyncDescendants = new Set;
this.childrenComplete = false;
if (!bindingInfo.asyncContext) {
ko.utils.domNodeDisposal.addDisposeCallback(node, asyncContextDispose);
}
bindingInfo.asyncContext || ko.utils.domNodeDisposal.addDisposeCallback(node, asyncContextDispose);
if (ancestorBindingInfo && ancestorBindingInfo.asyncContext) {
if (ancestorBindingInfo?.asyncContext) {
ancestorBindingInfo.asyncContext.asyncDescendants.add(node);
this.ancestorBindingInfo = ancestorBindingInfo;
}
}
notifyAncestor() {
if (this.ancestorBindingInfo && this.ancestorBindingInfo.asyncContext) {
this.ancestorBindingInfo.asyncContext.descendantComplete(this.node);
}
this.ancestorBindingInfo?.asyncContext?.descendantComplete(this.node);
}
descendantComplete(node) {
this.asyncDescendants.delete(node);
if (!this.asyncDescendants.size && this.childrenComplete) {
this.completeChildren();
}
this.asyncDescendants.size || this.completeChildren?.();
}
completeChildren() {
this.childrenComplete = true;
@ -192,7 +185,7 @@
if (!bindingInfo.eventSubscribable) {
bindingInfo.eventSubscribable = new ko.subscribable;
}
if (options && options['notifyImmediately'] && bindingInfo.notifiedEvents[event]) {
if (options?.['notifyImmediately'] && bindingInfo.notifiedEvents[event]) {
ko.dependencyDetection.ignore(callback, context, [node]);
}
return bindingInfo.eventSubscribable.subscribe(callback, context, event);
@ -202,13 +195,11 @@
var bindingInfo = ko.utils.domData.get(node, boundElementDomDataKey);
if (bindingInfo) {
bindingInfo.notifiedEvents[event] = true;
if (bindingInfo.eventSubscribable) {
bindingInfo.eventSubscribable.notifySubscribers(node, event);
}
bindingInfo.eventSubscribable?.notifySubscribers(node, event);
if (event == ko.bindingEvent.childrenComplete) {
if (bindingInfo.asyncContext) {
bindingInfo.asyncContext.completeChildren();
} else if (bindingInfo.asyncContext === undefined && bindingInfo.eventSubscribable && bindingInfo.eventSubscribable.hasSubscriptionsForEvent(ko.bindingEvent.descendantsComplete)) {
} else if (bindingInfo.asyncContext === undefined && bindingInfo.eventSubscribable?.hasSubscriptionsForEvent(ko.bindingEvent.descendantsComplete)) {
// It's currently an error to register a descendantsComplete handler for a node that was never registered as completing asynchronously.
// That's because without the asyncContext, we don't have a way to know that all descendants have completed.
throw new Error("descendantsComplete event not supported for bindings on this node");
@ -260,8 +251,7 @@
// Perf optimisation: Apply bindings only if...
// (1) We need to store the binding info for the node (all element nodes)
// (2) It might have bindings (e.g., it has a data-bind attribute, or it's a marker for a containerless template)
var shouldApplyBindings = isElement || ko.bindingProvider.nodeHasBindings(nodeVerified);
if (shouldApplyBindings)
if (isElement || ko.bindingProvider.nodeHasBindings(nodeVerified))
bindingContextForDescendants = applyBindingsToNodeInternal(nodeVerified, null, bindingContext)['bindingContextForDescendants'];
// Don't want bindings that operate on text nodes to mutate <script> and <textarea> contents,
@ -269,7 +259,7 @@
// Also bindings should not operate on <template> elements since this breaks in Internet Explorer
// and because such elements' contents are always intended to be bound in a different context
// from where they appear in the document.
if (bindingContextForDescendants && nodeVerified.matches && !nodeVerified.matches('SCRIPT,TEXTAREA,TEMPLATE')) {
if (bindingContextForDescendants && !nodeVerified.matches?.('SCRIPT,TEXTAREA,TEMPLATE')) {
applyBindingsToDescendantsInternal(bindingContextForDescendants, nodeVerified);
}
}
@ -336,12 +326,8 @@
bindings = sourceBindings ? sourceBindings(bindingContext, node) : ko.bindingProvider.getBindingAccessors(node, bindingContext);
// Register a dependency on the binding context to support observable view models.
if (bindings) {
if (bindingContext[contextSubscribable]) {
bindingContext[contextSubscribable]();
}
if (bindingContext[contextDataDependency]) {
bindingContext[contextDataDependency]();
}
bindingContext[contextSubscribable]?.();
bindingContext[contextDataDependency]?.();
}
return bindings;
},
@ -374,9 +360,7 @@
var callback = bindings[ko.bindingEvent.childrenComplete]();
if (callback) {
var nodes = ko.virtualElements.childNodes(node);
if (nodes.length) {
callback(nodes, ko.dataFor(nodes[0]));
}
nodes.length && callback(nodes, ko.dataFor(nodes[0]));
}
});
}

View file

@ -49,55 +49,57 @@
array = [array];
options = options || {};
var lastMappingResult = ko.utils.domData.get(domNode, lastMappingResultDomDataKey);
var isFirstExecution = !lastMappingResult;
var lastMappingResult = ko.utils.domData.get(domNode, lastMappingResultDomDataKey),
isFirstExecution = !lastMappingResult,
// Build the new mapping result
var newMappingResult = [];
var lastMappingResultIndex = 0;
var currentArrayIndex = 0;
// Build the new mapping result
newMappingResult = [],
lastMappingResultIndex = 0,
currentArrayIndex = 0,
var nodesToDelete = [];
var itemsToMoveFirstIndexes = [];
var itemsForBeforeRemoveCallbacks = [];
var mapData;
var countWaitingForRemove = 0;
nodesToDelete = [],
itemsToMoveFirstIndexes = [],
itemsForBeforeRemoveCallbacks = [],
mapData,
countWaitingForRemove = 0,
function itemAdded(value) {
mapData = { arrayEntry: value, indexObservable: ko.observable(currentArrayIndex++) };
newMappingResult.push(mapData);
}
itemAdded = value => {
mapData = { arrayEntry: value, indexObservable: ko.observable(currentArrayIndex++) };
newMappingResult.push(mapData);
},
function itemMovedOrRetained(oldPosition) {
mapData = lastMappingResult[oldPosition];
// Since updating the index might change the nodes, do so before calling fixUpContinuousNodeArray
mapData.indexObservable(currentArrayIndex++);
ko.utils.fixUpContinuousNodeArray(mapData.mappedNodes, domNode);
newMappingResult.push(mapData);
}
itemMovedOrRetained = oldPosition => {
mapData = lastMappingResult[oldPosition];
// Since updating the index might change the nodes, do so before calling fixUpContinuousNodeArray
mapData.indexObservable(currentArrayIndex++);
ko.utils.fixUpContinuousNodeArray(mapData.mappedNodes, domNode);
newMappingResult.push(mapData);
},
function callCallback(callback, items) {
if (callback) {
for (var i = 0, n = items.length; i < n; i++) {
items[i] && items[i].mappedNodes.forEach(node => callback(node, i, items[i].arrayEntry));
callCallback = (callback, items) => {
if (callback) {
for (var i = 0, n = items.length; i < n; i++) {
items[i] && items[i].mappedNodes.forEach(node => callback(node, i, items[i].arrayEntry));
}
}
}
}
};
if (isFirstExecution) {
array.forEach(itemAdded);
} else {
if (!editScript || (lastMappingResult && lastMappingResult['_countWaitingForRemove'])) {
// Compare the provided array against the previous one
var lastArray = Array.prototype.map.call(lastMappingResult, x => x.arrayEntry),
compareOptions = {
editScript = ko.utils.compareArrays(
Array.prototype.map.call(lastMappingResult, x => x.arrayEntry),
array,
{
'dontLimitMoves': options['dontLimitMoves'],
'sparse': true
};
editScript = ko.utils.compareArrays(lastArray, array, compareOptions);
});
}
for (let i = 0, editScriptItem, movedIndex, itemIndex; editScriptItem = editScript[i]; i++) {
let movedIndex, itemIndex;
editScript.forEach(editScriptItem => {
movedIndex = editScriptItem['moved'];
itemIndex = editScriptItem['index'];
switch (editScriptItem['status']) {
@ -145,7 +147,7 @@
}
break;
}
}
});
while (currentArrayIndex < array.length) {
itemMovedOrRetained(lastMappingResultIndex++);
@ -162,7 +164,11 @@
// Next remove nodes for deleted items (or just clean if there's a beforeRemove callback)
nodesToDelete.forEach(options['beforeRemove'] ? ko.cleanNode : ko.removeNode);
var i, j, lastNode, nodeToInsert, mappedNodes, activeElement;
var i, lastNode, mappedNodes, activeElement,
insertNode = nodeToInsert => {
ko.virtualElements.insertAfter(domNode, nodeToInsert, lastNode);
lastNode = nodeToInsert;
};
// Since most browsers remove the focus from an element when it's moved to another location,
// save the focused element and try to restore it later.
@ -173,27 +179,24 @@
while ((i = itemsToMoveFirstIndexes.shift()) != undefined) {
mapData = newMappingResult[i];
for (lastNode = undefined; i; ) {
if ((mappedNodes = newMappingResult[--i].mappedNodes) && mappedNodes.length) {
mappedNodes = newMappingResult[--i].mappedNodes;
if (mappedNodes?.length) {
lastNode = mappedNodes[mappedNodes.length - 1];
break;
}
}
for (j = 0; nodeToInsert = mapData.mappedNodes[j]; lastNode = nodeToInsert, j++) {
ko.virtualElements.insertAfter(domNode, nodeToInsert, lastNode);
}
mapData.mappedNodes.forEach(insertNode);
}
}
// Next add/reorder the remaining items (will include deleted items if there's a beforeRemove callback)
for (i = 0; mapData = newMappingResult[i]; i++) {
newMappingResult.forEach(mapData => {
// Get nodes for newly added items
if (!mapData.mappedNodes)
ko.utils.extend(mapData, mapNodeAndRefreshWhenChanged(domNode, mapping, mapData.arrayEntry, callbackAfterAddingNodes, mapData.indexObservable));
mapData.mappedNodes
|| ko.utils.extend(mapData, mapNodeAndRefreshWhenChanged(domNode, mapping, mapData.arrayEntry, callbackAfterAddingNodes, mapData.indexObservable));
// Put nodes in the right place if they aren't there already
for (j = 0; nodeToInsert = mapData.mappedNodes[j]; lastNode = nodeToInsert, j++) {
ko.virtualElements.insertAfter(domNode, nodeToInsert, lastNode);
}
mapData.mappedNodes.forEach(insertNode);
// Run the callbacks for newly added nodes (for example, to apply bindings, etc.)
if (!mapData.initialized && callbackAfterAddingNodes) {
@ -201,11 +204,11 @@
mapData.initialized = true;
lastNode = mapData.mappedNodes[mapData.mappedNodes.length - 1]; // get the last node again since it may have been changed by a preprocessor
}
}
});
// Restore the focused element if it had lost focus
if (activeElement && domNode.ownerDocument.activeElement != activeElement) {
activeElement.focus();
if (domNode.ownerDocument.activeElement != activeElement) {
activeElement?.focus();
}
// If there's a beforeRemove callback, call it after reordering.
@ -218,10 +221,6 @@
// Replace the stored values of deleted items with a dummy value. This provides two benefits: it marks this item
// as already "removed" so we won't call beforeRemove for it again, and it ensures that the item won't match up
// with an actual item in the array and appear as "retained" or "moved".
for (i = 0; i < itemsForBeforeRemoveCallbacks.length; ++i) {
if (itemsForBeforeRemoveCallbacks[i]) {
itemsForBeforeRemoveCallbacks[i].arrayEntry = deletedItemDummyValue;
}
}
itemsForBeforeRemoveCallbacks.forEach(callback => callback && (callback.arrayEntry = deletedItemDummyValue));
}
})();

View file

@ -1,20 +1,19 @@
// Go through the items that have been added and deleted and try to find matches between them.
ko.utils.findMovesInArrayComparison = (left, right, limitFailedCompares) => {
if (left.length && right.length) {
var failedCompares, l, r, leftItem, rightItem;
for (failedCompares = l = 0; (!limitFailedCompares || failedCompares < limitFailedCompares) && (leftItem = left[l]); ++l) {
for (r = 0; rightItem = right[r]; ++r) {
if (leftItem['value'] === rightItem['value']) {
leftItem['moved'] = rightItem['index'];
rightItem['moved'] = leftItem['index'];
right.splice(r, 1); // This item is marked as moved; so remove it from right list
failedCompares = r = 0; // Reset failed compares count because we're checking for consecutive failures
break;
}
}
failedCompares += r;
var failedCompares = 0, r, l = right.length;
l && left.every(leftItem => {
r = right.findIndex(rightItem => leftItem['value'] === rightItem['value']);
if (r >= 0) {
leftItem['moved'] = right[r]['index'];
right[r]['moved'] = leftItem['index'];
right.splice(r, 1); // This item is marked as moved; so remove it from right list
// right[r] = null;
failedCompares = r = 0; // Reset failed compares count because we're checking for consecutive failures
--l;
}
}
failedCompares += l;
return l && (!limitFailedCompares || failedCompares < limitFailedCompares);
});
};
ko.utils.compareArrays = (() => {
@ -24,15 +23,15 @@ ko.utils.compareArrays = (() => {
var myMin = Math.min,
myMax = Math.max,
editDistanceMatrix = [],
smlIndex, smlIndexMax = smlArray.length,
smlIndex = -1, smlIndexMax = smlArray.length,
bigIndex, bigIndexMax = bigArray.length,
compareRange = (bigIndexMax - smlIndexMax) || 1,
maxDistance = smlIndexMax + bigIndexMax + 1,
thisRow, lastRow,
thisRow, prevRow,
bigIndexMaxForRow, bigIndexMinForRow;
for (smlIndex = 0; smlIndex <= smlIndexMax; smlIndex++) {
lastRow = thisRow;
while (++smlIndex <= smlIndexMax) {
prevRow = thisRow;
editDistanceMatrix.push(thisRow = []);
bigIndexMaxForRow = myMin(bigIndexMax, smlIndex + compareRange);
bigIndexMinForRow = myMax(0, smlIndex - 1);
@ -42,9 +41,9 @@ ko.utils.compareArrays = (() => {
else if (!smlIndex) // Top row - transform empty array into new array via additions
thisRow[bigIndex] = bigIndex + 1;
else if (smlArray[smlIndex - 1] === bigArray[bigIndex - 1])
thisRow[bigIndex] = lastRow[bigIndex - 1]; // copy value (no edit)
thisRow[bigIndex] = prevRow[bigIndex - 1]; // copy value (no edit)
else {
var northDistance = lastRow[bigIndex] || maxDistance; // not in big (deletion)
var northDistance = prevRow[bigIndex] || maxDistance; // not in big (deletion)
var westDistance = thisRow[bigIndex - 1] || maxDistance; // not in small (addition)
thisRow[bigIndex] = myMin(northDistance, westDistance) + 1;
}
@ -52,7 +51,9 @@ ko.utils.compareArrays = (() => {
}
var editScript = [], meMinusOne, notInSml = [], notInBig = [];
for (smlIndex = smlIndexMax, bigIndex = bigIndexMax; smlIndex || bigIndex;) {
smlIndex = smlIndexMax;
bigIndex = bigIndexMax
while (smlIndex || bigIndex) {
meMinusOne = editDistanceMatrix[smlIndex][bigIndex] - 1;
if (bigIndex && meMinusOne === editDistanceMatrix[smlIndex][bigIndex-1]) {
notInSml.push(editScript[editScript.length] = { // added

View file

@ -176,9 +176,7 @@ ko.expressionRewriting = (() => {
// it is !== existing value on that writable observable
writeValueToProperty: (property, allBindings, key, value, checkIfDifferent) => {
if (!property || !ko.isObservable(property)) {
var propWriters = allBindings.get('_ko_property_writers');
if (propWriters && propWriters[key])
propWriters[key](value);
allBindings.get('_ko_property_writers')?.[key]?.(value);
} else if (ko.isWriteableObservable(property) && (!checkIfDifferent || property.peek() !== value)) {
property(value);
}

View file

@ -8,11 +8,13 @@
readValue : element => {
switch (element.nodeName) {
case 'OPTION':
if (element[hasDomDataExpandoProperty] === true)
return ko.utils.domData.get(element, ko.bindingHandlers.options.optionValueDomDataKey);
return element.value;
return (element[hasDomDataExpandoProperty] === true)
? ko.utils.domData.get(element, ko.bindingHandlers.options.optionValueDomDataKey)
: element.value;
case 'SELECT':
return element.selectedIndex >= 0 ? ko.selectExtensions.readValue(element.options[element.selectedIndex]) : undefined;
return element.selectedIndex >= 0
? ko.selectExtensions.readValue(element.options[element.selectedIndex])
: undefined;
default:
return element.value;
}
@ -37,8 +39,9 @@
break;
case 'SELECT':
// A blank string or null value will select the caption
var selection = -1, noValue = ("" === value || null == value);
for (var i = 0, n = element.options.length, optionValue; i < n; ++i) {
var selection = -1, noValue = ("" === value || null == value),
i = element.options.length, optionValue;
while (i--) {
optionValue = ko.selectExtensions.readValue(element.options[i]);
// Include special check to handle selecting a caption with a blank string value
if (optionValue == value || (optionValue === "" && noValue)) {

View file

@ -63,8 +63,6 @@ ko.computed = (evaluatorFunctionOrOptions, options) => {
state.pure = true;
state.isSleeping = true; // Starts off sleeping; will awake on the first subscription
ko.utils.extend(computedObservable, pureComputedOverrides);
} else if (options['deferEvaluation']) {
ko.utils.extend(computedObservable, deferEvaluationOverrides);
}
if (state.disposeWhenNodeIsRemoved) {
@ -82,10 +80,8 @@ ko.computed = (evaluatorFunctionOrOptions, options) => {
}
}
// Evaluate, unless sleeping or deferEvaluation is true
if (!state.isSleeping && !options['deferEvaluation']) {
computedObservable.evaluateImmediate();
}
// Evaluate, unless sleeping
state.isSleeping || computedObservable.evaluateImmediate();
// Attach a DOM node disposal callback so that the computed will be proactively disposed as soon as the node is
// removed using ko.removeNode. But skip if isActive is false (there will never be any dependencies to dispose).
@ -228,16 +224,13 @@ var computedFn = {
disposeWhen = state.disposeWhen,
changed = false;
if (state.isBeingEvaluated) {
// If the evaluation of a ko.computed causes side effects, it's possible that it will trigger its own re-evaluation.
// This is not desirable (it's hard for a developer to realise a chain of dependencies might cause this, and they almost
// certainly didn't intend infinite re-evaluations). So, for predictability, we simply prevent ko.computeds from causing
// their own re-evaluation. Further discussion at https://github.com/SteveSanderson/knockout/pull/387
return;
}
// If the evaluation of a ko.computed causes side effects, it's possible that it will trigger its own re-evaluation.
// This is not desirable (it's hard for a developer to realise a chain of dependencies might cause this, and they almost
// certainly didn't intend infinite re-evaluations). So, for predictability, we simply prevent ko.computeds from causing
// their own re-evaluation. Further discussion at https://github.com/SteveSanderson/knockout/pull/387
if (state.isBeingEvaluated
// Do not evaluate (and possibly capture new dependencies) if disposed
if (state.isDisposed) {
|| state.isDisposed) {
return;
}
@ -252,8 +245,8 @@ var computedFn = {
state.suppressDisposalUntilDisposeWhenReturnsFalse = false;
}
state.isBeingEvaluated = true;
try {
state.isBeingEvaluated = true;
changed = this.evaluateImmediate_CallReadWithDependencyDetection(notifyChange);
} finally {
state.isBeingEvaluated = false;
@ -324,7 +317,7 @@ var computedFn = {
return changed;
},
peek: function (evaluate) {
// By default, peek won't re-evaluate, except while the computed is sleeping or to get the initial value when "deferEvaluation" is set.
// By default, peek won't re-evaluate, except while the computed is sleeping.
// Pass in true to evaluate if needed.
var state = this[computedState];
if ((state.isDirty && (evaluate || !state.dependenciesCount)) || (state.isSleeping && this.haveDependenciesChanged())) {
@ -333,30 +326,31 @@ var computedFn = {
return state.latestValue;
},
limit: function (limitFunction) {
var self = this;
// Override the limit function with one that delays evaluation as well
ko.subscribable['fn'].limit.call(this, limitFunction);
this._evalIfChanged = function () {
if (!this[computedState].isSleeping) {
if (this[computedState].isStale) {
this.evaluateImmediate();
ko.subscribable['fn'].limit.call(self, limitFunction);
self._evalIfChanged = () => {
if (!self[computedState].isSleeping) {
if (self[computedState].isStale) {
self.evaluateImmediate();
} else {
this[computedState].isDirty = false;
self[computedState].isDirty = false;
}
}
return this[computedState].latestValue;
return self[computedState].latestValue;
};
this._evalDelayed = function (isChange) {
this._limitBeforeChange(this[computedState].latestValue);
self._evalDelayed = isChange => {
self._limitBeforeChange(self[computedState].latestValue);
// Mark as dirty
this[computedState].isDirty = true;
self[computedState].isDirty = true;
if (isChange) {
this[computedState].isStale = true;
self[computedState].isStale = true;
}
// Pass the observable to the "limit" code, which will evaluate it when
// it's time to do the notification.
this._limitChange(this, !isChange /* isDirty */);
self._limitChange(self, !isChange /* isDirty */);
};
},
dispose: function () {
@ -450,15 +444,6 @@ var pureComputedOverrides = {
}
};
var deferEvaluationOverrides = {
beforeSubscriptionAdd: function (event) {
// This will force a computed with deferEvaluation to evaluate when the first subscription is registered.
if (event == 'change' || event == 'beforeChange') {
this.peek();
}
}
};
// Note that for browsers that don't support proto assignment, the
// inheritance chain is created manually in the ko.computed constructor
Object.setPrototypeOf(computedFn, ko.subscribable['fn']);

View file

@ -22,25 +22,17 @@ ko.extenders['trackArrayChanges'] = (target, options) => {
// Watch "subscribe" calls, and for array change events, ensure change tracking is enabled
target.beforeSubscriptionAdd = event => {
if (underlyingBeforeSubscriptionAddFunction) {
underlyingBeforeSubscriptionAddFunction.call(target, event);
}
underlyingBeforeSubscriptionAddFunction?.call(target, event);
if (event === arrayChangeEventName) {
trackChanges();
}
};
// Watch "dispose" calls, and for array change events, ensure change tracking is disabled when all are disposed
target.afterSubscriptionRemove = event => {
if (underlyingAfterSubscriptionRemoveFunction) {
underlyingAfterSubscriptionRemoveFunction.call(target, event);
}
underlyingAfterSubscriptionRemoveFunction?.call(target, event);
if (event === arrayChangeEventName && !target.hasSubscriptionsForEvent(arrayChangeEventName)) {
if (changeSubscription) {
changeSubscription.dispose();
}
if (spectateSubscription) {
spectateSubscription.dispose();
}
changeSubscription?.dispose();
spectateSubscription?.dispose();
spectateSubscription = changeSubscription = null;
trackingChanges = false;
previousContents = undefined;
@ -48,23 +40,6 @@ ko.extenders['trackArrayChanges'] = (target, options) => {
};
function trackChanges() {
if (trackingChanges) {
// Whenever there's a new subscription and there are pending notifications, make sure all previous
// subscriptions are notified of the change so that all subscriptions are in sync.
notifyChanges();
return;
}
trackingChanges = true;
// Track how many times the array actually changed value
spectateSubscription = target.subscribe(() => ++pendingChanges, null, "spectate");
// Each time the array changes value, capture a clone so that on the next
// change it's possible to produce a diff
previousContents = [].concat(target.peek() || []);
cachedDiff = null;
changeSubscription = target.subscribe(notifyChanges);
function notifyChanges() {
if (pendingChanges) {
@ -86,6 +61,24 @@ ko.extenders['trackArrayChanges'] = (target, options) => {
}
}
}
if (trackingChanges) {
// Whenever there's a new subscription and there are pending notifications, make sure all previous
// subscriptions are notified of the change so that all subscriptions are in sync.
notifyChanges();
return;
}
trackingChanges = true;
// Track how many times the array actually changed value
spectateSubscription = target.subscribe(() => ++pendingChanges, null, "spectate");
// Each time the array changes value, capture a clone so that on the next
// change it's possible to produce a diff
previousContents = [].concat(target.peek() || []);
cachedDiff = null;
changeSubscription = target.subscribe(notifyChanges);
}
function getChanges(previousContents, currentContents) {
@ -126,20 +119,19 @@ ko.extenders['trackArrayChanges'] = (target, options) => {
case 'pop':
offset = arrayLength - 1;
case 'shift':
if (arrayLength) {
pushDiff('deleted', rawArray[offset], offset);
}
arrayLength && pushDiff('deleted', rawArray[offset], offset);
break;
case 'splice':
// Negative start index means 'from end of array'. After that we clamp to [0...arrayLength].
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
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,
var index = Math.min(Math.max(0, args[0] < 0 ? arrayLength + args[0] : args[0]), arrayLength),
endDeleteIndex = argsLength === 1 ? arrayLength : Math.min(index + (args[1] || 0), arrayLength),
endAddIndex = index + argsLength - 2,
endIndex = Math.max(endDeleteIndex, endAddIndex),
additions = [], deletions = [];
for (let index = startIndex, argsIndex = 2; index < endIndex; ++index, ++argsIndex) {
additions = [], deletions = [],
argsIndex = 2;
for (; index < endIndex; ++index, ++argsIndex) {
if (index < endDeleteIndex)
deletions.push(pushDiff('deleted', rawArray[index], index));
if (index < endAddIndex)

View file

@ -14,9 +14,8 @@ class koSubscription
dispose() {
var self = this;
if (!self._isDisposed) {
if (self._domNodeDisposalCallback) {
ko.utils.domNodeDisposal.removeDisposeCallback(self._node, self._domNodeDisposalCallback);
}
self._domNodeDisposalCallback
&& ko.utils.domNodeDisposal.removeDisposeCallback(self._node, self._domNodeDisposalCallback);
self._isDisposed = true;
self._disposeCallback();
@ -53,15 +52,12 @@ var ko_subscribable_fn = {
var subscription = new koSubscription(self, boundCallback, () => {
self._subscriptions.get(event).delete(subscription);
if (self.afterSubscriptionRemove)
self.afterSubscriptionRemove(event);
self.afterSubscriptionRemove?.(event);
});
if (self.beforeSubscriptionAdd)
self.beforeSubscriptionAdd(event);
self.beforeSubscriptionAdd?.(event);
if (!self._subscriptions.has(event))
self._subscriptions.set(event, new Set);
self._subscriptions.has(event) || self._subscriptions.set(event, new Set);
self._subscriptions.get(event).add(subscription);
return subscription;
@ -107,13 +103,13 @@ var ko_subscribable_fn = {
if (!self._origNotifySubscribers) {
self._origNotifySubscribers = self.notifySubscribers;
// Moved out of "limit" to avoid the extra closure
self.notifySubscribers = function(value, event) {
self.notifySubscribers = (value, event) => {
if (!event || event === defaultEvent) {
this._limitChange(value);
} else if (event === 'beforeChange') {
this._limitBeforeChange(value);
self._limitChange(value);
} else if (event === beforeChange) {
self._limitBeforeChange(value);
} else {
this._origNotifySubscribers(value, event);
self._origNotifySubscribers(value, event);
}
}
}