1import{c as Pe,n as qe,r as t,s as m,a as Re,v as De,j as e,t as x,a5 as ve,m as oe,u,X as se,e as Le,T as Ie,U as Ce}from"./index-DMRgbZm2.js";import{u as Je}from"./useFriends-Cs60YfpT.js";import{I as z}from"./input-05DN8RcK.js";import{T as _e}from"./textarea-DuaCKC_S.js";import{T as we,a as ke,b as J,c as $}from"./tabs-CpPabnqS.js";import{D as q,e as $e,a as T,b as M,c as E,d as de,f as me}from"./dialog-CTJ4xC4l.js";import{A as Ae}from"./arrow-left-k_C7nB0y.js";import{P as Ve}from"./plus-7841P1vC.js";import{S as xe}from"./swords-DTldCLcj.js";import{C as ue}from"./check-BVvbnuq-.js";import{S as pe}from"./share-2-WZc9L-Tc.js";import{C as Be}from"./crown-6clH7ck1.js";import{L as Fe}from"./log-out-BY0sOfJa.js";import{S as ae}from"./send-D-Lw4uxC.js";import{S as Se}from"./search-DD_rp3TB.js";import{C as ze}from"./copy-RnKrJiDH.js";import"./index-CE38CVHq.js";import"./index-Ba4C_T1S.js";import"./index-BUTuhxzg.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const he=Pe("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);function Ue(){const{profile:l}=qe(),[v,a]=t.useState([]),[y,O]=t.useState(null),[V,B]=t.useState(null),[F,U]=t.useState([]),[X,te]=t.useState([]),[H,P]=t.useState([]),[w,g]=t.useState([]),[_,k]=t.useState([]),[Q,j]=t.useState(!0),d=t.useCallback(async()=>{j(!0);const{data:i}=await m.from("clans").select("*").order("clan_points",{ascending:!1}).limit(50),r=i||[];if(r.length){const n=r.map(p=>p.id),{data:N}=await m.from("clan_members").select("clan_id").in("clan_id",n),b={};(N||[]).forEach(p=>{b[p.clan_id]=(b[p.clan_id]||0)+1}),r.forEach(p=>p.member_count=b[p.id]||0)}if(a(r),l){const{data:n}=await m.from("clan_members").select("*").eq("profile_id",l.id).maybeSingle();if(n){B(n);const{data:b}=await m.from("clans").select("*").eq("id",n.clan_id).maybeSingle();O(b||null);const{data:p}=await m.from("clan_members").select("*, profile:profiles(display_name, avatar, xp)").eq("clan_i
6d",n.clan_id);U(p||[]);const{data:ce}=await m.from("clan_challenges").select("*, challenger:clans!clan_challenges_challenger_clan_id_fkey(*), opponent:clans!clan_challenges_opponent_clan_id_fkey(*)").or(`challenger_clan_id.eq.${n.clan_id},opponent_clan_id.eq.${n.clan_id}`).order("created_at",{ascending:!1}).limit(20);if(k(ce||[]),n.role==="leader"||n.role==="officer"){const{data:Z}=await m.from("clan_invites").select("*, requester:profiles!clan_invites_to_profile_id_fkey(display_name, avatar, xp)").eq("clan_id",n.clan_id).eq("status","requested");P(Z||[])}else P([]);g([])}else{B(null),O(null),U([]),k([]),P([]);const{data:b}=await m.from("clan_invites").select("*, clan:clans(*)").eq("from_profile_id",l.id).eq("to_profile_id",l.id).eq("status","requested");g(b||[])}const{data:N}=await m.from("clan_invites").select("*, clan:clans(*)").eq("to_profile_id",l.id).neq("from_profile_id",l.id).eq("status","pending");te(N||[])}j(!1)},[l]);t.useEffect(()=>{l&&d()},[l,d]);const G=t.useCallback(async(i,r,n,N)=>{if(!l)return{success:!1,error:"Não autenticado"};const{data:b,error:p}=await m.rpc("create_clan",{p_profile_id:l.id,p_name:i,p_tag:r,p_description:n||null,p_emblem:N||"ð¡ï¸"});return p?{success:!1,error:p.message}:(await d(),b)},[l,d]),K=t.useCallback(async i=>{const{data:r,error:n}=await m.rpc("accept_clan_invite",{p_invite_id:i});return n?{success:!1,error:n.message}:(await d(),r)},[d]),C=t.useCallback(async i=>{await m.from("clan_invites").update({status:"declined"}).eq("id",i),await d()},[d]),R=t.useCallback(async i=>{if(!l||!y)return{success:!1,error:"Sem clã"};const{error:r}=await m.from("clan_invites").insert({clan_id:y.id,from_profile_id:l.id,to_profile_id:i});return r?{success:!1,error:r.message}:{success:!0}},[l,y]),W=t.useCallback(async()=>{if(!l)return{success:!1,error:"Não autenticado"};const{data:i,error:r}=await m.rpc("leave_clan",{p_profile_id:l.id});return r?{success:!1,error:r.message}:(await d(),i)},[l,d]),re=t.useCallback(async i=>{if(!l)return{success:!1,error:"Não autenticado"};const{data:r,error:n}=await m.rpc("join_clan_by_id",{p_profile_id:l.id,p_clan_id:i});return n?{success:!1,error:n.message}:(await d(),r)},[l,d]),D=t.useCallback(async i=>{const{data:r,error:n}=await m.rpc("find_clan_by_tag",{p_tag:i});return n?null:r&&r[0]||null},[]),ne=t.useCallback(async i=>{if(!i.trim()||!l)return[];const{data:r}=await m.from("profiles").select("id, display_name, avatar, xp").neq("id",l.id).ilike("display_name",`%${i}%`).limit(15);if(!r)return[];const n=r.map(p=>p.id),{data:N}=await m.from("clan_members").select("profile_id").in("profile_id",n),b=new Set((N||[]).map(p=>p.profile_id));return r.filter(p=>!b.has(p.id))},[l]),S=t.useCallback(async(i,r)=>{if(!l||!y)return{success:!1,error:"Sem clã"};const{error:n}=await m.from("clan_challenges").insert({challenger_clan_id:y.id,opponent_clan_id:i,proposed_by:l.id,message:r||null});return n?{success:!1,error:n.message}:(await d(),{success:!0})},[l,y,d]),le=t.useCallback(async(i,r)=>{await m.from("clan_challenges").update({status:r?"accepted":"declined"}).eq("id",i),await d()},[d]),Y=t.useCallback(async i=>{if(!l)return{success:!1,error:"Não autenticado"};const{data:r,error:n}=await m.rpc("request_join_clan",{p_profile_id:l.id,p_clan_id:i});return n?{success:!1,error:n.message}:(await d(),r)},[l,d]),L=t.useCallback(async i=>{const{data:r,error:n}=await m.rpc("approve_join_request",{p_invite_id:i});return n?{success:!1,error:n.message}:(await d(),r)},[d]),ie=t.useCallback(async i=>{const{data:r,error:n}=await m.rpc("decline_join_request",{p_invite_id:i});return n?{success:!1,error:n.message}:(await d(),r)},[d]),I=t.useCallback(async i=>{await m.from("clan_invites").delete().eq("id",i),await d()},[d]);return{clans:v,myClan:y,myMembership:V,members:F,invites:X,joinRequests:H,myPendingRequests:w,challenges:_,loading:Q,createClan:G,acceptInvite:K,declineInvite:C,inviteToClan:R,leaveClan:W,challengeClan:S,respondChallenge:le,joinByClanId:re,findClanByTag:D,searchPlayers:ne,requestJoinClan:Y,approveJoinRequest:L,declineJoinRequest:ie,cancelMyRequest:I,refresh:d}}const A=15,ms=()=>{var fe,je,be,ye;const l=Re(),{profile:v}=qe(),a=Ue(),{friends:y}=Je(),[O,V]=De(),[B,F]=t.useState(!1),[U,X]=t.useState(!1),[te,H]=t.useState(!1),[P,w]=t.useState(!1),[g,_]=t.useState(null),[k,Q]=t.useState(""),[j,d]=t.useState({name:"",tag:"",description:"",emblem:"ð¡ï¸"}),[G,K]=t.useState(""),[C,R]=t.useState(null),[W,re]=t.useState(0),[D,ne]=t.useState("friends"),[S,le]=t.useState(""),[Y,L]=t.useState([]),[ie,I]=t.useState(!1);t.useEffect(()=>{const s=O.get("join");s&&v&&!a.loading&&(async()=>{const{data:c}=await m.from("clans").select("*").eq("id",s).maybeSingle();if(c){_({...c,member_count:0});const{count:o}=await m.from("clan_members").select("*",{count:"exact",head:!0}
6).eq("clan_id",s);_(h=>({...h,member_count:o||0}))}V({},{replace:!0})})()},[O,v,a.loading,V]),t.useEffect(()=>{v&&(async()=>{const{count:s}=await m.from("match_history").select("*",{count:"exact",head:!0}).eq("profile_id",v.id);re(s||0)})()},[v]);const i=a.searchPlayers;t.useEffect(()=>{if(D!=="search")return;const s=S.trim();if(!s){L([]),I(!1);return}I(!0);const c=setTimeout(async()=>{try{const o=await i(s);L(o)}catch{L([])}finally{I(!1)}},350);return()=>clearTimeout(c)},[S,D,i]);const r=W>=A,n=((fe=a.myMembership)==null?void 0:fe.role)==="leader"||((je=a.myMembership)==null?void 0:je.role)==="officer",N=t.useMemo(()=>new Set(a.members.map(s=>s.profile_id)),[a.members]),b=t.useMemo(()=>y.filter(s=>!N.has(s.id)),[y,N]),p=async()=>{if(!r){u.error(`Você precisa de ${A} partidas para fundar um clã`);return}const s=await a.createClan(j.name,j.tag,j.description,j.emblem);s!=null&&s.success?(u.success("Clã criado!"),F(!1),d({name:"",tag:"",description:"",emblem:"ð¡ï¸"})):u.error((s==null?void 0:s.error)||"Erro ao criar clã")},ce=async()=>{if(!C)return;const s=await a.challengeClan(C.id,G);
6s!=null&&s.success?(u.success("Desafio enviado!"),R(null),K("")):u.error((s==null?void 0:s.error)||"Erro ao desafiar")},Z=async(s,c)=>{const o=await a.inviteToClan(s);o!=null&&o.success?u.success(`Convite enviado para ${c}!`):u.error((o==null?void 0:o.error)||"Erro ao convidar")},ee=a.myClan?`${window.location.origin}/clans?join=${a.myClan.id}`:"",ge=async()=>{try{await navigator.clipboard.writeText(ee),u.success("Link copiado!")}catch{u.error("Não foi possÃvel copiar")}},Te=async()=>{if(!a.myClan)return;const s=`Entra no meu clã "${a.myClan.name}" [${a.myClan.tag}] no Truco Arena! ${ee}`;if(navigator.share)try{await navigator.share({title:a.myClan.name,text:s,url:ee})}catch{}else ge()},Me=async()=>{if(a.myClan)try{await navigator.clipboard.writeText(a.myClan.tag),u.success(`Código [${a.myClan.tag}] copiado!`)}catch{}},Ee=async()=>{const s=k.trim().toUpperCase();if(!s)return;const c=await a.findClanByTag(s);if(!c){u.error("Nenhum clã com esse código");return}_(c),w(!1),Q("")},Oe=async()=>{if(!g)return;const s=await a.requestJoinClan(g.id);s!=null&&s.success?(u.success(`Solicitação enviada para ${g.name}! Aguarde aprovação do lÃder.`),_(null)):u.error((s==null?void 0:s.error)||"Erro ao solicitar")};return v?e.jsxs("div",{className:"min-h-screen bg-background pb-24",children:[e.jsxs("div",{className:"bg-card border-b border-border p-4 flex items-center justify-between sticky top-0 z-20",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>l("/home"),className:"text-muted-foreground hover:text-foreground",children:e.jsx(Ae,{size:24})}),e.jsxs("h1",{className:"font-display text-2xl text-gold tracking-wider flex items-center gap-2",children:[e.jsx(ve,{size:22})," CLÃS"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!a.myClan&&e.jsxs(x,{size:"sm",variant:"outline",className:"gap-1",onClick:()=>w(!0),children:[e.jsx(he,{size:14})," Código"]}),!a.myClan&&e.jsxs(q,{open:B,onOpenChange:F,children:[e.jsx($e,{asChild:!0,children:e.jsxs(x,{size:"sm",className:"gap-1",disabled:!r,children:[e.jsx(Ve,{size:16})," Criar"]})}),e.jsxs(T,{children:[e.jsx(M,{children:e.jsx(E,{children:"Fundar um Clã"})}),r?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Emblema"}),e.jsx(z,{value:j.emblem,onChange:s=>d({...j,emblem:s.target.value.slice(0,2)}),className:"text-2xl text-center w-20"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Nome do clã"}),e.jsx(z,{value:j.name,onChange:s=>d({...j,name:s.target.value.slice(0,30)}),placeholder:"Os Manilhas"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Tag (2-5 chars)"}),e.jsx(z,{value:j.tag,onChange:s=>d({...j,tag:s.target.value.toUpperCase().slice(0,5)}),placeholder:"MNL"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Descrição"}),e.jsx(_e,{value:j.description,onChange:s=>d({...j,description:s.target.value.slice(0,200)}),rows:2})]})]}):e.jsxs("div",{className:"text-center py-6",children:[e.jsxs("p",{className:"text-sm text-muted-foreground mb-2",children:["Você precisa ter jogado pelo menos ",e.jsxs("strong",{className:"text-foreground",children:[A," partidas"]})," para fundar um clã."]}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-4",children:["Você jogou ",W," de ",A," partidas."]}),e.jsxs(x,{onClick:()=>l("/lobby"),children:[e.jsx(xe,{size:16,className:"mr-1"})," Jogar agora"]})]}),e.jsx(de,{children:r&&e.jsx(x,{onClick:p,children:"Fundar Clã"})})]})]})]})]}),a.invites.length>0&&e.jsx("div",{className:"px-4 pt-4 space-y-2",children:a.invites.map(s=>{var c,o,h;return e.jsxs(oe.div,{initial:{y:-10,opacity:0},animate:{y:0,opacity:1},className:"bg-primary/10 border border-primary/30 rounded-xl p-3 flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:((c=s.clan)==null?void 0:c.emblem)||"ð¡ï¸"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-semibold text-foreground",children:["Convite: ",(o=s.clan)==null?void 0:o.name]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["[",(h=s.clan)==null?void 0:h.tag,"]"]})]}),e.jsx(x,{size:"sm",variant:"ghost",onClick:async()=>{const f=await a.acceptInvite(s.id);f!=null&&f.success?u.success("Bem-vindo ao clã!"):u.error((f==null?void 0:f.error)||"Erro")},children:e.jsx(ue,{size:16,className:"text-emerald-400"})}),e.jsx(x,{size:"sm",variant:"ghost",onClick:()=>a.declineInvite(s.id),children:e.jsx(se,{size:16,className:"text-red-400"})})]},s.id)})}),a.myPendingRequests.length>0&&e.jsx("div",{className:"px-4 pt-4 space-y-2",children:a.myPendingRequests.map(s=>{var c,o,h;return e.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/30 rounded-xl p-3 flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:((c=s.clan)==null?void 0:c.emblem)||"ð¡ï¸"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-semibold text-foreground",children:["Aguardando aprovação: ",(o=s.clan)==null?void 0:o.name]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["[",(h=s.clan)==null?void 0:h.tag,"] · O lÃder precisa aceitar"]})]}),e.jsx(x,{size:"sm",variant:"ghost",onClick:async()=>{await a.cancelMyRequest(s.id),u.success("Solicitação cancelada")},children:e.jsx(se,{size:16,className:"text-red-400"})})]},s.id)})}),a.joinRequests.length>0&&e.jsxs("div",{className:"px-4 pt-4 space-y-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground font-semibold uppercase tracking-wider",children:["Solicitações de entrada (",a.joinRequests.length,")"]}),a.joinRequests.map(s=>{var c,o,h;return e.jsxs(oe.div,{initial:{y:-10,opacity:0}
6,animate:{y:0,opacity:1},className:"bg-emerald-500/10 border border-emerald-500/30 rounded-xl p-3 flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:((c=s.requester)==null?void 0:c.avatar)||"ð"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:((o=s.requester)==null?void 0:o.display_name)||"Jogador"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[((h=s.requester)==null?void 0:h.xp)||0," XP · quer entrar"]})]}),e.jsx(x,{size:"sm",variant:"ghost",onClick:async()=>{const f=await a.approveJoinRequest(s.id);f!=null&&f.success?u.success("Jogador aceito!"):u.error((f==null?void 0:f.error)||"Erro")},children:e.jsx(ue,{size:16,className:"text-emerald-400"})}),e.jsx(x,{size:"sm",variant:"ghost",onClick:async()=>{await a.declineJoinRequest(s.id),u.success("Solicitação recusada")},children:e.jsx(se,{size:16,className:"text-red-400"})})]},s.id)})]}),e.jsx("div",{className:"px-4 py-4",children:e.jsxs(we,{defaultValue:a.myClan?"my":"ranking",children:[e.jsxs(ke,{className:"grid grid-cols-3 w-full",children:[e.jsx(J,{value:"my",children:"Meu Clã"}),e.jsx(J,{value:"ranking",children:"Ranking"}),e.jsx(J,{value:"challenges",children:"Desafios"})]}),e.jsx($,{value:"my",className:"mt-4 space-y-3",children:a.myClan?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-card border border-border rounded-xl p-4 flex items-center gap-4",children:[e.jsx("span",{className:"text-5xl",children:a.myClan.emblem}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"font-display text-xl text-foreground truncate",children:a.myClan.name}),e.jsxs("p",{className:"text-xs text-gold",children:["[",a.myClan.tag,"] · ",a.members.length,"/",a.myClan.max_members," membros"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:a.myClan.description||"Sem descrição"})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"font-display text-2xl text-gold",children:a.myClan.clan_points}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"PONTOS"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"bg-card border border-border rounded-lg p-3 text-center",children:[e.jsx(Ie,{size:16,className:"mx-auto text-emerald-400 mb-1"}),e.jsx("p",{className:"font-bold text-foreground",children:a.myClan.wins}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Vitórias"})]}),e.jsxs("div",{className:"bg-card border border-border rounded-lg p-3 text-center",children:[e.jsx(xe,{size:16,className:"mx-auto text-red-400 mb-1"}),e.jsx("p",{className:"font-bold text-foreground",children:a.myClan.losses}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Derrotas"})]})]}),n&&a.members.length<a.myClan.max_members&&e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-2",children:[e.jsxs(x,{variant:"default",className:"gap-1",onClick:()=>X(!0),children:[e.jsx(Ce,{size:16})," Convidar"]}),e.jsxs(x,{variant:"outline",className:"gap-1",onClick:()=>H(!0),children:[e.jsx(pe,{size:16})," Compartilhar"]})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold text-sm text-foreground mb-2 mt-3",children:["Membros (",a.members.length,"/",a.myClan.max_members,")"]}),e.jsx("div",{className:"space-y-1",children:a.members.sort((s,c)=>s.role==="leader"?-1:1).map(s=>{var c,o,h;return e.jsxs("div",{className:"flex items-center gap-3 bg-card border border-border/50 rounded-lg p-2",children:[e.jsx("span",{className:"text-xl",children:((c=s.profile)==null?void 0:c.avatar)||"ð"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:(o=s.profile)==null?void 0:o.display_name}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[((h=s.profile)==null?void 0:h.xp)||0," XP"]})]}),s.role==="leader"&&e.jsx(Be,{size:14,className:"text-gold"}),s.role==="officer"&&e.jsx(ve,{size:14,className:"text-blue-400"})]},s.id)})})]}),((be=a.myMembership)==null?void 0:be.role)!=="leader"&&e.jsxs(x,{variant:"outline",className:"w-full mt-3",onClick:async()=>{const s=await a.leaveClan();s!=null&&s.success?u.success("Você saiu do clã"):u.error((s==null?void 0:s.error)||"Erro")},children:[e.jsx(Fe,{size:14,className:"mr-1"})," Sair do clã"]})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Le,{size:36,className:"mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"Você ainda não pertence a um clã."}),e.jsxs("p",{className:"text-xs mt-1",children:["Aceite um convite, use um código ou ",r?"crie o seu!":`jogue ${A} partidas para fundar um.`]}),e.jsxs(x,{variant:"outline",size:"sm",className:"mt-4 gap-1",onClick:()=>w(!0),children:[e.jsx(he,{size:14}
6)," Entrar com código"]})]})}),e.jsx($,{value:"ranking",className:"mt-4 space-y-2",children:a.loading?e.jsx("p",{className:"text-center text-muted-foreground py-8 text-sm",children:"Carregando..."}):a.clans.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8 text-sm",children:"Nenhum clã ainda. Seja o primeiro!"}):a.clans.map((s,c)=>{var o,h;return e.jsxs(oe.div,{initial:{x:-10,opacity:0},animate:{x:0,opacity:1},transition:{delay:c*.02},className:"flex items-center gap-3 bg-card border border-border rounded-xl p-3",children:[e.jsx("span",{className:`font-display text-lg w-7 text-center ${c===0?"text-gold":c===1?"text-gray-300":c===2?"text-amber-700":"text-muted-foreground"}`,children:c+1}),e.jsx("span",{className:"text-2xl",children:s.emblem}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:s.name}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["[",s.tag,"] · ",s.member_count||0," membros · ",s.wins,"V/",s.losses,"D"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"font-display text-lg text-gold leading-none",children:s.clan_points}),e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"PTS"})]}),a.myClan&&s.id!==a.myClan.id&&(((o=a.myMembership)==null?void 0:o.role)==="leader"||((h=a.myMembership)==null?void 0:h.role)==="officer")&&e.jsx(x,{size:"sm",variant:"ghost",onClick:()=>R(s),children:e.jsx(xe,{size:14,className:"text-red-400"})})]},s.id)})}),e.jsx($,{value:"challenges",className:"mt-4 space-y-2",children:a.myClan?a.challenges.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8 text-sm",children:"Nenhum desafio ainda."}):a.challenges.map(s=>{var f,Ne;const c=s.challenger_clan_id===a.myClan.id,o=c?s.opponent:s.challenger,h=s.status==="pending"&&!c;return e.jsxs("div",{className:"bg-card border border-border rounded-xl p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:(o==null?void 0:o.emblem)||"ð¡ï¸"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-semibold text-foreground truncate",children:[c?"Desafiamos ":"Desafiados por "," ",e.jsx("span",{className:"text-gold",children:o==null?void 0:o.name})]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground capitalize",children:["Status: ",s.status]}),s.message&&e.jsxs("p",{className:"text-xs text-muted-foreground italic mt-1",children:['"',s.message,'"']})]}),h&&(((f=a.myMembership)==null?void 0:f.role)==="leader"||((Ne=a.myMembership)==null?void 0:Ne.role)==="officer")&&e.jsxs("div",{className:"flex gap-1",children:[e.jsx(x,{size:"sm",variant:"ghost",onClick:()=>a.respondChallenge(s.id,!0),children:e.jsx(ue,{size:14,className:"text-emerald-400"})}),e.jsx(x,{size:"sm",variant:"ghost",onClick:()=>a.respondChallenge(s.id,!1),children:e.jsx(se,{size:14,className:"text-red-400"})})]})]}),s.status==="completed"&&e.jsxs("p",{className:"text-xs text-center mt-2 font-semibold",children:[s.winner_clan_id===a.myClan.id?"ð Vitória":"ð Derrota"," (",s.score_challenger," à ",s.score_opponent,")"]})]},s.id)}):e.jsx("p",{className:"text-center text-muted-foreground py-8 text-sm",children:"Entre em um clã para participar de desafios."})})]})}),e.jsx(q,{open:U,onOpenChange:X,children:e.jsxs(T,{className:"max-w-md",children:[e.jsxs(M,{children:[e.jsxs(E,{className:"flex items-center gap-2",children:[e.jsx(Ce,{size:18})," Convidar para o clã"]}),e.jsx(me,{children:"Envie convites para amigos ou busque jogadores pelo nome."})]}),e.jsxs(we,{value:D,onValueChange:s=>ne(s),children:[e.jsxs(ke,{className:"grid grid-cols-2 w-full",children:[e.jsxs(J,{value:"friends",children:["Amigos (",b.length,")"]}),e.jsx(J,{value:"search",children:"Buscar jogador"})]}),e.jsx($,{value:"friends",className:"mt-3 max-h-72 overflow-y-auto space-y-1",children:b.length===0?e.jsx("p",{className:"text-center text-xs text-muted-foreground py-6",children:y.length===0?"Você ainda não tem amigos.":"Todos seus amigos já estão no clã."}):b.map(s=>e.jsxs("div",{className:"flex items-center gap-3 bg-card border border-border/50 rounded-lg p-2",children:[e.jsx("span",{className:"text-xl",children:s.avatar||"ð"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:s.display_name}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[s.xp," XP · ",s.status==="online"?"ð¢ online":s.status==="playing"?"ð® jogando":"â« offline"]})]}),e.jsxs(x,{size:"sm",variant:"outline",className:"gap-1",onClick:()=>Z(s.id,s.display_name),children:[e.jsx(ae,{size:12})," Convidar"]})]},s.id))}),e.jsxs($,{value:"search",className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Se,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),e.jsx(z,{placeholder:"Nome do jogador...",value:S,onChange:s=>le(s.target.value),className:"pl-9"})]}),e.jsx("div",{className:"max-h-60 overflow-y-auto space-y-1",children:ie?e.jsx("p",{className:"text-center text-xs text-muted-foreground py-4",children:"Buscando..."}):Y.length===0&&S.trim()?e.jsx("p",{className:"text-center text-xs text-muted-foreground py-4",children:"Nenhum jogador disponÃvel encontrado."}):Y.map(s=>e.jsxs("div",{className:"flex items-center gap-3 bg-card border border-border/50 rounded-lg p-2",children:[e.jsx("span",{className:"text-xl",children:s.avatar||"ð"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:s.display_name}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[s.xp||0," XP"]})]}),e.jsxs(x,{size:"sm",variant:"outline",className:"gap-1",onClick:()=>Z(s.id,s.display_name),children:[e.jsx(ae,{size:12})," Convidar"]})]},s.id))})]})]})]})}),e.jsx(q,{open:te,onOpenChange:H,children:e.jsxs(T,{className:"max-w-sm",children:[e.jsxs(M,{children:[e.jsxs(E,{className:"flex items-center gap-2",children:[e.jsx(pe,{size:18})," Compartilhar clã"]}),e.jsx(me,{children:"Envie o código ou link para qualquer jogador entrar direto."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Código do clã"}),e.jsxs("button",{onClick:Me,className:"w-full mt-1 bg-card border-2 border-dashed border-gold rounded-xl p-4 flex items-center justify-between hover:bg-gold/5 transition",children:[e.jsx("span",{className:"font-display text-3xl text-gold tracking-widest",children:(ye=a.myClan)==null?void 0:ye.tag}),e.jsx(ze,{size:18,className:"text-muted-foreground"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 text-center",children:"Toque para copiar"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Link de convite"}),e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(z,{value:ee,readOnly:!0,className:"text-xs"}),e.jsx(x,{size:"sm",variant:"outline",onClick:ge,children:e.jsx(ze,{size:14})})]})]}),e.jsxs(x,{className:"w-full gap-2",onClick:Te,children:[e.jsx(pe,{size:16})," Compartilhar"]})]})]})}),e.jsx(q,{open:P,onOpenChange:w,children:e.jsxs(T,{className:"max-w-sm",children:[e.jsxs(M,{children:[e.jsxs(E,{className:"flex items-center gap-2",children:[e.jsx(he,{size:18}
6)," Entrar com código"]}),e.jsx(me,{children:"Digite o código (tag) do clã que você quer entrar."})]}),e.jsx(z,{placeholder:"Ex: MNL",value:k,onChange:s=>Q(s.target.value.toUpperCase().slice(0,5)),className:"text-center text-2xl font-display tracking-widest",autoFocus:!0}),e.jsx(de,{children:e.jsxs(x,{onClick:Ee,disabled:!k.trim(),children:[e.jsx(Se,{size:14,className:"mr-1"})," Buscar"]})})]})}),e.jsx(q,{open:!!g,onOpenChange:s=>!s&&_(null),children:e.jsxs(T,{className:"max-w-sm",children:[e.jsx(M,{children:e.jsx(E,{children:"Entrar no clã?"})}),g&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"bg-card border border-border rounded-xl p-4 flex items-center gap-3",children:[e.jsx("span",{className:"text-5xl",children:g.emblem||"ð¡ï¸"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-display text-lg text-foreground truncate",children:g.name}),e.jsxs("p",{className:"text-xs text-gold",children:["[",g.tag,"]"]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[g.member_count||0,"/",g.max_members," membros · ",g.clan_points||0," pts"]})]})]}),g.description&&e.jsxs("p",{className:"text-sm text-muted-foreground italic",children:['"',g.description,'"']}),a.myClan?e.jsx("p",{className:"text-xs text-amber-400 text-center",children:"Você precisa sair do seu clã atual antes de entrar em outro."}):e.jsxs(x,{className:"w-full gap-1",onClick:Oe,children:[e.jsx(ae,{size:16})," Solicitar entrada"]}),e.jsx("p",{className:"text-[10px] text-muted-foreground text-center",children:"O lÃder do clã precisa aprovar sua entrada."})]})]})}),e.jsx(q,{open:!!C,onOpenChange:s=>!s&&R(null),children:e.jsxs(T,{children:[e.jsx(M,{children:e.jsxs(E,{children:["Desafiar ",C==null?void 0:C.name]})}),e.jsx(_e,{placeholder:"Mensagem (opcional)",value:G,onChange:s=>K(s.target.value.slice(0,200)),rows:3}),e.jsx(de,{children:e.jsxs(x,{onClick:ce,className:"gap-1",children:[e.jsx(ae,{size:14})," Enviar desafio"]})})]})})]}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx(x,{onClick:()=>l("/auth"),children:"Faça login para ver clãs"})})};export{ms 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.