1import{r as g,j as e}from"./react-vendor-CQHeQYbW.js";import{g as I,s as p}from"./index-03QIdqbv.js";import{u as q}from"./useProfile-CpYxP6KX.js";import{t as G}from"./sonner-shim-BMbR3fw5.js";import{G as L}from"./GeometricAvatar-BA2XmCgO.js";import{x as _,R as O,Z as w,aI as k,bs as T,w as K,a8 as M,v as U,G as V}from"./icons-vendor-xkjWahXw.js";import"./query-vendor-BGWRfI-9.js";import"./radix-vendor-DQ2ldzOa.js";import"./supabase-vendor-CTvjDBex.js";const A={dj:"DJ / Artista",rookie:"DJ Promesa",staff:"Camarero",azafata:"Azafata",event_manager:"Encargada Eventos",promotor:"Promotor",camarero:"Camarero",catering:"Catering",makeup:"Maquillaje",peluqueria:"PeluquerÃa a Domicilio",media:"Media / Foto",empresario:"Empresario"},F={dj:"#4285F4",rookie:"#FBBF24",staff:"#34D399",azafata:"#F472B6",event_manager:"#34D399",promotor:"#38BDF8",camarero:"#FB923C",catering:"#F472B6",makeup:"#F472B6",peluqueria:"#EC4899",media:"#A78BFA",empresario:"#D4AF37"},ae=()=>{const{user:u}=I(),{allProfiles:i,subscription_tier:b,switchProfile:C,profileId:P}=q(),[n,z]=g.useState([]),[c,f]=g.useState(!0),[j,v]=g.useState(null),h=b==="agency"||b==="elite";g.useEffect(()=>{if(!u||!h||i.length===0){f(!1);return}N()},[u,i,h]);const N=async()=>{f(!0);const s=i.map(l=>l.id),r=(await p.from("flash_bookings").select("professional_user_id, status, agreed_price").eq("professional_user_id",u.id)).data??[],o={};await Promise.all(i.filter(l=>l.role==="rookie").map(async l=>{const{data:t}=await p.rpc("get_vote_count",{p_profile_id:l.id});o[l.id]=t??0}));const y=i.map(l=>{const t=r.filter(d=>d.professional_user_id===u.id);return{id:l.id,display_name:l.display_name,role:l.role,photo_url:l.photo_url,zone:null,hourly_rate:0,is_live:!1,is_primary:l.is_primary,flashCount:t.length,flashPending:t.filter(d=>d.status==="pending").length,voteCount:o[l.id]??0,flashRevenue:t.reduce((d,B)=>d+(B.agreed_price??0),0)}}),{data:S}=await p.from("profiles").select("id, zone, is_live, hourly_rate").in("id",s);(S??[]).forEach(l=>{const t=y.find(d=>d.id===l.id);t&&(t.zone=l.zone,t.is_live=l.is_live,t.hourly_rate=l.hourly_rate)}),z(y),f(!1)},R=async s=>{v(s),await C(s),v(null),G.success("Perfil activo cambiado")};if(!h)return e.jsxs("div",{className:"animate-[fadeIn_0.4s_ease]",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("h2",{className:"text-2xl font-bold mb-1",children:["Panel de ",e.jsx("span",{className:"text-gradient",children:"Agencia"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Gestión centralizada de hasta 5 perfiles profesionales."})]}),e.jsxs("div",{className:"glass-panel p-10 flex flex-col items-center text-center gap-5",style:{border:"1px solid rgba(212,175,55,0.2)"},children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl flex items-center justify-center",style:{background:"linear-gradient(135deg,#D4AF37,#B8941E)",color:"#000"},children:e.jsx(_,{size:28})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-black mb-1",children:"Panel de Agencia"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-sm mx-auto leading-relaxed",children:"El Panel de Agencia permite gestionar hasta 5 perfiles con roles distintos desde un único punto de control. KPIs consolidados, cambio de perfil instantáneo y Sello Agencia exclusivo."})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3 w-full max-w-sm",children:["5 perfiles activos","KPIs consolidados","Sello Agencia"].map(s=>e.jsx("div",{className:"p-3 rounded-xl text-center text-xs font-bold",style:{background:"rgba(212,175,55,0.06)",border:"1px solid rgba(212,175,55,0.12)",color:"#8A6D0F"},children:s},s))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Contacta con el equipo de XPEAK para activar el acceso de agencia."})]})]});const D=n.reduce((s,a)=>s+a.flashCount,0),E=n.reduce((s,a)=>s+a.flashPending,0),m=n.reduce((s,a)=>s+a.flashRevenue,0),$=n.filter(s=>s.is_live).length,x=[...n].sort((s,a)=>a.flashCount-s.flashCount)[0];return e.jsxs("div",{className:"animate-[fadeIn_0.4s_ease] space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-2xl font-bold mb-1",children:["Panel de ",e.jsx("span",{className:"text-gradient",children:"Agencia"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[i.length," perfiles activos · Gestión centralizada"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs font-bold",style:{background:"linear-gradient(90deg,rgba(212,175,55,0.15),rgba(184,148,30,0.1))",border:"1px solid rgba(212,175,55,0.3)",color:"#8A6D0F"},children:[e.jsx(_,{size:12})," SELLO AGENCIA"]}),e.jsx("button",{onClick:N,className:"p-2 rounded-lg transition-all hover:scale-105",style:{background:"rgba(0,0,0,0.04)",border:"1px solid rgba(0,0,0,0.08)"},children:e.jsx(O,{size:13,style:{color:"#3d3d4e"}})})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[{label:"Flash Bookings",value:c?"â":D,sub:`${E} pendientes`,icon:e.jsx(w,{size:16}),color:"#8A6D0F"},{label:"Ingresos registrados",value:c?"â":`â¬${m.toFixed(0)}`,sub:"caché acordado total",icon:e.jsx(k,{size:16}),color:"#4285F4"},{label:"En directo ahora",value:c?"â":$,sub:`de ${i.length} perfiles`,icon:e.jsx(T,{size:16}),color:"#ef4444"}].map(s=>e.jsxs("div",{className:"glass-panel p-4",style:{border:`1px solid ${s.color}18`},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-[0.65rem] font-bold uppercase tracking-widest text-muted-foreground",children:s.label}),e.jsx("span",{style:{color:s.color},children:s.icon})]}),e.jsx("p",{className:"text-2xl font-black mb-0.5",style:{color:s.color},children:s.value}),e.jsx("p",{className:"text-[0.65rem] text-muted-foreground",children:s.sub})]},s.label))}),!c&&x&&x.flashCount>0&&e.jsxs("div",{className:"glass-panel p-4 flex items-center gap-4",style:{border:"1px solid rgba(212,175,55,0.2)",background:"rgba(212,175,55,0.03)"},children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:"linear-gradient(135deg,#D4AF37,#B8941E)",color:"#000"},children:e.jsx(K,{size:16,fill:"#000"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-wider mb-0.5",style:{color:"rgba(212,175,55,0.6)"},children:"Perfil más activo"}),e.jsx("p",{className:"font-black truncate",children:x.display_name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[x.flashCount," bookings · ",A[x.role]??x.role]})]}),e.jsx(M,{size:20,style:{color:"#8A6D0F",flexShrink:0}})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-widest text-muted-foreground mb-3",children:"Perfiles de la agencia"}),c?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:i.map((s,a)=>e.jsxs("div",{className:"glass-panel p-4 animate-pulse",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"h-3 bg-white/5 rounded mb-1.5 w-3/4"}),e.jsx("div",{className:"h-2 bg-white/5 rounded w-1/2"})]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:[...Array(3)].map((r,o)=>e.jsx("div",{className:"h-10 bg-white/5 rounded-lg"},o))})]},a))}):e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[n.map(s=>{const a=F[s.role]??"#D4AF37",r=s.id===P;return e.jsxs("div",{className:"glass-panel p-4 transition-all",style:{border:r?`1px solid ${a}40`:"1px solid rgba(0,0,0,0.05)",background:r?`${a}06`:void 0},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(L,{name:s.display_name,size:40,photoUrl:s.photo_url??void 0}),s.is_live&&e.jsx("span",{className:"absolute -top-1 -right-1 w-3 h-3 rounded-full bg-red-500 border-2 border-black animate-pulse"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsx("p",{className:"text-sm font-bold truncate",children:s.display_name}),r&&e.jsx("span",{className:"text-[0.55rem] font-bold px-1.5 py-0.5 rounded-full flex-shrink-0",style:{background:`${a}20`,color:a,border:`1px solid ${a}40`},children:"ACTIVO"})]}),e.jsx("p",{className:"text-xs truncate",style:{color:a},children:A[s.role]??s.role}),s.zone&&e.jsx("p",{className:"text-[0.65rem] text-muted-foreground truncate",children:s.zone})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2 mb-3",children:[{label:"Bookings",value:s.flashCount,color:"#8A6D0F"},{label:"Votos",value:s.role==="rookie"?s.voteCount:"â",color:"#4285F4"}].map(o=>e.jsxs("div",{className:"rounded-lg p-2 text-center",style:{background:"rgba(0,0,0,0.03)",border:"1px solid rgba(0,0,0,0.05)"},children:[e.jsx("p",{className:"text-sm font-black",style:{color:o.color},children:o.value}),e.jsx("p",{className:"text-[0.6rem] text-muted-foreground",children:o.label})]},o.label))}),s.flashPending>0&&e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 rounded-lg mb-3 text-xs font-bold",style:{background:"rgba(212,175,55,0.08)",border:"1px solid rgba(212,175,55,0.2)",color:"#8A6D0F"},children:[e.jsx(w,{size:11})," ",s.flashPending," booking",s.flashPending>1?"s":""," pendiente",s.flashPending>1?"s":""]}),!r&&e.jsx("button",{onClick:()=>
1R(s.id),disabled:j===s.id,className:"w-full flex items-center justify-center gap-2 py-2 rounded-lg text-xs font-bold transition-all hover:scale-[1.02] disabled:opacity-50",style:{background:`${a}12`,border:`1px solid ${a}25`,color:a},children:j===s.id?"Cambiando...":e.jsxs(e.Fragment,{children:["Cambiar a este perfil ",e.jsx(U,{size:11})]})}),r&&e.jsx("div",{className:"w-full flex items-center justify-center gap-2 py-2 rounded-lg text-xs font-bold",style:{background:`${a}08`,border:`1px solid ${a}20`,color:`${a}80`},children:"Perfil activo ahora"})]},s.id)}),Array.from({length:Math.max(0,5-i.length)}).map((s,a)=>e.jsxs("div",{className:"glass-panel p-4 flex flex-col items-center justify-center gap-2 text-center",style:{border:"1px dashed rgba(0,0,0,0.05)",minHeight:180},children:[e.jsx("div",{className:"w-8 h-8 rounded-xl flex items-center justify-center",style:{background:"rgba(0,0,0,0.03)",border:"1px solid rgba(0,0,0,0.05)"},children:e.jsx(V,{size:14,style:{color:"rgba(0,0,0,0.1)"}})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Slot disponible"}),e.jsx("p",{className:"text-[0.65rem] text-muted-foreground",children:"Crea un nuevo perfil en Ajustes"})]},`empty-${a}`))]})]}),!c&&m>0&&e.jsxs("div",{className:"glass-panel p-5",children:[e.jsxs("p",{className:"text-xs font-bold uppercase tracking-widest text-muted-foreground mb-4 flex items-center gap-2",children:[e.jsx(k,{size:12,style:{color:"#8A6D0F"}})," Ingresos por perfil"]}),e.jsx("div",{className:"space-y-2",children:n.filter(s=>s.flashRevenue>0).sort((s,a)=>a.flashRevenue-s.flashRevenue).map(s=>{const a=m>0?s.flashRevenue/m*100:0,r=F[s.role]??"#D4AF37";return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("p",{className:"text-xs w-28 truncate font-bold",style:{color:r},children:s.display_name}),e.jsx("div",{className:"flex-1 h-2 rounded-full overflow-hidden",style:{background:"rgba(0,0,0,0.05)"},children:e.jsx("div",{className:"h-full rounded-full transition-all duration-700",style:{width:`${a}%`,background:r}})}),e.jsxs("p",{className:"text-xs font-bold w-16 text-right",style:{color:r},children:["â¬",s.flashRevenue.toFixed(0)]})]},s.id)})}),e.jsxs("div",{className:"flex items-center justify-between mt-4 pt-3",style:{borderTop:"1px solid rgba(0,0,0,0.05)"},children:[e.jsx("p",{className:"text-xs font-bold text-muted-foreground",children:"Total agencia"}),e.jsxs("p",{className:"text-sm font-black",style:{color:"#22c55e"},children:["â¬",m.toFixed(2)]})]})]})]})};export{ae 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.