module.exports = "(function(e,t,i){var s=i(5894),n=i(7358),a=i(4810),r=\"*\";e.exports={initialize:function(){this.__state={},this.on(n.LOAD_PERSISTED_LAYER_STATES,this.__loadPersistedLayerStates),this.on(n.RECORD_LAYER_DECISION,this.__recordDecision),this.on(n.RECORD_LAYER_DECISION_EVENT_ID,this.__recordDecisionEventId)},getLayerState:function(e,t){if(this.__state[e]){var i=this.__state[e];if(s.keys(i).length>1&&!t)throw new Error(\"View Id must be specified when more than one layerState for layer.\");return t?s.cloneDeep(s.find(i,{pageId:t})):s.cloneDeep(i[r])}},getLayerStates:function(e){var t=[];for(var i in this.__state)s.forEach(this.__state[i],(function(i){(s.isUndefined(e)||i.namespace===e)&&t.push(s.cloneDeep(i))}));return t},getLayerStatesForAnalytics:function(){var e=[];for(var t in this.__state)s.forEach(this.__state[t],(function(t){e.push(s.pick(t,[\"layerId\",\"decision\",\"decisionEventId\"]))}));return e},__loadPersistedLayerStates:function(e){e.merge||(this.__state={}),s.each(e.layerStates,s.bind((function(e){var t=e.layerId;e.pageId||(e.pageId=e.viewId);var i=e.pageId||r,n=this.__state[t];if(s.isUndefined(n))this.__state[t]={},this.__state[t][i]=e;else{var a=n[i];(!a||e.decisionTimestamp>(a.decisionTimestamp||0))&&(this.__state[t][i]=e)}}),this)),this.emitChange()},__recordDecision:function(e){var t={layerId:e.layerId,revision:e.revision,namespace:e.namespace,pageId:e.pageId,decisionTicket:e.decisionTicket,decision:e.decision,decisionActivationId:e.activationId,decisionTimestamp:e.timestamp,decisionEventId:null},i=this.__state[e.layerId]||{};e.pageId?(delete i[r],i[e.pageId]=t):(i={})[r]=t,this.__state[e.layerId]=i,this.emitChange()},__recordDecisionEventId:function(e){var t=e.layerId,i=e.pageId||r;return this.__state[t]?this.__state[t][i]?(this.__state[t][i].decisionEventId=e.decisionId,this.emitChange(),void 0):(a.warn(\"Not recording decision event: Layer state not found for view\",i),void 0):(a.warn(\"Not recording decision event: Campaign not registered\",t),void 0)}}})";