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,CAAC,CAAC,CAAEE,OAAO,CAAC,CAAC,GAAI,CAAC,EAC1E;MACD;IACD;IAEAC,UAAU,CAAE,MAAM;MACjB,IAAI;QACHzB,kDAAU,CAAC0B,IAAI,CAAErB,aAAa,CAACE,EAAE,EAAE;UAClCW,SAAS,EAAE,SAAS;UACpBC,WAAW,EAAE,eAAe;UAC5BC,YAAY,EAAE,gBAAgB;UAC9BC,aAAa,EAAE,IAAI;UACnBM,MAAM,EAAEA,CAAA,KAAM;YACb,MAAMC,gBAAgB,GAAG,IAAIN,IAAI,CAAE,IAAIA,IAAI,CAAC,CAAC,CAAEO,OAAO,CAAG,IAAIP,IAAI,CAAC,CAAC,CAAEQ,OAAO,CAAC,CAAC,GAAGnB,cAAe,CAAC,CAAC;YAElGI,YAAY,CAACgB,OAAO,CAAElB,UAAU,EAAEmB,MAAM,CAAEJ,gBAAgB,CAACJ,OAAO,CAAC,CAAE,CAAE,CAAC;UACzE;QACD,CAAC,CAAC;MACH,CAAC,CAAC,OAAQS,KAAK,EAAG;QACjBC,OAAO,CAACD,KAAK,CACZ/B,wDAAO;QACN;QACAD,mDAAE,CAAE,8BAA8B,EAAE,oBAAqB,CAAC,EAC1DgC,KACD,CACD,CAAC;MACF;IACD,CAAC,EAAEzB,cAAc,GAAG,IAAK,CAAC;EAC3B,CAAC,MAAM;IACN0B,OAAO,CAACC,IAAI,CACXlC,mDAAE,CAAE,2DAA2D,EAAE,oBAAqB,CACvF,CAAC;EACF;AACD,CAAC,CAAC,C","sources":["webpack://simple-modal-block/./node_modules/micromodal/dist/micromodal.es.js","webpack://simple-modal-block/external window [\"wp\",\"i18n\"]","webpack://simple-modal-block/webpack/bootstrap","webpack://simple-modal-block/webpack/runtime/compat get default export","webpack://simple-modal-block/webpack/runtime/define property getters","webpack://simple-modal-block/webpack/runtime/hasOwnProperty shorthand","webpack://simple-modal-block/webpack/runtime/make namespace object","webpack://simple-modal-block/./src/blocks/simple-modal/view.js"],"sourcesContent":["function e(e,t){for(var o=0;oe.length)&&(t=e.length);for(var o=0,n=new Array(t);o0&&this.registerTriggers.apply(this,t(a)),this.onClick=this.onClick.bind(this),this.onKeydown=this.onKeydown.bind(this)}var i,a,r;return i=o,(a=[{key:\"registerTriggers\",value:function(){for(var e=this,t=arguments.length,o=new Array(t),n=0;n0&&void 0!==arguments[0]?arguments[0]:null;if(this.activeElement=document.activeElement,this.modal.setAttribute(\"aria-hidden\",\"false\"),this.modal.classList.add(this.config.openClass),this.scrollBehaviour(\"disable\"),this.addEventListeners(),this.config.awaitOpenAnimation){var o=function t(){e.modal.removeEventListener(\"animationend\",t,!1),e.setFocusToFirstNode()};this.modal.addEventListener(\"animationend\",o,!1)}else this.setFocusToFirstNode();this.config.onShow(this.modal,this.activeElement,t)}},{key:\"closeModal\",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=this.modal;if(this.modal.setAttribute(\"aria-hidden\",\"true\"),this.removeEventListeners(),this.scrollBehaviour(\"enable\"),this.activeElement&&this.activeElement.focus&&this.activeElement.focus(),this.config.onClose(this.modal,this.activeElement,e),this.config.awaitCloseAnimation){var o=this.config.openClass;this.modal.addEventListener(\"animationend\",(function e(){t.classList.remove(o),t.removeEventListener(\"animationend\",e,!1)}),!1)}else t.classList.remove(this.config.openClass)}},{key:\"closeModalById\",value:function(e){this.modal=document.getElementById(e),this.modal&&this.closeModal()}},{key:\"scrollBehaviour\",value:function(e){if(this.config.disableScroll){var t=document.querySelector(\"body\");switch(e){case\"enable\":Object.assign(t.style,{overflow:\"\"});break;case\"disable\":Object.assign(t.style,{overflow:\"hidden\"})}}}},{key:\"addEventListeners\",value:function(){this.modal.addEventListener(\"touchstart\",this.onClick),this.modal.addEventListener(\"click\",this.onClick),document.addEventListener(\"keydown\",this.onKeydown)}},{key:\"removeEventListeners\",value:function(){this.modal.removeEventListener(\"touchstart\",this.onClick),this.modal.removeEventListener(\"click\",this.onClick),document.removeEventListener(\"keydown\",this.onKeydown)}},{key:\"onClick\",value:function(e){(e.target.hasAttribute(this.config.closeTrigger)||e.target.parentNode.hasAttribute(this.config.closeTrigger))&&(e.preventDefault(),e.stopPropagation(),this.closeModal(e))}},{key:\"onKeydown\",value:function(e){27===e.keyCode&&this.closeModal(e),9===e.keyCode&&this.retainFocus(e)}},{key:\"getFocusableNodes\",value:function(){var e=this.modal.querySelectorAll(n);return Array.apply(void 0,t(e))}},{key:\"setFocusToFirstNode\",value:function(){var e=this;if(!this.config.disableFocus){var t=this.getFocusableNodes();if(0!==t.length){var o=t.filter((function(t){return!t.hasAttribute(e.config.closeTrigger)}));o.length>0&&o[0].focus(),0===o.length&&t[0].focus()}}}},{key:\"retainFocus\",value:function(e){var t=this.getFocusableNodes();if(0!==t.length)if(t=t.filter((function(e){return null!==e.offsetParent})),this.modal.contains(document.activeElement)){var o=t.indexOf(document.activeElement);e.shiftKey&&0===o&&(t[t.length-1].focus(),e.preventDefault()),!e.shiftKey&&t.length>0&&o===t.length-1&&(t[0].focus(),e.preventDefault())}else t[0].focus()}}])&&e(i.prototype,a),r&&e(i,r),o}(),a=null,r=function(e){if(!document.getElementById(e))return console.warn(\"MicroModal: ❗Seems like you have missed %c'\".concat(e,\"'\"),\"background-color: #f8f9fa;color: #50596c;font-weight: bold;\",\"ID somewhere in your code. Refer example below to resolve it.\"),console.warn(\"%cExample:\",\"background-color: #f8f9fa;color: #50596c;font-weight: bold;\",'
')),!1},s=function(e,t){if(function(e){e.length<=0&&(console.warn(\"MicroModal: ❗Please specify at least one %c'micromodal-trigger'\",\"background-color: #f8f9fa;color: #50596c;font-weight: bold;\",\"data attribute.\"),console.warn(\"%cExample:\",\"background-color: #f8f9fa;color: #50596c;font-weight: bold;\",''))}(e),!t)return!0;for(var o in t)r(o);return!0},{init:function(e){var o=Object.assign({},{openTrigger:\"data-micromodal-trigger\"},e),n=t(document.querySelectorAll(\"[\".concat(o.openTrigger,\"]\"))),r=function(e,t){var o=[];return e.forEach((function(e){var n=e.attributes[t].value;void 0===o[n]&&(o[n]=[]),o[n].push(e)})),o}(n,o.openTrigger);if(!0!==o.debugMode||!1!==s(n,r))for(var l in r){var c=r[l];o.targetModal=l,o.triggers=t(c),a=new i(o)}},show:function(e,t){var o=t||{};o.targetModal=e,!0===o.debugMode&&!1===r(e)||(a&&a.removeEventListeners(),(a=new i(o)).showModal())},close:function(e){e?a.closeModalById(e):a.closeModal()}});\"undefined\"!=typeof window&&(window.MicroModal=l);export default l;\n","module.exports = window[\"wp\"][\"i18n\"];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = function(module) {\n\tvar getter = module && module.__esModule ?\n\t\tfunction() { return module['default']; } :\n\t\tfunction() { return module; };\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","// define __esModule on exports\n__webpack_require__.r = function(exports) {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import MicroModal from 'micromodal';\nimport {\n\t__,\n\tsprintf\n} from '@wordpress/i18n';\n\ndocument.addEventListener(\"DOMContentLoaded\", function() {\n\tconst simpleModalEl = document.querySelector( '.simple-modal-block' );\n\n\tif ( ! simpleModalEl ) {\n\t\treturn;\n\t}\n\n\tif ( simpleModalEl.id ) {\n\t\tconst delayInSeconds = simpleModalEl.dataset?.smbDelay;\n\t\tconst intervalInDays = simpleModalEl.dataset?.interval || 3;\n\t\tconst storageKey = `${simpleModalEl.id}-interval`;\n\t\tconst intervalDate = localStorage.getItem( storageKey );\n\n\t\tif ( ! delayInSeconds ) {\n\t\t\tMicroModal.init( {\n\t\t\t\topenClass: 'is-open',\n\t\t\t\topenTrigger: 'data-smb-open',\n\t\t\t\tcloseTrigger: 'data-smb-close',\n\t\t\t\tdisableScroll: true,\n\t\t\t} );\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tintervalDate &&\n\t\t\t((new Date(parseInt(intervalDate))).getTime() - (new Date()).getTime()) > 0\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetTimeout( () => {\n\t\t\ttry {\n\t\t\t\tMicroModal.show( simpleModalEl.id, {\n\t\t\t\t\topenClass: 'is-open',\n\t\t\t\t\topenTrigger: 'data-smb-open',\n\t\t\t\t\tcloseTrigger: 'data-smb-close',\n\t\t\t\t\tdisableScroll: true,\n\t\t\t\t\tonShow: () => {\n\t\t\t\t\t\tconst nextIntervalDate = new Date((new Date()).setDate( (new Date()).getDate() + intervalInDays ));\n\n\t\t\t\t\t\tlocalStorage.setItem( storageKey, String( nextIntervalDate.getTime() ) );\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t} catch ( error ) {\n\t\t\t\tconsole.error(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// translators: %s: The error message.\n\t\t\t\t\t\t__( 'Simple modal block error: %s', 'simple-modal-block' ),\n\t\t\t\t\t\terror\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}, delayInSeconds * 1000 );\n\t} else {\n\t\tconsole.warn(\n\t\t\t__( 'The simple modal block requires a anchor value to be set.', 'simple-modal-block' )\n\t\t);\n\t}\n});\n"],"names":["MicroModal","__","sprintf","document","addEventListener","simpleModalEl","querySelector","id","delayInSeconds","dataset","smbDelay","intervalInDays","interval","storageKey","intervalDate","localStorage","getItem","init","openClass","openTrigger","closeTrigger","disableScroll","Date","parseInt","getTime","setTimeout","show","onShow","nextIntervalDate","setDate","getDate","setItem","String","error","console","warn"],"sourceRoot":""}