1import{j as e}from"./vendor-query-REUEbryQ.js";import{r as s,L as a}from"./vendor-react-tIoPkRwd.js";import{M as r}from"./MainLayout-Ksz7zHhr.js";import{S as i}from"./SEO-BruwIufJ.js";import{g as t,L as o,B as l,aa as n,I as d,u as c}from"./index--0ud_HHy.js";import{T as m}from"./textarea-C1OSlJeR.js";import{L as u}from"./label-BLxROBsa.js";import{B as p}from"./badge-CSsjGdxs.js";import{C as x,b as j,c as h,d as f,a as y}from"./card-DatLY8HA.js";import{S as g,a as v,b as N,c as b,d as w}from"./select-C_YCD5Vd.js";import{e as C,f as P,g as k,M as S}from"./useAffiliateProgram-CMQ2si1g.js";import{C as A}from"./check-ekX4Q09Q.js";import{C as _}from"./copy-CX5EaF_O.js";import{U as M}from"./users-D9GQzA5c.js";import{T as L}from"./trending-up-DmfaNIpn.js";import{W as E}from"./wallet-DUFPhTIc.js";import"./AdUnit-CEQHIbmD.js";import"./vendor-ui-BVtOlGvj.js";import"./chevron-down-D56Is0vg.js";import"./UserMenu-G0fpOx5r.js";import"./dropdown-menu-BhjWH65A.js";import"./chevron-right-0eTVlG1M.js";import"./circle-DNRAjJQk.js";import"./sparkles-B8pZP29O.js";import"./star-MSjiZEel.js";import"./ThemeToggle-DvFkM08t.js";import"./book-open-aITWI1Zk.js";import"./music-CBz0HdiS.js";import"./download-yNQ0nzkl.js";import"./credit-card-CYKdopSW.js";import"./useVyreExpansions-78Z_uhHg.js";import"./memberCodes-D8CLuRSK.js";import"./useAdPlacements-C3kKsaFs.js";import"./useCourseCategories-CHRMRi9s.js";import"./toolVersions-n8IhcncZ.js";import"./monitor-CWBouFUT.js";import"./audio-lines-DULcR7cS.js";import"./piano-DpUfrck2.js";import"./volume-2-BGXhlmMK.js";import"./graduation-cap-ByWPWr0j.js";import"./message-square-BEMCGeba.js";import"./arrow-left-DdlyX7wK.js";import"./ChangelogDialog-BzgFCNA6.js";import"./scroll-area-BAEFWRJq.js";import"./message-square-text-BD9gOrla.js";import"./external-link-D4r3JqVx.js";import"./info-O2IQVtLI.js";import"./circle-alert-CObcGLbk.js";import"./use-mobile-B4hqzuWL.js";import"./vendor-supabase-BcbvpzCe.js";import"./chevron-up-BfJN0B7B.js";function B({icon:s,label:a,value:r}){return e.jsx(x,{children:e.jsxs(y,{className:"pt-6",children:[e.jsx(s,{className:"w-5 h-5 text-primary mb-2"}),e.jsx("p",{className:"text-2xl font-semibold text-foreground",children:r}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a})]})})}function D(){var D,T;const{isLoggedIn:W,userEmail:q,userName:F}=t(),{data:U,isLoading:V}=C(),I=P(),{data:R}=k("approved"===(null==U?void 0:U.status)?U.id:void 0),[Y,z]=s.useState(F||""),[H,O]=s.useState(q||""),[Q,$]=s.useState("paypal"),[G,J]=s.useState(""),[K,X]=s.useState(""),[Z,ee]=s.useState(!1),se=U?`https://music-prod.com/?aff=${U.code}`:"";return e.jsxs(r,{children:[e.jsx(i,{title:"Affiliate Program",description:"Earn 30% recurring commission for every Music-Prod+ subscriber you refer.",url:"/affiliates"}),e.jsxs("div",{className:"container mx-auto px-4 py-12 max-w-3xl",children:[e.jsxs("header",{className:"text-center mb-10",children:[e.jsx("h1",{className:"text-4xl md:text-5xl font-serif text-foreground mb-3",children:"Affiliate Program"}),e.jsx("p",{className:"text-muted-foreground max-w-xl mx-auto",children:"Earn 30% recurring commission on every Music-Prod+ subscription you refer, for as long as that member stays subscribed."})]}),V?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(o,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):"approved"===(null==U?void 0:U.status)?e.jsxs("div",{className:"space-y-6",children:[e.jsxs(x,{children:[e.jsxs(j,{children:[e.jsx(h,{children:"Your affiliate link"}),e.jsxs(f,{children:["Commission rate: ",Math.round(100*Number(U.commission_rate)),"% recurring. Attribution window: 60 days."]})]}),e.jsxs(y,{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1 bg-secondary rounded-full px-4 py-3 text-sm font-mono text-foreground break-all",children:se}),e.jsx(l,{variant:"outline",size:"icon",className:"rounded-full",onClick:()=>{navigator.clipboard.writeText(se),ee(!0),c.success("Referral link copied"),setTimeout(()=>ee(!1),2e3)},children:Z?e.jsx(A,{className:"w-4 h-4"}):e.jsx(_,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(B,{icon:S,label:"Clicks",value:String((null==R?void 0:R.clicks)??0)}),e.jsx(B,{icon:M,label:"Referred members",value:String((null==R?void 0:R.referrals.length)??0)}),e.jsx(B,{icon:L,label:"Pending",value:n((null==R?void 0:R.pendingCents)??0)}),e.jsx(B,{icon:E,label:"Ready to pay out",value:n((null==R?void 0:R.approvedCents)??0)})]}),e.jsxs(x,{children:[e.jsxs(j,{children:[e.jsx(h,{children:"Commission history"}),e.jsxs(f,{children:["Lifetime earned: ",n((null==R?void 0:R.lifetimeCents)??0)," · Paid out: ",n((null==R?void 0:R.paidCents)??0)]})]}),e.jsx(y,{children:0===((null==(D=null==R?void 0:R.commissions)?void 0:D.length)??0)?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No commissions yet. Share your link to get started."}):e.jsx("div",{className:"divide-y divide-border",children:R.commissions.map(s=>e.jsxs("div",{className:"flex items-center justify-between py-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm text-foreground",children:[n(s.commission_amount_cents,s.currency),e.jsxs("span",{className:"text-muted-foreground",children:[" ","of ",n(s.gross_amount_cents,s.currency),s.is_recurring?" (renewal)":" (first payment)"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(s.created_at).toLocaleDateString()})]}),e.jsx(p,{variant:"paid"===s.status?"default":"reversed"===s.status?"destructive":"secondary",children:s.status})]},s.id))})})]}),e.jsxs(x,{children:[e.jsxs(j,{children:[e.jsx(h,{children:"Payouts"}),e.jsxs(f,{children:["Commissions are approved after a 30 day refund window and paid manually via"," ",U.payout_method,"."]})]}),e.jsx(y,{children:0===((null==(T=null==R?void 0:R.payouts)?void 0:T.length)??0)?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No payouts yet."}):e.jsx("div",{className:"divide-y divide-border",children:R.payouts.map(s=>e.jsxs("div",{className:"flex items-center justify-between py-3 text-sm",children:[e.jsx("span",{className:"text-foreground",children:n(s.amount_cents,s.currency)}),e.jsxs("span",{className:"text-muted-foreground",children:[s.method," · ",new Date(s.paid_at).toLocaleDateString()]})]},s.id))})})]})]}):U?e.jsx(x,{children:e.jsxs(j,{children:[e.jsxs(h,{children:["Application ",U.status]}),e.jsx(f,{children:"pending"===U.status?"Your application is being reviewed. We will email you once it is approved.":U.rejection_reason||"Your affiliate account is not active."})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs(x,{children:[e.jsx(j,{children:e.jsx(h,{children:"How it works"})}),e.jsx(y,{children:e.jsxs("ol",{className:"space-y-3 text-sm text-muted-foreground",children:[e.jsx("li",{children:"1. Apply below and get your unique referral link."}),e.jsx("li",{children:"2. Share it with your audience. Clicks are attributed for 60 days."}),e.jsx("li",{children:"3. Earn 30% of every payment they make, monthly or yearly, for as long as they stay subscribed."}),e.jsx("li",{children:"4. Commissions are approved after 30 days and paid out manually to your chosen method."})]})})]}),e.jsxs(x,{children:[e.jsxs(j,{children:[e.jsx(h,{children:"Apply"}),e.jsx(f,{children:"Anyone can join. Approval usually takes a day or two."})]}),e.jsx(y,{className:"space-y-4",children:W?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"aff-name",children:"Name or brand"}),e.jsx(d,{id:"aff-name",value:Y,onChange:e=>z(e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"aff-email",children:"Contact email"}),e.jsx(d,{id:"aff-email",type:"email",value:H,onChange:e=>O(e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{children:"Payout method"}),e.jsxs(g,{value:Q,onValueChange:$,children:[e.jsx(v,{children:e.jsx(N,{})}),e.jsxs(b,{children:[e.jsx(w,{value:"paypal",children:"PayPal"}),e.jsx(w,{value:"bank",children:"Bank transfer"}),e.jsx(w,{value:"wise",children:"Wise"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"aff-details",children:"Payout details"}),e.jsx(d,{id:"aff-details",placeholder:"PayPal email, IBAN or Wise account",value:G,onChange:e=>J(e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"aff-plan",children:"How will you promote Music-Prod?"}),e.jsx(m,{id:"aff-plan",rows:3,value:K,onChange:e=>X(e.target.value)})]}),e.jsx(l,{className:"rounded-full w-full",onClick:async()=>
1{if(Y.trim()&&H.trim()&&G.trim())try{await I.mutateAsync({displayName:Y,contactEmail:H,payoutMethod:Q,payoutDetails:G,promotionPlan:K}),c.success("Application submitted. We will review it shortly.")}catch(e){c.error(e instanceof Error?e.message:"Could not submit your application")}else c.error("Please fill in your name, email and payout details.")},disabled:I.isPending,children:I.isPending?"Submitting...":"Submit application"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-center",children:["By applying you agree to our ",e.jsx(a,{to:"/legal",className:"underline",children:"terms"}),"."]})]}):e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Create a free affiliate account, or sign in if you already have one. No Music-Prod+ subscription needed."}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[e.jsx(l,{asChild:!0,className:"rounded-full",children:e.jsx(a,{to:"/login?mode=signup&redirect=/affiliates",children:"Create affiliate account"})}),e.jsx(l,{asChild:!0,variant:"outline",className:"rounded-full",children:e.jsx(a,{to:"/login?redirect=/affiliates",children:"Sign in"})})]})]})})]})]})]})]})}export{D 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.