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