document.addEventListener("DOMContentLoaded",(function(){const{nonce:e,ajaxUrl:t,adminUrl:o,pluginStatus:s,importing:n,done:a,error:i,view:c}=maxiblocks;var r=document.getElementById("maxiblocks-go-notice-import-templates-patterns");if(r){var d=r.querySelector(".maxiblocks-go-button__text"),l=r.querySelector(".maxiblocks-go-button__icon"),m=d.textContent;r.addEventListener("click",(function(){if(r.classList.contains("view-templates"))return event.preventDefault(),void(window.location.href=`${o}site-editor.php?postType=wp_template&activeView=MaxiBlocks%20Go`);r.classList.add("updating-message","disabled"),d.textContent=n||"Importing...",l.classList.add("hidden");var s=new XMLHttpRequest;s.open("POST",t),s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.onload=function(){if(200===s.status){var e=JSON.parse(s.responseText);e.success?(console.log(e.data),r.classList.replace("updating-message","updated-message"),d.textContent=a||"Done",setTimeout((function(){r.classList.remove("updated-message","disabled"),d.textContent=c||"View theme templates",l.classList.remove("hidden"),r.classList.add("view-templates")}),1e3)):(console.error("Error:",e.data),r.classList.remove("updating-message","disabled"),d.textContent=i||m)}else console.error("AJAX error:",s.status),r.classList.remove("updating-message","disabled"),d.textContent=i||m},s.onerror=function(){console.error("AJAX error:",s.status),r.classList.remove("updating-message","disabled"),d.textContent=i||m};var p="action=maxiblocks_go_copy_patterns&nonce="+e;s.send(p)}));const s=document.querySelector(".maxiblocks-go-notice .maxiblocks-go-notice__dismiss");if(s){const o=document.querySelector(".maxiblocks-go-notice"),n=()=>o?.remove();s?.addEventListener("click",(async()=>{200===(await fetch(t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},body:`action=maxiblocks-go-theme-dismiss-templates-notice&nonce=${e}`})).status&&n()}))}}}));