import{t as e}from"./rolldown-runtime-DK3Fl9T5.js";import{$ as t,A as n,B as r,F as i,K as a,N as o,Q as s,V as c,X as l,_ as u,f as d,g as f,h as p,n as m,p as h,s as g,v as _,x as v,y}from"./vendor-vue-D9nMs6_1.js";import{i as b,r as x}from"./backendApi-CRLUmnjv.js";import{l as S,r as C,t as w}from"./style-editor-CCYkJCsR.js";import{t as T}from"./useCustomCss-DFnb_9hT.js";import{n as E,t as D}from"./renderReady-m0ZpQ02H.js";import{n as O,o as k,r as A}from"./placeholderResolver-DrfuyaOo.js";import{t as j}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{t as M}from"./bestoftype-D9b0yRcs.js";import{t as N}from"./FearlessChampionEntry-C6H3sdsC.js";var P=v({__name:`FearlessTree`,props:{matchId:{},previewData:{}},setup(e){let v=e,j=g(),P=x(),{t:F}=m(),{style:I}=E(`FearlessTreeV2`),L=I;S(L,`FearlessTreeV2`),T(L,`FearlessTreeV2`);let R=a(),z=a(0),B=a(),V=a(),H=a(!0),U=h(()=>O({leftTeam:B.value?.teams[0],rightTeam:B.value?.teams[1],matchName:B.value?.name,matchDate:B.value?.date,baseCtx:A({season:V.value,matchDate:B.value?.date})})),W=h(()=>I.value?k(I.value.titleTemplate,U.value):``),G=h(()=>I.value?k(I.value.subtitleTemplate,U.value):``),K=h(()=>B.value?.games??[]),q=h(()=>{let e=Math.min(K.value.length,Object.keys(R.value??{}).length+1,z.value);return Math.max(0,Math.min(I.value?.visibleGames||e,K.value.length))}),J=h(()=>K.value.slice(0,q.value));function Y(e,t){let n=R.value?.[e];return n?n[Object.keys(n).map(Number)[t]]??[]:[]}function X(e,t){return J.value.slice(0,e).flatMap(e=>Y(e.gameId,t))}function Z(e){return B.value?.teams[e]?.name??F(`postgame.fearless.team`,{number:e+1})}function Q(e){return k(I.value?.gameLabelTemplate??``,{...U.value,gameNumber:e+1})}function ee(){return v.matchId??(Number(j.params.matchId||j.query.matchId)||`current`)}function te(e){let t=Number(e);return Number.isNaN(t)?M[e]??5:t}async function $(){if(H.value=!0,v.previewData){R.value=v.previewData.bans,z.value=v.previewData.gameCount,B.value=v.previewData.match,V.value=v.previewData.season,H.value=!1,await D();return}try{let e=ee(),t=P.mocking,[n,r,i,a]=await Promise.all([b.get(`/match/${t?`current`:e}/fearless/bans`),b.get(`/match/${t?`current`:e}/bestof`),b.get(t?`/postgame/matchdata/mock`:`/postgame/matchdata/${e}`),b.get(`/season/current`)]);R.value=n.data,z.value=te(r.data),B.value=i.data,V.value=a.data,await D()}catch(e){console.error(`Error loading fearless tree:`,e),R.value=void 0}finally{H.value=!1}}return r(()=>[v.matchId,j.params.matchId,j.query.matchId,P.mocking,P.statsVersion],$),n($),(e,n)=>l(I)?(o(),p(l(C),{key:0,element:l(I),content:``,class:`fearless-tree-v2`},{default:c(()=>[y(l(C),{element:l(I).header},{default:c(()=>[y(l(w),{"text-style":l(I).title.text},{default:c(()=>[_(t(W.value),1)]),_:1},8,[`text-style`]),y(l(w),{"text-style":l(I).subtitle.text},{default:c(()=>[_(t(G.value),1)]),_:1},8,[`text-style`])]),_:1},8,[`element`]),H.value||!R.value||!J.value.length?(o(),p(l(w),{key:0,"text-style":l(I).status.text,class:`fearless-status`},{default:c(()=>[_(t(l(F)(H.value?`postgame.fearless.loading`:`postgame.fearless.noData`)),1)]),_:1},8,[`text-style`])):(o(),p(l(C),{key:1,element:l(I).tree,class:`fearless-tree-games`},{default:c(()=>[(o(!0),u(d,null,i(J.value,(e,n)=>(o(),u(d,{key:e.gameId},[n?(o(),p(l(C),{key:0,element:l(I).connector,class:`fearless-tree-connector`},null,8,[`element`])):f(``,!0),y(l(C),{element:l(I).game.container,class:`fearless-game`},{default:c(()=>[y(l(w),{"text-style":l(I).game.heading.text},{default:c(()=>[_(t(Q(n)),1)]),_:2},1032,[`text-style`]),y(l(C),{element:l(I).game.teams},{default:c(()=>[(o(),u(d,null,i(2,r=>y(l(C),{key:r,element:l(I).game.team},{default:c(()=>[y(l(w),{"text-style":l(I).game.teamHeading.text},{default:c(()=>[_(t(Z(r-1)),1)]),_:2},1032,[`text-style`]),X(n,r-1).length?(o(),p(l(C),{key:0,element:l(I).game.previous,class:`fearless-ban-strip`},{default:c(()=>[(o(!0),u(d,null,i(X(n,r-1),(e,t)=>(o(),p(N,{key:t,style:s(l(I).game.previousChampion),champion:e,muted:``},null,8,[`style`,`champion`]))),128))]),_:2},1032,[`element`])):f(``,!0),y(l(C),{element:l(I).game.current,class:`fearless-ban-strip`},{default:c(()=>[(o(),u(d,null,i(5,t=>y(N,{key:t,style:s(l(I).game.currentChampion),champion:Y(e.gameId,r-1)[t-1]},null,8,[`style`,`champion`])),64))]),_:2},1032,[`element`])]),_:2},1032,[`element`])),64))]),_:2},1032,[`element`])]),_:2},1032,[`element`])],64))),128))]),_:1},8,[`element`]))]),_:1},8,[`element`])):f(``,!0)}}),F=e({default:()=>I}),I=j(P,[[`__scopeId`,`data-v-9f816c21`]]);export{F as n,I as t};