text: !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";function e(e,t){var r=window.Element.prototype,n=r.matches||r.mozMatchesSelector||r.msMatchesSelector||r.oMatchesSelector||r.webkitMatchesSelector;if(!e||1!==e.nodeType)return!1;var o=e.parentNode;if(n)return n.call(e,t);for(var i=o.querySelectorAll(t),a=i.length,s=0;s<a;s++)if(i[s]===e)return!0;return!1}function t(e,t){return e===t||!!(16&e.compareDocumentPosition(t))}var r=e,n=t,o=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();!function(e){function t(e,r,n){if(e.nodeType==Node.ELEMENT_NODE){var o=e;r&&r(o);var i=o.shadowRoot||o.webkitShadowRoot;if(i)return void t(i,r,i);if("content"==o.localName){for(var a=o,s=a.getDistributedNodes?a.getDistributedNodes():[],d=0;d<s.length;d++)t(s[d],r,n);return}if("slot"==o.localName){for(var u=o,l=u.assignedNodes?u.assignedNodes({flatten:!0}):[],h=0;h<l.length;h++)t(l[h],r,n);return}}for(var f=e.firstChild;null!=f;)t(f,r,n),f=f.nextSibling}function a(t){if(!t.querySelector("style#inert-style")){var r=e.createElement("style");r.setAttribute("id","inert-style"),r.textContent="\n[inert] {\n  pointer-events: none;\n  cursor: default;\n}\n\n[inert], [inert] * {\n  user-select: none;\n  -webkit-user-select: none;\n  -moz-user-select: none;\n  -ms-user-select: none;\n}\n",t.appendChild(r)}}var s=["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]"].join(","),d=function(){function a(e,t){o(this,a),this._inertManager=t,this._rootElement=e,this._managedNodes=new Set([]),this._rootElement.setAttribute("aria-hidden","true"),this._makeSubtreeUnfocusable(this._rootElement),this._observer=new MutationObserver(this._onMutation.bind(this)),this._observer.observe(this._rootElement,{attributes:!0,childList:!0,subtree:!0})}return i(a,[{key:"destructor",value:function(){this._observer.disconnect(),this._observer=null,this._rootElement&&this._rootElement.removeAttribute("aria-hidden"),this._rootElement=null;var e=!0,t=!1,r=void 0;try{for(var n,o=this._managedNodes[Symbol.iterator]();!(e=(n=o.next()).done);e=!0){var i=n.value;this._unmanageNode(i.node)}}catch(e){t=!0,r=e}finally{try{!e&&o.return&&o.return()}finally{if(t)throw r}}this._managedNodes=null,this._inertManager=null}},{key:"_makeSubtreeUnfocusable",value:function(r){var o=this;t(r,function(e){return o._visitNode(e)});var i=e.activeElement;if(!n(e.body,r)){for(var a=r,s=void 0;a;){if(a.nodeType===Node.DOCUMENT_FRAGMENT_NODE){s=a;break}a=a.parentNode}s&&(i=s.activeElement)}n(r,i)&&i.blur()}},{key:"_visitNode",value:function(e){e.nodeType===Node.ELEMENT_NODE&&(e!==this._rootElement&&e.hasAttribute("inert")&&this._adoptInertRoot(e),(r(e,s)||e.hasAttribute("tabindex"))&&this._manageNode(e))}},{key:"_manageNode",value:function(e){var t=this._inertManager.register(e,this);this._managedNodes.add(t)}},{key:"_unmanageNode",value:function(e){var t=this._inertManager.deregister(e,this);t&&this._managedNodes.delete(t)}},{key:"_unmanageSubtree",value:function(e){var r=this;t(e,function(e){return r._unmanageNode(e)})}},{key:"_adoptInertRoot",value:function(e){var t=this._inertManager.getInertRoot(e);t||(this._inertManager.setInert(e,!0),t=this._inertManager.getInertRoot(e));var r=!0,n=!1,o=void 0;try{for(var i,a=t.managedNodes[Symbol.iterator]();!(r=(i=a.next()).done);r=!0){var s=i.value;this._manageNode(s.node)}}catch(e){n=!0,o=e}finally{try{!r&&a.return&&a.return()}finally{if(n)throw o}}}},{key:"_onMutation",value:function(e,t){var r=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done);r=!0){var d=a.value,u=d.target;if("childList"===d.type){var l=!0,h=!1,f=void 0;try{for(var c,v=Array.from(d.addedNodes)[Symbol.iterator]();!(l=(c=v.next()).done);l=!0){var y=c.value;this._makeSubtreeUnfocusable(y)}}catch(e){h=!0,f=e}finally{try{!l&&v.return&&v.return()}finally{if(h)throw f}}var b=!0,_=!1,m=void 0;try{for(var g,N=Array.from(d.removedNodes)[Symbol.iterator]();!(b=(g=N.next()).done);b=!0){var w=g.value;this._unmanageSubtree(w)}}catch(e){_=!0,m=e}finally{try{!b&&N.return&&N.return()}finally{if(_)throw m}}}else if("attributes"===d.type)if("tabindex"===d.attributeName)this._manageNode(u);else if(u!==this._rootElement&&"inert"===d.attributeName&&u.hasAttribute("inert")){this._adoptInertRoot(u);var I=this._inertManager.getInertRoot(u),p=!0,E=!1,x=void 0;try{for(var k,S=this._managedNodes[Symbol.iterator]();!(p=(k=S.next()).done);p=!0){var M=k.value;n(u,M.node)&&I._manageNode(M.node)}}catch(e){E=!0,x=e}finally{try{!p&&S.return&&S.return()}finally{if(E)throw x}}}}}catch(e){o=!0,i=e}finally{try{!r&&s.return&&s.return()}finally{if(o)throw i}}}},{key:"managedNodes",get:function(){return new Set(this._managedNodes)}}]),a}(),u=function(){function e(t,r){o(this,e),this._node=t,this._overrodeFocusMethod=!1,this._inertRoots=new Set([r]),this._destroyed=!1,this.ensureUntabbable()}return i(e,[{key:"destructor",value:function(){this._throwIfDestroyed(),this._node&&(this.hasSavedTabIndex?this._node.setAttribute("tabindex",this.savedTabIndex):this._node.removeAttribute("tabindex"),this._overrodeFocusMethod&&delete this._node.focus),this._node=null,this._inertRoots=null,this._destroyed=!0}},{key:"_throwIfDestroyed",value:function(){if(this.destroyed)throw new Error("Trying to access destroyed InertNode")}},{key:"ensureUntabbable",value:function(){var e=this.node;if(r(e,s)){if(-1===e.tabIndex&&this.hasSavedTabIndex)return;e.hasAttribute("tabindex")&&(this._savedTabIndex=e.tabIndex),e.setAttribute("tabindex","-1"),e.nodeType===Node.ELEMENT_NODE&&(e.focus=function(){},this._overrodeFocusMethod=!0)}else e.hasAttribute("tabindex")&&(this._savedTabIndex=e.tabIndex,e.removeAttribute("tabindex"))}},{key:"addInertRoot",value:function(e){this._throwIfDestroyed(),this._inertRoots.add(e)}},{key:"removeInertRoot",value:function(e){this._throwIfDestroyed(),this._inertRoots.delete(e),0===this._inertRoots.size&&this.destructor()}},{key:"destroyed",get:function(){return this._destroyed}},{key:"hasSavedTabIndex",get:function(){return"_savedTabIndex"in this}},{key:"node",get:function(){return this._throwIfDestroyed(),this._node}},{key:"savedTabIndex",set:function(e){this._throwIfDestroyed(),this._savedTabIndex=e},get:function(){return this._throwIfDestroyed(),this._savedTabIndex}}]),e}(),l=function(){function e(t){if(o(this,e),!t)throw new Error("Missing required argument; InertManager needs to wrap a document.");this._document=t,this._managedNodes=new Map,this._inertRoots=new Map,this._observer=new MutationObserver(this._watchForInert.bind(this)),a(t.head||t.body||t.documentElement),"loading"===t.readyState?t.addEventListener("DOMContentLoaded",this._onDocumentLoaded.bind(this)):this._onDocumentLoaded()}return i(e,[{key:"setInert",value:function(e,t){if(t){if(this._inertRoots.has(e))return;var r=new d(e,this);if(e.setAttribute("inert",""),this._inertRoots.set(e,r),!n(this._document.body,e))for(var o=e.parentNode;o;)11===o.nodeType&&a(o),o=o.parentNode}else{if(!this._inertRoots.has(e))return;this._inertRoots.get(e).destructor(),this._inertRoots.delete(e),e.removeAttribute("inert")}}},{key:"getInertRoot",value:function(e){return this._inertRoots.get(e)}},{key:"register",value:function(e,t){var r=this._managedNodes.get(e);return void 0!==r?(r.addInertRoot(t),r.ensureUntabbable()):r=new u(e,t),this._managedNodes.set(e,r),r}},{key:"deregister",value:function(e,t){var r=this._managedNodes.get(e);return r?(r.removeInertRoot(t),r.destroyed&&this._managedNodes.delete(e),r):null}},{key:"_onDocumentLoaded",value:function(){var e=Array.from(this._document.querySelectorAll("[inert]")),t=!0,r=!1,n=void 0;try{for(var o,i=e[Symbol.iterator]();!(t=(o=i.next()).done);t=!0){var a=o.value;this.setInert(a,!0)}}catch(e){r=!0,n=e}finally{try{!t&&i.return&&i.return()}finally{if(r)throw n}}this._observer.observe(this._document.body,{attributes:!0,subtree:!0,childList:!0})}},{key:"_watchForInert",value:function(e,t){var n=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var d=a.value;switch(d.type){case"childList":var u=!0,l=!1,h=void 0;try{for(var f,c=Array.from(d.addedNodes)[Symbol.iterator]();!(u=(f=c.next()).done);u=!0){var v=f.value;if(v.nodeType===Node.ELEMENT_NODE){var y=Array.from(v.querySelectorAll("[inert]"));r(v,"[inert]")&&y.unshift(v);var b=!0,_=!1,m=void 0;try{for(var g,N=y[Symbol.iterator]();!(b=(g=N.next()).done);b=!0){var w=g.value;this.setInert(w,!0)}}catch(e){_=!0,m=e}finally{try{!b&&N.return&&N.return()}finally{if(_)throw m}}}}}catch(e){l=!0,h=e}finally{try{!u&&c.return&&c.return()}finally{if(l)throw h}}break;case"attributes":if("inert"!==d.attributeName)continue;var I=d.target,p=I.hasAttribute("inert");this.setInert(I,p)}}}catch(e){o=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(o)throw i}}}}]),e}(),h=new l(e);Object.defineProperty(Element.prototype,"inert",{enumerable:!0,get:function(){return this.hasAttribute("inert")},set:function(e){h.setInert(this,e)}})}(document)});
  