define(["exports","./../viewmanager/basesettingsview.js","./../common/globalize.js","./../emby-elements/emby-input/emby-input.js","./../emby-elements/emby-button/emby-button.js","./../emby-elements/emby-button/paper-icon-button-light.js","./../emby-elements/emby-checkbox/emby-checkbox.js","./../emby-elements/emby-select/emby-select.js","./../emby-elements/emby-scroller/emby-scroller.js","./../common/appsettings.js","./../layoutmanager.js","./../common/pluginmanager.js","./../approuter.js","./../listview/listview.js"],function(_exports,_basesettingsview,_globalize,_embyInput,_embyButton,_paperIconButtonLight,_embyCheckbox,_embySelect,_embyScroller,_appsettings,_layoutmanager,_pluginmanager,_approuter,_listview){function getPlayerHtml(player){var html="",icon="live_tv",tagName=("Game"===player.mediaType?icon="games":"Audio"===player.mediaType&&(icon="audiotrack"),_layoutmanager.default.tv?"button":"div"),html=(html+="<"+tagName+' class="playerItem '+(_layoutmanager.default.tv?"listItem btnOptions playerItem":"listItem playerItem")+'" data-id="'+(player.id||"")+'">')+('<i class="md-icon listItemIcon">'+icon+"</i>")+'<div class="listItemBody">';return player.mediaType&&(html=(html+="<div>")+_globalize.default.translate(player.mediaType)+"</div>"),player.path&&(html=(html+='<div class="secondary">')+player.path+"</div>"),html+="</div>",_layoutmanager.default.tv||(html+='<button type="button" is="paper-icon-button-light" class="btnOptions"><i class="md-icon">more_vert</i></button>'),html+="</"+tagName+">"}function getPlayers(){return JSON.parse(_appsettings.default.get("externalplayers")||"[]")}function View(view,params){_basesettingsview.default.apply(this,arguments);var instance=this;function editPlayer(id){var url=_pluginmanager.default.mapRoute("externalplayer","externalplayer.html");id&&(url+="?id="+id),_approuter.default.show(url)}view.querySelector(".btnAdd").addEventListener("click",function(){editPlayer()}),view.querySelector(".players").addEventListener("click",function(e){var playerItem=e.target.closest(".playerItem");playerItem&&(e=e.target.closest(".btnOptions"),_layoutmanager.default.tv||e)&&!function(playerId){var menuItems;getPlayers().filter(function(p){return p.id===playerId})[0]&&((menuItems=[]).push({name:_globalize.default.translate("Edit"),id:"edit"}),menuItems.push({name:_globalize.default.translate("Delete"),id:"delete"}),function(options){return Emby.importModule("./modules/actionsheet/actionsheet.js").then(function(ActionSheet){return ActionSheet.show(options)})}({items:menuItems,title:_globalize.default.translate("ExternalPlayer")}).then(function(id){switch(id){case"edit":editPlayer(playerId);break;case"delete":!function(id){var players=getPlayers().filter(function(p){return p.id!==id});_appsettings.default.set("externalplayers",JSON.stringify(players)),instance.loadSettings({autoFocus:!0})}(playerId)}}))}(playerItem.getAttribute("data-id"))})}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,require(["material-icons"]),Object.assign(View.prototype,_basesettingsview.default.prototype),View.prototype.loadSettingsInternal=function(){var view,html;return view=this.view,html=getPlayers().map(getPlayerHtml).join(""),view.querySelector(".players").innerHTML=html,Promise.resolve()},_exports.default=View});