laipower/wp-content/plugins/gp-premium/dist/site-library.js

6 lines
27 KiB
JavaScript

(()=>{var e={703:(e,t,r)=>{"use strict";var n=r(414);function a(){}function s(){}s.resetWarningCache=a,e.exports=function(){function e(e,t,r,a,s,i){if(i!==n){var l=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw l.name="Invariant Violation",l}}function t(){return e}e.isRequired=e;var r={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:s,resetWarningCache:a};return r.PropTypes=r,r}},697:(e,t,r)=>{e.exports=r(703)()},414:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},216:(e,t,r)=>{"use strict";t.be=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),a=r(196),s=m(a),i=m(r(697)),l=r(81),o=m(r(315)),p=m(r(282)),c=m(r(821));function m(e){return e&&e.__esModule?e:{default:e}}var u="data-lazyload-listened",d=[],g=[],h=!1;try{var f=Object.defineProperty({},"passive",{get:function(){h=!0}});window.addEventListener("test",null,f)}catch(e){}var b=!!h&&{capture:!1,passive:!0},v=function(e){var t=e.ref;if(t instanceof HTMLElement){var r=(0,o.default)(t),n=e.props.overflow&&r!==t.ownerDocument&&r!==document&&r!==document.documentElement?function(e,t){var r=e.ref,n=void 0,a=void 0,s=void 0,i=void 0;try{var l=t.getBoundingClientRect();n=l.top,a=l.left,s=l.height,i=l.width}catch(e){n=0,a=0,s=0,i=0}var o=window.innerHeight||document.documentElement.clientHeight,p=window.innerWidth||document.documentElement.clientWidth,c=Math.max(n,0),m=Math.max(a,0),u=Math.min(o,n+s)-c,d=Math.min(p,a+i)-m,g=void 0,h=void 0,f=void 0,b=void 0;try{var v=r.getBoundingClientRect();g=v.top,h=v.left,f=v.height,b=v.width}catch(e){g=0,h=0,f=0,b=0}var y=g-c,_=h-m,E=Array.isArray(e.props.offset)?e.props.offset:[e.props.offset,e.props.offset];return y-E[0]<=u&&y+f+E[1]>=0&&_-E[0]<=d&&_+b+E[1]>=0}(e,r):function(e){var t=e.ref;if(!(t.offsetWidth||t.offsetHeight||t.getClientRects().length))return!1;var r=void 0,n=void 0;try{var a=t.getBoundingClientRect();r=a.top,n=a.height}catch(e){r=0,n=0}var s=window.innerHeight||document.documentElement.clientHeight,i=Array.isArray(e.props.offset)?e.props.offset:[e.props.offset,e.props.offset];return r-i[0]<=s&&r+n+i[1]>=0}(e);n?e.visible||(e.props.once&&g.push(e),e.visible=!0,e.forceUpdate()):e.props.once&&e.visible||(e.visible=!1,e.props.unmountIfInvisible&&e.forceUpdate())}},y=function(){for(var e=0;e<d.length;++e){var t=d[e];v(t)}g.forEach((function(e){var t=d.indexOf(e);-1!==t&&d.splice(t,1)})),g=[]},_=void 0,E=null,w=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.visible=!1,r.setRef=r.setRef.bind(r),r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),n(t,[{key:"componentDidMount",value:function(){var e=window,t=this.props.scrollContainer;t&&"string"==typeof t&&(e=e.document.querySelector(t));var r=void 0!==this.props.debounce&&"throttle"===_||"debounce"===_&&void 0===this.props.debounce;if(r&&((0,l.off)(e,"scroll",E,b),(0,l.off)(window,"resize",E,b),E=null),E||(void 0!==this.props.debounce?(E=(0,p.default)(y,"number"==typeof this.props.debounce?this.props.debounce:300),_="debounce"):void 0!==this.props.throttle?(E=(0,c.default)(y,"number"==typeof this.props.throttle?this.props.throttle:300),_="throttle"):E=y),this.props.overflow){var n=(0,o.default)(this.ref);if(n&&"function"==typeof n.getAttribute){var a=+n.getAttribute(u)+1;1===a&&n.addEventListener("scroll",E,b),n.setAttribute(u,a)}}else if(0===d.length||r){var s=this.props,i=s.scroll,m=s.resize;i&&(0,l.on)(e,"scroll",E,b),m&&(0,l.on)(window,"resize",E,b)}d.push(this),v(this)}},{key:"shouldComponentUpdate",value:function(){return this.visible}},{key:"componentWillUnmount",value:function(){if(this.props.overflow){var e=(0,o.default)(this.ref);if(e&&"function"==typeof e.getAttribute){var t=+e.getAttribute(u)-1;0===t?(e.removeEventListener("scroll",E,b),e.removeAttribute(u)):e.setAttribute(u,t)}}var r=d.indexOf(this);-1!==r&&d.splice(r,1),0===d.length&&"undefined"!=typeof window&&((0,l.off)(window,"resize",E,b),(0,l.off)(window,"scroll",E,b))}},{key:"setRef",value:function(e){e&&(this.ref=e)}},{key:"render",value:function(){var e=this.props,t=e.height,r=e.children,n=e.placeholder,a=e.className,i=e.classNamePrefix,l=e.style;return s.default.createElement("div",{className:i+"-wrapper "+a,ref:this.setRef,style:l},this.visible?r:n||s.default.createElement("div",{style:{height:t},className:i+"-placeholder"}))}}]),t}(a.Component);w.propTypes={className:i.default.string,classNamePrefix:i.default.string,once:i.default.bool,height:i.default.oneOfType([i.default.number,i.default.string]),offset:i.default.oneOfType([i.default.number,i.default.arrayOf(i.default.number)]),overflow:i.default.bool,resize:i.default.bool,scroll:i.default.bool,children:i.default.node,throttle:i.default.oneOfType([i.default.number,i.default.bool]),debounce:i.default.oneOfType([i.default.number,i.default.bool]),placeholder:i.default.node,scrollContainer:i.default.oneOfType([i.default.string,i.default.object]),unmountIfInvisible:i.default.bool,style:i.default.object},w.defaultProps={className:"",classNamePrefix:"lazyload",once:!1,offset:0,overflow:!1,resize:!1,scroll:!0,unmountIfInvisible:!1},t.ZP=w,t.be=y},282:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){var n=void 0,a=void 0,s=void 0,i=void 0,l=void 0,o=function o(){var p=+new Date-i;p<t&&p>=0?n=setTimeout(o,t-p):(n=null,r||(l=e.apply(s,a),n||(s=null,a=null)))};return function(){s=this,a=arguments,i=+new Date;var p=r&&!n;return n||(n=setTimeout(o,t)),p&&(l=e.apply(s,a),s=null,a=null),l}}},81:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.on=function(e,t,r,n){n=n||!1,e.addEventListener?e.addEventListener(t,r,n):e.attachEvent&&e.attachEvent("on"+t,(function(t){r.call(e,t||window.event)}))},t.off=function(e,t,r,n){n=n||!1,e.removeEventListener?e.removeEventListener(t,r,n):e.detachEvent&&e.detachEvent("on"+t,r)}},315:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){if(!(e instanceof HTMLElement))return document.documentElement;for(var t="absolute"===e.style.position,r=/(scroll|auto)/,n=e;n;){if(!n.parentNode)return e.ownerDocument||document.documentElement;var a=window.getComputedStyle(n),s=a.position,i=a.overflow,l=a["overflow-x"],o=a["overflow-y"];if("static"===s&&t)n=n.parentNode;else{if(r.test(i)&&r.test(l)&&r.test(o))return n;n=n.parentNode}}return e.ownerDocument||e.documentElement||document.documentElement}},821:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){var n,a;return t||(t=250),function(){var s=r||this,i=+new Date,l=arguments;n&&i<n+t?(clearTimeout(a),a=setTimeout((function(){n=i,e.apply(s,l)}),t)):(n=i,e.apply(s,l))}}},196:e=>{"use strict";e.exports=window.React}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e=r(196);const t=window.wp.i18n,n=window.wp.element,a=window.wp.components,s=window.wp.htmlEntities,i=window.wp.apiFetch;var l,o,p=r.n(i),c=r(216);function m(e,t,r){const n=r&&r.lexicographical,a=r&&r.zeroExtend;let s=e.split("."),i=t.split(".");function l(e){return(n?/^\d+[A-Za-z]*$/:/^\d+$/).test(e)}if(!s.every(l)||!i.every(l))return NaN;if(a){for(;s.length<i.length;)s.push("0");for(;i.length<s.length;)i.push("0")}n||(s=s.map(Number),i=i.map(Number));for(let e=0;e<s.length;++e){if(i.length===e)return 1;if(s[e]!==i[e])return s[e]>i[e]?1:-1}return s.length!==i.length?-1:0}function u({allSites:r,value:n,onChange:s}){if(!r)return null;const i=[""];return Object.keys(r).forEach((e=>{r[e].category.forEach((e=>{i.includes(e)||i.push(e)}))})),i.length<2?null:(0,e.createElement)("div",null,i.map((r=>(0,e.createElement)(a.Button,{key:r,variant:r===n?"primary":"",onClick:()=>s(r)},""===r?(0,t.__)("All","gp-premium"):r))))}function d({onChange:r,value:n}){return(0,e.createElement)("div",null,(0,e.createElement)("input",{type:"search",onChange:e=>r(e?.target?.value),value:n,placeholder:(0,t.__)("Search site name or author","gp-premium")}))}function g({url:t,previewWidth:r}){const a=(0,n.useRef)(null);return(0,n.useEffect)((()=>{const e=a.current.attachShadow({mode:"open"}),r=document.createElement("iframe");return r.src=t,r.style.width="100%",r.style.height="100%",e.appendChild(r),()=>{e.removeChild(r)}}),[t]),(0,e.createElement)("div",{style:{width:r},ref:a})}l=(0,e.createElement)((function(){const[r,i]=(0,n.useState)(!1),[l,o]=(0,n.useState)({}),[h,f]=(0,n.useState)(!1),[b,v]=(0,n.useState)(!1),[y,_]=(0,n.useState)({}),[E,w]=(0,n.useState)({}),[C,k]=(0,n.useState)({}),[S,O]=(0,n.useState)(!1),[T,x]=(0,n.useState)(!0),[N,L]=(0,n.useState)(!0),[P,R]=(0,n.useState)(!1),[j,B]=(0,n.useState)(!1),[I,D]=(0,n.useState)([]),[A,M]=(0,n.useState)([]),[W,F]=(0,n.useState)([]),[U,z]=(0,n.useState)(!1),[H,V]=(0,n.useState)(gppSiteLibrary.hasBackup),[G,q]=(0,n.useState)(""),[Z,$]=(0,n.useState)(""),[J,Y]=(0,n.useState)("desktop");function K(e){e.classList.add("gpp-library-action-message--show"),e.textContent=(0,t.__)("Activating plugins","gp-premium"),p()({path:"/generatepress-site-library/v1/activate_plugins",method:"POST",data:{siteData:y,siteSlug:y.name.replace(/\s+/g,"_").toLowerCase(),importOptions:T,importContent:N}}).then((t=>{e.textContent=t.response,t.success&&t.response||e.classList.add("gblocks-action-message--error"),setTimeout((()=>{Q(e)}),2e3)}))}function Q(e){e.classList.add("gpp-library-action-message--show"),e.textContent=(0,t.__)("Importing content","gp-premium"),p()({path:"/generatepress-site-library/v1/import_content",method:"POST",data:{siteData:y,siteSlug:y.name.replace(/\s+/g,"_").toLowerCase(),importOptions:T,importContent:N}}).then((r=>{e.textContent=r.response,r.success&&r.response||e.classList.add("gblocks-action-message--error"),setTimeout((()=>{!function(e){e.classList.add("gpp-library-action-message--show"),e.textContent=(0,t.__)("Importing site options","gp-premium"),p()({path:"/generatepress-site-library/v1/import_site_options",method:"POST",data:{siteData:y,siteSlug:y.name.replace(/\s+/g,"_").toLowerCase(),importOptions:T,importContent:N}}).then((r=>{e.textContent=r.response,r.success&&r.response||e.classList.add("gblocks-action-message--error"),setTimeout((()=>{S?function(e){e.classList.add("gpp-library-action-message--show"),e.textContent=(0,t.__)("Importing widgets","gp-premium"),p()({path:"/generatepress-site-library/v1/import_widgets",method:"POST",data:{siteData:y,siteSlug:y.name.replace(/\s+/g,"_").toLowerCase(),importOptions:T,importContent:N}}).then((r=>{e.textContent=r.response,r.success&&r.response||e.classList.add("gblocks-action-message--error"),setTimeout((()=>{e.textContent=(0,t.__)("Import Complete","gp-premium"),f(!1),B(!0),V(!0)}),2e3)}))}(e):(e.textContent=(0,t.__)("Import Complete","gp-premium"),f(!1),B(!0),V(!0))}),2e3)}))}(e)}),2e3)}))}if((0,n.useEffect)((()=>{p()({path:"/generatepress-site-library/v1/get_sites",method:"POST",data:{forceRefresh:!1}}).then((e=>{i(!0),o(e.response)}))}),[]),!r)return(0,e.createElement)(a.Placeholder,{className:"gpp-library-placeholder"},(0,e.createElement)(a.Spinner,null));if(!l||"no results"===l)return(0,e.createElement)("div",{className:"generatepress-site-library-no-results"},(0,e.createElement)("p",null,(0,t.__)("No sites were found.","gp-premium")," ",(0,e.createElement)("a",{href:"https://docs.generatepress.com/article/site-library-unavailable/",target:"_blank",rel:"noreferrer noopener"},(0,t.__)("Why?","gp-premium"))),(0,e.createElement)(a.Button,{variant:"primary",onClick:()=>{z(!0),p()({path:"/generatepress-site-library/v1/get_sites",method:"POST",data:{forceRefresh:!0}}).then((e=>{i(!0),o(e.response),z(!1)}))}},U&&(0,e.createElement)(a.Spinner,null),!U&&(0,t.__)("Try again","gp-premium")));let X="100%";"tablet"===J&&(X="768px"),"mobile"===J&&(X="480px");const ee=y.author_name&&y.author_url&&"GeneratePress"!==y.author_name;return(0,e.createElement)(n.Fragment,null,(0,e.createElement)("div",{className:"generatepress-site-library"},!!H&&(0,e.createElement)("div",{className:"generatepress-site-library-restore"},(0,e.createElement)("h2",null,(0,t.__)("Existing Site Import Detected","gp-premium")),(0,e.createElement)("p",null,(0,t.__)("It is highly recommended that you remove the last site you imported before importing a new one.","gp-premium")),(0,e.createElement)("p",null,(0,t.__)("This process restores your previous options, widgets and active plugins. It will also remove your imported content and CSS.","gp-premium")),(0,e.createElement)("div",{className:"gpp-library-action-button"},(0,e.createElement)(a.Button,{variant:"primary",onClick:e=>{window.confirm((0,t.__)("This process makes changes to your website. If it contains important data, we suggest backing it up before proceeding.","gp-premium"))&&(f(!0),function(e){const r=e.target.nextElementSibling;r.classList.add("gpp-library-action-message--show"),r.textContent=(0,t.__)("Restoring theme options","gp-premium"),p()({path:"/generatepress-site-library/v1/restore_theme_options",method:"POST"}).then((e=>{r.textContent=e.response,e.success&&e.response||r.classList.add("gblocks-action-message--error"),setTimeout((()=>{r.textContent=(0,t.__)("Restoring content","gp-premium"),p()({path:"/generatepress-site-library/v1/restore_content",method:"POST"}).then((e=>{r.textContent=e.response,e.success&&e.response||r.classList.add("gblocks-action-message--error"),f(!1),V(!1)}))}),2e3)}))}(e))}},h&&(0,e.createElement)(a.Spinner,null),!h&&(0,t.__)("Remove imported site","gp-premium")),(0,e.createElement)("span",{className:"gpp-library-action-message"}),!h&&(0,e.createElement)(a.Button,{onClick:()=>{V(!1)}},(0,t.__)("No thanks","gp-premium")))),!b&&!H&&(0,e.createElement)(n.Fragment,null,(0,e.createElement)("div",{className:"generatepress-site-library-filter"},(0,e.createElement)(u,{allSites:l,value:G,onChange:e=>{q(e),setTimeout((()=>{(0,c.be)()}),100)}}),(0,e.createElement)(d,{value:Z,onChange:e=>{$(e),q(""),setTimeout((()=>{(0,c.be)()}),100)}})),(0,e.createElement)("ul",{className:"generatepress-site-library-list"},Object.keys(l).map((r=>{if(""!==G&&!l[r].category.includes(G))return null;const n=l[r].name,a=(0,s.decodeEntities)(n);if(""!==Z&&!a.toLowerCase().includes(Z.toLowerCase())&&!l[r].author_name.toLowerCase().includes(Z.toLowerCase()))return null;const i=l[r].directory+"/screenshot.png",o=gppSiteLibrary.gppVersion.split("-")[0],p=l[r].min_version.split("-")[0],u=gppSiteLibrary.gpVersion.split("-")[0],d=gppSiteLibrary.generateblocksVersion.split("-")[0],g=l[r].min_theme_version?l[r].min_theme_version.split("-")[0]:u,h=l[r].min_generateblocks_version?l[r].min_generateblocks_version.split("-")[0]:d,f=l[r].image_width,b=l[r].image_height,y=m(p,o)>0||m(g,u)>0||d&&m(h,d)>0;return(0,e.createElement)("li",{className:"generatepress-site-library-list-item",key:n+":"+r},(0,e.createElement)("button",{disabled:y,onClick:()=>{v(!0),_(l[r]),w(JSON.parse(l[r].plugins))}},(0,e.createElement)("div",{className:"generatepress-site-library-list-item-image"},(0,e.createElement)(c.ZP,{offset:100,once:!0},(0,e.createElement)("img",{src:i,alt:n,width:f,height:b}))),(0,e.createElement)("div",{className:"generatepress-site-library-list-item-title"},a,!!y&&m(p,o)>0&&(0,e.createElement)("span",{className:"generatepress-site-library-required-version"},(0,t.sprintf)(/* translators: Version number */
(0,t.__)("Requires GP Premium %s.","gp-premium"),p)),!!y&&m(g,u)>0&&(0,e.createElement)("span",{className:"generatepress-site-library-required-version"},(0,t.sprintf)(/* translators: Version number */
(0,t.__)("Requires GeneratePress %s.","gp-premium"),g)),!!y&&d&&m(h,d)>0&&(0,e.createElement)("span",{className:"generatepress-site-library-required-version"},(0,t.sprintf)(/* translators: Version number */
(0,t.__)("Requires GenerateBlocks %s.","gp-premium"),h)))))}))),(0,e.createElement)("div",{className:"generatepress-site-library-refresh"},(0,e.createElement)(a.Button,{variant:"primary",onClick:()=>{z(!0),p()({path:"/generatepress-site-library/v1/get_sites",method:"POST",data:{forceRefresh:!0}}).then((e=>{i(!0),o(e.response),z(!1)}))}},U&&(0,e.createElement)(a.Spinner,null),!U&&(0,t.__)("Refresh sites","gp-premium")))),b&&(0,e.createElement)("div",{className:"generatepress-site-library-opened"},(0,e.createElement)("div",{className:"generatepress-site-library-iframe"},(0,e.createElement)(g,{url:y.preview_url,previewWidth:X})),(0,e.createElement)("div",{className:"generatepress-site-library-info"},(0,e.createElement)("div",{className:"generatepress-site-library-header"},(0,e.createElement)("div",{className:"generatepress-site-library-header__title"},(0,e.createElement)("h2",{className:ee?"has-author":""},(0,s.decodeEntities)(y.name)),ee&&(0,e.createElement)("span",{className:"site-library-author"},/* translators: Site library site built by "author name" */
(0,t.__)("Built by","gp-premium")+" ",(0,e.createElement)("a",{href:y.author_url,target:"_blank",rel:"noreferrer noopener"},y.author_name))),(0,e.createElement)(a.Button,{onClick:()=>{f(!1),v(!1),_({}),w({}),k({}),O(!1),x(!0),L(!0),R(!1),B(!1),D([]),M([]),F([])}},(0,e.createElement)("svg",{width:"35",height:"35",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",role:"img","aria-hidden":"true",focusable:"false"},(0,e.createElement)("path",{d:"M13 11.9l3.3-3.4-1.1-1-3.2 3.3-3.2-3.3-1.1 1 3.3 3.4-3.5 3.6 1 1L12 13l3.5 3.5 1-1z"})))),(0,e.createElement)("div",{className:"generatepress-site-library-content"},!!y.description&&(0,e.createElement)("p",null,(0,s.decodeEntities)(y.description)),!j&&(0,e.createElement)(n.Fragment,null,0===Object.keys(C).length&&(0,e.createElement)(n.Fragment,null,gppSiteLibrary.isDebugEnabled&&(0,e.createElement)(a.PanelBody,{className:"gpp-debug-panel",title:(0,t.__)("Debug Mode Enabled","gp-premium"),initialOpen:!1},(0,e.createElement)("p",null,(0,t.__)("WordPress debug mode is currently enabled. With this, any errors from third-party plugins might affect the import process.","gp-premium")),(0,e.createElement)("p",null,(0,t.__)("To disable it, find WP_DEBUG in your wp-config.php file and set it to false like the below.","gp-premium")),(0,e.createElement)("code",null,"define( 'WP_DEBUG', false );"),(0,e.createElement)("p",null,(0,e.createElement)("a",{href:"https://docs.generatepress.com/article/debug-mode-enabled/",target:"_blank",rel:"noreferrer noopener"},(0,t.__)("Learn more here","gp-premium")))),Object.keys(E).length>0&&(0,e.createElement)(n.Fragment,null,(0,e.createElement)("h3",null,(0,t.__)("Plugins","gp-premium")),(0,e.createElement)("p",null,(0,t.__)("This site uses the following plugins.","gp-premium")),(0,e.createElement)("ul",{className:"generatepress-site-library-plugins"},Object.entries(E).map((([t])=>(0,e.createElement)("li",{key:t},t))))),(0,e.createElement)("div",{className:"gpp-library-action-button"},(0,e.createElement)(a.Button,{variant:"primary",disabled:h,onClick:e=>{f(!0);const r=e.target.nextElementSibling;r.textContent=(0,t.__)("Gathering information","gp-premium"),p()({path:"/generatepress-site-library/v1/get_site_data",method:"POST",data:{siteData:y}}).then((e=>{const t=[],n=[],a=[];Object.entries(e.response.plugin_data).forEach((([r])=>{const s=e.response.plugin_data[r];s.repo&&!s.installed?t.push(s.name):s.installed||s.active?n.push(s.name):a.push(s.name)})),f(!1),k(e.response),w(e.response.plugins),O(e.response.widgets),D(t),M(n),F(a),r.classList.add("gpp-library-action-message--show"),r.textContent=e.response,e.success&&e.response?setTimeout((function(){r.classList.remove("gpp-library-action-message--show")}),3e3):r.classList.add("gpp-library-action-message--error")}))}},h&&(0,e.createElement)(a.Spinner,null),!h&&(0,t.__)("Get Started","gp-premium")),(0,e.createElement)("span",{className:"gpp-library-action-message"}))),Object.keys(C).length>0&&Object.keys(E).length>0&&(0,e.createElement)(n.Fragment,null,(0,e.createElement)("h3",null,(0,t.__)("Plugins","gp-premium")),I.length>0&&(0,e.createElement)(n.Fragment,null,(0,e.createElement)("p",null,(0,t.__)("These plugins can be installed automatically.","gp-premium")),(0,e.createElement)("ul",{className:"generatepress-site-library-plugins"},I.map((t=>(0,e.createElement)("li",{key:t},t))))),A.length>0&&(0,e.createElement)(n.Fragment,null,(0,e.createElement)("p",null,(0,t.__)("These plugins are already installed.","gp-premium")),(0,e.createElement)("ul",{className:"generatepress-site-library-plugins"},A.map((t=>(0,e.createElement)("li",{key:t},t))))),W.length>0&&(0,e.createElement)(n.Fragment,null,(0,e.createElement)("p",{style:{fontWeight:"bold"}},(0,t.__)("These plugins need to be installed manually.","gp-premium")),(0,e.createElement)("ul",{className:"generatepress-site-library-plugins"},W.map((t=>"GenerateBlocks Pro"===t?(0,e.createElement)("li",{key:t},(0,e.createElement)(a.ExternalLink,{href:"https://generatepress.com/blocks/#pricing"},t)):(0,e.createElement)("li",{key:t},t)))))),Object.keys(C).length>0&&(0,e.createElement)(n.Fragment,null,(0,e.createElement)("h3",null,(0,t.__)("Import","gp-premium")),!h&&0===W.length&&(0,e.createElement)(n.Fragment,null,(0,e.createElement)("p",null,(0,t.__)("This process makes changes to your website. If it contains important data, we suggest backing it up before proceeding.","gp-premium")),(0,e.createElement)(a.ToggleControl,{checked:!!P,label:(0,t.__)("I understand","gp-premium"),onChange:e=>{R(e)}})),(0,e.createElement)("div",{className:"gpp-library-action-button"},(0,e.createElement)(a.Button,{variant:"primary",disabled:!P||j||h||W.length>0,onClick:e=>{f(!0),function(e){const r=e.target.nextElementSibling;r.classList.add("gpp-library-action-message--show"),r.textContent=(0,t.__)("Importing theme options","gp-premium"),p()({path:"/generatepress-site-library/v1/import_theme_options",method:"POST",data:{siteData:y,siteSlug:y.name.replace(/\s+/g,"_").toLowerCase(),importOptions:T,importContent:N}}).then((e=>{r.textContent=e.response,e.success&&e.response||r.classList.add("gblocks-action-message--error"),setTimeout((()=>{N?Object.keys(C.plugin_data).length>0?function(e){void 0!==e.target&&(e=e.target.nextElementSibling),e.classList.add("gpp-library-action-message--show"),e.textContent=(0,t.__)("Installing plugins","gp-premium"),Object.entries(C.plugin_data).forEach((([r,n])=>{let a=n.slug.split("/")[0],s=n.name;n.installed?(delete C.plugin_data[r],0===Object.keys(C.plugin_data).length&&K(e)):("bb-plugin"===a&&(a="beaver-builder-lite-version",s="Beaver Builder Lite"),e.textContent=(0,t.sprintf)(/* translators: Installing "Plugin Name" */
(0,t.__)("Installing %s","gp-premium"),s),wp.updates.installPlugin({slug:a,success:t=>{console.log(t),delete C.plugin_data[r],0===Object.keys(C.plugin_data).length&&K(e)},error:t=>{console.log(t),delete C.plugin_data[r],0===Object.keys(C.plugin_data).length&&K(e)}}))}))}(r):Q(r):(r.textContent=(0,t.__)("Import Complete","gp-premium"),f(!1),B(!0),V(!0))}),2e3)}))}(e)}},h&&(0,e.createElement)(a.Spinner,null),!h&&(0,t.__)("Begin Import","gp-premium")),(0,e.createElement)("span",{className:"gpp-library-action-message"})))),!!j&&(0,e.createElement)(n.Fragment,null,(0,e.createElement)("h3",null,(0,t.__)("Import Complete","gp-premium")),(0,e.createElement)("p",null,(0,t.__)("Check out your new site and start making it yours!","gp-premium")),(0,e.createElement)("p",null,(0,t.__)("Note: We do our best to ensure all imported images are licensed for open use. However, image licenses can change, so we strongly advise that you replace all imported images with your own.","gp-premium")),(0,e.createElement)("a",{className:"components-button is-primary",href:gppSiteLibrary.homeUrl},(0,t.__)("View Site","gp-premium")),y.uploads_url&&Object.values(E).includes("elementor/elementor.php")&&(0,e.createElement)(n.Fragment,null,(0,e.createElement)("h3",null,(0,t.__)("Additional Cleanup","gp-premium")),(0,e.createElement)("p",null,(0,t.__)("This site is using Elementor which means you will want to replace the imported image URLs.","gp-premium")),(0,e.createElement)("p",null,(0,t.__)("Take note of the old and new URLs below, then head over to the Elementor Tools area to replace them.","gp-premium")),(0,e.createElement)(a.TextControl,{label:(0,t.__)("Old URL","gp-premium"),readOnly:!0,value:y.uploads_url}),(0,e.createElement)(a.TextControl,{label:(0,t.__)("New URL","gp-premium"),readOnly:!0,value:gppSiteLibrary.uploadsUrl}),(0,e.createElement)("a",{href:gppSiteLibrary.elementorReplaceUrls,className:"components-button is-primary",target:"_blank",rel:"noopener noreferrer"},(0,t.__)("Elementor Tools","gp-premium")))),(0,e.createElement)("div",{className:"generatepress-site-library-footer"},(0,e.createElement)(a.Tooltip,{text:(0,t.__)("Preview desktop","gp-premium")},(0,e.createElement)(a.Button,{variant:"desktop"===J?"primary":"",onClick:()=>{Y("desktop")}},(0,e.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24"},(0,e.createElement)("path",{d:"M21 14H3V4h18m0-2H3c-1.11 0-2 .89-2 2v12a2 2 0 002 2h7l-2 3v1h8v-1l-2-3h7a2 2 0 002-2V4a2 2 0 00-2-2z",fill:"currentColor"})))),(0,e.createElement)(a.Tooltip,{text:(0,t.__)("Preview tablet","gp-premium")},(0,e.createElement)(a.Button,{variant:"tablet"===J?"primary":"",onClick:()=>{Y("tablet")}},(0,e.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24"},(0,e.createElement)("path",{d:"M19 19H4V3h15m-7.5 20a1.5 1.5 0 01-1.5-1.5 1.5 1.5 0 011.5-1.5 1.5 1.5 0 011.5 1.5 1.5 1.5 0 01-1.5 1.5m7-23h-14A2.5 2.5 0 002 2.5v19A2.5 2.5 0 004.5 24h14a2.5 2.5 0 002.5-2.5v-19A2.5 2.5 0 0018.5 0z",fill:"currentColor"})))),(0,e.createElement)(a.Tooltip,{text:(0,t.__)("Preview mobile","gp-premium")},(0,e.createElement)(a.Button,{variant:"mobile"===J?"primary":"",onClick:()=>{Y("mobile")}},(0,e.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24"},(0,e.createElement)("path",{d:"M17 19H7V5h10m0-4H7c-1.11 0-2 .89-2 2v18a2 2 0 002 2h10a2 2 0 002-2V3a2 2 0 00-2-2z",fill:"currentColor"}))))))))))}),null),o=document.getElementById("gpp-site-library"),void 0!==n.createRoot?(0,n.createRoot)(o).render(l):(0,n.render)(l,o)})()})();