define(["dialogHelper","events","playbackManager","globalize","emby-input","paper-icon-button-light","emby-select","material-icons","formDialogStyle","emby-button"],function(dialogHelper,events,playbackManager,globalize){"use strict";function SubtitleOffsetDialog(options){this.options=options}function onDialogClosed(){var instance,player,localOnSubtitleOffsetChange;return player=(instance=this).options.player,(localOnSubtitleOffsetChange=instance.localOnSubtitleOffsetChange)&&events.off(player,"subtitleoffsetchange",localOnSubtitleOffsetChange),Promise.resolve()}function onIncrementButtonClick(e){playbackManager.incrementSubtitleOffset(parseInt(e.currentTarget.getAttribute("data-offset")),this.options.player)}function refreshData(instance,player){!function(instance,offsetValue){instance.dlg.querySelector(".offsetValue").innerHTML=offsetValue}(instance,playbackManager.getSubtitleOffset(player))}return SubtitleOffsetDialog.prototype.show=function(){var dlg,html,instance,player;function localOnSubtitleOffsetChange(e){refreshData(instance,player)}this.dlg||((dlg=dialogHelper.createDialog({removeOnClose:!1,scrollY:!1,autoFocus:!0,transparentBackground:!0})).classList.add("formDialog"),dlg.classList.add("subtitleOffsetDialog"),dlg.classList.add("dialog-blur"),html="",html+='<div class="formDialogHeader formDialogHeader-clear justify-content-center" style="padding-top:1.25em;">',html+='<button is="paper-icon-button-light" class="hide-mouse-idle-tv btnCancel autoSize" tabindex="-1" style="position:absolute;top:.9em;left:.25em;"><i class="md-icon">&#xE5C4;</i></button>',html+='<h3 class="formDialogHeaderTitle" style="margin:0;">',html+=globalize.translate("HeaderSubtitleOffset"),html+="</h3>",html+="</div>",html+=function(){var html="";return html+='<div class="formDialogContent flex flex-direction-column align-items-center" style="padding-left:1.5em;padding-right:1.5em;padding-bottom:.25em;">',html+='<div class="subtitleOverlayOffsetText" style="margin:1em 0;"><span class="offsetValue">0</span><span> ms</span></div>',html+='<div class="subtitleOverlayControls flex flex-direction-row align-items-center justify-content-center padded-top padded-bottom">',html+='<button is="emby-button" type="button" data-offset="-50" class="flex-shrink-zero btnDecrementSubtitleOffset raised raised-mini nobackdropfilter" title="'+globalize.translate("HeaderDecreaseSubtitleOffset")+'" aria-label="'+globalize.translate("HeaderDecreaseSubtitleOffset")+'">- 50 ms</button>',html+='<button is="emby-button" type="button" data-offset="50" class="flex-shrink-zero btnIncrementSubtitleOffset raised raised-mini nobackdropfilter" title="'+globalize.translate("HeaderIncreaseSubtitleOffset")+'" aria-label="'+globalize.translate("HeaderIncreaseSubtitleOffset")+'">+ 50 ms</button>',html+='<button is="emby-button" type="button" class="flex-shrink-zero btnReset raised raised-mini nobackdropfilter" title="'+globalize.translate("Reset")+'" aria-label="'+globalize.translate("Reset")+'">'+globalize.translate("Reset")+"</button>",html+="</div>",html+="</div>"}(),dlg.innerHTML=html,(this.dlg=dlg).querySelector(".btnCancel").addEventListener("click",function(){this.close()}.bind(this)),dlg.querySelector(".btnDecrementSubtitleOffset").addEventListener("click",onIncrementButtonClick.bind(this)),dlg.querySelector(".btnIncrementSubtitleOffset").addEventListener("click",onIncrementButtonClick.bind(this)),dlg.querySelector(".btnReset").addEventListener("click",function(e){playbackManager.setSubtitleOffset(0,this.options.player)}.bind(this))),player=(instance=this).options.player,instance.localOnSubtitleOffsetChange=localOnSubtitleOffsetChange,events.on(player,"subtitleoffsetchange",localOnSubtitleOffsetChange),refreshData(this,this.options.player);var dlgClosedFn=onDialogClosed.bind(this);return dialogHelper.open(this.dlg).then(dlgClosedFn,dlgClosedFn)},SubtitleOffsetDialog.prototype.close=function(){var dlg=this.dlg;dlg&&dialogHelper.close(dlg)},SubtitleOffsetDialog.prototype.destroy=function(){this.close(),this.options=null,this.dlg=null},SubtitleOffsetDialog});