function _createForOfIteratorHelperLoose(e,t){var a="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(a)return(a=a.call(e)).next.bind(a);if(Array.isArray(e)||(a=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){a&&(e=a);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var a={}.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,o=Array(t);a<t;a++)o[a]=e[a];return o}var FPF_Modal=function(){function i(){this.initEvents()}var e=i.prototype;return e.initEvents=function(){document.addEventListener("click",function(e){this.handleOpen(e),this.handleClose(e),this.handleSave(e)}.bind(this)),document.addEventListener("keydown",function(e){this.handleEscapeClose(e)}.bind(this))},e.handleOpen=function(e){var t=e.target.closest(".fpf-modal-opener");if(!t||e.target.classList.contains("fpf-modal-prevent"))return!1;var a=t.getAttribute("data-fpf-modal");if(!a)return!1;var o=document.querySelector(".fpf-modal > .modal"+a);o&&(o.closest(".fpf-modal").modal=this,i.open(o,t),"false"!==t.dataset.fpfModalPrevent&&e.preventDefault())},i.open=function(e,t){void 0===t&&(t=null);var a={modal_name:e.id,initiator:t},o=new CustomEvent("fpf_modal_open",{detail:a,cancelable:!0});e.dispatchEvent(o),document.body.classList.add("fpf-modal-open","fpf-modal-"+e.id+"-open");var n=e.parentElement;n.classList.add("is-visible"),i.tabindex||(i.tabindex=0),n.tabindex=i.tabindex,i.tabindex++,n.focus()},e.handleClose=function(e){(e.target.closest(".fpf-modal-close")||this.canCloseOnOverlay(e.target))&&(i.closeModal(e.target.closest(".fpf-modal")),e.preventDefault())},e.handleSave=function(e){var t=e.target.closest(".fpf-modal-save");if(t){var a=e.target.closest(".fpf-modal"),o={modal_name:a.querySelector(".modal").id},n=new CustomEvent("fpf_modal_save",{detail:o,cancelable:!0});a.querySelector(".modal").dispatchEvent(n),t.classList.contains("close")&&i.closeModal(a),e.preventDefault()}},i.closeModal=function(e){var t=e.querySelector(":scope > .modal");document.body.classList.remove("fpf-modal-open","fpf-modal-"+t.id+"-open"),e.classList.remove("is-visible");var a={modal_name:t.id},o=new CustomEvent("fpf_modal_close",{detail:a,cancelable:!0});t.dispatchEvent(o)},e.handleEscapeClose=function(e){if(27==(e=e||window.event).keyCode&&!document.querySelector(".fpf-modal.upgrade-pro.is-visible")&&!document.querySelector(".fpf-modal.upgrade-to-plan.is-visible")&&!document.querySelector(".fpf-modal.skip-esc-close.is-visible")){var t=document.querySelectorAll(".fpf-modal.is-visible");if(t){for(var a,o=null,n=-1,r=_createForOfIteratorHelperLoose(t);!(a=r()).done;){var l=a.value;l.classList.contains("upgrade-pro")||l.classList.contains("skip-esc-close")||void 0!==l.tabindex&&l.tabindex>n&&(n=l.tabindex,o=l)}o&&i.closeModal(o)}}},e.canCloseOnOverlay=function(e){var t=e.classList.contains("overlay");if(!t)return!1;var a=e.closest(".overlay").getAttribute("data-on-overlay-click");return!(!t||!a)},i}();document.addEventListener("DOMContentLoaded",function(e){new FPF_Modal});

