define([
  "exports",
  "./../modules/loading/loading.js",
  "./../modules/emby-apiclient/connectionmanager.js",
  "./../modules/emby-apiclient/apiclient.js",
  "./../modules/emby-apiclient/events.js",
  "./../modules/common/globalize.js",
  "./../modules/common/playback/playbackmanager.js",
  "./../modules/appheader/appheader.js",
  "./../modules/backdrop/backdrop.js",
  "./../modules/common/itemhelper.js",
  "./../modules/common/dataformatter.js",
  "./../modules/common/itemmanager/itemmanager.js",
  "./../modules/layoutmanager.js",
  "./../modules/common/usersettings/usersettings.js",
  "./../modules/viewmanager/baseview.js",
  "./../modules/emby-elements/emby-scroller/emby-scroller.js",
  "./../modules/emby-elements/emby-tabs/emby-tabs.js",
  "./../modules/emby-elements/emby-itemscontainer/emby-itemscontainer.js",
  "./../modules/emby-elements/emby-button/emby-button.js",
  "./../modules/emby-elements/sync/emby-downloadbutton.js",
  "./../modules/emby-elements/emby-select/emby-select.js",
  "./../modules/listview/listview.js",
  "./../modules/cardbuilder/cardbuilder.js",
  "./../modules/itemcontextmenu.js",
  "./../modules/indicators/indicators.js",
  "./../modules/navdrawer/navdrawer.js",
  "./../modules/common/textencoding.js",
  "./../modules/dom.js",
  "./../modules/approuter.js",
  "./../modules/common/datetime.js",
  "./../modules/mediainfo/mediainfo.js",
  "./../modules/common/servicelocator.js",
  "./../modules/focusmanager.js",
  "./../modules/imageloader/imageloader.js",
  "./../modules/multiselect/multiselect.js",
  "./../modules/skinmanager.js",
  "./../modules/common/input/api.js",
], function (
  _exports,
  _loading,
  _connectionmanager,
  _apiclient,
  _events,
  _globalize,
  _playbackmanager,
  _appheader,
  _backdrop,
  _itemhelper,
  _dataformatter,
  _itemmanager,
  _layoutmanager,
  _usersettings,
  _baseview,
  _embyScroller,
  _embyTabs,
  _embyItemscontainer,
  _embyButton,
  _embyDownloadbutton,
  _embySelect,
  _listview,
  _cardbuilder,
  _itemcontextmenu,
  _indicators,
  _navdrawer,
  _textencoding,
  _dom,
  _approuter,
  _datetime,
  _mediainfo,
  _servicelocator,
  _focusmanager,
  _imageloader,
  _multiselect,
  _skinmanager,
  _api,
) {
  Object.defineProperty(_exports, "__esModule", { value: !0 }),
    (_exports.default = void 0),
    require(["flexStyles", "css!item/item.css"]);
  var backdropContainer = document.querySelector(".backdropContainer"),
    backgroundContainer = document.querySelector(".backgroundContainer"),
    skinHeader = document.querySelector(".skinHeader"),
    decodingAttribute = _dom.default.supportsAsyncDecodedImages()
      ? ' decoding="async"'
      : "";
  function renderTrackSelectionsWithoutUser(page, instance, item, forceReload) {
    _connectionmanager.default
      .getApiClient(item.ServerId)
      .getCurrentUser()
      .then(function (user) {
        renderTrackSelections(page, instance, item, user, forceReload);
      });
  }
  function isMediaStreamDisplayed(stream) {
    return "Data" !== stream.Type && "Attachment" !== stream.Type;
  }
  function renderMediaSources(page, renderAdminFields, item, mediaSources) {
    for (
      var groupedVersions = mediaSources.filter(function (g) {
          return "Grouping" === g.Type;
        }),
        parentElem =
          (renderAdminFields && groupedVersions.length
            ? page
                .querySelector(".splitVersionContainer")
                .classList.remove("hide")
            : page
                .querySelector(".splitVersionContainer")
                .classList.add("hide"),
          page.querySelector(".mediaSources")),
        anyDisplayed = !1,
        i = ((parentElem.innerHTML = ""), 0),
        length = mediaSources.length;
      i < length;
      i++
    ) {
      var mediaSource = mediaSources[i];
      !(function (version, renderAdminFields) {
        for (var i = 0, length = version.MediaStreams.length; i < length; i++)
          if (isMediaStreamDisplayed(version.MediaStreams[i])) return 1;
        return (
          version.Container ||
          (version.Formats && version.Formats.length) ||
          (version.Path && "Http" !== version.Protocol && renderAdminFields) ||
          !!version.Size
        );
      })(mediaSource, renderAdminFields) ||
        ((anyDisplayed = !0),
        (function (parentElem, renderAdminFields, item, mediaSource, scrollX) {
          var elem = document.createElement("div"),
            html = (elem.classList.add("mediaSource"), ""),
            renderAdminFields =
              ((html += scrollX
                ? '<div class="sectionTitle sectionTitle-cards" style="display:block;padding: 0 .3em .5em;">'
                : '<div style="display:block;">'),
              mediaSource.Path &&
                "Http" !== mediaSource.Protocol &&
                renderAdminFields &&
                (html += "<div>" + mediaSource.Path + "</div>"),
              (html += '<div class="mediaInfoItems">'),
              mediaSource.Container &&
                (html += mediaSource.Container.toUpperCase()),
              mediaSource.Size &&
                (html +=
                  '<span class="mediaInfoItem">' +
                  _dataformatter.default.sizeToString(mediaSource.Size) +
                  "</span>"),
              new Date(Date.parse(item.DateCreated))),
            renderAdminFields =
              ((html +=
                '<span class="mediaInfoItem">' +
                _globalize.default.translate(
                  "AddedOnValue",
                  _datetime.default.toLocaleDateString(renderAdminFields) +
                    " " +
                    _datetime.default.getDisplayTime(renderAdminFields),
                ) +
                "</span>"),
              (elem.innerHTML = html =
                (html = html + "</div>" + "</div>") &&
                '<div class="padded-left padded-left-page padded-right">' +
                  html +
                  "</div>"),
              elem.insertAdjacentHTML(
                "beforeend",
                scrollX
                  ? '<div is="emby-scroller" class="emby-scroller padded-top-focusscale padded-bottom-focusscale padded-left padded-left-page padded-right" data-mousewheel="false" data-focusscroll="true" data-horizontal="true"><div is="emby-itemscontainer" class="detailMediaStreamsItemsContainer itemsContainer-defaultCardSize scrollSlider focuscontainer-x itemsContainer focusable" data-focusabletype="nearest"></div></div>'
                  : '<div is="emby-itemscontainer" class="vertical-list itemsContainer padded-left padded-left-page padded-right itemsContainer-defaultCardSize"></div>',
              ),
              parentElem.appendChild(elem),
              mediaSource.MediaStreams.filter(isMediaStreamDisplayed).map(
                function (s) {
                  return _itemhelper.default.normalizeMediaStreamForDisplay(
                    item,
                    mediaSource,
                    s,
                  );
                },
              ));
          scrollX
            ? _cardbuilder.default.buildCards(renderAdminFields, {
                shape: "backdrop",
                overlayText: !0,
                fields: ["MediaStreamInfo"],
                itemsContainer: elem.querySelector(".itemsContainer"),
                action: "none",
                multiSelect: !1,
                ratingButton: !1,
                playedButton: !1,
                defaultIcon: !1,
                typeIndicator: !1,
                playedIndicator: !1,
                syncIndicator: !1,
                timerIndicator: !1,
                randomDefaultBackground: !1,
                imageFallback: !1,
                cardPadderClass: _layoutmanager.default.tv
                  ? "mediaStreamPadder-tv"
                  : "mediaStreamPadder",
                innerCardFooterClass: "mediaStreamInnerCardFooter",
                enableUserData: !1,
                draggable: !1,
                enableFocusScaling: !1,
              })
            : _listview.default.buildItems(renderAdminFields, {
                image: !1,
                fields: ["MediaStreamInfo"],
                itemsContainer: elem.querySelector(".itemsContainer"),
                action: "none",
                multiSelect: !1,
                ratingButton: !1,
                playedButton: !1,
                defaultIcon: !1,
                typeIndicator: !1,
                playedIndicator: !1,
                syncIndicator: !1,
                timerIndicator: !1,
                randomDefaultBackground: !1,
                imageFallback: !1,
                innerCardFooterClass: "mediaStreamInnerCardFooter",
                enableUserDataButtons: !1,
                draggable: !1,
                itemClass: "detailsListItem",
              });
        })(parentElem, renderAdminFields, item, mediaSource, !0));
    }
    anyDisplayed && _usersettings.default.showFullMediaInfoOnDetailScreen()
  }
  function isRenderingTrackSelections(item) {
    return !(
      !_itemhelper.default.supportsMediaSourceSelection(item) ||
      -1 ===
        _playbackmanager.default
          .getSupportedCommands()
          .indexOf("PlayMediaSource") ||
      !_playbackmanager.default.canPlay(item)
    );
  }
  function renderTrackSelections(
    page,
    instance,
    item,
    user,
    forceReload,
    mediaSources,
  ) {
    var select = page.querySelector(".selectSource"),
      apiClient = _connectionmanager.default.getApiClient(item);
    isRenderingTrackSelections(item)
      ? (mediaSources
          ? Promise.resolve(mediaSources)
          : _playbackmanager.default.getPlaybackMediaSources(item)
        ).then(function (mediaSources) {
          var renderAdminFields = user.Policy.IsAdministrator,
            renderAdminFields =
              (renderMediaSources(page, renderAdminFields, item, mediaSources),
              (instance._currentPlaybackMediaSources = mediaSources),
              instance.trackSelectionsContainer.classList.remove("hide"),
              select.value),
            selectedId = mediaSources[0].Id;
          (select.innerHTML = mediaSources
            .map(function (v) {
              var selected = v.Id === selectedId ? " selected" : "";
              return (
                '<option value="' +
                v.Id +
                '"' +
                selected +
                ">" +
                _textencoding.default.htmlEncode(v.Name) +
                "</option>"
              );
            })
            .join("")),
            1 < mediaSources.length
              ? (select.removeAttribute("disabled"),
                page
                  .querySelector(".selectSourceContainer")
                  .classList.remove("hide"))
              : (page
                  .querySelector(".selectSourceContainer")
                  .classList.add("hide"),
                select.setAttribute("disabled", "disabled")),
            (select.value === renderAdminFields && !forceReload) ||
              (renderMediaInfo(0, page, item, mediaSources),
              renderVideoSelections(page, mediaSources),
              renderAudioSelections(page, mediaSources),
              renderSubtitleSelections(page, mediaSources),
              updateTrackSelectionsFocusState(instance, page));
        })
      : (renderMediaInfo(0, page, item, item.MediaSources || []),
        renderMediaSources(
          page,
          user.Policy.IsAdministrator,
          item,
          item.MediaSources || [],
        ),
        (instance._currentPlaybackMediaSources = []),
        instance.trackSelectionsContainer.classList.add("hide"),
        (select.innerHTML = ""),
        (page.querySelector(".selectVideo").innerHTML = ""),
        (page.querySelector(".selectAudio").innerHTML = ""),
        (page.querySelector(".selectSubtitles").innerHTML = ""),
        select.setAttribute("disabled", "disabled"),
        updateTrackSelectionsFocusState(instance, page));
  }
  function renderVideoSelections(page, mediaSources) {
    var mediaSourceId = page.querySelector(".selectSource").value,
      mediaSources = mediaSources
        .filter(function (m) {
          return m.Id === mediaSourceId;
        })[0]
        .MediaStreams.filter(function (m) {
          return "Video" === m.Type;
        }),
      select = page.querySelector(".selectVideo"),
      selectedId = mediaSources.length ? mediaSources[0].Index : -1;
    (select.innerHTML = mediaSources
      .map(function (v) {
        var selected = v.Index === selectedId ? " selected" : "",
          titleParts = [],
          resolutionText = _dataformatter.default.getResolutionText(v);
        return (
          resolutionText && titleParts.push(resolutionText),
          v.Codec && titleParts.push(v.Codec.toUpperCase()),
          '<option value="' +
            v.Index +
            '" ' +
            selected +
            ">" +
            _textencoding.default.htmlEncode(
              v.DisplayTitle || titleParts.join(" "),
            ) +
            "</option>"
        );
      })
      .join("")),
      select.setAttribute("disabled", "disabled"),
      mediaSources.length
        ? page.querySelector(".selectVideoContainer").classList.remove("hide")
        : page.querySelector(".selectVideoContainer").classList.add("hide");
  }
  function renderAudioSelections(page, mediaSources) {
    var mediaSourceId = page.querySelector(".selectSource").value,
      mediaSources = mediaSources.filter(function (m) {
        return m.Id === mediaSourceId;
      })[0],
      tracks = mediaSources.MediaStreams.filter(function (m) {
        return "Audio" === m.Type;
      }),
      select = page.querySelector(".selectAudio"),
      selectedId = mediaSources.DefaultAudioStreamIndex;
    (select.innerHTML = tracks
      .map(function (v) {
        var selected = v.Index === selectedId ? " selected" : "",
          embeddedTitle =
            v.Title && !(v.DisplayTitle || "").includes(v.Title)
              ? v.Title
              : null;
        return (
          "<option" +
          (embeddedTitle ? ' title="' + embeddedTitle + '"' : "") +
          ' value="' +
          v.Index +
          '" ' +
          selected +
          ">" +
          _textencoding.default.htmlEncode(v.DisplayTitle) +
          "</option>"
        );
      })
      .join("")),
      1 < tracks.length
        ? select.removeAttribute("disabled")
        : select.setAttribute("disabled", "disabled"),
      tracks.length
        ? page.querySelector(".selectAudioContainer").classList.remove("hide")
        : page.querySelector(".selectAudioContainer").classList.add("hide");
  }
  function renderSubtitleSelections(page, mediaSources) {
    var selected,
      mediaSourceId = page.querySelector(".selectSource").value,
      mediaSources = mediaSources.filter(function (m) {
        return m.Id === mediaSourceId;
      })[0],
      tracks = mediaSources.MediaStreams.filter(function (m) {
        return "Subtitle" === m.Type;
      }),
      select = page.querySelector(".selectSubtitles"),
      selectedId =
        null == mediaSources.DefaultSubtitleStreamIndex
          ? -1
          : mediaSources.DefaultSubtitleStreamIndex;
    tracks.length
      ? ((selected = -1 === selectedId ? " selected" : ""),
        (select.innerHTML =
          '<option value="-1">' +
          _globalize.default.translate("Off") +
          "</option>" +
          tracks
            .map(function (v) {
              selected = v.Index === selectedId ? " selected" : "";
              var embeddedTitle =
                v.Title && !(v.DisplayTitle || "").includes(v.Title)
                  ? v.Title
                  : null;
              return (
                "<option" +
                (embeddedTitle ? ' title="' + embeddedTitle + '"' : "") +
                ' value="' +
                v.Index +
                '" ' +
                selected +
                ">" +
                _textencoding.default.htmlEncode(v.DisplayTitle) +
                "</option>"
              );
            })
            .join("")),
        select.classList.remove("noSelections"),
        page
          .querySelector(".selectSubtitlesContainer")
          .classList.remove("hide"))
      : ((select.innerHTML = ""),
        select.classList.add("noSelections"),
        page.querySelector(".selectSubtitlesContainer").classList.add("hide"));
  }
  function setButtonText(page, query, html) {
    for (
      var elems = page.querySelectorAll(query), i = 0, length = elems.length;
      i < length;
      i++
    ) {
      elems[i].innerHTML = html;
      var btn = elems[i].closest("button");
      btn && ((btn.title = html), btn.setAttribute("aria-label", html));
    }
  }
  function setResumeProgress(resumeInfoElement, item) {
    var ticksLeft,
      resumeInfoElement = resumeInfoElement.querySelector(".resumeProgress");
    item.UserData &&
    0 < item.UserData.PlaybackPositionTicks &&
    item.RunTimeTicks
      ? ((ticksLeft = item.RunTimeTicks - item.UserData.PlaybackPositionTicks),
        (ticksLeft =
          '<div class="resumeTimeRemaining secondaryText">' +
          _globalize.default.translate(
            "TimeRemainingValue",
            _datetime.default.getHumanReadableRuntime(ticksLeft),
          ) +
          "</div>"),
        (resumeInfoElement.innerHTML =
          _indicators.default.getProgressBarHtml(item, {
            containerClass: "resumeInfoProgressBar",
            animated: !0,
          }) + ticksLeft),
        resumeInfoElement.classList.remove("hide"))
      : resumeInfoElement.classList.add("hide");
  }
  function reloadPlayButtons(instance, page, item, isUserDataChangeEvent) {
    var now,
      activeElement,
      isPlayFocused,
      btnPlay,
      btnResume,
      btnPlayTrailer,
      btnShuffle,
      playButtons = page.querySelectorAll(".btnPlay");
    "Program" === item.Type
      ? ((now = new Date()) >= new Date(Date.parse(item.StartDate)) &&
        now < new Date(Date.parse(item.EndDate))
          ? hideAll(page, playButtons, !0)
          : hideAll(page, playButtons),
        hideAll(page, "btnResume"),
        hideAll(page, "detailResumeInfo"),
        hideAll(page, "btnShuffle"),
        hideAll(page, "btnQueue"),
        setButtonText(
          page,
          ".playButtonText",
          _globalize.default.translate("Play"),
        ))
      : _playbackmanager.default.canPlay(item)
      ? (hideAll(page, "btnPlay", !0),
        (now =
          item.IsFolder ||
          -1 !==
            ["MusicAlbum", "MusicGenre", "MusicArtist"].indexOf(item.Type)),
        "MusicAlbum" === item.Type && item.SupportsResume && (now = !1),
        hideAll(
          page,
          "btnShuffle",
          (now = "Season" !== item.Type && "Series" !== item.Type ? now : !1),
        ),
        (isPlayFocused =
          (activeElement = document.activeElement) &&
          activeElement.classList &&
          (activeElement.classList.contains("btnResume") ||
            activeElement.classList.contains("btnMainPlay"))),
        (btnPlay = page.querySelector(".btnPlay")),
        (btnResume = page.querySelector(".btnResume")),
        ((btnPlayTrailer = page.querySelector(
          ".btnPlayTrailer-main",
        )).querySelector("i").innerHTML = _itemmanager.default.getDefaultIcon({
          Type: "Trailer",
          MediaType: "Video",
        })),
        (btnShuffle = page.querySelector(".btnShuffle")),
        "Series" === item.Type ||
        ("MusicAlbum" === item.Type && item.SupportsResume)
          ? (btnResume.classList.add("detailButton-primary"),
            btnPlay.classList.remove(
              "detailButton-primary",
              "detailButton-highres3",
            ),
            (function (instance, page) {
              getNextUpItems
                .call(instance, { Limit: 1, EnableTotalRecordCount: !1 })
                .then(function (result) {
                  var resumeName,
                    result = result.Items[0],
                    resumeInfo = page.querySelector(".detailResumeInfo");
                  result
                    ? (((resumeName =
                        resumeInfo.querySelector(".resumeName")).innerHTML =
                        _itemmanager.default.getDisplayName(result)),
                      resumeName.classList.remove("hide"),
                      setResumeProgress(resumeInfo, result),
                      result.UserData &&
                      0 < result.UserData.PlaybackPositionTicks
                        ? setButtonText(
                            page,
                            ".resumeButtonText",
                            _globalize.default.translate("Resume"),
                          )
                        : setButtonText(
                            page,
                            ".resumeButtonText",
                            _globalize.default.translate("Play"),
                          ),
                      resumeInfo.classList.remove("hide"))
                    : (setButtonText(
                        page,
                        ".resumeButtonText",
                        _globalize.default.translate("Play"),
                      ),
                      resumeInfo.classList.add("hide"));
                });
            })(instance, page),
            setButtonText(
              page,
              ".playButtonText",
              _globalize.default.translate("PlayFromBeginning"),
            ),
            btnPlay.classList.remove("detailButton-stacked"),
            btnShuffle.classList.remove("detailButton-stacked"),
            isTrailerButtonVisible(item)
              ? (btnPlayTrailer.classList.add("detailButton-stacked"),
                btnResume.classList.add("detailButton-stacked"))
              : (btnPlayTrailer.classList.remove("detailButton-stacked"),
                btnResume.classList.remove("detailButton-stacked")),
            hideAll(page, "detailResumeInfo", !0),
            hideAll(page, "btnResume", !0),
            hideAll(page, "btnPlay", now))
          : ((instance =
              item.UserData && 0 < item.UserData.PlaybackPositionTicks)
              ? (btnResume.classList.add(
                  "detailButton-primary",
                  "detailButton-stacked",
                ),
                btnPlay.classList.remove(
                  "detailButton-primary",
                  "detailButton-stacked",
                ),
                _layoutmanager.default.tv
                  ? btnPlay.classList.remove("detailButton-highres3")
                  : btnPlay.classList.add("detailButton-highres3"),
                btnPlayTrailer.classList.add("detailButton-stacked"),
                btnShuffle.classList.remove("detailButton-stacked"),
                setButtonText(
                  page,
                  ".playButtonText",
                  _globalize.default.translate("PlayFromBeginning"),
                ),
                hideAll(page, "detailResumeInfo", !0),
                hideAll(page, "resumeName"),
                setResumeProgress(
                  page.querySelector(".detailResumeInfo"),
                  item,
                ))
              : (btnPlay.classList.add("detailButton-primary"),
                btnPlay.classList.remove("detailButton-highres3"),
                now
                  ? (btnPlayTrailer.classList.remove("detailButton-stacked"),
                    btnResume.classList.remove("detailButton-stacked"),
                    btnShuffle.classList.add("detailButton-stacked"),
                    btnPlay.classList.add("detailButton-stacked"))
                  : (isTrailerButtonVisible(item)
                      ? (btnPlay.classList.add("detailButton-stacked"),
                        btnResume.classList.remove("detailButton-stacked"),
                        btnPlayTrailer.classList.add("detailButton-stacked"))
                      : (btnPlay.classList.remove("detailButton-stacked"),
                        btnResume.classList.remove("detailButton-stacked"),
                        btnPlayTrailer.classList.remove(
                          "detailButton-stacked",
                        )),
                    btnShuffle.classList.remove("detailButton-stacked")),
                setButtonText(
                  page,
                  ".playButtonText",
                  _globalize.default.translate("Play"),
                )),
            hideAll(page, "detailResumeInfo", instance),
            hideAll(page, "btnResume", instance)),
        isUserDataChangeEvent ||
          hideAll(page, "btnQueue", _playbackmanager.default.canQueue(item)),
        isPlayFocused && focusMainSection.call(activeElement.parentNode))
      : (hideAll(page, playButtons),
        hideAll(page, "btnQueue"),
        hideAll(page, "btnResume"),
        hideAll(page, "detailResumeInfo"),
        hideAll(page, "btnShuffle"));
  }
  function focusMainSection() {
    for (
      var btns = this.querySelectorAll(".detailButton"),
        i = 0,
        length = btns.length;
      i < length;
      i++
    ) {
      var btn = btns[i];
      if (_focusmanager.default.isCurrentlyFocusable(btn))
        try {
          return void _focusmanager.default.focus(btn);
        } catch (err) {}
    }
    _focusmanager.default.autoFocus(this, { skipIfNotEnabled: !0 });
  }
  function setTitle(item, apiClient, enableLogo) {
    (enableLogo = "TvChannel" === item.Type ? !1 : enableLogo)
      ? _appheader.default.setLogoTitle({
          items: [item],
          titleText: "",
          preferredLogoImageTypes:
            _skinmanager.default.getPreferredLogoImageTypes(),
        })
      : _appheader.default.setTitle("");
  }
  function getLogoPlacement(item) {
    return "TvChannel" === item.Type
      ? null
      : (("MusicAlbum" !== item.Type &&
          "Audio" !== item.Type &&
          "MusicVideo" !== item.Type) ||
          (item.ImageTags && item.ImageTags.Logo)) &&
        _usersettings.default.getEnableLogoAsTitle(
          _globalize.default.getCurrentLocale(),
        )
      ? "title"
      : "float";
  }
  function getArtistLinksHtml(artists, serverId) {
    for (var html = [], i = 0, length = artists.length; i < length; i++) {
      var artist = artists[i],
        href = _approuter.default.getRouteUrl(artist, {
          itemType: "MusicArtist",
          serverId: serverId,
        });
      html.push(
        '<a style="font-weight:inherit;" class="button-link" is="emby-linkbutton" href="' +
          href +
          '">' +
          _textencoding.default.htmlEncode(artist.Name) +
          "</a>",
      );
    }
    return (html = html.join(" / "));
  }
  function inferContext(item) {
    switch (item.Type) {
      case "Series":
      case "Season":
      case "Episode":
        return "tvshows";
      case "Movie":
        return "movies";
      case "Game":
      case "GameSystem":
        return "games";
      case "MusicArtist":
      case "MusicAlbum":
      case "Audio":
      case "AudioBook":
      case "MusicVideo":
        return "music";
      case "Program":
      case "TvChannel":
      case "Timer":
      case "SeriesTimer":
        return "livetv";
      default:
        return null;
    }
  }
  function renderName(instance, item, apiClient, user, containers) {
    var parentRoute,
      itemForTitle = ("Timer" === item.Type && item.ProgramInfo) || item,
      context = inferContext(itemForTitle),
      parentNameHtml = [],
      parentNameLast = !1,
      hasFocusableButton = !1,
      fontSize = parseFloat(
        window
          .getComputedStyle(document.body, null)
          .getPropertyValue("font-size"),
      ),
      fontSize = Math.round(2 * fontSize * 2.4) + Math.round(0.2 * fontSize),
      apiClient =
        "title" !== getLogoPlacement(itemForTitle)
          ? null
          : (function (item, apiClient, options) {
              options = options || {};
              var logoTypes = _skinmanager.default.getPreferredLogoImageTypes();
              return apiClient.getLogoImageUrl(item, options, logoTypes);
            })(itemForTitle, apiClient, { maxHeight: Math.max(fontSize, 260) }),
      fontSize = "itemLogoAsTitle",
      itemNamePrimaryClass =
        (_layoutmanager.default.tv && (fontSize += " itemLogoAsTitle-tv"),
        "itemName-primary"),
      itemPrimaryNameContainerClass = "itemPrimaryNameContainer",
      html =
        (itemForTitle.AlbumArtists && itemForTitle.AlbumArtists.length
          ? (parentNameHtml.push(
              getArtistLinksHtml(
                itemForTitle.AlbumArtists,
                itemForTitle.ServerId,
              ),
            ),
            (parentNameLast = !0))
          : itemForTitle.ArtistItems &&
            itemForTitle.ArtistItems.length &&
            "MusicVideo" === itemForTitle.Type
          ? (parentNameHtml.push(
              getArtistLinksHtml(
                itemForTitle.ArtistItems,
                itemForTitle.ServerId,
              ),
            ),
            (parentNameLast = !0))
          : itemForTitle.SeriesName && itemForTitle.SeriesId
          ? ((parentRoute = _approuter.default.getRouteUrl(
              {
                Id: itemForTitle.SeriesId,
                Name: itemForTitle.SeriesName,
                Type: "Series",
                IsFolder: !0,
                ServerId: itemForTitle.ServerId,
              },
              { context: context },
            )),
            (seriesName = _textencoding.default.htmlEncode(
              itemForTitle.SeriesName,
            )),
            apiClient
              ? ((itemNamePrimaryClass += " itemName-primary-logo"),
                _layoutmanager.default.tv &&
                  (itemNamePrimaryClass += " itemName-primary-logo-tv"),
                (itemPrimaryNameContainerClass +=
                  " itemPrimaryNameContainer-logo"),
                _layoutmanager.default.tv
                  ? (tabIndex = ' tabindex="-1"')
                  : (hasFocusableButton = !(tabIndex = "")),
                parentNameHtml.push(
                  "<a" +
                    tabIndex +
                    ' style="font-weight:inherit;height:100%;width:100%;" class="button-link button-link-color-inherit" is="emby-linkbutton" href="' +
                    parentRoute +
                    '">' +
                    (seriesName =
                      '<img draggable="false" loading="lazy"' +
                      decodingAttribute +
                      ' class="' +
                      fontSize +
                      '" alt="' +
                      seriesName +
                      '" src="' +
                      apiClient +
                      '" />') +
                    "</a>",
                ))
              : ((hasFocusableButton = !0),
                parentNameHtml.push(
                  '<a style="font-weight:300;font-size:20px" class="button-link button-link-color-inherit" is="emby-linkbutton" href="' +
                    parentRoute +
                    '">' +
                    seriesName +
                    "</a>",
                )))
          : itemForTitle.SeriesName
          ? parentNameHtml.push(
              _textencoding.default.htmlEncode(itemForTitle.SeriesName),
            )
          : (itemForTitle.IsSeries || itemForTitle.EpisodeTitle) &&
            parentNameHtml.push(
              _textencoding.default.htmlEncode(itemForTitle.Name),
            ),
        itemForTitle.Album &&
        itemForTitle.AlbumId &&
        ("MusicVideo" === itemForTitle.Type || "Audio" === itemForTitle.Type)
          ? ((parentRoute = _approuter.default.getRouteUrl(
              {
                Id: itemForTitle.AlbumId,
                Name: itemForTitle.Album,
                Type: "MusicAlbum",
                IsFolder: !0,
                ServerId: itemForTitle.ServerId,
              },
              { context: context },
            )),
            (hasFocusableButton = !0),
            parentNameHtml.push(
              '<a style="font-weight:inherit;" class="button-link button-link-color-inherit" is="emby-linkbutton" href="' +
                parentRoute +
                '">' +
                _textencoding.default.htmlEncode(itemForTitle.Album) +
                "</a>",
            ))
          : itemForTitle.Album &&
            parentNameHtml.push(
              _textencoding.default.htmlEncode(itemForTitle.Album),
            ),
        ""),
      tabIndex = "";
    _layoutmanager.default.tv ||
      (_itemmanager.default.canEdit(item, user) &&
        ((hasFocusableButton = !0),
        (tabIndex +=
          '<button is="paper-icon-button-light" class="btnDetailEdit btnEditMetadata secondaryText flex-shrink-zero" title="' +
          _globalize.default.translate("HeaderEditMetadata") +
          '" aria-label="' +
          _globalize.default.translate("HeaderEditMetadata") +
          '"><i class="md-icon autortl">&#xe3c9;</i></button>')),
      _itemmanager.default.canEditImages(item, user) &&
        ((hasFocusableButton = !0),
        (tabIndex +=
          '<button is="paper-icon-button-light" class="btnDetailEdit btnEditImages secondaryText flex-shrink-zero" title="' +
          _globalize.default.translate("HeaderEditImages") +
          '" aria-label="' +
          _globalize.default.translate("HeaderEditImages") +
          '"><i class="md-icon">photo</i></button>'))),
      enableItemBackdropAsTopImage(itemForTitle) ||
        (itemPrimaryNameContainerClass += " itemPrimaryNameContainer-centered"),
      parentNameHtml.length &&
        (html = parentNameLast
          ? '<div class="itemSecondaryNameContainer"><h3 class="itemName-secondary">' +
            parentNameHtml.join(" - ") +
            "</h3></div>"
          : '<div class="' +
            itemPrimaryNameContainerClass +
            '"><h1 class="' +
            itemNamePrimaryClass +
            '">' +
            parentNameHtml.join(" - ") +
            "</h1></div>");
    var seriesName =
      (seriesName = _itemmanager.default.getDisplayName(itemForTitle, {
        includeParentInfo: !0,
      })) && _textencoding.default.htmlEncode(seriesName);
    html && seriesName && !parentNameLast
      ? (html +=
          '<div class="flex align-items-center flex-wrap-wrap itemSecondaryNameContainer"><h3 class="itemName-secondary">' +
          seriesName +
          "</h3>" +
          tabIndex +
          "</div>")
      : (html =
          (parentNameLast ||
            (apiClient &&
              ((seriesName =
                '<img draggable="false" loading="lazy"' +
                decodingAttribute +
                ' class="' +
                fontSize +
                '" alt="' +
                seriesName +
                '" src="' +
                apiClient +
                '" />'),
              (itemNamePrimaryClass += " itemName-primary-logo"),
              (itemPrimaryNameContainerClass +=
                " itemPrimaryNameContainer-logo"),
              _layoutmanager.default.tv) &&
              (itemNamePrimaryClass += " itemName-primary-logo-tv")),
          '<div class="flex align-items-center flex-wrap-wrap ' +
            itemPrimaryNameContainerClass +
            '"><h1 class="' +
            itemNamePrimaryClass +
            '">' +
            seriesName +
            "</h1>" +
            tabIndex +
            "</div>" +
            html));
    for (var i = 0, length = containers.length; i < length; i++) {
      var container = containers[i],
        btnEditMetadata =
          (enableItemBackdropAsTopImage(itemForTitle)
            ? container.classList.remove("nameContainer-centered")
            : container.classList.add("nameContainer-centered"),
          (container.innerHTML = html),
          setScopedFocus(null, container, hasFocusableButton, "nearest"),
          html.length
            ? container.classList.remove("hide")
            : container.classList.add("hide"),
          container.querySelector(".btnEditMetadata")),
        btnEditMetadata =
          (btnEditMetadata &&
            btnEditMetadata.addEventListener(
              "click",
              onEditMetadataClick.bind(instance),
            ),
          container.querySelector(".btnEditImages"));
      btnEditMetadata &&
        btnEditMetadata.addEventListener(
          "click",
          onEditImagesClick.bind(instance),
        );
    }
  }
  function isTrailerButtonVisible(item) {
    if (
      _playbackmanager.default.getSupportedCommands().includes("PlayTrailers")
    ) {
      if (item.LocalTrailerCount) return 1;
      if (item.RemoteTrailers && item.RemoteTrailers.length) return 1;
    }
  }
  function setTrailerButtonVisibility(page, item) {
    isTrailerButtonVisible(item)
      ? hideAll(page, "btnPlayTrailer", !0)
      : hideAll(page, "btnPlayTrailer");
  }
  function enableTrackList(item) {
    return (
      !!_layoutmanager.default.tv &&
      ("Playlist" === item.Type ||
        ("MusicAlbum" === item.Type && !item.SupportsResume))
    );
  }
  function enableItemBackdropAsTopImage(item) {
    return (
      "Playlist" !== item.Type &&
      "MusicAlbum" !== item.Type &&
      "TvChannel" !== item.Type &&
      "Audio" !== item.Type
    );
  }
  function hideAll(page, className, show) {
    for (
      var elems =
          "string" == typeof className
            ? page.querySelectorAll("." + className)
            : className,
        i = 0,
        length = elems.length;
      i < length;
      i++
    )
      show ? elems[i].classList.remove("hide") : elems[i].classList.add("hide");
  }
  function getCommandOptions(view, item, user, button) {
    (view = view.querySelector(".selectSource")),
      (item = {
        items: [item],
        open: !1,
        play: !1,
        playFromBeginning: !0,
        playAllFromHere: !1,
        positionTo: button,
        cancelTimer: !1,
        record: !1,
        deleteItem: !0,
        shuffle: !0,
        instantMix: !0,
        user: user,
        share: !0,
        mediaSourceId: (view && view.value) || null,
        positionY: "center",
        positionX: "right",
        transformOrigin: "left top",
        played: !1,
        favorites: !1,
        navigateOnDelete: "back",
        showSeries: !!_layoutmanager.default.tv,
        showSeason: !0,
      });
    return (
      _servicelocator.appHost.supports("sync") && (item.syncLocal = !1), item
    );
  }
  function renderMediaInfo(instance, view, item, mediaSources) {
    var hasFocusElements,
      mediaSourceId = view.querySelector(".selectSource").value,
      mediaSources = mediaSources.filter(function (m) {
        return m.Id === mediaSourceId;
      })[0],
      mediaInfoElem = view.querySelector(".mediaInfoPrimary");
    "Season" === item.Type || "SeriesTimer" === item.Type
      ? (mediaInfoElem.classList.add("hide"),
        mediaInfoElem.classList.remove("focuscontainer-x"))
      : (_mediainfo.default.fillPrimaryMediaInfo(mediaInfoElem, item, {
          interactive: !0,
          episodeTitle: !1,
          subtitles: !1,
          dateAdded: !1,
          genres: !0,
          context: inferContext(item),
          endsAt: !0,
          endsAtClass: "detailEndsAt",
          bitrate: "Audio" === item.MediaType,
          runtime: "Timer" !== item.Type,
          mediaSource: mediaSources,
        }),
        (hasFocusElements = null != mediaInfoElem.querySelector("a,button")),
        setScopedFocus(null, mediaInfoElem, hasFocusElements, "nearest"),
        hasFocusElements
          ? mediaInfoElem.classList.add("focuscontainer-x")
          : mediaInfoElem.classList.remove("focuscontainer-x")),
      enableItemBackdropAsTopImage(item)
        ? mediaInfoElem.classList.remove("mediaInfo-centered", "secondaryText")
        : mediaInfoElem.classList.add("mediaInfo-centered", "secondaryText"),
      (mediaInfoElem = view.querySelector(".mediaInfoSecondary")),
      _mediainfo.default.fillSecondaryMediaInfo(mediaInfoElem, item, {
        interactive: !0,
        mediaSource: mediaSources,
      }),
      (hasFocusElements = null != mediaInfoElem.querySelector("a,button")),
      setScopedFocus(null, mediaInfoElem, hasFocusElements, "nearest"),
      hasFocusElements
        ? mediaInfoElem.classList.add("focuscontainer-x")
        : mediaInfoElem.classList.remove("focuscontainer-x"),
      mediaInfoElem.innerHTML.trim()
        ? mediaInfoElem.classList.remove("hide")
        : mediaInfoElem.classList.add("hide");
  }
  function renderDetails(instance, view, item, apiClient, user) {
    var promises = [],
      overviewElem = view.querySelector(".overview-container"),
      overviewTextElem = overviewElem.querySelector(".overview-text"),
      itemForDetails =
        (enableTrackList(item)
          ? overviewTextElem.classList.add("overview-text-tracklist")
          : overviewTextElem.classList.remove("overview-text-tracklist"),
        ("Timer" === item.Type && item.ProgramInfo) || item),
      overview = itemForDetails.Overview;
    overview
      ? ((function (elem, overview) {
          var scrollHeight,
            textButton,
            textElement = elem.querySelector(".overview-text"),
            btnReadMore = elem.querySelector(".btnReadMore");
          (btnReadMore.innerHTML = _globalize.default.translate("(Hover for more)")),
            overview
              ? ((textElement.innerHTML = overview),
                elem.classList.remove("hide"),
                (overview = textElement.offsetHeight),
                (scrollHeight = textElement.scrollHeight),
                (textButton = textElement.closest("button")),
                overview && scrollHeight && overview < scrollHeight
                  ? (_layoutmanager.default.tv
                      ? (textButton.removeAttribute("disabled"),
                        btnReadMore.classList.add("hide"))
                      : (textButton.setAttribute("disabled", "disabled"),
                        btnReadMore.classList.remove("hide")),
                    setScopedFocus(null, elem, !0))
                  : (textButton.setAttribute("disabled", "disabled"),
                    btnReadMore.classList.add("hide"),
                    setScopedFocus(null, elem, !1)))
              : (elem.classList.add("hide"), (textElement.innerHTML = ""));
        })(overviewElem, overview ? _dom.default.stripScripts(overview) : ""),
        "MusicAlbum" === itemForDetails.Type ||
        "Playlist" === itemForDetails.Type
          ? overviewTextElem.classList.add("overview-twoline")
          : overviewTextElem.classList.remove("overview-twoline"))
      : overviewElem.classList.add("hide"),
      (function (view, item) {
        var directors = (item.People || []).filter(function (p) {
            return "Director" === p.Type;
          }),
          html = directors
            .map(function (p) {
              return _layoutmanager.default.tv
                ? "<span>" +
                    _textencoding.default.htmlEncode(p.Name) +
                    "</span>"
                : '<a class="button-link button-link-color-inherit" is="emby-linkbutton" href="' +
                    _approuter.default.getRouteUrl(
                      {
                        Name: p.Name,
                        Type: "Person",
                        ServerId: item.ServerId,
                        Id: p.Id,
                      },
                      {},
                    ) +
                    '">' +
                    _textencoding.default.htmlEncode(p.Name) +
                    "</a>";
            })
            .join(", "),
          elem = view.querySelector(".directors");
        (elem.innerHTML =
          1 < directors.length
            ? _globalize.default.translate("DirectorsValue", html)
            : _globalize.default.translate("DirectorValue", html)),
          setScopedFocus(
            view,
            elem,
            directors.length && !_layoutmanager.default.tv,
            "nearest",
          ),
          directors.length
            ? elem.classList.remove("hide")
            : elem.classList.add("hide");
      })(view, itemForDetails),
      reloadPlayButtons(instance, view, item),
      (function (page, item) {
        for (
          var btnPlaystates = page.querySelectorAll(".btnPlaystate"),
            i = 0,
            length = btnPlaystates.length;
          i < length;
          i++
        ) {
          var btnPlaystate = btnPlaystates[i];
          _itemmanager.default.canMarkPlayed(item)
            ? (btnPlaystate.classList.remove("hide"),
              btnPlaystate.setItem(item))
            : (btnPlaystate.classList.add("hide"), btnPlaystate.setItem(null));
        }
        var btnUserRatings = page.querySelectorAll(".btnUserRating");
        for (i = 0, length = btnUserRatings.length; i < length; i++) {
          var btnUserRating = btnUserRatings[i];
          _itemmanager.default.canRate(item)
            ? (btnUserRating.classList.remove("hide"),
              btnUserRating.setItem(item))
            : (btnUserRating.classList.add("hide"),
              btnUserRating.setItem(null));
        }
      })(view, item),
      setTrailerButtonVisibility(view, item),
      "TvChannel" === item.Type
        ? hideAll(view, "btnManualRecording", !0)
        : hideAll(view, "btnManualRecording"),
      item.CanDelete && !item.IsFolder && "MusicArtist" !== item.Type
        ? hideAll(view, "btnDeleteItem", !0)
        : hideAll(view, "btnDeleteItem"),
      promises.push(
        (function (instance, page, item, user) {
          if (instance.currentRecordingFields)
            return (
              instance.currentRecordingFields.refresh(item), Promise.resolve()
            );
          return "Program" === item.Type && user.Policy.EnableLiveTvManagement
            ? require(["recordingFields"]).then(function (responses) {
                var responses = responses[0],
                  recordingFieldsElement =
                    page.querySelector(".mainDetailButtons");
                (instance.currentRecordingFields = new responses({
                  parent: recordingFieldsElement,
                  program: item,
                })),
                  _events.default.on(
                    instance.currentRecordingFields,
                    "recordingchanged",
                    onRecordingChanged.bind(instance),
                  ),
                  _events.default.on(
                    instance.currentRecordingFields,
                    "seriesrecordingchanged",
                    onRecordingChanged.bind(instance),
                  );
              })
            : Promise.resolve();
        })(instance, view, item, user),
      );
    _itemmanager.default.getCommands(getCommandOptions(view, item, user)).length
      ? hideAll(view, "btnMoreCommands", !0)
      : hideAll(view, "btnMoreCommands"),
      "Playlist" === item.Type ||
      ("BoxSet" === item.Type && apiClient.isMinServerVersion("4.8.0.16"))
        ? hideAll(view, "btnSortItems", !0)
        : hideAll(view, "btnSortItems"),
      enableItemBackdropAsTopImage(itemForDetails)
        ? view
            .querySelector(".detailTextContainerInner")
            .classList.remove("detailTextContainerInner-centered")
        : view
            .querySelector(".detailTextContainerInner")
            .classList.add("detailTextContainerInner-centered"),
      enableTvDetailImageLayout(item)
        ? view
            .querySelector(".detailTextContainer")
            .classList.add("detailTextContainer-extrapadding")
        : view
            .querySelector(".detailTextContainer")
            .classList.remove("detailTextContainer-extrapadding");
    overview = view.querySelector(".tagline");
    return (
      itemForDetails.Taglines && itemForDetails.Taglines.length
        ? (overview.classList.remove("hide"),
          (overview.innerHTML = _dom.default.stripScripts(
            itemForDetails.Taglines[0],
          )))
        : overview.classList.add("hide"),
      "Person" === itemForDetails.Type &&
        ((overviewTextElem = view.querySelector(".birthDate")),
        itemForDetails.PremiereDate
          ? ((overviewElem = _datetime.default.toLocaleDateString(
              new Date(Date.parse(itemForDetails.PremiereDate)),
              { year: "numeric", month: "long", day: "numeric" },
            )),
            (overviewElem =
              itemForDetails.ProductionLocations &&
              itemForDetails.ProductionLocations.length
                ? _globalize.default.translate(
                    "BornValueWithPlace",
                    overviewElem,
                    itemForDetails.ProductionLocations[0],
                  )
                : _globalize.default.translate("BornValue", overviewElem)),
            (overviewTextElem.innerHTML = overviewElem),
            overviewTextElem.classList.remove("hide"))
          : overviewTextElem.classList.add("hide"),
        (instance = view.querySelector(".deathDate")),
        itemForDetails.EndDate
          ? ((user = _datetime.default.toLocaleDateString(
              new Date(Date.parse(itemForDetails.EndDate)),
              { year: "numeric", month: "long", day: "numeric" },
            )),
            (user = _globalize.default.translate("DiedValue", user)),
            (instance.innerHTML = user),
            instance.classList.remove("hide"))
          : instance.classList.add("hide")),
      (function (page, item) {
        for (
          var itemTags = page.querySelector(".itemTags"),
            tagElements = [],
            tags = item.TagItems || [],
            i = 0,
            length = tags.length;
          i < length;
          i++
        ) {
          var href = _approuter.default.getRouteUrl(
            {
              Name: tags[i].Name,
              Type: "Tag",
              ServerId: item.ServerId,
              Id: tags[i].Id,
            },
            {
              itemTypes:
                "Person" === item.Type || "MusicArtist" === item.Type
                  ? item.Type
                  : null,
            },
          );
          tagElements.push(
            '<a is="emby-linkbutton" class="raised item-tag-button nobackdropfilter" href="' +
              href +
              '"><i class="md-icon button-icon button-icon-left autortl">&#xe892;</i>' +
              _textencoding.default.htmlEncode(tags[i].Name) +
              "</a>",
          );
        }
        (itemTags.innerHTML = tagElements.join("")),
          tagElements.length
            ? page.querySelector(".tagsSection").classList.remove("hide")
            : page.querySelector(".tagsSection").classList.add("hide");
      })(view, item),
      Promise.all(promises)
    );
  }
  function onRecordingChanged() {
    reloadItem(this, !0);
  }
  function renderPeopleItems(view, item, apiClient) {
    view = view.querySelector(".peopleItems");
    if ("Person" !== item.Type && "MusicArtist" !== item.Type)
      view.classList.add("hide");
    else {
      view.classList.remove("hide");
      for (
        var sections = [],
          sectionElems =
            ("Person" === item.Type
              ? (sections.push({
                  name: _globalize.default.translate("HeaderUpcomingOnTV"),
                  type: "Program",
                }),
                sections.push({
                  name: _globalize.default.translate("Movies"),
                  type: "Movie",
                }),
                sections.push({
                  name: _globalize.default.translate("Shows"),
                  type: "Series",
                }),
                sections.push({
                  name: _globalize.default.translate("Episodes"),
                  type: "Episode",
                }),
                sections.push({
                  name: _globalize.default.translate("Trailers"),
                  type: "Trailer",
                }),
                sections.push({
                  name: _globalize.default.translate("HeaderMusicVideos"),
                  type: "MusicVideo",
                }),
                sections.push({
                  name: _globalize.default.translate("Videos"),
                  type: "Video",
                }))
              : "MusicArtist" === item.Type &&
                sections.push({
                  name: _globalize.default.translate("HeaderMusicVideos"),
                  type: "MusicVideo",
                }),
            (view.innerHTML = sections
              .map(function (section) {
                var html = "";
                return (
                  (html +=
                    '<div class="verticalSection verticalSection-cards personSection hide" data-type="' +
                    section.type +
                    '">') +
                  '<div class="sectionTitleContainer sectionTitleContainer-cards padded-left padded-left-page padded-right">' +
                  ('<a is="emby-sectiontitle" href="' +
                    (function (item, type) {
                      return "Genre" === item.Type
                        ? "list/list.html?type=" +
                            type +
                            "&genreId=" +
                            item.Id +
                            "&serverId=" +
                            item.ServerId
                        : "MusicGenre" === item.Type
                        ? "list/list.html?type=" +
                          type +
                          "&musicGenreId=" +
                          item.Id +
                          "&serverId=" +
                          item.ServerId
                        : "GameGenre" === item.Type
                        ? "list/list.html?type=" +
                          type +
                          "&gameGenreId=" +
                          item.Id +
                          "&serverId=" +
                          item.ServerId
                        : "Studio" === item.Type
                        ? "list/list.html?type=" +
                          type +
                          "&studioId=" +
                          item.Id +
                          "&serverId=" +
                          item.ServerId
                        : "MusicArtist" === item.Type
                        ? "list/list.html?type=" +
                          type +
                          "&artistId=" +
                          item.Id +
                          "&serverId=" +
                          item.ServerId
                        : "Person" === item.Type
                        ? "list/list.html?type=" +
                          type +
                          "&personId=" +
                          item.Id +
                          "&serverId=" +
                          item.ServerId
                        : "list/list.html?type=" +
                          type +
                          "&parentId=" +
                          item.Id +
                          "&serverId=" +
                          item.ServerId;
                    })(item, section.type) +
                    '" class="button-link  button-link-color-inherit sectionTitleTextButton">') +
                  '<h2 class="sectionTitle sectionTitle-cards">' +
                  section.name +
                  "</h2>" +
                  "</a>" +
                  "</div>" +
                  '<div is="emby-scroller" class="emby-scroller padded-top-focusscale padded-bottom-focusscale padded-left padded-left-page padded-right" data-mousewheel="false" data-focusscroll="true" data-horizontal="true">' +
                  '<div is="emby-itemscontainer" class="scrollSlider focuscontainer-x itemsContainer"></div>' +
                  "</div>" +
                  "</div>" +
                  "</div>"
                );
              })
              .join("")),
            view.querySelectorAll(".personSection")),
          i = 0,
          length = sectionElems.length;
        i < length;
        i++
      )
        !(function (item, element, type, apiClient) {
          switch (type) {
            case "Program":
              loadPeopleItems(
                element,
                item,
                0,
                {
                  IncludeItemTypes: "Program",
                  Limit: 12,
                  SortBy: "StartDate",
                  Fields: "PrimaryImageAspectRatio",
                },
                {
                  shape: "autooverflow",
                  fields: ["Name", "ChannelName", "AirTime"],
                  centerText: !0,
                  preferThumb: !0,
                  overlayText: !1,
                  showAirDateTime: !0,
                },
                apiClient,
              );
              break;
            case "Movie":
              loadPeopleItems(
                element,
                item,
                0,
                {
                  IncludeItemTypes: "Movie",
                  Limit: 12,
                  SortBy: "SortName",
                  Fields: "PrimaryImageAspectRatio",
                },
                {
                  shape: "autooverflow",
                  fields: ["Name", "ProductionYear"],
                  centerText: !0,
                  overlayText: !1,
                },
                apiClient,
              );
              break;
            case "Video":
              loadPeopleItems(
                element,
                item,
                0,
                {
                  IncludeItemTypes: "Video",
                  Limit: 12,
                  SortBy: "SortName",
                  Fields: "PrimaryImageAspectRatio",
                },
                {
                  shape: "autooverflow",
                  fields: ["Name", "ProductionYear"],
                  centerText: !0,
                  overlayText: !1,
                },
                apiClient,
              );
              break;
            case "MusicVideo":
              loadPeopleItems(
                element,
                item,
                0,
                {
                  IncludeItemTypes: "MusicVideo",
                  Limit: 12,
                  SortBy: "SortName",
                  Fields: "PrimaryImageAspectRatio",
                },
                {
                  shape: "autooverflow",
                  fields: ["Name", "ProductionYear"],
                  centerText: !0,
                  overlayPlayButton: !0,
                },
                apiClient,
              );
              break;
            case "Game":
              loadPeopleItems(
                element,
                item,
                0,
                {
                  IncludeItemTypes: "Game",
                  Limit: 12,
                  SortBy: "SortName",
                  Fields: "PrimaryImageAspectRatio",
                },
                { shape: "autooverflow", fields: ["Name"], centerText: !0 },
                apiClient,
              );
              break;
            case "Trailer":
              loadPeopleItems(
                element,
                item,
                0,
                {
                  IncludeItemTypes: "Trailer",
                  Limit: 12,
                  SortBy: "SortName",
                  Fields: "PrimaryImageAspectRatio",
                },
                {
                  shape: "autooverflow",
                  fields: ["Name"],
                  centerText: !0,
                  overlayPlayButton: !0,
                },
                apiClient,
              );
              break;
            case "Series":
              loadPeopleItems(
                element,
                item,
                0,
                {
                  IncludeItemTypes: "Series",
                  Limit: 12,
                  SortBy: "SortName",
                  Fields: "PrimaryImageAspectRatio",
                },
                { shape: "autooverflow", fields: ["Name"], centerText: !0 },
                apiClient,
              );
              break;
            case "MusicAlbum":
              loadPeopleItems(
                element,
                item,
                0,
                {
                  IncludeItemTypes: "MusicAlbum",
                  Limit: 12,
                  SortBy: "ProductionYear,SortName",
                  SortOrder: "Descending,Ascending",
                  Fields: "ProductionYear,PrimaryImageAspectRatio",
                },
                {
                  shape: "autooverflow",
                  playFromHere: !0,
                  fields: ["Name", "ProductionYear"],
                  centerText: !0,
                  overlayPlayButton: !0,
                },
                apiClient,
              );
              break;
            case "MusicArtist":
              loadPeopleItems(
                element,
                item,
                0,
                {
                  IncludeItemTypes: "MusicArtist",
                  Limit: 8,
                  SortBy: "SortName",
                  Fields: "PrimaryImageAspectRatio",
                },
                {
                  shape: "autooverflow",
                  playFromHere: !0,
                  fields: ["Name"],
                  centerText: !0,
                  overlayPlayButton: !0,
                },
                apiClient,
              );
              break;
            case "Episode":
              loadPeopleItems(
                element,
                item,
                0,
                {
                  IncludeItemTypes: "Episode",
                  Limit: 6,
                  SortBy:
                    "SeriesSortName,ParentIndexNumber,IndexNumber,SortName",
                  Fields: "PrimaryImageAspectRatio",
                },
                {
                  shape: "autooverflow",
                  fields: ["ParentName", "Name"],
                  centerText: !0,
                  overlayPlayButton: !0,
                },
                apiClient,
              );
              break;
            case "Audio":
              loadPeopleItems(
                element,
                item,
                0,
                {
                  IncludeItemTypes: "Audio",
                  SortBy: "AlbumArtist,Album,SortName",
                  Fields: "PrimaryImageAspectRatio",
                },
                {
                  playFromHere: !0,
                  fields: ["Name", "ParentName"],
                  action: "playallfromhere",
                  smallIcon: !0,
                },
                apiClient,
              );
          }
        })(
          item,
          sectionElems[i],
          sectionElems[i].getAttribute("data-type"),
          apiClient,
        );
    }
  }
  function loadPeopleItems(element, item, type, query, listOptions, apiClient) {
    (query.SortOrder = "Ascending"),
      (query.Recursive = !0),
      (query.CollapseBoxSetItems = !1),
      (query.Fields = "PrimaryImageAspectRatio,ProductionYear"),
      "Person" === item.Type
        ? (query.PersonIds = item.Id)
        : "MusicArtist" === item.Type && (query.ArtistIds = item.Id),
      (query.ImageTypeLimit = 1),
      (query.EnableTotalRecordCount = !1),
      apiClient
        .getItems(apiClient.getCurrentUserId(), query)
        .then(function (result) {
          _cardbuilder.default.buildCards(result.Items, {
            parentContainer: element,
            itemsContainer: element.querySelector(".itemsContainer"),
            shape: listOptions.shape,
            fields: listOptions.fields,
            overlayText: !1,
            centerText: !0,
          });
        });
  }
  function onTrackSelectionsSubmit(e) {
    return e.preventDefault(), !1;
  }
  function bindAll(view, selector, eventName, fn) {
    for (
      var elems = view.querySelectorAll(selector), i = 0, length = elems.length;
      i < length;
      i++
    )
      elems[i].addEventListener(eventName, fn);
  }
  function executeCommandWithCommandProcessor(command, item, options) {
    require(["commandProcessor"]).then(function (responses) {
      return responses[0].executeCommand(command, [item], options);
    });
  }
  function onDataFetched(responses) {
    var itemInfo = responses[0],
      item = itemInfo.item,
      itemInfo = itemInfo.mediaSources,
      user = responses[1],
      responses = _connectionmanager.default.getApiClient(item.ServerId),
      view = this.view,
      itemMainScrollSlider =
        (("Person" === item.Type && _backdrop.default.hasBackdrop()) ||
          _backdrop.default.setBackdrops([item], {
            enableAnimation: !0,
            enablePrimaryImageBeforeInherited:
              enableTvDetailImageLayout(item) &&
              "Season" !== item.Type &&
              "Episode" !== item.Type,
            allowPrimaryImage: enableTvDetailImageLayout(item),
          }),
        this.updateDrawerState(),
        view.querySelector(".itemMainScrollSlider")),
      detailMainContainerParent = view.querySelector(
        ".detailMainContainerParent",
      ),
      itemMainScrollSlider =
        (_backdrop.default.hasBackdrop()
          ? (_layoutmanager.default.tv
              ? view.classList.add(
                  "darkContentContainer-tv",
                  "darkContentContainer-item",
                )
              : view.classList.add("darkContentContainer-item"),
            enableTvDetailImageLayout(item)
              ? (itemMainScrollSlider.classList.add(
                  "itemMainScrollSlider-fade",
                ),
                detailMainContainerParent.classList.add(
                  "detailMainContainerParent-fade",
                ),
                backgroundContainer.classList.add(
                  "itemBackgroundContainer-brighter",
                ))
              : (itemMainScrollSlider.classList.remove(
                  "itemMainScrollSlider-fade",
                ),
                detailMainContainerParent.classList.remove(
                  "detailMainContainerParent-fade",
                ),
                backgroundContainer.classList.remove(
                  "itemBackgroundContainer-brighter",
                )),
            enableItemBackdropAsTopImage(item)
              ? (backdropContainer.classList.add(
                  "backdropContainer-preventbackdrop",
                ),
                backgroundContainer.classList.add(
                  "itemBackgroundContainer",
                  "itemBackgroundContainer-preventbackdrop",
                ))
              : (backdropContainer.classList.remove(
                  "backdropContainer-preventbackdrop",
                ),
                backgroundContainer.classList.add("itemBackgroundContainer"),
                backgroundContainer.classList.remove(
                  "itemBackgroundContainer-preventbackdrop",
                )))
          : (view.classList.remove(
              "darkContentContainer-item",
              "darkContentContainer-tv",
            ),
            itemMainScrollSlider.classList.remove("itemMainScrollSlider-fade"),
            detailMainContainerParent.classList.remove(
              "detailMainContainerParent-fade",
            ),
            backgroundContainer.classList.remove(
              "itemBackgroundContainer-brighter",
              "itemBackgroundContainer",
              "itemBackgroundContainer-preventbackdrop",
            ),
            backdropContainer.classList.remove(
              "backdropContainer-preventbackdrop",
            )),
        (this.currentItem = item),
        []),
      detailMainContainerParent =
        (this.sectionsInitialized ||
          ((this.sectionsInitialized = !0),
          (function (instance, view, item) {
            var section;
            "Episode" === item.Type &&
              ((view = view.querySelector(".moreFromSeasonItemsContainer")),
              ((section = view.closest(".verticalSection")).querySelector(
                "h2",
              ).innerHTML = _globalize.default.translate(
                "MoreFromValue",
                item.SeasonName,
              )),
              (view.fetchData = function (query) {
                var apiClient,
                  item = this.currentItem;
                return item.SeasonId && item.SeriesId
                  ? ((apiClient =
                      _connectionmanager.default.getApiClient(item)),
                    (query = Object.assign(
                      {
                        SeasonId: item.SeasonId,
                        UserId: apiClient.getCurrentUserId(),
                        Fields:
                          this.getRequestedItemFields() +
                          ",PrimaryImageAspectRatio",
                      },
                      query,
                    )),
                    apiClient
                      .getEpisodes(item.SeriesId, query)
                      .then(function (result) {
                        return !query.StartIndex && result.Items.length < 2
                          ? Promise.resolve({ TotalRecordCount: 0, Items: [] })
                          : result;
                      }))
                  : Promise.resolve({ TotalRecordCount: 0, Items: [] });
              }.bind(instance)),
              (view.parentContainer = section),
              (view.getListOptions = getMoreFromSeasonListOptions),
              (view.afterRefresh = function (totalResult) {
                if (totalResult.Items.length) {
                  var item = this.currentItem;
                  if (item) {
                    var view = this.view;
                    if (view) {
                      var itemsContainer = view.querySelector(
                        ".moreFromSeasonItemsContainer",
                      );
                      if (itemsContainer) {
                        var query,
                          index = itemsContainer.indexOfItemId(item.Id);
                        if (-1 === index)
                          return (
                            (view =
                              _connectionmanager.default.getApiClient(item)),
                            (query = {
                              SeasonId: item.SeasonId,
                              UserId: view.getCurrentUserId(),
                              Fields:
                                this.getRequestedItemFields() +
                                ",PrimaryImageAspectRatio",
                              Limit: 0,
                              StartItemId: item.Id,
                            }),
                            view
                              .getEpisodes(item.SeriesId, query)
                              .then(function (result) {
                                (index = Math.max(
                                  totalResult.TotalRecordCount -
                                    result.TotalRecordCount,
                                  0,
                                )),
                                  itemsContainer.scrollToIndex(
                                    Math.min(
                                      index + 1,
                                      totalResult.TotalRecordCount - 1,
                                    ),
                                    {
                                      behavior: "instant",
                                      offset: "-padding-inline-start",
                                    },
                                    !1,
                                  );
                              })
                          );
                        itemsContainer.scrollToIndex(
                          Math.min(index + 1, totalResult.TotalRecordCount - 1),
                          {
                            behavior: "instant",
                            offset: "-padding-inline-start",
                          },
                          !1,
                        );
                      }
                    }
                  }
                }
              }.bind(instance)),
              view.classList.add("generalItemsContainer"));
          })(this, view, item),
          (function (instance, view, item) {
            var section;
            ("MusicArtist" !== item.Type && "MusicAlbum" !== item.Type) ||
              ((view = view.querySelector(".moreFromArtistItemsContainer")),
              (section = view.closest(".verticalSection")),
              "MusicArtist" === item.Type
                ? (section.querySelector(".sectionTitle").innerHTML =
                    _globalize.default.translate("HeaderAppearsOn"))
                : (section.querySelector(".sectionTitle").innerHTML =
                    _globalize.default.translate(
                      "MoreFromValue",
                      _textencoding.default.htmlEncode(
                        item.AlbumArtists[0].Name,
                      ),
                    )),
              (view.fetchData = function (query) {
                var item = this.currentItem;
                if (
                  "MusicAlbum" === item.Type &&
                  !item.AlbumArtists &&
                  !item.AlbumArtists.length
                )
                  return Promise.resolve({ TotalRecordCount: 0, Items: [] });
                query = Object.assign(
                  {
                    IncludeItemTypes: "MusicAlbum",
                    Recursive: !0,
                    SortBy: "ProductionYear,SortName",
                    SortOrder: "Descending",
                    Fields:
                      this.getRequestedItemFields() +
                      ",PrimaryImageAspectRatio,ProductionYear",
                  },
                  query,
                );
                var apiClient = _connectionmanager.default.getApiClient(item);
                "MusicArtist" === item.Type
                  ? (query.ContributingArtistIds = item.Id)
                  : ((query.AlbumArtistIds = item.AlbumArtists[0].Id),
                    (query.ExcludeItemIds = item.Id));
                return apiClient.getItems(apiClient.getCurrentUserId(), query);
              }.bind(instance)),
              (view.parentContainer = section),
              (view.getListOptions = getMoreFromArtistListOptions),
              view.classList.add("generalItemsContainer"));
          })(this, view, item),
          itemMainScrollSlider.push(
            (function (instance, item) {
              var section = instance.view.querySelector(".seriesItemsSection");
              return "Series" === item.Type
                ? getSeasons
                    .call(instance, {
                      EnableUserData: !1,
                      EnableTotalRecordCount: !1,
                      EnableImages: !1,
                    })
                    .then(function (result) {
                      instance.seasonItems = result.Items;
                      item.Type;
                      setScopedFocus(
                        instance.view,
                        section.querySelector(".focusable"),
                        !0,
                        "nearest",
                      );
                      var itemsContainer =
                          section.querySelector(".itemsContainer"),
                        seriesDisplay =
                          ((itemsContainer.parentContainer = section),
                          _usersettings.default.seriesDisplay()),
                        hasMultipleSeasons =
                          (_apiclient.default.isLocalItem(item) &&
                            (seriesDisplay = ""),
                          2 <= result.Items.length),
                        seriesDisplay = (instance.renderAllEpisodes =
                          "episodes" === seriesDisplay ||
                          ("episodessingleseason" === seriesDisplay &&
                            !hasMultipleSeasons)),
                        renderSeasonsWithTabs =
                          seriesDisplay &&
                          hasMultipleSeasons &&
                          _layoutmanager.default.tv,
                        sectionTitleElement =
                          section.querySelector(".sectionTitle"),
                        sectionTitleElement =
                          ((sectionTitleElement.innerHTML = seriesDisplay
                            ? 1 === result.Items.length
                              ? result.Items[0].Name
                              : _globalize.default.translate("Episodes")
                            : _globalize.default.translate("Seasons")),
                          seriesDisplay && hasMultipleSeasons
                            ? sectionTitleElement.classList.add("hide")
                            : sectionTitleElement.classList.remove("hide"),
                          section.querySelector(".detailSelectSeason")),
                        detailSelectSeasonContainer = section.querySelector(
                          ".detailSelectSeasonContainer",
                        ),
                        hasMultipleSeasons =
                          (seriesDisplay &&
                          hasMultipleSeasons &&
                          !renderSeasonsWithTabs
                            ? detailSelectSeasonContainer.classList.remove(
                                "hide",
                              )
                            : detailSelectSeasonContainer.classList.add("hide"),
                          section.querySelector(".seasonTabs"));
                      seriesDisplay
                        ? (itemsContainer.classList.add(
                            "allEpisodesItemsContainer",
                          ),
                          renderSeasonsWithTabs
                            ? ((function (seasonTabsParent, items) {
                                var index;
                                items.length
                                  ? ((index = 0),
                                    (items =
                                      '<div is="emby-tabs" data-index="-1" class="emby-tabs seasonTabs-emby-tabs padded-left padded-left-page padded-right"><div class="emby-tabs-slider scrollSliderX">' +
                                      items
                                        .map(function (item) {
                                          var tabClass =
                                              "emby-button emby-tab-button secondaryText detailSeasonTab",
                                            tabClass =
                                              (_layoutmanager.default.tv &&
                                                (tabClass += " emby-button-tv"),
                                              '<button type="button" is="emby-button" class="' +
                                                tabClass +
                                                '" data-seasonnumber="' +
                                                (null == item.IndexNumber
                                                  ? 1
                                                  : item.IndexNumber) +
                                                '" data-id="' +
                                                item.Id +
                                                '" data-index="' +
                                                index +
                                                '">' +
                                                _textencoding.default.htmlEncode(
                                                  item.Name,
                                                ) +
                                                "</button>");
                                          return index++, tabClass;
                                        })
                                        .join("") +
                                      "</div></div>"),
                                    (seasonTabsParent.innerHTML = items),
                                    seasonTabsParent.classList.remove("hide"))
                                  : (seasonTabsParent.classList.add("hide"),
                                    (seasonTabsParent.innerHTML = ""));
                              })(hasMultipleSeasons, result.Items),
                              (instance.seasonTabs = section.querySelector(
                                ".seasonTabs-emby-tabs",
                              )),
                              instance.seasonTabs.addEventListener(
                                "tabchange",
                                function (e) {
                                  var id,
                                    seasonTabs = this.seasonTabs;
                                  seasonTabs &&
                                    ((e = e.detail.selectedTabIndex),
                                    (seasonTabs = seasonTabs.querySelector(
                                      '.detailSeasonTab[data-index="' +
                                        e +
                                        '"]',
                                    ))) &&
                                    ((id = seasonTabs.getAttribute("data-id")),
                                    (e = (this.seasonItems || []).filter(
                                      function (s) {
                                        return s.Id === id;
                                      },
                                    )[0])) &&
                                    scrollEpisodesToSeason(this, e.Id);
                                }.bind(instance),
                              ))
                            : (hasMultipleSeasons.classList.add("hide"),
                              (hasMultipleSeasons.innerHTML = ""),
                              (instance.seasonTabs = null)))
                        : ((hasMultipleSeasons.innerHTML = ""),
                          hasMultipleSeasons.classList.add("hide"),
                          (instance.seasonTabs = null)),
                        (instance.detailSelectSeason = sectionTitleElement) &&
                          ((sectionTitleElement.getItems =
                            getSeasons.bind(instance)),
                          sectionTitleElement.addEventListener(
                            "change",
                            function (e) {
                              e = e.target.value;
                              e && scrollEpisodesToSeason(this, e);
                            }.bind(instance),
                          )),
                        (itemsContainer.fetchData = function (query) {
                          var item = this.currentItem,
                            apiClient =
                              _connectionmanager.default.getApiClient(item),
                            fields =
                              this.getRequestedItemFields() +
                              ",PrimaryImageAspectRatio";
                          if (this.renderAllEpisodes)
                            return (
                              (fields +=
                                ",Overview,PremiereDate,ProductionYear,RunTimeTicks,SpecialEpisodeNumbers"),
                              (query = Object.assign(
                                {
                                  UserId: apiClient.getCurrentUserId(),
                                  Fields: fields,
                                  Recursive: !0,
                                  IsFolder: !1,
                                  ParentId: item.Id,
                                },
                                query,
                              )),
                              apiClient.isMinServerVersion("4.8") ||
                                (query.IncludeItemTypes = "Episode"),
                              apiClient.getItems(
                                apiClient.getCurrentUserId(),
                                query,
                              )
                            );
                          return apiClient.getSeasons(
                            item.Id,
                            Object.assign(
                              {
                                UserId: apiClient.getCurrentUserId(),
                                Fields: fields,
                              },
                              query,
                            ),
                          );
                        }.bind(instance)),
                        (itemsContainer.getListOptions = function (items) {
                          var fields = ["Name"],
                            centerText = !0;
                          this.renderAllEpisodes &&
                            (fields.push("Overview"),
                            fields.push("MediaInfo"),
                            (centerText = !1));
                          return {
                            renderer: _cardbuilder.default,
                            options: {
                              shape: "auto",
                              scalable: !0,
                              centerText: centerText,
                              fields: fields,
                              overlayText: !1,
                              focusTransformTitleAdjust: !0,
                            },
                            virtualScrollLayout: "horizontal-grid",
                          };
                        }.bind(instance)),
                        seriesDisplay &&
                          ((itemsContainer.afterRefresh = function (
                            totalResult,
                          ) {
                            if (totalResult.Items.length) {
                              var item = this.currentItem;
                              if (item) {
                                var view = this.view;
                                if (view) {
                                  var apiClient,
                                    instance = this,
                                    itemsContainer = view.querySelector(
                                      ".childrenItemsContainer",
                                    );
                                  if (itemsContainer)
                                    return (
                                      (apiClient =
                                        _connectionmanager.default.getApiClient(
                                          item,
                                        )),
                                      getNextUpItems
                                        .call(this, { Limit: 1 })
                                        .then(function (nextUpResult) {
                                          var nextUpResult =
                                              nextUpResult.Items[0],
                                            detailSelectSeason =
                                              view.querySelector(
                                                ".detailSelectSeason",
                                              );
                                          if (nextUpResult) {
                                            onSeriesEpisodeFocusedOrScrolled(
                                              instance,
                                              nextUpResult,
                                            );
                                            var select,
                                              index =
                                                itemsContainer.indexOfItemId(
                                                  nextUpResult.Id,
                                                );
                                            if (-1 === index)
                                              return (
                                                (nextUpResult = {
                                                  UserId:
                                                    apiClient.getCurrentUserId(),
                                                  Limit: 0,
                                                  StartItemId: nextUpResult.Id,
                                                }),
                                                apiClient
                                                  .getEpisodes(
                                                    item.SeriesId || item.Id,
                                                    nextUpResult,
                                                  )
                                                  .then(function (result) {
                                                    (index = Math.max(
                                                      totalResult.TotalRecordCount -
                                                        result.TotalRecordCount,
                                                      0,
                                                    )),
                                                      itemsContainer.scrollToIndex(
                                                        Math.min(
                                                          index,
                                                          totalResult.TotalRecordCount -
                                                            1,
                                                        ),
                                                        {
                                                          behavior: "instant",
                                                          offset:
                                                            "-padding-inline-start",
                                                        },
                                                        !1,
                                                      );
                                                  })
                                              );
                                            itemsContainer.scrollToIndex(
                                              index,
                                              {
                                                behavior: "instant",
                                                offset: "-padding-inline-start",
                                              },
                                              !1,
                                            );
                                          } else
                                            itemsContainer.scrollToIndex(
                                              0,
                                              {
                                                behavior: "instant",
                                                offset: "-padding-inline-start",
                                              },
                                              !1,
                                            ),
                                              detailSelectSeason &&
                                                (select = detailSelectSeason)
                                                  .getItems({
                                                    StartIndex: 0,
                                                    Limit: 1,
                                                  })
                                                  .then(function (result) {
                                                    result.Items.length &&
                                                      select.setValues(
                                                        [result.Items[0].Id],
                                                        !1,
                                                        [result.Items[0]],
                                                      );
                                                  });
                                        })
                                    );
                                }
                              }
                            }
                          }.bind(instance)),
                          (detailSelectSeasonContainer =
                            instance.view.querySelector(
                              ".childrenItemsScroller",
                            )).addScrollEventListener(
                            function (e) {
                              var scrollSize, padding;
                              _layoutmanager.default.tv ||
                                ((e = e.currentTarget),
                                (padding = e.getPadding()),
                                (padding =
                                  e.getScrollLeft() +
                                  padding.inlineStart +
                                  padding.inlineEnd),
                                (scrollSize = e.getScrollWidth()),
                                (padding = Math.min(1, padding / scrollSize)),
                                (scrollSize = e.querySelector(
                                  ".childrenItemsContainer",
                                )),
                                (e = scrollSize.getItems()),
                                (padding = Math.floor(padding * e.length)) <
                                  e.length &&
                                  (e = scrollSize.getItem(padding)) &&
                                  onSeriesEpisodeFocusedOrScrolled(this, e));
                            }.bind(instance),
                            {},
                          ),
                          detailSelectSeasonContainer.addEventListener(
                            "focus",
                            function (e) {
                              var itemsContainer =
                                  e.currentTarget.querySelector(
                                    ".childrenItemsContainer",
                                  ),
                                e = e.target.closest(
                                  itemsContainer.getItemSelector(),
                                ),
                                itemsContainer =
                                  itemsContainer.getItemFromElement(e);
                              itemsContainer &&
                                onSeriesEpisodeFocusedOrScrolled(
                                  this,
                                  itemsContainer,
                                );
                            }.bind(instance),
                            !0,
                          ));
                    })
                : (section.classList.add("hide"), Promise.resolve());
            })(this, item),
          ),
          (function (instance, item) {
            var section = instance.view.querySelector(
                ".collectionItemsSection",
              ),
              itemsContainer = section.querySelector(".itemsContainer");
            (itemsContainer.parentContainer = section),
              (itemsContainer.fetchData = function (query) {
                var item = this.currentItem;
                if ("BoxSet" !== item.Type)
                  return Promise.resolve({ Items: [], TotalRecordCount: 0 });
                var apiClient = _connectionmanager.default.getApiClient(item),
                  sortBy =
                    _usersettings.default.itemSortBy(item.Id) || "default";
                "default" === sortBy && (sortBy = "DisplayOrder");
                apiClient.isMinServerVersion("4.8.0.16") || (sortBy = null);
                var sortOrder = sortBy
                  ? _usersettings.default.itemSortOrder(item.Id)
                  : null;
                return apiClient
                  .getItems(
                    apiClient.getCurrentUserId(),
                    Object.assign(
                      {
                        ParentId: item.Id,
                        ImageTypeLimit: 1,
                        Fields:
                          this.getRequestedItemFields() +
                          ",PrimaryImageAspectRatio,ProductionYear",
                        EnableTotalRecordCount: !1,
                        sortBy: sortBy,
                        sortOrder: sortOrder,
                      },
                      query,
                    ),
                  )
                  .then(function (result) {
                    for (
                      var i = 0, length = result.Items.length;
                      i < length;
                      i++
                    )
                      result.Items[i].CollectionId = item.Id;
                    return result;
                  });
              }.bind(instance)),
              (itemsContainer.afterRefresh = setSortLabelText.bind(instance)),
              (itemsContainer.getListOptions = (function (id) {
                return function (items) {
                  return {
                    renderer: _cardbuilder.default,
                    options: {
                      shape: "auto",
                      scalable: !0,
                      centerText: !0,
                      fields: ["Name", "ProductionYear"],
                      overlayText: !1,
                      collectionId: id,
                    },
                  };
                };
              })(item.Id)),
              itemsContainer.setAttribute("data-monitor", "CollectionItems"),
              itemsContainer.setAttribute("data-monitorids", item.Id);
          })(this, item),
          (function (instance, view, item, apiClient) {
            var headerText;
            "MusicArtist" === item.Type &&
              ((headerText = view.querySelector(".artistSongsItemsHeader")),
              (apiClient = _approuter.default.getRouteUrl("list", {
                serverId: apiClient.serverId(),
                itemTypes: "Audio",
                artistId: item.Id,
              })),
              (item = ""),
              (item =
                '<a is="emby-sectiontitle" href="' +
                apiClient +
                '" class="button-link  button-link-color-inherit sectionTitleTextButton">'),
              (item =
                (item =
                  (item += '<h2 class="sectionTitle sectionTitle-cards">') +
                  _globalize.default.translate("Songs")) + "</h2></a>"),
              (headerText.innerHTML = item),
              (apiClient = view.querySelector(
                ".artistSongsItemsContainer",
              )).classList.add("generalItemsContainer"),
              (apiClient.fetchData = function (query) {
                var item = this.currentItem,
                  item = _connectionmanager.default.getApiClient(item);
                return item.getItems(
                  item.getCurrentUserId(),
                  Object.assign(
                    {
                      Recursive: !0,
                      IncludeItemTypes: "Audio",
                      ArtistIds: this.currentItem.Id,
                      SortBy: "PlayCount,SortName",
                      SortOrder: "Descending,Ascending",
                      ImageTypeLimit: 1,
                      Fields:
                        this.getRequestedItemFields() +
                        ",PrimaryImageAspectRatio",
                    },
                    query,
                  ),
                );
              }.bind(instance)),
              (apiClient.getListOptions = getArtistSongsListOptions),
              (apiClient.parentContainer =
                apiClient.closest(".verticalSection")));
          })(this, view, item, responses),
          (function (instance, item, apiClient) {
            var section = instance.view.querySelector(".artistAlbumsSection"),
              itemsContainer =
                (setScopedFocus(
                  instance.view,
                  section.querySelector(".focusable"),
                  !0,
                  "nearest",
                ),
                section.querySelector(".itemsContainer")),
              apiClient =
                ((itemsContainer.parentContainer = section),
                _approuter.default.getRouteUrl("list", {
                  serverId: apiClient.serverId(),
                  itemTypes: "MusicAlbum",
                  albumArtistId: item.Id,
                }));
            (section.querySelector(".sectionTitleTextButton").href = apiClient),
              itemsContainer.setAttribute(
                "data-virtualscrolllayout",
                "horizontal-grid",
              ),
              (itemsContainer.fetchData = function (query) {
                var item = this.currentItem;
                if ("MusicArtist" !== item.Type)
                  return Promise.resolve({ Items: [], TotalRecordCount: 0 });
                var apiClient = _connectionmanager.default.getApiClient(item);
                return (
                  ((query = Object.assign(
                    {
                      IncludeItemTypes: "MusicAlbum",
                      Recursive: !0,
                      SortBy: "ProductionYear,SortName",
                      SortOrder: "Descending,Ascending",
                      ImageTypeLimit: 1,
                      Fields:
                        this.getRequestedItemFields() +
                        ",PrimaryImageAspectRatio,ProductionYear",
                    },
                    query,
                  )).AlbumArtistIds = item.Id),
                  apiClient.getItems(apiClient.getCurrentUserId(), query)
                );
              }.bind(instance)),
              (itemsContainer.getListOptions =
                getMusicArtistChildrenListOptions);
          })(this, item, responses),
          (function (instance, item, apiClient) {
            var trackList = instance.view.querySelector(".trackList");
            (trackList.parentContainer = trackList),
              "Season" === item.Type
                ? ((trackList.fetchData = (function (
                    serverId,
                    seriesId,
                    seasonId,
                  ) {
                    return function (query) {
                      var apiClient =
                        _connectionmanager.default.getApiClient(serverId);
                      return apiClient.getEpisodes(
                        seriesId,
                        Object.assign(
                          {
                            SeasonId: seasonId,
                            ImageTypeLimit: 1,
                            UserId: apiClient.getCurrentUserId(),
                            Fields:
                              "Overview,PrimaryImageAspectRatio,PremiereDate,ProductionYear",
                          },
                          query,
                        ),
                      );
                    };
                  })(apiClient.serverId(), item.SeriesId, item.Id)),
                  (trackList.getListOptions = (function (item) {
                    return function () {
                      return {
                        renderer: _listview.default,
                        options: {
                          showIndexNumber: !1,
                          imageSize: "large",
                          highlight: !1,
                          action: "link",
                          imagePlayButton: !_layoutmanager.default.tv,
                          includeParentInfoInTitle: !1,
                          enableSpecialEpisodePrefix: 0 !== item.IndexNumber,
                          itemClass: "detailsListItem",
                          fields: ["Name", "Overview"],
                        },
                        virtualScrollLayout: "vertical-list",
                      };
                    };
                  })(item)),
                  trackList.setAttribute(
                    "data-virtualscrolllayout",
                    "vertical-grid",
                  ),
                  trackList.classList.add("padded-bottom-page"))
                : "MusicAlbum" === item.Type
                ? ((trackList.fetchData = function (query) {
                    var item = this.currentItem,
                      apiClient = _connectionmanager.default.getApiClient(item),
                      includeOverview = !0 === item.SupportsResume,
                      fields =
                        this.getRequestedItemFields() +
                        ",PrimaryImageAspectRatio";
                    includeOverview && (fields += ",Overview");
                    return apiClient.getItems(
                      apiClient.getCurrentUserId(),
                      Object.assign({
                        ParentId: item.Id,
                        Fields: fields,
                        ImageTypeLimit: 1,
                        SortBy: null,
                        EnableTotalRecordCount: !1,
                      }),
                    );
                  }.bind(instance)),
                  (trackList.getListOptions = (
                    !0 === item.SupportsResume
                      ? function (item) {
                          return function (items) {
                            var fields = [];
                            return (
                              (function (items) {
                                for (
                                  var i = 0, length = items.length;
                                  i < length;
                                  i++
                                ) {
                                  var item = items[i];
                                  if (
                                    "Audio" !== item.MediaType ||
                                    item.SupportsResume
                                  )
                                    return 1;
                                }
                                return;
                              })(items) && fields.push("Overview"),
                              "Playlist" === item.Type &&
                                fields.push("ParentName"),
                              fields.push("Name"),
                              {
                                renderer: _listview.default,
                                options: {
                                  showIndexNumberLeft: !1,
                                  highlight: !1,
                                  action: "link",
                                  dragHandle: !1,
                                  image: !0,
                                  imageSize: "medium",
                                  showIndexNumber: !0,
                                  artist: "auto",
                                  imagePlayButton: !_layoutmanager.default.tv,
                                  showIndex: "MusicAlbum" === item.Type,
                                  fields: fields,
                                  index: "disc",
                                  containerAlbumArtists:
                                    "MusicAlbum" === item.Type
                                      ? item.AlbumArtists
                                      : null,
                                  playAction: "playallfromhere",
                                  includeParentInfoInTitle: !1,
                                  itemClass: "detailsListItem",
                                  autoHideMediaInfo: !1,
                                  enableSideMediaInfo: !0,
                                },
                                virtualScrollLayout: "vertical-list",
                                commandOptions: { openAlbum: !1 },
                              }
                            );
                          };
                        }
                      : getPlaylistListOptionsFn
                  )(item)),
                  trackList.classList.add("generalItemsContainer"))
                : "Playlist" === item.Type &&
                  ((trackList.fetchData = function (query) {
                    var currentItem = this.currentItem,
                      apiClient =
                        _connectionmanager.default.getApiClient(currentItem),
                      itemId = currentItem.Id,
                      currentItem =
                        _usersettings.default.itemSortBy(itemId) || "default";
                    "default" === currentItem &&
                      (currentItem = "ListItemOrder");
                    var sortOrder = currentItem
                      ? _usersettings.default.itemSortOrder(itemId)
                      : null;
                    return apiClient
                      .getItems(
                        apiClient.getCurrentUserId(),
                        Object.assign(
                          {
                            ParentId: itemId,
                            Fields:
                              "PrimaryImageAspectRatio,Overview,PremiereDate,ProductionYear,OfficialRating,CommunityRating",
                            ImageTypeLimit: 1,
                            SortBy: currentItem,
                            SortOrder: sortOrder,
                          },
                          query,
                        ),
                      )
                      .then(function (result) {
                        for (
                          var i = 0, length = result.Items.length;
                          i < length;
                          i++
                        )
                          result.Items[i].PlaylistId = itemId;
                        return result;
                      });
                  }.bind(instance)),
                  (trackList.getListOptions = getPlaylistListOptionsFn(item)),
                  trackList.setAttribute("data-monitor", "PlaylistItems"),
                  trackList.setAttribute("data-monitorids", item.Id),
                  trackList.setAttribute(
                    "data-virtualscrolllayout",
                    "vertical-grid",
                  ),
                  trackList.classList.add("padded-bottom-page"),
                  (trackList.afterRefresh = setSortLabelText.bind(instance)),
                  trackList.classList.add("generalItemsContainer"));
            _layoutmanager.default.tv ||
            ("Playlist" !== item.Type && "MusicAlbum" !== item.Type)
              ? trackList.classList.remove("tracklist-topmargin")
              : trackList.classList.add("tracklist-topmargin");
            _layoutmanager.default.tv && "Season" === item.Type
              ? trackList.classList.add("tracklist-sidemargin")
              : trackList.classList.remove("tracklist-sidemargin");
          })(this, item, responses),
          (function (instance, view, item, user) {
            (_itemmanager.default.canAddToCollection(item, user) ||
              _itemmanager.default.canAddToPlaylist(item)) &&
              "Season" !== item.Type &&
              (((user = view.querySelector(
                ".appearsOnListsItemsContainer",
              )).fetchData = function (query) {
                var item = this.currentItem,
                  apiClient = _connectionmanager.default.getApiClient(item);
                return (
                  (query = Object.assign(
                    {
                      fields:
                        this.getRequestedItemFields() +
                        ",PrimaryImageAspectRatio",
                      IncludeItemTypes: "Playlist,BoxSet",
                      Recursive: !0,
                      SortBy: "SortName",
                      ListItemIds: item.Id,
                    },
                    query,
                  )),
                  apiClient.getItems(apiClient.getCurrentUserId(), query)
                );
              }.bind(instance)),
              (user.getListOptions = getAppearsOnListsListOptions),
              (user.parentContainer = user.closest(".verticalSection")),
              user.classList.add("generalItemsContainer"));
          })(this, view, item, user),
          (function (instance, view) {
            view = view.querySelector(".peopleItemsContainer");
            (view.fetchData = (function (instance) {
              return function (query) {
                var serverId = instance.currentItem.ServerId,
                  people = (instance.currentItem.People || []).filter(
                    function (p) {
                      return (
                        (p.ServerId = serverId),
                        "Person" !== p.Type &&
                          ((p.PersonType = p.Type), (p.Type = "Person")),
                        !0
                      );
                    },
                  ),
                  totalRecordCount = people.length;
                return (
                  query &&
                    ((people = people.slice(query.StartIndex || 0)),
                    query.Limit) &&
                    people.length > query.Limit &&
                    (people.length = query.Limit),
                  Promise.resolve({
                    Items: people,
                    TotalRecordCount: totalRecordCount,
                  })
                );
              };
            })(instance)),
              (view.parentContainer = view.closest(".verticalSection")),
              (view.getListOptions = getPeopleListOptions),
              view.classList.add("generalItemsContainer");
          })(this, view),
          (function (instance, view, item) {
            _itemhelper.default.supportsSimilarItems(item) &&
              (((view = view.querySelector(
                ".similarItemsContainer",
              )).fetchData = function () {
                var item = this.currentItem,
                  apiClient = _connectionmanager.default.getApiClient(item),
                  options = {
                    Limit: 12,
                    UserId: apiClient.getCurrentUserId(),
                    ImageTypeLimit: 1,
                    Fields:
                      this.getRequestedItemFields() +
                      ",PrimaryImageAspectRatio,ProductionYear",
                    EnableTotalRecordCount: !1,
                  };
                ("Program" === item.Type ||
                  ("Timer" === item.Type &&
                    item.ProgramId &&
                    !item.IsSports)) &&
                  (options.GroupProgramsBySeries = !0);
                "MusicAlbum" === item.Type &&
                  item.AlbumArtists &&
                  item.AlbumArtists.length &&
                  (options.ExcludeArtistIds = item.AlbumArtists[0].Id);
                item = "Timer" === item.Type ? item.ProgramId : item.Id;
                return apiClient.getSimilarItems(item, options);
              }.bind(instance)),
              (view.parentContainer = view.closest(".verticalSection")),
              (view.getListOptions = (function (item) {
                return function (items) {
                  var fields = ["Name"];
                  return (
                    ("Movie" !== item.Type &&
                      "Trailer" !== item.Type &&
                      "Program" !== item.Type &&
                      "Game" !== item.Type) ||
                      fields.push("ProductionYear"),
                    ("MusicAlbum" !== item.Type && "Game" !== item.Type) ||
                      fields.push("ParentName"),
                    "Program" === item.Type && fields.unshift("ParentName"),
                    {
                      renderer: _cardbuilder.default,
                      options: {
                        shape: "auto",
                        lines:
                          "Game" === item.Type
                            ? 3
                            : "Program" === item.Type
                            ? 2
                            : null,
                        centerText: !0,
                        fields: fields,
                        overlayPlayButton: !0,
                        overlayText: !1,
                        multiSelect:
                          "Program" !== item.Type && "Timer" !== item.Type,
                        contextMenu:
                          "Program" !== item.Type && "Timer" !== item.Type,
                        draggable:
                          "Program" !== item.Type && "Timer" !== item.Type,
                        focusTransformTitleAdjust: !0,
                      },
                      virtualScrollLayout: "horizontal-grid",
                    }
                  );
                };
              })(item)),
              view.classList.add("generalItemsContainer"));
          })(this, view, item),
          (function (instance, view, item, apiClient) {
            _itemhelper.default.supportsSimilarItemsOnLiveTV(item, apiClient) &&
              (((item = view.querySelector(
                ".similarOnLiveTVItemsContainer",
              )).fetchData = function () {
                var item = this.currentItem,
                  apiClient = _connectionmanager.default.getApiClient(item);
                return apiClient.getSimilarItems(item.Id, {
                  userId: apiClient.getCurrentUserId(),
                  limit: 12,
                  fields:
                    this.getRequestedItemFields() +
                    ",PrimaryImageAspectRatio,ProductionYear",
                  IncludeItemTypes: "Program",
                  EnableTotalRecordCount: !1,
                  GroupProgramsBySeries: !0,
                });
              }.bind(instance)),
              (item.parentContainer = item.closest(".verticalSection")),
              (item.getListOptions = getMoreLikeThisOnLiveTVListOptions),
              item.classList.add("generalItemsContainer"));
          })(this, view, item, responses),
          (function (instance, view, item) {
            ("Series" === item.Type ||
              "Program" === item.Type ||
              ("Timer" === item.Type && item.ProgramId)) &&
              (((view = view.querySelector(
                ".seriesScheduleItemsContainer",
              )).fetchData = function (query) {
                var item = this.currentItem,
                  apiClient = _connectionmanager.default.getApiClient(item);
                (query = Object.assign(
                  {
                    UserId: apiClient.getCurrentUserId(),
                    HasAired: !1,
                    SortBy: "StartDate",
                    ImageTypeLimit: 1,
                    EnableImageTypes: "Primary,Thumb,Backdrop",
                    EnableUserData: !1,
                    Fields: "PrimaryImageAspectRatio,ChannelInfo",
                  },
                  query,
                )),
                  "Program" === item.Type ||
                  ("Timer" === item.Type && item.ProgramId)
                    ? item.AsSeries
                      ? (query.SeriesFromProgramId = item.Id)
                      : ((query.ShowingsFromProgramId =
                          item.ProgramId || item.Id),
                        (query.ExcludeItemIds = item.ProgramId || item.Id))
                    : (query.LibrarySeriesId = item.Id);
                return apiClient.getLiveTvPrograms(query);
              }.bind(instance)),
              (view.parentContainer = view.closest(".verticalSection")),
              (view.getListOptions = function (items) {
                return {
                  renderer: _cardbuilder.default,
                  options: {
                    preferThumb: "auto",
                    shape: "autooverflow",
                    fields: ["Name", "ChannelName", "AirTime"],
                    centerText: !0,
                    overlayText: !1,
                    overlayPlayButton: !1,
                    showAirDateTime: !0,
                    multiSelect: !1,
                    draggable: !1,
                    focusTransformTitleAdjust: !0,
                  },
                  virtualScrollLayout: "horizontal-grid",
                };
              }.bind(instance)),
              view.classList.add("generalItemsContainer"),
              ("Program" !== item.Type && "Timer" !== item.Type) ||
                (item.AsSeries
                  ? (view.parentContainer.querySelector(
                      ".sectionTitle",
                    ).innerHTML = _globalize.default.translate("Showings"))
                  : (view.parentContainer.querySelector(
                      ".sectionTitle",
                    ).innerHTML = _globalize.default.translate(
                      "HeaderOtherShowings",
                    ))));
          })(this, view, item),
          (function (instance, view, item) {
            _itemhelper.default.supportsExtras(item) &&
              (((item = view.querySelector(".extrasItemsContainer")).fetchData =
                function (query) {
                  var item = this.currentItem,
                    apiClient = _connectionmanager.default.getApiClient(item);
                  return apiClient
                    .getSpecialFeatures(apiClient.getCurrentUserId(), item.Id)
                    .then(function (items) {
                      var totalRecordCount = items.length;
                      return (
                        query &&
                          ((items = items.slice(query.StartIndex || 0)),
                          query.Limit) &&
                          items.length > query.Limit &&
                          (items.length = query.Limit),
                        { Items: items, TotalRecordCount: totalRecordCount }
                      );
                    });
                }.bind(instance)),
              (item.parentContainer = item.closest(".verticalSection")),
              (item.getListOptions = getExtrasListOptions),
              item.classList.add("generalItemsContainer"));
          })(this, view, item),
          (function (instance, view) {
            view = view.querySelector(".chaptersItemsContainer");
            (view.fetchData = function (query) {
              var item = this.currentItem,
                chapters = item.Chapters || [];
              chapters.length &&
                "Video" === item.MediaType &&
                !chapters[0].ImageTag &&
                (chapters = []);
              var videoStream =
                  (
                    ((item.MediaSources || [])[0] || {}).MediaStreams || []
                  ).filter(function (i) {
                    return "Video" === i.Type;
                  })[0] || {},
                aspect = null;
              videoStream.Width &&
                videoStream.Height &&
                (aspect = videoStream.Width / videoStream.Height);
              for (var i = 0, length = chapters.length; i < length; i++) {
                var chapter = chapters[i];
                (chapter.Id = item.Id),
                  (chapter.Type = item.Type),
                  (chapter.ServerId = item.ServerId),
                  (chapter.MediaType = item.MediaType),
                  (chapter.PrimaryImageAspectRatio = aspect),
                  null == chapter.ChapterIndex && (chapter.ChapterIndex = i);
              }
              videoStream = (chapters = (function (chapters) {
                for (
                  var list = [], i = 0, length = chapters.length;
                  i < length;
                  i++
                ) {
                  var chapter = chapters[i];
                  (chapter.MarkerType && "Chapter" !== chapter.MarkerType) ||
                    list.push(chapter);
                }
                return list;
              })(chapters)).length;
              query &&
                ((chapters = chapters.slice(query.StartIndex || 0)),
                query.Limit) &&
                chapters.length > query.Limit &&
                (chapters.length = query.Limit);
              return Promise.resolve({
                Items: chapters,
                TotalRecordCount: videoStream,
              });
            }.bind(instance)),
              (view.parentContainer = view.closest(".verticalSection")),
              (view.getListOptions = getChaptersListOptions),
              view.classList.add("generalItemsContainer");
          })(this, view),
          (function (instance, view) {
            view = view.querySelector(".additionalPartsItemsContainer");
            (view.fetchData = function () {
              var item = this.currentItem;
              if ((item.PartCount || 1) < 2)
                return Promise.resolve({ TotalRecordCount: 0, Items: [] });
              var apiClient = _connectionmanager.default.getApiClient(item);
              return apiClient.getAdditionalVideoParts(
                apiClient.getCurrentUserId(),
                item.Id,
              );
            }.bind(instance)),
              (view.parentContainer = view.closest(".verticalSection")),
              (view.getListOptions = getAdditionalPartsListOptions),
              view.classList.add("generalItemsContainer");
          })(this, view),
          (function (instance, view, item) {
            "TvChannel" === item.Type &&
              (((item = view.querySelector(
                ".programGuideItemsContainer",
              )).fetchData = function (query) {
                var item = this.currentItem,
                  apiClient = _connectionmanager.default.getApiClient(item);
                return apiClient.getLiveTvPrograms(
                  Object.assign(
                    {
                      ChannelIds: item.Id,
                      UserId: apiClient.getCurrentUserId(),
                      HasAired: !1,
                      SortBy: "StartDate",
                      ImageTypeLimit: 1,
                      EnableUserData: !1,
                      Fields: "PrimaryImageAspectRatio,Overview",
                    },
                    query,
                  ),
                );
              }.bind(instance)),
              (item.parentContainer = item.closest(".programGuideSection")),
              (item.getListOptions = getProgramGuideListOptions),
              item.classList.add("generalItemsContainer"));
          })(this, view, item),
          (function (instance, view, item) {
            "SeriesTimer" === item.Type &&
              (((item = view.querySelector(
                ".seriesTimerScheduleItemsContainer",
              )).fetchData = function () {
                var item = this.currentItem,
                  apiClient = _connectionmanager.default.getApiClient(item);
                return apiClient.getLiveTvTimers({
                  UserId: apiClient.getCurrentUserId(),
                  ImageTypeLimit: 1,
                  EnableImageTypes: "Primary,Backdrop,Thumb",
                  SortBy: "StartDate",
                  EnableTotalRecordCount: !1,
                  EnableUserData: !1,
                  SeriesTimerId: item.Id,
                  Fields: "ChannelInfo,ChannelImage",
                });
              }.bind(instance)),
              (item.parentContainer = item.closest(".verticalSection")),
              (item.getListOptions = getSeriesTimerListOptions),
              item.classList.add("generalItemsContainer"));
          })(this, view, item),
          (function (instance, view, item) {
            var itemsContainer = (function (view, item) {
                var sideImageContainer = view.querySelector(
                    ".detailImageContainer-side",
                  ),
                  view = view.querySelector(".detailImageContainer-main");
                return enableTrackList(item)
                  ? (view.classList.add("hide"),
                    sideImageContainer.classList.remove("hide"),
                    sideImageContainer)
                  : (view.classList.remove("hide"),
                    sideImageContainer.classList.add("hide"),
                    view);
              })(view, item),
              detailImage = itemsContainer,
              view = view.querySelector(".detailImageContainer-main");
            enableTrackList(item) ||
              ("Person" !== item.Type &&
                "BoxSet" !== item.Type &&
                "Season" !== item.Type &&
                "TvChannel" !== item.Type &&
                "Playlist" !== item.Type) ||
              detailImage.classList.add("detailImageContainer-small");
            "MusicAlbum" !== item.Type &&
              "Playlist" !== item.Type &&
              view.classList.add("detailImageContainer-main-extrabottommargin");
            _layoutmanager.default.tv
              ? view.classList.add("detailImageContainer-main-tv")
              : view.classList.remove("detailImageContainer-main-tv");
            enableItemBackdropAsTopImage(item)
              ? view.classList.add("detailImageContainer-hidemobile")
              : view.classList.remove("detailImageContainer-hidemobile");
            view = _imageloader.default.getShape([item], {});
            detailImage.classList.remove(
              "detailImageContainer-backdrop",
              "detailImageContainer-square",
              "detailImageContainer-portrait",
              "detailImageContainer-fourThree",
              "detailImageContainer-banner",
            ),
              view && detailImage.classList.add("detailImageContainer-" + view);
            "TvChannel" === item.Type ||
            "Season" === item.Type ||
            "MusicAlbum" === item.Type ||
            "Playlist" === item.Type
              ? detailImage.classList.add("detailImage-nomarginleft")
              : detailImage.classList.remove("detailImage-nomarginleft");
            (itemsContainer.fetchData = function () {
              var item = this.currentItem,
                items = [];
              !item || enableTvDetailImageLayout(item) || items.push(item);
              return Promise.resolve({
                Items: items,
                TotalRecordCount: items.length,
              });
            }.bind(instance)),
              ((itemsContainer.parentContainer =
                itemsContainer).getListOptions = (function (
                itemType,
                cardClass,
                imageContainerClassName,
              ) {
                (imageContainerClassName = imageContainerClassName
                  .split(" ")
                  .filter(function (c) {
                    return c.includes("detailImage");
                  })
                  .join(" ")).includes("detailImageContainer-side") &&
                  (imageContainerClassName += " item-fixed-side");
                return (
                  (imageContainerClassName += " imageWidthTest"),
                  function (items) {
                    return {
                      renderer: _cardbuilder.default,
                      options: {
                        overlayText: !0,
                        fields: [],
                        action: "none",
                        imageClass: "detailImage",
                        imageWidthTestClass: imageContainerClassName,
                        multiSelect: !1,
                        contextMenu: !1,
                        ratingButton: !1,
                        playedButton: !1,
                        cardClass: cardClass,
                        defaultIcon: !0,
                        typeIndicator: !1,
                        playedIndicator: !1,
                        syncIndicator: !1,
                        timerIndicator: !1,
                        randomDefaultBackground: !1,
                        staticElement: !0,
                        progress:
                          "Program" === itemType || "Timer" === itemType,
                        enableUserData: !1,
                        draggable: !1,
                        moreButton: !1,
                        programIndicators: !1,
                        keepImageAnimation: !0,
                      },
                      virtualScrollLayout: "vertical-grid",
                    };
                  }
                );
              })(item.Type, "detailImageContainerCard", detailImage.className)),
              (itemsContainer.afterRefresh = afterDetailImageRefreshed),
              itemsContainer.classList.add("generalItemsContainer"),
              enableTvDetailImageLayout(item) &&
                itemsContainer.classList.add("hide");
          })(this, view, item)),
        view.querySelector(".details-additionalContent")),
      detailMainContainer =
        ("TvChannel" === item.Type ||
        "Playlist" === item.Type ||
        "Season" === item.Type
          ? detailMainContainerParent.classList.remove("padded-bottom-page")
          : detailMainContainerParent.classList.add("padded-bottom-page"),
        this.mainSection),
      detailMainContainerParent =
        (_backdrop.default.hasBackdrop()
          ? (detailMainContainerParent.classList.add(
              "details-additionalContent-withbackdrop",
            ),
            detailMainContainer.classList.add(
              "detailMainContainer-withbackdrop",
            ))
          : (detailMainContainerParent.classList.remove(
              "details-additionalContent-withbackdrop",
            ),
            detailMainContainer.classList.remove(
              "detailMainContainer-withbackdrop",
            )),
        enableTrackList(item)
          ? "Season" === item.Type
            ? setTitle(item)
            : setTitle(item, 0, _layoutmanager.default.tv)
          : setTitle(
              item,
              0,
              "float" === getLogoPlacement(item) && "MusicAlbum" !== item.Type,
            ),
        view.querySelector(".topDetailsMain")),
      itemSideContainer = view.querySelector(".item-fixed-side"),
      mainDetailButtons = view.querySelector(".mainDetailButtons");
    return (
      enableTrackList(item)
        ? ("MusicAlbum" === item.Type
            ? detailMainContainer.classList.add(
                "detailMainContainer-marginleft",
              )
            : detailMainContainer.classList.remove(
                "detailMainContainer-marginleft",
              ),
          detailMainContainerParent.classList.remove(
            "topDetailsMain-graphic",
            "topDetailsMain-graphic-tv",
          ),
          detailMainContainer.classList.remove(
            "detailMainContainer-withitembackdrop",
            "detailMainContainer-vertical",
          ),
          itemSideContainer.classList.remove("hide"),
          _layoutmanager.default.tv && "Season" !== item.Type
            ? detailMainContainerParent.classList.add(
                "padded-left",
                "padded-left-page",
                "padded-right",
              )
            : detailMainContainerParent.classList.remove(
                "padded-left",
                "padded-left-page",
                "padded-right",
              ))
        : (detailMainContainer.classList.remove(
            "detailMainContainer-marginleft",
          ),
          enableItemBackdropAsTopImage(item)
            ? (detailMainContainer.classList.add(
                "detailMainContainer-withitembackdrop",
              ),
              detailMainContainer.classList.remove(
                "detailMainContainer-vertical",
              ))
            : (detailMainContainer.classList.remove(
                "detailMainContainer-withitembackdrop",
              ),
              detailMainContainer.classList.add(
                "detailMainContainer-vertical",
              )),
          enableTvDetailImageLayout(item)
            ? _layoutmanager.default.tv
              ? detailMainContainerParent.classList.add(
                  "topDetailsMain-graphic",
                  "topDetailsMain-graphic-tv",
                )
              : (detailMainContainerParent.classList.add(
                  "topDetailsMain-graphic",
                ),
                detailMainContainerParent.classList.remove(
                  "topDetailsMain-graphic-tv",
                ))
            : detailMainContainerParent.classList.remove(
                "topDetailsMain-graphic",
                "topDetailsMain-graphic-tv",
              ),
          itemSideContainer.classList.add("hide"),
          detailMainContainerParent.classList.remove(
            "padded-left",
            "padded-left-page",
            "padded-right",
          )),
      renderName(
        this,
        item,
        responses,
        user,
        view.querySelectorAll(".nameContainer"),
      ),
      (function (view, item, apiClient) {
        var imgUrl,
          usePrimaryImage,
          screenWidth = screen.availWidth,
          itemBackdropContainerElement = view.querySelector(
            ".itemBackdropContainer",
          ),
          itemBackdropElement =
            itemBackdropContainerElement.querySelector(".itemBackdrop");
        enableItemBackdropAsTopImage(item)
          ? (itemBackdropContainerElement.classList.remove("hide"),
            (usePrimaryImage =
              ("Video" === item.MediaType &&
                "Movie" !== item.Type &&
                "Trailer" !== item.Type) ||
              (item.MediaType && "Video" !== item.MediaType) ||
              "MusicAlbum" === item.Type ||
              "Playlist" === item.Type),
            "Program" === item.Type && item.ImageTags && item.ImageTags.Thumb
              ? (imgUrl = apiClient.getImageUrl(item.Id, {
                  type: "Thumb",
                  index: 0,
                  maxWidth: screenWidth,
                  tag: item.ImageTags.Thumb,
                  EnableImageEnhancers: !1,
                }))
              : usePrimaryImage && item.ImageTags && item.ImageTags.Primary
              ? (imgUrl = apiClient.getImageUrl(item.Id, {
                  type: "Primary",
                  index: 0,
                  maxWidth: screenWidth,
                  tag: item.ImageTags.Primary,
                  EnableImageEnhancers: !1,
                }))
              : item.BackdropImageTags && item.BackdropImageTags.length
              ? (imgUrl = apiClient.getImageUrl(item.Id, {
                  type: "Backdrop",
                  index: 0,
                  maxWidth: screenWidth,
                  tag: item.BackdropImageTags[0],
                }))
              : item.ParentBackdropItemId &&
                item.ParentBackdropImageTags &&
                item.ParentBackdropImageTags.length
              ? (imgUrl = apiClient.getImageUrl(item.ParentBackdropItemId, {
                  type: "Backdrop",
                  index: 0,
                  tag: item.ParentBackdropImageTags[0],
                  maxWidth: screenWidth,
                }))
              : item.ImageTags && item.ImageTags.Thumb
              ? (imgUrl = apiClient.getImageUrl(item.Id, {
                  type: "Thumb",
                  index: 0,
                  maxWidth: screenWidth,
                  tag: item.ImageTags.Thumb,
                  EnableImageEnhancers: !1,
                }))
              : item.ImageTags &&
                item.ImageTags.Primary &&
                (imgUrl = apiClient.getImageUrl(item.Id, {
                  type: "Primary",
                  index: 0,
                  maxWidth: screenWidth,
                  tag: item.ImageTags.Primary,
                  EnableImageEnhancers: !1,
                })),
            "TvChannel" === item.Type &&
              itemBackdropContainerElement.classList.add(
                "itemBackdropContainer-small",
              ),
            (usePrimaryImage = view.querySelector(".itemMainScrollSlider")),
            _layoutmanager.default.tv
              ? usePrimaryImage.classList.remove(
                  "itemMainScrollSlider-moveup",
                  "itemMainScrollSlider-nopaddingtop",
                )
              : "TvChannel" !== item.Type &&
                enableItemBackdropAsTopImage(item) &&
                usePrimaryImage.classList.add(
                  "itemMainScrollSlider-nopaddingtop",
                ),
            ("TvChannel" !== item.Type && "Person" !== item.Type) ||
              itemBackdropElement.classList.add("itemBackdrop-contain"),
            (itemBackdropElement.style.backgroundImage = imgUrl
              ? "url('" + imgUrl + "')"
              : ""))
          : itemBackdropContainerElement.classList.add("hide");
      })(view, item, responses),
      renderTrackSelections(view, this, item, user, !0, itemInfo),
      itemMainScrollSlider.push(
        renderDetails(this, view, item, responses, user),
      ),
      (function (view, user, item) {
        if (_servicelocator.appHost.supports("sync"))
          for (
            var canSync = _itemmanager.default.canSync(item, user),
              buttons = view.querySelectorAll(".btnSyncDownload"),
              i = 0,
              length = buttons.length;
            i < length;
            i++
          )
            buttons[i].setItem(item),
              canSync
                ? buttons[i].classList.remove("hide")
                : buttons[i].classList.add("hide");
      })(view, user, item),
      Promise.all(itemMainScrollSlider).then(function () {
        return (
          enableTrackList(item) ||
            (function (elem) {
              for (
                var btns = elem.querySelectorAll(".detailButton"),
                  i = 0,
                  length = btns.length;
                i < length;
                i++
              ) {
                var btn = btns[i];
                if (_focusmanager.default.isCurrentlyFocusable(btn))
                  return setScopedFocus(null, elem, !0);
              }
              setScopedFocus(null, elem, !1);
            })(mainDetailButtons),
          [item, user]
        );
      })
    );
  }
  function getItemWithMediaSource(instance, apiClient) {
    return (function (instance, apiClient) {
      var options;
      return (instance = instance.params).seriesTimerId
        ? apiClient.getLiveTvSeriesTimer(instance.seriesTimerId)
        : instance.timerId
        ? apiClient.getLiveTvTimer(instance.timerId)
        : ((options = {}),
          "true" === instance.asSeries
            ? (options.AsSeries = !0)
            : (options.Fields = "ShareLevel"),
          apiClient.getItem(
            apiClient.getCurrentUserId(),
            instance.id,
            options,
          ));
    })(instance, apiClient).then(function (item) {
      var playbackMediaSourcesPromise = isRenderingTrackSelections(item)
        ? _playbackmanager.default.getPlaybackMediaSources(item)
        : Promise.resolve([]);
      return playbackMediaSourcesPromise.then(function (mediaSources) {
        return { item: item, mediaSources: mediaSources };
      });
    });
  }
  function startDataLoad(instance) {
    var params = instance.params,
      apiClient = _connectionmanager.default.getApiClient(params.serverId),
      params = Promise.all([
        getItemWithMediaSource(instance, apiClient),
        apiClient.getCurrentUser(),
      ]).then(onDataFetched.bind(instance), function (err) {
        return (
          console.log("error loading item: " + err),
          (function (instance, apiClient) {
            (instance = instance.view)
              .querySelector(".details-additionalContent")
              .classList.add("hide"),
              (html = "<div><p>Content no longer available.</p>");
            var apiClient = _approuter.default.getRouteUrl("home", {
                serverId: apiClient.serverId(),
              }),
              html =
                (html +=
                  '<a href="' +
                  apiClient +
                  '" is="emby-linkbutton" class="raised btnHomeItemNotFound">') +
                _globalize.default.translate("Home") +
                "</a></div>";
            (instance.querySelector(".detailMainContainer").innerHTML = html),
              _focusmanager.default.focus(
                instance.querySelector(".btnHomeItemNotFound"),
              );
          })(instance, apiClient),
          Promise.reject(err)
        );
      });
    instance.dataPromise = params;
  }
  function playCurrentItem(instance, mode) {
    var item;
    _multiselect.default.canPlay()
      ? _multiselect.default.play()
      : ((item = instance.currentItem),
        ((instance = (function (view, startPositionTicks) {
          var audioStreamIndex =
            view.querySelector(".selectAudio").value || null;
          return {
            startPositionTicks: startPositionTicks,
            mediaSourceId: view.querySelector(".selectSource").value,
            audioStreamIndex: audioStreamIndex,
            subtitleStreamIndex: view.querySelector(".selectSubtitles").value,
          };
        })(
          instance.view,
          item.UserData && "resume" === mode ? null : 0,
        )).items = [item]),
        _playbackmanager.default.play(instance));
  }
  function onPlayClick(e) {
    playCurrentItem(this, e.currentTarget.getAttribute("data-mode"));
  }
  function onEdited() {
    reloadItem(this, !0);
  }
  function onEditCancel() {}
  function onEditMetadataClick() {
    var currentItem = this.currentItem,
      instance = this;
    require(["metadataEditor"]).then(function (responses) {
      return new responses[0]()
        .show(currentItem.Id, currentItem.ServerId)
        .then(onEdited.bind(instance), onEditCancel);
    });
  }
  function onEditImagesClick() {
    var currentItem = this.currentItem,
      instance = this;
    require(["imageEditor"], function (imageEditor) {
      imageEditor
        .show({ itemId: currentItem.Id, serverId: currentItem.ServerId })
        .then(onEdited.bind(instance), onEditCancel);
    });
  }
  function onDeleteClick() {
    var currentItem = this.currentItem;
    _itemmanager.default.deleteItems({
      items: [currentItem],
      navigate: "back",
    });
  }
  function onDownloadChange() {
    reloadItem(this, !0);
  }
  function splitVersions(instance, page, apiClient, params) {
    var options;
    (options =
      "Are you sure you wish to split the media sources into separate items?"),
      Emby.importModule("./modules/common/dialogs/confirm.js")
        .then(function (confirm) {
          return confirm(options);
        })
        .then(function () {
          _loading.default.show(),
            apiClient.ungroupVersions(params.id).then(function () {
              _loading.default.hide(), reloadItem(instance, !0);
            });
        });
  }
  function onReadMoreClick(e) {
    var options,
      e = e.currentTarget
        .closest(".overview-container")
        .querySelector(".overview-text");
    (options = {
      html: e.innerHTML,
      confirmButton: !1,
      title:
        _itemmanager.default.getDisplayName(this.currentItem) ||
        this.currentItem.Name,
      centerText: !1,
      item: this.currentItem,
    }),
      Emby.importModule("./modules/common/dialogs/alert.js").then(
        function (alert) {
          return alert(options);
        },
      );
  }
  function onPromiseRejected(e) {
    console.log("itemContextMenu close: " + e);
  }
  function getSortMenuOptions(item) {
    var options = [];
    return (
      options.push({
        name:
          "Playlist" === item.Type
            ? _globalize.default.translate("PlaylistOrder")
            : "BoxSet" === item.Type
            ? _globalize.default.translate("CollectionOrder")
            : _globalize.default.translate("Default"),
        value: "default",
        defaultSortOrder: "Ascending",
      }),
      options.push({
        name: _globalize.default.translate("Album"),
        value: "Album,ParentIndexNumber,IndexNumber",
        defaultSortOrder: "Ascending",
      }),
      "Playlist" === item.Type &&
        options.push({
          name: _globalize.default.translate("AlbumArtist"),
          value: "AlbumArtist,Album,ParentIndexNumber,IndexNumber,SortName",
          defaultSortOrder: "Ascending",
        }),
      options.push({
        name: _globalize.default.translate("Artist"),
        value: "Artist,Album,ParentIndexNumber,IndexNumber,SortName",
        defaultSortOrder: "Ascending",
      }),
      options.push({
        name: _globalize.default.translate("Runtime"),
        value: "Runtime,SortName",
        defaultSortOrder: "Ascending",
      }),
      options.push({
        name: _globalize.default.translate("Title"),
        value: "SortName",
        defaultSortOrder: "Ascending",
      }),
      options.push({
        name: _globalize.default.translate("Year"),
        value: "ProductionYear,SortName",
        defaultSortOrder: "Descending",
      }),
      options
    );
  }
  function getSortMenuOption(sortMenuOptions, sortBy) {
    for (var i = 0, length = sortMenuOptions.length; i < length; i++) {
      var option = sortMenuOptions[i];
      if (option.value === sortBy) return option;
    }
    return null;
  }
  function setSortLabelText() {
    var item = this.currentItem,
      sortItems = getSortMenuOptions(item),
      view = this.view,
      sortItems = getSortMenuOption(
        sortItems,
        _usersettings.default.itemSortBy(item.Id) || "default",
      ),
      item = view.querySelector(".btnSortItems");
    item.setAttribute(
      "title",
      _globalize.default.translate("SortByValue", sortItems.name),
    ),
      item.setAttribute(
        "aria-label",
        _globalize.default.translate("SortByValue", sortItems.name),
      ),
      (item.querySelector(".btnSortText").innerHTML =
        _globalize.default.translate("HeaderSortBy"));
  }
  function sortItem(instance, item, options) {
    var currentValues = {
        sortBy: _usersettings.default.itemSortBy(item.Id),
        sortOrder: _usersettings.default.itemSortOrder(item.Id),
      },
      sortItems = getSortMenuOptions(item);
    return (
      (function (options, currentValues) {
        for (var i = 0, length = options.length; i < length; i++) {
          var opt = options[i];
          if (
            ((opt.selected = opt.value === (currentValues.sortBy || "default")),
            opt.selected)
          ) {
            var icon =
              "Descending" === currentValues.sortOrder
                ? "&#xE5DB;"
                : "&#xE5D8;";
            opt.asideIcon = icon;
            break;
          }
        }
      })(sortItems, currentValues),
      (function (options) {
        return Emby.importModule("./modules/actionsheet/actionsheet.js").then(
          function (ActionSheet) {
            return ActionSheet.show(options);
          },
        );
      })({
        items: sortItems,
        positionTo: options.positionTo,
        positionY: options.positionY,
        positionX: options.positionX,
        positionClientY: options.positionClientY,
        positionClientX: options.positionClientX,
        transformOrigin: options.transformOrigin,
        title: _globalize.default.translate("HeaderSortBy"),
        offsetTop: 2,
        hasItemAsideIcon: !0,
        hasItemSelectionState: !0,
      }).then(function (value) {
        var sortOrder;
        sortOrder ||
          ((sortOrder = currentValues.sortOrder),
          (sortOrder =
            currentValues.sortBy === value
              ? "Ascending" === sortOrder
                ? "Descending"
                : "Ascending"
              : (function (sortMenuOptions, sortBy) {
                  if (sortBy) {
                    sortMenuOptions = getSortMenuOption(
                      sortMenuOptions,
                      sortBy,
                    );
                    if (
                      sortMenuOptions &&
                      sortMenuOptions.value === sortBy &&
                      sortMenuOptions.defaultSortOrder
                    )
                      return sortMenuOptions.defaultSortOrder;
                  }
                  return "Descending";
                })(sortItems, value))),
          _usersettings.default.itemSortBy(item.Id, value),
          _usersettings.default.itemSortOrder(item.Id, sortOrder);
      })
    );
  }
  function getMusicArtistChildrenListOptions(items) {
    return {
      renderer: _cardbuilder.default,
      options: {
        shape: "auto",
        scalable: !0,
        centerText: !0,
        fields: ["Name", "ProductionYear"],
        overlayText: !1,
        focusTransformTitleAdjust: !0,
      },
      virtualScrollLayout: "horizontal-grid",
    };
  }
  function getSeasons(query) {
    var item = this.currentItem,
      apiClient = _connectionmanager.default.getApiClient(item),
      fields =
        this.getRequestedItemFields() + ",PrimaryImageAspectRatio,Overview";
    return apiClient.getSeasons(
      item.Id,
      Object.assign(
        { UserId: apiClient.getCurrentUserId(), Fields: fields },
        query,
      ),
    );
  }
  function getPlaylistListOptionsFn(item) {
    return function (items) {
      var fields = [],
        items =
          (fields.push("ParentName"),
          fields.push("Name"),
          (function (items) {
            for (var i = 0, length = items.length; i < length; i++)
              if (items[i].Overview) return !0;
            return !1;
          })(items)),
        enableSideMediaInfo = !0,
        sortBy =
          (items && (fields.push("Overview"), (enableSideMediaInfo = !1)),
          _usersettings.default.itemSortBy(item.Id) || "default"),
        sortOrder = (sortBy = "default" === sortBy ? "ListItemOrder" : sortBy)
          ? _usersettings.default.itemSortOrder(item.Id)
          : null;
      return {
        renderer: _listview.default,
        options: {
          showIndexNumberLeft: "MusicAlbum" === item.Type,
          action: "playallfromhere",
          dragHandle:
            "Playlist" === item.Type &&
            !_layoutmanager.default.tv &&
            "ListItemOrder" === sortBy &&
            "Ascending" === sortOrder,
          playlistId: "Playlist" === item.Type ? item.Id : null,
          image: "Playlist" === item.Type,
          artist: "auto",
          showIndex: "MusicAlbum" === item.Type,
          autoHideArtist: "MusicAlbum" === item.Type,
          index: "disc",
          containerAlbumArtists:
            "MusicAlbum" === item.Type ? item.AlbumArtists : null,
          fields: fields,
          playAction: "playallfromhere",
          itemClass: "detailsListItem",
          enableSideMediaInfo: enableSideMediaInfo,
          imageSize: items ? "medium" : null,
          autoMoveParentName: !0,
        },
        virtualScrollLayout: "vertical-list",
        commandOptions: { openAlbum: "MusicAlbum" !== item.Type },
      };
    };
  }
  function scrollEpisodesToSeason(instance, seasonId) {
    var apiClient,
      seriesId,
      itemsContainer = instance.view.querySelector(".childrenItemsContainer");
    itemsContainer &&
      ((instance = instance.currentItem),
      (apiClient = _connectionmanager.default.getApiClient(instance)),
      (seriesId = instance.Id),
      apiClient
        .getEpisodes(seriesId, {
          SeasonId: seasonId,
          UserId: apiClient.getCurrentUserId(),
          EnableImages: !1,
          EnableUserData: !1,
          Limit: 1,
          TotalRecordCount: !1,
        })
        .then(function (result) {
          var startItem = result.Items[0];
          startItem &&
            (-1 !== (result = itemsContainer.indexOfItemId(startItem.Id))
              ? itemsContainer.scrollToIndex(
                  result,
                  { offset: "-padding-inline-start" },
                  !1,
                )
              : apiClient
                  .getEpisodes(seriesId, {
                    UserId: apiClient.getCurrentUserId(),
                    EnableTotalRecordCount: !1,
                    EnableImages: !1,
                    EnableUserData: !1,
                  })
                  .then(function (totalResult) {
                    for (
                      var i = 0, length = totalResult.Items.length;
                      i < length;
                      i++
                    )
                      if (totalResult.Items[i].Id === startItem.Id) {
                        itemsContainer.scrollToIndex(
                          i,
                          { offset: "-padding-inline-start" },
                          !1,
                        );
                        break;
                      }
                  }));
        }));
  }
  function onSeriesEpisodeFocusedOrScrolled(instance, item) {
    var detailSelectSeason,
      item = (function (instance, item) {
        if (
          ((instance = instance.seasonItems || []),
          item.SeasonId && 0 !== item.ParentIndexNumber)
        ) {
          var season = instance.filter(function (s) {
            return s.Id === item.SeasonId;
          })[0];
          if (season) return season;
        }
        var seasonNumber =
          null == item.SortParentIndexNumber
            ? item.ParentIndexNumber
            : item.SortParentIndexNumber;
        if (null != seasonNumber) {
          season = instance.filter(function (s) {
            return s.IndexNumber === seasonNumber;
          })[0];
          if (season) return season;
        }
        if (item.SeasonId) {
          season = instance.filter(function (s) {
            return s.Id === item.SeasonId;
          })[0];
          if (season) return season;
        }
        return null;
      })(instance, item);
    item &&
      ((detailSelectSeason = instance.detailSelectSeason) &&
        detailSelectSeason.setValues([item.Id], !1, [item]),
      (detailSelectSeason = instance.seasonTabs)) &&
      (instance = detailSelectSeason.querySelector(
        '.detailSeasonTab[data-id="' + item.Id + '"]',
      )) &&
      detailSelectSeason.selectedIndex(
        parseInt(instance.getAttribute("data-index")),
        !1,
      );
  }
  function getAppearsOnListsListOptions(items) {
    return {
      renderer: _cardbuilder.default,
      options: {
        shape: "autooverflow",
        centerText: !0,
        fields: ["Name"],
        overlayText: !1,
        focusTransformTitleAdjust: !0,
      },
      virtualScrollLayout: "horizontal-grid",
    };
  }
  function getArtistSongsListOptions(items) {
    return {
      renderer: _cardbuilder.default,
      options: {
        shape: "auto",
        lines: 2,
        centerText: !1,
        fields: ["Name", "Album"],
        overlayPlayButton: !0,
        overlayText: !1,
        sideFooter: !0,
        action: "play",
      },
      virtualScrollLayout: "horizontal-grid",
      commandOptions: { openArtist: !1 },
    };
  }
  function getPeopleListOptions(items) {
    return {
      renderer: _cardbuilder.default,
      options: {
        cardLayout: !1,
        centerText: !0,
        fields: ["Name", "PersonRole"],
        cardFooterAside: !1,
        showPersonRoleOrType: !0,
        multiSelect: !1,
        coverImage: !0,
        shape: "portrait",
        draggable: !1,
        focusTransformTitleAdjust: !0,
      },
      virtualScrollLayout: "horizontal-grid",
    };
  }
  function getMoreLikeThisOnLiveTVListOptions(items) {
    return {
      renderer: _cardbuilder.default,
      options: {
        shape: "auto",
        fields: ["ParentName", "Name", "ProductionYear"],
        centerText: !0,
        showDetailsMenu: !0,
        overlayPlayButton: !0,
        overlayText: !1,
        lines: 2,
        draggable: !1,
        multiSelect: !1,
        focusTransformTitleAdjust: !0,
      },
      virtualScrollLayout: "horizontal-grid",
    };
  }
  function getNextUpItems(query) {
    var item = this.currentItem,
      apiClient = _connectionmanager.default.getApiClient(item);
    return "MusicAlbum" === item.Type
      ? apiClient.getNextUpAudioBookItems(
          Object.assign(
            {
              AlbumId: item.Id,
              Fields:
                this.getRequestedItemFields() + ",PrimaryImageAspectRatio",
              ImageTypeLimit: 1,
              UserId: apiClient.getCurrentUserId(),
            },
            query,
          ),
        )
      : apiClient.getNextUpEpisodes(
          Object.assign(
            {
              SeriesId: item.Id,
              Fields:
                this.getRequestedItemFields() + ",PrimaryImageAspectRatio",
              ImageTypeLimit: 1,
              UserId: apiClient.getCurrentUserId(),
            },
            query,
          ),
        );
  }
  function getAdditionalPartsListOptions(items) {
    return {
      renderer: _cardbuilder.default,
      options: {
        shape: "autooverflow",
        scalable: !0,
        fields: ["Name", "Runtime"],
        action: "playallfromhere",
        centerText: !0,
        overlayText: !1,
        draggable: !1,
        focusTransformTitleAdjust: !0,
      },
      virtualScrollLayout: "horizontal-grid",
    };
  }
  function getExtrasListOptions(items) {
    return {
      renderer: _cardbuilder.default,
      options: {
        shape: "autooverflow",
        scalable: !0,
        fields: ["Name", "Runtime"],
        centerText: !0,
        overlayText: !1,
        draggable: !1,
        focusTransformTitleAdjust: !0,
      },
      virtualScrollLayout: "horizontal-grid",
    };
  }
  function getProgramGuideListOptions(items) {
    return {
      renderer: _listview.default,
      options: {
        imageSize: "large",
        enableUserDataButtons: !1,
        mediaInfo: !0,
        mediaInfoWithTitle: !0,
        draggable: !1,
        multiSelect: !1,
        defaultShape: "portrait",
        itemClass: "detailsListItem",
        fields: ["ParentName", "Name", "StartToEndDateTime", "Overview"],
        highlight: !1,
      },
      virtualScrollLayout: "vertical-grid",
    };
  }
  function getSeriesTimerListOptions(items) {
    return {
      renderer: _listview.default,
      options: {
        enableUserDataButtons: !1,
        image: !0,
        mediaInfo: !1,
        imageSize: "large",
        moreButton: !1,
        recordButton: !1,
        draggable: !1,
        multiSelect: !1,
        itemClass: "detailsListItem",
        fields: [
          "ParentName",
          "Name",
          "StartToEndDateTime",
          "ChannelName",
          "Overview",
        ],
        highlight: !1,
      },
      virtualScrollLayout: "vertical-grid",
    };
  }
  function enableTvDetailImageLayout(item) {
    if (_layoutmanager.default.tv) {
      switch (item.Type) {
        case "Series":
        case "Season":
        case "Audio":
        case "Program":
          return !0;
        case "BoxSet":
        case "TvChannel":
        case "Playlist":
        case "MusicAlbum":
        case "MusicArtist":
          return !1;
      }
      switch (item.MediaType) {
        case "Video":
        case "Photo":
        case "Game":
        case "Book":
          return !0;
      }
    }
    return !1;
  }
  function afterDetailImageRefreshed() {
    var detailImageElement = this.querySelector(".detailImage");
    detailImageElement &&
      (this.querySelector(".cardImageIcon")
        ? detailImageElement.classList.remove("detailImage-transparent")
        : detailImageElement.classList.add("detailImage-transparent"));
  }
  function getChaptersListOptions(items) {
    return {
      renderer: _cardbuilder.default,
      options: {
        shape: "autooverflow",
        centerText: !0,
        overlayText: !1,
        fields: ["Name", "ChapterTime"],
        multiSelect: !1,
        contextMenu: !1,
        playedButton: !1,
        ratingButton: !1,
        action: "play",
        enableUserData: !1,
        draggable: !1,
        background: "black",
        focusTransformTitleAdjust: !0,
      },
      virtualScrollLayout: "horizontal-grid",
    };
  }
  function getMoreFromSeasonListOptions(items) {
    return {
      renderer: _cardbuilder.default,
      options: {
        shape: "auto",
        scalable: !0,
        fields: ["Name"],
        overlayText: !1,
        centerText: !0,
        includeParentInfoInTitle: !1,
        focusTransformTitleAdjust: !0,
      },
      virtualScrollLayout: "horizontal-grid",
    };
  }
  function getMoreFromArtistListOptions(items) {
    return {
      renderer: _cardbuilder.default,
      options: {
        shape: "auto",
        scalable: !0,
        fields: ["Name", "ProductionYear"],
        centerText: !0,
        overlayText: !1,
        overlayPlayButton: !0,
        focusTransformTitleAdjust: !0,
      },
      virtualScrollLayout: "horizontal-grid",
    };
  }
  function onPromiseFailure() {}
  function reloadItem(instance, reloadAllData, restartDataLoad) {
    !reloadAllData ||
      (instance.dataPromise && !1 === restartDataLoad) ||
      startDataLoad(instance),
      instance.dataPromise.then(function (responses) {
        var trackList,
          item = responses[0],
          responses = responses[1],
          apiClient = _connectionmanager.default.getApiClient(item.ServerId),
          view = instance.view;
        !(function (view, refreshData) {
          for (
            var containers = view.querySelectorAll(".generalItemsContainer"),
              i = 0,
              length = containers.length;
            i < length;
            i++
          )
            containers[i].resume({ refresh: refreshData });
        })(view, reloadAllData),
          "Season" === item.Type &&
            (trackList = view.querySelector(".trackList")) &&
            trackList.resume({ refresh: reloadAllData }).then(function () {
              !(function (element) {
                var items = element.getItems(),
                  focusItem = items.filter(function (i) {
                    return !i.UserData || !i.UserData.Played;
                  })[0];
                if ((focusItem = focusItem || items[0])) {
                  items = element.indexOfItemId(focusItem.Id);
                  if (-1 !== items)
                    return element.scrollToIndex(items, {}, !0), 1;
                }
              })(trackList) &&
                _focusmanager.default.autoFocus(view, { skipIfNotEnabled: !0 });
            }),
          reloadAllData &&
            (renderPeopleItems(view, item, apiClient),
            (function (view, item, user, apiClient) {
              "SeriesTimer" === item.Type &&
                (user.Policy.EnableLiveTvManagement
                  ? (require(["seriesRecordingEditor"], function (
                      seriesRecordingEditor,
                    ) {
                      seriesRecordingEditor.embed(item, apiClient.serverId(), {
                        context: view.querySelector(".recordingEditor"),
                      });
                    }),
                    view
                      .querySelector(".seriesTimerScheduleSection")
                      .classList.remove("hide"),
                    view
                      .querySelector(".btnCancelSeriesTimer")
                      .classList.remove("hide"))
                  : (view
                      .querySelector(".seriesTimerScheduleSection")
                      .classList.add("hide"),
                    view
                      .querySelector(".btnCancelSeriesTimer")
                      .classList.add("hide")));
            })(view, item, responses, apiClient),
            (function (instance, view, item, user, apiClient) {
              ("Timer" === item.Type ||
                ("Recording" === item.Type &&
                  item.TimerId &&
                  "InProgress" === item.Status)) &&
              user.Policy.EnableLiveTvManagement
                ? (hideAll(view, "btnCancelTimer", !0),
                  require(["recordingEditor"], function (RecordingEditor) {
                    RecordingEditor = new RecordingEditor();
                    (instance.recordingEditor = RecordingEditor).embed(
                      item,
                      apiClient.serverId(),
                      { context: view.querySelector(".recordingEditor") },
                    );
                  }))
                : hideAll(view, "btnCancelTimer");
            })(instance, view, item, responses, apiClient),
            (function (page, item) {
              var page = page.querySelector(".linksSection"),
                links = [];
              if (
                item.ExternalUrls &&
                _servicelocator.appHost.supports("externallinks") &&
                !_layoutmanager.default.tv
              )
                for (
                  var i = 0, length = item.ExternalUrls.length;
                  i < length;
                  i++
                ) {
                  var url = item.ExternalUrls[i];
                  links.push(
                    '<a is="emby-linkbutton" class="raised item-tag-button nobackdropfilter" href="' +
                      url.Url +
                      '" target="_blank"><i class="md-icon button-icon button-icon-left">link</i>' +
                      _textencoding.default.htmlEncode(url.Name) +
                      "</a>",
                  );
                }
              (page.querySelector(".itemLinks").innerHTML = links.join("")),
                links.length
                  ? page.classList.remove("hide")
                  : page.classList.add("hide");
            })(view, item),
            view
              .querySelector(".audioVideoMediaInfo")
              .classList.remove("mediainfo-forcehide"),
            view
              .querySelector(".details-additionalContent")
              .classList.remove("hide"),
            focusMainSection.call(instance.mainSection)),
          (function (instance, eventName, item) {
            instance.itemShowDispatched ||
              ((instance.itemShowDispatched = !0),
              instance.view.dispatchEvent(
                new CustomEvent(eventName, {
                  detail: { item: item },
                  bubbles: !0,
                  cancelable: !1,
                }),
              ));
          })(instance, "itemshow", item),
          _loading.default.hide();
      }, onPromiseFailure);
  }
  function addClass(elems, className) {
    for (var i = 0, length = elems.length; i < length; i++)
      elems[i].classList.add(className);
  }
  function setScopedFocus(view, query, enabled, type) {
    view = "string" == typeof query ? view.querySelector(query) : query;
    enabled
      ? (view.classList.add("focusable"),
        view.setAttribute("data-focusabletype", type || "autofocus"))
      : (view.classList.remove("focusable"),
        view.removeAttribute("data-focusabletype"));
  }
  function updateTrackSelectionsFocusState(instance, view) {
    var instance = instance.trackSelectionsContainer,
      isEnabled = instance.querySelector("select:enabled:not(.noSelections)");
    setScopedFocus(view, instance, isEnabled, "nearest");
  }
  var drawerElement = document.querySelector(".mainDrawer");
  function onNavDrawerStateChange(e, drawerState) {
    2 <= drawerState && _backdrop.default.hasBackdrop()
      ? drawerElement.classList.add("darkContentContainer")
      : drawerElement.classList.remove("darkContentContainer");
  }
  function ItemPage(view, params) {
    _baseview.default.apply(this, arguments),
      (this.params = params),
      (this.playerChangeFn = function () {
        var view = this.view,
          item = this.currentItem;
        view && item && renderTrackSelectionsWithoutUser(view, this, item);
      }.bind(this)),
      (this.playbackStopFn = function (e, stopInfo) {
        var state = stopInfo.state || {};
        state.NextMediaType ||
          state.IsBackgroundPlayback ||
          (null != (stopInfo = stopInfo.player) &&
            stopInfo.isLocalPlayer &&
            !_usersettings.default.enableVideoUnderUI() &&
            ((stopInfo = state.NowPlayingItem || {}),
            (this.currentItem || {}).MediaType === stopInfo.MediaType) &&
            stopInfo.MediaType &&
            "Episode" === stopInfo.Type &&
            (this.showItemOnResume = stopInfo));
      }.bind(this)),
      (this.onNavDrawerStateChangeFn = onNavDrawerStateChange.bind(this)),
      (this.topDetailsContainer = view.querySelector(".topDetailsContainer")),
      (this.mainSection = view.querySelector(".detailMainContainer")),
      (this.trackSelectionsContainer = view.querySelector(".trackSelections")),
      _layoutmanager.default.tv
        ? addClass(
            view.querySelectorAll(".reduce-font-size-tv"),
            "reduce-font-size",
          )
        : (addClass(
            view.querySelectorAll(".detailTextContainer"),
            "details-largefont",
          ),
          addClass(
            view.querySelectorAll(".reduce-font-size-tv"),
            "reduce-font-size-mobile",
          )),
      (function (view, query, enabled, type) {
        for (
          var elems = view.querySelectorAll(query),
            i = 0,
            length = elems.length;
          i < length;
          i++
        )
          setScopedFocus(view, elems[i], enabled, type);
      })(view, ".focusable", !0, "nearest"),
      this.trackSelectionsContainer.addEventListener(
        "submit",
        onTrackSelectionsSubmit,
      ),
      bindAll(view, ".btnPlay", "click", onPlayClick.bind(this)),
      bindAll(view, ".btnResume", "click", onPlayClick.bind(this)),
      bindAll(
        view,
        ".btnShuffle",
        "click",
        function () {
          var currentItem = this.currentItem;
          _playbackmanager.default.shuffle(currentItem);
        }.bind(this),
      ),
      bindAll(
        view,
        ".btnPlayTrailer",
        "click",
        function () {
          var currentItem = this.currentItem;
          _playbackmanager.default.playTrailers(currentItem);
        }.bind(this),
      ),
      bindAll(
        view,
        ".btnCancelSeriesTimer",
        "click",
        function () {
          onDeleteClick.call(this);
        }.bind(this),
      ),
      bindAll(
        view,
        ".btnCancelTimer",
        "click",
        function () {
          var instance = this,
            item = this.currentItem,
            type = item.Type,
            serverId = item.ServerId,
            timerId = "Timer" === type ? item.Id : item.TimerId;
          require(["recordingHelper"], function (recordingHelper) {
            recordingHelper
              .cancelTimer(
                _connectionmanager.default.getApiClient(serverId),
                timerId,
              )
              .then(function () {
                reloadItem(instance, !0);
              });
          });
        }.bind(this),
      ),
      bindAll(view, ".btnDeleteItem", "click", onDeleteClick.bind(this)),
      bindAll(
        view,
        ".btnSyncDownload",
        "download",
        onDownloadChange.bind(this),
      ),
      bindAll(
        view,
        ".btnSyncDownload",
        "download-cancel",
        onDownloadChange.bind(this),
      ),
      bindAll(
        view,
        ".btnMoreCommands",
        "click",
        function (e) {
          var button = e.currentTarget,
            instance = this,
            e = this.params,
            e = _connectionmanager.default.getApiClient(e.serverId),
            currentItem = this.currentItem,
            view = this.view;
          e.getCurrentUser().then(function (user) {
            _itemcontextmenu.default
              .show(getCommandOptions(view, currentItem, user, button))
              .then(function (result) {
                ("addtoplaylist" !== result.command &&
                  "addtocollection" !== result.command) ||
                  reloadItem(instance, !0);
              }, onPromiseRejected);
          });
        }.bind(this),
      ),
      bindAll(
        view,
        ".btnSortItems",
        "click",
        function (e) {
          var e = e.currentTarget,
            instance = this;
          sortItem(0, instance.currentItem, {
            positionTo: e,
            positionY: "bottom",
          }).then(function () {
            reloadItem(instance, !0);
          });
        }.bind(this),
      ),
      bindAll(
        view,
        ".btnManageSeriesRecording",
        "click",
        function (e) {
          var item = this.currentItem;
          item.SeriesTimerId &&
            _approuter.default.showItem({
              Type: "SeriesTimer",
              Id: item.SeriesTimerId,
              ServerId: item.ServerId,
            });
        }.bind(this),
      ),
      bindAll(
        view,
        ".btnManageRecording",
        "click",
        function (e) {
          var item = this.currentItem;
          item.TimerId &&
            _approuter.default.showItem({
              Type: "Timer",
              Id: item.TimerId,
              ServerId: item.ServerId,
            });
        }.bind(this),
      ),
      this.mainSection.addEventListener(
        "focus",
        function (e) {
          _layoutmanager.default.tv &&
            !e.target.closest(
              ".btnReadMore,.recordingEditor,.btnOverviewText",
            ) &&
            this.view.scrollToBeginning();
        }.bind(this),
        !0,
      ),
      bindAll(
        view,
        ".btnSplitVersions",
        "click",
        function () {
          var params = this.params,
            apiClient = _connectionmanager.default.getApiClient(
              params.serverId,
            );
          splitVersions(this, this.view, apiClient, params);
        }.bind(this),
      ),
      bindAll(view, ".btnReadMore", "click", onReadMoreClick.bind(this)),
      bindAll(view, ".btnOverviewText", "click", onReadMoreClick.bind(this));
    var instance = this,
      onLibraryChangedFn =
        (view
          .querySelector(".selectSource")
          .addEventListener("change", function () {
            renderMediaInfo(
              0,
              view,
              instance.currentItem,
              instance._currentPlaybackMediaSources,
              _connectionmanager.default.getApiClient(instance.currentItem),
            ),
              renderVideoSelections(
                view,
                instance._currentPlaybackMediaSources,
              ),
              renderAudioSelections(
                view,
                instance._currentPlaybackMediaSources,
              ),
              renderSubtitleSelections(
                view,
                instance._currentPlaybackMediaSources,
              ),
              updateTrackSelectionsFocusState(instance, view);
          }),
        view.querySelector(".btnManualRecording").addEventListener(
          "click",
          function (e) {
            executeCommandWithCommandProcessor("record", this.currentItem, {
              positionTo: e.target,
            });
          }.bind(this),
        ),
        view.addEventListener(
          "viewbeforehide",
          function (e) {
            ((e = e.detail) &&
              e.newView &&
              e.newView.classList.contains("itemView")) ||
              (backgroundContainer.classList.remove(
                "itemBackgroundContainer",
                "itemBackgroundContainer-brighter",
                "itemBackgroundContainer-preventbackdrop",
              ),
              backdropContainer.classList.remove(
                "backdropContainer-preventbackdrop",
              ),
              skinHeader.classList.remove("detailHeader-noIcons"));
          }.bind(this),
        ),
        (this.onUserDataChangedFn = function (e, apiClient, userData) {
          var currentItem = this.currentItem,
            view = this.view;
          currentItem &&
            currentItem.Id === userData.ItemId &&
            ((currentItem.UserData = userData),
            this.paused || reloadPlayButtons(this, view, currentItem, !0));
        }.bind(this)),
        (this.onLibraryChangedFn = function (e, apiClient, data) {
          var currentItem = this.currentItem;
          currentItem &&
            null != (data = data.ItemsUpdated) &&
            data.includes(currentItem.Id) &&
            (this.paused
              ? (this._fullReloadOnResume = !0)
              : reloadItem(this, !0));
        }.bind(this)),
        (this.onTimerCancelledFn = function (e, apiClient, data) {
          var currentItem = this.currentItem;
          currentItem &&
            currentItem.Id === data.Id &&
            !this.paused &&
            _approuter.default.back();
        }.bind(this)),
        _events.default.on(
          _navdrawer.default,
          "drawer-state-change",
          this.onNavDrawerStateChangeFn,
        ),
        this.onLibraryChangedFn),
      onLibraryChangedFn =
        (onLibraryChangedFn &&
          _events.default.on(
            _api.default,
            "LibraryChanged",
            onLibraryChangedFn,
          ),
        this.onUserDataChangedFn),
      onLibraryChangedFn =
        (onLibraryChangedFn &&
          _events.default.on(
            _api.default,
            "UserDataChanged",
            onLibraryChangedFn,
          ),
        this.onTimerCancelledFn);
    onLibraryChangedFn &&
      _events.default.on(_api.default, "TimerCancelled", onLibraryChangedFn);
  }
  Object.assign(ItemPage.prototype, _baseview.default.prototype),
    (ItemPage.prototype.onInputCommand = function (e) {
      var command = e.detail.command;
      switch (command) {
        case "play":
          return (
            playCurrentItem(this, "resume"),
            e.preventDefault(),
            void e.stopPropagation()
          );
        case "delete":
          return (
            onDeleteClick.call(this),
            e.preventDefault(),
            void e.stopPropagation()
          );
        case "record":
          return (
            executeCommandWithCommandProcessor(command, this.currentItem, {
              positionTo: e.target,
            }),
            e.preventDefault(),
            void e.stopPropagation()
          );
      }
      _baseview.default.prototype.onInputCommand.apply(this, arguments);
    }),
    (ItemPage.prototype.onBeginResume = function (options) {
      _baseview.default.prototype.onBeginResume.apply(this, arguments),
        _layoutmanager.default.tv
          ? skinHeader.classList.add("detailHeader-noIcons")
          : skinHeader.classList.remove("detailHeader-noIcons"),
        startDataLoad(this);
    }),
    (ItemPage.prototype.onResume = function (options) {
      this.showItemOnResume &&
        ((newItem = this.showItemOnResume),
        _approuter.default.replaceState(
          _approuter.default.getRouteUrl(newItem, {}),
          {},
          !0,
        ),
        (this.showItemOnResume = null)),
        _baseview.default.prototype.onResume.apply(this, arguments),
        (this.itemShowDispatched = null);
      var newItem = this.view,
        onPlayerChangeFn = this.playerChangeFn,
        onPlayerChangeFn =
          (onPlayerChangeFn &&
            _events.default.on(
              _playbackmanager.default,
              "playerchange",
              onPlayerChangeFn,
            ),
          this.playbackStopFn),
        onPlayerChangeFn =
          (onPlayerChangeFn &&
            _events.default.on(
              _playbackmanager.default,
              "playbackstop",
              onPlayerChangeFn,
            ),
          options.refresh || this._fullReloadOnResume);
      (this._fullReloadOnResume = !1),
        reloadItem(this, onPlayerChangeFn, !1),
        onPlayerChangeFn ||
          (renderTrackSelectionsWithoutUser(
            newItem,
            this,
            (onPlayerChangeFn = this.currentItem),
            !0,
          ),
          setTrailerButtonVisibility(newItem, onPlayerChangeFn)),
        (this._fullReloadOnResume = !1),
        this.updateDrawerState();
    }),
    (ItemPage.prototype.updateDrawerState = function () {
      onNavDrawerStateChange.call(this, {}, _navdrawer.default.drawerState);
    }),
    (ItemPage.prototype.onPause = function (options) {
      _baseview.default.prototype.onPause.apply(this, arguments);
      for (
        var onPlayerChangeFn = this.playerChangeFn,
          onPlayerChangeFn =
            (onPlayerChangeFn &&
              _events.default.off(
                _playbackmanager.default,
                "playerchange",
                onPlayerChangeFn,
              ),
            this.playbackStopFn),
          onPlayerChangeFn =
            (onPlayerChangeFn &&
              _events.default.off(
                _playbackmanager.default,
                "playbackstopped",
                onPlayerChangeFn,
              ),
            this.onNavDrawerStateChangeFn &&
              _events.default.off(
                _navdrawer.default,
                "drawer-state-change",
                this.onNavDrawerStateChangeFn,
              ),
            this.view),
          containers = onPlayerChangeFn.querySelectorAll(
            ".generalItemsContainer",
          ),
          i = 0,
          length = containers.length;
        i < length;
        i++
      )
        containers[i].pause();
      (null != (onPlayerChangeFn = options.event) &&
        null != (onPlayerChangeFn = onPlayerChangeFn.detail) &&
        onPlayerChangeFn.newView.classList.contains("itemView")) ||
        drawerElement.classList.remove("darkContentContainer"),
        this.recordingEditor && this.recordingEditor.pause();
    }),
    (ItemPage.prototype.enableTransitions = function () {
      return !0;
    }),
    (ItemPage.prototype.destroy = function () {
      var onLibraryChangedFn = this.onLibraryChangedFn,
        onLibraryChangedFn =
          (onLibraryChangedFn &&
            _events.default.off(
              _api.default,
              "LibraryChanged",
              onLibraryChangedFn,
            ),
          (this.onLibraryChangedFn = null),
          this.onUserDataChangedFn),
        onLibraryChangedFn =
          (onLibraryChangedFn &&
            _events.default.off(
              _api.default,
              "UserDataChanged",
              onLibraryChangedFn,
            ),
          (this.onUserDataChangedFn = null),
          this.onTimerCancelledFn);
      onLibraryChangedFn &&
        _events.default.off(_api.default, "TimerCancelled", onLibraryChangedFn),
        (this.onTimerCancelledFn = null),
        _baseview.default.prototype.destroy.apply(this, arguments),
        (this.onNavDrawerStateChangeFn = null),
        (this.playerChangeFn = null),
        (this.playbackStopFn = null),
        (this.currentItem = null),
        (this._currentPlaybackMediaSources = null),
        this.currentRecordingFields &&
          (this.currentRecordingFields.destroy(),
          (this.currentRecordingFields = null)),
        this.recordingEditor &&
          (this.recordingEditor.destroy(), (this.recordingEditor = null)),
        (this.topDetailsContainer = null),
        (this.mainSection = null),
        (this.trackSelectionsContainer = null),
        (this.detailSelectSeason = null),
        (this.seasonTabs = null),
        (this.seasonItems = null),
        (this.params = null),
        (this.dataPromise = null);
    }),
    (_exports.default = ItemPage);
});
