!function(){"use strict";var t={};function e(t,e,n,r,o,i,a){try{var s=t[i](a),u=s.value}catch(t){return void n(t)}s.done?e(u):Promise.resolve(u).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,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=PatternsAutomotiveLocalize.nonce,this.bindEvents()},n=[{key:"bindEvents",value:function(){var t=this;document.addEventListener("click",(function(e){e.target.classList.contains("patterns-automotive-install-plugin")&&(e.target.classList.add("patterns-automotive-processing"),t.installPlugin(e.target))}))}},{key:"installPlugin",value:(r=a().mark((function t(e){var n,r,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=2,t.next=5,u()({path:"patterns-automotive/v1/install-plugin",method:"POST",data:r,headers:{"X-WP-Nonce":this.nonce}});case 5:(o=t.sent)&&(o.success?(e.innerText=e.dataset.successText,e.disabled=!0,e.classList.remove("patterns-automotive-install-plugin")):e.innerText=e.dataset.failText),t.next=13;break;case 9:t.prev=9,t.t0=t.catch(2),console.error(t.t0),e.innerText=e.dataset.failText;case 13:e.classList.remove("patterns-automotive-processing");case 14:case"end":return t.stop()}}),t,this,[[2,9]])})),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,u,"next",t)}function u(t){e(a,o,i,s,u,"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 c}))}();