From e827f4b6a2fc694ada43e6f69201dc66c556bc9e Mon Sep 17 00:00:00 2001 From: Max Battcher Date: Mon, 20 Nov 2023 13:32:34 -0500 Subject: [PATCH 01/15] =?UTF-8?q?=F0=9F=94=A7=20npm=20rm=20knockout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 8 +------- package.json | 3 +-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index fe0bca1..ad161eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,8 +10,7 @@ "license": "MIT", "dependencies": { "jquery": "^3.6.0", - "jquery-knob": "^1.2.11", - "knockout": "^3.5.1" + "jquery-knob": "^1.2.11" }, "devDependencies": { "@types/jquery": "^3.5.20", @@ -709,11 +708,6 @@ "resolved": "https://registry.npmjs.org/jquery-knob/-/jquery-knob-1.2.11.tgz", "integrity": "sha1-83w528HHpqbBLNsu1Pa/+2g/ENY=" }, - "node_modules/knockout": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/knockout/-/knockout-3.5.1.tgz", - "integrity": "sha512-wRJ9I4az0QcsH7A4v4l0enUpkS++MBx0BnL/68KaLzJg7x1qmbjSlwEoCNol7KTYZ+pmtI7Eh2J0Nu6/2Z5J/Q==" - }, "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", diff --git a/package.json b/package.json index 7d0c365..a957018 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,7 @@ "type": "module", "dependencies": { "jquery": "^3.6.0", - "jquery-knob": "^1.2.11", - "knockout": "^3.5.1" + "jquery-knob": "^1.2.11" }, "devDependencies": { "@types/jquery": "^3.5.20", From 24c990a32a1ee2ca674b1c1f593ce56db980c4ad Mon Sep 17 00:00:00 2001 From: Max Battcher Date: Mon, 20 Nov 2023 13:32:48 -0500 Subject: [PATCH 02/15] =?UTF-8?q?=F0=9F=94=A7=20npm=20i=20butterfloat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 22 ++++++++++++++++++++++ package.json | 1 + 2 files changed, 23 insertions(+) diff --git a/package-lock.json b/package-lock.json index ad161eb..f32491b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.0", "license": "MIT", "dependencies": { + "butterfloat": "^0.2.0", "jquery": "^3.6.0", "jquery-knob": "^1.2.11" }, @@ -433,6 +434,14 @@ "node": ">= 0.8" } }, + "node_modules/butterfloat": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/butterfloat/-/butterfloat-0.2.0.tgz", + "integrity": "sha512-Nptxs2b9vP1n2JV4fPbZ17UKF7Up/eHiu7B91vXXtLgr5u46z6uL6N/qeR7DyD3PKvRdKSZOfGaSz1lzUGxQOw==", + "dependencies": { + "rxjs": "^7.8.1" + } + }, "node_modules/call-bind": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", @@ -821,6 +830,14 @@ "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", "dev": true }, + "node_modules/rxjs": { + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", + "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", + "dependencies": { + "tslib": "^2.1.0" + } + }, "node_modules/safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -865,6 +882,11 @@ "node": ">=8" } }, + "node_modules/tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + }, "node_modules/typescript": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", diff --git a/package.json b/package.json index a957018..2ab02e8 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "main": "main.js", "type": "module", "dependencies": { + "butterfloat": "^0.2.0", "jquery": "^3.6.0", "jquery-knob": "^1.2.11" }, From 7d178291ca0f2738a17a846b0969da28316167ec Mon Sep 17 00:00:00 2001 From: Max Battcher Date: Mon, 20 Nov 2023 15:17:09 -0500 Subject: [PATCH 03/15] =?UTF-8?q?=F0=9F=94=A7=20npm=20i=20rxjs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 3 ++- package.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index f32491b..920baa1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,8 @@ "dependencies": { "butterfloat": "^0.2.0", "jquery": "^3.6.0", - "jquery-knob": "^1.2.11" + "jquery-knob": "^1.2.11", + "rxjs": "^7.8.1" }, "devDependencies": { "@types/jquery": "^3.5.20", diff --git a/package.json b/package.json index 2ab02e8..85b389c 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "dependencies": { "butterfloat": "^0.2.0", "jquery": "^3.6.0", - "jquery-knob": "^1.2.11" + "jquery-knob": "^1.2.11", + "rxjs": "^7.8.1" }, "devDependencies": { "@types/jquery": "^3.5.20", From 602aaee91b717dddf3af4dfe8625d87e762210d3 Mon Sep 17 00:00:00 2001 From: Max Battcher Date: Tue, 21 Nov 2023 14:25:23 -0500 Subject: [PATCH 04/15] =?UTF-8?q?=F0=9F=94=A7=20npm=20i=20@types/node?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 14 ++++++++++++++ package.json | 1 + 2 files changed, 15 insertions(+) diff --git a/package-lock.json b/package-lock.json index 920baa1..f01510d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.0", "license": "MIT", "dependencies": { + "@types/node": "^20.9.3", "butterfloat": "^0.2.0", "jquery": "^3.6.0", "jquery-knob": "^1.2.11", @@ -393,6 +394,14 @@ "@types/jquery": "*" } }, + "node_modules/@types/node": { + "version": "20.9.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.3.tgz", + "integrity": "sha512-nk5wXLAXGBKfrhLB0cyHGbSqopS+nz0BUgZkUQqSHSSgdee0kssp1IAqlQOu333bW+gMNs2QREx7iynm19Abxw==", + "dependencies": { + "undici-types": "~5.26.4" + } + }, "node_modules/@types/sizzle": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.4.tgz", @@ -901,6 +910,11 @@ "node": ">=14.17" } }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + }, "node_modules/union": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/union/-/union-0.5.0.tgz", diff --git a/package.json b/package.json index 85b389c..846c79f 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "main": "main.js", "type": "module", "dependencies": { + "@types/node": "^20.9.3", "butterfloat": "^0.2.0", "jquery": "^3.6.0", "jquery-knob": "^1.2.11", From 67f0663d40c9d171959ba6137c80974302052201 Mon Sep 17 00:00:00 2001 From: Max Battcher Date: Tue, 21 Nov 2023 17:19:13 -0500 Subject: [PATCH 05/15] Update VMs to RxJS with butterflies --- .vscode/extensions.json | 3 + .vscode/settings.json | 4 + _build.js | 3 +- compradprogvm.test.js | 1133 ++++- compradprogvm.test.ts | 53 + compradprogvm.ts | 259 +- main.js | 9339 ++++++++++++++++++--------------------- main.ts | 7 +- package.json | 1 + progvm.test.js | 94 +- progvm.test.ts | 51 + progvm.ts | 71 +- 12 files changed, 5770 insertions(+), 5248 deletions(-) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 compradprogvm.test.ts create mode 100644 progvm.test.ts diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..c83e263 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["esbenp.prettier-vscode"] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..89d1965 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode" +} \ No newline at end of file diff --git a/_build.js b/_build.js index b4cf325..625e68d 100644 --- a/_build.js +++ b/_build.js @@ -9,7 +9,8 @@ await esbuild.build({ // *** Test Modules *** await esbuild.build({ - entryPoints: ['compradprogvm.ts', 'progvm.ts'], + entryPoints: ['*.test.ts'], + platform: 'node', bundle: true, splitting: true, outdir: '.', diff --git a/compradprogvm.test.js b/compradprogvm.test.js index b9c9fec..ca4cc32 100644 --- a/compradprogvm.test.js +++ b/compradprogvm.test.js @@ -1,38 +1,1095 @@ -import assert from 'node:assert' -import { describe, it } from 'node:test' -import { CompRadProgVm } from './compradprogvm.js' - -describe('CompRadProgVm', () => { - it('adds items', () => { - const vm = new CompRadProgVm() - const startlength = vm.inprogress().length - vm.addItem() - assert(vm.inprogress().length > startlength) - }) - - it('pauses all', () => { - const vm = new CompRadProgVm() - vm.addItem() - vm.addItem() - vm.pauseAll() - assert(vm.inprogress().every(prog => prog.paused.peek())) - }) - - it('unpauses all', () => { - const vm = new CompRadProgVm() - vm.addItem() - vm.addItem() - vm.pauseAll() - vm.unpauseAll() - assert(vm.inprogress().every(prog => !prog.paused.peek())) - }) - - it('ticks forward', () => { - const vm = new CompRadProgVm() - vm.addItem() - vm.addItem() - const startProgress = vm.currentVal.peek() - vm.tick() - assert(vm.currentVal.peek() > startProgress) - }) -}) +import { + ProgVm, + Subscription, + __commonJS, + __toESM, + butterfly, + combineLatest, + combineLatestAll, + filter, + map, + require_Notification, + require_NotificationFactories, + require_Observable, + require_Subject, + require_Subscription, + require_VirtualTimeScheduler, + require_animationFrameProvider, + require_cjs, + require_dateTimestampProvider, + require_immediateProvider, + require_intervalProvider, + require_performanceTimestampProvider, + require_timeoutProvider, + shareReplay +} from "./chunk-33WHBTN2.js"; + +// node_modules/rxjs/dist/cjs/internal/testing/SubscriptionLog.js +var require_SubscriptionLog = __commonJS({ + "node_modules/rxjs/dist/cjs/internal/testing/SubscriptionLog.js"(exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.SubscriptionLog = void 0; + var SubscriptionLog = function() { + function SubscriptionLog2(subscribedFrame, unsubscribedFrame) { + if (unsubscribedFrame === void 0) { + unsubscribedFrame = Infinity; + } + this.subscribedFrame = subscribedFrame; + this.unsubscribedFrame = unsubscribedFrame; + } + return SubscriptionLog2; + }(); + exports.SubscriptionLog = SubscriptionLog; + } +}); + +// node_modules/rxjs/dist/cjs/internal/testing/SubscriptionLoggable.js +var require_SubscriptionLoggable = __commonJS({ + "node_modules/rxjs/dist/cjs/internal/testing/SubscriptionLoggable.js"(exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.SubscriptionLoggable = void 0; + var SubscriptionLog_1 = require_SubscriptionLog(); + var SubscriptionLoggable = function() { + function SubscriptionLoggable2() { + this.subscriptions = []; + } + SubscriptionLoggable2.prototype.logSubscribedFrame = function() { + this.subscriptions.push(new SubscriptionLog_1.SubscriptionLog(this.scheduler.now())); + return this.subscriptions.length - 1; + }; + SubscriptionLoggable2.prototype.logUnsubscribedFrame = function(index) { + var subscriptionLogs = this.subscriptions; + var oldSubscriptionLog = subscriptionLogs[index]; + subscriptionLogs[index] = new SubscriptionLog_1.SubscriptionLog(oldSubscriptionLog.subscribedFrame, this.scheduler.now()); + }; + return SubscriptionLoggable2; + }(); + exports.SubscriptionLoggable = SubscriptionLoggable; + } +}); + +// node_modules/rxjs/dist/cjs/internal/util/applyMixins.js +var require_applyMixins = __commonJS({ + "node_modules/rxjs/dist/cjs/internal/util/applyMixins.js"(exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.applyMixins = void 0; + function applyMixins(derivedCtor, baseCtors) { + for (var i = 0, len = baseCtors.length; i < len; i++) { + var baseCtor = baseCtors[i]; + var propertyKeys = Object.getOwnPropertyNames(baseCtor.prototype); + for (var j = 0, len2 = propertyKeys.length; j < len2; j++) { + var name_1 = propertyKeys[j]; + derivedCtor.prototype[name_1] = baseCtor.prototype[name_1]; + } + } + } + exports.applyMixins = applyMixins; + } +}); + +// node_modules/rxjs/dist/cjs/internal/testing/ColdObservable.js +var require_ColdObservable = __commonJS({ + "node_modules/rxjs/dist/cjs/internal/testing/ColdObservable.js"(exports) { + "use strict"; + var __extends = exports && exports.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + d2.__proto__ = b2; + } || function(d2, b2) { + for (var p in b2) + if (Object.prototype.hasOwnProperty.call(b2, p)) + d2[p] = b2[p]; + }; + return extendStatics(d, b); + }; + return function(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + }(); + Object.defineProperty(exports, "__esModule", { value: true }); + exports.ColdObservable = void 0; + var Observable_1 = require_Observable(); + var Subscription_1 = require_Subscription(); + var SubscriptionLoggable_1 = require_SubscriptionLoggable(); + var applyMixins_1 = require_applyMixins(); + var Notification_1 = require_Notification(); + var ColdObservable = function(_super) { + __extends(ColdObservable2, _super); + function ColdObservable2(messages, scheduler) { + var _this = _super.call(this, function(subscriber) { + var observable = this; + var index = observable.logSubscribedFrame(); + var subscription = new Subscription_1.Subscription(); + subscription.add(new Subscription_1.Subscription(function() { + observable.logUnsubscribedFrame(index); + })); + observable.scheduleMessages(subscriber); + return subscription; + }) || this; + _this.messages = messages; + _this.subscriptions = []; + _this.scheduler = scheduler; + return _this; + } + ColdObservable2.prototype.scheduleMessages = function(subscriber) { + var messagesLength = this.messages.length; + for (var i = 0; i < messagesLength; i++) { + var message = this.messages[i]; + subscriber.add(this.scheduler.schedule(function(state) { + var _a = state, notification = _a.message.notification, destination = _a.subscriber; + Notification_1.observeNotification(notification, destination); + }, message.frame, { message, subscriber })); + } + }; + return ColdObservable2; + }(Observable_1.Observable); + exports.ColdObservable = ColdObservable; + applyMixins_1.applyMixins(ColdObservable, [SubscriptionLoggable_1.SubscriptionLoggable]); + } +}); + +// node_modules/rxjs/dist/cjs/internal/testing/HotObservable.js +var require_HotObservable = __commonJS({ + "node_modules/rxjs/dist/cjs/internal/testing/HotObservable.js"(exports) { + "use strict"; + var __extends = exports && exports.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + d2.__proto__ = b2; + } || function(d2, b2) { + for (var p in b2) + if (Object.prototype.hasOwnProperty.call(b2, p)) + d2[p] = b2[p]; + }; + return extendStatics(d, b); + }; + return function(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + }(); + Object.defineProperty(exports, "__esModule", { value: true }); + exports.HotObservable = void 0; + var Subject_1 = require_Subject(); + var Subscription_1 = require_Subscription(); + var SubscriptionLoggable_1 = require_SubscriptionLoggable(); + var applyMixins_1 = require_applyMixins(); + var Notification_1 = require_Notification(); + var HotObservable = function(_super) { + __extends(HotObservable2, _super); + function HotObservable2(messages, scheduler) { + var _this = _super.call(this) || this; + _this.messages = messages; + _this.subscriptions = []; + _this.scheduler = scheduler; + return _this; + } + HotObservable2.prototype._subscribe = function(subscriber) { + var subject = this; + var index = subject.logSubscribedFrame(); + var subscription = new Subscription_1.Subscription(); + subscription.add(new Subscription_1.Subscription(function() { + subject.logUnsubscribedFrame(index); + })); + subscription.add(_super.prototype._subscribe.call(this, subscriber)); + return subscription; + }; + HotObservable2.prototype.setup = function() { + var subject = this; + var messagesLength = subject.messages.length; + var _loop_1 = function(i2) { + (function() { + var _a = subject.messages[i2], notification = _a.notification, frame = _a.frame; + subject.scheduler.schedule(function() { + Notification_1.observeNotification(notification, subject); + }, frame); + })(); + }; + for (var i = 0; i < messagesLength; i++) { + _loop_1(i); + } + }; + return HotObservable2; + }(Subject_1.Subject); + exports.HotObservable = HotObservable; + applyMixins_1.applyMixins(HotObservable, [SubscriptionLoggable_1.SubscriptionLoggable]); + } +}); + +// node_modules/rxjs/dist/cjs/internal/testing/TestScheduler.js +var require_TestScheduler = __commonJS({ + "node_modules/rxjs/dist/cjs/internal/testing/TestScheduler.js"(exports) { + "use strict"; + var __extends = exports && exports.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + d2.__proto__ = b2; + } || function(d2, b2) { + for (var p in b2) + if (Object.prototype.hasOwnProperty.call(b2, p)) + d2[p] = b2[p]; + }; + return extendStatics(d, b); + }; + return function(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + }(); + var __read = exports && exports.__read || function(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) + return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) + ar.push(r.value); + } catch (error) { + e = { error }; + } finally { + try { + if (r && !r.done && (m = i["return"])) + m.call(i); + } finally { + if (e) + throw e.error; + } + } + return ar; + }; + var __spreadArray = exports && exports.__spreadArray || function(to, from) { + for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) + to[j] = from[i]; + return to; + }; + var __values = exports && exports.__values || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) + return m.call(o); + if (o && typeof o.length === "number") + return { + next: function() { + if (o && i >= o.length) + o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.TestScheduler = void 0; + var Observable_1 = require_Observable(); + var ColdObservable_1 = require_ColdObservable(); + var HotObservable_1 = require_HotObservable(); + var SubscriptionLog_1 = require_SubscriptionLog(); + var VirtualTimeScheduler_1 = require_VirtualTimeScheduler(); + var NotificationFactories_1 = require_NotificationFactories(); + var dateTimestampProvider_1 = require_dateTimestampProvider(); + var performanceTimestampProvider_1 = require_performanceTimestampProvider(); + var animationFrameProvider_1 = require_animationFrameProvider(); + var immediateProvider_1 = require_immediateProvider(); + var intervalProvider_1 = require_intervalProvider(); + var timeoutProvider_1 = require_timeoutProvider(); + var defaultMaxFrame = 750; + var TestScheduler2 = function(_super) { + __extends(TestScheduler3, _super); + function TestScheduler3(assertDeepEqual) { + var _this = _super.call(this, VirtualTimeScheduler_1.VirtualAction, defaultMaxFrame) || this; + _this.assertDeepEqual = assertDeepEqual; + _this.hotObservables = []; + _this.coldObservables = []; + _this.flushTests = []; + _this.runMode = false; + return _this; + } + TestScheduler3.prototype.createTime = function(marbles) { + var indexOf = this.runMode ? marbles.trim().indexOf("|") : marbles.indexOf("|"); + if (indexOf === -1) { + throw new Error('marble diagram for time should have a completion marker "|"'); + } + return indexOf * TestScheduler3.frameTimeFactor; + }; + TestScheduler3.prototype.createColdObservable = function(marbles, values, error) { + if (marbles.indexOf("^") !== -1) { + throw new Error('cold observable cannot have subscription offset "^"'); + } + if (marbles.indexOf("!") !== -1) { + throw new Error('cold observable cannot have unsubscription marker "!"'); + } + var messages = TestScheduler3.parseMarbles(marbles, values, error, void 0, this.runMode); + var cold = new ColdObservable_1.ColdObservable(messages, this); + this.coldObservables.push(cold); + return cold; + }; + TestScheduler3.prototype.createHotObservable = function(marbles, values, error) { + if (marbles.indexOf("!") !== -1) { + throw new Error('hot observable cannot have unsubscription marker "!"'); + } + var messages = TestScheduler3.parseMarbles(marbles, values, error, void 0, this.runMode); + var subject = new HotObservable_1.HotObservable(messages, this); + this.hotObservables.push(subject); + return subject; + }; + TestScheduler3.prototype.materializeInnerObservable = function(observable, outerFrame) { + var _this = this; + var messages = []; + observable.subscribe({ + next: function(value) { + messages.push({ frame: _this.frame - outerFrame, notification: NotificationFactories_1.nextNotification(value) }); + }, + error: function(error) { + messages.push({ frame: _this.frame - outerFrame, notification: NotificationFactories_1.errorNotification(error) }); + }, + complete: function() { + messages.push({ frame: _this.frame - outerFrame, notification: NotificationFactories_1.COMPLETE_NOTIFICATION }); + } + }); + return messages; + }; + TestScheduler3.prototype.expectObservable = function(observable, subscriptionMarbles) { + var _this = this; + if (subscriptionMarbles === void 0) { + subscriptionMarbles = null; + } + var actual = []; + var flushTest = { actual, ready: false }; + var subscriptionParsed = TestScheduler3.parseMarblesAsSubscriptions(subscriptionMarbles, this.runMode); + var subscriptionFrame = subscriptionParsed.subscribedFrame === Infinity ? 0 : subscriptionParsed.subscribedFrame; + var unsubscriptionFrame = subscriptionParsed.unsubscribedFrame; + var subscription; + this.schedule(function() { + subscription = observable.subscribe({ + next: function(x) { + var value = x instanceof Observable_1.Observable ? _this.materializeInnerObservable(x, _this.frame) : x; + actual.push({ frame: _this.frame, notification: NotificationFactories_1.nextNotification(value) }); + }, + error: function(error) { + actual.push({ frame: _this.frame, notification: NotificationFactories_1.errorNotification(error) }); + }, + complete: function() { + actual.push({ frame: _this.frame, notification: NotificationFactories_1.COMPLETE_NOTIFICATION }); + } + }); + }, subscriptionFrame); + if (unsubscriptionFrame !== Infinity) { + this.schedule(function() { + return subscription.unsubscribe(); + }, unsubscriptionFrame); + } + this.flushTests.push(flushTest); + var runMode = this.runMode; + return { + toBe: function(marbles, values, errorValue) { + flushTest.ready = true; + flushTest.expected = TestScheduler3.parseMarbles(marbles, values, errorValue, true, runMode); + }, + toEqual: function(other) { + flushTest.ready = true; + flushTest.expected = []; + _this.schedule(function() { + subscription = other.subscribe({ + next: function(x) { + var value = x instanceof Observable_1.Observable ? _this.materializeInnerObservable(x, _this.frame) : x; + flushTest.expected.push({ frame: _this.frame, notification: NotificationFactories_1.nextNotification(value) }); + }, + error: function(error) { + flushTest.expected.push({ frame: _this.frame, notification: NotificationFactories_1.errorNotification(error) }); + }, + complete: function() { + flushTest.expected.push({ frame: _this.frame, notification: NotificationFactories_1.COMPLETE_NOTIFICATION }); + } + }); + }, subscriptionFrame); + } + }; + }; + TestScheduler3.prototype.expectSubscriptions = function(actualSubscriptionLogs) { + var flushTest = { actual: actualSubscriptionLogs, ready: false }; + this.flushTests.push(flushTest); + var runMode = this.runMode; + return { + toBe: function(marblesOrMarblesArray) { + var marblesArray = typeof marblesOrMarblesArray === "string" ? [marblesOrMarblesArray] : marblesOrMarblesArray; + flushTest.ready = true; + flushTest.expected = marblesArray.map(function(marbles) { + return TestScheduler3.parseMarblesAsSubscriptions(marbles, runMode); + }).filter(function(marbles) { + return marbles.subscribedFrame !== Infinity; + }); + } + }; + }; + TestScheduler3.prototype.flush = function() { + var _this = this; + var hotObservables = this.hotObservables; + while (hotObservables.length > 0) { + hotObservables.shift().setup(); + } + _super.prototype.flush.call(this); + this.flushTests = this.flushTests.filter(function(test) { + if (test.ready) { + _this.assertDeepEqual(test.actual, test.expected); + return false; + } + return true; + }); + }; + TestScheduler3.parseMarblesAsSubscriptions = function(marbles, runMode) { + var _this = this; + if (runMode === void 0) { + runMode = false; + } + if (typeof marbles !== "string") { + return new SubscriptionLog_1.SubscriptionLog(Infinity); + } + var characters = __spreadArray([], __read(marbles)); + var len = characters.length; + var groupStart = -1; + var subscriptionFrame = Infinity; + var unsubscriptionFrame = Infinity; + var frame = 0; + var _loop_1 = function(i2) { + var nextFrame = frame; + var advanceFrameBy = function(count) { + nextFrame += count * _this.frameTimeFactor; + }; + var c = characters[i2]; + switch (c) { + case " ": + if (!runMode) { + advanceFrameBy(1); + } + break; + case "-": + advanceFrameBy(1); + break; + case "(": + groupStart = frame; + advanceFrameBy(1); + break; + case ")": + groupStart = -1; + advanceFrameBy(1); + break; + case "^": + if (subscriptionFrame !== Infinity) { + throw new Error("found a second subscription point '^' in a subscription marble diagram. There can only be one."); + } + subscriptionFrame = groupStart > -1 ? groupStart : frame; + advanceFrameBy(1); + break; + case "!": + if (unsubscriptionFrame !== Infinity) { + throw new Error("found a second unsubscription point '!' in a subscription marble diagram. There can only be one."); + } + unsubscriptionFrame = groupStart > -1 ? groupStart : frame; + break; + default: + if (runMode && c.match(/^[0-9]$/)) { + if (i2 === 0 || characters[i2 - 1] === " ") { + var buffer = characters.slice(i2).join(""); + var match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /); + if (match) { + i2 += match[0].length - 1; + var duration = parseFloat(match[1]); + var unit = match[2]; + var durationInMs = void 0; + switch (unit) { + case "ms": + durationInMs = duration; + break; + case "s": + durationInMs = duration * 1e3; + break; + case "m": + durationInMs = duration * 1e3 * 60; + break; + default: + break; + } + advanceFrameBy(durationInMs / this_1.frameTimeFactor); + break; + } + } + } + throw new Error("there can only be '^' and '!' markers in a subscription marble diagram. Found instead '" + c + "'."); + } + frame = nextFrame; + out_i_1 = i2; + }; + var this_1 = this, out_i_1; + for (var i = 0; i < len; i++) { + _loop_1(i); + i = out_i_1; + } + if (unsubscriptionFrame < 0) { + return new SubscriptionLog_1.SubscriptionLog(subscriptionFrame); + } else { + return new SubscriptionLog_1.SubscriptionLog(subscriptionFrame, unsubscriptionFrame); + } + }; + TestScheduler3.parseMarbles = function(marbles, values, errorValue, materializeInnerObservables, runMode) { + var _this = this; + if (materializeInnerObservables === void 0) { + materializeInnerObservables = false; + } + if (runMode === void 0) { + runMode = false; + } + if (marbles.indexOf("!") !== -1) { + throw new Error('conventional marble diagrams cannot have the unsubscription marker "!"'); + } + var characters = __spreadArray([], __read(marbles)); + var len = characters.length; + var testMessages = []; + var subIndex = runMode ? marbles.replace(/^[ ]+/, "").indexOf("^") : marbles.indexOf("^"); + var frame = subIndex === -1 ? 0 : subIndex * -this.frameTimeFactor; + var getValue = typeof values !== "object" ? function(x) { + return x; + } : function(x) { + if (materializeInnerObservables && values[x] instanceof ColdObservable_1.ColdObservable) { + return values[x].messages; + } + return values[x]; + }; + var groupStart = -1; + var _loop_2 = function(i2) { + var nextFrame = frame; + var advanceFrameBy = function(count) { + nextFrame += count * _this.frameTimeFactor; + }; + var notification = void 0; + var c = characters[i2]; + switch (c) { + case " ": + if (!runMode) { + advanceFrameBy(1); + } + break; + case "-": + advanceFrameBy(1); + break; + case "(": + groupStart = frame; + advanceFrameBy(1); + break; + case ")": + groupStart = -1; + advanceFrameBy(1); + break; + case "|": + notification = NotificationFactories_1.COMPLETE_NOTIFICATION; + advanceFrameBy(1); + break; + case "^": + advanceFrameBy(1); + break; + case "#": + notification = NotificationFactories_1.errorNotification(errorValue || "error"); + advanceFrameBy(1); + break; + default: + if (runMode && c.match(/^[0-9]$/)) { + if (i2 === 0 || characters[i2 - 1] === " ") { + var buffer = characters.slice(i2).join(""); + var match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /); + if (match) { + i2 += match[0].length - 1; + var duration = parseFloat(match[1]); + var unit = match[2]; + var durationInMs = void 0; + switch (unit) { + case "ms": + durationInMs = duration; + break; + case "s": + durationInMs = duration * 1e3; + break; + case "m": + durationInMs = duration * 1e3 * 60; + break; + default: + break; + } + advanceFrameBy(durationInMs / this_2.frameTimeFactor); + break; + } + } + } + notification = NotificationFactories_1.nextNotification(getValue(c)); + advanceFrameBy(1); + break; + } + if (notification) { + testMessages.push({ frame: groupStart > -1 ? groupStart : frame, notification }); + } + frame = nextFrame; + out_i_2 = i2; + }; + var this_2 = this, out_i_2; + for (var i = 0; i < len; i++) { + _loop_2(i); + i = out_i_2; + } + return testMessages; + }; + TestScheduler3.prototype.createAnimator = function() { + var _this = this; + if (!this.runMode) { + throw new Error("animate() must only be used in run mode"); + } + var lastHandle = 0; + var map2; + var delegate = { + requestAnimationFrame: function(callback) { + if (!map2) { + throw new Error("animate() was not called within run()"); + } + var handle = ++lastHandle; + map2.set(handle, callback); + return handle; + }, + cancelAnimationFrame: function(handle) { + if (!map2) { + throw new Error("animate() was not called within run()"); + } + map2.delete(handle); + } + }; + var animate = function(marbles) { + var e_1, _a; + if (map2) { + throw new Error("animate() must not be called more than once within run()"); + } + if (/[|#]/.test(marbles)) { + throw new Error("animate() must not complete or error"); + } + map2 = /* @__PURE__ */ new Map(); + var messages = TestScheduler3.parseMarbles(marbles, void 0, void 0, void 0, true); + try { + for (var messages_1 = __values(messages), messages_1_1 = messages_1.next(); !messages_1_1.done; messages_1_1 = messages_1.next()) { + var message = messages_1_1.value; + _this.schedule(function() { + var e_2, _a2; + var now = _this.now(); + var callbacks = Array.from(map2.values()); + map2.clear(); + try { + for (var callbacks_1 = (e_2 = void 0, __values(callbacks)), callbacks_1_1 = callbacks_1.next(); !callbacks_1_1.done; callbacks_1_1 = callbacks_1.next()) { + var callback = callbacks_1_1.value; + callback(now); + } + } catch (e_2_1) { + e_2 = { error: e_2_1 }; + } finally { + try { + if (callbacks_1_1 && !callbacks_1_1.done && (_a2 = callbacks_1.return)) + _a2.call(callbacks_1); + } finally { + if (e_2) + throw e_2.error; + } + } + }, message.frame); + } + } catch (e_1_1) { + e_1 = { error: e_1_1 }; + } finally { + try { + if (messages_1_1 && !messages_1_1.done && (_a = messages_1.return)) + _a.call(messages_1); + } finally { + if (e_1) + throw e_1.error; + } + } + }; + return { animate, delegate }; + }; + TestScheduler3.prototype.createDelegates = function() { + var _this = this; + var lastHandle = 0; + var scheduleLookup = /* @__PURE__ */ new Map(); + var run = function() { + var now = _this.now(); + var scheduledRecords = Array.from(scheduleLookup.values()); + var scheduledRecordsDue = scheduledRecords.filter(function(_a2) { + var due = _a2.due; + return due <= now; + }); + var dueImmediates = scheduledRecordsDue.filter(function(_a2) { + var type = _a2.type; + return type === "immediate"; + }); + if (dueImmediates.length > 0) { + var _a = dueImmediates[0], handle = _a.handle, handler = _a.handler; + scheduleLookup.delete(handle); + handler(); + return; + } + var dueIntervals = scheduledRecordsDue.filter(function(_a2) { + var type = _a2.type; + return type === "interval"; + }); + if (dueIntervals.length > 0) { + var firstDueInterval = dueIntervals[0]; + var duration = firstDueInterval.duration, handler = firstDueInterval.handler; + firstDueInterval.due = now + duration; + firstDueInterval.subscription = _this.schedule(run, duration); + handler(); + return; + } + var dueTimeouts = scheduledRecordsDue.filter(function(_a2) { + var type = _a2.type; + return type === "timeout"; + }); + if (dueTimeouts.length > 0) { + var _b = dueTimeouts[0], handle = _b.handle, handler = _b.handler; + scheduleLookup.delete(handle); + handler(); + return; + } + throw new Error("Expected a due immediate or interval"); + }; + var immediate = { + setImmediate: function(handler) { + var handle = ++lastHandle; + scheduleLookup.set(handle, { + due: _this.now(), + duration: 0, + handle, + handler, + subscription: _this.schedule(run, 0), + type: "immediate" + }); + return handle; + }, + clearImmediate: function(handle) { + var value = scheduleLookup.get(handle); + if (value) { + value.subscription.unsubscribe(); + scheduleLookup.delete(handle); + } + } + }; + var interval = { + setInterval: function(handler, duration) { + if (duration === void 0) { + duration = 0; + } + var handle = ++lastHandle; + scheduleLookup.set(handle, { + due: _this.now() + duration, + duration, + handle, + handler, + subscription: _this.schedule(run, duration), + type: "interval" + }); + return handle; + }, + clearInterval: function(handle) { + var value = scheduleLookup.get(handle); + if (value) { + value.subscription.unsubscribe(); + scheduleLookup.delete(handle); + } + } + }; + var timeout = { + setTimeout: function(handler, duration) { + if (duration === void 0) { + duration = 0; + } + var handle = ++lastHandle; + scheduleLookup.set(handle, { + due: _this.now() + duration, + duration, + handle, + handler, + subscription: _this.schedule(run, duration), + type: "timeout" + }); + return handle; + }, + clearTimeout: function(handle) { + var value = scheduleLookup.get(handle); + if (value) { + value.subscription.unsubscribe(); + scheduleLookup.delete(handle); + } + } + }; + return { immediate, interval, timeout }; + }; + TestScheduler3.prototype.run = function(callback) { + var prevFrameTimeFactor = TestScheduler3.frameTimeFactor; + var prevMaxFrames = this.maxFrames; + TestScheduler3.frameTimeFactor = 1; + this.maxFrames = Infinity; + this.runMode = true; + var animator = this.createAnimator(); + var delegates = this.createDelegates(); + animationFrameProvider_1.animationFrameProvider.delegate = animator.delegate; + dateTimestampProvider_1.dateTimestampProvider.delegate = this; + immediateProvider_1.immediateProvider.delegate = delegates.immediate; + intervalProvider_1.intervalProvider.delegate = delegates.interval; + timeoutProvider_1.timeoutProvider.delegate = delegates.timeout; + performanceTimestampProvider_1.performanceTimestampProvider.delegate = this; + var helpers = { + cold: this.createColdObservable.bind(this), + hot: this.createHotObservable.bind(this), + flush: this.flush.bind(this), + time: this.createTime.bind(this), + expectObservable: this.expectObservable.bind(this), + expectSubscriptions: this.expectSubscriptions.bind(this), + animate: animator.animate + }; + try { + var ret = callback(helpers); + this.flush(); + return ret; + } finally { + TestScheduler3.frameTimeFactor = prevFrameTimeFactor; + this.maxFrames = prevMaxFrames; + this.runMode = false; + animationFrameProvider_1.animationFrameProvider.delegate = void 0; + dateTimestampProvider_1.dateTimestampProvider.delegate = void 0; + immediateProvider_1.immediateProvider.delegate = void 0; + intervalProvider_1.intervalProvider.delegate = void 0; + timeoutProvider_1.timeoutProvider.delegate = void 0; + performanceTimestampProvider_1.performanceTimestampProvider.delegate = void 0; + } + }; + TestScheduler3.frameTimeFactor = 10; + return TestScheduler3; + }(VirtualTimeScheduler_1.VirtualTimeScheduler); + exports.TestScheduler = TestScheduler2; + } +}); + +// node_modules/rxjs/dist/cjs/testing/index.js +var require_testing = __commonJS({ + "node_modules/rxjs/dist/cjs/testing/index.js"(exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.TestScheduler = void 0; + var TestScheduler_1 = require_TestScheduler(); + Object.defineProperty(exports, "TestScheduler", { enumerable: true, get: function() { + return TestScheduler_1.TestScheduler; + } }); + } +}); + +// compradprogvm.test.ts +var import_rxjs = __toESM(require_cjs(), 1); +var import_testing = __toESM(require_testing(), 1); +import { deepEqual, ok } from "node:assert/strict"; +import { describe, it } from "node:test"; + +// compradprogvm.js +var CompRadProgVm = class { + // *** Experiment modification fields *** + minBar = 1; + maxGrowthPerTick = 90; + maxCatchPerTick = 15; + catchSpinRate = 2; + growthSpinRate = 1; + spinTicks = 2; + spinRate = 1; + // Internal counter during ticks + #spinTickCount = 0; + #subscription = new Subscription(); + // *** Butterflies and observables *** + #progressAdded; + #addProgress; + get progressAdded() { + return this.#progressAdded; + } + #inprogress = []; + get progressCount() { + return this.#inprogress.length; + } + get pausedStatus() { + return combineLatest(this.#inprogress.map((prog) => prog.paused)); + } + #targetPercent; + get targetPercent() { + return this.#targetPercent; + } + #targetRoundPercent; + get targetRoundPercent() { + return this.#targetRoundPercent; + } + #targetVal; + get targetVal() { + return this.#targetVal; + } + #ticks; + #tick; + #currentVal; + #setCurrentVal; + get currentVal() { + return this.#currentVal; + } + #currentOffset; + #setCurrentOffset; + get currentOffset() { + return this.#currentOffset; + } + constructor(dial) { + ; + [this.#progressAdded, this.#addProgress] = butterfly(null); + [this.#ticks, this.#tick] = butterfly(void 0); + [this.#currentVal, this.#setCurrentVal] = butterfly(0); + [this.#currentOffset, this.#setCurrentOffset] = butterfly(0); + this.#targetPercent = this.progressAdded.pipe( + filter((progress) => progress !== null), + map((progress) => progress.percent), + combineLatestAll(), + map((progresses) => progresses.reduce((a, b) => a + b) / progresses.length), + shareReplay(1) + ); + this.#targetRoundPercent = this.targetPercent.pipe( + map((target) => Math.round(target * 100)) + ); + this.#targetVal = this.targetPercent.pipe( + map((target) => Math.round(target * 360)) + ); + const current = combineLatest([this.currentVal, this.currentOffset, this.targetVal, this.#ticks]).pipe( + map(([currentVal, currentOffset, targetVal]) => this.onTick(currentVal, currentOffset, targetVal)) + ); + this.#subscription.add( + current.subscribe({ + next: ([currentVal, currentOffset]) => { + this.#setCurrentVal(currentVal); + this.#setCurrentOffset(currentOffset); + } + }) + ); + if (dial) { + this.#subscription.add(this.currentVal.subscribe((currentVal) => dial.val(currentVal).trigger("change"))); + this.#subscription.add(this.currentOffset.subscribe( + (currentOffset) => dial.trigger("configure", { angleOffset: currentOffset }) + )); + } else { + console.warn("Unable to subscribe jQuery Knob dial to progress changes"); + } + } + pauseAll() { + this.#inprogress.forEach((item) => item.pause()); + } + unpauseAll() { + this.#inprogress.forEach((item) => item.unpause()); + } + addItem() { + const progress = new ProgVm(); + this.#addProgress(progress); + this.#inprogress.unshift(new ProgVm()); + } + tick() { + this.#inprogress.forEach((item) => item.tick()); + this.#tick(void 0); + } + onTick(currentVal, currentOffset, targetVal) { + if (currentVal < this.minBar) { + currentVal = this.minBar; + } + if (targetVal > currentVal) { + const diff = Math.min( + targetVal - currentVal, + this.maxGrowthPerTick + ); + currentVal += diff; + if (this.growthSpinRate) { + currentOffset += this.growthSpinRate; + } + this.#spinTickCount = 0; + } else if (targetVal < currentVal && currentVal > this.minBar) { + const diff = Math.min( + currentVal - targetVal, + this.maxCatchPerTick + ); + currentVal = Math.max(currentVal - diff, this.minBar); + const offset = (currentOffset + diff + this.catchSpinRate) % 360; + currentOffset = offset; + this.#spinTickCount = 0; + } else if (currentVal < 360) { + this.#spinTickCount++; + if (this.#spinTickCount == this.spinTicks) { + currentOffset = (currentOffset + this.spinRate) % 360; + this.#spinTickCount = 0; + } + } else if (currentVal == 360 && currentOffset != 0) { + currentOffset = 0; + } + return [currentVal, currentOffset]; + } + unsubscribe() { + this.#subscription.unsubscribe(); + } +}; + +// compradprogvm.test.ts +describe("CompRadProgVm", () => { + it("adds items", () => { + const vm = new CompRadProgVm(); + const startlength = vm.progressCount; + vm.addItem(); + ok(vm.progressCount > startlength); + }); + it("pauses all", async () => { + const vm = new CompRadProgVm(); + vm.addItem(); + vm.addItem(); + vm.pauseAll(); + const paused = await (0, import_rxjs.firstValueFrom)(vm.pausedStatus); + ok(paused.every((paused2) => paused2)); + }); + it("unpauses all", async () => { + const vm = new CompRadProgVm(); + vm.addItem(); + vm.addItem(); + vm.pauseAll(); + vm.unpauseAll(); + const paused = await (0, import_rxjs.firstValueFrom)(vm.pausedStatus); + ok(paused.every((paused2) => !paused2)); + }); + it.skip("ticks forward", async () => { + const testScheduler = new import_testing.TestScheduler( + (actual, expected) => deepEqual(actual, expected) + ); + testScheduler.run(({ cold, expectObservable }) => { + const ticks = cold("--x--x"); + const expected = " a-b--c"; + const expectedValues = { + a: 0, + b: 1, + c: 1 + }; + const vm = new CompRadProgVm(void 0, ticks); + vm.addItem(); + vm.addItem(); + expectObservable(vm.currentVal).toBe(expected, expectedValues); + }); + }); +}); diff --git a/compradprogvm.test.ts b/compradprogvm.test.ts new file mode 100644 index 0000000..973899b --- /dev/null +++ b/compradprogvm.test.ts @@ -0,0 +1,53 @@ +import { deepEqual, ok } from 'node:assert/strict' +import { describe, it } from 'node:test' +import { firstValueFrom, take, toArray } from 'rxjs' +import { TestScheduler } from 'rxjs/testing' +import { CompRadProgVm } from './compradprogvm.js' + +describe('CompRadProgVm', () => { + it('adds items', () => { + const vm = new CompRadProgVm() + const startlength = vm.progressCount + vm.addItem() + ok(vm.progressCount > startlength) + }) + + it('pauses all', async () => { + const vm = new CompRadProgVm() + vm.addItem() + vm.addItem() + vm.pauseAll() + const paused = await firstValueFrom(vm.pausedStatus) + ok(paused.every((paused) => paused)) + }) + + it('unpauses all', async () => { + const vm = new CompRadProgVm() + vm.addItem() + vm.addItem() + vm.pauseAll() + vm.unpauseAll() + const paused = await firstValueFrom(vm.pausedStatus) + ok(paused.every((paused) => !paused)) + }) + + it.skip('ticks forward', async () => { + // Test doesn't work because tick operations have embedded promises to update ProgVm ticks + const testScheduler = new TestScheduler((actual, expected) => + deepEqual(actual, expected), + ) + testScheduler.run(({ cold, expectObservable }) => { + const ticks = cold('--x--x') + const expected = ' a-b--c' + const expectedValues = { + a: 0, + b: 1, + c: 1, + } + const vm = new CompRadProgVm(undefined, ticks) + vm.addItem() + vm.addItem() + expectObservable(vm.currentVal).toBe(expected, expectedValues) + }) + }) +}) diff --git a/compradprogvm.ts b/compradprogvm.ts index bc1a5bc..48c6ba8 100644 --- a/compradprogvm.ts +++ b/compradprogvm.ts @@ -1,95 +1,186 @@ -import * as ko from 'knockout' +import { + Observable, + Subscription, + combineLatest, + combineLatestAll, + concat, + concatMap, + filter, + interval, + map, + of, + scan, + shareReplay, + withLatestFrom, +} from 'rxjs' import { ProgVm } from './progvm' +import { butterfly } from 'butterfloat' export class CompRadProgVm { - minBar = 1 - maxGrowthPerTick = 90 - maxCatchPerTick = 15 - catchSpinRate = 2 - growthSpinRate = 1 - spinTicks = 2 - spinTickCount = 0 - spinRate = 1 - - inprogress = ko.observableArray() - - targetPercent = ko.computed(() => - this.inprogress().length > 0 - ? this.inprogress() - .map((item) => item.percent()) - .reduce((a, b) => a + b) / this.inprogress().length - : 0, + // *** Experiment modification fields *** + minBar = 1 + maxGrowthPerTick = 90 + maxCatchPerTick = 15 + catchSpinRate = 2 + growthSpinRate = 1 + spinTicks = 2 + spinRate = 1 + + // Internal counter during ticks + #spinTickCount = 0 + + readonly #subscription = new Subscription() + + // *** Butterflies and observables *** + + readonly #progressAdded: Observable + readonly #addProgress: (progress: ProgVm) => void + get progressAdded() { + return this.#progressAdded + } + readonly #inprogress: ProgVm[] = [] + get progressCount() { + return this.#inprogress.length + } + get pausedStatus() { + return combineLatest(this.#inprogress.map((prog) => prog.paused)) + } + + readonly #targetPercent: Observable + get targetPercent() { + return this.#targetPercent + } + + readonly #targetRoundPercent: Observable + get targetRoundPercent() { + return this.#targetRoundPercent + } + + readonly #targetVal: Observable + get targetVal() { + return this.#targetVal + } + + readonly #currentVal: Observable + get currentVal() { + return this.#currentVal + } + + readonly #currentOffset: Observable + get currentOffset() { + return this.#currentOffset + } + + constructor(dial?: JQuery, ticks?: Observable) { + ;[this.#progressAdded, this.#addProgress] = butterfly(null) + + this.#targetPercent = this.progressAdded.pipe( + filter((progress) => progress !== null), + map((progress) => progress!.percent), + combineLatestAll(), + map( + (progresses) => progresses.reduce((a, b) => a + b) / progresses.length, + ), + shareReplay(1), + ) + + this.#targetRoundPercent = this.targetPercent.pipe( + map((target) => Math.round(target * 100)), + ) + + this.#targetVal = this.targetPercent.pipe( + map((target) => Math.round(target * 360)), + ) + + const current = concat( + of([0, 0]), + (ticks ?? interval(500)).pipe( + concatMap(() => + Promise.all(this.#inprogress.map((item) => item.tick())), + ), + withLatestFrom(this.targetVal), + scan( + ([currentVal, currentOffset], [, targetVal]) => + this.#onTick(currentVal, currentOffset, targetVal), + [0, 0], + ), + shareReplay(1), + ), ) - targetRoundPercent = ko.computed(() => Math.round(this.targetPercent() * 100)) - targetVal = ko.computed(() => Math.round(this.targetPercent() * 360)) - currentVal = ko.observable(0) - currentOffset = ko.observable(0) - - constructor(dial: JQuery | undefined) { - if (dial) { - this.currentVal.subscribe((v) => dial.val(v).trigger('change')) - - this.currentOffset.subscribe((v) => - dial.trigger('configure', { angleOffset: this.currentOffset() }), + + this.#currentVal = current.pipe(map(([currentVal]) => currentVal)) + this.#currentOffset = current.pipe( + map(([, currentOffset]) => currentOffset), + ) + + if (dial) { + this.#subscription.add( + this.currentVal.subscribe((currentVal) => + dial.val(currentVal).trigger('change'), + ), ) - } else { - console.warn('Unable to subscribe jQuery Knob dial to progress changes') - } - } - - pauseAll() { - this.inprogress().forEach((item) => item.pause()) - } - - unpauseAll() { - this.inprogress().forEach((item) => item.unpause()) + + this.#subscription.add( + this.currentOffset.subscribe((currentOffset) => + dial.trigger('configure', { angleOffset: currentOffset }), + ), + ) + } else { + console.warn('Unable to subscribe jQuery Knob dial to progress changes') } - - addItem() { - this.inprogress.unshift(new ProgVm()) + } + + pauseAll() { + this.#inprogress.forEach((item) => item.pause()) + } + + unpauseAll() { + this.#inprogress.forEach((item) => item.unpause()) + } + + addItem() { + const progress = new ProgVm() + this.#addProgress(progress) + this.#inprogress.unshift(new ProgVm()) + } + + #onTick( + currentVal: number, + currentOffset: number, + targetVal: number, + ): [currentVal: number, currentOffset: number] { + // update radial + if (currentVal < this.minBar) { + currentVal = this.minBar } - - tick() { - // update item percentages - this.inprogress().forEach((item) => item.tick()) - - // update radial - if (this.currentVal() < this.minBar) { - this.currentVal(this.minBar) + + if (targetVal > currentVal) { + const diff = Math.min(targetVal - currentVal, this.maxGrowthPerTick) + currentVal += diff + if (this.growthSpinRate) { + currentOffset += this.growthSpinRate } - - if (this.targetVal() > this.currentVal()) { - const diff = Math.min( - this.targetVal() - this.currentVal(), - this.maxGrowthPerTick, - ) - this.currentVal(this.currentVal() + diff) - if (this.growthSpinRate) { - this.currentOffset(this.currentOffset() + this.growthSpinRate) - } - this.spinTickCount = 0 - } else if ( - this.targetVal() < this.currentVal() && - this.currentVal() > this.minBar - ) { - const diff = Math.min( - this.currentVal() - this.targetVal(), - this.maxCatchPerTick, - ) - this.currentVal(Math.max(this.currentVal() - diff, this.minBar)) - const offset = (this.currentOffset() + diff + this.catchSpinRate) % 360 - this.currentOffset(offset) - this.spinTickCount = 0 - } else if (this.currentVal() < 360) { - this.spinTickCount++ - if (this.spinTickCount == this.spinTicks) { - this.currentOffset((this.currentOffset() + this.spinRate) % 360) - this.spinTickCount = 0 - } - } else if (this.currentVal() == 360 && this.currentOffset() != 0) { - // once complete, reset the offset for the next run - this.currentOffset(0) + this.#spinTickCount = 0 + } else if (targetVal < currentVal && currentVal > this.minBar) { + const diff = Math.min(currentVal - targetVal, this.maxCatchPerTick) + currentVal = Math.max(currentVal - diff, this.minBar) + const offset = (currentOffset + diff + this.catchSpinRate) % 360 + currentOffset = offset + this.#spinTickCount = 0 + } else if (currentVal < 360) { + this.#spinTickCount++ + if (this.#spinTickCount == this.spinTicks) { + currentOffset = (currentOffset + this.spinRate) % 360 + this.#spinTickCount = 0 } + } else if (currentVal == 360 && currentOffset != 0) { + // once complete, reset the offset for the next run + currentOffset = 0 } + return [currentVal, currentOffset] + } + + unsubscribe() { + this.#subscription.unsubscribe() } - \ No newline at end of file +} diff --git a/main.js b/main.js index e6caa67..8de3364 100644 --- a/main.js +++ b/main.js @@ -7,11 +7,11 @@ var __hasOwnProp = Object.prototype.hasOwnProperty; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; -var __copyProps = (to, from, except, desc) => { - if (from && typeof from === "object" || typeof from === "function") { - for (let key of __getOwnPropNames(from)) +var __copyProps = (to, from2, except, desc) => { + if (from2 && typeof from2 === "object" || typeof from2 === "function") { + for (let key of __getOwnPropNames(from2)) if (!__hasOwnProp.call(to, key) && key !== except) - __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + __defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable }); } return to; }; @@ -24,4824 +24,1635 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge mod )); -// node_modules/knockout/build/output/knockout-latest.js -var require_knockout_latest = __commonJS({ - "node_modules/knockout/build/output/knockout-latest.js"(exports, module) { - (function() { - (function(n) { - var A = this || (0, eval)("this"), w2 = A.document, R = A.navigator, v = A.jQuery, H = A.JSON; - v || "undefined" === typeof jQuery || (v = jQuery); - (function(n2) { - "function" === typeof define && define.amd ? define(["exports", "require"], n2) : "object" === typeof exports && "object" === typeof module ? n2(module.exports || exports) : n2(A.ko = {}); - })(function(S, T) { - function K(a2, c) { - return null === a2 || typeof a2 in W ? a2 === c : false; - } - function X(b, c) { - var d; - return function() { - d || (d = a.a.setTimeout(function() { - d = n; - b(); - }, c)); - }; - } - function Y(b, c) { - var d; - return function() { - clearTimeout(d); - d = a.a.setTimeout(b, c); - }; - } - function Z(a2, c) { - c && "change" !== c ? "beforeChange" === c ? this.pc(a2) : this.gb(a2, c) : this.qc(a2); +// node_modules/jquery/dist/jquery.js +var require_jquery = __commonJS({ + "node_modules/jquery/dist/jquery.js"(exports, module) { + (function(global, factory) { + "use strict"; + if (typeof module === "object" && typeof module.exports === "object") { + module.exports = global.document ? factory(global, true) : function(w2) { + if (!w2.document) { + throw new Error("jQuery requires a window with a document"); } - function aa(a2, c) { - null !== c && c.s && c.s(); + return factory(w2); + }; + } else { + factory(global); + } + })(typeof window !== "undefined" ? window : exports, function(window2, noGlobal) { + "use strict"; + var arr = []; + var getProto = Object.getPrototypeOf; + var slice = arr.slice; + var flat = arr.flat ? function(array) { + return arr.flat.call(array); + } : function(array) { + return arr.concat.apply([], array); + }; + var push = arr.push; + var indexOf = arr.indexOf; + var class2type = {}; + var toString = class2type.toString; + var hasOwn = class2type.hasOwnProperty; + var fnToString = hasOwn.toString; + var ObjectFunctionString = fnToString.call(Object); + var support = {}; + var isFunction2 = function isFunction3(obj) { + return typeof obj === "function" && typeof obj.nodeType !== "number" && typeof obj.item !== "function"; + }; + var isWindow = function isWindow2(obj) { + return obj != null && obj === obj.window; + }; + var document2 = window2.document; + var preservedScriptAttributes = { + type: true, + src: true, + nonce: true, + noModule: true + }; + function DOMEval(code, node, doc) { + doc = doc || document2; + var i, val, script = doc.createElement("script"); + script.text = code; + if (node) { + for (i in preservedScriptAttributes) { + val = node[i] || node.getAttribute && node.getAttribute(i); + if (val) { + script.setAttribute(i, val); + } } - function ba(a2, c) { - var d = this.qd, e = d[r]; - e.ra || (this.Qb && this.mb[c] ? (d.uc(c, a2, this.mb[c]), this.mb[c] = null, --this.Qb) : e.I[c] || d.uc(c, a2, e.J ? { da: a2 } : d.$c(a2)), a2.Ja && a2.gd()); + } + doc.head.appendChild(script).parentNode.removeChild(script); + } + function toType(obj) { + if (obj == null) { + return obj + ""; + } + return typeof obj === "object" || typeof obj === "function" ? class2type[toString.call(obj)] || "object" : typeof obj; + } + var version = "3.6.0", jQuery2 = function(selector, context2) { + return new jQuery2.fn.init(selector, context2); + }; + jQuery2.fn = jQuery2.prototype = { + // The current version of jQuery being used + jquery: version, + constructor: jQuery2, + // The default length of a jQuery object is 0 + length: 0, + toArray: function() { + return slice.call(this); + }, + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function(num) { + if (num == null) { + return slice.call(this); } - var a = "undefined" !== typeof S ? S : {}; - a.b = function(b, c) { - for (var d = b.split("."), e = a, f = 0; f < d.length - 1; f++) - e = e[d[f]]; - e[d[d.length - 1]] = c; - }; - a.L = function(a2, c, d) { - a2[c] = d; - }; - a.version = "3.5.1"; - a.b( - "version", - a.version - ); - a.options = { deferUpdates: false, useOnlyNativeEvents: false, foreachHidesDestroyed: false }; - a.a = function() { - function b(a2, b2) { - for (var c2 in a2) - f.call(a2, c2) && b2(c2, a2[c2]); - } - function c(a2, b2) { - if (b2) - for (var c2 in b2) - f.call(b2, c2) && (a2[c2] = b2[c2]); - return a2; - } - function d(a2, b2) { - a2.__proto__ = b2; - return a2; - } - function e(b2, c2, d2, e2) { - var l2 = b2[c2].match(q) || []; - a.a.D(d2.match(q), function(b3) { - a.a.Na(l2, b3, e2); - }); - b2[c2] = l2.join(" "); - } - var f = Object.prototype.hasOwnProperty, g = { __proto__: [] } instanceof Array, h = "function" === typeof Symbol, m = {}, k = {}; - m[R && /Firefox\/2/i.test(R.userAgent) ? "KeyboardEvent" : "UIEvents"] = ["keyup", "keydown", "keypress"]; - m.MouseEvents = "click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave".split(" "); - b(m, function(a2, b2) { - if (b2.length) - for (var c2 = 0, d2 = b2.length; c2 < d2; c2++) - k[b2[c2]] = a2; - }); - var l = { propertychange: true }, p = w2 && function() { - for (var a2 = 3, b2 = w2.createElement("div"), c2 = b2.getElementsByTagName("i"); b2.innerHTML = "", c2[0]; ) - ; - return 4 < a2 ? a2 : n; - }(), q = /\S+/g, t; - return { - Jc: ["authenticity_token", /^__RequestVerificationToken(_.*)?$/], - D: function(a2, b2, c2) { - for (var d2 = 0, e2 = a2.length; d2 < e2; d2++) - b2.call(c2, a2[d2], d2, a2); - }, - A: "function" == typeof Array.prototype.indexOf ? function(a2, b2) { - return Array.prototype.indexOf.call(a2, b2); - } : function(a2, b2) { - for (var c2 = 0, d2 = a2.length; c2 < d2; c2++) - if (a2[c2] === b2) - return c2; - return -1; - }, - Lb: function(a2, b2, c2) { - for (var d2 = 0, e2 = a2.length; d2 < e2; d2++) - if (b2.call(c2, a2[d2], d2, a2)) - return a2[d2]; - return n; - }, - Pa: function(b2, c2) { - var d2 = a.a.A(b2, c2); - 0 < d2 ? b2.splice(d2, 1) : 0 === d2 && b2.shift(); - }, - wc: function(b2) { - var c2 = []; - b2 && a.a.D(b2, function(b3) { - 0 > a.a.A(c2, b3) && c2.push(b3); - }); - return c2; - }, - Mb: function(a2, b2, c2) { - var d2 = []; - if (a2) - for (var e2 = 0, l2 = a2.length; e2 < l2; e2++) - d2.push(b2.call(c2, a2[e2], e2)); - return d2; - }, - jb: function(a2, b2, c2) { - var d2 = []; - if (a2) - for (var e2 = 0, l2 = a2.length; e2 < l2; e2++) - b2.call(c2, a2[e2], e2) && d2.push(a2[e2]); - return d2; - }, - Nb: function(a2, b2) { - if (b2 instanceof Array) - a2.push.apply(a2, b2); - else - for (var c2 = 0, d2 = b2.length; c2 < d2; c2++) - a2.push(b2[c2]); - return a2; - }, - Na: function(b2, c2, d2) { - var e2 = a.a.A(a.a.bc(b2), c2); - 0 > e2 ? d2 && b2.push(c2) : d2 || b2.splice(e2, 1); - }, - Ba: g, - extend: c, - setPrototypeOf: d, - Ab: g ? d : c, - P: b, - Ga: function(a2, b2, c2) { - if (!a2) - return a2; - var d2 = {}, e2; - for (e2 in a2) - f.call(a2, e2) && (d2[e2] = b2.call(c2, a2[e2], e2, a2)); - return d2; - }, - Tb: function(b2) { - for (; b2.firstChild; ) - a.removeNode(b2.firstChild); - }, - Yb: function(b2) { - b2 = a.a.la(b2); - for (var c2 = (b2[0] && b2[0].ownerDocument || w2).createElement("div"), d2 = 0, e2 = b2.length; d2 < e2; d2++) - c2.appendChild(a.oa(b2[d2])); - return c2; - }, - Ca: function(b2, c2) { - for (var d2 = 0, e2 = b2.length, l2 = []; d2 < e2; d2++) { - var k2 = b2[d2].cloneNode(true); - l2.push(c2 ? a.oa(k2) : k2); - } - return l2; - }, - va: function(b2, c2) { - a.a.Tb(b2); - if (c2) - for (var d2 = 0, e2 = c2.length; d2 < e2; d2++) - b2.appendChild(c2[d2]); - }, - Xc: function(b2, c2) { - var d2 = b2.nodeType ? [b2] : b2; - if (0 < d2.length) { - for (var e2 = d2[0], l2 = e2.parentNode, k2 = 0, f2 = c2.length; k2 < f2; k2++) - l2.insertBefore(c2[k2], e2); - k2 = 0; - for (f2 = d2.length; k2 < f2; k2++) - a.removeNode(d2[k2]); - } - }, - Ua: function(a2, b2) { - if (a2.length) { - for (b2 = 8 === b2.nodeType && b2.parentNode || b2; a2.length && a2[0].parentNode !== b2; ) - a2.splice(0, 1); - for (; 1 < a2.length && a2[a2.length - 1].parentNode !== b2; ) - a2.length--; - if (1 < a2.length) { - var c2 = a2[0], d2 = a2[a2.length - 1]; - for (a2.length = 0; c2 !== d2; ) - a2.push(c2), c2 = c2.nextSibling; - a2.push(d2); - } - } - return a2; - }, - Zc: function(a2, b2) { - 7 > p ? a2.setAttribute("selected", b2) : a2.selected = b2; - }, - Db: function(a2) { - return null === a2 || a2 === n ? "" : a2.trim ? a2.trim() : a2.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g, ""); - }, - Ud: function(a2, b2) { - a2 = a2 || ""; - return b2.length > a2.length ? false : a2.substring(0, b2.length) === b2; - }, - vd: function(a2, b2) { - if (a2 === b2) - return true; - if (11 === a2.nodeType) - return false; - if (b2.contains) - return b2.contains(1 !== a2.nodeType ? a2.parentNode : a2); - if (b2.compareDocumentPosition) - return 16 == (b2.compareDocumentPosition(a2) & 16); - for (; a2 && a2 != b2; ) - a2 = a2.parentNode; - return !!a2; - }, - Sb: function(b2) { - return a.a.vd(b2, b2.ownerDocument.documentElement); - }, - kd: function(b2) { - return !!a.a.Lb(b2, a.a.Sb); - }, - R: function(a2) { - return a2 && a2.tagName && a2.tagName.toLowerCase(); - }, - Ac: function(b2) { - return a.onError ? function() { - try { - return b2.apply(this, arguments); - } catch (c2) { - throw a.onError && a.onError(c2), c2; - } - } : b2; - }, - setTimeout: function(b2, c2) { - return setTimeout(a.a.Ac(b2), c2); - }, - Gc: function(b2) { - setTimeout(function() { - a.onError && a.onError(b2); - throw b2; - }, 0); - }, - B: function(b2, c2, d2) { - var e2 = a.a.Ac(d2); - d2 = l[c2]; - if (a.options.useOnlyNativeEvents || d2 || !v) - if (d2 || "function" != typeof b2.addEventListener) - if ("undefined" != typeof b2.attachEvent) { - var k2 = function(a2) { - e2.call(b2, a2); - }, f2 = "on" + c2; - b2.attachEvent( - f2, - k2 - ); - a.a.K.za(b2, function() { - b2.detachEvent(f2, k2); - }); - } else - throw Error("Browser doesn't support addEventListener or attachEvent"); - else - b2.addEventListener(c2, e2, false); - else - t || (t = "function" == typeof v(b2).on ? "on" : "bind"), v(b2)[t](c2, e2); - }, - Fb: function(b2, c2) { - if (!b2 || !b2.nodeType) - throw Error("element must be a DOM node when calling triggerEvent"); - var d2; - "input" === a.a.R(b2) && b2.type && "click" == c2.toLowerCase() ? (d2 = b2.type, d2 = "checkbox" == d2 || "radio" == d2) : d2 = false; - if (a.options.useOnlyNativeEvents || !v || d2) - if ("function" == typeof w2.createEvent) - if ("function" == typeof b2.dispatchEvent) - d2 = w2.createEvent(k[c2] || "HTMLEvents"), d2.initEvent(c2, true, true, A, 0, 0, 0, 0, 0, false, false, false, false, 0, b2), b2.dispatchEvent(d2); - else - throw Error("The supplied element doesn't support dispatchEvent"); - else if (d2 && b2.click) - b2.click(); - else if ("undefined" != typeof b2.fireEvent) - b2.fireEvent("on" + c2); - else - throw Error("Browser doesn't support triggering events"); - else - v(b2).trigger(c2); - }, - f: function(b2) { - return a.O(b2) ? b2() : b2; - }, - bc: function(b2) { - return a.O(b2) ? b2.v() : b2; - }, - Eb: function(b2, c2, d2) { - var l2; - c2 && ("object" === typeof b2.classList ? (l2 = b2.classList[d2 ? "add" : "remove"], a.a.D(c2.match(q), function(a2) { - l2.call(b2.classList, a2); - })) : "string" === typeof b2.className.baseVal ? e(b2.className, "baseVal", c2, d2) : e(b2, "className", c2, d2)); - }, - Bb: function(b2, c2) { - var d2 = a.a.f(c2); - if (null === d2 || d2 === n) - d2 = ""; - var e2 = a.h.firstChild(b2); - !e2 || 3 != e2.nodeType || a.h.nextSibling(e2) ? a.h.va(b2, [b2.ownerDocument.createTextNode(d2)]) : e2.data = d2; - a.a.Ad(b2); - }, - Yc: function(a2, b2) { - a2.name = b2; - if (7 >= p) - try { - var c2 = a2.name.replace(/[&<>'"]/g, function(a3) { - return "&#" + a3.charCodeAt(0) + ";"; - }); - a2.mergeAttributes(w2.createElement(""), false); - } catch (d2) { - } - }, - Ad: function(a2) { - 9 <= p && (a2 = 1 == a2.nodeType ? a2 : a2.parentNode, a2.style && (a2.style.zoom = a2.style.zoom)); - }, - wd: function(a2) { - if (p) { - var b2 = a2.style.width; - a2.style.width = 0; - a2.style.width = b2; - } - }, - Pd: function(b2, c2) { - b2 = a.a.f(b2); - c2 = a.a.f(c2); - for (var d2 = [], e2 = b2; e2 <= c2; e2++) - d2.push(e2); - return d2; - }, - la: function(a2) { - for (var b2 = [], c2 = 0, d2 = a2.length; c2 < d2; c2++) - b2.push(a2[c2]); - return b2; - }, - Da: function(a2) { - return h ? Symbol(a2) : a2; - }, - Zd: 6 === p, - $d: 7 === p, - W: p, - Lc: function(b2, c2) { - for (var d2 = a.a.la(b2.getElementsByTagName("input")).concat(a.a.la(b2.getElementsByTagName("textarea"))), e2 = "string" == typeof c2 ? function(a2) { - return a2.name === c2; - } : function(a2) { - return c2.test(a2.name); - }, l2 = [], k2 = d2.length - 1; 0 <= k2; k2--) - e2(d2[k2]) && l2.push(d2[k2]); - return l2; - }, - Nd: function(b2) { - return "string" == typeof b2 && (b2 = a.a.Db(b2)) ? H && H.parse ? H.parse(b2) : new Function("return " + b2)() : null; - }, - hc: function(b2, c2, d2) { - if (!H || !H.stringify) - throw Error("Cannot find JSON.stringify(). Some browsers (e.g., IE < 8) don't support it natively, but you can overcome this by adding a script reference to json2.js, downloadable from http://www.json.org/json2.js"); - return H.stringify(a.a.f(b2), c2, d2); - }, - Od: function(c2, d2, e2) { - e2 = e2 || {}; - var l2 = e2.params || {}, k2 = e2.includeFields || this.Jc, f2 = c2; - if ("object" == typeof c2 && "form" === a.a.R(c2)) - for (var f2 = c2.action, h2 = k2.length - 1; 0 <= h2; h2--) - for (var g2 = a.a.Lc(c2, k2[h2]), m2 = g2.length - 1; 0 <= m2; m2--) - l2[g2[m2].name] = g2[m2].value; - d2 = a.a.f(d2); - var p2 = w2.createElement("form"); - p2.style.display = "none"; - p2.action = f2; - p2.method = "post"; - for (var q2 in d2) - c2 = w2.createElement("input"), c2.type = "hidden", c2.name = q2, c2.value = a.a.hc(a.a.f(d2[q2])), p2.appendChild(c2); - b(l2, function(a2, b2) { - var c3 = w2.createElement("input"); - c3.type = "hidden"; - c3.name = a2; - c3.value = b2; - p2.appendChild(c3); - }); - w2.body.appendChild(p2); - e2.submitter ? e2.submitter(p2) : p2.submit(); - setTimeout(function() { - p2.parentNode.removeChild(p2); - }, 0); + return num < 0 ? this[num + this.length] : this[num]; + }, + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function(elems) { + var ret = jQuery2.merge(this.constructor(), elems); + ret.prevObject = this; + return ret; + }, + // Execute a callback for every element in the matched set. + each: function(callback) { + return jQuery2.each(this, callback); + }, + map: function(callback) { + return this.pushStack(jQuery2.map(this, function(elem, i) { + return callback.call(elem, i, elem); + })); + }, + slice: function() { + return this.pushStack(slice.apply(this, arguments)); + }, + first: function() { + return this.eq(0); + }, + last: function() { + return this.eq(-1); + }, + even: function() { + return this.pushStack(jQuery2.grep(this, function(_elem, i) { + return (i + 1) % 2; + })); + }, + odd: function() { + return this.pushStack(jQuery2.grep(this, function(_elem, i) { + return i % 2; + })); + }, + eq: function(i) { + var len = this.length, j = +i + (i < 0 ? len : 0); + return this.pushStack(j >= 0 && j < len ? [this[j]] : []); + }, + end: function() { + return this.prevObject || this.constructor(); + }, + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push, + sort: arr.sort, + splice: arr.splice + }; + jQuery2.extend = jQuery2.fn.extend = function() { + var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false; + if (typeof target === "boolean") { + deep = target; + target = arguments[i] || {}; + i++; + } + if (typeof target !== "object" && !isFunction2(target)) { + target = {}; + } + if (i === length) { + target = this; + i--; + } + for (; i < length; i++) { + if ((options = arguments[i]) != null) { + for (name in options) { + copy = options[name]; + if (name === "__proto__" || target === copy) { + continue; } - }; - }(); - a.b("utils", a.a); - a.b("utils.arrayForEach", a.a.D); - a.b("utils.arrayFirst", a.a.Lb); - a.b("utils.arrayFilter", a.a.jb); - a.b("utils.arrayGetDistinctValues", a.a.wc); - a.b("utils.arrayIndexOf", a.a.A); - a.b("utils.arrayMap", a.a.Mb); - a.b("utils.arrayPushAll", a.a.Nb); - a.b("utils.arrayRemoveItem", a.a.Pa); - a.b("utils.cloneNodes", a.a.Ca); - a.b( - "utils.createSymbolOrString", - a.a.Da - ); - a.b("utils.extend", a.a.extend); - a.b("utils.fieldsIncludedWithJsonPost", a.a.Jc); - a.b("utils.getFormFields", a.a.Lc); - a.b("utils.objectMap", a.a.Ga); - a.b("utils.peekObservable", a.a.bc); - a.b("utils.postJson", a.a.Od); - a.b("utils.parseJson", a.a.Nd); - a.b("utils.registerEventHandler", a.a.B); - a.b("utils.stringifyJson", a.a.hc); - a.b("utils.range", a.a.Pd); - a.b("utils.toggleDomNodeCssClass", a.a.Eb); - a.b("utils.triggerEvent", a.a.Fb); - a.b("utils.unwrapObservable", a.a.f); - a.b("utils.objectForEach", a.a.P); - a.b( - "utils.addOrRemoveItem", - a.a.Na - ); - a.b("utils.setTextContent", a.a.Bb); - a.b("unwrap", a.a.f); - Function.prototype.bind || (Function.prototype.bind = function(a2) { - var c = this; - if (1 === arguments.length) - return function() { - return c.apply(a2, arguments); - }; - var d = Array.prototype.slice.call(arguments, 1); - return function() { - var e = d.slice(0); - e.push.apply(e, arguments); - return c.apply(a2, e); - }; - }); - a.a.g = new function() { - var b = 0, c = "__ko__" + (/* @__PURE__ */ new Date()).getTime(), d = {}, e, f; - a.a.W ? (e = function(a2, e2) { - var f2 = a2[c]; - if (!f2 || "null" === f2 || !d[f2]) { - if (!e2) - return n; - f2 = a2[c] = "ko" + b++; - d[f2] = {}; - } - return d[f2]; - }, f = function(a2) { - var b2 = a2[c]; - return b2 ? (delete d[b2], a2[c] = null, true) : false; - }) : (e = function(a2, b2) { - var d2 = a2[c]; - !d2 && b2 && (d2 = a2[c] = {}); - return d2; - }, f = function(a2) { - return a2[c] ? (delete a2[c], true) : false; - }); - return { get: function(a2, b2) { - var c2 = e(a2, false); - return c2 && c2[b2]; - }, set: function(a2, b2, c2) { - (a2 = e(a2, c2 !== n)) && (a2[b2] = c2); - }, Ub: function(a2, b2, c2) { - a2 = e(a2, true); - return a2[b2] || (a2[b2] = c2); - }, clear: f, Z: function() { - return b++ + c; - } }; - }(); - a.b("utils.domData", a.a.g); - a.b("utils.domData.clear", a.a.g.clear); - a.a.K = new function() { - function b(b2, c2) { - var d2 = a.a.g.get(b2, e); - d2 === n && c2 && (d2 = [], a.a.g.set(b2, e, d2)); - return d2; - } - function c(c2) { - var e2 = b(c2, false); - if (e2) - for (var e2 = e2.slice(0), k = 0; k < e2.length; k++) - e2[k](c2); - a.a.g.clear(c2); - a.a.K.cleanExternalData(c2); - g[c2.nodeType] && d(c2.childNodes, true); - } - function d(b2, d2) { - for (var e2 = [], l, f2 = 0; f2 < b2.length; f2++) - if (!d2 || 8 === b2[f2].nodeType) { - if (c(e2[e2.length] = l = b2[f2]), b2[f2] !== l) - for (; f2-- && -1 == a.a.A(e2, b2[f2]); ) - ; - } - } - var e = a.a.g.Z(), f = { 1: true, 8: true, 9: true }, g = { 1: true, 9: true }; - return { za: function(a2, c2) { - if ("function" != typeof c2) - throw Error("Callback must be a function"); - b(a2, true).push(c2); - }, yb: function(c2, d2) { - var f2 = b(c2, false); - f2 && (a.a.Pa(f2, d2), 0 == f2.length && a.a.g.set(c2, e, n)); - }, oa: function(b2) { - a.u.G(function() { - f[b2.nodeType] && (c(b2), g[b2.nodeType] && d(b2.getElementsByTagName("*"))); - }); - return b2; - }, removeNode: function(b2) { - a.oa(b2); - b2.parentNode && b2.parentNode.removeChild(b2); - }, cleanExternalData: function(a2) { - v && "function" == typeof v.cleanData && v.cleanData([a2]); - } }; - }(); - a.oa = a.a.K.oa; - a.removeNode = a.a.K.removeNode; - a.b("cleanNode", a.oa); - a.b("removeNode", a.removeNode); - a.b("utils.domNodeDisposal", a.a.K); - a.b( - "utils.domNodeDisposal.addDisposeCallback", - a.a.K.za - ); - a.b("utils.domNodeDisposal.removeDisposeCallback", a.a.K.yb); - (function() { - var b = [0, "", ""], c = [1, "", "
"], d = [3, "", "
"], e = [1, ""], f = { thead: c, tbody: c, tfoot: c, tr: [2, "", "
"], td: d, th: d, option: e, optgroup: e }, g = 8 >= a.a.W; - a.a.ua = function(c2, d2) { - var e2; - if (v) - if (v.parseHTML) - e2 = v.parseHTML(c2, d2) || []; - else { - if ((e2 = v.clean([c2], d2)) && e2[0]) { - for (var l = e2[0]; l.parentNode && 11 !== l.parentNode.nodeType; ) - l = l.parentNode; - l.parentNode && l.parentNode.removeChild(l); - } + if (deep && copy && (jQuery2.isPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) { + src = target[name]; + if (copyIsArray && !Array.isArray(src)) { + clone = []; + } else if (!copyIsArray && !jQuery2.isPlainObject(src)) { + clone = {}; + } else { + clone = src; } - else { - (e2 = d2) || (e2 = w2); - var l = e2.parentWindow || e2.defaultView || A, p = a.a.Db(c2).toLowerCase(), q = e2.createElement("div"), t; - t = (p = p.match(/^(?:\x3c!--.*?--\x3e\s*?)*?<([a-z]+)[\s>]/)) && f[p[1]] || b; - p = t[0]; - t = "ignored
" + t[1] + c2 + t[2] + "
"; - "function" == typeof l.innerShiv ? q.appendChild(l.innerShiv(t)) : (g && e2.body.appendChild(q), q.innerHTML = t, g && q.parentNode.removeChild(q)); - for (; p--; ) - q = q.lastChild; - e2 = a.a.la(q.lastChild.childNodes); - } - return e2; - }; - a.a.Md = function(b2, c2) { - var d2 = a.a.ua( - b2, - c2 - ); - return d2.length && d2[0].parentElement || a.a.Yb(d2); - }; - a.a.fc = function(b2, c2) { - a.a.Tb(b2); - c2 = a.a.f(c2); - if (null !== c2 && c2 !== n) - if ("string" != typeof c2 && (c2 = c2.toString()), v) - v(b2).html(c2); - else - for (var d2 = a.a.ua(c2, b2.ownerDocument), e2 = 0; e2 < d2.length; e2++) - b2.appendChild(d2[e2]); - }; - })(); - a.b("utils.parseHtmlFragment", a.a.ua); - a.b("utils.setHtml", a.a.fc); - a.aa = function() { - function b(c2, e) { - if (c2) { - if (8 == c2.nodeType) { - var f = a.aa.Uc(c2.nodeValue); - null != f && e.push({ ud: c2, Kd: f }); - } else if (1 == c2.nodeType) - for (var f = 0, g = c2.childNodes, h = g.length; f < h; f++) - b( - g[f], - e - ); - } - } - var c = {}; - return { Xb: function(a2) { - if ("function" != typeof a2) - throw Error("You can only pass a function to ko.memoization.memoize()"); - var b2 = (4294967296 * (1 + Math.random()) | 0).toString(16).substring(1) + (4294967296 * (1 + Math.random()) | 0).toString(16).substring(1); - c[b2] = a2; - return ""; - }, bd: function(a2, b2) { - var f = c[a2]; - if (f === n) - throw Error("Couldn't find any memo with ID " + a2 + ". Perhaps it's already been unmemoized."); - try { - return f.apply(null, b2 || []), true; - } finally { - delete c[a2]; - } - }, cd: function(c2, e) { - var f = []; - b(c2, f); - for (var g = 0, h = f.length; g < h; g++) { - var m = f[g].ud, k = [m]; - e && a.a.Nb(k, e); - a.aa.bd(f[g].Kd, k); - m.nodeValue = ""; - m.parentNode && m.parentNode.removeChild(m); - } - }, Uc: function(a2) { - return (a2 = a2.match(/^\[ko_memo\:(.*?)\]$/)) ? a2[1] : null; - } }; - }(); - a.b("memoization", a.aa); - a.b("memoization.memoize", a.aa.Xb); - a.b("memoization.unmemoize", a.aa.bd); - a.b("memoization.parseMemoText", a.aa.Uc); - a.b("memoization.unmemoizeDomNodeAndDescendants", a.aa.cd); - a.na = function() { - function b() { - if (f) { - for (var b2 = f, c2 = 0, d2; h < f; ) - if (d2 = e[h++]) { - if (h > b2) { - if (5e3 <= ++c2) { - h = f; - a.a.Gc(Error("'Too much recursion' after processing " + c2 + " task groups.")); - break; - } - b2 = f; - } - try { - d2(); - } catch (p) { - a.a.Gc(p); - } - } + copyIsArray = false; + target[name] = jQuery2.extend(deep, clone, copy); + } else if (copy !== void 0) { + target[name] = copy; } } - function c() { - b(); - h = f = e.length = 0; - } - var d, e = [], f = 0, g = 1, h = 0; - A.MutationObserver ? d = function(a2) { - var b2 = w2.createElement("div"); - new MutationObserver(a2).observe(b2, { attributes: true }); - return function() { - b2.classList.toggle("foo"); - }; - }(c) : d = w2 && "onreadystatechange" in w2.createElement("script") ? function(a2) { - var b2 = w2.createElement("script"); - b2.onreadystatechange = function() { - b2.onreadystatechange = null; - w2.documentElement.removeChild(b2); - b2 = null; - a2(); - }; - w2.documentElement.appendChild(b2); - } : function(a2) { - setTimeout(a2, 0); - }; - return { scheduler: d, zb: function(b2) { - f || a.na.scheduler(c); - e[f++] = b2; - return g++; - }, cancel: function(a2) { - a2 = a2 - (g - f); - a2 >= h && a2 < f && (e[a2] = null); - }, resetForTesting: function() { - var a2 = f - h; - h = f = e.length = 0; - return a2; - }, Sd: b }; - }(); - a.b("tasks", a.na); - a.b("tasks.schedule", a.na.zb); - a.b("tasks.runEarly", a.na.Sd); - a.Ta = { throttle: function(b, c) { - b.throttleEvaluation = c; - var d = null; - return a.$({ read: b, write: function(e) { - clearTimeout(d); - d = a.a.setTimeout( - function() { - b(e); - }, - c - ); - } }); - }, rateLimit: function(a2, c) { - var d, e, f; - "number" == typeof c ? d = c : (d = c.timeout, e = c.method); - a2.Hb = false; - f = "function" == typeof e ? e : "notifyWhenChangesStop" == e ? Y : X; - a2.ub(function(a3) { - return f(a3, d, c); - }); - }, deferred: function(b, c) { - if (true !== c) - throw Error("The 'deferred' extender only accepts the value 'true', because it is not supported to turn deferral off once enabled."); - b.Hb || (b.Hb = true, b.ub(function(c2) { - var e, f = false; - return function() { - if (!f) { - a.na.cancel(e); - e = a.na.zb(c2); - try { - f = true, b.notifySubscribers(n, "dirty"); - } finally { - f = false; - } - } - }; - })); - }, notify: function(a2, c) { - a2.equalityComparer = "always" == c ? null : K; - } }; - var W = { undefined: 1, "boolean": 1, number: 1, string: 1 }; - a.b("extenders", a.Ta); - a.ic = function(b, c, d) { - this.da = b; - this.lc = c; - this.mc = d; - this.Ib = false; - this.fb = this.Jb = null; - a.L(this, "dispose", this.s); - a.L(this, "disposeWhenNodeIsRemoved", this.l); - }; - a.ic.prototype.s = function() { - this.Ib || (this.fb && a.a.K.yb(this.Jb, this.fb), this.Ib = true, this.mc(), this.da = this.lc = this.mc = this.Jb = this.fb = null); - }; - a.ic.prototype.l = function(b) { - this.Jb = b; - a.a.K.za(b, this.fb = this.s.bind(this)); - }; - a.T = function() { - a.a.Ab(this, D); - D.qb(this); - }; - var D = { - qb: function(a2) { - a2.U = { change: [] }; - a2.sc = 1; - }, - subscribe: function(b, c, d) { - var e = this; - d = d || "change"; - var f = new a.ic(e, c ? b.bind(c) : b, function() { - a.a.Pa(e.U[d], f); - e.hb && e.hb(d); - }); - e.Qa && e.Qa(d); - e.U[d] || (e.U[d] = []); - e.U[d].push(f); - return f; - }, - notifySubscribers: function(b, c) { - c = c || "change"; - "change" === c && this.Gb(); - if (this.Wa(c)) { - var d = "change" === c && this.ed || this.U[c].slice(0); - try { - a.u.xc(); - for (var e = 0, f; f = d[e]; ++e) - f.Ib || f.lc(b); - } finally { - a.u.end(); - } + } + } + return target; + }; + jQuery2.extend({ + // Unique for each copy of jQuery on the page + expando: "jQuery" + (version + Math.random()).replace(/\D/g, ""), + // Assume jQuery is ready without the ready module + isReady: true, + error: function(msg) { + throw new Error(msg); + }, + noop: function() { + }, + isPlainObject: function(obj) { + var proto, Ctor; + if (!obj || toString.call(obj) !== "[object Object]") { + return false; + } + proto = getProto(obj); + if (!proto) { + return true; + } + Ctor = hasOwn.call(proto, "constructor") && proto.constructor; + return typeof Ctor === "function" && fnToString.call(Ctor) === ObjectFunctionString; + }, + isEmptyObject: function(obj) { + var name; + for (name in obj) { + return false; + } + return true; + }, + // Evaluates a script in a provided context; falls back to the global one + // if not specified. + globalEval: function(code, options, doc) { + DOMEval(code, { nonce: options && options.nonce }, doc); + }, + each: function(obj, callback) { + var length, i = 0; + if (isArrayLike2(obj)) { + length = obj.length; + for (; i < length; i++) { + if (callback.call(obj[i], i, obj[i]) === false) { + break; } - }, - ob: function() { - return this.sc; - }, - Dd: function(a2) { - return this.ob() !== a2; - }, - Gb: function() { - ++this.sc; - }, - ub: function(b) { - var c = this, d = a.O(c), e, f, g, h, m; - c.gb || (c.gb = c.notifySubscribers, c.notifySubscribers = Z); - var k = b(function() { - c.Ja = false; - d && h === c && (h = c.nc ? c.nc() : c()); - var a2 = f || m && c.sb(g, h); - m = f = e = false; - a2 && c.gb(g = h); - }); - c.qc = function(a2, b2) { - b2 && c.Ja || (m = !b2); - c.ed = c.U.change.slice(0); - c.Ja = e = true; - h = a2; - k(); - }; - c.pc = function(a2) { - e || (g = a2, c.gb(a2, "beforeChange")); - }; - c.rc = function() { - m = true; - }; - c.gd = function() { - c.sb(g, c.v(true)) && (f = true); - }; - }, - Wa: function(a2) { - return this.U[a2] && this.U[a2].length; - }, - Bd: function(b) { - if (b) - return this.U[b] && this.U[b].length || 0; - var c = 0; - a.a.P(this.U, function(a2, b2) { - "dirty" !== a2 && (c += b2.length); - }); - return c; - }, - sb: function(a2, c) { - return !this.equalityComparer || !this.equalityComparer(a2, c); - }, - toString: function() { - return "[object Object]"; - }, - extend: function(b) { - var c = this; - b && a.a.P(b, function(b2, e) { - var f = a.Ta[b2]; - "function" == typeof f && (c = f(c, e) || c); - }); - return c; } - }; - a.L(D, "init", D.qb); - a.L(D, "subscribe", D.subscribe); - a.L(D, "extend", D.extend); - a.L(D, "getSubscriptionsCount", D.Bd); - a.a.Ba && a.a.setPrototypeOf( - D, - Function.prototype - ); - a.T.fn = D; - a.Qc = function(a2) { - return null != a2 && "function" == typeof a2.subscribe && "function" == typeof a2.notifySubscribers; - }; - a.b("subscribable", a.T); - a.b("isSubscribable", a.Qc); - a.S = a.u = function() { - function b(a2) { - d.push(e); - e = a2; - } - function c() { - e = d.pop(); - } - var d = [], e, f = 0; - return { - xc: b, - end: c, - cc: function(b2) { - if (e) { - if (!a.Qc(b2)) - throw Error("Only subscribable things can act as dependencies"); - e.od.call(e.pd, b2, b2.fd || (b2.fd = ++f)); - } - }, - G: function(a2, d2, e2) { - try { - return b(), a2.apply(d2, e2 || []); - } finally { - c(); - } - }, - qa: function() { - if (e) - return e.o.qa(); - }, - Va: function() { - if (e) - return e.o.Va(); - }, - Ya: function() { - if (e) - return e.Ya; - }, - o: function() { - if (e) - return e.o; - } - }; - }(); - a.b("computedContext", a.S); - a.b("computedContext.getDependenciesCount", a.S.qa); - a.b("computedContext.getDependencies", a.S.Va); - a.b("computedContext.isInitial", a.S.Ya); - a.b("computedContext.registerDependency", a.S.cc); - a.b("ignoreDependencies", a.Yd = a.u.G); - var I = a.a.Da("_latestValue"); - a.ta = function(b) { - function c() { - if (0 < arguments.length) - return c.sb(c[I], arguments[0]) && (c.ya(), c[I] = arguments[0], c.xa()), this; - a.u.cc(c); - return c[I]; - } - c[I] = b; - a.a.Ba || a.a.extend(c, a.T.fn); - a.T.fn.qb(c); - a.a.Ab(c, F); - a.options.deferUpdates && a.Ta.deferred(c, true); - return c; - }; - var F = { equalityComparer: K, v: function() { - return this[I]; - }, xa: function() { - this.notifySubscribers(this[I], "spectate"); - this.notifySubscribers(this[I]); - }, ya: function() { - this.notifySubscribers(this[I], "beforeChange"); - } }; - a.a.Ba && a.a.setPrototypeOf(F, a.T.fn); - var G = a.ta.Ma = "__ko_proto__"; - F[G] = a.ta; - a.O = function(b) { - if ((b = "function" == typeof b && b[G]) && b !== F[G] && b !== a.o.fn[G]) - throw Error("Invalid object that looks like an observable; possibly from another Knockout instance"); - return !!b; - }; - a.Za = function(b) { - return "function" == typeof b && (b[G] === F[G] || b[G] === a.o.fn[G] && b.Nc); - }; - a.b("observable", a.ta); - a.b("isObservable", a.O); - a.b("isWriteableObservable", a.Za); - a.b("isWritableObservable", a.Za); - a.b("observable.fn", F); - a.L(F, "peek", F.v); - a.L(F, "valueHasMutated", F.xa); - a.L(F, "valueWillMutate", F.ya); - a.Ha = function(b) { - b = b || []; - if ("object" != typeof b || !("length" in b)) - throw Error("The argument passed when initializing an observable array must be an array, or null, or undefined."); - b = a.ta(b); - a.a.Ab( - b, - a.Ha.fn - ); - return b.extend({ trackArrayChanges: true }); - }; - a.Ha.fn = { remove: function(b) { - for (var c = this.v(), d = [], e = "function" != typeof b || a.O(b) ? function(a2) { - return a2 === b; - } : b, f = 0; f < c.length; f++) { - var g = c[f]; - if (e(g)) { - 0 === d.length && this.ya(); - if (c[f] !== g) - throw Error("Array modified during remove; cannot remove item"); - d.push(g); - c.splice(f, 1); - f--; - } - } - d.length && this.xa(); - return d; - }, removeAll: function(b) { - if (b === n) { - var c = this.v(), d = c.slice(0); - this.ya(); - c.splice(0, c.length); - this.xa(); - return d; - } - return b ? this.remove(function(c2) { - return 0 <= a.a.A(b, c2); - }) : []; - }, destroy: function(b) { - var c = this.v(), d = "function" != typeof b || a.O(b) ? function(a2) { - return a2 === b; - } : b; - this.ya(); - for (var e = c.length - 1; 0 <= e; e--) { - var f = c[e]; - d(f) && (f._destroy = true); - } - this.xa(); - }, destroyAll: function(b) { - return b === n ? this.destroy(function() { - return true; - }) : b ? this.destroy(function(c) { - return 0 <= a.a.A(b, c); - }) : []; - }, indexOf: function(b) { - var c = this(); - return a.a.A(c, b); - }, replace: function(a2, c) { - var d = this.indexOf(a2); - 0 <= d && (this.ya(), this.v()[d] = c, this.xa()); - }, sorted: function(a2) { - var c = this().slice(0); - return a2 ? c.sort(a2) : c.sort(); - }, reversed: function() { - return this().slice(0).reverse(); - } }; - a.a.Ba && a.a.setPrototypeOf(a.Ha.fn, a.ta.fn); - a.a.D("pop push reverse shift sort splice unshift".split(" "), function(b) { - a.Ha.fn[b] = function() { - var a2 = this.v(); - this.ya(); - this.zc(a2, b, arguments); - var d = a2[b].apply(a2, arguments); - this.xa(); - return d === a2 ? this : d; - }; - }); - a.a.D(["slice"], function(b) { - a.Ha.fn[b] = function() { - var a2 = this(); - return a2[b].apply(a2, arguments); - }; - }); - a.Pc = function(b) { - return a.O(b) && "function" == typeof b.remove && "function" == typeof b.push; - }; - a.b("observableArray", a.Ha); - a.b("isObservableArray", a.Pc); - a.Ta.trackArrayChanges = function(b, c) { - function d() { - function c2() { - if (m) { - var d2 = [].concat(b.v() || []), e2; - if (b.Wa("arrayChange")) { - if (!f || 1 < m) - f = a.a.Pb(k, d2, b.Ob); - e2 = f; - } - k = d2; - f = null; - m = 0; - e2 && e2.length && b.notifySubscribers(e2, "arrayChange"); - } + } else { + for (i in obj) { + if (callback.call(obj[i], i, obj[i]) === false) { + break; } - e ? c2() : (e = true, h = b.subscribe(function() { - ++m; - }, null, "spectate"), k = [].concat(b.v() || []), f = null, g = b.subscribe(c2)); - } - b.Ob = {}; - c && "object" == typeof c && a.a.extend(b.Ob, c); - b.Ob.sparse = true; - if (!b.zc) { - var e = false, f = null, g, h, m = 0, k, l = b.Qa, p = b.hb; - b.Qa = function(a2) { - l && l.call(b, a2); - "arrayChange" === a2 && d(); - }; - b.hb = function(a2) { - p && p.call(b, a2); - "arrayChange" !== a2 || b.Wa("arrayChange") || (g && g.s(), h && h.s(), h = g = null, e = false, k = n); - }; - b.zc = function(b2, c2, d2) { - function l2(a2, b3, c3) { - return k2[k2.length] = { status: a2, value: b3, index: c3 }; - } - if (e && !m) { - var k2 = [], p2 = b2.length, g2 = d2.length, h2 = 0; - switch (c2) { - case "push": - h2 = p2; - case "unshift": - for (c2 = 0; c2 < g2; c2++) - l2("added", d2[c2], h2 + c2); - break; - case "pop": - h2 = p2 - 1; - case "shift": - p2 && l2("deleted", b2[h2], h2); - break; - case "splice": - c2 = Math.min(Math.max(0, 0 > d2[0] ? p2 + d2[0] : d2[0]), p2); - for (var p2 = 1 === g2 ? p2 : Math.min(c2 + (d2[1] || 0), p2), g2 = c2 + g2 - 2, h2 = Math.max(p2, g2), U = [], L = [], n2 = 2; c2 < h2; ++c2, ++n2) - c2 < p2 && L.push(l2("deleted", b2[c2], c2)), c2 < g2 && U.push(l2("added", d2[n2], c2)); - a.a.Kc(L, U); - break; - default: - return; - } - f = k2; - } - }; } - }; - var r = a.a.Da("_state"); - a.o = a.$ = function(b, c, d) { - function e() { - if (0 < arguments.length) { - if ("function" === typeof f) - f.apply(g.nb, arguments); - else - 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."); - return this; - } - g.ra || a.u.cc(e); - (g.ka || g.J && e.Xa()) && e.ha(); - return g.X; - } - "object" === typeof b ? d = b : (d = d || {}, b && (d.read = b)); - if ("function" != typeof d.read) - throw Error("Pass a function that returns the value of the ko.computed"); - var f = d.write, g = { X: n, sa: true, ka: true, rb: false, jc: false, ra: false, wb: false, J: false, Wc: d.read, nb: c || d.owner, l: d.disposeWhenNodeIsRemoved || d.l || null, Sa: d.disposeWhen || d.Sa, Rb: null, I: {}, V: 0, Ic: null }; - e[r] = g; - e.Nc = "function" === typeof f; - a.a.Ba || a.a.extend(e, a.T.fn); - a.T.fn.qb(e); - a.a.Ab(e, C); - d.pure ? (g.wb = true, g.J = true, a.a.extend(e, da)) : d.deferEvaluation && a.a.extend(e, ea); - a.options.deferUpdates && a.Ta.deferred(e, true); - g.l && (g.jc = true, g.l.nodeType || (g.l = null)); - g.J || d.deferEvaluation || e.ha(); - g.l && e.ja() && a.a.K.za(g.l, g.Rb = function() { - e.s(); - }); - return e; - }; - var C = { - equalityComparer: K, - qa: function() { - return this[r].V; - }, - Va: function() { - var b = []; - a.a.P(this[r].I, function(a2, d) { - b[d.Ka] = d.da; - }); - return b; - }, - Vb: function(b) { - if (!this[r].V) - return false; - var c = this.Va(); - return -1 !== a.a.A(c, b) ? true : !!a.a.Lb(c, function(a2) { - return a2.Vb && a2.Vb(b); - }); - }, - uc: function(a2, c, d) { - if (this[r].wb && c === this) - throw Error("A 'pure' computed must not be called recursively"); - this[r].I[a2] = d; - d.Ka = this[r].V++; - d.La = c.ob(); - }, - Xa: function() { - var a2, c, d = this[r].I; - for (a2 in d) - if (Object.prototype.hasOwnProperty.call(d, a2) && (c = d[a2], this.Ia && c.da.Ja || c.da.Dd(c.La))) - return true; - }, - Jd: function() { - this.Ia && !this[r].rb && this.Ia(false); - }, - ja: function() { - var a2 = this[r]; - return a2.ka || 0 < a2.V; - }, - Rd: function() { - this.Ja ? this[r].ka && (this[r].sa = true) : this.Hc(); - }, - $c: function(a2) { - if (a2.Hb) { - var c = a2.subscribe(this.Jd, this, "dirty"), d = a2.subscribe( - this.Rd, - this - ); - return { da: a2, s: function() { - c.s(); - d.s(); - } }; - } - return a2.subscribe(this.Hc, this); - }, - Hc: function() { - var b = this, c = b.throttleEvaluation; - c && 0 <= c ? (clearTimeout(this[r].Ic), this[r].Ic = a.a.setTimeout(function() { - b.ha(true); - }, c)) : b.Ia ? b.Ia(true) : b.ha(true); - }, - ha: function(b) { - var c = this[r], d = c.Sa, e = false; - if (!c.rb && !c.ra) { - if (c.l && !a.a.Sb(c.l) || d && d()) { - if (!c.jc) { - this.s(); - return; - } - } else - c.jc = false; - c.rb = true; - try { - e = this.zd(b); - } finally { - c.rb = false; - } - return e; - } - }, - zd: function(b) { - var c = this[r], d = false, e = c.wb ? n : !c.V, d = { qd: this, mb: c.I, Qb: c.V }; - a.u.xc({ - pd: d, - od: ba, - o: this, - Ya: e - }); - c.I = {}; - c.V = 0; - var f = this.yd(c, d); - c.V ? d = this.sb(c.X, f) : (this.s(), d = true); - d && (c.J ? this.Gb() : this.notifySubscribers(c.X, "beforeChange"), c.X = f, this.notifySubscribers(c.X, "spectate"), !c.J && b && this.notifySubscribers(c.X), this.rc && this.rc()); - e && this.notifySubscribers(c.X, "awake"); - return d; - }, - yd: function(b, c) { - try { - var d = b.Wc; - return b.nb ? d.call(b.nb) : d(); - } finally { - a.u.end(), c.Qb && !b.J && a.a.P(c.mb, aa), b.sa = b.ka = false; - } - }, - v: function(a2) { - var c = this[r]; - (c.ka && (a2 || !c.V) || c.J && this.Xa()) && this.ha(); - return c.X; - }, - ub: function(b) { - a.T.fn.ub.call(this, b); - this.nc = function() { - this[r].J || (this[r].sa ? this.ha() : this[r].ka = false); - return this[r].X; - }; - this.Ia = function(a2) { - this.pc(this[r].X); - this[r].ka = true; - a2 && (this[r].sa = true); - this.qc(this, !a2); - }; - }, - s: function() { - var b = this[r]; - !b.J && b.I && a.a.P(b.I, function(a2, b2) { - b2.s && b2.s(); - }); - b.l && b.Rb && a.a.K.yb(b.l, b.Rb); - b.I = n; - b.V = 0; - b.ra = true; - b.sa = false; - b.ka = false; - b.J = false; - b.l = n; - b.Sa = n; - b.Wc = n; - this.Nc || (b.nb = n); - } - }, da = { Qa: function(b) { - var c = this, d = c[r]; - if (!d.ra && d.J && "change" == b) { - d.J = false; - if (d.sa || c.Xa()) - d.I = null, d.V = 0, c.ha() && c.Gb(); - else { - var e = []; - a.a.P(d.I, function(a2, b2) { - e[b2.Ka] = a2; - }); - a.a.D(e, function(a2, b2) { - var e2 = d.I[a2], m = c.$c(e2.da); - m.Ka = b2; - m.La = e2.La; - d.I[a2] = m; - }); - c.Xa() && c.ha() && c.Gb(); - } - d.ra || c.notifySubscribers(d.X, "awake"); - } - }, hb: function(b) { - var c = this[r]; - c.ra || "change" != b || this.Wa("change") || (a.a.P(c.I, function(a2, b2) { - b2.s && (c.I[a2] = { da: b2.da, Ka: b2.Ka, La: b2.La }, b2.s()); - }), c.J = true, this.notifySubscribers(n, "asleep")); - }, ob: function() { - var b = this[r]; - b.J && (b.sa || this.Xa()) && this.ha(); - return a.T.fn.ob.call(this); - } }, ea = { Qa: function(a2) { - "change" != a2 && "beforeChange" != a2 || this.v(); - } }; - a.a.Ba && a.a.setPrototypeOf(C, a.T.fn); - var N = a.ta.Ma; - C[N] = a.o; - a.Oc = function(a2) { - return "function" == typeof a2 && a2[N] === C[N]; - }; - a.Fd = function(b) { - return a.Oc(b) && b[r] && b[r].wb; - }; - a.b("computed", a.o); - a.b("dependentObservable", a.o); - a.b("isComputed", a.Oc); - a.b("isPureComputed", a.Fd); - a.b("computed.fn", C); - a.L(C, "peek", C.v); - a.L(C, "dispose", C.s); - a.L(C, "isActive", C.ja); - a.L(C, "getDependenciesCount", C.qa); - a.L(C, "getDependencies", C.Va); - a.xb = function(b, c) { - if ("function" === typeof b) - return a.o( - b, - c, - { pure: true } - ); - b = a.a.extend({}, b); - b.pure = true; - return a.o(b, c); - }; - a.b("pureComputed", a.xb); - (function() { - function b(a2, f, g) { - g = g || new d(); - a2 = f(a2); - if ("object" != typeof a2 || null === a2 || a2 === n || a2 instanceof RegExp || a2 instanceof Date || a2 instanceof String || a2 instanceof Number || a2 instanceof Boolean) - return a2; - var h = a2 instanceof Array ? [] : {}; - g.save(a2, h); - c(a2, function(c2) { - var d2 = f(a2[c2]); - switch (typeof d2) { - case "boolean": - case "number": - case "string": - case "function": - h[c2] = d2; - break; - case "object": - case "undefined": - var l = g.get(d2); - h[c2] = l !== n ? l : b(d2, f, g); - } - }); - return h; - } - function c(a2, b2) { - if (a2 instanceof Array) { - for (var c2 = 0; c2 < a2.length; c2++) - b2(c2); - "function" == typeof a2.toJSON && b2("toJSON"); - } else - for (c2 in a2) - b2(c2); - } - function d() { - this.keys = []; - this.values = []; - } - a.ad = function(c2) { - if (0 == arguments.length) - throw Error("When calling ko.toJS, pass the object you want to convert."); - return b(c2, function(b2) { - for (var c3 = 0; a.O(b2) && 10 > c3; c3++) - b2 = b2(); - return b2; - }); - }; - a.toJSON = function(b2, c2, d2) { - b2 = a.ad(b2); - return a.a.hc(b2, c2, d2); - }; - d.prototype = { constructor: d, save: function(b2, c2) { - var d2 = a.a.A( - this.keys, - b2 + } + return obj; + }, + // results is for internal usage only + makeArray: function(arr2, results) { + var ret = results || []; + if (arr2 != null) { + if (isArrayLike2(Object(arr2))) { + jQuery2.merge( + ret, + typeof arr2 === "string" ? [arr2] : arr2 ); - 0 <= d2 ? this.values[d2] = c2 : (this.keys.push(b2), this.values.push(c2)); - }, get: function(b2) { - b2 = a.a.A(this.keys, b2); - return 0 <= b2 ? this.values[b2] : n; - } }; - })(); - a.b("toJS", a.ad); - a.b("toJSON", a.toJSON); - a.Wd = function(b, c, d) { - function e(c2) { - var e2 = a.xb(b, d).extend({ ma: "always" }), h = e2.subscribe(function(a2) { - a2 && (h.s(), c2(a2)); - }); - e2.notifySubscribers(e2.v()); - return h; + } else { + push.call(ret, arr2); } - return "function" !== typeof Promise || c ? e(c.bind(d)) : new Promise(e); - }; - a.b("when", a.Wd); - (function() { - a.w = { M: function(b) { - switch (a.a.R(b)) { - case "option": - return true === b.__ko__hasDomDataOptionValue__ ? a.a.g.get(b, a.c.options.$b) : 7 >= a.a.W ? b.getAttributeNode("value") && b.getAttributeNode("value").specified ? b.value : b.text : b.value; - case "select": - return 0 <= b.selectedIndex ? a.w.M(b.options[b.selectedIndex]) : n; - default: - return b.value; - } - }, cb: function(b, c, d) { - switch (a.a.R(b)) { - case "option": - "string" === typeof c ? (a.a.g.set(b, a.c.options.$b, n), "__ko__hasDomDataOptionValue__" in b && delete b.__ko__hasDomDataOptionValue__, b.value = c) : (a.a.g.set(b, a.c.options.$b, c), b.__ko__hasDomDataOptionValue__ = true, b.value = "number" === typeof c ? c : ""); - break; - case "select": - if ("" === c || null === c) - c = n; - for (var e = -1, f = 0, g = b.options.length, h; f < g; ++f) - if (h = a.w.M(b.options[f]), h == c || "" === h && c === n) { - e = f; - break; - } - if (d || 0 <= e || c === n && 1 < b.size) - b.selectedIndex = e, 6 === a.a.W && a.a.setTimeout(function() { - b.selectedIndex = e; - }, 0); - break; - default: - if (null === c || c === n) - c = ""; - b.value = c; - } - } }; - })(); - a.b("selectExtensions", a.w); - a.b("selectExtensions.readValue", a.w.M); - a.b("selectExtensions.writeValue", a.w.cb); - a.m = function() { - function b(b2) { - b2 = a.a.Db(b2); - 123 === b2.charCodeAt(0) && (b2 = b2.slice( - 1, - -1 - )); - b2 += "\n,"; - var c2 = [], d2 = b2.match(e), p, q = [], h2 = 0; - if (1 < d2.length) { - for (var x = 0, B; B = d2[x]; ++x) { - var u = B.charCodeAt(0); - if (44 === u) { - if (0 >= h2) { - c2.push(p && q.length ? { key: p, value: q.join("") } : { unknown: p || q.join("") }); - p = h2 = 0; - q = []; - continue; - } - } else if (58 === u) { - if (!h2 && !p && 1 === q.length) { - p = q.pop(); - continue; - } - } else if (47 === u && 1 < B.length && (47 === B.charCodeAt(1) || 42 === B.charCodeAt(1))) - continue; - else - 47 === u && x && 1 < B.length ? (u = d2[x - 1].match(f)) && !g[u[0]] && (b2 = b2.substr(b2.indexOf(B) + 1), d2 = b2.match(e), x = -1, B = "/") : 40 === u || 123 === u || 91 === u ? ++h2 : 41 === u || 125 === u || 93 === u ? --h2 : p || q.length || 34 !== u && 39 !== u || (B = B.slice(1, -1)); - q.push(B); - } - if (0 < h2) - throw Error("Unbalanced parentheses, braces, or brackets"); - } - return c2; - } - var c = ["true", "false", "null", "undefined"], d = /^(?:[$_a-z][$\w]*|(.+)(\.\s*[$_a-z][$\w]*|\[.+\]))$/i, e = RegExp("\"(?:\\\\.|[^\"])*\"|'(?:\\\\.|[^'])*'|`(?:\\\\.|[^`])*`|/\\*(?:[^*]|\\*+[^*/])*\\*+/|//.*\n|/(?:\\\\.|[^/])+/w*|[^\\s:,/][^,\"'`{}()/:[\\]]*[^\\s,\"'`{}()/:[\\]]|[^\\s]", "g"), f = /[\])"'A-Za-z0-9_$]+$/, g = { "in": 1, "return": 1, "typeof": 1 }, h = {}; - return { Ra: [], wa: h, ac: b, vb: function(e2, f2) { - function l(b2, e3) { - var f3; - if (!x) { - var k = a.getBindingHandler(b2); - if (k && k.preprocess && !(e3 = k.preprocess(e3, b2, l))) - return; - if (k = h[b2]) - f3 = e3, 0 <= a.a.A(c, f3) ? f3 = false : (k = f3.match(d), f3 = null === k ? false : k[1] ? "Object(" + k[1] + ")" + k[2] : f3), k = f3; - k && q.push("'" + ("string" == typeof h[b2] ? h[b2] : b2) + "':function(_z){" + f3 + "=_z}"); - } - g2 && (e3 = "function(){return " + e3 + " }"); - p.push("'" + b2 + "':" + e3); - } - f2 = f2 || {}; - var p = [], q = [], g2 = f2.valueAccessors, x = f2.bindingParams, B = "string" === typeof e2 ? b(e2) : e2; - a.a.D(B, function(a2) { - l( - a2.key || a2.unknown, - a2.value - ); - }); - q.length && l("_ko_property_writers", "{" + q.join(",") + " }"); - return p.join(","); - }, Id: function(a2, b2) { - for (var c2 = 0; c2 < a2.length; c2++) - if (a2[c2].key == b2) - return true; - return false; - }, eb: function(b2, c2, d2, e2, f2) { - if (b2 && a.O(b2)) - !a.Za(b2) || f2 && b2.v() === e2 || b2(e2); - else if ((b2 = c2.get("_ko_property_writers")) && b2[d2]) - b2[d2](e2); - } }; - }(); - a.b("expressionRewriting", a.m); - a.b("expressionRewriting.bindingRewriteValidators", a.m.Ra); - a.b("expressionRewriting.parseObjectLiteral", a.m.ac); - a.b("expressionRewriting.preProcessBindings", a.m.vb); - a.b( - "expressionRewriting._twoWayBindings", - a.m.wa - ); - a.b("jsonExpressionRewriting", a.m); - a.b("jsonExpressionRewriting.insertPropertyAccessorsIntoJson", a.m.vb); - (function() { - function b(a2) { - return 8 == a2.nodeType && g.test(f ? a2.text : a2.nodeValue); - } - function c(a2) { - return 8 == a2.nodeType && h.test(f ? a2.text : a2.nodeValue); - } - function d(d2, e2) { - for (var f2 = d2, h2 = 1, g2 = []; f2 = f2.nextSibling; ) { - if (c(f2) && (a.a.g.set(f2, k, true), h2--, 0 === h2)) - return g2; - g2.push(f2); - b(f2) && h2++; - } - if (!e2) - throw Error("Cannot find closing comment tag to match: " + d2.nodeValue); - return null; + } + return ret; + }, + inArray: function(elem, arr2, i) { + return arr2 == null ? -1 : indexOf.call(arr2, elem, i); + }, + // Support: Android <=4.0 only, PhantomJS 1 only + // push.apply(_, arraylike) throws on ancient WebKit + merge: function(first, second) { + var len = +second.length, j = 0, i = first.length; + for (; j < len; j++) { + first[i++] = second[j]; + } + first.length = i; + return first; + }, + grep: function(elems, callback, invert) { + var callbackInverse, matches = [], i = 0, length = elems.length, callbackExpect = !invert; + for (; i < length; i++) { + callbackInverse = !callback(elems[i], i); + if (callbackInverse !== callbackExpect) { + matches.push(elems[i]); } - function e(a2, b2) { - var c2 = d(a2, b2); - return c2 ? 0 < c2.length ? c2[c2.length - 1].nextSibling : a2.nextSibling : null; - } - var f = w2 && "" === w2.createComment("test").text, g = f ? /^\x3c!--\s*ko(?:\s+([\s\S]+))?\s*--\x3e$/ : /^\s*ko(?:\s+([\s\S]+))?\s*$/, h = f ? /^\x3c!--\s*\/ko\s*--\x3e$/ : /^\s*\/ko\s*$/, m = { ul: true, ol: true }, k = "__ko_matchedEndComment__"; - a.h = { ea: {}, childNodes: function(a2) { - return b(a2) ? d(a2) : a2.childNodes; - }, Ea: function(c2) { - if (b(c2)) { - c2 = a.h.childNodes(c2); - for (var d2 = 0, e2 = c2.length; d2 < e2; d2++) - a.removeNode(c2[d2]); - } else - a.a.Tb(c2); - }, va: function(c2, d2) { - if (b(c2)) { - a.h.Ea(c2); - for (var e2 = c2.nextSibling, f2 = 0, k2 = d2.length; f2 < k2; f2++) - e2.parentNode.insertBefore(d2[f2], e2); - } else - a.a.va(c2, d2); - }, Vc: function(a2, c2) { - var d2; - b(a2) ? (d2 = a2.nextSibling, a2 = a2.parentNode) : d2 = a2.firstChild; - d2 ? c2 !== d2 && a2.insertBefore(c2, d2) : a2.appendChild(c2); - }, Wb: function(c2, d2, e2) { - e2 ? (e2 = e2.nextSibling, b(c2) && (c2 = c2.parentNode), e2 ? d2 !== e2 && c2.insertBefore(d2, e2) : c2.appendChild(d2)) : a.h.Vc(c2, d2); - }, firstChild: function(a2) { - if (b(a2)) - return !a2.nextSibling || c(a2.nextSibling) ? null : a2.nextSibling; - if (a2.firstChild && c(a2.firstChild)) - throw Error("Found invalid end comment, as the first child of " + a2); - return a2.firstChild; - }, nextSibling: function(d2) { - b(d2) && (d2 = e(d2)); - if (d2.nextSibling && c(d2.nextSibling)) { - var f2 = d2.nextSibling; - if (c(f2) && !a.a.g.get(f2, k)) - throw Error("Found end comment without a matching opening comment, as child of " + d2); - return null; - } - return d2.nextSibling; - }, Cd: b, Vd: function(a2) { - return (a2 = (f ? a2.text : a2.nodeValue).match(g)) ? a2[1] : null; - }, Sc: function(d2) { - if (m[a.a.R(d2)]) { - var f2 = d2.firstChild; - if (f2) { - do - if (1 === f2.nodeType) { - var k2; - k2 = f2.firstChild; - var h2 = null; - if (k2) { - do - if (h2) - h2.push(k2); - else if (b(k2)) { - var g2 = e(k2, true); - g2 ? k2 = g2 : h2 = [k2]; - } else - c(k2) && (h2 = [k2]); - while (k2 = k2.nextSibling); - } - if (k2 = h2) - for (h2 = f2.nextSibling, g2 = 0; g2 < k2.length; g2++) - h2 ? d2.insertBefore(k2[g2], h2) : d2.appendChild(k2[g2]); - } - while (f2 = f2.nextSibling); - } - } - } }; - })(); - a.b("virtualElements", a.h); - a.b("virtualElements.allowedBindings", a.h.ea); - a.b("virtualElements.emptyNode", a.h.Ea); - a.b("virtualElements.insertAfter", a.h.Wb); - a.b("virtualElements.prepend", a.h.Vc); - a.b("virtualElements.setDomNodeChildren", a.h.va); - (function() { - a.ga = function() { - this.nd = {}; - }; - a.a.extend(a.ga.prototype, { - nodeHasBindings: function(b) { - switch (b.nodeType) { - case 1: - return null != b.getAttribute("data-bind") || a.j.getComponentNameForNode(b); - case 8: - return a.h.Cd(b); - default: - return false; - } - }, - getBindings: function(b, c) { - var d = this.getBindingsString(b, c), d = d ? this.parseBindingsString(d, c, b) : null; - return a.j.tc(d, b, c, false); - }, - getBindingAccessors: function(b, c) { - var d = this.getBindingsString(b, c), d = d ? this.parseBindingsString(d, c, b, { valueAccessors: true }) : null; - return a.j.tc(d, b, c, true); - }, - getBindingsString: function(b) { - switch (b.nodeType) { - case 1: - return b.getAttribute("data-bind"); - case 8: - return a.h.Vd(b); - default: - return null; - } - }, - parseBindingsString: function(b, c, d, e) { - try { - var f = this.nd, g = b + (e && e.valueAccessors || ""), h; - if (!(h = f[g])) { - var m, k = "with($context){with($data||{}){return{" + a.m.vb(b, e) + "}}}"; - m = new Function("$context", "$element", k); - h = f[g] = m; - } - return h(c, d); - } catch (l) { - throw l.message = "Unable to parse bindings.\nBindings value: " + b + "\nMessage: " + l.message, l; - } + } + return matches; + }, + // arg is for internal usage only + map: function(elems, callback, arg) { + var length, value, i = 0, ret = []; + if (isArrayLike2(elems)) { + length = elems.length; + for (; i < length; i++) { + value = callback(elems[i], i, arg); + if (value != null) { + ret.push(value); } - }); - a.ga.instance = new a.ga(); - })(); - a.b("bindingProvider", a.ga); - (function() { - function b(b2) { - var c2 = (b2 = a.a.g.get(b2, z)) && b2.N; - c2 && (b2.N = null, c2.Tc()); - } - function c(c2, d2, e2) { - this.node = c2; - this.yc = d2; - this.kb = []; - this.H = false; - d2.N || a.a.K.za(c2, b); - e2 && e2.N && (e2.N.kb.push(c2), this.Kb = e2); - } - function d(a2) { - return function() { - return a2; - }; } - function e(a2) { - return a2(); - } - function f(b2) { - return a.a.Ga(a.u.G(b2), function(a2, c2) { - return function() { - return b2()[c2]; - }; - }); + } else { + for (i in elems) { + value = callback(elems[i], i, arg); + if (value != null) { + ret.push(value); + } } - function g(b2, c2, e2) { - return "function" === typeof b2 ? f(b2.bind(null, c2, e2)) : a.a.Ga(b2, d); + } + return flat(ret); + }, + // A global GUID counter for objects + guid: 1, + // jQuery.support is not used in Core but other projects attach their + // properties to it so it needs to exist. + support + }); + if (typeof Symbol === "function") { + jQuery2.fn[Symbol.iterator] = arr[Symbol.iterator]; + } + jQuery2.each( + "Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "), + function(_i, name) { + class2type["[object " + name + "]"] = name.toLowerCase(); + } + ); + function isArrayLike2(obj) { + var length = !!obj && "length" in obj && obj.length, type = toType(obj); + if (isFunction2(obj) || isWindow(obj)) { + return false; + } + return type === "array" || length === 0 || typeof length === "number" && length > 0 && length - 1 in obj; + } + var Sizzle = ( + /*! + * Sizzle CSS Selector Engine v2.3.6 + * https://sizzlejs.com/ + * + * Copyright JS Foundation and other contributors + * Released under the MIT license + * https://js.foundation/ + * + * Date: 2021-02-16 + */ + function(window3) { + var i, support2, Expr, getText, isXML, tokenize, compile, select, outermostContext, sortInput, hasDuplicate, setDocument, document3, docElem, documentIsHTML, rbuggyQSA, rbuggyMatches, matches, contains, expando = "sizzle" + 1 * /* @__PURE__ */ new Date(), preferredDoc = window3.document, dirruns = 0, done = 0, classCache = createCache(), tokenCache = createCache(), compilerCache = createCache(), nonnativeSelectorCache = createCache(), sortOrder = function(a, b) { + if (a === b) { + hasDuplicate = true; + } + return 0; + }, hasOwn2 = {}.hasOwnProperty, arr2 = [], pop = arr2.pop, pushNative = arr2.push, push2 = arr2.push, slice2 = arr2.slice, indexOf2 = function(list, elem) { + var i2 = 0, len = list.length; + for (; i2 < len; i2++) { + if (list[i2] === elem) { + return i2; + } } - function h(a2, b2) { - return f(this.getBindings.bind(this, a2, b2)); + return -1; + }, booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", whitespace = "[\\x20\\t\\r\\n\\f]", identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+", attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + // Operator (capture 2) + "*([*^$|!~]?=)" + whitespace + // "Attribute values must be CSS identifiers [capture 5] + // or strings [capture 3 or capture 4]" + `*(?:'((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)"|(` + identifier + "))|)" + whitespace + "*\\]", pseudos = ":(" + identifier + `)(?:\\((('((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)")|((?:\\\\.|[^\\\\()[\\]]|` + attributes + ")*)|.*)\\)|)", rwhitespace = new RegExp(whitespace + "+", "g"), rtrim2 = new RegExp("^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g"), rcomma = new RegExp("^" + whitespace + "*," + whitespace + "*"), rcombinators = new RegExp("^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*"), rdescend = new RegExp(whitespace + "|>"), rpseudo = new RegExp(pseudos), ridentifier = new RegExp("^" + identifier + "$"), matchExpr = { + "ID": new RegExp("^#(" + identifier + ")"), + "CLASS": new RegExp("^\\.(" + identifier + ")"), + "TAG": new RegExp("^(" + identifier + "|[*])"), + "ATTR": new RegExp("^" + attributes), + "PSEUDO": new RegExp("^" + pseudos), + "CHILD": new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i"), + "bool": new RegExp("^(?:" + booleans + ")$", "i"), + // For use in libraries implementing .is() + // We use this for POS matching in `select` + "needsContext": new RegExp("^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i") + }, rhtml2 = /HTML$/i, rinputs = /^(?:input|select|textarea|button)$/i, rheader = /^h\d$/i, rnative = /^[^{]+\{\s*\[native \w/, rquickExpr2 = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, rsibling = /[+~]/, runescape = new RegExp("\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g"), funescape = function(escape, nonHex) { + var high = "0x" + escape.slice(1) - 65536; + return nonHex ? ( + // Strip the backslash prefix from a non-hex escape sequence + nonHex + ) : ( + // Replace a hexadecimal escape sequence with the encoded Unicode code point + // Support: IE <=11+ + // For values outside the Basic Multilingual Plane (BMP), manually construct a + // surrogate pair + high < 0 ? String.fromCharCode(high + 65536) : String.fromCharCode(high >> 10 | 55296, high & 1023 | 56320) + ); + }, rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g, fcssescape = function(ch, asCodePoint) { + if (asCodePoint) { + if (ch === "\0") { + return "\uFFFD"; + } + return ch.slice(0, -1) + "\\" + ch.charCodeAt(ch.length - 1).toString(16) + " "; } - function m(b2, c2) { - var d2 = a.h.firstChild(c2); - if (d2) { - var e2, f2 = a.ga.instance, l2 = f2.preprocessNode; - if (l2) { - for (; e2 = d2; ) - d2 = a.h.nextSibling(e2), l2.call(f2, e2); - d2 = a.h.firstChild(c2); + return "\\" + ch; + }, unloadHandler = function() { + setDocument(); + }, inDisabledFieldset = addCombinator( + function(elem) { + return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset"; + }, + { dir: "parentNode", next: "legend" } + ); + try { + push2.apply( + arr2 = slice2.call(preferredDoc.childNodes), + preferredDoc.childNodes + ); + arr2[preferredDoc.childNodes.length].nodeType; + } catch (e) { + push2 = { + apply: arr2.length ? ( + // Leverage slice if possible + function(target, els) { + pushNative.apply(target, slice2.call(els)); } - for (; e2 = d2; ) - d2 = a.h.nextSibling(e2), k(b2, e2); - } - a.i.ma(c2, a.i.H); - } - function k(b2, c2) { - var d2 = b2, e2 = 1 === c2.nodeType; - e2 && a.h.Sc(c2); - if (e2 || a.ga.instance.nodeHasBindings(c2)) - d2 = p(c2, null, b2).bindingContextForDescendants; - d2 && !u[a.a.R(c2)] && m(d2, c2); - } - function l(b2) { - var c2 = [], d2 = {}, e2 = []; - a.a.P(b2, function ca(f2) { - if (!d2[f2]) { - var k2 = a.getBindingHandler(f2); - k2 && (k2.after && (e2.push(f2), a.a.D(k2.after, function(c3) { - if (b2[c3]) { - if (-1 !== a.a.A(e2, c3)) - throw Error("Cannot combine the following bindings, because they have a cyclic dependency: " + e2.join(", ")); - ca(c3); - } - }), e2.length--), c2.push({ key: f2, Mc: k2 })); - d2[f2] = true; + ) : ( + // Support: IE<9 + // Otherwise append directly + function(target, els) { + var j = target.length, i2 = 0; + while (target[j++] = els[i2++]) { + } + target.length = j - 1; } - }); - return c2; - } - function p(b2, c2, d2) { - var f2 = a.a.g.Ub(b2, z, {}), k2 = f2.hd; - if (!c2) { - if (k2) - throw Error("You cannot apply bindings multiple times to the same element."); - f2.hd = true; - } - k2 || (f2.context = d2); - f2.Zb || (f2.Zb = {}); - var g2; - if (c2 && "function" !== typeof c2) - g2 = c2; - else { - var p2 = a.ga.instance, q2 = p2.getBindingAccessors || h, m2 = a.$(function() { - if (g2 = c2 ? c2(d2, b2) : q2.call(p2, b2, d2)) { - if (d2[t]) - d2[t](); - if (d2[B]) - d2[B](); + ) + }; + } + function Sizzle2(selector, context2, results, seed) { + var m, i2, elem, nid, match, groups, newSelector, newContext = context2 && context2.ownerDocument, nodeType = context2 ? context2.nodeType : 9; + results = results || []; + if (typeof selector !== "string" || !selector || nodeType !== 1 && nodeType !== 9 && nodeType !== 11) { + return results; + } + if (!seed) { + setDocument(context2); + context2 = context2 || document3; + if (documentIsHTML) { + if (nodeType !== 11 && (match = rquickExpr2.exec(selector))) { + if (m = match[1]) { + if (nodeType === 9) { + if (elem = context2.getElementById(m)) { + if (elem.id === m) { + results.push(elem); + return results; + } + } else { + return results; + } + } else { + if (newContext && (elem = newContext.getElementById(m)) && contains(context2, elem) && elem.id === m) { + results.push(elem); + return results; + } + } + } else if (match[2]) { + push2.apply(results, context2.getElementsByTagName(selector)); + return results; + } else if ((m = match[3]) && support2.getElementsByClassName && context2.getElementsByClassName) { + push2.apply(results, context2.getElementsByClassName(m)); + return results; } - return g2; - }, null, { l: b2 }); - g2 && m2.ja() || (m2 = null); - } - var x2 = d2, u2; - if (g2) { - var J2 = function() { - return a.a.Ga(m2 ? m2() : g2, e); - }, r2 = m2 ? function(a2) { - return function() { - return e(m2()[a2]); - }; - } : function(a2) { - return g2[a2]; - }; - J2.get = function(a2) { - return g2[a2] && e(r2(a2)); - }; - J2.has = function(a2) { - return a2 in g2; - }; - a.i.H in g2 && a.i.subscribe(b2, a.i.H, function() { - var c3 = (0, g2[a.i.H])(); - if (c3) { - var d3 = a.h.childNodes(b2); - d3.length && c3(d3, a.Ec(d3[0])); + } + if (support2.qsa && !nonnativeSelectorCache[selector + " "] && (!rbuggyQSA || !rbuggyQSA.test(selector)) && // Support: IE 8 only + // Exclude object elements + (nodeType !== 1 || context2.nodeName.toLowerCase() !== "object")) { + newSelector = selector; + newContext = context2; + if (nodeType === 1 && (rdescend.test(selector) || rcombinators.test(selector))) { + newContext = rsibling.test(selector) && testContext(context2.parentNode) || context2; + if (newContext !== context2 || !support2.scope) { + if (nid = context2.getAttribute("id")) { + nid = nid.replace(rcssescape, fcssescape); + } else { + context2.setAttribute("id", nid = expando); + } + } + groups = tokenize(selector); + i2 = groups.length; + while (i2--) { + groups[i2] = (nid ? "#" + nid : ":scope") + " " + toSelector(groups[i2]); + } + newSelector = groups.join(","); } - }); - a.i.pa in g2 && (x2 = a.i.Cb(b2, d2), a.i.subscribe(b2, a.i.pa, function() { - var c3 = (0, g2[a.i.pa])(); - c3 && a.h.firstChild(b2) && c3(b2); - })); - f2 = l(g2); - a.a.D(f2, function(c3) { - var d3 = c3.Mc.init, e2 = c3.Mc.update, f3 = c3.key; - if (8 === b2.nodeType && !a.h.ea[f3]) - throw Error("The binding '" + f3 + "' cannot be used with virtual elements"); try { - "function" == typeof d3 && a.u.G(function() { - var a2 = d3(b2, r2(f3), J2, x2.$data, x2); - if (a2 && a2.controlsDescendantBindings) { - if (u2 !== n) - throw Error("Multiple bindings (" + u2 + " and " + f3 + ") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element."); - u2 = f3; - } - }), "function" == typeof e2 && a.$(function() { - e2(b2, r2(f3), J2, x2.$data, x2); - }, null, { l: b2 }); - } catch (k3) { - throw k3.message = 'Unable to process binding "' + f3 + ": " + g2[f3] + '"\nMessage: ' + k3.message, k3; + push2.apply( + results, + newContext.querySelectorAll(newSelector) + ); + return results; + } catch (qsaError) { + nonnativeSelectorCache(selector, true); + } finally { + if (nid === expando) { + context2.removeAttribute("id"); + } } - }); + } } - f2 = u2 === n; - return { shouldBindDescendants: f2, bindingContextForDescendants: f2 && x2 }; } - function q(b2, c2) { - return b2 && b2 instanceof a.fa ? b2 : new a.fa(b2, n, n, c2); + return select(selector.replace(rtrim2, "$1"), context2, results, seed); + } + function createCache() { + var keys = []; + function cache(key, value) { + if (keys.push(key + " ") > Expr.cacheLength) { + delete cache[keys.shift()]; + } + return cache[key + " "] = value; } - var t = a.a.Da("_subscribable"), x = a.a.Da("_ancestorBindingInfo"), B = a.a.Da("_dataDependency"); - a.c = {}; - var u = { script: true, textarea: true, template: true }; - a.getBindingHandler = function(b2) { - return a.c[b2]; - }; - var J = {}; - a.fa = function(b2, c2, d2, e2, f2) { - function k2() { - var b3 = p2 ? h2() : h2, f3 = a.a.f(b3); - c2 ? (a.a.extend(l2, c2), x in c2 && (l2[x] = c2[x])) : (l2.$parents = [], l2.$root = f3, l2.ko = a); - l2[t] = q2; - g2 ? f3 = l2.$data : (l2.$rawData = b3, l2.$data = f3); - d2 && (l2[d2] = f3); - e2 && e2(l2, c2, f3); - if (c2 && c2[t] && !a.S.o().Vb(c2[t])) - c2[t](); - m2 && (l2[B] = m2); - return l2.$data; - } - var l2 = this, g2 = b2 === J, h2 = g2 ? n : b2, p2 = "function" == typeof h2 && !a.O(h2), q2, m2 = f2 && f2.dataDependency; - f2 && f2.exportDependencies ? k2() : (q2 = a.xb(k2), q2.v(), q2.ja() ? q2.equalityComparer = null : l2[t] = n); - }; - a.fa.prototype.createChildContext = function(b2, c2, d2, e2) { - !e2 && c2 && "object" == typeof c2 && (e2 = c2, c2 = e2.as, d2 = e2.extend); - if (c2 && e2 && e2.noChildContext) { - var f2 = "function" == typeof b2 && !a.O(b2); - return new a.fa(J, this, null, function(a2) { - d2 && d2(a2); - a2[c2] = f2 ? b2() : b2; - }, e2); - } - return new a.fa( - b2, - this, - c2, - function(a2, b3) { - a2.$parentContext = b3; - a2.$parent = b3.$data; - a2.$parents = (b3.$parents || []).slice(0); - a2.$parents.unshift(a2.$parent); - d2 && d2(a2); - }, - e2 - ); - }; - a.fa.prototype.extend = function(b2, c2) { - return new a.fa(J, this, null, function(c3) { - a.a.extend(c3, "function" == typeof b2 ? b2(c3) : b2); - }, c2); - }; - var z = a.a.g.Z(); - c.prototype.Tc = function() { - this.Kb && this.Kb.N && this.Kb.N.sd(this.node); - }; - c.prototype.sd = function(b2) { - a.a.Pa(this.kb, b2); - !this.kb.length && this.H && this.Cc(); - }; - c.prototype.Cc = function() { - this.H = true; - this.yc.N && !this.kb.length && (this.yc.N = null, a.a.K.yb(this.node, b), a.i.ma(this.node, a.i.pa), this.Tc()); - }; - a.i = { H: "childrenComplete", pa: "descendantsComplete", subscribe: function(b2, c2, d2, e2, f2) { - var k2 = a.a.g.Ub(b2, z, {}); - k2.Fa || (k2.Fa = new a.T()); - f2 && f2.notifyImmediately && k2.Zb[c2] && a.u.G(d2, e2, [b2]); - return k2.Fa.subscribe(d2, e2, c2); - }, ma: function(b2, c2) { - var d2 = a.a.g.get(b2, z); - if (d2 && (d2.Zb[c2] = true, d2.Fa && d2.Fa.notifySubscribers(b2, c2), c2 == a.i.H)) { - if (d2.N) - d2.N.Cc(); - else if (d2.N === n && d2.Fa && d2.Fa.Wa(a.i.pa)) - throw Error("descendantsComplete event not supported for bindings on this node"); - } - }, Cb: function(b2, d2) { - var e2 = a.a.g.Ub(b2, z, {}); - e2.N || (e2.N = new c(b2, e2, d2[x])); - return d2[x] == e2 ? d2 : d2.extend(function(a2) { - a2[x] = e2; - }); - } }; - a.Td = function(b2) { - return (b2 = a.a.g.get(b2, z)) && b2.context; - }; - a.ib = function(b2, c2, d2) { - 1 === b2.nodeType && a.h.Sc(b2); - return p(b2, c2, q(d2)); - }; - a.ld = function(b2, c2, d2) { - d2 = q(d2); - return a.ib(b2, g(c2, d2, b2), d2); - }; - a.Oa = function(a2, b2) { - 1 !== b2.nodeType && 8 !== b2.nodeType || m(q(a2), b2); - }; - a.vc = function(a2, b2, c2) { - !v && A.jQuery && (v = A.jQuery); - if (2 > arguments.length) { - if (b2 = w2.body, !b2) - throw Error("ko.applyBindings: could not find document.body; has the document been loaded?"); - } else if (!b2 || 1 !== b2.nodeType && 8 !== b2.nodeType) - throw Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node"); - k(q(a2, c2), b2); - }; - a.Dc = function(b2) { - return !b2 || 1 !== b2.nodeType && 8 !== b2.nodeType ? n : a.Td(b2); - }; - a.Ec = function(b2) { - return (b2 = a.Dc(b2)) ? b2.$data : n; - }; - a.b("bindingHandlers", a.c); - a.b("bindingEvent", a.i); - a.b("bindingEvent.subscribe", a.i.subscribe); - a.b("bindingEvent.startPossiblyAsyncContentBinding", a.i.Cb); - a.b("applyBindings", a.vc); - a.b("applyBindingsToDescendants", a.Oa); - a.b("applyBindingAccessorsToNode", a.ib); - a.b("applyBindingsToNode", a.ld); - a.b("contextFor", a.Dc); - a.b("dataFor", a.Ec); - })(); - (function(b) { - function c(c2, e2) { - var k = Object.prototype.hasOwnProperty.call(f, c2) ? f[c2] : b, l; - k ? k.subscribe(e2) : (k = f[c2] = new a.T(), k.subscribe(e2), d(c2, function(b2, d2) { - var e3 = !(!d2 || !d2.synchronous); - g[c2] = { definition: b2, Gd: e3 }; - delete f[c2]; - l || e3 ? k.notifySubscribers(b2) : a.na.zb(function() { - k.notifySubscribers(b2); - }); - }), l = true); - } - function d(a2, b2) { - e("getConfig", [a2], function(c2) { - c2 ? e("loadComponent", [a2, c2], function(a3) { - b2( - a3, - c2 - ); - }) : b2(null, null); - }); + return cache; + } + function markFunction(fn) { + fn[expando] = true; + return fn; + } + function assert(fn) { + var el = document3.createElement("fieldset"); + try { + return !!fn(el); + } catch (e) { + return false; + } finally { + if (el.parentNode) { + el.parentNode.removeChild(el); + } + el = null; } - function e(c2, d2, f2, l) { - l || (l = a.j.loaders.slice(0)); - var g2 = l.shift(); - if (g2) { - var q = g2[c2]; - if (q) { - var t = false; - if (q.apply(g2, d2.concat(function(a2) { - t ? f2(null) : null !== a2 ? f2(a2) : e(c2, d2, f2, l); - })) !== b && (t = true, !g2.suppressLoaderExceptions)) - throw Error("Component loaders must supply values by invoking the callback, not by returning values synchronously."); - } else - e(c2, d2, f2, l); - } else - f2(null); - } - var f = {}, g = {}; - a.j = { get: function(d2, e2) { - var f2 = Object.prototype.hasOwnProperty.call(g, d2) ? g[d2] : b; - f2 ? f2.Gd ? a.u.G(function() { - e2(f2.definition); - }) : a.na.zb(function() { - e2(f2.definition); - }) : c(d2, e2); - }, Bc: function(a2) { - delete g[a2]; - }, oc: e }; - a.j.loaders = []; - a.b("components", a.j); - a.b("components.get", a.j.get); - a.b("components.clearCachedDefinition", a.j.Bc); - })(); - (function() { - function b(b2, c2, d2, e2) { - function g2() { - 0 === --B && e2(h2); - } - var h2 = {}, B = 2, u = d2.template; - d2 = d2.viewModel; - u ? f(c2, u, function(c3) { - a.j.oc("loadTemplate", [b2, c3], function(a2) { - h2.template = a2; - g2(); - }); - }) : g2(); - d2 ? f(c2, d2, function(c3) { - a.j.oc("loadViewModel", [b2, c3], function(a2) { - h2[m] = a2; - g2(); - }); - }) : g2(); + } + function addHandle(attrs, handler) { + var arr3 = attrs.split("|"), i2 = arr3.length; + while (i2--) { + Expr.attrHandle[arr3[i2]] = handler; } - function c(a2, b2, d2) { - if ("function" === typeof b2) - d2(function(a3) { - return new b2(a3); - }); - else if ("function" === typeof b2[m]) - d2(b2[m]); - else if ("instance" in b2) { - var e2 = b2.instance; - d2(function() { - return e2; - }); - } else - "viewModel" in b2 ? c(a2, b2.viewModel, d2) : a2("Unknown viewModel value: " + b2); - } - function d(b2) { - switch (a.a.R(b2)) { - case "script": - return a.a.ua(b2.text); - case "textarea": - return a.a.ua(b2.value); - case "template": - if (e(b2.content)) - return a.a.Ca(b2.content.childNodes); - } - return a.a.Ca(b2.childNodes); - } - function e(a2) { - return A.DocumentFragment ? a2 instanceof DocumentFragment : a2 && 11 === a2.nodeType; - } - function f(a2, b2, c2) { - "string" === typeof b2.require ? T || A.require ? (T || A.require)([b2.require], function(a3) { - a3 && "object" === typeof a3 && a3.Xd && a3["default"] && (a3 = a3["default"]); - c2(a3); - }) : a2("Uses require, but no AMD loader is present") : c2(b2); - } - function g(a2) { - return function(b2) { - throw Error("Component '" + a2 + "': " + b2); - }; + } + function siblingCheck(a, b) { + var cur = b && a, diff = cur && a.nodeType === 1 && b.nodeType === 1 && a.sourceIndex - b.sourceIndex; + if (diff) { + return diff; } - var h = {}; - a.j.register = function(b2, c2) { - if (!c2) - throw Error("Invalid configuration for " + b2); - if (a.j.tb(b2)) - throw Error("Component " + b2 + " is already registered"); - h[b2] = c2; - }; - a.j.tb = function(a2) { - return Object.prototype.hasOwnProperty.call(h, a2); - }; - a.j.unregister = function(b2) { - delete h[b2]; - a.j.Bc(b2); - }; - a.j.Fc = { getConfig: function(b2, c2) { - c2(a.j.tb(b2) ? h[b2] : null); - }, loadComponent: function(a2, c2, d2) { - var e2 = g(a2); - f(e2, c2, function(c3) { - b(a2, e2, c3, d2); - }); - }, loadTemplate: function(b2, c2, f2) { - b2 = g(b2); - if ("string" === typeof c2) - f2(a.a.ua(c2)); - else if (c2 instanceof Array) - f2(c2); - else if (e(c2)) - f2(a.a.la(c2.childNodes)); - else if (c2.element) - if (c2 = c2.element, A.HTMLElement ? c2 instanceof HTMLElement : c2 && c2.tagName && 1 === c2.nodeType) - f2(d(c2)); - else if ("string" === typeof c2) { - var h2 = w2.getElementById(c2); - h2 ? f2(d(h2)) : b2("Cannot find element with ID " + c2); - } else - b2("Unknown element type: " + c2); - else - b2("Unknown template value: " + c2); - }, loadViewModel: function(a2, b2, d2) { - c(g(a2), b2, d2); - } }; - var m = "createViewModel"; - a.b("components.register", a.j.register); - a.b("components.isRegistered", a.j.tb); - a.b("components.unregister", a.j.unregister); - a.b("components.defaultLoader", a.j.Fc); - a.j.loaders.push(a.j.Fc); - a.j.dd = h; - })(); - (function() { - function b(b2, e) { - var f = b2.getAttribute("params"); - if (f) { - var f = c.parseBindingsString(f, e, b2, { valueAccessors: true, bindingParams: true }), f = a.a.Ga(f, function(c2) { - return a.o(c2, null, { l: b2 }); - }), g = a.a.Ga( - f, - function(c2) { - var e2 = c2.v(); - return c2.ja() ? a.o({ read: function() { - return a.a.f(c2()); - }, write: a.Za(e2) && function(a2) { - c2()(a2); - }, l: b2 }) : e2; - } - ); - Object.prototype.hasOwnProperty.call(g, "$raw") || (g.$raw = f); - return g; + if (cur) { + while (cur = cur.nextSibling) { + if (cur === b) { + return -1; + } } - return { $raw: {} }; } - a.j.getComponentNameForNode = function(b2) { - var c2 = a.a.R(b2); - if (a.j.tb(c2) && (-1 != c2.indexOf("-") || "[object HTMLUnknownElement]" == "" + b2 || 8 >= a.a.W && b2.tagName === c2)) - return c2; + return a ? 1 : -1; + } + function createInputPseudo(type) { + return function(elem) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === type; }; - a.j.tc = function(c2, e, f, g) { - if (1 === e.nodeType) { - var h = a.j.getComponentNameForNode(e); - if (h) { - c2 = c2 || {}; - if (c2.component) - throw Error('Cannot use the "component" binding on a custom element matching a component'); - var m = { name: h, params: b(e, f) }; - c2.component = g ? function() { - return m; - } : m; - } - } - return c2; + } + function createButtonPseudo(type) { + return function(elem) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && elem.type === type; }; - var c = new a.ga(); - 9 > a.a.W && (a.j.register = function(a2) { - return function(b2) { - return a2.apply(this, arguments); - }; - }(a.j.register), w2.createDocumentFragment = function(b2) { - return function() { - var c2 = b2(), f = a.j.dd, g; - for (g in f) - ; - return c2; - }; - }(w2.createDocumentFragment)); - })(); - (function() { - function b(b2, c2, d2) { - c2 = c2.template; - if (!c2) - throw Error("Component '" + b2 + "' has no template"); - b2 = a.a.Ca(c2); - a.h.va(d2, b2); - } - function c(a2, b2, c2) { - var d2 = a2.createViewModel; - return d2 ? d2.call( - a2, - b2, - c2 - ) : b2; - } - var d = 0; - a.c.component = { init: function(e, f, g, h, m) { - function k() { - var a2 = l && l.dispose; - "function" === typeof a2 && a2.call(l); - q && q.s(); - p = l = q = null; - } - var l, p, q, t = a.a.la(a.h.childNodes(e)); - a.h.Ea(e); - a.a.K.za(e, k); - a.o(function() { - var g2 = a.a.f(f()), h2, u; - "string" === typeof g2 ? h2 = g2 : (h2 = a.a.f(g2.name), u = a.a.f(g2.params)); - if (!h2) - throw Error("No component name specified"); - var n2 = a.i.Cb(e, m), z = p = ++d; - a.j.get(h2, function(d2) { - if (p === z) { - k(); - if (!d2) - throw Error("Unknown component '" + h2 + "'"); - b(h2, d2, e); - var f2 = c(d2, u, { element: e, templateNodes: t }); - d2 = n2.createChildContext(f2, { extend: function(a2) { - a2.$component = f2; - a2.$componentTemplateNodes = t; - } }); - f2 && f2.koDescendantsComplete && (q = a.i.subscribe(e, a.i.pa, f2.koDescendantsComplete, f2)); - l = f2; - a.Oa(d2, e); + } + function createDisabledPseudo(disabled) { + return function(elem) { + if ("form" in elem) { + if (elem.parentNode && elem.disabled === false) { + if ("label" in elem) { + if ("label" in elem.parentNode) { + return elem.parentNode.disabled === disabled; + } else { + return elem.disabled === disabled; + } } - }); - }, null, { l: e }); - return { controlsDescendantBindings: true }; - } }; - a.h.ea.component = true; - })(); - var V = { "class": "className", "for": "htmlFor" }; - a.c.attr = { update: function(b, c) { - var d = a.a.f(c()) || {}; - a.a.P(d, function(c2, d2) { - d2 = a.a.f(d2); - var g = c2.indexOf(":"), g = "lookupNamespaceURI" in b && 0 < g && b.lookupNamespaceURI(c2.substr(0, g)), h = false === d2 || null === d2 || d2 === n; - h ? g ? b.removeAttributeNS(g, c2) : b.removeAttribute(c2) : d2 = d2.toString(); - 8 >= a.a.W && c2 in V ? (c2 = V[c2], h ? b.removeAttribute(c2) : b[c2] = d2) : h || (g ? b.setAttributeNS(g, c2, d2) : b.setAttribute(c2, d2)); - "name" === c2 && a.a.Yc(b, h ? "" : d2); - }); - } }; - (function() { - a.c.checked = { after: ["value", "attr"], init: function(b, c, d) { - function e() { - var e2 = b.checked, f2 = g(); - if (!a.S.Ya() && (e2 || !m && !a.S.qa())) { - var k2 = a.u.G(c); - if (l) { - var q2 = p ? k2.v() : k2, z = t; - t = f2; - z !== f2 ? e2 && (a.a.Na(q2, f2, true), a.a.Na(q2, z, false)) : a.a.Na(q2, f2, e2); - p && a.Za(k2) && k2(q2); - } else - h && (f2 === n ? f2 = e2 : e2 || (f2 = n)), a.m.eb( - k2, - d, - "checked", - f2, - true - ); + return elem.isDisabled === disabled || // Where there is no isDisabled, check manually + /* jshint -W018 */ + elem.isDisabled !== !disabled && inDisabledFieldset(elem) === disabled; } + return elem.disabled === disabled; + } else if ("label" in elem) { + return elem.disabled === disabled; } - function f() { - var d2 = a.a.f(c()), e2 = g(); - l ? (b.checked = 0 <= a.a.A(d2, e2), t = e2) : b.checked = h && e2 === n ? !!d2 : g() === d2; - } - var g = a.xb(function() { - if (d.has("checkedValue")) - return a.a.f(d.get("checkedValue")); - if (q) - return d.has("value") ? a.a.f(d.get("value")) : b.value; - }), h = "checkbox" == b.type, m = "radio" == b.type; - if (h || m) { - var k = c(), l = h && a.a.f(k) instanceof Array, p = !(l && k.push && k.splice), q = m || l, t = l ? g() : n; - m && !b.name && a.c.uniqueName.init(b, function() { - return true; - }); - a.o(e, null, { l: b }); - a.a.B(b, "click", e); - a.o(f, null, { l: b }); - k = n; - } - } }; - a.m.wa.checked = true; - a.c.checkedValue = { update: function(b, c) { - b.value = a.a.f(c()); - } }; - })(); - a.c["class"] = { update: function(b, c) { - var d = a.a.Db(a.a.f(c())); - a.a.Eb(b, b.__ko__cssValue, false); - b.__ko__cssValue = d; - a.a.Eb(b, d, true); - } }; - a.c.css = { update: function(b, c) { - var d = a.a.f(c()); - null !== d && "object" == typeof d ? a.a.P(d, function(c2, d2) { - d2 = a.a.f(d2); - a.a.Eb(b, c2, d2); - }) : a.c["class"].update(b, c); - } }; - a.c.enable = { update: function(b, c) { - var d = a.a.f(c()); - d && b.disabled ? b.removeAttribute("disabled") : d || b.disabled || (b.disabled = true); - } }; - a.c.disable = { update: function(b, c) { - a.c.enable.update(b, function() { - return !a.a.f(c()); - }); - } }; - a.c.event = { init: function(b, c, d, e, f) { - var g = c() || {}; - a.a.P(g, function(g2) { - "string" == typeof g2 && a.a.B(b, g2, function(b2) { - var k, l = c()[g2]; - if (l) { - try { - var p = a.a.la(arguments); - e = f.$data; - p.unshift(e); - k = l.apply(e, p); - } finally { - true !== k && (b2.preventDefault ? b2.preventDefault() : b2.returnValue = false); - } - false === d.get(g2 + "Bubble") && (b2.cancelBubble = true, b2.stopPropagation && b2.stopPropagation()); - } - }); - }); - } }; - a.c.foreach = { Rc: function(b) { - return function() { - var c = b(), d = a.a.bc(c); - if (!d || "number" == typeof d.length) - return { foreach: c, templateEngine: a.ba.Ma }; - a.a.f(c); - return { foreach: d.data, as: d.as, noChildContext: d.noChildContext, includeDestroyed: d.includeDestroyed, afterAdd: d.afterAdd, beforeRemove: d.beforeRemove, afterRender: d.afterRender, beforeMove: d.beforeMove, afterMove: d.afterMove, templateEngine: a.ba.Ma }; + return false; }; - }, init: function(b, c) { - return a.c.template.init(b, a.c.foreach.Rc(c)); - }, update: function(b, c, d, e, f) { - return a.c.template.update(b, a.c.foreach.Rc(c), d, e, f); - } }; - a.m.Ra.foreach = false; - a.h.ea.foreach = true; - a.c.hasfocus = { init: function(b, c, d) { - function e(e2) { - b.__ko_hasfocusUpdating = true; - var f2 = b.ownerDocument; - if ("activeElement" in f2) { - var g2; - try { - g2 = f2.activeElement; - } catch (l) { - g2 = f2.body; - } - e2 = g2 === b; - } - f2 = c(); - a.m.eb(f2, d, "hasfocus", e2, true); - b.__ko_hasfocusLastValue = e2; - b.__ko_hasfocusUpdating = false; - } - var f = e.bind(null, true), g = e.bind(null, false); - a.a.B(b, "focus", f); - a.a.B(b, "focusin", f); - a.a.B(b, "blur", g); - a.a.B(b, "focusout", g); - b.__ko_hasfocusLastValue = false; - }, update: function(b, c) { - var d = !!a.a.f(c()); - b.__ko_hasfocusUpdating || b.__ko_hasfocusLastValue === d || (d ? b.focus() : b.blur(), !d && b.__ko_hasfocusLastValue && b.ownerDocument.body.focus(), a.u.G(a.a.Fb, null, [b, d ? "focusin" : "focusout"])); - } }; - a.m.wa.hasfocus = true; - a.c.hasFocus = a.c.hasfocus; - a.m.wa.hasFocus = "hasfocus"; - a.c.html = { init: function() { - return { controlsDescendantBindings: true }; - }, update: function(b, c) { - a.a.fc(b, c()); - } }; - (function() { - function b(b2, d, e) { - a.c[b2] = { init: function(b3, c, h, m, k) { - var l, p, q = {}, t, x, n2; - if (d) { - m = h.get("as"); - var u = h.get("noChildContext"); - n2 = !(m && u); - q = { as: m, noChildContext: u, exportDependencies: n2 }; - } - x = (t = "render" == h.get("completeOn")) || h.has(a.i.pa); - a.o(function() { - var h2 = a.a.f(c()), m2 = !e !== !h2, u2 = !p, r2; - if (n2 || m2 !== l) { - x && (k = a.i.Cb(b3, k)); - if (m2) { - if (!d || n2) - q.dataDependency = a.S.o(); - r2 = d ? k.createChildContext("function" == typeof h2 ? h2 : c, q) : a.S.qa() ? k.extend(null, q) : k; - } - u2 && a.S.qa() && (p = a.a.Ca(a.h.childNodes(b3), true)); - m2 ? (u2 || a.h.va(b3, a.a.Ca(p)), a.Oa(r2, b3)) : (a.h.Ea(b3), t || a.i.ma(b3, a.i.H)); - l = m2; + } + function createPositionalPseudo(fn) { + return markFunction(function(argument) { + argument = +argument; + return markFunction(function(seed, matches2) { + var j, matchIndexes = fn([], seed.length, argument), i2 = matchIndexes.length; + while (i2--) { + if (seed[j = matchIndexes[i2]]) { + seed[j] = !(matches2[j] = seed[j]); } - }, null, { l: b3 }); - return { controlsDescendantBindings: true }; - } }; - a.m.Ra[b2] = false; - a.h.ea[b2] = true; - } - b("if"); - b("ifnot", false, true); - b("with", true); - })(); - a.c.let = { init: function(b, c, d, e, f) { - c = f.extend(c); - a.Oa(c, b); - return { controlsDescendantBindings: true }; - } }; - a.h.ea.let = true; - var Q = {}; - a.c.options = { init: function(b) { - if ("select" !== a.a.R(b)) - throw Error("options binding applies only to SELECT elements"); - for (; 0 < b.length; ) - b.remove(0); - return { controlsDescendantBindings: true }; - }, update: function(b, c, d) { - function e() { - return a.a.jb(b.options, function(a2) { - return a2.selected; + } }); - } - function f(a2, b2, c2) { - var d2 = typeof b2; - return "function" == d2 ? b2(a2) : "string" == d2 ? a2[b2] : c2; - } - function g(c2, d2) { - if (x && l) - a.i.ma(b, a.i.H); - else if (t.length) { - var e2 = 0 <= a.a.A(t, a.w.M(d2[0])); - a.a.Zc(d2[0], e2); - x && !e2 && a.u.G(a.a.Fb, null, [b, "change"]); - } - } - var h = b.multiple, m = 0 != b.length && h ? b.scrollTop : null, k = a.a.f(c()), l = d.get("valueAllowUnset") && d.has("value"), p = d.get("optionsIncludeDestroyed"); - c = {}; - var q, t = []; - l || (h ? t = a.a.Mb(e(), a.w.M) : 0 <= b.selectedIndex && t.push(a.w.M(b.options[b.selectedIndex]))); - k && ("undefined" == typeof k.length && (k = [k]), q = a.a.jb(k, function(b2) { - return p || b2 === n || null === b2 || !a.a.f(b2._destroy); - }), d.has("optionsCaption") && (k = a.a.f(d.get("optionsCaption")), null !== k && k !== n && q.unshift(Q))); - var x = false; - c.beforeRemove = function(a2) { - b.removeChild(a2); - }; - k = g; - d.has("optionsAfterRender") && "function" == typeof d.get("optionsAfterRender") && (k = function(b2, c2) { - g(0, c2); - a.u.G(d.get("optionsAfterRender"), null, [c2[0], b2 !== Q ? b2 : n]); }); - a.a.ec(b, q, function(c2, e2, g2) { - g2.length && (t = !l && g2[0].selected ? [a.w.M(g2[0])] : [], x = true); - e2 = b.ownerDocument.createElement("option"); - c2 === Q ? (a.a.Bb(e2, d.get("optionsCaption")), a.w.cb(e2, n)) : (g2 = f(c2, d.get("optionsValue"), c2), a.w.cb(e2, a.a.f(g2)), c2 = f(c2, d.get("optionsText"), g2), a.a.Bb(e2, c2)); - return [e2]; - }, c, k); - if (!l) { - var B; - h ? B = t.length && e().length < t.length : B = t.length && 0 <= b.selectedIndex ? a.w.M(b.options[b.selectedIndex]) !== t[0] : t.length || 0 <= b.selectedIndex; - B && a.u.G(a.a.Fb, null, [b, "change"]); - } - (l || a.S.Ya()) && a.i.ma(b, a.i.H); - a.a.wd(b); - m && 20 < Math.abs(m - b.scrollTop) && (b.scrollTop = m); - } }; - a.c.options.$b = a.a.g.Z(); - a.c.selectedOptions = { init: function(b, c, d) { - function e() { - var e2 = c(), f2 = []; - a.a.D(b.getElementsByTagName("option"), function(b2) { - b2.selected && f2.push(a.w.M(b2)); - }); - a.m.eb( - e2, - d, - "selectedOptions", - f2 - ); + } + function testContext(context2) { + return context2 && typeof context2.getElementsByTagName !== "undefined" && context2; + } + support2 = Sizzle2.support = {}; + isXML = Sizzle2.isXML = function(elem) { + var namespace = elem && elem.namespaceURI, docElem2 = elem && (elem.ownerDocument || elem).documentElement; + return !rhtml2.test(namespace || docElem2 && docElem2.nodeName || "HTML"); + }; + setDocument = Sizzle2.setDocument = function(node) { + var hasCompare, subWindow, doc = node ? node.ownerDocument || node : preferredDoc; + if (doc == document3 || doc.nodeType !== 9 || !doc.documentElement) { + return document3; } - function f() { - var d2 = a.a.f(c()), e2 = b.scrollTop; - d2 && "number" == typeof d2.length && a.a.D(b.getElementsByTagName("option"), function(b2) { - var c2 = 0 <= a.a.A(d2, a.w.M(b2)); - b2.selected != c2 && a.a.Zc(b2, c2); - }); - b.scrollTop = e2; - } - if ("select" != a.a.R(b)) - throw Error("selectedOptions binding applies only to SELECT elements"); - var g; - a.i.subscribe(b, a.i.H, function() { - g ? e() : (a.a.B(b, "change", e), g = a.o(f, null, { l: b })); - }, null, { notifyImmediately: true }); - }, update: function() { - } }; - a.m.wa.selectedOptions = true; - a.c.style = { update: function(b, c) { - var d = a.a.f(c() || {}); - a.a.P(d, function(c2, d2) { - d2 = a.a.f(d2); - if (null === d2 || d2 === n || false === d2) - d2 = ""; - if (v) - v(b).css(c2, d2); - else if (/^--/.test(c2)) - b.style.setProperty(c2, d2); - else { - c2 = c2.replace(/-(\w)/g, function(a2, b2) { - return b2.toUpperCase(); - }); - var g = b.style[c2]; - b.style[c2] = d2; - d2 === g || b.style[c2] != g || isNaN(d2) || (b.style[c2] = d2 + "px"); + document3 = doc; + docElem = document3.documentElement; + documentIsHTML = !isXML(document3); + if (preferredDoc != document3 && (subWindow = document3.defaultView) && subWindow.top !== subWindow) { + if (subWindow.addEventListener) { + subWindow.addEventListener("unload", unloadHandler, false); + } else if (subWindow.attachEvent) { + subWindow.attachEvent("onunload", unloadHandler); } + } + support2.scope = assert(function(el) { + docElem.appendChild(el).appendChild(document3.createElement("div")); + return typeof el.querySelectorAll !== "undefined" && !el.querySelectorAll(":scope fieldset div").length; }); - } }; - a.c.submit = { init: function(b, c, d, e, f) { - if ("function" != typeof c()) - throw Error("The value for a submit binding must be a function"); - a.a.B(b, "submit", function(a2) { - var d2, e2 = c(); - try { - d2 = e2.call(f.$data, b); - } finally { - true !== d2 && (a2.preventDefault ? a2.preventDefault() : a2.returnValue = false); - } + support2.attributes = assert(function(el) { + el.className = "i"; + return !el.getAttribute("className"); + }); + support2.getElementsByTagName = assert(function(el) { + el.appendChild(document3.createComment("")); + return !el.getElementsByTagName("*").length; + }); + support2.getElementsByClassName = rnative.test(document3.getElementsByClassName); + support2.getById = assert(function(el) { + docElem.appendChild(el).id = expando; + return !document3.getElementsByName || !document3.getElementsByName(expando).length; }); - } }; - a.c.text = { init: function() { - return { controlsDescendantBindings: true }; - }, update: function(b, c) { - a.a.Bb(b, c()); - } }; - a.h.ea.text = true; - (function() { - if (A && A.navigator) { - var b = function(a2) { - if (a2) - return parseFloat(a2[1]); - }, c = A.navigator.userAgent, d, e, f, g, h; - (d = A.opera && A.opera.version && parseInt(A.opera.version())) || (h = b(c.match(/Edge\/([^ ]+)$/))) || b(c.match(/Chrome\/([^ ]+)/)) || (e = b(c.match(/Version\/([^ ]+) Safari/))) || (f = b(c.match(/Firefox\/([^ ]+)/))) || (g = a.a.W || b(c.match(/MSIE ([^ ]+)/))) || (g = b(c.match(/rv:([^ )]+)/))); - } - if (8 <= g && 10 > g) - var m = a.a.g.Z(), k = a.a.g.Z(), l = function(b2) { - var c2 = this.activeElement; - (c2 = c2 && a.a.g.get(c2, k)) && c2(b2); - }, p = function(b2, c2) { - var d2 = b2.ownerDocument; - a.a.g.get(d2, m) || (a.a.g.set(d2, m, true), a.a.B(d2, "selectionchange", l)); - a.a.g.set(b2, k, c2); + if (support2.getById) { + Expr.filter["ID"] = function(id) { + var attrId = id.replace(runescape, funescape); + return function(elem) { + return elem.getAttribute("id") === attrId; + }; }; - a.c.textInput = { init: function(b2, c2, k2) { - function l2(c3, d2) { - a.a.B(b2, c3, d2); - } - function m2() { - var d2 = a.a.f(c2()); - if (null === d2 || d2 === n) - d2 = ""; - L !== n && d2 === L ? a.a.setTimeout(m2, 4) : b2.value !== d2 && (y = true, b2.value = d2, y = false, v2 = b2.value); - } - function r2() { - w3 || (L = b2.value, w3 = a.a.setTimeout( - z, - 4 - )); - } - function z() { - clearTimeout(w3); - L = w3 = n; - var d2 = b2.value; - v2 !== d2 && (v2 = d2, a.m.eb(c2(), k2, "textInput", d2)); - } - var v2 = b2.value, w3, L, A2 = 9 == a.a.W ? r2 : z, y = false; - g && l2("keypress", z); - 11 > g && l2("propertychange", function(a2) { - y || "value" !== a2.propertyName || A2(a2); - }); - 8 == g && (l2("keyup", z), l2("keydown", z)); - p && (p(b2, A2), l2("dragend", r2)); - (!g || 9 <= g) && l2("input", A2); - 5 > e && "textarea" === a.a.R(b2) ? (l2("keydown", r2), l2("paste", r2), l2("cut", r2)) : 11 > d ? l2("keydown", r2) : 4 > f ? (l2("DOMAutoComplete", z), l2("dragdrop", z), l2("drop", z)) : h && "number" === b2.type && l2("keydown", r2); - l2( - "change", - z - ); - l2("blur", z); - a.o(m2, null, { l: b2 }); - } }; - a.m.wa.textInput = true; - a.c.textinput = { preprocess: function(a2, b2, c2) { - c2("textInput", a2); - } }; - })(); - a.c.uniqueName = { init: function(b, c) { - if (c()) { - var d = "ko_unique_" + ++a.c.uniqueName.rd; - a.a.Yc(b, d); - } - } }; - a.c.uniqueName.rd = 0; - a.c.using = { init: function(b, c, d, e, f) { - var g; - d.has("as") && (g = { as: d.get("as"), noChildContext: d.get("noChildContext") }); - c = f.createChildContext(c, g); - a.Oa(c, b); - return { controlsDescendantBindings: true }; - } }; - a.h.ea.using = true; - a.c.value = { init: function(b, c, d) { - var e = a.a.R(b), f = "input" == e; - if (!f || "checkbox" != b.type && "radio" != b.type) { - var g = [], h = d.get("valueUpdate"), m = false, k = null; - h && ("string" == typeof h ? g = [h] : g = a.a.wc(h), a.a.Pa(g, "change")); - var l = function() { - k = null; - m = false; - var e2 = c(), f2 = a.w.M(b); - a.m.eb(e2, d, "value", f2); + Expr.find["ID"] = function(id, context2) { + if (typeof context2.getElementById !== "undefined" && documentIsHTML) { + var elem = context2.getElementById(id); + return elem ? [elem] : []; + } }; - !a.a.W || !f || "text" != b.type || "off" == b.autocomplete || b.form && "off" == b.form.autocomplete || -1 != a.a.A(g, "propertychange") || (a.a.B(b, "propertychange", function() { - m = true; - }), a.a.B(b, "focus", function() { - m = false; - }), a.a.B(b, "blur", function() { - m && l(); - })); - a.a.D(g, function(c2) { - var d2 = l; - a.a.Ud(c2, "after") && (d2 = function() { - k = a.w.M(b); - a.a.setTimeout(l, 0); - }, c2 = c2.substring(5)); - a.a.B(b, c2, d2); - }); - var p; - p = f && "file" == b.type ? function() { - var d2 = a.a.f(c()); - null === d2 || d2 === n || "" === d2 ? b.value = "" : a.u.G(l); - } : function() { - var f2 = a.a.f(c()), g2 = a.w.M(b); - if (null !== k && f2 === k) - a.a.setTimeout(p, 0); - else if (f2 !== g2 || g2 === n) - "select" === e ? (g2 = d.get("valueAllowUnset"), a.w.cb(b, f2, g2), g2 || f2 === a.w.M(b) || a.u.G(l)) : a.w.cb(b, f2); + } else { + Expr.filter["ID"] = function(id) { + var attrId = id.replace(runescape, funescape); + return function(elem) { + var node2 = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); + return node2 && node2.value === attrId; + }; }; - if ("select" === e) { - var q; - a.i.subscribe( - b, - a.i.H, - function() { - q ? d.get("valueAllowUnset") ? p() : l() : (a.a.B(b, "change", l), q = a.o(p, null, { l: b })); - }, - null, - { notifyImmediately: true } - ); - } else - a.a.B(b, "change", l), a.o(p, null, { l: b }); - } else - a.ib(b, { checkedValue: c }); - }, update: function() { - } }; - a.m.wa.value = true; - a.c.visible = { update: function(b, c) { - var d = a.a.f(c()), e = "none" != b.style.display; - d && !e ? b.style.display = "" : !d && e && (b.style.display = "none"); - } }; - a.c.hidden = { update: function(b, c) { - a.c.visible.update(b, function() { - return !a.a.f(c()); - }); - } }; - (function(b) { - a.c[b] = { init: function(c, d, e, f, g) { - return a.c.event.init.call(this, c, function() { - var a2 = {}; - a2[b] = d(); - return a2; - }, e, f, g); - } }; - })("click"); - a.ca = function() { - }; - a.ca.prototype.renderTemplateSource = function() { - throw Error("Override renderTemplateSource"); - }; - a.ca.prototype.createJavaScriptEvaluatorBlock = function() { - throw Error("Override createJavaScriptEvaluatorBlock"); - }; - a.ca.prototype.makeTemplateSource = function(b, c) { - if ("string" == typeof b) { - c = c || w2; - var d = c.getElementById(b); - if (!d) - throw Error("Cannot find template with ID " + b); - return new a.C.F(d); - } - if (1 == b.nodeType || 8 == b.nodeType) - return new a.C.ia(b); - throw Error("Unknown template type: " + b); - }; - a.ca.prototype.renderTemplate = function(a2, c, d, e) { - a2 = this.makeTemplateSource(a2, e); - return this.renderTemplateSource(a2, c, d, e); - }; - a.ca.prototype.isTemplateRewritten = function(a2, c) { - return false === this.allowTemplateRewriting ? true : this.makeTemplateSource(a2, c).data("isRewritten"); - }; - a.ca.prototype.rewriteTemplate = function(a2, c, d) { - a2 = this.makeTemplateSource(a2, d); - c = c(a2.text()); - a2.text(c); - a2.data("isRewritten", true); - }; - a.b("templateEngine", a.ca); - a.kc = function() { - function b(b2, c2, d2, h) { - b2 = a.m.ac(b2); - for (var m = a.m.Ra, k = 0; k < b2.length; k++) { - var l = b2[k].key; - if (Object.prototype.hasOwnProperty.call( - m, - l - )) { - var p = m[l]; - if ("function" === typeof p) { - if (l = p(b2[k].value)) - throw Error(l); - } else if (!p) - throw Error("This template engine does not support the '" + l + "' binding within its templates"); + Expr.find["ID"] = function(id, context2) { + if (typeof context2.getElementById !== "undefined" && documentIsHTML) { + var node2, i2, elems, elem = context2.getElementById(id); + if (elem) { + node2 = elem.getAttributeNode("id"); + if (node2 && node2.value === id) { + return [elem]; + } + elems = context2.getElementsByName(id); + i2 = 0; + while (elem = elems[i2++]) { + node2 = elem.getAttributeNode("id"); + if (node2 && node2.value === id) { + return [elem]; + } + } + } + return []; } + }; + } + Expr.find["TAG"] = support2.getElementsByTagName ? function(tag, context2) { + if (typeof context2.getElementsByTagName !== "undefined") { + return context2.getElementsByTagName(tag); + } else if (support2.qsa) { + return context2.querySelectorAll(tag); } - d2 = "ko.__tr_ambtns(function($context,$element){return(function(){return{ " + a.m.vb(b2, { valueAccessors: true }) + " } })()},'" + d2.toLowerCase() + "')"; - return h.createJavaScriptEvaluatorBlock(d2) + c2; - } - var c = /(<([a-z]+\d*)(?:\s+(?!data-bind\s*=\s*)[a-z0-9\-]+(?:=(?:\"[^\"]*\"|\'[^\']*\'|[^>]*))?)*\s+)data-bind\s*=\s*(["'])([\s\S]*?)\3/gi, d = /\x3c!--\s*ko\b\s*([\s\S]*?)\s*--\x3e/g; - return { xd: function(b2, c2, d2) { - c2.isTemplateRewritten(b2, d2) || c2.rewriteTemplate(b2, function(b3) { - return a.kc.Ld(b3, c2); - }, d2); - }, Ld: function(a2, f) { - return a2.replace(c, function(a3, c2, d2, e, l) { - return b(l, c2, d2, f); - }).replace(d, function(a3, c2) { - return b(c2, "", "#comment", f); - }); - }, md: function(b2, c2) { - return a.aa.Xb(function(d2, h) { - var m = d2.nextSibling; - m && m.nodeName.toLowerCase() === c2 && a.ib(m, b2, h); - }); - } }; - }(); - a.b("__tr_ambtns", a.kc.md); - (function() { - a.C = {}; - a.C.F = function(b2) { - if (this.F = b2) { - var c2 = a.a.R(b2); - this.ab = "script" === c2 ? 1 : "textarea" === c2 ? 2 : "template" == c2 && b2.content && 11 === b2.content.nodeType ? 3 : 4; - } - }; - a.C.F.prototype.text = function() { - var b2 = 1 === this.ab ? "text" : 2 === this.ab ? "value" : "innerHTML"; - if (0 == arguments.length) - return this.F[b2]; - var c2 = arguments[0]; - "innerHTML" === b2 ? a.a.fc(this.F, c2) : this.F[b2] = c2; - }; - var b = a.a.g.Z() + "_"; - a.C.F.prototype.data = function(c2) { - if (1 === arguments.length) - return a.a.g.get(this.F, b + c2); - a.a.g.set(this.F, b + c2, arguments[1]); - }; - var c = a.a.g.Z(); - a.C.F.prototype.nodes = function() { - var b2 = this.F; - if (0 == arguments.length) { - var e = a.a.g.get(b2, c) || {}, f = e.lb || (3 === this.ab ? b2.content : 4 === this.ab ? b2 : n); - if (!f || e.jd) { - var g = this.text(); - g && g !== e.bb && (f = a.a.Md(g, b2.ownerDocument), a.a.g.set(b2, c, { lb: f, bb: g, jd: true })); + } : function(tag, context2) { + var elem, tmp = [], i2 = 0, results = context2.getElementsByTagName(tag); + if (tag === "*") { + while (elem = results[i2++]) { + if (elem.nodeType === 1) { + tmp.push(elem); + } } - return f; + return tmp; } - e = arguments[0]; - this.ab !== n && this.text(""); - a.a.g.set(b2, c, { lb: e }); - }; - a.C.ia = function(a2) { - this.F = a2; + return results; }; - a.C.ia.prototype = new a.C.F(); - a.C.ia.prototype.constructor = a.C.ia; - a.C.ia.prototype.text = function() { - if (0 == arguments.length) { - var b2 = a.a.g.get(this.F, c) || {}; - b2.bb === n && b2.lb && (b2.bb = b2.lb.innerHTML); - return b2.bb; - } - a.a.g.set( - this.F, - c, - { bb: arguments[0] } - ); + Expr.find["CLASS"] = support2.getElementsByClassName && function(className, context2) { + if (typeof context2.getElementsByClassName !== "undefined" && documentIsHTML) { + return context2.getElementsByClassName(className); + } }; - a.b("templateSources", a.C); - a.b("templateSources.domElement", a.C.F); - a.b("templateSources.anonymousTemplate", a.C.ia); - })(); - (function() { - function b(b2, c2, d2) { - var e2; - for (c2 = a.h.nextSibling(c2); b2 && (e2 = b2) !== c2; ) - b2 = a.h.nextSibling(e2), d2(e2, b2); - } - function c(c2, d2) { - if (c2.length) { - var e2 = c2[0], f2 = c2[c2.length - 1], g2 = e2.parentNode, h2 = a.ga.instance, m2 = h2.preprocessNode; - if (m2) { - b(e2, f2, function(a2, b2) { - var c3 = a2.previousSibling, d3 = m2.call(h2, a2); - d3 && (a2 === e2 && (e2 = d3[0] || b2), a2 === f2 && (f2 = d3[d3.length - 1] || c3)); - }); - c2.length = 0; - if (!e2) - return; - e2 === f2 ? c2.push(e2) : (c2.push(e2, f2), a.a.Ua(c2, g2)); + rbuggyMatches = []; + rbuggyQSA = []; + if (support2.qsa = rnative.test(document3.querySelectorAll)) { + assert(function(el) { + var input; + docElem.appendChild(el).innerHTML = ""; + if (el.querySelectorAll("[msallowcapture^='']").length) { + rbuggyQSA.push("[*^$]=" + whitespace + `*(?:''|"")`); } - b(e2, f2, function(b2) { - 1 !== b2.nodeType && 8 !== b2.nodeType || a.vc(d2, b2); - }); - b(e2, f2, function(b2) { - 1 !== b2.nodeType && 8 !== b2.nodeType || a.aa.cd(b2, [d2]); - }); - a.a.Ua(c2, g2); - } - } - function d(a2) { - return a2.nodeType ? a2 : 0 < a2.length ? a2[0] : null; - } - function e(b2, e2, f2, h2, m2) { - m2 = m2 || {}; - var n2 = (b2 && d(b2) || f2 || {}).ownerDocument, B = m2.templateEngine || g; - a.kc.xd(f2, B, n2); - f2 = B.renderTemplate(f2, h2, m2, n2); - if ("number" != typeof f2.length || 0 < f2.length && "number" != typeof f2[0].nodeType) - throw Error("Template engine must return an array of DOM nodes"); - n2 = false; - switch (e2) { - case "replaceChildren": - a.h.va( - b2, - f2 - ); - n2 = true; - break; - case "replaceNode": - a.a.Xc(b2, f2); - n2 = true; - break; - case "ignoreTargetNode": - break; - default: - throw Error("Unknown renderMode: " + e2); - } - n2 && (c(f2, h2), m2.afterRender && a.u.G(m2.afterRender, null, [f2, h2[m2.as || "$data"]]), "replaceChildren" == e2 && a.i.ma(b2, a.i.H)); - return f2; - } - function f(b2, c2, d2) { - return a.O(b2) ? b2() : "function" === typeof b2 ? b2(c2, d2) : b2; + if (!el.querySelectorAll("[selected]").length) { + rbuggyQSA.push("\\[" + whitespace + "*(?:value|" + booleans + ")"); + } + if (!el.querySelectorAll("[id~=" + expando + "-]").length) { + rbuggyQSA.push("~="); + } + input = document3.createElement("input"); + input.setAttribute("name", ""); + el.appendChild(input); + if (!el.querySelectorAll("[name='']").length) { + rbuggyQSA.push("\\[" + whitespace + "*name" + whitespace + "*=" + whitespace + `*(?:''|"")`); + } + if (!el.querySelectorAll(":checked").length) { + rbuggyQSA.push(":checked"); + } + if (!el.querySelectorAll("a#" + expando + "+*").length) { + rbuggyQSA.push(".#.+[+~]"); + } + el.querySelectorAll("\\\f"); + rbuggyQSA.push("[\\r\\n\\f]"); + }); + assert(function(el) { + el.innerHTML = ""; + var input = document3.createElement("input"); + input.setAttribute("type", "hidden"); + el.appendChild(input).setAttribute("name", "D"); + if (el.querySelectorAll("[name=d]").length) { + rbuggyQSA.push("name" + whitespace + "*[*^$|!~]?="); + } + if (el.querySelectorAll(":enabled").length !== 2) { + rbuggyQSA.push(":enabled", ":disabled"); + } + docElem.appendChild(el).disabled = true; + if (el.querySelectorAll(":disabled").length !== 2) { + rbuggyQSA.push(":enabled", ":disabled"); + } + el.querySelectorAll("*,:x"); + rbuggyQSA.push(",.*:"); + }); } - var g; - a.gc = function(b2) { - if (b2 != n && !(b2 instanceof a.ca)) - throw Error("templateEngine must inherit from ko.templateEngine"); - g = b2; - }; - a.dc = function(b2, c2, h2, m2, t) { - h2 = h2 || {}; - if ((h2.templateEngine || g) == n) - throw Error("Set a template engine before calling renderTemplate"); - t = t || "replaceChildren"; - if (m2) { - var x = d(m2); - return a.$(function() { - var g2 = c2 && c2 instanceof a.fa ? c2 : new a.fa(c2, null, null, null, { exportDependencies: true }), n2 = f(b2, g2.$data, g2), g2 = e(m2, t, n2, g2, h2); - "replaceNode" == t && (m2 = g2, x = d(m2)); - }, null, { Sa: function() { - return !x || !a.a.Sb(x); - }, l: x && "replaceNode" == t ? x.parentNode : x }); - } - return a.aa.Xb(function(d2) { - a.dc(b2, c2, h2, d2, "replaceNode"); + if (support2.matchesSelector = rnative.test(matches = docElem.matches || docElem.webkitMatchesSelector || docElem.mozMatchesSelector || docElem.oMatchesSelector || docElem.msMatchesSelector)) { + assert(function(el) { + support2.disconnectedMatch = matches.call(el, "*"); + matches.call(el, "[s!='']:x"); + rbuggyMatches.push("!=", pseudos); }); - }; - a.Qd = function(b2, d2, g2, h2, m2) { - function x(b3, c2) { - a.u.G(a.a.ec, null, [h2, b3, u, g2, r2, c2]); - a.i.ma(h2, a.i.H); - } - function r2(a2, b3) { - c(b3, v2); - g2.afterRender && g2.afterRender(b3, a2); - v2 = null; - } - function u(a2, c2) { - v2 = m2.createChildContext(a2, { as: z, noChildContext: g2.noChildContext, extend: function(a3) { - a3.$index = c2; - z && (a3[z + "Index"] = c2); - } }); - var d3 = f(b2, a2, v2); - return e(h2, "ignoreTargetNode", d3, v2, g2); - } - var v2, z = g2.as, w3 = false === g2.includeDestroyed || a.options.foreachHidesDestroyed && !g2.includeDestroyed; - if (w3 || g2.beforeRemove || !a.Pc(d2)) - return a.$(function() { - var b3 = a.a.f(d2) || []; - "undefined" == typeof b3.length && (b3 = [b3]); - w3 && (b3 = a.a.jb(b3, function(b4) { - return b4 === n || null === b4 || !a.a.f(b4._destroy); - })); - x(b3); - }, null, { l: h2 }); - x(d2.v()); - var A2 = d2.subscribe(function(a2) { - x(d2(), a2); - }, null, "arrayChange"); - A2.l(h2); - return A2; - }; - var h = a.a.g.Z(), m = a.a.g.Z(); - a.c.template = { init: function(b2, c2) { - var d2 = a.a.f(c2()); - if ("string" == typeof d2 || "name" in d2) - a.h.Ea(b2); - else if ("nodes" in d2) { - d2 = d2.nodes || []; - if (a.O(d2)) - throw Error('The "nodes" option must be a plain, non-observable array.'); - var e2 = d2[0] && d2[0].parentNode; - e2 && a.a.g.get(e2, m) || (e2 = a.a.Yb(d2), a.a.g.set(e2, m, true)); - new a.C.ia(b2).nodes(e2); - } else if (d2 = a.h.childNodes(b2), 0 < d2.length) - e2 = a.a.Yb(d2), new a.C.ia(b2).nodes(e2); - else - throw Error("Anonymous template defined, but no template content was provided"); - return { controlsDescendantBindings: true }; - }, update: function(b2, c2, d2, e2, f2) { - var g2 = c2(); - c2 = a.a.f(g2); - d2 = true; - e2 = null; - "string" == typeof c2 ? c2 = {} : (g2 = "name" in c2 ? c2.name : b2, "if" in c2 && (d2 = a.a.f(c2["if"])), d2 && "ifnot" in c2 && (d2 = !a.a.f(c2.ifnot)), d2 && !g2 && (d2 = false)); - "foreach" in c2 ? e2 = a.Qd(g2, d2 && c2.foreach || [], c2, b2, f2) : d2 ? (d2 = f2, "data" in c2 && (d2 = f2.createChildContext(c2.data, { as: c2.as, noChildContext: c2.noChildContext, exportDependencies: true })), e2 = a.dc(g2, d2, c2, b2)) : a.h.Ea(b2); - f2 = e2; - (c2 = a.a.g.get(b2, h)) && "function" == typeof c2.s && c2.s(); - a.a.g.set(b2, h, !f2 || f2.ja && !f2.ja() ? n : f2); - } }; - a.m.Ra.template = function(b2) { - b2 = a.m.ac(b2); - return 1 == b2.length && b2[0].unknown || a.m.Id(b2, "name") ? null : "This template engine does not support anonymous templates nested within its templates"; - }; - a.h.ea.template = true; - })(); - a.b("setTemplateEngine", a.gc); - a.b("renderTemplate", a.dc); - a.a.Kc = function(a2, c, d) { - if (a2.length && c.length) { - var e, f, g, h, m; - for (e = f = 0; (!d || e < d) && (h = a2[f]); ++f) { - for (g = 0; m = c[g]; ++g) - if (h.value === m.value) { - h.moved = m.index; - m.moved = h.index; - c.splice(g, 1); - e = g = 0; - break; + } + rbuggyQSA = rbuggyQSA.length && new RegExp(rbuggyQSA.join("|")); + rbuggyMatches = rbuggyMatches.length && new RegExp(rbuggyMatches.join("|")); + hasCompare = rnative.test(docElem.compareDocumentPosition); + contains = hasCompare || rnative.test(docElem.contains) ? function(a, b) { + var adown = a.nodeType === 9 ? a.documentElement : a, bup = b && b.parentNode; + return a === bup || !!(bup && bup.nodeType === 1 && (adown.contains ? adown.contains(bup) : a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16)); + } : function(a, b) { + if (b) { + while (b = b.parentNode) { + if (b === a) { + return true; } - e += g; + } } - } - }; - a.a.Pb = function() { - function b(b2, d, e, f, g) { - var h = Math.min, m = Math.max, k = [], l, p = b2.length, q, n2 = d.length, r2 = n2 - p || 1, v2 = p + n2 + 1, u, w3, z; - for (l = 0; l <= p; l++) - for (w3 = u, k.push(u = []), z = h(n2, l + r2), q = m(0, l - 1); q <= z; q++) - u[q] = q ? l ? b2[l - 1] === d[q - 1] ? w3[q - 1] : h(w3[q] || v2, u[q - 1] || v2) + 1 : q + 1 : l + 1; - h = []; - m = []; - r2 = []; - l = p; - for (q = n2; l || q; ) - n2 = k[l][q] - 1, q && n2 === k[l][q - 1] ? m.push(h[h.length] = { status: e, value: d[--q], index: q }) : l && n2 === k[l - 1][q] ? r2.push(h[h.length] = { status: f, value: b2[--l], index: l }) : (--q, --l, g.sparse || h.push({ status: "retained", value: d[q] })); - a.a.Kc(r2, m, !g.dontLimitMoves && 10 * p); - return h.reverse(); - } - return function(a2, d, e) { - e = "boolean" === typeof e ? { dontLimitMoves: e } : e || {}; - a2 = a2 || []; - d = d || []; - return a2.length < d.length ? b(a2, d, "added", "deleted", e) : b(d, a2, "deleted", "added", e); + return false; }; - }(); - a.b("utils.compareArrays", a.a.Pb); - (function() { - function b(b2, c2, d2, h, m) { - var k = [], l = a.$(function() { - var l2 = c2(d2, m, a.a.Ua(k, b2)) || []; - 0 < k.length && (a.a.Xc(k, l2), h && a.u.G(h, null, [d2, l2, m])); - k.length = 0; - a.a.Nb(k, l2); - }, null, { l: b2, Sa: function() { - return !a.a.kd(k); - } }); - return { Y: k, $: l.ja() ? l : n }; - } - var c = a.a.g.Z(), d = a.a.g.Z(); - a.a.ec = function(e, f, g, h, m, k) { - function l(b2) { - y = { Aa: b2, pb: a.ta(w3++) }; - v2.push(y); - r2 || F2.push(y); - } - function p(b2) { - y = t[b2]; - w3 !== y.pb.v() && D2.push(y); - y.pb(w3++); - a.a.Ua(y.Y, e); - v2.push(y); - } - function q(b2, c2) { - if (b2) - for (var d2 = 0, e2 = c2.length; d2 < e2; d2++) - a.a.D(c2[d2].Y, function(a2) { - b2(a2, d2, c2[d2].Aa); - }); + sortOrder = hasCompare ? function(a, b) { + if (a === b) { + hasDuplicate = true; + return 0; } - f = f || []; - "undefined" == typeof f.length && (f = [f]); - h = h || {}; - var t = a.a.g.get(e, c), r2 = !t, v2 = [], u = 0, w3 = 0, z = [], A2 = [], C2 = [], D2 = [], F2 = [], y, I2 = 0; - if (r2) - a.a.D(f, l); - else { - if (!k || t && t._countWaitingForRemove) { - var E = a.a.Mb(t, function(a2) { - return a2.Aa; - }); - k = a.a.Pb(E, f, { dontLimitMoves: h.dontLimitMoves, sparse: true }); - } - for (var E = 0, G2, H2, K2; G2 = k[E]; E++) - switch (H2 = G2.moved, K2 = G2.index, G2.status) { - case "deleted": - for (; u < K2; ) - p(u++); - H2 === n && (y = t[u], y.$ && (y.$.s(), y.$ = n), a.a.Ua(y.Y, e).length && (h.beforeRemove && (v2.push(y), I2++, y.Aa === d ? y = null : C2.push(y)), y && z.push.apply(z, y.Y))); - u++; - break; - case "added": - for (; w3 < K2; ) - p(u++); - H2 !== n ? (A2.push(v2.length), p(H2)) : l(G2.value); - } - for (; w3 < f.length; ) - p(u++); - v2._countWaitingForRemove = I2; - } - a.a.g.set(e, c, v2); - q(h.beforeMove, D2); - a.a.D( - z, - h.beforeRemove ? a.oa : a.removeNode + var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; + if (compare) { + return compare; + } + compare = (a.ownerDocument || a) == (b.ownerDocument || b) ? a.compareDocumentPosition(b) : ( + // Otherwise we know they are disconnected + 1 ); - var M, O, P; - try { - P = e.ownerDocument.activeElement; - } catch (N2) { - } - if (A2.length) - for (; (E = A2.shift()) != n; ) { - y = v2[E]; - for (M = n; E; ) - if ((O = v2[--E].Y) && O.length) { - M = O[O.length - 1]; - break; - } - for (f = 0; u = y.Y[f]; M = u, f++) - a.h.Wb(e, u, M); + if (compare & 1 || !support2.sortDetached && b.compareDocumentPosition(a) === compare) { + if (a == document3 || a.ownerDocument == preferredDoc && contains(preferredDoc, a)) { + return -1; + } + if (b == document3 || b.ownerDocument == preferredDoc && contains(preferredDoc, b)) { + return 1; } - for (E = 0; y = v2[E]; E++) { - y.Y || a.a.extend(y, b(e, g, y.Aa, m, y.pb)); - for (f = 0; u = y.Y[f]; M = u, f++) - a.h.Wb(e, u, M); - !y.Ed && m && (m(y.Aa, y.Y, y.pb), y.Ed = true, M = y.Y[y.Y.length - 1]); - } - P && e.ownerDocument.activeElement != P && P.focus(); - q(h.beforeRemove, C2); - for (E = 0; E < C2.length; ++E) - C2[E].Aa = d; - q(h.afterMove, D2); - q(h.afterAdd, F2); + return sortInput ? indexOf2(sortInput, a) - indexOf2(sortInput, b) : 0; + } + return compare & 4 ? -1 : 1; + } : function(a, b) { + if (a === b) { + hasDuplicate = true; + return 0; + } + var cur, i2 = 0, aup = a.parentNode, bup = b.parentNode, ap = [a], bp = [b]; + if (!aup || !bup) { + return a == document3 ? -1 : b == document3 ? 1 : ( + /* eslint-enable eqeqeq */ + aup ? -1 : bup ? 1 : sortInput ? indexOf2(sortInput, a) - indexOf2(sortInput, b) : 0 + ); + } else if (aup === bup) { + return siblingCheck(a, b); + } + cur = a; + while (cur = cur.parentNode) { + ap.unshift(cur); + } + cur = b; + while (cur = cur.parentNode) { + bp.unshift(cur); + } + while (ap[i2] === bp[i2]) { + i2++; + } + return i2 ? ( + // Do a sibling check if the nodes have a common ancestor + siblingCheck(ap[i2], bp[i2]) + ) : ( + // Otherwise nodes in our document sort first + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + /* eslint-disable eqeqeq */ + ap[i2] == preferredDoc ? -1 : bp[i2] == preferredDoc ? 1 : ( + /* eslint-enable eqeqeq */ + 0 + ) + ); }; - })(); - a.b("utils.setDomNodeChildrenFromArrayMapping", a.a.ec); - a.ba = function() { - this.allowTemplateRewriting = false; + return document3; }; - a.ba.prototype = new a.ca(); - a.ba.prototype.constructor = a.ba; - a.ba.prototype.renderTemplateSource = function(b, c, d, e) { - if (c = (9 > a.a.W ? 0 : b.nodes) ? b.nodes() : null) - return a.a.la(c.cloneNode(true).childNodes); - b = b.text(); - return a.a.ua(b, e); + Sizzle2.matches = function(expr, elements) { + return Sizzle2(expr, null, null, elements); }; - a.ba.Ma = new a.ba(); - a.gc(a.ba.Ma); - a.b("nativeTemplateEngine", a.ba); - (function() { - a.$a = function() { - var a2 = this.Hd = function() { - if (!v || !v.tmpl) - return 0; - try { - if (0 <= v.tmpl.tag.tmpl.open.toString().indexOf("__")) - return 2; - } catch (a3) { - } - return 1; - }(); - this.renderTemplateSource = function(b2, e, f, g) { - g = g || w2; - f = f || {}; - if (2 > a2) - throw Error("Your version of jQuery.tmpl is too old. Please upgrade to jQuery.tmpl 1.0.0pre or later."); - var h = b2.data("precompiled"); - h || (h = b2.text() || "", h = v.template(null, "{{ko_with $item.koBindingContext}}" + h + "{{/ko_with}}"), b2.data("precompiled", h)); - b2 = [e.$data]; - e = v.extend({ koBindingContext: e }, f.templateOptions); - e = v.tmpl(h, b2, e); - e.appendTo(g.createElement("div")); - v.fragments = {}; - return e; - }; - this.createJavaScriptEvaluatorBlock = function(a3) { - return "{{ko_code ((function() { return " + a3 + " })()) }}"; - }; - this.addTemplate = function(a3, b2) { - w2.write(" diff --git a/main.js b/main.js index 8de3364..3a244af 100644 --- a/main.js +++ b/main.js @@ -3741,9 +3741,9 @@ var require_jquery = __commonJS({ if (!div) { return; } - container.style.cssText = "position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0"; + container2.style.cssText = "position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0"; div.style.cssText = "position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%"; - documentElement.appendChild(container).appendChild(div); + documentElement.appendChild(container2).appendChild(div); var divStyle = window2.getComputedStyle(div); pixelPositionVal = divStyle.top !== "1%"; reliableMarginLeftVal = roundPixelMeasures(divStyle.marginLeft) === 12; @@ -3752,13 +3752,13 @@ var require_jquery = __commonJS({ boxSizingReliableVal = roundPixelMeasures(divStyle.width) === 36; div.style.position = "absolute"; scrollboxSizeVal = roundPixelMeasures(div.offsetWidth / 3) === 12; - documentElement.removeChild(container); + documentElement.removeChild(container2); div = null; } function roundPixelMeasures(measure) { return Math.round(parseFloat(measure)); } - var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal, reliableTrDimensionsVal, reliableMarginLeftVal, container = document2.createElement("div"), div = document2.createElement("div"); + var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal, reliableTrDimensionsVal, reliableMarginLeftVal, container2 = document2.createElement("div"), div = document2.createElement("div"); if (!div.style) { return; } @@ -6896,9 +6896,6 @@ var require_jquery_knob_min = __commonJS({ } }); -// main.ts -var import_jquery = __toESM(require_jquery(), 1); - // node_modules/tslib/tslib.es6.mjs var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { @@ -7748,6 +7745,43 @@ var OperatorSubscriber = function(_super) { return OperatorSubscriber2; }(Subscriber); +// node_modules/rxjs/dist/esm5/internal/scheduler/animationFrameProvider.js +var animationFrameProvider = { + schedule: function(callback) { + var request = requestAnimationFrame; + var cancel = cancelAnimationFrame; + var delegate = animationFrameProvider.delegate; + if (delegate) { + request = delegate.requestAnimationFrame; + cancel = delegate.cancelAnimationFrame; + } + var handle = request(function(timestamp) { + cancel = void 0; + callback(timestamp); + }); + return new Subscription(function() { + return cancel === null || cancel === void 0 ? void 0 : cancel(handle); + }); + }, + requestAnimationFrame: function() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var delegate = animationFrameProvider.delegate; + return ((delegate === null || delegate === void 0 ? void 0 : delegate.requestAnimationFrame) || requestAnimationFrame).apply(void 0, __spreadArray([], __read(args))); + }, + cancelAnimationFrame: function() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var delegate = animationFrameProvider.delegate; + return ((delegate === null || delegate === void 0 ? void 0 : delegate.cancelAnimationFrame) || cancelAnimationFrame).apply(void 0, __spreadArray([], __read(args))); + }, + delegate: void 0 +}; + // node_modules/rxjs/dist/esm5/internal/util/ObjectUnsubscribedError.js var ObjectUnsubscribedError = createErrorClass(function(_super) { return function ObjectUnsubscribedErrorImpl() { @@ -8023,9 +8057,9 @@ var Action = function(_super) { function Action2(scheduler, work) { return _super.call(this) || this; } - Action2.prototype.schedule = function(state, delay) { - if (delay === void 0) { - delay = 0; + Action2.prototype.schedule = function(state, delay2) { + if (delay2 === void 0) { + delay2 = 0; } return this; }; @@ -8062,10 +8096,10 @@ var AsyncAction = function(_super) { _this.pending = false; return _this; } - AsyncAction2.prototype.schedule = function(state, delay) { + AsyncAction2.prototype.schedule = function(state, delay2) { var _a; - if (delay === void 0) { - delay = 0; + if (delay2 === void 0) { + delay2 = 0; } if (this.closed) { return this; @@ -8074,24 +8108,24 @@ var AsyncAction = function(_super) { var id = this.id; var scheduler = this.scheduler; if (id != null) { - this.id = this.recycleAsyncId(scheduler, id, delay); + this.id = this.recycleAsyncId(scheduler, id, delay2); } this.pending = true; - this.delay = delay; - this.id = (_a = this.id) !== null && _a !== void 0 ? _a : this.requestAsyncId(scheduler, this.id, delay); + this.delay = delay2; + this.id = (_a = this.id) !== null && _a !== void 0 ? _a : this.requestAsyncId(scheduler, this.id, delay2); return this; }; - AsyncAction2.prototype.requestAsyncId = function(scheduler, _id, delay) { - if (delay === void 0) { - delay = 0; + AsyncAction2.prototype.requestAsyncId = function(scheduler, _id, delay2) { + if (delay2 === void 0) { + delay2 = 0; } - return intervalProvider.setInterval(scheduler.flush.bind(scheduler, this), delay); + return intervalProvider.setInterval(scheduler.flush.bind(scheduler, this), delay2); }; - AsyncAction2.prototype.recycleAsyncId = function(_scheduler, id, delay) { - if (delay === void 0) { - delay = 0; + AsyncAction2.prototype.recycleAsyncId = function(_scheduler, id, delay2) { + if (delay2 === void 0) { + delay2 = 0; } - if (delay != null && this.delay === delay && this.pending === false) { + if (delay2 != null && this.delay === delay2 && this.pending === false) { return id; } if (id != null) { @@ -8099,12 +8133,12 @@ var AsyncAction = function(_super) { } return void 0; }; - AsyncAction2.prototype.execute = function(state, delay) { + AsyncAction2.prototype.execute = function(state, delay2) { if (this.closed) { return new Error("executing a cancelled action"); } this.pending = false; - var error = this._execute(state, delay); + var error = this._execute(state, delay2); if (error) { return error; } else if (this.pending === false && this.id != null) { @@ -8151,11 +8185,11 @@ var Scheduler = function() { this.schedulerActionCtor = schedulerActionCtor; this.now = now; } - Scheduler2.prototype.schedule = function(work, delay, state) { - if (delay === void 0) { - delay = 0; + Scheduler2.prototype.schedule = function(work, delay2, state) { + if (delay2 === void 0) { + delay2 = 0; } - return new this.schedulerActionCtor(this, work).schedule(state, delay); + return new this.schedulerActionCtor(this, work).schedule(state, delay2); }; Scheduler2.now = dateTimestampProvider.now; return Scheduler2; @@ -8201,6 +8235,82 @@ var AsyncScheduler = function(_super) { var asyncScheduler = new AsyncScheduler(AsyncAction); var async = asyncScheduler; +// node_modules/rxjs/dist/esm5/internal/scheduler/AnimationFrameAction.js +var AnimationFrameAction = function(_super) { + __extends(AnimationFrameAction2, _super); + function AnimationFrameAction2(scheduler, work) { + var _this = _super.call(this, scheduler, work) || this; + _this.scheduler = scheduler; + _this.work = work; + return _this; + } + AnimationFrameAction2.prototype.requestAsyncId = function(scheduler, id, delay2) { + if (delay2 === void 0) { + delay2 = 0; + } + if (delay2 !== null && delay2 > 0) { + return _super.prototype.requestAsyncId.call(this, scheduler, id, delay2); + } + scheduler.actions.push(this); + return scheduler._scheduled || (scheduler._scheduled = animationFrameProvider.requestAnimationFrame(function() { + return scheduler.flush(void 0); + })); + }; + AnimationFrameAction2.prototype.recycleAsyncId = function(scheduler, id, delay2) { + var _a; + if (delay2 === void 0) { + delay2 = 0; + } + if (delay2 != null ? delay2 > 0 : this.delay > 0) { + return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay2); + } + var actions = scheduler.actions; + if (id != null && ((_a = actions[actions.length - 1]) === null || _a === void 0 ? void 0 : _a.id) !== id) { + animationFrameProvider.cancelAnimationFrame(id); + scheduler._scheduled = void 0; + } + return void 0; + }; + return AnimationFrameAction2; +}(AsyncAction); + +// node_modules/rxjs/dist/esm5/internal/scheduler/AnimationFrameScheduler.js +var AnimationFrameScheduler = function(_super) { + __extends(AnimationFrameScheduler2, _super); + function AnimationFrameScheduler2() { + return _super !== null && _super.apply(this, arguments) || this; + } + AnimationFrameScheduler2.prototype.flush = function(action) { + this._active = true; + var flushId = this._scheduled; + this._scheduled = void 0; + var actions = this.actions; + var error; + action = action || actions.shift(); + do { + if (error = action.execute(action.state, action.delay)) { + break; + } + } while ((action = actions[0]) && action.id === flushId && actions.shift()); + this._active = false; + if (error) { + while ((action = actions[0]) && action.id === flushId && actions.shift()) { + action.unsubscribe(); + } + throw error; + } + }; + return AnimationFrameScheduler2; +}(AsyncScheduler); + +// node_modules/rxjs/dist/esm5/internal/scheduler/animationFrame.js +var animationFrameScheduler = new AnimationFrameScheduler(AnimationFrameAction); + +// node_modules/rxjs/dist/esm5/internal/observable/empty.js +var EMPTY = new Observable(function(subscriber) { + return subscriber.complete(); +}); + // node_modules/rxjs/dist/esm5/internal/util/isScheduler.js function isScheduler(value) { return value && isFunction(value.schedule); @@ -8216,6 +8326,9 @@ function popResultSelector(args) { function popScheduler(args) { return isScheduler(last(args)) ? args.pop() : void 0; } +function popNumber(args, defaultValue) { + return typeof last(args) === "number" ? args.pop() : defaultValue; +} // node_modules/rxjs/dist/esm5/internal/util/isArrayLike.js var isArrayLike = function(x) { @@ -8447,9 +8560,9 @@ function process(asyncIterable, subscriber) { } // node_modules/rxjs/dist/esm5/internal/util/executeSchedule.js -function executeSchedule(parentSubscription, scheduler, work, delay, repeat) { - if (delay === void 0) { - delay = 0; +function executeSchedule(parentSubscription, scheduler, work, delay2, repeat) { + if (delay2 === void 0) { + delay2 = 0; } if (repeat === void 0) { repeat = false; @@ -8457,11 +8570,11 @@ function executeSchedule(parentSubscription, scheduler, work, delay, repeat) { var scheduleSubscription = scheduler.schedule(function() { work(); if (repeat) { - parentSubscription.add(this.schedule(null, delay)); + parentSubscription.add(this.schedule(null, delay2)); } else { this.unsubscribe(); } - }, delay); + }, delay2); parentSubscription.add(scheduleSubscription); if (!repeat) { return scheduleSubscription; @@ -8469,36 +8582,36 @@ function executeSchedule(parentSubscription, scheduler, work, delay, repeat) { } // node_modules/rxjs/dist/esm5/internal/operators/observeOn.js -function observeOn(scheduler, delay) { - if (delay === void 0) { - delay = 0; +function observeOn(scheduler, delay2) { + if (delay2 === void 0) { + delay2 = 0; } return operate(function(source, subscriber) { source.subscribe(createOperatorSubscriber(subscriber, function(value) { return executeSchedule(subscriber, scheduler, function() { return subscriber.next(value); - }, delay); + }, delay2); }, function() { return executeSchedule(subscriber, scheduler, function() { return subscriber.complete(); - }, delay); + }, delay2); }, function(err) { return executeSchedule(subscriber, scheduler, function() { return subscriber.error(err); - }, delay); + }, delay2); })); }); } // node_modules/rxjs/dist/esm5/internal/operators/subscribeOn.js -function subscribeOn(scheduler, delay) { - if (delay === void 0) { - delay = 0; +function subscribeOn(scheduler, delay2) { + if (delay2 === void 0) { + delay2 = 0; } return operate(function(source, subscriber) { subscriber.add(scheduler.schedule(function() { return source.subscribe(subscriber); - }, delay)); + }, delay2)); }); } @@ -8877,6 +8990,64 @@ function concat() { return concatAll()(from(args, popScheduler(args))); } +// node_modules/rxjs/dist/esm5/internal/observable/fromEvent.js +var nodeEventEmitterMethods = ["addListener", "removeListener"]; +var eventTargetMethods = ["addEventListener", "removeEventListener"]; +var jqueryMethods = ["on", "off"]; +function fromEvent(target, eventName, options, resultSelector) { + if (isFunction(options)) { + resultSelector = options; + options = void 0; + } + if (resultSelector) { + return fromEvent(target, eventName, options).pipe(mapOneOrManyArgs(resultSelector)); + } + var _a = __read(isEventTarget(target) ? eventTargetMethods.map(function(methodName) { + return function(handler) { + return target[methodName](eventName, handler, options); + }; + }) : isNodeStyleEventEmitter(target) ? nodeEventEmitterMethods.map(toCommonHandlerRegistry(target, eventName)) : isJQueryStyleEventEmitter(target) ? jqueryMethods.map(toCommonHandlerRegistry(target, eventName)) : [], 2), add = _a[0], remove = _a[1]; + if (!add) { + if (isArrayLike(target)) { + return mergeMap(function(subTarget) { + return fromEvent(subTarget, eventName, options); + })(innerFrom(target)); + } + } + if (!add) { + throw new TypeError("Invalid event target"); + } + return new Observable(function(subscriber) { + var handler = function() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return subscriber.next(1 < args.length ? args : args[0]); + }; + add(handler); + return function() { + return remove(handler); + }; + }); +} +function toCommonHandlerRegistry(target, eventName) { + return function(methodName) { + return function(handler) { + return target[methodName](eventName, handler); + }; + }; +} +function isNodeStyleEventEmitter(target) { + return isFunction(target.addListener) && isFunction(target.removeListener); +} +function isJQueryStyleEventEmitter(target) { + return isFunction(target.on) && isFunction(target.off); +} +function isEventTarget(target) { + return isFunction(target.addEventListener) && isFunction(target.removeEventListener); +} + // node_modules/rxjs/dist/esm5/internal/observable/timer.js function timer(dueTime, intervalOrScheduler, scheduler) { if (dueTime === void 0) { @@ -8926,6 +9097,18 @@ function interval(period, scheduler) { return timer(period, period, scheduler); } +// node_modules/rxjs/dist/esm5/internal/observable/merge.js +function merge() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var scheduler = popScheduler(args); + var concurrent = popNumber(args, Infinity); + var sources = args; + return !sources.length ? EMPTY : sources.length === 1 ? innerFrom(sources[0]) : mergeAll(concurrent)(from(sources, scheduler)); +} + // node_modules/rxjs/dist/esm5/internal/operators/filter.js function filter(predicate, thisArg) { return operate(function(source, subscriber) { @@ -8936,6 +9119,82 @@ function filter(predicate, thisArg) { }); } +// node_modules/rxjs/dist/esm5/internal/operators/bufferTime.js +function bufferTime(bufferTimeSpan) { + var _a, _b; + var otherArgs = []; + for (var _i = 1; _i < arguments.length; _i++) { + otherArgs[_i - 1] = arguments[_i]; + } + var scheduler = (_a = popScheduler(otherArgs)) !== null && _a !== void 0 ? _a : asyncScheduler; + var bufferCreationInterval = (_b = otherArgs[0]) !== null && _b !== void 0 ? _b : null; + var maxBufferSize = otherArgs[1] || Infinity; + return operate(function(source, subscriber) { + var bufferRecords = []; + var restartOnEmit = false; + var emit = function(record) { + var buffer = record.buffer, subs = record.subs; + subs.unsubscribe(); + arrRemove(bufferRecords, record); + subscriber.next(buffer); + restartOnEmit && startBuffer(); + }; + var startBuffer = function() { + if (bufferRecords) { + var subs = new Subscription(); + subscriber.add(subs); + var buffer = []; + var record_1 = { + buffer, + subs + }; + bufferRecords.push(record_1); + executeSchedule(subs, scheduler, function() { + return emit(record_1); + }, bufferTimeSpan); + } + }; + if (bufferCreationInterval !== null && bufferCreationInterval >= 0) { + executeSchedule(subscriber, scheduler, startBuffer, bufferCreationInterval, true); + } else { + restartOnEmit = true; + } + startBuffer(); + var bufferTimeSubscriber = createOperatorSubscriber(subscriber, function(value) { + var e_1, _a2; + var recordsCopy = bufferRecords.slice(); + try { + for (var recordsCopy_1 = __values(recordsCopy), recordsCopy_1_1 = recordsCopy_1.next(); !recordsCopy_1_1.done; recordsCopy_1_1 = recordsCopy_1.next()) { + var record = recordsCopy_1_1.value; + var buffer = record.buffer; + buffer.push(value); + maxBufferSize <= buffer.length && emit(record); + } + } catch (e_1_1) { + e_1 = { error: e_1_1 }; + } finally { + try { + if (recordsCopy_1_1 && !recordsCopy_1_1.done && (_a2 = recordsCopy_1.return)) + _a2.call(recordsCopy_1); + } finally { + if (e_1) + throw e_1.error; + } + } + }, function() { + while (bufferRecords === null || bufferRecords === void 0 ? void 0 : bufferRecords.length) { + subscriber.next(bufferRecords.shift().buffer); + } + bufferTimeSubscriber === null || bufferTimeSubscriber === void 0 ? void 0 : bufferTimeSubscriber.unsubscribe(); + subscriber.complete(); + subscriber.unsubscribe(); + }, void 0, function() { + return bufferRecords = null; + }); + source.subscribe(bufferTimeSubscriber); + }); +} + // node_modules/rxjs/dist/esm5/internal/operators/scanInternals.js function scanInternals(accumulator, seed, hasSeed, emitOnNext, emitBeforeComplete) { return function(source, subscriber) { @@ -8985,6 +9244,83 @@ function concatMap(project, resultSelector) { return isFunction(resultSelector) ? mergeMap(project, resultSelector, 1) : mergeMap(project, 1); } +// node_modules/rxjs/dist/esm5/internal/operators/take.js +function take(count) { + return count <= 0 ? function() { + return EMPTY; + } : operate(function(source, subscriber) { + var seen = 0; + source.subscribe(createOperatorSubscriber(subscriber, function(value) { + if (++seen <= count) { + subscriber.next(value); + if (count <= seen) { + subscriber.complete(); + } + } + })); + }); +} + +// node_modules/rxjs/dist/esm5/internal/operators/ignoreElements.js +function ignoreElements() { + return operate(function(source, subscriber) { + source.subscribe(createOperatorSubscriber(subscriber, noop)); + }); +} + +// node_modules/rxjs/dist/esm5/internal/operators/mapTo.js +function mapTo(value) { + return map(function() { + return value; + }); +} + +// node_modules/rxjs/dist/esm5/internal/operators/delayWhen.js +function delayWhen(delayDurationSelector, subscriptionDelay) { + if (subscriptionDelay) { + return function(source) { + return concat(subscriptionDelay.pipe(take(1), ignoreElements()), source.pipe(delayWhen(delayDurationSelector))); + }; + } + return mergeMap(function(value, index) { + return innerFrom(delayDurationSelector(value, index)).pipe(take(1), mapTo(value)); + }); +} + +// node_modules/rxjs/dist/esm5/internal/operators/delay.js +function delay(due, scheduler) { + if (scheduler === void 0) { + scheduler = asyncScheduler; + } + var duration = timer(due, scheduler); + return delayWhen(function() { + return duration; + }); +} + +// node_modules/rxjs/dist/esm5/internal/operators/distinctUntilChanged.js +function distinctUntilChanged(comparator, keySelector) { + if (keySelector === void 0) { + keySelector = identity; + } + comparator = comparator !== null && comparator !== void 0 ? comparator : defaultCompare; + return operate(function(source, subscriber) { + var previousKey; + var first = true; + source.subscribe(createOperatorSubscriber(subscriber, function(value) { + var currentKey = keySelector(value); + if (first || !comparator(previousKey, currentKey)) { + first = false; + previousKey = currentKey; + subscriber.next(value); + } + })); + }); +} +function defaultCompare(a, b) { + return a === b; +} + // node_modules/rxjs/dist/esm5/internal/operators/scan.js function scan(accumulator, seed) { return operate(scanInternals(accumulator, seed, arguments.length >= 2, true)); @@ -9096,6 +9432,32 @@ function shareReplay(configOrBufferSize, windowTime, scheduler) { }); } +// node_modules/rxjs/dist/esm5/internal/operators/switchMap.js +function switchMap(project, resultSelector) { + return operate(function(source, subscriber) { + var innerSubscriber = null; + var index = 0; + var isComplete = false; + var checkComplete = function() { + return isComplete && !innerSubscriber && subscriber.complete(); + }; + source.subscribe(createOperatorSubscriber(subscriber, function(value) { + innerSubscriber === null || innerSubscriber === void 0 ? void 0 : innerSubscriber.unsubscribe(); + var innerIndex = 0; + var outerIndex = index++; + innerFrom(project(value, outerIndex)).subscribe(innerSubscriber = createOperatorSubscriber(subscriber, function(innerValue) { + return subscriber.next(resultSelector ? resultSelector(value, innerValue, outerIndex, innerIndex++) : innerValue); + }, function() { + innerSubscriber = null; + checkComplete(); + })); + }, function() { + isComplete = true; + checkComplete(); + })); + }); +} + // node_modules/rxjs/dist/esm5/internal/operators/withLatestFrom.js function withLatestFrom() { var inputs = []; @@ -9133,6 +9495,50 @@ function withLatestFrom() { // node_modules/butterfloat/events.js var ButterfloatEvent = Symbol("Butterfloat Event"); +var EventProxyHandler = class { + #subjects = /* @__PURE__ */ new WeakMap(); + #componentName; + get componentName() { + return this.#componentName; + } + constructor(componentName) { + this.#componentName = componentName; + } + get(target, prop) { + if (prop in target) { + return target[prop]; + } + const subject = new Subject(); + const observable2 = subject.asObservable(); + observable2[ButterfloatEvent] = `${this.componentName} ${prop}`; + this.#subjects.set(observable2, subject); + target[prop] = observable2; + return target[prop]; + } + applyEvent(event, element, eventName) { + const subject = this.#subjects.get(event); + if (!subject) { + throw new Error(`Unhandled event subject: ${event[ButterfloatEvent]}`); + } + if (eventName === "bfDomAttach") { + subject.next(element); + return new Subscription(); + } + const observable2 = fromEvent(element, eventName); + return observable2.subscribe(subject); + } +}; +function makeEventProxy(componentName, baseEvents = {}) { + const events = { ...baseEvents }; + const handler = new EventProxyHandler(componentName); + const proxy = new Proxy(events, handler); + return { events: proxy, handler }; +} + +// node_modules/butterfloat/component.js +function hasAnyBinds(description) { + return description.childrenBind || Object.keys(description.bind).length > 0 || Object.keys(description.immediateBind).length > 0 || Object.keys(description.events).length > 0; +} // node_modules/butterfloat/butterfly.js function butterfly(startingValue) { @@ -9216,6 +9622,374 @@ function jsx(element, attributes, ...children) { /* @__PURE__ */ (function(jsx2) { })(jsx || (jsx = {})); +// node_modules/butterfloat/binding.js +function bindObjectKey(item, key, observable2, error, complete) { + return observable2.subscribe({ + next: (value) => { + item[key] = value; + }, + error, + complete + }); +} +function bindObjectChanges(item, observable2, error, complete) { + return observable2.subscribe({ + next: (changes) => { + Object.assign(item, changes); + }, + error, + complete + }); +} +function bufferEntries(observable2, suspense) { + if (suspense) { + return combineLatest([suspense, observable2]).pipe(bufferTime(0, animationFrameScheduler), map((states) => states.reduce((acc, [suspend, entry]) => ({ + suspend, + entries: [...acc.entries, entry] + }), { suspend: false, entries: [] })), scan((acc, cur) => ({ + changes: acc.suspend && cur.suspend ? Object.assign(acc.changes, Object.fromEntries(cur.entries)) : Object.fromEntries(cur.entries), + suspend: cur.suspend + }), { suspend: false, changes: {} }), filter(({ suspend }) => !suspend), map(({ changes }) => changes)); + } + return observable2.pipe(bufferTime(0, animationFrameScheduler), map((entries) => Object.fromEntries(entries))); +} +function schedulable(key, immediate) { + return !(immediate || key === "value"); +} +function makeEntries(key, observable2) { + return observable2.pipe(map((value) => [key, value])); +} +function bindElement(element, description, context2, document2 = globalThis.document) { + const { complete, componentRunner, error, eventBinder, suspense, subscription } = context2; + const schedulables = []; + const binds = [ + ...Object.entries(description.bind).map(([key, observable2]) => [key, observable2, false]), + ...Object.entries(description.immediateBind).map(([key, observable2]) => [key, observable2, true]) + ]; + for (const [key, observable2, immediate] of binds) { + if (schedulable(key, immediate)) { + schedulables.push([key, observable2]); + } else { + subscription.add(bindObjectKey(element, key, observable2, error, complete)); + } + } + const scheduled2 = schedulables.map(([key, observable2]) => makeEntries(key, observable2)); + subscription.add(bindObjectChanges(element, bufferEntries(merge(...scheduled2), suspense), error, complete)); + for (const [key, event] of Object.entries(description.events)) { + subscription.add(eventBinder.applyEvent(event, element, key)); + } + if (description.childrenBind) { + subscription.add(description.childrenBind.subscribe({ + next(child) { + const placeholder = document2.createComment(`${child.name} component`); + if (description.childrenPrepend) { + element.prepend(placeholder); + } else { + element.append(placeholder); + } + subscription.add(componentRunner(element, { + type: "component", + component: child, + properties: {}, + children: [] + }, context2, placeholder)); + }, + error, + complete + })); + } + return subscription; +} +function bindFragmentChildren(nodeDescription, node, subscription, context2) { + const { complete, error, componentRunner } = context2; + if (nodeDescription.childrenBind) { + subscription.add(nodeDescription.childrenBind.subscribe({ + next(child) { + const parent = node.parentElement; + if (!parent) { + throw new Error("Attempted to bind children to an unattached fragment"); + } + const placeholder = document.createComment(`${child.name} component`); + if (nodeDescription.childrenPrepend) { + parent.insertBefore(node, placeholder); + } else { + const next = node.nextSibling; + if (next) { + parent.insertBefore(next, placeholder); + } else { + parent.append(placeholder); + } + } + subscription.add(componentRunner(parent, { + type: "component", + component: child, + properties: {}, + children: [] + }, context2, placeholder)); + }, + error, + complete + })); + } +} + +// node_modules/butterfloat/static-dom.js +function buildElement(description, document2 = globalThis.document) { + const element = document2.createElement(description.element); + for (const [key, value] of Object.entries(description.attributes)) { + ; + element[key] = value; + } + return element; +} +function buildNode(description, container2, elementBinds, nodeBinds, document2 = globalThis.document) { + switch (description.type) { + case "element": { + const element = buildElement(description, document2); + if (hasAnyBinds(description)) { + elementBinds.push([element, description]); + } + container2.appendChild(element); + return element; + } + case "children": { + const childrenComment = document2.createComment("Children component"); + container2.appendChild(childrenComment); + nodeBinds.push([childrenComment, description]); + return null; + } + case "component": { + const componentComment = document2.createComment(`${description.component.name} component`); + container2.appendChild(componentComment); + nodeBinds.push([componentComment, description]); + return null; + } + case "fragment": + if (description.childrenBind && description.childrenPrepend) { + const fragmentComment = document2.createComment("fragment children binding"); + container2.appendChild(fragmentComment); + nodeBinds.push([fragmentComment, description]); + } + for (const child of description.children) { + if (typeof child === "string") { + container2.appendChild(document2.createTextNode(child)); + continue; + } + buildTree(child, container2, elementBinds, nodeBinds, document2); + } + if (description.childrenBind && !description.childrenPrepend) { + const fragmentComment = document2.createComment("fragment children binding"); + container2.appendChild(fragmentComment); + nodeBinds.push([fragmentComment, description]); + } + return container2; + } +} +function buildTree(description, container2 = null, elementBinds = [], nodeBinds = [], document2 = globalThis.document) { + if (!container2 && description.type === "element") { + const element = buildElement(description, document2); + container2 = element; + if (hasAnyBinds(description)) { + elementBinds.push([element, description]); + } + } else if (!container2) { + container2 = document2.createDocumentFragment(); + buildNode(description, container2, elementBinds, nodeBinds, document2); + } else { + const nextNode = buildNode(description, container2, elementBinds, nodeBinds, document2); + if (nextNode !== null) { + container2 = nextNode; + } + } + if (description.type !== "children" && description.type !== "fragment") { + for (const child of description.children) { + if (typeof child === "string") { + container2.appendChild(document2.createTextNode(child)); + continue; + } + buildTree(child, container2, elementBinds, nodeBinds, document2); + } + } + return { + elementBinds, + nodeBinds, + container: container2 + }; +} + +// node_modules/butterfloat/wiring.js +var contextChildrenDescriptions = /* @__PURE__ */ new WeakMap(); +function wireInternal(description, subscriber, context2, document2 = globalThis.document) { + const subscription = new Subscription(); + const error = (error2) => { + console.error(`Error in component ${description.component.name}`, error2); + }; + const complete = () => subscriber.complete(); + const { events, handler } = makeEventProxy(description.component.name); + const componentContext = { + bindEffect(observable2, effect) { + context2.isStaticComponent = false; + subscription.add(observable2.pipe(delay(0, animationFrameScheduler)).subscribe({ + next: effect, + error, + complete + })); + }, + bindImmediateEffect(observable2, effect) { + context2.isStaticComponent = false; + subscription.add(observable2.subscribe({ + next: effect, + error, + complete + })); + }, + events + }; + contextChildrenDescriptions.set(componentContext, description); + const tree = description.component(description.properties, componentContext); + const { elementBinds, nodeBinds, container: container2 } = buildTree(tree, void 0, void 0, void 0, document2); + context2.isStaticComponent &&= elementBinds.length === 0; + context2.isStaticTree &&= context2.isStaticComponent; + subscriber.next(container2); + const bindContext = { + ...context2, + complete, + error, + componentRunner: run, + eventBinder: handler, + subscription + }; + for (const [element, bindDescription] of elementBinds) { + subscription.add(bindElement(element, bindDescription, bindContext, document2)); + } + for (const [node, nodeDescription] of nodeBinds) { + switch (nodeDescription.type) { + case "component": { + const nestedContext = { + ...context2, + isStaticComponent: true, + isStaticTree: true + }; + subscription.add(run(container2, nodeDescription, nestedContext, node)); + context2.isStaticTree &&= nestedContext.isStaticTree; + break; + } + case "children": { + const nestedContext = { + ...context2, + isStaticComponent: true, + isStaticTree: true + }; + subscription.add(wireChildrenComponent(nodeDescription, componentContext, description, container2, nestedContext, node)); + context2.isStaticTree &&= nestedContext.isStaticTree; + break; + } + case "fragment": + context2.isStaticComponent = false; + context2.isStaticTree = false; + bindFragmentChildren(nodeDescription, node, subscription, bindContext); + break; + } + } + return () => { + subscription.unsubscribe(); + }; +} +function wireChildrenComponent(nodeDescription, componentContext, description, container2, context2, node) { + const parentDescription = contextChildrenDescriptions.get(nodeDescription.context ?? componentContext); + if (!parentDescription) { + throw new Error(`Unable to bind children for Children request in ${description.component.name}`); + } + const childrenComponent = () => ({ + type: "fragment", + attributes: {}, + children: [...parentDescription.children], + childrenBind: parentDescription.childrenBind, + childrenPrepend: parentDescription.childrenPrepend + }); + return run(container2, { + type: "component", + component: childrenComponent, + properties: {}, + children: [] + }, context2, node); +} +function wire(component, context2, document2 = globalThis.document) { + let description; + if ("type" in component) { + description = component; + } else { + description = { + type: "component", + component, + children: [], + properties: {} + }; + } + if (description.component === Suspense) { + return wireSuspense(description, context2, document2); + } + return new Observable((subscriber) => wireInternal(description, subscriber, context2, document2)); +} +function run(container2, component, context2, placeholder, document2 = globalThis.document) { + const observable2 = wire(component, context2 ?? { isStaticComponent: true, isStaticTree: true }, document2); + let previousNode = null; + return observable2.subscribe({ + next(node) { + if (previousNode) { + container2.replaceChild(previousNode, node); + } else if (placeholder) { + container2.replaceChild(placeholder, node); + } else { + container2.appendChild(node); + } + previousNode = node; + }, + error(error) { + if ("type" in component) { + console.error(`Error in component ${component.component.name}`, error); + } else { + console.error(`Error in component ${component.name}`, error); + } + }, + complete() { + if (!context2?.preserveOnComplete && previousNode) { + container2.removeChild(previousNode); + } + } + }); +} + +// node_modules/butterfloat/suspense.js +var Suspense = () => { + throw new Error("Suspense is a custom-wired component"); +}; +function wireSuspense(description, context2, document2 = globalThis.document) { + context2.isStaticComponent = false; + context2.isStaticTree = false; + const props = description.properties; + const suspense = context2.suspense ? combineLatest([props.when, context2.suspense]).pipe(map(([a, b]) => a || b)) : props.when; + const mainComponentFragment = { + type: "fragment", + attributes: {}, + children: description.children, + childrenBind: description.childrenBind, + childrenPrepend: description.childrenPrepend + }; + const mainComponent = () => mainComponentFragment; + const mainContext = { ...context2, suspense }; + const main = wire(mainComponent, mainContext, document2); + if (props.suspenseView) { + const suspenseView = wire(props.suspenseView, { ...context2 }, document2); + return combineLatest([props.when, main, suspenseView]).pipe(map(([suspend, main2, suspenseView2]) => suspend ? suspenseView2 : main2), distinctUntilChanged()); + } else { + return main; + } +} + +// main.tsx +var import_jquery = __toESM(require_jquery(), 1); + // progvm.ts var BaseSpeed = 5e-3; var SpeedMultiplier = 2; @@ -9251,7 +10025,7 @@ var ProgVm = class { [this.#paused, this.#setPaused] = butterfly(false); [this.#perTick, this.#setPerTick] = butterfly(BaseSpeed); this.#roundPercent = this.percent.pipe( - map((percent) => Math.round(percent * 100)) + map((percent) => percent.toLocaleString(void 0, { style: "percent" })) ); } pause() { @@ -9322,7 +10096,7 @@ var CompRadProgVm = class { get currentOffset() { return this.#currentOffset; } - constructor(dial2, ticks) { + constructor(dial, ticks) { ; [this.#progressAdded, this.#addProgress] = butterfly(null); this.#targetPercent = this.progressAdded.pipe( @@ -9335,7 +10109,7 @@ var CompRadProgVm = class { shareReplay(1) ); this.#targetRoundPercent = this.targetPercent.pipe( - map((target) => Math.round(target * 100)) + map((target) => target.toLocaleString(void 0, { style: "percent" })) ); this.#targetVal = this.targetPercent.pipe( map((target) => Math.round(target * 360)) @@ -9358,15 +10132,15 @@ var CompRadProgVm = class { this.#currentOffset = current.pipe( map(([, currentOffset]) => currentOffset) ); - if (dial2) { + if (dial) { this.#subscription.add( this.currentVal.subscribe( - (currentVal) => dial2.val(currentVal).trigger("change") + (currentVal) => dial.val(currentVal).trigger("change") ) ); this.#subscription.add( this.currentOffset.subscribe( - (currentOffset) => dial2.trigger("configure", { angleOffset: currentOffset }) + (currentOffset) => dial.trigger("configure", { angleOffset: currentOffset }) ) ); } else { @@ -9417,13 +10191,176 @@ var CompRadProgVm = class { } }; -// main.ts -var dial = (0, import_jquery.default)("#dial"); +// progress.tsx +function Progress({ item }, { bindEffect, events }) { + const { finish, pause, slowDown, speedUp, unpause } = events; + const progressStyle = item.roundPercent.pipe( + map((percent) => `min-width: 2em; width: ${percent}`) + ); + const pauseVisible = item.paused.pipe( + map((paused) => paused ? `visibility: hidden` : `visibility: visible`) + ); + const unpauseVisible = item.paused.pipe( + map((paused) => paused ? `visibility: visible` : `visibility: hidden`) + ); + bindEffect(finish, item.finish); + bindEffect(pause, item.pause); + bindEffect(slowDown, item.slowDown); + bindEffect(speedUp, item.speedUp); + bindEffect(unpause, item.unpause); + return /* @__PURE__ */ jsx("div", { className: "list-group-item" }, /* @__PURE__ */ jsx("div", { className: "progress" }, /* @__PURE__ */ jsx( + "div", + { + title: "Item Progress", + className: "progress-bar", + role: "progressbar", + style: "min-width: 2em", + bind: { innerText: item.roundPercent, style: progressStyle } + } + )), /* @__PURE__ */ jsx("div", { className: "btn-group" }, /* @__PURE__ */ jsx( + "button", + { + type: "button", + title: "Pause", + className: "btn btn-default", + bind: { style: pauseVisible }, + events: { click: pause } + }, + /* @__PURE__ */ jsx("span", { className: "glyphicon glyphicon-pause" }) + ), /* @__PURE__ */ jsx( + "button", + { + type: "button", + title: "Unpause", + className: "btn btn-default", + bind: { style: unpauseVisible }, + events: { click: unpause } + }, + /* @__PURE__ */ jsx("span", { class: "glyphicon glyphicon-play" }) + ), /* @__PURE__ */ jsx( + "button", + { + type: "button", + title: "Slow Down", + className: "btn btn-default", + events: { click: slowDown } + }, + /* @__PURE__ */ jsx("span", { class: "glyphicon glyphicon-backward" }) + ), /* @__PURE__ */ jsx( + "button", + { + type: "button", + title: "Speed Up", + className: "btn btn-default", + events: { click: speedUp } + }, + /* @__PURE__ */ jsx("span", { class: "glyphicon glyphicon-forward" }) + ), /* @__PURE__ */ jsx( + "button", + { + type: "button", + title: "Finish", + className: "btn btn-default", + events: { click: finish } + }, + /* @__PURE__ */ jsx("span", { class: "glyphicon glyphicon-fast-forward" }) + ))); +} + +// main.tsx var w = window; w.jQuery = w.$ = import_jquery.default; await Promise.resolve().then(() => __toESM(require_jquery_knob_min(), 1)); -dial.knob(); -var vm = new CompRadProgVm(dial, interval(500)); +function Main(_props, { bindEffect, events }) { + const { addItem, pauseAll, unpauseAll } = events; + const bfDomAttach = events.attach; + const dial = bfDomAttach.pipe( + switchMap((element) => { + console.log("dial attach"); + return new Observable((subscriber) => { + element.dataset.min = "0"; + element.dataset.max = "360"; + element.dataset.readOnly = "true"; + element.dataset.displayInput = "false"; + const dial2 = (0, import_jquery.default)(element); + dial2.knob(); + subscriber.next(dial2); + }); + }) + ); + const vm = dial.pipe( + switchMap((dial2) => { + return new Observable((subscriber) => { + const vm2 = new CompRadProgVm(dial2, interval(500)); + subscriber.next(vm2); + return () => vm2.unsubscribe(); + }); + }), + shareReplay(1) + ); + const targetRoundPercent = vm.pipe( + switchMap((vm2) => vm2.targetRoundPercent), + shareReplay(1) + ); + const progressStyle = targetRoundPercent.pipe( + map((targetRoundPercent2) => `min-width: 2em; width: ${targetRoundPercent2}`) + ); + bindEffect(addItem.pipe(withLatestFrom(vm)), ([, vm2]) => vm2.addItem()); + bindEffect(pauseAll.pipe(withLatestFrom(vm)), ([, vm2]) => vm2.unpauseAll()); + bindEffect(unpauseAll.pipe(withLatestFrom(vm)), ([, vm2]) => vm2.unpauseAll()); + const children = vm.pipe( + switchMap((vm2) => vm2.progressAdded), + filter((progVm) => progVm !== null), + map((progVm) => () => /* @__PURE__ */ jsx(Progress, { item: progVm })) + ); + return /* @__PURE__ */ jsx("div", { className: "row" }, /* @__PURE__ */ jsx("div", { className: "col-md-6" }, /* @__PURE__ */ jsx( + "input", + { + type: "text", + id: "dial", + className: "dial", + value: "0", + bind: { bfDomAttach } + } + ), /* @__PURE__ */ jsx("label", { htmlFor: "dial", className: "hidden" }, "Total Progress")), /* @__PURE__ */ jsx("div", { className: "col-md-6" }, /* @__PURE__ */ jsx("div", { className: "progress" }, /* @__PURE__ */ jsx( + "div", + { + className: "progress-bar", + role: "progressbar", + style: "min-width: 2em", + bind: { innerText: targetRoundPercent, style: progressStyle } + } + )), /* @__PURE__ */ jsx( + "button", + { + type: "button", + className: "btn btn-default", + events: { click: addItem } + }, + /* @__PURE__ */ jsx("span", { className: "glyphicon glyphicon-plus" }), + " Add Item" + ), /* @__PURE__ */ jsx("div", { className: "btn-group" }, /* @__PURE__ */ jsx( + "button", + { + type: "button", + className: "btn btn-default", + events: { click: pauseAll } + }, + /* @__PURE__ */ jsx("span", { className: "glyphicon glyphicon-pause" }), + " All" + ), /* @__PURE__ */ jsx( + "button", + { + type: "button", + className: "btn btn-default", + events: { click: unpauseAll } + }, + /* @__PURE__ */ jsx("span", { className: "glyphicon glyphicon-play" }), + " All" + )), /* @__PURE__ */ jsx("div", { className: "list-group", childrenBind: children, childrenPrepend: true }))); +} +var container = document.getElementById("container"); +run(container, Main); /*! Bundled license information: jquery/dist/jquery.js: diff --git a/main.ts b/main.ts deleted file mode 100644 index f7d3fe8..0000000 --- a/main.ts +++ /dev/null @@ -1,16 +0,0 @@ -import $ from 'jquery' -import { interval } from 'rxjs' -import { CompRadProgVm } from './compradprogvm' - -// create and bind -const dial = $('#dial') - -// Set global for jquery-knob -const w = window as any -w.jQuery = w.$ = $ - -// @ts-ignore -await import('jquery-knob') -dial.knob() -const vm = new CompRadProgVm(dial, interval(500)) -//ko.applyBindings(vm) diff --git a/main.tsx b/main.tsx new file mode 100644 index 0000000..caf7d39 --- /dev/null +++ b/main.tsx @@ -0,0 +1,141 @@ +import { ComponentContext, ObservableEvent, jsx, run } from 'butterfloat' +import $ from 'jquery' +import { + Observable, + filter, + interval, + map, + shareReplay, + switchMap, + withLatestFrom, +} from 'rxjs' +import { CompRadProgVm } from './compradprogvm' +import { Progress } from './progress' + +// Set global for jquery-knob +const w = window as any +w.jQuery = w.$ = $ + +// @ts-ignore +await import('jquery-knob') + +interface MainEvents { + addItem: ObservableEvent + attach: ObservableEvent + pauseAll: ObservableEvent + unpauseAll: ObservableEvent +} + +function Main( + _props: {}, + { bindEffect, events }: ComponentContext, +) { + const { addItem, pauseAll, unpauseAll } = events + + const bfDomAttach = events.attach + const dial = bfDomAttach.pipe( + switchMap((element) => { + return new Observable>((subscriber) => { + element.dataset.min = '0' + element.dataset.max = '360' + element.dataset.readOnly = 'true' + element.dataset.displayInput = 'false' + + // create and bind + const dial = $(element) + + dial.knob() + + subscriber.next(dial) + }) + }), + ) + + const vm = dial.pipe( + switchMap((dial) => { + // extra wrapper for cleanup logic + return new Observable((subscriber) => { + const vm = new CompRadProgVm(dial, interval(500)) + subscriber.next(vm) + return () => vm.unsubscribe() + }) + }), + shareReplay(1), + ) + + const targetRoundPercent = vm.pipe( + switchMap((vm) => vm.targetRoundPercent), + shareReplay(1), + ) + + const progressStyle = targetRoundPercent.pipe( + map((targetRoundPercent) => `min-width: 2em; width: ${targetRoundPercent}`), + ) + + bindEffect(addItem.pipe(withLatestFrom(vm)), ([, vm]) => vm.addItem()) + + bindEffect(pauseAll.pipe(withLatestFrom(vm)), ([, vm]) => vm.unpauseAll()) + + bindEffect(unpauseAll.pipe(withLatestFrom(vm)), ([, vm]) => vm.unpauseAll()) + + const children = vm.pipe( + switchMap((vm) => vm.progressAdded), + filter((progVm) => progVm !== null), + map((progVm) => () => ), + ) + + return ( +
+
+ + +
+
+
+
+
+ +
+ + +
+ +
+
+
+ ) +} + +const container = document.getElementById('container')! +run(container, Main) diff --git a/progress.tsx b/progress.tsx new file mode 100644 index 0000000..07bf537 --- /dev/null +++ b/progress.tsx @@ -0,0 +1,98 @@ +import { ComponentContext, ObservableEvent, jsx } from 'butterfloat' +import { map } from 'rxjs' +import { ProgVm } from './progvm' + +export interface ProgressProps { + item: ProgVm +} + +interface ProgressEvents { + finish: ObservableEvent + pause: ObservableEvent + slowDown: ObservableEvent + speedUp: ObservableEvent + unpause: ObservableEvent +} + +export function Progress( + { item }: ProgressProps, + { bindEffect, events }: ComponentContext, +) { + const { finish, pause, slowDown, speedUp, unpause } = events + + const progressStyle = item.roundPercent.pipe( + map((percent) => `min-width: 2em; width: ${percent}`), + ) + + const pauseVisible = item.paused.pipe( + map((paused) => (paused ? `visibility: hidden` : `visibility: visible`)), + ) + + const unpauseVisible = item.paused.pipe( + map((paused) => (paused ? `visibility: visible` : `visibility: hidden`)), + ) + + bindEffect(finish, item.finish) + bindEffect(pause, item.pause) + bindEffect(slowDown, item.slowDown) + bindEffect(speedUp, item.speedUp) + bindEffect(unpause, item.unpause) + + return ( +
+
+
+
+
+ + + + + +
+
+ ) +} diff --git a/progvm.ts b/progvm.ts index 5cb52aa..bc4c722 100644 --- a/progvm.ts +++ b/progvm.ts @@ -23,7 +23,7 @@ export class ProgVm { return this.#percent } - readonly #roundPercent: Observable + readonly #roundPercent: Observable get roundPercent() { return this.#roundPercent } @@ -47,7 +47,7 @@ export class ProgVm { ;[this.#perTick, this.#setPerTick] = butterfly(BaseSpeed) this.#roundPercent = this.percent.pipe( - map((percent) => Math.round(percent * 100)), + map((percent) => percent.toLocaleString(undefined, { style: 'percent' })), ) } diff --git a/tsconfig.json b/tsconfig.json index 4f28944..8fdf7a8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,8 @@ "moduleResolution": "node", "noEmit": true, "forceConsistentCasingInFileNames": true, - "strict": true + "strict": true, + "jsx": "react", + "jsxFactory": "jsx" } } From 08a2d3d4b3fddb3859090de322aa8a5d9e4c7d58 Mon Sep 17 00:00:00 2001 From: Max Battcher Date: Tue, 21 Nov 2023 19:03:18 -0500 Subject: [PATCH 07/15] =?UTF-8?q?=F0=9F=94=A7=20npm=20i=20butterfloat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index f01510d..196af68 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "@types/node": "^20.9.3", - "butterfloat": "^0.2.0", + "butterfloat": "^0.2.1", "jquery": "^3.6.0", "jquery-knob": "^1.2.11", "rxjs": "^7.8.1" @@ -445,9 +445,9 @@ } }, "node_modules/butterfloat": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/butterfloat/-/butterfloat-0.2.0.tgz", - "integrity": "sha512-Nptxs2b9vP1n2JV4fPbZ17UKF7Up/eHiu7B91vXXtLgr5u46z6uL6N/qeR7DyD3PKvRdKSZOfGaSz1lzUGxQOw==", + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/butterfloat/-/butterfloat-0.2.1.tgz", + "integrity": "sha512-riwmDf2NHT6KToFFtRL/hF4qx5a+6dVcr6J/HdNEJ5L+ZU8sJ7nrLUbVOGADhr23ofm5d54/wwqhtTtNIAuGBw==", "dependencies": { "rxjs": "^7.8.1" } diff --git a/package.json b/package.json index a8bfc93..f5baf4d 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "type": "module", "dependencies": { "@types/node": "^20.9.3", - "butterfloat": "^0.2.0", + "butterfloat": "^0.2.1", "jquery": "^3.6.0", "jquery-knob": "^1.2.11", "rxjs": "^7.8.1" From e831ad1b440d0c2bf72ff7f4aceb2ccb160b6499 Mon Sep 17 00:00:00 2001 From: Max Battcher Date: Tue, 21 Nov 2023 19:18:37 -0500 Subject: [PATCH 08/15] Fix dom attachment event and merge dial/vm observables --- main.tsx | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/main.tsx b/main.tsx index caf7d39..dbef283 100644 --- a/main.tsx +++ b/main.tsx @@ -33,9 +33,10 @@ function Main( const { addItem, pauseAll, unpauseAll } = events const bfDomAttach = events.attach - const dial = bfDomAttach.pipe( + + const vm = bfDomAttach.pipe( switchMap((element) => { - return new Observable>((subscriber) => { + return new Observable((subscriber) => { element.dataset.min = '0' element.dataset.max = '360' element.dataset.readOnly = 'true' @@ -46,15 +47,6 @@ function Main( dial.knob() - subscriber.next(dial) - }) - }), - ) - - const vm = dial.pipe( - switchMap((dial) => { - // extra wrapper for cleanup logic - return new Observable((subscriber) => { const vm = new CompRadProgVm(dial, interval(500)) subscriber.next(vm) return () => vm.unsubscribe() @@ -92,7 +84,7 @@ function Main( id="dial" className="dial" value="0" - bind={{ bfDomAttach }} + events={{ bfDomAttach }} />
From 190ec74dd9324fbe52983ebd8a1131c48bdeb30f Mon Sep 17 00:00:00 2001 From: Max Battcher Date: Tue, 21 Nov 2023 21:21:10 -0500 Subject: [PATCH 14/15] Fix event bindings --- progress.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/progress.tsx b/progress.tsx index 11d80e3..dedd9ab 100644 --- a/progress.tsx +++ b/progress.tsx @@ -32,11 +32,11 @@ export function Progress( map((paused) => (paused ? `visibility: visible` : `visibility: hidden`)), ) - bindEffect(finish, item.finish) - bindEffect(pause, item.pause) - bindEffect(slowDown, item.slowDown) - bindEffect(speedUp, item.speedUp) - bindEffect(unpause, item.unpause) + bindEffect(finish, () => item.finish()) + bindEffect(pause, () => item.pause()) + bindEffect(slowDown, () => item.slowDown()) + bindEffect(speedUp, () => item.speedUp()) + bindEffect(unpause, () => item.unpause()) return (
From 58b3a3bac908865ccfa321a77c8279ff8105e23f Mon Sep 17 00:00:00 2001 From: Max Battcher Date: Tue, 21 Nov 2023 22:43:47 -0500 Subject: [PATCH 15/15] Fix bugs; use immediate effects --- compradprogvm.ts | 35 ++++++----- main.js | 152 +++++++++++++++++++--------------------------- main.tsx | 33 +++++----- package-lock.json | 8 +-- package.json | 2 +- progress.tsx | 12 ++-- progvm.ts | 13 ++-- 7 files changed, 115 insertions(+), 140 deletions(-) diff --git a/compradprogvm.ts b/compradprogvm.ts index 75ee2d7..846aed9 100644 --- a/compradprogvm.ts +++ b/compradprogvm.ts @@ -4,15 +4,16 @@ import { combineLatest, combineLatestAll, concat, - concatMap, filter, interval, map, of, scan, shareReplay, + switchMap, withLatestFrom, } from 'rxjs' +import { tag } from 'rxjs-spy/operators' import { ProgVm } from './progvm' import { butterfly } from 'butterfloat' @@ -74,15 +75,22 @@ export class CompRadProgVm { constructor(dial?: JQuery, ticks?: Observable) { ;[this.#progressAdded, this.#addProgress] = butterfly(null) - this.#targetPercent = this.progressAdded.pipe( - filter((progress) => progress !== null), - map((progress) => progress!.percent), - combineLatestAll(), - map( - (progresses) => progresses.reduce((a, b) => a + b) / progresses.length, + this.#targetPercent = concat( + of(0), + this.progressAdded.pipe( + switchMap(() => { + return combineLatest( + this.#inprogress.map((progress) => progress.percent), + ) + }), + tag('target-percent-progresses'), + map((progresses) => + progresses.length + ? progresses.reduce((a, b) => a + b, 0) / progresses.length + : 0, + ), ), - shareReplay(1), - ) + ).pipe(tag('target-percent-raw'), shareReplay(1)) this.#targetRoundPercent = this.targetPercent.pipe( map((target) => target.toLocaleString(undefined, { style: 'percent' })), @@ -95,7 +103,7 @@ export class CompRadProgVm { const current = concat( of([0, 0]), (ticks ?? interval(500)).pipe( - concatMap(() => + switchMap(() => Promise.all(this.#inprogress.map((item) => item.tick())), ), withLatestFrom(this.targetVal), @@ -104,9 +112,8 @@ export class CompRadProgVm { this.#onTick(currentVal, currentOffset, targetVal), [0, 0], ), - shareReplay(1), ), - ) + ).pipe(tag('vm-current'), shareReplay(1)) this.#currentVal = current.pipe(map(([currentVal]) => currentVal)) this.#currentOffset = current.pipe( @@ -140,8 +147,8 @@ export class CompRadProgVm { addItem() { const progress = new ProgVm() + this.#inprogress.unshift(progress) this.#addProgress(progress) - this.#inprogress.unshift(new ProgVm()) } #onTick( @@ -158,7 +165,7 @@ export class CompRadProgVm { const diff = Math.min(targetVal - currentVal, this.maxGrowthPerTick) currentVal += diff if (this.growthSpinRate) { - currentOffset += this.growthSpinRate + currentOffset = (currentOffset + this.growthSpinRate) % 360 } this.#spinTickCount = 0 } else if (targetVal < currentVal && currentVal > this.minBar) { diff --git a/main.js b/main.js index 4d6eb40..856661f 100644 --- a/main.js +++ b/main.js @@ -1351,11 +1351,11 @@ var require_jquery = __commonJS({ } return results; } - function condense(unmatched, map2, filter2, context2, xml) { + function condense(unmatched, map2, filter3, context2, xml) { var elem, newUnmatched = [], i2 = 0, len = unmatched.length, mapped = map2 != null; for (; i2 < len; i2++) { if (elem = unmatched[i2]) { - if (!filter2 || filter2(elem, context2, xml)) { + if (!filter3 || filter3(elem, context2, xml)) { newUnmatched.push(elem); if (mapped) { map2.push(i2); @@ -7565,13 +7565,6 @@ function identity(x) { } // node_modules/rxjs/dist/esm5/internal/util/pipe.js -function pipe() { - var fns = []; - for (var _i = 0; _i < arguments.length; _i++) { - fns[_i] = arguments[_i]; - } - return pipeFromArray(fns); -} function pipeFromArray(fns) { if (fns.length === 0) { return identity; @@ -9334,38 +9327,6 @@ function scanInternals(accumulator, seed, hasSeed, emitOnNext, emitBeforeComplet }; } -// node_modules/rxjs/dist/esm5/internal/operators/reduce.js -function reduce(accumulator, seed) { - return operate(scanInternals(accumulator, seed, arguments.length >= 2, false, true)); -} - -// node_modules/rxjs/dist/esm5/internal/operators/toArray.js -var arrReducer = function(arr, value) { - return arr.push(value), arr; -}; -function toArray() { - return operate(function(source, subscriber) { - reduce(arrReducer, [])(source).subscribe(subscriber); - }); -} - -// node_modules/rxjs/dist/esm5/internal/operators/joinAllInternals.js -function joinAllInternals(joinFn, project) { - return pipe(toArray(), mergeMap(function(sources) { - return joinFn(sources); - }), project ? mapOneOrManyArgs(project) : identity); -} - -// node_modules/rxjs/dist/esm5/internal/operators/combineLatestAll.js -function combineLatestAll(project) { - return joinAllInternals(combineLatest, project); -} - -// node_modules/rxjs/dist/esm5/internal/operators/concatMap.js -function concatMap(project, resultSelector) { - return isFunction(resultSelector) ? mergeMap(project, resultSelector, 1) : mergeMap(project, 1); -} - // node_modules/rxjs/dist/esm5/internal/operators/take.js function take(count) { return count <= 0 ? function() { @@ -9775,7 +9736,10 @@ function bindObjectKey(item, key, observable3, error, complete) { item[key] = value; }, error, - complete + complete: () => { + console.debug(`${key.toString()} binding completed`, item); + complete(); + } }); } function bindObjectChanges(item, observable3, error, complete) { @@ -9784,7 +9748,10 @@ function bindObjectChanges(item, observable3, error, complete) { Object.assign(item, changes); }, error, - complete + complete: () => { + console.debug(`Change binding completed`, item); + complete(); + } }); } function bufferEntries(observable3, suspense) { @@ -9819,8 +9786,10 @@ function bindElement(element, description, context2, document2 = globalThis.docu subscription.add(bindObjectKey(element, key, observable3, error, complete)); } } - const scheduled2 = schedulables.map(([key, observable3]) => makeEntries(key, observable3)); - subscription.add(bindObjectChanges(element, bufferEntries(merge(...scheduled2), suspense), error, complete)); + if (schedulables.length) { + const scheduled2 = schedulables.map(([key, observable3]) => makeEntries(key, observable3)); + subscription.add(bindObjectChanges(element, bufferEntries(merge(...scheduled2), suspense), error, complete)); + } for (const [key, event] of Object.entries(description.events)) { subscription.add(eventBinder.applyEvent(event, element, key)); } @@ -9841,7 +9810,10 @@ function bindElement(element, description, context2, document2 = globalThis.docu }, context2, placeholder)); }, error, - complete + complete: () => { + console.debug(`Children binding completed`, element); + complete(); + } })); } return subscription; @@ -10091,9 +10063,9 @@ function run(container2, component, context2, placeholder, document2 = globalThi return observable3.subscribe({ next(node) { if (previousNode) { - container2.replaceChild(node, previousNode); + previousNode.replaceWith(node); } else if (placeholder) { - container2.replaceChild(node, placeholder); + placeholder.replaceWith(node); } else { container2.appendChild(node); } @@ -14254,7 +14226,9 @@ var ProgVm = class { [this.#paused, this.#setPaused] = butterfly(false); [this.#perTick, this.#setPerTick] = butterfly(BaseSpeed); this.#roundPercent = this.percent.pipe( - map((percent) => percent.toLocaleString(void 0, { style: "percent" })) + map((percent) => percent.toLocaleString(void 0, { style: "percent" })), + tag("progvm-round-percent"), + shareReplay(1) ); } pause() { @@ -14272,7 +14246,7 @@ var ProgVm = class { async tick() { const paused = await firstValueFrom(this.paused); const perTick = paused ? 0 : await firstValueFrom(this.perTick); - this.#setPercent((percent) => percent + perTick); + this.#setPercent((percent) => Math.min(percent + perTick, 1)); } finish() { this.#setPercent(1); @@ -14328,15 +14302,20 @@ var CompRadProgVm = class { constructor(dial, ticks) { ; [this.#progressAdded, this.#addProgress] = butterfly(null); - this.#targetPercent = this.progressAdded.pipe( - filter((progress) => progress !== null), - map((progress) => progress.percent), - combineLatestAll(), - map( - (progresses) => progresses.reduce((a, b) => a + b) / progresses.length - ), - shareReplay(1) - ); + this.#targetPercent = concat( + of(0), + this.progressAdded.pipe( + switchMap(() => { + return combineLatest( + this.#inprogress.map((progress) => progress.percent) + ); + }), + tag("target-percent-progresses"), + map( + (progresses) => progresses.length ? progresses.reduce((a, b) => a + b, 0) / progresses.length : 0 + ) + ) + ).pipe(tag("target-percent-raw"), shareReplay(1)); this.#targetRoundPercent = this.targetPercent.pipe( map((target) => target.toLocaleString(void 0, { style: "percent" })) ); @@ -14346,17 +14325,16 @@ var CompRadProgVm = class { const current = concat( of([0, 0]), (ticks ?? interval(500)).pipe( - concatMap( + switchMap( () => Promise.all(this.#inprogress.map((item) => item.tick())) ), withLatestFrom(this.targetVal), scan( ([currentVal, currentOffset], [, targetVal]) => this.#onTick(currentVal, currentOffset, targetVal), [0, 0] - ), - shareReplay(1) + ) ) - ); + ).pipe(tag("vm-current"), shareReplay(1)); this.#currentVal = current.pipe(map(([currentVal]) => currentVal)); this.#currentOffset = current.pipe( map(([, currentOffset]) => currentOffset) @@ -14384,8 +14362,8 @@ var CompRadProgVm = class { } addItem() { const progress = new ProgVm(); + this.#inprogress.unshift(progress); this.#addProgress(progress); - this.#inprogress.unshift(new ProgVm()); } #onTick(currentVal, currentOffset, targetVal) { if (currentVal < this.minBar) { @@ -14395,7 +14373,7 @@ var CompRadProgVm = class { const diff = Math.min(targetVal - currentVal, this.maxGrowthPerTick); currentVal += diff; if (this.growthSpinRate) { - currentOffset += this.growthSpinRate; + currentOffset = (currentOffset + this.growthSpinRate) % 360; } this.#spinTickCount = 0; } else if (targetVal < currentVal && currentVal > this.minBar) { @@ -14421,7 +14399,7 @@ var CompRadProgVm = class { }; // progress.tsx -function Progress({ item }, { bindEffect, events }) { +function Progress({ item }, { bindImmediateEffect, events }) { const { finish, pause, slowDown, speedUp, unpause } = events; const progressStyle = item.roundPercent.pipe( map((percent) => `min-width: 2em; width: ${percent}`) @@ -14432,11 +14410,11 @@ function Progress({ item }, { bindEffect, events }) { const unpauseVisible = item.paused.pipe( map((paused) => paused ? `visibility: visible` : `visibility: hidden`) ); - bindEffect(finish, item.finish); - bindEffect(pause, item.pause); - bindEffect(slowDown, item.slowDown); - bindEffect(speedUp, item.speedUp); - bindEffect(unpause, item.unpause); + bindImmediateEffect(finish, () => item.finish()); + bindImmediateEffect(pause, () => item.pause()); + bindImmediateEffect(slowDown, () => item.slowDown()); + bindImmediateEffect(speedUp, () => item.speedUp()); + bindImmediateEffect(unpause, () => item.unpause()); return /* @__PURE__ */ jsx("div", { className: "list-group-item" }, /* @__PURE__ */ jsx("div", { className: "progress" }, /* @__PURE__ */ jsx( "div", { @@ -14474,7 +14452,7 @@ function Progress({ item }, { bindEffect, events }) { className: "btn btn-default", events: { click: slowDown } }, - /* @__PURE__ */ jsx("span", { class: "glyphicon glyphicon-backward" }) + /* @__PURE__ */ jsx("span", { className: "glyphicon glyphicon-backward" }) ), /* @__PURE__ */ jsx( "button", { @@ -14483,7 +14461,7 @@ function Progress({ item }, { bindEffect, events }) { className: "btn btn-default", events: { click: speedUp } }, - /* @__PURE__ */ jsx("span", { class: "glyphicon glyphicon-forward" }) + /* @__PURE__ */ jsx("span", { className: "glyphicon glyphicon-forward" }) ), /* @__PURE__ */ jsx( "button", { @@ -14492,28 +14470,28 @@ function Progress({ item }, { bindEffect, events }) { className: "btn btn-default", events: { click: finish } }, - /* @__PURE__ */ jsx("span", { class: "glyphicon glyphicon-fast-forward" }) + /* @__PURE__ */ jsx("span", { className: "glyphicon glyphicon-fast-forward" }) ))); } // main.tsx var spy = create(); -spy.log(/./); var w = window; w.jQuery = w.$ = import_jquery.default; await Promise.resolve().then(() => __toESM(require_jquery_knob_min(), 1)); -function Main(_props, { bindEffect, events }) { +function Main(_props, { bindImmediateEffect, events }) { const { addItem, pauseAll, unpauseAll } = events; const bfDomAttach = events.attach; const vm = bfDomAttach.pipe( switchMap((element) => { return new Observable((subscriber) => { - element.dataset.min = "0"; - element.dataset.max = "360"; - element.dataset.readOnly = "true"; - element.dataset.displayInput = "false"; const dial = (0, import_jquery.default)(element); - dial.knob(); + dial.knob({ + min: 0, + max: 360, + readOnly: true, + displayInput: false + }); const vm2 = new CompRadProgVm(dial, interval(500)); subscriber.next(vm2); return () => vm2.unsubscribe(); @@ -14531,15 +14509,15 @@ function Main(_props, { bindEffect, events }) { map((targetRoundPercent2) => `min-width: 2em; width: ${targetRoundPercent2}`), tag("progress-style") ); - bindEffect( + bindImmediateEffect( addItem.pipe(withLatestFrom(vm), tag("add-item")), ([, vm2]) => vm2.addItem() ); - bindEffect( + bindImmediateEffect( pauseAll.pipe(withLatestFrom(vm), tag("pause-all")), ([, vm2]) => vm2.unpauseAll() ); - bindEffect( + bindImmediateEffect( unpauseAll.pipe(withLatestFrom(vm), tag("unpause-all")), ([, vm2]) => vm2.unpauseAll() ); @@ -14596,11 +14574,7 @@ function Main(_props, { bindEffect, events }) { )), /* @__PURE__ */ jsx("div", { className: "list-group", childrenBind: children, childrenPrepend: true }))); } var container = document.getElementById("container"); -run(container, Main, { - isStaticComponent: true, - isStaticTree: true, - preserveOnComplete: true -}); +run(container, Main); /*! Bundled license information: jquery/dist/jquery.js: diff --git a/main.tsx b/main.tsx index cf3695e..92a36d0 100644 --- a/main.tsx +++ b/main.tsx @@ -15,7 +15,6 @@ import { CompRadProgVm } from './compradprogvm' import { Progress } from './progress' const spy = create() -spy.log(/./) // Set global for jquery-knob const w = window as any @@ -33,7 +32,7 @@ interface MainEvents { function Main( _props: {}, - { bindEffect, events }: ComponentContext, + { bindImmediateEffect, events }: ComponentContext, ) { const { addItem, pauseAll, unpauseAll } = events @@ -42,15 +41,15 @@ function Main( const vm = bfDomAttach.pipe( switchMap((element) => { return new Observable((subscriber) => { - element.dataset.min = '0' - element.dataset.max = '360' - element.dataset.readOnly = 'true' - element.dataset.displayInput = 'false' - // create and bind const dial = $(element) - dial.knob() + dial.knob({ + min: 0, + max: 360, + readOnly: true, + displayInput: false, + }) const vm = new CompRadProgVm(dial, interval(500)) subscriber.next(vm) @@ -72,15 +71,17 @@ function Main( tag('progress-style'), ) - bindEffect(addItem.pipe(withLatestFrom(vm), tag('add-item')), ([, vm]) => - vm.addItem(), + bindImmediateEffect( + addItem.pipe(withLatestFrom(vm), tag('add-item')), + ([, vm]) => vm.addItem(), ) - bindEffect(pauseAll.pipe(withLatestFrom(vm), tag('pause-all')), ([, vm]) => - vm.unpauseAll(), + bindImmediateEffect( + pauseAll.pipe(withLatestFrom(vm), tag('pause-all')), + ([, vm]) => vm.unpauseAll(), ) - bindEffect( + bindImmediateEffect( unpauseAll.pipe(withLatestFrom(vm), tag('unpause-all')), ([, vm]) => vm.unpauseAll(), ) @@ -146,8 +147,4 @@ function Main( } const container = document.getElementById('container')! -run(container, Main, { - isStaticComponent: true, - isStaticTree: true, - preserveOnComplete: true, -}) +run(container, Main) diff --git a/package-lock.json b/package-lock.json index cc01d28..c9a4e08 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "@types/node": "^20.9.3", - "butterfloat": "^0.2.4", + "butterfloat": "^0.3.0", "jquery": "^3.6.0", "jquery-knob": "^1.2.11", "rxjs": "^7.8.1", @@ -809,9 +809,9 @@ } }, "node_modules/butterfloat": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/butterfloat/-/butterfloat-0.2.4.tgz", - "integrity": "sha512-U8wtFzv5Ny4v5XVlrxvmYnmdpHiax2nf6ddHOGnAkb4lXlGm/eZMyTYct2FPrJqHA5d9vj2Loyrc9frSEMgF+A==", + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/butterfloat/-/butterfloat-0.3.0.tgz", + "integrity": "sha512-Vbv3RJ6JE4OZXlv2p7x8DnxZVdrHvzW+2v6ou3AXvSU4l2RDo0kjdav0OwIGlqE/wJlqA44lVUsrlmfxCojExQ==", "dependencies": { "rxjs": "^7.8.1" } diff --git a/package.json b/package.json index 88007cb..0d2ef95 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "type": "module", "dependencies": { "@types/node": "^20.9.3", - "butterfloat": "^0.2.4", + "butterfloat": "^0.3.0", "jquery": "^3.6.0", "jquery-knob": "^1.2.11", "rxjs": "^7.8.1", diff --git a/progress.tsx b/progress.tsx index dedd9ab..0803f2d 100644 --- a/progress.tsx +++ b/progress.tsx @@ -16,7 +16,7 @@ interface ProgressEvents { export function Progress( { item }: ProgressProps, - { bindEffect, events }: ComponentContext, + { bindImmediateEffect, events }: ComponentContext, ) { const { finish, pause, slowDown, speedUp, unpause } = events @@ -32,11 +32,11 @@ export function Progress( map((paused) => (paused ? `visibility: visible` : `visibility: hidden`)), ) - bindEffect(finish, () => item.finish()) - bindEffect(pause, () => item.pause()) - bindEffect(slowDown, () => item.slowDown()) - bindEffect(speedUp, () => item.speedUp()) - bindEffect(unpause, () => item.unpause()) + bindImmediateEffect(finish, () => item.finish()) + bindImmediateEffect(pause, () => item.pause()) + bindImmediateEffect(slowDown, () => item.slowDown()) + bindImmediateEffect(speedUp, () => item.speedUp()) + bindImmediateEffect(unpause, () => item.unpause()) return (
diff --git a/progvm.ts b/progvm.ts index bc4c722..3b91fdf 100644 --- a/progvm.ts +++ b/progvm.ts @@ -1,11 +1,6 @@ import { StateSetter, butterfly } from 'butterfloat' -import { - combineLatest, - firstValueFrom, - Observable, - map, - shareReplay, -} from 'rxjs' +import { firstValueFrom, Observable, map, shareReplay } from 'rxjs' +import { tag } from 'rxjs-spy/operators' export const BaseSpeed = 0.005 export const SpeedMultiplier = 2 @@ -48,6 +43,8 @@ export class ProgVm { this.#roundPercent = this.percent.pipe( map((percent) => percent.toLocaleString(undefined, { style: 'percent' })), + tag('progvm-round-percent'), + shareReplay(1), ) } @@ -66,7 +63,7 @@ export class ProgVm { async tick() { const paused = await firstValueFrom(this.paused) const perTick = paused ? 0 : await firstValueFrom(this.perTick) - this.#setPercent((percent) => percent + perTick) + this.#setPercent((percent) => Math.min(percent + perTick, 1)) } finish() { this.#setPercent(1)