File "extendify-recommendations-b646230433527220e538.js"

Full Path: /home/fresvfqn/waterdamagerestorationandrepairsmithtown.com/wp-content/plugins/extendify/public/build/extendify-recommendations-b646230433527220e538.js
File size: 12.08 KB
MIME-type: text/html
Charset: utf-8

"use strict";(globalThis.webpackChunkextendify=globalThis.webpackChunkextendify||[]).push([[884],{790:e=>{e.exports=window.ReactJSXRuntime},1455:e=>{e.exports=window.wp.apiFetch},1609:e=>{e.exports=window.React},3832:e=>{e.exports=window.wp.url},5402:(e,t,n)=>{var i=n(8490),s=n.n(i),a=n(6087),r=n(7723),l=n(3832),o=n(6427),c=n(8537),d=n(7677),u=n(6891),g=n(8351),p=n(7108),m=n(8969);const{products:h=[]}=window.extRecommendationsData,x=e=>e.isSearchPluginsLoading||e.isInstalledPluginsLoading,f=e=>e.isSearchPluginsError||e.isInstalledPluginsError,w=e=>{const t=new Map,{searchPlugins:n,installedPlugins:i,searchPluginsLimit:s}=e,a=i.filter((({status:e})=>"active"===e)),r=n.slice(0,s);return h.filter((e=>e.slots.includes("plugin-search"))).filter((e=>e.pluginSearchTriggerSlugs.some((n=>{const i=r.includes(n);return i&&t.set(e.slug,n),i})))).filter((e=>"plugin"!==e.ctaType||!i.find((({slug:t})=>t===e.ctaPluginSlug)))).filter((e=>e.pluginExclusions.every((e=>!a.find((({slug:t})=>t===e)))))).filter((e=>e.pluginDependencies.every((e=>i.find((({slug:t})=>t===e)))))).filter(Boolean).map((e=>({...e,title:e.pluginSearchCustomTitle||e.title,description:e.pluginSearchCustomDescription||e.description,ctaContent:e.pluginSearchCustomCtaContent||e.ctaContent,triggerContent:t.get(e.slug),triggerType:"plugin-slug"}))).sort(((e,t)=>r.indexOf(e.triggerContent)-r.indexOf(t.triggerContent)))},y=e=>w(e).slice(0,e.recommendationsLimit),P=e=>{if(!e||!e.querySelectorAll)return[];const t=e.querySelectorAll(".plugin-card").values().map((e=>{const t=e.getAttribute("class"),n=t.match(/^plugin-card plugin-card-([\w-]*)$/)?.[1];return n})).filter(Boolean);return Array.from(t)};var v=n(9324),b=n(1621),j=n(7134);const S=(e,t)=>({query:null,searchPlugins:[],installedPlugins:[],searchPluginsLimit:6,recommendationsLimit:2,isSearchPluginsLoading:!1,isSearchPluginsError:!1,isInstalledPluginsLoading:!1,isInstalledPluginsError:!1,initialize:()=>{t().startListeningToAjax(),t().fetchInstalledPlugins()},startListeningToAjax:()=>{const t=new URLSearchParams(window.location.search).get("s");if(t){const n=document.getElementById("plugin-filter"),i=P(n);e({query:t,searchPlugins:i})}const n=new DOMParser;jQuery?.ajaxSetup({beforeSend:(t,i)=>{const s=new URLSearchParams(i.data),a=s.get("action"),r=s.get("s");"search-install-plugins"===a&&(i.success=t=>{if("string"==typeof t&&t?.startsWith("<!DOCTYPE html>")){const e=window.jQuery("#search-plugins"),t=e.val();return e.val(t.endsWith(" ")?t.trim():t+" "),void e.trigger("keyup")}try{const i=n.parseFromString(t?.data?.items||"","text/html"),s=P(i);e({searchPlugins:s,isSearchPluginsLoading:!1,isSearchPluginsError:!1})}catch(t){e({searchPlugins:[],isSearchPluginsLoading:!1,isSearchPluginsError:!0})}},i.error=()=>{e({searchPlugins:[],isSearchPluginsLoading:!1,isSearchPluginsError:!0})},e({query:r||null,searchPlugins:[],isSearchPluginsLoading:!!r,isSearchPluginsError:!1}))}})},fetchInstalledPlugins:async(n=!1)=>{if(!t().installedPlugins.length||n)try{e({isInstalledPluginsLoading:!0,isInstalledPluginsError:!1});const t=await(0,v.OH)();e({installedPlugins:t?.map((e=>({slug:e.plugin.split("/")[0],status:e.status}))),isInstalledPluginsLoading:!1,isInstalledPluginsError:!1})}catch(t){e({installedPlugins:[],isInstalledPluginsLoading:!1,isInstalledPluginsError:!0})}}}),k=(()=>{const e=(0,b.vt)((0,j.lt)(S,{name:"Extendify Plugin Search"}));return e.getState().initialize(),e})(),L=(e,t)=>Object.entries(e).filter((([e])=>t.includes(e))).reduce(((e,[t,n])=>({...e,[t]:n})),{}),{extSharedData:E,extRecommendationsData:C}=window,I=!(!C?.showPartnerBranding||!E?.partnerLogo),N={"plugin-search":k},T=Object.keys(N),A=({slot:e,event:t,product:n})=>{if(!t||!T.includes(e))return;const i=N[e].getState(),s=(e=>e.installedPlugins.map((e=>e.slug)))(i),a=(e=>e.installedPlugins.filter((e=>"active"===e.status)).map((e=>e.slug)))(i),r=w(i).map((e=>L(e,["slug","title","description","ctaContent","ctaType","triggerContent","triggerType"]))),l=r.find((e=>e.slug===n))?.slug,o={event:t,timestamp:(new Date).toISOString(),slot:e,recommendation:l,recommendations:r,recommendationsLimit:i.recommendationsLimit,query:decodeURIComponent(i.query),searchResults:i.searchPlugins,searchResultsLimit:i.searchPluginsLimit,installedPlugins:s,activePlugins:a,partnerBrandingEnabled:I,partnerId:E.partnerId,siteId:E.siteId,wpVersion:E.wpVersion,wpLocale:E.wpLanguage,extendifyVersion:E.version,devbuild:E.devbuild},c=new AbortController;window.setTimeout((()=>{c.abort()}),900),fetch(`${m.Dq}/api/v1/recommendations/activity`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","X-Extendify-Site-ID":E.siteId},signal:c.signal,body:JSON.stringify(o)}).catch((()=>null))};var _=n(1380),D=n(365),B=n(790);const R=({slug:e,title:t,description:n,ctaContent:i,provider:s,image:l,ctaType:o,ctaPluginSlug:d,ctaExternalLink:u,ctaInternalLink:g,priceTag:p})=>((0,a.useEffect)((()=>{A({slot:"plugin-search",event:"view",product:e})}),[e]),(0,B.jsxs)("div",{className:"flex flex-col rounded border border-gray-300","data-test":"extendify-recommendations-card",children:[(0,B.jsxs)("div",{className:"row-auto grid flex-grow grid-cols-[2fr_3fr] grid-rows-[min-content_1fr] gap-x-5 gap-y-3 border-b border-b-gray-100 p-5 xs:grid-cols-[8rem_1fr]",children:[(0,B.jsx)("div",{className:"row-span-1 xs:row-span-2",children:l&&("plugin"===o?(0,B.jsx)("a",{onClick:()=>A({slot:"plugin-search",event:"click-logo",product:e}),className:"thickbox open-plugin-details-modal block no-underline",href:`${window.extSharedData?.adminUrl}/plugin-install.php?tab=plugin-information&plugin=${d}&TB_iframe=true&width=600&height=550`,children:(0,B.jsx)("img",{className:"w-full xs:min-h-[8rem]",src:l,alt:t})}):(0,B.jsx)("img",{className:"w-full xs:min-h-[8rem]",src:l,alt:t}))}),(0,B.jsxs)("div",{className:"flex flex-col justify-center xs:justify-start",children:[(0,B.jsx)("h3",{className:"m-0 text-lg leading-tight text-wp-theme-main",children:"plugin"===o?(0,B.jsx)("a",{onClick:()=>A({slot:"plugin-search",event:"click-title",product:e}),className:"thickbox open-plugin-details-modal no-underline focus:shadow-none",href:`${window.extSharedData?.adminUrl}/plugin-install.php?tab=plugin-information&plugin=${d}&TB_iframe=true&width=600&height=550`,children:(0,c.decodeEntities)(t)}):(0,c.decodeEntities)(t)}),(0,B.jsx)("p",{className:"m-0 mt-1 text-xs",children:(0,r.sprintf)(
// translators: %s is a name
// translators: %s is a name
(0,r._x)("By %s",'Preposition for "By Author Name"',"extendify-local"),s)})]}),(0,B.jsx)("p",{className:"col-span-2 m-0 text-sm xs:col-span-1",children:(0,c.decodeEntities)(n)})]}),(0,B.jsxs)("div",{className:"flex min-h-14 flex-shrink-0 flex-col items-center justify-center p-3 px-5 xxs:flex-row xxs:justify-end",children:[p&&(0,B.jsx)("p",{className:"m-0 mb-3 xxs:mb-0 xxs:mr-4",dangerouslySetInnerHTML:{__html:(0,c.decodeEntities)(p)}}),"plugin"===o&&(0,B.jsx)(O,{product:e,ctaContent:(0,c.decodeEntities)(i),ctaPluginSlug:d}),"external-link"===o&&(0,B.jsx)(q,{product:e,ctaContent:(0,c.decodeEntities)(i),ctaExternalLink:u}),"internal-link"===o&&(0,B.jsx)(U,{product:e,ctaContent:(0,c.decodeEntities)(i),ctaInternalLink:g})]})]})),O=({product:e,ctaContent:t,ctaPluginSlug:n})=>{const[i,s]=(0,a.useState)("idle"),[l,c]=(0,a.useState)(null),p=(0,a.useCallback)((async()=>{A({slot:"plugin-search",event:"click-install",product:e});try{s("installing"),await Promise.all([(0,D.Uq)((()=>(0,v.xZ)(n)),{maxAttempts:2}),(0,D.yy)(1e3)])}catch(e){return c((0,r.__)("Failed to install the plugin","extendify-local")),void s("error")}const t=(({product:e,slot:t="plugin-search"})=>{const n=N[t].getState(),i=w(n).map((e=>L(e,["slug","title","description","ctaContent","ctaType","triggerContent","triggerType"])));return i.find((t=>t.slug===e))?.slug})({product:e});(0,_.yB)({slug:t||e,source:"search-recommendation-card"});try{s("activating"),await Promise.all([(0,D.Uq)((()=>(0,v.Bf)(n)),{maxAttempts:2}),(0,D.yy)(1e3)])}catch(e){return c((0,r.__)("Failed to activate the plugin","extendify-local")),void s("error")}s("activated")}),[e,n]),m={idle:t,installing:(0,r._x)("Installing...","Plugin installation status","extendify-local"),activating:(0,r._x)("Activating...","Plugin activation status","extendify-local"),activated:(0,r._x)("Activated","Plugin activation status","extendify-local"),error:l};return"error"===i?(0,B.jsxs)("p",{className:"m-0 flex items-center fill-wp-alert-red text-sm text-wp-alert-red",children:[(0,B.jsx)(d.A,{icon:u.A}),m[i]]}):"activated"===i?(0,B.jsxs)("p",{className:"m-0 flex items-center fill-wp-alert-green text-sm text-wp-alert-green",children:[(0,B.jsx)(d.A,{icon:g.A}),m[i]]}):(0,B.jsx)(o.Button,{className:"h-auto min-w-24 whitespace-normal break-words rounded-sm bg-wp-theme-main px-3 align-middle text-sm text-design-text shadow-none hover:opacity-90 disabled:opacity-80",type:"button",variant:"secondary",size:"compact",disabled:"idle"!==i,isBusy:"idle"!==i,onClick:p,children:m[i]})},q=({product:e,ctaContent:t,ctaExternalLink:n})=>{const i=(0,c.decodeEntities)(n).replace("{PARTNERID}",window.extSharedData?.partnerId);return(0,B.jsxs)("a",{onClick:()=>A({slot:"plugin-search",event:"click-link-external",product:e}),href:i,target:"_blank",className:"relative flex min-h-8 min-w-24 cursor-pointer items-center justify-center whitespace-normal break-words rounded-sm bg-wp-theme-main fill-design-text py-[6px] pl-3 pr-9 text-center text-sm leading-tight text-design-text no-underline hover:opacity-90 focus:shadow-none",children:[t,(0,B.jsx)(d.A,{className:"absolute right-3 h-5 w-5",icon:p.A})]})},U=({product:e,ctaContent:t,ctaInternalLink:n})=>(0,B.jsx)("a",{onClick:()=>A({slot:"plugin-search",event:"click-link-internal",product:e}),href:n,className:"relative flex min-h-8 min-w-24 cursor-pointer items-center justify-center whitespace-normal break-words rounded-sm bg-wp-theme-main fill-design-text px-3 py-[6px] text-center text-sm leading-tight text-design-text no-underline hover:opacity-90 focus:shadow-none",children:t}),$=({recommendations:e})=>(0,B.jsx)("div",{className:"grid grid-cols-1 gap-4 px-6 py-8 md:grid-cols-2 3xl:grid-cols-3 5xl:grid-cols-4","data-test":"extendify-recommendations-grid",children:e.map((e=>["plugin","external-link","internal-link"].includes(e.ctaType)?(0,B.jsx)(R,{...e},e.slug):null))}),F=window.extRecommendationsData?.showPartnerBranding&&window.extSharedData?.partnerLogo,W=()=>{const e=k((e=>e.query)),t=k(x),n=k(f),i=k((e=>e.recommendationsLimit)),s=k(y),o=k((e=>e.fetchInstalledPlugins));return(0,a.useEffect)((()=>{e&&!t&&A({slot:"plugin-search",event:"search"})}),[e,t]),(0,a.useEffect)((()=>{e&&o(!0)}),[e,o]),!e||!s?.length||t||n?null:(0,B.jsxs)("div",{className:"my-8 flex w-full flex-col overflow-hidden rounded border border-gray-400 bg-white","data-test":"extendify-recommendations-banner",children:[(0,B.jsxs)("div",{className:`flex h-14 border-b border-b-gray-200 ${F?"bg-banner-main":""} px-6 py-4`,children:[F?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("img",{className:"mr-3 h-full",src:window.extSharedData?.partnerLogo}),(0,B.jsx)("div",{className:"mr-3 border-l border-banner-text opacity-80"})]}):null,(0,B.jsx)("h2",{className:`m-0 flex h-full items-center ${F?"text-banner-text":""} `,children:(0,r.sprintf)(
// translators: %s: The search query term
// translators: %s: The search query term
(0,r.__)("Recommended Solutions for: %s","extendify-local"),(0,l.safeDecodeURIComponent)(e))})]}),(0,B.jsx)($,{recommendations:s.slice(0,i)})]})};var z=n(7828);s()((()=>{const e=new URL(window.location.href),t=e.pathname.endsWith("plugin-install.php"),n=e.pathname.endsWith("post-new.php")&&"page"!==e.searchParams.get("post_type"),i=e.pathname.endsWith("post-new.php")&&"page"===e.searchParams.get("post_type");if((t||n||i)&&t){const e=document.getElementById("plugin-filter");if(e){const t="ext-recommendations-plugin-search";if(document.getElementById(t))return;const n=Object.assign(document.createElement("div"),{id:t,className:"extendify-recommendations"});return e.parentNode.insertBefore(n,e),(0,z.X)((0,B.jsx)(W,{}),n)}}}))},5573:e=>{e.exports=window.wp.primitives},6087:e=>{e.exports=window.wp.element},6427:e=>{e.exports=window.wp.components},7723:e=>{e.exports=window.wp.i18n},8490:e=>{e.exports=window.wp.domReady},8537:e=>{e.exports=window.wp.htmlEntities}},e=>{e.O(0,[65,223],(()=>e(e.s=5402))),e.O()}]);