import{j as s,r as e,a as r}from"./router.chunk.YsRm4bSN.js";import{s as sprintf,_ as __}from"./wordpress.chunk.BVds2GcU.js";import{U as a}from"./user-preview-card.chunk.Dtl6ZM0u.js";import{bO as n,bX as o,C as d,n as t,o as i,bY as c,L as g,aB as u,N as f,i as l,B as m}from"./main.chunk.N-eZ2ybB.js";import{u as w}from"./use-currency.chunk.QE--bLc6.js";import{f as p,ba as h,bb as x,aB as j}from"./icons.chunk.BwnSC3zE.js";import{I as y}from"./infinite-query-scroll.chunk.CCKtXM2O.js";import{S as N,e as v,a as _,b,c as k}from"./sheet.chunk.B4xhWhQI.js";import{M as E}from"./metrics-card.chunk.ao_0wOYX.js";import"./react-jsx-runtime.chunk.ATkk6v2S.js";import"./react.js";import"./dot-separator.chunk.CtyhSI2x.js";import"./date-utils.chunk.DWRtWTmT.js";import"./react-dom-client.chunk.BMQ1litG.js";import"./react-dom.js";import"./pdf-core.chunk.D33I_Wdh.js";import"./ui-radix.chunk.Xzokq_Gv.js";import"./utils.chunk.C1IATKsN.js";import"./forms.chunk.Bz8aaTWe.js";import"./pro-badge.chunk.PstHsVdU.js";import"./tooltip.chunk.DtTQ21GF.js";const C=({icon:e,created_at:r,message:a})=>s.jsxs("div",{className:"growfund-flex growfund-items-start growfund-gap-3",children:[e,s.jsxs("div",{className:"growfund-grid growfund-gap-2",children:[a,s.jsx("div",{className:"growfund-typo-tiny growfund-font-medium growfund-text-fg-muted",children:r})]})]}),L=new Map([[n.PLEDGE_CREATION,{icon:s.jsx(p,{className:"growfund-size-6 growfund-text-icon-primary"}),message:(e,r)=>s.jsx("div",{className:"growfund-typo-small growfund-text-fg-secondary",dangerouslySetInnerHTML:{__html:sprintf(
/* translators: 1: pledge amount, 2: campaign title */
__('Pledged <span class="growfund-font-semibold growfund-text-fg-primary">%1$s</span> to the campaign “%2$s”',"growfund"),r(e.data?.pledge_amount??0),e.campaign_title)}})}],[n.PLEDGE_CANCELLED,{icon:s.jsx(p,{className:"growfund-size-6 growfund-text-icon-primary"}),message:e=>s.jsxs("div",{className:"growfund-typo-small growfund-text-fg-secondary",children:[s.jsx("span",{className:"growfund-text-fg-critical",children:__("Cancelled","growfund")}),sprintf(__(" pledge to the campaign “%s” ","growfund"),e.campaign_title)]})}],[n.PLEDGE_BACKED,{icon:s.jsx(p,{className:"growfund-size-6 growfund-text-icon-primary"}),message:e=>s.jsxs("div",{className:"growfund-typo-small growfund-text-fg-secondary",children:[s.jsx("span",{className:"growfund-text-fg-emphasis",children:__("Successfully Backed","growfund")}),sprintf(__(" to the campaign “%s”. ","growfund"),e.campaign_title)]})}],[n.PLEDGE_FAILED_TO_BACK,{icon:s.jsx(p,{className:"growfund-size-6 growfund-text-icon-primary"}),message:e=>s.jsxs("div",{className:"growfund-typo-small growfund-text-fg-secondary",children:[s.jsx("span",{className:"growfund-text-fg-critical",children:__("Failed to back","growfund")}),sprintf(__(" the campaign “%s”","growfund"),e.campaign_title)]})}],[n.PLEDGE_REFUND_REQUESTED,{icon:s.jsx(p,{className:"growfund-size-6 growfund-text-icon-primary"}),message:e=>s.jsx("div",{className:"growfund-typo-small growfund-text-fg-secondary",children:sprintf(
/* translators: %s: campaign title */
__("Refund requested from the campaign “%s”.","growfund"),e.campaign_title)})}],[n.PLEDGE_REFUND_RECEIVED,{icon:s.jsx(p,{className:"growfund-size-6 growfund-text-icon-primary"}),message:e=>s.jsx("div",{className:"growfund-typo-small growfund-text-fg-secondary",children:sprintf(
/* translators: %s: campaign title */
__("Received refund from the campaign “%s”.","growfund"),e.campaign_title)})}],[n.CAMPAIGN_COMMENT,{icon:s.jsx(h,{className:"growfund-size-6 growfund-text-icon-primary"}),message:e=>s.jsx("div",{className:"growfund-typo-small growfund-text-fg-secondary",children:sprintf(__("Commented on the campaign “%s”. ","growfund"),e.campaign_title)})}]]),A=({activity:e})=>{const{toCurrency:r}=w();if(!L.has(e.type))return null;const a=L.get(e.type);return s.jsx(C,{icon:a?.icon,message:a?.message(e,r),created_at:e.created_at},e.id)},D=({backerId:a,children:n})=>{const[c,g]=e.useState(!1),u=e.useRef(null),f=o(a,c);return s.jsxs(N,{onOpenChange:g,children:[s.jsx(v,{asChild:!0,children:n}),s.jsxs(_,{side:"bottom",children:[s.jsx(b,{children:s.jsxs(k,{children:[s.jsx(x,{className:"growfund-size-6"}),__("Activity Log","growfund")]})}),s.jsx(d,{className:"growfund-mt-7 growfund-flex growfund-justify-center growfund-min-h-[80svh]",children:f.data?.pages.some(s=>s.results.length>0)&&s.jsx(t,{ref:u,className:"growfund-shadow-none growfund-w-[35rem] growfund-h-full growfund-max-h-[80svh] growfund-overflow-y-auto growfund-p-6 growfund-pb-0",children:s.jsxs(i,{className:"growfund-flex growfund-flex-col growfund-gap-4",children:[f.data.pages.map((e,a)=>{const n=e.results;return s.jsx(r.Fragment,{children:n.map(e=>s.jsx(A,{activity:e},e.id))},a)}),s.jsx(y,{rootRef:u,query:f,showNoMore:!0,noMoreText:__("That’s it—end of the list, unless you’re here for invisible items. ;)","growfund")})]})})})]})]})},z=()=>{const{backer:e}=c(),r=e.activity_logs;return 0===r.length?s.jsx(t,{className:"growfund-border-none growfund-group/activity-logs",children:s.jsxs(i,{className:"growfund-p-5 growfund-h-full",children:[s.jsx("h6",{className:"growfund-typo-h6 growfund-font-semibold growfund-text-fg-primary",children:__("Activity Logs","growfund")}),s.jsxs(g,{className:"growfund-shadow-none growfund-mt-0",children:[s.jsx(u,{}),s.jsx(f,{children:__("No activities created yet.","growfund")})]})]})}):s.jsx(t,{className:"growfund-border-none growfund-group/activity-logs",children:s.jsxs(i,{className:"growfund-p-5",children:[s.jsxs("div",{className:"growfund-flex growfund-items-center growfund-justify-between",children:[s.jsx("h6",{className:"growfund-typo-h6 growfund-font-semibold growfund-text-fg-primary",children:__("Activity Logs","growfund")}),l(e)&&s.jsx(D,{backerId:e.backer_information.id,children:s.jsxs(m,{variant:"ghost",size:"sm",className:"growfund-transition-opacity growfund-opacity-0 group-hover/activity-logs:growfund-opacity-100",children:[s.jsx(j,{}),__("See All Logs","growfund")]})})]}),s.jsx("div",{className:"growfund-space-y-4 growfund-mt-5",children:r.map(e=>s.jsx(A,{activity:e},e.id))})]})})},P=()=>{const{backer:e}=c(),{toCurrencyCompact:r}=w();return s.jsxs("div",{className:"growfund-space-y-4 growfund-mt-4",children:[s.jsx("div",{className:"growfund-grid growfund-gap-4",children:s.jsxs("div",{className:"growfund-flex growfund-items-center growfund-gap-4",children:[s.jsx(E,{data:{label:__("Pledged Amount","growfund"),amount:r(e.pledged_amount)}}),s.jsx(E,{data:{label:__("Backed Amount","growfund"),amount:r(e.backed_amount)}}),s.jsx(E,{data:{label:__("Pledged Campaigns","growfund"),amount:e.pledged_campaigns.toString()}}),s.jsx(E,{data:{label:__("Backed Campaigns","growfund"),amount:e.backed_campaigns.toString()}})]})}),s.jsxs("div",{className:"growfund-grid growfund-grid-cols-[20rem_auto] growfund-gap-4",children:[s.jsx(a,{user:e.backer_information,hideHeader:!0}),s.jsx(z,{})]})]})};export{P as default};
