!function(){"use strict";var e=window.wp.element;const t=(e,t)=>{const{buttonText:n,buttonLink:a,buttonIconSrc:i,installationStatus:s,pluginRes:u,success:l,message:o}=e;let _=n,c="#",m="",g="",r={},d=i;switch(t.type){case"INSTALLATION_BEGINS":return"install-plugin"===gutena_theme_admin.plugin_action?(g="Plugin Installation Begins",_=gutena_theme_admin.installing_plugin_text):"activate-plugin"===gutena_theme_admin.plugin_action&&(g="Plugin activation Begins",_=gutena_theme_admin.activateing_plugin_text),r={buttonText:_,buttonLink:c,buttonIconSrc:d,installationStatus:"start",pluginRes:{},message:g},r;case"INSTALLATION_END":return void 0!==t.response.success&&t.response.success?(g=g=void 0===t.response.data||void 0===t.response.data.message?"Gutena Kit plugin activated successfully":t.response.data.message,_=gutena_theme_admin.success_plugin_text,c=gutena_theme_admin.demo_import_page_url,d=gutena_theme_admin.success_svg_url,m="success"):(m="failed",g=void 0===t.response.data||void 0===t.response.data.message?gutena_theme_admin.default_failed_text:t.response.data.message,_="install-plugin"===gutena_theme_admin.plugin_action?gutena_theme_admin.install_plugin_text:gutena_theme_admin.activate_plugin_text),r={buttonText:_,buttonLink:c,buttonIconSrc:d,installationStatus:m,pluginRes:t.response,message:g},r;default:return e}},{createContext:n,useReducer:a}=wp.element,i=n();var s=n=>{let s="#",u="",l="";"install-plugin"===gutena_theme_admin.plugin_action?(u=gutena_theme_admin.install_plugin_text,l=gutena_theme_admin.download_svg_url):"activate-plugin"===gutena_theme_admin.plugin_action?u=gutena_theme_admin.activate_plugin_text:(u=gutena_theme_admin.success_plugin_text,s=gutena_theme_admin.demo_import_page_url);let o={buttonText:u,buttonLink:s,buttonIconSrc:l,installationStatus:"",pluginRes:"",message:""};const[_,c]=a(t,o);return(0,e.createElement)(i.Provider,{value:{..._,dispatch:c}},n.children)};const{useContext:u,useEffect:l}=wp.element;var o=t=>{const{buttonText:n,buttonLink:a,buttonIconSrc:s,installationStatus:o,pluginRes:_,message:c,dispatch:m}=u(i);return l((()=>{setTimeout((()=>{"success"===o&&(location.href=gutena_theme_admin.demo_import_page_url)}),1e3)})),(0,e.createElement)("button",{className:`gutena-action-button ${o}-btn ${t.addclass}`,onClick:async e=>{if("#"===a&&"start"!=o){e.preventDefault(),m({type:"INSTALLATION_BEGINS"});const t=await(async()=>await fetch(gutena_theme_admin.ajax_url,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-WP-Nonce":gutena_theme_admin.nonce},body:new URLSearchParams({action:"install_activate_gutena_kit",gutena_security:gutena_theme_admin.nonce,plugin_require_action:gutena_theme_admin.plugin_action})}).then((e=>e.json())))();m({type:"INSTALLATION_END",response:t})}else"#"!==a&&a.length>7&&(location.href=gutena_theme_admin.demo_import_page_url)}}," ",""!==s?(0,e.createElement)("img",{src:s,alt:n,title:n}):""," ",(0,e.createElement)("span",null,n)," ")};const{Component:_,Fragment:c,render:m}=wp.element;class g extends _{render(){return"undefined"==typeof gutena_theme_admin?(0,e.createElement)("div",null):(0,e.createElement)(c,null,(0,e.createElement)(s,null,(0,e.createElement)(o,{addclass:" bg-gutena-wp-primary-btn "})))}}document.getElementById("install-gutena-kit-plugin")&&wp.domReady((()=>{m((0,e.createElement)(g,null),document.querySelector("#install-gutena-kit-plugin"))}))}();