"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[2414],{11225:function(e,t,n){n.r(t),n.d(t,{default:function(){return p}}),n(63238),n(55849),n(98010),n(90938);var i=n(56705),a=n(3319),r=n(44614),l=n(90914),o=n(56346),s=(n(78066),n(45368),n(20716),n(6626),n(664),[]);function c(e){i.ZP.show(),ApiClient.getJSON(ApiClient.getUrl("Repositories")).then((function(t){var n,a;s=t,n={listElement:e.querySelector("#repositories"),noneElement:e.querySelector("#none"),repositories:s},(a=document.createElement("div")).className="paperList",n.repositories.forEach((function(e){a.appendChild(function(e){var t=document.createElement("div");t.className="listItem listItem-border";var n=document.createElement("a","emby-linkbutton");n.classList.add("clearLink","listItemIconContainer"),n.style.margin="0",n.style.padding="0",n.rel="noopener noreferrer",n.target="_blank",n.href=e.Url,n.innerHTML='<span class="material-icons listItemIcon open_in_new" aria-hidden="true"></span>',t.appendChild(n);var i=document.createElement("div");i.className="listItemBody two-line";var a=document.createElement("h3");a.className="listItemBodyText",a.innerText=e.Name,i.appendChild(a);var l=document.createElement("div");l.className="listItemBodyText secondary",l.innerText=e.Url,i.appendChild(l),t.appendChild(i);var o=document.createElement("button","paper-icon-button-light");return o.type="button",o.classList.add("btnDelete"),o.id=e.Url,o.title=r.ZP.translate("Delete"),o.innerHTML='<span class="material-icons delete" aria-hidden="true"></span>',t.appendChild(o),t}(e))})),n.repositories.length?n.noneElement.classList.add("hide"):n.noneElement.classList.remove("hide"),n.listElement.innerHTML="",n.listElement.appendChild(a),i.ZP.hide()})).catch((function(t){console.error("error loading repositories",t),e.querySelector("#none").classList.remove("hide"),i.ZP.hide()}))}function d(e){i.ZP.show(),ApiClient.ajax({type:"POST",url:ApiClient.getUrl("Repositories"),data:JSON.stringify(s),contentType:"application/json"}).then((function(){c(e)})).catch((function(e){console.error("error saving repositories",e),i.ZP.hide()}))}function u(){return[{href:"#!/installedplugins.html",name:r.ZP.translate("TabMyPlugins")},{href:"#!/availableplugins.html",name:r.ZP.translate("TabCatalog")},{href:"#!/repositories.html",name:r.ZP.translate("TabRepositories")}]}function p(e){e.addEventListener("viewshow",(function(){a.Z.setTabs("plugins",2,u),c(this);var t=this;$("#repositories",e).on("click",".btnDelete",(function(){var e=this;s=s.filter((function(t){return t.Url!==e.id})),d(t)}))})),e.querySelector(".btnNewRepository").addEventListener("click",(function(){var t=l.default.createDialog({scrollY:!1,size:"large",modal:!1,removeOnClose:!0}),n="";n+='<div class="formDialogHeader">',n+='<button type="button" is="paper-icon-button-light" class="btnCancel autoSize" tabindex="-1" title="'.concat(r.ZP.translate("ButtonBack"),'"><span class="material-icons arrow_back" aria-hidden="true"></span></button>'),n+='<h3 class="formDialogHeaderTitle">'.concat(r.ZP.translate("HeaderNewRepository"),"</h3>"),n+="</div>",n+='<form class="newPluginForm" style="margin:4em">',n+='<div class="inputContainer">',n+='<input is="emby-input" id="txtRepositoryName" label="'.concat(r.ZP.translate("LabelRepositoryName"),'" type="text" required />'),n+='<div class="fieldDescription">'.concat(r.ZP.translate("LabelRepositoryNameHelp"),"</div>"),n+="</div>",n+='<div class="inputContainer">',n+='<input is="emby-input" id="txtRepositoryUrl" label="'.concat(r.ZP.translate("LabelRepositoryUrl"),'" type="url" required />'),n+='<div class="fieldDescription">'.concat(r.ZP.translate("LabelRepositoryUrlHelp"),"</div>"),n+="</div>",n+='<button is="emby-button" type="submit" class="raised button-submit block"><span>'.concat(r.ZP.translate("Save"),"</span></button>"),n+="</div>",n+="</form>",t.innerHTML=n,t.querySelector(".btnCancel").addEventListener("click",(function(){l.default.close(t)})),t.querySelector(".newPluginForm").addEventListener("submit",(function(n){n.preventDefault();var i=t.querySelector("#txtRepositoryUrl").value.toLowerCase(),a=function(){s.push({Name:t.querySelector("#txtRepositoryName").value,Url:t.querySelector("#txtRepositoryUrl").value,Enabled:!0}),d(e),l.default.close(t)};if(i.startsWith("https://repo.jellyfin.org/"))a();else{var c=r.ZP.translate("MessageRepositoryInstallDisclaimer");c+="<br/>",c+="<br/>",c+=r.ZP.translate("PleaseConfirmRepositoryInstallation"),(0,o.Z)(c,r.ZP.translate("HeaderConfirmRepositoryInstallation")).then((function(){a()})).catch((function(){console.debug("repository not installed"),l.default.close(t)}))}return!1})),l.default.open(t)}))}}}]);