1import{r as i,j as e,y as $,s as Q,b as K,t as O}from"./vendor-react-core-_0sZDOLQ.js";import{a as n,B as g,b as v}from"./index-j07E1qHv.js";import{C as A,b as J,c as V,d as q,a as k}from"./card-DHmBnTdH.js";import{T as W,a as X,b as w,c as z}from"./tabs-BUF6w8PE.js";import{B as d}from"./badge-BXqwvh8U.js";import{P as Y}from"./progress-Dvw4S3O3.js";import{t as C}from"./index-CDqomOa1.js";import{S as U}from"./scroll-area-BgfaAh_s.js";import{m as p,A as Z}from"./vendor-framer-motion-C1oRD-X5.js";import{at as ee,a8 as se,au as ae,av as te,aw as re,ax as le,U as N,ay as ie,r as S,E as T,a0 as oe,az as ne,aA as ce,k as de}from"./vendor-lucide-Ddz0eB7N.js";import"./vendor-radix-CFmJ1img.js";import"./vendor-utils-BRu4i-LD.js";import"./vendor-supabase-Ca6cp8v2.js";const me=i.forwardRef(({className:a,...l},t)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:t,className:n("w-full caption-bottom text-sm",a),...l})}));me.displayName="Table";const xe=i.forwardRef(({className:a,...l},t)=>e.jsx("thead",{ref:t,className:n("[&_tr]:border-b",a),...l}));xe.displayName="TableHeader";const he=i.forwardRef(({className:a,...l},t)=>e.jsx("tbody",{ref:t,className:n("[&_tr:last-child]:border-0",a),...l}));he.displayName="TableBody";const be=i.forwardRef(({className:a,...l},t)=>e.jsx("tfoot",{ref:t,className:n("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",a),...l}));be.displayName="TableFooter";const pe=i.forwardRef(({className:a,...l},t)=>e.jsx("tr",{ref:t,className:n("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",a),...l}));pe.displayName="TableRow";const ue=i.forwardRef(({className:a,...l},t)=>e.jsx("th",{ref:t,className:n("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",a),...l}));ue.displayName="TableHead";const je=i.forwardRef(({className:a,...l},t)=>e.jsx("td",{ref:t,className:n("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",a),...l}));je.displayName="TableCell";const fe=i.forwardRef(({className:a,...l},t)=>e.jsx("caption",{ref:t,className:n("mt-4 text-sm text-muted-foreground",a),...l}));fe.displayName="TableCaption";function Re(){var R,_,F,D;$();const a=Q(),[l,t]=i.useState("folders"),[s,y]=i.useState(null),[c,h]=i.useState(!1),[u,j]=i.useState(0);i.useEffect(()=>{fetch("/uploads/players_staging/metadata.json").then(r=>r.json()).then(r=>y(r)).catch(r=>{console.error("Erro ao carregar metadata.json:",r),C.error("Não foi possÃvel carregar o metadata.json de staging")})},[]);const{data:P=[]}=K({queryKey:["admin-players"],queryFn:()=>v.entities.Player.list()}),G=O({mutationFn:async({type:r,items:o})=>{h(!0),j(0);let M=0,B=0;for(let f=0;f<o.length;f++){const m=o[f];try{const b=r==="staff"?m.fileName.split(".")[0]:m.folder.split("_")[1]||m.folder,I=P.find(H=>H.name.toLowerCase().includes(b.toLowerCase())||b.toLowerCase().includes(H.name.toLowerCase())),L=m.targetUrl;I?await v.entities.Player.update(I.id,{photo_url:L}):await v.entities.Player.create({name:b,photo_url:L,position:r==="staff"?"Staff":"Jogador",team_type:"principal",status:"active"}),M++}catch(b){console.error(`Erro ao processar ${m.fileName||m.folder}:`,b),B++}j(Math.round((f+1)/o.length*100))}return{successCount:M,errorCount:B}},onSuccess:r=>{C.success(`Sincronização concluÃda: ${r.successCount} sucessos, ${r.errorCount} erros.`),a.invalidateQueries(["admin-players"]),h(!1)},onError:()=>{C.error("Erro fatal durante a sincronização"),h(!1)}}),E=r=>{if(!s)return;const o=r==="staff"?s.staff:s.players;G.mutate({type:r,items:o})};return e.jsx("main",{className:"min-h-screen bg-[#0a0a0a] text-white p-6 md:p-10 font-sans",children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("header",{className:"flex flex-col md:flex-row md:items-center justify-between gap-6 mb-12",children:[e.jsxs(p.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(d,{variant:"outline",className:"bg-emerald-500/10 text-emerald-500 border-emerald-500/20 px-3 py-1",children:"CMS Especializado"}),e.jsxs("div",{className:"flex items-center gap-1 text-zinc-500 text-sm",children:[e.jsx(ee,{className:"w-4 h-4"}),e.jsx("span",{children:"FAF Engine v2.0"})]})]}),e.jsxs("h1",{className:"text-4xl font-black tracking-tight text-white sm:text-5xl",children:["Gestor de ",e.jsx("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-emerald-400 to-cyan-400",children:"Conteúdo"})]}),e.jsx("p",{className:"text-zinc-400 mt-2 max-w-xl",children:"Ponto central de administração para sincronização de media, edição de jogadores e gestão dinâmica do portal."})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(g,{variant:"outline",className:"bg-zinc-900 border-zinc-800 text-white hover:bg-zinc-800",children:[e.jsx(se,{className:"w-4 h-4 mr-2"}),"Ver Site"]}),e.jsxs(g,{className:"bg-emerald-600 hover:bg-emerald-700 text-white",children:[e.jsx(ae,{className:"w-4 h-4 mr-2"}),"Publicar Alterações"]})]})]}),e.jsxs(W,{defaultValue:"folders",onValueChange:t,className:"space-y-8",children:[e.jsxs(X,{className:"bg-zinc-900/50 border border-zinc-800 p-1 rounded-xl h-auto flex flex-wrap gap-1",children:[e.jsxs(w,{value:"folders",className:"data-[state=active]:bg-emerald-600 data-[state=active]:text-white rounded-lg px-6 py-3 transition-all",children:[e.jsx(te,{className:"w-4 h-4 mr-2"}),"Sincronizar Pastas"]}),e.jsxs(w,{value:"editable",className:"data-[state=active]:bg-emerald-600 data-[state=active]:text-white rounded-lg px-6 py-3 transition-all",children:[e.jsx(re,{className:"w-4 h-4 mr-2"}),"Tudo Editável"]}),e.jsxs(w,{value:"settings",className:"data-[state=active]:bg-emerald-600 data-[state=active]:text-white rounded-lg px-6 py-3 transition-all",children:[e.jsx(le,{className:"w-4 h-4 mr-2"}),"Configurações"]})]}),e.jsxs(Z,{mode:"wait",children:[e.jsx(z,{value:"folders",children:e.jsxs(p.div,{initial:{opacity:0,y:10}
1,animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsxs(A,{className:"bg-zinc-900/50 border-zinc-800 shadow-2xl overflow-hidden group",children:[e.jsx("div",{className:"h-2 bg-gradient-to-r from-blue-500 to-indigo-500"}),e.jsxs(J,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"bg-blue-500/20 p-3 rounded-2xl",children:e.jsx(N,{className:"w-6 h-6 text-blue-400"})}),e.jsx(d,{className:"bg-blue-500/20 text-blue-400 border-none",children:"@pasta_1"})]}),e.jsx(V,{className:"text-2xl font-bold mt-4",children:"Importação de Staff"}),e.jsx(q,{className:"text-zinc-400",children:"Arquivos soltos detetados em `/public/uploads/players_staging/pasta_1`"})]}),e.jsx(k,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-black/40 rounded-xl p-4 border border-zinc-800/50",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm mb-4",children:[e.jsx("span",{className:"text-zinc-500",children:"Documentos Detetados"}),e.jsxs("span",{className:"font-mono text-blue-400",children:[((R=s==null?void 0:s.staff)==null?void 0:R.length)||0," ficheiros"]})]}),e.jsx(U,{className:"h-40",children:e.jsx("div",{className:"space-y-2",children:(_=s==null?void 0:s.staff)==null?void 0:_.map((r,o)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs text-zinc-400 p-2 hover:bg-white/5 rounded transition-colors",children:[e.jsx(ie,{className:"w-3 h-3 text-zinc-600"}),e.jsx("span",{className:"truncate",children:r.fileName})]},o))})})]}),e.jsxs(g,{onClick:()=>E("staff"),disabled:c||!(s!=null&&s.staff),className:"w-full h-12 bg-blue-600 hover:bg-blue-700 text-white font-bold rounded-xl",children:[c?e.jsx(S,{className:"w-4 h-4 animate-spin mr-2"}):e.jsx(T,{className:"w-4 h-4 mr-2"}),"Sincronizar Staff com BD"]})]})})]}),e.jsxs(A,{className:"bg-zinc-900/50 border-zinc-800 shadow-2xl overflow-hidden",children:[e.jsx("div",{className:"h-2 bg-gradient-to-r from-emerald-500 to-teal-500"}),e.jsxs(J,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"bg-emerald-500/20 p-3 rounded-2xl",children:e.jsx(N,{className:"w-6 h-6 text-emerald-400"})}),e.jsx(d,{className:"bg-emerald-500/20 text-emerald-400 border-none",children:"@pasta_2"})]}),e.jsx(V,{className:"text-2xl font-bold mt-4",children:"Importação de Jogadores"}),e.jsx(q,{className:"text-zinc-400",children:"Pastas estruturadas detetadas em `/public/uploads/players_staging/pasta_2`"})]}),e.jsx(k,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-black/40 rounded-xl p-4 border border-zinc-800/50",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm mb-4",children:[e.jsx("span",{className:"text-zinc-500",children:"Pastas de Jogador"}),e.jsxs("span",{className:"font-mono text-emerald-400",children:[((F=s==null?void 0:s.players)==null?void 0:F.length)||0," diretórios"]})]}),e.jsx(U,{className:"h-40",children:e.jsx("div",{className:"space-y-2",children:(D=s==null?void 0:s.players)==null?void 0:D.map((r,o)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs text-zinc-400 p-2 hover:bg-white/5 rounded transition-colors",children:[e.jsx(oe,{className:"w-3 h-3 text-zinc-600"}),e.jsx("span",{className:"truncate",children:r.folder}),e.jsx(d,{variant:"outline",className:"ml-auto text-[10px] py-0 border-zinc-800",children:r.image})]},o))})})]}),e.jsxs(g,{onClick:()=>E("players"),disabled:c||!(s!=null&&s.players),className:"w-full h-12 bg-emerald-600 hover:bg-emerald-700 text-white font-bold rounded-xl",children:[c?e.jsx(S,{className:"w-4 h-4 animate-spin mr-2"}):e.jsx(T,{className:"w-4 h-4 mr-2"}),"Sincronizar Plantel com BD"]})]})})]}),c&&e.jsxs(p.div,{initial:{opacity:0}
1,animate:{opacity:1},className:"lg:col-span-2 bg-zinc-900 border border-emerald-500/30 rounded-2xl p-8 text-center",children:[e.jsx("h3",{className:"text-xl font-bold mb-4",children:"Sincronização em Curso..."}),e.jsx(Y,{value:u,className:"h-3 bg-zinc-800"}),e.jsxs("p",{className:"mt-4 text-emerald-500 font-mono text-sm",children:[u,"% concluÃdo"]})]})]})}),e.jsx(z,{value:"editable",children:e.jsx(p.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[e.jsx(x,{name:"Jogadores e Plantel",icon:N,link:"AdminPlayers",count:P.length,status:"Gerido"}),e.jsx(x,{name:"NotÃcias e Imprensa",icon:ne,link:"AdminNews",count:12,status:"Atualizar",highlight:!0}),e.jsx(x,{name:"Loja e Produtos",icon:ce,link:"AdminProducts",count:24,status:"Ativo"}),e.jsx(x,{name:"Competições IA",icon:T,link:"AdminCompetitions",count:5,status:"Sincronizado"}),e.jsx(x,{name:"Sócios e Membros",icon:N,link:"AdminMembers",count:150,status:"Validar",highlight:!0}),e.jsx(x,{name:"Bilheteira",icon:S,link:"AdminTickets",count:89,status:"Ativo"})]})})}),e.jsx(z,{value:"settings",children:e.jsxs(p.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"bg-zinc-900/50 border border-zinc-800 rounded-2xl p-8",children:[e.jsx("h3",{className:"text-xl font-bold mb-4",children:"Configurações do CMS"}),e.jsx("p",{className:"text-zinc-400 mb-6",children:"Ajuste os parâmetros de sincronização e permissões do motor FAF."}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-black/40 rounded-xl border border-zinc-800",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-bold",children:"Modo de Segurança"}),e.jsx("p",{className:"text-xs text-zinc-500",children:"Exigir aprovação manual para todos os uploads."})]}),e.jsx(d,{className:"bg-emerald-500/20 text-emerald-500 border-none",children:"Ativo"})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-black/40 rounded-xl border border-zinc-800",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-bold",children:"Sincronização Automática"}),e.jsx("p",{className:"text-xs text-zinc-500",children:"Verificar novos ficheiros a cada 24 horas."})]}),e.jsx(d,{variant:"outline",className:"text-zinc-500",children:"Desativado"})]})]})]})})]})]})]})})}function x({name:a,icon:l,link:t,count:s,status:y,highlight:c}){const h=$(),u=j=>{h(`/${j}`)};return e.jsx(A,{className:"bg-zinc-900/40 border-zinc-800 hover:border-emerald-500/50 transition-all cursor-pointer group",onClick:()=>u(t),children:e.jsxs(k,{className:"p-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsx("div",{className:"bg-zinc-800 p-3 rounded-xl group-hover:bg-emerald-500/20 group-hover:text-emerald-400 transition-colors",children:e.jsx(l,{className:"w-6 h-6"})}),e.jsx(d,{className:c?"bg-amber-500/20 text-amber-500 border-none":"bg-zinc-800 text-zinc-400 border-none",children:y})]}),e.jsx("h3",{className:"text-xl font-bold text-white mb-1",children:a}),e.jsxs("p",{className:"text-zinc-500 text-sm",children:[s," registos encontrados"]}),e.jsxs("div",{className:"mt-4 flex items-center text-xs text-emerald-500 font-bold opacity-0 group-hover:opacity-100 transition-opacity",children:["GERIR ENTIDADE ",e.jsx(de,{className:"w-3 h-3 ml-1"})]})]})})}export{Re 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.