import{$ as e,A as t,B as n,F as r,K as i,N as a,Q as o,V as s,X as c,_ as l,f as u,g as d,h as f,n as p,p as m,s as h,v as g,x as _,y as v}from"./vendor-vue-D9nMs6_1.js";import{i as y,r as b,t as x}from"./backendApi-CRLUmnjv.js";import{l as S,n as C,r as w,t as T}from"./style-editor-CCYkJCsR.js";import{t as E}from"./useCustomCss-DFnb_9hT.js";import{n as D,t as O}from"./renderReady-m0ZpQ02H.js";import{n as k,o as A,r as j}from"./placeholderResolver-DrfuyaOo.js";import{t as M}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{t as N}from"./bestoftype-D9b0yRcs.js";import{t as P}from"./FearlessChampionEntry-C6H3sdsC.js";var F=M(_({__name:`FearlessDraft`,props:{matchId:{},previewData:{}},setup(_){let M=[`TOP`,`JUNGLE`,`MID`,`BOTTOM`,`SUPPORT`],F=[`top`,`jgl`,`mid`,`bot`,`sup`].map(e=>`/style/common/lane/${e}-placeholder-cropped.svg`),I=_,L=h(),R=b(),{t:z}=p(),{style:B}=D(`PostgameFearlessDraftV2`),V=B;S(V,`PostgameFearlessDraftV2`),E(V,`PostgameFearlessDraftV2`);let H=i(),U=i(0),W=i(),G=i(!0),K=m(()=>k({leftTeam:W.value?.teams[0],rightTeam:W.value?.teams[1],matchName:W.value?.name,matchDate:W.value?.date,baseCtx:j({matchDate:W.value?.date})})),q=m(()=>B.value?A(B.value.titleTemplate,K.value):``),J=m(()=>B.value?A(B.value.subtitleTemplate,K.value):``),Y=m(()=>Math.max(0,Math.min(B.value?.visibleGames||U.value-1,U.value-1))),X=m(()=>Math.max(2,(B.value?.gamesPerRow??2)*2));function Z(e){let t=[];return Object.values(H.value??{}).slice(0,Y.value).forEach(n=>Object.values(n).forEach(n=>{n[e]&&t.push(n[e])})),t}function Q(e){let t=Z(e),n=[],r=Y.value*2;for(let e=0;e<r;e+=X.value)n.push(Array.from({length:Math.min(X.value,r-e)},(n,r)=>t[e+r]));return n}function ee(){return I.matchId??(Number(L.params.matchId||L.query.matchId)||`current`)}function te(e){let t=Number(e);return Number.isNaN(t)?N[e]??5:t}async function $(){if(G.value=!0,I.previewData){H.value=I.previewData.bans,U.value=I.previewData.gameCount,W.value=I.previewData.match,G.value=!1,await O();return}try{let e=ee(),t=R.mocking?`/match/current`:`/match/${e}`,[n,r,i]=await Promise.all([y.get(`${t}/fearless/bans`),y.get(`${t}/bestof`),y.get(R.mocking?`/postgame/matchdata/mock`:`/postgame/matchdata/${e}`)]);H.value=n.data,U.value=te(r.data),W.value=i.data,await O()}catch(e){console.error(`Error loading fearless draft:`,e),H.value=void 0}finally{G.value=!1}}return n(()=>[I.matchId,L.params.matchId,L.query.matchId,R.mocking,R.statsVersion],$),t($),(t,n)=>c(B)?(a(),f(c(w),{key:0,element:c(B),content:``,class:`postgame-fearless-draft-v2`},{default:s(()=>[v(c(w),{element:c(B).header},{default:s(()=>[v(c(T),{"text-style":c(B).title.text},{default:s(()=>[g(e(q.value),1)]),_:1},8,[`text-style`]),v(c(T),{"text-style":c(B).subtitle.text},{default:s(()=>[g(e(J.value),1)]),_:1},8,[`text-style`])]),_:1},8,[`element`]),G.value||!H.value?(a(),f(c(T),{key:0,"text-style":c(B).status.text,class:`fearless-status`},{default:s(()=>[g(e(c(z)(G.value?`postgame.fearless.loading`:`postgame.fearless.noData`)),1)]),_:1},8,[`text-style`])):(a(),f(c(w),{key:1,element:c(B).lanes,class:`fearless-lanes`},{default:s(()=>[(a(),l(u,null,r(5,t=>v(c(w),{key:t,element:c(B).lane.container},{default:s(()=>[v(c(C),{"image-style":c(B).lane.icon.image,src:c(x).getCacheUrl(c(F)[t-1]),alt:M[t-1]},null,8,[`image-style`,`src`,`alt`]),v(c(T),{"text-style":c(B).lane.heading.text},{default:s(()=>[g(e(M[t-1]),1)]),_:2},1032,[`text-style`]),v(c(w),{element:c(B).lane.rows},{default:s(()=>[(a(!0),l(u,null,r(Q(t-1),(e,n)=>(a(),f(c(w),{key:n,element:c(B).lane.row,"style-override":{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`}},{default:s(()=>[(a(!0),l(u,null,r(e,(e,n)=>(a(),f(P,{key:n,style:o(c(B).lane.champion),champion:e,"placeholder-src":c(F)[t-1]},null,8,[`style`,`champion`,`placeholder-src`]))),128))]),_:2},1032,[`element`,`style-override`]))),128))]),_:2},1032,[`element`])]),_:2},1032,[`element`])),64))]),_:1},8,[`element`]))]),_:1},8,[`element`])):d(``,!0)}}),[[`__scopeId`,`data-v-79d1bdac`]]);export{F as default};