1import{r as a,cP as U,t as w,j as e,O as z,Q as P,W as $,Y as B,ax as F,L as v,B as R,q as V,b6 as E,G as l,H as Q,aE as W,N as Y,S as J,e as K,f as X,g as Z,h as p,v as ee,$ as se,aw as ae,I as L,a0 as te,z as le,ay as re,a1 as ie}from"./index-C1fX6R5K.js";import{T as ne,a as ce,b as f,c as d,d as de,e as r}from"./table-BgO0zTjk.js";import{d as oe}from"./challenges-Qr2G80hQ.js";import{C as xe,E as he}from"./CreateChallengeModal-C4x6MQ0l.js";import{T as O}from"./timer-BeTvNLmc.js";import"./i18n-BtccWlCM.js";import"./index-paNpr7jU.js";import"./image-plus-CV7nkfkg.js";import"./file-up-BPphhTmW.js";const me={running:"bg-orange-500/20 text-orange-300 border-orange-500/40",submitted:"bg-emerald-500/20 text-emerald-300 border-emerald-500/40",expired:"bg-red-500/20 text-red-300 border-red-500/40",abandoned:"bg-slate-500/20 text-slate-300 border-slate-500/40"};function ue({isOpen:i,onClose:o,challenge:n}){const[m,c]=a.useState([]),[u,x]=a.useState(!1);return a.useEffect(()=>{!i||!n||(x(!0),U(n.id).then(t=>c(t.data??[])).catch(()=>w.error("Impossible de charger les sessions.")).finally(()=>x(!1)))},[i,n]),e.jsx(z,{open:i,onOpenChange:t=>!t&&o(),children:e.jsxs(P,{className:"bg-[#0b0c12] border border-white/10 text-white sm:max-w-[560px] max-h-[80vh] overflow-y-auto",children:[e.jsxs($,{children:[e.jsxs(B,{className:"flex items-center gap-2",children:[e.jsx(O,{className:"h-4 w-4 text-orange-400"}),"Sessions Speed Design"]}),e.jsx(F,{className:"text-[#aaaebb]",children:n?.title?.fr??n?.title?.en})]}),u?e.jsx("div",{className:"py-10 text-center text-[#aaaebb]",children:e.jsx(v,{className:"h-5 w-5 animate-spin inline"})}):m.length===0?e.jsx("div",{className:"py-10 text-center text-sm text-[#aaaebb]",children:"Aucune session pour le moment."}):e.jsx("div",{className:"space-y-2",children:m.map(t=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl bg-[#13141a] border border-white/5 px-3 py-2.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm text-white font-medium truncate",children:t.user?.name??`#${t.user?.id}`}),e.jsxs("div",{className:"text-[11px] text-[#aaaebb]",children:["Démarré ",new Date(t.started_at).toLocaleString("fr-FR")," · ",Math.round(t.duration_seconds/60)," min",t.submission?` · ${t.submission.points_awarded} pts`:""]})]}),e.jsx(R,{className:`text-[11px] border shrink-0 ${me[t.status]??"bg-white/10 text-white border-white/20"}`,children:t.status})]},t.id))})]})})}const be={active:"bg-emerald-500/20 text-emerald-300 border-emerald-500/40",draft:"bg-yellow-500/20 text-yellow-300 border-yellow-500/40",closed:"bg-slate-500/20 text-slate-300 border-slate-500/40",archived:"bg-red-500/20 text-red-300 border-red-500/40"};function ge({value:i}){return e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(o=>e.jsx(ie,{className:`h-3 w-3 ${o<=i?"text-yellow-400 fill-yellow-400":"text-white/15"}`},o))})}function Te(){const[i,o]=a.useState([]),[n,m]=a.useState(!0),[c,u]=a.useState(1),[x,t]=a.useState(1),[S,I]=a.useState(0),[h,G]=a.useState(""),[b,H]=a.useState("all"),[M,y]=a.useState(!1),[C,T]=a.useState(null),[D,k]=a.useState(null),[g,N]=a.useState(null),[_,A]=a.useState(!1),j=a.useCallback(async()=>{m(!0);try{const{data:s}=await V.get("/api/admin/challenges",{params:{page:c,per_page:20,search:h||void 0,status:b!=="all"?b:void 0}});o(s.data??[]),t(s.last_page??1),I(s.total??0)}catch{w.error("Impossible de charger les challenges")}finally{m(!1)}},[c,h,b]);a.useEffect(()=>{const s=setTimeout(j,h?300:0);return()=>clearTimeout(s)},[j,h]),a.useEffect(()=>{u(1)},[h,b]);const q=async()=>{if(g){A(!0);try{await oe(g.id),w.success("Challenge supprimé"),N(null),j()}catch(s){w.error(s?.response?.data?.message??"Erreur lors de la suppression")}finally{A(!1)}}};return e.jsxs("div",{className:"space-y-6 max-w-7xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-orange-500/10 flex items-center justify-center shrink-0",children:e.jsx(E,{className:"h-5 w-5 text-orange-400"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-white",children:"Challenges"}),e.jsxs("p",{className:"text-sm text-[#aaaebb]",children:[S," challenge",S!==1?"s":""," au total"]})]})]}),e.jsxs(l,{onClick:()=>y(!0),className:"bg-orange-500 hover:bg-orange-600 text-white",children:[e.jsx(Q,{className:"h-4 w-4 mr-2"}),"Nouveau challenge"]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(W,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-[#aaaebb]"}),e.jsx(Y,{value:h,onChange:s=>G(s.target.value),placeholder:"Rechercher un challengeâ¦",className:"pl-9 bg-[#1e1f25] border-[#2d2e35] text-white"})]}),e.jsxs(J,{value:b,onValueChange:H,children:[e.jsx(K,{className:"w-[180px] bg-[#1e1f25] border-[#2d2e35] text-white",children:e.jsx(X,{})}),e.jsxs(Z,{children:[e.jsx(p,{value:"all",children:"Tous les statuts"}),e.jsx(p,{value:"active",children:"Actif"}),e.jsx(p,{value:"draft",children:"Brouillon"}),e.jsx(p,{value:"closed",children:"Fermé"}),e.jsx(p,{value:"archived",children:"Archivé"})]})]})]}),e.jsx("div",{className:"rounded-2xl border border-[#1e1f25] overflow-hidden",children:e.jsxs(ne,{children:[e.jsx(ce,{children:e.jsxs(f,{className:"border-[#2d2e35] hover:bg-transparent",children:[e.jsx(d,{className:"text-[#aaaebb]",children:"Challenge"}),e.jsx(d,{className:"text-[#aaaebb]",children:"Catégorie"}),e.jsx(d,{className:"text-[#aaaebb]",children:"Statut"}),e.jsx(d,{className:"text-[#aaaebb]",children:"Difficulté"}),e.jsx(d,{className:"text-[#aaaebb]",children:"Participants"}),e.jsx(d,{className:"text-[#aaaebb]",children:"Deadline"}),e.jsx(d,{className:"text-[#aaaebb] text-right",children:"Actions"})]})}),e.jsx(de,{children:n?e.jsx(f,{children:e.jsx(r,{colSpan:7,className:"text-center text-[#aaaebb] py-12",children:e.jsx(v,{className:"h-5 w-5 animate-spin inline"})})}):i.length===0?e.jsx(f,{children:e.jsx(r,{colSpan:7,className:"text-center text-[#aaaebb] py-12",children:"Aucun challenge trouvé."})}):i.map(s=>e.jsxs(f,{className:"border-[#2d2e35]",children:[e.jsx(r,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[s.cover_image_url?e.jsx("img",{src:s.cover_image_url,alt:"",className:"h-10 w-16 rounded-lg object-cover shrink-0"}):e.jsx("div",{className:"h-10 w-16 rounded-lg bg-[#2d2e35] shrink-0 grid place-items-center",children:e.jsx(E,{className:"h-4 w-4 text-[#aaaebb]"})}),e.jsxs("div",{className:"leading-tight min-w-0",children:[e.jsx("div",{className:"text-white text-sm font-medium line-clamp-1",children:s.title?.fr??s.title?.en??"â"}),e.jsxs("div",{className:"text-[11px] text-[#aaaebb]",children:[s.entry_points,"pts entrée · ",s.prize_points,"pts récompense"]})]})]})}),e.jsx(r,{className:"text-[#aaaebb] text-sm",children:s.category?.name?.fr??s.category?.name?.en??e.jsx("span",{className:"opacity-40",children:"â"})}),e.jsx(r,{children:e.jsx(R,{className:`text-[11px] border ${be[s.status]??"bg-white/10 text-white border-white/20"}`,children:s.status})}),e.jsx(r,{children:e.jsx(ge,{value:s.difficulty})}),e.jsx(r,{className:"text-white text-sm",children:s.participants_count??0}),e.jsx(r,{className:"text-[#aaaebb] text-sm",children:s.deadline?new Date(s.deadline).toLocaleDateString("fr-FR",{day:"2-digit",month:"short",year:"numeric"}):e.jsx("span",{className:"opacity-40",children:"â"})}),e.jsx(r,{className:"text-right",children:e.jsxs("div",{className:"inline-flex items-center gap-1",children:[e.jsx(l,{variant:"ghost",size:"sm",asChild:!0,className:"h-8 text-[#aaaebb] hover:text-white px-2",children:e.jsxs(ee,{to:`/admin/challenges/${s.id}/submissions`,state:{challenge:s},children:[e.jsx(se,{className:"h-3.5 w-3.5 mr-1"}),"Soumissions"]})}),s.type==="speed"&&e.jsx(l,{variant:"ghost",size:"icon",onClick:()=>k(s),className:"h-8 w-8 text-[#aaaebb] hover:text-white",title:"Sessions chronométrées",children:e.jsx(O,{className:"h-4 w-4"})}),e.jsx(l,{variant:"ghost",size:"icon",onClick:()=>T(s),className:"h-8 w-8 text-[#aaaebb] hover:text-white",children:e.jsx(ae,{className:"h-4 w-4"})}),e.jsx(l,{variant:"ghost",size:"icon",onClick:()=>N(s),className:"h-8 w-8 text-red-400 hover:text-red-300 hover:bg-red-500/10",children:e.jsx(L,{className:"h-4 w-4"})})]})})]},s.id))})]})}),x>1&&e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(l,{size:"sm",variant:"outline",disabled:c<=1,onClick:()=>u(s=>s-1),children:e.jsx(te,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-sm text-[#aaaebb]",children:["Page ",c," / ",x]}),e.jsx(l,{size:"sm",variant:"outline",disabled:c>=x,onClick:()=>u(s=>s+1),children:e.jsx(le,{className:"h-4 w-4"})})]}),e.jsx(xe,{isOpen:M,onClose:()=>{y(!1),j()}}),C&&e.jsx(he,{isOpen:!0,onClose:()=>{T(null),j()},challenge:C}),e.jsx(ue,{isOpen:!!D,onClose:()=>k(null),challenge:D}),e.jsx(z,{open:!!g,onOpenChange:s=>!s&&N(null),children:e.jsxs(P,{className:"bg-[#1e1f25] border-[#2d2e35] text-white",children:[e.jsxs($,{children:[e.jsx(B,{children:"Supprimer ce challenge ?"}),e.jsxs(F,{className:"text-[#aaaebb]",children:['"',g?.title?.fr??g?.title?.en,'" sera définitivement supprimé, ainsi que toutes ses participations et soumissions.']})]}),e.jsxs(re,{children:[e.jsx(l,{variant:"ghost",onClick:()=>N(null),className:"text-[#aaaebb] hover:text-white",children:"Annuler"}),e.jsxs(l,{onClick:q,disabled:_,className:"bg-red-500 hover:bg-red-600 text-white",children:[_?e.jsx(v,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(L,{className:"h-4 w-4 mr-2"}),"Supprimer"]})]})]})})]})}export{Te 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.