(()=>{"use strict";const e=window.wp.hooks,i=window.wp.compose,n=window.wp.element,o=window.wp.blockEditor,t=window.wp.components,a=window.wp.i18n,s=window.wp.primitives,r=window.ReactJSXRuntime,l=(0,r.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"-2 -2 24 24",children:(0,r.jsx)(s.Path,{d:"M10 1c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm0 16c-3.9 0-7-3.1-7-7s3.1-7 7-7 7 3.1 7 7-3.1 7-7 7zm1-11H9v3H6v2h3v3h2v-3h3V9h-3V6zM10 1c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm0 16c-3.9 0-7-3.1-7-7s3.1-7 7-7 7 3.1 7 7-3.1 7-7 7zm1-11H9v3H6v2h3v3h2v-3h3V9h-3V6z"})}),c=(0,r.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(s.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"})}),m=(0,i.createHigherOrderComponent)(e=>i=>{const[s,m]=(0,n.useState)(!1),[d,w]=(0,n.useState)(!1),[p,g]=(0,n.useState)(!0);return"core/image"===i.name&&p?(0,r.jsxs)(n.Fragment,{children:[(0,r.jsx)(e,{...i}),(0,r.jsxs)(o.InspectorControls,{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",fontWeight:"bold",marginBottom:"8px"},children:[(0,r.jsx)(t.Icon,{icon:l,style:{marginRight:8,marginLeft:8}}),(0,r.jsx)("span",{style:{flex:1},children:(0,a.__)("Optimize Your Images","%domain%")}),(0,r.jsx)(t.Button,{onClick:async()=>{try{await fetch(wpmedia_pluginfamily.ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},body:new URLSearchParams({action:"dismiss_promote_imagify",_ajax_nonce:wpmedia_pluginfamily.nonce}).toString()})}catch(e){console.error("AJAX error: ",e)}g(!1)},size:"compact",icon:c,iconPosition:"right"})]}),(0,r.jsxs)(t.PanelBody,{title:"",initialOpen:!0,children:[(0,r.jsx)("p",{style:{marginLeft:16},children:(0,a.__)("Boost your site’s performance by compressing images with Imagify, developed by WP Rocket.","%domain%")}),d?(0,r.jsx)("a",{href:wpmedia_pluginfamily.plugins_page_url,target:"_blank",rel:"noopener noreferrer",style:{marginLeft:16,color:"green",fontWeight:"bold",display:"block"},children:(0,a.__)("Imagify installed! Click here to start using it.","%domain%")}):(0,r.jsx)(t.Button,{style:{marginLeft:16},isSecondary:!0,isBusy:s,disabled:s,onClick:async()=>{m(!0);try{const e=await fetch(wpmedia_pluginfamily.ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},body:new URLSearchParams({action:"install_imagify",_ajax_nonce:wpmedia_pluginfamily.nonce}).toString()});(await e.json()).success&&(w(!0),window.open(wpmedia_pluginfamily.plugins_page_url,"_blank"))}catch(e){console.error("AJAX error: ",e)}m(!1)},children:(0,a.__)("Install Imagify Now","%domain%")})]})]})]}):(0,r.jsx)(e,{...i})},"promoteImagifyButton");(0,e.addFilter)("editor.BlockEdit","wpmedia-plugin-family/promote-imagify",m)})();