1import{r as n,j as e}from"./react-vendor-B6cClYO7.js";import{j as mt,d as w,c as h,t as Z,a as R,$ as Le,b as ut,f as pt}from"./index-D-q7twid.js";import{r as U}from"./ProfileFrameOverlay-CBkNmOKU.js";import{g as Q,T as ee}from"./tournamentFormats-zIhi9CRV.js";import{A as bt}from"./AssetLibraryPicker-CZ329Aqq.js";import"./preload-helper-BpFspJo9.js";import{bt as ht,bO as Be,bf as Me,T as gt,x as yt,aL as De,aD as ft,f as Ee,aX as vt,O as Ae,cp as jt,bT as Pe,l as Oe,a$ as wt,ag as Nt,p as _t,aa as kt,e as Ct,bJ as Re,a5 as St}from"./ui-vendor-DS3oINzv.js";import"./vendor-B8MFB3TR.js";import"./state-vendor-CmZDnCvr.js";import"./style-utils-vendor-CZ__NpDL.js";import"./publicUrl-Cka7uqZt.js";import"./Button-BgGl0oUy.js";import"./radix-vendor-BxXV1p6x.js";import"./ModalPortal-D5paL4J_.js";import"./assetLibraryUtils-BRJ7tp3M.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},g=new r.Error().stack;g&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[g]="5c29b976-f1eb-4494-8a8f-7219606599d9",r._sentryDebugIdIdentifier="sentry-dbid-5c29b976-f1eb-4494-8a8f-7219606599d9")}catch{}})();const F={registration:{label:"РегиÑÑÑаÑиÑ",color:"bg-green-500/20 text-green-400 border-green-500/30"},ongoing:{label:"ÐдÑÑ",color:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30"},completed:{label:"ÐавеÑÑÑн",color:"bg-gray-500/20 text-gray-400 border-gray-500/30"},cancelled:{label:"ÐÑменÑн",color:"bg-red-500/20 text-red-400 border-red-500/30"}},Ue=Object.fromEntries(ee.map(r=>[r.key,r.shortLabel])),Tt=[{value:"daily",label:"ÐаждÑй денÑ"},{value:"monday",label:"ÐонеделÑник"},{value:"tuesday",label:"ÐÑоÑник"},{value:"wednesday",label:"СÑеда"},{value:"thursday",label:"ЧеÑвеÑг"},{value:"friday",label:"ÐÑÑниÑа"},{value:"saturday",label:"СÑббоÑа"},{value:"sunday",label:"ÐоÑкÑеÑенÑе"}],N=5,Yt=()=>{const r=mt(t=>t.showToast),[g,C]=n.useState([]),[p,f]=n.useState(!0),[u,z]=n.useState(""),[x,S]=n.useState(!1),[te,ae]=n.useState(!1),[d,c]=n.useState({name:"",description:"",format:"single_elimination",time_control:"10+0",max_players:16,entry_fee:0,prize_pool:0,is_rated:!0,banner_url:"",arena_duration_minutes:60,is_private:!1,password:"",referral_bonus_xp:0}),[se,re]=n.useState(!1),[L,D]=n.useState({}),[Fe,B]=n.useState({}),[ne,le]=n.useState(null),[ie,de]=n.useState(null),[v,E]=n.useState(null),[A,Ge]=n.useState(!1),[G,P]=n.useState([]),[oe,ce]=n.useState(!1),[X,xe]=n.useState([]),[Y,me]=n.useState([]),[ue,pe]=n.useState(!1),[Xe,Ye]=n.useState(null),[J,be]=n.useState({}),[Je,he]=n.useState(null),O=Q(d.format),[y,Ke]=n.useState("list"),[K,qe]=n.useState([]),[ge,ye]=n.useState(!1),[fe,He]=n.useState([]),[ve,je]=n.useState(null),[M,we]=n.useState(null),[We,Ne]=n.useState(!1),[j,T]=n.useState({enabled:!1,max_ratio:.4,max_per_tournament:8,level_override:"4",paused_until:null}),[Ze,_e]=n.useState(!1),[ke,Ce]=n.useState(!1),_=(t,a)=>{if(t instanceof Error&&t.message)return t.message;if(typeof t=="object"&&t!==null&&"message"in t){const s=t.message;if(typeof s=="string"&&s.trim().length>0)return s}return a},I=t=>Fe[t]??{mode:"delay",delayMinutes:N,customStart:""},k=n.useCallback(async()=>{f(!0);try{const t=u?`?status=${u}`:"",a=await w(`/api/admin/tournaments${t}`);C(a?.tournaments||[])}catch{r("ÐÑибка загÑÑзки ÑÑÑниÑов","error")}finally{f(!1)}},[u,r]),Qe=n.useCallback(async()=>{try{const t=await w("/api/admin/tournaments/seasons");P(t?.templates||[])}catch{}},[]),Se=n.useCallback(async()=>{pe(!0);try{const t=await w("/api/admin/clubs/competitions?status=active&limit=6");xe(t?.wars||[]),me(t?.inter_club_tournaments||[])}catch{xe([]),me([])}finally{pe(!1)}},[]),$=n.useCallback(async()=>{ye(!0);try{const t=await w("/api/admin/tournaments/live");qe(t?.tournaments||[])}catch{r("ÐÑибка загÑÑзки live даннÑÑ
","error")}finally{ye(!1)}},[r]),q=n.useCallback(async()=>{try{const t=await w("/api/admin/tournaments/alerts");He(t?.alerts||[])}catch{}},[]),Ve=n.useCallback(async t=>{Ne(!0);try{const a=await w(`/api/admin/tournaments/${t}/live-detail`);we(a||null)}catch{r("ÐÑибка загÑÑзки деÑалей","error")}finally{Ne(!1)}},[r]),Te=n.useCallback(async t=>{if(!J[t]){he(t);try{const a=await w(`/api/admin/tournaments/${t}?matches_limit=50&matches_offset=0`);a&&be(s=>({...s,[t]:a}))}catch(a){r(_(a,"ÐÑибка загÑÑзки иÑогов ÑÑÑниÑа"),"error")}finally{he(null)}}},[J,r]),Ie=n.useCallback(async()=>{_e(!0);try{const t=await w("/api/admin/tournaments/bot-config");t&&T(t)}catch{}finally{_e(!1)}},[]),et=async()=>{Ce(!0);try{await Le("/api/admin/tournaments/bot-config",j),r("ÐонÑиг боÑов ÑоÑ
ÑанÑн","success")}catch{r("ÐÑибка ÑоÑ
ÑанениÑ","error")}finally{Ce(!1)}},tt=async t=>{if(confirm("УдалиÑÑ Ð²ÑеÑ
боÑов из ÑÑого ÑÑÑниÑа?"))try{await R(`/api/admin/tournaments/${t}/bots/remove`,{}),r("ÐоÑÑ ÑдаленÑ","success"),$()}catch{r("ÐÑибка ÑÐ´Ð°Ð»ÐµÐ½Ð¸Ñ Ð±Ð¾Ñов","error")}};n.useEffect(()=>{k()},[k]),n.useEffect(()=>{Se()},[Se]),n.useEffect(()=>{if(y!=="live")return;$(),q();const t=setInterval(()=>{$(),q()},3e4);return()=>clearInterval(t)},[y,$,q]),n.useEffect(()=>{y==="bots"&&Ie()},[y,Ie]);const at=async()=>
1{if(!d.name.trim())return r("ÐведиÑе название","error");ae(!0);try{const t={...d,banner_url:d.banner_url.trim()||null,arena_duration_minutes:d.format==="arena"?d.arena_duration_minutes:null};if(!await R("/api/admin/tournaments",{...t}))throw new Error("СеÑÐ²ÐµÑ Ð½Ðµ веÑнÑл даннÑе â пÑовеÑÑÑе логи бÑкенда");r("ТÑÑÐ½Ð¸Ñ Ñоздан","success"),S(!1),c({name:"",description:"",format:"single_elimination",time_control:"10+0",max_players:16,entry_fee:0,prize_pool:0,is_rated:!0,banner_url:"",arena_duration_minutes:60,is_private:!1,password:"",referral_bonus_xp:0}),k()}catch(t){r(_(t,"ÐÑибка ÑозданиÑ"),"error")}finally{ae(!1)}},$e=async(t,a)=>R("/api/admin/media/generate",{kind:"tournament_banner",title:t,body:a,style_hint:"Premium esports event banner for Toguzkumalak"}),st=async()=>{if(!d.name.trim()){r("СнаÑала ÑкажиÑе название ÑÑÑниÑа","error");return}re(!0);try{const t=await $e(d.name,[d.description,d.format,d.time_control].filter(Boolean).join(" · "));if(!t?.asset_url){r("Ðе ÑдалоÑÑ ÑгенеÑиÑоваÑÑ Ð±Ð°Ð½Ð½ÐµÑ","error");return}c(a=>({...a,banner_url:t.asset_url??""}))}catch(t){r(_(t,"ÐÑибка генеÑаÑии баннеÑа"),"error")}finally{re(!1)}},rt=async t=>{le(t.id);try{const a=await $e(t.name,[t.description,t.format,t.time_control].filter(Boolean).join(" · "));if(!a?.asset_url){r("Ðе ÑдалоÑÑ ÑгенеÑиÑоваÑÑ Ð±Ð°Ð½Ð½ÐµÑ","error");return}D(s=>({...s,[t.id]:a.asset_url??""}))}catch(a){r(_(a,"ÐÑибка генеÑаÑии баннеÑа"),"error")}finally{le(null)}},nt=async t=>{const a=(L[t]??"").trim();de(t);try{await Le(`/api/admin/tournaments/${t}`,{banner_url:a||null}),r("ÐÐ°Ð½Ð½ÐµÑ ÑÑÑниÑа ÑоÑ
ÑанÑн","success"),await k()}catch(s){r(_(s,"ÐÑибка ÑоÑ
ÑÐ°Ð½ÐµÐ½Ð¸Ñ Ð±Ð°Ð½Ð½ÐµÑа"),"error")}finally{de(null)}},lt=t=>{v&&(v.mode==="create"?c(a=>({...a,banner_url:t.url})):D(a=>({...a,[v.tournamentId]:t.url})),E(null))},ze=async(t,a,s)=>{if(!(s&&!confirm(s)))try{a==="cancel"&&await ut(`/api/admin/tournaments/${t}`),r(`ТÑÑниÑ: ${a} OK`,"success"),k()}catch(i){r(_(i,`ÐÑибка: ${a}`),"error")}},it=async t=>{const a=I(t.id),s={};let i=`ÑеÑез ${a.delayMinutes||N} мин`;if(a.mode==="custom"){if(!a.customStart){r("УкажиÑе вÑÐµÐ¼Ñ ÑÑаÑÑа ÑаÑнда","error");return}const l=new Date(a.customStart);if(Number.isNaN(l.getTime())){r("ÐекоÑÑекÑное вÑÐµÐ¼Ñ ÑÑаÑÑа","error");return}s.first_round_starts_at=l.toISOString(),i=l.toLocaleString("ru-RU")}else{const l=Math.max(0,Math.floor(a.delayMinutes||N));s.round_start_delay_minutes=l,i=l>0?`ÑеÑез ${l} мин`:"ÑÑазÑ"}if(confirm(`ÐапÑÑÑиÑÑ ÑÑÑÐ½Ð¸Ñ Â«${t.name}»? ÐеÑвÑй ÑаÑнд: ${i}.`))try{console.info("[admin:tournaments:start] request",{tournamentId:t.id,tournamentName:t.name,payload:s});const l=await pt(`/api/admin/tournaments/${t.id}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!l)throw console.error("[admin:tournaments:start] network_failure",{tournamentId:t.id,payload:s}),new Error("ÐÐµÑ Ð¾ÑвеÑа Ð¾Ñ ÑеÑвеÑа");const o=await l.text();let m=null;if(o)try{m=JSON.parse(o)}catch{m=o}if(!l.ok){console.error("[admin:tournaments:start] response_error",{tournamentId:t.id,status:l.status,statusText:l.statusText,payload:s,body:m});const W=m&&typeof m=="object"&&"detail"in m?m.detail:null;throw new Error(typeof W=="string"&&W.trim()?W:`HTTP ${l.status}`)}const H=m&&typeof m=="object"?m:null;console.info("[admin:tournaments:start] response_ok",{tournamentId:t.id,payload:s,body:H});const xt=H?.first_round_starts_at?new Date(H.first_round_starts_at).toLocaleString("ru-RU"):i;r(`ТÑÑÐ½Ð¸Ñ Ð·Ð°Ð¿ÑÑен. ÐеÑвÑй ÑаÑнд: ${xt}`,"success"),k(),y==="live"&&$()}catch(l){r(_(l,"ÐÑибка: start"),"error")}},dt=async()=>{ce(!0);try{await R("/api/admin/tournaments/seasons",G),r("СезоннÑе ÑÐ°Ð±Ð»Ð¾Ð½Ñ ÑоÑ
ÑаненÑ","success")}catch{r("ÐÑибка ÑоÑ
ÑанениÑ","error")}finally{ce(!1)}},ot=()=>{P(t=>[...t,{name:`ÐжедневнÑй #${t.length+1}`,format:"single_elimination",time_control:"5+3",max_players:16,entry_fee:0,prize_pool:500,is_rated:!0,banner_url:null,arena_duration_minutes:60,cron_day:"daily",cron_hour:18,enabled:!0}])},b=(t,a)=>{P(s=>s.map((i,l)=>l===t?{...i,...a}:i))},ct=t=>{P(a=>a.filter((s,i)=>i!==t))};return e.jsxs("div",{className:"max-w-4xl mx-auto px-4 py-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-bold text-white",children:"ТÑÑниÑÑ"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{"data-testid":"admin-tournaments-refresh",onClick:()=>y==="live"?$():k(),className:"p-2 rounded-lg bg-white/5 hover:bg-white/10 text-gray-400 hover:text-white",title:"ÐбновиÑÑ","aria-label":"ÐбновиÑÑ",children:e.jsx(ht,{size:16,className:p||ge?"animate-spin":""})}),e.jsxs("button",{onClick:()=>{Ge(!A),A||Qe()},"data-testid":"admin-tournaments-seasons-toggle",className:h("flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm",A?"bg-violet-600/20 text-violet-400":"bg-white/5 text-gray-400 hover:text-white hover:bg-white/10"),children:[e.jsx(Be,{size:14})," СезонÑ"]}),e.jsxs("button",{onClick:()=>S(!0),"data-testid":"admin-tournaments-create-open",className:"flex items-center gap-1.5 px-3 py-2 rounded-lg bg-violet-600 hover:bg-violet-500 text-white text-sm font-bold",children:[e.jsx(Me,{size:14})," СоздаÑÑ"]})]})]}),e.jsx("div",{className:"flex gap-1.5",children:[{key:"list",label:"СпиÑок",icon:e.jsx(gt,{size:12})},{key:"live",label:"Live",icon:e.jsx(yt,{size:12})},{key:"bots",label:"ÐоÑÑ",icon:e.jsx(De,{size:12})}].map(t=>e.jsxs("button",{onClick:()=>Ke(t.key),className:h("flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-bold transition-all",y===t.key?"bg-violet-600/20 text-violet-400 border border-violet-500/30":"text-gray-500 hover:text-gray-300 hover:bg-white/5"),children:[t.icon," ",t.label]},t.key))}),y==="live"&&e.jsxs("div",{className:"space-y-4",children:[fe.length>0&&e.jsx("div",{className:"space-y-1.5",children:fe.slice(0,5).map((t,a)=>e.jsxs("div",{className:h("flex items-center gap-2 px-3 py-2 rounded-lg border text-xs",t.type==="cancel"?"border-red-500/20 bg-red-500/5 text-red-300":t.type==="forfeit"?"border-yellow-500/20 bg-yellow-500/5 text-yellow-300":t.type==="bot_top3"?"border-violet-500/20 bg-violet-500/5 text-violet-300":"border-white/10 bg-white/5 text-gray-300"),children:[e.jsx(ft,{size:12}),e.jsx("span",{className:"flex-1",children:t.message}),e.jsx("span",{className:"text-[10px] text-gray-500",children:new Date(t.timestamp).toLocaleTimeString()})]},a))}),ge&&K.length===0?e.jsx("div",{className:"space-y-2",children:[1,2].map(t=>e.jsx("div",{className:"h-16 bg-white/3 border border-white/5 rounded-xl animate-pulse"},t))}):K.length===0?e.jsx("div",{className:"text-center text-gray-500 py-12",children:"ÐÐµÑ Ð°ÐºÑивнÑÑ
ÑÑÑниÑов"}):e.jsx("div",{className:"space-y-2",children:K.map(t=>{const a=F[t.status]||{label:t.status,color:"bg-white/10 text-gray-400 border-white/10"},s=t.max_players?Math.min(100,Math.round(t.participant_count/t.max_players*100)):0;return e.jsxs("div",{className:"border border-white/10 rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>
1{ve===t.id?(je(null),we(null)):(je(t.id),Ve(t.id))},className:"w-full flex items-center gap-3 px-4 py-3 hover:bg-white/3 transition-all text-left",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-bold text-white truncate",children:t.name}),e.jsx("span",{className:h("px-1.5 py-0.5 rounded text-[10px] font-bold border",a.color),children:a.label}),t.bot_count>0&&e.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-bold border border-violet-500/30 bg-violet-500/10 text-violet-300",children:[t.bot_count," bot"]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-[11px] text-gray-500",children:[e.jsx("span",{children:Ue[t.format]||t.format}),e.jsxs("span",{children:[e.jsx(Ee,{size:10,className:"inline mr-0.5"}),t.participant_count,"/",t.max_players]}),t.current_round>0&&e.jsxs("span",{className:"text-violet-400",children:["РаÑнд ",t.current_round,"/",t.total_rounds]}),t.matches.waiting>0&&e.jsxs("span",{className:"text-yellow-400",children:[t.matches.waiting," ожид."]}),t.forfeit_count>0&&e.jsxs("span",{className:"text-orange-400",children:[t.forfeit_count," неÑвок"]}),t.auto_start_in_seconds!=null&&e.jsxs("span",{className:"text-green-400",children:["СÑаÑÑ ÑеÑез ",Math.floor(t.auto_start_in_seconds/60)," мин"]})]}),e.jsx("div",{className:"mt-1.5 h-1 w-full rounded-full bg-white/5 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-violet-500/50 transition-all",style:{width:`${s}%`}})})]}),e.jsx(vt,{size:14,className:"text-gray-500"})]}),ve===t.id&&e.jsx("div",{className:"px-4 pb-3 pt-1 border-t border-white/5 space-y-3",children:We?e.jsx("div",{className:"h-20 bg-white/3 rounded-lg animate-pulse"}):M?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] text-gray-500 uppercase tracking-widest font-bold mb-1.5",children:["УÑаÑÑники (",M.participants.length,")"]}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:M.participants.map(i=>e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded-lg bg-white/3 text-xs",children:[e.jsx("span",{className:"text-white font-bold truncate",children:i.display_name||i.username||"?"}),e.jsxs("span",{className:"text-gray-500",children:[i.score," оÑк."]}),i.is_bot&&e.jsx("span",{className:"text-violet-400 text-[10px]",children:"BOT"})]},i.user_id))})]}),M.current_round_matches.length>0&&e.jsxs("div",{"data-testid":"admin-tournament-live-current-round-matches",children:[e.jsx("p",{className:"text-[10px] text-gray-500 uppercase tracking-widest font-bold mb-1.5",children:"ÐаÑÑи ÑекÑÑего ÑаÑнда"}),e.jsx("div",{className:"space-y-1",children:M.current_round_matches.map(i=>e.jsxs("div",{"data-testid":`admin-tournament-current-round-match-${i.id}`,className:"flex items-center gap-2 px-2 py-1.5 rounded-lg bg-white/3 text-xs",children:[e.jsx("span",{className:"text-white flex-1",children:i.white_name}),e.jsx("span",{className:"text-gray-500",children:"vs"}),e.jsx("span",{className:"text-white flex-1 text-right",children:i.black_name}),i.result?e.jsx("span",{className:h("px-1.5 py-0.5 rounded text-[10px] font-bold",i.result==="white"?"bg-green-500/20 text-green-400":i.result==="black"?"bg-blue-500/20 text-blue-400":i.result==="draw"?"bg-gray-500/20 text-gray-400":"bg-yellow-500/20 text-yellow-400"),children:i.result}):e.jsx("span",{className:"text-yellow-400 text-[10px]",children:i.waiting_seconds>0?`${Math.floor(i.waiting_seconds/60)}м ожид.`:"ожид."})]},i.id))})]}),t.bot_count>0&&e.jsxs("button",{onClick:()=>tt(t.id),className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg border border-red-500/20 bg-red-600/20 text-red-400 hover:bg-red-600/30 text-xs font-bold",children:[e.jsx(Ae,{size:12})," УдалиÑÑ Ð±Ð¾Ñов"]})]}):null})]},t.id)})}),e.jsx("p",{className:"text-[10px] text-gray-600",children:"ÐаннÑе обновлÑÑÑÑÑ ÐºÐ°Ð¶Ð´Ñе 30 ÑекÑнд"})]}),y==="bots"&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"bg-white/5 border border-violet-500/20 rounded-xl p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-sm font-bold text-violet-400 flex items-center gap-2",children:[e.jsx(De,{size:14}
1)," ÐлобалÑнÑй конÑиг боÑов"]}),e.jsx("button",{onClick:et,disabled:ke,className:"flex items-center gap-1 px-3 py-1.5 rounded-lg bg-violet-600 text-white text-xs font-bold disabled:opacity-50",children:ke?"...":"СоÑ
ÑаниÑÑ"})]}),Ze?e.jsx("div",{className:"h-20 bg-white/3 rounded-lg animate-pulse"}):e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx("div",{className:"col-span-2 flex items-center gap-3",children:e.jsxs("label",{className:"flex items-center gap-2 text-sm text-white cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:j.enabled,onChange:t=>T(a=>({...a,enabled:t.target.checked})),className:"rounded border-white/20"}),e.jsx(jt,{size:14,className:j.enabled?"text-green-400":"text-gray-500"}),j.enabled?"ÐоÑÑ Ð²ÐºÐ»ÑÑенÑ":"ÐоÑÑ Ð²ÑклÑÑенÑ"]})}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-gray-400",children:"ÐакÑ. Ð´Ð¾Ð»Ñ Ð±Ð¾Ñов"}),e.jsx("input",{type:"number",min:0,max:.4,step:.05,value:j.max_ratio,onChange:t=>T(a=>({...a,max_ratio:Math.min(.4,parseFloat(t.target.value)||0)})),className:"w-full mt-1 px-3 py-2 bg-black/30 border border-white/10 rounded-lg text-white text-sm"}),e.jsx("p",{className:"text-[10px] text-gray-600 mt-0.5",children:"ÐакÑимÑм 40% Ð¾Ñ ideal count"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-gray-400",children:"ÐакÑ. боÑов на ÑÑÑниÑ"}),e.jsx("input",{type:"number",min:0,max:32,value:j.max_per_tournament,onChange:t=>T(a=>({...a,max_per_tournament:parseInt(t.target.value)||0})),className:"w-full mt-1 px-3 py-2 bg-black/30 border border-white/10 rounded-lg text-white text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-gray-400",children:"УÑÐ¾Ð²ÐµÐ½Ñ Ð±Ð¾Ñов (1-8)"}),e.jsx("select",{value:j.level_override,onChange:t=>T(a=>({...a,level_override:t.target.value})),className:"w-full mt-1 px-3 py-2 bg-black/30 border border-white/10 rounded-lg text-white text-sm",children:[1,2,3,4,5,6,7,8].map(t=>e.jsxs("option",{value:String(t),children:["УÑÐ¾Ð²ÐµÐ½Ñ ",t]},t))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-gray-400",children:"ÐаÑза до (ISO)"}),e.jsx("input",{type:"text",value:j.paused_until||"",onChange:t=>T(a=>({...a,paused_until:t.target.value||null})),placeholder:"2026-04-01T00:00:00Z",className:"w-full mt-1 px-3 py-2 bg-black/30 border border-white/10 rounded-lg text-white text-sm"}),e.jsx("p",{className:"text-[10px] text-gray-600 mt-0.5",children:"ÐÑÑавÑÑе пÑÑÑÑм Ð´Ð»Ñ ÑнÑÑÐ¸Ñ Ð¿Ð°ÑзÑ"})]})]}),e.jsxs("div",{className:"border-t border-white/5 pt-3 space-y-1.5",children:[e.jsx("p",{className:"text-[10px] text-gray-500",children:"ÐоÑÑ Ð°Ð²ÑозаполнÑÑÑ ÑÑÑниÑÑ Ð´Ð¾ ближайÑей ÑÑепени двойки пеÑед авÑоÑÑаÑÑом."}),e.jsx("p",{className:"text-[10px] text-gray-500",children:"ÐоÑÑ Ð¿ÑозÑаÑÐ½Ñ (бейдж BOT), не полÑÑаÑÑ Ð¿ÑизÑ, не влиÑÑÑ Ð½Ð° Glicko-2 ÑейÑинг."})]})]})}),y==="list"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex gap-1.5",children:["","registration","ongoing","completed","cancelled"].map(t=>e.jsx("button",{onClick:()=>z(t),"data-testid":`admin-tournaments-filter-${t||"all"}`,className:h("px-2.5 py-1 rounded-lg text-xs font-bold transition-all",u===t?"bg-violet-600/20 text-violet-400":"text-gray-500 hover:text-gray-300 hover:bg-white/5"),children:t?F[t]?.label||t:"ÐÑе"},t))}),e.jsxs("div",{"data-testid":"admin-tournaments-club-events",className:"grid gap-3 lg:grid-cols-2",children:[e.jsxs("div",{className:"rounded-xl border border-red-500/15 bg-red-500/[0.04] p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-white",children:"ÐлÑбнÑе войнÑ"}),e.jsx("p",{className:"text-[11px] text-gray-400",children:"ÐивÑе ÑобÑÑÐ¸Ñ Ð¼ÐµÐ¶Ð´Ñ ÐºÐ»Ñбами, коÑоÑÑе влиÑÑÑ Ð½Ð° игÑоков"})]}),e.jsx("span",{className:"rounded-full border border-red-500/30 bg-red-500/10 px-2 py-1 text-[10px] font-black uppercase tracking-widest text-red-200",children:X.length})]}),e.jsx("div",{className:"mt-3 space-y-2",children:ue?e.jsx("div",{className:"h-20 rounded-lg bg-white/5 animate-pulse"}):X.length===0?e.jsx("p",{className:"rounded-lg border border-white/8 bg-black/20 px-3 py-2 text-xs text-gray-500",children:"ÐÐµÑ Ð°ÐºÑивнÑÑ
войн клÑбов"}):X.map(t=>e.jsxs("div",{className:"rounded-lg border border-white/8 bg-black/20 px-3 py-2",children:[e.jsxs("p",{className:"text-sm font-bold text-white",children:[t.challenger_name||"ÐлÑб"," vs ",t.defender_name||"ÐлÑб"]}),e.jsxs("p",{className:"mt-1 text-[11px] text-gray-400",children:["ФоÑмаÑ: ",t.format||"â"," · СÑÑÑ: ",t.score_challenger??0,":",t.score_defender??0," · ",t.status||"â"]}
1)]},t.id))})]}),e.jsxs("div",{className:"rounded-xl border border-violet-500/15 bg-violet-500/[0.04] p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-white",children:"ÐежклÑбнÑе ÑÑÑниÑÑ"}),e.jsx("p",{className:"text-[11px] text-gray-400",children:"СеÑии Ð¼ÐµÐ¶Ð´Ñ ÐºÐ»Ñбами, коÑоÑÑе идÑÑ Ð¿Ð°ÑаллелÑно обÑÑнÑм ÑÑÑниÑам"})]}),e.jsx("span",{className:"rounded-full border border-violet-500/30 bg-violet-500/10 px-2 py-1 text-[10px] font-black uppercase tracking-widest text-violet-200",children:Y.length})]}),e.jsx("div",{className:"mt-3 space-y-2",children:ue?e.jsx("div",{className:"h-20 rounded-lg bg-white/5 animate-pulse"}):Y.length===0?e.jsx("p",{className:"rounded-lg border border-white/8 bg-black/20 px-3 py-2 text-xs text-gray-500",children:"ÐÐµÑ Ð°ÐºÑивнÑÑ
межклÑбнÑÑ
ÑÑÑниÑов"}):Y.map(t=>e.jsxs("div",{className:"rounded-lg border border-white/8 bg-black/20 px-3 py-2",children:[e.jsx("p",{className:"text-sm font-bold text-white",children:t.name||"ÐежклÑбнÑй ÑÑÑниÑ"}),e.jsxs("p",{className:"mt-1 text-[11px] text-gray-400",children:[t.club1_name||"ÐлÑб"," vs ",t.club2_name||"ÐлÑб"," · СÑÑÑ: ",t.score1??0,":",t.score2??0," · ",t.status||"â"]})]},t.id))})]})]}),x&&e.jsxs("div",{className:"bg-white/5 border border-white/10 rounded-xl p-4 space-y-3",children:[e.jsx("h3",{className:"text-sm font-bold text-white",children:"ÐовÑй ÑÑÑниÑ"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"text-xs text-gray-400",children:"Ðазвание"}),e.jsx("input",{value:d.name,onChange:t=>c(a=>({...a,name:t.target.value})),"data-testid":"admin-tournament-name",className:"w-full mt-1 px-3 py-2 bg-black/30 border border-white/10 rounded-lg text-white text-sm focus:border-violet-500 focus:outline-none",placeholder:"ÐеÑенний ÑÑÑÐ½Ð¸Ñ 2026"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"text-xs text-gray-400",children:"ÐпиÑание"}),e.jsx("textarea",{value:d.description,onChange:t=>c(a=>({...a,description:t.target.value})),"data-testid":"admin-tournament-description",className:"w-full mt-1 px-3 py-2 bg-black/30 border border-white/10 rounded-lg text-white text-sm focus:border-violet-500 focus:outline-none resize-none",rows:3,placeholder:"ÐпиÑание ÑÑÑниÑа и аÑмоÑÑеÑÑ Ð±Ð°Ð½Ð½ÐµÑа"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-gray-400",children:"ФоÑмаÑ"}),e.jsx("select",{value:d.format,onChange:t=>c(a=>({...a,format:t.target.value})),"data-testid":"admin-tournament-format",className:"w-full mt-1 px-3 py-2 bg-black/30 border border-white/10 rounded-lg text-white text-sm",children:ee.map(t=>e.jsx("option",{value:t.key,children:t.shortLabel},t.key))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-gray-400",children:"ÐонÑÑÐ¾Ð»Ñ Ð²Ñемени"}),e.jsxs("select",{value:d.time_control,onChange:t=>c(a=>({...a,time_control:t.target.value})),"data-testid":"admin-tournament-time-control",className:"w-full mt-1 px-3 py-2 bg-black/30 border border-white/10 rounded-lg text-white text-sm",children:[e.jsx("option",{value:"3+2",children:"3+2 (Bullet)"}),e.jsx("option",{value:"5+3",children:"5+3 (Blitz)"}),e.jsx("option",{value:"10+5",children:"10+5 (Rapid)"}),e.jsx("option",{value:"30+20",children:"30+20 (Classical)"}),e.jsx("option",{value:"10+0",children:"10+0"}),e.jsx("option",{value:"5+0",children:"5+0"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-gray-400",children:"ÐакÑ. ÑÑаÑÑников"}),e.jsx("input",{type:"number",min:2,max:256,value:d.max_players,onChange:t=>c(a=>
1({...a,max_players:parseInt(t.target.value)||16})),"data-testid":"admin-tournament-max-players",className:"w-full mt-1 px-3 py-2 bg-black/30 border border-white/10 rounded-lg text-white text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-gray-400",children:"ÐÑÑÑпиÑелÑнÑй Ð²Ð·Ð½Ð¾Ñ (монеÑÑ)"}),e.jsx("input",{type:"number",min:0,value:d.entry_fee,onChange:t=>c(a=>({...a,entry_fee:parseInt(t.target.value)||0})),"data-testid":"admin-tournament-entry-fee",className:"w-full mt-1 px-3 py-2 bg-black/30 border border-white/10 rounded-lg text-white text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-gray-400",children:"ÐÑизовой Ñонд (монеÑÑ)"}),e.jsx("input",{type:"number",min:0,value:d.prize_pool,onChange:t=>c(a=>({...a,prize_pool:parseInt(t.target.value)||0})),"data-testid":"admin-tournament-prize-pool",className:"w-full mt-1 px-3 py-2 bg-black/30 border border-white/10 rounded-lg text-white text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-gray-400",children:"РеÑеÑалÑнÑй XP-бонÑÑ"}),e.jsx("input",{type:"number",min:0,value:d.referral_bonus_xp,onChange:t=>c(a=>({...a,referral_bonus_xp:parseInt(t.target.value)||0})),"data-testid":"admin-tournament-referral-bonus-xp",className:"w-full mt-1 px-3 py-2 bg-black/30 border border-white/10 rounded-lg text-white text-sm"})]}),d.format==="arena"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-gray-400",children:"ÐлиÑелÑноÑÑÑ Ð°ÑÐµÐ½Ñ (мин.)"}),e.jsx("input",{type:"number",min:5,max:240,value:d.arena_duration_minutes,onChange:t=>c(a=>({...a,arena_duration_minutes:parseInt(t.target.value)||60})),"data-testid":"admin-tournament-arena-duration",className:"w-full mt-1 px-3 py-2 bg-black/30 border border-white/10 rounded-lg text-white text-sm"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:d.is_rated,onChange:t=>c(a=>({...a,is_rated:t.target.checked})),className:"rounded border-white/20"}),e.jsx("label",{className:"text-xs text-gray-400",children:"РейÑинговÑй"})]}),e.jsx("div",{className:"col-span-2 rounded-xl border border-violet-500/20 bg-violet-500/5 p-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-xl leading-none",children:O.icon}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-bold text-white",children:O.shortLabel}),e.jsx("p",{className:"text-xs text-violet-200/90",children:Z(O.adminHintKey)}),e.jsx("ul",{className:"space-y-1 pt-1",children:O.joinRuleKeys.map(t=>e.jsxs("li",{className:"text-[11px] text-gray-300",children:["⢠",Z(t)]},t))})]})]})}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"text-xs text-gray-400",children:"ÐÐ°Ð½Ð½ÐµÑ ÑÑÑниÑа"}),e.jsxs("div",{className:"mt-1 space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:d.banner_url,onChange:t=>c(a=>({...a,banner_url:t.target.value})),"data-testid":"admin-tournament-banner-url",className:"w-full px-3 py-2 bg-black/30 border border-white/10 rounded-lg text-white text-sm focus:border-violet-500 focus:outline-none",placeholder:"/uploads/generated/tournament_banner/..."}),e.jsxs("button",{type:"button",onClick:()=>E({mode:"create"}),className:"inline-flex items-center gap-1.5 px-3 py-2 rounded-lg bg-cyan-600/15 text-cyan-200 border border-cyan-500/30 hover:bg-cyan-600/25 text-xs font-bold whitespace-nowrap",children:[e.jsx(Pe,{size:13}),"ÐиблиоÑека"]}),e.jsxs("button",{type:"button",onClick:st,disabled:se,"data-testid":"admin-tournament-banner-generate",className:"inline-flex items-center gap-1.5 px-3 py-2 rounded-lg bg-violet-600/20 text-violet-300 border border-violet-500/30 hover:bg-violet-600/30 disabled:opacity-50 text-xs font-bold whitespace-nowrap",children:[e.jsx(Oe,{size:13}),se?"ÐенеÑаÑиÑ...":"СгенеÑиÑоваÑÑ"]})]}),U(d.banner_url)&&e.jsx("img",{src:U(d.banner_url)||"",alt:"ÐÑедпÑоÑмоÑÑ Ð±Ð°Ð½Ð½ÐµÑа",className:"w-full h-36 rounded-xl object-cover border border-white/10",loading:"lazy"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 border-t border-white/5 pt-3 mt-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:d.is_private,onChange:t=>c(a=>({...a,is_private:t.target.checked})),"data-testid":"admin-tournament-private",className:"rounded border-white/20"}),e.jsx("label",{className:"text-xs text-gray-400",children:"ÐакÑÑÑÑй ÑÑÑниÑ"})]}),d.is_private&&e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-gray-400",children:"ÐаÑолÑ"}),e.jsx("input",{type:"text",value:d.password,onChange:t=>c(a=>({...a,password:t.target.value})),"data-testid":"admin-tournament-password",className:"w-full mt-1 px-3 py-2 bg-black/30 border border-white/10 rounded-lg text-white text-sm focus:border-violet-500 focus:outline-none",placeholder:"ÐаÑÐ¾Ð»Ñ Ð´Ð»Ñ Ð²Ñ
ода"})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx("button",{onClick:()=>S(!1),className:"px-4 py-2 rounded-lg bg-white/5 text-gray-400 text-sm hover:bg-white/10",children:"ÐÑмена"}),e.jsx("button",{onClick:at,disabled:te,"data-testid":"admin-tournament-save",className:"px-4 py-2 rounded-lg bg-violet-600 hover:bg-violet-500 text-white text-sm font-bold disabled:opacity-50",children:te?"Создание...":"СоздаÑÑ ÑÑÑниÑ"})]})]}),A&&e.jsxs("div",{className:"bg-white/5 border border-violet-500/20 rounded-xl p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-sm font-bold text-violet-400 flex items-center gap-2",children:[e.jsx(Be,{size:14})," СезоннÑе ÑÑÑниÑÑ (авÑо-Ñоздание)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{"data-testid":"admin-tournaments-season-add",onClick:ot,className:"flex items-center gap-1 px-2 py-1 rounded-lg bg-white/5 text-gray-400 text-xs hover:text-white hover:bg-white/10",children:[e.jsx(Me,{size:12})," Шаблон"]}),e.jsx("button",{onClick:dt,disabled:oe,"data-testid":"admin-tournaments-seasons-save",className:"flex items-center gap-1 px-2 py-1 rounded-lg bg-violet-600 text-white text-xs font-bold disabled:opacity-50",children:oe?"...":"СоÑ
ÑаниÑÑ"})]})]}),G.length===0?e.jsx("p",{className:"text-xs text-gray-500 py-2",children:"ÐÐµÑ ÑезоннÑÑ
Ñаблонов. ÐобавÑÑе Ñаблон Ð´Ð»Ñ Ð°Ð²ÑомаÑиÑеÑкого ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ ÑÑÑниÑов по ÑаÑпиÑаниÑ."}):e.jsx("div",{className:"space-y-2",children:G.map((t,a)=>e.jsxs("div",{"data-testid":`admin-tournaments-season-row-${a}`,className:h("border rounded-xl p-3 space-y-2",t.enabled?"border-violet-500/20 bg-violet-500/5":"border-white/5 bg-white/3 opacity-60"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("input",{value:t.name,onChange:s=>b(a,{name:s.target.value}),className:"bg-transparent text-white text-sm font-bold focus:outline-none border-b border-transparent focus:border-violet-500 w-48"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("label",{className:"flex items-center gap-1 text-xs text-gray-400",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:s=>b(a,{enabled:s.target.checked}),className:"rounded border-white/20"}),"ÐкÑивен"]}),e.jsx("button",{onClick:()=>ct(a),className:"p-1 text-red-400 hover:text-red-300",children:e.jsx(Ae,{size:12})})]})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-gray-500",children:"ÐенÑ"}),e.jsx("select",{value:t.cron_day,onChange:s=>b(a,{cron_day:s.target.value}),"data-testid":`admin-tournaments-season-day-${a}`,className:"w-full px-2 py-1 bg-black/30 border border-white/10 rounded text-white text-xs",children:Tt.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-gray-500",children:"Ð§Ð°Ñ (UTC)"}),e.jsx("input",{type:"number",min:0,max:23,value:t.cron_hour,onCh
1ange:s=>b(a,{cron_hour:parseInt(s.target.value)||0}),"data-testid":`admin-tournaments-season-hour-${a}`,className:"w-full px-2 py-1 bg-black/30 border border-white/10 rounded text-white text-xs"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-gray-500",children:"ФоÑмаÑ"}),e.jsx("select",{value:t.format,onChange:s=>b(a,{format:s.target.value}),"data-testid":`admin-tournaments-season-format-${a}`,className:"w-full px-2 py-1 bg-black/30 border border-white/10 rounded text-white text-xs",children:ee.map(s=>e.jsx("option",{value:s.key,children:s.shortLabel},s.key))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-gray-500",children:"ÐонÑÑолÑ"}),e.jsxs("select",{value:t.time_control,onChange:s=>b(a,{time_control:s.target.value}),"data-testid":`admin-tournaments-season-time-${a}`,className:"w-full px-2 py-1 bg-black/30 border border-white/10 rounded text-white text-xs",children:[e.jsx("option",{value:"3+2",children:"3+2"}),e.jsx("option",{value:"5+3",children:"5+3"}),e.jsx("option",{value:"10+5",children:"10+5"}),e.jsx("option",{value:"10+0",children:"10+0"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-gray-500",children:"ÐакÑ. игÑоков"}),e.jsx("input",{type:"number",min:2,max:256,value:t.max_players,onChange:s=>
1b(a,{max_players:parseInt(s.target.value)||16}),"data-testid":`admin-tournaments-season-max-${a}`,className:"w-full px-2 py-1 bg-black/30 border border-white/10 rounded text-white text-xs"})]}),t.format==="arena"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-gray-500",children:"ÐлиÑелÑноÑÑÑ Ð°ÑенÑ"}),e.jsx("input",{type:"number",min:5,max:240,value:t.arena_duration_minutes??60,onChange:s=>b(a,{arena_duration_minutes:parseInt(s.target.value)||60}),"data-testid":`admin-tournaments-season-arena-duration-${a}`,className:"w-full px-2 py-1 bg-black/30 border border-white/10 rounded text-white text-xs"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-gray-500",children:"ÐзноÑ"}),e.jsx("input",{type:"number",min:0,value:t.entry_fee,onChange:s=>b(a,{entry_fee:parseInt(s.target.value)||0}),"data-testid":`admin-tournaments-season-entry-fee-${a}`,className:"w-full px-2 py-1 bg-black/30 border border-white/10 rounded text-white text-xs"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-gray-500",children:"ÐÑизÑ"}),e.jsx("input",{type:"number",min:0,value:t.prize_pool,onChange:s=>b(a,{prize_pool:parseInt(s.target.value)||0}),"data-testid":`admin-tournaments-season-prize-pool-${a}`,className:"w-full px-2 py-1 bg-black/30 border border-white/10 rounded text-white text-xs"})]}),e.jsx("div",{className:"flex items-end pb-1",children:e.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-gray-500",children:[e.jsx("input",{type:"checkbox",checked:t.is_rated,onChange:s=>b(a,{is_rated:s.target.checked}),className:"rounded border-white/20"}),"РейÑинг"]})}),e.jsxs("div",{className:"col-span-4 rounded-lg border border-white/10 bg-black/20 px-2.5 py-2",children:[e.jsx("p",{className:"text-[11px] font-bold text-white",children:Q(t.format).shortLabel}),e.jsx("p",{className:"text-[10px] text-gray-400 mt-0.5",children:Z(Q(t.format).descKey)})]})]})]},a))}),e.jsx("p",{className:"text-[10px] text-gray-600",children:"ÐÑон-задаÑа пÑовеÑÑÐµÑ ÑÐ°Ð±Ð»Ð¾Ð½Ñ ÐºÐ°Ð¶Ð´Ñй ÑаÑ. ÐÑли наÑÑÑпил назнаÑеннÑй денÑ/ÑÐ°Ñ Ð¸ Ð½ÐµÑ Ð°ÐºÑивного ÑÑÑниÑа Ñ Ñаким именем â ÑоздаÑÑÑÑ Ð½Ð¾Ð²Ñй авÑомаÑиÑеÑки."})]}),p?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(t=>e.jsx("div",{className:"h-16 bg-white/3 border border-white/5 rounded-xl animate-pulse"},t))}):g.length===0?e.jsxs("div",{className:"text-center text-gray-500 py-12",children:["ÐÐµÑ ÑÑÑниÑов",u?` Ñо ÑÑаÑÑÑом «${F[u]?.label||u}»`:""]}):e.jsx("div",{className:"space-y-2",children:g.map(t=>{const a=F[t.status]||{label:t.status,color:"bg-white/10 text-gray-400 border-white/10"},s=Xe===t.id,i=t.max_participants||t.max_players||0;return e.jsxs("div",{className:"border border-white/10 rounded-xl overflow-hidden",children:[e.jsxs("button",{"data-testid":`admin-tournament-expand-${t.id}`,onClick:()=>{const l=s?null:t.id;Ye(l),D(o=>o[t.id]===void 0?{...o,[t.id]:t.banner_url??""}:o),B(o=>o[t.id]===void 0?{...o,[t.id]:{mode:"delay",delayMinutes:N,customStart:""}}:o),l&&t.status==="completed"&&Te(t.id)},className:"w-full flex items-center gap-3 px-4 py-3 hover:bg-white/3 transition-all text-left",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-bold text-white truncate",children:t.name}),e.jsx("span",{className:h("px-1.5 py-0.5 rounded text-[10px] font-bold border",a.color),children:a.label})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5 text-[11px] text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(wt,{size:10}),Ue[t.format||""]||t.format||"?"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Nt,{size:10}),t.time_control||"?"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ee,{size:10}),t.participant_count??"?","/",i]}),(t.prize_pool||0)>0&&e.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[e.jsx(_t,{size:10}),t.prize_pool]}
1),t.current_round&&e.jsxs("span",{className:"text-violet-400",children:["РаÑнд ",t.current_round,t.pending_matches?` (${t.pending_matches} ожид.)`:""]})]})]}),s?e.jsx(kt,{size:16,className:"text-gray-500"}):e.jsx(Ct,{size:16,className:"text-gray-500"})]}),s&&e.jsxs("div",{"data-testid":`admin-tournament-panel-${t.id}`,className:"px-4 pb-3 pt-1 border-t border-white/5 space-y-2",children:[t.status==="registration"&&e.jsxs("div",{className:"rounded-xl border border-emerald-500/15 bg-emerald-500/[0.05] p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-widest text-emerald-300",children:"СÑаÑÑ Ð¿ÐµÑвого ÑаÑнда"}),e.jsx("p",{className:"mt-1 text-[11px] text-gray-400",children:"ÐгÑоки ÑвидÑÑ countdown до оÑкÑÑÑÐ¸Ñ check-in."})]}),e.jsx("span",{className:"rounded-full border border-emerald-500/20 bg-emerald-500/10 px-2 py-1 text-[10px] font-black uppercase tracking-widest text-emerald-200",children:"check-in"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{onClick:()=>B(l=>{const o=l[t.id]??{mode:"delay",delayMinutes:N,customStart:""};return{...l,[t.id]:{...o,mode:"delay"}}}),className:h("px-3 py-1.5 rounded-lg border text-xs font-bold transition-all",I(t.id).mode==="delay"?"border-emerald-500/30 bg-emerald-500/15 text-emerald-200":"border-white/10 bg-white/5 text-gray-400 hover:text-white"),children:"ЧеÑез N минÑÑ"}),e.jsx("button",{onClick:()=>B(l=>{const o=l[t.id]??{mode:"delay",delayMinutes:N,customStart:""};return{...l,[t.id]:{...o,mode:"custom"}}}),className:h("px-3 py-1.5 rounded-lg border text-xs font-bold transition-all",I(t.id).mode==="custom"?"border-emerald-500/30 bg-emerald-500/15 text-emerald-200":"border-white/10 bg-white/5 text-gray-400 hover:text-white"),children:"Ð¡Ð²Ð¾Ñ Ð²ÑемÑ"})]}),I(t.id).mode==="delay"?e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-gray-400",children:"ÐадеÑжка до ÑÑаÑÑа ÑаÑнда (мин)"}),e.jsx("input",{type:"number",min:0,max:180,value:I(t.id).delayMinutes,onChange:l=>B(o=>{const m=o[t.id]??{mode:"delay",delayMinutes:N,customStart:""};return{...o,[t.id]:{...m,delayMinutes:Math.max(0,Math.min(180,parseInt(l.target.value,10)||0))}}}),"data-testid":`admin-tournament-start-delay-${t.id}`,className:"mt-1 w-full px-3 py-2 bg-black/30 border border-white/10 rounded-lg text-white text-sm"})]}):e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-gray-400",children:"СÑаÑÑ Ð¿ÐµÑвого ÑаÑнда"}),e.jsx("input",{type:"datetime-local",value:I(t.id).customStart,onChange:l=>B(o=>{const m=o[t.id]??{mode:"delay",delayMinutes:N,customStart:""};return{...o,[t.id]:{...m,customStart:l.target.value}}}),"data-testid":`admin-tournament-start-datetime-${t.id}`,className:"mt-1 w-full px-3 py-2 bg-black/30 border border-white/10 rounded-lg text-white text-sm"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.status==="ongoing"&&e.jsx(e.Fragment,{children:e.jsx(V,{icon:e.jsx(Re,{size:12}),label:"ÐÑмениÑÑ",color:"red",dataTestId:`admin-tournament-cancel-${t.id}`,onClick:()=>ze(t.id,"cancel","ÐÑмениÑÑ ÑÑÑÐ½Ð¸Ñ Ð¸ веÑнÑÑÑ Ð²Ð·Ð½Ð¾ÑÑ?")})}),t.status==="registration"&&e.jsxs(e.Fragment,{children:[e.jsx(V,{icon:e.jsx(St,{size:12}),label:"СÑаÑÑ",color:"green",dataTestId:`admin-tournament-start-${t.id}`,onClick:()=>it(t)}),e.jsx(V,{icon:e.jsx(Re,{size:12}),label:"ÐÑмениÑÑ",color:"red",dataTestId:`admin-tournament-cancel-${t.id}`,onClick:()=>ze(t.id,"cancel","ÐÑмениÑÑ Ð¸ веÑнÑÑÑ Ð²Ð·Ð½Ð¾ÑÑ?")})]})]}),e.jsxs("div",{className:"text-[10px] text-gray-600 space-y-0.5",children:[e.jsxs("p",{children:["ID: ",t.id]}),t.created_at&&e.jsxs("p",{children:["Создан: ",new Date(t.created_at).toLocaleString()]}),t.description&&e.jsxs("p",{children:["ÐпиÑание: ",t.description]}),e.jsxs("p",{children:["РейÑинговÑй: ",t.is_rated?"Ðа":"ÐеÑ"," · ÐзноÑ: ",t.entry_fee||0," монеÑ"]}),(t.referral_bonus_xp||0)>0&&e.jsxs("p",{children:["РеÑеÑалÑнÑй бонÑÑ: +",t.referral_bonus_xp," XP пÑиглаÑивÑÐµÐ¼Ñ Ð¸Ð³ÑокÑ"]})]}),t.status==="completed"&&e.jsx(It,{detail:J[t.id],loading:Je===t.id,onRetry:()=>{be(l=>{const o={...l};return delete o[t.id],o}),Te(t.id)}}),e.jsxs("div",{className:"pt-2 border-t border-white/5 space-y-2",children:[e.jsx("label",{className:"text-[10px] text-gray-500 uppercase tracking-widest font-bold",children:"ÐаннеÑ"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:L[t.id]??t.banner_url??"",onChange:l=>D(o=>({...o,[t.id]:l.target.value})),"data-testid":`admin-tournament-banner-input-${t.id}`,className:"w-full px-3 py-2 bg-black/30 border border-white/10 rounded-lg text-white text-xs focus:border-violet-500 focus:outline-none",placeholder:"/uploads/generated/tournament_banner/..."}),e.jsxs("button",{type:"button",onClick:()=>E({mode:"existing",tournamentId:t.id}),className:"inline-flex items-center gap-1 px-2.5 py-2 rounded-lg bg-cyan-600/15 text-cyan-200 border border-cyan-500/30 hover:bg-cyan-600/25 text-xs font-bold whitespace-nowrap",children:[e.jsx(Pe,{size:12}),"Ðибл."]}),e.jsxs("button",{onClick:()=>rt(t),disabled:ne===t.id,"data-testid":`admin-tournament-banner-generate-${t.id}`,className:"inline-flex items-center gap-1 px-2.5 py-2 rounded-lg bg-violet-600/20 text-violet-300 border border-violet-500/30 hover:bg-violet-600/30 disabled:opacity-50 text-xs font-bold whitespace-nowrap",children:[e.jsx(Oe,{size:12}),ne===t.id?"...":"AI"]}),e.jsx("button",{onClick:()=>
1nt(t.id),disabled:ie===t.id,"data-testid":`admin-tournament-banner-save-${t.id}`,className:"px-2.5 py-2 rounded-lg bg-emerald-600/20 text-emerald-300 border border-emerald-500/30 hover:bg-emerald-600/30 disabled:opacity-50 text-xs font-bold whitespace-nowrap",children:ie===t.id?"СоÑ
Ñанение...":"СоÑ
ÑаниÑÑ"})]}),U(L[t.id]??t.banner_url)&&e.jsx("img",{src:U(L[t.id]??t.banner_url)||"",alt:"ÐÐ°Ð½Ð½ÐµÑ ÑÑÑниÑа",className:"w-full h-40 rounded-xl object-cover border border-white/10",loading:"lazy"})]})]})]},t.id)})}),e.jsx(bt,{open:v!==null,title:"ÐиблиоÑека баннеÑов ÑÑÑниÑов",description:"ÐÑбеÑиÑе гоÑовÑй Ð±Ð°Ð½Ð½ÐµÑ Ð¸Ð· обÑей библиоÑеки или загÑÑзиÑе новÑй Ñайл пÑÑмо в каÑалог.",keyScope:"tournaments",selectedUrl:v?.mode==="create"?d.banner_url:v?.mode==="existing"?L[v.tournamentId]??g.find(t=>t.id===v.tournamentId)?.banner_url??"":null,onSelect:lt,onClose:()=>E(null)})]})]})},It=({detail:r,loading:g,onRetry:C})=>{const p=r?.post_mortem,f=p?.standings??r?.participants??[],u=r?.rounds??[],z=p?.winner??f[0]??null;return g&&!r?e.jsx("div",{className:"rounded-xl border border-white/8 bg-white/5 p-3 text-xs text-gray-400",children:"ÐагÑÑжаем иÑоги ÑÑÑниÑа..."}):r?e.jsxs("div",{className:"rounded-xl border border-violet-500/20 bg-violet-500/5 p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-widest text-violet-200",children:"Post-mortem"}),e.jsx("p",{className:"text-[11px] text-gray-400",children:"ÐобедиÑелÑ, ÑаблиÑа, ÑÑаÑÑники и ÐÑÑоÑÐ¸Ñ Ð¼Ð°ÑÑей загÑÑжаÑÑÑÑ Ð¸Ð· admin detail."})]}),e.jsxs("span",{className:"rounded-full border border-violet-500/25 bg-violet-500/10 px-2 py-1 text-[10px] font-bold text-violet-100",children:[p?.participants_count??f.length," ÑÑаÑÑников"]})]}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg border border-white/8 bg-black/20 p-2",children:[e.jsx("div",{className:"text-[10px] uppercase text-gray-500",children:"ÐобедиÑелÑ"}),e.jsx("div",{className:"mt-1 font-mono text-sm font-black text-white",children:z?.user_id??"Ð½ÐµÑ Ð´Ð°Ð½Ð½ÑÑ
"}),z&&e.jsxs("div",{className:"text-xs text-violet-200",children:[z.score??0," оÑков"]})]}),e.jsxs("div",{className:"rounded-lg border border-white/8 bg-black/20 p-2",children:[e.jsx("div",{className:"text-[10px] uppercase text-gray-500",children:"РаÑндÑ"}),e.jsx("div",{className:"mt-1 text-sm font-black text-white",children:p?.round_summary?.length??"â"}),e.jsxs("div",{className:"text-xs text-gray-500",children:[u.length," маÑÑей в пеÑвой ÑÑÑаниÑе"]})]}),e.jsxs("div",{className:"rounded-lg border border-white/8 bg-black/20 p-2",children:[e.jsx("div",{className:"text-[10px] uppercase text-gray-500",children:"ÐÑÐ¸Ð·Ñ / ÑейÑинг"}),e.jsx("div",{className:"mt-1 text-xs text-gray-300",children:p?.prize_effects_available||p?.rating_effects_available?"ÐÑÑÑ ÑÑÑекÑÑ":"ÐÐµÑ ÑоÑ
ÑанÑннÑÑ
ÑÑÑекÑов"})]})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-[10px] font-black uppercase tracking-widest text-gray-500",children:"ÐÑÐ¾Ð³Ð¾Ð²Ð°Ñ ÑаблиÑа"}),e.jsx("div",{className:"space-y-1",children:f.length===0?e.jsx("div",{className:"rounded-lg border border-white/8 bg-black/20 px-3 py-2 text-xs text-gray-500",children:"УÑаÑÑники не найденÑ"}):f.slice(0,8).map((x,S)=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-black/20 px-3 py-2 text-xs",children:[e.jsxs("span",{className:"font-mono text-gray-300",children:["#",x.rank??S+1," ",x.user_id]}),e.jsx("span",{className:"font-black text-white",children:x.score??0})]},`${x.user_id}-${S}`))})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-[10px] font-black uppercase tracking-widest text-gray-500",children:"ÐÑÑоÑÐ¸Ñ Ð¼Ð°ÑÑей"}),e.jsx("div",{className:"space-y-1",children:u.length===0?e.jsx("div",{className:"rounded-lg border border-white/8 bg-black/20 px-3 py-2 text-xs text-gray-500",children:"ÐаÑÑи не найденÑ"}):u.map(x=>e.jsxs("div",{className:"rounded-lg bg-black/20 px-3 py-2 text-xs text-gray-300",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["РаÑнд ",x.round_number,": ",x.white_id??"BYE"," vs ",x.black_id??"BYE"]}),e.jsx("span",{className:"font-bold text-white",children:x.result??"â"})]}),x.game_id&&e.jsx("div",{className:"mt-1 font-mono text-[10px] text-gray-600",children:x.game_id})]},x.id))}),(r.rounds_has_more||p?.match_history_has_more)&&e.jsx("p",{className:"mt-2 text-[10px] text-amber-200",children:"ÐÐ¾ÐºÐ°Ð·Ð°Ð½Ñ Ð¿ÐµÑвÑе 50 маÑÑей. ÐÑÑоÑÐ¸Ñ Ð¾Ð³ÑаниÑена Ð´Ð»Ñ ÑкоÑоÑÑи."})]})]})]}):e.jsxs("div",{className:"rounded-xl border border-amber-500/20 bg-amber-500/10 p-3 text-xs text-amber-100",children:["ÐÑоги ÑÑÑниÑа пока недоÑÑÑпнÑ.",e.jsx("button",{type:"button",onClick:C,className:"ml-3 font-bold text-amber-50 hover:underline",children:"ÐовÑоÑиÑÑ"})]})},V=({icon:r,label:g,color:C,onClick:p,dataTestId:f})=>{const u={green:"bg-green-600/20 text-green-400 hover:bg-green-600/30 border-green-500/20",red:"bg-red-600/20 text-red-400 hover:bg-red-600/30 border-red-500/20",violet:"bg-violet-600/20 text-violet-400 hover:bg-violet-600/30 border-violet-500/20",yellow:"bg-yellow-600/20 text-yellow-400 hover:bg-yellow-600/30 border-yellow-500/20"};return e.jsxs("button",{onClick:p,"data-testid":f,className:h("flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg border text-xs font-bold transition-all",u[C]),children:[r," ",g]})};export{Yt as AdminTournamentsTab};
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.