import globalize from"./../common/globalize.js";import layoutManager from"./../layoutmanager.js";import focusManager from"./../focusmanager.js";import"./../emby-elements/emby-input/emby-input.js";import"./../emby-elements/emby-textarea/emby-textarea.js";import"./../emby-elements/emby-button/emby-button.js";import"./../emby-elements/emby-checkbox/emby-checkbox.js";import"./../emby-elements/emby-select/emby-select.js";import"./../emby-elements/emby-multilineselect/emby-multilineselect.js";import"./../emby-elements/emby-radio/emby-radio.js";import"./../emby-elements/emby-toggle/emby-toggle.js";import"./../emby-elements/emby-premierecontainer/emby-premierecontainer.js";import"./../emby-elements/emby-button/paper-icon-button-light.js";import"./../listview/listview.js";require(["formDialogStyle","flexStyles","material-icons","css!legacy/dashboard.css","css!modules/genericedit/genericedit.css"]);let statusColorNone="transparent",statusColorOk="#8bc34a",statusColorWarning="#ffc107",statusColorError="#f44336",statusColorDisabled="#919191",statusColorGhosted="#dcdcdc";function showActionSheet(options){return Emby.importModule("./modules/actionsheet/actionsheet.js").then(function(ActionSheet){return ActionSheet.show(options)})}let genericEditDx=null;function checkGetDx(editorRoot){return genericEditDx||!isDxRequired(editorRoot)?Promise.resolve():require(["https://mediabrowser.github.io/genericedit_dx/genericedit_dx.js"],function(result){return genericEditDx=result,Promise.resolve()})}let customEditors={};function getEditor(type){return customEditors[type]}function registerEditor(type,editor){customEditors[type]=editor}let commandProcessors={};function getCommandProcessor(commandId){return commandProcessors[commandId]}function registerCommandProcessor(commandId,processor){commandProcessors[commandId]=processor}function runCommand(commandId,element,itemId){commandId=getCommandProcessor(commandId);return!!commandId&&(commandId(element,itemId),!0)}function actionSheetHandler(e){var innerListItem=e.target.closest(".listItem-inner");if(!innerListItem||innerListItem.classList.contains("focusable")||document.activeElement&&innerListItem.contains(document.activeElement)&&innerListItem!==document.activeElement||focusManager.autoFocus(innerListItem,{findAutoFocusElement:!1}),e.Data1)return!0;let button=e.target.closest("BUTTON");if(button&&"button"===button.type&&button.subMenuButtons){let menuButtons=button.subMenuButtons;var menuItems=[];let hasItemIcon=!1;for(let p=0;p',""),c2.push(DIV(null,null,"margin:1em 0;",innerHTML,"emby-premierecontainer")))})),children.push(DIV(null,"sectionContent",null,function(){return root.EditorItems.map(renderSingleItem).join("")}))):children.push(root.EditorItems.map(renderSingleItem).join(""))}),container.PostbackActions=root.PostbackActions,registerFilePickerEvents(container),editObjectContainer.Object);function onChangeHandler(e){if("text"!==e.target.type||e.target.classList.contains("ge-picker")){if("input"===e.type)return}else if("change"===e.type)return;let targetValue=e.target.value,targetId=("checkbox"===e.target.type&&(targetValue=e.target.checked),e.target.id);if("radio"===e.target.type&&(targetId=e.target.name),applyPropertyConditions(root,container,targetValue,targetId),e.target.classList.contains("emby-list-toggle")&&e.target.dataset.data1&&e.target.dataset.data2){let timerId=setTimeout(()=>{clearTimeout(timerId);var event=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0});event.Data1=e.target.dataset.data1,event.Data2=e.target.dataset.data2,container.dispatchEvent(event)},50)}if(container.PostbackActions){let action=null;for(let i=0;i{clearTimeout(timerId);var event=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0});event.Data1=action.PostbackCommandId,event.Data2=getValue(valueObject,action.CommandParameterPropertyId),container.dispatchEvent(event)},50)}}}return container.lastChangeHandler&&container.removeEventListener("change",container.lastChangeHandler),container.lastInputHandler&&container.removeEventListener("input",container.lastInputHandler),container.lastChangeHandler=onChangeHandler,container.lastInputHandler=onChangeHandler,container.addEventListener("change",container.lastChangeHandler),container.addEventListener("input",container.lastChangeHandler),container.removeEventListener("click",actionSheetHandler),container.addEventListener("click",actionSheetHandler),Promise.resolve()})):Promise.resolve()}function applyPropertyConditions(root,container,targetValue,targetId){for(let i=0;icondition.Value;break;case"IsGreaterOrEqual":conditionResult=targetValue>=condition.Value;break;case"IsLess":conditionResult=targetValueUnknown cofig element type: "+item.ElementType+""}}function renderCheckBox(item){let map=new Map;return item.IsReadOnly&&(map.set("readonly","readonly"),map.set("disabled","disabled")),DIV(null,"checkboxContainer checkboxContainer-withDescription"+item.extraClasses,null,function(children){children.push(LABEL(null,null,null,function(){return INPUT(item.Id,"checkbox","emby-checkbox",null,null,map,function(){return SPAN(null,null,null,item.DisplayName)})})),item.Description&&children.push(DIV(null,"fieldDescription checkboxFieldDescription",null,item.Description))})}function renderSelect(item,multiselect){if(item.ShowAsRadio)return renderRadio(item,!1);let html="",containerClass="selectContainer",elementName="emby-select",map=new Map;return item.AllowEmpty||map.set("required","required"),item.IsReadOnly&&map.set("disabled","disabled"),multiselect&&map.set("multiple","multiple"),map.set("allselected-labeltext",globalize.translate("All")),map.set("data-empty-is-all","false"),map.set("itemssourceid",item.ItemsSourceId),map.set("staticitemssourceid",item.StaticItemsSourceId),map.set("label",item.DisplayName),item.MultiLine&&1"+option.Name+""}function renderText(item){let element=item.MultiLine?"textarea":"input",elementIs="emby-"+element,elemType="text",style="",map=(item.IsPassword&&(elemType="password"),new Map);return item.MultiLine&&item.LineCount&&1';return item+'
'+'check_circle_outline'+'
'+"
"+'
'+'
 
 
'+"
"+""}function renderProgressItem(item){var attributes=[],html=(attributes.push('id="'+item.Id+'"'),attributes.push('min="0"'),attributes.push('max="0"'),attributes.push('style="width: 100%; height: 2em;"'),attributes.push('label="'+item.DisplayName+'"'),'
');return html=(html+="")+('
'+item.Description+"
")+"
"}function renderButtonItemCore(item){var attributes=[],item=(attributes.push('is="emby-button"'),attributes.push('id="'+item.Id+'"'),attributes.push('type="button"'),attributes.push('class="raised raised-mini btnButtonItem emby-button'+item.extraClasses+'"'),attributes.push('style="margin-left:0;"'),""}function renderTitleButtonItem(item){var attributes=[],item=(attributes.push('is="emby-button"'),attributes.push('id="'+item.Id+'"'),attributes.push('type="button"'),attributes.push('class="fab btnButtonItem submit sectionTitleButton'+item.extraClasses+'"'),attributes.push('style="margin-left:0.9em !important; opacity: 0.6;font-size: 0.9em;"'),""}function renderButtonItem(item){return DIV(null,"verticalSection","margin-top: 1.2em;",function(){return DIV(null,"horizontalSection allSection",null,function(){return renderButtonItemCore(item)})})}function renderButtonGroup(item){return item.IsBottomPanel?renderBottomButtonGroup(item):DIV(null,"verticalSection","margin-top: 1.2em;",function(){return DIV(null,"horizontalSection allSection",null,function(){return item.EditorItems.map(renderButtonItemCore).join("")})})}function renderBottomButtonGroup(item){return DIV(null,"verticalSection","position: absolute; bottom: 0.5em; left: 0.8em; z-index: 100000;",function(){return DIV(null,"horizontalSection allSection",null,function(){return item.EditorItems.map(renderButtonItemCore).join("")})})}function renderCaptionItem(item){return DIV(item.Id,"verticalSection"+item.extraClasses,"margin-top: 1em;",function(){return DIV(null,"sectionTitleContainer",null,function(){return H3(null,"sectionTitle captionText")})})}function renderLabelItem(item){return DIV(item.Id,"verticalSection"+item.extraClasses,"margin-top: 0.5em;",function(){return'

'})}function renderSpacerItem(item){return DIV(item.Id,"verticalSection"+item.extraClasses)}function renderItemList(item){return DIV(null,item.extraClasses,null,function(children){children.push(DIV(item.Id,"paperList visualCardBox vertical-list ge-itemlist")),children.push(DIV(null,"fieldDescription",null,item.Description))})}function renderRadio(item){let map=new Map;return map.set("itemssourceid",item.ItemsSourceId),map.set("staticitemssourceid",item.StaticItemsSourceId),DIV(null,"radioContainer"+item.extraClasses,null,function(children){item.DisplayName&&children.push(LABEL("radioLabel",null,item.Id,item.DisplayName)),children.push(EL("div",item.Id,"radioGroup",null,null,null,map,function(){return item.SelectOptions.map(renderRadioItem,item).join("")}))})}function renderRadioItem(item,x,y){var disabled=item.IsEnabled?"":'disabled="disabled"',disabled='"}function renderRadioGroup(item){let map=new Map;return map.set("itemssourceid",item.ItemsSourceId),DIV(null,"radioContainer"+item.extraClasses,null,function(children){item.DisplayName&&children.push(LABEL("radioLabel",null,item.Id,item.DisplayName)),children.push(EL("div",item.Id,"radioGroup",null,null,null,map))})}function renderRadioGroupItems(listElement,items){var hash=objHash(items);listElement.getAttribute("hash")!==hash&&(items=items.map(renderRadioGroupItem,listElement).join(""),listElement.setAttribute("hash",hash),listElement.innerHTML=items)}function renderRadioGroupItem(item,x,y){var disabled=item.IsEnabled?"":'disabled="disabled"';let html='",item.SecondaryText&&(html+='
'+item.SecondaryText+"
"),html}function objHash(obj){var objStr=JSON.stringify(obj);let hash=0;for(let i=0;iitems.length;)listElement.lastElementChild.remove();for(let i=0;i');return html=(html+="")+('
'+item.Description+"
")+""}function renderNumeric(item){var attributes=[],zeros=(attributes.push('is="emby-input"'),attributes.push('type="number"'),attributes.push('id="'+item.Id+'"'),item.AllowEmpty||attributes.push('required="required"'),item.IsReadOnly&&(attributes.push('readonly="readonly"'),attributes.push('disabled="disabled"')),layoutManager.tv&&attributes.push('autocomplete="off"'),null!=item.MinValue&&attributes.push('min="'+item.MinValue+'"'),null!=item.MaxValue&&attributes.push('max="'+item.MaxValue+'"'),item.DecimalPlaces&&0');return zeros=(zeros+="")+('
'+item.Description+"
")+""}function renderItemGroup(item){var itemcount=item.EditorItems.length;let html='
';if(item.DisplayName||item.Description){html='
',html+='
',item.DisplayName&&(html+='

'+item.DisplayName+"

");let desccriptionClass="ge-section-description";item.TitleButton&&(html+=renderTitleButtonItem(item.TitleButton),desccriptionClass+=" ge-section-withtitlebutton-description"),html+="
",item.Description&&(html+='

'+formatDescription(item.Description)+"

")}return html=(html+='
')+item.EditorItems.map(renderSingleItem).join("")+"
"}function formatDescription(description){return description&&0!==description.length?description.split("\n").join("
"):null}function getAllItems(editorRoot){var allItems=[];return editorRoot&&editorRoot.EditorItems&&collectItems(editorRoot,allItems),allItems}function collectItems(item,allItems){if(item.TitleButton&&allItems.push(item.TitleButton),item.EditorItems)for(let i=0;ioption.value)).join(",");setValue(valueObject,item.Id,selectedValues)}else if(elementId.classList.contains("radioGroup")){var radios=elementId.querySelectorAll("INPUT");for(let i=0;i");return contentFunc&&("function"==typeof contentFunc?(elemClass=contentFunc(id=[]),html=html+id.join(" ")+(elemClass||"")):html+=contentFunc),html+=""}function getStatusColor(status){switch(status){case"None":return statusColorNone;case"Succeeded":return statusColorOk;case"Failed":return statusColorError;case"Warning":return statusColorWarning;case"Unknown":return statusColorGhosted;default:return statusColorDisabled}}function P(id,cls,style,contentFunc,is){return EL("p",id,cls,style,is,null,null,contentFunc)}function DIV(id,cls,style,contentFunc,is){return EL("div",id,cls,style,is,null,null,contentFunc)}function H1(id,cls,style,contentFunc){return EL("h1",id,cls,style,null,null,null,contentFunc)}function H3(id,cls,style,contentFunc){return EL("h3",id,cls,style,null,null,null,contentFunc)}function SPAN(id,cls,style,contentFunc){return EL("span",id,cls,style,null,null,null,contentFunc)}function ICON(id,cls,style,contentFunc){return EL("i",id,cls,style,null,null,null,contentFunc)}function LABEL(cls,style,for1,contentFunc){var map=new Map;return for1&&0