define(["appStorage","events"],function(appStorage,events){"use strict";function getKey(name,userId){return userId&&(name=userId+"-"+name),name}function AppSettings(){var self=this;self.enableAutoLogin=function(val){return null!=val&&self.set("enableAutoLogin",val.toString()),"false"!==self.get("enableAutoLogin")},self.enableAutomaticBitrateDetection=function(val){return null!=val&&self.set("enableAutomaticBitrateDetection",val.toString()),"false"!==self.get("enableAutomaticBitrateDetection")},self.maxStreamingBitrate=function(val){return null!=val&&self.set("preferredVideoBitrate",val),parseInt(self.get("preferredVideoBitrate")||"0")||15e5},self.maxStaticMusicBitrate=function(val){void 0!==val&&self.set("maxStaticMusicBitrate",val);var defaultValue=32e4;return parseInt(self.get("maxStaticMusicBitrate")||defaultValue.toString())||defaultValue},self.maxChromecastBitrate=function(val){return null!=val&&self.set("chromecastBitrate1",val),val=self.get("chromecastBitrate1"),val?parseInt(val):null},self.syncOnlyOnWifi=function(val){return null!=val&&self.set("syncOnlyOnWifi",val.toString()),"false"!==self.get("syncOnlyOnWifi")},self.syncPath=function(val){return null!=val&&self.set("syncPath",val),self.get("syncPath")},self.cameraUploadServers=function(val){return null!=val&&self.set("cameraUploadServers",val.join(",")),val=self.get("cameraUploadServers"),val?val.split(","):[]},self.set=function(name,value,userId){var currentValue=self.get(name,userId);appStorage.setItem(getKey(name,userId),value),currentValue!==value&&events.trigger(self,"change",[name])},self.get=function(name,userId){return appStorage.getItem(getKey(name,userId))}}return new AppSettings});