(()=>{"use strict";var e={51609:e=>{e.exports=window.React},86087:e=>{e.exports=window.wp.element}},a={};function n(o){var t=a[o];if(void 0!==t)return t.exports;var r=a[o]={exports:{}};return e[o](r,r.exports,n),r.exports}var o=n(51609),t=n(86087);const r=window.wp.coreData,i=window.wp.i18n;function c(){return window.GiveCampaignOptions}window.wp.apiFetch;const s=(e,a)=>{switch(e){case"amount":case"amountFromSubscriptions":const{currency:e}=c(),n=function(e){return new Intl.NumberFormat(navigator.language,{style:"currency",currency:e})}(e);return n.format(a);default:return a}},m=({showImage:e,showGoal:a,showDescription:n,campaign:t})=>{var r,m;const g=c();return(0,o.createElement)("div",{className:"give-campaigns-component-campaign",style:{"--givewp-primary-color":null!==(r=t.primaryColor)&&void 0!==r?r:"#0b72d9","--givewp-secondary-color":null!==(m=t.secondaryColor)&&void 0!==m?m:"#27ae60",...t.pagePermalink&&!g.isAdmin&&{cursor:"pointer"}},...t.pagePermalink&&!g.isAdmin&&{onClick:()=>window.location=t.pagePermalink}},e&&t.image&&(0,o.createElement)("div",{style:{backgroundImage:`url(${t.image})`},className:"give-campaigns-component-campaign-image"}),(0,o.createElement)("div",{className:"give-campaigns-component-campaign-title"},t.title),n&&(0,o.createElement)("div",{className:"give-campaigns-component-campaign-description"},t.shortDescription),a&&(0,o.createElement)("div",{className:"give-campaigns-component-campaign__goal"},(0,o.createElement)("div",{className:"give-campaigns-component-campaign__goal-progress"},(0,o.createElement)("div",{className:"give-campaigns-component-campaign__goal-progress-container"},(0,o.createElement)("div",{className:"give-campaigns-component-campaign__goal-progress-bar",style:{width:`${t.goalStats.percentage}%`}}))),(0,o.createElement)("div",{className:"give-campaigns-component-campaign__goal-container"},(0,o.createElement)("div",{className:"give-campaigns-component-campaign__goal-container-item"},(0,o.createElement)("span",null,(e=>{switch(e){case"amount":return(0,i.__)("Amount raised","give");case"donations":return(0,i.__)("Number of donations","give");case"donors":return(0,i.__)("Number of donors","give");case"amountFromSubscriptions":return(0,i.__)("Recurring amount raised","give");case"subscriptions":return(0,i.__)("Number of recurring donations","give");case"donorsFromSubscriptions":return(0,i.__)("Number of recurring donors","give")}})(t.goalType)),(0,o.createElement)("strong",null,s(t.goalType,t.goalStats.actual))),(0,o.createElement)("div",{className:"give-campaigns-component-campaign__goal-container-item"},(0,o.createElement)("span",null,(0,i.__)("Our goal","give")),(0,o.createElement)("strong",null,s(t.goalType,t.goal))))))},g=({attributes:e})=>{const{campaign:a,hasResolved:n}=function(e){const a=(0,r.useEntityRecord)("givewp","campaign",e);return{campaign:{...a?.record},hasResolved:a?.hasResolved,isResolving:a?.isResolving}}(e?.campaignId);return n?(0,o.createElement)(m,{campaign:a,showImage:e?.showImage,showDescription:e?.showDescription,showGoal:e?.showGoal}):null},l=document.querySelectorAll("[data-givewp-campaign-block]");l&&Array.from(l).map((e=>{const a=JSON.parse(e.dataset?.attributes);return(0,t.createRoot)(e).render((0,o.createElement)(g,{attributes:a}))}))})();