"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[38965],{38965:function(t,e,a){a.r(e);var i=a(10736),l=a(5898),s=a(59774),d=a(44797),n=a(10353);function r(){var t=this,e=t.getAttribute("data-id"),a=t.getAttribute("data-serverid"),i=s.tF.getApiClient(a);t.classList.contains("playstatebutton-played")?(i.markUnplayed(i.getCurrentUserId(),e,new Date),u(t,!1)):(i.markPlayed(i.getCurrentUserId(),e,new Date),u(t,!0))}function c(t,e,a){a.ItemId===this.getAttribute("data-id")&&u(this,a.Played)}function u(t,e,a){var i=t.iconElement;i||(t.iconElement=t.querySelector(".material-icons"),i=t.iconElement),e?(t.classList.add("playstatebutton-played"),i&&(i.classList.add("playstatebutton-icon-played"),i.classList.remove("playstatebutton-icon-unplayed"))):(t.classList.remove("playstatebutton-played"),i&&(i.classList.remove("playstatebutton-icon-played"),i.classList.add("playstatebutton-icon-unplayed"))),!1!==a&&t.setAttribute("data-played",e),function(t,e,a){t.title="AudioBook"!==e&&"AudioPodcast"!==e?a?l.Ay.translate("Watched"):l.Ay.translate("MarkPlayed"):a?l.Ay.translate("Played"):l.Ay.translate("MarkPlayed");var i=t.querySelector(".button-text");i&&(i.innerText=t.title)}(t,t.getAttribute("data-type"),e)}function o(t){var e,a,l;t.removeEventListener("click",r),(l=(e=t)[a="UserDataChanged"])&&(d.A.off(i.default,a,l),e[a]=null)}function b(t){var e,a,l;o(t),t.addEventListener("click",r),e=t,a="UserDataChanged",l=c.bind(e),d.A.on(i.default,a,l),e[a]=l}var y=Object.create(n.A);y.createdCallback=function(){n.A.createdCallback&&n.A.createdCallback.call(this)},y.attachedCallback=function(){n.A.attachedCallback&&n.A.attachedCallback.call(this);var t=this.getAttribute("data-id"),e=this.getAttribute("data-serverid");t&&e&&(u(this,"true"===this.getAttribute("data-played"),!1),b(this))},y.detachedCallback=function(){n.A.detachedCallback&&n.A.detachedCallback.call(this),o(this),this.iconElement=null},y.setItem=function(t){var e;t?(this.setAttribute("data-id",t.Id),this.setAttribute("data-serverid",t.ServerId),this.setAttribute("data-type",t.Type),u(this,null===(e=t.UserData)||void 0===e?void 0:e.Played),b(this)):(this.removeAttribute("data-id"),this.removeAttribute("data-serverid"),this.removeAttribute("data-type"),this.removeAttribute("data-played"),o(this))},document.registerElement("emby-playstatebutton",{prototype:y,extends:"button"})}}]);