laipower/wp-content/plugins/menu-icons/vendor/codeinwp/themeisle-sdk/assets/js/build/promos/index.js

1 line
15 KiB
JavaScript
Raw Normal View History

(()=>{"use strict";var e,t={165:()=>{const e=window.wp.element,t=window.wp.blockEditor,o=window.wp.components,n=window.wp.compose,i=window.wp.data,s=window.wp.hooks,r=()=>{const{createNotice:t}=(0,i.dispatch)("core/notices"),[o,n]=(0,e.useState)({}),[s,r]=(0,e.useState)("loading");return(0,i.useSelect)((e=>{if(Object.keys(o).length)return;const{getEntityRecord:t}=e("core"),i=t("root","site");i&&(r("loaded"),n(i))}),[]),[e=>null==o?void 0:o[e],async function(e,o){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Settings saved.";const s={[e]:o};try{const e=await fetch("/wp-json/wp/v2/settings",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":wpApiSettings.nonce},body:JSON.stringify(s)});e.ok||(r("error"),t("error","Could not save the settings.",{isDismissible:!0,type:"snackbar"}));const o=await e.json();r("loaded"),t("success",i,{isDismissible:!0,type:"snackbar"}),n(o)}catch(e){console.error("Error updating option:",e)}},s]},l=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new Promise((o=>{wp.updates.ajax(!0===t?"install-theme":"install-plugin",{slug:e,success:()=>{o({success:!0})},error:e=>{o({success:!1,code:e.errorCode})}})}))},a=e=>new Promise((t=>{jQuery.get(e).done((()=>{t({success:!0})})).fail((()=>{t({success:!1})}))})),m=(e,t)=>{const o={};return Object.keys(t).forEach((function(e){"innerBlocks"!==e&&(o[e]=t[e])})),e.push(o),Array.isArray(t.innerBlocks)?(o.innerBlocks=t.innerBlocks.map((e=>e.id)),t.innerBlocks.reduce(m,e)):e},c={button:{display:"flex",justifyContent:"center",width:"100%"},image:{padding:"20px 0"},skip:{container:{display:"flex",flexDirection:"column",alignItems:"center"},button:{fontSize:"9px"},poweredby:{fontSize:"9px",textTransform:"uppercase"}}},d={"blocks-css":{title:"Custom CSS",description:"Enable Otter Blocks to add Custom CSS for this block.",image:"css.jpg"},"blocks-animation":{title:"Animations",description:"Enable Otter Blocks to add Animations for this block.",image:"animation.jpg"},"blocks-conditions":{title:"Visibility Conditions",description:"Enable Otter Blocks to add Visibility Conditions for this block.",image:"conditions.jpg"}},p=t=>{let{onClick:n}=t;return(0,e.createElement)("div",{style:c.skip.container},(0,e.createElement)(o.Button,{style:c.skip.button,variant:"tertiary",onClick:n},"Skip for now"),(0,e.createElement)("span",{style:c.skip.poweredby},"Recommended by ",window.themeisleSDKPromotions.product))},u=(0,n.createHigherOrderComponent)((n=>i=>{if(i.isSelected&&Boolean(window.themeisleSDKPromotions.showPromotion)){const[s,m]=(0,e.useState)(!1),[u,h]=(0,e.useState)("default"),[w,g]=(0,e.useState)(!1),[E,k,y]=r(),f=async()=>{m(!0),await l("otter-blocks"),k("themeisle_sdk_promotions_otter_installed",!Boolean(E("themeisle_sdk_promotions_otter_installed"))),await a(window.themeisleSDKPromotions.otterActivationUrl),m(!1),h("installed")},P=()=>"installed"===u?(0,e.createElement)("p",null,(0,e.createElement)("strong",null,"Awesome! Refresh the page to see Otter Blocks in action.")):(0,e.createElement)(o.Button,{variant:"secondary",onClick:f,isBusy:s,style:c.button},"Install & Activate Otter Blocks"),S=()=>{const e={...window.themeisleSDKPromotions.option};e[window.themeisleSDKPromotions.showPromotion]=(new Date).getTime()/1e3|0,k("themeisle_sdk_promotions",JSON.stringify(e)),window.themeisleSDKPromotions.showPromotion=!1};return(0,e.useEffect)((()=>{w&&S()}),[w]),w?(0,e.createElement)(n,i):(0,e.createElement)(e.Fragment,null,(0,e.createElement)(n,i),(0,e.createElement)(t.InspectorControls,null,Object.keys(d).map((t=>{if(t===window.themeisleSDKPromotions.showPromotion){const n=d[t];return(0,e.createElement)(o.PanelBody,{key:t,title:n.title,initialOpen:!1},(0,e.createElement)("p",null,n.description),(0,e.createElement)(P,null),(0,e.createElement)("img",{style:c.image,src:window.themeisleSDKPromotions.assets+n.image}),(0,e.createElement)(p,{onClick:()=>g(!0)}))}}))))}return(0,e.createElement)(n,i)}),"withInspectorControl");(0,i.select)("core/edit-site")||(0,s.addFilter)("editor.BlockEdit","themeisle-sdk/with-inspe