"use strict";(globalThis.webpackChunkast_block_templates=globalThis.webpackChunkast_block_templates||[]).push([[138],{3138:(e,t,o)=>{o.r(t),o.d(t,{default:()=>$});var a=o(3771),s=o(8242),r=o(1594),n=o(6134),l=o(3914),c=o(6597),i=o(7642),p=o(9583),m=o(6041),u=o(9431),d=o(2513),g=o(9392),b=o(8354),f=o(4403),y=o(5446),h=o(4715),k=o(8330),v=o(1760);const{post:I}=wp.ajax,{parse:w}=wp.blocks,{bypassAuth:_}=ast_block_template_vars,P=(0,a.A)((0,s.A)((e=>{const{getImportItemInfo:t,getCurrentScreen:o,getSitePreview:a,getActiveBlockPaletteSlug:s,getActivePagePaletteSlug:r,getDisableAi:n,getAdaptiveMode:l}=e("astra-sites");return{importItemInfo:t(),sitePreview:a(),currentScreen:o(),activeBlockPaletteSlug:s(),activePagePaletteSlug:r(),disableAI:n(),adaptiveMode:l()}})),(0,i.A)((e=>{const{setImportItemInfo:t,setTogglePopup:o,setOnboardingAiPopup:a}=e("astra-sites"),{insertBlocks:s}=wp.data.dispatch("core/block-editor");return{setImportItemInfo:t,onSetTogglePopup:o,insertBlocks:s,setOnboardingAiPopup:a}})))((0,r.memo)((({onImportFail:e,setImportItemInfo:t,requiredPlugins:o,importItemInfo:a,title:s,btnClass:i,insertBlocks:P,onSetTogglePopup:A,item:E,onClick:S,onBlockImport:x,activeBlockPaletteSlug:R,activePagePaletteSlug:N,currentScreen:C,disableAI:T,importing:$=!1,adaptiveMode:B,showIcon:O=!0})=>{let[j]=(0,r.useState)(a),F=o||[];const W=i||"",[D]=(0,r.useState)(s||"Import"),{index:L}=wp.data.select("core/block-editor").getBlockInsertionPoint(),{importInProgress:q,syncLibNotice:M,stepData:{token:z}}=(0,l.A)((e=>{const{getImportInProgress:t,getNotice:o,getAIStepData:a}=e(k.U);return{importInProgress:t(),syncLibNotice:o(),stepData:a()}}),[]),{setImportInProgress:H,toggleConnectZipAI:U,setNotice:Q}=(0,c.A)(k.U),V="info"===M?.type,X=(0,n.Fx)(),Z=(e,t,o)=>{(0,y.oR)((0,h.A)({title:e,message:t}),h.A.getOptions({type:o}))},G=async()=>{try{Q({type:"import-info",message:(0,v.__)("Activating Spectra plugin…","astra-sites")}),await(0,u.s)({slug:"ultimate-addons-for-gutenberg",init:"ultimate-addons-for-gutenberg/ultimate-addons-for-gutenberg.php",name:"Spectra"})}catch(e){H(!1),Z("Import failed!","Spectra activation failed!","error")}},J=async()=>{try{Q({type:"import-info",message:(0,v.__)("Activating WPForms plugin…","astra-sites")}),await(0,u.s)({slug:"wpforms-lite",init:"wpforms-lite/wpforms.php",name:"WPForms Lite"}),await te()}catch(e){H(!1),Z("Import failed!","WPForms activation failed!","error")}},K=()=>{const t=j.original_content,o="all-blocks-grid"===C?"block":"page",a="block"===o?j["blocks-category"][0]:j["pages-category"][0];I({action:"ast_block_templates_import_block",content:t,category:a,_ajax_nonce:ast_block_template_vars._ajax_nonce,style:"all-blocks-grid"===C?R:N,disableAI:T,block_type:o,adaptiveMode:B}).done((e=>{H(!1);const t=(0,n.XD)(w(e));P(t,L,"",!1),Y(t[0].clientId),A(),document.getElementById("ast-block-templates-modal-wrap").classList.remove("open"),document.body.classList.remove("ast-block-templates-modal-open"),(X.inactive||X.notInstalled)&&(0,b.mP)(),"function"==typeof x&&x(e,L)})).fail((()=>{H(!1),e(),Z("Import failed!","Failed to import the block. Please try again later or contact support for assistance.","error-import")}))},Y=e=>{e&&setTimeout((()=>{const t=ee(),o="block-"+e,a=t.getElementById(o);a&&a.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})}),2500)},ee=()=>{const e=document.getElementsByClassName("is-tablet-preview"),t=document.getElementsByClassName("is-mobile-preview");if(0!==e.length||0!==t.length){const o=e[0]||t[0];let a=!1;o&&(a=o.getElementsByTagName("iframe")[0]);const s=a?.contentWindow.document||a?.contentDocument;if(s)return s}return document},te=()=>{j?.["post-meta"]?.["astra-site-wpforms-path"]||""?I({action:"ast_block_templates_import_wpforms",id:j.id,_ajax_nonce:ast_block_template_vars._ajax_nonce}).done((()=>{K()})).fail((()=>{H(!1),Z("Import failed!","WPForms import failed!","error")})):K()};return React.createElement(p.A,{className:(0,n.xW)("min-w-[4.875rem] h-7 hover:shadow-small sp-text-sm",W,(q&&!$||V)&&"opacity-50 cursor-not-allowed"),type:"button",variant:"primary",onClick:z||_?async o=>{q||V||(H(!0),"function"==typeof S&&S(o),X.notInstalled?(await(async()=>{try{Q({type:"import-info",message:(0,v.__)("Installing Spectra plugin…","astra-sites")}),await(0,u.o)({slug:"ultimate-addons-for-gutenberg",init:"ultimate-addons-for-gutenberg/ultimate-addons-for-gutenberg.php",name:"Spectra"})}catch(e){H(!1),Z("Import failed!","Spectra installation failed!","error")}})(),await G()):X.inactive&&await G(),(0,g.V)(E.ID,"astra-blocks").then((e=>{t(e),j=e,F=e?.["post-meta"]?.["astra-blocks-required-plugins"]?d.j.parse(e["post-meta"]["astra-blocks-required-plugins"]):[],F.length?"not-installed"===ast_block_template_vars.wpforms_status?(async()=>{try{Q({type:"import-info",message:(0,v.__)("Installing WPForms plugin…","astra-sites")}),await(0,u.o)({slug:"wpforms-lite",init:"wpforms-lite/wpforms.php",name:"WPForms Lite"}),await J()}catch(e){H(!1),Z("Import failed!","WPForms installation failed!","error")}})():"inactive"===ast_block_template_vars.wpforms_status?J():te():te()})).catch((t=>{Z("Import failed!",t,"error-import"),H(!1),e()})))}:async()=>{U(),(0,n.HU)("ast-import",{blockId:E.ID,blockType:E.type,blockPaletteSlug:R,pagePaletteSlug:N})},isSmall:!0,hasPrefixIcon:!$&&O},$?React.createElement(m.A,{className:"h-4 w-4 !shrink-0"}):React.createElement(React.Fragment,null,O&&React.createElement(f.A,{className:"h-4 w-4 !shrink-0"}),React.createElement("span",{className:"truncate"},D)))})));var A=o(9260);const E=e=>{const t=["skip","logo","fav-icon"];for(const o of t)if(e.includes(o))return!0;return!1},S={linearTween:(e,t,o,a)=>o*e/a+t,easeInQuad:(e,t,o,a)=>o*(e/=a)*e+t,easeOutQuad:(e,t,o,a)=>-o*(e/=a)*(e-2)+t,easeInOutQuad:(e,t,o,a)=>(e/=a/2)<1?o/2*e*e+t:-o/2*(--e*(e-2)-1)+t,easeInCubic:(e,t,o,a)=>o*(e/=a)*e*e+t,easeOutCubic:(e,t,o,a)=>(e/=a,o*(--e*e*e+1)+t),easeInOutCubic:(e,t,o,a)=>(e/=a/2)<1?o/2*e*e*e+t:o/2*((e-=2)*e*e+2)+t};Object.seal(S);const x=S;var R=o(7497);const{spectra_common_styles:N,is_rtl:C}=ast_block_template_vars,T="visible",$=(0,a.A)((0,s.A)((e=>{const{getDisableAi:t,getDisablePreview:o,getTogglePopup:a}=e("astra-sites");return{disableAi:t(),disablePreview:o(),togglePopup:a()}})))((0,r.memo)((({item:e,content:t,stylesheet:o,astraCustomizer:a,globalStylesheet:s,colorPalette:l,dynamicContent:c,selectedImages:i,disableAi:p,togglePopup:m,email:u,phone:d,address:g})=>{const b=(0,r.useRef)(null),f=(0,r.useRef)(null),y=e["thumbnail-image-url"]||"",h=e["featured-image-url"]||"",k=(0,n.Fx)();let v=0,I=0;const[w,_]=(0,r.useState)({importing:!1}),[S,$]=(0,r.useState)(`${ast_block_template_vars.uri}dist/placeholder_200_200.png`),[B,O]=(0,r.useState)(`${ast_block_template_vars.uri}dist/placeholder_200_200.png`);function j(){const e=b?.current,t=f?.current;if(!e||!t)return;const o=e.parentNode.offsetWidth/1200,a=o*t.offsetHeight;e.style.transform=`scale(${o})`,e.style.height=`${a}px`}(0,r.useLayoutEffect)((()=>{let e=!0;const r=i,n=new Image;n.src=y;const m=new Image;m.src=h;const b=f.current;function k(t,o){e&&(t.onload=()=>{o(t.src)})}k(n,$),k(m,O);const w=document.getElementById("astra-wp-editor-styles-inline-css")?.textContent.replace(/:root/g,".block-container").replace(/body/g,".block-container"),_=document.getElementById("astra-block-editor-styles-inline-css")?.textContent.replace(/:root/g,".block-container").replace(/body/g,".block-container");let P="";if(o&&(o=((e,t=[])=>p?e:0!==Object.keys(c).length&&c?t&&0===t.length?e:e.replace(/background-image\s*:\s*url\(['"]?([^'")]+)['"]?\)/g,(function(e,o){if(E(o))return e;if(!t[I]?.url)return"";const a=t[I]?.url;return I++,I%=t.length,'background-image: url("'+a+'")'})):e)(o,r)),P+=a?``:"",P+=``,P=o?`${P} `:P,s&&(P+=``),w&&(P+=``),_&&(P+=``),b&&t){let e=b.shadowRoot;if(null===e&&(e=b.attachShadow({mode:"open"})),null===e)return;let o=t;if(!p){const e=c??[];e&&Object.keys(e)?.length>0&&Object.keys(e).forEach((t=>{o=null!==e[t]?o.replace(t,e[t]):o})),c&&Object.keys(c).length>0&&(A=o,u&&(A=A.replace("contact@example.com",u)),d&&(A=A.replace("202-555-0188",d)),g&&(A=A.replace("2360 Hood Avenue, San Diego, CA, 92123",g)),o=A,o=W(o))}e.innerHTML=P+'