????

Your IP : 3.17.81.34


Current Path : C:/inetpub/vhost/binhdinhinvest.gdtvietnam.com/www/
Upload File :
Current File : C:/inetpub/vhost/binhdinhinvest.gdtvietnam.com/www/76.46f7af16e5d31f2926a9.js

(function(){var e={"esri/views/2d/layers/features/controllers/StreamController":"A4oT","esri/views/2d/layers/features/controllers/support/DispatchQueue":"Wuf+","esri/layers/graphics/sources/connections/StreamConnection":"aROD","esri/layers/graphics/sources/connections/GeoEventConnection":"gSUo","esri/layers/graphics/data/StreamFeatureManager":"gsnf"},t=this||window,r=t.webpackJsonp=t.webpackJsonp||[];r.registerAbsMids?r.registerAbsMids(e):(r.absMidsWaiting=r.absMidsWaiting||[]).push(e)})(),(window.webpackJsonp=window.webpackJsonp||[]).push([[76],{A4oT:function(e,t,r){var n,i;n=[r.dj.c(e.i),t,r("zOht"),r("ma1f"),r("H1tY"),r("R2Zq"),r("LxLY"),r("qMld"),r("Vx27"),r("+6sX"),r("ZGAQ"),r("rfv1"),r("gsnf"),r("gSUo"),r("Btct"),r("Wuf+")],i=(function(e,t,r,n,i,o,s,a,u,c,h,d,p,l,f,_){Object.defineProperty(t,"__esModule",{value:!0});var y=function(){function e(e,t){this.store=e,this.onUpdate=t}return e.prototype.add=function(e){this.store.add(e)},e.prototype.forEach=function(e){this.store.forEach(e)},e.prototype.removeById=function(e){return this.store.removeById(e)},e.prototype.update=function(e,t){this.onUpdate(e,t)},Object.defineProperty(e.prototype,"size",{get:function(){return this.store.numFeatures},enumerable:!0,configurable:!0}),e}(),v=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="stream",t._tileDispatchMap=new Map,t._updateIntervalId=0,t}return r.__extends(t,e),t.prototype.initialize=function(){var e=this,t=this.service,r=t.objectIdField,n=t.timeInfo,i=t.purgeOptions;this.connection=new l.default(t.source,t.spatialReference,this.spatialReference,t.geometryType,t.serviceFilter),this._set("store",new d.default(this.geometryInfo)),this._set("streamFeatureManager",new p.default(new y(this.store,(function(t,r){return e._onUpdate(t,r)})),r,n,i)),this.connection.on("feature",(function(t){return e._onFeature(t)})),["connectionStatus","errorString"].forEach((function(t){e.watch("connection."+t,(function(r){return e.remoteClient.invoke("setProperty",{propertyName:t,value:r})}))})),this._updateIntervalId=setInterval((function(){return e.streamFeatureManager.checkForUpdates()}),64),this._shouldPushDataReceived=this.service.enableDataReceived},t.prototype.destroy=function(){clearInterval(this._updateIntervalId),this.connection.destroy(),this.queryEngine.destroy(),this._tileDispatchMap.forEach((function(e){return e.destroy()}))},Object.defineProperty(t.prototype,"queryEngine",{get:function(){return this._createQueryEngine(this.store)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"updating",{get:function(){return this._tempQueryEngine&&!!this._tempQueryEngine.featureStore.numFeatures||this._anyUpdatesQueued()},enumerable:!0,configurable:!0}),t.prototype.update=function(e){return r.__awaiter(this,void 0,void 0,(function(){var t,n,i=this;return r.__generator(this,(function(r){switch(r.label){case 0:return this.validateConfig(e),JSON.stringify(this.service.serviceFilter),t=this.renderer.getAttributeHash(),this._set("config",e),[4,this.updatePixelBuffer()];case 1:return r.sent(),JSON.stringify(this.service.serviceFilter),"heatmap"===this.renderer.type?[2]:t===this.renderer.getAttributeHash()?[3,3]:(n=this.queryEngine.featureStore,[4,this.attributeStore.setAttributeBindings(this.renderer,this.arcadeInfo)]);case 2:r.sent(),n.forEach((function(e){return i.attributeStore.setAttributeData(e.localId,e,i.geometryInfo,i.viewParams)})),r.label=3;case 3:return[4,this.attributeStore.updateFilters(this)];case 4:return r.sent(),[4,this.attributeStore.sendUpdates()];case 5:return r.sent(),[2]}}))}))},t.prototype.invalidate=function(){this._repushActiveTiles()},t.prototype.onEdits=function(){},t.prototype.queryFeatures=function(e){return this.queryEngine.executeQuery(e)},t.prototype.queryFeatureCount=function(e){return this.queryEngine.executeQueryForCount(e)},t.prototype.queryObjectIds=function(e){return this.queryEngine.executeQueryForIds(e)},t.prototype.queryExtent=function(e){return this.queryEngine.executeQueryForExtent(e)},t.prototype.queryLatestObservations=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){if(!this.service.timeInfo.trackIdField)throw new n("mapview-no-trackIdField","queryLatestObservation can only be used with services that define a TrackIdField");return[2,this.queryEngine.executeQueryForLatestObservations(e)]}))}))},t.prototype.queryStatistics=function(){throw new n("Method not implemented.")},t.prototype.refresh=function(){},t.prototype.setViewState=function(t){var r=this,n=this.viewState&&this.viewState.scale;e.prototype.setViewState.call(this,t),n!==this.viewState.scale&&this.attributeStore.hasScaleExpr&&(this.queryEngine.featureStore.forEach((function(e){return r.attributeStore.setAttributeData(e.localId,e,r.geometryInfo,r.viewParams)})),this.attributeStore.sendUpdates())},t.prototype.onTileUpdate=function(e){var t=this,r=e.added;e.removed.forEach((function(e){return t._handleTileRemove(e)})),r.forEach((function(e){return t._handleTileAdd(e)}))},t.prototype.enableEvent=function(e){"data-received"===e.name&&(this._shouldPushDataReceived=e.value)},t.prototype._onFeature=function(e){this._shouldPushDataReceived&&this.remoteClient.invoke("emitEvent",{name:"data-received",event:{attributes:e.attributes,centroid:e.centroid,geometry:e.geometry}});try{var t=this.geometryInfo,r=c.convertFromFeature(e,t.geometryType,t.hasZ,t.hasM,this.service.objectIdField);this.streamFeatureManager.add(r)}catch(e){i("esri-2d-debug")&&console.debug(e)}},t.prototype._createStoreWithFeatures=function(e){if(s.isNone(e))return null;var t=this._createFeatureStore();return t.addMany(e),t},t.prototype._onUpdate=function(e,t){return r.__awaiter(this,void 0,void 0,(function(){var n,i,o=this;return r.__generator(this,(function(r){switch(r.label){case 0:return s.isSome(e)&&e.forEach((function(e){return o.onFeatureAdd(e)})),n=this._createStoreWithFeatures(e),i=this._createStoreWithFeatures(t),this.attributeStore.sendUpdates(),this.processor.supportsTileUpdates?[4,this._updateActiveTiles(n,i)]:[3,2];case 1:return r.sent(),[3,3];case 2:this._repushActiveTiles(),r.label=3;case 3:return s.isSome(t)&&t.forEach((function(e){return o.onFeatureRemove(e)})),[2]}}))}))},t.prototype._handleTileAdd=function(e){if(this._tileDispatchMap.has(e.id))(t=this._tileDispatchMap.get(e.id)).up();else{var t=new _.default;this._tileDispatchMap.set(e.id,t)}this._queryTileFeatures(e,!0,this.queryEngine)},t.prototype._handleTileRemove=function(e){var t=this._tileDispatchMap.get(e.id);t&&(t.destroy(),this._tileDispatchMap.delete(e.id))},t.prototype._anyUpdatesQueued=function(){return o.valuesOfMap(this._tileDispatchMap).some((function(e){return e.hasAction()}))},t.prototype._updateActiveTiles=function(e,t){return r.__awaiter(this,void 0,void 0,(function(){var n,i,o=this;return r.__generator(this,(function(r){switch(r.label){case 0:return n=s.applySome(e,(function(e){return o._createQueryEngine(e)})),i=s.applySome(t,(function(e){return o._createQueryEngine(e)})),[4,a.all(this.tileStore.tiles.map((function(e){return o._queryTileFeatures(e,!1,n,i)})))];case 1:return r.sent(),[2]}}))}))},t.prototype._repushActiveTiles=function(){for(var e=0,t=this.tileStore.tiles;e<t.length;e++)this._queryTileFeatures(t[e],!0,this.queryEngine)},t.prototype._queryTileFeatures=function(e,t,n,i){return r.__awaiter(this,void 0,void 0,(function(){var o,u,c,d,p,l,f,_,y,v=this;return r.__generator(this,(function(g){switch(g.label){case 0:return o={hasZ:!1,hasM:!1,transform:{originPosition:"upperLeft",scale:[e.resolution,e.resolution],translate:[e.bounds[0],e.bounds[3]]}},c={returnCentroid:(u=this.queryInfo).returnCentroid,returnGeometry:u.returnGeometry,pixelBuffer:this._pixelBuffer,returnOutline:this.returnOutline},this._tileDispatchMap.has(e.id)?(d=this._tileDispatchMap.get(e.id),[4,s.applySome(n,(function(t){return t.featureStore.executeTileQuery(e,v.spatialReference,c)}))]):[2];case 1:return p=g.sent(),l=s.mapOr(p,[],(function(e){return e.features})),f=s.mapOr(i,[],(function(t){return h.executeTileQueryForIds(t,e,c)})).map((function(e){return v.attributeStore.getLocalId(e)})),_=a.createResolver(),y=function(n){return r.__awaiter(v,void 0,void 0,(function(){var i;return r.__generator(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.processor.onTileData(e,{addOrUpdate:l,remove:f,clear:t,transformParams:o},{signal:n})];case 1:return r.sent(),[3,3];case 2:return i=r.sent(),a.throwIfNotAbortError(i),[3,3];case 3:return _.resolve(),[2]}}))}))},d.enqueue(y),[2,_.promise]}}))}))},r.__decorate([u.property()],t.prototype,"connection",void 0),r.__decorate([u.property()],t.prototype,"service",void 0),r.__decorate([u.property({readOnly:!0})],t.prototype,"store",void 0),r.__decorate([u.property({readOnly:!0})],t.prototype,"streamFeatureManager",void 0),r.__decorate([u.property({readOnly:!0,dependsOn:["store","service","config"]})],t.prototype,"queryEngine",null),r.__decorate([u.property()],t.prototype,"updating",null),r.__decorate([u.subclass("esri.views.2d.layers.features.controllers.StreamController")],t)}(f.default);t.default=v}).apply(null,n),void 0===i||(e.exports=i)},"Wuf+":function(e,t,r){var n,i;n=[r.dj.c(e.i),t,r("zOht"),r("qMld")],void 0===(i=(function(e,t,r,n){Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){this._action=null,this._queue=[],this._abortController=n.createAbortController(),this._refs=1}return e.prototype.up=function(){this._refs++},e.prototype.down=function(){return this._refs--,0===this._refs},e.prototype.clear=function(){this._abortController.abort(),this._abortController=n.createAbortController()},e.prototype.destroy=function(){this._queue.length=0,this._action&&(this._action=null)},e.prototype.enqueue=function(e){this._action?this._queue.push(e):this._setAction(e)},e.prototype.flush=function(){return r.__awaiter(this,void 0,void 0,(function(){var e,t,i;return r.__generator(this,(function(r){return(e=this._action)?(t=this._abortController.signal,i=this._queue.reduce((function(e,r){return e.then((function(){return r(t)}))}),e).catch(n.throwIfNotAbortError),this._action=i.then(this._handleNext.bind(this)).catch(n.throwIfNotAbortError),this._queue.length=0,[2,i]):[2]}))}))},e.prototype.hasAction=function(){return!!this._action},e.prototype._setAction=function(e){this._action=e(this._abortController.signal).then(this._handleNext.bind(this)).catch(n.throwIfNotAbortError)},e.prototype._handleNext=function(){this._queue.length?this._setAction(this._queue.shift()):this._action=null},e}();t.default=i}).apply(null,n))||(e.exports=i)},aROD:function(e,t,r){var n,i;n=[r.dj.c(e.i),t,r("zOht"),r("BcWh"),r("7MDj"),r("Vx27")],i=(function(e,t,r,n,i,o){Object.defineProperty(t,"__esModule",{value:!0});var s=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.__extends(t,e),t.prototype.onFeature=function(e){this.emit("feature",e)},r.__decorate([o.subclass("esri.layers.graphics.sources.connections.StreamConnection")],t)}(n.EventedMixin(i.HandleOwner));t.default=s}).apply(null,n),void 0===i||(e.exports=i)},gSUo:function(e,t,r){var n,i;n=[r.dj.c(e.i),t,r("zOht"),r("TMur"),r("zp6E"),r("ma1f"),r("qsST"),r("LxLY"),r("qMld"),r("Vx27"),r("Zvuv"),r("aROD"),r("B16N"),r("HoQt"),r("IpeC")],void 0===(i=(function(e,t,r,n,i,o,s,a,u,c,h,d,p,l,f){Object.defineProperty(t,"__esModule",{value:!0});var _,y=s.getLogger("esri.layers.graphics.sources.connections.GeoEventConnection");!function(e){e[e.CONNECTING=0]="CONNECTING",e[e.OPEN=1]="OPEN",e[e.CLOSING=2]="CLOSING",e[e.CLOSED=3]="CLOSED"}(_=t.ReadyState||(t.ReadyState={}));var v=function(e){function t(t,r,n,i,o,s,a,u){void 0===s&&(s=5),void 0===a&&(a=3);var c=e.call(this)||this;return c._destroyed=!1,c.errorString=null,c._source=t,c._sourceSpatialReference=r,c._spatialReference=n,c._filter=o,c._outFields=u,c._maxQueryDepth=s,c._maxRecordCountFactor=a,c._featureZScaler=l.getGeometryZScaler(i,r,n),c._open(),c}return r.__extends(t,e),t.prototype._open=function(){return r.__awaiter(this,void 0,void 0,(function(){var e,t,n,i;return r.__generator(this,(function(r){switch(r.label){case 0:return[4,this._fetchServiceDefinition(this._source)];case 1:return(e=r.sent()).timeInfo.trackIdField||y.warn("GeoEvent service was configured without a TrackIdField. This may result in certain functionality being disabled. The purgeOptions.maxObservations property will have no effect."),[4,this._fetchWebSocketUrl(e.streamUrls,this._spatialReference)];case 2:return t=r.sent(),this._buddyServicesQuery||(this._buddyServicesQuery=this._queryBuddyServices()),[4,this._buddyServicesQuery];case 3:return r.sent(),[4,this._tryCreateWebSocket(t)];case 4:return r.sent(),n=this._filter,i=this._outFields,this._destroyed||this._setFilter(n,i),[2]}}))}))},t.prototype.destroy=function(){this._destroyed=!0,a.isSome(this._websocket)&&(this._websocket.onopen=null,this._websocket.onclose=null,this._websocket.onerror=null,this._websocket.onmessage=null,this._websocket.close()),this._websocket=null},Object.defineProperty(t.prototype,"connectionStatus",{get:function(){if(a.isNone(this._websocket))return"disconnected";switch(this._websocket.readyState){case _.CONNECTING:case _.OPEN:return"connected";case _.CLOSING:case _.CLOSED:return"disconnected"}},enumerable:!0,configurable:!0}),t.prototype._tryCreateWebSocket=function(e,t){return void 0===t&&(t=1e3),r.__awaiter(this,void 0,void 0,(function(){var n,i;return r.__generator(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,4]),this._destroyed?[2]:(n=this,[4,this._createWebSocket(e)]);case 1:return n._websocket=r.sent(),this.notifyChange("connectionStatus"),[3,4];case 2:return i=r.sent(),y.error(new o("geoevent-connection","Failed to connect. Attempting to reconnect in "+t/1e3+"s",i)),[4,u.after(t)];case 3:return r.sent(),[2,this._tryCreateWebSocket(e,1.5*t)];case 4:return[2]}}))}))},t.prototype._createWebSocket=function(e){var t=this,r=new WebSocket(e),n=u.create((function(e,t){r.onopen=function(){return e(r)},r.onclose=function(e){return t(e)}}));return n.then((function(){if(t._destroyed)return r.onclose=function(){},void r.close();r.onclose=function(e){return t._onClose(e)},r.onerror=function(e){return t._onError(e)},r.onmessage=function(e){return t._onMessage(e)}})),n},t.prototype._onMessage=function(e){var t;try{t=this._enrich(JSON.parse(e.data)),this._featureZScaler&&this._featureZScaler(t.geometry)}catch(e){return void y.error(new o("geoevent-connection","Failed to parse message",e))}this.onFeature(t)},t.prototype._onError=function(e){var t="Encountered an error over WebSocket connection";this._set("errorString",t),y.error("geoevent-connection",t)},t.prototype._onClose=function(e){this._websocket=null,this.notifyChange("connectionStatus"),1e3!==e.code&&y.error("geoevent-connection","WebSocket closed unexpectedly with error code "+e.code),this._destroyed||this._open()},t.prototype._fetchServiceDefinition=function(e){return r.__awaiter(this,void 0,void 0,(function(){var t,n;return r.__generator(this,(function(r){switch(r.label){case 0:return[4,i(e,{query:{f:"json"},responseType:"json"})];case 1:return t=r.sent(),this._serviceDefinition=n=t.data,[2,n]}}))}))},t.prototype._fetchWebSocketUrl=function(e,t){return r.__awaiter(this,void 0,void 0,(function(){var n,i;return r.__generator(this,(function(r){return i=(n=e[0]).token,[2,this._inferWebSocketBaseUrl(n.urls)+"/subscribe?outSR="+t.wkid+(i?"&token="+i:"")]}))}))},t.prototype._inferWebSocketBaseUrl=function(e){if(1===e.length)return e[0];for(var t=0,r=e;t<r.length;t++){var n=r[t];if(-1!==n.indexOf("wss"))return n}return y.error(new o("geoevent-connection","Unable to infer WebSocket url",e)),null},t.prototype._setFilter=function(e,t){return r.__awaiter(this,void 0,void 0,(function(){var n,i,s,c,h,d,p=this;return r.__generator(this,(function(r){return n=this._websocket,this._filter=e,this._outFields=t,a.isNone(n)||a.isNone(e)&&a.isNone(t)?[2]:(i=JSON.stringify({filter:this._serializeFilter(e,t)}),s=!1,c=u.createResolver(),h=function(){s||(p._destroyed||p._websocket!==n||y.error(new o("geoevent-connection","Server timed out when setting filter")),c.reject())},d=function(e){var t=JSON.parse(e.data);t.filter&&(t.error&&(y.error(new o("geoevent-connection","Failed to set service filter",t.error)),p._set("errorString","Could not set service filter - "+t.error),c.reject(t.error)),n.onmessage=p._onMessage.bind(p),s=!0,c.resolve())},n.onmessage=d,n.send(i),setTimeout(h,1e4),[2,c.promise])}))}))},t.prototype._serializeFilter=function(e,t){var r={};if(a.isNone(e)&&a.isNone(t))return r;if(a.isSome(e)&&e.geometry)try{var i=n.fromJSON(e.geometry);if("extent"!==i.type)throw new o("Expected extent but found type "+i.type);r.geometry=JSON.stringify(i.shiftCentralMeridian())}catch(e){y.error(new o("geoevent-connection","Encountered an error when setting connection geometryDefinition",e))}return a.isSome(e)&&e.where&&"1 = 1"!==e.where&&(r.where=e.where),a.isSome(t)&&(r.outFields=t.join(",")),r},t.prototype._enrich=function(e){if(!this._relatedFeatures)return e;var t=e.attributes[this._serviceDefinition.relatedFeatures.joinField];if(!this._relatedFeatures.has(t))return y.warn("geoevent-connection","Feature join failed. Is the join field configured correctly?",e),e;var r=this._relatedFeatures.get(t),n=r.attributes,i=r.geometry;for(var s in n)e.attributes[s]=n[s];return i&&(e.geometry=i),e.geometry||e.centroid||y.error(new o("geoevent-connection","Found malformed feature - no geometry found",e)),e},t.prototype._queryBuddyServices=function(){return r.__awaiter(this,void 0,void 0,(function(){var e,t,n,i,s,a,u,c;return r.__generator(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),t=(e=this._serviceDefinition).keepLatestArchive,n=this._queryRelatedFeatures(e.relatedFeatures),i=this._queryArchive(t),[4,n];case 1:return r.sent(),[4,i];case 2:if(!(s=r.sent()))return[2];for(a=0,u=s.features;a<u.length;a++)this.onFeature(this._enrich(u[a]));return[3,4];case 3:return c=r.sent(),y.error(new o("geoevent-connection","Encountered an error when querying buddy services",{error:c})),[3,4];case 4:return[2]}}))}))},t.prototype._queryRelatedFeatures=function(e){return r.__awaiter(this,void 0,void 0,(function(){var t;return r.__generator(this,(function(r){switch(r.label){case 0:return e?[4,this._queryBuddy(e.featuresUrl)]:[2];case 1:return t=r.sent(),this._addRelatedFeatures(t),[2]}}))}))},t.prototype._queryArchive=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return e?[2,this._queryBuddy(e.featuresUrl)]:[2,void 0]}))}))},t.prototype._queryBuddy=function(e){return r.__awaiter(this,void 0,void 0,(function(){var t,n,i,o,s,u,c,d,l,_;return r.__generator(this,(function(r){switch(r.label){case 0:return[4,(t=new h({url:e})).load()];case 1:return n=r.sent().capabilities,o=n.query.supportsPagination,s=n.query.supportsCentroid,u=this._maxRecordCountFactor,c=t.capabilities.query.maxRecordCount,d=(i=n.query.supportsMaxRecordCountFactor)?c*u:c,(l=new f).outFields=a.unwrapOr(this._outFields,["*"]),l.where=a.unwrapOr(a.get(this._filter,"where"),"1=1"),l.returnGeometry=!0,l.returnExceededLimitFeatures=!0,l.outSpatialReference=this._spatialReference,s&&(l.returnCentroid=!0),i&&(l.maxRecordCountFactor=u),o?(l.num=d,t.destroy(),[2,this._queryPages(e,l)]):[4,p.executeQuery(e,l,this._sourceSpatialReference)];case 2:return _=r.sent(),t.destroy(),[2,_.data]}}))}))},t.prototype._queryPages=function(e,t,n,i){return void 0===n&&(n=[]),void 0===i&&(i=0),r.__awaiter(this,void 0,void 0,(function(){var o;return r.__generator(this,(function(r){switch(r.label){case 0:return t.start=i*t.num,[4,p.executeQuery(e,t,this._sourceSpatialReference)];case 1:return(o=r.sent().data).exceededTransferLimit&&i<this._maxQueryDepth?(o.features.forEach((function(e){return n.push(e)})),[2,this._queryPages(e,t,n,i+1)]):(n.forEach((function(e){return o.features.push(e)})),[2,o])}}))}))},t.prototype._addRelatedFeatures=function(e){for(var t=new Map,r=this._serviceDefinition.relatedFeatures.joinField,n=0,i=e.features;n<i.length;n++){var o=i[n];t.set(o.attributes[r],o)}this._relatedFeatures=t},r.__decorate([c.property()],t.prototype,"connectionStatus",null),r.__decorate([c.property()],t.prototype,"errorString",void 0),r.__decorate([c.subclass("esri.layers.graphics.sources.connections.GeoEventConnection")],t)}(d.default);t.default=v}).apply(null,n))||(e.exports=i)},gsnf:function(e,t,r){var n,i;n=[r.dj.c(e.i),t,r("zIqJ"),r("xoE+"),r("LxLY")],void 0===(i=(function(e,t,r,n,i){Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_STREAM_ID_FIELD="__esri_stream_id__";var o=function(){function e(e,r,n,i,o){void 0===o&&(o=128),this._trackIdToObservations=new Map,this._idCounter=0,this._lastPurge=Date.now(),this._addOrUpdated=new Map,this._removed=[],this._maxAge=0,this._timeInfo=n,this._purgeOptions=i,this.store=e,this.objectIdField=r,this.purgeInterval=o,this._useGeneratedIds=this.objectIdField===t.DEFAULT_STREAM_ID_FIELD}return e.prototype.add=function(e){if(this._useGeneratedIds&&(e.attributes[this.objectIdField]=this._nextId()),e.objectId=e.attributes[this.objectIdField],this.store.add(e),this._addOrUpdated.set(e.objectId,e),this._maxAge=Math.max(this._maxAge,e.attributes[this._timeInfo.startTimeField]),this._timeInfo.trackIdField){var t=e.attributes[this._timeInfo.trackIdField];if(!this._trackIdToObservations.has(t)){var o=i.isSome(this._purgeOptions)&&null!=this._purgeOptions.maxObservations?this._purgeOptions.maxObservations:1e3,s=n.clamp(o,0,1e3);this._trackIdToObservations.set(t,new r.default(s))}var a=this._trackIdToObservations.get(t).enqueue(e.attributes[this.objectIdField]);if(i.isSome(a)){var u=this.store.removeById(a);i.isSome(u)&&(this._addOrUpdated.has(a)?this._addOrUpdated.delete(a):this._removed.push(u))}}},e.prototype.checkForUpdates=function(){var e=this._getToAdd(),t=this._getToRemove(),r=Date.now();r-this._lastPurge>=this.purgeInterval&&(this._purge(),this._lastPurge=r),(e||t)&&this.store.update(e,t)},e.prototype._getToAdd=function(){if(!this._addOrUpdated.size)return null;var e=new Array(this._addOrUpdated.size),t=0;return this._addOrUpdated.forEach((function(r){return e[t++]=r})),this._addOrUpdated.clear(),e},e.prototype._getToRemove=function(){var e=this._removed;return this._removed.length?(this._removed=[],e):null},e.prototype._nextId=function(){var e=this._idCounter;return this._idCounter=(this._idCounter+1)%4294967294+1,e},e.prototype._purge=function(){var e=this._purgeOptions;i.isSome(e)&&(this._purgeSomeByDisplayCount(e),this._purgeByAge(e),this._purgeTracks())},e.prototype._purgeSomeByDisplayCount=function(e){var t=this;if(e.displayCount){var r=this.store.size;r>e.displayCount&&this._trackIdToObservations.forEach((function(n){if(r>e.displayCount&&n.size){var o=t.store.removeById(i.unwrap(n.dequeue()));i.isSome(o)&&t._removed.push(o),r--}}))}},e.prototype._purgeByAge=function(e){var t=this;if(e.age){var r=this._maxAge-60*e.age*1e3,n=this._timeInfo.startTimeField;this.store.forEach((function(e){e.attributes[n]<r&&(t.store.removeById(e.objectId),t._removed.push(e))}))}},e.prototype._purgeTracks=function(){var e=this;this._trackIdToObservations.forEach((function(t,r){0===t.size&&e._trackIdToObservations.delete(r)}))},e}();t.default=o}).apply(null,n))||(e.exports=i)}}]);