!function(){"use strict";var t={};function e(t,e,n,r,a,o,i){try{var s=t[o](i),u=s.value}catch(t){return void n(t)}s.done?e(u):Promise.resolve(u).then(r,a)}function n(t){return n="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},n(t)}function r(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}function a(t,e){for(var n=0;n<e.length;n++){var a=e[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,r(a.key),a)}}t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,{a:n}),n},t.d=function(e,n){for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},t.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};var o=window.regeneratorRuntime,i=t.n(o),s=window.wp.apiFetch,u=t.n(s),c=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.nonce=PatternsRestaurantLocalize.nonce,this.bindEvents()},n=[{key:"bindEvents",value:function(){var t=this;document.addEventListener("click",function(e){e.target.classList.contains("patterns-restaurant-install-plugin")&&(e.target.classList.add("patterns-restaurant-processing"),t.installPlugin(e.target))})}},{key:"installPlugin",value:(r=i().mark(function t(e){var n,r,a,o;return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.dataset.plugin,r=JSON.parse(n),t.prev=1,t.next=2,u()({path:"patterns-restaurant/v1/install-plugin",method:"POST",data:r,headers:{"X-WP-Nonce":this.nonce}});case 2:(a=t.sent)&&(a.success?(e.innerText=e.dataset.successText,e.disabled=!0,e.classList.remove("patterns-restaurant-install-plugin")):e.innerText=e.dataset.failText),t.next=4;break;case 3:t.prev=3,o=t.catch(1),console.error(o),e.innerText=e.dataset.failText;case 4:e.classList.remove("patterns-restaurant-processing");case 5:case"end":return t.stop()}},t,this,[[1,3]])}),o=function(){var t=this,n=arguments;return new Promise(function(a,o){var i=r.apply(t,n);function s(t){e(i,a,o,s,u,"next",t)}function u(t){e(i,a,o,s,u,"throw",t)}s(void 0)})},function(_x){return o.apply(this,arguments)})}],n&&a(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,r,o}();document.addEventListener("DOMContentLoaded",function(){new c})}();