1import{ay as $,a1 as q,M as S,b as f,r as y,s as c,_,j as e,w as d,z as u,d as C,f as k,g as F,q as m,a5 as I,aa as P,cK as K}from"./index-DsKq7xQs.js";import{P as L}from"./progress-VpQ0twoJ.js";import{D as Q}from"./DonationForm-BMt7oVxz.js";import{u as T,a as U}from"./useSEO-B0zdsDFo.js";import{b as E}from"./shareUrl-Dr4PVPAp.js";import{u as R}from"./useForceLightTheme-BHsKwRKF.js";import{u as z}from"./usePublicBrandTheme-B0QygUIa.js";import{F as D}from"./facebook-99EGyE3D.js";import"./textarea-C-F52huV.js";import"./switch-3B-N2UIm.js";import"./index-BfGmSBt-.js";function Z(){R();const{slug:i,participantId:t}=$(),[p]=q(),o=S(),{data:r}=f({queryKey:["public-fundraiser",i],queryFn:async()=>{const{data:a,error:n}=await c.from("fundraisers").select("*, studio:studios(name, logo_url, social_share_image_url)").eq("slug",i).in("status",["active","completed"]).single();if(n)throw n;return a},enabled:!!i});z(r?.studio_id);const{data:s}=f({queryKey:["public-participant",t],queryFn:async()=>{const{data:a,error:n}=await c.from("fundraiser_participants").select("*, student:students(id, first_name, last_name, photo_url)").eq("id",t).single();if(n)throw n;return a},enabled:!!t}),{data:g=[]}=f({queryKey:["public-participant-donations",t],queryFn:async()=>{const{data:a,error:n}=await c.rpc("get_public_fundraiser_donations",{p_participant_id:t});if(n)throw n;return a||[]},enabled:!!t});y.useEffect(()=>{const a=p.get("donation"),n=p.get("donation_id");a==="success"&&n&&(c.functions.invoke("verify-fundraiser-donation",{body:{donation_id:n}}).then(({error:w})=>{w||(_.success("Thank you for your generous donation!"),o.invalidateQueries({queryKey:["public-participant",t]}),o.invalidateQueries({queryKey:["public-participant-donations",t]}),o.invalidateQueries({queryKey:["public-fundraiser",i]}))}),window.history.replaceState({},"",`/f/${i}/dancer/${t}`))},[p,i,t,o]),y.useEffect(()=>{if(!t)return;const a=c.channel(`participant-${t}`).on("postgres_changes",{event:"*",schema:"public",table:"fundraiser_donations",filter:`participant_id=eq.${t}`},()=>{o.invalidateQueries({queryKey:["public-participant",t]}),o.invalidateQueries({queryKey:["public-participant-donations",t]})}).subscribe();return()=>{c.removeChannel(a)}},[t,o]);const h=s?.student?`${s.student.first_name} ${s.student.last_name}`:"this dancer";if(T(U({studio:r?.studio,pageTitle:r?`Support ${h} in the ${r.title}`:"Fundraiser",pageDescription:s?`${s.personal_message?s.personal_message.slice(0,140)+" ":`Help ${h} reach their fundraising goal! `}$${Number(s.amount_raised).toLocaleString()} raised so far.`:void 0,pageImage:s?.student?.photo_url||void 0})),!r||!s)return e.jsx("div",{className:"flex justify-center items-center min-h-screen",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const b=h,x=s.goal_amount||r.goal_amount,N=x>0?Math.min(s.amount_raised/x*100,100):0,v=window.location.href.split("?")[0],l=E(v),j=`Support ${b} in the ${r.title} fundraiser!`;return e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("div",{className:"max-w-2xl mx-auto px-4 py-8 space-y-6",children:[e.jsxs("a",{href:`/f/${i}`,className:"text-sm text-primary hover:underline",children:["â Back to ",r.title]}),e.jsx(d,{children:e.jsxs(u,{className:"pt-6 text-center space-y-4",children:[e.jsxs(C,{className:"h-24 w-24 mx-auto ring-4 ring-primary/20",children:[e.jsx(k,{src:s.student?.photo_url||""}),e.jsx(F,{className:"text-2xl",children:s.student?`${s.student.first_name[0]}${s.student.last_name[0]}`:"?"})]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:b}),e.jsx("p",{className:"text-muted-foreground text-sm",children:r.title})]}),e.jsxs("div",{className:"space-y-2 max-w-sm mx-auto",children:[e.jsxs("p",{className:"text-3xl font-bold text-primary",children:["$",Number(s.amount_raised).toLocaleString()]}),e.jsx(L,{value:N,className:"h-3"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["of $",Number(x).toLocaleString()," goal"]})]})]})}),s.personal_message&&e.jsx(d,{children:e.jsxs(u,{className:"pt-6",children:[e.jsx("h3",{className:"font-semibold mb-2",children:"My Story"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:s.personal_message})]})}),s.personal_photos&&s.personal_photos.length>0&&e.jsx("div",{className:"grid grid-cols-2 gap-2",children:s.personal_photos.map((a,n)=>e.jsx("img",{src:a,alt:"Personal photo",className:"rounded-lg w-full h-48 object-cover"},n))}),r.status==="active"&&e.jsx(Q,{fundraiserId:r.id,studioId:r?.studio_id,participantId:s.id,dancerName:s.student?.first_name,danceathon:r.type==="danceathon"?r.danceathon_settings:null}),e.jsx(d,{children:e.jsxs(u,{className:"pt-6",children:[e.jsx("h3",{className:"font-semibold mb-3",children:"Share this page"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx(m,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(l)}`,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(D,{className:"h-4 w-4 mr-1"})," Facebook"]})}),e.jsx(m,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:`mailto:?subject=${encodeURIComponent(j)}&body=${encodeURIComponent(l)}`,children:[e.jsx(I,{className:"h-4 w-4 mr-1"})," Email"]})}),e.jsx(m,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:`sms:?body=${encodeURIComponent(j+" "+l)}`,children:[e.jsx(P,{className:"h-4 w-4 mr-1"})," Text"]})}),e.jsxs(m,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(l),_.success("Link copied!")},children:[e.jsx(K,{className:"h-4 w-4 mr-1"})," Copy Link"]})]})]})}),g.length>0&&e.jsx(d,{children:e.jsxs(u,{className:"pt-6",children:[e.jsx("h3",{className:"font-semibold mb-3",children:"Recent Donations"}),e.jsx("div",{className:"space-y-3",children:g.slice(0,10).map(a=>e.jsxs("div",{className:"flex justify-between items-center border-b pb-2 last:border-0",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:a.is_anonymous?"Anonymous":a.donor_name}),a.message&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a.message})]}),e.jsxs("span",{className:"font-semibold text-primary",children:["$",Number(a.amount).toLocaleStr
1ing()]})]},a.id))})]})})]})})}export{Z as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.