"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[44184],{78983:function(e,t,n){n(29305),n(32733),n(84701),n(69892),n(44962),n(89336),n(78557),n(95021),n(73687),n(83994),n(23630),n(82367);var r,a,i=n(39738),o=n(44797),c=n(5898),s=n(67430),l=n(2290),u=n(4935),d=n.p+"notificationicon.d6ecf2254db85ff3b545.png";function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function v(){document.removeEventListener("click",v),document.removeEventListener("keydown",v),window.Notification&&"default"===window.Notification.permission&&Notification.requestPermission()}function g(){o.A.off(s.tF,"localusersignedin",g),document.addEventListener("click",v),document.addEventListener("keydown",v)}function m(){var e=navigator.serviceWorker;e&&e.ready.then((function(e){a=e}))}function y(e,t,n){try{var r=new Notification(e,t);r.show&&r.show(),n&&function(e,t){setTimeout((function(){e.close?e.close():e.cancel&&e.cancel()}),t)}(r,n)}catch(r){if(!t.actions)throw r;t.actions=[],y(e,t,n)}}function b(e,t,n){var r=e.title;e.data=e.data||{},e.data.serverId=n.serverInfo().Id,e.icon=e.icon||d,e.badge=e.badge||d,m(),a?function(e,t){a.showNotification(e,t)}(r,e):y(r,e,t)}function I(e,t){if(!i.f.isPlayingLocally(["Video"])){var n=e.Name;e.SeriesName&&(n=e.SeriesName+" - "+n);var r={title:"New "+e.Type,body:n,vibrate:!0,tag:"newItem"+e.Id,data:{}},a=e.ImageTags||{};a.Primary&&(r.icon=t.getScaledImageUrl(e.Id,{width:80,tag:a.Primary,type:"Primary"})),b(r,15e3,t)}}function h(e,t,n){e.getCurrentUser().then((function(r){if(r.Policy.IsAdministrator){var a={tag:"install"+t.Id,data:{}};if("completed"===n?(a.title=c.Ay.translate("PackageInstallCompleted",t.Name,t.Version),a.vibrate=!0):"cancelled"===n?a.title=c.Ay.translate("PackageInstallCancelled",t.Name,t.Version):"failed"===n?(a.title=c.Ay.translate("PackageInstallFailed",t.Name,t.Version),a.vibrate=!0):"progress"===n&&(a.title=c.Ay.translate("InstallingPackage",t.Name,t.Version),a.actions=[{action:"cancel-install",title:c.Ay.translate("ButtonCancel"),icon:d}],a.data.id=t.id),"progress"===n){var i=Math.round(t.PercentComplete||0);a.body=i+"% complete."}b(a,"cancelled"===n?5e3:0,e)}}))}function p(e){e.subscribe([u.De.LibraryChanged],(function(t){!function(e,t){var n=e.ItemsAdded;n.length&&(n.length>12&&(n.length=12),(0,l.J)(t,t.getCurrentUserId(),{Recursive:!0,Limit:3,Filters:"IsNotFolder",SortBy:"DateCreated",SortOrder:"Descending",Ids:n.join(","),MediaTypes:"Audio,Video",EnableTotalRecordCount:!1}).then((function(e){var n,r=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return f(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?f(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,c=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){c=!0,i=e},f:function(){try{o||null==n.return||n.return()}finally{if(c)throw i}}}}(e.Items);try{for(r.s();!(n=r.n()).done;)I(n.value,t)}catch(e){r.e(e)}finally{r.f()}})))}(t.Data,e)})),e.subscribe([u.De.PackageInstallationCompleted],(function(t){var n=t.Data;h(e,n,"completed")})),e.subscribe([u.De.PackageInstallationFailed],(function(t){var n=t.Data;h(e,n,"failed")})),e.subscribe([u.De.PackageInstallationCancelled],(function(t){var n=t.Data;h(e,n,"cancelled")})),e.subscribe([u.De.PackageInstalling],(function(t){var n=t.Data;h(e,n,"progress")})),e.subscribe([u.De.ServerShuttingDown],(function(){b({tag:"restart"+e.serverInfo().Id,title:c.Ay.translate("ServerNameIsShuttingDown",e.serverInfo().Name)},0,e)})),e.subscribe([u.De.ServerRestarting],(function(){b({tag:"restart"+e.serverInfo().Id,title:c.Ay.translate("ServerNameIsRestarting",e.serverInfo().Name)},0,e)})),e.subscribe([u.De.RestartRequired],(function(){var t={tag:"restart"+e.serverInfo().Id,title:c.Ay.translate("PleaseRestartServerName",e.serverInfo().Name)};t.actions=[{action:"restart",title:c.Ay.translate("Restart"),icon:d}],b(t,0,e)}))}(r=s.tF.currentApiClient())?r.getCurrentUser().then((function(){return g()})).catch((function(){o.A.on(s.tF,"localusersignedin",g)})):g(),m(),s.tF.getApiClients().forEach(p),o.A.on(s.tF,"apiclientcreated",(function(e,t){return p(t)}))}}]);