define(["exports","./../../layoutmanager.js","./../../input/keyboard.js"],function(_exports,_layoutmanager,_keyboard){function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function(){return!!t})()}function onKeyDown(e){var key=_keyboard.default.normalizeKeyFromEvent(e);if("Enter"===key&&(e.preventDefault(),!e.repeat))return this.checked=!this.checked,this.dispatchEvent(new CustomEvent("change",{bubbles:!0})),!1}function onFocus(){var _this$closest;null!=(_this$closest=this.closest(".emby-toggle-label"))&&_this$closest.classList.add("emby-toggle-label-focus")}function onBlur(){var _this$closest2;null!=(_this$closest2=this.closest(".emby-toggle-label"))&&_this$closest2.classList.remove("emby-toggle-label-focus")}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,require(["css!modules/emby-elements/emby-toggle/emby-toggle.css"]);var EmbyToggle=function(_HTMLInputElement){function EmbyToggle(){var t,o,e;babelHelpers.classCallCheck(this,EmbyToggle),t=this,o=EmbyToggle,o=babelHelpers.getPrototypeOf(o),o=babelHelpers.possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],babelHelpers.getPrototypeOf(t).constructor):o.apply(t,e));return babelHelpers.possibleConstructorReturn(o,o)}return babelHelpers.inherits(EmbyToggle,_HTMLInputElement),babelHelpers.createClass(EmbyToggle,[{key:"connectedCallback",value:function(){!function(){this.setAttribute("role","switch"),this.classList.add("emby-toggle");var labelElement=this.parentNode,labelTextElement=(_layoutmanager.default.tv?(this.classList.add("emby-toggle-tv"),labelElement.classList.add("emby-toggle-label-tv")):this.classList.add("emby-toggle-focusring"),labelElement.classList.add("emby-toggle-label"),labelElement.querySelector(".toggleLabel"));labelTextElement||((labelTextElement=document.createElement("span")).innerHTML=this.getAttribute("label")||"",labelElement.appendChild(labelTextElement)),labelTextElement.classList.add("toggleLabel"),_layoutmanager.default.tv&&labelTextElement.classList.add("toggleLabel-tv"),this.classList.contains("toggle-inline")||labelTextElement.classList.add("flex-grow"),(labelTextElement=labelElement.querySelector(".toggleSwitch"))||((labelTextElement=document.createElement("div")).classList.add("toggleSwitch"),_layoutmanager.default.tv||labelTextElement.classList.add("toggleSwitch-autosize"),labelElement.appendChild(labelTextElement)),this.addEventListener("keydown",onKeyDown),this.removeEventListener("focus",onFocus),this.addEventListener("focus",onFocus),this.removeEventListener("blur",onBlur),this.addEventListener("blur",onBlur)}.call(this)}},{key:"disconnectedCallback",value:function(){!function(){this.removeEventListener("keydown",onKeyDown)}.call(this)}}])}(babelHelpers.wrapNativeSuper(HTMLInputElement));customElements.define("emby-toggle",EmbyToggle,{extends:"input"}),_exports.default=EmbyToggle});