PageSourceSearch

https://boostconcept.vercel.app/assets/AppPerfil-BOMplwhH.js

js boostconcept.vercel.app collected 2026-10-03 06:18:09 UTC 31,750 bytes, 6 lines download raw bytes

1import{s as as,J as ts,a2 as rs,a as i,a3 as ns,t as R,a4 as S,a_ as Re,a$ as os,a7 as De,a9 as g,ae as is,j as e,K as L,a0 as D,b0 as ls,b1 as ds,L as Le,aX as cs,a8 as us,b2 as qe,b3 as ps,T as l,v as m,aO as ne,aP as oe,aQ as ie,aR as le,b4 as ms,b5 as xs,O as Be,S as We,b6 as Fe,ad as b,b7 as hs}from"./crm/crm-Z7_lJbHh.js";import{A as fs}from"./AppNavbar-BR_wJoOs.js";import{B as gs}from"./BadgesSection-xnSSd6J3.js";import{C as bs}from"./checkbox-BsswrX6e.js";import{u as ys}from"./usePushNotifications-Bp1pwMuG.js";import{u as ws}from"./PwaInstallBanner-BOHB-cid.js";import{C as js}from"./CancelBookingDialog-D9lhld66.js";import{i as Ns}from"./phone-DRNKUjlS.js";import{a as vs,f as Te,W as F,i as _s}from"./wellhub-D_fhhAgM.js";const ks="https://cal.eu/carlaboost",T={gold:"Gold — 8 clases grupales/mes",diamond_plus:"Diamond+ — 8 grupales + 8 personal 4p/mes"},Ue={female:"Femenino",male:"Masculino",prefer_not_to_say:"Prefiero no decirlo"},Es={grupal:"Grupal",personal_1to1:"Entrenamiento personal",personal_4pers:"Grupo 4 personas",duo:"Dúo",welcome_pack:"Welcome Pack",sesion_suelta:"Sesión suelta",sesion_suelta_socio:"Sesión suelta (socio PT)",summer_shock:"Summer Shock",nutricion_presencial:"Nutrición presencial",nutricion_online:"Nutrición online"},Qe="boost.app.notif";function Cs(){try{const t=localStorage.getItem(Qe);if(t)return{reminder1h:!0,forceWeights:!0,bonoExpiry:!0,...JSON.parse(t)}}catch{}return{reminder1h:!0,forceWeights:!0,bonoExpiry:!0}}function Ts(){var Ne,ve,_e,ke,Ee,Ce,Se,Ae,Pe;const{user:t,logout:y}=as(),x=ts(),r=rs(),[w,E]=i.useState("bonos"),[o,f]=i.useState({first_name:"",last_name:"",email:"",phone:"",postal_code:"",birth_date:"",sex:"",dni:"",wellhub_id:""}),[P,U]=i.useState(!1),[ce,Ke]=i.useState("gold"),[ue,Q]=i.useState(null),[pe,I]=i.useState(null),[$e,O]=i.useState(!1),[j,V]=i.useState(()=>Cs()),u=ys(),v=ws(),[He,me]=i.useState(!1),{tiers:xe}=ns(),[K,$]=i.useState(null),[Ge,H]=i.useState(!1),[C,G]=i.useState({a:"",b:""}),[z,ze]=i.useState(!1),[Y,Ye]=i.useState(!1);i.useEffect(()=>{try{localStorage.setItem(Qe,JSON.stringify(j))}catch{}},[j]);const c=R({queryKey:["users","me",t==null?void 0:t.id],queryFn:async()=>{if(!t)return null;const{data:s,error:a}=await m.from("users").select("id,first_name,last_name,email,phone,role,status,created_at,postal_code,birth_date,sex,dni,wellhub_id,wellhub_tier").eq("id",t.id).single();if(a)throw a;return s},enabled:!!t});i.useEffect(()=>{c.data&&(f({first_name:c.data.first_name??"",last_name:c.data.last_name??"",email:c.data.email??"",phone:c.data.phone??"",postal_code:c.data.postal_code??"",birth_date:c.data.birth_date??"",sex:c.data.sex??"",dni:c.data.dni??"",wellhub_id:c.data.wellhub_id??""}),U(!!c.data.wellhub_id))},[c.data]);const _=R({queryKey:["user_plans","history",t==null?void 0:t.id],queryFn:async()=>{if(!t)return[];const{data:s,error:a}=await m.from("user_plans").select(`id, status, classes_total, classes_remaining, activated_at, expires_at, is_lifetime,
2                 plans:plan_id ( name, plan_type ),
3                 payments:payment_id ( amount )`).eq("user_id",t.id).order("activated_at",{ascending:!1});if(a)throw a;return s??[]},enabled:!!t}),q=R({queryKey:["wellhub","status",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:a}=await m.rpc("my_wellhub_status");if(a)throw a;return s??{}},enabled:!!t}),J=S({mutationFn:async()=>{const{data:s,error:a}=await m.functions.invoke("grant-wellhub-plan",{body:{}});if(a)throw a;if((s==null?void 0:s.ok)===!1)throw new Error(s.reason==="invalid_wellhub_id"?`${F} Corrígelo aquí arriba y pulsa GUARDAR.`:"Tu bono de Wellhub sigue activo. Podrás renovarlo cuando caduque.");return s},onSuccess:async()=>{l.success("Bono de Wellhub renovado"),await Promise.all([r.invalidateQueries({queryKey:["wellhub","status",t==null?void 0:t.id]}),r.invalidateQueries({queryKey:["user_plans"]})])},onError:s=>l.error(s instanceof Error?s.message:"No se pudo renovar tu bono de Wellhub")}),B=S({mutationFn:async()=>{const{data:s,error:a}=await m.functions.invoke("revoke-wellhub-plan",{body:{}});if(a)throw a;if((s==null?void 0:s.ok)===!1)throw new Error(s.reason==="in_use"?"Ya has usado este bono, así que no se puede eliminar. Escríbenos a [email protected].":"No tienes ningún bono de Wellhub activo que eliminar.");return s},onSuccess:async()=>{O(!1),U(!1),f(s=>({...s,wellhub_id:""})),I(null),l.success("Bono de Wellhub eliminado"),await Promise.all([r.invalidateQueries({queryKey:["users","me"]}),r.invalidateQueries({queryKey:["wellhub","status"]}),r.invalidateQueries({queryKey:["user_plans"]})])},onError:s=>{O(!1),l.error(s instanceof Error?s.message:"No se pudo eliminar tu bono de Wellhub")}}),M=R({queryKey:["bookings","history",t==null?void 0:t.id],queryFn:async()=>
3{if(!t)return[];const{data:s,error:a}=await m.from("bookings").select(`id, status, cancelled_at, booked_at, user_plan_id,
4                 user_plans:user_plan_id ( plans:plan_id ( name ) ),
5                 class_sessions:class_session_id ( starts_at,
6                   class_types:class_type_id ( name ) )`).eq("user_id",t.id).order("booked_at",{ascending:!1}).limit(50);if(a)throw a;return s??[]},enabled:!!t}),X=S({mutationFn:async()=>{if(!t)throw new Error("No authenticated user");const s=o.phone.trim();if(s&&!Ns(s))throw Q("Formato no válido. Ej: 612 345 678"),new Error("phone");if(Q(null),P&&!_s(o.wellhub_id))throw I(F),new Error("wellhub_id");I(null);const{error:a}=await m.from("users").update({first_name:o.first_name.trim(),last_name:o.last_name.trim(),phone:s||null,postal_code:o.postal_code.trim()||null,birth_date:o.birth_date||null,sex:o.sex||null,dni:o.dni.trim()||null,...P?{platform:"gympass",wellhub_id:Te(o.wellhub_id)||null}:{wellhub_id:null}}).eq("id",t.id);if(a)throw a;if(P&&!k){const{data:n,error:d}=await m.functions.invoke("grant-wellhub-plan",{body:{tier:ce}});d?l.error("Perfil guardado, pero no se pudo activar tu bono de Wellhub. Contacta con nosotros."):(n==null?void 0:n.ok)===!1&&n.reason==="invalid_wellhub_id"&&(I(F),l.error(`Perfil guardado, pero el bono no se ha activado. ${F}`))}},onSuccess:async()=>{l.success("Perfil actualizado"),await r.invalidateQueries({queryKey:["users","me"]}),await r.invalidateQueries({queryKey:["user_plans"]}),await r.invalidateQueries({queryKey:["wellhub","status"]})},onError:s=>{s instanceof Error&&(s.message==="phone"||s.message==="wellhub_id")||l.error(s instanceof Error?s.message:"Error al actualizar")}}),Z=S({mutationFn:async()=>{if(C.a.length<8)throw new Error("Mínimo 8 caracteres");if(C.a!==C.b)throw new Error("Las contraseñas no coinciden");const{error:s}=await m.auth.updateUser({password:C.a});if(s)throw s},onSuccess:()=>{l.success("Contraseña actualizada"),H(!1),G({a:"",b:""})},onError:s=>l.error(s instanceof Error?s.message:"Error")}),ee=S({mutationFn:async s=>{const{error:a}=await m.from("bookings").update({status:"cancelled"}).eq("id",s).eq("user_id",t.id);if(a)throw a},onSuccess:async()=>{l.success("Reserva cancelada"),await r.invalidateQueries({queryKey:["bookings"]})},onError:s=>l.error(s instanceof Error?s.message:"Error")}),[As,Ps]=i.useState(null),[Is,Je]=i.useState({exercise:"",weight:"",reps:"3"});R({queryKey:["workout_logs",t==null?void 0:t.id],queryFn:async()=>{if(!t)return[];const{data:s,error:a}=await m.from("workout_logs").select("id, exercise, weight_kg, reps, sets, logged_at").eq("user_id",t.id).order("logged_at",{ascending:!1}).limit(200);if(a)throw a;return s??[]},enabled:!!t}),S({mutationFn:async({exercise:s,weight_kg:a,reps:n})=>{if(!t)throw new Error("No autenticado");const{error:d}=await m.from("workout_logs").insert({user_id:t.id,exercise:s,weight_kg:a,reps:n,sets:1});if(d)throw d},onSuccess:async()=>{l.success("Peso guardado"),Je(s=>({...s,weight:"",reps:"3"})),await r.invalidateQueries({queryKey:["workout_logs"]})},onError:s=>l.error(s instanceof Error?s.message:"Error")});const N=new Date,he=_.data??[],fe=s=>s.status==="active"&&new Date(s.expires_at)>=N,p=he.find(s=>fe(s)&&Re(s)),ge=he.filter(s=>fe(s)&&!Re(s)),k=((Ne=q.data)==null?void 0:Ne.tier)??null,se=((ve=q.data)==null?void 0:ve.active_until)??null,be=((_e=q.data)==null?void 0:_e.last_expires_at)??null,Xe=!!k&&!se,Ze=!!((ke=q.data)!=null&&ke.can_revoke),ye=i.useMemo(()=>[..._.data??[]].sort((a,n)=>{const d=a.status==="active"&&new Date(a.expires_at)>=N?1:0,h=n.status==="active"&&new Date(n.expires_at)>=N?1:0;return d!==h?h-d:(n.activated_at??"").localeCompare(a.activated_at??"")}),[_.data]),we=i.useMemo(()=>os(_.data),[_.data]),je=(M.data??[]).filter(s=>{var a;return s.status==="confirmed"&&((a=s.class_sessions)==null?void 0:a.starts_at)&&new Date(s.class_sessions.starts_at)>=N}),ae=(M.data??[]).filter(s=>{var d;const a=(d=s.class_sessions)==null?void 0:d.starts_at;if(!(!a||new Date(a)<N))return!1;if(s.status==="cancelled"){if(!a)return!1;const h=s.cancelled_at??s.booked_at,W=(new Date(a).getTime()-new Date(h).getTime())/36e5;return!De(W,xe)}return!0}),es=i.useMemo(()=>{var a;const s={};for(const n of ae){const d=(a=n.class_sessions)!=null&&a.starts_at?new Date(n.class_sessions.starts_at):new Date(0),h=g(d,"MMMM yyyy",{locale:b}).toUpperCase();(s[h]||(s[h]=[])).push(n)}return s},[ae]),te=!!(p!=null&&p.is_lifetime),re=p&&!te?is(new Date(p.expires_at),N):null,
6ss=[{key:"bonos",label:"BONOS Y RESERVAS",wide:!0},{key:"logros",label:"LOGROS"},{key:"notif",label:"AVISOS"},{key:"datos",label:"DATOS"}];return e.jsxs("div",{className:"app-viewport bg-background app-content-pad app-shell",children:[e.jsx(fs,{}),e.jsxs("div",{className:"mx-auto max-w-lg px-4 app-content-top",children:[e.jsxs("header",{className:"pt-6",children:[e.jsxs("h1",{className:"font-display text-outline-ink text-6xl leading-[0.85] tracking-wide",children:["MI",e.jsx("br",{}),"PERFIL"]}),e.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:o.email}),((Ee=c.data)==null?void 0:Ee.created_at)&&e.jsxs("p",{className:"text-[10px] uppercase tracking-widest text-muted-foreground mt-1",children:["Booster desde ",g(new Date(c.data.created_at),"MMM yyyy",{locale:b})]})]}),e.jsx("div",{className:"mt-6 flex border border-foreground bg-card overflow-hidden",children:ss.map(s=>e.jsx("button",{onClick:()=>E(s.key),className:`min-w-0 whitespace-nowrap px-1.5 py-2 font-display text-[9px] tracking-wide xs:px-2 xs:text-[10px] xs:tracking-widest transition-colors ${s.wide?"flex-[2]":"flex-1"} ${w===s.key?"bg-foreground text-background":"text-foreground hover:bg-muted"}`,children:s.label},s.key))}),w==="datos"&&e.jsxs("section",{className:"mt-6 rounded-md border border-border bg-card p-5 space-y-3",children:[c.isLoading&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Cargando…"}),e.jsx(A,{label:"Nombre",value:o.first_name,onChange:s=>f(a=>({...a,first_name:s}))}),e.jsx(A,{label:"Apellidos",value:o.last_name,onChange:s=>f(a=>({...a,last_name:s}))}),e.jsx(A,{label:"Email",value:o.email,readOnly:!0}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-widest text-muted-foreground",children:"Teléfono"}),e.jsx(L,{value:o.phone,placeholder:"612 345 678",onChange:s=>{f(a=>({...a,phone:s.target.value})),Q(null)}}),ue&&e.jsx("p",{className:"mt-1 text-xs text-destructive",children:ue})]}),e.jsx(A,{label:"Código postal",value:o.postal_code,placeholder:"28001",onChange:s=>f(a=>({...a,postal_code:s}))}),e.jsx(A,{label:"DNI / NIE",value:o.dni,placeholder:"12345678A",onChange:s=>f(a=>({...a,dni:s}))}),e.jsx(A,{label:"Fecha de nacimiento",value:o.birth_date,placeholder:"AAAA-MM-DD",onChange:s=>f(a=>({...a,birth_date:s}))}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-widest text-muted-foreground",children:"Sexo"}),e.jsx("div",{className:"flex gap-2 mt-1",children:Object.keys(Ue).map(s=>e.jsx("button",{type:"button",onClick:()=>f(a=>({...a,sex:a.sex===s?"":s})),className:`flex-1 py-2 text-[10px] uppercase tracking-widest font-display border transition-colors ${o.sex===s?"bg-foreground text-background border-foreground":"text-foreground border-border hover:bg-muted"}`,children:Ue[s]},s))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-muted-foreground cursor-pointer select-none",children:[e.jsx(bs,{checked:P,onCheckedChange:s=>U(s===!0)}),"¿Vienes por Wellhub?"]}),P&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsx(L,{value:o.wellhub_id,onChange:s=>{f(a=>({...a,wellhub_id:Te(s.target.value)})),I(null)},placeholder:`Ej. ${vs}`,inputMode:"numeric",maxLength:16}),pe?e.jsx("p",{className:"text-[11px] text-destructive",children:pe}):e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Son 13 dígitos, tal y como salen en tu app de Wellhub."}),k?Xe?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Tu bono de Wellhub (",((Ce=T[k])==null?void 0:Ce.split(" — ")[0])??k,")",be?` caducó el ${g(new Date(be),"d MMM yyyy",{locale:b})}`:" ha caducado","."]}),e.jsx(D,{type:"button",variant:"outline",className:"w-full font-display text-[11px] tracking-widest",disabled:J.isPending,onClick:()=>J.mutate(),children:J.isPending?"RENOVANDO…":"RENOVAR BONO WELLHUB"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["✓ Bono Wellhub activo (",((Se=T[k])==null?void 0:Se.split(" — ")[0])??k,")",se?` hasta el ${g(new Date(se),"d MMM yyyy",{locale:b})}`:""]}),Ze&&e.jsx("button",{type:"button",onClick:()=>O(!0),className:"text-[11px] text-muted-foreground underline underline-offset-2 hover:text-destructive transition-colors",children:"Me he equivocado: eliminar el bono"})]}):e.jsx("div",{className:"space-y-1",children:Object.keys(T).map(s=>e.jsx("button",{type:"button",onClick:()=>Ke(s),className:`w-full text-left px-3 py-2 text-[11px] border rounded-md transition-colors ${ce===s?"bg-foreground text-background border-foreground":"text-foreground border-border hover:bg-muted"}`,children:T[s]},s))})]})]}),e.jsx(D,{onClick:()=>X.mutate(),disabled:X.isPending,className:"w-full font-display tracking-wider",children:X.isPending?"GUARDANDO…":"GUARDAR"}),e.jsx("button",{onClick:()=>H(!0),className:"w-full mt-2 px-4 py-2 font-display text-[11px] tracking-widest text-foreground border border-border hover:bg-muted transition-colors",children:"CAMBIAR CONTRASEÑA"}),!v.isStandalone&&(v.canPromptInstall||v.isIOS)&&e.jsxs("button",{onClick:()=>{v.canPromptInstall?v.promptInstall():me(!0)},className:"w-full mt-2 flex items-center justify-center gap-2 px-4 py-2 font-display text-[11px] tracking-widest text-foreground border border-border hover:bg-muted transition-colors",children:[e.jsx(ls,{className:"h-3.5 w-3.5"}),"INSTALAR APP"]}),e.jsxs("button",{onClick:async()=>{await y(),x("/login")},className:"w-full mt-2 flex items-center justify-center gap-2 px-4 py-2 font-display text-[11px] tracking-widest text-muted-foreground hover:text-destructive transition-colors",children:[e.jsx(ds,{className:"h-3.5 w-3.5"}),"CERRAR SESIÓN"]}),e.jsxs("nav",{className:"mt-8 flex items-center justify-center gap-3 text-[10px] uppercase tracking-widest text-muted-foreground
6/70",children:[e.jsx(Le,{to:"/app/legal/politica-de-privacidad",className:"hover:text-foreground transition-colors",children:"Privacidad"}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx(Le,{to:"/app/legal/aviso-legal",className:"hover:text-foreground transition-colors",children:"Aviso legal"})]})]}),w==="bonos"&&e.jsxs("section",{className:"mt-6 space-y-3",children:[e.jsx("h2",{className:"font-display text-[11px] tracking-[0.3em] text-muted-foreground",children:"BONO ACTIVO"}),!p&&e.jsxs("div",{className:"rounded-md border border-dashed border-border bg-card p-5",children:[e.jsx("p",{className:"font-display text-lg tracking-wide",children:"SIN BONO ACTIVO"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Compra un bono para empezar a reservar."}),e.jsx("button",{onClick:()=>x("/app/bonos"),className:"mt-4 inline-flex items-center gap-2 bg-foreground px-4 py-2.5 font-display text-sm tracking-wider text-background",children:"COMPRAR BONO"})]}),p&&e.jsxs("div",{className:"rounded-md border border-border bg-card p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-display text-2xl tracking-wide",children:(((Ae=p.plans)==null?void 0:Ae.name)??"BONO").toUpperCase()}),((Pe=p.plans)==null?void 0:Pe.plan_type)&&e.jsx("p",{className:"text-[10px] uppercase tracking-widest text-muted-foreground mt-0.5",children:Es[p.plans.plan_type]??p.plans.plan_type})]}),re!==null&&re<=7&&e.jsxs("span",{className:"text-[10px] uppercase tracking-widest font-bold px-2 py-1 bg-destructive text-destructive-foreground",children:["Expira en ",Math.max(0,re),"d"]})]}),e.jsx("p",{className:"mt-1 text-[11px] uppercase tracking-widest text-muted-foreground",children:te?"Vitalicio · sin caducidad":`Expira ${g(new Date(p.expires_at),"d MMM yyyy",{locale:b})}`}),e.jsx("p",{className:"mt-2 text-sm",children:te?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-display text-2xl text-foreground",children:"∞"}),e.jsx("span",{className:"text-muted-foreground",children:" clases"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-display text-2xl text-foreground",children:p.classes_remaining}),e.jsxs("span",{className:"text-muted-foreground",children:[" / ",p.classes_total," clases"]}
6)]})})]}),ge.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"mt-5 font-display text-[11px] tracking-[0.3em] text-muted-foreground",children:"NUTRICIÓN"}),ge.map(s=>{var a;return e.jsxs("div",{className:"rounded-md border border-border bg-card p-5",children:[e.jsx("p",{className:"font-display text-lg tracking-wide",children:(((a=s.plans)==null?void 0:a.name)??"PLAN DE NUTRICIÓN").toUpperCase()}),e.jsxs("p",{className:"mt-1 text-[11px] uppercase tracking-widest text-muted-foreground",children:["Contratado ",s.activated_at?g(new Date(s.activated_at),"d MMM yyyy",{locale:b}):"—"]}),e.jsx("a",{href:ks,target:"_blank",rel:"noopener noreferrer",className:"mt-3 inline-flex items-center gap-2 text-[11px] uppercase tracking-widest font-bold text-primary hover:underline",children:"Reservar consulta con Carla →"})]},s.id)})]}),e.jsx("h2",{className:"mt-5 font-display text-[11px] tracking-[0.3em] text-muted-foreground",children:"HISTORIAL"}),_.isLoading&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Cargando…"}),ye.length===0&&!_.isLoading&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Aún no has comprado bonos."}),ye.map(s=>{var n,d;const a=s.status==="active"&&new Date(s.expires_at)>=N;return e.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border bg-card px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-display text-sm tracking-wide truncate",children:(((n=s.plans)==null?void 0:n.name)??"Bono").toUpperCase()}),e.jsxs("p",{className:"text-[10px] uppercase tracking-widest text-muted-foreground",children:[s.activated_at?g(new Date(s.activated_at),"d MMM yyyy",{locale:b}):"—",((d=s.payments)==null?void 0:d.amount)!=null&&e.jsxs("span",{className:"ml-2",children:["· ",cs(s.payments.amount)]})]})]}),e.jsx("span",{className:`text-[10px] uppercase tracking-widest font-bold ${a?"text-primary":"text-muted-foreground"}`,children:a?"activo":s.status})]},s.id)}),e.jsx("h2",{className:"mt-5 font-display text-[11px] tracking-[0.3em] text-muted-foreground",children:"RESERVAS PRÓXIMAS"}),M.isLoading&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Cargando…"}),!M.isLoading&&je.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No tienes reservas futuras."}),je.map(s=>{var h,W,Ie;const a=(h=s.class_sessions)!=null&&h.starts_at?new Date(s.class_sessions.starts_at):null,n=a?us(a,N):0,d=a?De(n,xe):!1;return e.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border bg-card px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-display text-sm tracking-wide truncate",children:(((Ie=(W=s.class_sessions)==null?void 0:W.class_types)==null?void 0:Ie.name)??"Clase").toUpperCase()}),e.jsx("p",{className:"text-[10px] uppercase tracking-widest text-muted-foreground",children:a?g(a,"EEE d MMM · HH:mm",{locale:b}):"—"}),e.jsx(Ve,{b:s,show:we})]}),e.jsx("button",{onClick:()=>{var Oe,Me;if(d||!a){ee.mutate(s.id);return}$({bookingId:s.id,className:((Me=(Oe=s.class_sessions)==null?void 0:Oe.class_types)==null?void 0:Me.name)??"Clase",when:g(a,"EEE d MMM · HH:mm",{locale:b}),hoursUntilStart:n})},disabled:ee.isPending,className:"ml-3 text-[10px] uppercase tracking-widest font-bold text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50",children:d?"Cancelar":"Cancelar · sin reembolso"})]},s.id)}),e.jsx("h2",{className:"mt-5 font-display text-[11px] tracking-[0.3em] text-muted-foreground",children:"RESERVAS PASADAS"}),!M.isLoading&&ae.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sin reservas pasadas."}),Object.entries(es).map(([s,a])=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-display text-[10px] tracking-[0.3em] text-muted-foreground pt-2",children:s}),a.map(n=>e.jsx(Ss,{b:n,past:!0,showPlan:we},n.id))]},s))]}),w==="logros"&&e.jsx(gs,{userId:t==null?void 0:t.id}),w==="notif"&&e.jsxs("section",{className:"mt-6 space-y-4",children:[v.needsSafariForInstall&&e.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-4 flex items-start gap-3",children:[e.jsx(qe,{className:"h-5 w-5 text-destructive shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-display text-sm tracking-wide",children:"AVISOS NO DISPONIBLES AQUÍ"}),e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:['Instalando desde este navegador las notificaciones no van a funcionar — ni siquiera la más importante, el aviso de que se liberó un hueco en lista de espera. Este navegador puede dejarte "activarlas" pero nunca van a llegar. En iPhone, las notificaciones solo funcionan si instalas la a
6pp desde Safari: abre'," ",e.jsx("span",{className:"font-medium",children:"boostconcept.es"})," ahí e instálala desde ese navegador."]})]})]}),u.supported&&!u.subscribed&&u.status!=="denied"&&e.jsxs("div",{className:"rounded-md border border-primary/30 bg-primary/5 p-4 flex items-start gap-3",children:[e.jsx(ps,{className:"h-5 w-5 text-primary shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-display text-sm tracking-wide",children:"ACTIVAR AVISOS"}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:"Recibe recordatorios de clases, pesos y bono directamente en tu dispositivo."}),e.jsx("button",{onClick:async()=>{await u.subscribe(j)?l.success("Avisos activados"):l.error("No se pudieron activar los avisos")},className:"mt-3 px-4 py-2 bg-primary text-white font-display text-[11px] tracking-wider",children:"ACTIVAR"})]})]}),u.status==="denied"&&e.jsxs("div",{className:"rounded-md border border-border bg-card p-4 flex items-center gap-3",children:[e.jsx(qe,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Los avisos están bloqueados en tu navegador. Actívalos desde Ajustes del navegador."})]}),e.jsxs("div",{className:"rounded-md border border-border bg-card p-5 space-y-4",children:[e.jsx(de,{label:"Recordatorio 1h antes",hint:"Para ir cerrando temas y prepararme",checked:j.reminder1h,onChange:async s=>{const a={...j,reminder1h:s};V(a),u.subscribed&&await u.updatePrefs(a)}}),e.jsx("div",{className:"h-px bg-border"}),e.jsx(de,{label:"Registrar pesos tras FORCE",hint:"Recordatorio al terminar cada clase Force para apuntar tus marcas",checked:j.forceWeights,onChange:async s=>{const a={...j,forceWeights:s};V(a),u.subscribed&&await u.updatePrefs(a)}}),e.jsx("div",{className:"h-px bg-border"}),e.jsx(de,{label:"Bono por expirar",hint:"Aviso el día que vence tu bono para que no pierdas clases",checked:j.bonoExpiry,onChange:async s=>{const a={...j,bonoExpiry:s};V(a),u.subscribed&&await u.updatePrefs(a)}}),(u.subscribed||u.status==="granted")&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-px bg-border"}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("button",{onClick:async()=>{try{const{data:s,error:a}=await m.functions.invoke("send-push-notifications",{body:{type:"test",user_id:t==null?void 0:t.id}});if(a)throw a;(s==null?void 0:s.sent)>0?l.success("Notificación enviada — debería llegar en segundos"):l.error(`No llegó (sent=0, errors=${(s==null?void 0:s.errors)??"?"}). Revisa los secrets VAPID en Supabase.`)}catch(s){l.error(`Error: ${s instanceof Error?s.message:String(s)}`)}},className:"text-[10px] uppercase tracking-widest text-primary hover:opacity-70 transition-opacity",children:"Enviar aviso de prueba"}),e.jsx("button",{onClick:async()=>{await u.unsubscribe(),l.success("Avisos desactivados")},className:"text-[10px] uppercase tracking-widest text-muted-foreground hover:text-destructive transition-colors",children:"Desactivar"})]})]})]})]})]}),e.jsx(ne,{open:He,onOpenChange:me,children:e.jsxs(oe,{className:"max-w-sm",children:[e.jsx(ie,{children:e.jsx(le,{children:"Instalar la app"})}),v.needsSafariForInstall?e.jsxs("div",{className:"space-y-4 text-sm text-foreground",children:[e.jsxs("p",{children:["Estás usando un navegador que no es Safari. Instalando desde aquí las notificaciones"," ",e.jsx("span",{className:"font-medium",children:"no van a funcionar"})," — ni siquiera la más importante, el aviso de que se liberó un hueco en lista de espera. En iPhone, solo Safari puede instalar la app correctamente y recibirlas."]}),e.jsxs("p",{children:["Copia el enlace ",e.jsx("span",{className:"font-medium",children:"boostconcept.es"})," y ábrelo en Safari para instalarla desde ahí."]})]}):e.jsxs("div",{className:"space-y-4 text-sm text-foreground",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary/10 font-display text-xs text-primary",children:"1"}),e.jsxs("p",{children:["Haz clic en el icono de ",e.jsx(ms,{className:"inline h-4 w-4 -mt-0.5","aria-label":"Compartir"})," compartir en la barra de Safari"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary/10 font-display text-xs text-primary",children:"2"}),e.jsxs("p",{children:["Elige ",e.jsxs("span",{className:"inline-flex items-center gap-0.5 font-medium",children:[e.jsx(xs,{className:"h-4 w-4"}),"Agregar a pantalla de inicio"]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary/10 font-display text-xs text-primary",children:"3"}),e.jsx("p",{children:'Confirma tocando "Añadir" — listo, ya tienes el icono en tu pantalla de inicio'})]})]})]})}),e.jsx(ne,{open:Ge,onOpenChange:H,children:e.jsxs(oe,{className:"max-w-sm",children:[e.jsx(ie,{children:e.jsx(le,{children:"Cambiar contraseña"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-widest text-muted-foreground",children:"Nueva contraseña"}),e.jsxs("div",{className:"relative",children:[e.jsx(L,{type:z?"text":"password",value:C.a,onChange:s=>G(a=>({...a,a:s.target.value})),className:"pr-10"}),e.jsx("button",{type:"button",onClick:()=>ze(s=>!s),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":z?"Ocultar contraseña":"Mostrar c
6ontraseña",tabIndex:-1,children:z?e.jsx(Be,{className:"h-4 w-4"}):e.jsx(We,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-widest text-muted-foreground",children:"Confirmar"}),e.jsxs("div",{className:"relative",children:[e.jsx(L,{type:Y?"text":"password",value:C.b,onChange:s=>G(a=>({...a,b:s.target.value})),className:"pr-10"}),e.jsx("button",{type:"button",onClick:()=>Ye(s=>!s),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":Y?"Ocultar contraseña":"Mostrar contraseña",tabIndex:-1,children:Y?e.jsx(Be,{className:"h-4 w-4"}):e.jsx(We,{className:"h-4 w-4"})})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Mínimo 8 caracteres."})]}),e.jsx(Fe,{children:e.jsx(D,{onClick:()=>Z.mutate(),disabled:Z.isPending,className:"w-full font-display tracking-wider",children:Z.isPending?"GUARDANDO…":"ACTUALIZAR"})})]})}),e.jsx(ne,{open:$e,onOpenChange:O,children:e.jsxs(oe,{className:"max-w-sm",children:[e.jsx(ie,{children:e.jsx(le,{children:"¿Eliminar tu bono de Wellhub?"})}),e.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:"Se borrará el bono que se te cargó al marcar «¿Vienes por Wellhub?», y tu perfil dejará de figurar c
6omo socio de Wellhub."}),e.jsx("p",{children:"Puedes volver a activarlo cuando quieras: marca otra vez la casilla, escribe tu ID de Wellhub y elige tu plan."})]}),e.jsxs(Fe,{className:"gap-2 sm:gap-2",children:[e.jsx(D,{variant:"outline",onClick:()=>O(!1),disabled:B.isPending,className:"w-full font-display tracking-wider",children:"CANCELAR"}),e.jsx(D,{variant:"destructive",onClick:()=>B.mutate(),disabled:B.isPending,className:"w-full font-display tracking-wider",children:B.isPending?"ELIMINANDO…":"ELIMINAR BONO"})]})]})}),e.jsx(js,{cancellation:K,refundable:!1,onDismiss:()=>$(null),onConfirm:()=>{K&&(ee.mutate(K.bookingId),$(null))}})]})}function A({label:t,value:y,onChange:x,readOnly:r,placeholder:w}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-widest text-muted-foreground",children:t}),e.jsx(L,{value:y,readOnly:r,placeholder:w,onChange:x?E=>x(E.target.value):void 0})]})}function Ve({b:t,show:y}){var x,r;return!y||!t.user_plan_id?null:e.jsxs("p",{className:"text-[10px] tracking-wide text-muted-foreground/80 truncate mt-0.5",children:["Pagada con ",((r=(x=t.user_plans)==null?void 0:x.plans)==null?void 0:r.name)??"tu bono"]})}function Ss({b:t,past:y,showPlan:x}){var o;
6const r=t.class_sessions,w=(((o=r==null?void 0:r.class_types)==null?void 0:o.name)??"Clase").toUpperCase(),E=r!=null&&r.starts_at?new Date(r.starts_at):null;return e.jsxs("div",{className:`flex items-center justify-between rounded-md border border-border bg-card px-4 py-3 ${y?"opacity-70":""}`,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-display text-sm tracking-wide truncate",children:w}),e.jsx("p",{className:"text-[10px] uppercase tracking-widest text-muted-foreground",children:E?g(E,"EEE d MMM · HH:mm",{locale:b}):"—"}),e.jsx(Ve,{b:t,show:!!x})]}),e.jsx("span",{className:`text-[10px] uppercase tracking-widest font-bold ${t.status==="confirmed"?"text-primary":t.status==="cancelled"?"text-destructive":"text-muted-foreground"}`,children:t.status})]})}function de({label:t,hint:y,checked:x,onChange:r}){return e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-display text-sm tracking-wide",children:t.toUpperCase()}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:y})]}),e.jsx(hs,{checked:x,onCheckedChange:r})]})}export{Ts 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.