!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d654763c-9db0-48f1-b8e1-bece82a55e7a",e._sentryDebugIdIdentifier="sentry-dbid-d654763c-9db0-48f1-b8e1-bece82a55e7a")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3003],{73003:(e,t,n)=>{n.r(t),n.d(t,{default:()=>S});var r=n(6029),i=n(21377),s=n(76356),o=n(41249),u=n(59018),a=n.n(u),l=n(55729),d=n(90248),c=n(65789),h=n(75751),m=n(42360),f=n(48686),p=n(85986),g=n(95195),x=n(189),v=n(53214),y=n(14591),F=n(41735);let b=(0,F.default)(o.az).withConfig({componentId:"sc-ce9c6449-0"})(["cursor:move;transform-origin:top right;div{","}> div{border-top:1px solid ",";> div{min-height:268px;}}+ .cupTree-instruction-snackbar{transition:opacity 0.2s ease-in-out;opacity:0;}:hover{+ .cupTree-instruction-snackbar{opacity:1;pointer-events:none;}}"],e=>"rtl"===e.theme.settings.textDirection&&"transform-origin: top right 0px !important;",e=>e.theme.colors.onSurface.nLv4);function I(e){let{cupTree:t,roundDescriptions:n}=e,s=(0,l.useRef)([]),u=(0,l.useRef)(null),a=(0,l.useRef)(null),d="rtl"===(0,F.useTheme)().settings.textDirection,c=(0,l.useRef)(),{sourceTreeName:h,phaseFilter:m,rounds:g}=(0,p.B)(),x=(0,l.useCallback)(e=>{s.current.forEach(t=>t(e))},[s.current]),I=1===n.length,j=t.events.length>0,k=I&&/relegation|promotion/i.test(h),[S,E]=(0,l.useState)(!1),[T,w]=(0,l.useState)(!1),[_,A]=(0,l.useState)(1),[C,H]=(0,l.useState)(I?d?-300:300:0),[q,B]=(0,l.useState)(I?j?8:38:0);function D(e){("Control"===e.key||"Meta"===e.key)&&E(!0)}function M(e){S&&E(!1)}return(0,l.useEffect)(()=>{if(!c.current){var e;let t=null==(e=u.current)?void 0:e.getBoundingClientRect();t&&(c.current=t)}return document.addEventListener("keydown",D),document.addEventListener("keyup",M),()=>{document.removeEventListener("keydown",D),document.addEventListener("keyup",M)}},[S]),(0,l.useLayoutEffect)(()=>{function e(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;H(0),B(0);let r=t-n;if(0===r)return;let i=r>0?1:-1,s=n+.03*i;1===i&&s>t||-1===i&&se(t,s)))}let r=t.finished&&g[g.length-1].type===i.FFH.Finals&&!k;if("number"==typeof m&&m>0&&m<=4)return void requestAnimationFrame(()=>e(r?.92:1,_));if(a.current){let t=(a.current.clientWidth-36*!!r)/(300*n.length);t<.8&&_!==t&&requestAnimationFrame(()=>e(t,_))}},[m]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v.eS,{onChange:s.current}),(0,r.jsx)(v.Cq,{roundNames:n,x:C,scale:_}),(0,r.jsx)(b,{ref:a,children:(0,r.jsx)(y.MapInteractionCSS,{disableZoom:!S,value:{scale:_,translation:{x:C,y:q}},onChange:e=>{let{scale:t,translation:n}=e;if(T||w(!0),t>=f.Yv&&t<=f.AK){var r,i,s,o,u,l;A(t),H(Math.max(-(((null==(r=c.current)?void 0:r.width)||0)*t*.8),Math.min(((null==(s=a.current)||null==(i=s.parentElement)?void 0:i.clientWidth)||f.IT)-100,n.x))),B(Math.max(-(((null==(o=c.current)?void 0:o.height)||0)*t*1),Math.min(((null==(l=a.current)||null==(u=l.parentElement)?void 0:u.clientHeight)||f.XV)-100,n.y)))}},children:(0,r.jsx)(o.az,{position:"relative",ref:u,children:(0,r.jsx)(v.Vr,{tree:t,columnWidth:300,depth:n.length,highlights:{set:x,clear:()=>x([])},isRelegationDecider:k})})})}),T?null:(0,r.jsx)(v._4,{}),(0,r.jsx)(v.Dg,{onZoomIn:()=>{requestAnimationFrame(()=>{A(Math.min(_+.1,f.AK))})},onZoomOut:()=>{requestAnimationFrame(()=>{A(Math.max(_-.1,f.Yv))})}})]})}let j={0:(0,r.jsx)(d.A,{id:"full_bracket"}),[i.FFH.EighthFinals]:(0,r.jsx)(d.A,{id:"bracket_top_n",values:{n:16}}),[i.FFH.Quarterfinals]:(0,r.jsx)(d.A,{id:"bracket_top_n",values:{n:8}})};function k(e){let{selectedTree:t,sport:n,uniqueTournamentId:u,uniqueTournamentSlug:d,categorySlug:m,seasonId:g}=e,[y,F]=(0,l.useState)(0),b=function(e){let t=e.map(e=>e.type),n=[0];if(t.includes(i.FFH.EighthFinals)&&t.some(e=>e>i.FFH.EighthFinals)&&n.push(i.FFH.EighthFinals),t.includes(i.FFH.Quarterfinals)&&t.some(e=>e>i.FFH.Quarterfinals)&&n.push(i.FFH.Quarterfinals),n.length>1)return n}(t.rounds),k=null,S=a()(t.rounds.map(e=>e.description));if(y>0&&b){let e={...t,rounds:t.rounds.filter(e=>e.type<=b[y])};S=e.rounds.map(e=>e.description),k=(0,x.TI)((0,x.o$)(e),n,null)}else k=(0,x.TI)((0,x.o$)(t),n,null);if(!k||!(0,x.ov)(k))return null;let E=[];return t.showSingleParticipantByeBlocks||(E=(0,x.BE)(t.rounds)),(0,r.jsx)(h.t,{tag:"CupTree",children:(0,r.jsxs)(c.Zp,{children:[(0,r.jsx)(v.Y9,{id:t.id,name:t.name,sport:n,phaseSelector:b&&(0,r.jsx)(o.ms,{items:b,alignRight:!0,selectedItem:b[y],renderItem:e=>{if("number"==typeof e)return j[e]},onSelectedItemChange:e=>{"number"==typeof e.selectedItemIndex&&F(e.selectedItemIndex)}})}),(0,r.jsx)(s.az,{mt:"sm",style:{maxHeight:f.XV},overflow:"hidden","data-tree-id":t.id,children:(0,r.jsx)(p.J,{sport:n,tournamentId:u,seasonId:g,sourceTreeId:t.id,rounds:t.rounds,sourceTreeName:t.name,showSingleParticipantByeBlocks:t.showSingleParticipantByeBlocks,phaseFilter:b?b[y]:void 0,entrantsPerRound:E,children:(0,r.jsx)(I,{cupTree:k,roundDescriptions:S})})}),(0,x.KA)(E)&&(0,r.jsx)(v.eo,{}),(0,r.jsx)(v.fT,{uniqueTournamentId:u,uniqueTournamentSlug:d,categorySlug:m,seasonId:g,cupTree:t,sport:n})]})},t.id)}function S(e){let{uniqueTournamentId:t,uniqueTournamentSlug:n,categorySlug:i,seasonId:s,sport:o}=e,[u,a]=(0,g.Q)(t,s);return a?(0,r.jsx)(m.A,{}):u?(0,r.jsx)(r.Fragment,{children:u.map(e=>(0,r.jsx)(k,{selectedTree:e,uniqueTournamentId:t,uniqueTournamentSlug:n,categorySlug:i,seasonId:s,sport:o},e.id))}):null}}}]);