← Back
Editing: marketplace.js
"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[592],{58396:(e,o,t)=>{t.d(o,{A:()=>s});var r=t(39793),c=t(5573),s=(0,r.jsx)(c.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsx)(c.Path,{d:"M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"})})},8533:(e,o,t)=>{t.d(o,{A:()=>s});var r=t(39793),c=t(5573),s=(0,r.jsx)(c.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(c.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"})})},74515:(e,o,t)=>{t.d(o,{A:()=>s});var r=t(39793),c=t(5573),s=(0,r.jsx)(c.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsx)(c.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm.75 4v1.5h-1.5V8h1.5Zm0 8v-5h-1.5v5h1.5Z"})})},22201:(e,o,t)=>{t.d(o,{A:()=>s});var r=t(39793),c=t(5573),s=(0,r.jsx)(c.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(c.Path,{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"})})},7194:(e,o,t)=>{t.d(o,{A:()=>s});var r=t(39793),c=t(5573),s=(0,r.jsx)(c.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(c.Path,{fillRule:"evenodd",d:"M6.5 8a1.5 1.5 0 103 0 1.5 1.5 0 00-3 0zM8 5a3 3 0 100 6 3 3 0 000-6zm6.5 11a1.5 1.5 0 103 0 1.5 1.5 0 00-3 0zm1.5-3a3 3 0 100 6 3 3 0 000-6zM5.47 17.41a.75.75 0 001.06 1.06L18.47 6.53a.75.75 0 10-1.06-1.06L5.47 17.41z",clipRule:"evenodd"})})},52741:(e,o,t)=>{t.d(o,{A:()=>c});var r=t(42435);const c=e=>({__html:(0,r.sanitizeHTML)(e)})},51963:(e,o,t)=>{t.d(o,{A:()=>p});var r=t(4921),c=t(86087),s=t(74515),n=t(29471),a=t(7194),i=t(11789),l=t(8533),m=t(52741),u=t(39793);const d={info:s.A,check:n.A,percent:a.A};function p(e){const{id:o,description:t,children:s,icon:n,isDismissible:a=!0,variant:p="info",className:_,onClose:h,onLoad:w}=e,[g,b]=(0,c.useState)("true"!==localStorage.getItem(`wc-marketplaceNoticeClosed-${o}`));if((0,c.useEffect)(()=>{g&&"function"==typeof w&&w()},[g]),!g)return null;const x=(0,r.A)("woocommerce-marketplace__notice",`woocommerce-marketplace__notice--${p}`,{"is-dismissible":a},_),y=d[n||"info"],v=(0,r.A)("woocommerce-marketplace__notice-icon",`woocommerce-marketplace__notice-icon--${p}`);return(0,u.jsxs)("div",{className:x,children:[n&&(0,u.jsx)("span",{className:v,children:(0,u.jsx)(i.A,{icon:y})}),(0,u.jsxs)("div",{className:"woocommerce-marketplace__notice-content",children:[(0,u.jsx)("p",{className:"woocommerce-marketplace__notice-description",dangerouslySetInnerHTML:(0,m.A)(t)}),s&&(0,u.jsx)("div",{className:"woocommerce-marketplace__notice-children",children:s})]}),a&&(0,u.jsx)("button",{className:"woocommerce-marketplace__notice-close","aria-label":"Close",onClick:()=>{b(!1),localStorage.setItem(`wc-marketplaceNoticeClosed-${o}`,"true"),"function"==typeof h&&h()},children:(0,u.jsx)(i.A,{icon:l.A})})]})}},611:(e,o,t)=>{t.d(o,{A:()=>c});var r=t(39793);function c(){return(0,r.jsxs)("svg",{width:"72",height:"60",viewBox:"0 0 72 60",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsxs)("g",{clipPath:"url(#clip0_4074_10418)",children:[(0,r.jsx)("path",{d:"M68.5301 33.3144C68.0263 32.1006 66.3348 32.344 65.8443 31.1636C65.3538 29.9832 66.7251 28.9562 66.2213 27.7458C65.7175 26.5354 64.0259 26.7755 63.5355 25.5951C63.045 24.4147 64.4163 23.3877 63.9125 22.1773C63.4087 20.9669 61.7171 21.207 61.2267 20.0266C60.7362 18.8462 62.1075 17.8192 61.6037 16.6088C61.0999 15.395 59.4083 15.6385 58.9179 14.4581C58.4274 13.2777 59.7987 12.2507 59.2949 11.0403C58.7911 9.82652 57.0995 10.0699 56.6091 8.88955C56.1186 7.70915 57.4899 6.68214 56.9861 5.47174C56.4823 4.26134 54.7907 4.50142 54.3003 3.32102C53.8465 2.22733 55.0476 1.11696 54.8274 -0.00341797L0 22.5941C0.5038 23.8079 2.19537 23.5644 2.68582 24.7448C3.17627 25.9252 1.805 26.9522 2.3088 28.1626C2.8126 29.373 4.50417 29.133 4.99462 30.3134C5.48508 31.4937 4.11381 32.5208 4.61761 33.7312C5.12141 34.9416 6.81297 34.7015 7.30343 35.8819C7.79388 37.0623 6.42261 38.0893 6.92641 39.2997C7.43021 40.5134 9.12178 40.27 9.61223 41.4504C10.1027 42.6308 8.73142 43.6578 9.23522 44.8682C9.73902 46.0786 11.4306 45.8385 11.921 47.0189C12.4115 48.1993 11.0402 49.2263 11.544 50.4367C12.0478 51.6471 13.7394 51.4071 14.2298 52.5874C14.6836 53.6811 13.4825 54.7915 13.7027 55.9119L28.1928 49.9232L68.5368 33.3177L68.5301 33.3144Z",fill:"#720EEC"}),(0,r.jsx)("path",{d:"M13.696 55.912L28.1861 49.9234L52.3851 39.9634H7.46021C8.17086 40.4802 9.23852 40.5569 9.60886 41.4539C10.0993 42.6343 8.72805 43.6613 9.23185 44.8717C9.73565 46.0821 11.4272 45.842 11.9177 47.0224C12.4081 48.2028 11.0368 49.2298 11.5406 50.4402C12.0444 51.6506 13.736 51.4105 14.2265 52.5909C14.6802 53.6846 13.4791 54.795 13.6993 55.9154L13.696 55.912Z",fill:"#3C087E"}),(0,r.jsx)("path",{d:"M63.8523 41.9907C63.8523 37.4925 67.499 33.848 71.9998 33.848V23.988H17.873V33.848C22.3739 33.848 26.0206 37.4925 26.0206 41.9907C26.0206 46.4889 22.3739 50.1334 17.873 50.1334V59.9934H71.9998V50.1334C67.499 50.1334 63.8523 46.4889 63.8523 41.9907Z",fill:"#D1C1FF"}),(0,r.jsx)("path",{d:"M35.2527 37.676C35.2527 35.2051 37.0143 33.2878 39.6968 33.2878C42.3793 33.2878 44.1643 35.2051 44.1643 37.676C44.1643 40.1468 42.4026 42.0107 39.6968 42.0107C36.991 42.0107 35.2527 40.1201 35.2527 37.676ZM41.7954 37.676C41.7954 36.2288 40.9046 35.3385 39.6935 35.3385C38.4823 35.3385 37.6182 36.2288 37.6182 37.676C37.6182 39.1231 38.509 39.9601 39.6935 39.9601C40.8779 39.9601 41.7954 39.0664 41.7954 37.676ZM37.9852 51.0704L49.1789 33.5513H51.1774L39.9537 51.0704H37.9819H37.9852ZM44.8983 47.0524C44.8983 44.5849 46.6566 42.641 49.3391 42.641C52.0215 42.641 53.8065 44.5849 53.8065 47.0524C53.8065 49.5199 52.0182 51.3872 49.3391 51.3872C46.6599 51.3872 44.8983 49.4966 44.8983 47.0524ZM51.441 47.0524C51.441 45.6053 50.5468 44.715 49.3357 44.715C48.1246 44.715 47.2605 45.6053 47.2605 47.0524C47.2605 48.4996 48.1279 49.3365 49.3357 49.3365C50.5435 49.3365 51.441 48.4696 51.441 47.0524Z",fill:"#720EEC"})]}),(0,r.jsx)("defs",{children:(0,r.jsx)("clipPath",{id:"clip0_4074_10418",children:(0,r.jsx)("rect",{width:"72",height:"60",fill:"white"})})})]})}},20067:(e,o,t)=>{t.d(o,{A:()=>u});var r=t(56427),c=t(27723),s=t(86087),n=t(83306),a=t(52741),i=t(611),l=t(39793);const m={percent:i.A},u=({promotion:e,eventProperties:o={},onDismiss:t})=>{const i=window.location.pathname+window.location.search,u=()=>JSON.parse(localStorage.getItem("wc-marketplaceDismissedPromos")||"[]"),[d,p]=(0,s.useState)(!!t||!u().includes(i));if((0,s.useEffect)(()=>{d&&(0,n.recordEvent)("marketplace_promotion_viewed",{...o,path:i,format:"promo-card"})},[d]),!d)return null;const _="promo-card"+(e.style?` ${e.style}`:""),h=(0,l.jsxs)("div",{className:"promo-content",children:[(0,l.jsx)("h2",{className:"promo-title",children:e.title?.en_US}),(0,l.jsx)("div",{className:"promo-text",dangerouslySetInnerHTML:(0,a.A)(e.content?.en_US)})]}),w=(0,l.jsxs)("div",{className:"promo-links",children:[(0,l.jsx)(r.Button,{className:"promo-cta",href:e.cta_link??"",variant:"secondary",onClick:()=>((0,n.recordEvent)("marketplace_promotion_actioned",{...o,path:i,target_uri:e.cta_link,format:"promo-card"}),!0),children:e.cta_label?.en_US??""}),(0,l.jsx)(r.Button,{className:"promo-cta-link woocommerce-admin-dismiss-notification",onClick:()=>{p(!1),t?t():localStorage.setItem("wc-marketplaceDismissedPromos",JSON.stringify(u().concat(i))),(0,n.recordEvent)("marketplace_promotion_dismissed",{...o,path:i,format:"promo-card"})},children:(0,c.__)("Dismiss","woocommerce")})]});function g(){if(e.icon&&Object.hasOwn(m,e.icon)){const o=m[e.icon];return o?(0,l.jsx)("div",{className:"promo-image",children:(0,s.createElement)(o)}):null}return null}return(0,l.jsx)(r.Card,{className:_,children:(0,l.jsx)(r.CardBody,{className:"promo-card__body",children:"has-background"===e?.style?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"promo-content-links",children:[h,w]}),g()]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"promo-content-image",children:[h,g()]}),w]})})})}},80643:(e,o,t)=>{t.d(o,{A:()=>i});var r=t(83306),c=t(70288),s=t(51963),n=t(20067),a=t(39793);const i=({format:e})=>{if(!window?.wcMarketplace?.promotions||!Array.isArray(window?.wcMarketplace?.promotions))return null;const o=(window?.wcMarketplace?.promotions??[]).filter(o=>o.format===e),t=new URLSearchParams(window.location.search),i=t.get("page"),l=Date.now(),m=decodeURIComponent(t.get("path")||""),u=t.get("tab"),d=window.location.pathname+window.location.search,p=()=>{(0,r.recordEvent)("marketplace_promotion_viewed",{path:d,format:e})},_=()=>{(0,r.recordEvent)("marketplace_promotion_dismissed",{path:d,format:e})};return(0,a.jsx)(a.Fragment,{children:o.map((e,o)=>{if(!e.pages)return null;if(!e.pages.some(e=>{if(e.pathname)return e.pathname===d;if(!e.path)return!1;const o=e=>e.startsWith("/")?e:`/${e}`,t=o(e.path),r=o(m);return e.page===i&&t===r&&(e.tab?u:!u)}))return null;const t=new Date(e.date_from_gmt).getTime(),r=new Date(e.date_to_gmt).getTime();return l<t||l>r?null:"promo-card"===e.format?(0,a.jsx)(n.A,{promotion:e},o):"notice"===e.format&&e?.content?(0,a.jsx)(s.A,{id:e.menu_item_id??`promotion-${o}`,description:e.content[c.ne.userLocale]||e.content.en_US,variant:e.style?e.style:"info",icon:e?.icon||"",isDismissible:e.is_dismissible||!1,onLoad:p,onClose:_},o):null})})}},59418:(e,o,t)=>{t.r(o),t.d(o,{default:()=>So});var r=t(86087),c=t(750),s=t(70288),n=t(24597);const a="woocommerce_marketplace_product_preview_202610",i="utm_term";var l=t(39793);const m=(u="wc_iam_settings",{setWithExpiry:e=>{const o=new Date,t={data:e,expiry:new Date(o.getTime()+864e5).toISOString()};localStorage.setItem(u,JSON.stringify(t))},getWithExpiry:()=>{const e=localStorage.getItem(u);if(!e)return null;const o=JSON.parse(e);return new Date>new Date(o.expiry)?(localStorage.removeItem(u),null):o.data}});var u;const d=(0,r.createContext)({isLoading:!1,setIsLoading:()=>{},selectedTab:"",setSelectedTab:()=>{},isProductInstalled:()=>!1,addInstalledProduct:()=>{},searchResultsCount:{extensions:0,themes:0,"business-services":0},setSearchResultsCount:()=>{},iamSettings:{},productPreviewVariation:null});function p(e){const[o,t]=(0,r.useState)(!0),[i,u]=(0,r.useState)(""),[p,_]=(0,r.useState)({}),[,h]=(0,c.useExperiment)(a),w=window.wcTracks?.isEnabled?h?.variationName??null:null,[g,b]=(0,r.useState)([]),[x,y]=(0,r.useState)({extensions:0,themes:0,"business-services":0}),v=(0,r.useCallback)(e=>{y(o=>({...o,...e}))},[]);(0,r.useEffect)(()=>{const e=m.getWithExpiry();if(e?.settings&&e.locale===s.ne.userLocale)return void _(e.settings);let o=`${n.H2}${n.rx}`;s.ne.userLocale&&(o+=`?locale=${s.ne.userLocale}`),fetch(o).then(e=>{if(!e.ok)throw new Error(`Network response was not ok: ${e.statusText}`);return e.json()}).then(e=>{_(e),m.setWithExpiry({locale:s.ne.userLocale,settings:e})}).catch(e=>{console.error("Failed to fetch IAM settings:",e),_({})})},[]),(0,r.useEffect)(()=>{const e=(0,s.Qk)("wccomHelper",{}),o=e?.installedProducts;b(o)},[]);const f={isLoading:o,setIsLoading:t,selectedTab:i,setSelectedTab:u,isProductInstalled:function(e){return g.includes(e)},addInstalledProduct:function(e){b([...g,e])},searchResultsCount:x,setSearchResultsCount:v,iamSettings:p,productPreviewVariation:w};return(0,l.jsx)(d.Provider,{value:f,children:e.children})}var _=t(27723);function h(){return(0,l.jsx)("h1",{className:"woocommerce-marketplace__header-title",children:(0,_.__)("The WooCommerce Marketplace","woocommerce")})}var w=t(88693),g=t(56427),b=t(4921),x=t(96476);const y=(0,s.Qk)("wccomHelper",{}),v=y?.wooUpdateCount??0,f=(e,o,t)=>{const{selectedTab:r,setSelectedTab:c}=e,s=e=>{e!==r&&(c(e),((e,o)=>{const t=o.term?{term:o.term.trim()}:{};(0,x.navigateTo)({url:(0,x.getNewPath)({tab:e===n.mz?void 0:e},n.q$,t)})})(e,t))},a=[];for(const e in o)a.push(o[e]?.href?(0,l.jsx)("a",{className:(0,b.A)("woocommerce-marketplace__tab-button","components-button",`woocommerce-marketplace__tab-${e}`),href:o[e]?.href,children:o[e]?.title},e):(0,l.jsxs)(g.Button,{className:(0,b.A)("woocommerce-marketplace__tab-button",`woocommerce-marketplace__tab-${e}`,{"is-active":e===r}),onClick:()=>s(e),children:[o[e]?.title,o[e]?.showUpdateCount&&(0,l.jsx)("span",{className:(0,b.A)("woocommerce-marketplace__update-count",`woocommerce-marketplace__update-count-${e}`,{"is-active":e===r}),title:"my-subscriptions"===e?(0,_.sprintf)((0,_._n)("%d update available for your subscriptions","%d updates available for your subscriptions",o[e]?.updateCount,"woocommerce"),o[e]?.updateCount):(0,_.sprintf)((0,_._n)("%d matching item in this category","%d matching items in this category",o[e]?.updateCount,"woocommerce"),o[e]?.updateCount),"aria-label":"my-subscriptions"===e?(0,_.sprintf)((0,_._n)("%d update available for your subscriptions","%d updates available for your subscriptions",o[e]?.updateCount,"woocommerce"),o[e]?.updateCount):(0,_.sprintf)((0,_._n)("%d matching item in this category","%d matching items in this category",o[e]?.updateCount,"woocommerce"),o[e]?.updateCount),children:(0,l.jsxs)("span",{children:[" ",o[e]?.updateCount," "]})})]},e));return a},j=e=>{const{additionalClassNames:o}=e,t=(0,r.useContext)(d),{isLoading:c,setSelectedTab:s}=t,{searchResultsCount:a}=t,i=(0,x.useQuery)(),m=(0,r.useMemo)(()=>({discover:{name:"discover",title:(0,_.__)("Discover","woocommerce"),showUpdateCount:!1,updateCount:0},extensions:{name:"extensions",title:(0,_.__)("Extensions","woocommerce"),showUpdateCount:!!i.term&&!c,updateCount:a.extensions},themes:{name:"themes",title:(0,_.__)("Themes","woocommerce"),showUpdateCount:!!i.term&&!c,updateCount:a.themes},"business-services":{name:"business-services",title:(0,_.__)("Business services","woocommerce"),showUpdateCount:!!i.term&&!c,updateCount:a["business-services"]},"my-subscriptions":{name:"my-subscriptions",title:(0,_.__)("My subscriptions","woocommerce"),showUpdateCount:v>0,updateCount:v}}),[i,c,a]);return(0,r.useEffect)(()=>{i?.tab&&m[i.tab]?s(i.tab):Object.keys(i).length>0&&s(n.mz)},[i,s,m]),(0,l.jsx)("nav",{className:(0,b.A)("woocommerce-marketplace__tabs",o||[]),children:f(t,m,i)})};var k=t(83306);const N=function(){const[e,o]=(0,r.useState)(""),t=(0,_.__)("Search Marketplace","woocommerce"),c=(0,x.useQuery)();(0,r.useEffect)(()=>{c.term?o(c.term):o("")},[c.term]);const s=o=>{const t=c;return t.tab&&"my-subscriptions"!==t.tab||(t.tab="extensions"),t.term=void 0!==o?o:e.trim(),t.search="1",t.term||delete t.term,(0,x.navigateTo)({url:(0,x.getNewPath)(t,n.q$,{})}),[]};return(0,l.jsx)(g.SearchControl,{label:t,placeholder:t,value:e,onChange:e=>{o(e),""===e&&c.term&&s("")},onKeyUp:e=>{"Enter"===e.key&&s(),"Escape"===e.key&&o("")},onFocus:()=>{(0,k.recordEvent)("marketplace_search_start",{current_search_term:e,current_tab:c.tab||"discover"})},className:"woocommerce-marketplace__search"})};function C(){return(0,l.jsx)("div",{className:"woocommerce-marketplace__header-container",children:(0,l.jsxs)("header",{className:"woocommerce-marketplace__header",children:[(0,l.jsx)(h,{}),(0,l.jsx)(j,{additionalClassNames:["woocommerce-marketplace__header-tabs"]}),(0,l.jsx)(N,{}),(0,l.jsx)("div",{className:"woocommerce-marketplace__header-meta",children:(0,l.jsx)(w.A,{page:"wc-addons"})})]})})}var M=t(20195),T=t(20522),A=t(18537),I=t(40314);const S=function(e){const{product:o}=e,{user:t,currentUserCan:c}=(0,I.useUser)(),{selectedTab:s,isProductInstalled:n}=(0,r.useContext)(d),a={USD:"$%s",AUD:"A$%s",CAD:"C$%s",EUR:"€%s",GBP:"£%s"},i=e=>a[e]||"%s",m=o.freeTrialLengthDays,u=o.price>0&&"primary"!==o.freemium_type&&"number"==typeof m&&Number.isInteger(m)&&m>0?(0,_.sprintf)((0,_._n)("%d day free trial","%d day free trial",m,"woocommerce"),m):"";function p(){return u||(0===o.price?(0,_.__)("Free download","woocommerce"):"primary"===o.freemium_type?(0,_.__)("Free plan available","woocommerce"):(0,_.sprintf)(i(o.currency),o.price))}function h(){return u||"primary"===o.freemium_type?"":0!==o.price?function(){if(1===o.billingPeriodInterval||""===o.billingPeriod)switch(o.billingPeriod){case"day":return(0,_.__)("daily","woocommerce");case"week":return(0,_.__)("weekly","woocommerce");case"month":return(0,_.__)("monthly","woocommerce");case"year":case"":return(0,_.__)("annually","woocommerce");default:return""}let e;switch(o.billingPeriod){case"day":e=(0,_.__)("days","woocommerce");break;case"week":e=(0,_.__)("weeks","woocommerce");break;case"month":e=(0,_.__)("months","woocommerce");break;default:e=(0,_.__)("years","woocommerce")}return(0,_.sprintf)((0,_.__)("every %1$d %2$s","woocommerce"),o.billingPeriodInterval??0,e)}():""}if(o.slug&&n(o.slug))return(0,l.jsx)("span",{className:"woocommerce-marketplace__product-card__installed-label",children:(0,_.__)("Installed","woocommerce")});if(w=o,t&&w&&c("install_plugins")&&w.isInstallable&&"theme"!==w.type&&"discover"!==s&&(!w.slug||!n(w.slug)))return(0,l.jsx)(l.Fragment,{children:(0,l.jsx)("span",{className:"woocommerce-marketplace__product-card__add-to-store",children:(0,l.jsx)(g.Button,{variant:"secondary",onClick:function(){(0,k.recordEvent)("marketplace_add_to_store_clicked",{product_id:o.id}),(0,x.navigateTo)({url:(0,x.getNewPath)({installProduct:o.id})})},children:(0,_.__)("Add to Store","woocommerce")})})});var w;const b=o.averageRating??0;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"woocommerce-marketplace__product-card__price",children:[(0,l.jsxs)("span",{className:"woocommerce-marketplace__product-card__price-label",children:[(0,l.jsx)("span",{className:"screen-reader-text",children:u||(o.isOnSale?(0,_.sprintf)((0,_.__)("Sale Price %1$s %3$s, regular price %2$s %3$s","woocommerce"),p(),(0,_.sprintf)(i(o.currency),o.regularPrice),h()):0!==o.price&&"primary"!==o.freemium_type?(0,_.sprintf)((0,_.__)(" %1$s, %2$s ","woocommerce"),p(),h()):p())}),(0,l.jsx)("span",{"aria-hidden":!0,children:p()})]}),o.isOnSale&&!u&&(0,l.jsx)("span",{className:"woocommerce-marketplace__product-card__on-sale","aria-hidden":!0,children:(0,_.sprintf)(i(o.currency),o.regularPrice)}),(0,l.jsx)("span",{className:"woocommerce-marketplace__product-card__price-billing","aria-hidden":!0,children:h()})]}),(0,l.jsx)("div",{className:"woocommerce-marketplace__product-card__rating",children:Number.isFinite(b)&&b>0&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("span",{className:"woocommerce-marketplace__product-card__rating-icon",children:(0,l.jsx)(g.Icon,{icon:"star-filled",size:16})}),(0,l.jsxs)("span",{className:"woocommerce-marketplace__product-card__rating-average",children:[(0,l.jsx)("span",{"aria-hidden":!0,children:b}),(0,l.jsx)("span",{className:"screen-reader-text",children:(0,_.sprintf)((0,_.__)("%.1f stars","woocommerce"),b)})]}),(0,l.jsxs)("span",{className:"woocommerce-marketplace__product-card__rating-count",children:[(0,l.jsxs)("span",{"aria-hidden":!0,children:["(",o.reviewsCount,")"]}),(0,l.jsx)("span",{className:"screen-reader-text",children:(0,_.sprintf)((0,_.__)("from %d reviews","woocommerce"),o.reviewsCount??0)})]})]})})]})};function E({size:e=12}){return(0,l.jsxs)("svg",{className:"woocommerce-marketplace__quality-badge-icon",fill:"none",height:e,viewBox:"0 0 16 16",width:e,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[(0,l.jsx)("path",{d:"M8.63342 0.528086L9.86941 0.105681C10.8022 -0.212938 11.8262 0.211045 12.2606 1.09624L12.836 2.26913C13.0272 2.65841 13.342 2.97356 13.7316 3.16473L14.9045 3.74014C15.7894 4.17422 16.2137 5.19853 15.8951 6.13135L15.4727 7.36734C15.3323 7.77776 15.3323 8.22319 15.4727 8.63361L15.8951 9.8696C16.2137 10.8024 15.7897 11.8264 14.9045 12.2608L13.7316 12.8362C13.3423 13.0274 13.0272 13.3422 12.836 13.7318L12.2606 14.9047C11.8265 15.7896 10.8022 16.2139 9.86941 15.8953L8.63342 15.4729C8.223 15.3325 7.77757 15.3325 7.36715 15.4729L6.13116 15.8953C5.19834 16.2139 4.17434 15.7899 3.73995 14.9047L3.16454 13.7318C2.97337 13.3425 2.65854 13.0274 2.26894 12.8362L1.09605 12.2608C0.211172 11.8267 -0.213126 10.8024 0.105492 9.8696L0.527898 8.63361C0.668279 8.22319 0.668279 7.77776 0.527898 7.36734L0.105492 6.13135C-0.213126 5.19853 0.210857 4.17453 1.09605 3.74014L2.26894 3.16473C2.65822 2.97356 2.97337 2.65873 3.16454 2.26913L3.73995 1.09624C4.17371 0.211045 5.19802 -0.213253 6.13085 0.105681L7.36683 0.528086C7.77725 0.668468 8.22269 0.668468 8.6331 0.528086H8.63342Z",fill:"#1d2327"}),(0,l.jsx)("path",{d:"M7.31385 11.7143L4 7.98002L4.28348 7.14289L7.31385 8.81639L11.4267 4.95924L12.237 5.54286L7.31385 11.7143Z",fill:"#fff"})]})}function L(e){const o=function(e){try{const o=new URL(e??"");return"https:"===o.protocol?o.href:void 0}catch{return}}(e.docsUrl),{tooltip:t,anchor:c,onClose:s}=e;return(0,r.useEffect)(()=>{(0,M.speak)(t)},[t]),(0,r.useEffect)(()=>{const e=e=>{const o=e.target;!o||o.closest(".woocommerce-marketplace__quality-badge-popover")||c?.contains(o)||s()};return document.addEventListener("focusin",e),()=>document.removeEventListener("focusin",e)},[c,s]),(0,l.jsxs)(g.Popover,{className:"woocommerce-marketplace__quality-badge-popover",anchor:e.anchor,placement:"bottom",focusOnMount:!!o&&"firstElement",constrainTabbing:!1,onClose:s,children:[(0,l.jsx)("p",{children:e.tooltip}),o&&(0,l.jsx)("a",{href:o,target:"_blank",rel:"noreferrer","aria-label":(0,_.sprintf)((0,_.__)("Learn more about the %s badge","woocommerce"),e.label),onClick:()=>(0,k.recordEvent)("marketplace_quality_badge_learn_more_clicked",{source:e.source}),onKeyDown:e=>{"Escape"!==e.key&&"Tab"!==e.key||(s(),c?.focus())},children:(0,_.__)("Learn more","woocommerce")})]})}function D(e,o){const t=o?.quality_badge;return t?.enabled&&t.label&&e?.hasQualityBadge?{...t,label:t.label}:null}function z(e){const{iamSettings:o}=(0,r.useContext)(d),[t,c]=(0,r.useState)(!1),[s,n]=(0,r.useState)(null),a=D(e.product,o);if(!a)return null;const i=(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(E,{}),a.label]});return a.tooltip?(0,l.jsxs)("div",{className:"woocommerce-marketplace__quality-badge",children:[(0,l.jsx)("button",{ref:n,type:"button",className:"woocommerce-marketplace__quality-badge__chip","aria-expanded":t,onClick:()=>c(!t),onKeyDown:e=>{"Escape"===e.key&&t&&c(!1)},children:i}),t&&(0,l.jsx)(L,{label:a.label,tooltip:a.tooltip,docsUrl:a.docs_url,anchor:s,source:"product_card",onClose:()=>c(!1)})]}):(0,l.jsx)("div",{className:"woocommerce-marketplace__quality-badge",children:(0,l.jsx)("span",{className:"woocommerce-marketplace__quality-badge__chip",children:i})})}var U=t(14592),O=t(98846),P=t(42435);const R=["a","b","blockquote","br","button","cite","code","dd","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","i","img","li","mark","ol","p","pre","small","span","strong","sub","sup","table","tbody","td","th","thead","tr","ul"],Q=["alt","border","class","download","href","id","height","name","rel","role","sizes","src","srcset","style","target","title","width"],B={tags:[...R,"path","svg","footer","header"],attr:[...Q,"d","fill","viewBox","xmlns"]};function H({productTitle:e,productVendor:o,productIcon:t,productId:c,triggerRef:s,variation:a,onOpen:m,onClose:u}){const[d,p]=(0,r.useState)(!0),[h,w]=(0,r.useState)(null),[b,x]=(0,r.useState)(null),y=(0,r.useCallback)((e="")=>{u&&u(e),setTimeout(()=>{s.current&&s.current.focus()},100)},[u,s]);(0,r.useEffect)(()=>{const e=e=>{const o=e.target.closest("a");if(o){const e=o.getAttribute("data-iam-tracks");e&&y(`marketplace_product_preview_modal_${e}_clicked`)}},o=document.querySelector(".woocommerce-marketplace__product-preview-modal__content");if(o)return o.addEventListener("click",e),()=>{o.removeEventListener("click",e)}},[y]),(0,r.useEffect)(()=>{(async()=>{try{const e=await(0,U.QC)(c),o=e?.data||e;if(!o?.html||!o?.css)throw new Error("Invalid preview data structure");const t=a?function(e,o){const{hostname:t}=new URL(n.H2),r=document.createElement("template");return r.innerHTML=e,r.content.querySelectorAll("a[href]").forEach(e=>{let r;try{r=new URL(e.getAttribute("href")??"",document.baseURI)}catch{return}r.hostname===t&&(r.searchParams.set(i,o),e.setAttribute("href",r.toString()))}),r.innerHTML}(o.html,a):o.html,r=function(e,o={}){return e?{__html:(0,P.sanitizeHTML)(e,{tags:o.tags||R,attr:o.attr||Q})}:""}(t,B);w({html:r?.__html??"",css:o.css}),x(null)}catch(e){x((0,_.__)("Failed to load product preview.","woocommerce"))}finally{p(!1)}})(),m&&m()},[m,c,a]);const v=(0,l.jsxs)("div",{className:"woocommerce-marketplace__product-preview-modal__header",children:[t&&(0,l.jsx)("img",{className:"woocommerce-marketplace__product-preview-modal__icon",src:t,alt:e}),(0,l.jsxs)("div",{className:"woocommerce-marketplace__product-preview-modal__header-content",children:[(0,l.jsx)("h2",{children:e}),o&&(0,l.jsxs)("div",{className:"woocommerce-marketplace__product-preview-modal__vendor",children:[(0,l.jsx)("span",{children:(0,_.__)("By","woocommerce")})," ",o]})]})]});return(0,l.jsxs)(g.Modal,{onRequestClose:()=>y("marketplace_product_preview_modal_dismissed"),className:"woocommerce-marketplace__product-preview-modal",closeButtonLabel:(0,_.__)("Close product preview","woocommerce"),size:"large",focusOnMount:"firstElement",title:(0,_.__)("The WooCommerce Marketplace","woocommerce"),children:[v,(0,l.jsxs)("div",{className:"woocommerce-marketplace__product-preview-modal__content",children:[d&&(0,l.jsx)("div",{className:"woocommerce-marketplace__product-preview-modal__loading",children:(0,l.jsx)(O.Spinner,{})}),b&&(0,l.jsx)("div",{className:"woocommerce-marketplace__product-preview-modal__error",children:b}),!d&&!b&&h&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("style",{children:h.css}),(0,l.jsx)("div",{dangerouslySetInnerHTML:{__html:h.html}})]})]})]})}const W=function(e){const{isLoading:o,cardType:t}=e,c="compact"===t,s=(0,x.useQuery)(),[n,a]=(0,r.useState)(!1),m=(0,r.useRef)(null),u=e.product??{id:null,title:"",description:"",vendorName:"",vendorUrl:"",icon:"",label:null,primary_color:null,url:"",price:0,image:"",averageRating:null,reviewsCount:null,featuredImage:"",color:"",productCategory:"",billingPeriod:"",billingPeriodInterval:0,currency:"",isOnSale:!1,regularPrice:0,type:""},p=u.type===T.ch.businessService?u.type:e.type,h=p===T.ch.theme,w=p===T.ch.businessService,{iamSettings:y,productPreviewVariation:v}=(0,r.useContext)(d),f=!h&&!w&&!e.small,j=f?v:null,N=f&&(j?"treatment"===j:"modal"===y?.product_previews),C=!o&&!w&&null!==D(e.product,y),M=!c&&!o,I=!c&&o,E=!h&&!c,L=!h||c,O=h&&!c,P=(0,A.decodeEntities)(u.title),R=(0,A.decodeEntities)(u.description);function Q(){return"promoted"===u.label}const B=!o&&Q(),W=M||B;function Y(o,t){const{tracksData:r}=e;r.position&&(t.position=r.position),r.label&&(t.label=r.label),r.group&&(t.group=r.group),r.group_id&&(t.group_id=r.group_id),r.searchTerm&&(t.search_term=r.searchTerm),r.category&&(t.category=r.category),t.tab=s.tab||"discover",(0,k.recordEvent)(o,t)}const F=(0,l.jsx)("span",{className:"screen-reader-text",children:(0,_.__)("Opens in a new tab","woocommerce")}),$=e=>u?.vendorName&&u?.vendorUrl?(0,l.jsxs)("a",{href:u.vendorUrl,rel:"noopener noreferrer",target:"_blank",onClick:()=>{Y(e,{product:u.title,vendor:u.vendorName,product_type:p})},children:[u.vendorName,F]}):u?.vendorName||null,V=$("marketplace_product_card_vendor_clicked"),q=()=>{const e=[];return s.ref&&e.push(["utm_content",s.ref]),j&&e.push([i,j]),e.length?(0,U.A5)(u.url,e):u.url},G=(0,b.A)("woocommerce-marketplace__product-card",`woocommerce-marketplace__product-card--${p}`,{"is-loading":o,"is-small":e.small,"is-sponsored":Q(),"is-compact":c}),Z=()=>(0,l.jsxs)("a",{ref:m,className:"woocommerce-marketplace__product-card__link",href:q(),rel:"noopener noreferrer",target:"_blank",onClick:e=>{N&&e.preventDefault(),Y("marketplace_product_card_clicked",{product_id:u.id,product_name:u.title,vendor:u.vendorName,product_type:p,has_quality_badge:C,...j&&{preview_variation:j}}),N&&a(!0)},children:[o?" ":P,F]}),K=()=>{const e=c?u.icon:u.featuredImage,o=c?96:288;return(0,l.jsxs)("div",{className:"woocommerce-marketplace__business-card",children:[(0,l.jsx)("div",{className:"woocommerce-marketplace__business-card__header",style:{backgroundColor:u.color},children:(0,l.jsx)("img",{src:`${e||u.featuredImage}?h=${o}`,alt:""})}),(0,l.jsxs)("div",{className:"woocommerce-marketplace__business-card__content",children:[(0,l.jsxs)("div",{className:"woocommerce-marketplace__business-card__main-content",children:[(0,l.jsx)("h2",{children:(0,l.jsx)(Z,{})}),(0,l.jsx)("p",{className:"woocommerce-marketplace__product-card__description",children:R})]}),(0,l.jsx)("div",{className:"woocommerce-marketplace__business-card__badge",children:(0,l.jsx)("span",{children:u.productCategory})})]})]})},J=C&&e.product?(0,l.jsx)(z,{product:e.product}):null,X=w?null:(0,l.jsxs)("footer",{className:"woocommerce-marketplace__product-card__footer",children:[o&&(0,l.jsx)("div",{className:"woocommerce-marketplace__product-card__price"}),!c&&J,!o&&e.product&&(0,l.jsx)(S,{product:e.product})]}),ee=(0,l.jsxs)("div",{className:"woocommerce-marketplace__product-card__content",children:[O&&(0,l.jsx)("div",{className:"woocommerce-marketplace__product-card__image",children:!o&&(0,l.jsx)("img",{className:"woocommerce-marketplace__product-card__image-inner",src:u.image,alt:P})}),(0,l.jsx)("div",{className:"woocommerce-marketplace__product-card__header",children:(0,l.jsxs)("div",{className:"woocommerce-marketplace__product-card__details",children:[L&&(0,l.jsxs)(l.Fragment,{children:[o&&(0,l.jsx)("div",{className:"woocommerce-marketplace__product-card__icon"}),!o&&u.icon&&(0,l.jsx)("img",{className:"woocommerce-marketplace__product-card__icon",src:u.icon||u.image,alt:P})]}),(0,l.jsxs)("div",{className:"woocommerce-marketplace__product-card__meta",children:[(0,l.jsx)("h2",{className:"woocommerce-marketplace__product-card__title",children:(0,l.jsx)(Z,{})}),I&&(0,l.jsx)("p",{className:"woocommerce-marketplace__product-card__vendor-details",children:(0,l.jsx)("span",{className:"woocommerce-marketplace__product-card__vendor"})}),W&&(0,l.jsxs)("p",{className:"woocommerce-marketplace__product-card__vendor-details",children:[M&&V&&(0,l.jsxs)("span",{className:"woocommerce-marketplace__product-card__vendor",children:[(0,l.jsx)("span",{children:(0,_.__)("By","woocommerce")})," ",V]}),M&&V&&B&&(0,l.jsx)("span",{"aria-hidden":"true",className:"woocommerce-marketplace__product-card__vendor-details__separator",children:"·"}),B&&(0,l.jsx)("span",{className:"woocommerce-marketplace__product-card__sponsored-label",children:(0,_.__)("Sponsored","woocommerce")})]}),c&&J,c&&X]})]})}),E&&(0,l.jsx)("p",{className:"woocommerce-marketplace__product-card__description",children:!o&&R}),!c&&X]}),oe=()=>o?w?(0,l.jsx)(K,{}):ee:(0,l.jsx)("div",{className:"woocommerce-marketplace__product-card-wrapper",children:w?(0,l.jsx)(K,{}):ee});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(g.Card,{className:G,id:`product-${u.id}`,tabIndex:-1,"aria-hidden":o,style:Q()&&u.primary_color?{background:`linear-gradient(${u.primary_color} 0, ${u.primary_color} 5px, white 5px, white)`}:{},children:(0,l.jsx)(oe,{})}),N&&n&&u&&(0,l.jsx)(H,{productTitle:P,productVendor:$("marketplace_product_preview_vendor_clicked"),productIcon:u.icon||"",onOpen:()=>{Y("marketplace_product_preview_modal_opened",{product_id:u.id,product_name:u.title,vendor:u.vendorName,product_type:p})},onClose:e=>{Y(e||"marketplace_product_preview_modal_dismissed",{product_id:u.id,product_name:u.title,vendor:u.vendorName,product_type:p}),a(!1)},productId:u.id,triggerRef:m,variation:j})]})};function Y(e){const o=(0,s.Qk)("wccomHelper",{}),[t,c]=(0,r.useState)(e.products),[n,a]=(0,r.useState)(1),i=()=>{const e=window.innerWidth;a(e>=1920?4:e>=1024?3:e>=769?2:1)};(0,r.useEffect)(()=>(i(),window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)),[]),(0,r.useEffect)(()=>{if(!e.productGroup)return void c(e.products);if(e.cardType===T.WX.compact)return void c(e.products);if(e.products.length<n)return void c(e.products);let o=Math.floor(e.products.length/n);1===n&&(o=Math.min(o,4)),2===n&&(o=Math.min(o,2)),c(e.products.slice(0,o*n))},[n,e.products,e.productGroup,e.cardType]);const m=(0,b.A)("woocommerce-marketplace__product-list-content",e.className);return(0,l.jsx)(l.Fragment,{children:(0,l.jsx)("div",{className:m,children:t.map((t,c)=>(0,l.jsx)(r.Fragment,{children:(0,l.jsx)(W,{type:e.type,cardType:e.cardType,product:{id:t.id,slug:t.slug,title:t.title,image:t.image,type:t.type,freemium_type:t.freemium_type,icon:t.icon,label:t.label,primary_color:t.primary_color,vendorName:t.vendorName,vendorUrl:t.vendorUrl?(0,U.A5)(t.vendorUrl,[["utm_source","extensionsscreen"],["utm_medium","product"],["utm_campaign","wcaddons"],["utm_content","devpartner"]]):"",price:t.price,url:(0,U.A5)(t.url,Object.entries({...o.inAppPurchaseURLParams,...void 0!==e.productGroup?{utm_group:e.productGroup}:{}})),averageRating:t.averageRating,reviewsCount:t.reviewsCount,description:t.description,isInstallable:t.isInstallable,color:t.color,featuredImage:t.featuredImage,productCategory:t.productCategory,billingPeriod:t.billingPeriod,billingPeriodInterval:t.billingPeriodInterval,currency:t.currency,isOnSale:t.isOnSale,regularPrice:t.regularPrice,hasQualityBadge:t.hasQualityBadge,freeTrialLengthDays:t.freeTrialLengthDays},tracksData:{position:c+1,...t.label&&{label:t.label},...e.productGroup&&{group_id:e.productGroup},...e.group&&{group:e.group},...e.searchTerm&&{searchTerm:e.searchTerm},...e.category&&{category:e.category}}})},t.id))})})}function F(e){const{title:o,description:t,groupURL:r,groupURLText:c,groupURLType:s}=e,n=""===o,a=(0,b.A)("woocommerce-marketplace__product-list-header",{"is-loading":n});return(0,l.jsxs)("div",{className:a,"aria-hidden":n,children:[(0,l.jsx)("h2",{className:"woocommerce-marketplace__product-list-title",children:o}),t&&(0,l.jsx)("p",{className:"woocommerce-marketplace__product-list-description",children:t}),null!==r&&(0,l.jsx)("span",{className:"woocommerce-marketplace__product-list-link",children:(0,l.jsx)(O.Link,{href:r,type:s,target:"external"===s?"_blank":void 0,onClick:()=>{(0,k.recordEvent)("marketplace_see_more_clicked",{group_title:o,group_url:r})},children:c??(0,_.__)("See more","woocommerce")})})]})}function $(e){const{title:o,description:t,products:r,groupURL:c,type:s,productGroup:n,groupURLText:a,groupURLType:i,cardType:m,groupId:u,containerRef:d}=e;return(0,l.jsxs)("div",{className:"woocommerce-marketplace__product-list","data-group-id":u,ref:d,children:[(0,l.jsx)(F,{title:o,groupURL:c,groupURLText:a,description:t,groupURLType:i}),(0,l.jsx)(Y,{group:o,products:r,type:s,cardType:m,productGroup:n})]})}function V(e){const{hasTitle:o,type:t}=e,r=e.placeholderCount||12;return(0,l.jsxs)("div",{className:"woocommerce-marketplace__product-list",children:[!1!==o&&(0,l.jsx)(F,{title:"",groupURL:null,description:"",groupURLText:null,groupURLType:void 0}),(0,l.jsx)("div",{className:"woocommerce-marketplace__product-list-content",children:[...Array(r)].map((e,o)=>(0,l.jsx)(W,{isLoading:!0,type:t,tracksData:{}},o))})]})}function q(){const e=(0,s.Qk)("wccomHelper",{});return e?.isConnected??!1}function G(e){if(""===e.category)return;const o=e.view||"discover",t=e.search_term||null,r=e.product_type||null,c=e.category||null,s=e.utm_source||null,n=e.utm_campaign||null,a={...o&&{view:o},...t&&{search_term:t},...r&&{product_type:r},...c&&{category:c},...s&&{utm_source:s},...n&&{utm_campaign:n},wccom_connected:q()};o&&["extensions","themes","business-services"].includes(o)&&!c&&(a.category="_all"),(0,k.recordEvent)("marketplace_view",a)}function Z(){const[e,o]=(0,r.useState)([]),t=(0,r.useRef)({}),c=(0,r.useContext)(d),{isLoading:s,setIsLoading:n}=c;if((0,r.useEffect)(()=>{n(!0),(0,U.b8)().then(e=>Array.isArray(e)?e:[]).then(e=>{o(e),function(e){const o=e.flatMap(e=>e.items).map(e=>e.id),t=Object.fromEntries(e.map(e=>[e.id,e.items.map(e=>e.id)]));(0,k.recordEvent)("marketplace_discover_viewed",{view:"discover",product_ids:o,groups:t}),G({view:"discover"})}(e)}).finally(()=>{n(!1)})},[n]),(0,r.useEffect)(()=>{if(s||!e.length||!("IntersectionObserver"in window))return;const o=new Map(e.map(e=>[e.id,e])),r=new Set,c=new IntersectionObserver(e=>{e.forEach(e=>{if(!e.isIntersecting)return;const t=e.target.dataset.groupId;if(!t||r.has(t))return;const s=o.get(t);s&&(function(e){(0,k.recordEvent)("marketplace_discover_group_viewed",{view:"discover",group_id:e.id,product_ids:e.items.map(e=>e.id)})}(s),r.add(t),c.unobserve(e.target))})},{threshold:.25});return e.forEach(e=>{const o=t.current[e.id];o&&c.observe(o)}),()=>{c.disconnect()}},[s,e]),s)return(0,l.jsx)("div",{className:"woocommerce-marketplace__discover",children:(0,l.jsx)(V,{placeholderCount:9,type:T.ch.extension})});const a=e.flatMap(e=>e);return(0,l.jsx)("div",{className:"woocommerce-marketplace__discover",children:a.map(e=>(0,l.jsx)($,{productGroup:e.id,title:e.title,description:e.description,products:e.items,groupURL:e.url,groupURLText:e.url_text,groupURLType:e.url_type,type:e.itemType,cardType:e.cardType??T.WX.regular,groupId:e.id,containerRef:o=>{t.current[e.id]=o}},e.id))})}var K=t(29491);function J(e){const o=""===e.label,t=(0,b.A)("woocommerce-marketplace__category-item-button",{"woocommerce-marketplace__category-item-button--selected":e.selected,"is-loading":o});return(0,l.jsx)("button",{className:t,onClick:function(e){const o=e.currentTarget.value;o&&(0,x.navigateTo)({url:(0,x.getNewPath)({category:o})})},value:e.slug,"aria-hidden":o,children:e.label})}var X=t(11789),ee=t(58396),oe=t(10149);function te(e){function o(o){const t=o.currentTarget.value;t&&(e.onClick(),(0,x.navigateTo)({url:(0,x.getNewPath)({category:t})}))}return(0,l.jsx)("ul",{className:"woocommerce-marketplace__category-dropdown-list",children:e.categories.map(t=>(0,l.jsx)("li",{className:"woocommerce-marketplace__category-dropdown-item",children:(0,l.jsx)("button",{className:(0,b.A)("woocommerce-marketplace__category-dropdown-item-button",{"woocommerce-marketplace__category-dropdown-item-button--selected":t.slug===e.selected?.slug}),value:t.slug,onClick:o,children:t.label})},t.slug))})}function re(e){return(0,l.jsx)(g.Dropdown,{renderToggle:({isOpen:o,onToggle:t})=>(0,l.jsxs)("button",{onClick:()=>{o||(0,k.recordEvent)("marketplace_category_dropdown_opened",{type:e.type}),t()},className:e.buttonClassName,"aria-label":(0,_.__)("Toggle category dropdown","woocommerce"),children:[e.label,(0,l.jsx)(X.A,{icon:o?ee.A:oe.A,size:e.arrowIconSize})]}),className:e.className,renderContent:({onToggle:o})=>(0,l.jsx)(te,{categories:e.categories,selected:e.selected,onClick:o}),contentClassName:e.contentClassName})}const ce={[T.ch.extension]:"_all",[T.ch.theme]:"themes",[T.ch.businessService]:"business-services"};function se(e){const[o,t]=(0,r.useState)(),[c,s]=(0,r.useState)(!1),[n,a]=(0,r.useState)([]),[i,m]=(0,r.useState)(!1),[u,d]=(0,r.useState)("start"),p=(0,r.useRef)(null),h=(0,r.useRef)(null),w=(0,x.useQuery)();function b(){if(p.current&&p.current.parentElement?.scrollWidth){const e=p.current.scrollWidth>p.current.parentElement.scrollWidth;m(e)}}(0,r.useEffect)(()=>{s(!0),(0,U.jE)(e.type).then(e=>{const o=e.map(e=>({...e,selected:!1})).filter(e=>"_featured"!==e.slug);a(o)}).catch(()=>{a([])}).finally(()=>{s(!1)})},[e.type,a]),(0,r.useEffect)(()=>{let o=ce[e.type];w.category&&(o=w.category);const r=n.find(e=>e.slug===o);r&&t(r)},[w.category,e.type,n]),(0,r.useEffect)(()=>{h.current&&h.current.scrollIntoView({block:"nearest",inline:"center"})},[o]);const y=(0,K.useDebounce)(b,300),v=(0,K.useDebounce)(function(){const e=p.current;if(!e)return;const{scrollLeft:o,scrollWidth:t,clientWidth:r}=e;o<10?d("start"):o+r<t?d("middle"):o+r===t&&d("end")},100);function f(e){p.current&&p.current.scrollTo({left:p.current.scrollLeft+e,behavior:"smooth"})}return(0,r.useEffect)(()=>{window.addEventListener("resize",y);const e=p.current;return e&&e.addEventListener("scroll",v),()=>{window.removeEventListener("resize",y),e&&e.removeEventListener("scroll",v)}},[y,v]),(0,r.useEffect)(()=>{b()},[n]),c?(0,l.jsx)(l.Fragment,{children:(0,l.jsx)("ul",{className:"woocommerce-marketplace__category-selector",children:[...Array(5)].map((e,o)=>(0,l.jsx)("li",{className:"woocommerce-marketplace__category-item",children:(0,l.jsx)(J,{slug:"",label:"",selected:!1})},o))})}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("ul",{className:"woocommerce-marketplace__category-selector","aria-label":"Categories",ref:p,children:n.map(e=>(0,l.jsx)("li",{className:"woocommerce-marketplace__category-item",ref:e.slug===o?.slug?h:null,children:(0,l.jsx)(J,{...e,selected:e.slug===o?.slug,"aria-current":e.slug===o?.slug})},e.slug))}),(0,l.jsx)("div",{className:"woocommerce-marketplace__category-selector--full-width",children:(0,l.jsx)(re,{type:e.type,label:function(){const e=(0,_.__)("All Categories","woocommerce");return o?"All"===o.label?e:o.label:e}(),categories:n,buttonClassName:"woocommerce-marketplace__category-dropdown-button",className:"woocommerce-marketplace__category-dropdown",contentClassName:"woocommerce-marketplace__category-dropdown-content",selected:o})}),i&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("button",{onClick:function(){f(-200)},className:"woocommerce-marketplace__category-navigation-button woocommerce-marketplace__category-navigation-button--prev",hidden:"start"===u,"aria-label":"Scroll to previous categories",tabIndex:-1,children:(0,l.jsx)(g.Icon,{icon:"arrow-left-alt2"})}),(0,l.jsx)("button",{onClick:function(){f(200)},className:"woocommerce-marketplace__category-navigation-button woocommerce-marketplace__category-navigation-button--next",hidden:"end"===u,"aria-label":"Scroll to next categories",tabIndex:-1,children:(0,l.jsx)(g.Icon,{icon:"arrow-right-alt2"})})]})]})}var ne=t(74515);function ae(e){const[o,t]=(0,r.useState)(!1),[c,s]=(0,r.useState)(null);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("button",{ref:s,type:"button",className:"woocommerce-marketplace__quality-badge-filter__info","aria-expanded":o,"aria-label":(0,_.sprintf)((0,_.__)("About %s","woocommerce"),e.label),onClick:()=>t(!o),onKeyDown:e=>{"Escape"===e.key&&o&&t(!1)},children:(0,l.jsx)(g.Icon,{icon:ne.A,size:16})}),o&&(0,l.jsx)(L,{label:e.label,tooltip:e.tooltip,docsUrl:e.docsUrl,anchor:c,source:"filter",onClose:()=>t(!1)})]})}function ie(){const{iamSettings:e}=(0,r.useContext)(d),o=(0,x.useQuery)(),t=(0,K.useInstanceId)(ie,"woocommerce-marketplace-quality-badge-filter"),c=e?.quality_badge;if(!c?.enabled||!c.label)return null;const s="1"===o.quality_badge;return(0,l.jsxs)("div",{className:"woocommerce-marketplace__quality-badge-filter",children:[(0,l.jsx)(E,{size:18}),(0,l.jsx)("label",{htmlFor:t,children:(0,r.createInterpolateElement)((0,_.sprintf)((0,_.__)("Show only <badgeName>%s</badgeName>","woocommerce"),c.label),{badgeName:(0,l.jsx)("span",{className:"woocommerce-marketplace__quality-badge-filter__name"})})}),c.tooltip&&(0,l.jsx)(ae,{label:c.label,tooltip:c.tooltip,docsUrl:c.docs_url}),(0,l.jsx)(g.FormToggle,{id:t,checked:s,onChange:()=>{(0,k.recordEvent)("marketplace_quality_badge_filter_toggled",{state:s?"off":"on"}),(0,x.navigateTo)({url:(0,x.getNewPath)({quality_badge:s?void 0:"1"})})}})]})}function le(e){const[o,t]=(0,r.useState)(),[c,s]=(0,r.useState)(!1),n={[T.If.all]:["most-popular","popular-themes","business-services"],[T.If.theme]:["popular-themes"],[T.If.extension]:["most-popular"],[T.If.businessService]:["business-services"]};return(0,r.useEffect)(()=>{s(!0),(0,U.b8)().then(o=>{const r=n[e.type];if(!r)return;const c=o.filter(e=>r.includes(e.id)).map(e=>({...e,items:e.items.slice(0,4)}));c&&t(c)}).catch(()=>{t(void 0)}).finally(()=>{s(!1)})},[]),(0,l.jsxs)("div",{className:"woocommerce-marketplace__no-results",children:[function(){if(!1===e.showCategorySelector||e.type===T.If.all)return(0,l.jsx)(l.Fragment,{});let o=T.ch.extension;return e.type===T.If.theme&&(o=T.ch.theme),e.type===T.If.businessService&&(o=T.ch.businessService),(0,l.jsx)(se,{type:o})}(),(0,l.jsxs)("div",{className:"woocommerce-marketplace__no-results__content",children:[(0,l.jsx)("h2",{className:"woocommerce-marketplace__no-results__heading",children:e.showHeading?e.heading:""}),(0,l.jsx)("p",{className:"woocommerce-marketplace__no-results__description",children:(0,_.__)("Try searching again using a different term, or take a look at our recommendations below.","woocommerce")})]}),(0,l.jsx)("div",{className:"woocommerce-marketplace__no-results__product-groups",children:c?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(V,{type:T.ch.extension,placeholderCount:4}),(0,l.jsx)(V,{type:T.ch.theme,placeholderCount:4}),(0,l.jsx)(V,{type:T.ch.businessService,placeholderCount:4})]}):o&&0!==o.length?(0,l.jsx)(l.Fragment,{children:o.map(e=>{return(0,l.jsx)($,{title:(o=e.id,"popular-themes"===o?(0,_.__)("Our favorite themes","woocommerce"):"business-services"===o?(0,_.__)("Services to help your business grow","woocommerce"):(0,_.__)("Most popular extensions","woocommerce")),description:e.description,products:e.items,groupURL:e.url,productGroup:e.id,type:e.itemType,groupURLText:e.url_text,groupURLType:e.url_type},e.id);var o})}):(0,l.jsx)(l.Fragment,{})})]})}const me={[T.ch.extension]:{label:(0,_.__)("extensions","woocommerce"),singularLabel:(0,_.__)("extension","woocommerce")},[T.ch.theme]:{label:(0,_.__)("themes","woocommerce"),singularLabel:(0,_.__)("theme","woocommerce")},[T.ch.businessService]:{label:(0,_.__)("business services","woocommerce"),singularLabel:(0,_.__)("business service","woocommerce")}};function ue(e){const o=(0,r.useContext)(d),{isLoading:t}=o,c=me[e.type].label,n=(0,x.useQuery)(),a=n?.category,i=e.showAllButton??!1,m=e.products??[],u="business services"===c?"business-services":c,p="woocommerce-marketplace__search-",h=(0,b.A)(p+u),w=(0,b.A)("woocommerce-marketplace__view-all-button",p+"button-"+u),y=e.type===T.ch.extension,v=!t&&0===m.length,f=Boolean(e.categorySelector),j=e.searchTerm?.trim()??"",k=(y||f)&&(0,l.jsxs)("nav",{className:"woocommerce-marketplace__sub-header",children:[y&&(0,l.jsx)(ie,{}),(0,l.jsx)("div",{className:"woocommerce-marketplace__sub-header__categories",children:f&&(0,l.jsx)(se,{type:e.type})})]});let N=T.If.all;switch(e.type){case T.ch.extension:N=T.If.extension;break;case T.ch.theme:N=T.If.theme;break;case T.ch.businessService:N=T.If.businessService}const C=(0,b.A)(i?"woocommerce-marketplace__product-list-content--collapsed":"");return(0,l.jsxs)("div",{className:h,children:[j&&(0,l.jsx)("h2",{className:"woocommerce-marketplace__search-results-heading",children:(0,_.sprintf)((0,_.__)("Results for “%s”","woocommerce"),j)}),k,t&&(0,l.jsx)(V,{hasTitle:!1,type:e.type}),v&&(0,l.jsx)(le,{type:N,showHeading:!1,showCategorySelector:!f}),!t&&!v&&(0,l.jsx)(Y,{products:m,type:e.type,className:C,searchTerm:e.searchTerm,category:a}),!t&&!v&&"theme"===e.type&&(0,l.jsxs)("div",{className:"woocommerce-marketplace__browse-wp-theme-directory",children:[(0,l.jsx)("b",{children:(0,_.__)("Didn’t find a theme you like?","woocommerce")},"wp-theme-directory-heading")," ",(0,l.jsx)("span",{children:(0,r.createInterpolateElement)((0,_.__)("Browse the <a>WordPress.org theme directory</a> to discover more.","woocommerce"),{a:(0,l.jsx)("a",{href:s.kY+"theme-install.php?search=e-commerce"},"wp-theme-directory")})},"wp-theme-directory-copy")]}),!t&&!v&&i&&(0,l.jsx)(g.Button,{className:w,variant:"secondary",text:(0,_.__)("View all","woocommerce"),onClick:()=>{return o=e.type,void(0,x.navigateTo)({url:(0,x.getNewPath)({section:o})});var o}})]})}var de=t(96900),pe=t(1455),_e=t.n(pe),he=t(26845);const we={subscriptions:[],setSubscriptions:()=>{},loadSubscriptions:()=>Promise.resolve(),refreshSubscriptions:()=>Promise.resolve(),isLoading:!0,setIsLoading:()=>{}},ge=(0,r.createContext)(we);function be(e){const[o,t]=(0,r.useState)([]),[c,s]=(0,r.useState)(!0),n=e=>(!0===e&&s(!0),(0,U.hP)().then(e=>{t(e)}).finally(()=>{e&&s(!1)})),a=e=>(e&&s(!0),(0,U.wu)().then(e=>{t(e)}).catch(e=>{throw e}).finally(()=>{e&&s(!1)}));(0,r.useEffect)(()=>{new URLSearchParams(window.location.search).get("install")?a(!0).catch(e=>{(0,U.Mp)(he.W,(0,_.sprintf)((0,_.__)("Error refreshing subscriptions: %s","woocommerce"),(0,U.zu)(e)),he.T.Error)}):n(!0).catch(e=>{(0,U.Mp)("woocommerce-marketplace-load-subscriptions",(0,_.sprintf)((0,_.__)("Error loading subscriptions: %s","woocommerce"),e.message),he.T.Error)})},[]);const i={subscriptions:o,setSubscriptions:t,loadSubscriptions:n,refreshSubscriptions:a,isLoading:c,setIsLoading:s};return(0,l.jsx)(ge.Provider,{value:i,children:e.children})}const xe=[{key:"name",label:(0,_.__)("Name","woocommerce")},{key:"expiry",label:(0,_.__)("Expires/Renews on","woocommerce")},{key:"subscription",label:(0,_.__)("Subscription","woocommerce")},{key:"version",label:(0,_.__)("Version","woocommerce")}];function ye(e){if(e.isLoading)return(0,l.jsx)(O.TablePlaceholder,{caption:(0,_.__)("Loading your subscriptions","woocommerce"),headers:e.headers});const o=e.headers.map(e=>({...e,cellClassName:"woocommerce-marketplace__my-subscriptions__table__header--"+e.key}));return(0,l.jsx)(O.Table,{className:"woocommerce-marketplace__my-subscriptions__table",headers:o,rows:e.rows})}function ve(e){const o=[...xe,{key:"auto-updates",label:(0,_.__)("Automatic updates","woocommerce")},{key:"actions",label:(0,_.__)("Actions","woocommerce")}];if(!(e.isLoading||e.rows&&0!==e.rows.length)){const e=(0,x.getNewPath)({},n.q$,{}),o=(0,r.createInterpolateElement)((0,_.__)("No extensions or themes installed. <a>Browse the Marketplace</a>","woocommerce"),{a:(0,l.jsx)("a",{href:e})});return(0,l.jsx)(O.EmptyTable,{numberOfRows:4,children:o})}return(0,l.jsx)(ye,{rows:e.rows,isLoading:e.isLoading,headers:o})}function fe(e){const o=[...xe,{key:"actions",label:(0,_.__)("Actions","woocommerce")}];return(0,l.jsx)(ye,{rows:e.rows,isLoading:e.isLoading,headers:o})}var je=t(38443),ke=t(67759);let Ne=function(e){return e.Warning="warning",e.Error="error",e.Info="info",e}({});const Ce=["maxed_out","invalid_product_key","invalid_product"];function Me(e,o){(0,k.recordEvent)("marketplace_product_connect_error_action_clicked",{action:e,error_code:o})}var Te=t(52741);function Ae(e){const[o,t]=(0,r.useState)(!1),[c,s]=(0,r.useState)(!1),{loadSubscriptions:a}=(0,r.useContext)(ge),i=()=>{t(!0),s(!1),a(!1).then(()=>{(0,U.Mp)(e.subscription.product_key,(0,_.sprintf)((0,_.__)("%s successfully connected.","woocommerce"),e.subscription.product_name),he.T.Success),t(!1),e.onClose&&e.onClose()}).catch(()=>{t(!1)})},m=()=>{(0,k.recordEvent)("marketplace_product_connect_button_clicked",{product_zip_slug:e.subscription.zip_slug,product_id:e.subscription.product_id}),t(!0),s(!1),(0,U.fj)(e.subscription.product_key),(0,U.e2)(e.subscription).then(()=>{if(e.subscription.local.installed&&!e.subscription.local.active&&"plugin"===e.subscription.local.type)return t(!1),void s(!0);i()}).catch(o=>{const r=o,c=(0,_.sprintf)((0,_.__)("%s couldn’t be connected.","woocommerce"),e.subscription.product_name),s=function(e,o){const t=e?.data?.code||"";if("maxed_out"===t){const t=e?.data?.data?.sites_list||[],r=Number(e?.data?.data?.total_domains??t.length);if(r>=2){const e=t[0]||"",c=t[1]||"";if(2===r)return o+" "+(0,_.sprintf)((0,_.__)("This subscription is maxed out as it's connected to %1$s and %2$s.","woocommerce"),e,c);const s=r-2;return o+" "+(0,_.sprintf)((0,_._n)("This subscription is maxed out as it's connected to %1$s, %2$s, and %3$d other site.","This subscription is maxed out as it's connected to %1$s, %2$s, and %3$d other sites.",s,"woocommerce"),e,c,s)}}if("invalid_product_key"===t)return o+" "+(0,_.__)("The product key is invalid. Please contact support for assistance.","woocommerce");if("invalid_product"===t)return o+" "+(0,_.__)("We are unable to activate the subscription at this time. Please try again later.","woocommerce");if(Ce.includes(t)){const t=e?.data?.message||"";return t?o+" "+t:o}return o}(r,c),a=function(e){const o=e?.data?.code||"";return"maxed_out"===o?{label:(0,_.__)("Manage subscriptions","woocommerce"),onClick:()=>{Me("manage_subscriptions",o),window.location.assign(n.qc)}}:"invalid_product_key"===o?{label:(0,_.__)("Contact support","woocommerce"),onClick:()=>{Me("contact_support",o),window.location.assign(n.a$)}}:null}(r),i=a?[a]:[{label:(0,_.__)("Try again","woocommerce"),onClick:()=>{Me("try_again",r.data?.code||""),m()}}];(0,U.Mp)(e.subscription.product_key,s,he.T.Error,{actions:i}),t(!1),e.onClose&&e.onClose()})};return(0,l.jsxs)(l.Fragment,{children:[c?(0,l.jsxs)(g.Modal,{title:(0,_.__)("Activate the Plugin","woocommerce"),onRequestClose:()=>i(),focusOnMount:!0,className:"woocommerce-marketplace__header-account-modal",style:{borderRadius:4},overlayClassName:"woocommerce-marketplace__header-account-modal-overlay",children:[(0,l.jsx)("p",{className:"woocommerce-marketplace__header-account-modal-text",children:(0,l.jsx)("span",{dangerouslySetInnerHTML:(0,Te.A)((0,_.sprintf)((0,_.__)("<b>%s</b> is installed but not activated on this store. Would you like to activate it now?","woocommerce"),e.subscription.product_name))})}),(0,l.jsxs)(g.ButtonGroup,{className:"woocommerce-marketplace__header-account-modal-button-group",children:[(0,l.jsx)(g.Button,{onClick:()=>i(),variant:"tertiary",className:"woocommerce-marketplace__header-account-modal-button",children:(0,_.__)("No","woocommerce")}),(0,l.jsx)(g.Button,{onClick:()=>{t(!0),(0,U.CW)(e.subscription).then(()=>{i()}).catch(()=>{(0,U.Mp)(e.subscription.product_key,(0,_.sprintf)((0,_.__)("%s is connected to WooCommerce.com but failed to activate the local plugin.","woocommerce"),e.subscription.product_name),he.T.Error)}),s(!1)},variant:"primary",children:(0,_.__)("Yes","woocommerce")})]})]}):null,(0,l.jsx)(g.Button,{onClick:m,variant:e.variant??"secondary",isBusy:o,disabled:o,children:(0,_.__)("Connect","woocommerce")})]})}var Ie=t(47143),Se=t(93832);const Ee={installingProducts:[]},Le=(0,Ie.createReduxStore)("woocommerce-admin/installing",{reducer(e=Ee,o){switch(o.type){case"START_INSTALLING":return{...e,installingProducts:[...e.installingProducts,o.productKey]};case"STOP_INSTALLING":return{...e,installingProducts:[...e.installingProducts.filter(e=>e!==o.productKey)]}}return e},actions:{startInstalling:e=>({type:"START_INSTALLING",productKey:e}),stopInstalling:e=>({type:"STOP_INSTALLING",productKey:e})},selectors:{isInstalling:(e,o)=>!!e&&e.installingProducts.includes(o)}});function De(e){const{loadSubscriptions:o}=(0,r.useContext)(ge),{currentUserCan:t}=(0,I.useUser)(),c=(0,Ie.useSelect)(o=>o(Le).isInstalling(e.subscription.product_key),[e.subscription.product_key]),s=()=>{(0,Ie.dispatch)(Le).stopInstalling(e.subscription.product_key)},n=t=>{o(!1).then(()=>{let o=(0,_.sprintf)((0,_.__)("%s couldn’t be installed.","woocommerce"),e.subscription.product_name);!1===t?.success&&t?.data.message&&(o+=" "+t.data.message),(0,U.Mp)(e.subscription.product_key,o,he.T.Error,{actions:[{label:(0,_.__)("Download and install manually","woocommerce"),url:"https://woocommerce.com/my-account/downloads/",onClick:()=>{}}]}),s(),e.onError&&e.onError()}),(0,k.recordEvent)("marketplace_product_install_failed",{product_zip_slug:e.subscription.zip_slug,product_id:e.subscription.product_id,product_current_version:e.subscription.version,error_message:t?.data?.message})};return t("install_plugins")?(0,l.jsx)(g.Button,{variant:e.variant??"link",isBusy:c,disabled:c,onClick:()=>{(0,k.recordEvent)("marketplace_product_install_button_clicked",{product_zip_slug:e.subscription.zip_slug,product_id:e.subscription.product_id,product_current_version:e.subscription.version}),(0,Ie.dispatch)(Le).startInstalling(e.subscription.product_key),(0,U.fj)(e.subscription.product_key),e.subscription.is_installable?(0,U.dV)(e.subscription).then(()=>{o(!1).then(()=>{(0,U.Mp)(e.subscription.product_key,(0,_.sprintf)((0,_.__)("%s successfully installed.","woocommerce"),e.subscription.product_name),he.T.Success),s()}),(0,k.recordEvent)("marketplace_product_installed",{product_zip_slug:e.subscription.zip_slug,product_id:e.subscription.product_id,product_current_version:e.subscription.version}),e.onSuccess&&e.onSuccess()}).catch(n):(0,U.Xs)(e.subscription).then(o=>{if((0,k.recordEvent)("marketplace_product_install_url",{product_zip_slug:e.subscription.zip_slug,product_id:e.subscription.product_id,product_current_version:e.subscription.version,product_install_url:o?(0,Se.removeQueryArgs)(o,"token","signature","product-key"):o}),s(),!o)throw new Error;window.open(o,"_self")}).catch(n)},children:(0,_.__)("Install","woocommerce")}):null}function ze(e){return(0,l.jsx)(g.Button,{href:(0,U.LK)(e.subscription),variant:e.variant??"secondary",onClick:function(){(0,k.queueRecordEvent)("marketplace_renew_button_clicked",{product_zip_slug:e.subscription.zip_slug,product_id:e.subscription.product_id})},children:(0,_.__)("Renew","woocommerce")})}function Ue(e){return(0,l.jsx)(g.Button,{href:(0,U.SI)(e.subscription),variant:e.variant??"secondary",onClick:function(){(0,k.queueRecordEvent)("marketplace_auto_renew_button_clicked",{order_id:e.subscription.order_id,product_id:e.subscription.product_id})},children:(0,_.__)("Renew","woocommerce")})}function Oe(e){return(0,l.jsx)(g.Button,{href:(0,U.wX)(e.subscription),variant:e.variant??"secondary",onClick:function(){(0,k.queueRecordEvent)("marketplace_subscribe_button_clicked",{product_zip_slug:e.subscription.zip_slug,product_id:e.subscription.product_id})},children:(0,_.__)("Subscribe","woocommerce")})}function Pe(e){return(0,l.jsxs)(g.Modal,{title:(0,_.__)("Connect to update","woocommerce"),onRequestClose:e.onClose,focusOnMount:!0,className:"woocommerce-marketplace__header-account-modal",style:{borderRadius:4},overlayClassName:"woocommerce-marketplace__header-account-modal-overlay",children:[(0,l.jsx)("p",{className:"woocommerce-marketplace__header-account-modal-text",children:(0,_.sprintf)((0,_.__)("Version %s is available. To enable this update you need to connect your subscription to this store.","woocommerce"),e.subscription.version)}),(0,l.jsxs)(g.ButtonGroup,{className:"woocommerce-marketplace__header-account-modal-button-group",children:[(0,l.jsx)(g.Button,{variant:"tertiary",onClick:e.onClose,className:"woocommerce-marketplace__header-account-modal-button",children:(0,_.__)("Cancel","woocommerce")}),(0,l.jsx)(Ae,{subscription:e.subscription,onClose:e.onClose,variant:"primary"})]})]})}function Re(e){return(0,l.jsxs)(g.Modal,{title:(0,_.__)("Renew to update","woocommerce"),onRequestClose:e.onClose,focusOnMount:!0,className:"woocommerce-marketplace__header-account-modal",style:{borderRadius:4},overlayClassName:"woocommerce-marketplace__header-account-modal-overlay",children:[(0,l.jsx)("p",{className:"woocommerce-marketplace__header-account-modal-text",children:(0,_.sprintf)((0,_.__)("Version %s is available. To enable this update you need to renew your subscription.","woocommerce"),e.subscription.version)}),(0,l.jsxs)(g.ButtonGroup,{className:"woocommerce-marketplace__header-account-modal-button-group",children:[(0,l.jsx)(g.Button,{variant:"tertiary",onClick:e.onClose,className:"woocommerce-marketplace__header-account-modal-button",children:(0,_.__)("Cancel","woocommerce")}),(0,l.jsx)(ze,{subscription:e.subscription,variant:"primary"})]})]})}function Qe(e){return(0,l.jsxs)(g.Modal,{title:(0,_.__)("Subscribe to update","woocommerce"),onRequestClose:e.onClose,focusOnMount:!0,className:"woocommerce-marketplace__header-account-modal",style:{borderRadius:4},overlayClassName:"woocommerce-marketplace__header-account-modal-overlay",children:[(0,l.jsx)("p",{className:"woocommerce-marketplace__header-account-modal-text",children:(0,_.sprintf)((0,_.__)("Version %s is available. To enable this update you need to purchase a subscription.","woocommerce"),e.subscription.version)}),(0,l.jsxs)(g.ButtonGroup,{className:"woocommerce-marketplace__header-account-modal-button-group",children:[(0,l.jsx)(g.Button,{variant:"tertiary",onClick:e.onClose,className:"woocommerce-marketplace__header-account-modal-button",children:(0,_.__)("Cancel","woocommerce")}),(0,l.jsx)(Oe,{subscription:e.subscription,variant:"primary"})]})]})}function Be(e){const o=(0,s.Qk)("wccomHelper",{});return o?.wooUpdateManagerInstalled?o?.wooUpdateManagerActive?null:(0,l.jsxs)(g.Modal,{title:(0,_.__)("Access your updates","woocommerce"),onRequestClose:e.onClose,focusOnMount:!0,className:"woocommerce-marketplace__header-account-modal",style:{borderRadius:4},overlayClassName:"woocommerce-marketplace__header-account-modal-overlay",children:[(0,l.jsx)("p",{className:"woocommerce-marketplace__header-account-modal-text",children:(0,l.jsx)("span",{dangerouslySetInnerHTML:(0,Te.A)((0,_.sprintf)((0,_.__)("Version %s is available. To access this update, please <b>activate the WooCommerce.com Update Manager</b> extension.","woocommerce"),e.subscription.version))})}),(0,l.jsxs)(g.ButtonGroup,{className:"woocommerce-marketplace__header-account-modal-button-group",children:[(0,l.jsx)(g.Button,{onClick:e.onClose,variant:"link",children:(0,_.__)("Cancel","woocommerce")}),(0,l.jsx)(g.Button,{href:n.dL,variant:"primary",children:(0,_.__)("Activate","woocommerce")})]})]}):(0,l.jsxs)(g.Modal,{title:(0,_.__)("Access your updates","woocommerce"),onRequestClose:e.onClose,focusOnMount:!0,className:"woocommerce-marketplace__header-account-modal",style:{borderRadius:4},overlayClassName:"woocommerce-marketplace__header-account-modal-overlay",children:[(0,l.jsx)("p",{className:"woocommerce-marketplace__header-account-modal-text",children:(0,l.jsx)("span",{dangerouslySetInnerHTML:(0,Te.A)((0,_.sprintf)((0,_.__)("Version %s is available. To access this update, please first <b>install the WooCommerce.com Update Manager</b> extension. Alternatively, you can download and install it manually.","woocommerce"),e.subscription.version))})}),(0,l.jsxs)(g.ButtonGroup,{className:"woocommerce-marketplace__header-account-modal-button-group",children:[(0,l.jsx)(g.Button,{href:n.K_,variant:"secondary",children:(0,_.__)("Download","woocommerce")}),o?.wooUpdateManagerInstallUrl&&(0,l.jsx)(g.Button,{href:o?.wooUpdateManagerInstallUrl,variant:"primary",children:(0,_.__)("Install","woocommerce")})]})]})}function He(e){const[o,t]=(0,r.useState)(!1),[c,s]=(0,r.useState)(!1),{loadSubscriptions:n}=(0,r.useContext)(ge),a=e.subscription.active&&e.subscription.local&&e.subscription.local.slug&&e.subscription.local.path&&e.wooUpdateManagerActive;function i(o,t){const{message:r,actions:c}=(0,U.qM)(e.subscription.product_name,o,t);(0,U.Mp)(e.subscription.product_key,r,he.T.Error,{actions:c}),s(!1),(0,k.recordEvent)("marketplace_product_update_failed",{product_zip_slug:e.subscription.zip_slug,product_id:e.subscription.product_id,product_installed_version:e.subscription.local.version,product_current_version:e.subscription.version,error_code:(0,U.wf)(o).code||""})}return(0,l.jsxs)(l.Fragment,{children:[o?""===e.subscription.product_key?(0,l.jsx)(Qe,{onClose:()=>t(!1),subscription:e.subscription}):e.subscription.expired?(0,l.jsx)(Re,{subscription:e.subscription,onClose:()=>t(!1)}):e.subscription.active?e.wooUpdateManagerActive?null:(0,l.jsx)(Be,{subscription:e.subscription,onClose:()=>t(!1)}):(0,l.jsx)(Pe,{subscription:e.subscription,onClose:()=>t(!1)}):null,(0,l.jsx)(g.Button,{variant:"link",className:"woocommerce-marketplace__my-subscriptions-update",onClick:function o(){(0,k.recordEvent)("marketplace_product_update_button_clicked",{product_zip_slug:e.subscription.zip_slug,product_id:e.subscription.product_id,product_installed_version:e.subscription.local.version,product_current_version:e.subscription.version}),a?((0,U.fj)(e.subscription.product_key),!1!==e.subscription.update_requires_php_met?window.wp.updates?(s(!0),(0,U.vc)(e.subscription).then(()=>{n(!1).then(()=>{(0,U.Mp)(e.subscription.product_key,(0,_.sprintf)((0,_.__)("%s updated successfully.","woocommerce"),e.subscription.product_name),he.T.Success),s(!1)}),(0,k.recordEvent)("marketplace_product_updated",{product_zip_slug:e.subscription.zip_slug,product_id:e.subscription.product_id,product_installed_version:e.subscription.local.version,product_current_version:e.subscription.version})}).catch(e=>i(e,o))):(0,U.Mp)(e.subscription.product_key,(0,_.sprintf)((0,_.__)("%s couldn’t be updated.","woocommerce"),e.subscription.product_name),he.T.Error,{actions:[{label:(0,_.__)("Reload page and try again","woocommerce"),onClick:()=>{window.location.reload()}}]}):i({success:!1,data:{code:U.SD}},o)):t(!0)},isBusy:c,disabled:c,label:(0,_.sprintf)((0,_.__)("Update to %s","woocommerce"),e.subscription.version),showTooltip:!0,tooltipPosition:"top center",children:c?(0,_.__)("Updating","woocommerce"):(0,_.__)("Update","woocommerce")})]})}function We(e){const[o,t]=(0,r.useState)(!1),[c,s]=(0,r.useState)(!1),n=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{n.current&&clearTimeout(n.current)},[]);const a=()=>{e.explanationOnHover&&(n.current&&clearTimeout(n.current),t(!0))},i=()=>{e.explanationOnHover&&(n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{t(!1)},350))};return(0,l.jsxs)("button",{onClick:()=>s(!c),onMouseOver:a,onFocus:a,onMouseOut:i,onBlur:i,className:(0,b.A)("woocommerce-marketplace__my-subscriptions__product-status",`woocommerce-marketplace__my-subscriptions__product-status--${e.level}`),children:[e.icon,e.text,""!==e.explanation&&(c||e.explanationOnHover&&o)&&(0,l.jsx)(g.Popover,{className:"woocommerce-marketplace__my-subscriptions__popover",position:"top center",focusOnMount:!1,onMouseOver:a,onMouseOut:i,onFocus:a,onBlur:i,children:e.explanation})]})}(0,Ie.register)(Le);const Ye="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEyLjAwMDIgMi4yNVY0QzE2LjQxODUgNCAyMC4wMDAzIDcuNTgxNzIgMjAuMDAwMyAxMkMyMC4wMDAzIDE1LjcyNzcgMTcuNDUwNyAxOC44NTk5IDE0LjAwMDMgMTkuNzQ4VjE5Ljc0NzlDMTMuODMwMSAxOS43OTE3IDEzLjY1NzcgMTkuODMwMSAxMy40ODMzIDE5Ljg2MjhDMTMuMzM3MSAxOS44OTA1IDEzLjE5MDYgMTkuOTE0IDEzLjA0NDIgMTkuOTMzNEwxMy4wNDQxIDE5LjkzMjVDMTIuNzAyNCAxOS45NzcgMTIuMzUzOSAyMCAxMiAyMEMxMS42NDYgMjAgMTEuMjk3NSAxOS45NzcgMTAuOTU1NiAxOS45MzI0TDEwLjk1NTYgMTkuOTMyN0MxMC45MTQ4IDE5LjkyNzMgMTAuODc0IDE5LjkyMTYgMTAuODMzMyAxOS45MTU1QzkuNjEwMzYgMTkuNzM2OSA4LjQ3NzIyIDE5LjI4MTUgNy40OTk0OSAxOC42MTVDNy4zNzM2NSAxOC41Mjk1IDcuMjUwMTEgMTguNDQwNCA3LjEyOTA0IDE4LjM0NzdMNy4xMjk1NCAxOC4zNDdDNi41NzU0NiAxNy45MjEyIDYuMDc4NzIgMTcuNDI0NSA1LjY1MjkxIDE2Ljg3MDRMNS42NTE3MSAxNi44NzEzQzUuNDg1NTEgMTYuNjU0NSA1LjMyOTQxIDE2LjQyNzYgNS4xODQzOCAxNi4xOTExQzQuNjk0NTMgMTUuMzk2MiA0LjMzOTg1IDE0LjUwOTEgNC4xNTIzOSAxMy41NjE5QzQuMTE3ODggMTMuMzg5NSA0LjA4OTI1IDEzLjIxNjggNC4wNjY0MSAxMy4wNDQxTDQuMDY3NDkgMTMuMDQzOUM0LjAyMjk3IDEyLjcwMjIgNCAxMi4zNTM4IDQgMTJDNCAxMS42NDYgNC4wMjI5OSAxMS4yOTc0IDQuMDY3NTYgMTAuOTU1NUw0LjA2NzA4IDEwLjk1NTVDNC4wNzY5NCAxMC44ODExIDQuMDg3ODQgMTAuODA3IDQuMDk5NzYgMTAuNzMzQzQuMjgxIDkuNTk0IDQuNzAyNjYgOC41MzUwNyA1LjMxMTA5IDcuNjA5OTJDNS40MTg2NCA3LjQ0NTcyIDUuNTMyMzYgNy4yODUyNSA1LjY1MjEgNy4xMjg5MUw1LjY1Mjk0IDcuMTI5NTVDNS42NTUzNSA3LjEyNjQxIDUuNjU3NzcgNy4xMjMyNyA1LjY2MDE4IDcuMTIwMTRMNi44NjAzNyA4LjAyMDI4QzYuNzQwMTUgOC4xNzUzMSA2LjYyNjc5IDguMzM1OTMgNi41MjA3NCA4LjUwMTY4QzYuMDYwNDMgOS4yMjQzOSA1Ljc0NTQgMTAuMDMzMyA1LjU5NjM5IDEwLjg3ODVDNS41MzMwMyAxMS4yNDI4IDUuNSAxMS42MTc2IDUuNSAxMkM1LjUgMTIuNDc1MSA1LjU1MDk2IDEyLjkzODIgNS42NDc3MiAxMy4zODQzQzUuNzI4OTQgMTMuNzU0NCA1Ljg0Mzk3IDE0LjEyMzMgNS45OTQ3NSAxNC40ODczQzYuMTE3NTQgMTQuNzgzNyA2LjI1OTM4IDE1LjA2NTcgNi40MTgxMyAxNS4zMzI1QzYuOTE2NzIgMTYuMTY1OCA3LjU5NjYzIDE2Ljg3ODIgOC40MDMzNSAxNy40MTUxQzkuMTc2ODIgMTcuOTI3NSAxMC4wNTQgMTguMjcxIDEwLjk3MTQgMTguNDE5MUMxMS4zMDY0IDE4LjQ3MjMgMTEuNjUgMTguNSAxMiAxOC41QzEyLjQ1MDYgMTguNSAxMi44OTA0IDE4LjQ1NDIgMTMuMzE1MSAxOC4zNjY5QzEzLjUyNjMgMTguMzIzIDEzLjczNzIgMTguMjY4MSAxMy45NDcgMTguMjAxOUwxMy45NDc0IDE4LjIwMzJDMTYuNTg1OSAxNy4zNzU4IDE4LjUgMTQuOTExNCAxOC41IDEyQzE4LjUgOC40MTAyMyAxNS41OSA1LjUwMDEzIDEyLjAwMDIgNS41VjcuMjVMOS4wMDAyNCA0Ljc1TDEyLjAwMDIgMi4yNVoiIGZpbGw9IiMwMDdDQkEiLz4KPC9zdmc+";function Fe(e){const{subscription:o}=e,{loadSubscriptions:t}=(0,r.useContext)(ge),[c,n]=(0,r.useState)(!1),a=o.local;if(!a?.installed)return null;const i=a.auto_update?function(e){const o=[];if(""===e.product_key)return o.push((0,_.__)("There is no subscription for it.","woocommerce")),o;if(!e.local?.updates_from_wccom)return o;const t=(0,s.Qk)("wccomHelper",{});return t?.wooUpdateManagerActive||o.push((0,_.__)("WooCommerce.com Update Manager is not active, and it delivers these updates.","woocommerce")),e.expired&&!e.lifetime&&o.push((0,_.__)("The subscription has expired.","woocommerce")),e.active||o.push((0,_.__)("The subscription is not connected to this store.","woocommerce")),o}(o):[];return i.length>0?(0,l.jsx)(We,{icon:(0,l.jsx)(X.A,{icon:ne.A,size:16}),text:(0,_.__)("Blocked","woocommerce"),level:Ne.Error,explanation:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{children:(0,_.__)("Auto-updates are on, but it will not update because:","woocommerce")}),(0,l.jsx)("ul",{className:"woocommerce-marketplace__my-subscriptions__auto-update-blockers",children:i.map(e=>(0,l.jsx)("li",{children:e},e))})]}),explanationOnHover:!0}):a.auto_update_manageable?""!==o.product_key||a.auto_update?c?(0,l.jsxs)(g.Button,{variant:"link",disabled:!0,accessibleWhenDisabled:!0,children:[(0,l.jsx)("img",{src:Ye,alt:"",className:"woocommerce-marketplace__my-subscriptions__auto-updates-saving-icon"}),a.auto_update?(0,_.__)("Disabling…","woocommerce"):(0,_.__)("Enabling…","woocommerce")]}):(0,l.jsx)(g.Button,{variant:"link",onClick:()=>{return e=!a.auto_update,(0,k.recordEvent)(e?"marketplace_enable_auto_update_clicked":"marketplace_disable_auto_update_clicked",{product_id:o.product_id,product_zip_slug:o.zip_slug}),n(!0),(0,U.fj)(o.product_key),void(0,U.wP)(o,e).then(()=>{const r=e?(0,_.__)("Auto-updates enabled for %s.","woocommerce"):(0,_.__)("Auto-updates disabled for %s.","woocommerce");return(0,M.speak)((0,_.sprintf)(r,o.product_name)),t(!1).catch(()=>(0,U.Mp)(o.product_key,(0,_.__)("The setting was saved, but the list could not be refreshed. Reload the page to see the change.","woocommerce"),he.T.Error))}).catch(t=>{const r=e?(0,_.__)("Auto-updates could not be enabled.","woocommerce"):(0,_.__)("Auto-updates could not be disabled.","woocommerce"),c=t?.data?.message;(0,U.Mp)(o.product_key,c?`${r} ${c}`:r,he.T.Error)}).finally(()=>n(!1));var e},children:a.auto_update?(0,_.__)("Disable auto-updates","woocommerce"):(0,_.__)("Enable auto-updates","woocommerce")}):(0,l.jsx)(We,{text:(0,_.__)("Off","woocommerce"),level:Ne.Info,explanation:(0,_.__)("Subscribe to enable auto-updates for this product.","woocommerce"),explanationOnHover:!0}):(0,l.jsx)(We,{text:a.auto_update?(0,_.__)("On","woocommerce"):(0,_.__)("Off","woocommerce"),level:Ne.Info,explanation:(0,_.__)("Auto-updates for this product are controlled outside this screen.","woocommerce"),explanationOnHover:!0})}var $e=t(22201);function Ve(e){const o=[{title:(0,_.__)("Manage in Plugins","woocommerce"),onClick:()=>{window.location.href=s.kY+"plugins.php"}}];return e.subscription.is_shared||o.unshift({title:(0,_.__)("Manage on WooCommerce.com","woocommerce"),onClick:()=>{window.open("https://woocommerce.com/my-account/my-subscriptions","_blank")}}),e.subscription.documentation_url&&o.unshift({title:(0,_.__)("View documentation","woocommerce"),onClick:()=>{window.open(e.subscription.documentation_url,"_blank")}}),(0,l.jsx)(g.DropdownMenu,{icon:$e.A,label:(0,_.__)("Actions","woocommerce"),controls:o})}function qe(e){return(0,l.jsx)("span",{className:"woocommerce-marketplace__my-subscriptions-version",children:e.span})}function Ge(e,o){const t=(0,s.Qk)("wccomHelper",{});return e.local.version===e.version?(0,l.jsx)(qe,{span:e.local.version}):e.local.version&&e.version&&"installed"===o?(0,l.jsx)(He,{subscription:e,wooUpdateManagerActive:t?.wooUpdateManagerActive}):e.version?(0,l.jsx)(qe,{span:e.version}):e.local.version?(0,l.jsx)(qe,{span:e.local.version}):""}function Ze(e){return(0,U.A5)(e,[["utm_source","subscriptionsscreen"],["utm_medium","product"],["utm_campaign","wcaddons"],["utm_content","product-name"]])}function Ke(e){let o=(0,l.jsx)(X.A,{icon:ke.A,size:40});return e.product_icon&&(o=(0,l.jsx)("img",{src:e.product_icon,alt:(0,_.sprintf)((0,_.__)("%s icon","woocommerce"),e.product_name)})),{display:(0,l.jsxs)("div",{className:"woocommerce-marketplace__my-subscriptions__product",children:[(0,l.jsx)("a",{href:Ze(e.product_url),target:"_blank",rel:"noreferrer",children:(0,l.jsx)("span",{className:"woocommerce-marketplace__my-subscriptions__product-icon",children:o})}),(0,l.jsx)("a",{href:Ze(e.product_url),className:"woocommerce-marketplace__my-subscriptions__product-name",target:"_blank",rel:"noreferrer",children:e.product_name}),(0,l.jsx)("span",{className:"woocommerce-marketplace__my-subscriptions__product-statuses",children:e.is_shared&&(0,l.jsx)(We,{text:(0,_.__)("Shared with you","woocommerce"),level:Ne.Info,explanation:(0,r.createInterpolateElement)((0,_.sprintf)((0,_.__)("This subscription was shared by <email>%s</email>. <link>Learn more</link>.","woocommerce"),e.owner_email),{email:(0,l.jsx)("strong",{style:{overflowWrap:"anywhere"},children:"email"}),link:(0,l.jsx)("a",{href:n.$Y,rel:"nofollow noopener noreferrer",children:"Learn more"})})})})]}),value:e.product_name}}function Je(e){if(!0===e.local.installed&&""===e.product_key)return{display:"",value:""};if(e.is_agency||e.included_in_host_plan){const o=e.is_agency?(0,_.__)("Managed by agency","woocommerce"):(0,_.__)("Managed by host","woocommerce");return{display:(0,l.jsx)(We,{text:o,level:Ne.Info,explanation:""}),value:"host_plan"}}let o=(0,_.__)("Never expires","woocommerce");const t=e.expires;return t&&(o=(0,je.gmdateI18n)("j M, Y",new Date(1e3*t))),{display:(0,l.jsx)("span",{className:"woocommerce-marketplace__my-subscriptions__expiry-date",children:o}),value:t}}function Xe(e,o){return{display:function(){const t=function(e,o){return""===e.product_key?{text:(0,_.__)("No subscription","woocommerce"),level:Ne.Error,explanation:(0,r.createInterpolateElement)((0,_.__)("To receive updates and support, please <purchase>purchase</purchase> a subscription or use a subscription from another account by <sharing>sharing</sharing> or <transferring>transferring</transferring>.","woocommerce"),{purchase:(0,l.jsx)("a",{href:(0,U.wX)(e),rel:"nofollow noopener noreferrer",children:"renew"}),sharing:(0,l.jsx)("a",{href:n.$Y,rel:"nofollow noopener noreferrer",children:"sharing"}),transferring:(0,l.jsx)("a",{href:n.UD,rel:"nofollow noopener noreferrer",children:"sharing"})})}:e.expired?{text:(0,_.__)("Expired","woocommerce"),level:Ne.Error,explanation:(0,r.createInterpolateElement)((0,_.__)("To receive updates and support, please <renew>renew</renew> this subscription or use a subscription from another account by <sharing>sharing</sharing> or <transferring>transferring</transferring>.","woocommerce"),{renew:(0,l.jsx)("a",{href:(0,U.LK)(e),rel:"nofollow noopener noreferrer",children:"renew"}),sharing:(0,l.jsx)("a",{href:n.$Y,rel:"nofollow noopener noreferrer",children:"sharing"}),transferring:(0,l.jsx)("a",{href:n.UD,rel:"nofollow noopener noreferrer",children:"sharing"})})}:e.expiring&&!e.autorenew?{text:(0,_.__)("Expires soon","woocommerce"),level:Ne.Error,explanation:(0,r.createInterpolateElement)((0,_.__)("To receive updates and support, please <renew>renew</renew> this subscription before it expires or use a subscription from another account by <sharing>sharing</sharing> or <transferring>transferring</transferring>.","woocommerce"),{renew:(0,l.jsx)("a",{href:(0,U.SI)(e),rel:"nofollow noopener noreferrer",children:"renew"}),sharing:(0,l.jsx)("a",{href:n.$Y,rel:"nofollow noopener noreferrer",children:"sharing"}),transferring:(0,l.jsx)("a",{href:n.UD,rel:"nofollow noopener noreferrer",children:"sharing"})})}:"installed"===o&&e.local.installed&&!e.active?{text:(0,_.__)("Not connected","woocommerce"),level:Ne.Warning,explanation:(0,_.__)("To receive updates and support, please connect your subscription to this store.","woocommerce")}:!(e.autorenew||e.lifetime||e.expired)&&{text:(0,_.__)("Auto-renew: off","woocommerce"),level:Ne.Warning,explanation:(0,r.createInterpolateElement)((0,_.__)("This subscription will not renew automatically. <enable>Enable auto-renew</enable> to ensure uninterrupted updates and support.","woocommerce"),{enable:(0,l.jsx)("a",{href:(0,U.SI)(e),rel:"nofollow noopener noreferrer",children:"enable"})})}}(e,o);if(t)return(0,l.jsx)(We,{text:t.text,level:t.level,explanation:t.explanation??"",explanationOnHover:!0});let c;return c=e.lifetime?(0,_.__)("Lifetime","woocommerce"):e.autorenew?(0,_.__)("Active","woocommerce"):(0,_.__)("Cancelled","woocommerce"),c}()}}function eo(e,o){return{display:Ge(e,o)}}function oo(e,o){const t=[Ke(e),Je(e),Xe(e,o),eo(e,o)];var r;return"installed"===o&&t.push((r=e,{display:(0,l.jsx)("div",{className:"woocommerce-marketplace__my-subscriptions__auto-updates",children:(0,l.jsx)(Fe,{subscription:r})})})),t.push(function(e){let o=null;return""===e.product_key?o=(0,l.jsx)(Oe,{subscription:e}):e.expired&&!e.lifetime?o=(0,l.jsx)(ze,{subscription:e}):!1===e.local.installed&&!1===e.subscription_installed&&!0===e.has_changelog?o=(0,l.jsx)(De,{subscription:e}):!1===e.active&&!0===e.subscription_available&&!0===e.has_changelog?o=(0,l.jsx)(Ae,{subscription:e,variant:"link"}):e.autorenew||e.lifetime||(o=(0,l.jsx)(Ue,{subscription:e})),{display:(0,l.jsxs)("div",{className:"woocommerce-marketplace__my-subscriptions__actions",children:[o,(0,l.jsx)(Ve,{subscription:e})]})}}(e)),t}function to(){const{refreshSubscriptions:e}=(0,r.useContext)(ge),[o,t]=(0,r.useState)(!1);return(0,l.jsxs)(g.Button,{className:"woocommerce-marketplace__refresh-subscriptions",onClick:()=>{o||((0,U.fj)(he.W),t(!0),e().then(()=>{(0,U.Mp)(he.W,(0,_.__)("Subscriptions refreshed.","woocommerce"),he.T.Success)}).catch(e=>{(0,U.Mp)(he.W,(0,_.sprintf)((0,_.__)("Error refreshing subscriptions: %s","woocommerce"),(0,U.zu)(e)),he.T.Error)}).finally(()=>{t(!1)}))},isBusy:o,children:[(0,l.jsx)("img",{src:Ye,alt:(0,_.__)("Refresh subscriptions","woocommerce"),className:"woocommerce-marketplace__refresh-subscriptions-icon"}),(0,_.__)("Refresh","woocommerce")]})}const ro="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgaWQ9ImFsZXJ0Ij4KPHBhdGggaWQ9IlZlY3RvciIgZD0iTTEyIDIwQzE2LjQxODMgMjAgMjAgMTYuNDE4MyAyMCAxMkMyMCA3LjU4MTcyIDE2LjQxODMgNCAxMiA0QzcuNTgxNzIgNCA0IDcuNTgxNzIgNCAxMkM0IDE2LjQxODMgNy41ODE3MiAyMCAxMiAyMFoiIHN0cm9rZT0iI0NDMTgxOCIgc3Ryb2tlLXdpZHRoPSIxLjUiLz4KPHBhdGggaWQ9IlZlY3Rvcl8yIiBkPSJNMTMgN0gxMVYxM0gxM1Y3WiIgZmlsbD0iI0NDMTgxOCIvPgo8cGF0aCBpZD0iVmVjdG9yXzMiIGQ9Ik0xMyAxNUgxMVYxN0gxM1YxNVoiIGZpbGw9IiNDQzE4MTgiLz4KPC9nPgo8L3N2Zz4K";var co=t(2362);const so=({label:e,url:o,onClick:t})=>{const r={label:e,variant:"link",className:"is-link"};return o?{...r,url:o}:{...r,onClick:()=>t?.()}},no=e=>!!e.url&&!!e.openInNewTab;function ao(){const e=(0,Ie.useSelect)(e=>e(co.E).notices(),[]),o=[];for(const t of e){const e=t.options?.actions??[],r=e.filter(no);o.push((0,l.jsxs)(g.Notice,{className:"woocommerce-marketplace__notice--error",status:t.status,onRemove:()=>(0,U.fj)(t.productKey),actions:e.filter(e=>!no(e)).map(so),children:[(0,l.jsx)("img",{src:ro,alt:"",width:24,height:24}),t.message,r.length>0&&(0,l.jsx)("div",{className:"components-notice__actions",children:r.map(({label:e,url:o})=>(0,l.jsx)(g.ExternalLink,{href:o,className:"components-button components-notice__action is-link is-next-40px-default-size",children:e},e))})]},t.productKey))}return(0,l.jsx)(l.Fragment,{children:o})}function io(e){const o=new URL((0,U.E4)());return e.install&&o.searchParams.set("install",e.install),(0,l.jsx)(g.Button,{href:o.href,variant:e.variant??"secondary",children:(0,_.__)("Connect Account","woocommerce")})}function lo(){const e=(0,x.useQuery)(),o=e?.install,t=(0,s.Qk)("wccomHelper",{}),c=!!t?.isConnected,[a,i]=(0,r.useState)(!1),[m,u]=(0,r.useState)(!1),{subscriptions:d,isLoading:p}=(0,r.useContext)(ge),h=d.find(e=>e.product_key===o),w=(0,r.useCallback)(()=>{(0,x.navigateTo)({url:(0,x.getNewPath)({...e,install:void 0},n.q$,{})})},[e]);(0,r.useEffect)(()=>{p||(o&&c&&!p&&!h?((0,U.Mp)(o,(0,_.sprintf)((0,_.__)("Could not find subscription with product key %s.","woocommerce"),o),he.T.Error),w()):i(!!o))},[c,p,o,w,h]),(0,r.useEffect)(()=>{h&&h.local.installed&&u(!0)},[h]);const b=()=>{w(),i(!1)};return a?(0,l.jsxs)(g.Modal,{title:m?(0,_.__)("You are ready to go!","woocommerce"):(0,_.__)("Add to store","woocommerce"),onRequestClose:b,focusOnMount:!0,className:"woocommerce-marketplace__header-account-modal has-size-medium",style:{borderRadius:4},overlayClassName:"woocommerce-marketplace__header-account-modal-overlay",children:[(()=>{if(!c)return(0,l.jsx)(g.Notice,{status:"warning",isDismissible:!1,children:(0,_.__)("In order to install a product, you need to first connect your account.","woocommerce")});if(h){const e=m?(0,_.__)("Keep the momentum going and start setting up your extension.","woocommerce"):(0,_.__)("Would you like to install this extension?","woocommerce");return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"woocommerce-marketplace__header-account-modal-text",children:e}),(0,l.jsx)(W,{product:(0,U.w5)(h),small:!0,tracksData:{position:1,group:"subscriptions",label:"install"}})]})}})(),(()=>{const e=[];return m?(e.push((0,l.jsx)(g.Button,{variant:"secondary",href:h?.documentation_url,target:"_blank",className:"woocommerce-marketplace__header-account-modal-button",children:(0,_.__)("View docs","woocommerce")},"docs")),e.push((0,l.jsx)(g.Button,{variant:"primary",href:n.dL,className:"woocommerce-marketplace__header-account-modal-button",children:(0,_.__)("View in Plugins","woocommerce")},"plugin-list"))):(e.push((0,l.jsx)(g.Button,{variant:"tertiary",onClick:b,className:"woocommerce-marketplace__header-account-modal-button",children:(0,_.__)("Cancel","woocommerce")},"cancel")),c?h&&e.push((0,l.jsx)(De,{subscription:h,variant:"primary",onError:b},"install")):e.push((0,l.jsx)(io,{variant:"primary",install:o},"connect"))),(0,l.jsx)(g.ButtonGroup,{className:"woocommerce-marketplace__header-account-modal-button-group",children:e})})()]}):null}var mo=t(51963),uo=t(8533),po=t(5573),_o=(0,l.jsx)(po.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,l.jsx)(po.Path,{d:"M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z"})}),ho=t(95305);const wo="woo-connected-account-notice";let go=!1;function bo({onDismiss:e}){const o=(0,s.Qk)("wccomHelper",{}),t=o?.isConnected??!1,[c,a]=(0,r.useState)(go),[i,m]=(0,r.useState)(!1);if(!t||c||!1===o?.show_connected_account_notice)return null;const u=o?.userEmail;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("section",{className:"woocommerce-marketplace__my-subscriptions__account",children:[(0,l.jsx)(g.Button,{className:"woocommerce-marketplace__my-subscriptions__account-dismiss",icon:uo.A,label:(0,_.__)("Dismiss this notice","woocommerce"),onClick:()=>{go=!0,a(!0),_e()({path:"/wc-admin/notice/dismiss",method:"POST",data:{notice_id:wo,dismiss_notice_nonce:o?.dismissNoticeNonce||""}}),(0,M.speak)((0,_.__)("Connected account notice dismissed.","woocommerce"),"polite"),e?.()}}),(0,l.jsxs)("h2",{className:"woocommerce-marketplace__my-subscriptions__account-header",children:[(0,l.jsx)(X.A,{icon:_o,size:24}),(0,_.sprintf)((0,_.__)("Connected to %s","woocommerce"),u)]}),(0,l.jsx)("p",{className:"woocommerce-marketplace__my-subscriptions__account-content",children:(0,r.createInterpolateElement)((0,_.sprintf)((0,_.__)("Your store is currently connected to <strong>%s</strong> account on WooCommerce.com. If you think this is a mistake, you can <disconnect>disconnect your account</disconnect> and connect it to your current WooCommerce.com account. Doing this will not affect WooCommerce or any related extensions running on your site.","woocommerce"),u),{strong:(0,l.jsx)("strong",{}),disconnect:(0,l.jsx)(g.Button,{variant:"link",onClick:()=>m(!0)})})}),(0,l.jsx)("div",{className:"woocommerce-marketplace__my-subscriptions__account-actions",children:(0,l.jsx)(g.Button,{variant:"secondary",href:n.TQ,target:"_blank",children:(0,_.__)("View account","woocommerce")})})]}),i&&(0,l.jsx)(ho.A,{setIsModalOpen:m,disconnectURL:(0,U.E4)("wc-addons")})]})}let xo=!1;function yo(){const{subscriptions:e,isLoading:o}=(0,r.useContext)(ge),t=(0,s.Qk)("wccomHelper",{}),c=(0,r.useRef)(null);(0,r.useEffect)(()=>{!xo&&t?.api_error_notice&&(xo=!0,(0,U.Mp)(he.W,t.api_error_notice,he.T.Error))},[t?.api_error_notice]);const a=(0,r.createInterpolateElement)((0,_.__)("WooCommerce.com extensions and themes installed on this store. To see all your subscriptions go to <a>your account<custom_icon /></a> on WooCommerce.com.","woocommerce"),{a:(0,l.jsx)("a",{href:"https://woocommerce.com/my-account/my-subscriptions",target:"_blank",rel:"nofollow noopener noreferrer",children:"your account"}),custom_icon:(0,l.jsx)(X.A,{icon:de.A,size:12})}),i=e.filter(e=>e.subscription_installed),m=e.filter(e=>!e.subscription_installed&&t?.wooUpdateManagerPluginSlug!==e.product_slug&&!e.maxed);if(!t?.isConnected){const e=(0,_.__)("Create and connect your WooCommerce.com account to get product updates, manage your subscriptions from your store admin, and get streamlined support.","woocommerce"),o=()=>{const e={notice_id:"woo-disconnect-notice",dismiss_notice_nonce:t?.dismissNoticeNonce||""};_e()({path:"/wc-admin/notice/dismiss",method:"POST",data:e}),localStorage.setItem("wc-marketplaceNoticeClosed-woo-disconnect-notice","false")};return(0,l.jsxs)(l.Fragment,{children:[t?.disconnected_notice&&(0,l.jsx)(mo.A,{id:"woo-disconnect-notice",description:t?.disconnected_notice,isDismissible:!0,variant:"info",onClose:o}),(0,l.jsxs)("div",{className:"woocommerce-marketplace__my-subscriptions--connect",children:[(0,l.jsx)(lo,{}),(0,l.jsx)("div",{className:"woocommerce-marketplace__my-subscriptions__icon"}),(0,l.jsx)("h2",{className:"woocommerce-marketplace__my-subscriptions__header",children:(0,_.__)("Connect your WooCommerce.com account","woocommerce")}),(0,l.jsx)("p",{className:"woocommerce-marketplace__my-subscriptions__description",children:e}),(0,l.jsxs)("div",{className:"woocommerce-marketplace__my-subscriptions__connect-actions",children:[(0,l.jsx)(g.Button,{href:(0,U.E4)(),variant:"primary",children:(0,_.__)("Connect","woocommerce")}),(0,l.jsxs)(g.Button,{href:n.rL,target:"_blank",rel:"noopener noreferrer",variant:"secondary",icon:de.A,iconSize:16,iconPosition:"right",children:[(0,_.__)("Learn more","woocommerce"),(0,l.jsx)(g.VisuallyHidden,{as:"span",children:(0,_.__)("(opens in a new tab)","woocommerce")})]})]})]})]})}return(0,l.jsxs)(l.Fragment,{children:[t?.connected_notice&&(0,l.jsx)(mo.A,{id:"woo-connect-notice",description:t?.connected_notice,isDismissible:!0,variant:"success",onClose:()=>{const e={notice_id:"woo-connect-notice",dismiss_notice_nonce:t?.dismissNoticeNonce||""};_e()({path:"/wc-admin/notice/dismiss",method:"POST",data:e}),localStorage.setItem("wc-marketplaceNoticeClosed-woo-connect-notice","false")}}),!t?.has_host_plan_orders&&t?.connection_url_notice&&(0,l.jsx)(mo.A,{id:"woo-connection-url-notice",description:t?.connection_url_notice,isDismissible:!1,variant:"error",children:(0,l.jsx)(g.Button,{href:(0,U.E4)("wc-admin",!0),variant:"secondary",children:(0,_.__)("Reconnect","woocommerce")})}),t?.maybe_deleted_connection&&(0,l.jsx)(mo.A,{id:"woo-deleted-connection-notice",description:t?.maybe_deleted_connection,isDismissible:!1,variant:"error"}),(0,l.jsxs)("div",{className:"woocommerce-marketplace__my-subscriptions",children:[(0,l.jsx)(lo,{}),(0,l.jsx)("section",{className:"woocommerce-marketplace__my-subscriptions__notices",children:(0,l.jsx)(ao,{})}),(0,l.jsx)(bo,{onDismiss:()=>c.current?.focus()}),(0,l.jsxs)("section",{className:"woocommerce-marketplace__my-subscriptions-section woocommerce-marketplace__my-subscriptions__installed",children:[(0,l.jsxs)("header",{className:"woocommerce-marketplace__my-subscriptions__header",children:[(0,l.jsxs)("div",{className:"woocommerce-marketplace__my-subscriptions__header-content",children:[(0,l.jsx)("h2",{className:"woocommerce-marketplace__my-subscriptions__heading",ref:c,tabIndex:-1,children:(0,_.__)("Installed on this store","woocommerce")}),(0,l.jsx)("p",{className:"woocommerce-marketplace__my-subscriptions__table-description",children:a})]}),(0,l.jsx)("div",{className:"woocommerce-marketplace__my-subscriptions__header-refresh",children:(0,l.jsx)(to,{})})]}),(0,l.jsx)("div",{className:"woocommerce-marketplace__my-subscriptions__table-wrapper",children:(0,l.jsx)(ve,{isLoading:o,rows:i.map(e=>oo(e,"installed"))})})]}),m.length>0&&(0,l.jsxs)("section",{className:"woocommerce-marketplace__my-subscriptions-section woocommerce-marketplace__my-subscriptions__available",children:[(0,l.jsx)("h2",{className:"woocommerce-marketplace__my-subscriptions__heading",children:(0,_.__)("Available to use","woocommerce")}),(0,l.jsx)("p",{className:"woocommerce-marketplace__my-subscriptions__table-description",children:(0,_.__)("WooCommerce.com subscriptions you haven't used yet.","woocommerce")}),(0,l.jsx)("div",{className:"woocommerce-marketplace__my-subscriptions__table-wrapper",children:(0,l.jsx)(fe,{isLoading:o,rows:m.map(e=>oo(e,"available"))})})]})]})]})}var vo=function(e){return e[e.notConnected=0]="notConnected",e[e.notInstalled=1]="notInstalled",e[e.installing=2]="installing",e[e.installedCanActivate=3]="installedCanActivate",e[e.installedCannotActivate=4]="installedCannotActivate",e[e.installFailed=5]="installFailed",e[e.activating=6]="activating",e[e.activated=7]="activated",e[e.activationFailed=8]="activationFailed",e}(vo||{});const fo=function(e){const[o,t]=(0,r.useState)(vo.notInstalled),[c,a]=(0,r.useState)(),[i,m]=(0,r.useState)(),[u,p]=(0,r.useState)(),[h,w]=(0,r.useState)(),[b,y]=(0,r.useState)(),[v,f]=(0,r.useState)(!1),[j,N]=(0,r.useState)(),{addInstalledProduct:C}=(0,r.useContext)(d),M=(0,x.useQuery)();function T(){t(vo.notInstalled),N(void 0),(0,x.navigateTo)({url:(0,x.getNewPath)({...M,install:void 0,installProduct:void 0},n.q$,{})})}return(0,r.useEffect)(()=>{const e=(0,s.Qk)("wccomHelper",{});m(e?.installedProducts),p(e?.isConnected)},[]),(0,r.useEffect)(()=>{if(f(!1),!M.installProduct)return;const o=parseInt(M.installProduct,10),r=e.products.find(e=>e.id===o);if(r){if(i&&i.find(e=>e===r.slug))return;u?t(vo.notInstalled):(t(vo.notConnected),N({status:"warning",message:(0,_.__)("In order to install a product, you need to first connect your account.","woocommerce")})),f(!0),a(r)}},[M,e.products,i,u]),c&&v?(0,l.jsxs)(g.Modal,{title:o===vo.activated?(0,_.__)("You are ready to go!","woocommerce"):(0,_.__)("Add to Store","woocommerce"),onRequestClose:T,focusOnMount:!0,className:"woocommerce-marketplace__header-account-modal has-size-medium",style:{borderRadius:4},overlayClassName:"woocommerce-marketplace__header-account-modal-overlay",children:[j&&(0,l.jsx)(g.Notice,{status:j.status,isDismissible:!1,children:j.message}),(0,l.jsx)("p",{className:"woocommerce-marketplace__header-account-modal-text",children:o===vo.notConnected?"":o===vo.installedCanActivate||o===vo.activating?(0,_.__)("Extension successfully installed. Would you like to activate it?","woocommerce"):o===vo.installedCannotActivate?(0,_.__)("Extension successfully installed but we can't activate it at the moment. Please visit the plugins page to see more.","woocommerce"):o===vo.activated?(0,_.__)("Keep the momentum going and start setting up your extension.","woocommerce"):(0,_.__)("Would you like to install this extension?","woocommerce")}),c&&(0,l.jsx)(W,{product:c,small:!0,tracksData:{position:1,group:"install-flow",label:"install"}}),(0,l.jsxs)(g.ButtonGroup,{className:"woocommerce-marketplace__header-account-modal-button-group",children:[o===vo.activated?b?(0,l.jsx)(g.Button,{variant:"tertiary",href:b,className:"woocommerce-marketplace__header-account-modal-button",children:(0,_.__)("View Docs","woocommerce")},"docs"):(0,l.jsx)(l.Fragment,{}):(0,l.jsx)(g.Button,{variant:"tertiary",onClick:T,className:"woocommerce-marketplace__header-account-modal-button",children:(0,_.__)("Cancel","woocommerce")},"cancel"),o===vo.notConnected?(0,l.jsx)(io,{variant:"primary"},"connect"):o===vo.installedCanActivate||o===vo.activating?(0,l.jsx)(g.Button,{variant:"primary",onClick:function(){h&&(t(vo.activating),(0,k.recordEvent)("marketplace_activate_new_product_clicked",{product_id:c?c.id:0}),fetch(h).then(()=>{t(vo.activated)}).catch(()=>{t(vo.activationFailed),N({status:"error",message:(0,_.__)("Activation failed. Please try again from the plugins page.","woocommerce")})}))},isBusy:o===vo.activating,disabled:o===vo.activating,children:(0,_.__)("Activate","woocommerce")},"activate"):o===vo.activated||o===vo.installedCannotActivate||o===vo.activationFailed?(0,l.jsx)(g.Button,{variant:"primary",href:n.dL,className:"woocommerce-marketplace__header-account-modal-button",children:(0,_.__)("View in Plugins","woocommerce")},"plugin-list"):(0,l.jsx)(g.Button,{variant:"primary",onClick:function(){var e;c&&c.id&&((0,k.recordEvent)("marketplace_install_new_product_clicked",{product_id:c.id}),t(vo.installing),(e=c.id,_e()({path:"/wc/v3/marketplace/create-order",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({product_id:e})})).then(e=>{if(!e.success)throw e;return(0,Ie.dispatch)(Le).startInstalling(String(c.id??"")),y(e.data.documentation_url),c.slug&&C(c.slug??""),(0,U.UN)(e.data.product_type,e.data.zip_slug).then(e=>{(0,Ie.dispatch)(Le).stopInstalling(String(c.id??"")),e.data.activateUrl?(w(e.data.activateUrl),t(vo.installedCanActivate)):t(vo.installedCannotActivate)})}).catch(e=>{e.data.redirect_location?(N({status:"warning",message:(0,_.__)("We need your address to complete installing this product. We will redirect you to WooCommerce.com checkout. Afterwards, you will be able to install the product.","woocommerce")}),setTimeout(()=>{window.location.href=e.data.redirect_location},5e3)):(t(vo.installFailed),N({status:"error",message:e.data.message??(0,_.__)("An error occurred. Please try again later.","woocommerce")}))}))},isBusy:o===vo.installing,disabled:o===vo.installing||o===vo.installFailed,children:(0,_.__)("Install","woocommerce")},"install")]})]}):(0,l.jsx)(l.Fragment,{})};var jo=t(80643);function ko(){const e="woo-connect-notice-marketplace-dismissed",o=(0,s.Qk)("wccomHelper",{}),t=o?.woocomConnectNoticeType||"none",r=(0,_.__)("Your store","woocommerce"),c=o?.storeName||r,n=c!==r?`<strong>${c}</strong>`:c;if("none"===t||"long"===t)return null;const a=localStorage.getItem(e),i=new Date(a||""),m=new Date;m.setMonth(m.getMonth()-1),(null===a||isNaN(i.valueOf())||m.valueOf()>i.valueOf())&&(localStorage.removeItem("wc-marketplaceNoticeClosed-woo-connect-notice"),localStorage.removeItem(e));const u={short:(0,_.sprintf)((0,_.__)("%s is not yet connected to a WooCommerce.com account. Please complete the connection to get updates and streamlined support.","woocommerce"),n)}[t],d=(0,U.A5)((0,U.E4)(),[["utm_source","pu"],["utm_campaign","pu_in_apps_screen_connect"]]);return(0,l.jsxs)(mo.A,{id:"woo-connect-notice",description:u,isDismissible:!0,variant:"warning",className:"woocommerce-marketplace__connect-notice",onClose:()=>{localStorage.setItem(e,(new Date).toString()),(0,k.recordEvent)("woo_connect_notice_in_marketplace_dismissed")},onLoad:()=>{(0,k.recordEvent)("woo_connect_notice_in_marketplace_shown")},children:[(0,l.jsx)(g.Button,{href:d,variant:"primary",onClick:()=>((0,k.recordEvent)("woo_connect_notice_in_marketplace_clicked"),!0),children:(0,_.__)("Connect your store","woocommerce")}),(0,l.jsx)(g.Button,{href:"https://woocommerce.com/document/managing-woocommerce-com-subscriptions/#connect-your-site-woocommercecom-account",target:"_blank",variant:"tertiary",onClick:()=>((0,k.recordEvent)("woo_connect_notice_learn_more_clicked"),!0),children:(0,_.__)("Learn more","woocommerce")})]})}function No(e){const o=(0,s.Qk)("wccomHelper",{});if(!o?.isConnected)return null;const{selectedTab:t}=e;return"my-subscriptions"!==t&&o?.mySubscriptionsTabLoaded?null:o?.wooUpdateManagerActive||o?.wooUpdateManagerInstalled?o?.wooUpdateManagerInstalled&&!o?.wooUpdateManagerActive?(0,l.jsx)("section",{className:"woocommerce-marketplace__woo-update-manager-plugin__notices",children:(0,l.jsxs)(g.Notice,{status:"error",isDismissible:!1,children:[(0,l.jsx)("span",{dangerouslySetInnerHTML:(0,Te.A)((0,_.__)("Activate the <b>WooCommerce.com Update Manager</b> to continue receiving the updates and streamlined support included in your WooCommerce.com subscriptions.","woocommerce"))}),(0,l.jsx)("div",{className:"components-notice__buttons",children:(0,l.jsx)(g.Button,{href:n.dL,variant:"secondary",children:(0,_.__)("Activate","woocommerce")})})]})}):null:(0,l.jsx)("section",{className:"woocommerce-marketplace__woo-update-manager-plugin__notices",children:(0,l.jsxs)(g.Notice,{status:"error",isDismissible:!1,children:[(0,l.jsx)("span",{dangerouslySetInnerHTML:(0,Te.A)((0,_.__)("Please install the <b>WooCommerce.com Update Manager</b> to continue receiving the updates and streamlined support included in your WooCommerce.com subscriptions.<br/>Alternatively, you can download and install it manually.","woocommerce"))}),(0,l.jsxs)("div",{className:"components-notice__buttons",children:[o?.wooUpdateManagerInstallUrl&&(0,l.jsx)(g.Button,{href:o?.wooUpdateManagerInstallUrl,variant:"secondary",children:(0,_.__)("Install","woocommerce")}),(0,l.jsx)(g.Button,{href:n.K_,variant:"link",children:(0,_.__)("Download","woocommerce")})]})]})})}function Co(e){const{type:o}=e,t=(0,s.Qk)("wccomHelper",{}),r={"woo-subscription-expired-notice":{shown:"woo_subscription_expired_notice_in_marketplace_shown",clicked:"woo_subscription_expired_notice_in_marketplace_clicked",dismissed:"woo_subscription_expired_notice_in_marketplace_dismissed"},"woo-subscription-expiring-notice":{shown:"woo_subscription_expiring_notice_in_marketplace_shown",clicked:"woo_subscription_expiring_notice_in_marketplace_clicked",dismissed:"woo_subscription_expiring_notice_in_marketplace_dismissed"},"woo-subscription-missing-notice":{shown:"woo_subscription_missing_notice_in_marketplace_shown",clicked:"woo_subscription_missing_notice_in_marketplace_clicked",dismissed:"woo_subscription_missing_notice_in_marketplace_dismissed"}};let c=null,n="";const a=t?.dismissNoticeNonce||"";if("expired"===o)c=t?.subscription_expired_notice||{},n="woo-subscription-expired-notice";else if("expiring"===o)c=t?.subscription_expiring_notice||{},n="woo-subscription-expiring-notice";else{if("missing"!==o)return null;c=t?.subscription_missing_notice||{},n="woo-subscription-missing-notice"}return t.isConnected&&c?.description?(0,l.jsx)(mo.A,{id:n,description:c.description,isDismissible:!0,variant:"error",onClose:()=>{(0,k.recordEvent)(r[n].dismissed);const e={notice_id:n,dismiss_notice_nonce:a};_e()({path:"/wc-admin/notice/dismiss",method:"POST",data:e})},onLoad:function(){(0,k.recordEvent)(r[n].shown)},children:(0,l.jsx)(g.Button,{href:c.button_link,variant:"secondary",onClick:function(){(0,k.recordEvent)(r[n].clicked)},children:c.button_text})}):null}function Mo(e){const{onLoadMore:o,isBusy:t,disabled:r}=e;return t&&(0,M.speak)((0,_.__)("Loading more products","woocommerce")),(0,l.jsx)(g.Button,{className:"woocommerce-marketplace__load-more",variant:"secondary",onClick:function(){(0,k.queueRecordEvent)("marketplace_load_more_button_clicked",{}),o()},isBusy:t,disabled:r,children:(0,_.__)("Load more","woocommerce")})}function To(){const e=(0,r.useContext)(d),[o,t]=(0,r.useState)([]),[c,n]=(0,r.useState)([]),[a,i]=(0,r.useState)(1),[m,u]=(0,r.useState)(1),[p,h]=(0,r.useState)(1),[w,g]=(0,r.useState)(1),[b,y]=(0,r.useState)(1),[v,f]=(0,r.useState)(0),[j,N]=(0,r.useState)(!1),{isLoading:C,setIsLoading:A,selectedTab:I,setSearchResultsCount:S}=e,E=(0,x.useQuery)(),L=function(e,o){const t=o?.quality_badge;return"1"===e.quality_badge&&Boolean(t?.enabled&&t.label)}(E,e.iamSettings),D=e=>{(0,M.speak)((0,_.sprintf)((0,_.__)("%d products found","woocommerce"),e))},z=(0,r.useCallback)(()=>{N(!0);const e=new URLSearchParams,o=new AbortController;E.category&&"_all"!==E.category&&e.append("category",E.category),"themes"!==E.tab&&"business-services"!==E.tab||e.append("category",E.tab),E.term&&e.append("term",E.term),L&&"extensions"===E.tab&&e.append("quality_badge","1");const r=(0,s.Qk)("wccomHelper",!1);return r.storeCountry&&e.append("country",r.storeCountry),e.append("page",(a+1).toString()),(0,U.Hu)(e,o.signal).then(e=>{t(o=>{const t=Array.isArray(o[0])?o.flat():o,r=e.products.filter(e=>!t.some(o=>o.id===e.id));return r.length>0&&f(r[0].id??0),[...t,...r]}),(0,M.speak)((0,_.__)("More products loaded","woocommerce")),i(e=>e+1)}).catch(()=>{(0,M.speak)((0,_.__)("Error loading more products","woocommerce"))}).finally(()=>{N(!1)}),()=>{o.abort()}},[a,E.category,E.term,E.tab,L,N]);return(0,r.useEffect)(()=>{if(a>1)return;const e=[{category:"extensions",type:T.ch.extension},{category:"themes",type:T.ch.theme},{category:"business-services",type:T.ch.businessService}],o=e.map(()=>new AbortController);A(!0),t([]);const r=e=>{if(E.search){(0,k.recordEvent)("marketplace_search_finish",{tab:E.tab,total_products:e,category:E.category||"_all",search_term:E.term||""});const o=new URL(window.location.href);o.searchParams.delete("search"),window.history.replaceState(null,"",o.pathname+o.search)}};if(E.category&&"_all"!==E.category){const e=new URLSearchParams;e.append("category",E.category),E.term&&e.append("term",E.term),L&&"extensions"===E.tab&&e.append("quality_badge","1");const c=(0,s.Qk)("wccomHelper",!1);c.storeCountry&&e.append("country",c.storeCountry),(0,U.Hu)(e,o[0].signal).then(e=>{t(e.products),u(e.totalPages),S({[E.tab]:e.totalProducts}),D(e.totalProducts),r(e.totalProducts)}).catch(()=>{t([])}).finally(()=>{A(!1)})}else Promise.all(e.map(({category:e,type:t},r)=>{const c=new URLSearchParams;"extensions"!==e&&c.append("category",e),E.term&&c.append("term",E.term),"extensions"===e&&L&&c.append("quality_badge","1");const n=(0,s.Qk)("wccomHelper",!1);return n.storeCountry&&c.append("country",n.storeCountry),(0,U.Hu)(c,o[r].signal).then(e=>{const o=((e,o)=>e.map(e=>({...e,type:o})))(e.products,t);return{products:o,totalPages:e.totalPages,totalProducts:e.totalProducts,type:t}})})).then(e=>{const o=e.flatMap(e=>e.products);t(o);const c={extensions:e.find(e=>"extension"===e.type)?.totalProducts,themes:e.find(e=>"theme"===e.type)?.totalProducts,"business-services":e.find(e=>"business-service"===e.type)?.totalProducts};S(c),e.forEach(e=>{switch(e.type){case T.ch.extension:h(e.totalPages);break;case T.ch.theme:g(e.totalPages);break;case T.ch.businessService:y(e.totalPages)}});const s=E.tab;r(c[s]),D(e.reduce((e,o)=>e+o.totalProducts,0))}).catch(()=>{t([])}).finally(()=>{A(!1)});return()=>{o.forEach(e=>{e.abort()})}},[E.tab,E.term,E.category,L,A,S,a]),(0,r.useEffect)(()=>{let e;switch(I){case"extensions":e=o.filter(e=>e.type===T.ch.extension);break;case"themes":e=o.filter(e=>e.type===T.ch.theme);break;case"business-services":e=o.filter(e=>e.type===T.ch.businessService);break;default:e=[]}n(e)},[I,o]),(0,r.useEffect)(()=>{const e={view:E?.tab,search_term:E?.term,product_type:E?.section,category:E?.category,utm_source:E?.utm_source,utm_campaign:E?.utm_campaign};G(e),function(e){if(e.product_type)return;let o="extensions_view";const t=e.view||"_featured",r=e.search_term||null,c=e.category||null,s={...t&&{section:t},...r&&{search_term:r},version:"2",wccom_connected:q()};switch(t){case"extensions":s.section=c||"_all";break;case"themes":s.section="themes";break;case"my-subscriptions":o="subscriptions_view",s.section="helper"}(0,k.recordEvent)(o,s)}(e)},[E?.tab,E?.term,E?.section,E?.category,E?.utm_source,E?.utm_campaign]),(0,r.useEffect)(()=>{i(1),f(0)},[I,E?.category,E?.term,L]),(0,r.useEffect)(()=>{v&&setTimeout(()=>{const e=document.getElementById(`product-${v}`);e&&e.focus()},0)},[v]),(0,l.jsxs)("div",{className:"woocommerce-marketplace__content",children:[(0,l.jsx)(jo.A,{format:"promo-card"}),(0,l.jsx)(jo.A,{format:"notice"}),(0,l.jsx)(fo,{products:c}),"business-services"!==I&&"my-subscriptions"!==I&&(0,l.jsx)(ko,{}),"business-services"!==I&&(0,l.jsx)(No,{selectedTab:I}),"business-services"!==I&&(0,l.jsx)(Co,{type:"expired"}),"business-services"!==I&&(0,l.jsx)(Co,{type:"expiring"}),(()=>{switch(I){case"extensions":case"themes":case"business-services":return(0,l.jsx)(ue,{products:c,categorySelector:!0,type:(0,U.YW)(I),searchTerm:E.term});case"discover":return(0,l.jsx)(Z,{});case"my-subscriptions":return(0,l.jsx)(be,{children:(0,l.jsx)(yo,{})});default:return(0,l.jsx)(l.Fragment,{})}})(),!C&&(()=>{if(E.category&&"_all"!==E.category)return a<m;switch(I){case"extensions":return a<p;case"themes":return a<w;case"business-services":return a<b;default:return!1}})()&&(0,l.jsx)(Mo,{onLoadMore:z,isBusy:j,disabled:j})]})}var Ao=t(28938);function Io(){const{selectedTab:e}=(0,r.useContext)(d),o="woocommerce-marketplace"+(e?" woocommerce-marketplace--"+e:"");return(0,l.jsxs)("div",{className:o,children:[(0,l.jsx)(C,{}),(0,l.jsx)(To,{}),(0,l.jsx)(Ao.Ay,{})]})}function So(){return(0,l.jsx)(p,{children:(0,l.jsx)(Io,{})})}}}]);
Save File
Cancel