"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[15605],{15605:function(t,e,a){a.r(e);var i=a(10736),r=a(5898),s=a(67430),n=a(44797),d=a(10353);function l(){var t=this,e=t.getAttribute("data-id"),a=t.getAttribute("data-serverid"),i=s.tF.getApiClient(a),r=this.getAttribute("data-likes");r="true"===r||"false"!==r&&null,function(t,e,a,i,r){return e.updateFavoriteStatus(e.getCurrentUserId(),a,!r)}(0,i,e,0,"true"===this.getAttribute("data-isfavorite")).then((function(e){c(t,e.Likes,e.IsFavorite)}))}function u(t,e,a){a.ItemId===this.getAttribute("data-id")&&c(this,a.Likes,a.IsFavorite)}function c(t,e,a,i){var r=t.querySelector(".material-icons");a?(r&&(r.classList.add("favorite"),r.classList.add("ratingbutton-icon-withrating")),t.classList.add("ratingbutton-withrating")):(r&&(r.classList.add("favorite"),r.classList.remove("ratingbutton-icon-withrating")),t.classList.remove("ratingbutton-withrating")),!1!==i&&(t.setAttribute("data-isfavorite",a),t.setAttribute("data-likes",null===e?"":e)),o(t,a)}function o(t,e){t.title=e?r.Ay.translate("Favorite"):r.Ay.translate("AddToFavorites");var a=t.querySelector(".button-text");a&&(a.innerText=t.title)}function h(t){var e,a,r;t.removeEventListener("click",l),(r=(e=t)[a="UserDataChanged"])&&(n.A.off(i.default,a,r),e[a]=null)}function b(t){var e,a,r;h(t),t.addEventListener("click",l),e=t,a="UserDataChanged",r=u.bind(e),n.A.on(i.default,a,r),e[a]=r}var v=Object.create(d.A);v.createdCallback=function(){d.A.createdCallback&&d.A.createdCallback.call(this)},v.attachedCallback=function(){d.A.attachedCallback&&d.A.attachedCallback.call(this);var t=this.getAttribute("data-id"),e=this.getAttribute("data-serverid");if(t&&e){var a=this.getAttribute("data-likes");c(this,a="true"===a||"false"!==a&&null,"true"===this.getAttribute("data-isfavorite"),!1),b(this)}else o(this)},v.detachedCallback=function(){d.A.detachedCallback&&d.A.detachedCallback.call(this),h(this)},v.setItem=function(t){if(t){this.setAttribute("data-id",t.Id),this.setAttribute("data-serverid",t.ServerId);var e=t.UserData||{};c(this,e.Likes,e.IsFavorite),b(this)}else this.removeAttribute("data-id"),this.removeAttribute("data-serverid"),this.removeAttribute("data-likes"),this.removeAttribute("data-isfavorite"),h(this)},document.registerElement("emby-ratingbutton",{prototype:v,extends:"button"})}}]);