"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[38965],{38965:function(t,e,a){a.r(e),a(69703),a(78557);var i=a(5898),s=a(67430),l=a(4935),r=a(10353);function n(){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),d(t,!1)):(i.markPlayed(i.getCurrentUserId(),e,new Date),d(t,!0))}function d(t,e,a){var s=t.iconElement;s||(t.iconElement=t.querySelector(".material-icons"),s=t.iconElement),e?(t.classList.add("playstatebutton-played"),s&&(s.classList.add("playstatebutton-icon-played"),s.classList.remove("playstatebutton-icon-unplayed"))):(t.classList.remove("playstatebutton-played"),s&&(s.classList.remove("playstatebutton-icon-played"),s.classList.add("playstatebutton-icon-unplayed"))),!1!==a&&t.setAttribute("data-played",e),function(t,e,a){t.title="AudioBook"!==e?a?i.Ay.translate("Watched"):i.Ay.translate("MarkPlayed"):a?i.Ay.translate("Played"):i.Ay.translate("MarkPlayed");var s=t.querySelector(".button-text");s&&(s.innerText=t.title)}(t,t.getAttribute("data-type"),e)}function c(t){var e;t.removeEventListener("click",n),null===(e=t._unsubscribeUserData)||void 0===e||e.call(t),t._unsubscribeUserData=null}function u(t){c(t),t.addEventListener("click",n);var e=t.dataset.serverid,a=s.tF.getApiClient(e);t._unsubscribeUserData=null==a?void 0:a.subscribe([l.De.UserDataChanged],(function(e){return function(t,e){var a,i=t.Data,s=e.dataset.id,l=(null!==(a=null==i?void 0:i.UserDataList)&&void 0!==a?a:[]).find((function(t){return t.ItemId===s}));l&&d(e,l.Played)}(e,t)}))}var o=Object.create(r.A);o.createdCallback=function(){r.A.createdCallback&&r.A.createdCallback.call(this)},o.attachedCallback=function(){r.A.attachedCallback&&r.A.attachedCallback.call(this);var t=this.getAttribute("data-id"),e=this.getAttribute("data-serverid");t&&e&&(d(this,"true"===this.getAttribute("data-played"),!1),u(this))},o.detachedCallback=function(){r.A.detachedCallback&&r.A.detachedCallback.call(this),c(this),this.iconElement=null},o.setItem=function(t){var e;t?(this.setAttribute("data-id",t.Id),this.setAttribute("data-serverid",t.ServerId),this.setAttribute("data-type",t.Type),d(this,null===(e=t.UserData)||void 0===e?void 0:e.Played),u(this)):(this.removeAttribute("data-id"),this.removeAttribute("data-serverid"),this.removeAttribute("data-type"),this.removeAttribute("data-played"),c(this))},document.registerElement("emby-playstatebutton",{prototype:o,extends:"button"})}}]);