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QAAO,IAGrE,GAmCJ,EAAQ,iBAAmB,EAC3B,EAAQ,aAjCc,GAAU,GAAW,EAAO,KAAK,IAAI,EAAa,GAloBxE,WACI,GAAI,EAAE,KAAM,CACR,IAAI,EAAO,EAAE,KAAK,QAClB,OAAI,EAAK,OAAS,EACP,EAAK,OAET,CACX,CACJ,CA0nBgF,KAmChF,OAAO,eAAe,EAAS,aAAc,CAAE,OAAO,GAEzD","file":"/npm/meteor-rxjs@0.4.14/dist/bundles/index.umd.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/meteor-rxjs@0.4.14/dist/bundles/index.umd.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","(function (global, factory) {\n    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs')) :\n    typeof define === 'function' && define.amd ? define(['exports', 'rxjs'], factory) :\n    (factory((global.meteor = global.meteor || {}, global.meteor.rxjs = {}),null));\n}(this, (function (exports,rxjs) { 'use strict';\n\n    const subscribeEvents = ['onReady', 'onError', 'onStop'];\n    function isFunction(fn) {\n        return typeof fn === 'function';\n    }\n    function isMeteorCallbacks(callbacks) {\n        return isFunction(callbacks) || isCallbacksObject(callbacks);\n    }\n    // Checks if callbacks of {@link CallbacksObject} type.\n    function isCallbacksObject(callbacks) {\n        return callbacks && subscribeEvents.some((event) => {\n            return isFunction(callbacks[event]);\n        });\n    }\n    const g = typeof global === 'object' ? global :\n        typeof window === 'object' ? window :\n            typeof self === 'object' ? self : undefined;\n    const METEOR_RXJS_ZONE = 'meteor-rxjs-zone';\n    const fakeZone = {\n        name: METEOR_RXJS_ZONE,\n        run(func) {\n            return func();\n        },\n        fork(spec) {\n            return fakeZone;\n        }\n    };\n    function forkZone() {\n        if (g.Zone) {\n            let zone = g.Zone.current;\n            if (zone.name === METEOR_RXJS_ZONE) {\n                zone = zone.parent || fakeZone;\n            }\n            return zone.fork({ name: METEOR_RXJS_ZONE });\n        }\n        return fakeZone;\n    }\n    function getZone() {\n        if (g.Zone) {\n            let zone = g.Zone.current;\n            if (zone.name === METEOR_RXJS_ZONE) {\n                return zone.parent;\n            }\n            return zone;\n        }\n    }\n    function removeObserver(observers, observer, onEmpty) {\n        let index = observers.indexOf(observer);\n        observers.splice(index, 1);\n        if (observers.length === 0 && onEmpty) {\n            onEmpty();\n        }\n    }\n    const gZone = g.Zone ? g.Zone.current : fakeZone;\n\n    class ObservableCursor extends rxjs.Observable {\n        /**\n         * @constructor\n         * @extends Observable\n         * @param {Mongo.Cursor<T>} cursor - The Mongo.Cursor to wrap.\n         */\n        constructor(cursor) {\n            super((observer) => {\n                this._observers.push(observer);\n                if (!this._hCursor) {\n                    this._hCursor = this._observeCursor(cursor);\n                }\n                Meteor.setTimeout(() => {\n                    if (this._isDataInitinialized) {\n                        observer.next(this._data);\n                    }\n                    else if (cursor.count() === 0) {\n                        this._isDataInitinialized = true;\n                        observer.next(this._data);\n                    }\n                }, 0);\n                return () => {\n                    removeObserver(this._observers, observer, () => this.stop());\n                };\n            });\n            this._data = [];\n            this._observers = [];\n            this._countObserver = new rxjs.Subject();\n            this._isDataInitinialized = false;\n            for (const key in cursor) {\n                if (key !== 'count' && key !== 'map') {\n                    this[key] = cursor[key];\n                }\n            }\n            this._cursor = cursor;\n            this._zone = forkZone();\n        }\n        /**\n         *  Static method which creates an ObservableCursor from Mongo.Cursor.\n         *  Use this to create an ObservableCursor object from an existing Mongo.Cursor.\n         *  Prefer to create an Cursors from the ObservableCollection instance instead.\n         *\n         *  @param {Mongo.Cursor<T>} cursor - The Mongo.Cursor to wrap.\n         *  @static\n         *  @returns {ObservableCursor} Wrapped Cursor.\n         */\n        static create(cursor) {\n            return new ObservableCursor(cursor);\n        }\n        /**\n         * Returns the actual Mongo.Cursor that wrapped by current ObservableCursor instance.\n         * @return {Mongo.Cursor<T>} The actual MongoDB Cursor.\n         */\n        get cursor() {\n            return this._cursor;\n        }\n        /**\n         * A wrapper for Mongo.Cursor.count() method - returns an Observable of number, which\n         * triggers each time there is a change in the collection, and exposes the number of\n         * objects in the collection.\n         * @returns {Observable} Observable which trigger the callback when the\n         * count of the object changes.\n         */\n        collectionCount() {\n            return this._countObserver.asObservable();\n        }\n        /**\n         * Stops the observation on the cursor.\n         */\n        stop() {\n            this._zone.run(() => {\n                this._runComplete();\n            });\n            if (this._hCursor) {\n                this._hCursor.stop();\n            }\n            this._data = [];\n            this._hCursor = null;\n        }\n        /**\n         * Clears the Observable definition.\n         * Use this method only when the Observable is still cold, and there are no active subscriptions yet.\n         */\n        dispose() {\n            this._observers = null;\n            this._cursor = null;\n        }\n        /**\n         * Return all matching documents as an Array.\n         *\n         * @return {Array<T>} The array with the matching documents.\n         */\n        fetch() {\n            return this._cursor.fetch();\n        }\n        /**\n         * Watch a query. Receive callbacks as the result set changes.\n         * @param {Mongo.ObserveCallbacks} callbacks - The callbacks object.\n         * @return {Meteor.LiveQueryHandle} The array with the matching documents.\n         */\n        observe(callbacks) {\n            return this._cursor.observe(callbacks);\n        }\n        /**\n         * Watch a query. Receive callbacks as the result set changes.\n         * Only the differences between the old and new documents are passed to the callbacks.\n         * @param {Mongo.ObserveChangesCallbacks} callbacks - The callbacks object.\n         * @return {Meteor.LiveQueryHandle} The array with the matching documents.\n         */\n        observeChanges(callbacks) {\n            return this._cursor.observeChanges(callbacks);\n        }\n        _runComplete() {\n            this._countObserver.complete();\n            this._observers.forEach(observer => {\n                observer.complete();\n            });\n        }\n        _runNext(data) {\n            this._countObserver.next(this._data.length);\n            this._observers.forEach(observer => {\n                observer.next(data);\n            });\n        }\n        _addedAt(doc, at, before) {\n            this._data.splice(at, 0, doc);\n            this._handleChange();\n        }\n        _changedAt(doc, old, at) {\n            this._data[at] = doc;\n            this._handleChange();\n        }\n        _removedAt(doc, at) {\n            this._data.splice(at, 1);\n            this._handleChange();\n        }\n        _movedTo(doc, fromIndex, toIndex) {\n            this._data.splice(fromIndex, 1);\n            this._data.splice(toIndex, 0, doc);\n            this._handleChange();\n        }\n        _handleChange() {\n            this._isDataInitinialized = true;\n            this._zone.run(() => {\n                this._runNext(this._data);\n            });\n        }\n        _observeCursor(cursor) {\n            return gZone.run(() => cursor.observe({\n                addedAt: this._addedAt.bind(this),\n                changedAt: this._changedAt.bind(this),\n                movedTo: this._movedTo.bind(this),\n                removedAt: this._removedAt.bind(this)\n            }));\n        }\n    }\n\n    (function (MongoObservable) {\n        /**\n         *  Creates a new MongoObservable.Collection from an existing of predefined Mongo.Collection.\n         *  Use this feature to wrap existing collections such as Meteor.users.\n         *  @param {Mongo.Collection} collection - The collection.\n         *  @returns {MongoObservable.Collection} - Wrapped collection.\n         *  @static\n         */\n        function fromExisting(collection) {\n            return new MongoObservable.Collection(collection);\n        }\n        MongoObservable.fromExisting = fromExisting;\n        /**\n         * A class represents a MongoDB collection in the client side, wrapped with RxJS\n         * Observables, so you can use it with your Angular 2 easier.\n         * The wrapper has the same API as Mongo.Collection, only the \"find\" method returns\n         * an ObservableCursor instead of regular Mongo.Cursor.\n         *\n         * T is a generic type - should be used with the type of the objects inside the collection.\n         */\n        class Collection {\n            /**\n             *  Creates a new Mongo.Collection instance wrapped with Observable features.\n             *  @param {String | Mongo.Collection} nameOrExisting - The name of the collection. If null, creates an\n             *  unmanaged (unsynchronized) local collection. If provided an instance of existing collection, will\n             *  create a wrapper for the existing Mongo.Collection.\n             *  @param {ConstructorOptions} options - Creation options.\n             *  @constructor\n             */\n            constructor(nameOrExisting, \n            // tslint:disable-next-line:align\n            options) {\n                if (nameOrExisting instanceof Mongo.Collection) {\n                    this._collection = nameOrExisting;\n                }\n                else {\n                    this._collection = new Mongo.Collection(nameOrExisting, options);\n                }\n            }\n            /**\n             *  Returns the Mongo.Collection object that wrapped with the MongoObservable.Collection.\n             *  @returns {Mongo.Collection<T>} The Collection instance\n             */\n            get collection() {\n                return this._collection;\n            }\n            /**\n             *  Allow users to write directly to this collection from client code, subject to limitations you define.\n             *\n             *  @returns {Boolean}\n             */\n            allow(options) {\n                return this._collection.allow(options);\n            }\n            /**\n             *  Override allow rules.\n             *\n             *  @returns {Boolean}\n             */\n            deny(options) {\n                return this._collection.deny(options);\n            }\n            /**\n             *  Returns the Collection object corresponding to this collection from the npm\n             *  mongodb driver module which is wrapped by Mongo.Collection.\n             *\n             *  @returns {Mongo.Collection} The Collection instance\n             *\n             * @see {@link https://docs.meteor.com/api/collections.html#Mongo-Collection-rawCollection|rawCollection on Meteor documentation}\n             */\n            rawCollection() {\n                return this._collection.rawCollection();\n            }\n            /**\n             *  Returns the Db object corresponding to this collection's database connection from the\n             *  npm mongodb driver module which is wrapped by Mongo.Collection.\n             *\n             *  @returns {Mongo.Db} The Db instance\n             *\n             * @see {@link https://docs.meteor.com/api/collections.html#Mongo-Collection-rawDatabase|rawDatabase on Meteor documentation}\n             */\n            rawDatabase() {\n                return this._collection.rawDatabase();\n            }\n            /**\n             *  Insert a document in the collection.\n             *\n             *  @param {T} doc - The document to insert. May not yet have an _id\n             *  attribute, in which case Meteor will generate one for you.\n             *  @returns {Observable<string>} Observable which completes with the inserted ObjectId\n             *\n             * @see {@link https://docs.meteor.com/api/collections.html#Mongo-Collection-insert|insert on Meteor documentation}\n             */\n            insert(doc) {\n                let observers = [];\n                let obs = this._createObservable(observers);\n                this._collection.insert(doc, (error, docId) => {\n                    observers.forEach(observer => {\n                        error ? observer.error(error) :\n                            observer.next(docId);\n                        observer.complete();\n                    });\n                });\n                return obs;\n            }\n            /**\n             *  Remove documents from the collection.\n             *\n             *  @param {Collection~MongoQueryMongo.Selector} selector - Specifies which documents to modify\n             *  @returns {Observable<Number>} Observable which completes with the number of affected rows\n             *\n             * @see {@link https://docs.meteor.com/api/collections.html#Mongo-Collection-remove|remove on Meteor documentation}\n             */\n            remove(selector) {\n                let observers = [];\n                let obs = this._createObservable(observers);\n                this._collection.remove(selector, (error, removed) => {\n                    observers.forEach(observer => {\n                        error ? observer.error(error) :\n                            observer.next(removed);\n                        observer.complete();\n                    });\n                });\n                return obs;\n            }\n            /**\n             *  Modify one or more documents in the collection.\n             *\n             *  @param {Collection~MongoQueryMongo.Selector} selector - Specifies which documents to modify\n             *  @param {Modifier} modifier - Specifies how to modify the documents\n             *  @param {MongoUpdateOptions} options - Update options\n             *  first argument and, if no error, the number of affected documents as the second\n             *  @returns {Observable<Number>} Observable which completes with the number of affected rows\n             *\n             * @see {@link https://docs.meteor.com/api/collections.html#Mongo-Collection-update|update on Meteor documentation}\n             */\n            update(selector, \n            // tslint:disable-next-line:align\n            modifier, \n            // tslint:disable-next-line:align\n            options) {\n                let observers = [];\n                let obs = this._createObservable(observers);\n                this._collection.update(selector, modifier, options, (error, updated) => {\n                    observers.forEach(observer => {\n                        error ? observer.error(error) :\n                            observer.next(updated);\n                        observer.complete();\n                    });\n                });\n                return obs;\n            }\n            /**\n             *  Finds the first document that matches the selector, as ordered by sort and skip options.\n             *\n             *  @param {Collection~MongoQueryMongo.Selector} selector - Specifies which documents to modify\n             *  @param {Modifier} modifier - Specifies how to modify the documents\n             *  @param {MongoUpsertOptions} options - Upsert options\n             *  first argument and, if no error, the number of affected documents as the second.\n             *  @returns {Observable<{numberAffected, insertedId}>} Observable which completes with an\n             *  Object that contain the keys numberAffected and insertedId.\n             *\n             * @see {@link https://docs.meteor.com/api/collections.html#Mongo-Collection-upsert|upsert on Meteor documentation}\n             */\n            upsert(selector, \n            // tslint:disable-next-line:align\n            modifier, \n            // tslint:disable-next-line:align\n            options) {\n                let observers = [];\n                let obs = this._createObservable(observers);\n                this._collection.upsert(selector, modifier, options, (error, affected) => {\n                    observers.forEach(observer => {\n                        error ? observer.error(error) :\n                            observer.next(affected);\n                        observer.complete();\n                    });\n                });\n                return obs;\n            }\n            /**\n             *  Method has the same notation as Mongo.Collection.find, only returns Observable.\n             *\n             *  @param {Collection~MongoQueryMongo.Selector} selector - A query describing the documents to find\n             *  @param {Collection~MongoQueryOptions} options - Query options, such as sort, limit, etc.\n             *  @returns {ObservableCursor<T>} RxJS Observable wrapped with Meteor features.\n             *  @example <caption>Using Angular2 Component</caption>\n             *  const MyCollection = MongoObservable.Collection(\"myCollection\");\n             *\n             *  class MyComponent  {\n             *     private myData: ObservableCursor<any>;\n             *\n             *     constructor() {\n             *        this.myData = MyCollection.find({}, {limit: 10});\n             *     }\n             *  }\n             *\n             * @see {@link https://docs.meteor.com/api/collections.html#Mongo-Collection-find|find on Meteor documentation}\n             */\n            find(selector, options) {\n                const cursor = this._collection.find.apply(this._collection, arguments);\n                return ObservableCursor.create(cursor);\n            }\n            /**\n             *  Finds the first document that matches the selector, as ordered by sort and skip options.\n             *\n             *  @param {Collection~MongoQueryMongo.Selector} selector - A query describing the documents to find\n             *  @param {Collection~MongoQueryOptions} options - Query options, such as sort, limit, etc.\n             *  @returns {any} The first object, or `undefined` in case of non-existing object.\n             *\n             * @see {@link https://docs.meteor.com/api/collections.html#Mongo-Collection-findOne|findOne on Meteor documentation}\n             */\n            findOne(selector, options) {\n                return this._collection.findOne.apply(this._collection, arguments);\n            }\n            _createObservable(observers) {\n                return rxjs.Observable.create((observer) => {\n                    observers.push(observer);\n                    return () => {\n                        removeObserver(observers, observer);\n                    };\n                });\n            }\n        }\n        MongoObservable.Collection = Collection;\n    })(exports.MongoObservable || (exports.MongoObservable = {}));\n    /**\n     * An options object for MongoDB queries.\n     * @typedef {Object} Collection~MongoQueryOptions\n     * @property {Object} sort - Sort order (default: natural order)\n     * @property {Number} skip - Number of results to skip at the beginning\n     * @property {Object} fields - Dictionary of fields to return or exclude.\n     * @property {Boolean} reactive - (Client only) Default true; pass false to disable reactivity\n     * @property {Function} transform - Overrides transform on the Collection for this cursor. Pass null to disable transformation.\n     */\n    /**\n     * A MongoDB query selector representation.\n     * @typedef {(Mongo.Mongo.Selector|Mongo.Mongo.ObjectID|string)} Collection~MongoQueryMongo.Selector\n     */\n    /**\n     * A MongoDB query options for upsert action\n     * @typedef {Object} Collection~MongoUpsertOptions\n     * @property {Boolean} multi - True to modify all matching documents;\n     * false to only modify one of the matching documents (the default).\n     */\n    /**\n     * A MongoDB query options for update action\n     * @typedef {Object} Collection~MongoUpdateOptions\n     * @property {Boolean} multi - True to modify all matching documents;\n     * @property {Boolean} upsert - True to use upsert logic.\n     */\n\n    let liveSubscriptions = [];\n    function throwInvalidCallback(method) {\n        throw new Error(`Invalid ${method} arguments:\r\n     your last param can't be a callback function,\r\n     please remove it and use \".subscribe\" of the Observable!`);\n    }\n    /**\n     * This is a class with static methods that wrap Meteor's API and return RxJS\n     * Observables. The methods' signatures are the same as Meteor's, with the ]\n     * exception that the callbacks are handled by Meteor-rxjs. Instead of\n     * providing callbacks, you need to subscribe to the observables that are\n     * returned. The methods that are wrapped in MeteorObservable are\n     * [Meteor.call](https://docs.meteor.com/api/methods.html#Meteor-call),\n     * [Meteor.autorun](https://docs.meteor.com/api/tracker.html#Tracker-autorun)\n     * and [Meteor.subscribe](https://docs.meteor.com/api/pubsub.html#Meteor-subscribe).\n     */\n    class MeteorObservable {\n        /**\n         * Invokes a [Meteor Method](https://docs.meteor.com/api/methods.html)\n         * defined on the server, passing any number of arguments. This method has\n         * the same signature as\n         * [Meteor.call](https://docs.meteor.com/api/methods.html#Meteor-call), only\n         * without the callbacks:\n         *    MeteorObservable.call(name, [...args])\n         *\n         *\n         *  @param {string} name - Name of the method in the Meteor server\n         *  @param {any} args - Parameters that will be forwarded to the method.\n         *   after the func call to initiate change detection.\n         *  @returns {Observable<T>} - RxJS Observable, which completes when the\n         *  server returns a response.\n         *\n         *  @example <caption>Example using Angular2 Component</caption>\n         *  class MyComponent  {\n         *     constructor() {\n         *\n         *     }\n         *\n         *     doAction(payload) {\n         *        MeteorObservable.call(\"myData\", payload).subscribe((response) => {\n         *           // Handle success and response from server!\n         *        }, (err) => {\n         *          // Handle error\n         *        });\n         *     }\n         *  }\n         */\n        static call(name, ...args) {\n            const lastParam = args[args.length - 1];\n            if (isMeteorCallbacks(lastParam)) {\n                throwInvalidCallback('MeteorObservable.call');\n            }\n            let zone = forkZone();\n            return rxjs.Observable.create((observer) => {\n                Meteor.call(name, ...args.concat([\n                    (error, result) => {\n                        zone.run(() => {\n                            error ? observer.error(error) :\n                                observer.next(result);\n                            observer.complete();\n                        });\n                    }\n                ]));\n            });\n        }\n        /**\n         * When you subscribe to a collection, it tells the server to send records to\n         * the client. This method has the same signature as\n         * [Meteor.subscribe](https://docs.meteor.com/api/pubsub.html#Meteor-subscribe),\n         * except without the callbacks again:\n         *    subscribe(name, [...args])\n         *\n         *  You can use this method from any Angular2 element - such as Component,\n         *  Pipe or Service.\n         *\n         *  @param {string} name - Name of the publication in the Meteor server\n         *  @param {any} args - Parameters that will be forwarded to the publication.\n         *   after the func call to initiate change detection.\n         *  @returns {Observable} - RxJS Observable, which completes when the\n         *  subscription is ready.\n         *\n         *  @example <caption>Example using Angular2 Service</caption>\n         *  class MyService {\n         *     private meteorSubscription: Observable<any>;\n         *\n         *     constructor() {\n         *\n         *     }\n         *\n         *     subscribeToData() {\n         *        this.meteorSubscription = MeteorObservable.subscribe<any>(\"myData\").subscribe(() => {\n         *           // Subscription is ready!\n         *        });\n         *     }\n         *\n         *     unsubscribeToData() {\n         *        this.meteorSubscription.unsubscribe();\n         *     }\n         *  }\n         *\n         *  @example <caption>Example using Angular2 Component</caption>\n         *  class MyComponent implements OnInit, OnDestroy {\n         *     private meteorSubscription: Observable<any>;\n         *\n         *     constructor() {\n         *\n         *     }\n         *\n         *     ngOnInit() {\n         *        this.meteorSubscription = MeteorObservable.subscribe(\"myData\").subscribe(() => {\n         *           // Subscription is ready!\n         *        });\n         *     }\n         *\n         *     ngOnDestroy() {\n         *        this.meteorSubscription.unsubscribe();\n         *     }\n         *  }\n         *\n         *  @see {@link http://docs.meteor.com/api/pubsub.html|Publications in Meteor documentation}\n         */\n        static subscribe(name, ...args) {\n            let lastParam = args[args.length - 1];\n            if (isMeteorCallbacks(lastParam)) {\n                throwInvalidCallback('MeteorObservable.subscribe');\n            }\n            let zone = forkZone();\n            let observers = [];\n            let subscribe = () => {\n                return Meteor.subscribe(name, ...args.concat([{\n                        onError: (error) => {\n                            zone.run(() => {\n                                observers.forEach(observer => observer.error(error));\n                            });\n                        },\n                        onReady: () => {\n                            zone.run(() => {\n                                observers.forEach(observer => observer.next());\n                            });\n                        }\n                    }\n                ]));\n            };\n            let subHandler = null;\n            return rxjs.Observable.create((observer) => {\n                observers.push(observer);\n                // Execute subscribe lazily.\n                if (subHandler === null) {\n                    subHandler = subscribe();\n                    if (liveSubscriptions.find(sub => sub === subHandler.subscriptionId)) {\n                        // subscription already exists, call observer.next() since Meteor won't.\n                        observer.next();\n                    }\n                    else {\n                        liveSubscriptions.push(subHandler.subscriptionId);\n                    }\n                }\n                return () => {\n                    removeObserver(observers, observer, () => {\n                        // remove subscription from liveSubscriptions list\n                        let i = liveSubscriptions.findIndex(sub => sub === subHandler.subscriptionId);\n                        if (i > -1) {\n                            liveSubscriptions.splice(i, 1);\n                        }\n                        subHandler.stop();\n                    });\n                };\n            });\n        }\n        /**\n         * Allows you to run a function every time there is a change is a reactive\n         * data sources. This method has the same signature as\n         * [Meteor.autorun](https://docs.meteor.com/api/tracker.html#Tracker-autorun),\n         * only without the callback:\n         *    MeteorObservable.autorun()\n         *\n         *  @returns {Observable<T>} - RxJS Observable, which trigger the subscription callback\n         *  each time that Meteor Tracker detects a change.\n         *  @example <caption>Example using Angular2 Component</caption>\n         *  class MyComponent  {\n         *     constructor() {\n         *\n         *     }\n         *\n         *     doAction(payload) {\n         *        MeteorObservable.autorun().subscribe(() => {\n         *           // Handle Tracker autorun change\n         *        });\n         *     }\n         *  }\n         */\n        static autorun() {\n            let zone = forkZone();\n            let observers = [];\n            let autorun = () => {\n                return Tracker.autorun((computation) => {\n                    zone.run(() => {\n                        observers.forEach(observer => observer.next(computation));\n                    });\n                });\n            };\n            let handler = null;\n            return rxjs.Observable.create((observer) => {\n                observers.push(observer);\n                // Execute autorun lazily.\n                if (handler === null) {\n                    handler = autorun();\n                }\n                return () => {\n                    removeObserver(observers, observer, () => handler.stop());\n                };\n            });\n        }\n    }\n\n    const zoneOperator = (zone) => (source) => source.lift(new ZoneOperator(zone || getZone()));\n    class ZoneOperator {\n        constructor(zone) {\n            this.zone = zone;\n        }\n        call(subscriber, source) {\n            return source._subscribe(new ZoneSubscriber(subscriber, this.zone));\n        }\n    }\n    class ZoneSubscriber extends rxjs.Subscriber {\n        constructor(destination, zone) {\n            super(destination);\n            this.zone = zone;\n        }\n        _next(value) {\n            this.zone.run(() => {\n                this.destination.next(value);\n            });\n        }\n        _complete() {\n            this.zone.run(() => {\n                this.destination.complete();\n            });\n        }\n        _error(err) {\n            this.zone.run(() => {\n                this.destination.error(err);\n            });\n        }\n    }\n\n    exports.MeteorObservable = MeteorObservable;\n    exports.ObservableCursor = ObservableCursor;\n    exports.zoneOperator = zoneOperator;\n\n    Object.defineProperty(exports, '__esModule', { value: true });\n\n})));\n"]}