(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7675],{48917:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/cdl",function(){return t(93207)}])},78531:function(e,n,t){"use strict";t.d(n,{Z:function(){return _}});var a=t(85893),r=t(65984),l=t(39484),o=t(38878),i=t(95429),s=t(24920),d=t(25675),c=t.n(d),m=t(41664),u=t.n(m);function _(){let e=(0,r.rZ)(),n=(0,l.X)();return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(o.Z,{p:0,style:{backgroundColor:"dark"===n.colorScheme?e.colors.dark[8]:e.colors.gray[1]},children:(0,a.jsxs)(i.k,{direction:"column",children:[(0,a.jsx)("div",{style:{position:"relative",aspectRatio:"831/196"},children:(0,a.jsx)(c(),{src:"dark"===n.colorScheme?"/images/bpl/CDL-TAB-Light.webp":"/images/bpl/CDL-TAB-Dark.webp",alt:"BP x CDL logo",fill:!0,style:{objectFit:"contain"}})}),(0,a.jsxs)(i.k,{gap:8,justify:"left",p:16,wrap:"wrap",direction:"row",children:[(0,a.jsx)(u(),{href:"/cdl",style:{flex:1},children:(0,a.jsx)(s.z,{w:"100%",variant:"light",color:"gray",style:{boxShadow:"0px 0px 5px 0px rgba(0,0,0,0.25)",color:"dark"===n.colorScheme?"white":"black"},children:"Standings"})}),(0,a.jsx)(u(),{href:"/cdl/teams-and-players",style:{flex:1},children:(0,a.jsx)(s.z,{w:"100%",variant:"light",color:"gray",style:{boxShadow:"0px 0px 5px 0px rgba(0,0,0,0.25)",color:"dark"===n.colorScheme?"white":"black"},children:"Teams & Players"})}),(0,a.jsx)(u(),{href:"/cdl/events",style:{flex:1},children:(0,a.jsx)(s.z,{w:"100%",variant:"light",color:"gray",style:{boxShadow:"0px 0px 5px 0px rgba(0,0,0,0.25)",color:"dark"===n.colorScheme?"white":"black"},children:"Events"})})]})]})})})}},93207:function(e,n,t){"use strict";t.r(n),t.d(n,{__N_SSP:function(){return B},default:function(){return H}});var a=t(85893),r=t(65984),l=t(39484),o=t(38878),i=t(67294),s=t(95429),d=t(28008),c=t(24920),m=t(10576),u=t(70313),_=t(96486),h=t.n(_),g=t(79274),f=t(82922),v=t(41664),p=t.n(v),x=t(25675),w=t.n(x),k=t(1506),b=t(49746),j=t(89734),y=t.n(j),S=t(78964),N=t(68660),O=t(29425),E=t(86402),L=t(95448),C=t(89383),q=t(24777),Q=t(40437);let I={online:"ONLINE",lan:"LAN"},D=(0,f.k)(e=>({teamLogo:{marginRight:e.spacing.sm}}));function M(e){let{loading:n,standings:t,showPoints:o=!0}=e,{classes:d}=D(),c=(0,r.rZ)(),m=(0,l.X)(),u=(0,S.a)("(max-width: ".concat(c.breakpoints.md,"px)")),[_,h]=(0,i.useState)({columnAccessor:"rank",direction:"asc"}),[g,f]=(0,i.useState)();return(0,i.useEffect)(()=>{let e=y()(t,_.columnAccessor);f("desc"===_.direction?e.reverse():e)},[t,_]),(0,a.jsx)(a.Fragment,{children:n?(0,a.jsx)(k.O,{height:600}):(0,a.jsx)(N.wQ,{columns:[{accessor:"rank",sortable:!0,title:u?"#":"Rank"},{accessor:"team_name",render:e=>{var n,t;let r="dark"===m.colorScheme?null===(n=e.team_logo_darkmode)||void 0===n?void 0:n.logo_darkmode:null===(t=e.team_logo_lightmode)||void 0===t?void 0:t.logo_lightmode;return(0,a.jsxs)(s.k,{align:"center",children:[r&&(0,a.jsx)(w(),{alt:"".concat(e.team_name.name," logo"),className:d.teamLogo,objectFit:"contain",height:u?20:32,width:u?20:32,src:r}),(0,a.jsx)(b.l,{children:(0,a.jsx)(p(),{href:"/teams/".concat(e.team_id),style:{fontSize:12},children:u?e.team_name_short.name_short:e.team_name.name})})]})},sortable:!0,title:"Team"},{accessor:"points",sortable:!0,title:u?"Pts":"Points",hidden:!o},{accessor:"match_wins",sortable:!0,title:"MW"},{accessor:"match_losses",sortable:!0,title:"ML"},{accessor:"match_percentage_wins",render:e=>(0,O.o1)(e.match_wins,e.match_losses),sortable:!0,title:"MW%"},{accessor:"game_wins",sortable:!0,title:"GW"},{accessor:"game_losses",sortable:!0,title:"GL"},{accessor:"game_percentage_wins",render:e=>(0,O.o1)(e.game_wins,e.game_losses),sortable:!0,title:"GW%"}],onSortStatusChange:e=>h(e),records:g,sortStatus:_,customLoader:(0,a.jsx)(k.O,{height:600}),className:"striped-table"})})}function P(e){let{eventId:n,selectedTab:t,standingsType:r,showPoints:l=!0}=e,[o,s]=(0,i.useState)(!1),[d,c]=(0,i.useState)();return(0,i.useEffect)(()=>{if(s(!0),"Season Standings"===t)(async()=>{c((await (0,E.H2)(L.m)).data||void 0),s(!1)})();else if(r===I.online){if(!n)return;(async()=>{c((await (0,E.xM)(n,L.m)).data||void 0),s(!1)})()}else if(r===I.lan){if(!n)return;(async()=>{let{data:e}=await (0,C.yD)(n),{data:t}=await (0,q.O6)(n),{data:a}=await (0,Q.H)(L.m);e&&t&&a&&(c(e.map(e=>{var n,r,l,o,i;return{event_id:e.event_id,event_name:e.event_name,game_losses:(r=e.team_id,t.filter(e=>e.team_1_id===r||e.team_2_id===r).reduce((e,n)=>e+n.games.filter(e=>e.winner_id!==r).length,0)),game_wins:(l=e.team_id,t.filter(e=>e.team_1_id===l||e.team_2_id===l).reduce((e,n)=>e+n.games.filter(e=>e.winner_id===l).length,0)),match_losses:(o=e.team_id,t.filter(e=>(e.team_1_id===o||e.team_2_id===o)&&e.winner_id!==o).length),match_wins:(i=e.team_id,t.filter(e=>(e.team_1_id===i||e.team_2_id===i)&&e.winner_id===i).length),points:(null===(n=a.find(n=>n.placement===e.placement))||void 0===n?void 0:n.points)||0,rank:e.placement,team_id:e.team_id,team_logo_darkmode:e.team_logo_darkmode,team_logo_lightmode:e.team_logo_lightmode,team_name:e.team_name,team_name_short:e.team_name_short}})),s(!1))})()}},[n,t,r]),(0,a.jsx)(M,{loading:o,standings:d,showPoints:l})}let T=(0,f.k)(e=>({heading:{marginBottom:e.spacing.sm},majorLANButton:{marginLeft:e.spacing.sm},standingsHeader:{margin:0}})),Z="Season Standings";function A(e){let n,{events:t}=e,{classes:_}=T(),f=(0,r.rZ)(),v=(0,l.X)(),p=h().map(["Major 1","Major 2","Major 3","Major 4","Champs"],e=>{let n=h().filter(t,n=>{var t;return h().includes(n.name.toLowerCase(),e.toLowerCase())||h().includes(null===(t=n.name_short)||void 0===t?void 0:t.toLowerCase(),e.toLowerCase())});return{major:e,events:n}}).map(e=>{var n,t;return{tabName:e.major,qualifierEventId:(null===(n=e.events.find(e=>"Qualifier"===e.tier))||void 0===n?void 0:n.id)||null,tournamentEventId:(null===(t=e.events.find(e=>"Tournament"===e.tier))||void 0===t?void 0:t.id)||null}});p.unshift({tabName:Z,qualifierEventId:null,tournamentEventId:null});let[x,w]=(0,g.v1)("tab",g.Oi.withDefault(p[0].tabName).withOptions({clearOnDefault:!0})),[k,b]=(0,g.v1)("type",g.Oi.withDefault(I.online).withOptions({clearOnDefault:!0})),j=(0,i.useCallback)(()=>b(I.online),[]),y=(0,i.useCallback)(()=>b(I.lan),[]),S=p.find(e=>x===e.tabName),N=(null==S?void 0:S.qualifierEventId)!==null,O=(null==S?void 0:S.tournamentEventId)!==null,E=x!==Z&&N&&O,L=k;N&&O?n=k===I.online?null==S?void 0:S.qualifierEventId:null==S?void 0:S.tournamentEventId:(null==S?void 0:S.qualifierEventId)?(L=I.online,n=S.qualifierEventId):(L=I.lan,n=null==S?void 0:S.tournamentEventId);let C=t.find(e=>e.id===n);return(0,a.jsxs)(o.Z,{style:{backgroundColor:"dark"===v.colorScheme?f.colors.dark[8]:f.colors.gray[1]},children:[(0,a.jsxs)(s.k,{align:"flex-end",className:_.heading,justify:"space-between",gap:8,wrap:"wrap",children:[(0,a.jsx)(d.D,{className:_.standingsHeader,order:1,children:"Standings"}),E&&(0,a.jsxs)(s.k,{children:[(0,a.jsx)(c.z,{onClick:j,variant:k===I.online?"subtle":"light",color:"gray",style:{boxShadow:"0px 0px 5px 0px rgba(0,0,0,0.25)",color:"dark"===v.colorScheme?"white":"black"},children:"Online Qualifiers"}),(0,a.jsx)(c.z,{className:_.majorLANButton,onClick:y,variant:k===I.lan?"subtle":"light",color:"gray",style:{boxShadow:"0px 0px 5px 0px rgba(0,0,0,0.25)",color:"dark"===v.colorScheme?"white":"black"},children:"Major LAN"})]})]}),(0,a.jsx)(m.i,{}),(0,a.jsxs)(u.m,{keepMounted:!1,value:x,onChange:w,children:[(0,a.jsx)(u.m.List,{children:p.map(e=>(0,a.jsx)(u.m.Tab,{value:e.tabName,children:e.tabName},e.tabName))}),p.map(e=>(0,a.jsx)(u.m.Panel,{value:e.tabName,children:(0,a.jsx)(P,{eventId:n,selectedTab:x,standingsType:L,showPoints:null==C?void 0:C.show_points})},e.tabName))]})]})}var z=t(78531),B=!0;function H(e){let{events:n}=e,t=(0,r.rZ)(),i=(0,l.X)();return(0,a.jsx)(a.Fragment,{children:n?(0,a.jsxs)(o.Z,{p:0,style:{backgroundColor:"dark"===i.colorScheme?t.colors.dark[8]:t.colors.gray[1]},children:[(0,a.jsx)(z.Z,{}),(0,a.jsx)(A,{events:n})]}):(0,a.jsx)("div",{children:"Sorry, an error has occured"})})}},89383:function(e,n,t){"use strict";t.d(n,{uj:function(){return r},$Q:function(){return o},yD:function(){return l}});var a=t(36281);async function r(e){return await a.OQ.from("event_placements").select("*, events!inner(season_id)").eq("events.season_id",e)}async function l(e){let n=await a.OQ.from("event_placements").select("*, \n team_logo_darkmode: team_id (logo_darkmode),\n team_logo_lightmode: team_id (logo_lightmode),\n team_name: team_id (name), \n team_name_short: team_id (name_short),\n event_name: event_id (name)").eq("event_id",e).order("placement",{ascending:!0}),t=n.data?n.data.map(e=>e&&"name"in e.team_name&&"name_short"in e.team_name_short?e:null).filter(e=>null!==e):null;return null===n.error?{...n,data:null!=t?t:[]}:{...n,data:null}}async function o(e){let n=await a.OQ.from("event_placements").select("*, event: events(*, season: seasons(*, title: titles(*)), event_teams(*, event_team_players(*, player: players(*))))").eq("team_id",e),t=n.data?n.data.map(e=>e&&e.event&&"id"in e.event?e:null).filter(e=>!!e):null;return null===n.error?{...n,data:null!=t?t:[]}:{...n,data:null}}},40437:function(e,n,t){"use strict";t.d(n,{H:function(){return r}});var a=t(36281);async function r(e){return await a.OQ.from("placement_earned_points").select("*").eq("season_id",e)}},86402:function(e,n,t){"use strict";t.d(n,{xM:function(){return i},o0:function(){return l},H2:function(){return s},vk:function(){return o},Qe:function(){return d}});var a=t(36281);function r(e){return e&&"name"in e.team_name&&"name_short"in e.team_name_short?e:null}async function l(e){return await a.OQ.from("standings").select("*").eq("event_id",e)}async function o(e){return await a.OQ.from("standings").select("*").eq("season_id",e)}async function i(e,n){let t=await a.OQ.from("standings").select("*, \n team_logo_darkmode: team_id (logo_darkmode), \n team_logo_lightmode: team_id (logo_lightmode), \n team_name: team_id (name), \n team_name_short: team_id (name_short),\n event_name: event_id (name)").eq("season_id",n).eq("event_id",e).order("rank",{ascending:!0}),l=t.data?t.data.map(e=>r(e)).filter(e=>!!e):null;return null===t.error?{...t,data:null!=l?l:[]}:{...t,data:null}}async function s(e){let n=await a.OQ.from("standings").select("*,\n team_logo_darkmode: team_id (logo_darkmode),\n team_logo_lightmode: team_id (logo_lightmode),\n team_name: team_id (name),\n team_name_short: team_id (name_short),\n event_name: event_id (name)").eq("season_id",e).is("event_id",null).order("rank",{ascending:!0}),t=n.data?n.data.map(e=>r(e)).filter(e=>null!==e):null;return null===n.error?{...n,data:null!=t?t:[]}:{...n,data:null}}async function d(e,n){return await a.OQ.from("standings").select("*").eq("season_id",e).eq("team_id",n).is("event_id",null).single()}},95448:function(e,n,t){"use strict";t.d(n,{m:function(){return a}});let a=2025}},function(e){e.O(0,[2331,1959,8660,2949,2888,9774,179],function(){return e(e.s=48917)}),_N_E=e.O()}]);