import itemManager from"./../../modules/common/itemmanager/itemmanager.js";import globalize from"./../../modules/common/globalize.js";import{appHost}from"./../../modules/common/servicelocator.js";import ImageOptionsEditor from"./../imageoptionseditor/imageoptionseditor.js";import"./../../modules/emby-elements/emby-scroller/emby-scroller.js";import"./../../modules/emby-elements/emby-input/emby-input.js";import"./../../modules/emby-elements/emby-select/emby-select.js";import"./../../modules/emby-elements/emby-checkbox/emby-checkbox.js";import"./../../modules/emby-elements/emby-itemscontainer/emby-itemscontainer.js";import listView from"./../../modules/listview/listview.js";import layoutManager from"./../../modules/layoutmanager.js";let currentLibraryOptions,currentAvailableOptions;function getSelectLanguages(query){var apiClient=ApiClient;let select=this;return apiClient.getCultures().then(function(cultures){let selectedValues=select.values,items=(Array.isArray(selectedValues)||(selectedValues=selectedValues?.split?selectedValues.split(","):[]),cultures.map(function(c){return{Name:c.DisplayName,Id:c.TwoLetterISOLanguageName,Type:"GenericListItem"}}));items.sort(function(a,b){let aIndex=selectedValues.indexOf(a.Id),bIndex=selectedValues.indexOf(b.Id);return aIndex<0&&(aIndex=items.length),bIndex<0&&(bIndex=items.length),aIndex===bIndex?0:aIndexquery.Limit&&(items.length=Math.min(items.length,query.Limit)),{TotalRecordCount:cultures,Items:items}})}function populateLanguages(parent){return ApiClient.getCultures().then(function(languages){populateLanguagesIntoSelect(parent.querySelector(".selectLanguage"),languages),populateLanguagesIntoSelect(parent.querySelector(".selectImageLanguage"),languages)})}function populateLanguagesIntoSelect(select,languages){let html="";html+="";for(let i=0,length=languages.length;i"+culture.DisplayName+""}select.innerHTML=html}function populateCountries(select){return ApiClient.getCountries().then(function(allCountries){let html="";html+="";for(let i=0,length=allCountries.length;i"+culture.DisplayName+""}select.innerHTML=html})}function populateRefreshInterval(select,interval){var html="",html=(html+="")+interval.map(function(val){return""}).join("");select.innerHTML=html}function populateMaxDownloadAge(select){var html="",html=(html+="")+[14,30,60,90,120,180].map(function(val){return""}).join("");select.innerHTML=html}function refreshItemsContainer(itemsContainer){return itemsContainer.waitForCustomElementUpgrade().then(function(){itemsContainer.resume({refresh:!0})})}function refreshItemsContainers(page){var promises=[],itemsContainers=page.querySelectorAll(".itemsContainer");for(let i=0,length=itemsContainers.length;i').replace("{1}",""):tvdbText.replace("{0}","").replace("{1}",""),shortOverviewHtml=tvdbText}return{Type:"GenericListItem",Name:i.Name,Icon:"folder",DeleteType:"remove",OriginalItem:i,CanReorder:!0,ShortOverviewHtml:shortOverviewHtml}});for(let i=0,length=items.length;i'+globalize.translate("HeaderMetadataSavers"))+'
';for(let i=0,length=metadataSavers.length;i"+plugin.Name+""}return html=(html+="
")+('
'+globalize.translate("LabelMetadataSaversHelp")+"
"),page.innerHTML=html,page.classList.remove("hide"),!0}function getMetadataFetchersForTypeHtml(availableTypeOptions,libraryOptionsForType){var html="";return getOrderedPlugins(availableTypeOptions.MetadataFetchers||[],libraryOptionsForType.MetadataFetcherOrder||[]).length?'

'+globalize.translate("HeaderTypeMetadataDownloaders",itemManager.getItemTypeName(availableTypeOptions.Type))+'

'+globalize.translate("LabelMetadataDownloadersHelp")+'

':""}function getTypeOptions(allOptions,type,createIfNotFound){var allTypeOptions=allOptions.TypeOptions||[];for(let i=0,length=allTypeOptions.length;i'+plugin.Name:plugin.Name;return globalize.translate("ProviderNeedsSetupWithUrl",plugin.Name,linkStart,enableLink?"":"")}function getImageFetchersForTypeHtml(availableTypeOptions,libraryOptionsForType){let html="";return getOrderedPlugins(availableTypeOptions.ImageFetchers||[],libraryOptionsForType.ImageFetcherOrder||[]).length&&(html=(html=html+('
')+'

'+globalize.translate("HeaderTypeImageFetchers",itemManager.getItemTypeName(availableTypeOptions.Type))+"

",(1<(libraryOptionsForType=availableTypeOptions.SupportedImageTypes||[]).length||1===libraryOptionsForType.length&&"Primary"!==libraryOptionsForType[0])&&(html+='"),html=(html=(html=(html+="
")+'

'+globalize.translate("LabelImageFetchersHelp")+"

")+'
')+"
"),html}function renderImageFetchers(page,availableOptions,libraryOptions){let html="";var elem=page.querySelector(".imageFetchers");for(let i=0,length=availableOptions.TypeOptions.length;i'+o.name+""}).join("")}function triggerElementEvents(parent){var selectThumbnailImages=parent.querySelector(".selectThumbnailImages"),selectThumbnailImages=(onThumbnailScheduleChange.call(selectThumbnailImages,{target:selectThumbnailImages}),parent.querySelector(".selectThumbnailInterval")),selectThumbnailImages=(onThumbnailIntervalChange.call(selectThumbnailImages,{target:selectThumbnailImages}),parent.querySelector(".chkImportCollections"));onImportCollectionsChange.call(selectThumbnailImages,{target:selectThumbnailImages})}function embed(parent,contentType,libraryOptions){currentLibraryOptions={TypeOptions:[]};let isNewLibrary=(currentAvailableOptions=null)==libraryOptions;return isNewLibrary&&parent.classList.add("newlibrary"),require(["text!./components/libraryoptionseditor/libraryoptionseditor.template.html"]).then(function(responses){parent.innerHTML=globalize.translateDocument(responses[0]);responses=parent.querySelector(".metadataReaderItemsContainer"),responses.fetchData=getMetadataReaderItems,responses.getListOptions=getMetadataReaderListOptions,responses.parentContainer=responses.closest(".verticalSection"),responses=parent.querySelector(".subtitleFetchersItemsContainer"),responses.fetchData=getSubtitleFetcherItems,responses.getListOptions=getSubtitleFetcherListOptions,responses.parentContainer=responses.closest(".subtitleDownloadSettings"),responses=parent.querySelector(".lyricsFetchersItemsContainer"),responses.fetchData=getLyricsFetcherItems,responses.getListOptions=getLyricsFetcherListOptions,responses.parentContainer=responses.closest(".lyricsDownloadSettings"),populateRefreshInterval(parent.querySelector(".selectAutoRefreshInterval"),[30,60,90]),populateRefreshInterval(parent.querySelector(".selectPlaceholderMetadataRefreshInterval"),[2,3,7,14,30,60,90]),populateMaxDownloadAge(parent.querySelector(".selectSubtitleDownloadMaxAge")),populateMaxDownloadAge(parent.querySelector(".selectLyricsDownloadMaxAge")),responses=[populateLanguages(parent),populateCountries(parent.querySelector(".selectCountry"))];return populateThumbnailInterval(parent),Promise.all(responses).then(function(){return setContentType(parent,contentType,isNewLibrary).then(function(){libraryOptions?setLibraryOptions(parent,libraryOptions):setListDefaults(parent),triggerElementEvents(parent),onMetadataFetchersOrReadersChange.call(parent.querySelector(".metadataFetchers")),bindEvents(parent)})})})}function setAdvancedVisible(parent,visible){var elems=parent.querySelectorAll(".advanced");for(let i=0,length=elems.length;i