1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1298],{5610:(e,t,a)=>{"use strict";a.d(t,{j2:()=>c});var r=a(3915),s=a(5317),l=a(6203),n=a(858);let i=0===(0,r.Dk)().length?(0,r.Wp)({apiKey:"AIzaSyAPr_AOnHN6Lo1Ivyw19STkCip7fohksRM",authDomain:"mytrtapp.firebaseapp.com",projectId:"mytrtapp",storageBucket:"mytrtapp.firebasestorage.app",messagingSenderId:"440029471879",appId:"1:440029471879:web:ec53edcf2b8b343e578422"}):(0,r.Dk)()[0];(0,s.aU)(i);let c=(0,l.xI)(i);(0,n.c7)(i)},6068:(e,t,a)=>{"use strict";a.d(t,{A:()=>d,AuthProvider:()=>o});var r=a(5155),s=a(2115),l=a(6203),n=a(5610);let i=(0,s.createContext)({user:null,authReady:!1,signIn:async()=>{},signInApple:async()=>{},signOutUser:async()=>{}});async function c(e){try{return await (0,l.df)(n.j2,e)}catch(t){if((null==t?void 0:t.code)==="auth/popup-blocked"||(null==t?void 0:t.code)==="auth/operation-not-supported-in-this-environment")return(0,l.$2)(n.j2,e);throw t}}function o(e){let{children:t}=e,[a,o]=(0,s.useState)(null),[d,x]=(0,s.useState)(!1);async function m(){return c(new l.HF)}async function p(){let e=new l.LD("apple.com");return e.addScope("email"),e.addScope("name"),c(e)}async function u(){return(0,l.CI)(n.j2)}return(0,s.useEffect)(()=>{let e=(0,l.hg)(n.j2,e=>{o(e),x(!0)});return()=>e()},[]),(0,r.jsx)(i.Provider,{value:{user:a,authReady:d,signIn:m,signInApple:p,signOutUser:u},children:t})}function d(){return(0,s.useContext)(i)}},8356:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>M});var r=a(5155),s=a(2115),l=a(6874),n=a.n(l),i=a(6671),c=a(6068);function o(e){let{children:t}=e;return(0,r.jsx)("main",{className:"min-h-screen bg-black text-cream",children:(0,r.jsx)("section",{className:"mx-auto max-w-4xl px-6 py-14 md:py-16",children:t})})}function d(e){let{label:t,title:a,body:s,children:l}=e;return(0,r.jsxs)("div",{className:"border border-border bg-surface p-8 md:p-10",children:[(0,r.jsx)("div",{className:"font-display text-[10px] uppercase tracking-[0.25em] text-amber",children:t}),(0,r.jsx)("h1",{className:"mt-4 font-display text-3xl uppercase leading-[1.1] text-cream md:text-4xl",children:a}),(0,r.jsx)("p",{className:"mt-5 text-secondary leading-relaxed",children:s}),l]})}function x(e){if(!e)return"â";let t=new Date(e);return Number.isNaN(t.getTime())?"â":t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function m(e){if(!e)return"â";let t=new Date(e);return Number.isNaN(t.getTime())?"â":t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function p(e){let t=Number(e)||0;return"$".concat(t.toFixed(2))}let u=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function b(e){let{conversions:t}=e,a=function(e){let t=new Date,a=[],r=new Map;for(let e=5;e>=0;e--){let s=new Date(t.getFullYear(),t.getMonth()-e,1),l="".concat(s.getFullYear(),"-").concat(s.getMonth()),n={key:l,label:u[s.getMonth()],usd:0};a.push(n),r.set(l,n)}for(let t of Array.isArray(e)?e:[]){if(!t||!t.at)continue;let e=new Date(t.at);if(Number.isNaN(e.getTime()))continue;let a="".concat(e.getFullYear(),"-").concat(e.getMonth()),s=r.get(a);s&&(s.usd+=Number(t.bountyUsd)||0)}return a}(t),s=a.reduce((e,t)=>Math.max(e,t.usd),0);return 0>=a.reduce((e,t)=>e+t.usd,0)?(0,r.jsx)("div",{className:"mt-3 border border-border bg-elevated px-5 py-8 text-center",children:(0,r.jsx)("p",{className:"text-sm text-secondary leading-relaxed",children:"Earnings will chart here once conversions land."})}):(0,r.jsxs)("div",{className:"mt-3 border border-border bg-surface p-6",children:[(0,r.jsx)("div",{className:"flex items-end justify-between gap-2",style:{height:96},children:a.map(e=>{let t=e.usd>0?Math.max(2,Math.round(e.usd/s*96)):0;return(0,r.jsx)("div",{className:"flex flex-1 items-end justify-center self-stretch",title:"".concat(e.label,": ").concat(p(e.usd)),children:(0,r.jsx)("div",{className:"w-full max-w-[36px] ".concat(e.usd>0?"bg-amber":"bg-elevated"),style:{height:e.usd>0?t:2},"aria-hidden":"true"})},e.key)})}),(0,r.jsx)("div",{className:"mt-2 flex justify-between gap-2",children:a.map(e=>(0,r.jsx)("div",{className:"flex-1 text-center font-display text-[10px] uppercase tracking-wider text-muted",children:e.label},e.key))})]})}function h(e){let{className:t=""}=e;return(0,r.jsx)("div",{className:"animate-pulse bg-elevated ".concat(t)})}function f(){return(0,r.jsxs)("div",{"aria-busy":"true","aria-label":"Loading your dashboard",children:[(0,r.jsx)(h,{className:"h-3 w-24"}),(0,r.jsx)(h,{className:"mt-4 h-9 w-72"}),(0,r.jsx)(h,{className:"mt-4 h-4 w-96 max-w-full"}),(0,r.jsxs)("div",{className:"mt-10 border border-border bg-surface p-6 md:p-8",children:[(0,r.jsx)(h,{className:"h-3 w-24"}),(0,r.jsxs)("div",{className:"mt-4 flex items-center justify-between gap-4",children:[(0,r.jsx)(h,{className:"h-12 w-48"}),(0,r.jsx)(h,{className:"h-10 w-28"})]}),(0,r.jsx)("div",{className:"mt-8 grid gap-px border border-border bg-border sm:grid-cols-2 lg:grid-cols-4",children:[0,1,2,3].map(e=>(0,r.jsxs)("div",{className:"bg-elevated px-5 py-5",children:[(0,r.jsx)(h,{className:"h-3 w-16"}),(0,r.jsx)(h,{className:"mt-3 h-7 w-20"})]},e))}),(0,r.jsxs)("div",{className:"mt-8 border border-border bg-elevated p-5",children:[(0,r.jsx)(h,{className:"h-3 w-24"}),(0,r.jsx)(h,{className:"mt-4 h-4 w-64 max-w-full"}),(0,r.jsx)(h,{className:"mt-3 h-10 w-32"})]})]}),(0,r.jsx)("div",{className:"mt-8",children:(0,r.jsx)(h,{className:"h-24 w-full"})})]})}function y(e){let{text:t,label:a="Copy",className:l=""}
1=e,[n,c]=(0,s.useState)(!1);async function o(){try{await navigator.clipboard.writeText(t),c(!0),setTimeout(()=>c(!1),1800)}catch(e){i.oR.error("Couldn't copy to clipboard.")}}return(0,r.jsx)("button",{type:"button",onClick:o,className:"inline-flex h-10 items-center px-4 font-display text-xs font-semibold uppercase tracking-[0.15em] transition-colors ".concat(n?"bg-green text-black":"border border-border-strong bg-elevated text-cream hover:border-amber"," ").concat(l),children:n?"Copied â":a})}let g=[{value:"individual",label:"Individual"},{value:"sole_prop",label:"Sole proprietor"},{value:"llc",label:"LLC"},{value:"s_corp",label:"S corporation"},{value:"c_corp",label:"C corporation"},{value:"partnership",label:"Partnership"}];function j(e){var t;let{user:a,affiliate:l}=e,n=Number(l&&l.pendingUsd)||0,c=(null!=(t=null==l?void 0:l.payouts)?t:[])[0]||null,o=c?new Date(c.at).getTime():null,d=o&&Number.isFinite(o)?o+2592e6:null,x=null!==d&&Date.now()<d,m=n>=50&&!x,[u,b]=(0,s.useState)(!1),[h,f]=(0,s.useState)(""),[y,g]=(0,s.useState)(""),[j,N]=(0,s.useState)(!1);async function v(){if(!u&&!j&&m){f(""),g(""),b(!0);try{let e=await a.getIdToken(),t=await fetch("/api/affiliates/request-payout",{method:"POST",headers:{Authorization:"Bearer ".concat(e)}}),r=await t.json().catch(()=>({}));if(t.ok)N(!0),g("Requested ".concat(p(r.amountUsd)," â expect payment within 7 days.")),i.oR.success("Payout requested â ".concat(p(r.amountUsd),"."));else if(409===t.status)N(!0),f("Request already open.");else{let e=r.error||"Couldn't request payout. Please try again.";f(e),i.oR.error(e)}}catch(e){f("Network error. Please try again."),i.oR.error("Network error. Please try again.")}finally{b(!1)}}}let w=u||j||!m;return(0,r.jsxs)("div",{className:"mt-3 border-b border-border pb-6",children:[(0,r.jsx)("p",{className:"font-display text-[10px] uppercase tracking-wider text-muted",children:"Pending balance"}),(0,r.jsxs)("div",{className:"mt-1 flex flex-wrap items-center justify-between gap-4",children:[(0,r.jsx)("p",{className:"font-display text-2xl text-cream",children:p(n)}),(0,r.jsx)("button",{type:"button",onClick:v,disabled:w,className:"inline-flex h-10 items-center px-4 font-display text-xs font-semibold uppercase tracking-[0.15em] transition-colors ".concat(w?"cursor-not-allowed border border-border-strong bg-elevated text-muted":"bg-amber text-black hover:bg-cream"),children:j?"Request open":u?"Requestingâ¦":"Request payout"})]}),!m&&!j&&(0,r.jsx)("p",{className:"mt-2 font-display text-[10px] uppercase tracking-wider text-muted",children:x?"Payouts are limited to once every 30 days â next request available ".concat(new Date(d).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})):"Minimum $50 â you're at ".concat(p(n))}),y&&(0,r.jsx)("p",{className:"mt-2 font-display text-xs uppercase tracking-wider text-green",children:y}),h&&(0,r.jsx)("p",{className:"mt-2 font-display text-xs uppercase tracking-wider text-red",children:h})]})}function N(e){var t,a,l,n,c;let{user:o}=e,[d,x]=(0,s.useState)(null),[m,p]=(0,s.useState)(!1),[u,b]=(0,s.useState)(!1),[h,f]=(0,s.useState)(!1),[y,j]=(0,s.useState)(""),[N,v]=(0,s.useState)(""),[w,k]=(0,s.useState)(""),[S,C]=(0,s.useState)("individual"),[A,P]=(0,s.useState)(""),[T,R]=(0,s.use
1State)(!1),[D,I]=(0,s.useState)(!1),[E,U]=(0,s.useState)(""),[O,L]=(0,s.useState)(""),[B,M]=(0,s.useState)(""),[z,F]=(0,s.useState)(""),[W,Y]=(0,s.useState)("");function _(){if(d){v(d.legalName||""),k(d.businessName||""),C(d.taxClassification||"individual");let e=d.address||{};U(e.line1||""),L(e.line2||""),M(e.city||""),F(e.state||""),Y(e.zip||"")}P(""),R(!1),j(""),b(!0)}async function H(){if(!D){I(!0);try{let e=await o.getIdToken(),t=await fetch("/api/affiliates/tax/w9",{headers:{Authorization:"Bearer ".concat(e)}});if(!t.ok){let e=await t.json().catch(()=>({}));i.oR.error(e.error||"Couldn't generate your W-9.");return}let a=await t.blob(),r=URL.createObjectURL(a),s=document.createElement("a");s.href=r,s.download="mytrt-w9-".concat((null==d?void 0:d.tinLast4)||"0000",".pdf"),document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(r)}catch(e){i.oR.error("Network error. Please try again.")}finally{I(!1)}}}async function q(e){if(e.preventDefault(),!h){j(""),f(!0);try{let e=await o.getIdToken(),t=await fetch("/api/affiliates/tax",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify({legalName:N.trim(),businessName:w.trim()||void 0,taxClassification:S,tin:A.trim(),address:{line1:E.trim(),line2:O.trim()||void 0,city:B.trim(),state:z.trim(),zip:W.trim()}})}),a=await t.json().catch(()=>({}));if(t.ok)x(a.taxInfo||null),b(!1),i.oR.success("Tax details saved.");else{let e=a.error||"Couldn't save. Please try again.";j(e),i.oR.error(e)}}catch(e){j("Network error. Please try again."),i.oR.error("Network error. Please try again.")}finally{f(!1)}}}(0,s.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await o.getIdToken(),a=await fetch("/api/affiliates/tax",{headers:{Authorization:"Bearer ".concat(t)}});if(e)return;if(a.ok){let e=await a.json().catch(()=>({}));x(e.taxInfo||null)}else x(null)}catch(t){e||x(null)}finally{e||p(!0)}})(),()=>{e=!0}},[o]);let G="h-12 w-full bg-elevated border border-border-strong px-4 font-display text-sm text-cream placeholder:text-muted focus:border-amber focus:outline-none";return(0,r.jsxs)("div",{id:"tax-info",className:"mt-6 scroll-mt-6",children:[(0,r.jsx)("p",{className:"font-display text-[10px] uppercase tracking-[0.2em] text-amber",children:"/TAX_INFO"}),m?u?(0,r.jsxs)("form",{onSubmit:q,className:"mt-3 flex flex-col gap-3",children:[(0,r.jsx)("p",{className:"text-sm text-secondary leading-relaxed",children:"We use these details to auto-generate your IRS W-9 â no manual form filling. Your SSN/EIN is never displayed on this site; it stays masked and only appears inside the W-9 PDF you download."}),(0,r.jsx)("input",{type:"text",value:N,onChange:e=>v(e.target.value),placeholder:"Legal name","aria-label":"Legal name",className:G}),(0,r.jsx)("input",{type:"text",value:w,onChange:e=>k(e.target.value),placeholder:"Business name (optional)","aria-label":"Business name",className:G}),(0,r.jsx)("select",{value:S,onChange:e=>C(e.target.value),"aria-label":"Tax classification",className:G,children:g.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("input",{type:T?"text":"password",inputMode:"numeric",value:A,onChange:e=>P(e.target.value),placeholder:d?"â¢â¢â¢â¢â¢".concat(d.tinLast4||""," â enter again to change"):"Taxpayer ID (SSN or EIN)","aria-label":"Taxpayer ID",autoComplete:"off",className:"".concat(G," pr-16")}),(0,r.jsx)("button",{type:"button",onClick:()=>R(e=>!e),"aria-label":T?"Hide taxpayer ID":"Show taxpayer ID",className:"absolute right-0 top-0 flex h-12 items-center px-4 font-display text-[10px] uppercase tracking-wider text-muted hover:text-cream transition-colors",children:T?"Hide":"Show"})]}),(0,r.jsx)("p",{className:"mt-1 font-display text-[10px] tracking-wider text-muted",children:"\uD83D\uDD12 Masked on entry, stored server-side, used only to fill your W-9."})]}),(0,r.jsx)("input",{type:"text",value:E,onChange:e=>U(e.target.value),placeholder:"Address line 1","aria-label":"Address line 1",className:G}),(0,r.jsx)("input",{type:"text",value:O,onChange:e=>L(e.target.value),placeholder:"Address line 2 (optional)","aria-label":"Address line 2",className:G}),(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row",children:[(0,r.jsx)("input",{type:"text",value:B,onChange:e=>M(e.target.value),placeholder:"City","aria-label":"City",className:G}),(0,r.jsx)("input",{type:"text",value:z,onChange:e=>F(e.target.value),placeholder:"State","aria-label":"State",className:G}),(0,r.jsx)("input",{type:"text",value:W,onChange:e=>Y(e.target.value),placeholder:"ZIP","aria-label":"ZIP",className:G})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{type:"submit",disabled:h,className:"inline-flex h-12 items-center bg-amber px-5 font-display text-xs font-semibold uppercase tracking-[0.15em] text-black hover:bg-cream transition-colors disabled:opacity-50",children:h?"Savingâ¦":"Save tax info"}),(0,r.jsx)("button",{type:"button",onClick:()=>{b(!1),j("")},className:"inline-flex h-12 items-center border border-border-strong bg-transparent px-5 font-display text-xs font-semibold uppercase tracking-[0.15em] text-cream hover:bg-elevated transition-colors",children:"Cancel"})]}),y&&(0,r.jsx)("p",{className:"font-display text-xs uppercase tracking-wider text-red",children:y})]}):d?(0,r.jsxs)("div",{className:"mt-3 border border-border bg-elevated p-4",children:[(0,r.jsxs)("dl",{className:"grid grid-cols-1 gap-y-2 sm:grid-cols-2 sm:gap-x-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("dt",{className:"font-display text-[10px] uppercase tracking-wider text-muted",children:"Legal name"}),(0,r.jsx)("dd",{className:"mt-0.5 font-display text-sm text-cream break-all",children:d.legalName||"â"})]}),d.businessName&&(0,r.jsxs)("div",{children:[(0,r.jsx)("dt",{className:"font-display text-[10px] uppercase tracking-wider text-muted",children:"Business name"}),(0,r.jsx)("dd",{className:"mt-0.5 font-display text-sm text-cream break-all",children:d.businessName})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("dt",{className:"font-display text-[10px] uppercase tracking-wider text-muted",children:"Classification"}),(0,r.jsx)("dd",{className:"mt-0.5 font-display text-sm text-cream",children:function(e){let t=g.find(t=>t.value===e);return t?t.label:e||"â"}(d.taxClassification)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("dt",{className:"font-display text-[10px] uppercase tracking-wider text-muted",children:"Taxpayer ID"}),(0,r.jsxs)("dd",{className:"mt-0.5 font-display text-sm text-cream",children:["â¢â¢â¢â¢â¢",d.tinLast4||""]})]}),(0,r.jsxs)("div",{className:"sm:col-span-2",children:[(0,r.jsx)("dt",{className:"font-display text-[10px] uppercase tracking-wider text-muted",children:"Address"}),(0,r.jsx)("dd",{className:"mt-0.5 font-display text-sm text-cream break-words",children:[null==(t=d.address)?void 0:t.line1,null==(a=d.address)?void 0:a.line2,[null==(l=d.address)?void 0:l.city,null==(n=d.address)?void 0:n.state,null==(c=d.address)?void 0:c.zip].filter(
1Boolean).join(", ")].filter(Boolean).join(" \xb7 ")})]})]}),(0,r.jsxs)("div",{className:"mt-4 flex flex-wrap items-center gap-x-6 gap-y-2",children:[(0,r.jsx)("button",{type:"button",onClick:_,className:"font-display text-xs uppercase tracking-wider text-amber hover:text-cream transition-colors",children:"Update â"}),(0,r.jsx)("button",{type:"button",onClick:H,disabled:D,className:"font-display text-xs uppercase tracking-wider text-amber hover:text-cream transition-colors disabled:opacity-50",children:D?"Generatingâ¦":"Download W-9 â"})]}),(0,r.jsx)("p",{className:"mt-2 font-display text-[10px] tracking-wider text-muted",children:"Ready-to-sign official IRS form â add your signature and date after download."})]}):(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("p",{className:"text-sm text-secondary leading-relaxed",children:"US affiliates earning $600+/year need tax details on file before payout."}),(0,r.jsx)("p",{className:"mt-2 text-sm text-secondary leading-relaxed",children:"We use these details to auto-generate your IRS W-9 â no manual form filling. Your SSN/EIN is never displayed on this site; it stays masked and only appears inside the W-9 PDF you download."}),(0,r.jsx)("button",{type:"button",onClick:_,className:"mt-3 font-display text-xs uppercase tracking-wider text-amber hover:text-cream transition-colors",children:"Add tax info â"})]}):(0,r.jsx)("p",{className:"mt-3 font-display text-xs uppercase tracking-wider text-muted",children:"Loadingâ¦"})]})}function v(e){let{user:t,currentEmail:a,affiliate:l}=e,[n,c]=(0,s.useState)(!1),[o,d]=(0,s.useState)(a||""),[x,m]=(0,s.useState)(a||""),[p,u]=(0,s.useState)(!1),[b,h]=(0,s.useState)(""),[f,y]=(0,s.useState)(!1);async function g(e){if(e.preventDefault(),!p){if(h(""),y(!1),!o.trim())return void h("A PayPal email is required.");u(!0);try{let e=await t.getIdToken(),a=await fetch("/api/affiliates/payout",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify({paypalEmail:o.trim()})}),r=await a.json().catch(()=>({}));if(a.ok)m(o.trim()),c(!1),y(!0),setTimeout(()=>y(!1),2500),i.oR.success("PayPal email saved.");else{let e=r.error||"Couldn't save. Please try again.";h(e),i.oR.error(e)}}catch(e){h("Network error. Please try again."),i.oR.error("Network error. Please try again.")}finally{u(!1)}}}return(0,r.jsxs)("div",{id:"payout",className:"border border-border bg-surface p-6 scroll-mt-6",children:[(0,r.jsx)("p",{className:"label",children:"/PAYOUT"}),l&&(0,r.jsx)(j,{user:t,affiliate:l}),n?(0,r.jsxs)("form",{onSubmit:g,className:"mt-3 flex flex-col gap-3 sm:flex-row",children:[(0,r.jsx)("input",{type:"email",value:o,onChange:e=>d(e.target.value),placeholder:"[email protected]",autoComplete:"email","aria-label":"PayPal email",className:"h-12 flex-1 bg-elevated border border-border-strong px-4 font-display text-sm text-cream placeholder:text-muted focus:border-amber focus:outline-none"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{type:"submit",disabled:p,className:"inline-flex h-12 items-center bg-amber px-5 font-display text-xs font-semibold uppercase tracking-[0.15em] text-black hover:bg-cream transition-colors disabled:opacity-50",children:p?"Savingâ¦":"Save"}),(0,r.jsx)("button",{type:"button",onClick:()=>{c(!1),h("")},className:"inline-flex h-12 items-center border border-border-strong bg-transparent px-5 font-display text-xs font-semibold uppercase tracking-[0.15em] text-cream hover:bg-elevated transition-colors",children:"Cancel"})]})]}):(0,r.jsxs)("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"font-display text-[10px] uppercase tracking-wider text-muted",children:"PayPal email"}),(0,r.jsx)("p",{className:"mt-1 font-display text-sm text-cream break-all",children:x||"Not set"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[f&&(0,r.jsx)("span",{className:"font-display text-[10px] uppercase tracking-wider text-green",children:"Saved â"}),(0,r.jsx)("button",{type:"button",onClick:()=>{d(x),c(!0)},className:"inline-flex h-10 items-center border border-border-strong bg-elevated px-4 font-display text-xs font-semibold uppercase tracking-[0.15em] text-cream hover:border-amber transition-colors",children:"Edit"})]})]}),b&&(0,r.jsx)("p",{className:"mt-3 font-display text-xs uppercase tracking-wider text-red",children:b}),(0,r.jsx)(N,{user:t})]})}function w(e){return"".concat("https://www.mytrt.app","/?ref=").concat(e)}
1function k(e){let{code:t,baseLink:a}=e,[l,n]=(0,s.useState)(""),i=l?"".concat(a,"&c=").concat(l):null;return(0,r.jsxs)("div",{className:"mt-6 border-t border-border pt-5",children:[(0,r.jsx)("p",{className:"font-display text-[10px] uppercase tracking-wider text-muted",children:"Campaign link"}),(0,r.jsxs)("div",{className:"mt-2 flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,r.jsx)("input",{type:"text",value:l,onChange:function(e){n(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"").slice(0,24))},maxLength:24,spellCheck:!1,placeholder:"e.g. podcast, newsletter, tiktok","aria-label":"Campaign tag",className:"h-10 flex-1 bg-black border border-border-strong px-3 font-mono text-sm text-cream placeholder:text-muted focus:border-amber focus:outline-none"}),(0,r.jsx)(y,{text:i||a,label:"Copy link"})]}),i?(0,r.jsx)("p",{className:"mt-2 font-mono text-sm text-cream break-all",children:i}):(0,r.jsx)("p",{className:"mt-2 font-mono text-sm text-muted break-all",children:a}),(0,r.jsx)("p",{className:"mt-2 font-display text-[10px] uppercase tracking-wider text-muted",children:"Tag your channels to see which ones drive clicks."})]})}function S(e){let{code:t}=e,a=w(t),s="I track my TRT with My TRT App â labs, doses, and progress in one place. Use my code ".concat(t," when you subscribe: ").concat(w(t)),l='<a href="'.concat(w(t),'" style="display:inline-block;background:#0A0A0A;color:#F0EDE5;border:1px solid #3A3A3A;border-radius:10px;padding:14px 18px;font-family:Arial,sans-serif;text-decoration:none;line-height:1.4"><span style="color:#FFB454;font-size:12px;letter-spacing:1px">MY TRT APP</span><br>Get the app â use code <strong style="color:#FFB454">').concat(t,"</strong></a>");return(0,r.jsxs)("div",{id:"share-kit",className:"border border-border bg-elevated p-5 scroll-mt-6",children:[(0,r.jsx)("p",{className:"font-display text-[10px] uppercase tracking-[0.2em] text-amber",children:"/SHARE_KIT"}),(0,r.jsxs)("div",{className:"mt-4",children:[(0,r.jsx)("p",{className:"font-display text-[10px] uppercase tracking-wider text-muted",children:"Your link"}),(0,r.jsx)("p",{className:"mt-2 font-display text-sm text-cream break-all",children:a}),(0,r.jsx)("div",{className:"mt-3",children:(0,r.jsx)(y,{text:a,label:"Copy link"})})]}),(0,r.jsx)(k,{code:t,baseLink:a}),(0,r.jsxs)("div",{className:"mt-6 border-t border-border pt-5",children:[(0,r.jsx)("p",{className:"font-display text-[10px] uppercase tracking-wider text-muted",children:"Share text"}),(0,r.jsx)("p",{className:"mt-2 text-sm text-cream leading-relaxed",children:s}),(0,r.jsx)("div",{className:"mt-3",children:(0,r.jsx)(y,{text:s,label:"Copy share text"})})]}),(0,r.jsxs)("div",{className:"mt-6 border-t border-border pt-5",children:[(0,r.jsx)("p",{className:"font-display text-[10px] uppercase tracking-wider text-muted",children:"Website embed (HTML)"}),(0,r.jsx)("textarea",{readOnly:!0,rows:5,value:l,onFocus:e=>e.target.select(),"aria-label":"Website embed HTML",className:"mt-2 w-full resize-none bg-black border border-border-strong px-3 py-2 font-mono text-xs text-secondary focus:border-amber focus:outline-none"}),(0,r.jsx)("div",{className:"mt-3",children:(0,r.jsx)(y,{text:l,label:"Copy embed HTML"})})]})]})}function C(e){let{user:t,code:a,onSaved:l,onCancel:n}=e,[c,o]=(0,s.useState)(a),[d,x]=(0,s.useState)(!1),[m,p]=(0,s.useState)(""),[u,b]=(0,s.useState)(null);async function h(e){if(e.preventDefault(),!d){if(p(""),c===a)return void p("That's already your code.");if(c.length<3||c.length>20)return void p("Codes are 3â20 letters or numbers.");x(!0);try{let e=await t.getIdToken(),r=await fetch("/api/affiliates/update-code",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify({code:c,currentCode:a})}),s=await r.json().catch(()=>({}));if(r.ok&&s.ok)i.oR.success("Your code is now ".concat(s.code,".")),l(s.code);else{let e=s.error||"Couldn't change your code. Please try again.";p(e),i.oR.error(e)}}catch(e){p("Network error. Please try again."),i.oR.error("Network error. Please try again.")}finally{x(!1)}}}(0,s.useEffect)(()=>
1{if(b(null),!c||c===a||c.length<3||c.length>20)return;let e=!1,t=setTimeout(async()=>{try{let t=await fetch("/api/affiliates/check-code?code=".concat(encodeURIComponent(c))),a=await t.json().catch(()=>({}));e||b(a)}catch(e){}},400);return()=>{e=!0,clearTimeout(t)}},[c,a]);let f=null;if(u&&c!==a&&c.length>=3){if(!0===u.available)f=(0,r.jsx)("span",{className:"font-display text-[10px] uppercase tracking-wider text-green",children:"Available â"});else if(!1===u.available){let e="reserved"===u.reason?"Reserved":"invalid"===u.reason?"Invalid":"Taken";f=(0,r.jsx)("span",{className:"font-display text-[10px] uppercase tracking-wider text-red",children:e})}}return(0,r.jsxs)("form",{onSubmit:h,className:"mt-3 w-full",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,r.jsx)("input",{type:"text",value:c,onChange:function(e){o(e.target.value.toLowerCase().replace(/[^a-z0-9]/g,"")),p("")},autoFocus:!0,maxLength:20,spellCheck:!1,"aria-label":"Referral code",className:"h-12 flex-1 bg-elevated border border-border-strong px-4 font-mono text-2xl uppercase tracking-[0.15em] text-amber focus:border-amber focus:outline-none"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[f,(0,r.jsx)("button",{type:"submit",disabled:d,className:"inline-flex h-12 items-center bg-amber px-5 font-display text-xs font-semibold uppercase tracking-[0.15em] text-black hover:bg-cream transition-colors disabled:opacity-50",children:d?"Savingâ¦":"Save"}),(0,r.jsx)("button",{type:"button",onClick:n,className:"inline-flex h-12 items-center border border-border-strong bg-transparent px-5 font-display text-xs font-semibold uppercase tracking-[0.15em] text-cream hover:bg-elevated transition-colors",children:"Cancel"})]})]}),m&&(0,r.jsx)("p",{className:"mt-3 font-display text-xs uppercase tracking-wider text-red",children:m}),(0,r.jsx)("p",{className:"mt-3 font-display text-[10px] uppercase tracking-wider text-muted",children:"3â20 characters, aâz 0â9. Code changes limited to once per 30 days."})]})}function A(e){let{label:t,value:a,caption:s}=e;return(0,r.jsxs)("div",{className:"bg-elevated px-5 py-5",children:[(0,r.jsx)("p",{className:"font-display text-[10px] uppercase tracking-wider text-muted",children:t}),(0,r.jsx)("p",{className:"mt-2 font-display text-2xl tabular-nums text-amber",children:a}),s&&(0,r.jsx)("p",{className:"mt-1 font-display text-[10px] uppercase tracking-wider text-muted",children:s})]})}function P(e){let{campaignClicks:t,totalClicks:a}=e,s=Object.entries(null!=t?t:{}).map(e=>{let[t,a]=e;return[t,Number(a)||0]}).sort((e,t)=>t[1]-e[1]);if(0===s.length)return null;let l=s.reduce((e,t)=>{let[,a]=t;return e+a},0),n=(Number(a)||0)-l;return(0,r.jsx)("div",{className:"mt-3 overflow-x-auto border border-border",children:(0,r.jsxs)("table",{className:"w-full text-left text-sm",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-border font-display text-[10px] uppercase tracking-wider text-muted",children:[(0,r.jsx)("th",{className:"px-4 py-3 font-normal",children:"By campaign"}),(0,r.jsx)("th",{className:"px-4 py-3 font-normal text-right",children:"Clicks"})]})}),(0,r.jsxs)("tbody",{children:[s.map(e=>{let[t,a]=e;return(0,r.jsxs)("tr",{className:"border-b border-border last:border-b-0",children:[(0,r.jsx)("td",{className:"px-4 py-3 font-mono text-secondary break-all",children:t}),(0,r.jsx)("td",{className:"px-4 py-3 text-right tabular-nums text-cream",children:a})]},t)}),n>0&&(0,r.jsxs)("tr",{className:"border-b border-border last:border-b-0",children:[(0,r.jsx)("td",{className:"px-4 py-3 font-mono text-muted",children:"untagged"}),(0,r.jsx)("td",{className:"px-4 py-3 text-right tabular-nums text-cream",children:n})]})]})]})})}function T(e){let{status:t}=e,a="paid"===t;return(0,r.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 font-display text-[10px] uppercase tracking-wider ".concat(a?"bg-green/15 text-green":"bg-amber/15 text-amber"),children:t||"pending"})}function R(e){var t;let{conversion:a}=e,[l,n]=(0,s.useState)(!1),i="percent"===a.commissionType,c=void 0!==a.priceUsd&&null!==a.priceUsd&&!Number.isNaN(Number(a.priceUsd)),o=i&&(Number(a.commissionPct)||c)?"".concat(Number(a.commissionPct)||0,"%").concat(c?" of ".concat(p(a.priceUsd)):""):null,d=function(e,t){if(!e||"string"!=typeof e)return"â";let a=e.toLowerCase(),r=null==t||Number.isNaN(Number(t))?null:Number(t),s=null!==r?" ".concat(p(r)):"";return a.includes("year")||a.includes("annual")?"Pro Yearly".concat(s):a.includes("month")?"Pro Monthly".concat(s):"â"}(a.productId,a.priceUsd),x=a.campaign||null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("tr",{className:"border-b border-border last:border-b-0",children:[(0,r.jsx)("td",{className:"whitespace-nowrap px-4 py-3 text-secondary",children:m(a.at)}),(0,r.jsx)("td",{className:"whitespace-nowrap px-4 py-3 text-secondary",children:a.platform||"â"}),(0,r.jsx)("td",{className:"whitespace-nowrap px-4 py-3 text-secondary",children:d}),(0,r.jsx)("td",{className:"whitespace-nowrap px-4 py-3",children:x?(0,r.jsx)("span",{className:"inline-flex items-center border border-border-strong bg-black px-2 py-0.5 font-mono text-xs text-cream",children:x}):(0,r.jsx)("span",{className:"text-muted",children:"â"})}),(0,r.jsxs)("td",{className:"whitespace-nowrap px-4 py-3 tabular-nums text-cream",children:[p(a.bountyUsd),o&&(0,r.jsx)("span",{className:"mt-0.5 block font-display text-[10px] uppercase tracking-wider text-muted",children:o})]}),(0,r.jsx)("td",{className:"whitespace-nowrap px-4 py-3",children:(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,r.jsx)(T,{status:a.status}),(0,r.jsx)("button",{type:"button",onClick:()=>n(e=>!e),"aria-expanded":l,"aria-label":l?"Hide details":"Show details",className:"inline-flex h-6 w-6 items-center justify-center border border-border-strong bg-elevated font-mono text-xs text-cream hover:border-amber transition-colors",children:(0,r.jsx)("span",{className:"inline-block transition-transform ".concat(l?"rotate-90":""),"aria-hidden":"true",children:"âº"})})]})})]}),l&&(0,r.jsx)("tr",{className:"border-b border-border last:border-b-0 bg-black/40",children:(0,r.jsx)("td",{colSpan:6,className:"px-4 py-4",children:(0,r.jsxs)("dl",{className:"grid gap-x-8 gap-y-2 sm:grid-cols-2",children:[(0,r.jsxs)("div",{className:"flex justify-between gap-4 border-b border-border/60 pb-1.5",children:[(0,r.jsx)("dt",{className:"font-display text-[10px] uppercase tracking-wider text-muted",children:"User"}),(0,r.jsx)("dd",{className:"font-mono text-xs text-secondary",children:(t=a.uid)&&"string"==typeof t?"".concat(t.slice(0,6),"â¦"):"â"})]}),(0,r.jsxs)("div",{className:"flex justify-between gap-4 border-b border-border/60 pb-1.5",children:[(0,r.jsx)("dt",{className:"font-display text-[10px] uppercase tracking-wider text-muted",children:"Product ID"}),(0,r.jsx)("dd",{className:"font-mono text-xs text-secondary break-all",children:a.productId||"â"})]}),(0,r.jsxs)("div",{className:"flex justify-between gap-4 border-b border-border/60 pb-1.5",children:[(0,r.jsx)("dt",{className:"font-display text-[10px] uppercase tracking-wider text-muted",children:"Price"}),(0,r.jsx)("dd",{className:"font-mono text-xs text-secondary",children:c?p(a.priceUsd):"â"})]}),(0,r.jsxs)("div",{className:"flex justify-between gap-4 border-b border-border/60 pb-1.5",children:[(0,r.jsx)("dt",{className:"font-display text-[10px] uppercase tracking-wider text-muted",children:"Commission"}),(0,r.jsx)("dd",{className:"font-mono text-xs text-secondary",children:i?"".concat(Number(a.commissionPct)||0,"% (percent)"):"".concat(p(a.bountyUsd)," (flat)")})]}),(0,r.jsxs)("div",{className:"flex justify-between gap-4 border-b border-border/60 pb-1.5",children:[(0,r.jsx)("dt",{className:"font-display text-[10px] uppercase tracking-wider text-muted",children:"Campaign"}),(0,r.jsx)("dd",{className:"font-mono text-xs text-secondary break-all",children:x||"â"})]}),(0,r.jsxs)("div",{className:"flex justify-between gap-4 border-b border-border/60 pb-1.5",children:[(0,r.jsx)("dt",{className:"font-display text-[10px] uppercase tracking-wider text-muted",children:"Recorded"}),(0,r.jsx)("dd",{className:"font-mono text-xs text-secondary",children:m(a.at)})]})]})})})]})}function D(e){let{term:t,children:a}=e;return(0,r.jsxs)("div",{className:"flex flex-col gap-1 border-b border-border py-3 sm:flex-row sm:items-baseline sm:justify-between sm:gap-6 last:border-b-0",children:[(0,r.jsx)("dt",{className:"font-display text-[10px] uppercase tracking-wider text-muted",children:t}),(0,r.jsx)("dd",{className:"text-sm text-cream sm:text-right break-words",children:a})]})}function I(e){let{active:t}=e;return(0,r.jsxs)("span",{className:"inline-flex items-center gap-2 font-display text-[10px] uppercase tracking-wider",children:[(0,r.jsx)("span",{className:"inline-block h-2 w-2 rounded-full ".concat(t?"bg-green":"bg-red"),"aria-hidden":"true"}),(0,r.jsx)("span",{className:t?"text-green":"text-red",children:t?"Active":"Inactive"})]})}function E(e){let{affiliate:t,application:a}=e,s=a||{},l="Available now";if(t.codeChangedAt){let e=new Date(t.codeChangedAt);if(!Number.isNaN(e.getTime())){let a=new Date(e.getTime()+2592e6);l="Last changed ".concat(x(t.codeChangedAt)," â next change available ").concat(x(a.toISOString()))}}let n=s.payout||{},i=n.method||"PayPal",c=n.paypalEmail||t.contact||null,o=Array.isArray(s.channels)?s.channels.filter(
1Boolean):[],d=Array.isArray(s.links)?s.links.filter(Boolean):"string"==typeof s.links&&s.links.trim()?[s.links.trim()]:[],m=void 0!==s.audienceSize&&null!==s.audienceSize&&""!==s.audienceSize?String(s.audienceSize):null,u=s.appliedAt||s.createdAt||null,b=s.decidedAt||null,h=s.displayName||null,f=s.email||null;return(0,r.jsxs)("div",{className:"border border-border bg-surface p-6",children:[(0,r.jsx)("p",{className:"label",children:"/INFO"}),(0,r.jsx)("h2",{className:"mt-3 font-display text-xl uppercase text-cream",children:"Your affiliate record"}),(0,r.jsxs)("dl",{className:"mt-4",children:[(0,r.jsx)(D,{term:"Code",children:(0,r.jsx)("span",{className:"font-display uppercase tracking-[0.15em] text-amber",children:t.code})}),(0,r.jsx)(D,{term:"Status",children:(0,r.jsx)(I,{active:!0===t.active})}),(0,r.jsx)(D,{term:"Member since",children:x(t.createdAt)}),(0,r.jsx)(D,{term:"Commission model",children:t?"percent"===t.commissionType?"".concat(Number(t.commissionPct)||0,"% of first payment"):"Flat ".concat(p(t.bountyUsd)," per conversion"):"â"}),(0,r.jsxs)(D,{term:"Payout method",children:[i,c&&(0,r.jsxs)("span",{className:"ml-1 text-secondary break-all",children:["\xb7 ",c]})]}),(0,r.jsx)(D,{term:"Code changes",children:l}),u&&(0,r.jsx)(D,{term:"Applied",children:x(u)}),b&&(0,r.jsx)(D,{term:"Approved",children:x(b)}),h&&(0,r.jsx)(D,{term:"Display name",children:h}),f&&(0,r.jsx)(D,{term:"Email",children:(0,r.jsx)("span",{className:"break-all",children:f})}),o.length>0&&(0,r.jsx)(D,{term:"Channels",children:(0,r.jsx)("span",{className:"inline-flex flex-wrap justify-end gap-1.5",children:o.map((e,t)=>(0,r.jsx)("span",{className:"inline-flex items-center border border-border-strong bg-black px-2 py-0.5 font-mono text-xs text-cream",children:e},"".concat(e,"-").concat(t)))})}),d.length>0&&(0,r.jsx)(D,{term:"Links",children:(0,r.jsx)("span",{className:"flex flex-col gap-1 sm:items-end",children:d.map((e,t)=>(0,r.jsx)("span",{className:"font-mono text-xs text-secondary break-all",children:e},"".concat(e,"-").concat(t)))})}),m&&(0,r.jsx)(D,{term:"Audience size",children:m}),void 0!==s.applicationCount&&null!==s.applicationCount&&(0,r.jsx)(D,{term:"Applications",children:String(s.applicationCount)})]})]})}function U(e){let{done:t}=e;return t?(0,r.jsx)("span",{className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-amber font-display text-xs text-black","aria-hidden":"true",children:"â"}):(0,r.jsx)("span",{className:"inline-block h-6 w-6 shrink-0 rounded-full border-2 border-border-strong","aria-hidden":"true"})}function O(e){let{done:t,label:a,href:s}=e,l=(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(U,{done:t}),(0,r.jsx)("span",{className:"font-display text-sm uppercase tracking-wider ".concat(t?"text-muted line-through":"text-cream"),children:a}),!t&&(0,r.jsx)("span",{className:"ml-auto font-display text-[10px] uppercase tracking-wider text-amber",children:"â"})]});return t?(0,r.jsx)("div",{className:"border-b border-border py-3 last:border-b-0",children:l}):(0,r.jsx)("a",{href:s,className:"block border-b border-border py-3 last:border-b-0 transition-colors hover:bg-elevated",children:l})}function L(e){let{user:t,affiliate:a}=e,[l,n]=(0,s.useState)(null);(0,s.useEffect)(()=>{let e=!1;return(async()=>{try{let a=await t.getIdToken(),r=await fetch("/api/affiliates/tax",{headers:{Authorization:"Bearer ".concat(a)}});if(e)return;if(r.ok){let e=await r.json().catch(()=>({}));n(!!e.taxInfo)}else n(!1)}catch(t){e||n(!1)}})(),()=>{e=!0}},[t]);let i="string"==typeof(null==a?void 0:a.contact)&&a.contact.trim().length>0,c=(Number(null==a?void 0:a.clicks)||0)>0||(Number(null==a?void 0:a.conversions)||0)>0;if(null===l)return null;let o=[{key:"payout",done:i,label:"Confirm your payout email",href:"#payout"},{key:"share",done:c,label:"Share your link for the first time",href:"#share-kit"},{key:"tax",done:l,label:"Add your tax details",href:"#tax-info"}],d=o.filter(e=>e.done).length;return d===o.length?null:(0,r.jsxs)("div",{className:"border border-border bg-surface p-6 md:p-8",children:[(0,r.jsx)("p",{className:"label",children:"/GET_STARTED"}),(0,r.jsx)("h2",{className:"mt-3 font-display text-xl uppercase text-cream",children:"Set up your affiliate account"}),(0,r.jsxs)("p",{className:"mt-2 font-display text-[10px] uppercase tracking-wider text-amber",children:[d," of ",o.length," complete"]}),(0,r.jsx)("div",{className:"mt-4",children:o.map(e=>(0,r.jsx)(O,{done:e.done,label:e.label,href:e.href},e.key))})]})}function B(e){var t,a,l,n,i,c;let{affiliate:o,user:d}
1=e,[m,u]=(0,s.useState)(o.code),[h,f]=(0,s.useState)(!1),g="percent"===o.commissionType,j=g?"".concat(Number(o.commissionPct)||0,"%"):p(o.bountyUsd),N=null!=(a=o.conversions)?a:0,v=null!=(l=o.clicks)?l:0,w=null!=(n=o.campaignClicks)?n:{},k=v>0?"".concat((N/v*100).toFixed(1),"%"):"â",T=o.recentConversions&&o.recentConversions.length>0,D=null!=(i=o.payouts)?i:[];return(0,r.jsxs)("div",{className:"border border-border bg-surface p-6 md:p-8",children:[(0,r.jsx)("p",{className:"label",children:"/CODE"}),h?(0,r.jsx)(C,{user:d,code:m,onSaved:e=>{u(e),f(!1)},onCancel:()=>f(!1)}):(0,r.jsxs)("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"font-display text-4xl uppercase tracking-[0.15em] text-amber md:text-5xl",children:m}),(0,r.jsx)("button",{type:"button",onClick:()=>f(!0),"aria-label":"Edit code",className:"inline-flex h-8 items-center gap-1.5 border border-border-strong bg-elevated px-3 font-display text-[10px] font-semibold uppercase tracking-[0.15em] text-cream hover:border-amber transition-colors",children:"â Edit"})]}),(0,r.jsx)(y,{text:m,label:"Copy code"})]}),(0,r.jsxs)("div",{className:"mt-12",children:[(0,r.jsx)("p",{className:"label",children:"/STATS"}),(0,r.jsxs)("div",{className:"mt-3 grid gap-px border border-border bg-border sm:grid-cols-2 lg:grid-cols-3",children:[(0,r.jsx)(A,{label:"Clicks",value:String(v)}),(0,r.jsx)(A,{label:"Conversions",value:String(N)}),(0,r.jsx)(A,{label:"Conv. rate",value:k,caption:"conversions / clicks"}),(0,r.jsx)(A,{label:"Pending",value:p(o.pendingUsd)}),(0,r.jsx)(A,{label:"Paid",value:p(o.paidUsd)}),(0,r.jsx)(A,{label:g?"Commission":"Per conversion",value:j,caption:g?"of first payment":null})]}),(0,r.jsx)(P,{campaignClicks:w,totalClicks:v})]}),(0,r.jsxs)("div",{className:"mt-12",children:[(0,r.jsx)("p",{className:"label",children:"/EARNINGS"}),(0,r.jsx)(b,{conversions:o.recentConversions})]}),(0,r.jsxs)("div",{className:"mt-12",children:[(0,r.jsx)("p",{className:"label",children:"/SHARE"}),(0,r.jsx)("div",{className:"mt-3",children:(0,r.jsx)(S,{code:m})})]}),(0,r.jsxs)("div",{className:"mt-12",children:[(0,r.jsxs)("p",{className:"label",children:["/CONVERSIONS (",null!=(c=null==(t=o.recentConversions)?void 0:t.length)?c:0,")"]}),T?(0,r.jsx)("div",{className:"mt-3 overflow-x-auto border border-border",children:(0,r.jsxs)("table",{className:"w-full min-w-[720px] text-left text-sm",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-border font-display text-[10px] uppercase tracking-wider text-muted",children:[(0,r.jsx)("th",{className:"px-4 py-3 font-normal",children:"Date"}),(0,r.jsx)("th",{className:"px-4 py-3 font-normal",children:"Platform"}),(0,r.jsx)("th",{className:"px-4 py-3 font-normal",children:"Product"}),(0,r.jsx)("th",{className:"px-4 py-3 font-normal",children:"Campaign"}),(0,r.jsx)("th",{className:"px-4 py-3 font-normal",children:"Bounty"}),(0,r.jsx)("th",{className:"px-4 py-3 font-normal",children:"Status"})]})}),(0,r.jsx)("tbody",{children:o.recentConversions.map((e,t)=>(0,r.jsx)(R,{conversion:e},t))})]})}):(0,r.jsxs)("div",{className:"mt-3 border border-border bg-elevated px-5 py-8 text-center",children:[(0,r.jsx)("p",{className:"text-sm text-secondary leading-relaxed",children:"No conversions yet â share your link to get started."}),(0,r.jsx)("a",{href:"#share-kit",className:"mt-4 inline-flex h-10 items-center border border-border-strong bg-black px-4 font-display text-xs font-semibold uppercase tracking-[0.15em] text-cream hover:border-amber transition-colors",children:"Jump to your share kit â"})]})]}),(0,r.jsxs)("div",{className:"mt-12",children:[(0,r.jsx)("p",{className:"label",children:"/PAYOUTS"}),D.length>0?(0,r.jsx)("div",{className:"mt-3 overflow-x-auto border border-border",children:(0,r.jsxs)("table",{className:"w-full text-left text-sm",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-border font-display text-[10px] uppercase tracking-wider text-muted",children:[(0,r.jsx)("th",{className:"px-4 py-3 font-normal",children:"Date"}),(0,r.jsx)("th",{className:"px-4 py-3 font-normal",children:"Amount"}),(0,r.jsx)("th",{className:"px-4 py-3 font-normal",children:"Conversions"}),(0,r.jsx)("th",{className:"px-4 py-3 font-normal",children:"Method"})]})}),(0,r.jsx)("tbody",{children:D.map((e,t)=>{var a;return(0,r.jsxs)("tr",{className:"border-b border-border last:border-b-0",children:[(0,r.jsx)("td",{className:"px-4 py-3 text-secondary",children:x(e.at)}),(0,r.jsx)("td",{className:"px-4 py-3 tabular-nums text-cream",children:p(e.amountUsd)}),(0,r.jsx)("td",{className:"px-4 py-3 tabular-nums text-secondary",children:null!=(a=e.count)?a:0}),(0,r.jsx)("td",{className:"px-4 py-3 text-secondary",children:e.method||"PayPal"})]},e.id||t)})})]})}):(0,r.jsx)("div",{className:"mt-3 border border-border bg-elevated px-5 py-8 text-center",children:(0,r.jsx)("p",{className:"text-sm text-secondary leading-relaxed",children:"No payouts yet â pending earnings are paid out manually via PayPal."})})]})]})}
1function M(){let{user:e,authReady:t,signIn:a,signInApple:l}=(0,c.A)(),[i,m]=(0,s.useState)(!0),[p,u]=(0,s.useState)(""),[b,h]=(0,s.useState)(null),[y,g]=(0,s.useState)([]),j=(0,s.useCallback)(async()=>{if(t){if(!e)return void m(!1);m(!0),u("");try{let t=await e.getIdToken(),a=await fetch("/api/affiliates/me",{headers:{Authorization:"Bearer ".concat(t)}}),r=await a.json().catch(()=>({}));if(!a.ok){u(r.error||"We couldn't load your dashboard just now. Please try again."),m(!1);return}h(r.application||null),g(Array.isArray(r.affiliates)?r.affiliates:[]),m(!1)}catch(e){u("We couldn't reach the server. Check your connection and try again."),m(!1)}}},[t,e]);(0,s.useEffect)(()=>{let e=!1;return j(),()=>{}},[j]);let N=b&&b.payout&&b.payout.paypalEmail||y[0]&&y[0].contact||"";if(!t)return(0,r.jsx)(o,{children:(0,r.jsx)(f,{})});if(!e)return(0,r.jsx)(o,{children:(0,r.jsxs)(d,{label:"/DASHBOARD \xb7 SIGN_IN",title:"Affiliate dashboard",body:"Sign in to view your code, stats, and payouts. Use the same account you use in the app.",children:[(0,r.jsxs)("div",{className:"mt-8 flex flex-col gap-3",children:[(0,r.jsx)("button",{onClick:()=>a(),className:"inline-flex h-12 items-center justify-center bg-cream px-5 font-display text-xs font-semibold uppercase tracking-[0.15em] text-black hover:bg-amber transition-colors",children:"Continue with Google"}),(0,r.jsx)("button",{onClick:()=>l(),className:"inline-flex h-12 items-center justify-center border border-border-strong bg-transparent px-5 font-display text-xs font-semibold uppercase tracking-[0.15em] text-cream hover:bg-elevated transition-colors",children:"Continue with Apple"})]}),(0,r.jsx)("p",{className:"mt-5 font-display text-[10px] uppercase tracking-wider text-muted",children:"Use the same account you use in the app."})]})});if(i)return(0,r.jsx)(o,{children:(0,r.jsx)(f,{})});if(p)return(0,r.jsx)(o,{children:(0,r.jsx)(d,{label:"/DASHBOARD \xb7 ERROR",title:"Couldn't load your dashboard",body:p,children:(0,r.jsx)("button",{onClick:()=>j(),className:"mt-8 inline-flex h-12 items-center bg-amber px-5 font-display text-xs font-semibold uppercase tracking-[0.15em] text-black hover:bg-cream transition-colors",children:"Try again"})})});let w=y.length>0;if(!b&&!w)return(0,r.jsx)(o,{children:(0,r.jsx)(d,{label:"/DASHBOARD",title:"You're not an affiliate yet",body:"Apply to the affiliate program to get your referral code and start earning.",children:(0,r.jsx)(n(),{href:"/affiliates/apply",className:"mt-8 inline-flex h-12 items-center bg-amber px-5 font-display text-xs font-semibold uppercase tracking-[0.15em] text-black hover:bg-cream transition-colors",children:"Apply now â"})})});if(!w&&b&&"pending"===b.status)return(0,r.jsx)(o,{children:(0,r.jsx)(d,{label:"/DASHBOARD \xb7 UNDER_REVIEW",title:"Under review",body:"Your application is in. We'll email you as soon as there's a decision. Your dashboard unlocks once you're approved."})});if(!w&&b&&"rejected"===b.status){let e=null;if(b.decidedAt){let t=new Date(b.decidedAt);Number.isNaN(t.getTime())||(e=x(new Date(t.getTime()+2592e6).toISOString()))}return(0,r.jsx)(o,{children:(0,r.jsxs)(d,{label:"/DASHBOARD \xb7 NOT_APPROVED",title:"Not approved",body:b.rejectReason?b.rejectReason:"Your application wasn't approved.",children:[e&&(0,r.jsxs)("p",{className:"mt-6 border border-border bg-elevated p-4 font-display text-xs uppercase tracking-wider text-amber",children:["You can reapply on ",e,"."]}),(0,r.jsx)("div",{className:"mt-6",children:(0,r.jsx)(n(),{href:"/affiliates/apply",className:"inline-flex h-12 items-center border border-border-strong bg-transparent px-5 font-display text-xs font-semibold uppercase tracking-[0.15em] text-cream hover:bg-elevated transition-colors",children:"Go to apply â"})})]})})}let k=function(e){let t=((null==e?void 0:e.displayName)||"").trim();if(t)return t.split(/\s+/)[0];let a=((null==e?void 0:e.email)||"").split("@")[0]||"";return a?a.charAt(0).toUpperCase()+a.slice(1):"there"}(e);return(0,r.jsxs)(o,{children:[(0,r.jsx)("div",{className:"font-display text-[10px] uppercase tracking-[0.25em] text-amber",children:"/DASHBOARD"}),(0,r.jsxs)("h1",{className:"mt-4 font-display text-3xl uppercase leading-[1.1] text-cream md:text-4xl",children:["Welcome back, ",k]}),(0,r.jsx)("p",{className:"mt-5 text-secondary leading-relaxed",children:"Share your co
1de, track conversions, and manage payouts."}),(0,r.jsxs)("div",{className:"mt-12 space-y-8",children:[y[0]&&(0,r.jsx)(L,{user:e,affiliate:y[0]}),y.map(t=>(0,r.jsx)(B,{affiliate:t,user:e},t.code)),(0,r.jsx)(v,{user:e,currentEmail:N,affiliate:y[0]||null}),y.map(e=>(0,r.jsx)(E,{affiliate:e,application:b},"info-".concat(e.code))),(0,r.jsxs)("div",{className:"border border-border-strong bg-elevated p-5",children:[(0,r.jsx)("p",{className:"font-display text-[10px] uppercase tracking-[0.2em] text-amber",children:"/FTC_REMINDER"}),(0,r.jsx)("p",{className:"mt-2 text-sm text-secondary leading-relaxed",children:"Always clearly disclose your affiliate relationship â use #ad or an affiliate label wherever you share your code. No spam, no misleading claims, no self-referral."})]})]})]})}},8974:(e,t,a)=>{Promise.resolve().then(a.bind(a,8356))}},e=>{var t=t=>e(e.s=t);e.O(0,[2992,7811,6874,2534,6671,8441,1684,7358],()=>t(8974)),_N_E=e.O()}]);
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.