← Back
Editing: addons-page.js
(()=>{"use strict";var a={576(a,t,e){var s=e(795);t.H=s.createRoot,s.hydrateRoot},795(a){a.exports=window.ReactDOM}},t={};function e(s){var n=t[s];if(void 0!==n)return n.exports;var o=t[s]={exports:{}};return a[s](o,o.exports,e),o.exports}e.n=a=>{var t=a&&a.__esModule?()=>a.default:()=>a;return e.d(t,{a:t}),t},e.d=(a,t)=>{for(var s in t)e.o(t,s)&&!e.o(a,s)&&Object.defineProperty(a,s,{enumerable:!0,get:t[s]})},e.o=(a,t)=>Object.prototype.hasOwnProperty.call(a,t);const s=window.React;var n=e(576);const o=window.wp.domReady;var r=e.n(o);const l=window.wp.components,p=window.popupMaker.layout,d=window.popupMaker.i18n,h=()=>{const a=window.popupMakerAddonsPage??{};return{restPath:a.restPath??"/popup-maker/v2/addons",canActivate:Boolean(a.canActivate),proUpgradeUrl:a.proUpgradeUrl??"https://wppopupmaker.com/pricing/",proPlusUpgradeUrl:a.proPlusUpgradeUrl??"https://wppopupmaker.com/pricing/",supportUrl:a.supportUrl??"https://wppopupmaker.com/support/",pluginsUrl:a.pluginsUrl??"",categories:a.categories??{},planLogoUrl:a.planLogoUrl??"",planState:a.planState??"default",planStatus:a.planStatus??"",planTitle:a.planTitle??"",planSubtitle:a.planSubtitle??"",upgradeLabel:a.upgradeLabel??"",upgradeUrl:a.upgradeUrl??"",upgradeExternal:Boolean(a.upgradeExternal)}},i=(a,t)=>t?"working":a.networkActivated?"network":a.activated?"active":a.installed?"installed":a.isUpsell?"locked":"unavailable",P=(a,t=!1)=>{switch(a){case"working":return(0,d.__)("Working…","popup-maker");case"network":return(0,d.__)("Network Active","popup-maker");case"active":return(0,d.__)("Active","popup-maker");case"locked":return t?(0,d.__)("Pro+ required","popup-maker"):(0,d.__)("Pro required","popup-maker");case"installed":return(0,d.__)("Inactive","popup-maker");default:return(0,d.__)("Unavailable","popup-maker")}},u=window.wp.apiFetch;var c=e.n(u);const S=a=>({slug:"",name:"",description:"",longDescription:"",category:"",image:"",isProPlus:!1,isUpsell:!1,pluginBasename:"",version:"",installed:!1,activated:!1,networkActivated:!1,...a,features:Array.isArray(a.features)?a.features.filter(a=>"string"==typeof a):[]}),G=(a,t)=>{if(!a||"object"!=typeof a)return{message:t,details:""};if("code"in a&&("invalid_json"===a.code||"fetch_error"===a.code))return{message:(0,d.__)("The add-on triggered a fatal error and the change was not applied.","popup-maker"),details:""};const e=a;return{message:"string"==typeof e.message?e.message:t,details:"string"==typeof e.details?e.details:""}},V=(a,t)=>"deactivate"===a?(0,d.sprintf)((0,d.__)("%s deactivated.","popup-maker"),t):(0,d.sprintf)((0,d.__)("%s activated.","popup-maker"),t),m=(a,t)=>"deactivate"===a?(0,d.sprintf)(/* translators: %s: add-on name. */ /* translators: %s: add-on name. */ (0,d.__)("%s couldn’t be deactivated","popup-maker"),t):(0,d.sprintf)(/* translators: %s: add-on name. */ /* translators: %s: add-on name. */ (0,d.__)("%s couldn’t be activated","popup-maker"),t),_=window.ReactJSXRuntime,g=a=>{const{notice:t,config:e,onDismiss:n}=a,o="success"===t.type;return(0,s.useEffect)(()=>{if(!o)return;const a=window.setTimeout(n,4e3);return()=>window.clearTimeout(a)},[o,n]),o?(0,_.jsx)("div",{className:"pum-addons__snackbar",children:(0,_.jsx)(l.Snackbar,{onRemove:n,children:t.message})}):(0,_.jsxs)(l.Modal,{title:t.title??(0,d.__)("The add-on action failed","popup-maker"),className:"pum-addons__modal pum-addons__error-modal",overlayClassName:"pum-addons__modal-overlay",onRequestClose:n,children:[(0,_.jsx)("div",{className:"pum-addons__modal-copy",dangerouslySetInnerHTML:{__html:t.message}}),t.details&&(0,_.jsx)("code",{className:"pum-addons__error-details",children:t.details}),(0,_.jsxs)("div",{className:"pum-addons__modal-footer pum-addons__error-modal-footer",children:[(0,_.jsx)(l.Button,{variant:"tertiary",href:e.pluginsUrl,children:(0,d.__)("Manage plugins","popup-maker")}),(0,_.jsx)(l.Button,{variant:"primary",className:"pum-addons__action",href:e.supportUrl,target:"_blank",rel:"noopener noreferrer",children:(0,d.__)("Get support","popup-maker")})]})]})},x=window.wp.element,k=((0,x.forwardRef)(({icon:a,size:t=24,...e},s)=>(0,x.cloneElement)(a,{width:t,height:t,...e,ref:s})),window.wp.primitives),j=(k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.Circle,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,(0,_.jsx)(k.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,_.jsx)(k.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})}));function f(a){var t,e,s="";if("string"==typeof a||"number"==typeof a)s+=a;else if("object"==typeof a)if(Array.isArray(a)){var n=a.length;for(t=0;t<n;t++)a[t]&&(e=f(a[t]))&&(s&&(s+=" "),s+=e)}else for(e in a)a[e]&&(s&&(s+=" "),s+=e);return s}k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.Path,k.Circle,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.G,k.Path,k.Path,k.SVG,k.G,k.Path,k.Path,k.SVG,k.G,k.Path,k.Path,k.SVG,k.G,k.Path,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.Path,k.SVG,k.Path,k.Path,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.Path,k.SVG,k.Path,k.Path,k.Path,k.SVG,k.Path,k.Path,k.SVG,k.Path,k.Path,k.SVG,k.Path,k.Path,k.SVG,k.Path,k.Path,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path,k.SVG,k.Path;const v=function(){for(var a,t,e=0,s="",n=arguments.length;e<n;e++)(a=arguments[e])&&(t=f(a))&&(s&&(s+=" "),s+=t);return s},w=({addon:a,busy:t,config:e,large:s,onAction:n})=>{const{action:o,disabled:r,label:p}=((a,t,e)=>t?{action:null,disabled:!0,label:(0,d.__)("Working…","popup-maker")}:a.networkActivated?{action:null,disabled:!0,label:(0,d.__)("Network Active","popup-maker")}:a.activated?{action:"deactivate",disabled:!e.canActivate,label:(0,d.__)("Deactivate","popup-maker")}:a.installed?{action:"activate",disabled:!e.canActivate,label:(0,d.__)("Activate","popup-maker")}:a.isUpsell?{action:"upgrade",disabled:!1,label:a.isProPlus?(0,d.__)("Get Pro+","popup-maker"):(0,d.__)("Get Pro","popup-maker")}:{action:null,disabled:!0,label:(0,d.__)("Unavailable","popup-maker")})(a,t,e);if(!o&&!r)return null;const h=v("pum-addons__action",{"pum-addons__action--lg":s,"pum-addons__action--upgrade":"upgrade"===o,"pum-addons__action--pro-plus":"upgrade"===o&&a.isProPlus});if("upgrade"===o)return(0,_.jsx)(l.Button,{variant:"primary",className:h,href:a.isProPlus?e.proPlusUpgradeUrl:e.proUpgradeUrl,target:"_blank",rel:"noopener noreferrer",children:p});const i="activate"===o;return(0,_.jsx)(l.Button,{variant:i?"primary":"secondary",className:h,disabled:r,isBusy:t,onClick:t=>{t.stopPropagation(),o&&n(a,o)},children:p})},b={"popup-maker-age-verification-modals":"shield","popup-maker-ajax-login-modals":"admin-users","popup-maker-aweber-integration":"email-alt","popup-maker-ecommerce-popups":"cart","popup-maker-geotargeting":"location-alt","popup-maker-leaving-notices":"external","popup-maker-lms-popups":"welcome-learn-more","popup-maker-mailchimp-integration":"email-alt","popup-maker-remote-content":"cloud","popup-maker-secure-idle-user-logout":"lock","popup-maker-terms-conditions-popups":"media-text","popup-maker-videos":"video-alt3"},y=({addon:a})=>{const[t,e]=(0,s.useState)(!1),n=(a=>{try{const t=new URL(a,window.location.origin);return"https:"===t.protocol||t.origin===window.location.origin?t.toString():""}catch(a){return""}})(a.image);return(0,_.jsx)("span",{className:"pum-addons__icon","aria-hidden":"true",children:n&&!t?(0,_.jsx)("img",{src:n,alt:"",onError:()=>e(!0)}):(0,_.jsx)("span",{className:`dashicons dashicons-${b[a.slug]??"admin-plugins"}`})})},N=({status:a,proPlus:t})=>(0,_.jsxs)("span",{className:v("pum-addons__status",`pum-addons__status--${a}`,{"pum-addons__status--pro-plus":t}),children:[(0,_.jsx)("span",{className:"pum-addons__status-dot"}),(0,_.jsx)("span",{children:P(a,Boolean(t))})]}),A=({addon:a,busy:t,config:e,onAction:s,onClose:n})=>{const o=i(a,t),r=a.isProPlus?(0,d.__)("Pro+","popup-maker"):(0,d.__)("Pro","popup-maker");return(0,_.jsxs)(l.Modal,{title:a.name||a.slug,className:"pum-addons__modal",overlayClassName:"pum-addons__modal-overlay",onRequestClose:n,children:[(0,_.jsxs)("div",{className:"pum-addons__modal-lede",children:[(0,_.jsx)(y,{addon:a}),(0,_.jsx)("p",{className:"pum-addons__modal-meta",children:r})]}),(0,_.jsx)("p",{className:"pum-addons__modal-copy",children:a.longDescription||a.description}),a.features.length>0&&(0,_.jsx)("ul",{className:"pum-addons__features",children:a.features.map(a=>(0,_.jsxs)("li",{children:[(0,_.jsx)(l.Icon,{icon:j,size:18}),(0,_.jsx)("span",{children:a})]},a))}),(0,_.jsxs)("div",{className:"pum-addons__modal-footer",children:[(0,_.jsx)(N,{status:o,proPlus:a.isProPlus}),(0,_.jsx)(w,{addon:a,busy:t,config:e,large:!0,onAction:s})]})]})},U=({addon:a,busy:t,config:e,onAction:s,onOpen:n})=>{const o=i(a,t);return(0,_.jsxs)("article",{className:v("pum-addons__card",`pum-addons__card--${o}`,{"pum-addons__card--pro-plus-tier":a.isProPlus}),children:[(0,_.jsxs)("button",{type:"button",className:"pum-addons__card-main","aria-label":(0,d.sprintf)(/* translators: %s: add-on name. */ /* translators: %s: add-on name. */ (0,d.__)("View details for %s","popup-maker"),a.name||a.slug),onClick:()=>n(a),children:[(0,_.jsxs)("span",{className:"pum-addons__card-heading",children:[(0,_.jsx)(y,{addon:a}),(0,_.jsxs)("span",{className:"pum-addons__title-wrap",children:[(0,_.jsx)("span",{className:"pum-addons__title",children:a.name||a.slug}),a.isUpsell&&(0,_.jsx)("span",{className:v("pum-addons__tier-badge",{"pum-addons__tier-badge--pro-plus":a.isProPlus}),children:a.isProPlus?(0,d.__)("Pro+","popup-maker"):(0,d.__)("Pro","popup-maker")})]})]}),(0,_.jsx)("span",{className:"pum-addons__description",children:a.description})]}),(0,_.jsxs)("div",{className:"pum-addons__card-footer",children:[(0,_.jsx)(N,{status:o,proPlus:a.isProPlus}),(0,_.jsx)(w,{addon:a,busy:t,config:e,onAction:s})]})]})},C=({addons:a,title:t,featured:e,busySlugs:s,config:n,onAction:o,onOpen:r})=>(0,_.jsxs)("section",{className:v("pum-addons__section",{"pum-addons__section--pro-plus":e}),children:[(0,_.jsxs)("div",{className:"pum-addons__section-heading",children:[(0,_.jsx)("h2",{children:t}),e&&(0,_.jsx)("span",{className:"pum-addons__pro-plus-badge",children:(0,d.__)("Available with Pro+","popup-maker")}),(0,_.jsx)("span",{className:"pum-addons__section-rule"})]}),(0,_.jsx)("div",{className:"pum-addons__grid",children:a.map(a=>(0,_.jsx)(U,{addon:a,busy:Boolean(s[a.slug]),config:n,onAction:o,onOpen:r},a.slug))})]}),M=({config:a})=>{if(!a.planTitle)return null;const t="warning"===a.planState;return(0,_.jsxs)("div",{className:"pum-addons__plan"+(t?" pum-addons__plan--warning":""),children:[(0,_.jsx)("span",{className:"pum-addons__plan-mark","aria-hidden":"true",children:a.planLogoUrl&&(0,_.jsx)("img",{src:a.planLogoUrl,alt:""})}),(0,_.jsxs)("div",{className:"pum-addons__plan-copy",children:[(0,_.jsxs)("span",{className:"pum-addons__plan-title-row",children:[(0,_.jsx)("span",{className:"pum-addons__plan-title",children:a.planTitle}),t&&a.planStatus&&(0,_.jsx)("span",{className:"pum-addons__plan-status",children:a.planStatus})]}),(0,_.jsx)("span",{className:"pum-addons__plan-sub",children:a.planSubtitle})]}),a.upgradeLabel&&a.upgradeUrl&&(0,_.jsx)(l.Button,{variant:"primary",className:"pum-addons__plan-action",href:a.upgradeUrl,...a.upgradeExternal?{target:"_blank",rel:"noopener noreferrer"}:{},children:a.upgradeLabel})]})},B=window.popupMaker.components,L=({counts:a,filter:t,query:e,onFilterChange:s,onQueryChange:n})=>{const o=[{name:"all",label:(0,d.__)("All","popup-maker")},{name:"active",label:(0,d.__)("Active","popup-maker")},{name:"installed",label:(0,d.__)("Installed","popup-maker")},{name:"locked",label:(0,d.__)("Premium","popup-maker")}].map(t=>({name:t.name,className:`pum-addons__tab pum-addons__tab--${t.name}`,title:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("span",{children:t.label}),(0,_.jsx)("span",{className:"pum-addons__tab-count",children:a[t.name]})]})}));return(0,_.jsxs)("div",{className:"pum-addons__toolbar",children:[(0,_.jsx)(B.ControlledTabPanel,{className:"pum-addons__tabs",tabs:o,selected:t,onSelect:a=>s(a)}),(0,_.jsx)(l.SearchControl,{className:"pum-addons__search",label:(0,d.__)("Search add-ons","popup-maker"),placeholder:(0,d.__)("Search add-ons","popup-maker"),value:e,onChange:n,__nextHasNoMarginBottom:!0})]})},T=()=>{const a=(0,s.useMemo)(h,[]),{addons:t,loading:e,loadError:n,busySlugs:o,notice:r,clearNotice:P,runAction:u}=(a=>{const[t,e]=(0,s.useState)([]),[n,o]=(0,s.useState)(!0),[r,l]=(0,s.useState)(null),[p,h]=(0,s.useState)({}),[i,P]=(0,s.useState)(null),u=(0,s.useCallback)(()=>c()({path:a.restPath}).then(a=>{e(Array.isArray(a)?a.map(S):[]),l(null)}).catch(a=>{e([]),l(((a,t)=>G(a,t).message)(a,(0,d.__)("The add-on catalog could not be loaded. Please retry shortly.","popup-maker")))}),[a.restPath]);(0,s.useEffect)(()=>{o(!0),u().then(()=>o(!1))},[u]);const _=(0,s.useCallback)((t,e)=>{if("upgrade"===e||p[t.slug])return;h(a=>({...a,[t.slug]:!0})),P(null);const s=t.name||t.slug;c()({path:`${a.restPath}/${e}`,method:"POST",data:{slug:t.slug}}).then(()=>(P({type:"success",message:V(e,s)}),u())).catch(a=>{const t=G(a,(0,d.__)("The add-on action failed.","popup-maker"));return P({type:"error",title:m(e,s),message:t.message,details:t.details,actionFailure:!0}),u()}).then(()=>{h(a=>{const e={...a};return delete e[t.slug],e})})},[p,a.restPath,u]);return{addons:t,loading:n,loadError:r,busySlugs:p,notice:i,clearNotice:(0,s.useCallback)(()=>P(null),[]),runAction:_}})(a),[x,k]=(0,s.useState)("all"),[j,f]=(0,s.useState)(""),[v,w]=(0,s.useState)(null),b=(0,s.useMemo)(()=>{const a={all:t.length,active:0,installed:0,locked:0};return t.forEach(t=>{const e=i(t,Boolean(o[t.slug]));"active"===e||"network"===e?(a.active++,a.installed++):"installed"===e?a.installed++:"locked"===e&&a.locked++}),a},[t,o]),y=(0,s.useMemo)(()=>t.filter(t=>((a,t,e)=>{const s=t.trim().toLowerCase();return!s||[a.name,a.description,e[a.category]??""].join(" ").toLowerCase().includes(s)})(t,j,a.categories)&&((a,t)=>{switch(t){case"active":return"active"===a||"network"===a;case"installed":return"active"===a||"network"===a||"installed"===a||"working"===a;case"locked":return"locked"===a;default:return!0}})(i(t,Boolean(o[t.slug])),x)),[t,o,a.categories,x,j]),N=y.filter(a=>a.isProPlus),U=y.filter(a=>!a.isProPlus),B=null!==v?t.find(a=>a.slug===v):void 0,T=(t,e,s=!1)=>(0,_.jsx)(C,{addons:t,title:e,featured:s,busySlugs:o,config:a,onAction:u,onOpen:a=>w(a.slug)},e);let E;E=e?(0,_.jsxs)("p",{className:"pum-addons__loading",children:[(0,_.jsx)(l.Spinner,{}),(0,d.__)("Loading add-ons…","popup-maker")]}):n?(0,_.jsx)(l.Notice,{status:"error",isDismissible:!1,children:n}):(0,_.jsx)(_.Fragment,{children:0===t.length?(0,_.jsx)("p",{className:"pum-addons__empty",children:(0,d.__)("No add-ons are currently available.","popup-maker")}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(L,{counts:b,filter:x,query:j,onFilterChange:k,onQueryChange:f}),0===y.length?(0,_.jsx)("p",{className:"pum-addons__empty",children:j?(0,d.sprintf)(/* translators: %s: search query. */ /* translators: %s: search query. */ (0,d.__)("No add-ons match “%s”.","popup-maker"),j):(0,d.__)("No add-ons match the selected filter.","popup-maker")}):(0,_.jsxs)(_.Fragment,{children:[N.length>0&&T(N,(0,d.__)("Pro+ Add-ons","popup-maker"),!0),U.length>0&&T(U,(0,d.__)("Add-ons","popup-maker"))]})]})});const R=(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(M,{config:a}),r&&(0,_.jsx)(g,{notice:r,config:a,onDismiss:P}),E]});return(0,_.jsxs)(p.AppLayout,{className:"pum-addons-app",children:[(0,_.jsx)(p.AppHeader,{navTabId:"extend"}),(0,_.jsx)(p.AppContent,{children:(0,_.jsxs)("div",{className:"pum-addons",children:[(0,_.jsxs)("header",{className:"pum-addons__page-heading",children:[(0,_.jsxs)("h1",{children:[(0,d.__)("Extend","popup-maker"),t.length>0&&(0,_.jsx)("span",{className:"pum-addons__count",children:(0,d.sprintf)(/* translators: %d: number of add-ons. */ /* translators: %d: number of add-ons. */ (0,d._n)("%d add-on","%d add-ons",t.length,"popup-maker"),t.length)})]}),(0,_.jsx)("p",{children:(0,d.__)("Explore Popup Maker add-ons and manage extensions installed on this site.","popup-maker")})]}),R]})}),B&&(0,_.jsx)(A,{addon:B,busy:Boolean(o[B.slug]),config:a,onAction:u,onClose:()=>w(null)}),(0,_.jsx)(l.Popover.Slot,{})]})};r()(()=>{const a=document.getElementById("popup-maker-addons");a&&(0,n.H)(a).render((0,_.jsx)(T,{}))}),(window.popupMaker=window.popupMaker||{}).addonsPage={}})();
Save File
Cancel