{ "version": 3, "sources": ["../../../node_modules/mobx-utils/mobx-utils.module.js"], "sourcesContent": ["import { $mobx, _allowStateChanges, _endAction, _getAdministration, _isComputingDerivation, _startAction, action, autorun, computed, createAtom, entries, extendObservable, flow, getAtom, isAction, isComputed, isComputedProp, isObservableArray, isObservableMap, isObservableObject, keys, observable, observe, onBecomeUnobserved, runInAction, values, when } from 'mobx';\n\nvar NOOP = function () { };\nvar IDENTITY = function (_) { return _; };\nfunction fail$1(message) {\n throw new Error(\"[mobx-utils] \" + message);\n}\nfunction invariant(cond, message) {\n if (message === void 0) { message = \"Illegal state\"; }\n if (!cond)\n fail$1(message);\n}\nvar deprecatedMessages = [];\nfunction deprecated(msg) {\n if (deprecatedMessages.indexOf(msg) !== -1)\n return;\n deprecatedMessages.push(msg);\n console.error(\"[mobx-utils] Deprecated: \" + msg);\n}\nfunction addHiddenProp(object, propName, value) {\n Object.defineProperty(object, propName, {\n enumerable: false,\n writable: true,\n configurable: true,\n value: value\n });\n}\nvar deepFields = function (x) {\n return (x &&\n x !== Object.prototype &&\n Object.getOwnPropertyNames(x).concat(deepFields(Object.getPrototypeOf(x)) || []));\n};\nvar distinctDeepFields = function (x) {\n var deepFieldsIndistinct = deepFields(x);\n var deepFieldsDistinct = deepFieldsIndistinct.filter(function (item, index) { return deepFieldsIndistinct.indexOf(item) === index; });\n return deepFieldsDistinct;\n};\nvar getAllMethodsAndProperties = function (x) {\n return distinctDeepFields(x).filter(function (name) { return name !== \"constructor\" && !~name.indexOf(\"__\"); });\n};\n\nvar PENDING = \"pending\";\nvar FULFILLED = \"fulfilled\";\nvar REJECTED = \"rejected\";\nfunction caseImpl(handlers) {\n switch (this.state) {\n case PENDING:\n return handlers.pending && handlers.pending(this.value);\n case REJECTED:\n return handlers.rejected && handlers.rejected(this.value);\n case FULFILLED:\n return handlers.fulfilled ? handlers.fulfilled(this.value) : this.value;\n }\n}\nfunction createObservablePromise(origPromise, oldPromise) {\n invariant(arguments.length <= 2, \"fromPromise expects up to two arguments\");\n invariant(typeof origPromise === \"function\" ||\n (typeof origPromise === \"object\" &&\n origPromise &&\n typeof origPromise.then === \"function\"), \"Please pass a promise or function to fromPromise\");\n if (origPromise.isPromiseBasedObservable === true)\n return origPromise;\n if (typeof origPromise === \"function\") {\n // If it is a (reject, resolve function, wrap it)\n origPromise = new Promise(origPromise);\n }\n var promise = origPromise;\n origPromise.then(action(\"observableFromPromise-resolve\", function (value) {\n promise.value = value;\n promise.state = FULFILLED;\n }), action(\"observableFromPromise-reject\", function (reason) {\n promise.value = reason;\n promise.state = REJECTED;\n }));\n promise.isPromiseBasedObservable = true;\n promise.case = caseImpl;\n var oldData = oldPromise && oldPromise.state === FULFILLED ? oldPromise.value : undefined;\n extendObservable(promise, {\n value: oldData,\n state: PENDING\n }, {}, { deep: false });\n return promise;\n}\n/**\n * `fromPromise` takes a Promise, extends it with 2 observable properties that track\n * the status of the promise and returns it. The returned object has the following observable properties:\n * - `value`: either the initial value, the value the Promise resolved to, or the value the Promise was rejected with. use `.state` if you need to be able to tell the difference.\n * - `state`: one of `\"pending\"`, `\"fulfilled\"` or `\"rejected\"`\n *\n * And the following methods:\n * - `case({fulfilled, rejected, pending})`: maps over the result using the provided handlers, or returns `undefined` if a handler isn't available for the current promise state.\n * - `then((value: TValue) => TResult1 | PromiseLike, [(rejectReason: any) => any])`: chains additional handlers to the provided promise.\n *\n * The returned object implements `PromiseLike`, so you can chain additional `Promise` handlers using `then`. You may also use it with `await` in `async` functions.\n *\n * Note that the status strings are available as constants:\n * `mobxUtils.PENDING`, `mobxUtils.REJECTED`, `mobxUtil.FULFILLED`\n *\n * fromPromise takes an optional second argument, a previously created `fromPromise` based observable.\n * This is useful to replace one promise based observable with another, without going back to an intermediate\n * \"pending\" promise state while fetching data. For example:\n *\n * @example\n * \\@observer\n * class SearchResults extends React.Component {\n * \\@observable searchResults\n *\n * componentDidUpdate(nextProps) {\n * if (nextProps.query !== this.props.query)\n * this.comments = fromPromise(\n * window.fetch(\"/search?q=\" + nextProps.query),\n * // by passing, we won't render a pending state if we had a successful search query before\n * // rather, we will keep showing the previous search results, until the new promise resolves (or rejects)\n * this.searchResults\n * )\n * }\n *\n * render() {\n * return this.searchResults.case({\n * pending: (staleValue) => {\n * return staleValue || \"searching\" // <- value might set to previous results while the promise is still pending\n * },\n * fulfilled: (value) => {\n * return value // the fresh results\n * },\n * rejected: (error) => {\n * return \"Oops: \" + error\n * }\n * })\n * }\n * }\n *\n * Observable promises can be created immediately in a certain state using\n * `fromPromise.reject(reason)` or `fromPromise.resolve(value?)`.\n * The main advantage of `fromPromise.resolve(value)` over `fromPromise(Promise.resolve(value))` is that the first _synchronously_ starts in the desired state.\n *\n * It is possible to directly create a promise using a resolve, reject function:\n * `fromPromise((resolve, reject) => setTimeout(() => resolve(true), 1000))`\n *\n * @example\n * const fetchResult = fromPromise(fetch(\"http://someurl\"))\n *\n * // combine with when..\n * when(\n * () => fetchResult.state !== \"pending\",\n * () => {\n * console.log(\"Got \", fetchResult.value)\n * }\n * )\n *\n * // or a mobx-react component..\n * const myComponent = observer(({ fetchResult }) => {\n * switch(fetchResult.state) {\n * case \"pending\": return
Loading...
\n * case \"rejected\": return
Ooops... {fetchResult.value}
\n * case \"fulfilled\": return
Gotcha: {fetchResult.value}
\n * }\n * })\n *\n * // or using the case method instead of switch:\n *\n * const myComponent = observer(({ fetchResult }) =>\n * fetchResult.case({\n * pending: () =>
Loading...
,\n * rejected: error =>
Ooops.. {error}
,\n * fulfilled: value =>
Gotcha: {value}
,\n * }))\n *\n * // chain additional handler(s) to the resolve/reject:\n *\n * fetchResult.then(\n * (result) => doSomeTransformation(result),\n * (rejectReason) => console.error('fetchResult was rejected, reason: ' + rejectReason)\n * ).then(\n * (transformedResult) => console.log('transformed fetchResult: ' + transformedResult)\n * )\n *\n * @param {IThenable} promise The promise which will be observed\n * @param {IThenable} oldPromise? The promise which will be observed\n * @returns {IPromiseBasedObservable}\n */\nvar fromPromise = createObservablePromise;\nfromPromise.reject = action(\"fromPromise.reject\", function (reason) {\n var p = fromPromise(Promise.reject(reason));\n p.state = REJECTED;\n p.value = reason;\n return p;\n});\nfromPromise.resolve = action(\"fromPromise.resolve\", function (value) {\n if (value === void 0) { value = undefined; }\n var p = fromPromise(Promise.resolve(value));\n p.state = FULFILLED;\n p.value = value;\n return p;\n});\n/**\n * Returns true if the provided value is a promise-based observable.\n * @param value any\n * @returns {boolean}\n */\nfunction isPromiseBasedObservable(value) {\n return value && value.isPromiseBasedObservable === true;\n}\n\nvar __spreadArrays = (undefined && undefined.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n};\n/**\n * Moves an item from one position to another, checking that the indexes given are within bounds.\n *\n * @example\n * const source = observable([1, 2, 3])\n * moveItem(source, 0, 1)\n * console.log(source.map(x => x)) // [2, 1, 3]\n *\n * @export\n * @param {ObservableArray} target\n * @param {number} fromIndex\n * @param {number} toIndex\n * @returns {ObservableArray}\n */\nfunction moveItem(target, fromIndex, toIndex) {\n checkIndex(target, fromIndex);\n checkIndex(target, toIndex);\n if (fromIndex === toIndex) {\n return;\n }\n var oldItems = target[$mobx].values;\n var newItems;\n if (fromIndex < toIndex) {\n newItems = __spreadArrays(oldItems.slice(0, fromIndex), oldItems.slice(fromIndex + 1, toIndex + 1), [\n oldItems[fromIndex]\n ], oldItems.slice(toIndex + 1));\n }\n else {\n // toIndex < fromIndex\n newItems = __spreadArrays(oldItems.slice(0, toIndex), [\n oldItems[fromIndex]\n ], oldItems.slice(toIndex, fromIndex), oldItems.slice(fromIndex + 1));\n }\n target.replace(newItems);\n return target;\n}\n/**\n * Checks whether the specified index is within bounds. Throws if not.\n *\n * @private\n * @param {ObservableArray} target\n * @param {number }index\n */\nfunction checkIndex(target, index) {\n if (index < 0) {\n throw new Error(\"[mobx.array] Index out of bounds: \" + index + \" is negative\");\n }\n var length = target[$mobx].values.length;\n if (index >= length) {\n throw new Error(\"[mobx.array] Index out of bounds: \" + index + \" is not smaller than \" + length);\n }\n}\n\n/**\n * `lazyObservable` creates an observable around a `fetch` method that will not be invoked\n * until the observable is needed the first time.\n * The fetch method receives a `sink` callback which can be used to replace the\n * current value of the lazyObservable. It is allowed to call `sink` multiple times\n * to keep the lazyObservable up to date with some external resource.\n *\n * Note that it is the `current()` call itself which is being tracked by MobX,\n * so make sure that you don't dereference to early.\n *\n * @example\n * const userProfile = lazyObservable(\n * sink => fetch(\"/myprofile\").then(profile => sink(profile))\n * )\n *\n * // use the userProfile in a React component:\n * const Profile = observer(({ userProfile }) =>\n * userProfile.current() === undefined\n * ?
Loading user profile...
\n * :
{userProfile.current().displayName}
\n * )\n *\n * // triggers refresh the userProfile\n * userProfile.refresh()\n *\n * @param {(sink: (newValue: T) => void) => void} fetch method that will be called the first time the value of this observable is accessed. The provided sink can be used to produce a new value, synchronously or asynchronously\n * @param {T} [initialValue=undefined] optional initialValue that will be returned from `current` as long as the `sink` has not been called at least once\n * @returns {{\n * current(): T,\n * refresh(): T,\n * reset(): T\n * pendind: boolean\n * }}\n */\nfunction lazyObservable(fetch, initialValue) {\n if (initialValue === void 0) { initialValue = undefined; }\n var started = false;\n var value = observable.box(initialValue, { deep: false });\n var pending = observable.box(false);\n var currentFnc = function () {\n if (!started) {\n started = true;\n pending.set(true);\n fetch(function (newValue) {\n _allowStateChanges(true, function () {\n value.set(newValue);\n pending.set(false);\n });\n });\n }\n return value.get();\n };\n var resetFnc = action(\"lazyObservable-reset\", function () {\n started = false;\n value.set(initialValue);\n return value.get();\n });\n return {\n current: currentFnc,\n refresh: function () {\n if (started) {\n started = false;\n return currentFnc();\n }\n else {\n return value.get();\n }\n },\n reset: function () {\n return resetFnc();\n },\n get pending() {\n return pending.get();\n }\n };\n}\n\n/**\n * `fromResource` creates an observable whose current state can be inspected using `.current()`,\n * and which can be kept in sync with some external datasource that can be subscribed to.\n *\n * The created observable will only subscribe to the datasource if it is in use somewhere,\n * (un)subscribing when needed. To enable `fromResource` to do that two callbacks need to be provided,\n * one to subscribe, and one to unsubscribe. The subscribe callback itself will receive a `sink` callback, which can be used\n * to update the current state of the observable, allowing observes to react.\n *\n * Whatever is passed to `sink` will be returned by `current()`. The values passed to the sink will not be converted to\n * observables automatically, but feel free to do so.\n * It is the `current()` call itself which is being tracked,\n * so make sure that you don't dereference to early.\n *\n * For inspiration, an example integration with the apollo-client on [github](https://github.com/apollostack/apollo-client/issues/503#issuecomment-241101379),\n * or the [implementation](https://github.com/mobxjs/mobx-utils/blob/1d17cf7f7f5200937f68cc0b5e7ec7f3f71dccba/src/now.ts#L43-L57) of `mobxUtils.now`\n *\n * The following example code creates an observable that connects to a `dbUserRecord`,\n * which comes from an imaginary database and notifies when it has changed.\n *\n * @example\n * function createObservableUser(dbUserRecord) {\n * let currentSubscription;\n * return fromResource(\n * (sink) => {\n * // sink the current state\n * sink(dbUserRecord.fields)\n * // subscribe to the record, invoke the sink callback whenever new data arrives\n * currentSubscription = dbUserRecord.onUpdated(() => {\n * sink(dbUserRecord.fields)\n * })\n * },\n * () => {\n * // the user observable is not in use at the moment, unsubscribe (for now)\n * dbUserRecord.unsubscribe(currentSubscription)\n * }\n * )\n * }\n *\n * // usage:\n * const myUserObservable = createObservableUser(myDatabaseConnector.query(\"name = 'Michel'\"))\n *\n * // use the observable in autorun\n * autorun(() => {\n * // printed everytime the database updates its records\n * console.log(myUserObservable.current().displayName)\n * })\n *\n * // ... or a component\n * const userComponent = observer(({ user }) =>\n *
{user.current().displayName}
\n * )\n *\n * @export\n * @template T\n * @param {(sink: (newValue: T) => void) => void} subscriber\n * @param {IDisposer} [unsubscriber=NOOP]\n * @param {T} [initialValue=undefined] the data that will be returned by `get()` until the `sink` has emitted its first data\n * @returns {{\n * current(): T;\n * dispose(): void;\n * isAlive(): boolean;\n * }}\n */\nfunction fromResource(subscriber, unsubscriber, initialValue) {\n if (unsubscriber === void 0) { unsubscriber = NOOP; }\n if (initialValue === void 0) { initialValue = undefined; }\n var isActive = false;\n var isDisposed = false;\n var value = initialValue;\n var suspender = function () {\n if (isActive) {\n isActive = false;\n unsubscriber();\n }\n };\n var atom = createAtom(\"ResourceBasedObservable\", function () {\n invariant(!isActive && !isDisposed);\n isActive = true;\n subscriber(function (newValue) {\n _allowStateChanges(true, function () {\n value = newValue;\n atom.reportChanged();\n });\n });\n }, suspender);\n return {\n current: function () {\n invariant(!isDisposed, \"subscribingObservable has already been disposed\");\n var isBeingTracked = atom.reportObserved();\n if (!isBeingTracked && !isActive)\n console.warn(\"Called `get` of a subscribingObservable outside a reaction. Current value will be returned but no new subscription has started\");\n return value;\n },\n dispose: function () {\n isDisposed = true;\n suspender();\n },\n isAlive: function () { return isActive; }\n };\n}\n\nvar __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nfunction observableSymbol() {\n return (typeof Symbol === \"function\" && Symbol.observable) || \"@@observable\";\n}\nfunction self() {\n return this;\n}\n/**\n * Converts an expression to an observable stream (a.k.a. TC 39 Observable / RxJS observable).\n * The provided expression is tracked by mobx as long as there are subscribers, automatically\n * emitting when new values become available. The expressions respect (trans)actions.\n *\n * @example\n *\n * const user = observable({\n * firstName: \"C.S\",\n * lastName: \"Lewis\"\n * })\n *\n * Rx.Observable\n * .from(mobxUtils.toStream(() => user.firstname + user.lastName))\n * .scan(nameChanges => nameChanges + 1, 0)\n * .subscribe(nameChanges => console.log(\"Changed name \", nameChanges, \"times\"))\n *\n * @export\n * @template T\n * @param {() => T} expression\n * @param {boolean} fireImmediately (by default false)\n * @returns {IObservableStream}\n */\nfunction toStream(expression, fireImmediately) {\n var _a;\n if (fireImmediately === void 0) { fireImmediately = false; }\n var computedValue = computed(expression);\n return _a = {\n subscribe: function (observer) {\n return {\n unsubscribe: computedValue.observe(typeof observer === \"function\"\n ? function (_a) {\n var newValue = _a.newValue;\n return observer(newValue);\n }\n : function (_a) {\n var newValue = _a.newValue;\n return observer.next(newValue);\n }, fireImmediately)\n };\n }\n }, _a[observableSymbol()] = self, _a;\n}\nvar StreamListener = /** @class */ (function () {\n function StreamListener(observable$$1, initialValue) {\n var _this = this;\n this.current = undefined;\n runInAction(function () {\n _this.current = initialValue;\n _this.subscription = observable$$1.subscribe(_this);\n });\n }\n StreamListener.prototype.dispose = function () {\n if (this.subscription) {\n this.subscription.unsubscribe();\n }\n };\n StreamListener.prototype.next = function (value) {\n this.current = value;\n };\n StreamListener.prototype.complete = function () {\n this.dispose();\n };\n StreamListener.prototype.error = function (value) {\n this.current = value;\n this.dispose();\n };\n __decorate([\n observable.ref\n ], StreamListener.prototype, \"current\", void 0);\n __decorate([\n action.bound\n ], StreamListener.prototype, \"next\", null);\n __decorate([\n action.bound\n ], StreamListener.prototype, \"complete\", null);\n __decorate([\n action.bound\n ], StreamListener.prototype, \"error\", null);\n return StreamListener;\n}());\n/**\n *\n * Converts a subscribable, observable stream (TC 39 observable / RxJS stream)\n * into an object which stores the current value (as `current`). The subscription can be cancelled through the `dispose` method.\n * Takes an initial value as second optional argument\n *\n * @example\n * const debouncedClickDelta = MobxUtils.fromStream(Rx.Observable.fromEvent(button, 'click')\n * .throttleTime(1000)\n * .map(event => event.clientX)\n * .scan((count, clientX) => count + clientX, 0)\n * )\n *\n * autorun(() => {\n * console.log(\"distance moved\", debouncedClickDelta.current)\n * })\n *\n * @export\n * @template T\n * @param {IObservableStream} observable\n * @returns {{\n * current: T;\n * dispose(): void;\n * }}\n */\nfunction fromStream(observable$$1, initialValue) {\n if (initialValue === void 0) { initialValue = undefined; }\n return new StreamListener(observable$$1, initialValue);\n}\n\nvar __assign = (undefined && undefined.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nvar RESERVED_NAMES = [\"model\", \"reset\", \"submit\", \"isDirty\", \"isPropertyDirty\", \"resetProperty\"];\nvar ViewModel = /** @class */ (function () {\n function ViewModel(model) {\n var _this = this;\n this.model = model;\n this.localValues = observable.map({});\n this.localComputedValues = observable.map({});\n this.isPropertyDirty = function (key) {\n return _this.localValues.has(key);\n };\n invariant(isObservableObject(model), \"createViewModel expects an observable object\");\n // use this helper as Object.getOwnPropertyNames doesn't return getters\n getAllMethodsAndProperties(model).forEach(function (key) {\n if (key === $mobx || key === \"__mobxDidRunLazyInitializers\") {\n return;\n }\n invariant(RESERVED_NAMES.indexOf(key) === -1, \"The propertyname \" + key + \" is reserved and cannot be used with viewModels\");\n if (isComputedProp(model, key)) {\n var derivation = _getAdministration(model, key).derivation; // Fixme: there is no clear api to get the derivation\n _this.localComputedValues.set(key, computed(derivation.bind(_this)));\n }\n var descriptor = Object.getOwnPropertyDescriptor(model, key);\n var additionalDescriptor = descriptor ? { enumerable: descriptor.enumerable } : {};\n Object.defineProperty(_this, key, __assign(__assign({}, additionalDescriptor), { configurable: true, get: function () {\n if (isComputedProp(model, key))\n return _this.localComputedValues.get(key).get();\n if (_this.isPropertyDirty(key))\n return _this.localValues.get(key);\n else\n return _this.model[key];\n }, set: action(function (value) {\n if (value !== _this.model[key]) {\n _this.localValues.set(key, value);\n }\n else {\n _this.localValues.delete(key);\n }\n }) }));\n });\n }\n Object.defineProperty(ViewModel.prototype, \"isDirty\", {\n get: function () {\n return this.localValues.size > 0;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(ViewModel.prototype, \"changedValues\", {\n get: function () {\n return this.localValues.toJS();\n },\n enumerable: true,\n configurable: true\n });\n ViewModel.prototype.submit = function () {\n var _this = this;\n keys(this.localValues).forEach(function (key) {\n var source = _this.localValues.get(key);\n var destination = _this.model[key];\n if (isObservableArray(destination)) {\n destination.replace(source);\n }\n else if (isObservableMap(destination)) {\n destination.clear();\n destination.merge(source);\n }\n else if (!isComputed(source)) {\n _this.model[key] = source;\n }\n });\n this.localValues.clear();\n };\n ViewModel.prototype.reset = function () {\n this.localValues.clear();\n };\n ViewModel.prototype.resetProperty = function (key) {\n this.localValues.delete(key);\n };\n __decorate$1([\n computed\n ], ViewModel.prototype, \"isDirty\", null);\n __decorate$1([\n computed\n ], ViewModel.prototype, \"changedValues\", null);\n __decorate$1([\n action.bound\n ], ViewModel.prototype, \"submit\", null);\n __decorate$1([\n action.bound\n ], ViewModel.prototype, \"reset\", null);\n __decorate$1([\n action.bound\n ], ViewModel.prototype, \"resetProperty\", null);\n return ViewModel;\n}());\n/**\n * `createViewModel` takes an object with observable properties (model)\n * and wraps a viewmodel around it. The viewmodel proxies all enumerable properties of the original model with the following behavior:\n * - as long as no new value has been assigned to the viewmodel property, the original property will be returned.\n * - any future change in the model will be visible in the viewmodel as well unless the viewmodel property was dirty at the time of the attempted change.\n * - once a new value has been assigned to a property of the viewmodel, that value will be returned during a read of that property in the future. However, the original model remain untouched until `submit()` is called.\n *\n * The viewmodel exposes the following additional methods, besides all the enumerable properties of the model:\n * - `submit()`: copies all the values of the viewmodel to the model and resets the state\n * - `reset()`: resets the state of the viewmodel, abandoning all local modifications\n * - `resetProperty(propName)`: resets the specified property of the viewmodel\n * - `isDirty`: observable property indicating if the viewModel contains any modifications\n * - `isPropertyDirty(propName)`: returns true if the specified property is dirty\n * - `changedValues`: returns a key / value map with the properties that have been changed in the model so far\n * - `model`: The original model object for which this viewModel was created\n *\n * You may use observable arrays, maps and objects with `createViewModel` but keep in mind to assign fresh instances of those to the viewmodel's properties, otherwise you would end up modifying the properties of the original model.\n * Note that if you read a non-dirty property, viewmodel only proxies the read to the model. You therefore need to assign a fresh instance not only the first time you make the assignment but also after calling `reset()` or `submit()`.\n *\n * @example\n * class Todo {\n * \\@observable title = \"Test\"\n * }\n *\n * const model = new Todo()\n * const viewModel = createViewModel(model);\n *\n * autorun(() => console.log(viewModel.model.title, \",\", viewModel.title))\n * // prints \"Test, Test\"\n * model.title = \"Get coffee\"\n * // prints \"Get coffee, Get coffee\", viewModel just proxies to model\n * viewModel.title = \"Get tea\"\n * // prints \"Get coffee, Get tea\", viewModel's title is now dirty, and the local value will be printed\n * viewModel.submit()\n * // prints \"Get tea, Get tea\", changes submitted from the viewModel to the model, viewModel is proxying again\n * viewModel.title = \"Get cookie\"\n * // prints \"Get tea, Get cookie\" // viewModel has diverged again\n * viewModel.reset()\n * // prints \"Get tea, Get tea\", changes of the viewModel have been abandoned\n *\n * @param {T} model\n * @returns {(T & IViewModel)}\n * ```\n */\nfunction createViewModel(model) {\n return new ViewModel(model);\n}\n\n/**\n * Like normal `when`, except that this `when` will automatically dispose if the condition isn't met within a certain amount of time.\n *\n * @example\n * test(\"expect store to load\", t => {\n * const store = {\n * items: [],\n * loaded: false\n * }\n * fetchDataForStore((data) => {\n * store.items = data;\n * store.loaded = true;\n * })\n * whenWithTimeout(\n * () => store.loaded\n * () => t.end()\n * 2000,\n * () => t.fail(\"store didn't load with 2 secs\")\n * )\n * })\n *\n *\n * @export\n * @param {() => boolean} expr see when, the expression to await\n * @param {() => void} action see when, the action to execut when expr returns truthy\n * @param {number} [timeout=10000] maximum amount when spends waiting before giving up\n * @param {any} [onTimeout=() => {}] the ontimeout handler will be called if the condition wasn't met within the given time\n * @returns {IDisposer} disposer function that can be used to cancel the when prematurely. Neither action or onTimeout will be fired if disposed\n */\nfunction whenWithTimeout(expr, action$$1, timeout, onTimeout) {\n if (timeout === void 0) { timeout = 10000; }\n if (onTimeout === void 0) { onTimeout = function () { }; }\n deprecated(\"whenWithTimeout is deprecated, use mobx.when with timeout option instead\");\n return when(expr, action$$1, {\n timeout: timeout,\n onError: onTimeout\n });\n}\n\n/**\n * MobX normally suspends any computed value that is not in use by any reaction,\n * and lazily re-evaluates the expression if needed outside a reaction while not in use.\n * `keepAlive` marks a computed value as always in use, meaning that it will always fresh, but never disposed automatically.\n *\n * @example\n * const obj = observable({\n * number: 3,\n * doubler: function() { return this.number * 2 }\n * })\n * const stop = keepAlive(obj, \"doubler\")\n *\n * @param {Object} target an object that has a computed property, created by `@computed` or `extendObservable`\n * @param {string} property the name of the property to keep alive\n * @returns {IDisposer} stops this keep alive so that the computed value goes back to normal behavior\n */\n/**\n * @example\n * const number = observable(3)\n * const doubler = computed(() => number.get() * 2)\n * const stop = keepAlive(doubler)\n * // doubler will now stay in sync reactively even when there are no further observers\n * stop()\n * // normal behavior, doubler results will be recomputed if not observed but needed, but lazily\n *\n * @param {IComputedValue} computedValue created using the `computed` function\n * @returns {IDisposer} stops this keep alive so that the computed value goes back to normal behavior\n */\nfunction keepAlive(_1, _2) {\n var computed$$1 = getAtom(_1, _2);\n if (!computed$$1)\n throw new Error(\"No computed provided, please provide an object created with `computed(() => expr)` or an object + property name\");\n return computed$$1.observe(function () { });\n}\n\n/**\n * `queueProcessor` takes an observable array, observes it and calls `processor`\n * once for each item added to the observable array, optionally deboucing the action\n *\n * @example\n * const pendingNotifications = observable([])\n * const stop = queueProcessor(pendingNotifications, msg => {\n * // show Desktop notification\n * new Notification(msg);\n * })\n *\n * // usage:\n * pendingNotifications.push(\"test!\")\n *\n * @param {T[]} observableArray observable array instance to track\n * @param {(item: T) => void} processor action to call per item\n * @param {number} [debounce=0] optional debounce time in ms. With debounce 0 the processor will run synchronously\n * @returns {IDisposer} stops the processor\n */\nfunction queueProcessor(observableArray, processor, debounce) {\n if (debounce === void 0) { debounce = 0; }\n if (!isObservableArray(observableArray))\n throw new Error(\"Expected observable array as first argument\");\n if (!isAction(processor))\n processor = action(\"queueProcessor\", processor);\n var runner = function () {\n // construct a final set\n var items = observableArray.slice(0);\n // clear the queue for next iteration\n runInAction(function () { return observableArray.splice(0); });\n // fire processor\n items.forEach(processor);\n };\n if (debounce > 0)\n return autorun(runner, { delay: debounce });\n else\n return autorun(runner);\n}\n\n/**\n * `chunkProcessor` takes an observable array, observes it and calls `processor`\n * once for a chunk of items added to the observable array, optionally deboucing the action.\n * The maximum chunk size can be limited by number.\n * This allows both, splitting larger into smaller chunks or (when debounced) combining smaller\n * chunks and/or single items into reasonable chunks of work.\n *\n * @example\n * const trackedActions = observable([])\n * const stop = chunkProcessor(trackedActions, chunkOfMax10Items => {\n * sendTrackedActionsToServer(chunkOfMax10Items);\n * }, 100, 10)\n *\n * // usage:\n * trackedActions.push(\"scrolled\")\n * trackedActions.push(\"hoveredButton\")\n * // when both pushes happen within 100ms, there will be only one call to server\n *\n * @param {T[]} observableArray observable array instance to track\n * @param {(item: T[]) => void} processor action to call per item\n * @param {number} [debounce=0] optional debounce time in ms. With debounce 0 the processor will run synchronously\n * @param {number} [maxChunkSize=0] optionally do not call on full array but smaller chunks. With 0 it will process the full array.\n * @returns {IDisposer} stops the processor\n */\nfunction chunkProcessor(observableArray, processor, debounce, maxChunkSize) {\n if (debounce === void 0) { debounce = 0; }\n if (maxChunkSize === void 0) { maxChunkSize = 0; }\n if (!isObservableArray(observableArray))\n throw new Error(\"Expected observable array as first argument\");\n if (!isAction(processor))\n processor = action(\"chunkProcessor\", processor);\n var runner = function () {\n var _loop_1 = function () {\n var chunkSize = maxChunkSize === 0\n ? observableArray.length\n : Math.min(observableArray.length, maxChunkSize);\n // construct a final set\n var items = observableArray.slice(0, chunkSize);\n // clear the slice for next iteration\n runInAction(function () { return observableArray.splice(0, chunkSize); });\n // fire processor\n processor(items);\n };\n while (observableArray.length > 0) {\n _loop_1();\n }\n };\n if (debounce > 0)\n return autorun(runner, { delay: debounce });\n else\n return autorun(runner);\n}\n\nvar tickers = {};\n/**\n * Returns the current date time as epoch number.\n * The date time is read from an observable which is updated automatically after the given interval.\n * So basically it treats time as an observable.\n *\n * The function takes an interval as parameter, which indicates how often `now()` will return a new value.\n * If no interval is given, it will update each second. If \"frame\" is specified, it will update each time a\n * `requestAnimationFrame` is available.\n *\n * Multiple clocks with the same interval will automatically be synchronized.\n *\n * Countdown example: https://jsfiddle.net/mweststrate/na0qdmkw/\n *\n * @example\n *\n * const start = Date.now()\n *\n * autorun(() => {\n * console.log(\"Seconds elapsed: \", (mobxUtils.now() - start) / 1000)\n * })\n *\n *\n * @export\n * @param {(number | \"frame\")} [interval=1000] interval in milliseconds about how often the interval should update\n * @returns\n */\nfunction now(interval) {\n if (interval === void 0) { interval = 1000; }\n if (!_isComputingDerivation()) {\n // See #40\n return Date.now();\n }\n if (!tickers[interval]) {\n if (typeof interval === \"number\")\n tickers[interval] = createIntervalTicker(interval);\n else\n tickers[interval] = createAnimationFrameTicker();\n }\n return tickers[interval].current();\n}\nfunction createIntervalTicker(interval) {\n var subscriptionHandle;\n return fromResource(function (sink) {\n subscriptionHandle = setInterval(function () { return sink(Date.now()); }, interval);\n }, function () {\n clearInterval(subscriptionHandle);\n }, Date.now());\n}\nfunction createAnimationFrameTicker() {\n var frameBasedTicker = fromResource(function (sink) {\n function scheduleTick() {\n window.requestAnimationFrame(function () {\n sink(Date.now());\n if (frameBasedTicker.isAlive())\n scheduleTick();\n });\n }\n scheduleTick();\n }, function () { }, Date.now());\n return frameBasedTicker;\n}\n\nvar __assign$1 = (undefined && undefined.__assign) || function () {\n __assign$1 = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign$1.apply(this, arguments);\n};\n/**\n * _deprecated_ this functionality can now be found as `flow` in the mobx package. However, `flow` is not applicable as decorator, where `asyncAction` still is.\n *\n *\n *\n * `asyncAction` takes a generator function and automatically wraps all parts of the process in actions. See the examples below.\n * `asyncAction` can be used both as decorator or to wrap functions.\n *\n * - It is important that `asyncAction should always be used with a generator function (recognizable as `function*` or `*name` syntax)\n * - Each yield statement should return a Promise. The generator function will continue as soon as the promise settles, with the settled value\n * - When the generator function finishes, you can return a normal value. The `asyncAction` wrapped function will always produce a promise delivering that value.\n *\n * When using the mobx devTools, an asyncAction will emit `action` events with names like:\n * * `\"fetchUsers - runid: 6 - init\"`\n * * `\"fetchUsers - runid: 6 - yield 0\"`\n * * `\"fetchUsers - runid: 6 - yield 1\"`\n *\n * The `runId` represents the generator instance. In other words, if `fetchUsers` is invoked multiple times concurrently, the events with the same `runid` belong together.\n * The `yield` number indicates the progress of the generator. `init` indicates spawning (it won't do anything, but you can find the original arguments of the `asyncAction` here).\n * `yield 0` ... `yield n` indicates the code block that is now being executed. `yield 0` is before the first `yield`, `yield 1` after the first one etc. Note that yield numbers are not determined lexically but by the runtime flow.\n *\n * `asyncActions` requires `Promise` and `generators` to be available on the target environment. Polyfill `Promise` if needed. Both TypeScript and Babel can compile generator functions down to ES5.\n *\n * N.B. due to a [babel limitation](https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy/issues/26), in Babel generatos cannot be combined with decorators. See also [#70](https://github.com/mobxjs/mobx-utils/issues/70)\n *\n *\n * @example\n * import {asyncAction} from \"mobx-utils\"\n *\n * let users = []\n *\n * const fetchUsers = asyncAction(\"fetchUsers\", function* (url) {\n * const start = Date.now()\n * const data = yield window.fetch(url)\n * users = yield data.json()\n * return start - Date.now()\n * })\n *\n * fetchUsers(\"http://users.com\").then(time => {\n * console.dir(\"Got users\", users, \"in \", time, \"ms\")\n * })\n *\n * @example\n * import {asyncAction} from \"mobx-utils\"\n *\n * mobx.configure({ enforceActions: \"observed\" }) // don't allow state modifications outside actions\n *\n * class Store {\n * \t\\@observable githubProjects = []\n * \t\\@state = \"pending\" // \"pending\" / \"done\" / \"error\"\n *\n * \t\\@asyncAction\n * \t*fetchProjects() { // <- note the star, this a generator function!\n * \t\tthis.githubProjects = []\n * \t\tthis.state = \"pending\"\n * \t\ttry {\n * \t\t\tconst projects = yield fetchGithubProjectsSomehow() // yield instead of await\n * \t\t\tconst filteredProjects = somePreprocessing(projects)\n * \t\t\t// the asynchronous blocks will automatically be wrapped actions\n * \t\t\tthis.state = \"done\"\n * \t\t\tthis.githubProjects = filteredProjects\n * \t\t} catch (error) {\n * \t\t\tthis.state = \"error\"\n * \t\t}\n * \t}\n * }\n *\n * @export\n * @returns {Promise}\n */\nfunction asyncAction(arg1, arg2) {\n // decorator\n if (typeof arguments[1] === \"string\") {\n var name_1 = arguments[1];\n var descriptor_1 = arguments[2];\n if (descriptor_1 && descriptor_1.value) {\n return Object.assign({}, descriptor_1, {\n value: flow(descriptor_1.value)\n });\n }\n else {\n return Object.assign({}, descriptor_1, {\n set: function (v) {\n Object.defineProperty(this, name_1, __assign$1(__assign$1({}, descriptor_1), { value: flow(v) }));\n }\n });\n }\n }\n // direct invocation\n var generator = typeof arg1 === \"string\" ? arg2 : arg1;\n deprecated(\"asyncAction is deprecated. use mobx.flow instead\");\n return flow(generator); // name get's dropped..\n}\n\n/**\n * _deprecated_ whenAsync is deprecated, use mobx.when without effect instead.\n *\n * Like normal `when`, except that this `when` will return a promise that resolves when the expression becomes truthy\n *\n * @example\n * await whenAsync(() => !state.someBoolean)\n *\n * @export\n * @param {() => boolean} fn see when, the expression to await\n * @param {number} timeout maximum amount of time to wait, before the promise rejects\n * @returns Promise for when an observable eventually matches some condition. Rejects if timeout is provided and has expired\n */\nfunction whenAsync(fn, timeout) {\n if (timeout === void 0) { timeout = 0; }\n deprecated(\"whenAsync is deprecated, use mobx.when without effect instead\");\n return when(fn, {\n timeout: timeout\n });\n}\n\n/**\n * expr can be used to create temporarily views inside views.\n * This can be improved to improve performance if a value changes often, but usually doesn't affect the outcome of an expression.\n *\n * In the following example the expression prevents that a component is rerender _each time_ the selection changes;\n * instead it will only rerenders when the current todo is (de)selected.\n *\n * @example\n * const Todo = observer((props) => {\n * const todo = props.todo;\n * const isSelected = mobxUtils.expr(() => props.viewState.selection === todo);\n * return
{todo.title}
\n * });\n *\n */\nfunction expr(expr) {\n if (!_isComputingDerivation())\n console.warn(\"'expr' should only be used inside other reactive functions.\");\n // optimization: would be more efficient if the expr itself wouldn't be evaluated first on the next change, but just a 'changed' signal would be fired\n return computed(expr).get();\n}\n\nvar memoizationId = 0;\nfunction createTransformer(transformer, arg2) {\n invariant(typeof transformer === \"function\" && transformer.length < 2, \"createTransformer expects a function that accepts one argument\");\n // Memoizes: object id -> reactive view that applies transformer to the object\n var views = {};\n var onCleanup = undefined;\n var debugNameGenerator = undefined;\n function createView(sourceIdentifier, sourceObject) {\n var latestValue;\n if (typeof arg2 === \"object\") {\n onCleanup = arg2.onCleanup;\n debugNameGenerator = arg2.debugNameGenerator;\n }\n else if (typeof arg2 === \"function\") {\n onCleanup = arg2;\n }\n else {\n onCleanup = undefined;\n debugNameGenerator = undefined;\n }\n var prettifiedName = debugNameGenerator\n ? debugNameGenerator(sourceObject)\n : \"Transformer-\" + transformer.name + \"-\" + sourceIdentifier;\n var expr = computed(function () {\n return (latestValue = transformer(sourceObject));\n }, {\n name: prettifiedName\n });\n var disposer = onBecomeUnobserved(expr, function () {\n delete views[sourceIdentifier];\n disposer();\n if (onCleanup)\n onCleanup(latestValue, sourceObject);\n });\n return expr;\n }\n return function (object) {\n var identifier = getMemoizationId(object);\n var reactiveView = views[identifier];\n if (reactiveView)\n return reactiveView.get();\n // Not in cache; create a reactive view\n reactiveView = views[identifier] = createView(identifier, object);\n return reactiveView.get();\n };\n}\nfunction getMemoizationId(object) {\n var objectType = typeof object;\n if (objectType === \"string\")\n return \"string:\" + object;\n if (objectType === \"number\")\n return \"number:\" + object;\n if (object === null || (objectType !== \"object\" && objectType !== \"function\"))\n throw new Error(\"[mobx-utils] transform expected an object, function, string or number, got: \" + String(object));\n var tid = object.$transformId;\n if (tid === undefined) {\n tid = \"memoizationId:\" + ++memoizationId;\n addHiddenProp(object, \"$transformId\", tid);\n }\n return tid;\n}\n\nfunction buildPath(entry) {\n var res = [];\n while (entry.parent) {\n res.push(entry.path);\n entry = entry.parent;\n }\n return res.reverse().join(\"/\");\n}\nfunction isRecursivelyObservable(thing) {\n return isObservableObject(thing) || isObservableArray(thing) || isObservableMap(thing);\n}\n/**\n * Given an object, deeply observes the given object.\n * It is like `observe` from mobx, but applied recursively, including all future children.\n *\n * Note that the given object cannot ever contain cycles and should be a tree.\n *\n * As benefit: path and root will be provided in the callback, so the signature of the listener is\n * (change, path, root) => void\n *\n * The returned disposer can be invoked to clean up the listener\n *\n * deepObserve cannot be used on computed values.\n *\n * @example\n * const disposer = deepObserve(target, (change, path) => {\n * console.dir(change)\n * })\n */\nfunction deepObserve(target, listener) {\n var entrySet = new WeakMap();\n function genericListener(change) {\n var entry = entrySet.get(change.object);\n processChange(change, entry);\n listener(change, buildPath(entry), target);\n }\n function processChange(change, parent) {\n switch (change.type) {\n // Object changes\n case \"add\": // also for map\n observeRecursively(change.newValue, parent, change.name);\n break;\n case \"update\": // also for array and map\n unobserveRecursively(change.oldValue);\n observeRecursively(change.newValue, parent, change.name || \"\" + change.index);\n break;\n case \"remove\": // object\n case \"delete\": // map\n unobserveRecursively(change.oldValue);\n break;\n // Array changes\n case \"splice\":\n change.removed.map(unobserveRecursively);\n change.added.forEach(function (value, idx) {\n return observeRecursively(value, parent, \"\" + (change.index + idx));\n });\n // update paths\n for (var i = change.index + change.addedCount; i < change.object.length; i++) {\n if (isRecursivelyObservable(change.object[i])) {\n var entry = entrySet.get(change.object[i]);\n if (entry)\n entry.path = \"\" + i;\n }\n }\n break;\n }\n }\n function observeRecursively(thing, parent, path) {\n if (isRecursivelyObservable(thing)) {\n if (entrySet.has(thing)) {\n var entry = entrySet.get(thing);\n if (entry.parent !== parent || entry.path !== path)\n // MWE: this constraint is artificial, and this tool could be made to work with cycles,\n // but it increases administration complexity, has tricky edge cases and the meaning of 'path'\n // would become less clear. So doesn't seem to be needed for now\n throw new Error(\"The same observable object cannot appear twice in the same tree, trying to assign it to '\" + buildPath(parent) + \"/\" + path + \"', but it already exists at '\" + buildPath(entry.parent) + \"/\" + entry.path + \"'\");\n }\n else {\n var entry_1 = {\n parent: parent,\n path: path,\n dispose: observe(thing, genericListener)\n };\n entrySet.set(thing, entry_1);\n entries(thing).forEach(function (_a) {\n var key = _a[0], value = _a[1];\n return observeRecursively(value, entry_1, key);\n });\n }\n }\n }\n function unobserveRecursively(thing) {\n if (isRecursivelyObservable(thing)) {\n var entry = entrySet.get(thing);\n if (!entry)\n return;\n entrySet.delete(thing);\n entry.dispose();\n values(thing).forEach(unobserveRecursively);\n }\n }\n observeRecursively(target, undefined, \"\");\n return function () {\n unobserveRecursively(target);\n };\n}\n\n/**\n * @private\n */\nvar DeepMapEntry = /** @class */ (function () {\n function DeepMapEntry(base, args) {\n this.base = base;\n this.args = args;\n this.closestIdx = 0;\n this.isDisposed = false;\n var current = (this.closest = this.root = base);\n var i = 0;\n for (; i < this.args.length - 1; i++) {\n current = current.get(args[i]);\n if (current)\n this.closest = current;\n else\n break;\n }\n this.closestIdx = i;\n }\n DeepMapEntry.prototype.exists = function () {\n this.assertNotDisposed();\n var l = this.args.length;\n return this.closestIdx >= l - 1 && this.closest.has(this.args[l - 1]);\n };\n DeepMapEntry.prototype.get = function () {\n this.assertNotDisposed();\n if (!this.exists())\n throw new Error(\"Entry doesn't exist\");\n return this.closest.get(this.args[this.args.length - 1]);\n };\n DeepMapEntry.prototype.set = function (value) {\n this.assertNotDisposed();\n var l = this.args.length;\n var current = this.closest;\n // create remaining maps\n for (var i = this.closestIdx; i < l - 1; i++) {\n var m = new Map();\n current.set(this.args[i], m);\n current = m;\n }\n this.closestIdx = l - 1;\n this.closest = current;\n current.set(this.args[l - 1], value);\n };\n DeepMapEntry.prototype.delete = function () {\n this.assertNotDisposed();\n if (!this.exists())\n throw new Error(\"Entry doesn't exist\");\n var l = this.args.length;\n this.closest.delete(this.args[l - 1]);\n // clean up remaining maps if needed (reconstruct stack first)\n var c = this.root;\n var maps = [c];\n for (var i = 0; i < l - 1; i++) {\n c = c.get(this.args[i]);\n maps.push(c);\n }\n for (var i = maps.length - 1; i > 0; i--) {\n if (maps[i].size === 0)\n maps[i - 1].delete(this.args[i - 1]);\n }\n this.isDisposed = true;\n };\n DeepMapEntry.prototype.assertNotDisposed = function () {\n // TODO: once this becomes annoying, we should introduce a reset method to re-run the constructor logic\n if (this.isDisposed)\n throw new Error(\"Concurrent modification exception\");\n };\n return DeepMapEntry;\n}());\n/**\n * @private\n */\nvar DeepMap = /** @class */ (function () {\n function DeepMap() {\n this.store = new Map();\n this.argsLength = -1;\n }\n DeepMap.prototype.entry = function (args) {\n if (this.argsLength === -1)\n this.argsLength = args.length;\n else if (this.argsLength !== args.length)\n throw new Error(\"DeepMap should be used with functions with a consistent length, expected: \" + this.argsLength + \", got: \" + args.length);\n if (this.last)\n this.last.isDisposed = true;\n return (this.last = new DeepMapEntry(this.store, args));\n };\n return DeepMap;\n}());\n\nvar __assign$2 = (undefined && undefined.__assign) || function () {\n __assign$2 = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign$2.apply(this, arguments);\n};\n/**\n * computedFn takes a function with an arbitrarily amount of arguments,\n * and memoized the output of the function based on the arguments passed in.\n *\n * computedFn(fn) returns a function with the very same signature. There is no limit on the amount of arguments\n * that is accepted. However, the amount of arguments must be consistent and default arguments are not supported.\n *\n * By default the output of a function call will only be memoized as long as the\n * output is being observed.\n *\n * The function passes into `computedFn` should be pure, not be an action and only be relying on\n * observables.\n *\n * Setting `keepAlive` to `true` will cause the output to be forcefully cached forever.\n * Note that this might introduce memory leaks!\n *\n * @example\n * const store = observable({\n a: 1,\n b: 2,\n c: 3,\n m: computedFn(function(x) {\n return this.a * this.b * x\n })\n })\n\n const d = autorun(() => {\n // store.m(3) will be cached as long as this autorun is running\n console.log((store.m(3) * store.c))\n })\n *\n * @param fn\n * @param keepAliveOrOptions\n */\nfunction computedFn(fn, keepAliveOrOptions) {\n if (keepAliveOrOptions === void 0) { keepAliveOrOptions = false; }\n if (isAction(fn))\n throw new Error(\"computedFn shouldn't be used on actions\");\n var memoWarned = false;\n var i = 0;\n var opts = typeof keepAliveOrOptions === \"boolean\"\n ? { keepAlive: keepAliveOrOptions }\n : keepAliveOrOptions;\n var d = new DeepMap();\n return function () {\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n var self = this;\n var entry = d.entry(args);\n // cache hit, return\n if (entry.exists())\n return entry.get().get();\n // if function is invoked, and its a cache miss without reactive, there is no point in caching...\n if (!opts.keepAlive && !_isComputingDerivation()) {\n if (!memoWarned) {\n console.warn(\"invoking a computedFn from outside an reactive context won't be memoized, unless keepAlive is set\");\n memoWarned = true;\n }\n return fn.apply(self, args);\n }\n // create new entry\n var c = computed(function () {\n return fn.apply(self, args);\n }, __assign$2(__assign$2({}, opts), { name: \"computedFn(\" + fn.name + \"#\" + ++i + \")\" }));\n entry.set(c);\n // clean up if no longer observed\n if (!opts.keepAlive)\n onBecomeUnobserved(c, function () {\n d.entry(args).delete();\n });\n // return current val\n return c.get();\n };\n}\n\nfunction decorateMethodOrField(decoratorName, decorateFn, target, prop, descriptor) {\n if (descriptor) {\n return decorateMethod(decoratorName, decorateFn, prop, descriptor);\n }\n else {\n decorateField(decorateFn, target, prop);\n }\n}\nfunction decorateMethod(decoratorName, decorateFn, prop, descriptor) {\n if (descriptor.get !== undefined) {\n return fail(decoratorName + \" cannot be used with getters\");\n }\n // babel / typescript\n // @action method() { }\n if (descriptor.value) {\n // typescript\n return {\n value: decorateFn(prop, descriptor.value),\n enumerable: false,\n configurable: true,\n writable: true // for typescript, this must be writable, otherwise it cannot inherit :/ (see inheritable actions test)\n };\n }\n // babel only: @action method = () => {}\n var initializer = descriptor.initializer;\n return {\n enumerable: false,\n configurable: true,\n writable: true,\n initializer: function () {\n // N.B: we can't immediately invoke initializer; this would be wrong\n return decorateFn(prop, initializer.call(this));\n }\n };\n}\nfunction decorateField(decorateFn, target, prop) {\n // Simple property that writes on first invocation to the current instance\n Object.defineProperty(target, prop, {\n configurable: true,\n enumerable: false,\n get: function () {\n return undefined;\n },\n set: function (value) {\n addHiddenProp(this, prop, decorateFn(prop, value));\n }\n });\n}\n\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (undefined && undefined.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar runId = 0;\nvar unfinishedIds = new Set();\nvar currentlyActiveIds = new Set();\nvar taskOrderPromise = Promise.resolve();\nvar emptyFunction = function () { };\nvar actionAsyncContextStack = [];\nfunction task(value) {\n return __awaiter(this, void 0, void 0, function () {\n var ctx, runId, actionName, args, scope, actionRunInfo, step, nextStep, ret, actionRunInfo_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n ctx = actionAsyncContextStack[actionAsyncContextStack.length - 1];\n if (!ctx) {\n fail$1(\"'actionAsync' context not present when running 'task'. did you await inside an 'actionAsync' without using 'task(promise)'? did you forget to await the task?\");\n }\n runId = ctx.runId, actionName = ctx.actionName, args = ctx.args, scope = ctx.scope, actionRunInfo = ctx.actionRunInfo, step = ctx.step;\n nextStep = step + 1;\n actionAsyncContextStack.pop();\n _endAction(actionRunInfo);\n currentlyActiveIds.delete(runId);\n _a.label = 1;\n case 1:\n _a.trys.push([1, , 4, 5]);\n return [4 /*yield*/, value\n // we use this trick to force a proper order of execution\n // even for immediately resolved promises\n ];\n case 2:\n ret = _a.sent();\n // we use this trick to force a proper order of execution\n // even for immediately resolved promises\n taskOrderPromise = taskOrderPromise.then(emptyFunction);\n return [4 /*yield*/, taskOrderPromise];\n case 3:\n _a.sent();\n return [2 /*return*/, ret];\n case 4:\n // only restart if it not a dangling promise (the action is not yet finished)\n if (unfinishedIds.has(runId)) {\n actionRunInfo_1 = _startAction(getActionAsyncName(actionName, runId, nextStep), this, args);\n actionAsyncContextStack.push({\n runId: runId,\n step: nextStep,\n actionRunInfo: actionRunInfo_1,\n actionName: actionName,\n args: args,\n scope: scope\n });\n currentlyActiveIds.add(runId);\n }\n return [7 /*endfinally*/];\n case 5: return [2 /*return*/];\n }\n });\n });\n}\n// base\n/**\n * Alternative syntax for async actions, similar to `flow` but more compatible with\n * Typescript typings. Not to be confused with `asyncAction`, which is deprecated.\n *\n * `actionAsync` can be used either as a decorator or as a function.\n * It takes an async function that internally must use `await task(promise)` rather than\n * the standard `await promise`.\n *\n * When using the mobx devTools, an asyncAction will emit `action` events with names like:\n * * `\"fetchUsers - runid 6 - step 0\"`\n * * `\"fetchUsers - runid 6 - step 1\"`\n * * `\"fetchUsers - runid 6 - step 2\"`\n *\n * The `runId` represents the action instance. In other words, if `fetchUsers` is invoked\n * multiple times concurrently, the events with the same `runid` belong together.\n * The `step` number indicates the code block that is now being executed.\n *\n * @example\n * import {actionAsync, task} from \"mobx-utils\"\n *\n * let users = []\n *\n * const fetchUsers = actionAsync(\"fetchUsers\", async (url) => {\n * const start = Date.now()\n * // note the use of task when awaiting!\n * const data = await task(window.fetch(url))\n * users = await task(data.json())\n * return start - Date.now()\n * })\n *\n * const time = await fetchUsers(\"http://users.com\")\n * console.log(\"Got users\", users, \"in \", time, \"ms\")\n *\n * @example\n * import {actionAsync, task} from \"mobx-utils\"\n *\n * mobx.configure({ enforceActions: \"observed\" }) // don't allow state modifications outside actions\n *\n * class Store {\n * \\@observable githubProjects = []\n * \\@state = \"pending\" // \"pending\" / \"done\" / \"error\"\n *\n * \\@actionAsync\n * async fetchProjects() {\n * this.githubProjects = []\n * this.state = \"pending\"\n * try {\n * // note the use of task when awaiting!\n * const projects = await task(fetchGithubProjectsSomehow())\n * const filteredProjects = somePreprocessing(projects)\n * // the asynchronous blocks will automatically be wrapped actions\n * this.state = \"done\"\n * this.githubProjects = filteredProjects\n * } catch (error) {\n * this.state = \"error\"\n * }\n * }\n * }\n */\nfunction actionAsync(arg1, arg2, arg3) {\n // decorator\n if (typeof arguments[1] === \"string\") {\n return decorateMethodOrField(\"@actionAsync\", function (prop, v) {\n return actionAsyncFn(prop, v);\n }, arg1, arg2, arg3);\n }\n // direct invocation\n var actionName = typeof arg1 === \"string\" ? arg1 : arg1.name || \"\";\n var fn = typeof arg1 === \"function\" ? arg1 : arg2;\n return actionAsyncFn(actionName, fn);\n}\nfunction actionAsyncFn(actionName, fn) {\n if (!_startAction || !_endAction) {\n fail$1(\"'actionAsync' requires mobx >=5.13.1 or >=4.13.1\");\n }\n invariant(typeof fn === \"function\", \"'asyncAction' expects a function\");\n if (typeof actionName !== \"string\" || !actionName)\n fail$1(\"actions should have valid names, got: '\" + actionName + \"'\");\n return function () {\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n return __awaiter(this, void 0, void 0, function () {\n var nextRunId, actionRunInfo, finish, promise, ret, err_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n nextRunId = runId++;\n unfinishedIds.add(nextRunId);\n actionRunInfo = _startAction(getActionAsyncName(actionName, nextRunId, 0), this, args);\n actionAsyncContextStack.push({\n runId: nextRunId,\n step: 0,\n actionRunInfo: actionRunInfo,\n actionName: actionName,\n args: args,\n scope: this\n });\n currentlyActiveIds.add(nextRunId);\n finish = function (err) {\n unfinishedIds.delete(nextRunId);\n var ctx = actionAsyncContextStack.pop();\n if (!ctx || ctx.runId !== nextRunId) {\n // push it back if invalid\n if (ctx) {\n actionAsyncContextStack.push(ctx);\n }\n var msg = \"invalid 'actionAsync' context when finishing action '\" + actionName + \"'.\";\n if (!ctx) {\n msg += \" no action context could be found instead.\";\n }\n else {\n msg += \" an action context for '\" + ctx.actionName + \"' was found instead.\";\n }\n msg +=\n \" did you await inside an 'actionAsync' without using 'task(promise)'? did you forget to await the task?\";\n fail$1(msg);\n }\n ctx.actionRunInfo.error = err;\n _endAction(ctx.actionRunInfo);\n currentlyActiveIds.delete(nextRunId);\n if (err) {\n throw err;\n }\n };\n try {\n promise = fn.apply(this, args);\n }\n catch (err) {\n finish(err);\n }\n // are we done sync? (no task run)\n if (currentlyActiveIds.has(nextRunId)) {\n finish(undefined);\n return [2 /*return*/, promise];\n }\n _a.label = 1;\n case 1:\n _a.trys.push([1, 3, , 4]);\n return [4 /*yield*/, promise];\n case 2:\n ret = _a.sent();\n return [3 /*break*/, 4];\n case 3:\n err_1 = _a.sent();\n finish(err_1);\n return [3 /*break*/, 4];\n case 4:\n finish(undefined);\n return [2 /*return*/, ret];\n }\n });\n });\n };\n}\nfunction getActionAsyncName(actionName, runId, step) {\n return actionName + \" - runid \" + runId + \" - step \" + step;\n}\n\nexport { computedFn, actionAsync, task, PENDING, FULFILLED, REJECTED, fromPromise, isPromiseBasedObservable, moveItem, lazyObservable, fromResource, toStream, fromStream, ViewModel, createViewModel, whenWithTimeout, keepAlive, queueProcessor, chunkProcessor, now, NOOP, IDENTITY, fail$1 as fail, invariant, deprecated, addHiddenProp, getAllMethodsAndProperties, asyncAction, whenAsync, expr, createTransformer, deepObserve };\n"], "mappings": "yMAAAA,IAAAC,IAIA,SAASC,EAAOC,EAAS,CACrB,MAAM,IAAI,MAAM,gBAAkBA,CAAO,CAC7C,CAFSC,EAAAF,EAAA,UAGT,SAASG,EAAUC,EAAMH,EAAS,CAC1BA,IAAY,SAAUA,EAAU,iBAC/BG,GACDJ,EAAOC,CAAO,CACtB,CAJSC,EAAAC,EAAA,aAYT,SAASE,EAAcC,EAAQC,EAAUC,EAAO,CAC5C,OAAO,eAAeF,EAAQC,EAAU,CACpC,WAAY,GACZ,SAAU,GACV,aAAc,GACd,M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AAO,KAAM,EAAEJ,EAAI,GAAI,CAAC,CAAC,EACxF,OAAAY,EAAM,IAAIlB,CAAC,EAENc,EAAK,WACNO,EAAmBrB,EAAG,UAAY,CAC9Be,EAAE,MAAMrB,CAAI,EAAE,OAAO,CACzB,CAAC,EAEEM,EAAE,IAAI,CACjB,CACJ,CAzCSJ,EAAAa,GAAA,cAmIT,IAAIa,GAAmB,QAAQ,QAAQ", "names": ["init_virtual_process_polyfill", "init_buffer", "fail$1", "message", "__name", "invariant", "cond", "addHiddenProp", "object", "propName", "value", "__name", "deepFields", "x", "distinctDeepFields", "deepFieldsIndistinct", "deepFieldsDistinct", "item", "index", "getAllMethodsAndProperties", "name", "PENDING", "FULFILLED", "REJECTED", "caseImpl", "handlers", "createObservablePromise", "origPromise", "oldPromise", "invariant", "promise", "action", "reason", "oldData", "extendObservable", "fromPromise", "p", "__decorate", "decorators", "target", "key", "desc", "c", "r", "d", "i", "StreamListener", "observable$$1", "initialValue", "_this", "runInAction", "__name", "value", "__decorate", "observable", "action", "__assign", "t", "s", "i", "n", "p", "__decorate$1", "decorators", "target", "key", "desc", "c", "r", "d", "RESERVED_NAMES", "ViewModel", "model", "_this", "observable", "invariant", "isObservableObject", "getAllMethodsAndProperties", "$mobx", "isComputedProp", "derivation", "getAdministration", "computed", "descriptor", "additionalDescriptor", "action", "value", "__name", "keys", "source", "destination", "isObservableArray", "isObservableMap", "isComputed", "createViewModel", "memoizationId", "createTransformer", "transformer", "arg2", "invariant", "views", "onCleanup", "debugNameGenerator", "createView", "sourceIdentifier", "sourceObject", "latestValue", "prettifiedName", "expr", "computed", "disposer", "onBecomeUnobserved", "__name", "object", "identifier", "getMemoizationId", "reactiveView", "objectType", "tid", "addHiddenProp", "DeepMapEntry", "base", "args", "current", "__name", "l", "value", "m", "c", "maps", "DeepMap", "__assign$2", "t", "s", "i", "n", "p", "computedFn", "fn", "keepAliveOrOptions", "isAction", "memoWarned", "opts", "d", "_i", "self", "entry", "isComputingDerivation", "computed", "onBecomeUnobserved", "taskOrderPromise"] }