define(["appHeader","playbackSettings","connectionManager","userSettingsBuilder","userSettings","layoutManager","dom","globalize","loading","listViewStyle","emby-scroller"],function(appHeader,PlaybackSettings,connectionManager,userSettingsBuilder,currentUserSettings,layoutManager,dom,globalize,loading){"use strict";return function(view,params){var settingsInstance,apiClient=connectionManager.getApiClient(params.serverId),userId=params.userId||apiClient.getCurrentUserId(),userSettings=userId===apiClient.getCurrentUserId()?currentUserSettings:new userSettingsBuilder,hasChanges=!1;function onBeforeUnload(e){hasChanges&&(e.returnValue="You currently have unsaved changes. Are you sure you wish to leave?")}view.addEventListener("change",function(){hasChanges=!0}),view.addEventListener("viewshow",function(e){window.addEventListener("beforeunload",onBeforeUnload);e.detail.isRestored;settingsInstance?settingsInstance.loadData():settingsInstance=new PlaybackSettings({serverId:apiClient.serverId(),userId:userId,element:view.querySelector(".settingsContainer"),userSettings:userSettings,enableSaveButton:!1,enableSaveConfirmation:!1,autoFocus:!0})}),view.addEventListener("viewbeforehide",function(){window.removeEventListener("beforeunload",onBeforeUnload),settingsInstance&&settingsInstance.submit()}),view.addEventListener("viewdestroy",function(){settingsInstance&&(settingsInstance.destroy(),settingsInstance=null)})}});