!function(){"use strict";var t={};function e(t,e,n,r,i,o,a){try{var c=t[o](a),s=c.value}catch(t){return void n(t)}c.done?e(s):Promise.resolve(s).then(r,i)}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 i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,r(i.key),i)}}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,a=t.n(o),c=window.wp.apiFetch,s=t.n(c),u=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=PatternsCharityLocalize.nonce,this.bindEvents()},n=[{key:"bindEvents",value:function(){var t=this;document.addEventListener("click",function(e){e.target.classList.contains("patterns-charity-install-plugin")&&(e.target.classList.add("patterns-charity-processing"),t.installPlugin(e.target))})}},{key:"installPlugin",value:(r=a().mark(function t(e){var n,r,i,o;return a().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,s()({path:"patterns-charity/v1/install-plugin",method:"POST",data:r,headers:{"X-WP-Nonce":this.nonce}});case 2:(i=t.sent)&&(i.success?(e.innerText=e.dataset.successText,e.disabled=!0,e.classList.remove("patterns-charity-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-charity-processing");case 5:case"end":return t.stop()}},t,this,[[1,3]])}),o=function(){var t=this,n=arguments;return new Promise(function(i,o){var a=r.apply(t,n);function c(t){e(a,i,o,c,s,"next",t)}function s(t){e(a,i,o,c,s,"throw",t)}c(void 0)})},function(_x){return o.apply(this,arguments)})}],n&&i(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,r,o}();document.addEventListener("DOMContentLoaded",function(){new u})}();