import{r as a,j as r}from"./router.chunk.YsRm4bSN.js";import{_ as __,s as sprintf}from"./wordpress.chunk.BVds2GcU.js";import{u as s,k as e}from"./forms.chunk.Bz8aaTWe.js";import{D as t}from"./date-picker-field.chunk.ipSHuuNj.js";import{f as o,D as n,cg as c,L as d,N as i,aC as m,aB as u,aD as g,i as p,c3 as f,C as h,K as l,T as j,b4 as w}from"./main.chunk.N-eZ2ybB.js";import{p as x,a as k}from"./index.chunk.CJx-PkC0.js";import{S as _}from"./empty-search.chunk.LcW09zII.js";import{S as y}from"./campaign.chunk.Bl3EV_wc.js";import{C as v}from"./campaign-card.chunk._yjiAIk3.js";import{P as N}from"./paginator.chunk.r-wRTa3n.js";import{C as D}from"./campaign-card-skeleton.chunk.DVSpHftA.js";import{u as b}from"./use-form-query-sync.chunk.DqmzEVyi.js";import{m as E}from"./match-paginated-query-status.chunk.78H-Yncx.js";import{f as P}from"./date-utils.chunk.DWRtWTmT.js";import{g as C}from"./icons.chunk.BwnSC3zE.js";import"./react-jsx-runtime.chunk.ATkk6v2S.js";import"./react.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"./dot-separator.chunk.CtyhSI2x.js";import"./progress.chunk.Bl335FuN.js";import"./goal-info.chunk.5sJIIQ8N.js";import"./use-currency.chunk.QE--bLc6.js";import"./select.chunk.BdL8rppi.js";const S=({onLoadData:e})=>{const{currentUser:t}=o(),f=s(),{syncQueryParams:h,params:l}=b({keyMap:{pg:k.withDefault(1),search:x,start_date:x,end_date:x},form:f,paramsToForm:a=>({search:a.search??"",date_range:{from:a.start_date?new Date(a.start_date):void 0,to:a.end_date?new Date(a.end_date):void 0}}),formToParams:a=>({search:a.search||void 0,start_date:a.date_range?.from?P(a.date_range.from,n.DATE):void 0,end_date:a.date_range?.to?P(a.date_range.to,n.DATE):void 0}),watchFields:["search","date_range"]}),j=c({backer_id:t.id,page:l.pg,search:l.search??void 0,start_date:l.start_date??void 0,end_date:l.end_date??void 0});return a.useEffect(()=>{e(j.data?.total??0)},[j.data?.total,e]),E(j,{Loading:r.jsx("div",{className:"growfund-space-y-4",children:Array.from({length:5}).map((a,s)=>r.jsx(D,{},s))}),Error:r.jsxs(m,{children:[r.jsx(u,{}),r.jsx(g,{children:__("Error loading campaigns","growfund")})]}),Empty:r.jsxs(d,{children:[r.jsx(y,{}),r.jsx(i,{children:__("No campaigns backed yet","growfund")})]}),EmptyResult:r.jsxs(d,{children:[r.jsx(_,{}),r.jsx(i,{children:__("No matching results found.","growfund")})]}),Success:({data:a},s)=>p(s)?s:r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"growfund-space-y-3",children:a.results.map(a=>r.jsx(v,{campaign:a,className:"growfund-border-none growfund-shadow-none",mode:"view"},a.id))}),r.jsx(N,{currentPage:a.current_page,totalItems:a.total,itemsPerPage:a.per_page,onPageChange:a=>{h({pg:a})}})]})})},T=()=>{const{setTopbar:s}=f(),[o,n]=a.useState(0),c=e();return a.useEffect(()=>{s({title:__("Backed Campaigns","growfund"),icon:C})},[s]),r.jsx(h,{className:"growfund-mt-10 growfund-space-y-3",size:"sm",children:r.jsxs(l,{...c,children:[r.jsxs("div",{className:"growfund-flex growfund-items-center growfund-justify-between",children:[r.jsxs("div",{className:"growfund-flex growfund-items-center growfund-gap-2 growfund-text-fg-primary",children:[r.jsx("h5",{className:"growfund-typo-h5 growfund-font-semibold",children:__("Backed Campaigns","growfund")}),r.jsx("h6",{className:"growfund-typo-h6 growfund-font-regular",children:sprintf("(%s)",o)})]}),r.jsxs("div",{className:"growfund-max-w-[25rem] growfund-flex growfund-items-center growfund-gap-2",children:[r.jsx(j,{control:c.control,name:"search",type:"search",placeholder:__("Search...","growfund")}),r.jsx(t,{control:c.control,name:"date_range",type:"range",placeholder:__("Select Date","growfund"),showRangePresets:!0,clearable:!0})]})]}),r.jsx(S,{onLoadData:n})]})})},B=()=>w.isBacker()?r.jsx(T,{}):r.jsx("div",{children:__("You are not allowed to access this page.","growfund")});export{B as default};
