var WPO_Status_Report=function(e){var t=!1,o=!1;return function(){function i(){wp.apiFetch({path:"wp-site-health/v1/directory-sizes"}).then(function(t){var o;for(var i in t)e("#wpo-value-wp-paths-sizes-"+i).html(t[i].size),o="{{[wp-paths-sizes-"+i+"]}}",p(o,t[i].size),delete c[i];for(var i in c)null!==c[i]&&(p(c[i],wpoptimize.data_not_available),e("#wpo-value-wp-paths-sizes-"+i).html(wpoptimize.data_not_available))})["catch"](function(e){var t=document.querySelectorAll(".wpo-ajax-field-wp-paths-sizes");t.forEach(function(e){e.innerHTML=wpoptimize.data_not_available})})}function n(){o=!0,e("#wpo-generate-status-report-text").html(wpoptimize.please_wait+'
'),wp_optimize.send_command("generate_status_report",{},function(o){e("#wpo-status-report-container").html(o.html),a(),r(),i(),c=o.replaceable_md_tags,t=!0}).always(function(){o=!1})}function a(){function t(t){e("#wpo-copy-action-result").html(t),e("#wpo-copy-action-result").show(),setTimeout(function(){e("#wpo-copy-action-result").hide()},1500)}var o=e("#wpo-server-info"),i=e("#wpo-show-status-report-btn"),n=e("#wpo-copy-status-report-btn"),a=e("#wpo-server-info-report");i.on("click",function(t){var i=a.is(":hidden");!0===i?(e(this).text(wpoptimize.hide),o.prepend(a),a.show(),a.trigger("select"),setTimeout(function(e){e.scrollTop(0)},50,a)):(e(this).text(wpoptimize.show),o.append(a),a.hide())}),function(o){o.on("click",function(i){i.preventDefault();var n=e("#wpo-server-info-report");try{if(!(clipboard in navigator))throw new Error;navigator.clipboard.writeText(n.val()),t(wpoptimize.clipboard_success)}catch(a){const r=document.createElement("textarea");r.value=n.val(),r.style.opacity=0;var p=o.parent();p.append(r),r.focus(),r.select();try{const c=document.execCommand("copy");if(!c)throw new Error("Exec command failed, could not copy");t(wpoptimize.clipboard_success)}catch(s){console.log(s),t(wpoptimize.clipboard_failed)}e(r).remove()}})}(n),e("#wpo-download-logs").on("click",function(){e("#wpo-generate-zip-file-text").html(wpoptimize.please_wait+'
'),e(this).prop("disabled",!0),wp_optimize.send_command("generate_logs_zip",{},function(t){const o=new JSZip;t.data.forEach(function(e){e.compressed?o.file(e.name+".gz",atob(e.src),{binary:!0}):o.file(e.name,atob(e.src),{binary:!0})}),o.generateAsync({type:"blob",compression:"DEFLATE"}).then(function(t){var o=new Blob([t]);const i=window.URL.createObjectURL(o),n=document.createElement("a");n.style.display="none",n.href=i;var a=(new Date).toJSON().replace(/:/g,"_");n.download="logs-"+a+".zip",document.body.appendChild(n),n.click(),window.URL.revokeObjectURL(i),e("#wpo-generate-zip-file-text").html(""),e("#wpo-download-logs").prop("disabled",!1)})})}),e("#wpo-download-status-report-btn").on("click",function(){var e=new Blob([a.val()]);const t=window.URL.createObjectURL(e),o=document.createElement("a");o.style.display="none",o.href=t;var i=(new Date).toJSON().replace(/:/g,"_");o.download="wp-optimize-report-"+i+".txt",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(t)})}function r(){var t=JSON.stringify(WP_Optimize.build_settings(),null,2);e("#wpo-general-settings").html(t),p("{{[wpo-general-settings]}}",t)}function p(t,o){var i=e("#wpo-server-info-report").html();i=i.replace(t,o),e("#wpo-server-info-report").html(i)}if(!1===t&&!1===o){var c;e("#wp-optimize-wrap").on("tab-change/wpo_settings/status",function(e){e.preventDefault(),!1===t&&n()})}}}(jQuery);