module.exports = "(function(t,s,i){var e=i(5894),_=i(7358);t.exports={initialize:function(){this.__resetStore(),this.on(_.FINALIZE_BATCH_SNAPSHOT,this.__finalizeSnapshot),this.on(_.REGISTER_PREVIOUS_BATCH,this.__registerPreviousBatch),this.on(_.REGISTER_TRACKER_VISITOR,this.__registerVisitor),this.on(_.REGISTER_TRACKER_EVENT,this.__registerEvent),this.on(_.REGISTER_TRACKER_DECISION,this.__registerDecision),this.on(_.RESET_TRACKER_EVENTS,this.__clearEvents),this.on(_.RESET_TRACKER_STORE,this.__resetStore),this.on(_.RESET_TRACKER_PREVIOUS_BATCHES,this.__resetPreviousBatches),this.on(_.SET_TRACKER_POLLING,this.__setPolling),this.on(_.SET_TRACKER_BATCHING,this.__setBatching),this.on(_.SET_TRACKER_SEND_EVENTS,this.__setCanSend),this.on(_.SET_TRACKER_PERSISTABLE_STATE,this.__setPersistableState),this.on(_.SET_TRACKER_DIRTY,this.__setDirty),this.on(_.UPDATE_TRACKER_VISITOR_ATTRIBUTES,this.__updateAttributes)},getPersistableState:function(){return this.__state.isDirty?this.hasEventsToSend()||this.hasPreviousBatchesToSend()?{data:this.__state.data,decisions:this.__state.decisions,decisionEvents:this.__state.decisionEvents,previousBatches:this.__state.previousBatches}:{}:null},__setPersistableState:function(t){e.isEmpty(this.__state.data)||e.isEmpty(t.data)||(this.__finalizeSnapshot(),this.__state.previousBatches.push(this.getEventBatch())),this.__state.data=t.data||{},this.__state.decisions=t.decisions||[],this.__state.decisionEvents=t.decisionEvents||[],e.isEmpty(this.__state.previousBatches)||e.isEmpty(t.previousBatches)?this.__state.previousBatches=t.previousBatches||[]:this.__state.previousBatches=this.__state.previousBatches.concat(t.previousBatches),this.emitChange()},__setDirty:function(t){this.__state.isDirty=t,this.emitChange()},__registerEvent:function(t){if(__INVARIANT__){if(i(2048).isType(\"BatchEventTicket\",t.event),!t.decisions)throw new Error(\"decisions array is required\");e.forEach(t.decisions,(function(t){i(2048).isType(\"BatchDecisionTicket\",t)}))}var s=this.__getCurrentVisitor();(e.isEmpty(s.snapshots)||!e.isEmpty(this.__state.decisionEvents))&&this.__createSnapshot(),this.__getCurrentSnapshot().events.push(t.event),this.__state.decisions=t.decisions,this.__setDirty(!0)},__registerDecision:function(t){if(__INVARIANT__){if(i(2048).isType(\"BatchEventTicket\",t.decisionEvent),!t.decisions)throw new Error(\"decisions array is required\");e.forEach(t.decisions,(function(t){i(2048).isType(\"BatchDecisionTicket\",t)}))}this.__state.decisionEvents.push(t.decisionEvent),this.__state.decisions=t.decisions,this.__setDirty(!0)},__registerVisitor:function(t){__INVARIANT__&&(i(2048).isType(\"EventBatch\",t.data),i(2048).isType(\"BatchVisitor\",t.visitor)),e.isEmpty(this.__state.data)?this.__state.data=t.data:this.__finalizeSnapshot(),this.__state.data.visitors.push(t.visitor),this.__state.decisions=t.decisions,this.__state.decisionEvents=[],this.__setDirty(!0)},__registerPreviousBatch:function(t){this.__state.previousBatches.push(t),this.__setDirty(!0)},__resetStore:function(){this.__state={polling:!1,shouldBatch:!0,data:{},decisions:[],decisionEvents:[],canSend:!1,isDirty:!1,previousBatches:[]},this.emitChange()},__clearEvents:function(){var t=this.__getCurrentVisitor();this.__state.data.visitors=[t],t.snapshots=[],this.__setDirty(!0)},__resetPreviousBatches:function(){this.__state.previousBatches=[],this.__setDirty(!0)},__setPolling:function(t){this.__state.polling=t,this.emitChange()},__setBatching:function(t){this.__state.shouldBatch=t,this.emitChange()},__setCanSend:function(t){this.__state.canSend=t,this.emitChange()},getEventBatch:function(){return e.cloneDeep(this.__state.data)},getPreviousBatches:function(){return e.cloneDeep(this.__state.previousBatches)},__getDecisionEvents:function(){return this.__state.decisionEvents.slice()},__clearDecisionEvents:function(){this.__state.decisionEvents=[]},__getDecisions:function(){return this.__state.decisions.slice()},isPolling:function(){return this.__state.polling},shouldBatch:function(){return this.__state.shouldBatch},__getCurrentSnapshot:function(){return e.last(this.__getCurrentVisitor().snapshots)},__getCurrentVisitor:function(){return e.last(this.__state.data.visitors)},__createSnapshot:function(){var t=this.__getDecisionEvents();this.__getCurrentVisitor().snapshots.push({decisions:this.__getDecisions(),events:t}),this.__clearDecisionEvents(),this.__setDirty(!0)},__finalizeSnapshot:function(){this.__state.decisionEvents.length>0&&this.__createSnapshot()},hasEventsToSend:function(){if(!e.isEmpty(this.__state.decisionEvents))return!0;if(!e.isEmpty(this.__state.data)&&e.some(this.__state.data.visitors||[],(function(t){return t.snapshots.length>0})))return!0;return!1},hasPreviousBatchesToSend:function(){return!e.isEmpty(this.__state.previousBatches)},canSend:function(){return this.__state.canSend},__updateAttributes:function(t){var s=this.__getCurrentVisitor();s&&(s.attributes=t.attributes)}}})";