"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[6408],{21767:function(e,t,i){i.r(t),i(61013),i(27471),i(5769),i(63238),i(61418),i(17460),i(14078),i(98010);var n=i(65009),s=i.n(n),r=(i(72326),i(45368),i(76543));function o(e,t,i,n,r,o){var a='<div class="checkboxList paperList" style="padding: .5em 1em;">';a+=t.map((function(e){var t=(o?-1!=r.indexOf(e.Id):-1==r.indexOf(e.Id))?' checked="checked"':"";return'<label><input is="emby-checkbox" class="'+i+'" type="checkbox" data-itemid="'+e.Id+'"'+t+"/><span>"+s()(e.Name)+"</span></label>"})).join(""),a+="</div>",e.html(a).trigger("create")}function a(){var e,t,i,n;return e=$(this).parents(".page"),t=getParameterByName("type"),i=ApiClient.getNamedConfiguration(c),n=ApiClient.getJSON(ApiClient.getUrl("Notifications/Types")),Promise.all([i,n]).then((function(i){var n=i[0],s=n.Options.filter((function(e){return e.Type==t}))[0];s||(s={Type:t},n.Options.push(s)),s.Enabled=$("#chkEnabled",e).is(":checked"),s.SendToUserMode=$("#selectUsers",e).val(),s.DisabledMonitorUsers=$(".chkMonitor",e).get().filter((function(e){return!e.checked})).map((function(e){return e.getAttribute("data-itemid")})),s.SendToUsers=$(".chkSendTo",e).get().filter((function(e){return e.checked})).map((function(e){return e.getAttribute("data-itemid")})),s.DisabledServices=$(".chkService",e).get().filter((function(e){return!e.checked})).map((function(e){return e.getAttribute("data-itemid")})),ApiClient.updateNamedConfiguration(c,n).then((function(){r.ZP.processServerConfigurationUpdateResult(),r.ZP.navigate("notificationsettings.html")}))})),!1}var c="notifications";$(document).on("pageinit","#notificationSettingPage",(function(){var e=this;$("#selectUsers",e).on("change",(function(){"Custom"==this.value?$(".selectCustomUsers",e).show():$(".selectCustomUsers",e).hide()})),$(".notificationSettingForm").off("submit",a).on("submit",a)})).on("pageshow","#notificationSettingPage",(function(){var e,t,i,n,r,a;e=this,t=getParameterByName("type"),i=ApiClient.getUsers(),n=ApiClient.getNamedConfiguration(c),r=ApiClient.getJSON(ApiClient.getUrl("Notifications/Types")),a=ApiClient.getJSON(ApiClient.getUrl("Notifications/Services")),Promise.all([i,n,r,a]).then((function(i){var n=i[0],r=i[1],a=i[2],c=i[3],d=r.Options.filter((function(e){return e.Type==t}))[0],l=a.filter((function(e){return e.Type==t}))[0]||{};l.IsBasedOnUserEvent?$(".monitorUsers",e).show():$(".monitorUsers",e).hide(),$(".notificationType",e).html(s()(l.Name||"")||"Unknown Notification"),d||(d={DisabledMonitorUsers:[],SendToUsers:[],DisabledServices:[],SendToUserMode:"Admins"}),o($(".monitorUsersList",e),n,"chkMonitor",0,d.DisabledMonitorUsers),o($(".sendToUsersList",e),n,"chkSendTo",0,d.SendToUsers,!0),o($(".servicesList",e),c,"chkService",0,d.DisabledServices),$("#chkEnabled",e).prop("checked",d.Enabled||!1),$("#selectUsers",e).val(d.SendToUserMode).trigger("change")}))}))}}]);