function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}!function(o){"use strict";function c(t,e){function n(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),n}n.prototype=o.Event.prototype,(e=new(o.CustomEvent&&"function"==typeof o.CustomEvent?o.CustomEvent:n)(e))&&t.dispatchEvent(e)}function r(t){return a(["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'].join(","),t).filter(function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)})}function a(t,e){return Array.prototype.slice.call((e||document).querySelectorAll(t))}function f(t){t=r(t);t.length&&t[0].focus()}function t(o,t){var e="data-a11y-dialog",i=this;function n(t){i.shown&&!o.contains(t.target)&&f(o)}function u(){i.shown=!0,o.removeAttribute("aria-hidden"),t.setAttribute("aria-hidden","true"),s=document.activeElement,f(o),document.body.addEventListener("focus",n,!0),c(o,"dialog:show")}function d(){i.shown=!1,o.setAttribute("aria-hidden","true"),t.removeAttribute("aria-hidden"),s&&s.focus(),document.body.removeEventListener("focus",n,!0),c(o,"dialog:hide")}t=t||document.querySelector("#main"),this.shown=!1,this.isModal=!1,this.show=u,this.hide=d,this.modal=function(t){i.isModal=t},a("["+e+'-show="'+o.id+'"]').forEach(function(t){t.addEventListener("click",u)}),a("["+e+"-hide]",o).concat(a("["+e+'-hide="'+o.id+'"]')).forEach(function(t){t.addEventListener("click",function(){i.isModal||d()})}),document.addEventListener("keydown",function(t){var e,n;!i.isModal&&i.shown&&27===t.which&&(t.preventDefault(),d()),i.shown&&9===t.which&&(t=t,n=(e=r(e=o)).indexOf(document.activeElement),t.shiftKey&&0===n?(e[e.length-1].focus(),t.preventDefault()):t.shiftKey||n!==e.length-1||(e[0].focus(),t.preventDefault()))})}var s;"undefined"!=typeof module&&void 0!==module.exports?module.exports=t:"function"==typeof define&&define.amd?define("A11yDialog",[],function(){return t}):"object"===_typeof(o)&&(o.A11yDialog=t)}(window);