define(["exports","./../emby-elements/emby-scroller/emby-scroller.js"],function(_exports,_embyScroller){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,require(["css!modules/dialogsidebar/dialogsidebar.css"]);var SIDEBAR_CLASS="sidebar",SIDEBAR_BACKDROP_CLASS="sidebarBackdrop",SIDEBAR_EXTRA_CLASSES="focuscontainer padded-bottom-page flex-direction-column drawer-open",sidebars={};function DialogSidebar(anchorcontainer,options){var self=this,container=anchorcontainer;if(!(anchorcontainer instanceof _embyScroller.default)){container=document.createElement("div",{is:"emby-scroller"});for(var attr of anchorcontainer.attributes)"is"!==attr.name&&container.setAttribute(attr.name,attr.value)}(self.container=container).dataset.miniscrollbar="true",container.dataset.horizontal="false",container.dataset.focusscroll="true",container.dataset.forcescrollbar="true",container.dataset.forcenativescroll="false",container.classList.add(SIDEBAR_CLASS),container.dataset.sidebar=options.className,options.className.split(" ").forEach(function(classToAdd){return container.classList.add(classToAdd)}),SIDEBAR_EXTRA_CLASSES.split(" ").forEach(function(classToAdd){return container.classList.add(classToAdd)}),container.style[options.reverse?"insetInlineEnd":"insetInlineStart"]=0;var contents=container.querySelector(".scrollSlider"),anchorcontainer=(contents||((contents=document.createElement("div")).classList.add("scrollSlider"),container.append(contents)),self.contents=contents,anchorcontainer!==container&&(anchorcontainer.parentElement.insertBefore(container,anchorcontainer),anchorcontainer.remove()),sidebars[options.className]=this,options.backdropElement);(anchorcontainer="string"==typeof anchorcontainer?document.querySelector(anchorcontainer):anchorcontainer)||!1===anchorcontainer||(anchorcontainer=document.createElement("div"),container.parentElement.insertBefore(anchorcontainer,container)),anchorcontainer instanceof HTMLElement&&(anchorcontainer.classList.add(SIDEBAR_BACKDROP_CLASS),anchorcontainer.dataset.sidebar=options.className,anchorcontainer.addEventListener("click",function(){self.hide()}),self.backdropContainer=anchorcontainer),options.template&&(contents.innerHTML=options.template),self.show=function(){self.container.classList.remove("hide"),self.backdropContainer&&self.backdropContainer.classList.remove("hide")},self.hide=function(){self.container.classList.add("hide"),self.backdropContainer&&self.backdropContainer.classList.add("hide")},self.toggle=function(){self.container.classList.contains("hide")?self.show():self.hide()},self.destroy=function(){self.hide(),self.container.classList.remove(SIDEBAR_CLASS),delete self.container.dataset.sidebar,sidebars[options.className]&&delete sidebars[options.className]}}function show(options){("object"!=typeof options||options instanceof HTMLElement)&&(options={container:options});var sidebar,container=(options=Object.assign({container:void 0,parent:void 0,className:void 0,template:void 0,reverse:!1,backdropElement:void 0},options)).container;if(!((container="string"==typeof container?document.querySelector(container):container)instanceof HTMLElement))throw new Error("The container must be a HTML element.");if(options.parent||(options.parent=container.parentElement),container.classList.contains(SIDEBAR_CLASS))return(sidebar=sidebars[container.dataset.sidebar]).show(),sidebar;if(options.className)return new DialogSidebar(container,options);throw new Error("Sidebar requires a className.")}_exports.default={show:show,create:function(options){if((options="object"!=typeof options||options instanceof HTMLElement?{parent:options}:options).parent)return options.container=document.createElement("div"),options.parent.append(options.container),show(options);throw new Error("This function requires a 'parent' element.")},get:function(className){return sidebars[className]},sidebarClass:SIDEBAR_CLASS}});