!function(){"use strict";var c=250,u="opacity",d=new WeakMap;function l(t){t=t.getAttribute("data-dialog");return t?Array.from(document.querySelectorAll('[data-dialog-trigger="'+t+'"]')):[]}function e(t,e){var n,o,a,i;function r(t){t&&"transitionend"===t.type&&t.propertyName!==u||i||(i=!0,n.removeEventListener("transitionend",r),n.removeAttribute("data-dialog-closing"),n.close(),o&&"function"==typeof o.focus&&o.focus(),"function"==typeof a&&a())}t&&t.open&&(e=void 0!==e?e:d.get(t)||l(t)[0]||null,o=e,(n=t).setAttribute("data-dialog-closing",""),i=!1,n.addEventListener("transitionend",r),setTimeout(r,c))}function t(o){l(o).forEach(function(n){n.addEventListener("click",function(t){var e;t.preventDefault(),t=n,!(e=o)||"function"!=typeof e.showModal||e.open||(t&&d.set(e,t),e.showModal(),e.querySelector("[autofocus]"))||(t=e.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'))&&t.focus()})}),o.addEventListener("click",function(t){t.target===o&&e(o)}),o.addEventListener("cancel",function(t){t.preventDefault(),e(o)}),o.querySelectorAll("[data-dialog-close]").forEach(function(t){t.addEventListener("click",function(t){t.preventDefault(),e(o)})})}function n(){document.querySelectorAll("[data-dialog]").forEach(t)}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",n):n()}();