(()=>{"use strict";var M={n:L=>{var I=L&&L.__esModule?()=>L.default:()=>L;return M.d(I,{a:I}),I},d:(L,I)=>{for(var j in I)M.o(I,j)&&!M.o(L,j)&&Object.defineProperty(L,j,{enumerable:!0,get:I[j]})},o:(M,L)=>Object.prototype.hasOwnProperty.call(M,L)};const L=window.wp.domReady;var I=M.n(L);const j=window.wp.element,u="nfd-installer",g=window.nfdInstaller?.restUrl,A=window.nfdInstaller?.pluginInstallHash,N=`${g}/newfold-installer/v1/plugins/install`,D=window.wp.apiFetch;var y=M.n(D);const S=window.wp.i18n;window.React;const T=window.ReactJSXRuntime,C=({action:M,pluginBasename:L,pluginDownloadUrl:I,pluginName:g,pluginProvider:D,pluginSlug:C,redirectUrl:i})=>{const[t,E]=(0,j.useState)("unknown"),[x,z]=(0,j.useState)(!0),w=(0,j.useRef)(null);(0,j.useEffect)((()=>{document.getElementById(u).style.display=x?"block":"none"}),[x]),(0,j.useEffect)((()=>{switch(M){case"installFreePlugin":c();break;case"installPremiumPlugin":U()}}),[M]);const O=M=>{"Escape"===M.key&&z(!1)},Y=M=>{"failed"===t&&w.current&&!w.current.contains(M.target)&&z(!1)};(0,j.useEffect)((()=>(document.addEventListener("keydown",O),document.addEventListener("mousedown",Y),()=>{document.removeEventListener("keydown",O),document.removeEventListener("mousedown",Y)})),[t]);const Q=async()=>{try{"yith"===D?await y()({url:N,method:"POST",headers:{"X-NFD-INSTALLER":A},data:{queue:!1,priority:0,plugin:"woocommerce",basename:"woocommerce/woocommerce.php"}}):"yoast"===D?await y()({url:N,method:"POST",headers:{"X-NFD-INSTALLER":A},data:{queue:!1,priority:0,plugin:"wordpress-seo",basename:"wordpress-seo/wp-seo.php"}}):"bluehost"===D&&await y()({url:N,method:"POST",headers:{"X-NFD-INSTALLER":A},data:{queue:!1,priority:0,plugin:"woocommerce",basename:"woocommerce/woocommerce.php"}})}catch(M){throw M}},U=async()=>{try{E("installing"),await Q(),await y()({url:N,method:"POST",headers:{"X-NFD-INSTALLER":A},data:{queue:!1,priority:0,premium:!0,plugin:C,provider:D,basename:L}}),E("completed"),window.location.href=i}catch(M){E("failed")}},c=async()=>{try{E("installing"),await Q();const M=await y()({url:N,method:"POST",parse:!1,headers:{"X-NFD-INSTALLER":A},data:{queue:!1,priority:0,plugin:I,basename:L}});if(M.status>=300&&M.status<400){E("completed");const L=M.headers.get("Location");window.location.href=L||i}else{if(!M.ok)throw new Error(`HTTP ${M.status}: ${M.statusText}`);E("completed"),window.location.href=i}}catch(M){E("failed")}},e=`${window.NewfoldRuntime.adminUrl}admin.php?page=${window.NewfoldRuntime.plugin.brand}#/help`,s=(0,j.createInterpolateElement)((0,S.__)("Sorry, there was an error installing and activating the plugin. Please try again. If the problem persists, <a>contact support</a>.","wp-module-installer"),{a:(0,T.jsx)("a",{href:e,onClick:()=>z(!1)})});return(0,T.jsx)("div",{className:"nfd-installer-modal",children:(0,T.jsxs)("div",{ref:w,className:"nfd-installer-modal__content",children:[(0,T.jsx)("div",{className:"nfd-installer-modal__content-heading",children:(0,S.__)("Hold on while we get things setup for you!","wp-module-installer")}),(0,T.jsxs)("div",{className:"nfd-installer-modal__content-section",children:[(0,T.jsx)("img",{src:"data:image/svg+xml;base64,[encoded data, 37372 characters]",alt:(0,S.__)("Loading Vector.","wp-module-installer"),className:"nfd-installer-modal__content-image"}),"installing"===t&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("div",{className:"nfd-installer-modal__content-subheading",children:(0,S.sprintf)(/* translators: %s: Plugin Name */ /* translators: %s: Plugin Name */
(0,S.__)("Activating %s","wp-module-installer"),g)}),(0,T.jsx)("div",{className:"nfd-installer-modal__loader"})]}),"completed"===t&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("div",{className:"nfd-installer-modal__content-subheading",children:(0,S.__)("Activation Complete! Redirecting…","wp-module-installer")}),(0,T.jsx)("div",{className:"nfd-installer-modal__loader"})]}),"failed"===t&&(0,T.jsxs)("div",{className:"nfd-installer-modal__content-error",children:[(0,T.jsx)("img",{src:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjgiIGhlaWdodD0iMjkiIHZpZXdCb3g9IjAgMCAyOCAyOSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0yNS4yIDE0LjVDMjUuMiAyMC42ODU2IDIwLjE4NTYgMjUuNyAxNCAyNS43QzcuODE0NCAyNS43IDIuNzk5OTkgMjAuNjg1NiAyLjc5OTk5IDE0LjVDMi43OTk5OSA4LjMxNDQ2IDcuODE0NCAzLjMwMDA1IDE0IDMuMzAwMDVDMjAuMTg1NiAzLjMwMDA1IDI1LjIgOC4zMTQ0NiAyNS4yIDE0LjVaTTE0IDcuNTAwMDVDMTQuNTc5OSA3LjUwMDA1IDE1LjA1IDcuOTcwMTUgMTUuMDUgOC41NTAwNVYxNC44NUMxNS4wNSAxNS40Mjk5IDE0LjU3OTkgMTUuOSAxNCAxNS45QzEzLjQyMDEgMTUuOSAxMi45NSAxNS40Mjk5IDEyLjk1IDE0Ljg1VjguNTUwMDVDMTIuOTUgNy45NzAxNSAxMy40MjAxIDcuNTAwMDUgMTQgNy41MDAwNVpNMTQgMjEuNUMxNC43NzMyIDIxLjUgMTUuNCAyMC44NzMyIDE1LjQgMjAuMUMxNS40IDE5LjMyNjggMTQuNzczMiAxOC43IDE0IDE4LjdDMTMuMjI2OCAxOC43IDEyLjYgMTkuMzI2OCAxMi42IDIwLjFDMTIuNiAyMC44NzMyIDEzLjIyNjggMjEuNSAxNCAyMS41WiIgZmlsbD0iI0M3MTkxOSIvPgo8L3N2Zz4K",alt:(0,S.__)("Error Icon.","wp-module-installer"),className:"nfd-installer-modal__content-error--icon"}),(0,T.jsx)("div",{children:s})]})]})]})})},i=()=>{const[M,L]=(0,j.useState)(),[I,u]=(0,j.useState)(!1),[g,A]=(0,j.useState)(),[N,D]=(0,j.useState)(),[y,S]=(0,j.useState)(),[i,t]=(0,j.useState)(),[E,x]=(0,j.useState)(),[z,w]=(0,j.useState)(),O=M=>{u(!1),L(M.detail.action),A(M.detail.pluginBasename),D(M.detail.pluginName),S(M.detail.pluginDownloadUrl),t(M.detail.pluginProvider),x(M.detail.pluginSlug),w(M.detail.redirectUrl),u(!0)};return(0,j.useEffect)((()=>(window.addEventListener("installerParamsSet",O),()=>{window.removeEventListener("installerParamsSet",O)})),[]),(0,T.jsx)("div",{className:"nfd-installer-app",children:I&&(0,T.jsx)(C,{action:M,pluginBasename:g,pluginName:N,pluginDownloadUrl:y,pluginProvider:i,pluginSlug:E,redirectUrl:z})})};I()((()=>{t(u)}));const t=M=>{const L=document.createElement("div");L.id=M,document.getElementById(M)||document.body.append(L),void 0!==j.createRoot&&(0,j.createRoot)(L).render((0,T.jsx)(i,{}))};((window.newfold=window.newfold||{}).Installer=window.newfold.Installer||{}).installer={}})();