1import{_ as M}from"./vendor-three-dec0Z_i3.js";import{j as e}from"./index-s7cxMHZ5.js";import{r as l,e as F,u as O}from"./vendor-react-0R6VX6ld.js";import{f as B,h as q,o as z,s as G,j as H,T as V}from"./index-9ccb475d-PhXEXAVG.js";import{j as W}from"./index.esm-9ScWneaz.js";import{g as U,h as X}from"./index.esm-8Nbthlc-.js";const Y={apiKey:"AIzaSyCbxnXCczX4BORWmMy_MCQxZTi6mMxjm34",authDomain:"gympal-dashboard.firebaseapp.com",projectId:"gympal-dashboard",storageBucket:"gympal-dashboard.firebasestorage.app",messagingSenderId:"879433876509",appId:"1:879433876509:web:64f10b9cf66410df06b2f4"},I=B(Y,"gympal"),j=q(I);W(I);const K=U(I,"us-central1"),Q=()=>{const[t,a]=l.useState(null),[u,i]=l.useState(null),[n,c]=l.useState(null),[r,g]=l.useState(!0),[x,y]=l.useState(null);return l.useEffect(()=>z(j,async d=>{if(!d){a(null),i(null),c(null),g(!1);return}const o=await d.getIdTokenResult(),w=o.claims.gympalAdmin===!0,b=typeof o.claims.gympalInfluencer=="string"?o.claims.gympalInfluencer:null;w?(a(d),i("admin"),c(null)):b?(a(d),i("influencer"),c(b)):(a(d),i(null),c(null)),g(!1)}),[]),{user:t,role:u,influencerId:n,loading:r,error:x,login:async m=>{y(null);try{return await(await G(j,m.email,m.password)).user.getIdTokenResult(!0),{success:!0}}catch(d){const o=Z(d);return y(o),{success:!1,error:d}}},logout:async()=>{try{return await H(j),y(null),{success:!0}}catch(m){return{success:!1,error:m}}},refreshClaims:async()=>{if(j.currentUser){const m=await j.currentUser.getIdTokenResult(!0),d=m.claims.gympalAdmin===!0,o=typeof m.claims.gympalInfluencer=="string"?m.claims.gympalInfluencer:null;d?(i("admin"),c(null)):o?(i("influencer"),c(o)):(i(null),c(null))}}}};function Z(t){switch($(t)){case"auth/invalid-credential":case"auth/wrong-password":case"auth/user-not-found":return"Invalid email or password.";case"auth/invalid-email":return"Please enter a valid email address.";case"auth/user-disabled":return"This account has been disabled. Contact an admin.";case"auth/too-many-requests":return"Too many failed attempts. Please try again in a few minutes.";case"auth/network-request-failed":return"Network error. Please check your connection.";case"auth/operation-not-allowed":return"Sign-in is currently disabled.";case"auth/email-already-in-use":return"This email is already in use.";default:return"Sign-in failed. Please try again."}}function $(t){if(!t)return null;const a=t.code;if(typeof a=="string")return a;
1if(t instanceof Error){const u=t.message.match(/auth\/[a-z-]+/);if(u)return u[0]}return null}function s(t){const a=X(K,t);return async u=>(await a(u)).data}const be=s("setUserRole"),he=s("createInfluencer"),J=s("registerInfluencer"),fe=s("updateInfluencer"),we=s("deleteInfluencer"),je=s("setRevenueSettings"),ke=s("getRevenueSettings"),ve=s("listSubscriptions"),Ne=s("getMySubscriptions");s("debugMyPayoutSources");const Se=s("getMyMonthlyPayouts"),Ce=s("clearMyTestData");s("getDashboardStats");const Ie=s("getDashboardCharts"),Pe=s("getDashboardOverview"),Re=s("listInfluencers"),Te=s("generateMonthlyReport"),Ae=s("getMyDashboardStats"),De=s("getMyMonthlyReport"),ee=s("bootstrapFirstAdmin"),Me=s("listFeedback"),Ee=s("listOnboarding"),Le=s("getOnboardingFunnel"),_e=s("markFeedbackAnswered"),Fe=s("reopenFeedback"),Oe=s("listDuties"),Be=s("createDuty"),qe=s("updateDuty"),ze=s("deleteDuty"),Ge=s("generateDutySuggestion"),He=s("generateDutiesBulk"),te=({onSubmit:t,onRegister:a,loading:u,error:i})=>{const[n,c]=l.useState({email:"",password:""}),[r,g]=l.useState(!1),[x,y]=l.useState("signin"),[h,f]=l.useState(!1),[k,m]=l.useState(null),[d,o]=l.useState(null),[w,b]=l.useState(""),[P,R]=l.useState(!1),[T,v]=l.useState(null),N=p=>{c({...n,[p.target.name]:p.target.value})},E=async p=>{p.preventDefault(),await t(n)},L=async p=>{if(p.preventDefault(),v(null),n.password.length<8){v("Password must be at least 8 characters.");return}if(n.password!==w){v("Passwords do not match.");return}R(!0);try{const C=await a({email:n.email.trim(),password:n.password});C.success||v(C.error??"Registration failed. Please try again.")}finally{R(!1)}},_=async p=>{p.preventDefault(),f(!0),o(null),m(null);try{await V(j,n.email.trim()),m("If an account exists for this email, we've sent a password reset link. Check your inbox.")}catch(C){const A=C.code;A==="auth/invalid-email"?o("Please enter a valid email address."):A==="auth/missing-email"?o("Please enter your email."):m("If an account exists for this email, we've sent a password reset link. Check your inbox.")}finally{f(!1)}},S=p=>{y(p),m(null),o(null),v(null),b("")};return e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-gympal-bg px-4",children:[e.jsx("img",{src:"/gympal/logo.png",alt:"GymPal",className:"mb-10 h-32 w-32 object-contain"}),x==="signin"?e.jsxs("form",{onSubmit:E,className:"w-full max-w-sm space-y-4",children:[i&&e.jsx("div",{className:"rounded-lg border border-gympal-orange/40 bg-gympal-orange/10 px-4 py-3 text-sm text-gympal-orange",children:i}),e.jsx("input",{type:"email",name:"email",autoComplete:"email",placeholder:"Email",value:n.email,onChange:N,required:!0,className:"w-full rounded-lg border border-gympal-dark2 bg-gympal-cards px-4 py-3.5 text-sm text-white placeholder-gympal-dark2 outline-none transition-colors focus:border-gympal-yellow/60"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:r?"text":"password",name:"password",autoComplete:"current-password",placeholder:"Password",value:n.password,onChange:N,required:!0,className:"w-full rounded-lg border border-gympal-dark2 bg-gympal-cards px-4 py-3.5 pr-12 text-sm text-white placeholder-gympal-dark2 outline-none transition-colors focus:border-gympal-yellow/60"}),e.jsx("button",{type:"button",onClick:()=>g(!r),className:"absolute right-3 top-1/2 -translate-y-1/2 text-xs text-gympal-darkTypo hover:text-white","aria-label":r?"Hide password":"Show password",children:r?"Hide":"Show"})]}),e.jsx("button",{type:"submit",disabled:u,className:"w-full rounded-lg bg-gympal-yellow px-4 py-3.5 text-sm font-semibold text-black transition-all hover:brightness-110 disabled:cursor-not-allowed disabled:opacity-50",children:u?"Signing inâ¦":"Sign In"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("button",{type:"button",onClick:()=>S("register"),className:"text-xs text-gympal-darkTypo underline-offset-2 hover:text-gympal-yellow hover:underline",children:"New influencer? Create account"}),e.jsx("button",{type:"button",onClick:()=>S("reset"),className:"text-xs text-gympal-darkTypo underline-offset-2 hover:text-gympal-yellow hover:underline",children:"Forgot password?"})]})]}):x==="reset"?e.jsxs("form",{onSubmit:_,className:"w-full max-w-sm space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-white",children:"Reset your password"}),e.jsx("p",{className:"mt-1 text-xs text-gympal-darkTypo",children:"Enter your email â we'll send you a link to set a new password."})]}),d&&e.jsx("div",{className:"rounded-lg border border-gympal-orange/40 bg-gympal-orange/10 px-4 py-3 text-sm text-gympal-orange",children:d}),k&&e.jsx("div",{className:"rounded-lg border border-gympal-yellow/40 bg-gympal-yellow/10 px-4 py-3 text-sm text-gympal-yellow",children:k}),e.jsx("input",{type:"email",name:"email",autoComplete:"email",placeholder:"Email",value:n.email,onChange:N,required:!0,className:"w-full rounded-lg border border-gympal-dark2 bg-gympal-cards px-4 py-3.5 text-sm text-white placeholder-gympal-dark2 outline-none transition-colors focus:border-gympal-yellow/60"}),e.jsx("button",{type:"submit",disabled:h,className:"w-full rounded-lg bg-gympal-yellow px-4 py-3.5 text-sm font-semibold text-black transition-all hover:brightness-110 disabled:cursor-not-allowed disabled:opacity-50",children:h?"Sendingâ¦":"Send reset link"}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"button",onClick:()=>S("signin"),className:"text-xs text-gympal-darkTypo underline-offset-2 hover:text-gympal-yellow hover:underline",children:"â Back to sign in"})})]}):e.jsxs("form",{onSubmit:L,className:"w-full max-w-sm space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-white",children:"Create your influencer account"}),e.jsx("p",{className:"mt-1 text-xs text-gympal-darkTypo",children:"Use the same email your admin invited you with. Access is granted automatically once you register."})]}),T&&e.jsx("div",{className:"rounded-lg border border-gympal-orange/40 bg-gympal-orange/10 px-4 py-3 text-sm text-gympal-orange",children:T}),e.jsx("input",{type:"email",name:"email",autoComplete:"email",placeholder:"Email",value:n.email,onChange:N,required:!0,className:"w-full rounded-lg border border-gympal-dark2 bg-gympal-cards px-4 py-3.5 text-sm text-white placeholder-gympal-dark2 outline-none transition-colors focus:border-gympal-yellow/60"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:r?"text":"password",name:"password",autoComplete:"new-password",placeholder:"Password (min. 8 characters)",value:n.password,onChange:N,required:!0,className:"w-full rounded-lg border border-gympal-dark2 bg-gympal-cards px-4 py-3.5 pr-12 text-sm text-white placeholder-gympal-dark2 outline-none transition-colors focus:border-gympal-yellow/60"}),e.jsx("button",{type:"button",onClick:()=>g(!r),className:"absolute right-3 top-1/2 -translate-y-1/2 text-xs text-gympal-darkTypo hover:text-white","aria-label":r?"Hide password":"Show password",children:r?"Hide":"Show"})]}),e.jsx("input",{type:r?"text":"password",name:"confirmPassword",autoComplete:"new-password",placeholder:"Confirm password",value:w,onChange:p=>b(p.target.value),required:!0,className:"w-full rounded-lg border border-gympal-dark2 bg-gympal-cards px-4 py-3.5 text-sm text-white placeholder-gympal-dark2 outline-none transition-colors focus:border-gympal-yellow/60"}),e.jsx("button",{type:"submit",disabled:P,className:"w-full rounded-lg bg-gympal-yellow px-4 py-3.5 text-sm font-semibold text-black transition-all hover:brightness-110 disabled:cursor-not-allowed disabled:opacity-50",children:P?"Creating accountâ¦":"Create account"}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"button",onClick:()=>S("signin"),className:"text-xs text-gympal-darkTypo underline-offset-2 hover:text-gympal-yellow hover:underline",children:"â Back to sign in"})})]})]})},se=["[email protected]"],ae=({email:t,onLogout:a,onPromoted:u})=>{const[i,n]=l.useState(!1),[c,r]=l.useState(null),[g,x]=l.useState(null),y=se.includes(t.trim().toLowerCase()),h=async()=>{n(!0),x(null),r(null);try{await ee({}),r("Successfully promoted. Loading dashboardâ¦"),await u()}catch(f){x(f.message)}finally{n(!1)}};return e.jsxs("div",{className:"flex min-h-screen flex-col items-center justify-center bg-gympal-bg px-4",children:[e.jsx("img",{src:"/gympal/logo.png",alt:"GymPal",className:"mb-10 h-32 w-32 object-contain"}),e.jsxs("div",{className:"w-full max-w-sm rounded-2xl border border-gympal-dark2 bg-gympal-cards p-8 text-center",children:[e.jsx("p",{className:"text-sm text-gympal-darkTypo",children:"Signed in as"}),e.jsx("p",{className:"mt-1 break-all text-sm font-semibold text-white",children:t}),y?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-6 text-sm text-gympal-darkTypo",children:"No admin exists
1yet. As the bootstrap account, you can promote yourself once."}),g&&e.jsx("div",{className:"mt-4 rounded-lg border border-gympal-orange/40 bg-gympal-orange/10 px-3 py-2 text-xs text-gympal-orange",children:g}),c&&e.jsx("div",{className:"mt-4 rounded-lg border border-gympal-yellow/40 bg-gympal-yellow/10 px-3 py-2 text-xs text-gympal-yellow",children:c}),e.jsx("button",{type:"button",disabled:i,onClick:h,className:"mt-6 w-full rounded-lg bg-gympal-yellow px-4 py-3 text-sm font-semibold text-black transition-all hover:brightness-110 disabled:cursor-not-allowed disabled:opacity-50",children:i?"Promotingâ¦":"Promote myself to admin"})]}):e.jsx("p",{className:"mt-6 text-sm text-gympal-darkTypo",children:"Your account is set up but has no role yet. Please ask an administrator to assign your role."}),e.jsx("button",{type:"button",onClick:a,className:"mt-3 w-full rounded-lg border border-gympal-dark2 px-4 py-3 text-xs text-gympal-darkTypo hover:text-white",children:"Sign Out"})]})]})},le=({userEmail:t,role:a,onLogout:u})=>e.jsx("header",{className:"sticky top-0 z-50 border-b border-gympal-dark2 bg-gympal-bg/90 backdrop-blur-xl",children:e.jsxs("div",{className:"mx-auto flex max-w-7xl items-center justify-between px-4 py-3 sm:px-6",children:[e.jsx("img",{src:"/gympal/logo.png",alt:"GymPal",className:"h-14 w-14 object-contain"}),e.jsxs("div",{className:"flex items-center gap-3",children:[a==="admin"&&e.jsx("span",{className:"hidden rounded-full bg-gympal-yellow/15 px-2.5 py-1 text-[10px] font-semibold uppercase tracking-wider text-gympal-yellow sm:inline",children:"Admin"}),e.jsx("span",{className:"hidden text-xs text-gympal-darkTypo sm:block",children:t}),e.jsx("button",{type:"button",onClick:u,className:"rounded-lg border border-gympal-dark2 bg-gympal-cards px-3 py-1.5 text-xs font-medium text-gympal-darkTypo transition-colors hover:border-gympal-yellow/50 hover:text-white",children:"Sign Out"})]})]})}),ne=l.lazy(()=>M(()=>import("./AdminView-qRw37BI7.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),re=l.lazy(()=>M(()=>import("./InfluencerView-ChEMqGnb.js"),__vite__mapDeps([13,1,2,3,4,5,6,7,8,9,10,11,12]))),D=()=>e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-gympal-bg",children:e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-4 border-gympal-yellow border-t-transparent"})}),oe=t=>t.includes("/gympal/influencer")?"influencer":t.includes("/gympal/admin")?"admin":null,ie=()=>{const{user:t,role:a,influencerId:u,loading:i,error:n,login:c,logout:r,refreshClaims:g}=Q(),[x,y]=l.useState(!1),h=F(),f=O(),k=async o=>{y(!0);try{await c(o)}finally{y(!1)}},m=async o=>{const w=o.email.trim();try{return await J({email:w,password:o.password}),(await c({email:w,password:o.password})).success?{success:!0}:{success:!1,error:"Account created â please sign in."}}catch(b){return{success:!1,error:de(b)}}};if(i)return e.jsx(D,{});if(!t)return e.jsx(te,{onSubmit:k,onRegister:m,loading:x,error:n});if(!a)return e.jsx(ae,{email:t.email??"",onLogout:()=>r(),onPromoted:g});const d=oe(h.pathname);return d&&d!==a?e.jsx(ce,{actualRole:a,intendedRole:d,onSwitch:()=>f(a==="admin"?"/gympal/admin":"/gympal/influencer"),onLogout:()=>r()}):e.jsxs("div",{className:"min-h-screen bg-gympal-bg font-sans text-gray-100",children:[e.jsx(le,{userEmail:t.email,role:a,onLogout:()=>r()}),e.jsx("main",{className:"mx-auto max-w-7xl px-4 py-6 sm:px-6",children:e.jsx(l.Suspense,{fallback:e.jsx(D,{}),children:a==="admin"?e.jsx(ne,{}):e.jsx(re,{influencerId:u??""})})})]})},ce=({actualRole:t,intendedRole:a,onSwitch:u,onLogout:i})=>{const n=a==="admin"?"Admin":"Influencer",c=t==="admin"?"Admin":"Influencer",r=t==="admin"?"/gympal/admin":"/gympal/influencer";return e.jsxs("div",{className:"flex min-h-screen flex-col items-center justify-center bg-gympal-bg px-4",children:[e.jsx("img",{src:"/gympal/logo.png",alt:"GymPal",className:"mb-10 h-32 w-32 object-contain"}),e.jsxs("div",{className:"w-full max-w-sm rounded-2xl border border-gympal-dark2 bg-gympal-cards p-8 text-center",children:[e.jsxs("p",{className:"text-sm text-gympal-darkTypo",children:["This page is the ",e.jsx("span",{className:"text-white",children:n})," ","dashboard, but you're signed in as"," ",e.jsx("span",{className:"text-white",children:c}),"."]}),e.jsxs("p",{className:"mt-3 text-xs text-gympal-darkTypo",children:["Your dashboard lives at"," ",e.jsx("code",{className:"font-mono text-gympal-yellow",children:r}),"."]}),e.jsxs("button",{type:"button",onClick:u,className:"mt-6 w-full rounded-lg bg-gympal-yellow px-4 py-3 text-sm font-semibold text-black transition-all hover:brightness-110",children:["Go to ",c," dashboard"]}),e.jsx("button",{type:"button",onClick:i,className:"mt-3 w-full rounded-lg border border-gympal-dark2 px-4 py-3 text-xs text-gympal-darkTypo hover:text-white",children:"Sign Out"})]})]})};function de(t){if(t&&typeof t=="object"&&"message"in t){const a=t.message;
1if(typeof a=="string"&&a.trim())return a}return"Registration failed. Please try again."}const Ve=Object.freeze(Object.defineProperty({__proto__:null,default:ie},Symbol.toStringTag,{value:"Module"}));export{De as A,Ve as G,Pe as a,Me as b,he as c,we as d,be as e,Be as f,Te as g,qe as h,ze as i,Ge as j,He as k,ve as l,_e as m,Ie as n,Re as o,ke as p,Ae as q,Fe as r,je as s,Ne as t,fe as u,Se as v,Oe as w,Ee as x,Le as y,Ce as z}; 2function __vite__mapDeps(indexes) { 3 if (!__vite__mapDeps.viteFileDeps) { 4 __vite__mapDeps.viteFileDeps = ["assets/AdminView-qRw37BI7.js","assets/index-s7cxMHZ5.js","assets/vendor-react-0R6VX6ld.js","assets/vendor-three-dec0Z_i3.js","assets/vendor-framer-JqHIcSWX.js","assets/vendor-icons-LlCGcXb-.js","assets/index-_US79g3c.css","assets/payoutPdf-pyhbHRk5.js","assets/LineChart-rLQY3wmp.js","assets/jspdf.es.min-6-6ucsSz.js","assets/index-9ccb475d-PhXEXAVG.js","assets/index.esm-9ScWneaz.js","assets/index.esm-8Nbthlc-.js","assets/InfluencerView-ChEMqGnb.js"] 5 } 6 return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) 7}
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.