define(["exports","./browser.js","./emby-apiclient/events.js","./common/appsettings.js","./common/servicelocator.js"],function(_exports,_browser,_events,_appsettings,_servicelocator){var currentLayout;function setLayout(instance,layout,selectedLayout){layout===selectedLayout?(instance[layout]=!0,"tv"===layout&&document.documentElement.classList.add("layout-"+layout)):(instance[layout]=!1,"tv"===layout&&document.documentElement.classList.remove("layout-"+layout))}function LayoutManager(){var saved=this.getSavedLayout();saved?this.setLayout(saved,!1):this.autoLayout()}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,LayoutManager.prototype.setLayout=function(layout,save){var changed;layout&&"auto"!==layout?(setLayout(this,"mobile",layout),setLayout(this,"tv",layout),setLayout(this,"desktop",layout),!1!==save&&_appsettings.default.set("layout",layout),changed=currentLayout!==layout,currentLayout=layout,changed&&_events.default.trigger(this,"modechange")):(this.autoLayout(),!1!==save&&_appsettings.default.set("layout",""))},LayoutManager.prototype.getSavedLayout=function(layout){return _appsettings.default.get("layout")},LayoutManager.prototype.autoLayout=function(){this.setLayout(this.getDefaultLayout(),!1)},LayoutManager.prototype.getDefaultLayout=function(){if(_servicelocator.appHost.getDefaultLayout){var result=_servicelocator.appHost.getDefaultLayout();if(result)return result}return _browser.default.tv||(!(result=navigator.userAgentData)||!result.mobile)&&(_browser.default.electron||window.location.href.toString().toLowerCase().includes("tv.emby"))?"tv":"mobile"};_exports.default=new LayoutManager});