courthive-components 6.0.0 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -142,7 +142,7 @@
142
142
  color: var(--chc-text-primary) !important;
143
143
  background-color: var(--chc-bg-elevated) !important;
144
144
  border: 1px solid var(--chc-border-primary) !important;
145
- `,e.label.length>1&&!e.isSpecial?t.style.fontSize=`1.3rem`:e.isSpecial&&[`RET`,`WO`,`DEF`].includes(e.label)?(t.style.fontSize=`0.95rem`,t.style.setProperty(`background-color`,ul,`important`)):e.isSpecial?(t.style.fontSize=`1.3rem`,t.style.setProperty(`background-color`,ul,`important`)):t.style.fontSize=`1.3rem`,(e.value===`retired`||e.value===`defaulted`)&&(t.dataset.button=e.value),e.disabled&&(t.disabled=!0,t.style.visibility=`hidden`),e.requiresScore&&(t.disabled=!0),t.onclick=()=>{e.value===`delete`?L():e.value===`minus`?I(`-`):e.value===`retired`?(m=el,h=void 0,g.querySelectorAll(fl).forEach(e=>e.checked=!1),F()):e.value===`walkover`?(m=tl,h=void 0,d.digits=``,g.querySelectorAll(fl).forEach(e=>e.checked=!1),F(),te()):e.value===`defaulted`?(m=nl,h=void 0,g.querySelectorAll(fl).forEach(e=>e.checked=!1),F()):e.value===`empty`||I(e.value)},O.appendChild(t)});let ne=e=>{if(e.key>=`0`&&e.key<=`9`)e.preventDefault(),I(Number.parseInt(e.key));else if(e.key===`Backspace`||e.key===`Delete`)e.preventDefault(),L();else if(e.key===`-`||e.key===` `||e.key===`/`)e.preventDefault(),I(`-`);else if(e.key===`)`){e.preventDefault();let t=N(d.digits);t.includes(`(`)&&!t.includes(`)`)&&(d.digits+=`-`,F())}};r.setAttribute(`tabindex`,`-1`),r.style.outline=`none`,r.addEventListener(`keydown`,ne),setTimeout(()=>r.focus(),100),globalThis.cleanupDialPad=()=>{r.removeEventListener(`keydown`,ne)};let z=u===el||u===tl||u===nl||u===rl||u===il;z?(u===rl?(m=tl,h=As):u===il?(m=nl,h=As):(m=u,h=l),g.querySelectorAll(dl).forEach(e=>{e.value===m&&(e.checked=!0)}),h!==void 0&&(g.querySelectorAll(fl).forEach(e=>{e.value===String(h)&&(e.checked=!0)}),v.style.display=`block`,D(h===As))):!c&&(!u||u===`TO_BE_PLAYED`)&&R(),d.digits||z?(F(),setTimeout(()=>{let e=document.getElementById(`clearScoreV2`);e&&(e.disabled=!1),te()},0)):(P(null),te())}catch(e){console.error(`Error rendering dial pad:`,e),r.innerHTML=`<p style="color: red;">Error: ${e instanceof Error?e.message:`Unknown error`}</p>`}}var{RETIRED:hl,WALKOVER:gl,DEFAULTED:_l,SUSPENDED:vl,CANCELLED:yl,INCOMPLETE:bl,DEAD_RUBBER:xl,IN_PROGRESS:Sl,AWAITING_RESULT:Cl,ABANDONED:wl}=t.matchUpStatusConstants;function Tl(e,t){let n=e.substring(t).trim().toLowerCase();return/^in(\s+p(rog(ress)?)?)?$/i.exec(n)?{ending:Sl,endPos:e.length}:/^inc(omp(lete?)?)?/i.exec(n)?{ending:bl,endPos:e.length}:/^(dr|dead(\s*r(ubber)?)?)/i.exec(n)?{ending:xl,endPos:e.length}:/^r(et(ired?)?)?/i.exec(n)?{ending:hl,endPos:e.length}:/^(w(\/o|o|alk(over?)?)?)/i.exec(n)?{ending:gl,endPos:e.length}:/^d(ef(aulted?)?)?/i.exec(n)?{ending:_l,endPos:e.length}:/^s(usp(ended?)?)?/i.exec(n)?{ending:vl,endPos:e.length}:/^c(anc(ell?ed?)?)?/i.exec(n)?{ending:yl,endPos:e.length}:/^ab(and(on(ed)?)?)?/i.exec(n)?{ending:wl,endPos:e.length}:/^a(wait(ing(\s*r(esult)?)?)?)?/i.exec(n)?{ending:Cl,endPos:e.length}:{endPos:t}}function El(e,t){return t===(e.bestOf||3)-1&&e.finalSetFormat?e.finalSetFormat:e.setFormat}function Dl(e){return!!e?.tiebreakSet?.tiebreakTo&&!e?.setTo}function Ol(e){return Dl(e)?0:(e?.setTo||6)+1}function kl(e){let t=e?.tiebreakSet,n=e?.tiebreakFormat;return t?t.tiebreakTo||10:n&&n.tiebreakTo||7}function Al(e){return e>=`0`&&e<=`9`}function jl(e){for(let t of e)if(!Al(t))return!1;return!0}function Ml(e){return!Al(e)&&!Nl(e)&&!Pl(e)}function Nl(e){return e===`(`||e===`[`}function Pl(e){return e===`)`||e===`]`}function Fl(e,t,n){let r=n?.tiebreakAt||n?.setTo||6;return e===r&&t===r}function Il(e,t,n){let r=n?.setTo||6,i=Math.max(e,t);return i<r?!1:i-Math.min(e,t)>=2||(r+1,!1)}function Ll(e,t,n){let r=kl(n),i=Math.max(e,t),a=Math.min(e,t);return n?.tiebreakSet?.NoAD||n?.tiebreakFormat?.NoAD?i>=r:i<r?!1:i-a>=2}function Rl(e,t){let n=+(e===`1-0`),r=+(e===`0-1`);return{side1TiebreakScore:n,side2TiebreakScore:r,setNumber:t,winningSide:n>r?1:2}}function zl(e,t,n){let r=e.indexOf(`-`);if(r===-1)return n.push({position:0,message:`Set ${t}: Invalid format "${e}". Expected "#-#" (e.g., "5-3")`,expected:`#-#`,got:e}),null;let i=e.slice(0,r),a=e.slice(r+1);return!i||!a||!jl(i)||!jl(a)?(n.push({position:0,message:`Set ${t}: Invalid format "${e}". Expected "#-#" (e.g., "5-3")`,expected:`#-#`,got:e}),null):{side1Score:Number.parseInt(i,10),side2Score:Number.parseInt(a,10),setNumber:t}}function Bl(e,t,n){let r=e.indexOf(`-`);if(r===-1)return n.push({position:0,message:`Final set: Invalid format "${e}". Expected TB format "1-0" or "0-1", or regular "#-#"`,expected:`1-0, 0-1, or #-#`,got:e}),null;let i=e.slice(0,r),a=e.slice(r+1);return!i||!a||!jl(i)||!jl(a)?(n.push({position:0,message:`Final set: Invalid format "${e}". Expected TB format "1-0" or "0-1", or regular "#-#"`,expected:`1-0, 0-1, or #-#`,got:e}),null):{side1Score:Number.parseInt(i,10),side2Score:Number.parseInt(a,10),setNumber:t}}function Vl(e,t){return e.slice(0,t).reduce((e,t)=>(e.side1+=t.side1Score||0,e.side2+=t.side2Score||0,e),{side1:0,side2:0})}function Hl(e,t,n){let r=e.filter(e=>e.side1Score!==void 0),i=e.some(e=>e.side1TiebreakScore!==void 0);if(r.length<t)return;let a=Vl(r,t),o=a.side1===a.side2,s=r.length>t;if(o&&!i){if(s){let e=r[t];n.push({position:0,message:`Aggregate tied (${a.side1}-${a.side2}). Final set score "${e.side1Score}-${e.side2Score}" invalid. TB1 only accepts "1-0" or "0-1"`})}else n.push({position:0,message:`Aggregate tied (${a.side1}-${a.side2}), final TB required`})}else!o&&i?n.push({position:0,message:`Aggregate not tied (${a.side1}-${a.side2}), final TB not allowed`}):!o&&s&&n.push({position:0,message:`Aggregate not tied (${a.side1}-${a.side2}), extra sets not allowed`})}function Ul(e,t,n,r){let i=[];for(let a=0;a<e.length;a++){let o=e[a],s=a+1,c=s===n,l=o===`1-0`||o===`0-1`;if(t&&c&&l)i.push(Rl(o,s));else if(t&&c&&!l){let e=Bl(o,s,r);e&&i.push(e)}else{let e=zl(o,s,r);e&&i.push(e)}}return i}function Wl(e,t){return{valid:!1,formattedScore:``,sets:[],confidence:1,errors:[],warnings:[],ambiguities:[],suggestions:e?[`Enter ${t-1} timed sets (final TB only if tied)`]:[`Enter ${t} sets in format: #-# #-# ...`],incomplete:!0,matchComplete:!1}}function Gl(e,t,n,r,i){if(e>n){let a=r?`${t}-${n}`:`${n}`;i.push({position:0,message:`Too many sets: got ${e}, expected ${a}`})}}function Kl(e,t,n,r,i){if(!e)return[];if(t){let e=n-r;return[`Enter ${e} more timed set${e===1?``:`s`} (or final TB if aggregate tied)`]}let a=i-r;return[`Need ${a} more set${a===1?``:`s`}`]}function ql(e){return e.map(e=>e.side1TiebreakScore===void 0?`${e.side1Score}-${e.side2Score}`:`${e.side1TiebreakScore}-${e.side2TiebreakScore}`).join(` `)}function Jl(e,t){let n=t.exactly||t.bestOf||1,r=e.trim(),i=!!t?.aggregate,a=t.finalSetFormat?.tiebreakSet?.tiebreakTo!==void 0,o=i&&a;if(!r)return Wl(o,n);let s=r.split(/\s+/),c=[],l=o?n-1:n,u=Ul(s,o,n,c);o&&c.length===0&&Hl(u,l,c);let d=o?l:n,f=n;Gl(u.length,d,f,o,c);let p=u.length<d&&c.length===0,m=(u.length===n||o&&u.length===l)&&c.length===0,h=ql(u);return{valid:c.length===0&&(u.length===d||u.length===f),formattedScore:h,sets:u,confidence:+(c.length===0),errors:c,warnings:[],ambiguities:[],suggestions:Kl(p,o,d,u.length,n),incomplete:p,matchComplete:m}}function Yl(e,n){let r=typeof n==`string`?t.matchUpFormatCode.parse(n):n;if(!r)return{valid:!1,formattedScore:``,sets:[],confidence:0,errors:[{position:0,message:`Invalid matchUpFormat`}],warnings:[],ambiguities:[],suggestions:[],incomplete:!1,matchComplete:!1};let i=!!(r.setFormat?.timed||r.finalSetFormat?.timed),a=!!r.exactly||r.bestOf===1;if(i&&a)return Jl(e,r);let o={input:e,position:0,setIndex:0,currentSide1Buffer:``,currentSide2Buffer:``,currentTiebreakSide1Buffer:``,currentTiebreakSide2Buffer:``,sets:[],parsedFormat:r,state:`START`,inTiebreak:!1,expectingTiebreakOnly:!1,isValid:!0,errors:[],warnings:[],confidence:1,ambiguities:[],suggestions:[]};for(Dl(El(r,0))?(o.expectingTiebreakOnly=!0,o.inTiebreak=!0,o.state=`PARSING_TIEBREAK_SIDE1`):o.state=`PARSING_SIDE1`;o.position<e.length&&o.isValid;)Xl(o);gu(o);let s=o.sets,c;o.irregularEnding&&(c=o.irregularEnding,(o.irregularEnding===gl||o.irregularEnding===yl||o.irregularEnding===xl)&&(s=[]));let l=!o.irregularEnding&&_u(o),u=vu(o);return{valid:o.isValid&&o.errors.length===0,formattedScore:u,sets:s,confidence:o.confidence,errors:o.errors,warnings:o.warnings,ambiguities:o.ambiguities,suggestions:o.suggestions,incomplete:!l&&s.length>0,matchComplete:l,matchUpStatus:c}}function Xl(e){let t=e.input[e.position];if(!Al(t)&&!Nl(t)&&!Pl(t)){let t=Tl(e.input,e.position);if(t.ending){e.irregularEnding=t.ending,e.irregularEndingPosition=e.position,e.position=t.endPos;return}}if(Ml(t)){Zl(e);return}if(Nl(t)){Ql(e);return}if(Pl(t)){$l(e);return}if(Al(t)){eu(e,t);return}e.errors.push({position:e.position,message:`Unexpected character '${t}'`,got:t,context:yu(e)}),e.isValid=!1}function Zl(e){if(e.state===`PARSING_SIDE1`&&e.currentSide1Buffer){e.state=`PARSING_SIDE2`,e.position++;return}if(e.state===`PARSING_SIDE2`&&e.currentSide2Buffer){if(du(Number.parseInt(e.currentSide1Buffer),Number.parseInt(e.currentSide2Buffer),El(e.parsedFormat,e.setIndex))){e.inTiebreak=!0,e.state=`PARSING_TIEBREAK_SIDE1`,e.position++;return}mu(e),e.position++;return}if(e.state===`PARSING_TIEBREAK_SIDE1`&&e.currentTiebreakSide1Buffer){if(e.currentSide1Buffer&&e.currentSide2Buffer){mu(e),e.position++;return}e.state=`PARSING_TIEBREAK_SIDE2`,e.position++;return}e.position++}function Ql(e){let t=El(e.parsedFormat,e.setIndex);if(Dl(t)){e.inTiebreak=!0,e.state=`PARSING_TIEBREAK_SIDE1`,e.position++;return}if(e.currentSide1Buffer&&e.currentSide2Buffer&&Fl(Number.parseInt(e.currentSide1Buffer),Number.parseInt(e.currentSide2Buffer),t)){e.inTiebreak=!0,e.state=`PARSING_TIEBREAK_SIDE1`,e.position++;return}e.warnings.push(`Tiebreak indicator at position ${e.position} may be ambiguous`),e.inTiebreak=!0,e.state=`PARSING_TIEBREAK_SIDE1`,e.position++}function $l(e){if(e.inTiebreak){hu(e),e.inTiebreak=!1,e.position++;return}e.warnings.push(`Unexpected tiebreak closer at position ${e.position}`),e.position++}function eu(e,t){let n=El(e.parsedFormat,e.setIndex);e.inTiebreak?su(e,t,n):iu(e,t,n)}function tu(e,t,n){return Number.parseInt(e+t)>n}function nu(e,t,n){e.state=`PARSING_SIDE1`,e.currentSide1Buffer+=t;let r=Number.parseInt(e.currentSide1Buffer),i=e.position+1;if(i<e.input.length&&Al(e.input[i])){let t=e.input[i];tu(e.currentSide1Buffer,t,n)&&(e.warnings.push(`Potential score issue: "${e.currentSide1Buffer}${t}" would exceed max game score ${n}`),e.state=`PARSING_SIDE2`)}else e.state=`PARSING_SIDE2`;r>n&&e.warnings.push(`Score ${r} exceeds max ${n} at position ${e.position}`),e.position++}function ru(e,t,n,r){e.currentSide2Buffer+=t;let i=Number.parseInt(e.currentSide1Buffer),a=Number.parseInt(e.currentSide2Buffer);if(du(i,a,n)){e.inTiebreak=!0,e.state=`PARSING_TIEBREAK_SIDE1`,e.position++;return}let o=e.position+1;if(o<e.input.length&&Al(e.input[o])){let t=e.input[o];tu(e.currentSide2Buffer,t,r)&&(Il(i,a,n)||Fl(i,a,n)||e.warnings.push(`Set ${e.setIndex+1} may be incomplete: ${i}-${a}`),mu(e))}e.position++}function iu(e,t,n){let r=Ol(n);if(e.state===`PARSING_SIDE1`||e.state===`START`){nu(e,t,r);return}if(e.state===`PARSING_SIDE2`){ru(e,t,n,r);return}e.position++}function au(e,t){e.currentTiebreakSide1Buffer+=t,e.position++}function ou(e,t,n){e.currentTiebreakSide2Buffer+=t;let r=Number.parseInt(e.currentTiebreakSide2Buffer),i=e.position+1;if(i<e.input.length&&Al(e.input[i])){let t=e.input[i],a=Number.parseInt(e.currentTiebreakSide2Buffer+t),o=Number.parseInt(e.currentTiebreakSide1Buffer);if(a>999){let t=r;Ll(o,t,n)||e.warnings.push(`Tiebreak may be incomplete: ${o}-${t}`),mu(e)}}e.position++}function su(e,t,n){if(e.state===`PARSING_TIEBREAK_SIDE1`){au(e,t);return}if(e.state===`PARSING_TIEBREAK_SIDE2`){ou(e,t,n);return}e.position++}function cu(e){if(!e.currentTiebreakSide1Buffer||!e.currentTiebreakSide2Buffer)return null;let t=Number.parseInt(e.currentTiebreakSide1Buffer),n=Number.parseInt(e.currentTiebreakSide2Buffer);return{side1Score:0,side2Score:0,side1TiebreakScore:t,side2TiebreakScore:n,setNumber:e.setIndex+1,winningSide:t>n?1:2}}function lu(e,t,n){let r=t.currentTiebreakSide1Buffer,i=t.currentTiebreakSide2Buffer;r&&i?(e.side1TiebreakScore=Number.parseInt(r),e.side2TiebreakScore=Number.parseInt(i)):(r||i)&&uu(e,r,i,n)}function uu(e,t,n,r){let i=Number.parseInt(t||n),a=kl(r),o=r?.tiebreakFormat?.NoAD?a:Math.max(a,i+2);e.side1Score>e.side2Score?(e.side1TiebreakScore=o,e.side2TiebreakScore=i):(e.side1TiebreakScore=i,e.side2TiebreakScore=o)}function du(e,t,n){let r=n.tiebreakAt||n.setTo||6;return e===r&&t===r+1||t===r&&e===r+1}function fu(e,t){if(!e.currentSide1Buffer||!e.currentSide2Buffer)return null;let n=Number.parseInt(e.currentSide1Buffer),r=Number.parseInt(e.currentSide2Buffer);if(du(n,r,t)&&!e.currentTiebreakSide1Buffer&&!e.currentTiebreakSide2Buffer)return null;let i={side1Score:n,side2Score:r,setNumber:e.setIndex+1};return(e.currentTiebreakSide1Buffer||e.currentTiebreakSide2Buffer)&&lu(i,e,t),n>r?i.winningSide=1:r>n&&(i.winningSide=2),i}function pu(e){e.currentSide1Buffer=``,e.currentSide2Buffer=``,e.currentTiebreakSide1Buffer=``,e.currentTiebreakSide2Buffer=``,e.setIndex++,e.inTiebreak=!1,e.state=`PARSING_SIDE1`,Dl(El(e.parsedFormat,e.setIndex))&&(e.expectingTiebreakOnly=!0,e.inTiebreak=!0,e.state=`PARSING_TIEBREAK_SIDE1`)}function mu(e){let t=El(e.parsedFormat,e.setIndex),n=Dl(t)?cu(e):fu(e,t);n&&e.sets.push(n),pu(e)}function hu(e){mu(e)}function gu(e){(e.currentSide1Buffer||e.currentSide2Buffer||e.currentTiebreakSide1Buffer||e.currentTiebreakSide2Buffer)&&mu(e)}function _u(e){let t=e.parsedFormat.bestOf||3,n=Math.ceil(t/2),r=e.sets.filter(e=>e.winningSide===1).length,i=e.sets.filter(e=>e.winningSide===2).length;return r>=n||i>=n}function vu(e){let t=[];for(let n of e.sets)if((!n.side1Score||n.side1Score===0)&&(!n.side2Score||n.side2Score===0)&&(n.side1TiebreakScore!==void 0||n.side2TiebreakScore!==void 0)){let e=n.side1TiebreakScore??0,r=n.side2TiebreakScore??0;t.push(`[${e}-${r}]`)}else{let e=`${n.side1Score||0}-${n.side2Score||0}`;if(n.side1TiebreakScore!==void 0||n.side2TiebreakScore!==void 0){let t=n.side1TiebreakScore??0,r=n.side2TiebreakScore??0,i=n.winningSide===1?r:t;e+=`(${i})`}t.push(e)}return t.join(` `)}function yu(e){let t=Math.max(0,e.position-5),n=Math.min(e.input.length,e.position+5),r=e.input.substring(t,e.position),i=e.input.substring(e.position+1,n);return`...${r}[${e.input[e.position]}]${i}...`}var{RETIRED:bu,WALKOVER:xu,DEFAULTED:Su,DOUBLE_WALKOVER:Cu,DOUBLE_DEFAULT:wu,SUSPENDED:Tu,CANCELLED:Eu,INCOMPLETE:Du,DEAD_RUBBER:Ou,IN_PROGRESS:ku,AWAITING_RESULT:Au,COMPLETED:ju,TO_BE_PLAYED:Mu}=t.matchUpStatusConstants;function Nu(e,t){let n=``;if(e&&(n=(e.sets||[]).map(e=>{let t=`${e.side1Score||0}-${e.side2Score||0}`;if(e.side1TiebreakScore!==void 0||e.side2TiebreakScore!==void 0){let n=e.winningSide===1?e.side2TiebreakScore:e.side1TiebreakScore;t+=`(${n})`}return t}).join(` `)),t&&t!==ju&&t!==Mu){let e=Pu(t);if(e)return n?`${n} ${e}`:e}return n}function Pu(e){return{[bu]:`ret`,[xu]:`wo`,[Su]:`def`,[Cu]:`wo`,[wu]:`def`,[Tu]:`susp`,[Eu]:`canc`,[Du]:`inc`,[Ou]:`dr`,[ku]:`in`,[Au]:`await`}[e]||``}var{RETIRED:Fu,WALKOVER:Iu,DEFAULTED:Lu,SUSPENDED:Ru,CANCELLED:zu,INCOMPLETE:Bu,DEAD_RUBBER:Vu,IN_PROGRESS:Hu,AWAITING_RESULT:Uu,ABANDONED:Wu,DOUBLE_WALKOVER:Gu,DOUBLE_DEFAULT:Ku}=t.matchUpStatusConstants,qu=`var(--chc-status-success)`;function Ju(e){let{matchUp:n,container:r,onScoreChange:i,labels:a={}}=e;r.innerHTML=``,r.style.display=`flex`,r.style.flexDirection=`column`,r.style.gap=`1em`;let o=n?.sides?.find(e=>e.sideNumber===1),s=n?.sides?.find(e=>e.sideNumber===2),c=n.score?{...n.score}:void 0,l=n.winningSide,u=n.matchUpStatus,d=document.createElement(`div`);d.style.marginBottom=`0.25em`,r.appendChild(d);let f=document.createElement(`div`);f.style.display=`none`,f.style.marginTop=`0.25em`,f.style.padding=`0.35em 0.5em`,f.style.backgroundColor=`var(--chc-bg-secondary)`,f.style.borderRadius=`4px`,f.style.flexDirection=`column`,f.style.gap=`0.35em`;let p=document.createElement(`label`);p.style.display=`flex`,p.style.alignItems=`center`,p.style.gap=`0.4em`,p.style.cursor=`pointer`;let m=document.createElement(`input`);m.type=`radio`,m.name=`winnerSelection`,m.value=`1`;let h=document.createElement(`span`);h.textContent=o?.participant?.participantName||`Side 1`,h.style.fontSize=`0.75rem`,p.appendChild(m),p.appendChild(h);let g=document.createElement(`label`);g.style.display=`flex`,g.style.alignItems=`center`,g.style.gap=`0.4em`,g.style.cursor=`pointer`;let _=document.createElement(`input`);_.type=`radio`,_.name=`winnerSelection`,_.value=`2`;let v=document.createElement(`span`);v.textContent=s?.participant?.participantName||`Side 2`,v.style.fontSize=`0.75rem`,g.appendChild(_),g.appendChild(v);let y=document.createElement(`label`);y.style.display=`flex`,y.style.alignItems=`center`,y.style.gap=`0.4em`,y.style.cursor=`pointer`;let b=document.createElement(`input`);b.type=`radio`,b.name=`winnerSelection`,b.value=As;let x=document.createElement(`span`);x.textContent=a.neitherSide||`Neither side`,x.style.fontSize=`0.75rem`,y.appendChild(b),y.appendChild(x);let S=document.createElement(`div`);S.style.display=`none`,S.style.fontSize=`0.7rem`,S.style.color=`var(--chc-text-warning, var(--chc-text-primary))`,f.appendChild(p),f.appendChild(g),f.appendChild(y),f.appendChild(S),r.appendChild(f);let C=e=>{let{WALKOVER:r,CANCELLED:i,DEAD_RUBBER:a}=t.matchUpStatusConstants,o=[r,i,a],s=e?.matchUpStatus&&o.includes(e.matchUpStatus),f;e?.clearAll||s?(f=void 0,c=void 0):e?.scoreObject?(f=e.scoreObject,c=e.scoreObject):f=c,e?.clearAll?(l=void 0,u=void 0):e!=null&&(`winningSide`in e&&(l=e.winningSide),`matchUpStatus`in e&&(u=e.matchUpStatus));let p={...n,score:f,winningSide:l,matchUpStatus:u};d.innerHTML=``;let m=ui({matchUp:p,isLucky:!0,composition:wi[tc().composition||`Australian`]||wi.Australian});d.appendChild(m)};if(C(),n.matchUpFormat){let e=document.createElement(`div`);e.style.fontSize=`0.9rem`,e.style.marginBottom=`0.5em`,e.style.display=`flex`,e.style.alignItems=`center`,e.style.gap=`0.5em`;let t=document.createElement(`span`);t.textContent=(a.format||`Format`)+`:`,t.style.color=`var(--chc-text-secondary)`,e.appendChild(t);let i=document.createElement(`button`);i.textContent=n.matchUpFormat,i.className=`button is-small is-white`,i.style.fontSize=`0.75rem`,i.style.padding=`0.2em 0.5em`,i.style.cursor=`pointer`,i.title=`Click to edit format`,i.addEventListener(`click`,()=>{try{Qa({existingMatchUpFormat:n.matchUpFormat,callback:e=>{if(e&&e!==n.matchUpFormat){n.matchUpFormat=e,i.textContent=e;let t=document.getElementById(`scoreInputV2`);t&&(t.value=``,t.dispatchEvent(new Event(`input`,{bubbles:!0}))),O.textContent=`Score cleared - format changed`,O.style.color=`var(--chc-text-muted)`}},modalConfig:{style:{fontSize:`12px`,border:`3px solid #0066cc`}}})}catch(e){console.error(`[FreeScore] Error opening format selector:`,e)}}),e.appendChild(i),r.appendChild(e)}let w=document.createElement(`div`);w.style.display=`flex`,w.style.alignItems=`center`,w.style.gap=`0.5em`;let T=document.createElement(`input`);T.type=`text`,T.className=`input`,T.placeholder=``,T.style.flex=`1`,T.id=`scoreInputV2`,c&&(T.value=Nu(c,u));let E=document.createElement(`span`);E.style.fontSize=`1.2rem`,E.style.minWidth=`1.5em`,w.appendChild(T),w.appendChild(E),r.appendChild(w);let D=document.createElement(`div`);D.style.fontSize=`0.9rem`,D.style.color=`var(--chc-border-focus)`,D.style.fontFamily=`monospace`,D.style.minHeight=`1.5em`,D.style.padding=`0.25em`,r.appendChild(D);let O=document.createElement(`div`);O.style.fontSize=`0.9rem`,O.style.minHeight=`1.5em`,r.appendChild(O);let k=l,A=()=>{m.checked?(k=1,p.style.fontWeight=`bold`,p.style.color=qu,g.style.fontWeight=``,g.style.color=``):_.checked?(k=2,g.style.fontWeight=`bold`,g.style.color=qu,p.style.fontWeight=``,p.style.color=``):b.checked&&(k=As,y.style.fontWeight=`bold`,y.style.color=qu,p.style.fontWeight=``,p.style.color=``,g.style.fontWeight=``,g.style.color=``),I()};m.addEventListener(`change`,A),_.addEventListener(`change`,A),b.addEventListener(`change`,A);function j(){f.style.display=`none`,m.checked=!1,_.checked=!1,b.checked=!1,p.style.fontWeight=``,p.style.color=``,g.style.fontWeight=``,g.style.color=``,y.style.fontWeight=``,y.style.color=``,S.style.display=`none`,k=void 0}let M={[Fu]:a.retired||`RETIRED`,[Iu]:a.walkover||`WALKOVER`,[Lu]:a.defaulted||`DEFAULTED`,[Ru]:`SUSPENDED`,[zu]:`CANCELLED`,[Bu]:`INCOMPLETE`,[Vu]:`DEAD RUBBER`,[Hu]:`IN PROGRESS`,[Uu]:`AWAITING RESULT`,[Wu]:a.abandoned||`ABANDONED`};function N(e){let{result:t,matchUpStatus:n,winningSide:r,isValid:i,error:a,scoreString:o,formattedScore:s}=e,c=Ls(n),l={...t,isValid:i,matchUpStatus:n,winningSide:r,sets:c?[]:t.sets,scoreObject:c?void 0:t.scoreObject,score:c?void 0:s||o};return a?l.error=a:delete l.error,l}function P(e){let t=a.validScore||`Valid score`,n=e&&M[e];return n?`${t} - ${n}`:t}function F(e,t,n){let r=e.matchUpStatus||t.matchUpStatus,a=Ms.has(r),o=[zu,Vu,Uu,Bu,Hu,Ru,Wu].includes(r);if(a){f.style.display=`flex`;let a=Bs(r);y.style.display=a?`flex`:`none`,!a&&k===`NEITHER`&&(k=void 0,b.checked=!1,y.style.fontWeight=``,y.style.color=``);let o=Hs({selectedOutcome:r,winnerSelection:k});if(S.style.display=o.isDoubleExit?`block`:`none`,o.isDoubleExit&&(S.textContent=Vs(r)),o.winningSide===void 0){i(N({result:e,matchUpStatus:o.matchUpStatus,winningSide:void 0,isValid:o.isValid,error:o.isValid?void 0:js,formattedScore:t.formattedScore,scoreString:n}));return}return o.winningSide}if(o){j();return}return j(),e.winningSide}let I=()=>{let e=T.value.trim();if(!e){E.textContent=``,D.textContent=``,O.textContent=``,O.style.color=``,j(),C({clearAll:!0}),i({isValid:!1,sets:[],matchUpStatus:`TO_BE_PLAYED`});return}let t=Yl(e,n.matchUpFormat);D.textContent=t.formattedScore||``;let r=new Set([Fu,Iu,Lu,Ru,zu,Bu,Vu,Hu,Uu,Wu]),a=t.matchUpStatus&&r.has(t.matchUpStatus),o=t.formattedScore?dc(t.formattedScore,n.matchUpFormat,t.matchUpStatus):{isValid:!1,sets:[],error:`No score to validate`},s=o.sets&&o.sets.length>0,c=(typeof k==`number`?k:void 0)??o.winningSide;if((s&&o.scoreObject||a)&&C({scoreObject:o.scoreObject,winningSide:c,matchUpStatus:o.matchUpStatus||t.matchUpStatus}),o.isValid||a){if(E.textContent=`✓`,E.style.color=qu,O.textContent=P(o.matchUpStatus||t.matchUpStatus),O.style.color=qu,a){let n=F(o,t,e),r=o.matchUpStatus||t.matchUpStatus;if(n===void 0&&Ms.has(r))return;i(N({result:o,matchUpStatus:r,winningSide:n,isValid:!0,formattedScore:t.formattedScore,scoreString:e}))}else j(),i({...o,isValid:!0,winningSide:o.winningSide,matchUpStatus:o.matchUpStatus||t.matchUpStatus,score:t.formattedScore||e})}else!o.isValid&&s?(E.textContent=`⋯`,E.style.color=`var(--chc-status-warning)`,O.textContent=o.error||`Score incomplete - continue typing`,O.style.color=`var(--chc-status-warning)`,j(),i(o)):(E.textContent=`✗`,E.style.color=`var(--chc-status-error)`,O.textContent=o.error||`Invalid score`,O.style.color=`var(--chc-status-error)`,j(),C({scoreObject:void 0,winningSide:void 0,matchUpStatus:void 0}),i(o))},L=!1;T.addEventListener(`input`,()=>{I();let e=T.value,r=e.trim();if(!L&&r){let i=Yl(r,n.matchUpFormat),a=i.formattedScore?dc(i.formattedScore,n.matchUpFormat,i.matchUpStatus):{isValid:!1,winningSide:void 0},o=a.isValid&&a.winningSide!==void 0,s=e.length>0&&/[\s-]$/.test(e),c=t.matchUpFormatCode.parse(n.matchUpFormat),l=!!c?.exactly||c?.bestOf===1,u=c?.exactly||c?.bestOf||3,d=i.sets?.length>=u;o&&s&&(!l||d)&&(L=!0)}else if(L){let t=e.length>0&&/[\s-]$/.test(e);(r.length===0||!t)&&(L=!1)}}),T.addEventListener(`keydown`,e=>{L&&![`Backspace`,`Delete`,`ArrowLeft`,`ArrowRight`,`Tab`].includes(e.key)&&e.preventDefault()}),T.addEventListener(`keyup`,e=>{if(e.key===`Enter`){let e=document.getElementById(`submitScoreV2`);e&&!e.disabled&&e.click()}}),l===1?(m.checked=!0,p.style.fontWeight=`bold`,p.style.color=qu):l===2&&(_.checked=!0,g.style.fontWeight=`bold`,g.style.color=qu),setTimeout(()=>{T.focus(),u===Gu||u===Ku?(C({scoreObject:c,winningSide:l,matchUpStatus:u}),i({isValid:!0,sets:c?.sets||[],scoreObject:c,winningSide:l,matchUpStatus:u})):(T.value||u&&u!==`TO_BE_PLAYED`&&u!==`COMPLETED`)&&I()},100),globalThis.resetFreeScore=()=>{T.value=``,c=void 0,l=void 0,u=void 0,E.textContent=``,D.textContent=``,O.textContent=``,O.style.color=``,f.style.display=`none`,m.checked=!1,_.checked=!1,p.style.fontWeight=``,p.style.color=``,g.style.fontWeight=``,g.style.color=``,k=void 0,L=!1,C({clearAll:!0}),i({isValid:!1,sets:[],matchUpStatus:`TO_BE_PLAYED`}),T.focus()}}var{WALKOVER:Yu,DEFAULTED:Xu,DOUBLE_WALKOVER:Zu,DOUBLE_DEFAULT:Qu}=t.matchUpStatusConstants;function $u(e){return e===Zu?Yu:e===Qu?Xu:e}function ed(e){if(typeof e==`string`)return e||void 0;if(!e||typeof e!=`object`)return;let t=e,n=t.matchUpStatusCode??t.code;return typeof n==`string`&&n?n:void 0}function td(e,t){let n=$u(t);if(!e||!n)return[];let r=e[n];return Array.isArray(r)?r.filter(e=>!!ed(e)):[]}function nd(e){return e.matchUpStatusCodeDisplay||e.label||e.matchUpStatusCode}function rd(e){let t=nd(e),n=e.label&&e.label!==t?e.label:e.description;return n&&n!==t?n:void 0}var id=`statusCodeSelectV2`;function ad(e){let{groups:t,labels:n={}}=e,r=document.createElement(`div`);r.style.display=`none`,r.style.marginTop=`0.6em`;let i=document.createElement(`div`);i.textContent=(n.reasonCode||`Reason`)+`:`,i.style.fontSize=`0.75rem`,i.style.fontWeight=`500`,i.style.marginBottom=`0.25em`,i.style.color=`var(--chc-text-primary)`,r.appendChild(i);let a=document.createElement(`select`);a.id=id,a.className=`input`,a.style.fontSize=`0.8rem`,a.style.width=`100%`,a.style.backgroundColor=`var(--chc-bg-primary)`,a.style.color=`var(--chc-text-primary)`,a.style.border=`1px solid var(--chc-border-primary)`,r.appendChild(a);let o=document.createElement(`div`);o.style.fontSize=`0.7rem`,o.style.marginTop=`0.2em`,o.style.color=`var(--chc-text-secondary)`,r.appendChild(o);let s,c=[],l=()=>{let e=c.find(e=>e.matchUpStatusCode===s);o.textContent=e?.description??``,o.style.display=e?.description?`block`:`none`};return a.addEventListener(`change`,()=>{s=a.value||void 0,l()}),{element:r,update:e=>{if(c=td(t,e),!c.length){r.style.display=`none`,a.innerHTML=``,s=void 0,l();return}s&&!c.some(e=>e.matchUpStatusCode===s)&&(s=void 0),a.innerHTML=``;let i=document.createElement(`option`);i.value=``,i.textContent=n.noReasonCode||`No reason given`,a.appendChild(i);for(let e of c){let t=document.createElement(`option`);t.value=e.matchUpStatusCode;let n=rd(e);t.textContent=n?`${nd(e)} — ${n}`:nd(e),a.appendChild(t)}return a.value=s??``,r.style.display=`block`,l(),s},getSelectedCode:()=>s}}var od=`Irregular Endings:`,sd={dynamicSets:`Dynamic Sets`,freeScore:`Free Score`,dialPad:`Dial Pad`,inlineScoring:`Inline Scoring`},cd=[`dynamicSets`,`freeScore`,`dialPad`,`inlineScoring`];function ld(e){let{matchUp:t,callback:n,onClose:r,labels:i={},matchUpStatusCodes:a}=e,o=ad({groups:a,labels:i}),s=tc().scoringApproach||`dynamicSets`,c=!!(t.score?.sets?.length||t.matchUpStatus),l=null,u=!1,d=e=>{l=e,o.update(e?.matchUpStatus),u&&(e.sets?.length>0||e.score)&&(u=!1);let t=document.getElementById(`submitScoreV2`);t&&(t.disabled=!(s===`inlineScoring`||e.isValid||u&&c));let n=document.getElementById(`clearScoreV2`);if(n){let t=document.getElementById(`scoreInputV2`);if(t)n.disabled=!t.value.trim();else{let t=e.sets&&e.sets.length>0,r=e.matchUpStatus&&e.matchUpStatus!==`COMPLETED`&&e.matchUpStatus!==`TO_BE_PLAYED`;n.disabled=!(t||r)}}},f=()=>{window.cleanupDialPad&&(window.cleanupDialPad(),window.cleanupDialPad=void 0),window.resetDialPad&&(window.resetDialPad=void 0),window.resetDynamicSets&&(window.resetDynamicSets=void 0),window.resetInlineScoring&&(window.resetInlineScoring=void 0)},p=e=>{let n=document.createElement(`div`);n.style.padding=`1em`;let r=document.createElement(`div`);return n.appendChild(r),n.appendChild(o.element),o.update(l?.matchUpStatus),e===`freeScore`?Ju({matchUp:t,container:r,onScoreChange:d,labels:i}):e===`dynamicSets`?Kc({matchUp:t,container:r,onScoreChange:d,labels:i}):e===`dialPad`?ml({matchUp:t,container:r,onScoreChange:d,labels:i}):e===`inlineScoring`&&ac({matchUp:t,container:r,onScoreChange:d,labels:i}),n},m={freeScore:`
145
+ `,e.label.length>1&&!e.isSpecial?t.style.fontSize=`1.3rem`:e.isSpecial&&[`RET`,`WO`,`DEF`].includes(e.label)?(t.style.fontSize=`0.95rem`,t.style.setProperty(`background-color`,ul,`important`)):e.isSpecial?(t.style.fontSize=`1.3rem`,t.style.setProperty(`background-color`,ul,`important`)):t.style.fontSize=`1.3rem`,(e.value===`retired`||e.value===`defaulted`)&&(t.dataset.button=e.value),e.disabled&&(t.disabled=!0,t.style.visibility=`hidden`),e.requiresScore&&(t.disabled=!0),t.onclick=()=>{e.value===`delete`?L():e.value===`minus`?I(`-`):e.value===`retired`?(m=el,h=void 0,g.querySelectorAll(fl).forEach(e=>e.checked=!1),F()):e.value===`walkover`?(m=tl,h=void 0,d.digits=``,g.querySelectorAll(fl).forEach(e=>e.checked=!1),F(),te()):e.value===`defaulted`?(m=nl,h=void 0,g.querySelectorAll(fl).forEach(e=>e.checked=!1),F()):e.value===`empty`||I(e.value)},O.appendChild(t)});let ne=e=>{if(e.key>=`0`&&e.key<=`9`)e.preventDefault(),I(Number.parseInt(e.key));else if(e.key===`Backspace`||e.key===`Delete`)e.preventDefault(),L();else if(e.key===`-`||e.key===` `||e.key===`/`)e.preventDefault(),I(`-`);else if(e.key===`)`){e.preventDefault();let t=N(d.digits);t.includes(`(`)&&!t.includes(`)`)&&(d.digits+=`-`,F())}};r.setAttribute(`tabindex`,`-1`),r.style.outline=`none`,r.addEventListener(`keydown`,ne),setTimeout(()=>r.focus(),100),globalThis.cleanupDialPad=()=>{r.removeEventListener(`keydown`,ne)};let z=u===el||u===tl||u===nl||u===rl||u===il;z?(u===rl?(m=tl,h=As):u===il?(m=nl,h=As):(m=u,h=l),g.querySelectorAll(dl).forEach(e=>{e.value===m&&(e.checked=!0)}),h!==void 0&&(g.querySelectorAll(fl).forEach(e=>{e.value===String(h)&&(e.checked=!0)}),v.style.display=`block`,D(h===As))):!c&&(!u||u===`TO_BE_PLAYED`)&&R(),d.digits||z?(F(),setTimeout(()=>{let e=document.getElementById(`clearScoreV2`);e&&(e.disabled=!1),te()},0)):(P(null),te())}catch(e){console.error(`Error rendering dial pad:`,e),r.innerHTML=`<p style="color: red;">Error: ${e instanceof Error?e.message:`Unknown error`}</p>`}}var{RETIRED:hl,WALKOVER:gl,DEFAULTED:_l,SUSPENDED:vl,CANCELLED:yl,INCOMPLETE:bl,DEAD_RUBBER:xl,IN_PROGRESS:Sl,AWAITING_RESULT:Cl,ABANDONED:wl}=t.matchUpStatusConstants;function Tl(e,t){let n=e.substring(t).trim().toLowerCase();return/^in(\s+p(rog(ress)?)?)?$/i.exec(n)?{ending:Sl,endPos:e.length}:/^inc(omp(lete?)?)?/i.exec(n)?{ending:bl,endPos:e.length}:/^(dr|dead(\s*r(ubber)?)?)/i.exec(n)?{ending:xl,endPos:e.length}:/^r(et(ired?)?)?/i.exec(n)?{ending:hl,endPos:e.length}:/^(w(\/o|o|alk(over?)?)?)/i.exec(n)?{ending:gl,endPos:e.length}:/^d(ef(aulted?)?)?/i.exec(n)?{ending:_l,endPos:e.length}:/^s(usp(ended?)?)?/i.exec(n)?{ending:vl,endPos:e.length}:/^c(anc(ell?ed?)?)?/i.exec(n)?{ending:yl,endPos:e.length}:/^ab(and(on(ed)?)?)?/i.exec(n)?{ending:wl,endPos:e.length}:/^a(wait(ing(\s*r(esult)?)?)?)?/i.exec(n)?{ending:Cl,endPos:e.length}:{endPos:t}}function El(e,t){return t===(e.bestOf||3)-1&&e.finalSetFormat?e.finalSetFormat:e.setFormat}function Dl(e){return!!e?.tiebreakSet?.tiebreakTo&&!e?.setTo}function Ol(e){return Dl(e)?0:(e?.setTo||6)+1}function kl(e){let t=e?.tiebreakSet,n=e?.tiebreakFormat;return t?t.tiebreakTo||10:n&&n.tiebreakTo||7}function Al(e){return e>=`0`&&e<=`9`}function jl(e){for(let t of e)if(!Al(t))return!1;return!0}function Ml(e){return!Al(e)&&!Nl(e)&&!Pl(e)}function Nl(e){return e===`(`||e===`[`}function Pl(e){return e===`)`||e===`]`}function Fl(e,t,n){let r=n?.tiebreakAt||n?.setTo||6;return e===r&&t===r}function Il(e,t,n){let r=n?.setTo||6,i=Math.max(e,t);return i<r?!1:i-Math.min(e,t)>=2||(r+1,!1)}function Ll(e,t,n){let r=kl(n),i=Math.max(e,t),a=Math.min(e,t);return n?.tiebreakSet?.NoAD||n?.tiebreakFormat?.NoAD?i>=r:i<r?!1:i-a>=2}function Rl(e,t){let n=+(e===`1-0`),r=+(e===`0-1`);return{side1TiebreakScore:n,side2TiebreakScore:r,setNumber:t,winningSide:n>r?1:2}}function zl(e,t,n){let r=e.indexOf(`-`);if(r===-1)return n.push({position:0,message:`Set ${t}: Invalid format "${e}". Expected "#-#" (e.g., "5-3")`,expected:`#-#`,got:e}),null;let i=e.slice(0,r),a=e.slice(r+1);return!i||!a||!jl(i)||!jl(a)?(n.push({position:0,message:`Set ${t}: Invalid format "${e}". Expected "#-#" (e.g., "5-3")`,expected:`#-#`,got:e}),null):{side1Score:Number.parseInt(i,10),side2Score:Number.parseInt(a,10),setNumber:t}}function Bl(e,t,n){let r=e.indexOf(`-`);if(r===-1)return n.push({position:0,message:`Final set: Invalid format "${e}". Expected TB format "1-0" or "0-1", or regular "#-#"`,expected:`1-0, 0-1, or #-#`,got:e}),null;let i=e.slice(0,r),a=e.slice(r+1);return!i||!a||!jl(i)||!jl(a)?(n.push({position:0,message:`Final set: Invalid format "${e}". Expected TB format "1-0" or "0-1", or regular "#-#"`,expected:`1-0, 0-1, or #-#`,got:e}),null):{side1Score:Number.parseInt(i,10),side2Score:Number.parseInt(a,10),setNumber:t}}function Vl(e,t){return e.slice(0,t).reduce((e,t)=>(e.side1+=t.side1Score||0,e.side2+=t.side2Score||0,e),{side1:0,side2:0})}function Hl(e,t,n){let r=e.filter(e=>e.side1Score!==void 0),i=e.some(e=>e.side1TiebreakScore!==void 0);if(r.length<t)return;let a=Vl(r,t),o=a.side1===a.side2,s=r.length>t;if(o&&!i){if(s){let e=r[t];n.push({position:0,message:`Aggregate tied (${a.side1}-${a.side2}). Final set score "${e.side1Score}-${e.side2Score}" invalid. TB1 only accepts "1-0" or "0-1"`})}else n.push({position:0,message:`Aggregate tied (${a.side1}-${a.side2}), final TB required`})}else!o&&i?n.push({position:0,message:`Aggregate not tied (${a.side1}-${a.side2}), final TB not allowed`}):!o&&s&&n.push({position:0,message:`Aggregate not tied (${a.side1}-${a.side2}), extra sets not allowed`})}function Ul(e,t,n,r){let i=[];for(let a=0;a<e.length;a++){let o=e[a],s=a+1,c=s===n,l=o===`1-0`||o===`0-1`;if(t&&c&&l)i.push(Rl(o,s));else if(t&&c&&!l){let e=Bl(o,s,r);e&&i.push(e)}else{let e=zl(o,s,r);e&&i.push(e)}}return i}function Wl(e,t){return{valid:!1,formattedScore:``,sets:[],confidence:1,errors:[],warnings:[],ambiguities:[],suggestions:e?[`Enter ${t-1} timed sets (final TB only if tied)`]:[`Enter ${t} sets in format: #-# #-# ...`],incomplete:!0,matchComplete:!1}}function Gl(e,t,n,r,i){if(e>n){let a=r?`${t}-${n}`:`${n}`;i.push({position:0,message:`Too many sets: got ${e}, expected ${a}`})}}function Kl(e,t,n,r,i){if(!e)return[];if(t){let e=n-r;return[`Enter ${e} more timed set${e===1?``:`s`} (or final TB if aggregate tied)`]}let a=i-r;return[`Need ${a} more set${a===1?``:`s`}`]}function ql(e){return e.map(e=>e.side1TiebreakScore===void 0?`${e.side1Score}-${e.side2Score}`:`${e.side1TiebreakScore}-${e.side2TiebreakScore}`).join(` `)}function Jl(e,t){let n=t.exactly||t.bestOf||1,r=e.trim(),i=!!t?.aggregate,a=t.finalSetFormat?.tiebreakSet?.tiebreakTo!==void 0,o=i&&a;if(!r)return Wl(o,n);let s=r.split(/\s+/),c=[],l=o?n-1:n,u=Ul(s,o,n,c);o&&c.length===0&&Hl(u,l,c);let d=o?l:n,f=n;Gl(u.length,d,f,o,c);let p=u.length<d&&c.length===0,m=(u.length===n||o&&u.length===l)&&c.length===0,h=ql(u);return{valid:c.length===0&&(u.length===d||u.length===f),formattedScore:h,sets:u,confidence:+(c.length===0),errors:c,warnings:[],ambiguities:[],suggestions:Kl(p,o,d,u.length,n),incomplete:p,matchComplete:m}}function Yl(e,n){let r=typeof n==`string`?t.matchUpFormatCode.parse(n):n;if(!r)return{valid:!1,formattedScore:``,sets:[],confidence:0,errors:[{position:0,message:`Invalid matchUpFormat`}],warnings:[],ambiguities:[],suggestions:[],incomplete:!1,matchComplete:!1};let i=!!(r.setFormat?.timed||r.finalSetFormat?.timed),a=!!r.exactly||r.bestOf===1;if(i&&a)return Jl(e,r);let o={input:e,position:0,setIndex:0,currentSide1Buffer:``,currentSide2Buffer:``,currentTiebreakSide1Buffer:``,currentTiebreakSide2Buffer:``,sets:[],parsedFormat:r,state:`START`,inTiebreak:!1,expectingTiebreakOnly:!1,isValid:!0,errors:[],warnings:[],confidence:1,ambiguities:[],suggestions:[]};for(Dl(El(r,0))?(o.expectingTiebreakOnly=!0,o.inTiebreak=!0,o.state=`PARSING_TIEBREAK_SIDE1`):o.state=`PARSING_SIDE1`;o.position<e.length&&o.isValid;)Xl(o);gu(o);let s=o.sets,c;o.irregularEnding&&(c=o.irregularEnding,(o.irregularEnding===gl||o.irregularEnding===yl||o.irregularEnding===xl)&&(s=[]));let l=!o.irregularEnding&&_u(o),u=vu(o);return{valid:o.isValid&&o.errors.length===0,formattedScore:u,sets:s,confidence:o.confidence,errors:o.errors,warnings:o.warnings,ambiguities:o.ambiguities,suggestions:o.suggestions,incomplete:!l&&s.length>0,matchComplete:l,matchUpStatus:c}}function Xl(e){let t=e.input[e.position];if(!Al(t)&&!Nl(t)&&!Pl(t)){let t=Tl(e.input,e.position);if(t.ending){e.irregularEnding=t.ending,e.irregularEndingPosition=e.position,e.position=t.endPos;return}}if(Ml(t)){Zl(e);return}if(Nl(t)){Ql(e);return}if(Pl(t)){$l(e);return}if(Al(t)){eu(e,t);return}e.errors.push({position:e.position,message:`Unexpected character '${t}'`,got:t,context:yu(e)}),e.isValid=!1}function Zl(e){if(e.state===`PARSING_SIDE1`&&e.currentSide1Buffer){e.state=`PARSING_SIDE2`,e.position++;return}if(e.state===`PARSING_SIDE2`&&e.currentSide2Buffer){if(du(Number.parseInt(e.currentSide1Buffer),Number.parseInt(e.currentSide2Buffer),El(e.parsedFormat,e.setIndex))){e.inTiebreak=!0,e.state=`PARSING_TIEBREAK_SIDE1`,e.position++;return}mu(e),e.position++;return}if(e.state===`PARSING_TIEBREAK_SIDE1`&&e.currentTiebreakSide1Buffer){if(e.currentSide1Buffer&&e.currentSide2Buffer){mu(e),e.position++;return}e.state=`PARSING_TIEBREAK_SIDE2`,e.position++;return}e.position++}function Ql(e){let t=El(e.parsedFormat,e.setIndex);if(Dl(t)){e.inTiebreak=!0,e.state=`PARSING_TIEBREAK_SIDE1`,e.position++;return}if(e.currentSide1Buffer&&e.currentSide2Buffer&&Fl(Number.parseInt(e.currentSide1Buffer),Number.parseInt(e.currentSide2Buffer),t)){e.inTiebreak=!0,e.state=`PARSING_TIEBREAK_SIDE1`,e.position++;return}e.warnings.push(`Tiebreak indicator at position ${e.position} may be ambiguous`),e.inTiebreak=!0,e.state=`PARSING_TIEBREAK_SIDE1`,e.position++}function $l(e){if(e.inTiebreak){hu(e),e.inTiebreak=!1,e.position++;return}e.warnings.push(`Unexpected tiebreak closer at position ${e.position}`),e.position++}function eu(e,t){let n=El(e.parsedFormat,e.setIndex);e.inTiebreak?su(e,t,n):iu(e,t,n)}function tu(e,t,n){return Number.parseInt(e+t)>n}function nu(e,t,n){e.state=`PARSING_SIDE1`,e.currentSide1Buffer+=t;let r=Number.parseInt(e.currentSide1Buffer),i=e.position+1;if(i<e.input.length&&Al(e.input[i])){let t=e.input[i];tu(e.currentSide1Buffer,t,n)&&(e.warnings.push(`Potential score issue: "${e.currentSide1Buffer}${t}" would exceed max game score ${n}`),e.state=`PARSING_SIDE2`)}else e.state=`PARSING_SIDE2`;r>n&&e.warnings.push(`Score ${r} exceeds max ${n} at position ${e.position}`),e.position++}function ru(e,t,n,r){e.currentSide2Buffer+=t;let i=Number.parseInt(e.currentSide1Buffer),a=Number.parseInt(e.currentSide2Buffer);if(du(i,a,n)){e.inTiebreak=!0,e.state=`PARSING_TIEBREAK_SIDE1`,e.position++;return}let o=e.position+1;if(o<e.input.length&&Al(e.input[o])){let t=e.input[o];tu(e.currentSide2Buffer,t,r)&&(Il(i,a,n)||Fl(i,a,n)||e.warnings.push(`Set ${e.setIndex+1} may be incomplete: ${i}-${a}`),mu(e))}e.position++}function iu(e,t,n){let r=Ol(n);if(e.state===`PARSING_SIDE1`||e.state===`START`){nu(e,t,r);return}if(e.state===`PARSING_SIDE2`){ru(e,t,n,r);return}e.position++}function au(e,t){e.currentTiebreakSide1Buffer+=t,e.position++}function ou(e,t,n){e.currentTiebreakSide2Buffer+=t;let r=Number.parseInt(e.currentTiebreakSide2Buffer),i=e.position+1;if(i<e.input.length&&Al(e.input[i])){let t=e.input[i],a=Number.parseInt(e.currentTiebreakSide2Buffer+t),o=Number.parseInt(e.currentTiebreakSide1Buffer);if(a>999){let t=r;Ll(o,t,n)||e.warnings.push(`Tiebreak may be incomplete: ${o}-${t}`),mu(e)}}e.position++}function su(e,t,n){if(e.state===`PARSING_TIEBREAK_SIDE1`){au(e,t);return}if(e.state===`PARSING_TIEBREAK_SIDE2`){ou(e,t,n);return}e.position++}function cu(e){if(!e.currentTiebreakSide1Buffer||!e.currentTiebreakSide2Buffer)return null;let t=Number.parseInt(e.currentTiebreakSide1Buffer),n=Number.parseInt(e.currentTiebreakSide2Buffer);return{side1Score:0,side2Score:0,side1TiebreakScore:t,side2TiebreakScore:n,setNumber:e.setIndex+1,winningSide:t>n?1:2}}function lu(e,t,n){let r=t.currentTiebreakSide1Buffer,i=t.currentTiebreakSide2Buffer;r&&i?(e.side1TiebreakScore=Number.parseInt(r),e.side2TiebreakScore=Number.parseInt(i)):(r||i)&&uu(e,r,i,n)}function uu(e,t,n,r){let i=Number.parseInt(t||n),a=kl(r),o=r?.tiebreakFormat?.NoAD?a:Math.max(a,i+2);e.side1Score>e.side2Score?(e.side1TiebreakScore=o,e.side2TiebreakScore=i):(e.side1TiebreakScore=i,e.side2TiebreakScore=o)}function du(e,t,n){let r=n.tiebreakAt||n.setTo||6;return e===r&&t===r+1||t===r&&e===r+1}function fu(e,t){if(!e.currentSide1Buffer||!e.currentSide2Buffer)return null;let n=Number.parseInt(e.currentSide1Buffer),r=Number.parseInt(e.currentSide2Buffer);if(du(n,r,t)&&!e.currentTiebreakSide1Buffer&&!e.currentTiebreakSide2Buffer)return null;let i={side1Score:n,side2Score:r,setNumber:e.setIndex+1};return(e.currentTiebreakSide1Buffer||e.currentTiebreakSide2Buffer)&&lu(i,e,t),n>r?i.winningSide=1:r>n&&(i.winningSide=2),i}function pu(e){e.currentSide1Buffer=``,e.currentSide2Buffer=``,e.currentTiebreakSide1Buffer=``,e.currentTiebreakSide2Buffer=``,e.setIndex++,e.inTiebreak=!1,e.state=`PARSING_SIDE1`,Dl(El(e.parsedFormat,e.setIndex))&&(e.expectingTiebreakOnly=!0,e.inTiebreak=!0,e.state=`PARSING_TIEBREAK_SIDE1`)}function mu(e){let t=El(e.parsedFormat,e.setIndex),n=Dl(t)?cu(e):fu(e,t);n&&e.sets.push(n),pu(e)}function hu(e){mu(e)}function gu(e){(e.currentSide1Buffer||e.currentSide2Buffer||e.currentTiebreakSide1Buffer||e.currentTiebreakSide2Buffer)&&mu(e)}function _u(e){let t=e.parsedFormat.bestOf||3,n=Math.ceil(t/2),r=e.sets.filter(e=>e.winningSide===1).length,i=e.sets.filter(e=>e.winningSide===2).length;return r>=n||i>=n}function vu(e){let t=[];for(let n of e.sets)if((!n.side1Score||n.side1Score===0)&&(!n.side2Score||n.side2Score===0)&&(n.side1TiebreakScore!==void 0||n.side2TiebreakScore!==void 0)){let e=n.side1TiebreakScore??0,r=n.side2TiebreakScore??0;t.push(`[${e}-${r}]`)}else{let e=`${n.side1Score||0}-${n.side2Score||0}`;if(n.side1TiebreakScore!==void 0||n.side2TiebreakScore!==void 0){let t=n.side1TiebreakScore??0,r=n.side2TiebreakScore??0,i=n.winningSide===1?r:t;e+=`(${i})`}t.push(e)}return t.join(` `)}function yu(e){let t=Math.max(0,e.position-5),n=Math.min(e.input.length,e.position+5),r=e.input.substring(t,e.position),i=e.input.substring(e.position+1,n);return`...${r}[${e.input[e.position]}]${i}...`}var{RETIRED:bu,WALKOVER:xu,DEFAULTED:Su,DOUBLE_WALKOVER:Cu,DOUBLE_DEFAULT:wu,SUSPENDED:Tu,CANCELLED:Eu,INCOMPLETE:Du,DEAD_RUBBER:Ou,IN_PROGRESS:ku,AWAITING_RESULT:Au,COMPLETED:ju,TO_BE_PLAYED:Mu}=t.matchUpStatusConstants;function Nu(e,t){let n=``;if(e&&(n=(e.sets||[]).map(e=>{let t=`${e.side1Score||0}-${e.side2Score||0}`;if(e.side1TiebreakScore!==void 0||e.side2TiebreakScore!==void 0){let n=e.winningSide===1?e.side2TiebreakScore:e.side1TiebreakScore;t+=`(${n})`}return t}).join(` `)),t&&t!==ju&&t!==Mu){let e=Pu(t);if(e)return n?`${n} ${e}`:e}return n}function Pu(e){return{[bu]:`ret`,[xu]:`wo`,[Su]:`def`,[Cu]:`wo`,[wu]:`def`,[Tu]:`susp`,[Eu]:`canc`,[Du]:`inc`,[Ou]:`dr`,[ku]:`in`,[Au]:`await`}[e]||``}var{RETIRED:Fu,WALKOVER:Iu,DEFAULTED:Lu,SUSPENDED:Ru,CANCELLED:zu,INCOMPLETE:Bu,DEAD_RUBBER:Vu,IN_PROGRESS:Hu,AWAITING_RESULT:Uu,ABANDONED:Wu,DOUBLE_WALKOVER:Gu,DOUBLE_DEFAULT:Ku}=t.matchUpStatusConstants,qu=`var(--chc-status-success)`;function Ju(e){let{matchUp:n,container:r,onScoreChange:i,labels:a={}}=e;r.innerHTML=``,r.style.display=`flex`,r.style.flexDirection=`column`,r.style.gap=`1em`;let o=n?.sides?.find(e=>e.sideNumber===1),s=n?.sides?.find(e=>e.sideNumber===2),c=n.score?{...n.score}:void 0,l=n.winningSide,u=n.matchUpStatus,d=document.createElement(`div`);d.style.marginBottom=`0.25em`,r.appendChild(d);let f=document.createElement(`div`);f.style.display=`none`,f.style.marginTop=`0.25em`,f.style.padding=`0.35em 0.5em`,f.style.backgroundColor=`var(--chc-bg-secondary)`,f.style.borderRadius=`4px`,f.style.flexDirection=`column`,f.style.gap=`0.35em`;let p=document.createElement(`label`);p.style.display=`flex`,p.style.alignItems=`center`,p.style.gap=`0.4em`,p.style.cursor=`pointer`;let m=document.createElement(`input`);m.type=`radio`,m.name=`winnerSelection`,m.value=`1`;let h=document.createElement(`span`);h.textContent=o?.participant?.participantName||`Side 1`,h.style.fontSize=`0.75rem`,p.appendChild(m),p.appendChild(h);let g=document.createElement(`label`);g.style.display=`flex`,g.style.alignItems=`center`,g.style.gap=`0.4em`,g.style.cursor=`pointer`;let _=document.createElement(`input`);_.type=`radio`,_.name=`winnerSelection`,_.value=`2`;let v=document.createElement(`span`);v.textContent=s?.participant?.participantName||`Side 2`,v.style.fontSize=`0.75rem`,g.appendChild(_),g.appendChild(v);let y=document.createElement(`label`);y.style.display=`flex`,y.style.alignItems=`center`,y.style.gap=`0.4em`,y.style.cursor=`pointer`;let b=document.createElement(`input`);b.type=`radio`,b.name=`winnerSelection`,b.value=As;let x=document.createElement(`span`);x.textContent=a.neitherSide||`Neither side`,x.style.fontSize=`0.75rem`,y.appendChild(b),y.appendChild(x);let S=document.createElement(`div`);S.style.display=`none`,S.style.fontSize=`0.7rem`,S.style.color=`var(--chc-text-warning, var(--chc-text-primary))`,f.appendChild(p),f.appendChild(g),f.appendChild(y),f.appendChild(S),r.appendChild(f);let C=e=>{let{WALKOVER:r,CANCELLED:i,DEAD_RUBBER:a}=t.matchUpStatusConstants,o=[r,i,a],s=e?.matchUpStatus&&o.includes(e.matchUpStatus),f;e?.clearAll||s?(f=void 0,c=void 0):e?.scoreObject?(f=e.scoreObject,c=e.scoreObject):f=c,e?.clearAll?(l=void 0,u=void 0):e!=null&&(`winningSide`in e&&(l=e.winningSide),`matchUpStatus`in e&&(u=e.matchUpStatus));let p={...n,score:f,winningSide:l,matchUpStatus:u};d.innerHTML=``;let m=ui({matchUp:p,isLucky:!0,composition:wi[tc().composition||`Australian`]||wi.Australian});d.appendChild(m)};if(C(),n.matchUpFormat){let e=document.createElement(`div`);e.style.fontSize=`0.9rem`,e.style.marginBottom=`0.5em`,e.style.display=`flex`,e.style.alignItems=`center`,e.style.gap=`0.5em`;let t=document.createElement(`span`);t.textContent=(a.format||`Format`)+`:`,t.style.color=`var(--chc-text-secondary)`,e.appendChild(t);let i=document.createElement(`button`);i.textContent=n.matchUpFormat,i.className=`button is-small is-white`,i.style.fontSize=`0.75rem`,i.style.padding=`0.2em 0.5em`,i.style.cursor=`pointer`,i.title=`Click to edit format`,i.addEventListener(`click`,()=>{try{Qa({existingMatchUpFormat:n.matchUpFormat,callback:e=>{if(e&&e!==n.matchUpFormat){n.matchUpFormat=e,i.textContent=e;let t=document.getElementById(`scoreInputV2`);t&&(t.value=``,t.dispatchEvent(new Event(`input`,{bubbles:!0}))),O.textContent=`Score cleared - format changed`,O.style.color=`var(--chc-text-muted)`}},modalConfig:{style:{fontSize:`12px`,border:`3px solid #0066cc`}}})}catch(e){console.error(`[FreeScore] Error opening format selector:`,e)}}),e.appendChild(i),r.appendChild(e)}let w=document.createElement(`div`);w.style.display=`flex`,w.style.alignItems=`center`,w.style.gap=`0.5em`;let T=document.createElement(`input`);T.type=`text`,T.className=`input`,T.placeholder=``,T.style.flex=`1`,T.id=`scoreInputV2`,c&&(T.value=Nu(c,u));let E=document.createElement(`span`);E.style.fontSize=`1.2rem`,E.style.minWidth=`1.5em`,w.appendChild(T),w.appendChild(E),r.appendChild(w);let D=document.createElement(`div`);D.style.fontSize=`0.9rem`,D.style.color=`var(--chc-border-focus)`,D.style.fontFamily=`monospace`,D.style.minHeight=`1.5em`,D.style.padding=`0.25em`,r.appendChild(D);let O=document.createElement(`div`);O.style.fontSize=`0.9rem`,O.style.minHeight=`1.5em`,r.appendChild(O);let k=l,A=()=>{m.checked?(k=1,p.style.fontWeight=`bold`,p.style.color=qu,g.style.fontWeight=``,g.style.color=``):_.checked?(k=2,g.style.fontWeight=`bold`,g.style.color=qu,p.style.fontWeight=``,p.style.color=``):b.checked&&(k=As,y.style.fontWeight=`bold`,y.style.color=qu,p.style.fontWeight=``,p.style.color=``,g.style.fontWeight=``,g.style.color=``),I()};m.addEventListener(`change`,A),_.addEventListener(`change`,A),b.addEventListener(`change`,A);function j(){f.style.display=`none`,m.checked=!1,_.checked=!1,b.checked=!1,p.style.fontWeight=``,p.style.color=``,g.style.fontWeight=``,g.style.color=``,y.style.fontWeight=``,y.style.color=``,S.style.display=`none`,k=void 0}let M={[Fu]:a.retired||`RETIRED`,[Iu]:a.walkover||`WALKOVER`,[Lu]:a.defaulted||`DEFAULTED`,[Ru]:`SUSPENDED`,[zu]:`CANCELLED`,[Bu]:`INCOMPLETE`,[Vu]:`DEAD RUBBER`,[Hu]:`IN PROGRESS`,[Uu]:`AWAITING RESULT`,[Wu]:a.abandoned||`ABANDONED`};function N(e){let{result:t,matchUpStatus:n,winningSide:r,isValid:i,error:a,scoreString:o,formattedScore:s}=e,c=Ls(n),l={...t,isValid:i,matchUpStatus:n,winningSide:r,sets:c?[]:t.sets,scoreObject:c?void 0:t.scoreObject,score:c?void 0:s||o};return a?l.error=a:delete l.error,l}function P(e){let t=a.validScore||`Valid score`,n=e&&M[e];return n?`${t} - ${n}`:t}function F(e,t,n){let r=e.matchUpStatus||t.matchUpStatus,a=Ms.has(r),o=[zu,Vu,Uu,Bu,Hu,Ru,Wu].includes(r);if(a){f.style.display=`flex`;let a=Bs(r);y.style.display=a?`flex`:`none`,!a&&k===`NEITHER`&&(k=void 0,b.checked=!1,y.style.fontWeight=``,y.style.color=``);let o=Hs({selectedOutcome:r,winnerSelection:k});if(S.style.display=o.isDoubleExit?`block`:`none`,o.isDoubleExit&&(S.textContent=Vs(r)),o.winningSide===void 0){i(N({result:e,matchUpStatus:o.matchUpStatus,winningSide:void 0,isValid:o.isValid,error:o.isValid?void 0:js,formattedScore:t.formattedScore,scoreString:n}));return}return o.winningSide}if(o){j();return}return j(),e.winningSide}let I=()=>{let e=T.value.trim();if(!e){E.textContent=``,D.textContent=``,O.textContent=``,O.style.color=``,j(),C({clearAll:!0}),i({isValid:!1,sets:[],matchUpStatus:`TO_BE_PLAYED`});return}let t=Yl(e,n.matchUpFormat);D.textContent=t.formattedScore||``;let r=new Set([Fu,Iu,Lu,Ru,zu,Bu,Vu,Hu,Uu,Wu]),a=t.matchUpStatus&&r.has(t.matchUpStatus),o=t.formattedScore?dc(t.formattedScore,n.matchUpFormat,t.matchUpStatus):{isValid:!1,sets:[],error:`No score to validate`},s=o.sets&&o.sets.length>0,c=(typeof k==`number`?k:void 0)??o.winningSide;if((s&&o.scoreObject||a)&&C({scoreObject:o.scoreObject,winningSide:c,matchUpStatus:o.matchUpStatus||t.matchUpStatus}),o.isValid||a){if(E.textContent=`✓`,E.style.color=qu,O.textContent=P(o.matchUpStatus||t.matchUpStatus),O.style.color=qu,a){let n=F(o,t,e),r=o.matchUpStatus||t.matchUpStatus;if(n===void 0&&Ms.has(r))return;i(N({result:o,matchUpStatus:r,winningSide:n,isValid:!0,formattedScore:t.formattedScore,scoreString:e}))}else j(),i({...o,isValid:!0,winningSide:o.winningSide,matchUpStatus:o.matchUpStatus||t.matchUpStatus,score:t.formattedScore||e})}else!o.isValid&&s?(E.textContent=`⋯`,E.style.color=`var(--chc-status-warning)`,O.textContent=o.error||`Score incomplete - continue typing`,O.style.color=`var(--chc-status-warning)`,j(),i(o)):(E.textContent=`✗`,E.style.color=`var(--chc-status-error)`,O.textContent=o.error||`Invalid score`,O.style.color=`var(--chc-status-error)`,j(),C({scoreObject:void 0,winningSide:void 0,matchUpStatus:void 0}),i(o))},L=!1;T.addEventListener(`input`,()=>{I();let e=T.value,r=e.trim();if(!L&&r){let i=Yl(r,n.matchUpFormat),a=i.formattedScore?dc(i.formattedScore,n.matchUpFormat,i.matchUpStatus):{isValid:!1,winningSide:void 0},o=a.isValid&&a.winningSide!==void 0,s=e.length>0&&/[\s-]$/.test(e),c=t.matchUpFormatCode.parse(n.matchUpFormat),l=!!c?.exactly||c?.bestOf===1,u=c?.exactly||c?.bestOf||3,d=i.sets?.length>=u;o&&s&&(!l||d)&&(L=!0)}else if(L){let t=e.length>0&&/[\s-]$/.test(e);(r.length===0||!t)&&(L=!1)}}),T.addEventListener(`keydown`,e=>{L&&![`Backspace`,`Delete`,`ArrowLeft`,`ArrowRight`,`Tab`].includes(e.key)&&e.preventDefault()}),T.addEventListener(`keyup`,e=>{if(e.key===`Enter`){let e=document.getElementById(`submitScoreV2`);e&&!e.disabled&&e.click()}}),l===1?(m.checked=!0,p.style.fontWeight=`bold`,p.style.color=qu):l===2&&(_.checked=!0,g.style.fontWeight=`bold`,g.style.color=qu),setTimeout(()=>{T.focus(),u===Gu||u===Ku?(C({scoreObject:c,winningSide:l,matchUpStatus:u}),i({isValid:!0,sets:c?.sets||[],scoreObject:c,winningSide:l,matchUpStatus:u})):(T.value||u&&u!==`TO_BE_PLAYED`&&u!==`COMPLETED`)&&I()},100),globalThis.resetFreeScore=()=>{T.value=``,c=void 0,l=void 0,u=void 0,E.textContent=``,D.textContent=``,O.textContent=``,O.style.color=``,f.style.display=`none`,m.checked=!1,_.checked=!1,p.style.fontWeight=``,p.style.color=``,g.style.fontWeight=``,g.style.color=``,k=void 0,L=!1,C({clearAll:!0}),i({isValid:!1,sets:[],matchUpStatus:`TO_BE_PLAYED`}),T.focus()}}var{WALKOVER:Yu,DEFAULTED:Xu,DOUBLE_WALKOVER:Zu,DOUBLE_DEFAULT:Qu}=t.matchUpStatusConstants;function $u(e){return e===Zu?Yu:e===Qu?Xu:e}function ed(e){if(typeof e==`string`)return e||void 0;if(!e||typeof e!=`object`)return;let t=e,n=t.matchUpStatusCode??t.code;return typeof n==`string`&&n?n:void 0}function td(e,t){let n=$u(t);if(!e||!n)return[];let r=e[n];return Array.isArray(r)?r.filter(e=>!!ed(e)):[]}function nd(e){return e.matchUpStatusCodeDisplay||e.label||e.matchUpStatusCode}function rd(e){let t=nd(e),n=e.label&&e.label!==t?e.label:e.description;return n&&n!==t?n:void 0}var id=`statusCodeSelectV2`;function ad(e){let{groups:t,labels:n={},initialCode:r}=e,i=document.createElement(`div`);i.style.display=`none`,i.style.marginTop=`0.6em`;let a=document.createElement(`div`);a.textContent=(n.reasonCode||`Reason`)+`:`,a.style.fontSize=`0.75rem`,a.style.fontWeight=`500`,a.style.marginBottom=`0.25em`,a.style.color=`var(--chc-text-primary)`,i.appendChild(a);let o=document.createElement(`select`);o.id=id,o.className=`input`,o.style.fontSize=`0.8rem`,o.style.width=`100%`,o.style.backgroundColor=`var(--chc-bg-primary)`,o.style.color=`var(--chc-text-primary)`,o.style.border=`1px solid var(--chc-border-primary)`,i.appendChild(o);let s=document.createElement(`div`);s.style.fontSize=`0.7rem`,s.style.marginTop=`0.2em`,s.style.color=`var(--chc-text-secondary)`,i.appendChild(s);let c=r,l=[],u=()=>{let e=l.find(e=>e.matchUpStatusCode===c);s.textContent=e?.description??``,s.style.display=e?.description?`block`:`none`};return o.addEventListener(`change`,()=>{c=o.value||void 0,u()}),{element:i,update:e=>{if(l=td(t,e),!l.length){i.style.display=`none`,o.innerHTML=``,c=void 0,u();return}c&&!l.some(e=>e.matchUpStatusCode===c)&&(c=void 0),o.innerHTML=``;let r=document.createElement(`option`);r.value=``,r.textContent=n.noReasonCode||`No reason given`,o.appendChild(r);for(let e of l){let t=document.createElement(`option`);t.value=e.matchUpStatusCode;let n=rd(e);t.textContent=n?`${nd(e)} — ${n}`:nd(e),o.appendChild(t)}return o.value=c??``,i.style.display=`block`,u(),c},getSelectedCode:()=>c}}var od=`Irregular Endings:`,sd={dynamicSets:`Dynamic Sets`,freeScore:`Free Score`,dialPad:`Dial Pad`,inlineScoring:`Inline Scoring`},cd=[`dynamicSets`,`freeScore`,`dialPad`,`inlineScoring`];function ld(e){let{matchUp:t,callback:n,onClose:r,labels:i={},matchUpStatusCodes:a}=e,o=ad({initialCode:ed(t?.matchUpStatusCodes?.[0]),groups:a,labels:i}),s=tc().scoringApproach||`dynamicSets`,c=!!(t.score?.sets?.length||t.matchUpStatus),l=null,u=!1,d=e=>{l=e,o.update(e?.matchUpStatus),u&&(e.sets?.length>0||e.score)&&(u=!1);let t=document.getElementById(`submitScoreV2`);t&&(t.disabled=!(s===`inlineScoring`||e.isValid||u&&c));let n=document.getElementById(`clearScoreV2`);if(n){let t=document.getElementById(`scoreInputV2`);if(t)n.disabled=!t.value.trim();else{let t=e.sets&&e.sets.length>0,r=e.matchUpStatus&&e.matchUpStatus!==`COMPLETED`&&e.matchUpStatus!==`TO_BE_PLAYED`;n.disabled=!(t||r)}}},f=()=>{window.cleanupDialPad&&(window.cleanupDialPad(),window.cleanupDialPad=void 0),window.resetDialPad&&(window.resetDialPad=void 0),window.resetDynamicSets&&(window.resetDynamicSets=void 0),window.resetInlineScoring&&(window.resetInlineScoring=void 0)},p=e=>{let n=document.createElement(`div`);n.style.padding=`1em`;let r=document.createElement(`div`);return n.appendChild(r),n.appendChild(o.element),o.update(l?.matchUpStatus??t.matchUpStatus),e===`freeScore`?Ju({matchUp:t,container:r,onScoreChange:d,labels:i}):e===`dynamicSets`?Kc({matchUp:t,container:r,onScoreChange:d,labels:i}):e===`dialPad`?ml({matchUp:t,container:r,onScoreChange:d,labels:i}):e===`inlineScoring`&&ac({matchUp:t,container:r,onScoreChange:d,labels:i}),n},m={freeScore:`
146
146
  <strong>${i.scoreTips||`Score Entry Tips:`}</strong><br><br>
147
147
  <strong>${i.setScores||`Set Scores:`}</strong> Space or dash-separated (e.g., "6-4 6-3")<br><br>
148
148
  <strong>${i.tiebreaks||`Tiebreaks:`}</strong> Auto-detected from digits (e.g., "67 3" becomes "6-7(3)")<br><br>
@@ -211,7 +211,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
211
211
  `,`Instead, pass the .innerHTML of the element, or use a function that`,`returns a cloned version of the element instead.`,`
212
212
 
213
213
  `,`1) content: element.innerHTML
214
- `,`2) content: () => element.cloneNode(true)`].join(` `))}var s=i.reduce(function(e,t){var n=t&&Oh(t,r);return n&&e.push(n),e},[]);return Rm(e)?s[0]:s}kh.defaultProps=fh,kh.setDefaultProps=mh,kh.currentInput=Ym,Object.assign({},Uf,{effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:`0`,top:`0`,margin:`0`},arrow:{position:`absolute`},reference:{}};Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow)}}),kh.setDefaultProps({render:wh});var Ah=`#000000.#434343.#666666.#999999.#b7b7b7.#cccccc.#d9d9d9.#ffffff.#980000.#ff0000.#ff9900.#ffff00.#00ff00.#00ffff.#4a86e8.#0000ff.#9900ff.#ff00ff.#e6b8af.#f4cccc.#fce5cd.#fff2cc.#d9ead3.#d0e0e3.#c9daf8.#cfe2f3.#d9d2e9.#ead1dc`.split(`.`),jh=`notes-toolbar-recent-colors`,Mh=8;function Nh(){try{return JSON.parse(localStorage.getItem(jh)||`[]`)}catch{return[]}}function Ph(e){let t=Nh().filter(t=>t!==e);t.unshift(e),t.length>Mh&&(t=t.slice(0,Mh)),localStorage.setItem(jh,JSON.stringify(t))}function Fh(e={}){let t=document.createElement(`div`);return t.className=`notes-toolbar`,t.appendChild(Bh(e)),t.appendChild(Vh(e)),t.appendChild(Hh(e)),t.appendChild(Kh(e)),t.appendChild(Yh(e)),t.appendChild(Xh(e)),t.appendChild(Qh(e)),t}function Ih(e,t){for(let[n,r]of Object.entries(t)){let t=e.querySelector(`[data-action="${n}"]`);t&&t.classList.toggle(`is-active`,r)}}function Lh(e,t){let n=e.querySelector(`[data-action="heading"]`);n&&(n.value=t===!1?`0`:String(t))}function Rh(){let e=document.createElement(`div`);return e.className=`notes-toolbar-group`,e}function zh(e,t,n,r){let i=document.createElement(`button`);return i.className=`notes-toolbar-btn`,i.dataset.action=e,i.title=n,i.type=`button`,i.innerHTML=t,r&&i.addEventListener(`click`,r),i}function Bh(e){let t=Rh(),n=document.createElement(`select`);n.dataset.action=`heading`,n.title=`Text style`;for(let e of[{value:`0`,label:`Paragraph`},{value:`1`,label:`Heading 1`},{value:`2`,label:`Heading 2`},{value:`3`,label:`Heading 3`},{value:`4`,label:`Heading 4`},{value:`5`,label:`Heading 5`},{value:`6`,label:`Heading 6`}]){let t=document.createElement(`option`);t.value=e.value,t.textContent=e.label,n.appendChild(t)}return n.addEventListener(`change`,()=>{let t=parseInt(n.value,10);e.onHeading?.(t!==0&&t)}),t.appendChild(n),t}function Vh(e){let t=Rh();return t.appendChild(zh(`bold`,`<b>B</b>`,`Bold`,e.onBold)),t.appendChild(zh(`italic`,`<i>I</i>`,`Italic`,e.onItalic)),t.appendChild(zh(`underline`,`<u>U</u>`,`Underline`,e.onUnderline)),t.appendChild(zh(`strike`,`<s>S</s>`,`Strikethrough`,e.onStrike)),t}function Hh(e){let t=Rh();return t.appendChild(Uh(`color`,`A`,`Text color`,`#000000`,t=>{Ph(t),e.onColor?.(t)})),t.appendChild(Uh(`background`,`A`,`Background color`,`#ffff00`,t=>{Ph(t),e.onBackground?.(t)})),t}function Uh(e,t,n,r,i){let a=document.createElement(`button`);a.className=`notes-toolbar-btn notes-toolbar-color-btn`,a.dataset.action=e,a.title=n,a.type=`button`;let o=document.createElement(`span`);o.className=`notes-toolbar-color-letter`,o.textContent=t,a.appendChild(o);let s=document.createElement(`span`);s.className=`notes-toolbar-color-bar`,s.style.backgroundColor=r,a.appendChild(s);let c;return a.addEventListener(`click`,()=>{if(c){c.destroy(),c=void 0;return}let e=Wh(r,e=>{s.style.backgroundColor=e,i(e),c?.destroy(),c=void 0});c=kh(a,{content:e,theme:`light-border`,trigger:`manual`,interactive:!0,placement:`bottom-start`,onHidden:()=>{c?.destroy(),c=void 0}}),c.show()}),a}function Wh(e,t){let n=document.createElement(`div`);n.className=`notes-color-panel`;let r=document.createElement(`div`);r.className=`notes-color-swatches`;for(let n of Ah)r.appendChild(Gh(n,n===e,t));n.appendChild(r);let i=Nh();if(i.length){let r=document.createElement(`div`);r.className=`notes-color-section-label`,r.textContent=`Recent`,n.appendChild(r);let a=document.createElement(`div`);a.className=`notes-color-swatches`;for(let n of i)a.appendChild(Gh(n,n===e,t));n.appendChild(a)}let a=document.createElement(`div`);a.className=`notes-color-custom-row`;let o=document.createElement(`input`);o.type=`color`,o.value=e,o.className=`notes-color-custom-input`;let s=document.createElement(`label`);return s.className=`notes-color-custom-label`,s.textContent=`Custom...`,s.addEventListener(`click`,()=>o.click()),o.addEventListener(`input`,()=>t(o.value)),a.appendChild(o),a.appendChild(s),n.appendChild(a),n}function Gh(e,t,n){let r=document.createElement(`button`);return r.type=`button`,r.className=`notes-color-swatch`,t&&r.classList.add(`is-selected`),r.style.backgroundColor=e,(e===`#ffffff`||e===`#fff`)&&(r.style.border=`1px solid var(--chc-border-secondary)`),r.title=e,r.addEventListener(`click`,()=>n(e)),r}function Kh(e){let t=Rh();return t.appendChild(zh(`orderedList`,qh(16,16,`<path d="M3 2h12v2H3zm0 5h12v2H3zm0 5h12v2H3z" fill="currentColor"/><text x="0" y="4" font-size="3.5" fill="currentColor">1</text><text x="0" y="9" font-size="3.5" fill="currentColor">2</text><text x="0" y="14" font-size="3.5" fill="currentColor">3</text>`),`Ordered list`,e.onOrderedList)),t.appendChild(zh(`bulletList`,qh(16,16,`<circle cx="1.5" cy="3" r="1.5" fill="currentColor"/><circle cx="1.5" cy="8" r="1.5" fill="currentColor"/><circle cx="1.5" cy="13" r="1.5" fill="currentColor"/><path d="M5 2h10v2H5zm0 5h10v2H5zm0 5h10v2H5z" fill="currentColor"/>`),`Bullet list`,e.onBulletList)),t}function qh(e,t,n){return`<svg width="${e}" height="${t}" viewBox="0 0 ${e} ${t}" xmlns="http://www.w3.org/2000/svg">${n}</svg>`}var Jh={alignLeft:qh(16,16,`<path d="M1 2h14v2H1zm0 4h9v2H1zm0 4h14v2H1zm0 4h9v2H1z" fill="currentColor"/>`),alignCenter:qh(16,16,`<path d="M1 2h14v2H1zm3.5 4h7v2h-7zM1 10h14v2H1zm3.5 4h7v2h-7z" fill="currentColor"/>`),alignRight:qh(16,16,`<path d="M1 2h14v2H1zm6 4h8v2H7zM1 10h14v2H1zm6 4h8v2H7z" fill="currentColor"/>`),alignJustify:qh(16,16,`<path d="M1 2h14v2H1zm0 4h14v2H1zm0 4h14v2H1zm0 4h14v2H1z" fill="currentColor"/>`)};function Yh(e){let t=Rh();return t.appendChild(zh(`alignLeft`,Jh.alignLeft,`Align left`,()=>e.onAlign?.(`left`))),t.appendChild(zh(`alignCenter`,Jh.alignCenter,`Align center`,()=>e.onAlign?.(`center`))),t.appendChild(zh(`alignRight`,Jh.alignRight,`Align right`,()=>e.onAlign?.(`right`))),t.appendChild(zh(`alignJustify`,Jh.alignJustify,`Justify`,()=>e.onAlign?.(`justify`))),t}function Xh(e){let t=Rh();t.appendChild(zh(`blockquote`,`“`,`Blockquote`,e.onBlockquote)),t.appendChild(zh(`codeBlock`,`</>`,`Code block`,e.onCodeBlock));let n=zh(`link`,`⇗`,`Insert link`);Zh(n,`Enter URL`,`https://`,t=>e.onLink?.(t)),t.appendChild(n);let r=zh(`video`,`▷`,`Insert video`);return Zh(r,`YouTube URL`,`https://youtube.com/...`,t=>e.onVideo?.(t)),t.appendChild(r),t}function Zh(e,t,n,r){let i;e.addEventListener(`click`,()=>{if(i){i.destroy(),i=void 0;return}let a=document.createElement(`div`);a.className=`notes-url-panel`;let o=document.createElement(`div`);o.className=`notes-url-label`,o.textContent=t,a.appendChild(o);let s=document.createElement(`input`);s.type=`url`,s.className=`notes-url-input`,s.placeholder=n,a.appendChild(s);let c=document.createElement(`div`);c.className=`notes-url-actions`;let l=document.createElement(`button`);l.type=`button`,l.className=`button notes-url-cancel`,l.textContent=`Cancel`,l.addEventListener(`click`,()=>{i?.destroy(),i=void 0});let u=document.createElement(`button`);u.type=`button`,u.className=`button is-info notes-url-confirm`,u.textContent=`Insert`,u.addEventListener(`click`,()=>{let e=s.value.trim();e&&r(e),i?.destroy(),i=void 0}),c.appendChild(l),c.appendChild(u),a.appendChild(c),s.addEventListener(`keydown`,e=>{e.key===`Enter`?(e.preventDefault(),u.click()):e.key===`Escape`&&l.click()}),i=kh(e,{content:a,theme:`light-border`,trigger:`manual`,interactive:!0,placement:`bottom-start`,onShown:()=>setTimeout(()=>s.focus(),0),onHidden:()=>{i?.destroy(),i=void 0}}),i.show()})}function Qh(e){let t=Rh();return t.appendChild(zh(`clearFormatting`,`⊘`,`Clear formatting`,e.onClearFormatting)),t}function $h(e={}){let t=document.createElement(`div`);t.className=`notes-editor-content`;let l={toolbar:void 0,editorElement:t,editor:void 0,getHtml:()=>l.editor&&!l.editor.isEmpty?l.editor.getHTML():``,isEmpty:()=>!l.editor||l.editor.isEmpty,destroy:()=>{l.editor?.destroy(),l.editor=void 0}};l.toolbar=Fh({onHeading:e=>{l.editor&&(e===!1?l.editor.chain().focus().setParagraph().run():l.editor.chain().focus().toggleHeading({level:e}).run())},onBold:()=>l.editor?.chain().focus().toggleBold().run(),onItalic:()=>l.editor?.chain().focus().toggleItalic().run(),onUnderline:()=>l.editor?.chain().focus().toggleUnderline().run(),onStrike:()=>l.editor?.chain().focus().toggleStrike().run(),onColor:e=>l.editor?.chain().focus().setColor(e).run(),onBackground:e=>l.editor?.chain().focus().setHighlight({color:e}).run(),onBulletList:()=>l.editor?.chain().focus().toggleBulletList().run(),onOrderedList:()=>l.editor?.chain().focus().toggleOrderedList().run(),onAlign:e=>l.editor?.chain().focus().setTextAlign(e).run(),onBlockquote:()=>l.editor?.chain().focus().toggleBlockquote().run(),onCodeBlock:()=>l.editor?.chain().focus().toggleCodeBlock().run(),onLink:e=>l.editor?.chain().focus().setLink({href:e}).run(),onVideo:e=>l.editor?.commands.setYoutubeVideo({src:e}),onClearFormatting:()=>l.editor?.chain().focus().clearNodes().unsetAllMarks().run()});let u=()=>{if(l.editor){Ih(l.toolbar,{bold:l.editor.isActive(`bold`),italic:l.editor.isActive(`italic`),underline:l.editor.isActive(`underline`),strike:l.editor.isActive(`strike`),orderedList:l.editor.isActive(`orderedList`),bulletList:l.editor.isActive(`bulletList`),blockquote:l.editor.isActive(`blockquote`),codeBlock:l.editor.isActive(`codeBlock`),alignLeft:l.editor.isActive({textAlign:`left`}),alignCenter:l.editor.isActive({textAlign:`center`}),alignRight:l.editor.isActive({textAlign:`right`}),alignJustify:l.editor.isActive({textAlign:`justify`})});for(let e=1;e<=6;e++)if(l.editor.isActive(`heading`,{level:e})){Lh(l.toolbar,e);return}Lh(l.toolbar,!1)}};return requestAnimationFrame(()=>{l.editor=new r.Editor({element:t,extensions:[o.default,i.TextStyle,n.Color,a.default.configure({multicolor:!0}),s.default.configure({types:[`heading`,`paragraph`]}),c.default.configure({inline:!1})],content:e.initialHtml||``,onSelectionUpdate:u,onTransaction:u})}),l}function eg(e,t,n){if(!e)return{};let r=document.createElement(`aside`);r.classList.add(`menu`);let i={},a=e=>n&&e.close!==!1?t=>{t.stopPropagation(),n(),e.onClick()}:t=>{t.stopPropagation(),e.onClick()},o=0,s=()=>(o+=1,o),c=e=>e?.heading||e?.text||e?.label||`Item ${s()}`,l=e=>{let t=document.createElement(`li`);if(t.className=`font-medium`,e.style&&(t.style.cssText=e.style),e.onClick){let n=e.fontSize||`1em`;if(e.divider){let e=document.createElement(`hr`);e.classList.add(`dropdown-divider`),t.appendChild(e)}else{let r=document.createElement(`a`),i=e.disabled?`0.4`:`1`;r.style.cssText=`text-decoration: none; opacity: ${i}; font-size: ${n}`,e.class&&r.classList.add(e.class),e.color&&(r.style.color=e.color),e.heading&&(r.style.fontWeight=`bold`),e.disabled||(r.onclick=a(e)),r.innerHTML=c(e),t.appendChild(r)}}else t.innerHTML=c(e),e.disabled||(t.onclick=e.onClick);return t},u;for(let e of t||[])if(!e.hide){if(e.items){if(e.text){let t=document.createElement(`p`);t.className=`menu-label font-medium`,t.innerHTML=e.text,r.appendChild(t)}let t=document.createElement(`ul`);t.className=`menu-list`;for(let n of e.items)n.hide||t.appendChild(l(n));r.appendChild(t)}else if(e.type===`input`){let{field:t,inputElement:n}=_n(e);e.focus&&(u=n),i[e.field]=n,r.appendChild(t)}else if(e.type===`divider`){let e=document.createElement(`hr`);e.classList.add(`dropdown-divider`),r.appendChild(e)}}return e.appendChild(r),{focusElement:u}}function tg(e){return typeof e==`function`}var ng;function rg(e){ng&&=(ng?.destroy(!0),void 0),e?.remove&&e.remove()}function ig(e){let{title:t,options:n,menuItems:r=[],coords:i,callback:a,config:o}=e,{target:s,items:c}=e;if(!n?.length&&!c?.length&&!r)return;rg();let l=document.createElement(`div`),u;return s||=i?.evt?.target,s&&(ng=kh(s,{content:()=>{c=c?.filter(e=>!e.hide&&!e.disabled).map(e=>({...e,onClick:()=>{rg(l),tg(e.onClick)&&e.onClick()}}))||n?.filter(e=>!e.hide&&!e.disabled).map(e=>({text:typeof e==`object`?e.option:e,style:e.style,onClick:()=>{e.subMenu?ng.setContent(`IMPLEMENT SUB MENU`):tg(e.onClick)?(rg(l),e.onClick()):tg(a)&&a&&(rg(l),a(typeof e==`object`?{...e,coords:i}:e))}}));let e=[{text:t,items:c},...r];return u=eg(l,e).focusElement,l},theme:`light-border`,trigger:`click`,onShown:()=>{u&&setTimeout(()=>u?.focus(),0)},...o}),ng.show(),ng.setProps({interactive:!0})),ng}var Y=`court-line`;function X(e,t){let n=document.createElementNS(`http://www.w3.org/2000/svg`,e);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);return n}function ag(e,t){let n=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);return n.setAttribute(`viewBox`,e),n.setAttribute(`class`,t),n.setAttribute(`fill`,`none`),n.style.width=`100%`,n.style.height=`auto`,n.style.display=`block`,n}function og(e){let t=ag(`0 0 360 780`,e);for(let e of[`M 0 0 L 360 0 L 360 780 L 0 780 Z`,`M 45 0 L 45 780`,`M 315 0 L 315 780`,`M 0 390 L 360 390`,`M 45 210 L 315 210`,`M 45 570 L 315 570`,`M 180 210 L 180 570`,`M 180 0 L 180 20`,`M 180 760 L 180 780`])t.appendChild(X(`path`,{d:e,class:Y}));return t}function sg(e){let t=ag(`0 0 500 470`,e),n=[X(`rect`,{x:`0`,y:`0`,width:`500`,height:`470`,class:Y}),X(`circle`,{cx:`250`,cy:`470`,r:`60`,class:Y}),X(`line`,{x1:`0`,y1:`470`,x2:`500`,y2:`470`,class:Y}),X(`rect`,{x:`170`,y:`0`,width:`160`,height:`190`,class:Y}),X(`circle`,{cx:`250`,cy:`190`,r:`60`,class:Y}),X(`line`,{x1:`220`,y1:`40`,x2:`280`,y2:`40`,class:Y}),X(`circle`,{cx:`250`,cy:`52`,r:`12`,class:Y}),X(`path`,{d:`M 30 0 L 30 90 A 220 220 0 0 0 470 90 L 470 0`,class:Y})];for(let e of n)t.appendChild(e);return t}function cg(e){let t=ag(`0 0 500 440`,e),n=[X(`path`,{d:`M 20 170 A 350 400 0 0 1 480 170`,class:Y}),X(`line`,{x1:`250`,y1:`400`,x2:`20`,y2:`170`,class:Y}),X(`line`,{x1:`250`,y1:`400`,x2:`480`,y2:`170`,class:Y}),X(`path`,{d:`M 250 400 L 314 336 L 250 273 L 186 336 Z`,class:Y}),X(`path`,{d:`M 340 355 A 100 100 0 0 1 160 355`,class:Y}),X(`line`,{x1:`340`,y1:`355`,x2:`265`,y2:`405`,class:Y}),X(`line`,{x1:`160`,y1:`355`,x2:`235`,y2:`405`,class:Y}),X(`path`,{d:`M 235 405 A 18 18 0 0 1 265 405`,class:Y}),X(`circle`,{cx:`250`,cy:`340`,r:`9`,class:Y}),X(`line`,{x1:`247`,y1:`339`,x2:`253`,y2:`339`,class:Y}),X(`path`,{d:`M 244 398 L 244 404 L 250 408 L 256 404 L 256 398 Z`,class:Y}),X(`rect`,{x:`310`,y:`332`,width:`8`,height:`8`,transform:`rotate(45 314 336)`,class:Y}),X(`rect`,{x:`246`,y:`269`,width:`8`,height:`8`,transform:`rotate(45 250 273)`,class:Y}),X(`rect`,{x:`182`,y:`332`,width:`8`,height:`8`,transform:`rotate(45 186 336)`,class:Y}),X(`rect`,{x:`230`,y:`393`,width:`8`,height:`18`,class:Y}),X(`rect`,{x:`262`,y:`393`,width:`8`,height:`18`,class:Y})];for(let e of n)t.appendChild(e);return t}function lg(e){let t=ag(`0 0 850 2000`,e),n=[X(`rect`,{x:`0`,y:`0`,width:`850`,height:`2000`,rx:`280`,ry:`280`,class:Y}),X(`line`,{x1:`0`,y1:`1000`,x2:`850`,y2:`1000`,class:Y}),X(`circle`,{cx:`425`,cy:`1000`,r:`60`,class:Y}),X(`line`,{x1:`0`,y1:`650`,x2:`850`,y2:`650`,class:Y}),X(`line`,{x1:`0`,y1:`1350`,x2:`850`,y2:`1350`,class:Y}),X(`line`,{x1:`140`,y1:`300`,x2:`710`,y2:`300`,class:Y}),X(`line`,{x1:`140`,y1:`1700`,x2:`710`,y2:`1700`,class:Y}),X(`path`,{d:`M 395 300 A 40 40 0 0 1 455 300`,class:Y}),X(`path`,{d:`M 395 1700 A 40 40 0 0 0 455 1700`,class:Y}),X(`circle`,{cx:`270`,cy:`650`,r:`50`,class:Y}),X(`circle`,{cx:`580`,cy:`650`,r:`50`,class:Y}),X(`circle`,{cx:`270`,cy:`1350`,r:`50`,class:Y}),X(`circle`,{cx:`580`,cy:`1350`,r:`50`,class:Y})];for(let e of n)t.appendChild(e);return t}function ug(e){let t=ag(`0 0 200 440`,e);for(let e of[`M 0 0 L 200 0 L 200 440 L 0 440 Z`,`M 0 220 L 200 220`,`M 0 150 L 200 150`,`M 0 290 L 200 290`,`M 100 0 L 100 150`,`M 100 290 L 100 440`])t.appendChild(X(`path`,{d:e,class:Y}));return t}function dg(e){let t=ag(`0 0 200 440`,e);for(let e of[`M 0 0 L 200 0 L 200 440 L 0 440 Z`,`M 18 0 L 18 440`,`M 182 0 L 182 440`,`M 0 220 L 200 220`,`M 0 146 L 200 146`,`M 0 294 L 200 294`,`M 0 30 L 200 30`,`M 0 410 L 200 410`,`M 100 146 L 100 220`,`M 100 220 L 100 294`])t.appendChild(X(`path`,{d:e,class:Y}));return t}function fg(e){let t=ag(`0 0 100 200`,e);for(let e of[`M 0 0 L 100 0 L 100 200 L 0 200 Z`,`M 0 100 L 100 100`,`M 0 69.5 L 100 69.5`,`M 0 130.5 L 100 130.5`,`M 50 69.5 L 50 67.5`,`M 50 130.5 L 50 132.5`])t.appendChild(X(`path`,{d:e,class:Y}));return t}var pg=`COURT_SVG`,mg={tennis:og,basketball:sg,baseball:cg,hockey:lg,pickleball:ug,badminton:dg,padel:fg},hg={TENNIS:`tennis`,PADEL:`padel`,PICKLEBALL:`pickleball`,BADMINTON:`badminton`},gg={HAL:`basketball`,INN:`baseball`,PER:`hockey`};function _g(e){if(e){for(let[t,n]of Object.entries(gg))if(e.startsWith(t))return n;if(e.startsWith(`SET`)||e.startsWith(`T`))return e.includes(`@RALLY`)?`pickleball`:`tennis`}}function vg(e){let t=e?.competitionFormat?.sport;return t&&hg[t]?hg[t]:_g(e?.matchUpFormat)}function yg(e){let t=e.getAttribute(`viewBox`);if(!t)return e;let n=t.split(/\s+/).map(Number);if(n.length!==4)return e;let[r,i,a,o]=n;if(o<=a)return e;e.setAttribute(`viewBox`,`${r} ${i} ${o} ${a}`);let s=document.createElementNS(`http://www.w3.org/2000/svg`,`g`);for(s.setAttribute(`transform`,`translate(${o}, 0) rotate(90)`);e.firstChild;)s.appendChild(e.firstChild);return e.appendChild(s),e}function bg(e,t=``){let n=e?mg[e]:void 0;if(n)return yg(n(t?`court--${e} ${t}`:`court--${e}`))}function xg(e){let t=[];return e.city&&t.push(e.city),(e.state||e.region)&&t.push(e.state||e.region),e.countryCode?t.push(e.countryCode):e.country&&t.push(e.country),t.join(`, `)}function Sg(e){if(!e)return;let t=xg(e);return t.length?t:void 0}function Cg(e){let t=e?.find(Boolean);if(!t)return;let n=t.addresses?.find(Boolean);return n?Sg(n)??t.venueName:t.venueName}var wg=/^(\d{4})-(\d{2})-(\d{2})/,Tg=864e5;function Eg(e){if(!e)return null;let t=wg.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]);return!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i)?null:{year:n,month:r,day:i}}function Dg(e,t){if(!t)return new Date(e.year,e.month-1,e.day);let n=Date.UTC(e.year,e.month-1,e.day,0,0,0,0),r=new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}),i=new Date(n);for(let e=0;e<2;e++){let e=r.formatToParts(i),t=t=>Number(e.find(e=>e.type===t)?.value??0),a=Date.UTC(t(`year`),t(`month`)-1,t(`day`),t(`hour`),t(`minute`),t(`second`))-i.getTime();i=new Date(n-a)}return i}function Og(e,t){if(!t)return new Date(e.year,e.month-1,e.day+1);let n=Dg(e,t),r=new Date(n.getTime()+Tg),i=new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`2-digit`,day:`2-digit`}).formatToParts(r),a=e=>Number(i.find(t=>t.type===e)?.value??0);return Dg({year:a(`year`),month:a(`month`),day:a(`day`)},t)}function kg(e){if(!e)return null;let t=Eg(e);if(t)return new Date(t.year,t.month-1,t.day);let n=new Date(e);return Number.isNaN(n.getTime())?null:n}function Ag(e){return e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}function jg(e){return e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})}function Mg(e,t){if(!e&&!t)return;let n=kg(e),r=kg(t),i=!!n&&!Number.isNaN(n.getTime()),a=!!r&&!Number.isNaN(r.getTime());if(i||a)return i&&a&&n.getTime()===r.getTime()?jg(n):i&&a?n.getFullYear()===r.getFullYear()?`${Ag(n)} – ${Ag(r)}, ${r.getFullYear()}`:`${jg(n)} – ${jg(r)}`:jg(i?n:r)}function Ng(e){return e.slice().sort((e,t)=>{let n=e.courtOrder,r=t.courtOrder;return Number.isFinite(n)&&Number.isFinite(r)&&n!==r?n-r:Number.isFinite(n)&&!Number.isFinite(r)?-1:!Number.isFinite(n)&&Number.isFinite(r)?1:e.courtName.localeCompare(t.courtName,void 0,{numeric:!0})})}var Pg=`URL`;function Fg(e,t){if(!Array.isArray(e))return;let n=e.find(e=>e?.name===t&&e?.resourceType===Pg);return n?.url??n?.identifier}function Ig(e,t){if(Array.isArray(e))return e.find(e=>e?.resourceSubType===`COURT_SVG`&&(!t||e?.name===t))?.identifier}function Lg(e){if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(typeof e==`string`){let t=e.trim();if(!t)return;let n=Number(t);return Number.isFinite(n)?n:void 0}}function Rg(...e){for(let t of e){let e=Lg(t);if(e!==void 0)return e}}function zg(e){let t=document.createElement(`div`);if(t.className=e.cardClass,t.setAttribute(`aria-busy`,`true`),e.showImage){let n=document.createElement(`div`);n.className=e.imageClass;let r=document.createElement(`div`);r.className=e.blockClass,n.appendChild(r),t.appendChild(n)}if(e.bodyLines>0){let n=document.createElement(`div`);n.className=e.bodyClass;for(let t=0;t<e.bodyLines;t++){let r=document.createElement(`div`);r.className=e.lineClass,r.style.width=t===0?`90%`:`${60+t*10}%`,n.appendChild(r)}t.appendChild(n)}if(e.showFooter){let n=document.createElement(`div`);n.className=e.footerClass;let r=document.createElement(`div`);r.className=e.lineClass,r.style.width=`40%`,n.appendChild(r),t.appendChild(n)}return t}var Bg={showImage:!0,cornerBadges:[`status`],body:[`title`,`tier`,`location`,`dateRange`],footer:[`feeBadge`,`playerCount`]};function Vg(e){return e?{showImage:e.showImage??Bg.showImage,cornerBadges:e.cornerBadges??Bg.cornerBadges,body:e.body??Bg.body,footer:e.footer??Bg.footer}:Bg}var Hg=()=>`chc-tc-card`,Ug=()=>`chc-tc-card--clickable`,Wg=()=>`chc-tc-card--offline`,Gg=()=>`chc-tc-image`,Kg=()=>`chc-tc-image-img`,qg=()=>`chc-tc-image-svg`,Jg=()=>`chc-tc-image-placeholder`,Yg=()=>`chc-tc-corner-badges`,Xg=()=>`chc-tc-status-pill`,Zg=()=>`chc-tc-offline-badge`,Qg=()=>`chc-tc-body`,$g=()=>`chc-tc-title`,e_=()=>`chc-tc-location`,t_=()=>`chc-tc-date-range`,n_=()=>`chc-tc-organizer`,r_=()=>`chc-tc-updated-at`,i_=()=>`chc-tc-footer`,a_=()=>`chc-tc-fee-badge`,o_=()=>`chc-tc-player-count`,s_=()=>`chc-tc-event-count`,c_=()=>`chc-tc-tier-badge`,l_=()=>`chc-tc-card chc-tc-skeleton`,u_=()=>`chc-tc-skeleton-line`,d_=()=>`chc-tc-skeleton-block`;function f_(e,t,n){let r=Vg(t),i=document.createElement(`div`);return i.className=Hg(),i.dataset.tournamentId=e.tournamentId,e.offline&&i.classList.add(Wg()),n?.onClick&&(i.classList.add(Ug()),i.tabIndex=0,i.addEventListener(`click`,t=>{t.stopPropagation(),n.onClick(e)}),i.addEventListener(`keydown`,t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),n.onClick(e))})),r.showImage!==!1&&i.appendChild(p_(e,r)),r.body.length&&i.appendChild(v_(e,r)),r.footer.length&&i.appendChild(E_(e,r)),i}function p_(e,t){let n=document.createElement(`div`);if(n.className=Gg(),e.tournamentImageURL){let t=document.createElement(`img`);t.className=Kg(),t.src=e.tournamentImageURL,t.alt=e.tournamentName||``,t.loading=`lazy`,t.addEventListener(`error`,()=>h_(n,e)),n.appendChild(t)}else m_(n,e);if(t.cornerBadges.length){let r=g_(e,t.cornerBadges);r&&n.appendChild(r)}return n}function m_(e,t){let n=bg(t.courtSvgSport,qg());if(n){e.appendChild(n);return}let r=document.createElement(`div`);r.className=Jg(),e.appendChild(r)}function h_(e,t){e.querySelector(`.${Kg()}`)?.remove(),m_(e,t)}function g_(e,t){let n=[];for(let r of t){let t=__(r,e);t&&n.push(t)}if(!n.length)return null;let r=document.createElement(`div`);r.className=Yg();for(let e of n)r.appendChild(e);return r}function __(e,t){if(e===`status`){if(!t.status)return null;let e=document.createElement(`div`);return e.className=Xg(),e.dataset.kind=t.status.kind,e.textContent=t.status.label,e}if(e===`offline`){if(!t.offline)return null;let e=document.createElement(`div`);return e.className=Zg(),e.textContent=`Offline`,e}return null}function v_(e,t){let n=document.createElement(`div`);n.className=Qg();for(let r of t.body){let t=y_(r,e);t&&n.appendChild(t)}return n}function y_(e,t){switch(e){case`title`:return b_(t);case`tier`:return x_(t);case`location`:return S_(t);case`dateRange`:return C_(t);case`organizerName`:return w_(t);case`updatedAt`:return T_(t);default:return null}}function b_(e){if(!e.tournamentName)return null;let t=document.createElement(`div`);return t.className=$g(),t.textContent=e.tournamentName,t.title=e.tournamentName,t}function x_(e){let t=e.tournamentTier?.value;if(!t)return null;let n=document.createElement(`div`);return n.className=c_(),n.textContent=t,n.title=e.tournamentTier?.system?`${e.tournamentTier.system}: ${t}`:t,n}function S_(e){if(!e.location)return null;let t=document.createElement(`div`);return t.className=e_(),t.textContent=e.location,t.title=e.location,t}function C_(e){if(!e.dateRangeFormatted)return null;let t=document.createElement(`div`);return t.className=t_(),t.textContent=e.dateRangeFormatted,t}function w_(e){if(!e.organizerName)return null;let t=document.createElement(`div`);return t.className=n_(),t.textContent=e.organizerName,t}function T_(e){if(!e.updatedAt)return null;let t=document.createElement(`div`);t.className=r_();let n=new Date(e.updatedAt);return t.textContent=Number.isNaN(n.getTime())?e.updatedAt:n.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),t}function E_(e,t){let n=document.createElement(`div`);n.className=i_();for(let r of t.footer){let t=D_(r,e);t&&n.appendChild(t)}return n}function D_(e,t){switch(e){case`feeBadge`:return O_(t);case`playerCount`:return k_(t);case`eventCount`:return A_(t);default:return null}}function O_(e){if(!e.feeFormatted)return null;let t=document.createElement(`div`);return t.className=a_(),t.textContent=e.feeFormatted,t}function k_(e){if(typeof e.participantCount!=`number`)return null;let t=document.createElement(`div`);return t.className=o_(),t.textContent=`${e.participantCount} ${e.participantCount===1?`player`:`players`}`,t}function A_(e){if(typeof e.eventCount!=`number`)return null;let t=document.createElement(`div`);return t.className=s_(),t.textContent=`${e.eventCount} ${e.eventCount===1?`event`:`events`}`,t}function j_(e){let t=Vg(e);return zg({showImage:t.showImage!==!1,bodyLines:t.body.length,showFooter:t.footer.length>0,cardClass:l_(),imageClass:Gg(),bodyClass:Qg(),footerClass:i_(),blockClass:d_(),lineClass:u_()})}var M_=6048e5;function N_(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function P_(e,t,n){return!t||!n?!1:t.getTime()<=e.getTime()&&e.getTime()<n.getTime()}function F_(e){return`Opens ${e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}`}function I_(e,t=new Date){let n=e.tournamentStatus?.toUpperCase();if(n===`CANCELLED`||n===`ABANDONDED`||n===`ABANDONED`)return{kind:`cancelled`,label:`Cancelled`};let r=e.timeZone,i=Eg(e.endDate),a=i?Og(i,r):null;if(n===`COMPLETED`||a&&t.getTime()>=a.getTime())return{kind:`completed`,label:`Completed`};let o=Eg(e.startDate);if(P_(t,o?Dg(o,r):null,a))return{kind:`live`,label:`Live`};let s=N_(e.entriesClose);if(s){let e=s.getTime()-t.getTime();if(e>0&&e<=M_)return{kind:`closing-soon`,label:`Closing Soon`}}let c=N_(e.entriesOpen);return c&&c.getTime()>t.getTime()?{kind:`registration-opens`,label:F_(c)}:null}var L_=`–`,R_={JPY:0,KRW:0,VND:0,CLP:0,ISK:0,KWD:3,BHD:3,OMR:3,JOD:3,TND:3};function z_({amount:e,currencyCode:t,unit:n}){return n===`MAJOR`?e:e/10**(R_[t]??2)}function B_(e,t){try{return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t}).format(e)}catch{return`${e.toFixed(2)} ${t}`}}function V_(e){let t=[];for(let n of e)typeof n?.amount!=`number`||Number.isNaN(n.amount)||n.currencyCode&&n.unit&&t.push({amount:n.amount,currencyCode:n.currencyCode,unit:n.unit});return t}function H_(e){if(!e?.length)return null;let t=V_(e);if(!t.length)return null;let n=new Map;for(let e of t){let t=`${e.currencyCode}/${e.unit}`,r=n.get(t);r?r.push(e):n.set(t,[e])}let r=[...n.values()].sort((e,t)=>t.length-e.length),i=r[0],a=i[0].currencyCode,o=i.map(z_).sort((e,t)=>e-t),s=o[0],c=o.at(-1)??s;return r.length>1?`From ${a} ${B_(s,a)}`:s===c?`${a} ${B_(s,a)}`:`${a} ${B_(s,a)} ${L_} ${B_(c,a)}`}var U_=`tournamentImage`;function W_(e){let t=e?.registrationProfile?.entryFees;return Array.isArray(t)?t.filter(e=>e&&typeof e.amount==`number`):[]}function G_(e,t){let n=e?.individualParticipantCount;return typeof n==`number`?n||void 0:t.filter(e=>(!e?.participantType||e.participantType===`INDIVIDUAL`)&&(!e?.participantRole||e.participantRole===`COMPETITOR`)).length||void 0}function K_(e){let t=e?.timeItems;if(Array.isArray(t))return t.find(e=>e?.itemType===`TMX`)?.itemValue?.offline}function q_(e,t){let n=Array.isArray(e?.onlineResources)?e.onlineResources:void 0,r=Array.isArray(e?.venues)?e.venues:[],i=Array.isArray(e?.participants)?e.participants:[],a=Array.isArray(e?.events)?e.events:[],o=t?.statusOverride===void 0?I_({tournamentStatus:e?.tournamentStatus,startDate:e?.startDate,endDate:e?.endDate,entriesOpen:e?.registrationProfile?.entriesOpen,entriesClose:e?.registrationProfile?.entriesClose,timeZone:e?.localTimeZone||e?.timeZone},t?.now):t.statusOverride,s=e?.tournamentImageURL??Fg(n,U_),c=e?.courtSvgSport??Ig(n);return{tournamentId:e?.tournamentId??``,tournamentName:e?.tournamentName??``,startDate:e?.startDate,endDate:e?.endDate,dateRangeFormatted:Mg(e?.startDate,e?.endDate),location:Cg(r),tournamentImageURL:s,courtSvgSport:c,participantCount:G_(e,i),eventCount:a.length||void 0,organizerName:e?.tournamentOrganizers?.find?.(Boolean)?.organizerName,status:o,feeFormatted:H_(W_(e)),updatedAt:e?.updatedAt,offline:K_(e),tournamentTier:J_(e)}}function J_(e){let t=e?.tournamentTier;if(!t||typeof t!=`object`||typeof t.system!=`string`||typeof t.value!=`string`)return;let n={system:t.system,value:t.value};return typeof t.numericRank==`number`&&Number.isFinite(t.numericRank)&&(n.numericRank=t.numericRank),n}var Y_={showImage:!0,showMap:!0,cornerBadges:[`primaryBadge`],body:[`title`,`address`,`courtBreakdown`],footer:[`amenityRow`]};function X_(e){return e?{showImage:e.showImage??Y_.showImage,showMap:e.showMap??Y_.showMap,cornerBadges:e.cornerBadges??Y_.cornerBadges,body:e.body??Y_.body,footer:e.footer??Y_.footer}:Y_}var Z_=()=>`chc-vc-card`,Q_=()=>`chc-vc-card--clickable`,$_=()=>`chc-vc-image`,ev=()=>`chc-vc-image-img`,tv=()=>`chc-vc-image-svg`,nv=()=>`chc-vc-image-map`,rv=()=>`chc-vc-image-placeholder`,iv=()=>`chc-vc-corner-badges`,av=()=>`chc-vc-primary-badge`,ov=()=>`chc-vc-body`,sv=()=>`chc-vc-title`,cv=()=>`chc-vc-address`,lv=()=>`chc-vc-court-breakdown`,uv=()=>`chc-vc-footer`,dv=()=>`chc-vc-amenity-row`,fv=()=>`chc-vc-amenity`,pv=()=>`chc-vc-card chc-vc-skeleton`,mv=()=>`chc-vc-skeleton-line`,hv=()=>`chc-vc-skeleton-block`;function gv(e,t,n){let r=X_(t),i=document.createElement(`div`);i.className=Z_(),i.dataset.venueId=e.venueId;let a=null;r.showImage!==!1&&(a=bv(e,r,()=>f()),i.appendChild(a));let o=r.body.length?Ov(e,r):null;o&&i.appendChild(o);let s=r.footer.length?Mv(e,r):null;s&&i.appendChild(s);function c(){return!!a?.querySelector(`iframe`)}let l=new Map;function u(e,t){if(l.has(e))return;let n=e=>{e.stopPropagation(),t()},r=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),t())};e.classList.add(Q_()),e.tabIndex=0,e.addEventListener(`click`,n),e.addEventListener(`keydown`,r),l.set(e,{click:n,keydown:r})}function d(e){let t=l.get(e);t&&(e.removeEventListener(`click`,t.click),e.removeEventListener(`keydown`,t.keydown),e.classList.remove(Q_()),e.removeAttribute(`tabindex`),l.delete(e))}function f(){if(!n?.onClick)return;let t=()=>n.onClick(e);c()?(d(i),o&&u(o,t),s&&u(s,t)):(o&&d(o),s&&d(s),u(i,t))}return f(),i}function _v(e){return typeof e.latitude==`number`&&typeof e.longitude==`number`}function vv(e){let t=e.latitude,n=e.longitude,r=.01,i=`https://www.openstreetmap.org/export/embed.html?bbox=${`${n-r},${t-r},${n+r},${t+r}`}&marker=${t},${n}&layer=mapnik`,a=document.createElement(`iframe`);return a.className=nv(),a.src=i,a.loading=`lazy`,a.title=`Map of ${e.venueName}`,a}function yv(e,t){let n=bg(t.courtSvgSport,tv());if(n){e.appendChild(n);return}let r=document.createElement(`div`);r.className=rv(),e.appendChild(r)}function bv(e,t,n){let r=document.createElement(`div`);if(r.className=$_(),e.venueImageURL){let i=document.createElement(`img`);i.className=ev(),i.src=e.venueImageURL,i.alt=e.venueName||``,i.loading=`lazy`,i.addEventListener(`error`,()=>{i.remove(),t.showMap!==!1&&_v(e)?r.appendChild(vv(e)):yv(r,e),n?.()}),r.appendChild(i)}else t.showMap!==!1&&_v(e)?r.appendChild(vv(e)):yv(r,e);if(t.cornerBadges.length){let n=Sv(e,t.cornerBadges);n&&r.appendChild(n)}return r}function xv(e,t){if(e===`primaryBadge`){if(!t.isPrimary)return null;let e=document.createElement(`div`);return e.className=av(),e.textContent=`Primary`,e}return null}function Sv(e,t){let n=[];for(let r of t){let t=xv(r,e);t&&n.push(t)}if(!n.length)return null;let r=document.createElement(`div`);r.className=iv();for(let e of n)r.appendChild(e);return r}function Cv(e){if(!e.venueName)return null;let t=document.createElement(`div`);return t.className=sv(),t.textContent=e.venueName,t.title=e.notes?`${e.venueName}\n${e.notes}`:e.venueName,t}function wv(e){if(!e.addressFormatted)return null;let t=document.createElement(`div`);return t.className=cv(),t.textContent=e.addressFormatted,t.title=e.addressFormatted,t}function Tv(e){if(!e.courtBreakdown)return null;let t=document.createElement(`div`);return t.className=lv(),t.textContent=e.courtBreakdown,t}function Ev(e){if(!e.venueAbbreviation)return null;let t=document.createElement(`div`);return t.className=lv(),t.textContent=e.venueAbbreviation,t}function Dv(e,t){return e===`title`?Cv(t):e===`address`?wv(t):e===`courtBreakdown`?Tv(t):e===`venueAbbreviation`?Ev(t):null}function Ov(e,t){let n=document.createElement(`div`);n.className=ov();for(let r of t.body){let t=Dv(r,e);t&&n.appendChild(t)}return n}function kv(e){let t=document.createElement(`span`);return t.className=fv(),t.textContent=e,t}function Av(e){let t=[];if(typeof e.courtCount==`number`&&t.push(kv(`${e.courtCount} ${e.courtCount===1?`court`:`courts`}`)),e.indoorCount&&t.push(kv(`${e.indoorCount} indoor`)),e.outdoorCount&&t.push(kv(`${e.outdoorCount} outdoor`)),e.floodlitCount&&t.push(kv(`${e.floodlitCount} lit`)),!t.length)return null;let n=document.createElement(`div`);n.className=dv();for(let e of t)n.appendChild(e);return n}function jv(e,t){return e===`amenityRow`?Av(t):e===`address`?wv(t):e===`courtBreakdown`?Tv(t):null}function Mv(e,t){let n=document.createElement(`div`);n.className=uv();for(let r of t.footer){let t=jv(r,e);t&&n.appendChild(t)}return n}function Nv(e){let t=X_(e);return zg({showImage:t.showImage!==!1,bodyLines:t.body.length,showFooter:t.footer.length>0,cardClass:pv(),imageClass:$_(),bodyClass:ov(),footerClass:uv(),blockClass:hv(),lineClass:mv()})}var Pv=`venueImage`;function Fv(e){let t=[];return e.indoorOutdoor&&t.push(e.indoorOutdoor.toLowerCase()),e.surfaceCategory&&t.push(e.surfaceCategory.toLowerCase()),t.length?t.join(` `):`court`}function Iv(e){if(!e.length)return;let t=new Map;for(let n of e){let e=Fv(n);t.set(e,(t.get(e)??0)+1)}return[...t.entries()].sort((e,t)=>t[1]-e[1]).map(([e,t])=>`${t} ${e}`).join(`, `)}function Lv(e,t){let n=0;for(let r of e)t(r)&&(n+=1);return n}function Rv(e,t){let n=Array.isArray(e?.courts)?e.courts:[],r=Array.isArray(e?.onlineResources)?e.onlineResources:void 0,i=e?.addresses?.find(e=>e);return{venueId:e?.venueId??``,venueName:e?.venueName??``,venueAbbreviation:e?.venueAbbreviation,addressFormatted:Sg(i),latitude:Lg(i?.latitude),longitude:Lg(i?.longitude),courtCount:n.length||void 0,courtBreakdown:Iv(n),indoorCount:Lv(n,e=>e.indoorOutdoor===`INDOOR`)||void 0,outdoorCount:Lv(n,e=>e.indoorOutdoor===`OUTDOOR`)||void 0,floodlitCount:Lv(n,e=>!!e.floodlit)||void 0,isPrimary:!!e?.isPrimary,venueImageURL:e?.venueImageURL??Fg(r,Pv),courtSvgSport:e?.courtSvgSport??Ig(r)??t?.sport,notes:e?.notes}}var zv={showImage:!0,cornerBadges:[`indoorOutdoor`,`floodlit`],body:[`title`,`surface`],footer:[`amenityRow`]};function Bv(e){return e?{showImage:e.showImage??zv.showImage,cornerBadges:e.cornerBadges??zv.cornerBadges,body:e.body??zv.body,footer:e.footer??zv.footer}:zv}var Vv=()=>`chc-cc-card`,Hv=()=>`chc-cc-card--clickable`,Uv=()=>`chc-cc-image`,Wv=()=>`chc-cc-image-svg`,Gv=()=>`chc-cc-image-placeholder`,Kv=()=>`chc-cc-corner-badges`,qv=()=>`chc-cc-indoor-badge`,Jv=()=>`chc-cc-floodlit-badge`,Yv=()=>`chc-cc-body`,Xv=()=>`chc-cc-title`,Zv=()=>`chc-cc-surface`,Qv=()=>`chc-cc-availability`,$v=()=>`chc-cc-abbr`,ey=()=>`chc-cc-footer`,ty=()=>`chc-cc-amenity-row`,ny=()=>`chc-cc-card chc-cc-skeleton`,ry=()=>`chc-cc-skeleton-line`,iy=()=>`chc-cc-skeleton-block`;function ay(e,t,n){let r=Bv(t),i=document.createElement(`div`);return i.className=Vv(),i.dataset.courtId=e.courtId,n?.onClick&&(i.classList.add(Hv()),i.tabIndex=0,i.addEventListener(`click`,t=>{t.stopPropagation(),n.onClick(e)}),i.addEventListener(`keydown`,t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),n.onClick(e))})),r.showImage!==!1&&i.appendChild(sy(e,r)),r.body.length&&i.appendChild(_y(e,r)),r.footer.length&&i.appendChild(by(e,r)),i}function oy(e,t){let n=bg(t.courtSvgSport,Wv());if(n){e.appendChild(n);return}let r=document.createElement(`div`);r.className=Gv(),e.appendChild(r)}function sy(e,t){let n=document.createElement(`div`);if(n.className=Uv(),e.surfaceCategory&&(n.dataset.surface=e.surfaceCategory),oy(n,e),t.cornerBadges.length){let r=dy(e,t.cornerBadges);r&&n.appendChild(r)}return n}function cy(e){if(!e.indoorOutdoor)return null;let t=document.createElement(`div`);return t.className=qv(),t.dataset.kind=e.indoorOutdoor,t.textContent=e.indoorOutdoor===`INDOOR`?`Indoor`:`Outdoor`,t}function ly(e){if(!e.floodlit)return null;let t=document.createElement(`div`);return t.className=Jv(),t.textContent=`Lit`,t}function uy(e,t){return e===`indoorOutdoor`?cy(t):e===`floodlit`?ly(t):null}function dy(e,t){let n=[];for(let r of t){let t=uy(r,e);t&&n.push(t)}if(!n.length)return null;let r=document.createElement(`div`);r.className=Kv();for(let e of n)r.appendChild(e);return r}function fy(e){if(!e.courtName)return null;let t=document.createElement(`div`);return t.className=Xv(),t.textContent=e.courtName,t.title=e.notes?`${e.courtName}\n${e.notes}`:e.courtName,t}function py(e){if(!e.surfaceLabel)return null;let t=document.createElement(`div`);return t.className=Zv(),t.textContent=e.surfaceLabel,t}function my(e){if(!e.availabilitySummary)return null;let t=document.createElement(`div`);return t.className=Qv(),t.textContent=e.availabilitySummary,t}function hy(e){if(!e.courtAbbreviation)return null;let t=document.createElement(`div`);return t.className=$v(),t.textContent=e.courtAbbreviation,t}function gy(e,t){return e===`title`?fy(t):e===`surface`?py(t):e===`availability`?my(t):e===`abbreviation`?hy(t):null}function _y(e,t){let n=document.createElement(`div`);n.className=Yv();for(let r of t.body){let t=gy(r,e);t&&n.appendChild(t)}return n}function vy(e){let t=[];if(e.indoorOutdoor&&t.push(e.indoorOutdoor===`INDOOR`?`indoor`:`outdoor`),e.surfaceCategory&&t.push(e.surfaceCategory.toLowerCase()),e.floodlit&&t.push(`floodlit`),!t.length)return null;let n=document.createElement(`div`);return n.className=ty(),n.textContent=t.join(` · `),n}function yy(e,t){return e===`amenityRow`?vy(t):e===`availability`?my(t):e===`surface`?py(t):null}function by(e,t){let n=document.createElement(`div`);n.className=ey();for(let r of t.footer){let t=yy(r,e);t&&n.appendChild(t)}return n}function xy(e){let t=Bv(e);return zg({showImage:t.showImage!==!1,bodyLines:t.body.length,showFooter:t.footer.length>0,cardClass:ny(),imageClass:Uv(),bodyClass:Yv(),footerClass:ey(),blockClass:iy(),lineClass:ry()})}var Sy=`INDOOR`,Cy=`OUTDOOR`,wy=new Set([`HARD`,`CLAY`,`GRASS`,`ARTIFICIAL`,`CARPET`]);function Ty(e){if(!e)return;let t=String(e).toUpperCase();if(t===Sy)return Sy;if(t===Cy)return Cy}function Ey(e){let t=e?.surfaceCategory?String(e.surfaceCategory).toUpperCase():void 0;if(t&&wy.has(t))return t;let n=e?.surfaceType?String(e.surfaceType).toUpperCase():void 0;return n&&wy.has(n)?n:t}function Dy(e,t){let n=[];return e&&n.push(e.charAt(0)+e.slice(1).toLowerCase()),t&&n.push(t.charAt(0)+t.slice(1).toLowerCase()),n.length?n.join(` · `):void 0}function Oy(e,t){let n=Ty(e?.indoorOutdoor),r=Ey(e);return{courtId:e?.courtId??``,courtName:e?.courtName??``,courtAbbreviation:e?.courtAbbreviation,surfaceLabel:Dy(n,r),indoorOutdoor:n,surfaceCategory:r,floodlit:!!e?.floodlit,courtSvgSport:t?.sport,notes:e?.notes}}var ky={grouping:`setting`,sport:`tennis`,showGroupHeadings:!0,showSummary:!0,minCardWidth:`11rem`,emptyMessage:`No courts recorded for this venue`};function Ay(e){return e?{grouping:e.grouping??ky.grouping,sport:e.sport??ky.sport,showGroupHeadings:e.showGroupHeadings??ky.showGroupHeadings,showSummary:e.showSummary??ky.showSummary,minCardWidth:e.minCardWidth??ky.minCardWidth,emptyMessage:e.emptyMessage??ky.emptyMessage}:ky}var jy=()=>`chc-cl`,My=()=>`chc-cl-summary`,Ny=()=>`chc-cl-summary-count`,Py=()=>`chc-cl-group`,Fy=()=>`chc-cl-group-heading`,Iy=()=>`chc-cl-group-count`,Ly=()=>`chc-cl-grid`,Ry=()=>`chc-cl-empty`,zy=`Unspecified`,By=`Unspecified surface`;function Vy(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function Hy(e){let t=typeof e.indoorOutdoor==`string`?e.indoorOutdoor.trim():``;return t?Vy(t):zy}function Uy(e){let t=typeof e.surfaceCategory==`string`?e.surfaceCategory.trim():``;return t?Vy(t):By}function Wy(e,t){let n=Ng(e);if(t===`none`)return[{key:`all`,label:`All courts`,courts:n}];let r=e=>t===`setting`?Hy(e):t===`surface`?Uy(e):`${Hy(e)} · ${Uy(e)}`,i=new Map;for(let e of n){let t=r(e),n=i.get(t);n?n.courts.push(e):i.set(t,{key:t,label:t,courts:[e]})}return[...i.values()]}function Gy(e){let t=new Map;for(let n of e){let e=Hy(n),r=Uy(n),i=`${e===zy?``:e.toLowerCase()} ${r===By?``:r.toLowerCase()}`.trim()||`court`;t.set(i,(t.get(i)??0)+1)}return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).map(([e,t])=>`${t} ${e}`).join(`, `)}function Ky(e,t,n){let r=Ay(t),i=e.courts??[],a=document.createElement(`div`);if(a.className=jy(),e.venueId&&(a.dataset.venueId=e.venueId),!i.length){let e=document.createElement(`div`);return e.className=Ry(),e.textContent=r.emptyMessage,a.appendChild(e),a}r.showSummary&&a.appendChild(qy(i));for(let e of Wy(i,r.grouping))a.appendChild(Jy(e,r,n));return a}function qy(e){let t=document.createElement(`div`);t.className=My();let n=document.createElement(`span`);n.className=Ny(),n.textContent=`${e.length} ${e.length===1?`court`:`courts`}`;let r=document.createElement(`span`);return r.textContent=Gy(e),t.append(n,r),t}function Jy(e,t,n){let r=document.createElement(`div`);if(r.className=Py(),r.dataset.group=e.key,t.showGroupHeadings&&t.grouping!==`none`){let t=document.createElement(`div`);t.className=Fy();let n=document.createElement(`span`);n.textContent=e.label;let i=document.createElement(`span`);i.className=Iy(),i.textContent=String(e.courts.length),t.append(n,i),r.appendChild(t)}let i=document.createElement(`div`);i.className=Ly(),i.style.setProperty(`--chc-cl-min-card`,t.minCardWidth);for(let r of e.courts)i.appendChild(Xy(r,t,n));return r.appendChild(i),r}function Yy(e){if(e===`setting`||e===`both`)return{cornerBadges:[`floodlit`]}}function Xy(e,t,n){let r=Oy(e,{sport:t.sport}),i=n?.onCourtClick?{onClick:()=>n.onCourtClick?.(e)}:void 0;return ay(r,Yy(t.grouping),i)}var Zy={tiles:{map:{tileLayer:`https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png`,attribution:`&copy; <a href="https://openstreetmap.org">OpenStreetMap</a> Contributors`,maxZoom:18},satellite:{tileLayer:`https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}`,attribution:`Tiles &copy; Esri`}},darkTileLayer:{tileLayer:`https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png`,attribution:`&copy; <a href="https://openstreetmap.org">OpenStreetMap</a> Contributors &copy; <a href="https://carto.com/attributions">CARTO</a>`,maxZoom:20},view:`map`,showViewToggle:!0,zoom:16,height:`320px`,courtsLayout:`side`,showHeader:!0,showPopup:!0,scrollWheelZoom:!1,darkTiles:`auto`};function Qy(e){return e?{tiles:e.tiles??Zy.tiles,darkTileLayer:e.darkTileLayer===void 0?Zy.darkTileLayer:e.darkTileLayer,view:e.view??Zy.view,showViewToggle:e.showViewToggle??Zy.showViewToggle,zoom:e.zoom??Zy.zoom,height:e.height??Zy.height,courtsLayout:e.courtsLayout??Zy.courtsLayout,showHeader:e.showHeader??Zy.showHeader,showPopup:e.showPopup??Zy.showPopup,scrollWheelZoom:e.scrollWheelZoom??Zy.scrollWheelZoom,darkTiles:e.darkTiles??Zy.darkTiles}:Zy}var $y=()=>`chc-vl`,eb=()=>`chc-vl-header`,tb=()=>`chc-vl-title`,nb=()=>`chc-vl-address`,rb=()=>`chc-vl-notes`,ib=()=>`chc-vl-body`,ab=()=>`chc-vl-body--below`,ob=()=>`chc-vl-mapwrap`,sb=()=>`chc-vl-map`,cb=()=>`chc-vl-map--invertible`,lb=()=>`chc-vl-toggle`,ub=()=>`chc-vl-toggle-btn`,db=()=>`chc-vl-fallback`,fb=()=>`chc-vl-fallback-icon`,pb=()=>`chc-vl-courts`,mb=()=>`chc-vl-courts-title`,hb=()=>`chc-vl-court-list`,gb=()=>`chc-vl-court`,_b=()=>`chc-vl-court--clickable`,vb=()=>`chc-vl-court-name`,yb=()=>`chc-vl-court-meta`,bb=()=>`chc-vl-pip`,xb=()=>`chc-vl-marker`,Sb=()=>`chc-vl-popup-title`,Cb=()=>`chc-vl-popup-address`,wb=`No coordinates for this venue`,Tb=`Map unavailable`,Eb=new WeakMap;function Db(e){return Number.isFinite(e.latitude)&&Number.isFinite(e.longitude)}function Ob(e){return Ng(e)}function kb(e){let t=[];return e.indoorOutdoor&&t.push(e.indoorOutdoor.toLowerCase()),e.surfaceCategory&&t.push(e.surfaceCategory.toLowerCase()),t.join(` · `)}function Ab(e,t,n){let r=Qy(t),i=document.createElement(`div`);i.className=$y(),i.dataset.venueId=e.venueId,r.showHeader&&i.appendChild(Mb(e));let a=document.createElement(`div`);a.className=r.courtsLayout===`side`?ib():`${ib()} ${ab()}`;let{wrap:o,mapEl:s}=Pb(e,r,n);a.appendChild(o);let c=e.courts??[];return r.courtsLayout!==`none`&&c.length&&a.appendChild(Lb(c,e,n)),i.appendChild(a),s&&Db(e)&&zb({root:i,mapEl:s,data:e,cfg:r,callbacks:n}),i}function jb(e){let t=Eb.get(e);t&&(t(),Eb.delete(e))}function Mb(e){let t=document.createElement(`div`);t.className=eb();let n=document.createElement(`div`);if(n.className=tb(),n.textContent=e.venueName,t.appendChild(n),e.addressFormatted){let n=document.createElement(`div`);n.className=nb(),n.textContent=e.addressFormatted,t.appendChild(n)}if(e.notes){let n=document.createElement(`div`);n.className=rb(),n.textContent=e.notes,t.appendChild(n)}return t}function Nb(e){let t=document.createElement(`div`);t.className=db();let n=document.createElement(`div`);n.className=fb(),n.textContent=`📍`,n.setAttribute(`aria-hidden`,`true`);let r=document.createElement(`div`);return r.textContent=e,t.append(n,r),t}function Pb(e,t,n){let r=document.createElement(`div`);if(r.className=ob(),r.style.height=t.height,!Db(e))return r.appendChild(Nb(wb)),{wrap:r,mapEl:null};let i=document.createElement(`div`);i.className=sb(),i.appendChild(Nb(``)),r.appendChild(i);let a=Object.keys(t.tiles);return t.showViewToggle&&a.length>1&&r.appendChild(Fb(a,t,n)),{wrap:r,mapEl:i}}function Fb(e,t,n){let r=document.createElement(`div`);r.className=lb(),r.dataset.viewToggle=`true`;let i=[];for(let a of e){let e=document.createElement(`button`);e.type=`button`,e.className=ub(),e.dataset.view=a,e.textContent=a===`satellite`?`Satellite`:`Map`,e.setAttribute(`aria-pressed`,String(a===t.view)),e.addEventListener(`click`,()=>{for(let t of i)t.setAttribute(`aria-pressed`,String(t===e));n?.onViewChange?.(a)}),i.push(e),r.appendChild(e)}return r}function Ib(e,t,n){let r=!!n?.onCourtClick,i=document.createElement(r?`button`:`div`);i.className=r?`${gb()} ${_b()}`:gb(),i.dataset.courtId=e.courtId,r&&(i.type=`button`,i.addEventListener(`click`,()=>n?.onCourtClick?.(e,t)));let a=document.createElement(`span`);a.className=vb(),a.textContent=e.courtName;let o=document.createElement(`span`);o.className=yb();let s=kb(e);if(s&&o.append(document.createTextNode(s)),e.floodlit){let e=document.createElement(`span`);e.className=bb(),e.title=`floodlit`,o.appendChild(e)}return i.append(a,o),i}function Lb(e,t,n){let r=document.createElement(`div`);r.className=pb();let i=document.createElement(`div`);i.className=mb(),i.textContent=`Courts (${e.length})`,r.appendChild(i);let a=document.createElement(`div`);a.className=hb();for(let r of Ob(e))a.appendChild(Ib(r,t,n));return r.appendChild(a),r}function Rb(e){let t=e=>e.replace(/[&<>"]/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`})[e]),n=e.addressFormatted?`<div class="${Cb()}">${t(e.addressFormatted)}</div>`:``;return`<div class="${Sb()}">${t(e.venueName)}</div>${n}`}async function zb({root:e,mapEl:t,data:n,cfg:r,callbacks:i}){let a;try{a=await import(`leaflet`)}catch(e){t.replaceChildren(Nb(Tb)),i?.onMapUnavailable?.(Error(`leaflet is an optional peerDependency of courthive-components and is not installed`,{cause:e}));return}let o=a.default??a;try{t.replaceChildren();let a=o.map(t,{scrollWheelZoom:r.scrollWheelZoom,attributionControl:!0});a.setView([n.latitude,n.longitude],r.zoom);let s=r.view,c=Gb(o,a,r,s);Kb(t,r,s);let l=e=>{s=e,a.removeLayer(c),c=Gb(o,a,r,e),Kb(t,r,e)},u=o.divIcon({className:``,html:`<div class="${xb()}"></div>`,iconSize:[14,14]}),d=o.marker([n.latitude,n.longitude],{icon:u}).addTo(a);r.showPopup&&d.bindPopup(Rb(n)),d.on(`click`,()=>i?.onVenueClick?.(n)),e.querySelector(`[data-view-toggle]`)?.addEventListener(`click`,e=>{let t=e.target?.closest(`button[data-view]`);t&&l(t.dataset.view)}),Hb(t);let f=new ResizeObserver(()=>a.invalidateSize());f.observe(t);let p,m=globalThis.document?.documentElement;if(m&&r.darkTiles!==`never`&&r.darkTileLayer){let e=Ub();p=new MutationObserver(()=>{let t=Ub();t!==e&&(e=t,s!==`satellite`&&l(s))}),p.observe(m,{attributes:!0,attributeFilter:[`data-theme`]})}Eb.set(e,()=>{f.disconnect(),p?.disconnect(),a.remove()})}catch(e){t.replaceChildren(Nb(Tb)),i?.onMapUnavailable?.(Error(`Leaflet map failed to initialize`,{cause:e}))}}var Bb=!1;function Vb(e){return e?e!==`relative`&&e!==`absolute`:!1}function Hb(e){Bb||Vb(globalThis.getComputedStyle?.(e)?.position)&&(Bb=!0,console.warn("[courthive-components] venue-locator: leaflet's stylesheet is missing — the map will render incorrectly. Add `import 'leaflet/dist/leaflet.css';` to the host application."))}function Ub(){return globalThis.document?.documentElement?.dataset.theme===`dark`}function Wb(e,t,n){let r=e.tiles[t]??e.tiles.map;return t===`satellite`||e.darkTiles===`never`||!n?r:e.darkTileLayer??r}function Gb(e,t,n,r){let i=Wb(n,r,Ub());return e.tileLayer(i.tileLayer,{attribution:i.attribution,maxZoom:i.maxZoom??19}).addTo(t)}function Kb(e,t,n){let r=t.darkTiles===`auto`&&n!==`satellite`&&!t.darkTileLayer;e.classList.toggle(cb(),r)}function qb(...e){for(let t of e)if(typeof t==`number`&&Number.isFinite(t))return t}function Jb(e,t){let n=typeof e?.indoorOutdoor==`string`?e.indoorOutdoor.toUpperCase():void 0;return{courtId:e?.courtId??`court-${t+1}`,courtName:e?.courtName??`Court ${t+1}`,indoorOutdoor:n===`INDOOR`||n===`OUTDOOR`?n:void 0,surfaceCategory:e?.surfaceCategory,floodlit:e?.floodlit,courtOrder:qb(e?.courtOrder),latitude:Rg(e?.latitude),longitude:Rg(e?.longitude)}}function Yb(e){let t=Array.isArray(e?.courts)?e.courts:[],n=e?.addresses?.find(e=>e);return{venueId:e?.venueId??``,venueName:e?.venueName??e?.venueAbbreviation??``,venueAbbreviation:e?.venueAbbreviation,addressFormatted:Sg(n),latitude:Rg(e?.latitude,n?.latitude),longitude:Rg(e?.longitude,n?.longitude),courts:t.map(Jb),notes:e?.notes}}var Xb=()=>`chc-team-card`,Zb=()=>`chc-team-card--clickable`,Qb=()=>`chc-team-card__title-row`,$b=()=>`chc-team-card__name`,ex=()=>`chc-team-card__nickname`,tx=()=>`chc-team-card__counts`,nx=` · `;function rx(e,t){let n=document.createElement(`div`);n.className=Xb(),e.teamId&&(n.dataset.teamId=e.teamId),t?.onClick&&(n.classList.add(Zb()),n.tabIndex=0,n.setAttribute(`role`,`button`),n.addEventListener(`click`,n=>{n.stopPropagation(),t.onClick(e)}),n.addEventListener(`keydown`,n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),n.stopPropagation(),t.onClick(e))})),n.appendChild(ix(e));let r=(e.countSegments??[]).map(e=>(e??``).trim()).filter(Boolean);return r.length&&n.appendChild(ax(r)),n}function ix(e){let t=document.createElement(`div`);t.className=Qb();let n=document.createElement(`span`);if(n.className=$b(),n.textContent=e.teamName,t.appendChild(n),e.nickname){let n=document.createElement(`span`);n.className=ex(),n.textContent=`"${e.nickname}"`,t.appendChild(n)}return t}function ax(e){let t=document.createElement(`div`);return t.className=tx(),t.textContent=e.join(nx),t}var ox=[`COMPETITIVE`,`ROUTINE`,`DECISIVE`,`WALKOVER`],sx=new Set([`WALKOVER`,`DOUBLE_WALKOVER`,`DEFAULTED`,`DOUBLE_DEFAULT`]);function cx(){return{COMPETITIVE:0,ROUTINE:0,DECISIVE:0,WALKOVER:0}}function lx(e){let t=cx();if(!Array.isArray(e))return t;for(let n of e){let e=typeof n?.getData==`function`?n.getData():n;if(!e)continue;if(e.matchUpStatus&&sx.has(e.matchUpStatus)){t.WALKOVER+=1;continue}let r=e.competitiveProfile?.competitiveness;r&&r!==`WALKOVER`&&ox.includes(r)&&(t[r]+=1)}return t}function ux(e){return ox.reduce((t,n)=>t+e[n],0)}var dx={COMPETITIVE:`Competitive`,ROUTINE:`Routine`,DECISIVE:`Decisive`,WALKOVER:`Walkover / Defaulted`};function fx(e={}){let{onSegmentClick:t}=e,n=document.createElement(`div`);n.className=`chc-cb`;let r={};for(let e of ox){let i=document.createElement(`div`);i.className=`chc-cb__seg`,i.dataset.bucket=e,t&&(i.classList.add(`is-clickable`),i.setAttribute(`role`,`button`),i.addEventListener(`click`,()=>t(e))),r[e]=i,n.appendChild(i)}return{element:n,update:e=>{let t=ux(e);if(n.style.display=t>0?`flex`:`none`,t)for(let t of ox){let n=r[t],i=e[t];i===0?(n.style.flex=`0 0 0`,n.style.padding=`0`,n.textContent=``,n.removeAttribute(`title`)):(n.style.flex=`${i} 1 0`,n.style.padding=`0 4px`,n.textContent=String(i),n.title=`${dx[t]}: ${i}`)}},setActive:e=>{n.classList.toggle(`has-active`,!!e);for(let t of ox)r[t].classList.toggle(`is-active`,t===e)}}}var px={COMPETITIVE:`Competitive`,ROUTINE:`Routine`,DECISIVE:`Decisive`,WALKOVER:`Walkover / Defaulted`},mx=`http://www.w3.org/2000/svg`,hx=96,gx=hx/2,_x=47,vx=31;function yx(e,t){return{x:gx+t*Math.cos(e),y:gx+t*Math.sin(e)}}function bx(e,t){let n=yx(e,_x),r=yx(t,_x),i=yx(t,vx),a=yx(e,vx),o=+(t-e>Math.PI);return[`M ${n.x} ${n.y}`,`A ${_x} ${_x} 0 ${o} 1 ${r.x} ${r.y}`,`L ${i.x} ${i.y}`,`A ${vx} ${vx} 0 ${o} 0 ${a.x} ${a.y}`,`Z`].join(` `)}function xx(){let e=yx(-Math.PI/2,_x),t=yx(Math.PI/2,_x),n=yx(-Math.PI/2,vx),r=yx(Math.PI/2,vx);return[`M ${e.x} ${e.y}`,`A ${_x} ${_x} 0 1 1 ${t.x} ${t.y}`,`A ${_x} ${_x} 0 1 1 ${e.x} ${e.y}`,`L ${n.x} ${n.y}`,`A ${vx} ${vx} 0 1 0 ${r.x} ${r.y}`,`A ${vx} ${vx} 0 1 0 ${n.x} ${n.y}`,`Z`].join(` `)}function Sx(){let e=document.createElement(`div`);e.className=`chc-cd`;let t=document.createElementNS(mx,`svg`);t.setAttribute(`viewBox`,`0 0 ${hx} ${hx}`),t.setAttribute(`class`,`chc-cd__svg`),t.setAttribute(`role`,`img`);let n={};for(let e of ox){let r=document.createElementNS(mx,`path`);r.setAttribute(`class`,`chc-cd__arc`),r.setAttribute(`data-bucket`,e),t.appendChild(r);let i=document.createElementNS(mx,`title`);r.appendChild(i),n[e]=r}let r=document.createElement(`div`);return r.className=`chc-cd__total`,e.appendChild(t),e.appendChild(r),{element:e,update:i=>{let a=ux(i);if(e.style.display=a>0?`inline-flex`:`none`,!a)return;let o=ox.filter(e=>i[e]>0),s=-Math.PI/2;for(let e of ox){let t=i[e],r=n[e],c=r.querySelector(`title`);if(t===0){r.removeAttribute(`d`),c&&(c.textContent=``);continue}if(o.length===1)r.setAttribute(`d`,xx());else{let e=t/a,n=s+e*Math.PI*2;r.setAttribute(`d`,bx(s,n)),s=n}c&&(c.textContent=`${px[e]}: ${t}`)}r.textContent=String(a),t.setAttribute(`aria-label`,`Competitiveness across ${a} matches`)}}}function Cx(e){let{segments:t,onSegmentClick:n}=e,r=document.createElement(`div`);r.className=`chc-sb`;let i={},a={};for(let{key:e,label:o,color:s}of t){i[e]=o;let t=document.createElement(`div`);t.className=`chc-sb__seg`,t.dataset.key=e,t.style.setProperty(`--seg-bg`,s),n&&(t.classList.add(`is-clickable`),t.setAttribute(`role`,`button`),t.addEventListener(`click`,()=>n(e))),a[e]=t,r.appendChild(t)}return{element:r,update:e=>{let n=t.reduce((t,n)=>t+(e[n.key]||0),0);if(r.style.display=n>0?`flex`:`none`,n)for(let{key:n}of t){let t=a[n],r=e[n]||0;r===0?(t.style.flex=`0 0 0`,t.style.padding=`0`,t.textContent=``,t.removeAttribute(`title`)):(t.style.flex=`${r} 1 0`,t.style.padding=`0 4px`,t.textContent=String(r),t.title=`${i[n]}: ${r}`)}},setActive:e=>{r.classList.toggle(`has-active`,!!e);for(let{key:n}of t)a[n].classList.toggle(`is-active`,n===e)}}}var wx={cornerBadges:[`status`,`publishedBadge`,`embargoBadge`],body:[`title`,`drawTypeLabel`,`matchUpProgress`],footer:[`drawSize`,`entries`,`matchUpFormat`,`flightNumber`,`ratings`],showVisualization:!1};function Tx(e){return e?{cornerBadges:e.cornerBadges??wx.cornerBadges,body:e.body??wx.body,footer:e.footer??wx.footer,showVisualization:e.showVisualization??wx.showVisualization}:wx}var Ex=()=>`chc-dc-card`,Dx=()=>`chc-dc-card--clickable`,Ox=()=>`chc-dc-corner-badges`,kx=()=>`chc-dc-status-pill`,Ax=()=>`chc-dc-secondary-badge`,jx=()=>`chc-dc-body`,Mx=()=>`chc-dc-viz`,Nx=()=>`chc-dc-title-row`,Px=()=>`chc-dc-title`,Fx=()=>`chc-dc-draw-type`,Ix=()=>`chc-dc-meta`,Lx=()=>`chc-dc-footer`,Rx=()=>`chc-dc-chip`,zx=()=>`chc-dc-progress`,Bx=()=>`chc-dc-progress-bar`,Vx=()=>`chc-dc-progress-fill`,Hx=()=>`chc-dc-card chc-dc-skeleton`,Ux=()=>`chc-dc-skeleton-line`;function Wx(e,t,n){let r=Tx(t),i=document.createElement(`div`);if(i.className=Ex(),i.dataset.drawId=e.drawId,e.eventId&&(i.dataset.eventId=e.eventId),n?.onClick&&(i.classList.add(Dx()),i.tabIndex=0,i.addEventListener(`click`,t=>{t.stopPropagation(),n.onClick(e)}),i.addEventListener(`keydown`,t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),n.onClick(e))})),r.showVisualization&&e.visualization){let t=document.createElement(`div`);t.className=Mx(),t.appendChild(e.visualization),i.appendChild(t)}return(r.body.length||r.cornerBadges.length)&&i.appendChild(sS(e,r)),r.footer.length&&i.appendChild(cS(e,r)),i}function Gx(e){if(!e.status)return null;let t=document.createElement(`div`);return t.className=kx(),t.dataset.kind=e.status.kind,t.textContent=e.status.label,t}function Kx(e){if(!e.published)return null;let t=document.createElement(`div`);return t.className=Ax(),t.dataset.kind=`published`,t.textContent=`Published`,t}function qx(e){if(!e.embargoActive)return null;let t=document.createElement(`div`);return t.className=Ax(),t.dataset.kind=`embargo`,t.textContent=`Embargo`,t}function Jx(e,t){return e===`status`?Gx(t):e===`publishedBadge`?Kx(t):e===`embargoBadge`?qx(t):null}function Yx(e,t){let n=[];for(let r of t){let t=Jx(r,e);t&&n.push(t)}if(!n.length)return null;let r=document.createElement(`div`);r.className=Ox();for(let e of n)r.appendChild(e);return r}function Xx(e){if(!e.drawName)return null;let t=document.createElement(`div`);return t.className=Px(),t.textContent=e.drawName,t.title=e.drawName,t}function Zx(e){if(!e.drawTypeLabel)return null;let t=document.createElement(`div`);return t.className=Fx(),t.textContent=e.drawTypeLabel,t}function Qx(e){let t=document.createElement(`span`);return t.className=Rx(),t.textContent=e,t}function $x(e){return typeof e.drawSize==`number`?Qx(`Size ${e.drawSize}`):null}function eS(e){return typeof e.entryCount==`number`?Qx(`${e.entryCount} ${e.entryCount===1?`entry`:`entries`}`):null}function tS(e){return e.matchUpFormat?Qx(e.matchUpFormat):null}function nS(e){return typeof e.flightNumber==`number`?Qx(`Flight ${e.flightNumber}`):null}function rS(e){let t=[];if(typeof e.utrAvg==`number`&&t.push(`UTR ${e.utrAvg.toFixed(2)}`),typeof e.wtnAvg==`number`&&t.push(`WTN ${e.wtnAvg.toFixed(2)}`),!t.length)return null;let n=document.createElement(`div`);return n.className=Ix(),n.textContent=t.join(` · `),n}function iS(e){if(!e.matchUpCounts||e.matchUpCounts.total===0)return null;let{total:t,completed:n}=e.matchUpCounts,r=Math.round(n/t*100),i=document.createElement(`div`);i.className=zx();let a=document.createElement(`div`);a.className=Ix(),a.textContent=`${n}/${t} matches · ${r}%`,i.appendChild(a);let o=document.createElement(`div`);o.className=Bx();let s=document.createElement(`div`);return s.className=Vx(),s.style.right=`${100-r}%`,o.appendChild(s),i.appendChild(o),i}function aS(e,t){return e===`title`?Xx(t):e===`drawTypeLabel`?Zx(t):e===`drawSize`?$x(t):e===`entries`?eS(t):e===`matchUpFormat`?tS(t):e===`flightNumber`?nS(t):e===`ratings`?rS(t):e===`matchUpProgress`?iS(t):null}function oS(e,t){let n=document.createElement(`div`);n.className=Nx();let r=Xx(e);r&&n.appendChild(r);let i=Yx(e,t);return i&&n.appendChild(i),n}function sS(e,t){let n=document.createElement(`div`);n.className=jx();let r=t.body.includes(`title`),i=t.cornerBadges.length>0;if(i&&!r){let r=Yx(e,t.cornerBadges);r&&n.appendChild(r)}for(let r of t.body){if(r===`title`&&i){n.appendChild(oS(e,t.cornerBadges));continue}let a=aS(r,e);a&&n.appendChild(a)}return n}function cS(e,t){let n=document.createElement(`div`);n.className=Lx();for(let r of t.footer){let t=aS(r,e);t&&n.appendChild(t)}return n}function lS(){let e=document.createElement(`div`);e.className=Hx();let t=document.createElement(`div`);t.className=jx();for(let e of[`70%`,`40%`,`85%`]){let n=document.createElement(`div`);n.className=Ux(),n.style.width=e,t.appendChild(n)}return e.appendChild(t),e}var uS={SINGLE_ELIMINATION:`Single Elimination`,DOUBLE_ELIMINATION:`Double Elimination`,ELIMINATION:`Elimination`,ROUND_ROBIN:`Round Robin`,ROUND_ROBIN_WITH_PLAYOFF:`Round Robin + Playoff`,COMPASS:`Compass`,FEED_IN_CHAMPIONSHIP:`Feed-In Championship`,FIRST_MATCH_LOSER_CONSOLATION:`First Match Loser Consolation`,FIRST_ROUND_LOSER_CONSOLATION:`First Round Loser Consolation`,PLAY_OFF:`Play-Off`,CURTIS_CONSOLATION:`Curtis Consolation`,AD_HOC:`Ad-Hoc`,OLYMPIC:`Olympic`,LUCKY_DRAW:`Lucky Draw`,STAGGERED_ENTRY:`Staggered Entry`};function dS(e){if(e)return uS[e]?uS[e]:e.toLowerCase().split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function fS(e){let{matchUps:n=[]}=t.tournamentEngine.getAllDrawMatchUps({drawDefinition:e}),r=0,i=0,a=0,o=0;for(let e of n)e?.matchUpStatus!==`BYE`&&e?.matchUpStatus!==`DOUBLE_BYE`&&(r+=1,e?.winningSide?i+=1:e?.schedule?.scheduledTime&&(a+=1),e?.matchUpStatus===`IN_PROGRESS`&&(o+=1));return{total:r,completed:i,scheduled:a,inProgress:o}}function pS(e){let t=e?.drawSize;if(typeof t==`number`)return t;let n=(e?.structures?.find(e=>e?.stage===`MAIN`))?.positionAssignments?.length;return typeof n==`number`?n:void 0}function mS(e){if(e.cancelled)return{kind:`cancelled`,label:`Cancelled`};if(!e.generated)return{kind:`ungenerated`,label:`Not generated`};let t=e.matchUpCounts;return!t||t.total===0?{kind:`ready`,label:`Ready`}:t.completed===t.total?{kind:`completed`,label:`Completed`}:t.inProgress>0||t.completed>0?{kind:`in-progress`,label:`In progress`}:{kind:`ready`,label:`Ready`}}function hS(e,t){let n=Array.isArray(e?.structures)&&e.structures.length>0,r=t?.matchUpStats??(t?.lightMode||!n?void 0:fS(e)),i=e?.drawStatus===`CANCELLED`,a=t?.statusOverride===void 0?mS({generated:n,cancelled:i,matchUpCounts:r}):t.statusOverride;return{drawId:e?.drawId??``,drawName:e?.drawName??``,drawType:e?.drawType,drawTypeLabel:dS(e?.drawType),drawSize:pS(e),entryCount:t?.entryCount,matchUpFormat:e?.matchUpFormat,flightNumber:e?.flightNumber,matchUpCounts:r,generated:n,published:t?.published,embargoActive:t?.embargoActive,utrAvg:t?.utrAvg,wtnAvg:t?.wtnAvg,status:a,eventId:t?.eventId}}var gS={showImage:!0,cornerBadges:[`status`,`eventTypeBadge`,`genderBadge`],body:[`title`,`categoryLabel`,`drawSummary`],footer:[`playerCount`,`matchUpProgress`]},_S=15;function vS(e){return e?{showImage:e.showImage??gS.showImage,cornerBadges:e.cornerBadges??gS.cornerBadges,body:e.body??gS.body,footer:e.footer??gS.footer}:gS}var yS=()=>`chc-ec-card`,bS=()=>`chc-ec-card--clickable`,xS=()=>`chc-ec-image`,SS=()=>`chc-ec-image-img`,CS=()=>`chc-ec-image-svg`,wS=()=>`chc-ec-image-placeholder`,TS=()=>`chc-ec-corner-badges`,ES=()=>`chc-ec-status-pill`,DS=()=>`chc-ec-eventtype-badge`,OS=()=>`chc-ec-gender-badge`,kS=()=>`chc-ec-body`,AS=()=>`chc-ec-title`,jS=()=>`chc-ec-category`,MS=()=>`chc-ec-draw-summary`,NS=()=>`chc-ec-date-range`,PS=()=>`chc-ec-footer`,FS=()=>`chc-ec-player-count`,IS=()=>`chc-ec-progress`,LS=()=>`chc-ec-progress-meta`,RS=()=>`chc-ec-progress-bar`,zS=()=>`chc-ec-progress-fill`,BS=()=>`chc-ec-updated-at`,VS=()=>`chc-ec-card chc-ec-skeleton`,HS=()=>`chc-ec-skeleton-line`,US=()=>`chc-ec-skeleton-block`;function WS(e,t,n){let r=vS(t),i=document.createElement(`div`);return i.className=yS(),i.dataset.eventId=e.eventId,n?.onClick&&(i.classList.add(bS()),i.tabIndex=0,i.addEventListener(`click`,t=>{t.stopPropagation(),n.onClick(e)}),i.addEventListener(`keydown`,t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),n.onClick(e))})),r.showImage!==!1&&i.appendChild(KS(e,r)),r.body.length&&i.appendChild(oC(e,r)),r.footer.length&&i.appendChild(sC(e,r)),i}function GS(e,t){let n=bg(t.courtSvgSport,CS());if(n){e.appendChild(n);return}let r=document.createElement(`div`);r.className=wS(),e.appendChild(r)}function KS(e,t){let n=document.createElement(`div`);if(n.className=xS(),e.eventImageURL){let t=document.createElement(`img`);t.className=SS(),t.src=e.eventImageURL,t.alt=e.eventName||``,t.loading=`lazy`,t.addEventListener(`error`,()=>{t.remove(),GS(n,e)}),n.appendChild(t)}else GS(n,e);if(t.cornerBadges.length){let r=ZS(e,t.cornerBadges);r&&n.appendChild(r)}return n}function qS(e){if(!e.status)return null;let t=document.createElement(`div`);return t.className=ES(),t.dataset.kind=e.status.kind,t.textContent=e.status.label,t}function JS(e){if(!e.eventType)return null;let t=document.createElement(`div`);return t.className=DS(),t.dataset.kind=e.eventType,t.textContent=e.eventType,t}function YS(e){if(!e.gender)return null;let t=document.createElement(`div`);return t.className=OS(),t.dataset.kind=e.gender,t.textContent=e.gender===`MALE`?`M`:e.gender===`FEMALE`?`W`:`X`,t}function XS(e,t){return e===`status`?qS(t):e===`eventTypeBadge`?JS(t):e===`genderBadge`?YS(t):null}function ZS(e,t){let n=[];for(let r of t){let t=XS(r,e);t&&n.push(t)}if(!n.length)return null;let r=document.createElement(`div`);r.className=TS();for(let e of n)r.appendChild(e);return r}function QS(e){if(!e.eventName)return null;let t=document.createElement(`div`);return t.className=AS(),t.textContent=e.eventName,t.title=e.eventName,t}function $S(e){if(!e.categoryLabel)return null;let t=document.createElement(`div`);return t.className=jS(),t.textContent=e.categoryLabel,t}function eC(e){if(!e.drawSummary)return null;let t=document.createElement(`div`);return t.className=MS(),t.textContent=e.drawSummary,t}function tC(e){if(!e.dateRangeFormatted)return null;let t=document.createElement(`div`);return t.className=NS(),t.textContent=e.dateRangeFormatted,t}function nC(e){if(!e.updatedAt)return null;let t=document.createElement(`div`);t.className=BS();let n=new Date(e.updatedAt);return t.textContent=Number.isNaN(n.getTime())?e.updatedAt:n.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),t}function rC(e){if(typeof e.entryCount!=`number`)return null;let t=document.createElement(`div`);return t.className=FS(),t.textContent=`${e.entryCount} ${e.entryCount===1?`player`:`players`}`,t}function iC(e){if(!e.matchUpCounts||e.matchUpCounts.total===0)return null;let{total:t,completed:n}=e.matchUpCounts,r=Math.round(n/t*100),i=document.createElement(`div`);i.className=IS();let a=document.createElement(`div`);a.className=LS(),a.textContent=`${n}/${t} matches · ${r}%`,i.appendChild(a);let o=document.createElement(`div`);o.className=RS();let s=document.createElement(`div`);return s.className=zS(),s.style.right=`${100-r}%`,o.appendChild(s),i.appendChild(o),i}function aC(e,t){return e===`title`?QS(t):e===`categoryLabel`?$S(t):e===`drawSummary`?eC(t):e===`dateRange`?tC(t):e===`updatedAt`?nC(t):e===`playerCount`?rC(t):e===`matchUpProgress`?iC(t):null}function oC(e,t){let n=document.createElement(`div`);n.className=kS();for(let r of t.body){let t=aC(r,e);t&&n.appendChild(t)}return n}function sC(e,t){let n=document.createElement(`div`);n.className=PS();for(let r of t.footer){let t=aC(r,e);t&&n.appendChild(t)}return n}function cC(e){let t=vS(e);return zg({showImage:t.showImage!==!1,bodyLines:t.body.length,showFooter:t.footer.length>0,cardClass:VS(),imageClass:xS(),bodyClass:kS(),footerClass:PS(),blockClass:US(),lineClass:HS()})}function lC(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function uC(e,t,n){return!t||!n?!1:t.getTime()<=e.getTime()&&e.getTime()<=n.getTime()}function dC(e,t=new Date){if(e.allDrawsCancelled)return{kind:`cancelled`,label:`Cancelled`};let n=e.matchUpCounts;if(n&&n.total>0&&n.completed===n.total)return{kind:`completed`,label:`Completed`};let r=lC(e.startDate),i=lC(e.endDate);if(n&&(n.inProgress>0||uC(t,r,i)&&n.total>0))return{kind:`live`,label:`Live`};let a=e.drawCount??0;return a>0&&(e.hasDraftState||e.hasSeedsOnlyDraw)?{kind:`drawing`,label:`Drawing`}:a===0&&(e.entryCount??0)>0?{kind:`entries-open`,label:`Entries Open`}:r&&t.getTime()<r.getTime()?{kind:`upcoming`,label:`Upcoming`}:null}var fC=`eventImage`,pC=`DRAFT_STATE`;function mC(e){if(!e)return;let t=String(e).toUpperCase();if(t===`SINGLES`||t===`DOUBLES`||t===`TEAM`||t===`HYBRID`)return t}function hC(e){if(!e)return;let t=String(e).toUpperCase();if(t===`M`||t===`MALE`)return`MALE`;if(t===`F`||t===`FEMALE`)return`FEMALE`;if(t===`MIXED`||t===`X`)return`MIXED`}function gC(e){if(!e)return;let t=_C(e.categoryName);if(t)return t;if(typeof e.ageMin==`number`&&typeof e.ageMax==`number`)return e.ageMin===e.ageMax?`Age ${e.ageMin}`:`Age ${e.ageMin}–${e.ageMax}`;let n=_C(e.ageCategoryCode);if(n)return n;if(e.ratingMin&&e.ratingMax)return`Rating ${e.ratingMin}–${e.ratingMax}`}function _C(e){if(typeof e!=`string`)return;let t=e.trim();if(t&&!/^[-—–_]+$/.test(t))return t}function vC(e){if(!e.length)return;let t=e.find(Boolean);if(!t)return;let n=[];return typeof t.drawSize==`number`&&n.push(String(t.drawSize)),t.drawType&&n.push(String(t.drawType)),e.length>1&&n.push(`+${e.length-1}`),n.length?n.join(` `):void 0}function yC(e){let{matchUps:n=[]}=t.tournamentEngine.allEventMatchUps({event:e,inContext:!1})??{},r=0,i=0,a=0,o=0;for(let e of n)e?.matchUpStatus!==`BYE`&&e?.matchUpStatus!==`DOUBLE_BYE`&&(r+=1,e?.winningSide?i+=1:e?.schedule?.scheduledTime&&(a+=1),e?.matchUpStatus===`IN_PROGRESS`&&(o+=1));return{total:r,completed:i,scheduled:a,inProgress:o}}function bC(e){if(e?.draftState!=null)return!0;let t=e?.extensions;return Array.isArray(t)?t.some(e=>e?.name===pC):!1}function xC(e){return e.some(e=>e?.automated?.seedsOnly===!0||bC(e))}function SC(e){return e.length!==0&&e.every(e=>e?.drawStatus===`CANCELLED`)}var CC=new Set([`DIRECT_ACCEPTANCE`,`DA`,`DIRECT_CONFIRMED`,`DC`,`ACCEPTED`,`A`,`ENTERED`,`PE`,`QUALIFIER`,`Q`,`WILDCARD`,`WC`]);function wC(e){if(!e.length)return 0;let t=0;for(let n of e)CC.has(String(n?.entryStatus))&&(t+=1);return t}function TC(e,t){let n=Array.isArray(e?.drawDefinitions)?e.drawDefinitions:[],r=Array.isArray(e?.entries)?e.entries:[],i=Array.isArray(e?.onlineResources)?e.onlineResources:void 0,a=t?.matchUpStats??(t?.lightMode?void 0:yC(e)),o=t?.statusOverride===void 0?dC({allDrawsCancelled:SC(n),drawCount:n.length,entryCount:wC(r),startDate:e?.startDate,endDate:e?.endDate,matchUpCounts:a,hasDraftState:n.some(bC),hasSeedsOnlyDraw:xC(n)},t?.now):t.statusOverride;return{eventId:e?.eventId??``,eventName:e?.eventName??``,eventAbbreviation:e?.eventAbbreviation,categoryLabel:gC(e?.category),eventType:mC(e?.eventType),gender:hC(e?.gender),drawCount:n.length||void 0,drawSummary:vC(n),entryCount:wC(r)||void 0,matchUpCounts:a,startDate:e?.startDate,endDate:e?.endDate,dateRangeFormatted:Mg(e?.startDate,e?.endDate),status:o,eventImageURL:e?.eventImageURL??Fg(i,fC),courtSvgSport:e?.courtSvgSport??Ig(i)??t?.sport,updatedAt:e?.updatedAt}}var EC=()=>`chc-hil-container`,DC=()=>`chc-hil-form`,OC=()=>`chc-hil-header`,kC=()=>`chc-hil-title`,AC=()=>`chc-hil-tabs`,jC=()=>`chc-hil-tab`,MC=()=>`chc-hil-tab--active`,NC=()=>`chc-hil-field`,PC=()=>`chc-hil-label`,FC=()=>`chc-hil-input`,IC=()=>`chc-hil-row`,LC=()=>`chc-hil-submit`,RC=()=>`chc-hil-message`,zC=()=>`chc-hil-message--error`,BC=()=>`chc-hil-message--success`,VC=()=>`chc-hil-switch-mode`;function HC(e){return e.replace(/\/+$/,``)}async function UC(e,t,n,r=fetch){let i=HC(e)+t,a;try{a=await r(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})}catch(e){throw{kind:`network`,cause:e}}let o=null;try{o=await a.json()}catch(e){if(a.ok)throw{kind:`parse`,cause:e}}if(!a.ok)throw{kind:`http`,status:a.status,body:o};return o}function WC(e,t,n){return UC(e,`/auth/hiveid/signup`,t,n)}function GC(e,t,n){return UC(e,`/auth/hiveid/verify-existing`,t,n)}function KC(e,t,n){return UC(e,`/auth/hiveid/magic-link`,t,n)}function qC(e,t,n){return UC(e,`/auth/hiveid/magic-link/consume`,t,n)}function JC(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.kind!==`http`||t.status!==409?!1:t.body?.code===`EXISTING_USER`}var YC=[{value:`M`,label:`Male`},{value:`F`,label:`Female`}],XC=`signup`,ZC=`login`,QC=`magic-link`,$C=[XC,ZC,QC],ew=`hiveid:authenticated`,tw={[XC]:`Sign up`,[ZC]:`Log in`,[QC]:`Email link`},nw={[XC]:`Create your CourtHive identity`,[ZC]:`Log in to CourtHive`,[QC]:`Email me a sign-in link`};function rw(e){if(!e?.cfsBaseUrl)throw Error(`buildHiveIDLogin: cfsBaseUrl is required`);let t=e.mode??`signup`,n=!1,r=document.createElement(`div`);r.className=EC(),r.dataset.hiveidLogin=`true`;let i=document.createElement(`div`);i.className=OC();let a=document.createElement(`h2`);a.className=kC(),i.appendChild(a);let o=document.createElement(`div`);o.className=AC(),i.appendChild(o);let s={};$C.forEach(e=>{let t=document.createElement(`button`);t.type=`button`,t.className=jC(),t.textContent=tw[e],t.dataset.mode=e,t.onclick=()=>w(e),o.appendChild(t),s[e]=t}),r.appendChild(i);let c=document.createElement(`form`);c.className=DC(),c.noValidate=!0,r.appendChild(c);let l=document.createElement(`div`);l.className=RC(),l.hidden=!0,r.appendChild(l);function u(e,t=`info`){l.textContent=e,l.className=RC(),t===`error`&&l.classList.add(zC()),t===`success`&&l.classList.add(BC()),l.hidden=!e}function d(){u(``)}function f(e,t,n=`text`,r=``){let i=document.createElement(`div`);i.className=NC();let a=document.createElement(`label`);a.className=PC(),a.textContent=t,a.htmlFor=`chc-hil-${e}`;let o=document.createElement(`input`);return o.id=`chc-hil-${e}`,o.name=e,o.type=n,o.value=r,o.className=FC(),o.required=!0,i.appendChild(a),i.appendChild(o),c.appendChild(i),o}function p(){let e=document.createElement(`div`);return e.className=IC(),c.appendChild(e),e}function m(e){let t=document.createElement(`button`);return t.type=`submit`,t.className=LC(),t.textContent=e,c.appendChild(t),t}function h(e,t,n){let r=document.createElement(`div`);r.className=VC();let i=document.createElement(`button`);i.type=`button`,i.textContent=n,i.onclick=()=>w(t),r.append(e+` `,i),c.appendChild(r)}function g(e){if(e.note){let t=document.createElement(`p`);t.className=PC(),t.textContent=e.note,c.appendChild(t)}let t=null;if(e.providers.length>1){let n=document.createElement(`div`);n.className=NC();let r=document.createElement(`label`);r.className=PC(),r.textContent=`Provider`,r.htmlFor=`chc-hil-fedProvider`;let i=document.createElement(`select`);i.id=`chc-hil-fedProvider`,i.className=FC(),e.providers.forEach(e=>{let t=document.createElement(`option`);t.value=e.value,t.textContent=e.label,i.appendChild(t)}),n.append(r,i),c.appendChild(n),t=i}let n=document.createElement(`div`);n.className=NC();let r=document.createElement(`label`);r.className=PC(),r.textContent=e.idLabel??`Player ID`,r.htmlFor=`chc-hil-federationId`;let i=document.createElement(`input`);i.id=`chc-hil-federationId`,i.type=`text`,i.className=FC(),n.append(r,i),c.appendChild(n);let a=e.providers[0]?.value??``;return()=>{let e=i.value.trim();if(!e)return null;let n=t?t.value:a;return n?{provider:n,externalId:e}:null}}function _(e){if(e.note){let t=document.createElement(`p`);t.className=PC(),t.textContent=e.note,c.appendChild(t)}let t=e.required!==!1,n=document.createElement(`div`);n.className=NC();let r=document.createElement(`label`);r.className=PC(),r.textContent=e.dobLabel??`Date of birth`,r.htmlFor=`chc-hil-birthDate`;let i=document.createElement(`input`);i.id=`chc-hil-birthDate`,i.type=`date`,i.required=t,i.className=FC(),n.append(r,i),c.appendChild(n);let a=document.createElement(`div`);a.className=NC();let o=document.createElement(`label`);o.className=PC(),o.textContent=e.sexLabel??`Sex`,o.htmlFor=`chc-hil-sex`;let s=document.createElement(`select`);s.id=`chc-hil-sex`,s.required=t,s.className=FC();let l=document.createElement(`option`);return l.value=``,l.textContent=`Select…`,s.appendChild(l),(e.sexOptions??YC).forEach(e=>{let t=document.createElement(`option`);t.value=e.value,t.textContent=e.label,s.appendChild(t)}),a.append(o,s),c.appendChild(a),()=>ow({birthDate:i.value,sex:s.value})}function v(e){r.dispatchEvent(new CustomEvent(ew,{detail:e,bubbles:!0}))}function y(e,t){return async r=>{if(r.preventDefault(),!n){n=!0,e.disabled=!0,d();try{await t()}finally{n=!1,e.disabled=!1}}}}async function b(t,n,r,i={}){let a=t.value.trim(),o=n.value.trim(),s=r.value.trim();if(!a||!o||!s){u(`Email, first name, and last name are required.`,`error`);return}let{federationIds:c,birthDate:l,sex:d,provider:f,requirePii:p}=i;if(p&&(!l||!d)){u(`Date of birth and sex are required.`,`error`);return}try{let t=await WC(e.cfsBaseUrl,{email:a,firstName:o,lastName:s,federationIds:c,birthDate:l,sex:d,provider:f},e.fetchImpl);if(t.status===`candidate`){u(`We found possible matches — please log in with your existing account.`,`info`),w(`login`);return}v({token:t.token,refreshToken:t.refreshToken,personId:t.personId,cached:t.cached}),u(`Welcome to CourtHive.`,`success`)}catch(e){if(JC(e)){u(`That email already has a CourtHive account — please verify your password.`,`info`),w(`login`);return}u(cw(e)??`Sign-up failed. Please try again.`,`error`)}}async function x(t,n){let r=t.value.trim(),i=n.value;if(!r||!i){u(`Email and password are required.`,`error`);return}try{let t=await GC(e.cfsBaseUrl,{email:r,password:i},e.fetchImpl);v({token:t.token,refreshToken:t.refreshToken,personId:t.personId,cached:t.cached??sw()}),u(`Signed in.`,`success`)}catch(e){u(cw(e)??`Sign-in failed. Please check your password.`,`error`)}}async function S(t){let n=t.value.trim();if(!n){u(`Email is required.`,`error`);return}try{await KC(e.cfsBaseUrl,{email:n},e.fetchImpl),u(`If ${n} is registered, a sign-in link is on its way.`,`success`)}catch(e){u(cw(e)??`Could not send link. Please try again.`,`error`)}}function C(){if(c.replaceChildren(),a.textContent=nw[t],$C.forEach(e=>{s[e].classList.toggle(MC(),e===t)}),t===`signup`){let t=p(),n=document.createElement(`input`);n.id=`chc-hil-firstName`,n.type=`text`,n.placeholder=`First name`,n.required=!0,n.className=FC();let r=document.createElement(`input`);r.id=`chc-hil-lastName`,r.type=`text`,r.placeholder=`Last name`,r.required=!0,r.className=FC();let i=document.createElement(`div`);i.className=NC();let a=document.createElement(`label`);a.textContent=`First name`,a.className=PC(),a.htmlFor=n.id,i.append(a,n);let o=document.createElement(`div`);o.className=NC();let s=document.createElement(`label`);s.textContent=`Last name`,s.className=PC(),s.htmlFor=r.id,o.append(s,r),t.append(i,o);let l=f(`email`,`Email`,`email`,e.defaultEmail??``),u=e.federationIdCapture?g(e.federationIdCapture):()=>null,d=e.dobSexCapture?_(e.dobSexCapture):()=>({}),v=!!e.dobSexCapture&&e.dobSexCapture.required!==!1,x=m(`Create account`);c.onsubmit=y(x,()=>b(l,n,r,{federationIds:aw(u(),e.federationIds),...d(),provider:e.provider,requirePii:v})),h(`Already have an account?`,`login`,`Log in`)}else if(t===`login`){let t=f(`email`,`Email`,`email`,e.defaultEmail??``),n=f(`password`,`Password`,`password`),r=m(`Log in`);c.onsubmit=y(r,()=>x(t,n)),h(`Forgot your password?`,`magic-link`,`Email me a link`)}else{let t=f(`email`,`Email`,`email`,e.defaultEmail??``),n=m(`Send link`);c.onsubmit=y(n,()=>S(t)),h(`Have a password?`,`login`,`Log in instead`)}}function w(e){e!==t&&(t=e,d(),C())}function T(){return t}function E(e){let t=t=>e(t.detail);return r.addEventListener(ew,t),()=>r.removeEventListener(ew,t)}return C(),{root:r,setMode:w,getMode:T,onAuthenticated:E}}async function iw(e,t,n){let r=await qC(e,{code:t},n);return{token:r.token,refreshToken:r.refreshToken,personId:r.personId,cached:r.cached??sw()}}function aw(e,t){let n=[],r=new Set,i=e=>{if(!e?.provider||!e?.externalId)return;let t=`${e.provider}::${e.externalId}`;r.has(t)||(r.add(t),n.push({provider:e.provider,externalId:e.externalId}))};return(t??[]).forEach(i),i(e),n.length?n:void 0}function ow(e){let t={},n=e.birthDate?.trim(),r=e.sex?.trim();return n&&(t.birthDate=n),r&&(t.sex=r),t}function sw(){return{standardFamilyName:null,standardGivenName:null,birthDate:null,sex:null,nationalityCode:null}}function cw(e){if(!e||typeof e!=`object`)return null;if(e.kind===`http`){let t=e.body;if(t?.message&&typeof t.message==`string`)return t.message;if(typeof t?.status==`string`&&t.status===`incomplete`)return`We need a bit more information to identify you.`}return e.kind===`network`?`Could not reach CourtHive. Check your connection.`:null}var lw={name:`courthive-components`,packageManager:`pnpm@12.5.1`,version:`6.0.0`,engines:{node:`>=22`},description:`Components for competitions projects`,files:[`dist`],main:`./dist/courthive-components.umd.js`,module:`./dist/courthive-components.es.js`,types:`./dist/index.d.ts`,exports:{".":{types:`./dist/index.d.ts`,import:`./dist/courthive-components.es.js`,require:`./dist/courthive-components.umd.js`},"./dist/*":`./dist/*`},repository:{type:`git`,url:`git+https://github.com/CourtHive/courthive-components.git`},keywords:[`tournament`,`match`,`score`,`vanillajs`,`bracket`],author:`Charles Allen`,license:`MIT`,bugs:{url:`https://github.com/CourtHive/courthive-components/issues`},homepage:`https://courthive.github.io/courthive-component`,scripts:{commits:`git log $(git describe --tags --abbrev=0)..HEAD --oneline --no-merges --pretty=format:'%s: %h' | sed '/courthive-components/d'`,release:`npm run release:patch`,test:`vitest run`,"test:watch":`vitest`,"test:ui":`vitest --ui`,dev:`vite`,build:`tsc && vite build`,"check-types":`tsc --noEmit`,prepublishOnly:`pnpm build`,preview:`vite preview`,storybook:`storybook dev -p 6006`,"build-storybook":`storybook build`,"test-storybook":`test-storybook --url http://localhost:6006`,"deploy-storybook":`gh-pages -d storybook-static`,"pre-commit":`lint-staged`,predeploy:`pnpm build-storybook`,lint:`eslint src --cache --max-warnings 0`,"lint:fix":`eslint src --fix --cache`,"lint:report":`eslint src & eslint --cache src -f json > eslint-report.json`,format:`prettier --write src`,"release:major":`npm run commits && npm version $(semver $npm_package_version -i major) && git push && git push --tags`,"release:minor":`npm run commits && npm version $(semver $npm_package_version -i minor) && git push && git push --tags`,"release:patch":`npm run commits && npm version $(semver $npm_package_version -i patch) && git push && git push --tags`,"release:beta":`npm run commits && npm version $(semver $npm_package_version -i prerelease --preid beta) && git push && git push --tags`,"patch:beta":`npm run commits && npm version $(semver $npm_package_version -i prerelease --preid beta) && npm publish --tag beta`},"lint-staged":{"*.{js,ts}":`eslint --cache --fix`,"*":`prettier --ignore-unknown --write`},devDependencies:{"@chromatic-com/storybook":`^5.0.0`,"@commitlint/cli":`21.2.3`,"@commitlint/config-conventional":`21.2.3`,"@eslint/js":`^10.0.1`,"@fortawesome/fontawesome-free":`^7.2.0`,"@storybook/addon-docs":`^10.2.17`,"@storybook/html-vite":`^10.2.17`,"@storybook/test-runner":`^0.24.0`,"@types/d3":`^7.4.3`,"@types/leaflet":`^1.9.12`,"@types/vanillajs-datepicker":`^1.3.5`,"@typescript-eslint/eslint-plugin":`8.70.0`,"@typescript-eslint/parser":`8.70.0`,"@vitest/coverage-v8":`^5.0.0`,"@vitest/ui":`^5.0.0`,eslint:`10.11.0`,"eslint-plugin-sonarjs":`4.2.1`,"eslint-plugin-storybook":`^10.2.17`,"gh-pages":`6.3.0`,globals:`^17.3.0`,"happy-dom":`^20.8.3`,husky:`9.1.7`,leaflet:`1.9.4`,"lint-staged":`17.5.1`,playwright:`^1.57.0`,prettier:`^3.8.1`,semver:`7.8.5`,storybook:`^10.2.17`,"tabulator-tables":`6.5.3`,"tods-competition-factory":`^7.1.0`,typescript:`^6.0.2`,vite:`8.3.0`,"vite-plugin-dts":`^5.0.0`,vitest:`^5.0.0`},dependencies:{"@tiptap/core":`^3.22.2`,"@tiptap/extension-color":`^3.22.2`,"@tiptap/extension-highlight":`^3.22.2`,"@tiptap/extension-text-align":`^3.22.2`,"@tiptap/extension-text-style":`^3.22.2`,"@tiptap/extension-youtube":`^3.22.2`,"@tiptap/starter-kit":`^3.22.2`,awesomplete:`1.1.7`,"class-variance-authority":`0.7.1`,classnames:`2.5.1`,d3:`^7.9.0`,dayjs:`1.11.23`,"focus-trap":`^8.0.0`,"timepicker-ui":`^4.1.2`,"tippy.js":`6.3.7`,"vanillajs-datepicker":`1.3.4`},peerDependencies:{"tods-competition-factory":`^7.1.0`,leaflet:`^1.9.4`},peerDependenciesMeta:{leaflet:{optional:!0}}};function uw(){return lw.version}var dw={SET3_S6_TB7:`SET3-S:6/TB7`,SET3_S6_TB7_F_TB10:`SET3-S:6/TB7-F:TB10`,SET3_S6_TB10:`SET3-S:6/TB10`,SET3_S6_F_TB10:`SET3-S:6-F:TB10`,SET3_S6_TB7_NOAD:`SET3-S:6/TB7NOAD`,SET3_S8_TB7:`SET3-S:8/TB7`,SET3_S8_TB7_AT7:`SET3-S:8/TB7@7`,SET3_S4_TB7:`SET3-S:4/TB7`,SET3_S4_TB7_F_TB10:`SET3-S:4/TB7-F:TB10`,SET3_S4_TB5_AT3_F_TB10:`SET3-S:4/TB5@3-F:TB10`,SET5_S6_TB7:`SET5-S:6/TB7`,SET5_S6_TB7_F_TB10:`SET5-S:6/TB7-F:TB10`,SET1_S6_TB7:`SET1-S:6/TB7`,SET1_S6_TB10:`SET1-S:6/TB10`,SET1_S6_TB7_AT5:`SET1-S:6/TB7@5`,SET1_S8_TB7:`SET1-S:8/TB7`,SET1_S4_TB7:`SET1-S:4/TB7`,SET1_S5_TB9_AT4:`SET1-S:5/TB9@4`,SET1_S_TB7:`SET1-S:T7`,SET1_S_TB10:`SET1-S:TB10`,SET1_S_TB21:`SET1-S:T21`,SET1_S8:`SET1-S:8`,SET1_S10:`SET1-S:10`,FAST4:`SET5-S:4/NOAD`,SET3X_T10A_TB1:`SET3XA-S:T10-F:TB1`,SET3X_T10A_TB1_NOAD:`SET3XA-S:T10-F:TB1NOAD`,SET4X_T10A_TB1:`SET4XA-S:T10-F:TB1`};function fw(e,t,n){if(!e)return{elements:{}};let r={};for(let i of t||[]){if(!i?.label||i.hide)continue;let t=document.createElement(`button`);i.id&&(r[i.id]=t,t.id=i.id),t.style.marginRight=`.5em`,t.className=`button font-medium`,i.intent&&t.classList.add(i.intent),t.innerHTML=i.label,i.disabled&&(t.disabled=!0),t.onclick=e=>{e.stopPropagation(),!e.target.disabled&&V(i.onClick)&&i.onClick(),n&&V(n)&&n()},e.appendChild(t)}return{elements:r}}var pw=(e,t)=>n=>n?.trim().length>=e&&(!t||n?.trim().length<=t);function mw(e){return t.tools.isConvertableInteger(e)&&parseInt(e.toString())>=0}var hw=(e,t)=>n=>mw(n)&&Number(n)>=e&&Number(n)<=t,gw=e=>/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?\d)(?=.*?[#?!@$%^&*-]).{8,12}$/.test(e);function _w(e){return t.tools.dateTime.dateValidation.test(e)}var vw=(e,t)=>n=>{let r=(n||``).trim().split(` `).length;return r>=e&&(!t||r<=t)},yw=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,bw=e=>yw.exec(e),xw=_({dateValidator:()=>_w,emailValidator:()=>bw,nameValidator:()=>pw,numericRange:()=>hw,numericValidator:()=>mw,passwordValidator:()=>gw,wordValidator:()=>vw}),Sw=class{constructor({tournamentRecord:e,drawId:n,structureId:r,eventId:i}){this.tournamentRecord=e,this.drawId=n,this.structureId=r,this.eventId=i||e.events?.[0]?.eventId,t.tournamentEngine.setState(e)}setRenderCallback(e){this.renderCallback=e}getDrawEntryParticipantIds(){let{event:e,drawDefinition:n}=t.tournamentEngine.getEvent({drawId:this.drawId})||{};if(!e)return[];let{flightProfile:r}=t.tournamentEngine.getFlightProfile({eventId:this.eventId})||{};return(r?.flights?.find(e=>e.drawId===this.drawId)?.drawEntries||n?.entries||[]).map(e=>e.participantId).filter(Boolean)}getAllParticipants(){t.tournamentEngine.setState(this.tournamentRecord);let e=this.getDrawEntryParticipantIds();if(!e.length)return[];let{participants:n=[]}=t.tournamentEngine.getParticipants({participantFilters:{participantIds:e}})||{};return n.map(e=>({participantId:e.participantId,participantName:e.participantName,participantType:e.participantType,person:e.person,individualParticipants:e.individualParticipants}))}getAvailableParticipants(){t.tournamentEngine.setState(this.tournamentRecord);let e=this.getAllParticipants(),{assignedParticipantIds:n=[]}=t.tournamentEngine.getAssignedParticipantIds({drawId:this.drawId})||{};return e.filter(e=>!n.includes(e.participantId))}removeAssignment({drawPosition:e}){t.tournamentEngine.setState(this.tournamentRecord);let n=this.getMatchUps().find(t=>t.sides?.some(t=>t.drawPosition===e))?.sides?.find(t=>t.drawPosition===e)?.bye===!0,r=t.tournamentEngine.removeDrawPositionAssignment({drawId:this.drawId,structureId:this.structureId,drawPosition:e});if(r.error)return{success:!1,error:r.error};let{tournamentRecord:i}=t.tournamentEngine.getState()||{};return this.tournamentRecord=i,n&&this.renderCallback&&this.renderCallback(),{success:!0}}assignParticipant({drawPosition:e,participantId:n}){t.tournamentEngine.setState(this.tournamentRecord);let r=t.tournamentEngine.assignDrawPosition({drawId:this.drawId,structureId:this.structureId,drawPosition:e,participantId:n});if(r.error)return{success:!1,error:r.error};let{tournamentRecord:i}=t.tournamentEngine.getState()||{};return this.tournamentRecord=i,this.focusDrawPosition=e+1,this.renderCallback&&this.renderCallback(),{success:!0}}getAndClearFocusDrawPosition(){let e=this.focusDrawPosition;return this.focusDrawPosition=void 0,e}assignBye({drawPosition:e}){t.tournamentEngine.setState(this.tournamentRecord);let n=t.tournamentEngine.assignDrawPositionBye({drawId:this.drawId,structureId:this.structureId,drawPosition:e});if(n.error)return{success:!1,error:n.error};let{tournamentRecord:r}=t.tournamentEngine.getState()||{};return this.tournamentRecord=r,this.focusDrawPosition=e+1,this.renderCallback&&this.renderCallback(),{success:!0}}assignQualifier({drawPosition:e}){t.tournamentEngine.setState(this.tournamentRecord);let n=t.tournamentEngine.assignDrawPosition({drawId:this.drawId,structureId:this.structureId,drawPosition:e,qualifier:!0});if(n.error)return{success:!1,error:n.error};let{tournamentRecord:r}=t.tournamentEngine.getState()||{};return this.tournamentRecord=r,this.focusDrawPosition=e+1,this.renderCallback&&this.renderCallback(),{success:!0}}getMatchUps(){t.tournamentEngine.setState(this.tournamentRecord);let{eventData:e}=t.tournamentEngine.getEventData({eventId:this.eventId})||{},n=(e?.drawsData?.find(e=>e.drawId===this.drawId))?.structures?.find(e=>e.structureId===this.structureId)?.roundMatchUps;return n?Object.values(n).flat():[]}getState(){return this.tournamentRecord}getContext(){return{drawId:this.drawId,structureId:this.structureId}}},Cw=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="14" height="14" fill="currentColor"><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM175 175c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z"/></svg>`,ww=new WeakMap;function Tw(e,t){let n=document.createElement(`div`);n.style.cssText=`position: relative; flex: 1; display: flex; min-width: 0;`,e.style.paddingRight=`28px`,n.appendChild(e);let r=document.createElement(`button`);r.type=`button`,r.setAttribute(`aria-label`,`Clear search`),r.style.cssText=[`position: absolute`,`right: 8px`,`top: 50%`,`transform: translateY(-50%)`,`background: transparent`,`border: 0`,`padding: 2px`,`cursor: pointer`,`display: none`,`align-items: center`,`justify-content: center`,`line-height: 0`,`opacity: 0.55`,`color: currentColor`].join(`; `),r.innerHTML=Cw,r.addEventListener(`mouseenter`,()=>r.style.opacity=`0.9`),r.addEventListener(`mouseleave`,()=>r.style.opacity=`0.55`),r.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),t(),i()});let i=()=>{r.style.display=e.value?`inline-flex`:`none`};return e.addEventListener(`keyup`,n=>{n.key===`Escape`&&e.value&&(t(),i())}),e.addEventListener(`input`,i),ww.set(n,i),n.appendChild(r),n}function Ew(e){ww.get(e)?.()}function Dw(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Ow(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function kw(e){let t,n,r;e.length===2?(t=e===Dw||e===Ow?e:Aw,n=e,r=e):(t=Dw,n=(t,n)=>Dw(e(t),n),r=(t,n)=>e(t)-n);function i(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<0?i=t+1:a=t}while(i<a)}return i}function a(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<=0?i=t+1:a=t}while(i<a)}return i}function o(e,t,n=0,a=e.length){let o=i(e,t,n,a-1);return o>n&&r(e[o-1],t)>-r(e[o],t)?o-1:o}return{left:i,center:o,right:a}}function Aw(){return 0}function jw(e){return e===null?NaN:+e}var Mw=kw(Dw),Nw=Mw.right;Mw.left,kw(jw).center;function Pw(e,t){let n,r;if(t===void 0)for(let t of e)t!=null&&(n===void 0?t>=t&&(n=r=t):(n>t&&(n=t),r<t&&(r=t)));else{let i=-1;for(let a of e)(a=t(a,++i,e))!=null&&(n===void 0?a>=a&&(n=r=a):(n>a&&(n=a),r<a&&(r=a)))}return[n,r]}var Fw=class extends Map{constructor(e,t=zw){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(let[t,n]of e)this.set(t,n)}get(e){return super.get(Iw(this,e))}has(e){return super.has(Iw(this,e))}set(e,t){return super.set(Lw(this,e),t)}delete(e){return super.delete(Rw(this,e))}};function Iw({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):n}function Lw({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function Rw({_intern:e,_key:t},n){let r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function zw(e){return typeof e==`object`&&e?e.valueOf():e}var Bw=Math.sqrt(50),Vw=Math.sqrt(10),Hw=Math.sqrt(2);function Uw(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=Bw?10:a>=Vw?5:a>=Hw?2:1,s,c,l;return i<0?(l=10**-i/o,s=Math.round(e*l),c=Math.round(t*l),s/l<e&&++s,c/l>t&&--c,l=-l):(l=10**i*o,s=Math.round(e/l),c=Math.round(t/l),s*l<e&&++s,c*l>t&&--c),c<s&&.5<=n&&n<2?Uw(e,t,n*2):[s,c,l]}function Ww(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];let r=t<e,[i,a,o]=r?Uw(t,e,n):Uw(e,t,n);if(!(a>=i))return[];let s=a-i+1,c=Array(s);if(r){if(o<0)for(let e=0;e<s;++e)c[e]=(a-e)/-o;else for(let e=0;e<s;++e)c[e]=(a-e)*o}else if(o<0)for(let e=0;e<s;++e)c[e]=(i+e)/-o;else for(let e=0;e<s;++e)c[e]=(i+e)*o;return c}function Gw(e,t,n){return t=+t,e=+e,n=+n,Uw(e,t,n)[2]}function Kw(e,t,n){t=+t,e=+e,n=+n;let r=t<e,i=r?Gw(t,e,n):Gw(e,t,n);return(r?-1:1)*(i<0?1/-i:i)}function qw(e,t){let n;if(t===void 0)for(let t of e)t!=null&&(n<t||n===void 0&&t>=t)&&(n=t);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n<i||n===void 0&&i>=i)&&(n=i)}return n}function Jw(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r<i;)a[r]=e+r*n;return a}function Yw(e){return e}var Xw=1,Zw=2,Qw=3,$w=4,eT=1e-6;function tT(e){return`translate(`+e+`,0)`}function nT(e){return`translate(0,`+e+`)`}function rT(e){return t=>+e(t)}function iT(e,t){return t=Math.max(0,e.bandwidth()-t*2)/2,e.round()&&(t=Math.round(t)),n=>+e(n)+t}function aT(){return!this.__axis}function oT(e,t){var n=[],r=null,i=null,a=6,o=6,s=3,c=typeof window<`u`&&window.devicePixelRatio>1?0:.5,l=e===Xw||e===$w?-1:1,u=e===$w||e===Zw?`x`:`y`,d=e===Xw||e===Qw?tT:nT;function f(f){var p=r??(t.ticks?t.ticks.apply(t,n):t.domain()),m=i??(t.tickFormat?t.tickFormat.apply(t,n):Yw),h=Math.max(a,0)+s,g=t.range(),_=+g[0]+c,v=+g[g.length-1]+c,y=(t.bandwidth?iT:rT)(t.copy(),c),b=f.selection?f.selection():f,x=b.selectAll(`.domain`).data([null]),S=b.selectAll(`.tick`).data(p,t).order(),C=S.exit(),w=S.enter().append(`g`).attr(`class`,`tick`),T=S.select(`line`),E=S.select(`text`);x=x.merge(x.enter().insert(`path`,`.tick`).attr(`class`,`domain`).attr(`stroke`,`currentColor`)),S=S.merge(w),T=T.merge(w.append(`line`).attr(`stroke`,`currentColor`).attr(u+`2`,l*a)),E=E.merge(w.append(`text`).attr(`fill`,`currentColor`).attr(u,l*h).attr(`dy`,e===Xw?`0em`:e===Qw?`0.71em`:`0.32em`)),f!==b&&(x=x.transition(f),S=S.transition(f),T=T.transition(f),E=E.transition(f),C=C.transition(f).attr(`opacity`,eT).attr(`transform`,function(e){return isFinite(e=y(e))?d(e+c):this.getAttribute(`transform`)}),w.attr(`opacity`,eT).attr(`transform`,function(e){var t=this.parentNode.__axis;return d((t&&isFinite(t=t(e))?t:y(e))+c)})),C.remove(),x.attr(`d`,e===$w||e===Zw?o?`M`+l*o+`,`+_+`H`+c+`V`+v+`H`+l*o:`M`+c+`,`+_+`V`+v:o?`M`+_+`,`+l*o+`V`+c+`H`+v+`V`+l*o:`M`+_+`,`+c+`H`+v),S.attr(`opacity`,1).attr(`transform`,function(e){return d(y(e)+c)}),T.attr(u+`2`,l*a),E.attr(u,l*h).text(m),b.filter(aT).attr(`fill`,`none`).attr(`font-size`,10).attr(`font-family`,`sans-serif`).attr(`text-anchor`,e===Zw?`start`:e===$w?`end`:`middle`),b.each(function(){this.__axis=y})}return f.scale=function(e){return arguments.length?(t=e,f):t},f.ticks=function(){return n=Array.from(arguments),f},f.tickArguments=function(e){return arguments.length?(n=e==null?[]:Array.from(e),f):n.slice()},f.tickValues=function(e){return arguments.length?(r=e==null?null:Array.from(e),f):r&&r.slice()},f.tickFormat=function(e){return arguments.length?(i=e,f):i},f.tickSize=function(e){return arguments.length?(a=o=+e,f):a},f.tickSizeInner=function(e){return arguments.length?(a=+e,f):a},f.tickSizeOuter=function(e){return arguments.length?(o=+e,f):o},f.tickPadding=function(e){return arguments.length?(s=+e,f):s},f.offset=function(e){return arguments.length?(c=+e,f):c},f}function sT(e){return oT(Qw,e)}function cT(e){return oT($w,e)}var lT={value:()=>{}};function uT(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new dT(n)}function dT(e){this._=e}function fT(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}dT.prototype=uT.prototype={constructor:dT,on:function(e,t){var n=this._,r=fT(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=pT(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=mT(n[i],e.name,t);else if(t==null)for(i in n)n[i]=mT(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new dT(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function pT(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function mT(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=lT,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var hT={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function gT(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),hT.hasOwnProperty(t)?{space:hT[t],local:e}:e}function _T(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function vT(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function yT(e){var t=gT(e);return(t.local?vT:_T)(t)}function bT(){}function xT(e){return e==null?bT:function(){return this.querySelector(e)}}function ST(e){typeof e!=`function`&&(e=xT(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new uD(r,this._parents)}function CT(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function wT(){return[]}function TT(e){return e==null?wT:function(){return this.querySelectorAll(e)}}function ET(e){return function(){return CT(e.apply(this,arguments))}}function DT(e){e=typeof e==`function`?ET(e):TT(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new uD(r,i)}function OT(e){return function(){return this.matches(e)}}function kT(e){return function(t){return t.matches(e)}}var AT=Array.prototype.find;function jT(e){return function(){return AT.call(this.children,e)}}function MT(){return this.firstElementChild}function NT(e){return this.select(e==null?MT:jT(typeof e==`function`?e:kT(e)))}var PT=Array.prototype.filter;function FT(){return Array.from(this.children)}function IT(e){return function(){return PT.call(this.children,e)}}function LT(e){return this.selectAll(e==null?FT:IT(typeof e==`function`?e:kT(e)))}function RT(e){typeof e!=`function`&&(e=OT(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new uD(r,this._parents)}function zT(e){return Array(e.length)}function BT(){return new uD(this._enter||this._groups.map(zT),this._parents)}function VT(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}VT.prototype={constructor:VT,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function HT(e){return function(){return e}}function UT(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new VT(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function WT(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new VT(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function GT(e){return e.__data__}function KT(e,t){if(!arguments.length)return Array.from(this,GT);var n=t?WT:UT,r=this._parents,i=this._groups;typeof e!=`function`&&(e=HT(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=qT(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new uD(o,r),o._enter=s,o._exit=c,o}function qT(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function JT(){return new uD(this._exit||this._groups.map(zT),this._parents)}function YT(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function XT(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new uD(s,this._parents)}function ZT(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function QT(e){e||=$T;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new uD(i,this._parents).order()}function $T(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function eE(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function tE(){return Array.from(this)}function nE(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function rE(){let e=0;for(let t of this)++e;return e}function iE(){return!this.node()}function aE(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function oE(e){return function(){this.removeAttribute(e)}}function sE(e){return function(){this.removeAttributeNS(e.space,e.local)}}function cE(e,t){return function(){this.setAttribute(e,t)}}function lE(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function uE(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function dE(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function fE(e,t){var n=gT(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?sE:oE:typeof t==`function`?n.local?dE:uE:n.local?lE:cE)(n,t))}function pE(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function mE(e){return function(){this.style.removeProperty(e)}}function hE(e,t,n){return function(){this.style.setProperty(e,t,n)}}function gE(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function _E(e,t,n){return arguments.length>1?this.each((t==null?mE:typeof t==`function`?gE:hE)(e,t,n??``)):vE(this.node(),e)}function vE(e,t){return e.style.getPropertyValue(t)||pE(e).getComputedStyle(e,null).getPropertyValue(t)}function yE(e){return function(){delete this[e]}}function bE(e,t){return function(){this[e]=t}}function xE(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function SE(e,t){return arguments.length>1?this.each((t==null?yE:typeof t==`function`?xE:bE)(e,t)):this.node()[e]}function CE(e){return e.trim().split(/^|\s+/)}function wE(e){return e.classList||new TE(e)}function TE(e){this._node=e,this._names=CE(e.getAttribute(`class`)||``)}TE.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function EE(e,t){for(var n=wE(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function DE(e,t){for(var n=wE(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function OE(e){return function(){EE(this,e)}}function kE(e){return function(){DE(this,e)}}function AE(e,t){return function(){(t.apply(this,arguments)?EE:DE)(this,e)}}function jE(e,t){var n=CE(e+``);if(arguments.length<2){for(var r=wE(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?AE:t?OE:kE)(n,t))}function ME(){this.textContent=``}function NE(e){return function(){this.textContent=e}}function PE(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function FE(e){return arguments.length?this.each(e==null?ME:(typeof e==`function`?PE:NE)(e)):this.node().textContent}function IE(){this.innerHTML=``}function LE(e){return function(){this.innerHTML=e}}function RE(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function zE(e){return arguments.length?this.each(e==null?IE:(typeof e==`function`?RE:LE)(e)):this.node().innerHTML}function BE(){this.nextSibling&&this.parentNode.appendChild(this)}function VE(){return this.each(BE)}function HE(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function UE(){return this.each(HE)}function WE(e){var t=typeof e==`function`?e:yT(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function GE(){return null}function KE(e,t){var n=typeof e==`function`?e:yT(e),r=t==null?GE:typeof t==`function`?t:xT(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function qE(){var e=this.parentNode;e&&e.removeChild(this)}function JE(){return this.each(qE)}function YE(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function XE(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ZE(e){return this.select(e?XE:YE)}function QE(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function $E(e){return function(t){e.call(this,t,this.__data__)}}function eD(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function tD(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function nD(e,t,n){return function(){var r=this.__on,i,a=$E(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function rD(e,t,n){var r=eD(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?nD:tD,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function iD(e,t,n){var r=pE(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function aD(e,t){return function(){return iD(this,e,t)}}function oD(e,t){return function(){return iD(this,e,t.apply(this,arguments))}}function sD(e,t){return this.each((typeof t==`function`?oD:aD)(e,t))}function*cD(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var lD=[null];function uD(e,t){this._groups=e,this._parents=t}function dD(){return new uD([[document.documentElement]],lD)}function fD(){return this}uD.prototype=dD.prototype={constructor:uD,select:ST,selectAll:DT,selectChild:NT,selectChildren:LT,filter:RT,data:KT,enter:BT,exit:JT,join:YT,merge:XT,selection:fD,order:ZT,sort:QT,call:eE,nodes:tE,node:nE,size:rE,empty:iE,each:aE,attr:fE,style:_E,property:SE,classed:jE,text:FE,html:zE,raise:VE,lower:UE,append:WE,insert:KE,remove:JE,clone:ZE,datum:QE,on:rD,dispatch:sD,[Symbol.iterator]:cD};function pD(e){return typeof e==`string`?new uD([[document.querySelector(e)]],[document.documentElement]):new uD([[e]],lD)}function mD(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function hD(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function gD(){}var _D=.7,vD=1/_D,yD=`\\s*([+-]?\\d+)\\s*`,bD=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,xD=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,SD=/^#([0-9a-f]{3,8})$/,CD=RegExp(`^rgb\\(${yD},${yD},${yD}\\)$`),wD=RegExp(`^rgb\\(${xD},${xD},${xD}\\)$`),TD=RegExp(`^rgba\\(${yD},${yD},${yD},${bD}\\)$`),ED=RegExp(`^rgba\\(${xD},${xD},${xD},${bD}\\)$`),DD=RegExp(`^hsl\\(${bD},${xD},${xD}\\)$`),OD=RegExp(`^hsla\\(${bD},${xD},${xD},${bD}\\)$`),kD={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};mD(gD,PD,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:AD,formatHex:AD,formatHex8:jD,formatHsl:MD,formatRgb:ND,toString:ND});function AD(){return this.rgb().formatHex()}function jD(){return this.rgb().formatHex8()}function MD(){return qD(this).formatHsl()}function ND(){return this.rgb().formatRgb()}function PD(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=SD.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?FD(t):n===3?new zD(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?ID(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?ID(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=CD.exec(e))?new zD(t[1],t[2],t[3],1):(t=wD.exec(e))?new zD(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=TD.exec(e))?ID(t[1],t[2],t[3],t[4]):(t=ED.exec(e))?ID(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=DD.exec(e))?KD(t[1],t[2]/100,t[3]/100,1):(t=OD.exec(e))?KD(t[1],t[2]/100,t[3]/100,t[4]):kD.hasOwnProperty(e)?FD(kD[e]):e===`transparent`?new zD(NaN,NaN,NaN,0):null}function FD(e){return new zD(e>>16&255,e>>8&255,e&255,1)}function ID(e,t,n,r){return r<=0&&(e=t=n=NaN),new zD(e,t,n,r)}function LD(e){return e instanceof gD||(e=PD(e)),e?(e=e.rgb(),new zD(e.r,e.g,e.b,e.opacity)):new zD}function RD(e,t,n,r){return arguments.length===1?LD(e):new zD(e,t,n,r??1)}function zD(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}mD(zD,RD,hD(gD,{brighter(e){return e=e==null?vD:vD**+e,new zD(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?_D:_D**+e,new zD(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new zD(WD(this.r),WD(this.g),WD(this.b),UD(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:BD,formatHex:BD,formatHex8:VD,formatRgb:HD,toString:HD}));function BD(){return`#${GD(this.r)}${GD(this.g)}${GD(this.b)}`}function VD(){return`#${GD(this.r)}${GD(this.g)}${GD(this.b)}${GD((isNaN(this.opacity)?1:this.opacity)*255)}`}function HD(){let e=UD(this.opacity);return`${e===1?`rgb(`:`rgba(`}${WD(this.r)}, ${WD(this.g)}, ${WD(this.b)}${e===1?`)`:`, ${e})`}`}function UD(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function WD(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function GD(e){return e=WD(e),(e<16?`0`:``)+e.toString(16)}function KD(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new YD(e,t,n,r)}function qD(e){if(e instanceof YD)return new YD(e.h,e.s,e.l,e.opacity);if(e instanceof gD||(e=PD(e)),!e)return new YD;if(e instanceof YD)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new YD(o,s,c,e.opacity)}function JD(e,t,n,r){return arguments.length===1?qD(e):new YD(e,t,n,r??1)}function YD(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}mD(YD,JD,hD(gD,{brighter(e){return e=e==null?vD:vD**+e,new YD(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?_D:_D**+e,new YD(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new zD(QD(e>=240?e-240:e+120,i,r),QD(e,i,r),QD(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new YD(XD(this.h),ZD(this.s),ZD(this.l),UD(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=UD(this.opacity);return`${e===1?`hsl(`:`hsla(`}${XD(this.h)}, ${ZD(this.s)*100}%, ${ZD(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function XD(e){return e=(e||0)%360,e<0?e+360:e}function ZD(e){return Math.max(0,Math.min(1,e||0))}function QD(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var $D=e=>()=>e;function eO(e,t){return function(n){return e+n*t}}function tO(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function nO(e){return(e=+e)==1?rO:function(t,n){return n-t?tO(t,n,e):$D(isNaN(t)?n:t)}}function rO(e,t){var n=t-e;return n?eO(e,n):$D(isNaN(e)?t:e)}var iO=(function e(t){var n=nO(t);function r(e,t){var r=n((e=RD(e)).r,(t=RD(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=rO(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function aO(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function oO(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function sO(e,t){for(var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o=0;o<r;++o)i[o]=gO(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function cO(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function lO(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function uO(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=gO(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var dO=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,fO=new RegExp(dO.source,`g`);function pO(e){return function(){return e}}function mO(e){return function(t){return e(t)+``}}function hO(e,t){var n=dO.lastIndex=fO.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=dO.exec(e))&&(i=fO.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:lO(r,i)})),n=fO.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?mO(c[0].x):pO(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function gO(e,t){var n=typeof t,r;return t==null||n===`boolean`?$D(t):(n===`number`?lO:n===`string`?(r=PD(t))?(t=r,iO):hO:t instanceof PD?iO:t instanceof Date?cO:oO(t)?aO:Array.isArray(t)?sO:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?uO:lO)(e,t)}function _O(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var vO=180/Math.PI,yO={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function bO(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*vO,skewX:Math.atan(c)*vO,scaleX:o,scaleY:s}}var xO;function SO(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?yO:bO(t.a,t.b,t.c,t.d,t.e,t.f)}function CO(e){return e==null||(xO||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),xO.setAttribute(`transform`,e),!(e=xO.transform.baseVal.consolidate()))?yO:(e=e.matrix,bO(e.a,e.b,e.c,e.d,e.e,e.f))}function wO(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:lO(e,i)},{i:c-2,x:lO(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:lO(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:lO(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:lO(e,n)},{i:s-2,x:lO(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var TO=wO(SO,`px, `,`px)`,`deg)`),EO=wO(CO,`, `,`)`,`)`),DO=0,OO=0,kO=0,AO=1e3,jO,MO,NO=0,PO=0,FO=0,IO=typeof performance==`object`&&performance.now?performance:Date,LO=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function RO(){return PO||=(LO(zO),IO.now()+FO)}function zO(){PO=0}function BO(){this._call=this._time=this._next=null}BO.prototype=VO.prototype={constructor:BO,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?RO():+n)+(t==null?0:+t),!this._next&&MO!==this&&(MO?MO._next=this:jO=this,MO=this),this._call=e,this._time=n,KO()},stop:function(){this._call&&(this._call=null,this._time=1/0,KO())}};function VO(e,t,n){var r=new BO;return r.restart(e,t,n),r}function HO(){RO(),++DO;for(var e=jO,t;e;)(t=PO-e._time)>=0&&e._call.call(void 0,t),e=e._next;--DO}function UO(){PO=(NO=IO.now())+FO,DO=OO=0;try{HO()}finally{DO=0,GO(),PO=0}}function WO(){var e=IO.now(),t=e-NO;t>AO&&(FO-=t,NO=e)}function GO(){for(var e,t=jO,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:jO=n);MO=e,KO(r)}function KO(e){DO||(OO&&=clearTimeout(OO),e-PO>24?(e<1/0&&(OO=setTimeout(UO,e-IO.now()-FO)),kO&&=clearInterval(kO)):(kO||=(NO=IO.now(),setInterval(WO,AO)),DO=1,LO(UO)))}function qO(e,t,n){var r=new BO;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var JO=uT(`start`,`end`,`cancel`,`interrupt`),YO=[];function XO(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;ek(e,n,{name:t,index:r,group:i,on:JO,tween:YO,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function ZO(e,t){var n=$O(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function QO(e,t){var n=$O(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function $O(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function ek(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=VO(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return qO(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(qO(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function tk(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function nk(e){return this.each(function(){tk(this,e)})}function rk(e,t){var n,r;return function(){var i=QO(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function ik(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=QO(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function ak(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=$O(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?rk:ik)(n,e,t))}function ok(e,t,n){var r=e._id;return e.each(function(){var e=QO(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return $O(e,r).value[t]}}function sk(e,t){var n;return(typeof t==`number`?lO:t instanceof PD?iO:(n=PD(t))?(t=n,iO):hO)(e,t)}function ck(e){return function(){this.removeAttribute(e)}}function lk(e){return function(){this.removeAttributeNS(e.space,e.local)}}function uk(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function dk(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function fk(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function pk(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function mk(e,t){var n=gT(e),r=n===`transform`?EO:sk;return this.attrTween(e,typeof t==`function`?(n.local?pk:fk)(n,r,ok(this,`attr.`+e,t)):t==null?(n.local?lk:ck)(n):(n.local?dk:uk)(n,r,t))}function hk(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function gk(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function _k(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&gk(e,i)),n}return i._value=t,i}function vk(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&hk(e,i)),n}return i._value=t,i}function yk(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=gT(e);return this.tween(n,(r.local?_k:vk)(r,t))}function bk(e,t){return function(){ZO(this,e).delay=+t.apply(this,arguments)}}function xk(e,t){return t=+t,function(){ZO(this,e).delay=t}}function Sk(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?bk:xk)(t,e)):$O(this.node(),t).delay}function Ck(e,t){return function(){QO(this,e).duration=+t.apply(this,arguments)}}function wk(e,t){return t=+t,function(){QO(this,e).duration=t}}function Tk(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?Ck:wk)(t,e)):$O(this.node(),t).duration}function Ek(e,t){if(typeof t!=`function`)throw Error();return function(){QO(this,e).ease=t}}function Dk(e){var t=this._id;return arguments.length?this.each(Ek(t,e)):$O(this.node(),t).ease}function Ok(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();QO(this,e).ease=n}}function kk(e){if(typeof e!=`function`)throw Error();return this.each(Ok(this._id,e))}function Ak(e){typeof e!=`function`&&(e=OT(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new aA(r,this._parents,this._name,this._id)}function jk(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new aA(o,this._parents,this._name,this._id)}function Mk(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function Nk(e,t,n){var r,i,a=Mk(t)?ZO:QO;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function Pk(e,t){var n=this._id;return arguments.length<2?$O(this.node(),n).on.on(e):this.each(Nk(n,e,t))}function Fk(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Ik(){return this.on(`end.remove`,Fk(this._id))}function Lk(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=xT(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,XO(l[f],t,n,f,l,$O(u,n)));return new aA(a,this._parents,t,n)}function Rk(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=TT(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=$O(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&XO(p,t,n,h,f,m);a.push(f),o.push(u)}return new aA(a,o,t,n)}var zk=dD.prototype.constructor;function Bk(){return new zk(this._groups,this._parents)}function Vk(e,t){var n,r,i;return function(){var a=vE(this,e),o=(this.style.removeProperty(e),vE(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function Hk(e){return function(){this.style.removeProperty(e)}}function Uk(e,t,n){var r,i=n+``,a;return function(){var o=vE(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function Wk(e,t,n){var r,i,a;return function(){var o=vE(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),vE(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function Gk(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=QO(this,e),l=c.on,u=c.value[a]==null?s||=Hk(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function Kk(e,t,n){var r=(e+=``)==`transform`?TO:sk;return t==null?this.styleTween(e,Vk(e,r)).on(`end.style.`+e,Hk(e)):typeof t==`function`?this.styleTween(e,Wk(e,r,ok(this,`style.`+e,t))).each(Gk(this._id,e)):this.styleTween(e,Uk(e,r,t),n).on(`end.style.`+e,null)}function qk(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Jk(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&qk(e,a,n)),r}return a._value=t,a}function Yk(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,Jk(e,t,n??``))}function Xk(e){return function(){this.textContent=e}}function Zk(e){return function(){var t=e(this);this.textContent=t??``}}function Qk(e){return this.tween(`text`,typeof e==`function`?Zk(ok(this,`text`,e)):Xk(e==null?``:e+``))}function $k(e){return function(t){this.textContent=e.call(this,t)}}function eA(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&$k(r)),t}return r._value=e,r}function tA(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,eA(e))}function nA(){for(var e=this._name,t=this._id,n=oA(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=$O(c,t);XO(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new aA(r,this._parents,e,n)}function rA(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=QO(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var iA=0;function aA(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function oA(){return++iA}var sA=dD.prototype;aA.prototype={constructor:aA,select:Lk,selectAll:Rk,selectChild:sA.selectChild,selectChildren:sA.selectChildren,filter:Ak,merge:jk,selection:Bk,transition:nA,call:sA.call,nodes:sA.nodes,node:sA.node,size:sA.size,empty:sA.empty,each:sA.each,on:Pk,attr:mk,attrTween:yk,style:Kk,styleTween:Yk,text:Qk,textTween:tA,remove:Ik,tween:ak,delay:Sk,duration:Tk,ease:Dk,easeVarying:kk,end:rA,[Symbol.iterator]:sA[Symbol.iterator]};function cA(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var lA={time:null,delay:0,duration:250,ease:cA};function uA(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function dA(e){var t,n;e instanceof aA?(t=e._id,e=e._name):(t=oA(),(n=lA).time=RO(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&XO(c,e,t,l,o,n||uA(c,t));return new aA(r,this._parents,e,t)}dD.prototype.interrupt=nk,dD.prototype.transition=dA;var{abs:fA,max:pA,min:mA}=Math;[`w`,`e`].map(hA),[`n`,`s`].map(hA),[`n`,`w`,`e`,`s`,`nw`,`ne`,`sw`,`se`].map(hA);function hA(e){return{type:e}}var gA=Math.PI,_A=2*gA,vA=1e-6,yA=_A-vA;function bA(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function xA(e){let t=Math.floor(e);if(!(t>=0))throw Error(`invalid digits: ${e}`);if(t>15)return bA;let n=10**t;return function(e){this._+=e[0];for(let t=1,r=e.length;t<r;++t)this._+=Math.round(arguments[t]*n)/n+e[t]}}var SA=class{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._=``,this._append=e==null?bA:xA(e)}moveTo(e,t){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,t){this._append`L${this._x1=+e},${this._y1=+t}`}quadraticCurveTo(e,t,n,r){this._append`Q${+e},${+t},${this._x1=+n},${this._y1=+r}`}bezierCurveTo(e,t,n,r,i,a){this._append`C${+e},${+t},${+n},${+r},${this._x1=+i},${this._y1=+a}`}arcTo(e,t,n,r,i){if(e=+e,t=+t,n=+n,r=+r,i=+i,i<0)throw Error(`negative radius: ${i}`);let a=this._x1,o=this._y1,s=n-e,c=r-t,l=a-e,u=o-t,d=l*l+u*u;if(this._x1===null)this._append`M${this._x1=e},${this._y1=t}`;else if(d>vA){if(!(Math.abs(u*s-c*l)>vA)||!i)this._append`L${this._x1=e},${this._y1=t}`;else{let f=n-a,p=r-o,m=s*s+c*c,h=f*f+p*p,g=Math.sqrt(m),_=Math.sqrt(d),v=i*Math.tan((gA-Math.acos((m+d-h)/(2*g*_)))/2),y=v/_,b=v/g;Math.abs(y-1)>vA&&this._append`L${e+y*l},${t+y*u}`,this._append`A${i},${i},0,0,${+(u*f>l*p)},${this._x1=e+b*s},${this._y1=t+b*c}`}}}arc(e,t,n,r,i,a){if(e=+e,t=+t,n=+n,a=!!a,n<0)throw Error(`negative radius: ${n}`);let o=n*Math.cos(r),s=n*Math.sin(r),c=e+o,l=t+s,u=1^a,d=a?r-i:i-r;this._x1===null?this._append`M${c},${l}`:(Math.abs(this._x1-c)>vA||Math.abs(this._y1-l)>vA)&&this._append`L${c},${l}`,n&&(d<0&&(d=d%_A+_A),d>yA?this._append`A${n},${n},0,1,${u},${e-o},${t-s}A${n},${n},0,1,${u},${this._x1=c},${this._y1=l}`:d>vA&&this._append`A${n},${n},0,${+(d>=gA)},${u},${this._x1=e+n*Math.cos(i)},${this._y1=t+n*Math.sin(i)}`)}rect(e,t,n,r){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}};SA.prototype;function CA(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function wA(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function TA(e){return e=wA(Math.abs(e)),e?e[1]:NaN}function EA(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}function DA(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var OA=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function kA(e){if(!(t=OA.exec(e)))throw Error(`invalid format: `+e);var t;return new AA({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}kA.prototype=AA.prototype;function AA(e){this.fill=e.fill===void 0?` `:e.fill+``,this.align=e.align===void 0?`>`:e.align+``,this.sign=e.sign===void 0?`-`:e.sign+``,this.symbol=e.symbol===void 0?``:e.symbol+``,this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?``:e.type+``}AA.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?`0`:``)+(this.width===void 0?``:Math.max(1,this.width|0))+(this.comma?`,`:``)+(this.precision===void 0?``:`.`+Math.max(0,this.precision|0))+(this.trim?`~`:``)+this.type};function jA(e){out:for(var t=e.length,n=1,r=-1,i;n<t;++n)switch(e[n]){case`.`:r=i=n;break;case`0`:r===0&&(r=n),i=n;break;default:if(!+e[n])break out;r>0&&(r=0)}return r>0?e.slice(0,r)+e.slice(i+1):e}var MA;function NA(e,t){var n=wA(e,t);if(!n)return MA=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(MA=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+wA(e,Math.max(0,t+a-1))[0]}function PA(e,t){var n=wA(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var FA={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:CA,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>PA(e*100,t),r:PA,s:NA,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function IA(e){return e}var LA=Array.prototype.map,RA=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function zA(e){var t=e.grouping===void 0||e.thousands===void 0?IA:EA(LA.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?IA:DA(LA.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=kA(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):FA[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),x=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),S=FA[y],C=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function w(e){var n=b,r=x,o,l,p;if(y===`c`)r=S(e)+r,e=``;else{e=+e;var w=e<0||1/e<0;if(e=isNaN(e)?c:S(Math.abs(e),_),v&&(e=jA(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&MA!==void 0?RA[8+MA/3]:``)+r+(w&&f===`(`?`)`:``),C){for(o=-1,l=e.length;++o<l;)if(p=e.charCodeAt(o),48>p||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var T=n.length+e.length+r.length,E=T<h?Array(h-T+1).join(u):``;switch(g&&m&&(e=t(E+e,E.length?h-r.length:1/0),E=``),d){case`<`:e=n+e+r+E;break;case`=`:e=n+E+e+r;break;case`^`:e=E.slice(0,T=E.length>>1)+n+e+r+E.slice(T);break;default:e=E+n+e+r}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(TA(t)/3)))*3,r=10**-n,i=l((e=kA(e),e.type=`f`,e),{suffix:RA[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var BA,VA,HA;UA({thousands:`,`,grouping:[3],currency:[`$`,``]});function UA(e){return BA=zA(e),VA=BA.format,HA=BA.formatPrefix,BA}function WA(e){return Math.max(0,-TA(Math.abs(e)))}function GA(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(TA(t)/3)))*3-TA(Math.abs(e)))}function KA(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,TA(t)-TA(e))+1}function qA(e){var t=0,n=e.children,r=n&&n.length;if(!r)t=1;else for(;--r>=0;)t+=n[r].value;e.value=t}function JA(){return this.eachAfter(qA)}function YA(e,t){let n=-1;for(let r of this)e.call(t,r,++n,this);return this}function XA(e,t){for(var n=this,r=[n],i,a,o=-1;n=r.pop();)if(e.call(t,n,++o,this),i=n.children)for(a=i.length-1;a>=0;--a)r.push(i[a]);return this}function ZA(e,t){for(var n=this,r=[n],i=[],a,o,s,c=-1;n=r.pop();)if(i.push(n),a=n.children)for(o=0,s=a.length;o<s;++o)r.push(a[o]);for(;n=i.pop();)e.call(t,n,++c,this);return this}function QA(e,t){let n=-1;for(let r of this)if(e.call(t,r,++n,this))return r}function $A(e){return this.eachAfter(function(t){for(var n=+e(t.data)||0,r=t.children,i=r&&r.length;--i>=0;)n+=r[i].value;t.value=n})}function ej(e){return this.eachBefore(function(t){t.children&&t.children.sort(e)})}function tj(e){for(var t=this,n=nj(t,e),r=[t];t!==n;)t=t.parent,r.push(t);for(var i=r.length;e!==n;)r.splice(i,0,e),e=e.parent;return r}function nj(e,t){if(e===t)return e;var n=e.ancestors(),r=t.ancestors(),i=null;for(e=n.pop(),t=r.pop();e===t;)i=e,e=n.pop(),t=r.pop();return i}function rj(){for(var e=this,t=[e];e=e.parent;)t.push(e);return t}function ij(){return Array.from(this)}function aj(){var e=[];return this.eachBefore(function(t){t.children||e.push(t)}),e}function oj(){var e=this,t=[];return e.each(function(n){n!==e&&t.push({source:n.parent,target:n})}),t}function*sj(){var e=this,t,n=[e],r,i,a;do for(t=n.reverse(),n=[];e=t.pop();)if(yield e,r=e.children)for(i=0,a=r.length;i<a;++i)n.push(r[i]);while(n.length)}function cj(e,t){e instanceof Map?(e=[void 0,e],t===void 0&&(t=dj)):t===void 0&&(t=uj);for(var n=new mj(e),r,i=[n],a,o,s,c;r=i.pop();)if((o=t(r.data))&&(c=(o=Array.from(o)).length))for(r.children=o,s=c-1;s>=0;--s)i.push(a=o[s]=new mj(o[s])),a.parent=r,a.depth=r.depth+1;return n.eachBefore(pj)}function lj(){return cj(this).eachBefore(fj)}function uj(e){return e.children}function dj(e){return Array.isArray(e)?e[1]:null}function fj(e){e.data.value!==void 0&&(e.value=e.data.value),e.data=e.data.data}function pj(e){var t=0;do e.height=t;while((e=e.parent)&&e.height<++t)}function mj(e){this.data=e,this.depth=this.height=0,this.parent=null}mj.prototype=cj.prototype={constructor:mj,count:JA,each:YA,eachAfter:ZA,eachBefore:XA,find:QA,sum:$A,sort:ej,path:tj,ancestors:rj,descendants:ij,leaves:aj,links:oj,copy:lj,[Symbol.iterator]:sj};function hj(e){e.x0=Math.round(e.x0),e.y0=Math.round(e.y0),e.x1=Math.round(e.x1),e.y1=Math.round(e.y1)}function gj(e,t,n,r,i){for(var a=e.children,o,s=-1,c=a.length,l=e.value&&(r-t)/e.value;++s<c;)o=a[s],o.y0=n,o.y1=i,o.x0=t,o.x1=t+=o.value*l}function _j(){var e=1,t=1,n=0,r=!1;function i(i){var o=i.height+1;return i.x0=i.y0=n,i.x1=e,i.y1=t/o,i.eachBefore(a(t,o)),r&&i.eachBefore(hj),i}function a(e,t){return function(r){r.children&&gj(r,r.x0,e*(r.depth+1)/t,r.x1,e*(r.depth+2)/t);var i=r.x0,a=r.y0,o=r.x1-n,s=r.y1-n;o<i&&(i=o=(i+o)/2),s<a&&(a=s=(a+s)/2),r.x0=i,r.y0=a,r.x1=o,r.y1=s}}return i.round=function(e){return arguments.length?(r=!!e,i):r},i.size=function(n){return arguments.length?(e=+n[0],t=+n[1],i):[e,t]},i.padding=function(e){return arguments.length?(n=+e,i):n},i}function vj(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e)}return this}var yj=Symbol(`implicit`);function bj(){var e=new Fw,t=[],n=[],r=yj;function i(i){let a=e.get(i);if(a===void 0){if(r!==yj)return r;e.set(i,a=t.push(i)-1)}return n[a%n.length]}return i.domain=function(n){if(!arguments.length)return t.slice();t=[],e=new Fw;for(let r of n)e.has(r)||e.set(r,t.push(r)-1);return i},i.range=function(e){return arguments.length?(n=Array.from(e),i):n.slice()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return bj(t,n).unknown(r)},vj.apply(i,arguments),i}function xj(){var e=bj().unknown(void 0),t=e.domain,n=e.range,r=0,i=1,a,o,s=!1,c=0,l=0,u=.5;delete e.unknown;function d(){var e=t().length,d=i<r,f=d?i:r,p=d?r:i;a=(p-f)/Math.max(1,e-c+l*2),s&&(a=Math.floor(a)),f+=(p-f-a*(e-c))*u,o=a*(1-c),s&&(f=Math.round(f),o=Math.round(o));var m=Jw(e).map(function(e){return f+a*e});return n(d?m.reverse():m)}return e.domain=function(e){return arguments.length?(t(e),d()):t()},e.range=function(e){return arguments.length?([r,i]=e,r=+r,i=+i,d()):[r,i]},e.rangeRound=function(e){return[r,i]=e,r=+r,i=+i,s=!0,d()},e.bandwidth=function(){return o},e.step=function(){return a},e.round=function(e){return arguments.length?(s=!!e,d()):s},e.padding=function(e){return arguments.length?(c=Math.min(1,l=+e),d()):c},e.paddingInner=function(e){return arguments.length?(c=Math.min(1,e),d()):c},e.paddingOuter=function(e){return arguments.length?(l=+e,d()):l},e.align=function(e){return arguments.length?(u=Math.max(0,Math.min(1,e)),d()):u},e.copy=function(){return xj(t(),[r,i]).round(s).paddingInner(c).paddingOuter(l).align(u)},vj.apply(d(),arguments)}function Sj(e){var t=e.copy;return e.padding=e.paddingOuter,delete e.paddingInner,delete e.paddingOuter,e.copy=function(){return Sj(t())},e}function Cj(){return Sj(xj.apply(null,arguments).paddingInner(1))}function wj(e){return function(){return e}}function Tj(e){return+e}var Ej=[0,1];function Dj(e){return e}function Oj(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:wj(isNaN(t)?NaN:.5)}function kj(e,t){var n;return e>t&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function Aj(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i<r?(r=Oj(i,r),a=n(o,a)):(r=Oj(r,i),a=n(a,o)),function(e){return a(r(e))}}function jj(e,t,n){var r=Math.min(e.length,t.length)-1,i=Array(r),a=Array(r),o=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++o<r;)i[o]=Oj(e[o],e[o+1]),a[o]=n(t[o],t[o+1]);return function(t){var n=Nw(e,t,1,r)-1;return a[n](i[n](t))}}function Mj(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function Nj(){var e=Ej,t=Ej,n=gO,r,i,a,o=Dj,s,c,l;function u(){var n=Math.min(e.length,t.length);return o!==Dj&&(o=kj(e[0],e[n-1])),s=n>2?jj:Aj,c=l=null,d}function d(i){return i==null||isNaN(i=+i)?a:(c||=s(e.map(r),t,n))(r(o(i)))}return d.invert=function(n){return o(i((l||=s(t,e.map(r),lO))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,Tj),u()):e.slice()},d.range=function(e){return arguments.length?(t=Array.from(e),u()):t.slice()},d.rangeRound=function(e){return t=Array.from(e),n=_O,u()},d.clamp=function(e){return arguments.length?(o=e?!0:Dj,u()):o!==Dj},d.interpolate=function(e){return arguments.length?(n=e,u()):n},d.unknown=function(e){return arguments.length?(a=e,d):a},function(e,t){return r=e,i=t,u()}}function Pj(){return Nj()(Dj,Dj)}function Fj(e,t,n,r){var i=Kw(e,t,n),a;switch(r=kA(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=GA(i,o))&&(r.precision=a),HA(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=KA(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=WA(i))&&(r.precision=a-(r.type===`%`)*2)}return VA(r)}function Ij(e){var t=e.domain;return e.ticks=function(e){var n=t();return Ww(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return Fj(r[0],r[r.length-1],e??10,n)},e.nice=function(n){n??=10;var r=t(),i=0,a=r.length-1,o=r[i],s=r[a],c,l,u=10;for(s<o&&(l=o,o=s,s=l,l=i,i=a,a=l);u-->0;){if(l=Gw(o,s,n),l===c)return r[i]=o,r[a]=s,t(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;c=l}return e},e}function Lj(){var e=Pj();return e.copy=function(){return Mj(e,Lj())},vj.apply(e,arguments),Ij(e)}function Rj(e,t){e=e.slice();var n=0,r=e.length-1,i=e[n],a=e[r],o;return a<i&&(o=n,n=r,r=o,o=i,i=a,a=o),e[n]=t.floor(i),e[r]=t.ceil(a),e}var zj=new Date,Bj=new Date;function Vj(e,t,n,r){function i(t){return e(t=arguments.length===0?new Date:new Date(+t)),t}return i.floor=t=>(e(t=new Date(+t)),t),i.ceil=n=>(e(n=new Date(n-1)),t(n,1),e(n),n),i.round=e=>{let t=i(e),n=i.ceil(e);return e-t<n-e?t:n},i.offset=(e,n)=>(t(e=new Date(+e),n==null?1:Math.floor(n)),e),i.range=(n,r,a)=>{let o=[];if(n=i.ceil(n),a=a==null?1:Math.floor(a),!(n<r)||!(a>0))return o;let s;do o.push(s=new Date(+n)),t(n,a),e(n);while(s<n&&n<r);return o},i.filter=n=>Vj(t=>{if(t>=t)for(;e(t),!n(t);)t.setTime(t-1)},(e,r)=>{if(e>=e){if(r<0)for(;++r<=0;)for(;t(e,-1),!n(e););else for(;--r>=0;)for(;t(e,1),!n(e););}}),n&&(i.count=(t,r)=>(zj.setTime(+t),Bj.setTime(+r),e(zj),e(Bj),Math.floor(n(zj,Bj))),i.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?i.filter(r?t=>r(t)%e===0:t=>i.count(0,t)%e===0):i)),i}var Hj=Vj(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);Hj.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?Vj(t=>{t.setTime(Math.floor(t/e)*e)},(t,n)=>{t.setTime(+t+n*e)},(t,n)=>(n-t)/e):Hj),Hj.range;var Uj=1e3,Wj=Uj*60,Gj=Wj*60,Kj=Gj*24,qj=Kj*7,Jj=Kj*30,Yj=Kj*365,Xj=Vj(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*Uj)},(e,t)=>(t-e)/Uj,e=>e.getUTCSeconds());Xj.range;var Zj=Vj(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Uj)},(e,t)=>{e.setTime(+e+t*Wj)},(e,t)=>(t-e)/Wj,e=>e.getMinutes());Zj.range;var Qj=Vj(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*Wj)},(e,t)=>(t-e)/Wj,e=>e.getUTCMinutes());Qj.range;var $j=Vj(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Uj-e.getMinutes()*Wj)},(e,t)=>{e.setTime(+e+t*Gj)},(e,t)=>(t-e)/Gj,e=>e.getHours());$j.range;var eM=Vj(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*Gj)},(e,t)=>(t-e)/Gj,e=>e.getUTCHours());eM.range;var tM=Vj(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Wj)/Kj,e=>e.getDate()-1);tM.range;var nM=Vj(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Kj,e=>e.getUTCDate()-1);nM.range;var rM=Vj(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Kj,e=>Math.floor(e/Kj));rM.range;function iM(e){return Vj(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(e,t)=>{e.setDate(e.getDate()+t*7)},(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Wj)/qj)}var aM=iM(0),oM=iM(1),sM=iM(2),cM=iM(3),lM=iM(4),uM=iM(5),dM=iM(6);aM.range,oM.range,sM.range,cM.range,lM.range,uM.range,dM.range;function fM(e){return Vj(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t*7)},(e,t)=>(t-e)/qj)}var pM=fM(0),mM=fM(1),hM=fM(2),gM=fM(3),_M=fM(4),vM=fM(5),yM=fM(6);pM.range,mM.range,hM.range,gM.range,_M.range,vM.range,yM.range;var bM=Vj(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());bM.range;var xM=Vj(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());xM.range;var SM=Vj(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());SM.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Vj(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)}),SM.range;var CM=Vj(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());CM.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Vj(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)}),CM.range;function wM(e,t,n,r,i,a){let o=[[Xj,1,Uj],[Xj,5,5*Uj],[Xj,15,15*Uj],[Xj,30,30*Uj],[a,1,Wj],[a,5,5*Wj],[a,15,15*Wj],[a,30,30*Wj],[i,1,Gj],[i,3,3*Gj],[i,6,6*Gj],[i,12,12*Gj],[r,1,Kj],[r,2,2*Kj],[n,1,qj],[t,1,Jj],[t,3,3*Jj],[e,1,Yj]];function s(e,t,n){let r=t<e;r&&([e,t]=[t,e]);let i=n&&typeof n.range==`function`?n:c(e,t,n),a=i?i.range(e,+t+1):[];return r?a.reverse():a}function c(t,n,r){let i=Math.abs(n-t)/r,a=kw(([,,e])=>e).right(o,i);if(a===o.length)return e.every(Kw(t/Yj,n/Yj,r));if(a===0)return Hj.every(Math.max(Kw(t,n,r),1));let[s,c]=o[i/o[a-1][2]<o[a][2]/i?a-1:a];return s.every(c)}return[s,c]}var[TM,EM]=wM(CM,xM,pM,rM,eM,Qj),[DM,OM]=wM(SM,bM,aM,tM,$j,Zj);function kM(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function AM(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function jM(e,t,n){return{y:e,m:t,d:n,H:0,M:0,S:0,L:0}}function MM(e){var t=e.dateTime,n=e.date,r=e.time,i=e.periods,a=e.days,o=e.shortDays,s=e.months,c=e.shortMonths,l=RM(i),u=zM(i),d=RM(a),f=zM(a),p=RM(o),m=zM(o),h=RM(s),g=zM(s),_=RM(c),v=zM(c),y={a:N,A:P,b:F,B:I,c:null,d:oN,e:oN,f:dN,g:SN,G:wN,H:sN,I:cN,j:lN,L:uN,m:fN,M:pN,p:L,q:R,Q:qN,s:JN,S:mN,u:hN,U:gN,V:vN,w:yN,W:bN,x:null,X:null,y:xN,Y:CN,Z:TN,"%":KN},b={a:ee,A:te,b:ne,B:z,c:null,d:EN,e:EN,f:jN,g:HN,G:WN,H:DN,I:ON,j:kN,L:AN,m:MN,M:NN,p:re,q:ie,Q:qN,s:JN,S:PN,u:FN,U:IN,V:RN,w:zN,W:BN,x:null,X:null,y:VN,Y:UN,Z:GN,"%":KN},x={a:E,A:D,b:O,B:k,c:A,d:XM,e:XM,f:nN,g:KM,G:GM,H:QM,I:QM,j:ZM,L:tN,m:YM,M:$M,p:T,q:JM,Q:iN,s:aN,S:eN,u:VM,U:HM,V:UM,w:BM,W:WM,x:j,X:M,y:KM,Y:GM,Z:qM,"%":rN};y.x=S(n,y),y.X=S(r,y),y.c=S(t,y),b.x=S(n,b),b.X=S(r,b),b.c=S(t,b);function S(e,t){return function(n){var r=[],i=-1,a=0,o=e.length,s,c,l;for(n instanceof Date||(n=new Date(+n));++i<o;)e.charCodeAt(i)===37&&(r.push(e.slice(a,i)),(c=NM[s=e.charAt(++i)])==null?c=s===`e`?` `:`0`:s=e.charAt(++i),(l=t[s])&&(s=l(n,c)),r.push(s),a=i+1);return r.push(e.slice(a,i)),r.join(``)}}function C(e,t){return function(n){var r=jM(1900,void 0,1),i=w(r,e,n+=``,0),a,o;if(i!=n.length)return null;if(`Q`in r)return new Date(r.Q);if(`s`in r)return new Date(r.s*1e3+(`L`in r?r.L:0));if(t&&!(`Z`in r)&&(r.Z=0),`p`in r&&(r.H=r.H%12+r.p*12),r.m===void 0&&(r.m=`q`in r?r.q:0),`V`in r){if(r.V<1||r.V>53)return null;`w`in r||(r.w=1),`Z`in r?(a=AM(jM(r.y,0,1)),o=a.getUTCDay(),a=o>4||o===0?mM.ceil(a):mM(a),a=nM.offset(a,(r.V-1)*7),r.y=a.getUTCFullYear(),r.m=a.getUTCMonth(),r.d=a.getUTCDate()+(r.w+6)%7):(a=kM(jM(r.y,0,1)),o=a.getDay(),a=o>4||o===0?oM.ceil(a):oM(a),a=tM.offset(a,(r.V-1)*7),r.y=a.getFullYear(),r.m=a.getMonth(),r.d=a.getDate()+(r.w+6)%7)}else(`W`in r||`U`in r)&&(`w`in r||(r.w=`u`in r?r.u%7:+(`W`in r)),o=`Z`in r?AM(jM(r.y,0,1)).getUTCDay():kM(jM(r.y,0,1)).getDay(),r.m=0,r.d=`W`in r?(r.w+6)%7+r.W*7-(o+5)%7:r.w+r.U*7-(o+6)%7);return`Z`in r?(r.H+=r.Z/100|0,r.M+=r.Z%100,AM(r)):kM(r)}}function w(e,t,n,r){for(var i=0,a=t.length,o=n.length,s,c;i<a;){if(r>=o)return-1;if(s=t.charCodeAt(i++),s===37){if(s=t.charAt(i++),c=x[s in NM?t.charAt(i++):s],!c||(r=c(e,n,r))<0)return-1}else if(s!=n.charCodeAt(r++))return-1}return r}function T(e,t,n){var r=l.exec(t.slice(n));return r?(e.p=u.get(r[0].toLowerCase()),n+r[0].length):-1}function E(e,t,n){var r=p.exec(t.slice(n));return r?(e.w=m.get(r[0].toLowerCase()),n+r[0].length):-1}function D(e,t,n){var r=d.exec(t.slice(n));return r?(e.w=f.get(r[0].toLowerCase()),n+r[0].length):-1}function O(e,t,n){var r=_.exec(t.slice(n));return r?(e.m=v.get(r[0].toLowerCase()),n+r[0].length):-1}function k(e,t,n){var r=h.exec(t.slice(n));return r?(e.m=g.get(r[0].toLowerCase()),n+r[0].length):-1}function A(e,n,r){return w(e,t,n,r)}function j(e,t,r){return w(e,n,t,r)}function M(e,t,n){return w(e,r,t,n)}function N(e){return o[e.getDay()]}function P(e){return a[e.getDay()]}function F(e){return c[e.getMonth()]}function I(e){return s[e.getMonth()]}function L(e){return i[+(e.getHours()>=12)]}function R(e){return 1+~~(e.getMonth()/3)}function ee(e){return o[e.getUTCDay()]}function te(e){return a[e.getUTCDay()]}function ne(e){return c[e.getUTCMonth()]}function z(e){return s[e.getUTCMonth()]}function re(e){return i[+(e.getUTCHours()>=12)]}function ie(e){return 1+~~(e.getUTCMonth()/3)}return{format:function(e){var t=S(e+=``,y);return t.toString=function(){return e},t},parse:function(e){var t=C(e+=``,!1);return t.toString=function(){return e},t},utcFormat:function(e){var t=S(e+=``,b);return t.toString=function(){return e},t},utcParse:function(e){var t=C(e+=``,!0);return t.toString=function(){return e},t}}}var NM={"-":``,_:` `,0:`0`},PM=/^\s*\d+/,FM=/^%/,IM=/[\\^$*+?|[\]().{}]/g;function Z(e,t,n){var r=e<0?`-`:``,i=(r?-e:e)+``,a=i.length;return r+(a<n?Array(n-a+1).join(t)+i:i)}function LM(e){return e.replace(IM,`\\$&`)}function RM(e){return RegExp(`^(?:`+e.map(LM).join(`|`)+`)`,`i`)}function zM(e){return new Map(e.map((e,t)=>[e.toLowerCase(),t]))}function BM(e,t,n){var r=PM.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function VM(e,t,n){var r=PM.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function HM(e,t,n){var r=PM.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function UM(e,t,n){var r=PM.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function WM(e,t,n){var r=PM.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function GM(e,t,n){var r=PM.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function KM(e,t,n){var r=PM.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function qM(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||`00`)),n+r[0].length):-1}function JM(e,t,n){var r=PM.exec(t.slice(n,n+1));return r?(e.q=r[0]*3-3,n+r[0].length):-1}function YM(e,t,n){var r=PM.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function XM(e,t,n){var r=PM.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function ZM(e,t,n){var r=PM.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function QM(e,t,n){var r=PM.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function $M(e,t,n){var r=PM.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function eN(e,t,n){var r=PM.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function tN(e,t,n){var r=PM.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function nN(e,t,n){var r=PM.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function rN(e,t,n){var r=FM.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function iN(e,t,n){var r=PM.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function aN(e,t,n){var r=PM.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function oN(e,t){return Z(e.getDate(),t,2)}function sN(e,t){return Z(e.getHours(),t,2)}function cN(e,t){return Z(e.getHours()%12||12,t,2)}function lN(e,t){return Z(1+tM.count(SM(e),e),t,3)}function uN(e,t){return Z(e.getMilliseconds(),t,3)}function dN(e,t){return uN(e,t)+`000`}function fN(e,t){return Z(e.getMonth()+1,t,2)}function pN(e,t){return Z(e.getMinutes(),t,2)}function mN(e,t){return Z(e.getSeconds(),t,2)}function hN(e){var t=e.getDay();return t===0?7:t}function gN(e,t){return Z(aM.count(SM(e)-1,e),t,2)}function _N(e){var t=e.getDay();return t>=4||t===0?lM(e):lM.ceil(e)}function vN(e,t){return e=_N(e),Z(lM.count(SM(e),e)+(SM(e).getDay()===4),t,2)}function yN(e){return e.getDay()}function bN(e,t){return Z(oM.count(SM(e)-1,e),t,2)}function xN(e,t){return Z(e.getFullYear()%100,t,2)}function SN(e,t){return e=_N(e),Z(e.getFullYear()%100,t,2)}function CN(e,t){return Z(e.getFullYear()%1e4,t,4)}function wN(e,t){var n=e.getDay();return e=n>=4||n===0?lM(e):lM.ceil(e),Z(e.getFullYear()%1e4,t,4)}function TN(e){var t=e.getTimezoneOffset();return(t>0?`-`:(t*=-1,`+`))+Z(t/60|0,`0`,2)+Z(t%60,`0`,2)}function EN(e,t){return Z(e.getUTCDate(),t,2)}function DN(e,t){return Z(e.getUTCHours(),t,2)}function ON(e,t){return Z(e.getUTCHours()%12||12,t,2)}function kN(e,t){return Z(1+nM.count(CM(e),e),t,3)}function AN(e,t){return Z(e.getUTCMilliseconds(),t,3)}function jN(e,t){return AN(e,t)+`000`}function MN(e,t){return Z(e.getUTCMonth()+1,t,2)}function NN(e,t){return Z(e.getUTCMinutes(),t,2)}function PN(e,t){return Z(e.getUTCSeconds(),t,2)}function FN(e){var t=e.getUTCDay();return t===0?7:t}function IN(e,t){return Z(pM.count(CM(e)-1,e),t,2)}function LN(e){var t=e.getUTCDay();return t>=4||t===0?_M(e):_M.ceil(e)}function RN(e,t){return e=LN(e),Z(_M.count(CM(e),e)+(CM(e).getUTCDay()===4),t,2)}function zN(e){return e.getUTCDay()}function BN(e,t){return Z(mM.count(CM(e)-1,e),t,2)}function VN(e,t){return Z(e.getUTCFullYear()%100,t,2)}function HN(e,t){return e=LN(e),Z(e.getUTCFullYear()%100,t,2)}function UN(e,t){return Z(e.getUTCFullYear()%1e4,t,4)}function WN(e,t){var n=e.getUTCDay();return e=n>=4||n===0?_M(e):_M.ceil(e),Z(e.getUTCFullYear()%1e4,t,4)}function GN(){return`+0000`}function KN(){return`%`}function qN(e){return+e}function JN(e){return Math.floor(e/1e3)}var YN,XN;ZN({dateTime:`%x, %X`,date:`%-m/%-d/%Y`,time:`%-I:%M:%S %p`,periods:[`AM`,`PM`],days:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],shortDays:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],months:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],shortMonths:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`]});function ZN(e){return YN=MM(e),XN=YN.format,YN.parse,YN.utcFormat,YN.utcParse,YN}function QN(e){return new Date(e)}function $N(e){return e instanceof Date?+e:+new Date(+e)}function eP(e,t,n,r,i,a,o,s,c,l){var u=Pj(),d=u.invert,f=u.domain,p=l(`.%L`),m=l(`:%S`),h=l(`%I:%M`),g=l(`%I %p`),_=l(`%a %d`),v=l(`%b %d`),y=l(`%B`),b=l(`%Y`);function x(e){return(c(e)<e?p:s(e)<e?m:o(e)<e?h:a(e)<e?g:r(e)<e?i(e)<e?_:v:n(e)<e?y:b)(e)}return u.invert=function(e){return new Date(d(e))},u.domain=function(e){return arguments.length?f(Array.from(e,$N)):f().map(QN)},u.ticks=function(t){var n=f();return e(n[0],n[n.length-1],t??10)},u.tickFormat=function(e,t){return t==null?x:l(t)},u.nice=function(e){var n=f();return(!e||typeof e.range!=`function`)&&(e=t(n[0],n[n.length-1],e??10)),e?f(Rj(n,e)):u},u.copy=function(){return Mj(u,eP(e,t,n,r,i,a,o,s,c,l))},u}function tP(){return vj.apply(eP(DM,OM,SM,bM,aM,tM,$j,Zj,Xj,XN).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function nP(e){return function(){return e}}var rP=Math.abs,iP=Math.atan2,aP=Math.cos,oP=Math.max,sP=Math.min,cP=Math.sin,lP=Math.sqrt,uP=Math.PI,dP=uP/2,fP=2*uP;function pP(e){return e>1?0:e<-1?uP:Math.acos(e)}function mP(e){return e>=1?dP:e<=-1?-dP:Math.asin(e)}function hP(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{let e=Math.floor(n);if(!(e>=0))throw RangeError(`invalid digits: ${n}`);t=e}return e},()=>new SA(t)}function gP(e){return e.innerRadius}function _P(e){return e.outerRadius}function vP(e){return e.startAngle}function yP(e){return e.endAngle}function bP(e){return e&&e.padAngle}function xP(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=d*c-u*l;if(!(f*f<1e-12))return f=(u*(t-a)-d*(e-i))/f,[e+f*c,t+f*l]}function SP(e,t,n,r,i,a,o){var s=e-n,c=t-r,l=(o?a:-a)/lP(s*s+c*c),u=l*c,d=-l*s,f=e+u,p=t+d,m=n+u,h=r+d,g=(f+m)/2,_=(p+h)/2,v=m-f,y=h-p,b=v*v+y*y,x=i-a,S=f*h-m*p,C=(y<0?-1:1)*lP(oP(0,x*x*b-S*S)),w=(S*y-v*C)/b,T=(-S*v-y*C)/b,E=(S*y+v*C)/b,D=(-S*v+y*C)/b,O=w-g,k=T-_,A=E-g,j=D-_;return O*O+k*k>A*A+j*j&&(w=E,T=D),{cx:w,cy:T,x01:-u,y01:-d,x11:w*(i/x-1),y11:T*(i/x-1)}}function CP(){var e=gP,t=_P,n=nP(0),r=null,i=vP,a=yP,o=bP,s=null,c=hP(l);function l(){var l,u,d=+e.apply(this,arguments),f=+t.apply(this,arguments),p=i.apply(this,arguments)-dP,m=a.apply(this,arguments)-dP,h=rP(m-p),g=m>p;if(s||=l=c(),f<d&&(u=f,f=d,d=u),!(f>1e-12))s.moveTo(0,0);else if(h>fP-1e-12)s.moveTo(f*aP(p),f*cP(p)),s.arc(0,0,f,p,m,!g),d>1e-12&&(s.moveTo(d*aP(m),d*cP(m)),s.arc(0,0,d,m,p,g));else{var _=p,v=m,y=p,b=m,x=h,S=h,C=o.apply(this,arguments)/2,w=C>1e-12&&(r?+r.apply(this,arguments):lP(d*d+f*f)),T=sP(rP(f-d)/2,+n.apply(this,arguments)),E=T,D=T,O,k;if(w>1e-12){var A=mP(w/d*cP(C)),j=mP(w/f*cP(C));(x-=A*2)>1e-12?(A*=g?1:-1,y+=A,b-=A):(x=0,y=b=(p+m)/2),(S-=j*2)>1e-12?(j*=g?1:-1,_+=j,v-=j):(S=0,_=v=(p+m)/2)}var M=f*aP(_),N=f*cP(_),P=d*aP(b),F=d*cP(b);if(T>1e-12){var I=f*aP(v),L=f*cP(v),R=d*aP(y),ee=d*cP(y),te;if(h<uP){if(te=xP(M,N,R,ee,I,L,P,F)){var ne=M-te[0],z=N-te[1],re=I-te[0],ie=L-te[1],B=1/cP(pP((ne*re+z*ie)/(lP(ne*ne+z*z)*lP(re*re+ie*ie)))/2),ae=lP(te[0]*te[0]+te[1]*te[1]);E=sP(T,(d-ae)/(B-1)),D=sP(T,(f-ae)/(B+1))}else E=D=0}}S>1e-12?D>1e-12?(O=SP(R,ee,M,N,f,D,g),k=SP(I,L,P,F,f,D,g),s.moveTo(O.cx+O.x01,O.cy+O.y01),D<T?s.arc(O.cx,O.cy,D,iP(O.y01,O.x01),iP(k.y01,k.x01),!g):(s.arc(O.cx,O.cy,D,iP(O.y01,O.x01),iP(O.y11,O.x11),!g),s.arc(0,0,f,iP(O.cy+O.y11,O.cx+O.x11),iP(k.cy+k.y11,k.cx+k.x11),!g),s.arc(k.cx,k.cy,D,iP(k.y11,k.x11),iP(k.y01,k.x01),!g))):(s.moveTo(M,N),s.arc(0,0,f,_,v,!g)):s.moveTo(M,N),!(d>1e-12)||!(x>1e-12)?s.lineTo(P,F):E>1e-12?(O=SP(P,F,I,L,d,-E,g),k=SP(M,N,R,ee,d,-E,g),s.lineTo(O.cx+O.x01,O.cy+O.y01),E<T?s.arc(O.cx,O.cy,E,iP(O.y01,O.x01),iP(k.y01,k.x01),!g):(s.arc(O.cx,O.cy,E,iP(O.y01,O.x01),iP(O.y11,O.x11),!g),s.arc(0,0,d,iP(O.cy+O.y11,O.cx+O.x11),iP(k.cy+k.y11,k.cx+k.x11),g),s.arc(k.cx,k.cy,E,iP(k.y11,k.x11),iP(k.y01,k.x01),!g))):s.arc(0,0,d,b,y,g)}if(s.closePath(),l)return s=null,l+``||null}return l.centroid=function(){var n=(+e.apply(this,arguments)+ +t.apply(this,arguments))/2,r=(+i.apply(this,arguments)+ +a.apply(this,arguments))/2-uP/2;return[aP(r)*n,cP(r)*n]},l.innerRadius=function(t){return arguments.length?(e=typeof t==`function`?t:nP(+t),l):e},l.outerRadius=function(e){return arguments.length?(t=typeof e==`function`?e:nP(+e),l):t},l.cornerRadius=function(e){return arguments.length?(n=typeof e==`function`?e:nP(+e),l):n},l.padRadius=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:nP(+e),l):r},l.startAngle=function(e){return arguments.length?(i=typeof e==`function`?e:nP(+e),l):i},l.endAngle=function(e){return arguments.length?(a=typeof e==`function`?e:nP(+e),l):a},l.padAngle=function(e){return arguments.length?(o=typeof e==`function`?e:nP(+e),l):o},l.context=function(e){return arguments.length?(s=e??null,l):s},l}Array.prototype.slice;function wP(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function TP(e){this._context=e}TP.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t)}}};function EP(e){return new TP(e)}function DP(e){return e[0]}function OP(e){return e[1]}function kP(e,t){var n=nP(!0),r=null,i=EP,a=null,o=hP(s);e=typeof e==`function`?e:e===void 0?DP:nP(e),t=typeof t==`function`?t:t===void 0?OP:nP(t);function s(s){var c,l=(s=wP(s)).length,u,d=!1,f;for(r??(a=i(f=o())),c=0;c<=l;++c)!(c<l&&n(u=s[c],c,s))===d&&((d=!d)?a.lineStart():a.lineEnd()),d&&a.point(+e(u,c,s),+t(u,c,s));if(f)return a=null,f+``||null}return s.x=function(t){return arguments.length?(e=typeof t==`function`?t:nP(+t),s):e},s.y=function(e){return arguments.length?(t=typeof e==`function`?e:nP(+e),s):t},s.defined=function(e){return arguments.length?(n=typeof e==`function`?e:nP(!!e),s):n},s.curve=function(e){return arguments.length?(i=e,r!=null&&(a=i(r)),s):i},s.context=function(e){return arguments.length?(e==null?r=a=null:a=i(r=e),s):r},s}function AP(e,t,n){var r=null,i=nP(!0),a=null,o=EP,s=null,c=hP(l);e=typeof e==`function`?e:e===void 0?DP:nP(+e),t=typeof t==`function`?t:nP(t===void 0?0:+t),n=typeof n==`function`?n:n===void 0?OP:nP(+n);function l(l){var u,d,f,p=(l=wP(l)).length,m,h=!1,g,_=Array(p),v=Array(p);for(a??(s=o(g=c())),u=0;u<=p;++u){if(!(u<p&&i(m=l[u],u,l))===h){if(h=!h)d=u,s.areaStart(),s.lineStart();else{for(s.lineEnd(),s.lineStart(),f=u-1;f>=d;--f)s.point(_[f],v[f]);s.lineEnd(),s.areaEnd()}}h&&(_[u]=+e(m,u,l),v[u]=+t(m,u,l),s.point(r?+r(m,u,l):_[u],n?+n(m,u,l):v[u]))}if(g)return s=null,g+``||null}function u(){return kP().defined(i).curve(o).context(a)}return l.x=function(t){return arguments.length?(e=typeof t==`function`?t:nP(+t),r=null,l):e},l.x0=function(t){return arguments.length?(e=typeof t==`function`?t:nP(+t),l):e},l.x1=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:nP(+e),l):r},l.y=function(e){return arguments.length?(t=typeof e==`function`?e:nP(+e),n=null,l):t},l.y0=function(e){return arguments.length?(t=typeof e==`function`?e:nP(+e),l):t},l.y1=function(e){return arguments.length?(n=e==null?null:typeof e==`function`?e:nP(+e),l):n},l.lineX0=l.lineY0=function(){return u().x(e).y(t)},l.lineY1=function(){return u().x(e).y(n)},l.lineX1=function(){return u().x(r).y(t)},l.defined=function(e){return arguments.length?(i=typeof e==`function`?e:nP(!!e),l):i},l.curve=function(e){return arguments.length?(o=e,a!=null&&(s=o(a)),l):o},l.context=function(e){return arguments.length?(e==null?a=s=null:s=o(a=e),l):a},l}function jP(e){return e<0?-1:1}function MP(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),s=(a*i+o*r)/(r+i);return(jP(a)+jP(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function NP(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function PP(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,s=(a-r)/3;e._context.bezierCurveTo(r+s,i+s*t,a-s,o-s*n,a,o)}function FP(e){this._context=e}FP.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:PP(this,this._t0,NP(this,this._t0))}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,e!==this._x1||t!==this._y1){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,PP(this,NP(this,n=MP(this,e,t)),n);break;default:PP(this,this._t0,n=MP(this,e,t))}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}},Object.create(FP.prototype).point=function(e,t){FP.prototype.point.call(this,t,e)};function IP(e){return new FP(e)}function LP(e,t){this._context=e,this._t=t}LP.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}}this._x=e,this._y=t}};function RP(e){return new LP(e,1)}function zP(e,t,n){this.k=e,this.x=t,this.y=n}zP.prototype={constructor:zP,scale:function(e){return e===1?this:new zP(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new zP(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var BP=new zP(1,0,0);VP.prototype=zP.prototype;function VP(e){for(;!e.__zoom;)if(!(e=e.parentNode))return BP;return e.__zoom}function HP(e,t=15){let n=e.split(` `),r=[],i=[],a=0;return n.forEach(e=>{a+e.length>t?(i.length&&r.push(i.join(` `)),i=[e],a=e.length):(i.push(e),a+=e.length+ +(i.length>0))}),i.length&&r.push(i.join(` `)),r}var UP={DECISIVE:20,ROUTINE:50},WP=new Set([`WALKOVER`,`DOUBLE_WALKOVER`,`DEFAULTED`,`DOUBLE_DEFAULT`]),GP={COMPETITIVE:`#16a34a`,ROUTINE:`#3b82f6`,DECISIVE:`#8e44ad`,WALKOVER:`#6b7280`},KP=`#cfd8dc`,qP=`COMPETITIVE`,JP=`ROUTINE`,YP=`DECISIVE`,XP=`WALKOVER`;function ZP(e,t=UP){if(!e?.length)return;let n=[0,0],r=[0,0];for(let t of e)n[0]+=t.side1Score||0,n[1]+=t.side2Score||0,r[0]+=t.side1TiebreakScore||0,r[1]+=t.side2TiebreakScore||0;r[0]+r[1]&&(n[r[0]>r[1]?0:1]+=1);let i=Math.max(n[0],n[1]);if(i===0)return;let a=Math.round(Math.min(n[0],n[1])/i*100);return Number.isNaN(a)?XP:a<=t.DECISIVE?YP:a<=t.ROUTINE?JP:qP}function QP(e,n=UP){if(e)return ZP(t.scoreGovernor.parseScoreString({scoreString:e}),n)}function $P({winningSide:e,matchUpStatus:t,sets:n,scoreString:r,bands:i}){if(t&&WP.has(t))return XP;if(e)return n?.length?ZP(n,i):QP(r,i)}function eF(e,t){return e?t?.[e]??GP[e]:KP}var{WILDCARD:tF,QUALIFIER:nF,LUCKY_LOSER:rF}=t.entryStatusConstants,iF=`text-anchor`,aF=`dominant-baseline`,oF=`fill-opacity`,sF=Object.assign({},...t.fixtures.countries.filter(e=>e.ioc).map(e=>({[e.ioc]:e.iso2})),...t.fixtures.countries.filter(e=>e.iso).map(e=>({[e.iso]:e.iso2})));function cF(e){let t=Math.floor(e.length/2),n=e.slice(0,t),r=e.slice(t).reverse();return[...n,...r]}function lF(e){if(e)switch(e){case tF:return`WC`;case nF:return`Q`;case rF:return`LL`;default:return e}}function uF(e,t){let n=[];for(let r of e)for(let e of r.sides){let i=r.matchUpStatus===`BYE`&&!e.participantName;n.push({name:e.participantName||(i?`BYE`:``),participantName:e.participantName||(i?`BYE`:void 0),drawPosition:e.drawPosition,seedNumber:e.seedNumber,entryStatus:lF(e.entryStatus),nationalityCode:e.nationalityCode,matchUp:r,depth:t,value:1})}return n}function dF(e,t){let n=e.winningSide!==void 0&&e.winningSide!==null?e.sides.find(t=>t.sideNumber===e.winningSide):void 0;!n&&e.matchUpStatus===`BYE`&&(n=e.sides.find(e=>e.participantName));let r=n?.participantName,i=r?t.get(r):void 0;return{winnerName:r,winnerSide:n,winnerLookup:i}}function fF(e,t,n,r){return e.map((e,i)=>{let a=i*2,o=[t[a],t[a+1]].filter(Boolean),{winnerName:s,winnerSide:c,winnerLookup:l}=dF(e,r);return{name:s||``,participantName:s,drawPosition:l?.drawPosition??c?.drawPosition,seedNumber:c?.seedNumber??l?.seedNumber,entryStatus:lF(c?.entryStatus)??l?.entryStatus,nationalityCode:c?.nationalityCode??l?.nationalityCode,scoreString:e.scoreString,matchUpStatus:e.matchUpStatus,competitiveness:e.competitiveness,matchUp:e,depth:n,children:o.length>0?o:void 0}})}function pF(e){let{roundMatchUps:t}=e,n=Object.keys(t).map(Number).sort((e,t)=>e-t);if(n.length===0)throw Error(`No round data found in draw`);let r=t[n[0]],i=cF(uF(r,n.length)),a=new Map;for(let e of i)e.participantName&&e.participantName!==`BYE`&&a.set(e.participantName,e);let o=fF(cF(r),i,n.length-1,a);for(let e=1;e<n.length;e++)o=fF(cF(t[n[e]]),o,n.length-1-e,a);return o.length===1?o[0]:{name:`Tournament`,depth:0,children:o}}function mF(e,t){if(!e)return;let{seedNumber:n,entryStatus:r,drawPosition:i,participantName:a}=e,o;if(a?.trim().toUpperCase()===`BYE`)o=`#B0BEC5`;else if(n){let e=Number(n),t=Lj().domain([1,32]).range([`0`,`1`]);o=Lj().domain(Jw(0,1,1/7)).range([`#81D4FA`,`#42A5F5`,`#1E88E5`,`#1565C0`,`#5C6BC0`,`#673AB7`,`#9C27B0`])(Number(t(e)))}else if(r?.toUpperCase()===`WC`)o=`red`;else if(r&&(r===`Q`||r===`LL`))o=Lj().domain(Jw(0,1,1/3)).range([`#FFF176`,`#FBC02D`,`#FF9800`])(t(i));else{let e=[`#C8E6C9`,`#81C784`,`#66BB6A`,`#4CAF50`,`#43A047`,`#388E3C`,`#2E7D32`,`#1B5E20`,`#A5D6A7`,`#90CAF9`,`#64B5F6`,`#42A5F5`,`#2196F3`,`#1E88E5`,`#1976D2`,`#1565C0`];o=Lj().domain(Jw(0,1,1/e.length)).range(e)(t(i))}e.color=o,e.children&&e.children.forEach(n=>{n.participantName===e.participantName&&(n.color=o),mF(n,t)})}function hF(e,t){e&&(e.competitivenessColor=e.children?.length&&e.competitiveness?eF(e.competitiveness,t):KP,e.children?.forEach(e=>hF(e,t)))}function gF(e,t){let n=[];return e.seedNumber?n.push(`Seed ${e.seedNumber}`):e.entryStatus&&n.push(e.entryStatus),t===7&&e.drawPosition&&n.push(`Draw ${e.drawPosition}`),n.length>0?n.join(` • `):void 0}function _F(e,t){let n=e.find(e=>e.data.participantName&&e.data.participantName!==t);return n?.data.participantName?n.data:void 0}function vF(e,t){let n=[e.participantName],r;if(t.children&&t.children.length>0)e.scoreString&&n.push(e.scoreString),r=_F(t.children,e.participantName),r&&n.push(r.participantName);else{let r=gF(e,t.depth);r&&n.push(r)}return{messageLines:n,opponentData:r}}function yF(e,t){return-(e*t/2)+t/2}function bF(e,t,n){let r=pD(e).append(`svg`).attr(`width`,t).attr(`height`,n).style(`display`,`block`),i=r.append(`g`).attr(`transform`,`translate(${t/2}, ${n/2})`);return{svg:r,g:i,flagsGroup:i.append(`g`).attr(`class`,`flags-group`),winningFlagsGroup:i.append(`g`).attr(`class`,`winning-flags-group`),losingFlagsGroup:i.append(`g`).attr(`class`,`losing-flags-group`)}}function xF(e,t,n,r,i){let a=e.append(`text`).attr(`x`,t/2).attr(`y`,n/2).attr(iF,`middle`).attr(aF,`middle`).attr(`font-size`,`${r}px`).attr(`font-weight`,`bold`).style(`fill`,`var(--chc-text-primary, #333)`).attr(`pointer-events`,`none`),o=r+i*.5;return{centerText:a,centerText2:e.append(`text`).attr(`x`,t/2).attr(`y`,n/2+o).attr(iF,`middle`).attr(aF,`middle`).attr(`font-size`,`${i}px`).style(`fill`,`var(--chc-text-secondary, #666)`).attr(`pointer-events`,`none`)}}function SF(e,t,n,r,i,a,o){n&&(i?(t.flagsGroup.selectAll(`text`).remove(),t.winningFlagsGroup.selectAll(`text`).remove(),t.losingFlagsGroup.selectAll(`text`).remove()):e.selectAll(`text`).remove(),e.append(`text`).attr(`font-size`,`${o}px`).attr(iF,`middle`).attr(aF,`middle`).attr(`transform`,`translate(0, ${r*a})`).text(EF(n)))}function CF(e,n,r,i={}){let a=i.width||800,o=i.height||800,s=Math.min(a,o)/800*(i.textScaleFactor??1),c=28*s,l=24*s,u=30*s,d=r||i.title||`Tournament`,f=Object.assign({},...t.fixtures.countries.filter(e=>e.label).map(e=>({[e.ioc]:e.label})));if(!Object.keys(n?.roundMatchUps??{}).length)return{highlightPlayer:()=>0,hide:()=>void 0,setColorMode:()=>void 0};let p=pF(n),m=cj(p,e=>e.children).sum(e=>e.value||0),h=Math.min(a,o)/2,g=h/2,_=e=>e*h/200;_j().size([2*Math.PI,h-g])(m),mF(p,Lj().domain([0,n.drawSize||128]).range([0,1])),hF(p,i.competitivenessColors);let v=i.colorMode??`default`,y=e=>v===`competitiveness`?e.competitivenessColor||`#cfd8dc`:e.color||`#ccc`,b=m.descendants(),x=CP().startAngle(e=>e.x0).endAngle(e=>e.x1).innerRadius(e=>e.y0+g).outerRadius(e=>e.y1+g),{svg:S,g:C,flagsGroup:w,winningFlagsGroup:T,losingFlagsGroup:E}=bF(e,a,o),D=new Set,O=e=>{e.nationalityCode&&D.add(e.nationalityCode),e.children&&e.children.forEach(O)};O(p);let k=Array.from(D),{centerText:A,centerText2:j}=xF(S,a,o,c,l);function M(){let e=HP(d,15);A.text(``),A.selectAll(`tspan`).remove(),j.text(``),j.selectAll(`tspan`).remove(),A.selectAll(`tspan`).data(e).join(`tspan`).attr(`x`,a/2).attr(`dy`,(e,t)=>t===0?0:u).text(e=>e);let t=-(e.length*u/2)+u/2;A.attr(`y`,o/2+t),A.style(`display`,`block`),j.style(`display`,`none`)}function N(){if(w.selectAll(`text`).remove(),T.selectAll(`text`).remove(),E.selectAll(`text`).remove(),k.length===0)return;let e=Lj().domain([0,k.length]).range([0,Math.PI*2]),t=_(20),n=g-t+10;w.selectAll(`text`).data(k).join(`text`).attr(`font-size`,`${t}px`).attr(iF,`middle`).attr(aF,`middle`).attr(`transform`,(t,r)=>{let i=e(r);return`translate(${Math.cos(i)*n}, ${Math.sin(i)*n})`}).text(e=>EF(e)).style(`cursor`,`pointer`).on(`mouseover`,function(e,t){let n=f[t]||t;A.selectAll(`tspan`).remove(),A.attr(`y`,o/2),A.text(n).style(`display`,`block`),j.selectAll(`tspan`).remove(),j.text(``).style(`display`,`none`),F||C.selectAll(`path`).attr(oF,e=>e.data.nationalityCode===t?.9:.3)}).on(`mouseout`,function(){F||C.selectAll(`path`).attr(oF,.8),M()})}N(),M();let P=i.eventHandlers?.clickCenter;P&&C.insert(`circle`,`:first-child`).attr(`r`,g).attr(`fill`,`transparent`).style(`cursor`,`pointer`).on(`click`,P);let F=!1,I;function L(e,t){let n=t.data;if(n.participantName){let{messageLines:e,opponentData:r}=vF(n,t);r&&(n.opponent=r),A.selectAll(`tspan`).remove(),A.text(``),A.selectAll(`tspan`).data(e).join(`tspan`).attr(`x`,a/2).attr(`dy`,(e,t)=>t===0?0:u).text(e=>e);let i=yF(e.length,u);A.attr(`y`,o/2+i),A.style(`display`,`block`),j.style(`display`,`none`)}F?n.participantName?.toLowerCase()!==I?.toLowerCase()&&pD(e.currentTarget).attr(oF,.9):C.selectAll(`path`).attr(oF,e=>e.data.participantName===t.data.participantName?.9:.3);let r=_(30),i=g-r-10,s={flagsGroup:w,winningFlagsGroup:T,losingFlagsGroup:E};SF(T,s,n.nationalityCode,-1,!0,i,r),n.opponent&&SF(E,s,n.opponent.nationalityCode,1,!1,i,r)}function R(e,t){if(F){let n=t.data.participantName?.toLowerCase()===I?.toLowerCase();pD(e.currentTarget).attr(oF,n?1:.2)}else C.selectAll(`path`).attr(oF,.8);N(),M()}let ee=i.eventHandlers?.clickSegment;function te(e,t){if(!ee)return;let n=t.data;ee({participantName:n.participantName,drawPosition:n.drawPosition,seedNumber:n.seedNumber,entryStatus:n.entryStatus,nationalityCode:n.nationalityCode,scoreString:n.scoreString,matchUpStatus:n.matchUpStatus,competitiveness:n.competitiveness,roundName:n.roundName,depth:n.depth,matchUp:n.matchUp})}let ne=C.selectAll(`path`).data(b).join(`path`).attr(`d`,e=>x(e)).attr(`fill`,e=>y(e.data)).attr(oF,.8).attr(`stroke`,`#fff`).attr(`stroke-width`,1).on(`mouseover`,L).on(`mouseout`,R);ee&&ne.style(`cursor`,`pointer`).on(`click`,te),ne.append(`title`).text(e=>{let t=e.data;if(t.participantName){let e=[t.participantName,`Draw: ${t.drawPosition||`N/A`}`];return t.competitiveness&&e.push(`Competitiveness: ${t.competitiveness}`),e.join(`
214
+ `,`2) content: () => element.cloneNode(true)`].join(` `))}var s=i.reduce(function(e,t){var n=t&&Oh(t,r);return n&&e.push(n),e},[]);return Rm(e)?s[0]:s}kh.defaultProps=fh,kh.setDefaultProps=mh,kh.currentInput=Ym,Object.assign({},Uf,{effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:`0`,top:`0`,margin:`0`},arrow:{position:`absolute`},reference:{}};Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow)}}),kh.setDefaultProps({render:wh});var Ah=`#000000.#434343.#666666.#999999.#b7b7b7.#cccccc.#d9d9d9.#ffffff.#980000.#ff0000.#ff9900.#ffff00.#00ff00.#00ffff.#4a86e8.#0000ff.#9900ff.#ff00ff.#e6b8af.#f4cccc.#fce5cd.#fff2cc.#d9ead3.#d0e0e3.#c9daf8.#cfe2f3.#d9d2e9.#ead1dc`.split(`.`),jh=`notes-toolbar-recent-colors`,Mh=8;function Nh(){try{return JSON.parse(localStorage.getItem(jh)||`[]`)}catch{return[]}}function Ph(e){let t=Nh().filter(t=>t!==e);t.unshift(e),t.length>Mh&&(t=t.slice(0,Mh)),localStorage.setItem(jh,JSON.stringify(t))}function Fh(e={}){let t=document.createElement(`div`);return t.className=`notes-toolbar`,t.appendChild(Bh(e)),t.appendChild(Vh(e)),t.appendChild(Hh(e)),t.appendChild(Kh(e)),t.appendChild(Yh(e)),t.appendChild(Xh(e)),t.appendChild(Qh(e)),t}function Ih(e,t){for(let[n,r]of Object.entries(t)){let t=e.querySelector(`[data-action="${n}"]`);t&&t.classList.toggle(`is-active`,r)}}function Lh(e,t){let n=e.querySelector(`[data-action="heading"]`);n&&(n.value=t===!1?`0`:String(t))}function Rh(){let e=document.createElement(`div`);return e.className=`notes-toolbar-group`,e}function zh(e,t,n,r){let i=document.createElement(`button`);return i.className=`notes-toolbar-btn`,i.dataset.action=e,i.title=n,i.type=`button`,i.innerHTML=t,r&&i.addEventListener(`click`,r),i}function Bh(e){let t=Rh(),n=document.createElement(`select`);n.dataset.action=`heading`,n.title=`Text style`;for(let e of[{value:`0`,label:`Paragraph`},{value:`1`,label:`Heading 1`},{value:`2`,label:`Heading 2`},{value:`3`,label:`Heading 3`},{value:`4`,label:`Heading 4`},{value:`5`,label:`Heading 5`},{value:`6`,label:`Heading 6`}]){let t=document.createElement(`option`);t.value=e.value,t.textContent=e.label,n.appendChild(t)}return n.addEventListener(`change`,()=>{let t=parseInt(n.value,10);e.onHeading?.(t!==0&&t)}),t.appendChild(n),t}function Vh(e){let t=Rh();return t.appendChild(zh(`bold`,`<b>B</b>`,`Bold`,e.onBold)),t.appendChild(zh(`italic`,`<i>I</i>`,`Italic`,e.onItalic)),t.appendChild(zh(`underline`,`<u>U</u>`,`Underline`,e.onUnderline)),t.appendChild(zh(`strike`,`<s>S</s>`,`Strikethrough`,e.onStrike)),t}function Hh(e){let t=Rh();return t.appendChild(Uh(`color`,`A`,`Text color`,`#000000`,t=>{Ph(t),e.onColor?.(t)})),t.appendChild(Uh(`background`,`A`,`Background color`,`#ffff00`,t=>{Ph(t),e.onBackground?.(t)})),t}function Uh(e,t,n,r,i){let a=document.createElement(`button`);a.className=`notes-toolbar-btn notes-toolbar-color-btn`,a.dataset.action=e,a.title=n,a.type=`button`;let o=document.createElement(`span`);o.className=`notes-toolbar-color-letter`,o.textContent=t,a.appendChild(o);let s=document.createElement(`span`);s.className=`notes-toolbar-color-bar`,s.style.backgroundColor=r,a.appendChild(s);let c;return a.addEventListener(`click`,()=>{if(c){c.destroy(),c=void 0;return}let e=Wh(r,e=>{s.style.backgroundColor=e,i(e),c?.destroy(),c=void 0});c=kh(a,{content:e,theme:`light-border`,trigger:`manual`,interactive:!0,placement:`bottom-start`,onHidden:()=>{c?.destroy(),c=void 0}}),c.show()}),a}function Wh(e,t){let n=document.createElement(`div`);n.className=`notes-color-panel`;let r=document.createElement(`div`);r.className=`notes-color-swatches`;for(let n of Ah)r.appendChild(Gh(n,n===e,t));n.appendChild(r);let i=Nh();if(i.length){let r=document.createElement(`div`);r.className=`notes-color-section-label`,r.textContent=`Recent`,n.appendChild(r);let a=document.createElement(`div`);a.className=`notes-color-swatches`;for(let n of i)a.appendChild(Gh(n,n===e,t));n.appendChild(a)}let a=document.createElement(`div`);a.className=`notes-color-custom-row`;let o=document.createElement(`input`);o.type=`color`,o.value=e,o.className=`notes-color-custom-input`;let s=document.createElement(`label`);return s.className=`notes-color-custom-label`,s.textContent=`Custom...`,s.addEventListener(`click`,()=>o.click()),o.addEventListener(`input`,()=>t(o.value)),a.appendChild(o),a.appendChild(s),n.appendChild(a),n}function Gh(e,t,n){let r=document.createElement(`button`);return r.type=`button`,r.className=`notes-color-swatch`,t&&r.classList.add(`is-selected`),r.style.backgroundColor=e,(e===`#ffffff`||e===`#fff`)&&(r.style.border=`1px solid var(--chc-border-secondary)`),r.title=e,r.addEventListener(`click`,()=>n(e)),r}function Kh(e){let t=Rh();return t.appendChild(zh(`orderedList`,qh(16,16,`<path d="M3 2h12v2H3zm0 5h12v2H3zm0 5h12v2H3z" fill="currentColor"/><text x="0" y="4" font-size="3.5" fill="currentColor">1</text><text x="0" y="9" font-size="3.5" fill="currentColor">2</text><text x="0" y="14" font-size="3.5" fill="currentColor">3</text>`),`Ordered list`,e.onOrderedList)),t.appendChild(zh(`bulletList`,qh(16,16,`<circle cx="1.5" cy="3" r="1.5" fill="currentColor"/><circle cx="1.5" cy="8" r="1.5" fill="currentColor"/><circle cx="1.5" cy="13" r="1.5" fill="currentColor"/><path d="M5 2h10v2H5zm0 5h10v2H5zm0 5h10v2H5z" fill="currentColor"/>`),`Bullet list`,e.onBulletList)),t}function qh(e,t,n){return`<svg width="${e}" height="${t}" viewBox="0 0 ${e} ${t}" xmlns="http://www.w3.org/2000/svg">${n}</svg>`}var Jh={alignLeft:qh(16,16,`<path d="M1 2h14v2H1zm0 4h9v2H1zm0 4h14v2H1zm0 4h9v2H1z" fill="currentColor"/>`),alignCenter:qh(16,16,`<path d="M1 2h14v2H1zm3.5 4h7v2h-7zM1 10h14v2H1zm3.5 4h7v2h-7z" fill="currentColor"/>`),alignRight:qh(16,16,`<path d="M1 2h14v2H1zm6 4h8v2H7zM1 10h14v2H1zm6 4h8v2H7z" fill="currentColor"/>`),alignJustify:qh(16,16,`<path d="M1 2h14v2H1zm0 4h14v2H1zm0 4h14v2H1zm0 4h14v2H1z" fill="currentColor"/>`)};function Yh(e){let t=Rh();return t.appendChild(zh(`alignLeft`,Jh.alignLeft,`Align left`,()=>e.onAlign?.(`left`))),t.appendChild(zh(`alignCenter`,Jh.alignCenter,`Align center`,()=>e.onAlign?.(`center`))),t.appendChild(zh(`alignRight`,Jh.alignRight,`Align right`,()=>e.onAlign?.(`right`))),t.appendChild(zh(`alignJustify`,Jh.alignJustify,`Justify`,()=>e.onAlign?.(`justify`))),t}function Xh(e){let t=Rh();t.appendChild(zh(`blockquote`,`“`,`Blockquote`,e.onBlockquote)),t.appendChild(zh(`codeBlock`,`</>`,`Code block`,e.onCodeBlock));let n=zh(`link`,`⇗`,`Insert link`);Zh(n,`Enter URL`,`https://`,t=>e.onLink?.(t)),t.appendChild(n);let r=zh(`video`,`▷`,`Insert video`);return Zh(r,`YouTube URL`,`https://youtube.com/...`,t=>e.onVideo?.(t)),t.appendChild(r),t}function Zh(e,t,n,r){let i;e.addEventListener(`click`,()=>{if(i){i.destroy(),i=void 0;return}let a=document.createElement(`div`);a.className=`notes-url-panel`;let o=document.createElement(`div`);o.className=`notes-url-label`,o.textContent=t,a.appendChild(o);let s=document.createElement(`input`);s.type=`url`,s.className=`notes-url-input`,s.placeholder=n,a.appendChild(s);let c=document.createElement(`div`);c.className=`notes-url-actions`;let l=document.createElement(`button`);l.type=`button`,l.className=`button notes-url-cancel`,l.textContent=`Cancel`,l.addEventListener(`click`,()=>{i?.destroy(),i=void 0});let u=document.createElement(`button`);u.type=`button`,u.className=`button is-info notes-url-confirm`,u.textContent=`Insert`,u.addEventListener(`click`,()=>{let e=s.value.trim();e&&r(e),i?.destroy(),i=void 0}),c.appendChild(l),c.appendChild(u),a.appendChild(c),s.addEventListener(`keydown`,e=>{e.key===`Enter`?(e.preventDefault(),u.click()):e.key===`Escape`&&l.click()}),i=kh(e,{content:a,theme:`light-border`,trigger:`manual`,interactive:!0,placement:`bottom-start`,onShown:()=>setTimeout(()=>s.focus(),0),onHidden:()=>{i?.destroy(),i=void 0}}),i.show()})}function Qh(e){let t=Rh();return t.appendChild(zh(`clearFormatting`,`⊘`,`Clear formatting`,e.onClearFormatting)),t}function $h(e={}){let t=document.createElement(`div`);t.className=`notes-editor-content`;let l={toolbar:void 0,editorElement:t,editor:void 0,getHtml:()=>l.editor&&!l.editor.isEmpty?l.editor.getHTML():``,isEmpty:()=>!l.editor||l.editor.isEmpty,destroy:()=>{l.editor?.destroy(),l.editor=void 0}};l.toolbar=Fh({onHeading:e=>{l.editor&&(e===!1?l.editor.chain().focus().setParagraph().run():l.editor.chain().focus().toggleHeading({level:e}).run())},onBold:()=>l.editor?.chain().focus().toggleBold().run(),onItalic:()=>l.editor?.chain().focus().toggleItalic().run(),onUnderline:()=>l.editor?.chain().focus().toggleUnderline().run(),onStrike:()=>l.editor?.chain().focus().toggleStrike().run(),onColor:e=>l.editor?.chain().focus().setColor(e).run(),onBackground:e=>l.editor?.chain().focus().setHighlight({color:e}).run(),onBulletList:()=>l.editor?.chain().focus().toggleBulletList().run(),onOrderedList:()=>l.editor?.chain().focus().toggleOrderedList().run(),onAlign:e=>l.editor?.chain().focus().setTextAlign(e).run(),onBlockquote:()=>l.editor?.chain().focus().toggleBlockquote().run(),onCodeBlock:()=>l.editor?.chain().focus().toggleCodeBlock().run(),onLink:e=>l.editor?.chain().focus().setLink({href:e}).run(),onVideo:e=>l.editor?.commands.setYoutubeVideo({src:e}),onClearFormatting:()=>l.editor?.chain().focus().clearNodes().unsetAllMarks().run()});let u=()=>{if(l.editor){Ih(l.toolbar,{bold:l.editor.isActive(`bold`),italic:l.editor.isActive(`italic`),underline:l.editor.isActive(`underline`),strike:l.editor.isActive(`strike`),orderedList:l.editor.isActive(`orderedList`),bulletList:l.editor.isActive(`bulletList`),blockquote:l.editor.isActive(`blockquote`),codeBlock:l.editor.isActive(`codeBlock`),alignLeft:l.editor.isActive({textAlign:`left`}),alignCenter:l.editor.isActive({textAlign:`center`}),alignRight:l.editor.isActive({textAlign:`right`}),alignJustify:l.editor.isActive({textAlign:`justify`})});for(let e=1;e<=6;e++)if(l.editor.isActive(`heading`,{level:e})){Lh(l.toolbar,e);return}Lh(l.toolbar,!1)}};return requestAnimationFrame(()=>{l.editor=new r.Editor({element:t,extensions:[o.default,i.TextStyle,n.Color,a.default.configure({multicolor:!0}),s.default.configure({types:[`heading`,`paragraph`]}),c.default.configure({inline:!1})],content:e.initialHtml||``,onSelectionUpdate:u,onTransaction:u})}),l}function eg(e,t,n){if(!e)return{};let r=document.createElement(`aside`);r.classList.add(`menu`);let i={},a=e=>n&&e.close!==!1?t=>{t.stopPropagation(),n(),e.onClick()}:t=>{t.stopPropagation(),e.onClick()},o=0,s=()=>(o+=1,o),c=e=>e?.heading||e?.text||e?.label||`Item ${s()}`,l=e=>{let t=document.createElement(`li`);if(t.className=`font-medium`,e.style&&(t.style.cssText=e.style),e.onClick){let n=e.fontSize||`1em`;if(e.divider){let e=document.createElement(`hr`);e.classList.add(`dropdown-divider`),t.appendChild(e)}else{let r=document.createElement(`a`),i=e.disabled?`0.4`:`1`;r.style.cssText=`text-decoration: none; opacity: ${i}; font-size: ${n}`,e.class&&r.classList.add(e.class),e.color&&(r.style.color=e.color),e.heading&&(r.style.fontWeight=`bold`),e.disabled||(r.onclick=a(e)),r.innerHTML=c(e),t.appendChild(r)}}else t.innerHTML=c(e),e.disabled||(t.onclick=e.onClick);return t},u;for(let e of t||[])if(!e.hide){if(e.items){if(e.text){let t=document.createElement(`p`);t.className=`menu-label font-medium`,t.innerHTML=e.text,r.appendChild(t)}let t=document.createElement(`ul`);t.className=`menu-list`;for(let n of e.items)n.hide||t.appendChild(l(n));r.appendChild(t)}else if(e.type===`input`){let{field:t,inputElement:n}=_n(e);e.focus&&(u=n),i[e.field]=n,r.appendChild(t)}else if(e.type===`divider`){let e=document.createElement(`hr`);e.classList.add(`dropdown-divider`),r.appendChild(e)}}return e.appendChild(r),{focusElement:u}}function tg(e){return typeof e==`function`}var ng;function rg(e){ng&&=(ng?.destroy(!0),void 0),e?.remove&&e.remove()}function ig(e){let{title:t,options:n,menuItems:r=[],coords:i,callback:a,config:o}=e,{target:s,items:c}=e;if(!n?.length&&!c?.length&&!r)return;rg();let l=document.createElement(`div`),u;return s||=i?.evt?.target,s&&(ng=kh(s,{content:()=>{c=c?.filter(e=>!e.hide&&!e.disabled).map(e=>({...e,onClick:()=>{rg(l),tg(e.onClick)&&e.onClick()}}))||n?.filter(e=>!e.hide&&!e.disabled).map(e=>({text:typeof e==`object`?e.option:e,style:e.style,onClick:()=>{e.subMenu?ng.setContent(`IMPLEMENT SUB MENU`):tg(e.onClick)?(rg(l),e.onClick()):tg(a)&&a&&(rg(l),a(typeof e==`object`?{...e,coords:i}:e))}}));let e=[{text:t,items:c},...r];return u=eg(l,e).focusElement,l},theme:`light-border`,trigger:`click`,onShown:()=>{u&&setTimeout(()=>u?.focus(),0)},...o}),ng.show(),ng.setProps({interactive:!0})),ng}var Y=`court-line`;function X(e,t){let n=document.createElementNS(`http://www.w3.org/2000/svg`,e);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);return n}function ag(e,t){let n=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);return n.setAttribute(`viewBox`,e),n.setAttribute(`class`,t),n.setAttribute(`fill`,`none`),n.style.width=`100%`,n.style.height=`auto`,n.style.display=`block`,n}function og(e){let t=ag(`0 0 360 780`,e);for(let e of[`M 0 0 L 360 0 L 360 780 L 0 780 Z`,`M 45 0 L 45 780`,`M 315 0 L 315 780`,`M 0 390 L 360 390`,`M 45 210 L 315 210`,`M 45 570 L 315 570`,`M 180 210 L 180 570`,`M 180 0 L 180 20`,`M 180 760 L 180 780`])t.appendChild(X(`path`,{d:e,class:Y}));return t}function sg(e){let t=ag(`0 0 500 470`,e),n=[X(`rect`,{x:`0`,y:`0`,width:`500`,height:`470`,class:Y}),X(`circle`,{cx:`250`,cy:`470`,r:`60`,class:Y}),X(`line`,{x1:`0`,y1:`470`,x2:`500`,y2:`470`,class:Y}),X(`rect`,{x:`170`,y:`0`,width:`160`,height:`190`,class:Y}),X(`circle`,{cx:`250`,cy:`190`,r:`60`,class:Y}),X(`line`,{x1:`220`,y1:`40`,x2:`280`,y2:`40`,class:Y}),X(`circle`,{cx:`250`,cy:`52`,r:`12`,class:Y}),X(`path`,{d:`M 30 0 L 30 90 A 220 220 0 0 0 470 90 L 470 0`,class:Y})];for(let e of n)t.appendChild(e);return t}function cg(e){let t=ag(`0 0 500 440`,e),n=[X(`path`,{d:`M 20 170 A 350 400 0 0 1 480 170`,class:Y}),X(`line`,{x1:`250`,y1:`400`,x2:`20`,y2:`170`,class:Y}),X(`line`,{x1:`250`,y1:`400`,x2:`480`,y2:`170`,class:Y}),X(`path`,{d:`M 250 400 L 314 336 L 250 273 L 186 336 Z`,class:Y}),X(`path`,{d:`M 340 355 A 100 100 0 0 1 160 355`,class:Y}),X(`line`,{x1:`340`,y1:`355`,x2:`265`,y2:`405`,class:Y}),X(`line`,{x1:`160`,y1:`355`,x2:`235`,y2:`405`,class:Y}),X(`path`,{d:`M 235 405 A 18 18 0 0 1 265 405`,class:Y}),X(`circle`,{cx:`250`,cy:`340`,r:`9`,class:Y}),X(`line`,{x1:`247`,y1:`339`,x2:`253`,y2:`339`,class:Y}),X(`path`,{d:`M 244 398 L 244 404 L 250 408 L 256 404 L 256 398 Z`,class:Y}),X(`rect`,{x:`310`,y:`332`,width:`8`,height:`8`,transform:`rotate(45 314 336)`,class:Y}),X(`rect`,{x:`246`,y:`269`,width:`8`,height:`8`,transform:`rotate(45 250 273)`,class:Y}),X(`rect`,{x:`182`,y:`332`,width:`8`,height:`8`,transform:`rotate(45 186 336)`,class:Y}),X(`rect`,{x:`230`,y:`393`,width:`8`,height:`18`,class:Y}),X(`rect`,{x:`262`,y:`393`,width:`8`,height:`18`,class:Y})];for(let e of n)t.appendChild(e);return t}function lg(e){let t=ag(`0 0 850 2000`,e),n=[X(`rect`,{x:`0`,y:`0`,width:`850`,height:`2000`,rx:`280`,ry:`280`,class:Y}),X(`line`,{x1:`0`,y1:`1000`,x2:`850`,y2:`1000`,class:Y}),X(`circle`,{cx:`425`,cy:`1000`,r:`60`,class:Y}),X(`line`,{x1:`0`,y1:`650`,x2:`850`,y2:`650`,class:Y}),X(`line`,{x1:`0`,y1:`1350`,x2:`850`,y2:`1350`,class:Y}),X(`line`,{x1:`140`,y1:`300`,x2:`710`,y2:`300`,class:Y}),X(`line`,{x1:`140`,y1:`1700`,x2:`710`,y2:`1700`,class:Y}),X(`path`,{d:`M 395 300 A 40 40 0 0 1 455 300`,class:Y}),X(`path`,{d:`M 395 1700 A 40 40 0 0 0 455 1700`,class:Y}),X(`circle`,{cx:`270`,cy:`650`,r:`50`,class:Y}),X(`circle`,{cx:`580`,cy:`650`,r:`50`,class:Y}),X(`circle`,{cx:`270`,cy:`1350`,r:`50`,class:Y}),X(`circle`,{cx:`580`,cy:`1350`,r:`50`,class:Y})];for(let e of n)t.appendChild(e);return t}function ug(e){let t=ag(`0 0 200 440`,e);for(let e of[`M 0 0 L 200 0 L 200 440 L 0 440 Z`,`M 0 220 L 200 220`,`M 0 150 L 200 150`,`M 0 290 L 200 290`,`M 100 0 L 100 150`,`M 100 290 L 100 440`])t.appendChild(X(`path`,{d:e,class:Y}));return t}function dg(e){let t=ag(`0 0 200 440`,e);for(let e of[`M 0 0 L 200 0 L 200 440 L 0 440 Z`,`M 18 0 L 18 440`,`M 182 0 L 182 440`,`M 0 220 L 200 220`,`M 0 146 L 200 146`,`M 0 294 L 200 294`,`M 0 30 L 200 30`,`M 0 410 L 200 410`,`M 100 146 L 100 220`,`M 100 220 L 100 294`])t.appendChild(X(`path`,{d:e,class:Y}));return t}function fg(e){let t=ag(`0 0 100 200`,e);for(let e of[`M 0 0 L 100 0 L 100 200 L 0 200 Z`,`M 0 100 L 100 100`,`M 0 69.5 L 100 69.5`,`M 0 130.5 L 100 130.5`,`M 50 69.5 L 50 67.5`,`M 50 130.5 L 50 132.5`])t.appendChild(X(`path`,{d:e,class:Y}));return t}var pg=`COURT_SVG`,mg={tennis:og,basketball:sg,baseball:cg,hockey:lg,pickleball:ug,badminton:dg,padel:fg},hg={TENNIS:`tennis`,PADEL:`padel`,PICKLEBALL:`pickleball`,BADMINTON:`badminton`},gg={HAL:`basketball`,INN:`baseball`,PER:`hockey`};function _g(e){if(e){for(let[t,n]of Object.entries(gg))if(e.startsWith(t))return n;if(e.startsWith(`SET`)||e.startsWith(`T`))return e.includes(`@RALLY`)?`pickleball`:`tennis`}}function vg(e){let t=e?.competitionFormat?.sport;return t&&hg[t]?hg[t]:_g(e?.matchUpFormat)}function yg(e){let t=e.getAttribute(`viewBox`);if(!t)return e;let n=t.split(/\s+/).map(Number);if(n.length!==4)return e;let[r,i,a,o]=n;if(o<=a)return e;e.setAttribute(`viewBox`,`${r} ${i} ${o} ${a}`);let s=document.createElementNS(`http://www.w3.org/2000/svg`,`g`);for(s.setAttribute(`transform`,`translate(${o}, 0) rotate(90)`);e.firstChild;)s.appendChild(e.firstChild);return e.appendChild(s),e}function bg(e,t=``){let n=e?mg[e]:void 0;if(n)return yg(n(t?`court--${e} ${t}`:`court--${e}`))}function xg(e){let t=[];return e.city&&t.push(e.city),(e.state||e.region)&&t.push(e.state||e.region),e.countryCode?t.push(e.countryCode):e.country&&t.push(e.country),t.join(`, `)}function Sg(e){if(!e)return;let t=xg(e);return t.length?t:void 0}function Cg(e){let t=e?.find(Boolean);if(!t)return;let n=t.addresses?.find(Boolean);return n?Sg(n)??t.venueName:t.venueName}var wg=/^(\d{4})-(\d{2})-(\d{2})/,Tg=864e5;function Eg(e){if(!e)return null;let t=wg.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]);return!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i)?null:{year:n,month:r,day:i}}function Dg(e,t){if(!t)return new Date(e.year,e.month-1,e.day);let n=Date.UTC(e.year,e.month-1,e.day,0,0,0,0),r=new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}),i=new Date(n);for(let e=0;e<2;e++){let e=r.formatToParts(i),t=t=>Number(e.find(e=>e.type===t)?.value??0),a=Date.UTC(t(`year`),t(`month`)-1,t(`day`),t(`hour`),t(`minute`),t(`second`))-i.getTime();i=new Date(n-a)}return i}function Og(e,t){if(!t)return new Date(e.year,e.month-1,e.day+1);let n=Dg(e,t),r=new Date(n.getTime()+Tg),i=new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`2-digit`,day:`2-digit`}).formatToParts(r),a=e=>Number(i.find(t=>t.type===e)?.value??0);return Dg({year:a(`year`),month:a(`month`),day:a(`day`)},t)}function kg(e){if(!e)return null;let t=Eg(e);if(t)return new Date(t.year,t.month-1,t.day);let n=new Date(e);return Number.isNaN(n.getTime())?null:n}function Ag(e){return e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}function jg(e){return e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})}function Mg(e,t){if(!e&&!t)return;let n=kg(e),r=kg(t),i=!!n&&!Number.isNaN(n.getTime()),a=!!r&&!Number.isNaN(r.getTime());if(i||a)return i&&a&&n.getTime()===r.getTime()?jg(n):i&&a?n.getFullYear()===r.getFullYear()?`${Ag(n)} – ${Ag(r)}, ${r.getFullYear()}`:`${jg(n)} – ${jg(r)}`:jg(i?n:r)}function Ng(e){return e.slice().sort((e,t)=>{let n=e.courtOrder,r=t.courtOrder;return Number.isFinite(n)&&Number.isFinite(r)&&n!==r?n-r:Number.isFinite(n)&&!Number.isFinite(r)?-1:!Number.isFinite(n)&&Number.isFinite(r)?1:e.courtName.localeCompare(t.courtName,void 0,{numeric:!0})})}var Pg=`URL`;function Fg(e,t){if(!Array.isArray(e))return;let n=e.find(e=>e?.name===t&&e?.resourceType===Pg);return n?.url??n?.identifier}function Ig(e,t){if(Array.isArray(e))return e.find(e=>e?.resourceSubType===`COURT_SVG`&&(!t||e?.name===t))?.identifier}function Lg(e){if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(typeof e==`string`){let t=e.trim();if(!t)return;let n=Number(t);return Number.isFinite(n)?n:void 0}}function Rg(...e){for(let t of e){let e=Lg(t);if(e!==void 0)return e}}function zg(e){let t=document.createElement(`div`);if(t.className=e.cardClass,t.setAttribute(`aria-busy`,`true`),e.showImage){let n=document.createElement(`div`);n.className=e.imageClass;let r=document.createElement(`div`);r.className=e.blockClass,n.appendChild(r),t.appendChild(n)}if(e.bodyLines>0){let n=document.createElement(`div`);n.className=e.bodyClass;for(let t=0;t<e.bodyLines;t++){let r=document.createElement(`div`);r.className=e.lineClass,r.style.width=t===0?`90%`:`${60+t*10}%`,n.appendChild(r)}t.appendChild(n)}if(e.showFooter){let n=document.createElement(`div`);n.className=e.footerClass;let r=document.createElement(`div`);r.className=e.lineClass,r.style.width=`40%`,n.appendChild(r),t.appendChild(n)}return t}var Bg={showImage:!0,cornerBadges:[`status`],body:[`title`,`tier`,`location`,`dateRange`],footer:[`feeBadge`,`playerCount`]};function Vg(e){return e?{showImage:e.showImage??Bg.showImage,cornerBadges:e.cornerBadges??Bg.cornerBadges,body:e.body??Bg.body,footer:e.footer??Bg.footer}:Bg}var Hg=()=>`chc-tc-card`,Ug=()=>`chc-tc-card--clickable`,Wg=()=>`chc-tc-card--offline`,Gg=()=>`chc-tc-image`,Kg=()=>`chc-tc-image-img`,qg=()=>`chc-tc-image-svg`,Jg=()=>`chc-tc-image-placeholder`,Yg=()=>`chc-tc-corner-badges`,Xg=()=>`chc-tc-status-pill`,Zg=()=>`chc-tc-offline-badge`,Qg=()=>`chc-tc-body`,$g=()=>`chc-tc-title`,e_=()=>`chc-tc-location`,t_=()=>`chc-tc-date-range`,n_=()=>`chc-tc-organizer`,r_=()=>`chc-tc-updated-at`,i_=()=>`chc-tc-footer`,a_=()=>`chc-tc-fee-badge`,o_=()=>`chc-tc-player-count`,s_=()=>`chc-tc-event-count`,c_=()=>`chc-tc-tier-badge`,l_=()=>`chc-tc-card chc-tc-skeleton`,u_=()=>`chc-tc-skeleton-line`,d_=()=>`chc-tc-skeleton-block`;function f_(e,t,n){let r=Vg(t),i=document.createElement(`div`);return i.className=Hg(),i.dataset.tournamentId=e.tournamentId,e.offline&&i.classList.add(Wg()),n?.onClick&&(i.classList.add(Ug()),i.tabIndex=0,i.addEventListener(`click`,t=>{t.stopPropagation(),n.onClick(e)}),i.addEventListener(`keydown`,t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),n.onClick(e))})),r.showImage!==!1&&i.appendChild(p_(e,r)),r.body.length&&i.appendChild(v_(e,r)),r.footer.length&&i.appendChild(E_(e,r)),i}function p_(e,t){let n=document.createElement(`div`);if(n.className=Gg(),e.tournamentImageURL){let t=document.createElement(`img`);t.className=Kg(),t.src=e.tournamentImageURL,t.alt=e.tournamentName||``,t.loading=`lazy`,t.addEventListener(`error`,()=>h_(n,e)),n.appendChild(t)}else m_(n,e);if(t.cornerBadges.length){let r=g_(e,t.cornerBadges);r&&n.appendChild(r)}return n}function m_(e,t){let n=bg(t.courtSvgSport,qg());if(n){e.appendChild(n);return}let r=document.createElement(`div`);r.className=Jg(),e.appendChild(r)}function h_(e,t){e.querySelector(`.${Kg()}`)?.remove(),m_(e,t)}function g_(e,t){let n=[];for(let r of t){let t=__(r,e);t&&n.push(t)}if(!n.length)return null;let r=document.createElement(`div`);r.className=Yg();for(let e of n)r.appendChild(e);return r}function __(e,t){if(e===`status`){if(!t.status)return null;let e=document.createElement(`div`);return e.className=Xg(),e.dataset.kind=t.status.kind,e.textContent=t.status.label,e}if(e===`offline`){if(!t.offline)return null;let e=document.createElement(`div`);return e.className=Zg(),e.textContent=`Offline`,e}return null}function v_(e,t){let n=document.createElement(`div`);n.className=Qg();for(let r of t.body){let t=y_(r,e);t&&n.appendChild(t)}return n}function y_(e,t){switch(e){case`title`:return b_(t);case`tier`:return x_(t);case`location`:return S_(t);case`dateRange`:return C_(t);case`organizerName`:return w_(t);case`updatedAt`:return T_(t);default:return null}}function b_(e){if(!e.tournamentName)return null;let t=document.createElement(`div`);return t.className=$g(),t.textContent=e.tournamentName,t.title=e.tournamentName,t}function x_(e){let t=e.tournamentTier?.value;if(!t)return null;let n=document.createElement(`div`);return n.className=c_(),n.textContent=t,n.title=e.tournamentTier?.system?`${e.tournamentTier.system}: ${t}`:t,n}function S_(e){if(!e.location)return null;let t=document.createElement(`div`);return t.className=e_(),t.textContent=e.location,t.title=e.location,t}function C_(e){if(!e.dateRangeFormatted)return null;let t=document.createElement(`div`);return t.className=t_(),t.textContent=e.dateRangeFormatted,t}function w_(e){if(!e.organizerName)return null;let t=document.createElement(`div`);return t.className=n_(),t.textContent=e.organizerName,t}function T_(e){if(!e.updatedAt)return null;let t=document.createElement(`div`);t.className=r_();let n=new Date(e.updatedAt);return t.textContent=Number.isNaN(n.getTime())?e.updatedAt:n.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),t}function E_(e,t){let n=document.createElement(`div`);n.className=i_();for(let r of t.footer){let t=D_(r,e);t&&n.appendChild(t)}return n}function D_(e,t){switch(e){case`feeBadge`:return O_(t);case`playerCount`:return k_(t);case`eventCount`:return A_(t);default:return null}}function O_(e){if(!e.feeFormatted)return null;let t=document.createElement(`div`);return t.className=a_(),t.textContent=e.feeFormatted,t}function k_(e){if(typeof e.participantCount!=`number`)return null;let t=document.createElement(`div`);return t.className=o_(),t.textContent=`${e.participantCount} ${e.participantCount===1?`player`:`players`}`,t}function A_(e){if(typeof e.eventCount!=`number`)return null;let t=document.createElement(`div`);return t.className=s_(),t.textContent=`${e.eventCount} ${e.eventCount===1?`event`:`events`}`,t}function j_(e){let t=Vg(e);return zg({showImage:t.showImage!==!1,bodyLines:t.body.length,showFooter:t.footer.length>0,cardClass:l_(),imageClass:Gg(),bodyClass:Qg(),footerClass:i_(),blockClass:d_(),lineClass:u_()})}var M_=6048e5;function N_(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function P_(e,t,n){return!t||!n?!1:t.getTime()<=e.getTime()&&e.getTime()<n.getTime()}function F_(e){return`Opens ${e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}`}function I_(e,t=new Date){let n=e.tournamentStatus?.toUpperCase();if(n===`CANCELLED`||n===`ABANDONDED`||n===`ABANDONED`)return{kind:`cancelled`,label:`Cancelled`};let r=e.timeZone,i=Eg(e.endDate),a=i?Og(i,r):null;if(n===`COMPLETED`||a&&t.getTime()>=a.getTime())return{kind:`completed`,label:`Completed`};let o=Eg(e.startDate);if(P_(t,o?Dg(o,r):null,a))return{kind:`live`,label:`Live`};let s=N_(e.entriesClose);if(s){let e=s.getTime()-t.getTime();if(e>0&&e<=M_)return{kind:`closing-soon`,label:`Closing Soon`}}let c=N_(e.entriesOpen);return c&&c.getTime()>t.getTime()?{kind:`registration-opens`,label:F_(c)}:null}var L_=`–`,R_={JPY:0,KRW:0,VND:0,CLP:0,ISK:0,KWD:3,BHD:3,OMR:3,JOD:3,TND:3};function z_({amount:e,currencyCode:t,unit:n}){return n===`MAJOR`?e:e/10**(R_[t]??2)}function B_(e,t){try{return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t}).format(e)}catch{return`${e.toFixed(2)} ${t}`}}function V_(e){let t=[];for(let n of e)typeof n?.amount!=`number`||Number.isNaN(n.amount)||n.currencyCode&&n.unit&&t.push({amount:n.amount,currencyCode:n.currencyCode,unit:n.unit});return t}function H_(e){if(!e?.length)return null;let t=V_(e);if(!t.length)return null;let n=new Map;for(let e of t){let t=`${e.currencyCode}/${e.unit}`,r=n.get(t);r?r.push(e):n.set(t,[e])}let r=[...n.values()].sort((e,t)=>t.length-e.length),i=r[0],a=i[0].currencyCode,o=i.map(z_).sort((e,t)=>e-t),s=o[0],c=o.at(-1)??s;return r.length>1?`From ${a} ${B_(s,a)}`:s===c?`${a} ${B_(s,a)}`:`${a} ${B_(s,a)} ${L_} ${B_(c,a)}`}var U_=`tournamentImage`;function W_(e){let t=e?.registrationProfile?.entryFees;return Array.isArray(t)?t.filter(e=>e&&typeof e.amount==`number`):[]}function G_(e,t){let n=e?.individualParticipantCount;return typeof n==`number`?n||void 0:t.filter(e=>(!e?.participantType||e.participantType===`INDIVIDUAL`)&&(!e?.participantRole||e.participantRole===`COMPETITOR`)).length||void 0}function K_(e){let t=e?.timeItems;if(Array.isArray(t))return t.find(e=>e?.itemType===`TMX`)?.itemValue?.offline}function q_(e,t){let n=Array.isArray(e?.onlineResources)?e.onlineResources:void 0,r=Array.isArray(e?.venues)?e.venues:[],i=Array.isArray(e?.participants)?e.participants:[],a=Array.isArray(e?.events)?e.events:[],o=t?.statusOverride===void 0?I_({tournamentStatus:e?.tournamentStatus,startDate:e?.startDate,endDate:e?.endDate,entriesOpen:e?.registrationProfile?.entriesOpen,entriesClose:e?.registrationProfile?.entriesClose,timeZone:e?.localTimeZone||e?.timeZone},t?.now):t.statusOverride,s=e?.tournamentImageURL??Fg(n,U_),c=e?.courtSvgSport??Ig(n);return{tournamentId:e?.tournamentId??``,tournamentName:e?.tournamentName??``,startDate:e?.startDate,endDate:e?.endDate,dateRangeFormatted:Mg(e?.startDate,e?.endDate),location:Cg(r),tournamentImageURL:s,courtSvgSport:c,participantCount:G_(e,i),eventCount:a.length||void 0,organizerName:e?.tournamentOrganizers?.find?.(Boolean)?.organizerName,status:o,feeFormatted:H_(W_(e)),updatedAt:e?.updatedAt,offline:K_(e),tournamentTier:J_(e)}}function J_(e){let t=e?.tournamentTier;if(!t||typeof t!=`object`||typeof t.system!=`string`||typeof t.value!=`string`)return;let n={system:t.system,value:t.value};return typeof t.numericRank==`number`&&Number.isFinite(t.numericRank)&&(n.numericRank=t.numericRank),n}var Y_={showImage:!0,showMap:!0,cornerBadges:[`primaryBadge`],body:[`title`,`address`,`courtBreakdown`],footer:[`amenityRow`]};function X_(e){return e?{showImage:e.showImage??Y_.showImage,showMap:e.showMap??Y_.showMap,cornerBadges:e.cornerBadges??Y_.cornerBadges,body:e.body??Y_.body,footer:e.footer??Y_.footer}:Y_}var Z_=()=>`chc-vc-card`,Q_=()=>`chc-vc-card--clickable`,$_=()=>`chc-vc-image`,ev=()=>`chc-vc-image-img`,tv=()=>`chc-vc-image-svg`,nv=()=>`chc-vc-image-map`,rv=()=>`chc-vc-image-placeholder`,iv=()=>`chc-vc-corner-badges`,av=()=>`chc-vc-primary-badge`,ov=()=>`chc-vc-body`,sv=()=>`chc-vc-title`,cv=()=>`chc-vc-address`,lv=()=>`chc-vc-court-breakdown`,uv=()=>`chc-vc-footer`,dv=()=>`chc-vc-amenity-row`,fv=()=>`chc-vc-amenity`,pv=()=>`chc-vc-card chc-vc-skeleton`,mv=()=>`chc-vc-skeleton-line`,hv=()=>`chc-vc-skeleton-block`;function gv(e,t,n){let r=X_(t),i=document.createElement(`div`);i.className=Z_(),i.dataset.venueId=e.venueId;let a=null;r.showImage!==!1&&(a=bv(e,r,()=>f()),i.appendChild(a));let o=r.body.length?Ov(e,r):null;o&&i.appendChild(o);let s=r.footer.length?Mv(e,r):null;s&&i.appendChild(s);function c(){return!!a?.querySelector(`iframe`)}let l=new Map;function u(e,t){if(l.has(e))return;let n=e=>{e.stopPropagation(),t()},r=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),t())};e.classList.add(Q_()),e.tabIndex=0,e.addEventListener(`click`,n),e.addEventListener(`keydown`,r),l.set(e,{click:n,keydown:r})}function d(e){let t=l.get(e);t&&(e.removeEventListener(`click`,t.click),e.removeEventListener(`keydown`,t.keydown),e.classList.remove(Q_()),e.removeAttribute(`tabindex`),l.delete(e))}function f(){if(!n?.onClick)return;let t=()=>n.onClick(e);c()?(d(i),o&&u(o,t),s&&u(s,t)):(o&&d(o),s&&d(s),u(i,t))}return f(),i}function _v(e){return typeof e.latitude==`number`&&typeof e.longitude==`number`}function vv(e){let t=e.latitude,n=e.longitude,r=.01,i=`https://www.openstreetmap.org/export/embed.html?bbox=${`${n-r},${t-r},${n+r},${t+r}`}&marker=${t},${n}&layer=mapnik`,a=document.createElement(`iframe`);return a.className=nv(),a.src=i,a.loading=`lazy`,a.title=`Map of ${e.venueName}`,a}function yv(e,t){let n=bg(t.courtSvgSport,tv());if(n){e.appendChild(n);return}let r=document.createElement(`div`);r.className=rv(),e.appendChild(r)}function bv(e,t,n){let r=document.createElement(`div`);if(r.className=$_(),e.venueImageURL){let i=document.createElement(`img`);i.className=ev(),i.src=e.venueImageURL,i.alt=e.venueName||``,i.loading=`lazy`,i.addEventListener(`error`,()=>{i.remove(),t.showMap!==!1&&_v(e)?r.appendChild(vv(e)):yv(r,e),n?.()}),r.appendChild(i)}else t.showMap!==!1&&_v(e)?r.appendChild(vv(e)):yv(r,e);if(t.cornerBadges.length){let n=Sv(e,t.cornerBadges);n&&r.appendChild(n)}return r}function xv(e,t){if(e===`primaryBadge`){if(!t.isPrimary)return null;let e=document.createElement(`div`);return e.className=av(),e.textContent=`Primary`,e}return null}function Sv(e,t){let n=[];for(let r of t){let t=xv(r,e);t&&n.push(t)}if(!n.length)return null;let r=document.createElement(`div`);r.className=iv();for(let e of n)r.appendChild(e);return r}function Cv(e){if(!e.venueName)return null;let t=document.createElement(`div`);return t.className=sv(),t.textContent=e.venueName,t.title=e.notes?`${e.venueName}\n${e.notes}`:e.venueName,t}function wv(e){if(!e.addressFormatted)return null;let t=document.createElement(`div`);return t.className=cv(),t.textContent=e.addressFormatted,t.title=e.addressFormatted,t}function Tv(e){if(!e.courtBreakdown)return null;let t=document.createElement(`div`);return t.className=lv(),t.textContent=e.courtBreakdown,t}function Ev(e){if(!e.venueAbbreviation)return null;let t=document.createElement(`div`);return t.className=lv(),t.textContent=e.venueAbbreviation,t}function Dv(e,t){return e===`title`?Cv(t):e===`address`?wv(t):e===`courtBreakdown`?Tv(t):e===`venueAbbreviation`?Ev(t):null}function Ov(e,t){let n=document.createElement(`div`);n.className=ov();for(let r of t.body){let t=Dv(r,e);t&&n.appendChild(t)}return n}function kv(e){let t=document.createElement(`span`);return t.className=fv(),t.textContent=e,t}function Av(e){let t=[];if(typeof e.courtCount==`number`&&t.push(kv(`${e.courtCount} ${e.courtCount===1?`court`:`courts`}`)),e.indoorCount&&t.push(kv(`${e.indoorCount} indoor`)),e.outdoorCount&&t.push(kv(`${e.outdoorCount} outdoor`)),e.floodlitCount&&t.push(kv(`${e.floodlitCount} lit`)),!t.length)return null;let n=document.createElement(`div`);n.className=dv();for(let e of t)n.appendChild(e);return n}function jv(e,t){return e===`amenityRow`?Av(t):e===`address`?wv(t):e===`courtBreakdown`?Tv(t):null}function Mv(e,t){let n=document.createElement(`div`);n.className=uv();for(let r of t.footer){let t=jv(r,e);t&&n.appendChild(t)}return n}function Nv(e){let t=X_(e);return zg({showImage:t.showImage!==!1,bodyLines:t.body.length,showFooter:t.footer.length>0,cardClass:pv(),imageClass:$_(),bodyClass:ov(),footerClass:uv(),blockClass:hv(),lineClass:mv()})}var Pv=`venueImage`;function Fv(e){let t=[];return e.indoorOutdoor&&t.push(e.indoorOutdoor.toLowerCase()),e.surfaceCategory&&t.push(e.surfaceCategory.toLowerCase()),t.length?t.join(` `):`court`}function Iv(e){if(!e.length)return;let t=new Map;for(let n of e){let e=Fv(n);t.set(e,(t.get(e)??0)+1)}return[...t.entries()].sort((e,t)=>t[1]-e[1]).map(([e,t])=>`${t} ${e}`).join(`, `)}function Lv(e,t){let n=0;for(let r of e)t(r)&&(n+=1);return n}function Rv(e,t){let n=Array.isArray(e?.courts)?e.courts:[],r=Array.isArray(e?.onlineResources)?e.onlineResources:void 0,i=e?.addresses?.find(e=>e);return{venueId:e?.venueId??``,venueName:e?.venueName??``,venueAbbreviation:e?.venueAbbreviation,addressFormatted:Sg(i),latitude:Lg(i?.latitude),longitude:Lg(i?.longitude),courtCount:n.length||void 0,courtBreakdown:Iv(n),indoorCount:Lv(n,e=>e.indoorOutdoor===`INDOOR`)||void 0,outdoorCount:Lv(n,e=>e.indoorOutdoor===`OUTDOOR`)||void 0,floodlitCount:Lv(n,e=>!!e.floodlit)||void 0,isPrimary:!!e?.isPrimary,venueImageURL:e?.venueImageURL??Fg(r,Pv),courtSvgSport:e?.courtSvgSport??Ig(r)??t?.sport,notes:e?.notes}}var zv={showImage:!0,cornerBadges:[`indoorOutdoor`,`floodlit`],body:[`title`,`surface`],footer:[`amenityRow`]};function Bv(e){return e?{showImage:e.showImage??zv.showImage,cornerBadges:e.cornerBadges??zv.cornerBadges,body:e.body??zv.body,footer:e.footer??zv.footer}:zv}var Vv=()=>`chc-cc-card`,Hv=()=>`chc-cc-card--clickable`,Uv=()=>`chc-cc-image`,Wv=()=>`chc-cc-image-svg`,Gv=()=>`chc-cc-image-placeholder`,Kv=()=>`chc-cc-corner-badges`,qv=()=>`chc-cc-indoor-badge`,Jv=()=>`chc-cc-floodlit-badge`,Yv=()=>`chc-cc-body`,Xv=()=>`chc-cc-title`,Zv=()=>`chc-cc-surface`,Qv=()=>`chc-cc-availability`,$v=()=>`chc-cc-abbr`,ey=()=>`chc-cc-footer`,ty=()=>`chc-cc-amenity-row`,ny=()=>`chc-cc-card chc-cc-skeleton`,ry=()=>`chc-cc-skeleton-line`,iy=()=>`chc-cc-skeleton-block`;function ay(e,t,n){let r=Bv(t),i=document.createElement(`div`);return i.className=Vv(),i.dataset.courtId=e.courtId,n?.onClick&&(i.classList.add(Hv()),i.tabIndex=0,i.addEventListener(`click`,t=>{t.stopPropagation(),n.onClick(e)}),i.addEventListener(`keydown`,t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),n.onClick(e))})),r.showImage!==!1&&i.appendChild(sy(e,r)),r.body.length&&i.appendChild(_y(e,r)),r.footer.length&&i.appendChild(by(e,r)),i}function oy(e,t){let n=bg(t.courtSvgSport,Wv());if(n){e.appendChild(n);return}let r=document.createElement(`div`);r.className=Gv(),e.appendChild(r)}function sy(e,t){let n=document.createElement(`div`);if(n.className=Uv(),e.surfaceCategory&&(n.dataset.surface=e.surfaceCategory),oy(n,e),t.cornerBadges.length){let r=dy(e,t.cornerBadges);r&&n.appendChild(r)}return n}function cy(e){if(!e.indoorOutdoor)return null;let t=document.createElement(`div`);return t.className=qv(),t.dataset.kind=e.indoorOutdoor,t.textContent=e.indoorOutdoor===`INDOOR`?`Indoor`:`Outdoor`,t}function ly(e){if(!e.floodlit)return null;let t=document.createElement(`div`);return t.className=Jv(),t.textContent=`Lit`,t}function uy(e,t){return e===`indoorOutdoor`?cy(t):e===`floodlit`?ly(t):null}function dy(e,t){let n=[];for(let r of t){let t=uy(r,e);t&&n.push(t)}if(!n.length)return null;let r=document.createElement(`div`);r.className=Kv();for(let e of n)r.appendChild(e);return r}function fy(e){if(!e.courtName)return null;let t=document.createElement(`div`);return t.className=Xv(),t.textContent=e.courtName,t.title=e.notes?`${e.courtName}\n${e.notes}`:e.courtName,t}function py(e){if(!e.surfaceLabel)return null;let t=document.createElement(`div`);return t.className=Zv(),t.textContent=e.surfaceLabel,t}function my(e){if(!e.availabilitySummary)return null;let t=document.createElement(`div`);return t.className=Qv(),t.textContent=e.availabilitySummary,t}function hy(e){if(!e.courtAbbreviation)return null;let t=document.createElement(`div`);return t.className=$v(),t.textContent=e.courtAbbreviation,t}function gy(e,t){return e===`title`?fy(t):e===`surface`?py(t):e===`availability`?my(t):e===`abbreviation`?hy(t):null}function _y(e,t){let n=document.createElement(`div`);n.className=Yv();for(let r of t.body){let t=gy(r,e);t&&n.appendChild(t)}return n}function vy(e){let t=[];if(e.indoorOutdoor&&t.push(e.indoorOutdoor===`INDOOR`?`indoor`:`outdoor`),e.surfaceCategory&&t.push(e.surfaceCategory.toLowerCase()),e.floodlit&&t.push(`floodlit`),!t.length)return null;let n=document.createElement(`div`);return n.className=ty(),n.textContent=t.join(` · `),n}function yy(e,t){return e===`amenityRow`?vy(t):e===`availability`?my(t):e===`surface`?py(t):null}function by(e,t){let n=document.createElement(`div`);n.className=ey();for(let r of t.footer){let t=yy(r,e);t&&n.appendChild(t)}return n}function xy(e){let t=Bv(e);return zg({showImage:t.showImage!==!1,bodyLines:t.body.length,showFooter:t.footer.length>0,cardClass:ny(),imageClass:Uv(),bodyClass:Yv(),footerClass:ey(),blockClass:iy(),lineClass:ry()})}var Sy=`INDOOR`,Cy=`OUTDOOR`,wy=new Set([`HARD`,`CLAY`,`GRASS`,`ARTIFICIAL`,`CARPET`]);function Ty(e){if(!e)return;let t=String(e).toUpperCase();if(t===Sy)return Sy;if(t===Cy)return Cy}function Ey(e){let t=e?.surfaceCategory?String(e.surfaceCategory).toUpperCase():void 0;if(t&&wy.has(t))return t;let n=e?.surfaceType?String(e.surfaceType).toUpperCase():void 0;return n&&wy.has(n)?n:t}function Dy(e,t){let n=[];return e&&n.push(e.charAt(0)+e.slice(1).toLowerCase()),t&&n.push(t.charAt(0)+t.slice(1).toLowerCase()),n.length?n.join(` · `):void 0}function Oy(e,t){let n=Ty(e?.indoorOutdoor),r=Ey(e);return{courtId:e?.courtId??``,courtName:e?.courtName??``,courtAbbreviation:e?.courtAbbreviation,surfaceLabel:Dy(n,r),indoorOutdoor:n,surfaceCategory:r,floodlit:!!e?.floodlit,courtSvgSport:t?.sport,notes:e?.notes}}var ky={grouping:`setting`,sport:`tennis`,showGroupHeadings:!0,showSummary:!0,minCardWidth:`11rem`,emptyMessage:`No courts recorded for this venue`};function Ay(e){return e?{grouping:e.grouping??ky.grouping,sport:e.sport??ky.sport,showGroupHeadings:e.showGroupHeadings??ky.showGroupHeadings,showSummary:e.showSummary??ky.showSummary,minCardWidth:e.minCardWidth??ky.minCardWidth,emptyMessage:e.emptyMessage??ky.emptyMessage}:ky}var jy=()=>`chc-cl`,My=()=>`chc-cl-summary`,Ny=()=>`chc-cl-summary-count`,Py=()=>`chc-cl-group`,Fy=()=>`chc-cl-group-heading`,Iy=()=>`chc-cl-group-count`,Ly=()=>`chc-cl-grid`,Ry=()=>`chc-cl-empty`,zy=`Unspecified`,By=`Unspecified surface`;function Vy(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function Hy(e){let t=typeof e.indoorOutdoor==`string`?e.indoorOutdoor.trim():``;return t?Vy(t):zy}function Uy(e){let t=typeof e.surfaceCategory==`string`?e.surfaceCategory.trim():``;return t?Vy(t):By}function Wy(e,t){let n=Ng(e);if(t===`none`)return[{key:`all`,label:`All courts`,courts:n}];let r=e=>t===`setting`?Hy(e):t===`surface`?Uy(e):`${Hy(e)} · ${Uy(e)}`,i=new Map;for(let e of n){let t=r(e),n=i.get(t);n?n.courts.push(e):i.set(t,{key:t,label:t,courts:[e]})}return[...i.values()]}function Gy(e){let t=new Map;for(let n of e){let e=Hy(n),r=Uy(n),i=`${e===zy?``:e.toLowerCase()} ${r===By?``:r.toLowerCase()}`.trim()||`court`;t.set(i,(t.get(i)??0)+1)}return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).map(([e,t])=>`${t} ${e}`).join(`, `)}function Ky(e,t,n){let r=Ay(t),i=e.courts??[],a=document.createElement(`div`);if(a.className=jy(),e.venueId&&(a.dataset.venueId=e.venueId),!i.length){let e=document.createElement(`div`);return e.className=Ry(),e.textContent=r.emptyMessage,a.appendChild(e),a}r.showSummary&&a.appendChild(qy(i));for(let e of Wy(i,r.grouping))a.appendChild(Jy(e,r,n));return a}function qy(e){let t=document.createElement(`div`);t.className=My();let n=document.createElement(`span`);n.className=Ny(),n.textContent=`${e.length} ${e.length===1?`court`:`courts`}`;let r=document.createElement(`span`);return r.textContent=Gy(e),t.append(n,r),t}function Jy(e,t,n){let r=document.createElement(`div`);if(r.className=Py(),r.dataset.group=e.key,t.showGroupHeadings&&t.grouping!==`none`){let t=document.createElement(`div`);t.className=Fy();let n=document.createElement(`span`);n.textContent=e.label;let i=document.createElement(`span`);i.className=Iy(),i.textContent=String(e.courts.length),t.append(n,i),r.appendChild(t)}let i=document.createElement(`div`);i.className=Ly(),i.style.setProperty(`--chc-cl-min-card`,t.minCardWidth);for(let r of e.courts)i.appendChild(Xy(r,t,n));return r.appendChild(i),r}function Yy(e){if(e===`setting`||e===`both`)return{cornerBadges:[`floodlit`]}}function Xy(e,t,n){let r=Oy(e,{sport:t.sport}),i=n?.onCourtClick?{onClick:()=>n.onCourtClick?.(e)}:void 0;return ay(r,Yy(t.grouping),i)}var Zy={tiles:{map:{tileLayer:`https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png`,attribution:`&copy; <a href="https://openstreetmap.org">OpenStreetMap</a> Contributors`,maxZoom:18},satellite:{tileLayer:`https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}`,attribution:`Tiles &copy; Esri`}},darkTileLayer:{tileLayer:`https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png`,attribution:`&copy; <a href="https://openstreetmap.org">OpenStreetMap</a> Contributors &copy; <a href="https://carto.com/attributions">CARTO</a>`,maxZoom:20},view:`map`,showViewToggle:!0,zoom:16,height:`320px`,courtsLayout:`side`,showHeader:!0,showPopup:!0,scrollWheelZoom:!1,darkTiles:`auto`};function Qy(e){return e?{tiles:e.tiles??Zy.tiles,darkTileLayer:e.darkTileLayer===void 0?Zy.darkTileLayer:e.darkTileLayer,view:e.view??Zy.view,showViewToggle:e.showViewToggle??Zy.showViewToggle,zoom:e.zoom??Zy.zoom,height:e.height??Zy.height,courtsLayout:e.courtsLayout??Zy.courtsLayout,showHeader:e.showHeader??Zy.showHeader,showPopup:e.showPopup??Zy.showPopup,scrollWheelZoom:e.scrollWheelZoom??Zy.scrollWheelZoom,darkTiles:e.darkTiles??Zy.darkTiles}:Zy}var $y=()=>`chc-vl`,eb=()=>`chc-vl-header`,tb=()=>`chc-vl-title`,nb=()=>`chc-vl-address`,rb=()=>`chc-vl-notes`,ib=()=>`chc-vl-body`,ab=()=>`chc-vl-body--below`,ob=()=>`chc-vl-mapwrap`,sb=()=>`chc-vl-map`,cb=()=>`chc-vl-map--invertible`,lb=()=>`chc-vl-toggle`,ub=()=>`chc-vl-toggle-btn`,db=()=>`chc-vl-fallback`,fb=()=>`chc-vl-fallback-icon`,pb=()=>`chc-vl-courts`,mb=()=>`chc-vl-courts-title`,hb=()=>`chc-vl-court-list`,gb=()=>`chc-vl-court`,_b=()=>`chc-vl-court--clickable`,vb=()=>`chc-vl-court-name`,yb=()=>`chc-vl-court-meta`,bb=()=>`chc-vl-pip`,xb=()=>`chc-vl-marker`,Sb=()=>`chc-vl-popup-title`,Cb=()=>`chc-vl-popup-address`,wb=`No coordinates for this venue`,Tb=`Map unavailable`,Eb=new WeakMap;function Db(e){return Number.isFinite(e.latitude)&&Number.isFinite(e.longitude)}function Ob(e){return Ng(e)}function kb(e){let t=[];return e.indoorOutdoor&&t.push(e.indoorOutdoor.toLowerCase()),e.surfaceCategory&&t.push(e.surfaceCategory.toLowerCase()),t.join(` · `)}function Ab(e,t,n){let r=Qy(t),i=document.createElement(`div`);i.className=$y(),i.dataset.venueId=e.venueId,r.showHeader&&i.appendChild(Mb(e));let a=document.createElement(`div`);a.className=r.courtsLayout===`side`?ib():`${ib()} ${ab()}`;let{wrap:o,mapEl:s}=Pb(e,r,n);a.appendChild(o);let c=e.courts??[];return r.courtsLayout!==`none`&&c.length&&a.appendChild(Lb(c,e,n)),i.appendChild(a),s&&Db(e)&&zb({root:i,mapEl:s,data:e,cfg:r,callbacks:n}),i}function jb(e){let t=Eb.get(e);t&&(t(),Eb.delete(e))}function Mb(e){let t=document.createElement(`div`);t.className=eb();let n=document.createElement(`div`);if(n.className=tb(),n.textContent=e.venueName,t.appendChild(n),e.addressFormatted){let n=document.createElement(`div`);n.className=nb(),n.textContent=e.addressFormatted,t.appendChild(n)}if(e.notes){let n=document.createElement(`div`);n.className=rb(),n.textContent=e.notes,t.appendChild(n)}return t}function Nb(e){let t=document.createElement(`div`);t.className=db();let n=document.createElement(`div`);n.className=fb(),n.textContent=`📍`,n.setAttribute(`aria-hidden`,`true`);let r=document.createElement(`div`);return r.textContent=e,t.append(n,r),t}function Pb(e,t,n){let r=document.createElement(`div`);if(r.className=ob(),r.style.height=t.height,!Db(e))return r.appendChild(Nb(wb)),{wrap:r,mapEl:null};let i=document.createElement(`div`);i.className=sb(),i.appendChild(Nb(``)),r.appendChild(i);let a=Object.keys(t.tiles);return t.showViewToggle&&a.length>1&&r.appendChild(Fb(a,t,n)),{wrap:r,mapEl:i}}function Fb(e,t,n){let r=document.createElement(`div`);r.className=lb(),r.dataset.viewToggle=`true`;let i=[];for(let a of e){let e=document.createElement(`button`);e.type=`button`,e.className=ub(),e.dataset.view=a,e.textContent=a===`satellite`?`Satellite`:`Map`,e.setAttribute(`aria-pressed`,String(a===t.view)),e.addEventListener(`click`,()=>{for(let t of i)t.setAttribute(`aria-pressed`,String(t===e));n?.onViewChange?.(a)}),i.push(e),r.appendChild(e)}return r}function Ib(e,t,n){let r=!!n?.onCourtClick,i=document.createElement(r?`button`:`div`);i.className=r?`${gb()} ${_b()}`:gb(),i.dataset.courtId=e.courtId,r&&(i.type=`button`,i.addEventListener(`click`,()=>n?.onCourtClick?.(e,t)));let a=document.createElement(`span`);a.className=vb(),a.textContent=e.courtName;let o=document.createElement(`span`);o.className=yb();let s=kb(e);if(s&&o.append(document.createTextNode(s)),e.floodlit){let e=document.createElement(`span`);e.className=bb(),e.title=`floodlit`,o.appendChild(e)}return i.append(a,o),i}function Lb(e,t,n){let r=document.createElement(`div`);r.className=pb();let i=document.createElement(`div`);i.className=mb(),i.textContent=`Courts (${e.length})`,r.appendChild(i);let a=document.createElement(`div`);a.className=hb();for(let r of Ob(e))a.appendChild(Ib(r,t,n));return r.appendChild(a),r}function Rb(e){let t=e=>e.replace(/[&<>"]/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`})[e]),n=e.addressFormatted?`<div class="${Cb()}">${t(e.addressFormatted)}</div>`:``;return`<div class="${Sb()}">${t(e.venueName)}</div>${n}`}async function zb({root:e,mapEl:t,data:n,cfg:r,callbacks:i}){let a;try{a=await import(`leaflet`)}catch(e){t.replaceChildren(Nb(Tb)),i?.onMapUnavailable?.(Error(`leaflet is an optional peerDependency of courthive-components and is not installed`,{cause:e}));return}let o=a.default??a;try{t.replaceChildren();let a=o.map(t,{scrollWheelZoom:r.scrollWheelZoom,attributionControl:!0});a.setView([n.latitude,n.longitude],r.zoom);let s=r.view,c=Gb(o,a,r,s);Kb(t,r,s);let l=e=>{s=e,a.removeLayer(c),c=Gb(o,a,r,e),Kb(t,r,e)},u=o.divIcon({className:``,html:`<div class="${xb()}"></div>`,iconSize:[14,14]}),d=o.marker([n.latitude,n.longitude],{icon:u}).addTo(a);r.showPopup&&d.bindPopup(Rb(n)),d.on(`click`,()=>i?.onVenueClick?.(n)),e.querySelector(`[data-view-toggle]`)?.addEventListener(`click`,e=>{let t=e.target?.closest(`button[data-view]`);t&&l(t.dataset.view)}),Hb(t);let f=new ResizeObserver(()=>a.invalidateSize());f.observe(t);let p,m=globalThis.document?.documentElement;if(m&&r.darkTiles!==`never`&&r.darkTileLayer){let e=Ub();p=new MutationObserver(()=>{let t=Ub();t!==e&&(e=t,s!==`satellite`&&l(s))}),p.observe(m,{attributes:!0,attributeFilter:[`data-theme`]})}Eb.set(e,()=>{f.disconnect(),p?.disconnect(),a.remove()})}catch(e){t.replaceChildren(Nb(Tb)),i?.onMapUnavailable?.(Error(`Leaflet map failed to initialize`,{cause:e}))}}var Bb=!1;function Vb(e){return e?e!==`relative`&&e!==`absolute`:!1}function Hb(e){Bb||Vb(globalThis.getComputedStyle?.(e)?.position)&&(Bb=!0,console.warn("[courthive-components] venue-locator: leaflet's stylesheet is missing — the map will render incorrectly. Add `import 'leaflet/dist/leaflet.css';` to the host application."))}function Ub(){return globalThis.document?.documentElement?.dataset.theme===`dark`}function Wb(e,t,n){let r=e.tiles[t]??e.tiles.map;return t===`satellite`||e.darkTiles===`never`||!n?r:e.darkTileLayer??r}function Gb(e,t,n,r){let i=Wb(n,r,Ub());return e.tileLayer(i.tileLayer,{attribution:i.attribution,maxZoom:i.maxZoom??19}).addTo(t)}function Kb(e,t,n){let r=t.darkTiles===`auto`&&n!==`satellite`&&!t.darkTileLayer;e.classList.toggle(cb(),r)}function qb(...e){for(let t of e)if(typeof t==`number`&&Number.isFinite(t))return t}function Jb(e,t){let n=typeof e?.indoorOutdoor==`string`?e.indoorOutdoor.toUpperCase():void 0;return{courtId:e?.courtId??`court-${t+1}`,courtName:e?.courtName??`Court ${t+1}`,indoorOutdoor:n===`INDOOR`||n===`OUTDOOR`?n:void 0,surfaceCategory:e?.surfaceCategory,floodlit:e?.floodlit,courtOrder:qb(e?.courtOrder),latitude:Rg(e?.latitude),longitude:Rg(e?.longitude)}}function Yb(e){let t=Array.isArray(e?.courts)?e.courts:[],n=e?.addresses?.find(e=>e);return{venueId:e?.venueId??``,venueName:e?.venueName??e?.venueAbbreviation??``,venueAbbreviation:e?.venueAbbreviation,addressFormatted:Sg(n),latitude:Rg(e?.latitude,n?.latitude),longitude:Rg(e?.longitude,n?.longitude),courts:t.map(Jb),notes:e?.notes}}var Xb=()=>`chc-team-card`,Zb=()=>`chc-team-card--clickable`,Qb=()=>`chc-team-card__title-row`,$b=()=>`chc-team-card__name`,ex=()=>`chc-team-card__nickname`,tx=()=>`chc-team-card__counts`,nx=` · `;function rx(e,t){let n=document.createElement(`div`);n.className=Xb(),e.teamId&&(n.dataset.teamId=e.teamId),t?.onClick&&(n.classList.add(Zb()),n.tabIndex=0,n.setAttribute(`role`,`button`),n.addEventListener(`click`,n=>{n.stopPropagation(),t.onClick(e)}),n.addEventListener(`keydown`,n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),n.stopPropagation(),t.onClick(e))})),n.appendChild(ix(e));let r=(e.countSegments??[]).map(e=>(e??``).trim()).filter(Boolean);return r.length&&n.appendChild(ax(r)),n}function ix(e){let t=document.createElement(`div`);t.className=Qb();let n=document.createElement(`span`);if(n.className=$b(),n.textContent=e.teamName,t.appendChild(n),e.nickname){let n=document.createElement(`span`);n.className=ex(),n.textContent=`"${e.nickname}"`,t.appendChild(n)}return t}function ax(e){let t=document.createElement(`div`);return t.className=tx(),t.textContent=e.join(nx),t}var ox=[`COMPETITIVE`,`ROUTINE`,`DECISIVE`,`WALKOVER`],sx=new Set([`WALKOVER`,`DOUBLE_WALKOVER`,`DEFAULTED`,`DOUBLE_DEFAULT`]);function cx(){return{COMPETITIVE:0,ROUTINE:0,DECISIVE:0,WALKOVER:0}}function lx(e){let t=cx();if(!Array.isArray(e))return t;for(let n of e){let e=typeof n?.getData==`function`?n.getData():n;if(!e)continue;if(e.matchUpStatus&&sx.has(e.matchUpStatus)){t.WALKOVER+=1;continue}let r=e.competitiveProfile?.competitiveness;r&&r!==`WALKOVER`&&ox.includes(r)&&(t[r]+=1)}return t}function ux(e){return ox.reduce((t,n)=>t+e[n],0)}var dx={COMPETITIVE:`Competitive`,ROUTINE:`Routine`,DECISIVE:`Decisive`,WALKOVER:`Walkover / Defaulted`};function fx(e={}){let{onSegmentClick:t}=e,n=document.createElement(`div`);n.className=`chc-cb`;let r={};for(let e of ox){let i=document.createElement(`div`);i.className=`chc-cb__seg`,i.dataset.bucket=e,t&&(i.classList.add(`is-clickable`),i.setAttribute(`role`,`button`),i.addEventListener(`click`,()=>t(e))),r[e]=i,n.appendChild(i)}return{element:n,update:e=>{let t=ux(e);if(n.style.display=t>0?`flex`:`none`,t)for(let t of ox){let n=r[t],i=e[t];i===0?(n.style.flex=`0 0 0`,n.style.padding=`0`,n.textContent=``,n.removeAttribute(`title`)):(n.style.flex=`${i} 1 0`,n.style.padding=`0 4px`,n.textContent=String(i),n.title=`${dx[t]}: ${i}`)}},setActive:e=>{n.classList.toggle(`has-active`,!!e);for(let t of ox)r[t].classList.toggle(`is-active`,t===e)}}}var px={COMPETITIVE:`Competitive`,ROUTINE:`Routine`,DECISIVE:`Decisive`,WALKOVER:`Walkover / Defaulted`},mx=`http://www.w3.org/2000/svg`,hx=96,gx=hx/2,_x=47,vx=31;function yx(e,t){return{x:gx+t*Math.cos(e),y:gx+t*Math.sin(e)}}function bx(e,t){let n=yx(e,_x),r=yx(t,_x),i=yx(t,vx),a=yx(e,vx),o=+(t-e>Math.PI);return[`M ${n.x} ${n.y}`,`A ${_x} ${_x} 0 ${o} 1 ${r.x} ${r.y}`,`L ${i.x} ${i.y}`,`A ${vx} ${vx} 0 ${o} 0 ${a.x} ${a.y}`,`Z`].join(` `)}function xx(){let e=yx(-Math.PI/2,_x),t=yx(Math.PI/2,_x),n=yx(-Math.PI/2,vx),r=yx(Math.PI/2,vx);return[`M ${e.x} ${e.y}`,`A ${_x} ${_x} 0 1 1 ${t.x} ${t.y}`,`A ${_x} ${_x} 0 1 1 ${e.x} ${e.y}`,`L ${n.x} ${n.y}`,`A ${vx} ${vx} 0 1 0 ${r.x} ${r.y}`,`A ${vx} ${vx} 0 1 0 ${n.x} ${n.y}`,`Z`].join(` `)}function Sx(){let e=document.createElement(`div`);e.className=`chc-cd`;let t=document.createElementNS(mx,`svg`);t.setAttribute(`viewBox`,`0 0 ${hx} ${hx}`),t.setAttribute(`class`,`chc-cd__svg`),t.setAttribute(`role`,`img`);let n={};for(let e of ox){let r=document.createElementNS(mx,`path`);r.setAttribute(`class`,`chc-cd__arc`),r.setAttribute(`data-bucket`,e),t.appendChild(r);let i=document.createElementNS(mx,`title`);r.appendChild(i),n[e]=r}let r=document.createElement(`div`);return r.className=`chc-cd__total`,e.appendChild(t),e.appendChild(r),{element:e,update:i=>{let a=ux(i);if(e.style.display=a>0?`inline-flex`:`none`,!a)return;let o=ox.filter(e=>i[e]>0),s=-Math.PI/2;for(let e of ox){let t=i[e],r=n[e],c=r.querySelector(`title`);if(t===0){r.removeAttribute(`d`),c&&(c.textContent=``);continue}if(o.length===1)r.setAttribute(`d`,xx());else{let e=t/a,n=s+e*Math.PI*2;r.setAttribute(`d`,bx(s,n)),s=n}c&&(c.textContent=`${px[e]}: ${t}`)}r.textContent=String(a),t.setAttribute(`aria-label`,`Competitiveness across ${a} matches`)}}}function Cx(e){let{segments:t,onSegmentClick:n}=e,r=document.createElement(`div`);r.className=`chc-sb`;let i={},a={};for(let{key:e,label:o,color:s}of t){i[e]=o;let t=document.createElement(`div`);t.className=`chc-sb__seg`,t.dataset.key=e,t.style.setProperty(`--seg-bg`,s),n&&(t.classList.add(`is-clickable`),t.setAttribute(`role`,`button`),t.addEventListener(`click`,()=>n(e))),a[e]=t,r.appendChild(t)}return{element:r,update:e=>{let n=t.reduce((t,n)=>t+(e[n.key]||0),0);if(r.style.display=n>0?`flex`:`none`,n)for(let{key:n}of t){let t=a[n],r=e[n]||0;r===0?(t.style.flex=`0 0 0`,t.style.padding=`0`,t.textContent=``,t.removeAttribute(`title`)):(t.style.flex=`${r} 1 0`,t.style.padding=`0 4px`,t.textContent=String(r),t.title=`${i[n]}: ${r}`)}},setActive:e=>{r.classList.toggle(`has-active`,!!e);for(let{key:n}of t)a[n].classList.toggle(`is-active`,n===e)}}}var wx={cornerBadges:[`status`,`publishedBadge`,`embargoBadge`],body:[`title`,`drawTypeLabel`,`matchUpProgress`],footer:[`drawSize`,`entries`,`matchUpFormat`,`flightNumber`,`ratings`],showVisualization:!1};function Tx(e){return e?{cornerBadges:e.cornerBadges??wx.cornerBadges,body:e.body??wx.body,footer:e.footer??wx.footer,showVisualization:e.showVisualization??wx.showVisualization}:wx}var Ex=()=>`chc-dc-card`,Dx=()=>`chc-dc-card--clickable`,Ox=()=>`chc-dc-corner-badges`,kx=()=>`chc-dc-status-pill`,Ax=()=>`chc-dc-secondary-badge`,jx=()=>`chc-dc-body`,Mx=()=>`chc-dc-viz`,Nx=()=>`chc-dc-title-row`,Px=()=>`chc-dc-title`,Fx=()=>`chc-dc-draw-type`,Ix=()=>`chc-dc-meta`,Lx=()=>`chc-dc-footer`,Rx=()=>`chc-dc-chip`,zx=()=>`chc-dc-progress`,Bx=()=>`chc-dc-progress-bar`,Vx=()=>`chc-dc-progress-fill`,Hx=()=>`chc-dc-card chc-dc-skeleton`,Ux=()=>`chc-dc-skeleton-line`;function Wx(e,t,n){let r=Tx(t),i=document.createElement(`div`);if(i.className=Ex(),i.dataset.drawId=e.drawId,e.eventId&&(i.dataset.eventId=e.eventId),n?.onClick&&(i.classList.add(Dx()),i.tabIndex=0,i.addEventListener(`click`,t=>{t.stopPropagation(),n.onClick(e)}),i.addEventListener(`keydown`,t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),n.onClick(e))})),r.showVisualization&&e.visualization){let t=document.createElement(`div`);t.className=Mx(),t.appendChild(e.visualization),i.appendChild(t)}return(r.body.length||r.cornerBadges.length)&&i.appendChild(sS(e,r)),r.footer.length&&i.appendChild(cS(e,r)),i}function Gx(e){if(!e.status)return null;let t=document.createElement(`div`);return t.className=kx(),t.dataset.kind=e.status.kind,t.textContent=e.status.label,t}function Kx(e){if(!e.published)return null;let t=document.createElement(`div`);return t.className=Ax(),t.dataset.kind=`published`,t.textContent=`Published`,t}function qx(e){if(!e.embargoActive)return null;let t=document.createElement(`div`);return t.className=Ax(),t.dataset.kind=`embargo`,t.textContent=`Embargo`,t}function Jx(e,t){return e===`status`?Gx(t):e===`publishedBadge`?Kx(t):e===`embargoBadge`?qx(t):null}function Yx(e,t){let n=[];for(let r of t){let t=Jx(r,e);t&&n.push(t)}if(!n.length)return null;let r=document.createElement(`div`);r.className=Ox();for(let e of n)r.appendChild(e);return r}function Xx(e){if(!e.drawName)return null;let t=document.createElement(`div`);return t.className=Px(),t.textContent=e.drawName,t.title=e.drawName,t}function Zx(e){if(!e.drawTypeLabel)return null;let t=document.createElement(`div`);return t.className=Fx(),t.textContent=e.drawTypeLabel,t}function Qx(e){let t=document.createElement(`span`);return t.className=Rx(),t.textContent=e,t}function $x(e){return typeof e.drawSize==`number`?Qx(`Size ${e.drawSize}`):null}function eS(e){return typeof e.entryCount==`number`?Qx(`${e.entryCount} ${e.entryCount===1?`entry`:`entries`}`):null}function tS(e){return e.matchUpFormat?Qx(e.matchUpFormat):null}function nS(e){return typeof e.flightNumber==`number`?Qx(`Flight ${e.flightNumber}`):null}function rS(e){let t=[];if(typeof e.utrAvg==`number`&&t.push(`UTR ${e.utrAvg.toFixed(2)}`),typeof e.wtnAvg==`number`&&t.push(`WTN ${e.wtnAvg.toFixed(2)}`),!t.length)return null;let n=document.createElement(`div`);return n.className=Ix(),n.textContent=t.join(` · `),n}function iS(e){if(!e.matchUpCounts||e.matchUpCounts.total===0)return null;let{total:t,completed:n}=e.matchUpCounts,r=Math.round(n/t*100),i=document.createElement(`div`);i.className=zx();let a=document.createElement(`div`);a.className=Ix(),a.textContent=`${n}/${t} matches · ${r}%`,i.appendChild(a);let o=document.createElement(`div`);o.className=Bx();let s=document.createElement(`div`);return s.className=Vx(),s.style.right=`${100-r}%`,o.appendChild(s),i.appendChild(o),i}function aS(e,t){return e===`title`?Xx(t):e===`drawTypeLabel`?Zx(t):e===`drawSize`?$x(t):e===`entries`?eS(t):e===`matchUpFormat`?tS(t):e===`flightNumber`?nS(t):e===`ratings`?rS(t):e===`matchUpProgress`?iS(t):null}function oS(e,t){let n=document.createElement(`div`);n.className=Nx();let r=Xx(e);r&&n.appendChild(r);let i=Yx(e,t);return i&&n.appendChild(i),n}function sS(e,t){let n=document.createElement(`div`);n.className=jx();let r=t.body.includes(`title`),i=t.cornerBadges.length>0;if(i&&!r){let r=Yx(e,t.cornerBadges);r&&n.appendChild(r)}for(let r of t.body){if(r===`title`&&i){n.appendChild(oS(e,t.cornerBadges));continue}let a=aS(r,e);a&&n.appendChild(a)}return n}function cS(e,t){let n=document.createElement(`div`);n.className=Lx();for(let r of t.footer){let t=aS(r,e);t&&n.appendChild(t)}return n}function lS(){let e=document.createElement(`div`);e.className=Hx();let t=document.createElement(`div`);t.className=jx();for(let e of[`70%`,`40%`,`85%`]){let n=document.createElement(`div`);n.className=Ux(),n.style.width=e,t.appendChild(n)}return e.appendChild(t),e}var uS={SINGLE_ELIMINATION:`Single Elimination`,DOUBLE_ELIMINATION:`Double Elimination`,ELIMINATION:`Elimination`,ROUND_ROBIN:`Round Robin`,ROUND_ROBIN_WITH_PLAYOFF:`Round Robin + Playoff`,COMPASS:`Compass`,FEED_IN_CHAMPIONSHIP:`Feed-In Championship`,FIRST_MATCH_LOSER_CONSOLATION:`First Match Loser Consolation`,FIRST_ROUND_LOSER_CONSOLATION:`First Round Loser Consolation`,PLAY_OFF:`Play-Off`,CURTIS_CONSOLATION:`Curtis Consolation`,AD_HOC:`Ad-Hoc`,OLYMPIC:`Olympic`,LUCKY_DRAW:`Lucky Draw`,STAGGERED_ENTRY:`Staggered Entry`};function dS(e){if(e)return uS[e]?uS[e]:e.toLowerCase().split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function fS(e){let{matchUps:n=[]}=t.tournamentEngine.getAllDrawMatchUps({drawDefinition:e}),r=0,i=0,a=0,o=0;for(let e of n)e?.matchUpStatus!==`BYE`&&e?.matchUpStatus!==`DOUBLE_BYE`&&(r+=1,e?.winningSide?i+=1:e?.schedule?.scheduledTime&&(a+=1),e?.matchUpStatus===`IN_PROGRESS`&&(o+=1));return{total:r,completed:i,scheduled:a,inProgress:o}}function pS(e){let t=e?.drawSize;if(typeof t==`number`)return t;let n=(e?.structures?.find(e=>e?.stage===`MAIN`))?.positionAssignments?.length;return typeof n==`number`?n:void 0}function mS(e){if(e.cancelled)return{kind:`cancelled`,label:`Cancelled`};if(!e.generated)return{kind:`ungenerated`,label:`Not generated`};let t=e.matchUpCounts;return!t||t.total===0?{kind:`ready`,label:`Ready`}:t.completed===t.total?{kind:`completed`,label:`Completed`}:t.inProgress>0||t.completed>0?{kind:`in-progress`,label:`In progress`}:{kind:`ready`,label:`Ready`}}function hS(e,t){let n=Array.isArray(e?.structures)&&e.structures.length>0,r=t?.matchUpStats??(t?.lightMode||!n?void 0:fS(e)),i=e?.drawStatus===`CANCELLED`,a=t?.statusOverride===void 0?mS({generated:n,cancelled:i,matchUpCounts:r}):t.statusOverride;return{drawId:e?.drawId??``,drawName:e?.drawName??``,drawType:e?.drawType,drawTypeLabel:dS(e?.drawType),drawSize:pS(e),entryCount:t?.entryCount,matchUpFormat:e?.matchUpFormat,flightNumber:e?.flightNumber,matchUpCounts:r,generated:n,published:t?.published,embargoActive:t?.embargoActive,utrAvg:t?.utrAvg,wtnAvg:t?.wtnAvg,status:a,eventId:t?.eventId}}var gS={showImage:!0,cornerBadges:[`status`,`eventTypeBadge`,`genderBadge`],body:[`title`,`categoryLabel`,`drawSummary`],footer:[`playerCount`,`matchUpProgress`]},_S=15;function vS(e){return e?{showImage:e.showImage??gS.showImage,cornerBadges:e.cornerBadges??gS.cornerBadges,body:e.body??gS.body,footer:e.footer??gS.footer}:gS}var yS=()=>`chc-ec-card`,bS=()=>`chc-ec-card--clickable`,xS=()=>`chc-ec-image`,SS=()=>`chc-ec-image-img`,CS=()=>`chc-ec-image-svg`,wS=()=>`chc-ec-image-placeholder`,TS=()=>`chc-ec-corner-badges`,ES=()=>`chc-ec-status-pill`,DS=()=>`chc-ec-eventtype-badge`,OS=()=>`chc-ec-gender-badge`,kS=()=>`chc-ec-body`,AS=()=>`chc-ec-title`,jS=()=>`chc-ec-category`,MS=()=>`chc-ec-draw-summary`,NS=()=>`chc-ec-date-range`,PS=()=>`chc-ec-footer`,FS=()=>`chc-ec-player-count`,IS=()=>`chc-ec-progress`,LS=()=>`chc-ec-progress-meta`,RS=()=>`chc-ec-progress-bar`,zS=()=>`chc-ec-progress-fill`,BS=()=>`chc-ec-updated-at`,VS=()=>`chc-ec-card chc-ec-skeleton`,HS=()=>`chc-ec-skeleton-line`,US=()=>`chc-ec-skeleton-block`;function WS(e,t,n){let r=vS(t),i=document.createElement(`div`);return i.className=yS(),i.dataset.eventId=e.eventId,n?.onClick&&(i.classList.add(bS()),i.tabIndex=0,i.addEventListener(`click`,t=>{t.stopPropagation(),n.onClick(e)}),i.addEventListener(`keydown`,t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),n.onClick(e))})),r.showImage!==!1&&i.appendChild(KS(e,r)),r.body.length&&i.appendChild(oC(e,r)),r.footer.length&&i.appendChild(sC(e,r)),i}function GS(e,t){let n=bg(t.courtSvgSport,CS());if(n){e.appendChild(n);return}let r=document.createElement(`div`);r.className=wS(),e.appendChild(r)}function KS(e,t){let n=document.createElement(`div`);if(n.className=xS(),e.eventImageURL){let t=document.createElement(`img`);t.className=SS(),t.src=e.eventImageURL,t.alt=e.eventName||``,t.loading=`lazy`,t.addEventListener(`error`,()=>{t.remove(),GS(n,e)}),n.appendChild(t)}else GS(n,e);if(t.cornerBadges.length){let r=ZS(e,t.cornerBadges);r&&n.appendChild(r)}return n}function qS(e){if(!e.status)return null;let t=document.createElement(`div`);return t.className=ES(),t.dataset.kind=e.status.kind,t.textContent=e.status.label,t}function JS(e){if(!e.eventType)return null;let t=document.createElement(`div`);return t.className=DS(),t.dataset.kind=e.eventType,t.textContent=e.eventType,t}function YS(e){if(!e.gender)return null;let t=document.createElement(`div`);return t.className=OS(),t.dataset.kind=e.gender,t.textContent=e.gender===`MALE`?`M`:e.gender===`FEMALE`?`W`:`X`,t}function XS(e,t){return e===`status`?qS(t):e===`eventTypeBadge`?JS(t):e===`genderBadge`?YS(t):null}function ZS(e,t){let n=[];for(let r of t){let t=XS(r,e);t&&n.push(t)}if(!n.length)return null;let r=document.createElement(`div`);r.className=TS();for(let e of n)r.appendChild(e);return r}function QS(e){if(!e.eventName)return null;let t=document.createElement(`div`);return t.className=AS(),t.textContent=e.eventName,t.title=e.eventName,t}function $S(e){if(!e.categoryLabel)return null;let t=document.createElement(`div`);return t.className=jS(),t.textContent=e.categoryLabel,t}function eC(e){if(!e.drawSummary)return null;let t=document.createElement(`div`);return t.className=MS(),t.textContent=e.drawSummary,t}function tC(e){if(!e.dateRangeFormatted)return null;let t=document.createElement(`div`);return t.className=NS(),t.textContent=e.dateRangeFormatted,t}function nC(e){if(!e.updatedAt)return null;let t=document.createElement(`div`);t.className=BS();let n=new Date(e.updatedAt);return t.textContent=Number.isNaN(n.getTime())?e.updatedAt:n.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),t}function rC(e){if(typeof e.entryCount!=`number`)return null;let t=document.createElement(`div`);return t.className=FS(),t.textContent=`${e.entryCount} ${e.entryCount===1?`player`:`players`}`,t}function iC(e){if(!e.matchUpCounts||e.matchUpCounts.total===0)return null;let{total:t,completed:n}=e.matchUpCounts,r=Math.round(n/t*100),i=document.createElement(`div`);i.className=IS();let a=document.createElement(`div`);a.className=LS(),a.textContent=`${n}/${t} matches · ${r}%`,i.appendChild(a);let o=document.createElement(`div`);o.className=RS();let s=document.createElement(`div`);return s.className=zS(),s.style.right=`${100-r}%`,o.appendChild(s),i.appendChild(o),i}function aC(e,t){return e===`title`?QS(t):e===`categoryLabel`?$S(t):e===`drawSummary`?eC(t):e===`dateRange`?tC(t):e===`updatedAt`?nC(t):e===`playerCount`?rC(t):e===`matchUpProgress`?iC(t):null}function oC(e,t){let n=document.createElement(`div`);n.className=kS();for(let r of t.body){let t=aC(r,e);t&&n.appendChild(t)}return n}function sC(e,t){let n=document.createElement(`div`);n.className=PS();for(let r of t.footer){let t=aC(r,e);t&&n.appendChild(t)}return n}function cC(e){let t=vS(e);return zg({showImage:t.showImage!==!1,bodyLines:t.body.length,showFooter:t.footer.length>0,cardClass:VS(),imageClass:xS(),bodyClass:kS(),footerClass:PS(),blockClass:US(),lineClass:HS()})}function lC(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function uC(e,t,n){return!t||!n?!1:t.getTime()<=e.getTime()&&e.getTime()<=n.getTime()}function dC(e,t=new Date){if(e.allDrawsCancelled)return{kind:`cancelled`,label:`Cancelled`};let n=e.matchUpCounts;if(n&&n.total>0&&n.completed===n.total)return{kind:`completed`,label:`Completed`};let r=lC(e.startDate),i=lC(e.endDate);if(n&&(n.inProgress>0||uC(t,r,i)&&n.total>0))return{kind:`live`,label:`Live`};let a=e.drawCount??0;return a>0&&(e.hasDraftState||e.hasSeedsOnlyDraw)?{kind:`drawing`,label:`Drawing`}:a===0&&(e.entryCount??0)>0?{kind:`entries-open`,label:`Entries Open`}:r&&t.getTime()<r.getTime()?{kind:`upcoming`,label:`Upcoming`}:null}var fC=`eventImage`,pC=`DRAFT_STATE`;function mC(e){if(!e)return;let t=String(e).toUpperCase();if(t===`SINGLES`||t===`DOUBLES`||t===`TEAM`||t===`HYBRID`)return t}function hC(e){if(!e)return;let t=String(e).toUpperCase();if(t===`M`||t===`MALE`)return`MALE`;if(t===`F`||t===`FEMALE`)return`FEMALE`;if(t===`MIXED`||t===`X`)return`MIXED`}function gC(e){if(!e)return;let t=_C(e.categoryName);if(t)return t;if(typeof e.ageMin==`number`&&typeof e.ageMax==`number`)return e.ageMin===e.ageMax?`Age ${e.ageMin}`:`Age ${e.ageMin}–${e.ageMax}`;let n=_C(e.ageCategoryCode);if(n)return n;if(e.ratingMin&&e.ratingMax)return`Rating ${e.ratingMin}–${e.ratingMax}`}function _C(e){if(typeof e!=`string`)return;let t=e.trim();if(t&&!/^[-—–_]+$/.test(t))return t}function vC(e){if(!e.length)return;let t=e.find(Boolean);if(!t)return;let n=[];return typeof t.drawSize==`number`&&n.push(String(t.drawSize)),t.drawType&&n.push(String(t.drawType)),e.length>1&&n.push(`+${e.length-1}`),n.length?n.join(` `):void 0}function yC(e){let{matchUps:n=[]}=t.tournamentEngine.allEventMatchUps({event:e,inContext:!1})??{},r=0,i=0,a=0,o=0;for(let e of n)e?.matchUpStatus!==`BYE`&&e?.matchUpStatus!==`DOUBLE_BYE`&&(r+=1,e?.winningSide?i+=1:e?.schedule?.scheduledTime&&(a+=1),e?.matchUpStatus===`IN_PROGRESS`&&(o+=1));return{total:r,completed:i,scheduled:a,inProgress:o}}function bC(e){if(e?.draftState!=null)return!0;let t=e?.extensions;return Array.isArray(t)?t.some(e=>e?.name===pC):!1}function xC(e){return e.some(e=>e?.automated?.seedsOnly===!0||bC(e))}function SC(e){return e.length!==0&&e.every(e=>e?.drawStatus===`CANCELLED`)}var CC=new Set([`DIRECT_ACCEPTANCE`,`DA`,`DIRECT_CONFIRMED`,`DC`,`ACCEPTED`,`A`,`ENTERED`,`PE`,`QUALIFIER`,`Q`,`WILDCARD`,`WC`]);function wC(e){if(!e.length)return 0;let t=0;for(let n of e)CC.has(String(n?.entryStatus))&&(t+=1);return t}function TC(e,t){let n=Array.isArray(e?.drawDefinitions)?e.drawDefinitions:[],r=Array.isArray(e?.entries)?e.entries:[],i=Array.isArray(e?.onlineResources)?e.onlineResources:void 0,a=t?.matchUpStats??(t?.lightMode?void 0:yC(e)),o=t?.statusOverride===void 0?dC({allDrawsCancelled:SC(n),drawCount:n.length,entryCount:wC(r),startDate:e?.startDate,endDate:e?.endDate,matchUpCounts:a,hasDraftState:n.some(bC),hasSeedsOnlyDraw:xC(n)},t?.now):t.statusOverride;return{eventId:e?.eventId??``,eventName:e?.eventName??``,eventAbbreviation:e?.eventAbbreviation,categoryLabel:gC(e?.category),eventType:mC(e?.eventType),gender:hC(e?.gender),drawCount:n.length||void 0,drawSummary:vC(n),entryCount:wC(r)||void 0,matchUpCounts:a,startDate:e?.startDate,endDate:e?.endDate,dateRangeFormatted:Mg(e?.startDate,e?.endDate),status:o,eventImageURL:e?.eventImageURL??Fg(i,fC),courtSvgSport:e?.courtSvgSport??Ig(i)??t?.sport,updatedAt:e?.updatedAt}}var EC=()=>`chc-hil-container`,DC=()=>`chc-hil-form`,OC=()=>`chc-hil-header`,kC=()=>`chc-hil-title`,AC=()=>`chc-hil-tabs`,jC=()=>`chc-hil-tab`,MC=()=>`chc-hil-tab--active`,NC=()=>`chc-hil-field`,PC=()=>`chc-hil-label`,FC=()=>`chc-hil-input`,IC=()=>`chc-hil-row`,LC=()=>`chc-hil-submit`,RC=()=>`chc-hil-message`,zC=()=>`chc-hil-message--error`,BC=()=>`chc-hil-message--success`,VC=()=>`chc-hil-switch-mode`;function HC(e){return e.replace(/\/+$/,``)}async function UC(e,t,n,r=fetch){let i=HC(e)+t,a;try{a=await r(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})}catch(e){throw{kind:`network`,cause:e}}let o=null;try{o=await a.json()}catch(e){if(a.ok)throw{kind:`parse`,cause:e}}if(!a.ok)throw{kind:`http`,status:a.status,body:o};return o}function WC(e,t,n){return UC(e,`/auth/hiveid/signup`,t,n)}function GC(e,t,n){return UC(e,`/auth/hiveid/verify-existing`,t,n)}function KC(e,t,n){return UC(e,`/auth/hiveid/magic-link`,t,n)}function qC(e,t,n){return UC(e,`/auth/hiveid/magic-link/consume`,t,n)}function JC(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.kind!==`http`||t.status!==409?!1:t.body?.code===`EXISTING_USER`}var YC=[{value:`M`,label:`Male`},{value:`F`,label:`Female`}],XC=`signup`,ZC=`login`,QC=`magic-link`,$C=[XC,ZC,QC],ew=`hiveid:authenticated`,tw={[XC]:`Sign up`,[ZC]:`Log in`,[QC]:`Email link`},nw={[XC]:`Create your CourtHive identity`,[ZC]:`Log in to CourtHive`,[QC]:`Email me a sign-in link`};function rw(e){if(!e?.cfsBaseUrl)throw Error(`buildHiveIDLogin: cfsBaseUrl is required`);let t=e.mode??`signup`,n=!1,r=document.createElement(`div`);r.className=EC(),r.dataset.hiveidLogin=`true`;let i=document.createElement(`div`);i.className=OC();let a=document.createElement(`h2`);a.className=kC(),i.appendChild(a);let o=document.createElement(`div`);o.className=AC(),i.appendChild(o);let s={};$C.forEach(e=>{let t=document.createElement(`button`);t.type=`button`,t.className=jC(),t.textContent=tw[e],t.dataset.mode=e,t.onclick=()=>w(e),o.appendChild(t),s[e]=t}),r.appendChild(i);let c=document.createElement(`form`);c.className=DC(),c.noValidate=!0,r.appendChild(c);let l=document.createElement(`div`);l.className=RC(),l.hidden=!0,r.appendChild(l);function u(e,t=`info`){l.textContent=e,l.className=RC(),t===`error`&&l.classList.add(zC()),t===`success`&&l.classList.add(BC()),l.hidden=!e}function d(){u(``)}function f(e,t,n=`text`,r=``){let i=document.createElement(`div`);i.className=NC();let a=document.createElement(`label`);a.className=PC(),a.textContent=t,a.htmlFor=`chc-hil-${e}`;let o=document.createElement(`input`);return o.id=`chc-hil-${e}`,o.name=e,o.type=n,o.value=r,o.className=FC(),o.required=!0,i.appendChild(a),i.appendChild(o),c.appendChild(i),o}function p(){let e=document.createElement(`div`);return e.className=IC(),c.appendChild(e),e}function m(e){let t=document.createElement(`button`);return t.type=`submit`,t.className=LC(),t.textContent=e,c.appendChild(t),t}function h(e,t,n){let r=document.createElement(`div`);r.className=VC();let i=document.createElement(`button`);i.type=`button`,i.textContent=n,i.onclick=()=>w(t),r.append(e+` `,i),c.appendChild(r)}function g(e){if(e.note){let t=document.createElement(`p`);t.className=PC(),t.textContent=e.note,c.appendChild(t)}let t=null;if(e.providers.length>1){let n=document.createElement(`div`);n.className=NC();let r=document.createElement(`label`);r.className=PC(),r.textContent=`Provider`,r.htmlFor=`chc-hil-fedProvider`;let i=document.createElement(`select`);i.id=`chc-hil-fedProvider`,i.className=FC(),e.providers.forEach(e=>{let t=document.createElement(`option`);t.value=e.value,t.textContent=e.label,i.appendChild(t)}),n.append(r,i),c.appendChild(n),t=i}let n=document.createElement(`div`);n.className=NC();let r=document.createElement(`label`);r.className=PC(),r.textContent=e.idLabel??`Player ID`,r.htmlFor=`chc-hil-federationId`;let i=document.createElement(`input`);i.id=`chc-hil-federationId`,i.type=`text`,i.className=FC(),n.append(r,i),c.appendChild(n);let a=e.providers[0]?.value??``;return()=>{let e=i.value.trim();if(!e)return null;let n=t?t.value:a;return n?{provider:n,externalId:e}:null}}function _(e){if(e.note){let t=document.createElement(`p`);t.className=PC(),t.textContent=e.note,c.appendChild(t)}let t=e.required!==!1,n=document.createElement(`div`);n.className=NC();let r=document.createElement(`label`);r.className=PC(),r.textContent=e.dobLabel??`Date of birth`,r.htmlFor=`chc-hil-birthDate`;let i=document.createElement(`input`);i.id=`chc-hil-birthDate`,i.type=`date`,i.required=t,i.className=FC(),n.append(r,i),c.appendChild(n);let a=document.createElement(`div`);a.className=NC();let o=document.createElement(`label`);o.className=PC(),o.textContent=e.sexLabel??`Sex`,o.htmlFor=`chc-hil-sex`;let s=document.createElement(`select`);s.id=`chc-hil-sex`,s.required=t,s.className=FC();let l=document.createElement(`option`);return l.value=``,l.textContent=`Select…`,s.appendChild(l),(e.sexOptions??YC).forEach(e=>{let t=document.createElement(`option`);t.value=e.value,t.textContent=e.label,s.appendChild(t)}),a.append(o,s),c.appendChild(a),()=>ow({birthDate:i.value,sex:s.value})}function v(e){r.dispatchEvent(new CustomEvent(ew,{detail:e,bubbles:!0}))}function y(e,t){return async r=>{if(r.preventDefault(),!n){n=!0,e.disabled=!0,d();try{await t()}finally{n=!1,e.disabled=!1}}}}async function b(t,n,r,i={}){let a=t.value.trim(),o=n.value.trim(),s=r.value.trim();if(!a||!o||!s){u(`Email, first name, and last name are required.`,`error`);return}let{federationIds:c,birthDate:l,sex:d,provider:f,requirePii:p}=i;if(p&&(!l||!d)){u(`Date of birth and sex are required.`,`error`);return}try{let t=await WC(e.cfsBaseUrl,{email:a,firstName:o,lastName:s,federationIds:c,birthDate:l,sex:d,provider:f},e.fetchImpl);if(t.status===`candidate`){u(`We found possible matches — please log in with your existing account.`,`info`),w(`login`);return}v({token:t.token,refreshToken:t.refreshToken,personId:t.personId,cached:t.cached}),u(`Welcome to CourtHive.`,`success`)}catch(e){if(JC(e)){u(`That email already has a CourtHive account — please verify your password.`,`info`),w(`login`);return}u(cw(e)??`Sign-up failed. Please try again.`,`error`)}}async function x(t,n){let r=t.value.trim(),i=n.value;if(!r||!i){u(`Email and password are required.`,`error`);return}try{let t=await GC(e.cfsBaseUrl,{email:r,password:i},e.fetchImpl);v({token:t.token,refreshToken:t.refreshToken,personId:t.personId,cached:t.cached??sw()}),u(`Signed in.`,`success`)}catch(e){u(cw(e)??`Sign-in failed. Please check your password.`,`error`)}}async function S(t){let n=t.value.trim();if(!n){u(`Email is required.`,`error`);return}try{await KC(e.cfsBaseUrl,{email:n},e.fetchImpl),u(`If ${n} is registered, a sign-in link is on its way.`,`success`)}catch(e){u(cw(e)??`Could not send link. Please try again.`,`error`)}}function C(){if(c.replaceChildren(),a.textContent=nw[t],$C.forEach(e=>{s[e].classList.toggle(MC(),e===t)}),t===`signup`){let t=p(),n=document.createElement(`input`);n.id=`chc-hil-firstName`,n.type=`text`,n.placeholder=`First name`,n.required=!0,n.className=FC();let r=document.createElement(`input`);r.id=`chc-hil-lastName`,r.type=`text`,r.placeholder=`Last name`,r.required=!0,r.className=FC();let i=document.createElement(`div`);i.className=NC();let a=document.createElement(`label`);a.textContent=`First name`,a.className=PC(),a.htmlFor=n.id,i.append(a,n);let o=document.createElement(`div`);o.className=NC();let s=document.createElement(`label`);s.textContent=`Last name`,s.className=PC(),s.htmlFor=r.id,o.append(s,r),t.append(i,o);let l=f(`email`,`Email`,`email`,e.defaultEmail??``),u=e.federationIdCapture?g(e.federationIdCapture):()=>null,d=e.dobSexCapture?_(e.dobSexCapture):()=>({}),v=!!e.dobSexCapture&&e.dobSexCapture.required!==!1,x=m(`Create account`);c.onsubmit=y(x,()=>b(l,n,r,{federationIds:aw(u(),e.federationIds),...d(),provider:e.provider,requirePii:v})),h(`Already have an account?`,`login`,`Log in`)}else if(t===`login`){let t=f(`email`,`Email`,`email`,e.defaultEmail??``),n=f(`password`,`Password`,`password`),r=m(`Log in`);c.onsubmit=y(r,()=>x(t,n)),h(`Forgot your password?`,`magic-link`,`Email me a link`)}else{let t=f(`email`,`Email`,`email`,e.defaultEmail??``),n=m(`Send link`);c.onsubmit=y(n,()=>S(t)),h(`Have a password?`,`login`,`Log in instead`)}}function w(e){e!==t&&(t=e,d(),C())}function T(){return t}function E(e){let t=t=>e(t.detail);return r.addEventListener(ew,t),()=>r.removeEventListener(ew,t)}return C(),{root:r,setMode:w,getMode:T,onAuthenticated:E}}async function iw(e,t,n){let r=await qC(e,{code:t},n);return{token:r.token,refreshToken:r.refreshToken,personId:r.personId,cached:r.cached??sw()}}function aw(e,t){let n=[],r=new Set,i=e=>{if(!e?.provider||!e?.externalId)return;let t=`${e.provider}::${e.externalId}`;r.has(t)||(r.add(t),n.push({provider:e.provider,externalId:e.externalId}))};return(t??[]).forEach(i),i(e),n.length?n:void 0}function ow(e){let t={},n=e.birthDate?.trim(),r=e.sex?.trim();return n&&(t.birthDate=n),r&&(t.sex=r),t}function sw(){return{standardFamilyName:null,standardGivenName:null,birthDate:null,sex:null,nationalityCode:null}}function cw(e){if(!e||typeof e!=`object`)return null;if(e.kind===`http`){let t=e.body;if(t?.message&&typeof t.message==`string`)return t.message;if(typeof t?.status==`string`&&t.status===`incomplete`)return`We need a bit more information to identify you.`}return e.kind===`network`?`Could not reach CourtHive. Check your connection.`:null}var lw={name:`courthive-components`,packageManager:`pnpm@12.5.1`,version:`6.0.1`,engines:{node:`>=22`},description:`Components for competitions projects`,files:[`dist`],main:`./dist/courthive-components.umd.js`,module:`./dist/courthive-components.es.js`,types:`./dist/index.d.ts`,exports:{".":{types:`./dist/index.d.ts`,import:`./dist/courthive-components.es.js`,require:`./dist/courthive-components.umd.js`},"./dist/*":`./dist/*`},repository:{type:`git`,url:`git+https://github.com/CourtHive/courthive-components.git`},keywords:[`tournament`,`match`,`score`,`vanillajs`,`bracket`],author:`Charles Allen`,license:`MIT`,bugs:{url:`https://github.com/CourtHive/courthive-components/issues`},homepage:`https://courthive.github.io/courthive-component`,scripts:{commits:`git log $(git describe --tags --abbrev=0)..HEAD --oneline --no-merges --pretty=format:'%s: %h' | sed '/courthive-components/d'`,release:`npm run release:patch`,test:`vitest run`,"test:watch":`vitest`,"test:ui":`vitest --ui`,dev:`vite`,build:`tsc && vite build`,"check-types":`tsc --noEmit`,prepublishOnly:`pnpm build`,preview:`vite preview`,storybook:`storybook dev -p 6006`,"build-storybook":`storybook build`,"test-storybook":`test-storybook --url http://localhost:6006`,"deploy-storybook":`gh-pages -d storybook-static`,"pre-commit":`lint-staged`,predeploy:`pnpm build-storybook`,lint:`eslint src --cache --max-warnings 0`,"lint:fix":`eslint src --fix --cache`,"lint:report":`eslint src & eslint --cache src -f json > eslint-report.json`,format:`prettier --write src`,"release:major":`npm run commits && npm version $(semver $npm_package_version -i major) && git push && git push --tags`,"release:minor":`npm run commits && npm version $(semver $npm_package_version -i minor) && git push && git push --tags`,"release:patch":`npm run commits && npm version $(semver $npm_package_version -i patch) && git push && git push --tags`,"release:beta":`npm run commits && npm version $(semver $npm_package_version -i prerelease --preid beta) && git push && git push --tags`,"patch:beta":`npm run commits && npm version $(semver $npm_package_version -i prerelease --preid beta) && npm publish --tag beta`},"lint-staged":{"*.{js,ts}":`eslint --cache --fix`,"*":`prettier --ignore-unknown --write`},devDependencies:{"@chromatic-com/storybook":`^5.0.0`,"@commitlint/cli":`21.2.3`,"@commitlint/config-conventional":`21.2.3`,"@eslint/js":`^10.0.1`,"@fortawesome/fontawesome-free":`^7.2.0`,"@storybook/addon-docs":`^10.2.17`,"@storybook/html-vite":`^10.2.17`,"@storybook/test-runner":`^0.24.0`,"@types/d3":`^7.4.3`,"@types/leaflet":`^1.9.12`,"@types/vanillajs-datepicker":`^1.3.5`,"@typescript-eslint/eslint-plugin":`8.70.0`,"@typescript-eslint/parser":`8.70.0`,"@vitest/coverage-v8":`^5.0.0`,"@vitest/ui":`^5.0.0`,eslint:`10.11.0`,"eslint-plugin-sonarjs":`4.2.1`,"eslint-plugin-storybook":`^10.2.17`,"gh-pages":`6.3.0`,globals:`^17.3.0`,"happy-dom":`^20.8.3`,husky:`9.1.7`,leaflet:`1.9.4`,"lint-staged":`17.5.1`,playwright:`^1.57.0`,prettier:`^3.8.1`,semver:`7.8.5`,storybook:`^10.2.17`,"tabulator-tables":`6.5.3`,"tods-competition-factory":`7.1.1`,typescript:`^6.0.2`,vite:`8.3.0`,"vite-plugin-dts":`^5.0.0`,vitest:`^5.0.0`},dependencies:{"@tiptap/core":`^3.22.2`,"@tiptap/extension-color":`^3.22.2`,"@tiptap/extension-highlight":`^3.22.2`,"@tiptap/extension-text-align":`^3.22.2`,"@tiptap/extension-text-style":`^3.22.2`,"@tiptap/extension-youtube":`^3.22.2`,"@tiptap/starter-kit":`^3.22.2`,awesomplete:`1.1.7`,"class-variance-authority":`0.7.1`,classnames:`2.5.1`,d3:`^7.9.0`,dayjs:`1.11.23`,"focus-trap":`^8.0.0`,"timepicker-ui":`^4.1.2`,"tippy.js":`6.3.7`,"vanillajs-datepicker":`1.3.4`},peerDependencies:{"tods-competition-factory":`^7.1.0`,leaflet:`^1.9.4`},peerDependenciesMeta:{leaflet:{optional:!0}}};function uw(){return lw.version}var dw={SET3_S6_TB7:`SET3-S:6/TB7`,SET3_S6_TB7_F_TB10:`SET3-S:6/TB7-F:TB10`,SET3_S6_TB10:`SET3-S:6/TB10`,SET3_S6_F_TB10:`SET3-S:6-F:TB10`,SET3_S6_TB7_NOAD:`SET3-S:6/TB7NOAD`,SET3_S8_TB7:`SET3-S:8/TB7`,SET3_S8_TB7_AT7:`SET3-S:8/TB7@7`,SET3_S4_TB7:`SET3-S:4/TB7`,SET3_S4_TB7_F_TB10:`SET3-S:4/TB7-F:TB10`,SET3_S4_TB5_AT3_F_TB10:`SET3-S:4/TB5@3-F:TB10`,SET5_S6_TB7:`SET5-S:6/TB7`,SET5_S6_TB7_F_TB10:`SET5-S:6/TB7-F:TB10`,SET1_S6_TB7:`SET1-S:6/TB7`,SET1_S6_TB10:`SET1-S:6/TB10`,SET1_S6_TB7_AT5:`SET1-S:6/TB7@5`,SET1_S8_TB7:`SET1-S:8/TB7`,SET1_S4_TB7:`SET1-S:4/TB7`,SET1_S5_TB9_AT4:`SET1-S:5/TB9@4`,SET1_S_TB7:`SET1-S:T7`,SET1_S_TB10:`SET1-S:TB10`,SET1_S_TB21:`SET1-S:T21`,SET1_S8:`SET1-S:8`,SET1_S10:`SET1-S:10`,FAST4:`SET5-S:4/NOAD`,SET3X_T10A_TB1:`SET3XA-S:T10-F:TB1`,SET3X_T10A_TB1_NOAD:`SET3XA-S:T10-F:TB1NOAD`,SET4X_T10A_TB1:`SET4XA-S:T10-F:TB1`};function fw(e,t,n){if(!e)return{elements:{}};let r={};for(let i of t||[]){if(!i?.label||i.hide)continue;let t=document.createElement(`button`);i.id&&(r[i.id]=t,t.id=i.id),t.style.marginRight=`.5em`,t.className=`button font-medium`,i.intent&&t.classList.add(i.intent),t.innerHTML=i.label,i.disabled&&(t.disabled=!0),t.onclick=e=>{e.stopPropagation(),!e.target.disabled&&V(i.onClick)&&i.onClick(),n&&V(n)&&n()},e.appendChild(t)}return{elements:r}}var pw=(e,t)=>n=>n?.trim().length>=e&&(!t||n?.trim().length<=t);function mw(e){return t.tools.isConvertableInteger(e)&&parseInt(e.toString())>=0}var hw=(e,t)=>n=>mw(n)&&Number(n)>=e&&Number(n)<=t,gw=e=>/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?\d)(?=.*?[#?!@$%^&*-]).{8,12}$/.test(e);function _w(e){return t.tools.dateTime.dateValidation.test(e)}var vw=(e,t)=>n=>{let r=(n||``).trim().split(` `).length;return r>=e&&(!t||r<=t)},yw=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,bw=e=>yw.exec(e),xw=_({dateValidator:()=>_w,emailValidator:()=>bw,nameValidator:()=>pw,numericRange:()=>hw,numericValidator:()=>mw,passwordValidator:()=>gw,wordValidator:()=>vw}),Sw=class{constructor({tournamentRecord:e,drawId:n,structureId:r,eventId:i}){this.tournamentRecord=e,this.drawId=n,this.structureId=r,this.eventId=i||e.events?.[0]?.eventId,t.tournamentEngine.setState(e)}setRenderCallback(e){this.renderCallback=e}getDrawEntryParticipantIds(){let{event:e,drawDefinition:n}=t.tournamentEngine.getEvent({drawId:this.drawId})||{};if(!e)return[];let{flightProfile:r}=t.tournamentEngine.getFlightProfile({eventId:this.eventId})||{};return(r?.flights?.find(e=>e.drawId===this.drawId)?.drawEntries||n?.entries||[]).map(e=>e.participantId).filter(Boolean)}getAllParticipants(){t.tournamentEngine.setState(this.tournamentRecord);let e=this.getDrawEntryParticipantIds();if(!e.length)return[];let{participants:n=[]}=t.tournamentEngine.getParticipants({participantFilters:{participantIds:e}})||{};return n.map(e=>({participantId:e.participantId,participantName:e.participantName,participantType:e.participantType,person:e.person,individualParticipants:e.individualParticipants}))}getAvailableParticipants(){t.tournamentEngine.setState(this.tournamentRecord);let e=this.getAllParticipants(),{assignedParticipantIds:n=[]}=t.tournamentEngine.getAssignedParticipantIds({drawId:this.drawId})||{};return e.filter(e=>!n.includes(e.participantId))}removeAssignment({drawPosition:e}){t.tournamentEngine.setState(this.tournamentRecord);let n=this.getMatchUps().find(t=>t.sides?.some(t=>t.drawPosition===e))?.sides?.find(t=>t.drawPosition===e)?.bye===!0,r=t.tournamentEngine.removeDrawPositionAssignment({drawId:this.drawId,structureId:this.structureId,drawPosition:e});if(r.error)return{success:!1,error:r.error};let{tournamentRecord:i}=t.tournamentEngine.getState()||{};return this.tournamentRecord=i,n&&this.renderCallback&&this.renderCallback(),{success:!0}}assignParticipant({drawPosition:e,participantId:n}){t.tournamentEngine.setState(this.tournamentRecord);let r=t.tournamentEngine.assignDrawPosition({drawId:this.drawId,structureId:this.structureId,drawPosition:e,participantId:n});if(r.error)return{success:!1,error:r.error};let{tournamentRecord:i}=t.tournamentEngine.getState()||{};return this.tournamentRecord=i,this.focusDrawPosition=e+1,this.renderCallback&&this.renderCallback(),{success:!0}}getAndClearFocusDrawPosition(){let e=this.focusDrawPosition;return this.focusDrawPosition=void 0,e}assignBye({drawPosition:e}){t.tournamentEngine.setState(this.tournamentRecord);let n=t.tournamentEngine.assignDrawPositionBye({drawId:this.drawId,structureId:this.structureId,drawPosition:e});if(n.error)return{success:!1,error:n.error};let{tournamentRecord:r}=t.tournamentEngine.getState()||{};return this.tournamentRecord=r,this.focusDrawPosition=e+1,this.renderCallback&&this.renderCallback(),{success:!0}}assignQualifier({drawPosition:e}){t.tournamentEngine.setState(this.tournamentRecord);let n=t.tournamentEngine.assignDrawPosition({drawId:this.drawId,structureId:this.structureId,drawPosition:e,qualifier:!0});if(n.error)return{success:!1,error:n.error};let{tournamentRecord:r}=t.tournamentEngine.getState()||{};return this.tournamentRecord=r,this.focusDrawPosition=e+1,this.renderCallback&&this.renderCallback(),{success:!0}}getMatchUps(){t.tournamentEngine.setState(this.tournamentRecord);let{eventData:e}=t.tournamentEngine.getEventData({eventId:this.eventId})||{},n=(e?.drawsData?.find(e=>e.drawId===this.drawId))?.structures?.find(e=>e.structureId===this.structureId)?.roundMatchUps;return n?Object.values(n).flat():[]}getState(){return this.tournamentRecord}getContext(){return{drawId:this.drawId,structureId:this.structureId}}},Cw=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="14" height="14" fill="currentColor"><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM175 175c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z"/></svg>`,ww=new WeakMap;function Tw(e,t){let n=document.createElement(`div`);n.style.cssText=`position: relative; flex: 1; display: flex; min-width: 0;`,e.style.paddingRight=`28px`,n.appendChild(e);let r=document.createElement(`button`);r.type=`button`,r.setAttribute(`aria-label`,`Clear search`),r.style.cssText=[`position: absolute`,`right: 8px`,`top: 50%`,`transform: translateY(-50%)`,`background: transparent`,`border: 0`,`padding: 2px`,`cursor: pointer`,`display: none`,`align-items: center`,`justify-content: center`,`line-height: 0`,`opacity: 0.55`,`color: currentColor`].join(`; `),r.innerHTML=Cw,r.addEventListener(`mouseenter`,()=>r.style.opacity=`0.9`),r.addEventListener(`mouseleave`,()=>r.style.opacity=`0.55`),r.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),t(),i()});let i=()=>{r.style.display=e.value?`inline-flex`:`none`};return e.addEventListener(`keyup`,n=>{n.key===`Escape`&&e.value&&(t(),i())}),e.addEventListener(`input`,i),ww.set(n,i),n.appendChild(r),n}function Ew(e){ww.get(e)?.()}function Dw(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Ow(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function kw(e){let t,n,r;e.length===2?(t=e===Dw||e===Ow?e:Aw,n=e,r=e):(t=Dw,n=(t,n)=>Dw(e(t),n),r=(t,n)=>e(t)-n);function i(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<0?i=t+1:a=t}while(i<a)}return i}function a(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<=0?i=t+1:a=t}while(i<a)}return i}function o(e,t,n=0,a=e.length){let o=i(e,t,n,a-1);return o>n&&r(e[o-1],t)>-r(e[o],t)?o-1:o}return{left:i,center:o,right:a}}function Aw(){return 0}function jw(e){return e===null?NaN:+e}var Mw=kw(Dw),Nw=Mw.right;Mw.left,kw(jw).center;function Pw(e,t){let n,r;if(t===void 0)for(let t of e)t!=null&&(n===void 0?t>=t&&(n=r=t):(n>t&&(n=t),r<t&&(r=t)));else{let i=-1;for(let a of e)(a=t(a,++i,e))!=null&&(n===void 0?a>=a&&(n=r=a):(n>a&&(n=a),r<a&&(r=a)))}return[n,r]}var Fw=class extends Map{constructor(e,t=zw){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(let[t,n]of e)this.set(t,n)}get(e){return super.get(Iw(this,e))}has(e){return super.has(Iw(this,e))}set(e,t){return super.set(Lw(this,e),t)}delete(e){return super.delete(Rw(this,e))}};function Iw({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):n}function Lw({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function Rw({_intern:e,_key:t},n){let r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function zw(e){return typeof e==`object`&&e?e.valueOf():e}var Bw=Math.sqrt(50),Vw=Math.sqrt(10),Hw=Math.sqrt(2);function Uw(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=Bw?10:a>=Vw?5:a>=Hw?2:1,s,c,l;return i<0?(l=10**-i/o,s=Math.round(e*l),c=Math.round(t*l),s/l<e&&++s,c/l>t&&--c,l=-l):(l=10**i*o,s=Math.round(e/l),c=Math.round(t/l),s*l<e&&++s,c*l>t&&--c),c<s&&.5<=n&&n<2?Uw(e,t,n*2):[s,c,l]}function Ww(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];let r=t<e,[i,a,o]=r?Uw(t,e,n):Uw(e,t,n);if(!(a>=i))return[];let s=a-i+1,c=Array(s);if(r){if(o<0)for(let e=0;e<s;++e)c[e]=(a-e)/-o;else for(let e=0;e<s;++e)c[e]=(a-e)*o}else if(o<0)for(let e=0;e<s;++e)c[e]=(i+e)/-o;else for(let e=0;e<s;++e)c[e]=(i+e)*o;return c}function Gw(e,t,n){return t=+t,e=+e,n=+n,Uw(e,t,n)[2]}function Kw(e,t,n){t=+t,e=+e,n=+n;let r=t<e,i=r?Gw(t,e,n):Gw(e,t,n);return(r?-1:1)*(i<0?1/-i:i)}function qw(e,t){let n;if(t===void 0)for(let t of e)t!=null&&(n<t||n===void 0&&t>=t)&&(n=t);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n<i||n===void 0&&i>=i)&&(n=i)}return n}function Jw(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r<i;)a[r]=e+r*n;return a}function Yw(e){return e}var Xw=1,Zw=2,Qw=3,$w=4,eT=1e-6;function tT(e){return`translate(`+e+`,0)`}function nT(e){return`translate(0,`+e+`)`}function rT(e){return t=>+e(t)}function iT(e,t){return t=Math.max(0,e.bandwidth()-t*2)/2,e.round()&&(t=Math.round(t)),n=>+e(n)+t}function aT(){return!this.__axis}function oT(e,t){var n=[],r=null,i=null,a=6,o=6,s=3,c=typeof window<`u`&&window.devicePixelRatio>1?0:.5,l=e===Xw||e===$w?-1:1,u=e===$w||e===Zw?`x`:`y`,d=e===Xw||e===Qw?tT:nT;function f(f){var p=r??(t.ticks?t.ticks.apply(t,n):t.domain()),m=i??(t.tickFormat?t.tickFormat.apply(t,n):Yw),h=Math.max(a,0)+s,g=t.range(),_=+g[0]+c,v=+g[g.length-1]+c,y=(t.bandwidth?iT:rT)(t.copy(),c),b=f.selection?f.selection():f,x=b.selectAll(`.domain`).data([null]),S=b.selectAll(`.tick`).data(p,t).order(),C=S.exit(),w=S.enter().append(`g`).attr(`class`,`tick`),T=S.select(`line`),E=S.select(`text`);x=x.merge(x.enter().insert(`path`,`.tick`).attr(`class`,`domain`).attr(`stroke`,`currentColor`)),S=S.merge(w),T=T.merge(w.append(`line`).attr(`stroke`,`currentColor`).attr(u+`2`,l*a)),E=E.merge(w.append(`text`).attr(`fill`,`currentColor`).attr(u,l*h).attr(`dy`,e===Xw?`0em`:e===Qw?`0.71em`:`0.32em`)),f!==b&&(x=x.transition(f),S=S.transition(f),T=T.transition(f),E=E.transition(f),C=C.transition(f).attr(`opacity`,eT).attr(`transform`,function(e){return isFinite(e=y(e))?d(e+c):this.getAttribute(`transform`)}),w.attr(`opacity`,eT).attr(`transform`,function(e){var t=this.parentNode.__axis;return d((t&&isFinite(t=t(e))?t:y(e))+c)})),C.remove(),x.attr(`d`,e===$w||e===Zw?o?`M`+l*o+`,`+_+`H`+c+`V`+v+`H`+l*o:`M`+c+`,`+_+`V`+v:o?`M`+_+`,`+l*o+`V`+c+`H`+v+`V`+l*o:`M`+_+`,`+c+`H`+v),S.attr(`opacity`,1).attr(`transform`,function(e){return d(y(e)+c)}),T.attr(u+`2`,l*a),E.attr(u,l*h).text(m),b.filter(aT).attr(`fill`,`none`).attr(`font-size`,10).attr(`font-family`,`sans-serif`).attr(`text-anchor`,e===Zw?`start`:e===$w?`end`:`middle`),b.each(function(){this.__axis=y})}return f.scale=function(e){return arguments.length?(t=e,f):t},f.ticks=function(){return n=Array.from(arguments),f},f.tickArguments=function(e){return arguments.length?(n=e==null?[]:Array.from(e),f):n.slice()},f.tickValues=function(e){return arguments.length?(r=e==null?null:Array.from(e),f):r&&r.slice()},f.tickFormat=function(e){return arguments.length?(i=e,f):i},f.tickSize=function(e){return arguments.length?(a=o=+e,f):a},f.tickSizeInner=function(e){return arguments.length?(a=+e,f):a},f.tickSizeOuter=function(e){return arguments.length?(o=+e,f):o},f.tickPadding=function(e){return arguments.length?(s=+e,f):s},f.offset=function(e){return arguments.length?(c=+e,f):c},f}function sT(e){return oT(Qw,e)}function cT(e){return oT($w,e)}var lT={value:()=>{}};function uT(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new dT(n)}function dT(e){this._=e}function fT(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}dT.prototype=uT.prototype={constructor:dT,on:function(e,t){var n=this._,r=fT(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=pT(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=mT(n[i],e.name,t);else if(t==null)for(i in n)n[i]=mT(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new dT(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function pT(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function mT(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=lT,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var hT={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function gT(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),hT.hasOwnProperty(t)?{space:hT[t],local:e}:e}function _T(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function vT(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function yT(e){var t=gT(e);return(t.local?vT:_T)(t)}function bT(){}function xT(e){return e==null?bT:function(){return this.querySelector(e)}}function ST(e){typeof e!=`function`&&(e=xT(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new uD(r,this._parents)}function CT(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function wT(){return[]}function TT(e){return e==null?wT:function(){return this.querySelectorAll(e)}}function ET(e){return function(){return CT(e.apply(this,arguments))}}function DT(e){e=typeof e==`function`?ET(e):TT(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new uD(r,i)}function OT(e){return function(){return this.matches(e)}}function kT(e){return function(t){return t.matches(e)}}var AT=Array.prototype.find;function jT(e){return function(){return AT.call(this.children,e)}}function MT(){return this.firstElementChild}function NT(e){return this.select(e==null?MT:jT(typeof e==`function`?e:kT(e)))}var PT=Array.prototype.filter;function FT(){return Array.from(this.children)}function IT(e){return function(){return PT.call(this.children,e)}}function LT(e){return this.selectAll(e==null?FT:IT(typeof e==`function`?e:kT(e)))}function RT(e){typeof e!=`function`&&(e=OT(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new uD(r,this._parents)}function zT(e){return Array(e.length)}function BT(){return new uD(this._enter||this._groups.map(zT),this._parents)}function VT(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}VT.prototype={constructor:VT,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function HT(e){return function(){return e}}function UT(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new VT(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function WT(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new VT(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function GT(e){return e.__data__}function KT(e,t){if(!arguments.length)return Array.from(this,GT);var n=t?WT:UT,r=this._parents,i=this._groups;typeof e!=`function`&&(e=HT(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=qT(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new uD(o,r),o._enter=s,o._exit=c,o}function qT(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function JT(){return new uD(this._exit||this._groups.map(zT),this._parents)}function YT(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function XT(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new uD(s,this._parents)}function ZT(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function QT(e){e||=$T;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new uD(i,this._parents).order()}function $T(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function eE(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function tE(){return Array.from(this)}function nE(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function rE(){let e=0;for(let t of this)++e;return e}function iE(){return!this.node()}function aE(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function oE(e){return function(){this.removeAttribute(e)}}function sE(e){return function(){this.removeAttributeNS(e.space,e.local)}}function cE(e,t){return function(){this.setAttribute(e,t)}}function lE(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function uE(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function dE(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function fE(e,t){var n=gT(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?sE:oE:typeof t==`function`?n.local?dE:uE:n.local?lE:cE)(n,t))}function pE(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function mE(e){return function(){this.style.removeProperty(e)}}function hE(e,t,n){return function(){this.style.setProperty(e,t,n)}}function gE(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function _E(e,t,n){return arguments.length>1?this.each((t==null?mE:typeof t==`function`?gE:hE)(e,t,n??``)):vE(this.node(),e)}function vE(e,t){return e.style.getPropertyValue(t)||pE(e).getComputedStyle(e,null).getPropertyValue(t)}function yE(e){return function(){delete this[e]}}function bE(e,t){return function(){this[e]=t}}function xE(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function SE(e,t){return arguments.length>1?this.each((t==null?yE:typeof t==`function`?xE:bE)(e,t)):this.node()[e]}function CE(e){return e.trim().split(/^|\s+/)}function wE(e){return e.classList||new TE(e)}function TE(e){this._node=e,this._names=CE(e.getAttribute(`class`)||``)}TE.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function EE(e,t){for(var n=wE(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function DE(e,t){for(var n=wE(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function OE(e){return function(){EE(this,e)}}function kE(e){return function(){DE(this,e)}}function AE(e,t){return function(){(t.apply(this,arguments)?EE:DE)(this,e)}}function jE(e,t){var n=CE(e+``);if(arguments.length<2){for(var r=wE(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?AE:t?OE:kE)(n,t))}function ME(){this.textContent=``}function NE(e){return function(){this.textContent=e}}function PE(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function FE(e){return arguments.length?this.each(e==null?ME:(typeof e==`function`?PE:NE)(e)):this.node().textContent}function IE(){this.innerHTML=``}function LE(e){return function(){this.innerHTML=e}}function RE(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function zE(e){return arguments.length?this.each(e==null?IE:(typeof e==`function`?RE:LE)(e)):this.node().innerHTML}function BE(){this.nextSibling&&this.parentNode.appendChild(this)}function VE(){return this.each(BE)}function HE(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function UE(){return this.each(HE)}function WE(e){var t=typeof e==`function`?e:yT(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function GE(){return null}function KE(e,t){var n=typeof e==`function`?e:yT(e),r=t==null?GE:typeof t==`function`?t:xT(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function qE(){var e=this.parentNode;e&&e.removeChild(this)}function JE(){return this.each(qE)}function YE(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function XE(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ZE(e){return this.select(e?XE:YE)}function QE(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function $E(e){return function(t){e.call(this,t,this.__data__)}}function eD(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function tD(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function nD(e,t,n){return function(){var r=this.__on,i,a=$E(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function rD(e,t,n){var r=eD(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?nD:tD,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function iD(e,t,n){var r=pE(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function aD(e,t){return function(){return iD(this,e,t)}}function oD(e,t){return function(){return iD(this,e,t.apply(this,arguments))}}function sD(e,t){return this.each((typeof t==`function`?oD:aD)(e,t))}function*cD(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var lD=[null];function uD(e,t){this._groups=e,this._parents=t}function dD(){return new uD([[document.documentElement]],lD)}function fD(){return this}uD.prototype=dD.prototype={constructor:uD,select:ST,selectAll:DT,selectChild:NT,selectChildren:LT,filter:RT,data:KT,enter:BT,exit:JT,join:YT,merge:XT,selection:fD,order:ZT,sort:QT,call:eE,nodes:tE,node:nE,size:rE,empty:iE,each:aE,attr:fE,style:_E,property:SE,classed:jE,text:FE,html:zE,raise:VE,lower:UE,append:WE,insert:KE,remove:JE,clone:ZE,datum:QE,on:rD,dispatch:sD,[Symbol.iterator]:cD};function pD(e){return typeof e==`string`?new uD([[document.querySelector(e)]],[document.documentElement]):new uD([[e]],lD)}function mD(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function hD(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function gD(){}var _D=.7,vD=1/_D,yD=`\\s*([+-]?\\d+)\\s*`,bD=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,xD=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,SD=/^#([0-9a-f]{3,8})$/,CD=RegExp(`^rgb\\(${yD},${yD},${yD}\\)$`),wD=RegExp(`^rgb\\(${xD},${xD},${xD}\\)$`),TD=RegExp(`^rgba\\(${yD},${yD},${yD},${bD}\\)$`),ED=RegExp(`^rgba\\(${xD},${xD},${xD},${bD}\\)$`),DD=RegExp(`^hsl\\(${bD},${xD},${xD}\\)$`),OD=RegExp(`^hsla\\(${bD},${xD},${xD},${bD}\\)$`),kD={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};mD(gD,PD,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:AD,formatHex:AD,formatHex8:jD,formatHsl:MD,formatRgb:ND,toString:ND});function AD(){return this.rgb().formatHex()}function jD(){return this.rgb().formatHex8()}function MD(){return qD(this).formatHsl()}function ND(){return this.rgb().formatRgb()}function PD(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=SD.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?FD(t):n===3?new zD(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?ID(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?ID(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=CD.exec(e))?new zD(t[1],t[2],t[3],1):(t=wD.exec(e))?new zD(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=TD.exec(e))?ID(t[1],t[2],t[3],t[4]):(t=ED.exec(e))?ID(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=DD.exec(e))?KD(t[1],t[2]/100,t[3]/100,1):(t=OD.exec(e))?KD(t[1],t[2]/100,t[3]/100,t[4]):kD.hasOwnProperty(e)?FD(kD[e]):e===`transparent`?new zD(NaN,NaN,NaN,0):null}function FD(e){return new zD(e>>16&255,e>>8&255,e&255,1)}function ID(e,t,n,r){return r<=0&&(e=t=n=NaN),new zD(e,t,n,r)}function LD(e){return e instanceof gD||(e=PD(e)),e?(e=e.rgb(),new zD(e.r,e.g,e.b,e.opacity)):new zD}function RD(e,t,n,r){return arguments.length===1?LD(e):new zD(e,t,n,r??1)}function zD(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}mD(zD,RD,hD(gD,{brighter(e){return e=e==null?vD:vD**+e,new zD(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?_D:_D**+e,new zD(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new zD(WD(this.r),WD(this.g),WD(this.b),UD(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:BD,formatHex:BD,formatHex8:VD,formatRgb:HD,toString:HD}));function BD(){return`#${GD(this.r)}${GD(this.g)}${GD(this.b)}`}function VD(){return`#${GD(this.r)}${GD(this.g)}${GD(this.b)}${GD((isNaN(this.opacity)?1:this.opacity)*255)}`}function HD(){let e=UD(this.opacity);return`${e===1?`rgb(`:`rgba(`}${WD(this.r)}, ${WD(this.g)}, ${WD(this.b)}${e===1?`)`:`, ${e})`}`}function UD(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function WD(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function GD(e){return e=WD(e),(e<16?`0`:``)+e.toString(16)}function KD(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new YD(e,t,n,r)}function qD(e){if(e instanceof YD)return new YD(e.h,e.s,e.l,e.opacity);if(e instanceof gD||(e=PD(e)),!e)return new YD;if(e instanceof YD)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new YD(o,s,c,e.opacity)}function JD(e,t,n,r){return arguments.length===1?qD(e):new YD(e,t,n,r??1)}function YD(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}mD(YD,JD,hD(gD,{brighter(e){return e=e==null?vD:vD**+e,new YD(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?_D:_D**+e,new YD(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new zD(QD(e>=240?e-240:e+120,i,r),QD(e,i,r),QD(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new YD(XD(this.h),ZD(this.s),ZD(this.l),UD(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=UD(this.opacity);return`${e===1?`hsl(`:`hsla(`}${XD(this.h)}, ${ZD(this.s)*100}%, ${ZD(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function XD(e){return e=(e||0)%360,e<0?e+360:e}function ZD(e){return Math.max(0,Math.min(1,e||0))}function QD(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var $D=e=>()=>e;function eO(e,t){return function(n){return e+n*t}}function tO(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function nO(e){return(e=+e)==1?rO:function(t,n){return n-t?tO(t,n,e):$D(isNaN(t)?n:t)}}function rO(e,t){var n=t-e;return n?eO(e,n):$D(isNaN(e)?t:e)}var iO=(function e(t){var n=nO(t);function r(e,t){var r=n((e=RD(e)).r,(t=RD(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=rO(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function aO(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function oO(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function sO(e,t){for(var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o=0;o<r;++o)i[o]=gO(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function cO(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function lO(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function uO(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=gO(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var dO=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,fO=new RegExp(dO.source,`g`);function pO(e){return function(){return e}}function mO(e){return function(t){return e(t)+``}}function hO(e,t){var n=dO.lastIndex=fO.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=dO.exec(e))&&(i=fO.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:lO(r,i)})),n=fO.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?mO(c[0].x):pO(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function gO(e,t){var n=typeof t,r;return t==null||n===`boolean`?$D(t):(n===`number`?lO:n===`string`?(r=PD(t))?(t=r,iO):hO:t instanceof PD?iO:t instanceof Date?cO:oO(t)?aO:Array.isArray(t)?sO:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?uO:lO)(e,t)}function _O(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var vO=180/Math.PI,yO={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function bO(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*vO,skewX:Math.atan(c)*vO,scaleX:o,scaleY:s}}var xO;function SO(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?yO:bO(t.a,t.b,t.c,t.d,t.e,t.f)}function CO(e){return e==null||(xO||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),xO.setAttribute(`transform`,e),!(e=xO.transform.baseVal.consolidate()))?yO:(e=e.matrix,bO(e.a,e.b,e.c,e.d,e.e,e.f))}function wO(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:lO(e,i)},{i:c-2,x:lO(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:lO(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:lO(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:lO(e,n)},{i:s-2,x:lO(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var TO=wO(SO,`px, `,`px)`,`deg)`),EO=wO(CO,`, `,`)`,`)`),DO=0,OO=0,kO=0,AO=1e3,jO,MO,NO=0,PO=0,FO=0,IO=typeof performance==`object`&&performance.now?performance:Date,LO=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function RO(){return PO||=(LO(zO),IO.now()+FO)}function zO(){PO=0}function BO(){this._call=this._time=this._next=null}BO.prototype=VO.prototype={constructor:BO,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?RO():+n)+(t==null?0:+t),!this._next&&MO!==this&&(MO?MO._next=this:jO=this,MO=this),this._call=e,this._time=n,KO()},stop:function(){this._call&&(this._call=null,this._time=1/0,KO())}};function VO(e,t,n){var r=new BO;return r.restart(e,t,n),r}function HO(){RO(),++DO;for(var e=jO,t;e;)(t=PO-e._time)>=0&&e._call.call(void 0,t),e=e._next;--DO}function UO(){PO=(NO=IO.now())+FO,DO=OO=0;try{HO()}finally{DO=0,GO(),PO=0}}function WO(){var e=IO.now(),t=e-NO;t>AO&&(FO-=t,NO=e)}function GO(){for(var e,t=jO,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:jO=n);MO=e,KO(r)}function KO(e){DO||(OO&&=clearTimeout(OO),e-PO>24?(e<1/0&&(OO=setTimeout(UO,e-IO.now()-FO)),kO&&=clearInterval(kO)):(kO||=(NO=IO.now(),setInterval(WO,AO)),DO=1,LO(UO)))}function qO(e,t,n){var r=new BO;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var JO=uT(`start`,`end`,`cancel`,`interrupt`),YO=[];function XO(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;ek(e,n,{name:t,index:r,group:i,on:JO,tween:YO,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function ZO(e,t){var n=$O(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function QO(e,t){var n=$O(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function $O(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function ek(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=VO(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return qO(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(qO(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function tk(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function nk(e){return this.each(function(){tk(this,e)})}function rk(e,t){var n,r;return function(){var i=QO(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function ik(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=QO(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function ak(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=$O(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?rk:ik)(n,e,t))}function ok(e,t,n){var r=e._id;return e.each(function(){var e=QO(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return $O(e,r).value[t]}}function sk(e,t){var n;return(typeof t==`number`?lO:t instanceof PD?iO:(n=PD(t))?(t=n,iO):hO)(e,t)}function ck(e){return function(){this.removeAttribute(e)}}function lk(e){return function(){this.removeAttributeNS(e.space,e.local)}}function uk(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function dk(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function fk(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function pk(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function mk(e,t){var n=gT(e),r=n===`transform`?EO:sk;return this.attrTween(e,typeof t==`function`?(n.local?pk:fk)(n,r,ok(this,`attr.`+e,t)):t==null?(n.local?lk:ck)(n):(n.local?dk:uk)(n,r,t))}function hk(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function gk(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function _k(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&gk(e,i)),n}return i._value=t,i}function vk(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&hk(e,i)),n}return i._value=t,i}function yk(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=gT(e);return this.tween(n,(r.local?_k:vk)(r,t))}function bk(e,t){return function(){ZO(this,e).delay=+t.apply(this,arguments)}}function xk(e,t){return t=+t,function(){ZO(this,e).delay=t}}function Sk(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?bk:xk)(t,e)):$O(this.node(),t).delay}function Ck(e,t){return function(){QO(this,e).duration=+t.apply(this,arguments)}}function wk(e,t){return t=+t,function(){QO(this,e).duration=t}}function Tk(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?Ck:wk)(t,e)):$O(this.node(),t).duration}function Ek(e,t){if(typeof t!=`function`)throw Error();return function(){QO(this,e).ease=t}}function Dk(e){var t=this._id;return arguments.length?this.each(Ek(t,e)):$O(this.node(),t).ease}function Ok(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();QO(this,e).ease=n}}function kk(e){if(typeof e!=`function`)throw Error();return this.each(Ok(this._id,e))}function Ak(e){typeof e!=`function`&&(e=OT(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new aA(r,this._parents,this._name,this._id)}function jk(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new aA(o,this._parents,this._name,this._id)}function Mk(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function Nk(e,t,n){var r,i,a=Mk(t)?ZO:QO;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function Pk(e,t){var n=this._id;return arguments.length<2?$O(this.node(),n).on.on(e):this.each(Nk(n,e,t))}function Fk(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Ik(){return this.on(`end.remove`,Fk(this._id))}function Lk(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=xT(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,XO(l[f],t,n,f,l,$O(u,n)));return new aA(a,this._parents,t,n)}function Rk(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=TT(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=$O(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&XO(p,t,n,h,f,m);a.push(f),o.push(u)}return new aA(a,o,t,n)}var zk=dD.prototype.constructor;function Bk(){return new zk(this._groups,this._parents)}function Vk(e,t){var n,r,i;return function(){var a=vE(this,e),o=(this.style.removeProperty(e),vE(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function Hk(e){return function(){this.style.removeProperty(e)}}function Uk(e,t,n){var r,i=n+``,a;return function(){var o=vE(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function Wk(e,t,n){var r,i,a;return function(){var o=vE(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),vE(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function Gk(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=QO(this,e),l=c.on,u=c.value[a]==null?s||=Hk(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function Kk(e,t,n){var r=(e+=``)==`transform`?TO:sk;return t==null?this.styleTween(e,Vk(e,r)).on(`end.style.`+e,Hk(e)):typeof t==`function`?this.styleTween(e,Wk(e,r,ok(this,`style.`+e,t))).each(Gk(this._id,e)):this.styleTween(e,Uk(e,r,t),n).on(`end.style.`+e,null)}function qk(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Jk(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&qk(e,a,n)),r}return a._value=t,a}function Yk(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,Jk(e,t,n??``))}function Xk(e){return function(){this.textContent=e}}function Zk(e){return function(){var t=e(this);this.textContent=t??``}}function Qk(e){return this.tween(`text`,typeof e==`function`?Zk(ok(this,`text`,e)):Xk(e==null?``:e+``))}function $k(e){return function(t){this.textContent=e.call(this,t)}}function eA(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&$k(r)),t}return r._value=e,r}function tA(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,eA(e))}function nA(){for(var e=this._name,t=this._id,n=oA(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=$O(c,t);XO(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new aA(r,this._parents,e,n)}function rA(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=QO(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var iA=0;function aA(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function oA(){return++iA}var sA=dD.prototype;aA.prototype={constructor:aA,select:Lk,selectAll:Rk,selectChild:sA.selectChild,selectChildren:sA.selectChildren,filter:Ak,merge:jk,selection:Bk,transition:nA,call:sA.call,nodes:sA.nodes,node:sA.node,size:sA.size,empty:sA.empty,each:sA.each,on:Pk,attr:mk,attrTween:yk,style:Kk,styleTween:Yk,text:Qk,textTween:tA,remove:Ik,tween:ak,delay:Sk,duration:Tk,ease:Dk,easeVarying:kk,end:rA,[Symbol.iterator]:sA[Symbol.iterator]};function cA(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var lA={time:null,delay:0,duration:250,ease:cA};function uA(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function dA(e){var t,n;e instanceof aA?(t=e._id,e=e._name):(t=oA(),(n=lA).time=RO(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&XO(c,e,t,l,o,n||uA(c,t));return new aA(r,this._parents,e,t)}dD.prototype.interrupt=nk,dD.prototype.transition=dA;var{abs:fA,max:pA,min:mA}=Math;[`w`,`e`].map(hA),[`n`,`s`].map(hA),[`n`,`w`,`e`,`s`,`nw`,`ne`,`sw`,`se`].map(hA);function hA(e){return{type:e}}var gA=Math.PI,_A=2*gA,vA=1e-6,yA=_A-vA;function bA(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function xA(e){let t=Math.floor(e);if(!(t>=0))throw Error(`invalid digits: ${e}`);if(t>15)return bA;let n=10**t;return function(e){this._+=e[0];for(let t=1,r=e.length;t<r;++t)this._+=Math.round(arguments[t]*n)/n+e[t]}}var SA=class{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._=``,this._append=e==null?bA:xA(e)}moveTo(e,t){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,t){this._append`L${this._x1=+e},${this._y1=+t}`}quadraticCurveTo(e,t,n,r){this._append`Q${+e},${+t},${this._x1=+n},${this._y1=+r}`}bezierCurveTo(e,t,n,r,i,a){this._append`C${+e},${+t},${+n},${+r},${this._x1=+i},${this._y1=+a}`}arcTo(e,t,n,r,i){if(e=+e,t=+t,n=+n,r=+r,i=+i,i<0)throw Error(`negative radius: ${i}`);let a=this._x1,o=this._y1,s=n-e,c=r-t,l=a-e,u=o-t,d=l*l+u*u;if(this._x1===null)this._append`M${this._x1=e},${this._y1=t}`;else if(d>vA){if(!(Math.abs(u*s-c*l)>vA)||!i)this._append`L${this._x1=e},${this._y1=t}`;else{let f=n-a,p=r-o,m=s*s+c*c,h=f*f+p*p,g=Math.sqrt(m),_=Math.sqrt(d),v=i*Math.tan((gA-Math.acos((m+d-h)/(2*g*_)))/2),y=v/_,b=v/g;Math.abs(y-1)>vA&&this._append`L${e+y*l},${t+y*u}`,this._append`A${i},${i},0,0,${+(u*f>l*p)},${this._x1=e+b*s},${this._y1=t+b*c}`}}}arc(e,t,n,r,i,a){if(e=+e,t=+t,n=+n,a=!!a,n<0)throw Error(`negative radius: ${n}`);let o=n*Math.cos(r),s=n*Math.sin(r),c=e+o,l=t+s,u=1^a,d=a?r-i:i-r;this._x1===null?this._append`M${c},${l}`:(Math.abs(this._x1-c)>vA||Math.abs(this._y1-l)>vA)&&this._append`L${c},${l}`,n&&(d<0&&(d=d%_A+_A),d>yA?this._append`A${n},${n},0,1,${u},${e-o},${t-s}A${n},${n},0,1,${u},${this._x1=c},${this._y1=l}`:d>vA&&this._append`A${n},${n},0,${+(d>=gA)},${u},${this._x1=e+n*Math.cos(i)},${this._y1=t+n*Math.sin(i)}`)}rect(e,t,n,r){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}};SA.prototype;function CA(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function wA(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function TA(e){return e=wA(Math.abs(e)),e?e[1]:NaN}function EA(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}function DA(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var OA=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function kA(e){if(!(t=OA.exec(e)))throw Error(`invalid format: `+e);var t;return new AA({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}kA.prototype=AA.prototype;function AA(e){this.fill=e.fill===void 0?` `:e.fill+``,this.align=e.align===void 0?`>`:e.align+``,this.sign=e.sign===void 0?`-`:e.sign+``,this.symbol=e.symbol===void 0?``:e.symbol+``,this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?``:e.type+``}AA.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?`0`:``)+(this.width===void 0?``:Math.max(1,this.width|0))+(this.comma?`,`:``)+(this.precision===void 0?``:`.`+Math.max(0,this.precision|0))+(this.trim?`~`:``)+this.type};function jA(e){out:for(var t=e.length,n=1,r=-1,i;n<t;++n)switch(e[n]){case`.`:r=i=n;break;case`0`:r===0&&(r=n),i=n;break;default:if(!+e[n])break out;r>0&&(r=0)}return r>0?e.slice(0,r)+e.slice(i+1):e}var MA;function NA(e,t){var n=wA(e,t);if(!n)return MA=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(MA=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+wA(e,Math.max(0,t+a-1))[0]}function PA(e,t){var n=wA(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var FA={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:CA,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>PA(e*100,t),r:PA,s:NA,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function IA(e){return e}var LA=Array.prototype.map,RA=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function zA(e){var t=e.grouping===void 0||e.thousands===void 0?IA:EA(LA.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?IA:DA(LA.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=kA(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):FA[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),x=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),S=FA[y],C=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function w(e){var n=b,r=x,o,l,p;if(y===`c`)r=S(e)+r,e=``;else{e=+e;var w=e<0||1/e<0;if(e=isNaN(e)?c:S(Math.abs(e),_),v&&(e=jA(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&MA!==void 0?RA[8+MA/3]:``)+r+(w&&f===`(`?`)`:``),C){for(o=-1,l=e.length;++o<l;)if(p=e.charCodeAt(o),48>p||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var T=n.length+e.length+r.length,E=T<h?Array(h-T+1).join(u):``;switch(g&&m&&(e=t(E+e,E.length?h-r.length:1/0),E=``),d){case`<`:e=n+e+r+E;break;case`=`:e=n+E+e+r;break;case`^`:e=E.slice(0,T=E.length>>1)+n+e+r+E.slice(T);break;default:e=E+n+e+r}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(TA(t)/3)))*3,r=10**-n,i=l((e=kA(e),e.type=`f`,e),{suffix:RA[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var BA,VA,HA;UA({thousands:`,`,grouping:[3],currency:[`$`,``]});function UA(e){return BA=zA(e),VA=BA.format,HA=BA.formatPrefix,BA}function WA(e){return Math.max(0,-TA(Math.abs(e)))}function GA(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(TA(t)/3)))*3-TA(Math.abs(e)))}function KA(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,TA(t)-TA(e))+1}function qA(e){var t=0,n=e.children,r=n&&n.length;if(!r)t=1;else for(;--r>=0;)t+=n[r].value;e.value=t}function JA(){return this.eachAfter(qA)}function YA(e,t){let n=-1;for(let r of this)e.call(t,r,++n,this);return this}function XA(e,t){for(var n=this,r=[n],i,a,o=-1;n=r.pop();)if(e.call(t,n,++o,this),i=n.children)for(a=i.length-1;a>=0;--a)r.push(i[a]);return this}function ZA(e,t){for(var n=this,r=[n],i=[],a,o,s,c=-1;n=r.pop();)if(i.push(n),a=n.children)for(o=0,s=a.length;o<s;++o)r.push(a[o]);for(;n=i.pop();)e.call(t,n,++c,this);return this}function QA(e,t){let n=-1;for(let r of this)if(e.call(t,r,++n,this))return r}function $A(e){return this.eachAfter(function(t){for(var n=+e(t.data)||0,r=t.children,i=r&&r.length;--i>=0;)n+=r[i].value;t.value=n})}function ej(e){return this.eachBefore(function(t){t.children&&t.children.sort(e)})}function tj(e){for(var t=this,n=nj(t,e),r=[t];t!==n;)t=t.parent,r.push(t);for(var i=r.length;e!==n;)r.splice(i,0,e),e=e.parent;return r}function nj(e,t){if(e===t)return e;var n=e.ancestors(),r=t.ancestors(),i=null;for(e=n.pop(),t=r.pop();e===t;)i=e,e=n.pop(),t=r.pop();return i}function rj(){for(var e=this,t=[e];e=e.parent;)t.push(e);return t}function ij(){return Array.from(this)}function aj(){var e=[];return this.eachBefore(function(t){t.children||e.push(t)}),e}function oj(){var e=this,t=[];return e.each(function(n){n!==e&&t.push({source:n.parent,target:n})}),t}function*sj(){var e=this,t,n=[e],r,i,a;do for(t=n.reverse(),n=[];e=t.pop();)if(yield e,r=e.children)for(i=0,a=r.length;i<a;++i)n.push(r[i]);while(n.length)}function cj(e,t){e instanceof Map?(e=[void 0,e],t===void 0&&(t=dj)):t===void 0&&(t=uj);for(var n=new mj(e),r,i=[n],a,o,s,c;r=i.pop();)if((o=t(r.data))&&(c=(o=Array.from(o)).length))for(r.children=o,s=c-1;s>=0;--s)i.push(a=o[s]=new mj(o[s])),a.parent=r,a.depth=r.depth+1;return n.eachBefore(pj)}function lj(){return cj(this).eachBefore(fj)}function uj(e){return e.children}function dj(e){return Array.isArray(e)?e[1]:null}function fj(e){e.data.value!==void 0&&(e.value=e.data.value),e.data=e.data.data}function pj(e){var t=0;do e.height=t;while((e=e.parent)&&e.height<++t)}function mj(e){this.data=e,this.depth=this.height=0,this.parent=null}mj.prototype=cj.prototype={constructor:mj,count:JA,each:YA,eachAfter:ZA,eachBefore:XA,find:QA,sum:$A,sort:ej,path:tj,ancestors:rj,descendants:ij,leaves:aj,links:oj,copy:lj,[Symbol.iterator]:sj};function hj(e){e.x0=Math.round(e.x0),e.y0=Math.round(e.y0),e.x1=Math.round(e.x1),e.y1=Math.round(e.y1)}function gj(e,t,n,r,i){for(var a=e.children,o,s=-1,c=a.length,l=e.value&&(r-t)/e.value;++s<c;)o=a[s],o.y0=n,o.y1=i,o.x0=t,o.x1=t+=o.value*l}function _j(){var e=1,t=1,n=0,r=!1;function i(i){var o=i.height+1;return i.x0=i.y0=n,i.x1=e,i.y1=t/o,i.eachBefore(a(t,o)),r&&i.eachBefore(hj),i}function a(e,t){return function(r){r.children&&gj(r,r.x0,e*(r.depth+1)/t,r.x1,e*(r.depth+2)/t);var i=r.x0,a=r.y0,o=r.x1-n,s=r.y1-n;o<i&&(i=o=(i+o)/2),s<a&&(a=s=(a+s)/2),r.x0=i,r.y0=a,r.x1=o,r.y1=s}}return i.round=function(e){return arguments.length?(r=!!e,i):r},i.size=function(n){return arguments.length?(e=+n[0],t=+n[1],i):[e,t]},i.padding=function(e){return arguments.length?(n=+e,i):n},i}function vj(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e)}return this}var yj=Symbol(`implicit`);function bj(){var e=new Fw,t=[],n=[],r=yj;function i(i){let a=e.get(i);if(a===void 0){if(r!==yj)return r;e.set(i,a=t.push(i)-1)}return n[a%n.length]}return i.domain=function(n){if(!arguments.length)return t.slice();t=[],e=new Fw;for(let r of n)e.has(r)||e.set(r,t.push(r)-1);return i},i.range=function(e){return arguments.length?(n=Array.from(e),i):n.slice()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return bj(t,n).unknown(r)},vj.apply(i,arguments),i}function xj(){var e=bj().unknown(void 0),t=e.domain,n=e.range,r=0,i=1,a,o,s=!1,c=0,l=0,u=.5;delete e.unknown;function d(){var e=t().length,d=i<r,f=d?i:r,p=d?r:i;a=(p-f)/Math.max(1,e-c+l*2),s&&(a=Math.floor(a)),f+=(p-f-a*(e-c))*u,o=a*(1-c),s&&(f=Math.round(f),o=Math.round(o));var m=Jw(e).map(function(e){return f+a*e});return n(d?m.reverse():m)}return e.domain=function(e){return arguments.length?(t(e),d()):t()},e.range=function(e){return arguments.length?([r,i]=e,r=+r,i=+i,d()):[r,i]},e.rangeRound=function(e){return[r,i]=e,r=+r,i=+i,s=!0,d()},e.bandwidth=function(){return o},e.step=function(){return a},e.round=function(e){return arguments.length?(s=!!e,d()):s},e.padding=function(e){return arguments.length?(c=Math.min(1,l=+e),d()):c},e.paddingInner=function(e){return arguments.length?(c=Math.min(1,e),d()):c},e.paddingOuter=function(e){return arguments.length?(l=+e,d()):l},e.align=function(e){return arguments.length?(u=Math.max(0,Math.min(1,e)),d()):u},e.copy=function(){return xj(t(),[r,i]).round(s).paddingInner(c).paddingOuter(l).align(u)},vj.apply(d(),arguments)}function Sj(e){var t=e.copy;return e.padding=e.paddingOuter,delete e.paddingInner,delete e.paddingOuter,e.copy=function(){return Sj(t())},e}function Cj(){return Sj(xj.apply(null,arguments).paddingInner(1))}function wj(e){return function(){return e}}function Tj(e){return+e}var Ej=[0,1];function Dj(e){return e}function Oj(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:wj(isNaN(t)?NaN:.5)}function kj(e,t){var n;return e>t&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function Aj(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i<r?(r=Oj(i,r),a=n(o,a)):(r=Oj(r,i),a=n(a,o)),function(e){return a(r(e))}}function jj(e,t,n){var r=Math.min(e.length,t.length)-1,i=Array(r),a=Array(r),o=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++o<r;)i[o]=Oj(e[o],e[o+1]),a[o]=n(t[o],t[o+1]);return function(t){var n=Nw(e,t,1,r)-1;return a[n](i[n](t))}}function Mj(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function Nj(){var e=Ej,t=Ej,n=gO,r,i,a,o=Dj,s,c,l;function u(){var n=Math.min(e.length,t.length);return o!==Dj&&(o=kj(e[0],e[n-1])),s=n>2?jj:Aj,c=l=null,d}function d(i){return i==null||isNaN(i=+i)?a:(c||=s(e.map(r),t,n))(r(o(i)))}return d.invert=function(n){return o(i((l||=s(t,e.map(r),lO))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,Tj),u()):e.slice()},d.range=function(e){return arguments.length?(t=Array.from(e),u()):t.slice()},d.rangeRound=function(e){return t=Array.from(e),n=_O,u()},d.clamp=function(e){return arguments.length?(o=e?!0:Dj,u()):o!==Dj},d.interpolate=function(e){return arguments.length?(n=e,u()):n},d.unknown=function(e){return arguments.length?(a=e,d):a},function(e,t){return r=e,i=t,u()}}function Pj(){return Nj()(Dj,Dj)}function Fj(e,t,n,r){var i=Kw(e,t,n),a;switch(r=kA(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=GA(i,o))&&(r.precision=a),HA(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=KA(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=WA(i))&&(r.precision=a-(r.type===`%`)*2)}return VA(r)}function Ij(e){var t=e.domain;return e.ticks=function(e){var n=t();return Ww(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return Fj(r[0],r[r.length-1],e??10,n)},e.nice=function(n){n??=10;var r=t(),i=0,a=r.length-1,o=r[i],s=r[a],c,l,u=10;for(s<o&&(l=o,o=s,s=l,l=i,i=a,a=l);u-->0;){if(l=Gw(o,s,n),l===c)return r[i]=o,r[a]=s,t(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;c=l}return e},e}function Lj(){var e=Pj();return e.copy=function(){return Mj(e,Lj())},vj.apply(e,arguments),Ij(e)}function Rj(e,t){e=e.slice();var n=0,r=e.length-1,i=e[n],a=e[r],o;return a<i&&(o=n,n=r,r=o,o=i,i=a,a=o),e[n]=t.floor(i),e[r]=t.ceil(a),e}var zj=new Date,Bj=new Date;function Vj(e,t,n,r){function i(t){return e(t=arguments.length===0?new Date:new Date(+t)),t}return i.floor=t=>(e(t=new Date(+t)),t),i.ceil=n=>(e(n=new Date(n-1)),t(n,1),e(n),n),i.round=e=>{let t=i(e),n=i.ceil(e);return e-t<n-e?t:n},i.offset=(e,n)=>(t(e=new Date(+e),n==null?1:Math.floor(n)),e),i.range=(n,r,a)=>{let o=[];if(n=i.ceil(n),a=a==null?1:Math.floor(a),!(n<r)||!(a>0))return o;let s;do o.push(s=new Date(+n)),t(n,a),e(n);while(s<n&&n<r);return o},i.filter=n=>Vj(t=>{if(t>=t)for(;e(t),!n(t);)t.setTime(t-1)},(e,r)=>{if(e>=e){if(r<0)for(;++r<=0;)for(;t(e,-1),!n(e););else for(;--r>=0;)for(;t(e,1),!n(e););}}),n&&(i.count=(t,r)=>(zj.setTime(+t),Bj.setTime(+r),e(zj),e(Bj),Math.floor(n(zj,Bj))),i.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?i.filter(r?t=>r(t)%e===0:t=>i.count(0,t)%e===0):i)),i}var Hj=Vj(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);Hj.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?Vj(t=>{t.setTime(Math.floor(t/e)*e)},(t,n)=>{t.setTime(+t+n*e)},(t,n)=>(n-t)/e):Hj),Hj.range;var Uj=1e3,Wj=Uj*60,Gj=Wj*60,Kj=Gj*24,qj=Kj*7,Jj=Kj*30,Yj=Kj*365,Xj=Vj(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*Uj)},(e,t)=>(t-e)/Uj,e=>e.getUTCSeconds());Xj.range;var Zj=Vj(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Uj)},(e,t)=>{e.setTime(+e+t*Wj)},(e,t)=>(t-e)/Wj,e=>e.getMinutes());Zj.range;var Qj=Vj(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*Wj)},(e,t)=>(t-e)/Wj,e=>e.getUTCMinutes());Qj.range;var $j=Vj(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Uj-e.getMinutes()*Wj)},(e,t)=>{e.setTime(+e+t*Gj)},(e,t)=>(t-e)/Gj,e=>e.getHours());$j.range;var eM=Vj(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*Gj)},(e,t)=>(t-e)/Gj,e=>e.getUTCHours());eM.range;var tM=Vj(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Wj)/Kj,e=>e.getDate()-1);tM.range;var nM=Vj(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Kj,e=>e.getUTCDate()-1);nM.range;var rM=Vj(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Kj,e=>Math.floor(e/Kj));rM.range;function iM(e){return Vj(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(e,t)=>{e.setDate(e.getDate()+t*7)},(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Wj)/qj)}var aM=iM(0),oM=iM(1),sM=iM(2),cM=iM(3),lM=iM(4),uM=iM(5),dM=iM(6);aM.range,oM.range,sM.range,cM.range,lM.range,uM.range,dM.range;function fM(e){return Vj(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t*7)},(e,t)=>(t-e)/qj)}var pM=fM(0),mM=fM(1),hM=fM(2),gM=fM(3),_M=fM(4),vM=fM(5),yM=fM(6);pM.range,mM.range,hM.range,gM.range,_M.range,vM.range,yM.range;var bM=Vj(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());bM.range;var xM=Vj(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());xM.range;var SM=Vj(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());SM.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Vj(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)}),SM.range;var CM=Vj(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());CM.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Vj(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)}),CM.range;function wM(e,t,n,r,i,a){let o=[[Xj,1,Uj],[Xj,5,5*Uj],[Xj,15,15*Uj],[Xj,30,30*Uj],[a,1,Wj],[a,5,5*Wj],[a,15,15*Wj],[a,30,30*Wj],[i,1,Gj],[i,3,3*Gj],[i,6,6*Gj],[i,12,12*Gj],[r,1,Kj],[r,2,2*Kj],[n,1,qj],[t,1,Jj],[t,3,3*Jj],[e,1,Yj]];function s(e,t,n){let r=t<e;r&&([e,t]=[t,e]);let i=n&&typeof n.range==`function`?n:c(e,t,n),a=i?i.range(e,+t+1):[];return r?a.reverse():a}function c(t,n,r){let i=Math.abs(n-t)/r,a=kw(([,,e])=>e).right(o,i);if(a===o.length)return e.every(Kw(t/Yj,n/Yj,r));if(a===0)return Hj.every(Math.max(Kw(t,n,r),1));let[s,c]=o[i/o[a-1][2]<o[a][2]/i?a-1:a];return s.every(c)}return[s,c]}var[TM,EM]=wM(CM,xM,pM,rM,eM,Qj),[DM,OM]=wM(SM,bM,aM,tM,$j,Zj);function kM(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function AM(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function jM(e,t,n){return{y:e,m:t,d:n,H:0,M:0,S:0,L:0}}function MM(e){var t=e.dateTime,n=e.date,r=e.time,i=e.periods,a=e.days,o=e.shortDays,s=e.months,c=e.shortMonths,l=RM(i),u=zM(i),d=RM(a),f=zM(a),p=RM(o),m=zM(o),h=RM(s),g=zM(s),_=RM(c),v=zM(c),y={a:N,A:P,b:F,B:I,c:null,d:oN,e:oN,f:dN,g:SN,G:wN,H:sN,I:cN,j:lN,L:uN,m:fN,M:pN,p:L,q:R,Q:qN,s:JN,S:mN,u:hN,U:gN,V:vN,w:yN,W:bN,x:null,X:null,y:xN,Y:CN,Z:TN,"%":KN},b={a:ee,A:te,b:ne,B:z,c:null,d:EN,e:EN,f:jN,g:HN,G:WN,H:DN,I:ON,j:kN,L:AN,m:MN,M:NN,p:re,q:ie,Q:qN,s:JN,S:PN,u:FN,U:IN,V:RN,w:zN,W:BN,x:null,X:null,y:VN,Y:UN,Z:GN,"%":KN},x={a:E,A:D,b:O,B:k,c:A,d:XM,e:XM,f:nN,g:KM,G:GM,H:QM,I:QM,j:ZM,L:tN,m:YM,M:$M,p:T,q:JM,Q:iN,s:aN,S:eN,u:VM,U:HM,V:UM,w:BM,W:WM,x:j,X:M,y:KM,Y:GM,Z:qM,"%":rN};y.x=S(n,y),y.X=S(r,y),y.c=S(t,y),b.x=S(n,b),b.X=S(r,b),b.c=S(t,b);function S(e,t){return function(n){var r=[],i=-1,a=0,o=e.length,s,c,l;for(n instanceof Date||(n=new Date(+n));++i<o;)e.charCodeAt(i)===37&&(r.push(e.slice(a,i)),(c=NM[s=e.charAt(++i)])==null?c=s===`e`?` `:`0`:s=e.charAt(++i),(l=t[s])&&(s=l(n,c)),r.push(s),a=i+1);return r.push(e.slice(a,i)),r.join(``)}}function C(e,t){return function(n){var r=jM(1900,void 0,1),i=w(r,e,n+=``,0),a,o;if(i!=n.length)return null;if(`Q`in r)return new Date(r.Q);if(`s`in r)return new Date(r.s*1e3+(`L`in r?r.L:0));if(t&&!(`Z`in r)&&(r.Z=0),`p`in r&&(r.H=r.H%12+r.p*12),r.m===void 0&&(r.m=`q`in r?r.q:0),`V`in r){if(r.V<1||r.V>53)return null;`w`in r||(r.w=1),`Z`in r?(a=AM(jM(r.y,0,1)),o=a.getUTCDay(),a=o>4||o===0?mM.ceil(a):mM(a),a=nM.offset(a,(r.V-1)*7),r.y=a.getUTCFullYear(),r.m=a.getUTCMonth(),r.d=a.getUTCDate()+(r.w+6)%7):(a=kM(jM(r.y,0,1)),o=a.getDay(),a=o>4||o===0?oM.ceil(a):oM(a),a=tM.offset(a,(r.V-1)*7),r.y=a.getFullYear(),r.m=a.getMonth(),r.d=a.getDate()+(r.w+6)%7)}else(`W`in r||`U`in r)&&(`w`in r||(r.w=`u`in r?r.u%7:+(`W`in r)),o=`Z`in r?AM(jM(r.y,0,1)).getUTCDay():kM(jM(r.y,0,1)).getDay(),r.m=0,r.d=`W`in r?(r.w+6)%7+r.W*7-(o+5)%7:r.w+r.U*7-(o+6)%7);return`Z`in r?(r.H+=r.Z/100|0,r.M+=r.Z%100,AM(r)):kM(r)}}function w(e,t,n,r){for(var i=0,a=t.length,o=n.length,s,c;i<a;){if(r>=o)return-1;if(s=t.charCodeAt(i++),s===37){if(s=t.charAt(i++),c=x[s in NM?t.charAt(i++):s],!c||(r=c(e,n,r))<0)return-1}else if(s!=n.charCodeAt(r++))return-1}return r}function T(e,t,n){var r=l.exec(t.slice(n));return r?(e.p=u.get(r[0].toLowerCase()),n+r[0].length):-1}function E(e,t,n){var r=p.exec(t.slice(n));return r?(e.w=m.get(r[0].toLowerCase()),n+r[0].length):-1}function D(e,t,n){var r=d.exec(t.slice(n));return r?(e.w=f.get(r[0].toLowerCase()),n+r[0].length):-1}function O(e,t,n){var r=_.exec(t.slice(n));return r?(e.m=v.get(r[0].toLowerCase()),n+r[0].length):-1}function k(e,t,n){var r=h.exec(t.slice(n));return r?(e.m=g.get(r[0].toLowerCase()),n+r[0].length):-1}function A(e,n,r){return w(e,t,n,r)}function j(e,t,r){return w(e,n,t,r)}function M(e,t,n){return w(e,r,t,n)}function N(e){return o[e.getDay()]}function P(e){return a[e.getDay()]}function F(e){return c[e.getMonth()]}function I(e){return s[e.getMonth()]}function L(e){return i[+(e.getHours()>=12)]}function R(e){return 1+~~(e.getMonth()/3)}function ee(e){return o[e.getUTCDay()]}function te(e){return a[e.getUTCDay()]}function ne(e){return c[e.getUTCMonth()]}function z(e){return s[e.getUTCMonth()]}function re(e){return i[+(e.getUTCHours()>=12)]}function ie(e){return 1+~~(e.getUTCMonth()/3)}return{format:function(e){var t=S(e+=``,y);return t.toString=function(){return e},t},parse:function(e){var t=C(e+=``,!1);return t.toString=function(){return e},t},utcFormat:function(e){var t=S(e+=``,b);return t.toString=function(){return e},t},utcParse:function(e){var t=C(e+=``,!0);return t.toString=function(){return e},t}}}var NM={"-":``,_:` `,0:`0`},PM=/^\s*\d+/,FM=/^%/,IM=/[\\^$*+?|[\]().{}]/g;function Z(e,t,n){var r=e<0?`-`:``,i=(r?-e:e)+``,a=i.length;return r+(a<n?Array(n-a+1).join(t)+i:i)}function LM(e){return e.replace(IM,`\\$&`)}function RM(e){return RegExp(`^(?:`+e.map(LM).join(`|`)+`)`,`i`)}function zM(e){return new Map(e.map((e,t)=>[e.toLowerCase(),t]))}function BM(e,t,n){var r=PM.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function VM(e,t,n){var r=PM.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function HM(e,t,n){var r=PM.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function UM(e,t,n){var r=PM.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function WM(e,t,n){var r=PM.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function GM(e,t,n){var r=PM.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function KM(e,t,n){var r=PM.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function qM(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||`00`)),n+r[0].length):-1}function JM(e,t,n){var r=PM.exec(t.slice(n,n+1));return r?(e.q=r[0]*3-3,n+r[0].length):-1}function YM(e,t,n){var r=PM.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function XM(e,t,n){var r=PM.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function ZM(e,t,n){var r=PM.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function QM(e,t,n){var r=PM.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function $M(e,t,n){var r=PM.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function eN(e,t,n){var r=PM.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function tN(e,t,n){var r=PM.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function nN(e,t,n){var r=PM.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function rN(e,t,n){var r=FM.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function iN(e,t,n){var r=PM.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function aN(e,t,n){var r=PM.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function oN(e,t){return Z(e.getDate(),t,2)}function sN(e,t){return Z(e.getHours(),t,2)}function cN(e,t){return Z(e.getHours()%12||12,t,2)}function lN(e,t){return Z(1+tM.count(SM(e),e),t,3)}function uN(e,t){return Z(e.getMilliseconds(),t,3)}function dN(e,t){return uN(e,t)+`000`}function fN(e,t){return Z(e.getMonth()+1,t,2)}function pN(e,t){return Z(e.getMinutes(),t,2)}function mN(e,t){return Z(e.getSeconds(),t,2)}function hN(e){var t=e.getDay();return t===0?7:t}function gN(e,t){return Z(aM.count(SM(e)-1,e),t,2)}function _N(e){var t=e.getDay();return t>=4||t===0?lM(e):lM.ceil(e)}function vN(e,t){return e=_N(e),Z(lM.count(SM(e),e)+(SM(e).getDay()===4),t,2)}function yN(e){return e.getDay()}function bN(e,t){return Z(oM.count(SM(e)-1,e),t,2)}function xN(e,t){return Z(e.getFullYear()%100,t,2)}function SN(e,t){return e=_N(e),Z(e.getFullYear()%100,t,2)}function CN(e,t){return Z(e.getFullYear()%1e4,t,4)}function wN(e,t){var n=e.getDay();return e=n>=4||n===0?lM(e):lM.ceil(e),Z(e.getFullYear()%1e4,t,4)}function TN(e){var t=e.getTimezoneOffset();return(t>0?`-`:(t*=-1,`+`))+Z(t/60|0,`0`,2)+Z(t%60,`0`,2)}function EN(e,t){return Z(e.getUTCDate(),t,2)}function DN(e,t){return Z(e.getUTCHours(),t,2)}function ON(e,t){return Z(e.getUTCHours()%12||12,t,2)}function kN(e,t){return Z(1+nM.count(CM(e),e),t,3)}function AN(e,t){return Z(e.getUTCMilliseconds(),t,3)}function jN(e,t){return AN(e,t)+`000`}function MN(e,t){return Z(e.getUTCMonth()+1,t,2)}function NN(e,t){return Z(e.getUTCMinutes(),t,2)}function PN(e,t){return Z(e.getUTCSeconds(),t,2)}function FN(e){var t=e.getUTCDay();return t===0?7:t}function IN(e,t){return Z(pM.count(CM(e)-1,e),t,2)}function LN(e){var t=e.getUTCDay();return t>=4||t===0?_M(e):_M.ceil(e)}function RN(e,t){return e=LN(e),Z(_M.count(CM(e),e)+(CM(e).getUTCDay()===4),t,2)}function zN(e){return e.getUTCDay()}function BN(e,t){return Z(mM.count(CM(e)-1,e),t,2)}function VN(e,t){return Z(e.getUTCFullYear()%100,t,2)}function HN(e,t){return e=LN(e),Z(e.getUTCFullYear()%100,t,2)}function UN(e,t){return Z(e.getUTCFullYear()%1e4,t,4)}function WN(e,t){var n=e.getUTCDay();return e=n>=4||n===0?_M(e):_M.ceil(e),Z(e.getUTCFullYear()%1e4,t,4)}function GN(){return`+0000`}function KN(){return`%`}function qN(e){return+e}function JN(e){return Math.floor(e/1e3)}var YN,XN;ZN({dateTime:`%x, %X`,date:`%-m/%-d/%Y`,time:`%-I:%M:%S %p`,periods:[`AM`,`PM`],days:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],shortDays:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],months:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],shortMonths:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`]});function ZN(e){return YN=MM(e),XN=YN.format,YN.parse,YN.utcFormat,YN.utcParse,YN}function QN(e){return new Date(e)}function $N(e){return e instanceof Date?+e:+new Date(+e)}function eP(e,t,n,r,i,a,o,s,c,l){var u=Pj(),d=u.invert,f=u.domain,p=l(`.%L`),m=l(`:%S`),h=l(`%I:%M`),g=l(`%I %p`),_=l(`%a %d`),v=l(`%b %d`),y=l(`%B`),b=l(`%Y`);function x(e){return(c(e)<e?p:s(e)<e?m:o(e)<e?h:a(e)<e?g:r(e)<e?i(e)<e?_:v:n(e)<e?y:b)(e)}return u.invert=function(e){return new Date(d(e))},u.domain=function(e){return arguments.length?f(Array.from(e,$N)):f().map(QN)},u.ticks=function(t){var n=f();return e(n[0],n[n.length-1],t??10)},u.tickFormat=function(e,t){return t==null?x:l(t)},u.nice=function(e){var n=f();return(!e||typeof e.range!=`function`)&&(e=t(n[0],n[n.length-1],e??10)),e?f(Rj(n,e)):u},u.copy=function(){return Mj(u,eP(e,t,n,r,i,a,o,s,c,l))},u}function tP(){return vj.apply(eP(DM,OM,SM,bM,aM,tM,$j,Zj,Xj,XN).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function nP(e){return function(){return e}}var rP=Math.abs,iP=Math.atan2,aP=Math.cos,oP=Math.max,sP=Math.min,cP=Math.sin,lP=Math.sqrt,uP=Math.PI,dP=uP/2,fP=2*uP;function pP(e){return e>1?0:e<-1?uP:Math.acos(e)}function mP(e){return e>=1?dP:e<=-1?-dP:Math.asin(e)}function hP(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{let e=Math.floor(n);if(!(e>=0))throw RangeError(`invalid digits: ${n}`);t=e}return e},()=>new SA(t)}function gP(e){return e.innerRadius}function _P(e){return e.outerRadius}function vP(e){return e.startAngle}function yP(e){return e.endAngle}function bP(e){return e&&e.padAngle}function xP(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=d*c-u*l;if(!(f*f<1e-12))return f=(u*(t-a)-d*(e-i))/f,[e+f*c,t+f*l]}function SP(e,t,n,r,i,a,o){var s=e-n,c=t-r,l=(o?a:-a)/lP(s*s+c*c),u=l*c,d=-l*s,f=e+u,p=t+d,m=n+u,h=r+d,g=(f+m)/2,_=(p+h)/2,v=m-f,y=h-p,b=v*v+y*y,x=i-a,S=f*h-m*p,C=(y<0?-1:1)*lP(oP(0,x*x*b-S*S)),w=(S*y-v*C)/b,T=(-S*v-y*C)/b,E=(S*y+v*C)/b,D=(-S*v+y*C)/b,O=w-g,k=T-_,A=E-g,j=D-_;return O*O+k*k>A*A+j*j&&(w=E,T=D),{cx:w,cy:T,x01:-u,y01:-d,x11:w*(i/x-1),y11:T*(i/x-1)}}function CP(){var e=gP,t=_P,n=nP(0),r=null,i=vP,a=yP,o=bP,s=null,c=hP(l);function l(){var l,u,d=+e.apply(this,arguments),f=+t.apply(this,arguments),p=i.apply(this,arguments)-dP,m=a.apply(this,arguments)-dP,h=rP(m-p),g=m>p;if(s||=l=c(),f<d&&(u=f,f=d,d=u),!(f>1e-12))s.moveTo(0,0);else if(h>fP-1e-12)s.moveTo(f*aP(p),f*cP(p)),s.arc(0,0,f,p,m,!g),d>1e-12&&(s.moveTo(d*aP(m),d*cP(m)),s.arc(0,0,d,m,p,g));else{var _=p,v=m,y=p,b=m,x=h,S=h,C=o.apply(this,arguments)/2,w=C>1e-12&&(r?+r.apply(this,arguments):lP(d*d+f*f)),T=sP(rP(f-d)/2,+n.apply(this,arguments)),E=T,D=T,O,k;if(w>1e-12){var A=mP(w/d*cP(C)),j=mP(w/f*cP(C));(x-=A*2)>1e-12?(A*=g?1:-1,y+=A,b-=A):(x=0,y=b=(p+m)/2),(S-=j*2)>1e-12?(j*=g?1:-1,_+=j,v-=j):(S=0,_=v=(p+m)/2)}var M=f*aP(_),N=f*cP(_),P=d*aP(b),F=d*cP(b);if(T>1e-12){var I=f*aP(v),L=f*cP(v),R=d*aP(y),ee=d*cP(y),te;if(h<uP){if(te=xP(M,N,R,ee,I,L,P,F)){var ne=M-te[0],z=N-te[1],re=I-te[0],ie=L-te[1],B=1/cP(pP((ne*re+z*ie)/(lP(ne*ne+z*z)*lP(re*re+ie*ie)))/2),ae=lP(te[0]*te[0]+te[1]*te[1]);E=sP(T,(d-ae)/(B-1)),D=sP(T,(f-ae)/(B+1))}else E=D=0}}S>1e-12?D>1e-12?(O=SP(R,ee,M,N,f,D,g),k=SP(I,L,P,F,f,D,g),s.moveTo(O.cx+O.x01,O.cy+O.y01),D<T?s.arc(O.cx,O.cy,D,iP(O.y01,O.x01),iP(k.y01,k.x01),!g):(s.arc(O.cx,O.cy,D,iP(O.y01,O.x01),iP(O.y11,O.x11),!g),s.arc(0,0,f,iP(O.cy+O.y11,O.cx+O.x11),iP(k.cy+k.y11,k.cx+k.x11),!g),s.arc(k.cx,k.cy,D,iP(k.y11,k.x11),iP(k.y01,k.x01),!g))):(s.moveTo(M,N),s.arc(0,0,f,_,v,!g)):s.moveTo(M,N),!(d>1e-12)||!(x>1e-12)?s.lineTo(P,F):E>1e-12?(O=SP(P,F,I,L,d,-E,g),k=SP(M,N,R,ee,d,-E,g),s.lineTo(O.cx+O.x01,O.cy+O.y01),E<T?s.arc(O.cx,O.cy,E,iP(O.y01,O.x01),iP(k.y01,k.x01),!g):(s.arc(O.cx,O.cy,E,iP(O.y01,O.x01),iP(O.y11,O.x11),!g),s.arc(0,0,d,iP(O.cy+O.y11,O.cx+O.x11),iP(k.cy+k.y11,k.cx+k.x11),g),s.arc(k.cx,k.cy,E,iP(k.y11,k.x11),iP(k.y01,k.x01),!g))):s.arc(0,0,d,b,y,g)}if(s.closePath(),l)return s=null,l+``||null}return l.centroid=function(){var n=(+e.apply(this,arguments)+ +t.apply(this,arguments))/2,r=(+i.apply(this,arguments)+ +a.apply(this,arguments))/2-uP/2;return[aP(r)*n,cP(r)*n]},l.innerRadius=function(t){return arguments.length?(e=typeof t==`function`?t:nP(+t),l):e},l.outerRadius=function(e){return arguments.length?(t=typeof e==`function`?e:nP(+e),l):t},l.cornerRadius=function(e){return arguments.length?(n=typeof e==`function`?e:nP(+e),l):n},l.padRadius=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:nP(+e),l):r},l.startAngle=function(e){return arguments.length?(i=typeof e==`function`?e:nP(+e),l):i},l.endAngle=function(e){return arguments.length?(a=typeof e==`function`?e:nP(+e),l):a},l.padAngle=function(e){return arguments.length?(o=typeof e==`function`?e:nP(+e),l):o},l.context=function(e){return arguments.length?(s=e??null,l):s},l}Array.prototype.slice;function wP(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function TP(e){this._context=e}TP.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t)}}};function EP(e){return new TP(e)}function DP(e){return e[0]}function OP(e){return e[1]}function kP(e,t){var n=nP(!0),r=null,i=EP,a=null,o=hP(s);e=typeof e==`function`?e:e===void 0?DP:nP(e),t=typeof t==`function`?t:t===void 0?OP:nP(t);function s(s){var c,l=(s=wP(s)).length,u,d=!1,f;for(r??(a=i(f=o())),c=0;c<=l;++c)!(c<l&&n(u=s[c],c,s))===d&&((d=!d)?a.lineStart():a.lineEnd()),d&&a.point(+e(u,c,s),+t(u,c,s));if(f)return a=null,f+``||null}return s.x=function(t){return arguments.length?(e=typeof t==`function`?t:nP(+t),s):e},s.y=function(e){return arguments.length?(t=typeof e==`function`?e:nP(+e),s):t},s.defined=function(e){return arguments.length?(n=typeof e==`function`?e:nP(!!e),s):n},s.curve=function(e){return arguments.length?(i=e,r!=null&&(a=i(r)),s):i},s.context=function(e){return arguments.length?(e==null?r=a=null:a=i(r=e),s):r},s}function AP(e,t,n){var r=null,i=nP(!0),a=null,o=EP,s=null,c=hP(l);e=typeof e==`function`?e:e===void 0?DP:nP(+e),t=typeof t==`function`?t:nP(t===void 0?0:+t),n=typeof n==`function`?n:n===void 0?OP:nP(+n);function l(l){var u,d,f,p=(l=wP(l)).length,m,h=!1,g,_=Array(p),v=Array(p);for(a??(s=o(g=c())),u=0;u<=p;++u){if(!(u<p&&i(m=l[u],u,l))===h){if(h=!h)d=u,s.areaStart(),s.lineStart();else{for(s.lineEnd(),s.lineStart(),f=u-1;f>=d;--f)s.point(_[f],v[f]);s.lineEnd(),s.areaEnd()}}h&&(_[u]=+e(m,u,l),v[u]=+t(m,u,l),s.point(r?+r(m,u,l):_[u],n?+n(m,u,l):v[u]))}if(g)return s=null,g+``||null}function u(){return kP().defined(i).curve(o).context(a)}return l.x=function(t){return arguments.length?(e=typeof t==`function`?t:nP(+t),r=null,l):e},l.x0=function(t){return arguments.length?(e=typeof t==`function`?t:nP(+t),l):e},l.x1=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:nP(+e),l):r},l.y=function(e){return arguments.length?(t=typeof e==`function`?e:nP(+e),n=null,l):t},l.y0=function(e){return arguments.length?(t=typeof e==`function`?e:nP(+e),l):t},l.y1=function(e){return arguments.length?(n=e==null?null:typeof e==`function`?e:nP(+e),l):n},l.lineX0=l.lineY0=function(){return u().x(e).y(t)},l.lineY1=function(){return u().x(e).y(n)},l.lineX1=function(){return u().x(r).y(t)},l.defined=function(e){return arguments.length?(i=typeof e==`function`?e:nP(!!e),l):i},l.curve=function(e){return arguments.length?(o=e,a!=null&&(s=o(a)),l):o},l.context=function(e){return arguments.length?(e==null?a=s=null:s=o(a=e),l):a},l}function jP(e){return e<0?-1:1}function MP(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),s=(a*i+o*r)/(r+i);return(jP(a)+jP(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function NP(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function PP(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,s=(a-r)/3;e._context.bezierCurveTo(r+s,i+s*t,a-s,o-s*n,a,o)}function FP(e){this._context=e}FP.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:PP(this,this._t0,NP(this,this._t0))}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,e!==this._x1||t!==this._y1){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,PP(this,NP(this,n=MP(this,e,t)),n);break;default:PP(this,this._t0,n=MP(this,e,t))}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}},Object.create(FP.prototype).point=function(e,t){FP.prototype.point.call(this,t,e)};function IP(e){return new FP(e)}function LP(e,t){this._context=e,this._t=t}LP.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}}this._x=e,this._y=t}};function RP(e){return new LP(e,1)}function zP(e,t,n){this.k=e,this.x=t,this.y=n}zP.prototype={constructor:zP,scale:function(e){return e===1?this:new zP(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new zP(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var BP=new zP(1,0,0);VP.prototype=zP.prototype;function VP(e){for(;!e.__zoom;)if(!(e=e.parentNode))return BP;return e.__zoom}function HP(e,t=15){let n=e.split(` `),r=[],i=[],a=0;return n.forEach(e=>{a+e.length>t?(i.length&&r.push(i.join(` `)),i=[e],a=e.length):(i.push(e),a+=e.length+ +(i.length>0))}),i.length&&r.push(i.join(` `)),r}var UP={DECISIVE:20,ROUTINE:50},WP=new Set([`WALKOVER`,`DOUBLE_WALKOVER`,`DEFAULTED`,`DOUBLE_DEFAULT`]),GP={COMPETITIVE:`#16a34a`,ROUTINE:`#3b82f6`,DECISIVE:`#8e44ad`,WALKOVER:`#6b7280`},KP=`#cfd8dc`,qP=`COMPETITIVE`,JP=`ROUTINE`,YP=`DECISIVE`,XP=`WALKOVER`;function ZP(e,t=UP){if(!e?.length)return;let n=[0,0],r=[0,0];for(let t of e)n[0]+=t.side1Score||0,n[1]+=t.side2Score||0,r[0]+=t.side1TiebreakScore||0,r[1]+=t.side2TiebreakScore||0;r[0]+r[1]&&(n[r[0]>r[1]?0:1]+=1);let i=Math.max(n[0],n[1]);if(i===0)return;let a=Math.round(Math.min(n[0],n[1])/i*100);return Number.isNaN(a)?XP:a<=t.DECISIVE?YP:a<=t.ROUTINE?JP:qP}function QP(e,n=UP){if(e)return ZP(t.scoreGovernor.parseScoreString({scoreString:e}),n)}function $P({winningSide:e,matchUpStatus:t,sets:n,scoreString:r,bands:i}){if(t&&WP.has(t))return XP;if(e)return n?.length?ZP(n,i):QP(r,i)}function eF(e,t){return e?t?.[e]??GP[e]:KP}var{WILDCARD:tF,QUALIFIER:nF,LUCKY_LOSER:rF}=t.entryStatusConstants,iF=`text-anchor`,aF=`dominant-baseline`,oF=`fill-opacity`,sF=Object.assign({},...t.fixtures.countries.filter(e=>e.ioc).map(e=>({[e.ioc]:e.iso2})),...t.fixtures.countries.filter(e=>e.iso).map(e=>({[e.iso]:e.iso2})));function cF(e){let t=Math.floor(e.length/2),n=e.slice(0,t),r=e.slice(t).reverse();return[...n,...r]}function lF(e){if(e)switch(e){case tF:return`WC`;case nF:return`Q`;case rF:return`LL`;default:return e}}function uF(e,t){let n=[];for(let r of e)for(let e of r.sides){let i=r.matchUpStatus===`BYE`&&!e.participantName;n.push({name:e.participantName||(i?`BYE`:``),participantName:e.participantName||(i?`BYE`:void 0),drawPosition:e.drawPosition,seedNumber:e.seedNumber,entryStatus:lF(e.entryStatus),nationalityCode:e.nationalityCode,matchUp:r,depth:t,value:1})}return n}function dF(e,t){let n=e.winningSide!==void 0&&e.winningSide!==null?e.sides.find(t=>t.sideNumber===e.winningSide):void 0;!n&&e.matchUpStatus===`BYE`&&(n=e.sides.find(e=>e.participantName));let r=n?.participantName,i=r?t.get(r):void 0;return{winnerName:r,winnerSide:n,winnerLookup:i}}function fF(e,t,n,r){return e.map((e,i)=>{let a=i*2,o=[t[a],t[a+1]].filter(Boolean),{winnerName:s,winnerSide:c,winnerLookup:l}=dF(e,r);return{name:s||``,participantName:s,drawPosition:l?.drawPosition??c?.drawPosition,seedNumber:c?.seedNumber??l?.seedNumber,entryStatus:lF(c?.entryStatus)??l?.entryStatus,nationalityCode:c?.nationalityCode??l?.nationalityCode,scoreString:e.scoreString,matchUpStatus:e.matchUpStatus,competitiveness:e.competitiveness,matchUp:e,depth:n,children:o.length>0?o:void 0}})}function pF(e){let{roundMatchUps:t}=e,n=Object.keys(t).map(Number).sort((e,t)=>e-t);if(n.length===0)throw Error(`No round data found in draw`);let r=t[n[0]],i=cF(uF(r,n.length)),a=new Map;for(let e of i)e.participantName&&e.participantName!==`BYE`&&a.set(e.participantName,e);let o=fF(cF(r),i,n.length-1,a);for(let e=1;e<n.length;e++)o=fF(cF(t[n[e]]),o,n.length-1-e,a);return o.length===1?o[0]:{name:`Tournament`,depth:0,children:o}}function mF(e,t){if(!e)return;let{seedNumber:n,entryStatus:r,drawPosition:i,participantName:a}=e,o;if(a?.trim().toUpperCase()===`BYE`)o=`#B0BEC5`;else if(n){let e=Number(n),t=Lj().domain([1,32]).range([`0`,`1`]);o=Lj().domain(Jw(0,1,1/7)).range([`#81D4FA`,`#42A5F5`,`#1E88E5`,`#1565C0`,`#5C6BC0`,`#673AB7`,`#9C27B0`])(Number(t(e)))}else if(r?.toUpperCase()===`WC`)o=`red`;else if(r&&(r===`Q`||r===`LL`))o=Lj().domain(Jw(0,1,1/3)).range([`#FFF176`,`#FBC02D`,`#FF9800`])(t(i));else{let e=[`#C8E6C9`,`#81C784`,`#66BB6A`,`#4CAF50`,`#43A047`,`#388E3C`,`#2E7D32`,`#1B5E20`,`#A5D6A7`,`#90CAF9`,`#64B5F6`,`#42A5F5`,`#2196F3`,`#1E88E5`,`#1976D2`,`#1565C0`];o=Lj().domain(Jw(0,1,1/e.length)).range(e)(t(i))}e.color=o,e.children&&e.children.forEach(n=>{n.participantName===e.participantName&&(n.color=o),mF(n,t)})}function hF(e,t){e&&(e.competitivenessColor=e.children?.length&&e.competitiveness?eF(e.competitiveness,t):KP,e.children?.forEach(e=>hF(e,t)))}function gF(e,t){let n=[];return e.seedNumber?n.push(`Seed ${e.seedNumber}`):e.entryStatus&&n.push(e.entryStatus),t===7&&e.drawPosition&&n.push(`Draw ${e.drawPosition}`),n.length>0?n.join(` • `):void 0}function _F(e,t){let n=e.find(e=>e.data.participantName&&e.data.participantName!==t);return n?.data.participantName?n.data:void 0}function vF(e,t){let n=[e.participantName],r;if(t.children&&t.children.length>0)e.scoreString&&n.push(e.scoreString),r=_F(t.children,e.participantName),r&&n.push(r.participantName);else{let r=gF(e,t.depth);r&&n.push(r)}return{messageLines:n,opponentData:r}}function yF(e,t){return-(e*t/2)+t/2}function bF(e,t,n){let r=pD(e).append(`svg`).attr(`width`,t).attr(`height`,n).style(`display`,`block`),i=r.append(`g`).attr(`transform`,`translate(${t/2}, ${n/2})`);return{svg:r,g:i,flagsGroup:i.append(`g`).attr(`class`,`flags-group`),winningFlagsGroup:i.append(`g`).attr(`class`,`winning-flags-group`),losingFlagsGroup:i.append(`g`).attr(`class`,`losing-flags-group`)}}function xF(e,t,n,r,i){let a=e.append(`text`).attr(`x`,t/2).attr(`y`,n/2).attr(iF,`middle`).attr(aF,`middle`).attr(`font-size`,`${r}px`).attr(`font-weight`,`bold`).style(`fill`,`var(--chc-text-primary, #333)`).attr(`pointer-events`,`none`),o=r+i*.5;return{centerText:a,centerText2:e.append(`text`).attr(`x`,t/2).attr(`y`,n/2+o).attr(iF,`middle`).attr(aF,`middle`).attr(`font-size`,`${i}px`).style(`fill`,`var(--chc-text-secondary, #666)`).attr(`pointer-events`,`none`)}}function SF(e,t,n,r,i,a,o){n&&(i?(t.flagsGroup.selectAll(`text`).remove(),t.winningFlagsGroup.selectAll(`text`).remove(),t.losingFlagsGroup.selectAll(`text`).remove()):e.selectAll(`text`).remove(),e.append(`text`).attr(`font-size`,`${o}px`).attr(iF,`middle`).attr(aF,`middle`).attr(`transform`,`translate(0, ${r*a})`).text(EF(n)))}function CF(e,n,r,i={}){let a=i.width||800,o=i.height||800,s=Math.min(a,o)/800*(i.textScaleFactor??1),c=28*s,l=24*s,u=30*s,d=r||i.title||`Tournament`,f=Object.assign({},...t.fixtures.countries.filter(e=>e.label).map(e=>({[e.ioc]:e.label})));if(!Object.keys(n?.roundMatchUps??{}).length)return{highlightPlayer:()=>0,hide:()=>void 0,setColorMode:()=>void 0};let p=pF(n),m=cj(p,e=>e.children).sum(e=>e.value||0),h=Math.min(a,o)/2,g=h/2,_=e=>e*h/200;_j().size([2*Math.PI,h-g])(m),mF(p,Lj().domain([0,n.drawSize||128]).range([0,1])),hF(p,i.competitivenessColors);let v=i.colorMode??`default`,y=e=>v===`competitiveness`?e.competitivenessColor||`#cfd8dc`:e.color||`#ccc`,b=m.descendants(),x=CP().startAngle(e=>e.x0).endAngle(e=>e.x1).innerRadius(e=>e.y0+g).outerRadius(e=>e.y1+g),{svg:S,g:C,flagsGroup:w,winningFlagsGroup:T,losingFlagsGroup:E}=bF(e,a,o),D=new Set,O=e=>{e.nationalityCode&&D.add(e.nationalityCode),e.children&&e.children.forEach(O)};O(p);let k=Array.from(D),{centerText:A,centerText2:j}=xF(S,a,o,c,l);function M(){let e=HP(d,15);A.text(``),A.selectAll(`tspan`).remove(),j.text(``),j.selectAll(`tspan`).remove(),A.selectAll(`tspan`).data(e).join(`tspan`).attr(`x`,a/2).attr(`dy`,(e,t)=>t===0?0:u).text(e=>e);let t=-(e.length*u/2)+u/2;A.attr(`y`,o/2+t),A.style(`display`,`block`),j.style(`display`,`none`)}function N(){if(w.selectAll(`text`).remove(),T.selectAll(`text`).remove(),E.selectAll(`text`).remove(),k.length===0)return;let e=Lj().domain([0,k.length]).range([0,Math.PI*2]),t=_(20),n=g-t+10;w.selectAll(`text`).data(k).join(`text`).attr(`font-size`,`${t}px`).attr(iF,`middle`).attr(aF,`middle`).attr(`transform`,(t,r)=>{let i=e(r);return`translate(${Math.cos(i)*n}, ${Math.sin(i)*n})`}).text(e=>EF(e)).style(`cursor`,`pointer`).on(`mouseover`,function(e,t){let n=f[t]||t;A.selectAll(`tspan`).remove(),A.attr(`y`,o/2),A.text(n).style(`display`,`block`),j.selectAll(`tspan`).remove(),j.text(``).style(`display`,`none`),F||C.selectAll(`path`).attr(oF,e=>e.data.nationalityCode===t?.9:.3)}).on(`mouseout`,function(){F||C.selectAll(`path`).attr(oF,.8),M()})}N(),M();let P=i.eventHandlers?.clickCenter;P&&C.insert(`circle`,`:first-child`).attr(`r`,g).attr(`fill`,`transparent`).style(`cursor`,`pointer`).on(`click`,P);let F=!1,I;function L(e,t){let n=t.data;if(n.participantName){let{messageLines:e,opponentData:r}=vF(n,t);r&&(n.opponent=r),A.selectAll(`tspan`).remove(),A.text(``),A.selectAll(`tspan`).data(e).join(`tspan`).attr(`x`,a/2).attr(`dy`,(e,t)=>t===0?0:u).text(e=>e);let i=yF(e.length,u);A.attr(`y`,o/2+i),A.style(`display`,`block`),j.style(`display`,`none`)}F?n.participantName?.toLowerCase()!==I?.toLowerCase()&&pD(e.currentTarget).attr(oF,.9):C.selectAll(`path`).attr(oF,e=>e.data.participantName===t.data.participantName?.9:.3);let r=_(30),i=g-r-10,s={flagsGroup:w,winningFlagsGroup:T,losingFlagsGroup:E};SF(T,s,n.nationalityCode,-1,!0,i,r),n.opponent&&SF(E,s,n.opponent.nationalityCode,1,!1,i,r)}function R(e,t){if(F){let n=t.data.participantName?.toLowerCase()===I?.toLowerCase();pD(e.currentTarget).attr(oF,n?1:.2)}else C.selectAll(`path`).attr(oF,.8);N(),M()}let ee=i.eventHandlers?.clickSegment;function te(e,t){if(!ee)return;let n=t.data;ee({participantName:n.participantName,drawPosition:n.drawPosition,seedNumber:n.seedNumber,entryStatus:n.entryStatus,nationalityCode:n.nationalityCode,scoreString:n.scoreString,matchUpStatus:n.matchUpStatus,competitiveness:n.competitiveness,roundName:n.roundName,depth:n.depth,matchUp:n.matchUp})}let ne=C.selectAll(`path`).data(b).join(`path`).attr(`d`,e=>x(e)).attr(`fill`,e=>y(e.data)).attr(oF,.8).attr(`stroke`,`#fff`).attr(`stroke-width`,1).on(`mouseover`,L).on(`mouseout`,R);ee&&ne.style(`cursor`,`pointer`).on(`click`,te),ne.append(`title`).text(e=>{let t=e.data;if(t.participantName){let e=[t.participantName,`Draw: ${t.drawPosition||`N/A`}`];return t.competitiveness&&e.push(`Competitiveness: ${t.competitiveness}`),e.join(`
215
215
  `)}return`${t.name}\nDepth: ${e.depth}`});function z(e){let t=0;return F=!!e,I=e,C.selectAll(`path`).attr(oF,n=>e?n.data.participantName?.toLowerCase()===e.toLowerCase()?(t+=1,1):.2:.8),t}function re(e){S.style(`display`,e?`none`:`block`)}function ie(e){v=e,C.selectAll(`path`).attr(`fill`,e=>y(e.data))}return{highlightPlayer:z,hide:re,setColorMode:ie}}function wF(e={}){return{render:(t,n,r)=>CF(t,n,r,e)}}function TF(e){return e?.length===2?e&&String.fromCodePoint!==void 0?e.toUpperCase().replaceAll(/./g,e=>String.fromCodePoint((e.codePointAt(0)??0)+127397)):e:``}function EF(e){return TF(sF[e]||e)}var{LUCKY_LOSER:DF,WILDCARD:OF,QUALIFIER:kF}=t.entryStatusConstants,{WIN_RATIO:AF,ROUND_OUTCOME:jF,MAIN:MF,CONTAINER:NF}=t.drawDefinitionConstants;function PF(e){return e?.finishingPosition===jF&&e?.structureType!==NF}function FF(e){return e?.finishingPosition===AF||e?.structureType===NF}function IF(e){if(!e?.length)return;let t=e.filter(PF);if(t.length)return t.find(e=>e.stage===MF)??t[0]}function LF(e){if(FF(e))return{drawSize:0,roundMatchUps:{}};let t={};for(let[n,r]of Object.entries(e.roundMatchUps))t[Number(n)]=r.map(e=>({...e,winningSide:e.winningSide,drawPositions:e.drawPositions||[],competitiveness:$P({winningSide:e.winningSide,matchUpStatus:e.matchUpStatus,sets:e.score?.sets}),scoreString:e.winningSide===1?e.score?.scoreStringSide1:e.winningSide===2?e.score?.scoreStringSide2:void 0,sides:(e.sides||[]).map(e=>({sideNumber:e.sideNumber,drawPosition:e.drawPosition,participantName:e.participant?.participantName,nationalityCode:e.participant?.person?.nationalityCode,seedNumber:e.seedNumber,entryStatus:e.participant?.entryStatus}))}));return{drawSize:(t[1]?.length||0)*2,roundMatchUps:t,seedAssignments:e.seedAssignments}}var RF={LL:DF,WC:OF,Q:kF},zF=[`R128`,`R64`,`R32`,`R16`,`QF`,`SF`,`F`];function BF(e){let t=VF(e);if(t.length===0)return{drawSize:0,roundMatchUps:{}};let n=t[0].data,r=n.length,i=HF(n),a=UF(t,e),o={};o[1]=GF(n,a,t);for(let e=1;e<t.length;e++)o[e+1]=KF(e,t,a,i);return{drawSize:r,roundMatchUps:o}}function VF(e){let t=[],n=!1;for(let r of zF){let i=e[r];i&&i.length>0&&(n=!0),n&&i&&i.length>0&&t.push({key:r,data:i})}return t}function HF(e){let t=new Map;return e.forEach((e,n)=>{let r=qF(e.player);r&&r!==`BYE`&&t.set(r,{drawPosition:e.Draw??n+1,country:e.country,seed:e.seed,entry:e.entry})}),t}function UF(e,t){let n=new Map;for(let r=0;r<e.length;r++){let i=r+1<e.length?e[r+1].data:t.W||[],a=new Set;for(let e of i){let t=qF(e.player);t&&a.add(t)}n.set(e[r].key,a)}return n}function WF(e,t,n){if(e===`BYE`||t===`BYE`)return e===`BYE`?2:1;if(n.has(e))return 1;if(n.has(t))return 2}function GF(e,t,n){let r=[],i=t.get(n[0].key)||new Set;for(let t=0;t<e.length;t+=2){let a=e[t],o=e[t+1],s=qF(a?.player),c=qF(o?.player),l=s===`BYE`||c===`BYE`,u=WF(s,c,i),d;if(!l&&n.length>1){let e=n[1].data,t=u===1?s:c;d=e.find(e=>qF(e.player)===t)?.score}let f=l?`BYE`:u?`COMPLETED`:`TO_BE_PLAYED`;r.push({roundNumber:1,matchUpStatus:f,winningSide:u,drawPositions:[a?.Draw??t+1,o?.Draw??t+2],competitiveness:$P({winningSide:u,matchUpStatus:f,scoreString:d}),scoreString:d,sides:[YF(1,a,t+1),YF(2,o,t+2)]})}return r}function KF(e,t,n,r){let i=e+1,a=t[e].data,o=n.get(t[e].key)||new Set,s=[];for(let e=0;e<a.length;e+=2){let t=a[e],n=a[e+1],c=qF(t?.player),l=qF(n?.player),u=o.has(c)?1:o.has(l)?2:void 0,d=(u===1?t:u===2?n:void 0)?.score,f=u?`COMPLETED`:`TO_BE_PLAYED`;s.push({roundNumber:i,matchUpStatus:f,winningSide:u,drawPositions:[r.get(c)?.drawPosition??0,r.get(l)?.drawPosition??0],competitiveness:$P({winningSide:u,matchUpStatus:f,scoreString:d}),scoreString:d,sides:[XF(1,t,r),XF(2,n,r)]})}return s}function qF(e){if(!e)return``;let t=e.trim();return t.toUpperCase()===`BYE`?`BYE`:t}function JF(e){if(e)return RF[e.toUpperCase()]||e}function YF(e,t,n){if(!t)return{sideNumber:e,drawPosition:n};let r=qF(t.player);return{sideNumber:e,drawPosition:t.Draw??n,participantName:r||void 0,nationalityCode:t.country||void 0,seedNumber:t.seed?Number(t.seed):void 0,entryStatus:JF(t.entry)}}function XF(e,t,n){if(!t)return{sideNumber:e,drawPosition:0};let r=qF(t.player),i=n.get(r);return{sideNumber:e,drawPosition:i?.drawPosition??0,participantName:r||void 0,nationalityCode:t.country||i?.country||void 0,seedNumber:t.seed?Number(t.seed):i?.seed?Number(i.seed):void 0,entryStatus:JF(t.entry||i?.entry)}}var ZF=480,QF=200,$F=280,eI={top:12,right:12,bottom:28,left:32},tI={top:12,right:12,bottom:12,left:12},nI=.6,rI=.9,iI=`http://www.w3.org/2000/svg`,aI=`middle`,oI=`text-anchor`,sI=`dominant-baseline`,cI=[`var(--chc-rating-low, #5b8ff9)`,`var(--chc-rating-high, #00b894)`];function lI(e,t,n){let r=document.createElementNS(iI,`svg`);return r.setAttribute(`width`,String(e)),r.setAttribute(`height`,String(t)),r.setAttribute(`viewBox`,`0 0 ${e} ${t}`),r.setAttribute(`class`,`chc-rating-distribution-chart`),n&&r.setAttribute(`aria-label`,n),r}function uI(e,t,n){return n<=1||t/(n-1)<.5?cI[0]:cI[1]}function dI(e,t,n,r){return r?r(e,t):uI(e,t,n)}function fI(e){return`${e.binStart.toFixed(1)}–${e.binEnd.toFixed(1)}`}function pI(e){let{stats:t,width:n,height:r,margin:i,showAxis:a,showCounts:o,showMean:s,binColor:c,ariaLabel:l}=e,u=lI(n,r,l),d=pD(u).append(`g`).attr(`class`,`chc-rdc-histogram`).attr(`transform`,`translate(${i.left}, ${i.top})`),f=Math.max(0,n-i.left-i.right),p=Math.max(0,r-i.top-i.bottom);if(t.histogram.length===0||f===0||p===0)return u;let m=xj().domain(t.histogram.map(fI)).range([0,f]).padding(.12),h=Lj().domain([0,qw(t.histogram,e=>e.count)??0]).nice().range([p,0]),g=t.histogram.length;if(d.selectAll(`rect.chc-rdc-bar`).data(t.histogram).enter().append(`rect`).attr(`class`,`chc-rdc-bar`).attr(`x`,e=>m(fI(e))??0).attr(`y`,e=>h(e.count)).attr(`width`,m.bandwidth()).attr(`height`,e=>p-h(e.count)).attr(`fill`,(e,t)=>dI(e,t,g,c)).append(`title`).text(e=>`${fI(e)}: ${e.count}`),o&&d.selectAll(`text.chc-rdc-count`).data(t.histogram).enter().append(`text`).attr(`class`,`chc-rdc-count`).attr(`x`,e=>(m(fI(e))??0)+m.bandwidth()/2).attr(`y`,e=>h(e.count)-4).attr(oI,aI).attr(`font-size`,`11`).attr(`fill`,`var(--chc-rdc-count-color, var(--chc-text-primary, #111827))`).text(e=>e.count>0?String(e.count):``),a){let e=t.histogram.map(fI),n=f/g>=55?e:[e[0],e.at(-1)].filter((e,t,n)=>n.indexOf(e)===t);d.append(`g`).attr(`class`,`chc-rdc-axis`).attr(`transform`,`translate(0, ${p})`).call(sT(m).tickValues(n).tickSize(0)).call(e=>e.select(`.domain`).remove()).call(e=>e.selectAll(`text`).attr(`font-size`,`10`).attr(`dy`,`0.9em`))}if(s&&Number.isFinite(t.mean)&&t.histogram.length>0){let e=t.histogram[0],n=t.histogram.at(-1),r=(t.mean-e.binStart)/(n.binEnd-e.binStart);if(r>=0&&r<=1){let e=r*f;d.append(`line`).attr(`class`,`chc-rdc-mean`).attr(`x1`,e).attr(`x2`,e).attr(`y1`,0).attr(`y2`,p).attr(`stroke`,`var(--chc-rating-mean, #d63031)`).attr(`stroke-dasharray`,`4 3`).attr(`stroke-width`,1.5)}}return u}function mI(e,t,n,r){return[e+n*Math.sin(r),t-n*Math.cos(r)]}function hI(e,t,n,r,i,a){let[o,s]=mI(e,t,n,i),[c,l]=mI(e,t,n,a),[u,d]=mI(e,t,r,a),[f,p]=mI(e,t,r,i),m=+(a-i>Math.PI);return[`M ${o} ${s}`,`A ${n} ${n} 0 ${m} 1 ${c} ${l}`,`L ${u} ${d}`,`A ${r} ${r} 0 ${m} 0 ${f} ${p}`,`Z`].join(` `)}function gI(e){let{stats:t,size:n,margin:r,showCounts:i,binColor:a,ariaLabel:o}=e,s=lI(n,n,o);if(t.histogram.length===0||t.count===0)return s;let c=(n-Math.max(r.left+r.right,r.top+r.bottom))/2,l=n/2,u=n/2,d=c*rI,f=c*nI,p=0,m=t.histogram.length;for(let e=0;e<m;e++){let n=t.histogram[e];if(n.count===0)continue;let r=n.count/t.count*2*Math.PI,o=p,c=p+r,h=document.createElementNS(iI,`path`);if(h.setAttribute(`class`,`chc-rdc-slice`),h.setAttribute(`d`,hI(l,u,d,f,o,c)),h.setAttribute(`fill`,dI(n,e,m,a)),s.appendChild(h),i){let e=o+r/2,[t,i]=mI(l,u,(d+f)/2,e),a=document.createElementNS(iI,`text`);a.setAttribute(`class`,`chc-rdc-slice-label`),a.setAttribute(`x`,String(t)),a.setAttribute(`y`,String(i)),a.setAttribute(oI,aI),a.setAttribute(sI,aI),a.setAttribute(`font-size`,`11`),a.setAttribute(`fill`,`var(--chc-rating-label, #2d3436)`),a.textContent=String(n.count),s.appendChild(a)}p=c}let h=document.createElementNS(iI,`text`);return h.setAttribute(`class`,`chc-rdc-center-count`),h.setAttribute(`x`,String(l)),h.setAttribute(`y`,String(u)),h.setAttribute(oI,aI),h.setAttribute(sI,aI),h.setAttribute(`font-size`,`20`),h.setAttribute(`font-weight`,`600`),h.textContent=String(t.count),s.appendChild(h),s}function _I(e,t={}){let n=t.mode??`HISTOGRAM`,r=t.ariaLabel??`Participant rating distribution`;return n===`DONUT`?gI({stats:e,size:t.width??t.height??$F,margin:t.margin??tI,showCounts:t.showCounts??!0,binColor:t.binColor,ariaLabel:r}):pI({stats:e,width:t.width??ZF,height:t.height??QF,margin:t.margin??eI,showAxis:t.showAxis??!0,showCounts:t.showCounts??!0,showMean:t.showMean??!0,binColor:t.binColor,ariaLabel:r})}var vI=`http://www.w3.org/2000/svg`,yI={top:36,right:16,bottom:28,left:56},bI=600,xI=260,SI=6,CI=8;function wI(e,t){let n=document.createElementNS(vI,`svg`);n.classList.add(`lc-svg`),e.appendChild(n);let r={container:e,svg:n,config:{...t},destroyed:!1};return TI(r),{element:n,update(e){r.destroyed||(r.config={...r.config,...e},TI(r))},destroy(){r.destroyed||(r.destroyed=!0,n.parentNode===e&&e.removeChild(n))}}}function TI(e){let{svg:t,container:n,config:r}=e,i={...yI,...r.margins||{}},a=n.clientWidth||bI,o=r.width??a,s=r.height??xI;for(;t.firstChild;)t.removeChild(t.firstChild);t.setAttribute(`width`,String(o)),t.setAttribute(`height`,String(s)),t.setAttribute(`viewBox`,`0 0 ${o} ${s}`);let c=Math.max(0,o-i.left-i.right),l=Math.max(0,s-i.top-i.bottom),u=(r.data||[]).map(e=>({...e,_dateValue:e.date instanceof Date?e.date:new Date(e.date),_rung:Math.max(0,Math.min(r.rungs.length-1,e.rung))})).filter(e=>!Number.isNaN(e._dateValue.getTime())).sort((e,t)=>e._dateValue.getTime()-t._dateValue.getTime());if(r.title){let e=document.createElementNS(vI,`text`);e.setAttribute(`class`,`lc-title`),e.setAttribute(`x`,String(i.left)),e.setAttribute(`y`,String(Math.max(16,i.top-12))),e.textContent=r.title,t.appendChild(e)}if(!u.length){let e=document.createElementNS(vI,`text`);e.setAttribute(`class`,`lc-empty`),e.setAttribute(`x`,String(o/2)),e.setAttribute(`y`,String(s/2)),e.setAttribute(`text-anchor`,`middle`),e.textContent=`No data`,t.appendChild(e);return}let d=Pw(u,e=>e._dateValue),f=Math.max(3,(d[1].getTime()-d[0].getTime())/864e5*.04),p=new Date(d[0].getTime()-f*864e5),m=new Date(d[1].getTime()+f*864e5),h=tP().domain([p,m]).range([0,c]),g=Cj().domain([...r.rungs].reverse()).range([0,l]).padding(.5),_=document.createElementNS(vI,`g`);_.setAttribute(`transform`,`translate(${i.left},${i.top})`),t.appendChild(_);let v=document.createElementNS(vI,`g`);v.setAttribute(`class`,`lc-axis lc-axis-y`),_.appendChild(v),pD(v).call(cT(g).tickSize(-c).tickPadding(8));let y=document.createElementNS(vI,`g`);y.setAttribute(`class`,`lc-axis lc-axis-x`),y.setAttribute(`transform`,`translate(0,${l})`),_.appendChild(y);let b=d[1].getFullYear()-d[0].getFullYear()>=1?`%Y`:`%b`,x=r.xTickFormat??b;if(pD(y).call(sT(h).ticks(r.xMaxTicks??CI).tickFormat(XN(x))),r.showConnector!==!1&&u.length>1){let e=kP().x(e=>h(e._dateValue)).y(e=>g(r.rungs[e._rung])??0).curve(RP),t=document.createElementNS(vI,`path`);t.setAttribute(`class`,`lc-connector`),t.setAttribute(`d`,e(u)||``),r.connectorColor&&(t.style.stroke=r.connectorColor),_.appendChild(t)}let S=document.createElementNS(vI,`g`);S.setAttribute(`class`,`lc-marks`),_.appendChild(S);for(let e of u){let t=h(e._dateValue),n=g(r.rungs[e._rung])??0,i=e.radius??r.markRadius??SI,a=document.createElementNS(vI,`circle`);if(a.setAttribute(`class`,`lc-mark`),a.setAttribute(`cx`,String(t)),a.setAttribute(`cy`,String(n)),a.setAttribute(`r`,String(i)),(e.color||r.markColor)&&(a.style.fill=e.color??r.markColor),e.label){let t=[e.label,e.detail].filter(Boolean).join(` — `);a.setAttribute(`aria-label`,t);let n=document.createElementNS(vI,`title`);n.textContent=t,a.appendChild(n)}r.onMarkClick&&(a.style.cursor=`pointer`,a.addEventListener(`click`,t=>r.onMarkClick(e,t))),r.onMarkHover&&(a.addEventListener(`mouseenter`,t=>r.onMarkHover(e,t)),a.addEventListener(`mouseleave`,e=>r.onMarkHover(null,e))),S.appendChild(a)}if(r.source){let e=document.createElementNS(vI,`text`);e.setAttribute(`class`,`lc-source`),e.setAttribute(`x`,String(o-i.right)),e.setAttribute(`y`,String(s-6)),e.setAttribute(`text-anchor`,`end`),e.textContent=`Source: ${r.source}`,t.appendChild(e)}}var EI=`http://www.w3.org/2000/svg`,DI=`text-anchor`,OI=`dominant-baseline`,kI=`class`,AI=`middle`,jI=520,MI=240,NI={top:16,right:64,bottom:28,left:44},PI=5,FI=3;function II(e,t,n){let r=n-t;if(n>=3){if(r===1)return`F`;if(r===2)return`SF`;if(r===3)return`QF`}return`R${t+1}`}function LI(e,t){let n=document.createElementNS(EI,e);return t&&n.setAttribute(kI,t),n}function RI(e){let t=Math.round(e);return t>0?`+${t}`:String(t)}function zI(e,t){if(t)return t;let n=[];for(let t of e)for(let e of[t.projected.expected,t.projected.low,t.projected.high,t.actual])e!=null&&n.push(e);if(!n.length)return[-100,100];let r=Math.max(Math.abs(Math.min(...n)),Math.abs(Math.max(...n)),50)*1.15;return[-r,r]}function BI(e,t){let n=t.width??jI,r=t.height??MI,i=t.margin??(t.spark?{top:6,right:6,bottom:6,left:6}:NI),a=Math.max(1,n-i.left-i.right),o=Math.max(1,r-i.top-i.bottom),s=Lj().domain([0,Math.max(1,e.length-1)]).range([0,a]),c=zI(e,t.yDomain),l=Lj().domain(c).range([o,0]);return{x:e=>s(e),y:e=>l(e),yDomain:c,innerWidth:a,innerHeight:o,margin:i}}function VI(e,t,n){let r=t.map((e,t)=>({point:e,index:t})).filter(({point:e})=>e.projected.low!==null&&e.projected.high!==null);if(r.length<2)return;let i=AP().x(({index:e})=>n.x(e)).y0(({point:e})=>n.y(e.projected.low)).y1(({point:e})=>n.y(e.projected.high)),a=LI(`path`,`chc-pc__band`);a.setAttribute(`d`,i(r)??``),e.appendChild(a)}function HI({group:e,points:t,geometry:n,className:r,accessor:i}){let a=t.map((e,t)=>({point:e,index:t})).filter(({point:e})=>i(e)!==null);if(a.length<2)return;let o=kP().x(({index:e})=>n.x(e)).y(({point:e})=>n.y(i(e))),s=LI(`path`,r);s.setAttribute(`d`,o(a)??``),e.appendChild(s)}function UI(e){return eF(e)}function WI({group:e,points:t,geometry:n,radius:r,onHover:i}){t.forEach((t,a)=>{if(t.actual===null)return;let o=LI(`circle`,t.won===!1?`chc-pc__marker chc-pc__marker--lost`:`chc-pc__marker`);o.setAttribute(`cx`,String(n.x(a))),o.setAttribute(`cy`,String(n.y(t.actual))),o.setAttribute(`r`,String(r)),o.setAttribute(`fill`,UI(t.competitiveness));let s=document.createElementNS(EI,`title`);s.textContent=`Round ${t.roundNumber}: ${RI(t.actual)} · ${t.competitiveness??`unclassified`}`,o.appendChild(s),i&&(o.addEventListener(`mouseenter`,e=>i(t,a,e)),o.addEventListener(`mousemove`,e=>i(t,a,e))),e.appendChild(o)})}function GI({group:e,geometry:t}){let[n,r]=t.yDomain,i=KI(Math.max(Math.abs(n),Math.abs(r)));for(let a of[-i,i]){if(a<n||a>r)continue;let i=LI(`line`,`chc-pc__tick`);i.setAttribute(`x1`,`0`),i.setAttribute(`x2`,String(t.innerWidth)),i.setAttribute(`y1`,String(t.y(a))),i.setAttribute(`y2`,String(t.y(a))),e.appendChild(i);let o=LI(`text`,`chc-pc__tick-label`);o.setAttribute(`x`,`-6`),o.setAttribute(`y`,String(t.y(a))),o.setAttribute(DI,`end`),o.setAttribute(OI,AI),o.textContent=RI(a),e.appendChild(o)}}function KI(e){if(!Number.isFinite(e)||e<=0)return 1;let t=e/2,n=10**Math.floor(Math.log10(t)),r=t/n;return(r>=5&&5||r>=2&&2||1)*n}function qI({group:e,points:t,geometry:n,options:r}){let i=LI(`line`,`chc-pc__zero`);if(i.setAttribute(`x1`,`0`),i.setAttribute(`x2`,String(n.innerWidth)),i.setAttribute(`y1`,String(n.y(0))),i.setAttribute(`y2`,String(n.y(0))),e.appendChild(i),r.spark)return;GI({group:e,geometry:n});let a=LI(`text`,`chc-pc__axis-label`);a.setAttribute(`x`,String(n.innerWidth+6)),a.setAttribute(`y`,String(n.y(0))),a.setAttribute(OI,AI),a.textContent=`even`,e.appendChild(a);let o=r.roundLabels??II;t.forEach((r,i)=>{let a=LI(`text`,`chc-pc__round-label`);if(a.setAttribute(`x`,String(n.x(i))),a.setAttribute(`y`,String(n.innerHeight+16)),a.setAttribute(DI,AI),a.textContent=o(r.roundNumber,i,t.length),e.appendChild(a),r.bye){let t=LI(`text`,`chc-pc__bye`);t.setAttribute(`x`,String(n.x(i))),t.setAttribute(`y`,String(n.y(0)-8)),t.setAttribute(DI,AI),t.textContent=`bye`,e.appendChild(t)}});let s=LI(`text`,`chc-pc__axis-label`);s.setAttribute(`x`,`0`),s.setAttribute(`y`,`-4`),s.textContent=r.scaleName?`opponent strength vs own (${r.scaleName}, ELO-equivalent)`:`opponent strength vs own`,e.appendChild(s)}function JI({group:e,points:t,geometry:n}){let r=[...t].reverse().find(e=>e.projected.expected!==null),i=[...t].reverse().find(e=>e.actual!==null);if(r){let i=t.indexOf(r),a=LI(`text`,`chc-pc__series-label`);a.setAttribute(`x`,String(n.x(i)+8)),a.setAttribute(`y`,String(n.y(r.projected.expected))),a.setAttribute(OI,AI),a.setAttribute(`fill`,`var(--chc-pc-projected)`),a.textContent=`projected`,e.appendChild(a)}if(i){let r=t.indexOf(i),a=r<t.length-1,o=LI(`text`,`chc-pc__series-label`);o.setAttribute(`x`,String(n.x(r)+8)),o.setAttribute(`y`,String(n.y(i.actual)+(a?-12:0))),o.setAttribute(OI,AI),o.textContent=`actual`,e.appendChild(o)}}function YI(){let e=document.createElement(`div`);e.className=`chc-pc__legend`;for(let[t,n]of[[`chc-pc__legend-swatch chc-pc__legend-swatch--band`,`possible opponents`],[`chc-pc__legend-swatch chc-pc__legend-swatch--projected`,`projected`],[`chc-pc__legend-swatch chc-pc__legend-swatch--line`,`actual`]]){let r=document.createElement(`span`);r.className=`chc-pc__legend-item`;let i=document.createElement(`span`);i.className=t,r.append(i,document.createTextNode(n)),e.appendChild(r)}for(let t of[`COMPETITIVE`,`ROUTINE`,`DECISIVE`]){let n=document.createElement(`span`);n.className=`chc-pc__legend-item`;let r=document.createElement(`span`);r.className=`chc-pc__legend-swatch`,r.style.background=eF(t),n.append(r,document.createTextNode(t.toLowerCase())),e.appendChild(n)}return e}function XI(){let e=document.createElement(`div`);return e.className=`chc-pc__tooltip`,e.dataset.visible=`false`,e}function ZI(e,t){let n=document.createElement(`div`);n.className=`chc-pc__tooltip-row`;let r=document.createElement(`span`);r.textContent=e;let i=document.createElement(`span`);return i.textContent=t,n.append(r,i),n}function QI(e,t){e.replaceChildren();let n=document.createElement(`div`);n.className=`chc-pc__tooltip-title`,n.textContent=`Round ${t.roundNumber}`,e.appendChild(n),t.actual!==null&&e.appendChild(ZI(`faced`,RI(t.actual))),t.competitiveness&&e.appendChild(ZI(`scoreline`,t.competitiveness.toLowerCase())),t.won!==void 0&&e.appendChild(ZI(`result`,t.won?`won`:`lost`)),t.projected.expected!==null&&e.appendChild(ZI(`projected`,RI(t.projected.expected))),t.projected.low!==null&&t.projected.high!==null&&e.appendChild(ZI(`range`,`${RI(t.projected.low)} … ${RI(t.projected.high)}`)),e.appendChild(ZI(`reach`,`${Math.round(t.reachProbability*100)}%`))}function $I(e){let t=document.createElement(`div`);return t.className=`chc-pc__empty`,t.textContent=e,t}function eL(e,t,n={}){let r=document.createElement(`div`);r.className=`chc-pc`,e.appendChild(r);let i=XI();function a(e,t){r.replaceChildren();let n=e?.points??[];if(!e||!n.length||!e.rating){r.appendChild($I(t.emptyMessage??`No rating data for this draw, so no pressure to plot.`));return}let a=t.width??jI,o=t.height??MI,s=BI(n,t),c=LI(`svg`,`chc-pc__svg`);c.setAttribute(`width`,String(a)),c.setAttribute(`height`,String(o)),c.setAttribute(`viewBox`,`0 0 ${a} ${o}`),c.setAttribute(`role`,`img`),c.setAttribute(`aria-label`,t.ariaLabel??`Projected and actual opponent difficulty by round for ${e.participantName??e.participantId}`);let l=LI(`g`);l.setAttribute(`transform`,`translate(${s.margin.left}, ${s.margin.top})`),c.appendChild(l),VI(l,n,s),qI({group:l,points:n,geometry:s,options:t}),HI({group:l,points:n,geometry:s,className:`chc-pc__projected-line`,accessor:e=>e.projected.expected}),HI({group:l,points:n,geometry:s,className:`chc-pc__actual-line`,accessor:e=>e.actual}),WI({group:l,points:n,geometry:s,radius:t.spark?FI:PI,onHover:t.spark?void 0:(e,t,n)=>{QI(i,e),i.dataset.visible=`true`,i.style.left=`${n.offsetX+12}px`,i.style.top=`${n.offsetY+12}px`}}),t.spark||JI({group:l,points:n,geometry:s}),r.appendChild(c),t.spark||(r.appendChild(i),t.showLegend!==!1&&r.appendChild(YI()),r.addEventListener(`mouseleave`,()=>{i.dataset.visible=`false`}))}return a(t,n),{element:r,update:(e,t)=>a(e,{...n,...t}),destroy:()=>{pD(r).remove()}}}var tL={NO_MATCHUPS:`NO_MATCHUPS`,NOT_ELIMINATION:`NOT_ELIMINATION`,NO_RATINGS:`NO_RATINGS`};function nL(e){return{participantId:e?.participant?.participantId??e?.participantId,participant:e?.participant,drawPosition:e?.drawPosition,bye:!!e?.bye}}function rL(e){let t=e?.roundNumber,n=e?.roundPosition;if(typeof t!=`number`||typeof n!=`number`)return null;let r=Array.isArray(e.sides)?e.sides:[],i=r.find(e=>e?.sideNumber===1)??r[0],a=r.find(e=>e?.sideNumber===2)??r[1];return{matchUpId:e.matchUpId,roundNumber:t,roundPosition:n,sides:[nL(i),nL(a)],winningSide:e.winningSide,matchUpStatus:e.matchUpStatus,raw:e}}function iL(e){if(!Array.isArray(e)||!e.length)return{unsupported:tL.NO_MATCHUPS};let t=new Map;for(let n of e){let e=rL(n);if(!e)continue;let r=t.get(e.roundNumber)??new Map;r.set(e.roundPosition,e),t.set(e.roundNumber,r)}let n=[...t.keys()].toSorted((e,t)=>e-t);if(!n.length)return{unsupported:tL.NOT_ELIMINATION};let r=n[0];for(let e=1;e<n.length;e+=1){let r=t.get(n[e-1])?.size??0,i=t.get(n[e])?.size??0;if(n[e]!==n[e-1]+1||i*2!==r)return{unsupported:tL.NOT_ELIMINATION}}return n.length===1&&(t.get(r)?.size??0)>1?{unsupported:tL.NOT_ELIMINATION}:{graph:{roundNumbers:n,byRound:t,firstRound:r}}}function aL(e){return[e*2-1,e*2]}function oL(e){return e.matchUpStatus===`BYE`||e.sides.some(e=>e.bye)}var{ELO:sL}=t.ratingConstants,cL=`SINGLES`,lL=`DOUBLES`;function uL(){return t.fixtures?.ratingsParameters??{}}function dL({value:e,sourceRange:t,targetRange:n}){if(!Array.isArray(t)||t.length!==2||!Array.isArray(n)||n.length!==2)return 0;let r=Math.min(...t),i=Math.max(...t),a=Math.min(...n),o=Math.max(...n);return i===r?a:(e-r)*(o-a)/(i-r)+a}function fL({scaleName:e,value:t}){if(typeof t!=`number`||Number.isNaN(t))return;if(e===sL)return t;let n=e?uL()[e]?.range:void 0;if(!n)return;let r=uL()[sL]?.range;if(r)return dL({value:n[0]>n[1]?n[0]-t:t,sourceRange:n,targetRange:r})}function pL(e){if(typeof e==`number`)return Number.isNaN(e)?void 0:e;if(typeof e!=`string`||!e.trim())return;let t=Number.parseFloat(e);return Number.isNaN(t)?void 0:t}function mL(e,t){let n=pL(t);if(n!==void 0)return n;if(!t||typeof t!=`object`)return;let r=uL()[e],i=[r?.accessor,...r?.accessors??[]].filter(Boolean);for(let e of i){let n=pL(t[e]);if(n!==void 0)return n}}function hL({participant:e,matchUpType:t,preferredScaleName:n}){let r=t===lL?lL:cL,i=e?.ratings?.[r];if(!Array.isArray(i)||!i.length)return null;let a=(n&&i.find(e=>e?.scaleName===n))??i.find(e=>typeof e?.scaleName==`string`);if(!a?.scaleName)return null;let o=mL(a.scaleName,a.scaleValue);if(o===void 0)return null;let s=fL({scaleName:a.scaleName,value:o});return s===void 0?null:{elo:s,scaleName:a.scaleName,sourceValue:o}}function gL(e){let t=new Map;for(let n of e)n&&t.set(n.scaleName,(t.get(n.scaleName)??0)+1);if(t.size)return[...t.entries()].toSorted((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0],`en`))[0][0]}function _L(e,t,n){let r=n?.divisor??400;return r?1/(1+10**((t-e)/r)):.5}function vL(e,t,n){return e===null||t===null?.5:_L(e,t,n)}function yL(e){return e.sides.map(e=>e.bye?void 0:e.participantId)}function bL(e,t){let n=new Map,[r,i]=yL(e);if(t.respectResults&&e.winningSide){let t=yL(e)[e.winningSide-1];return t&&n.set(t,1),n}if(r&&!i)n.set(r,1);else if(i&&!r)n.set(i,1);else if(r&&i){let e=vL(t.eloOf.get(r)??null,t.eloOf.get(i)??null,t.model);n.set(r,e),n.set(i,1-e)}return n}function xL(e,t,n){if(!t.size)return 1;let r=0;for(let[i,a]of t)r+=a*vL(n.eloOf.get(e)??null,n.eloOf.get(i)??null,n.model);return r}function SL(e,t,n){let r=new Map;if(!e.size)return new Map(t);if(!t.size)return new Map(e);for(let[i,a]of e)r.set(i,a*xL(i,t,n));for(let[i,a]of t)r.set(i,a*xL(i,e,n));return r}function CL(e,t,n){if(n.respectResults&&e.winningSide){let t=yL(e)[e.winningSide-1];if(t)return new Map([[t,1]])}return SL(t[0],t[1],n)}function wL(e,t){let n=new Map;for(let r of e.roundNumbers){let i=e.byRound.get(r),a=new Map;if(i){for(let[o,s]of i){if(r===e.firstRound){a.set(o,bL(s,t));continue}let i=n.get(r-1),[c,l]=aL(o),u=[i?.get(c)??new Map,i?.get(l)??new Map];a.set(o,CL(s,u,t))}n.set(r,a)}}return n}function TL({opponents:e,context:t,names:n,rangeThreshold:r}){let i=0,a=0,o=[],s=[];for(let[c,l]of e){let e=t.eloOf.get(c)??null;s.push({participantId:c,participantName:n.get(c),probability:l,elo:e}),e!==null&&(i+=l,a+=l*e,l>=r&&o.push(e))}return{expectedOpponentElo:i?a/i:null,opponentEloRange:o.length?[Math.min(...o),Math.max(...o)]:null,possibleOpponentCount:e.size,possibleOpponents:s.toSorted((e,t)=>t.probability-e.probability||e.participantId.localeCompare(t.participantId,`en`))}}function EL({graph:e,winners:t,roundNumber:n,feederPosition:r}){if(n===e.firstRound)return new Map;let i=r%2==1?r+1:r-1;return t.get(n-1)?.get(i)??new Map}function DL(e,t){let n=new Map;for(let r of e.sides)!r.bye&&r.participantId&&r.participantId!==t&&n.set(r.participantId,1);return n}function OL({participantId:e,entryMatchUp:t,graph:n,winners:r,context:i,ratings:a,names:o,rangeThreshold:s}){let c=a.get(e)??null,l=[],u=t.roundPosition,d=u,f=1;for(let t of n.roundNumbers){let a=n.byRound.get(t)?.get(u),p=t===n.firstRound&&!!a&&oL(a),m=TL({opponents:t===n.firstRound&&a?DL(a,e):EL({graph:n,winners:r,roundNumber:t,feederPosition:d}),context:i,names:o,rangeThreshold:s}),h=m.expectedOpponentElo!==null&&c?m.expectedOpponentElo-c.elo:null;l.push({roundNumber:t,reachProbability:f,expectedSignedDelta:h,resolved:m.possibleOpponentCount===1,bye:p,...m}),f=r.get(t)?.get(u)?.get(e)??0,d=u,u=Math.ceil(u/2)}return{participantId:e,participantName:t.sides.find(t=>t.participantId===e)?.participant?.participantName,drawPosition:t.sides.find(t=>t.participantId===e)?.drawPosition,rating:c,rounds:l,pathDifficulty:kL(l),slotDifficulty:AL(l),expectedMatchesPlayed:l.reduce((e,t)=>e+(t.bye?0:t.reachProbability),0)}}function kL(e){let t=0,n=0;for(let r of e)r.bye||r.expectedSignedDelta===null||(t+=r.reachProbability,n+=r.reachProbability*r.expectedSignedDelta);return t?n/t:null}function AL(e){let t=e.filter(e=>!e.bye&&e.expectedSignedDelta!==null).map(e=>e.expectedSignedDelta);return t.length?t.reduce((e,t)=>e+t,0)/t.length:null}function jL(e){let t=new Map,n=e.byRound.get(e.firstRound);if(!n)return t;for(let e of n.values())for(let n of e.sides)!n.bye&&n.participantId&&t.set(n.participantId,e);return t}function ML(e){let{graph:t,unsupported:n}=iL(e.matchUps);if(!t)return{projections:[],unsupported:n,unratedCount:0};let r=jL(t);if(!r.size)return{projections:[],unsupported:tL.NO_MATCHUPS,unratedCount:0};let i=new Map,a=new Map,o=new Map;for(let[t,n]of r){let r=n.sides.find(e=>e.participantId===t),s=hL({participant:r?.participant,matchUpType:e.matchUpType,preferredScaleName:e.scaleName});i.set(t,s),a.set(t,s?.elo??null),o.set(t,r?.participant?.participantName)}let s=[...i.values()].filter(e=>!e).length;if(s===i.size)return{projections:[],unsupported:tL.NO_RATINGS,unratedCount:s};let c={eloOf:a,model:e.model,respectResults:!!e.respectResults},l=wL(t,c),u=e.rangeThreshold??.01;return{projections:[...r.entries()].map(([e,n])=>OL({participantId:e,entryMatchUp:n,graph:t,winners:l,context:c,ratings:i,names:o,rangeThreshold:u})).toSorted((e,t)=>(e.drawPosition??0)-(t.drawPosition??0)),scaleName:gL([...i.values()]),unratedCount:s}}function NL(e){return e.raw?.competitiveProfile?.competitiveness||$P({winningSide:e.winningSide,matchUpStatus:e.matchUpStatus,sets:e.raw?.score?.sets,scoreString:e.raw?.score?.scoreStringSide1})}function PL(e,t){return hL({participant:e?.participant,matchUpType:t.matchUpType,preferredScaleName:t.scaleName})}function FL({matchUp:e,participantId:t,ownElo:n,params:r}){let i=e.sides.findIndex(e=>e.participantId===t),a=e.sides[1-i],o=oL(e),s=!!e.winningSide,c=(o||!s?null:PL(a,r))?.elo??null;return{roundNumber:e.roundNumber,matchUpId:e.matchUpId,opponentParticipantId:o?void 0:a?.participantId,opponentParticipantName:o?void 0:a?.participant?.participantName,opponentElo:c,signedDelta:c!==null&&n!==null?c-n:null,competitiveness:o||!s?void 0:NL(e),won:s?e.winningSide===i+1:void 0,bye:o}}function IL(e){let{graph:t}=iL(e.matchUps);if(!t)return[];let n=new Map,r=new Map;for(let i of t.byRound.values())for(let t of i.values())for(let i of t.sides){if(i.bye||!i.participantId)continue;let a=n.get(i.participantId)??[];a.push(t),n.set(i.participantId,a),r.has(i.participantId)||r.set(i.participantId,PL(i,e))}return[...n.entries()].map(([t,n])=>{let i=r.get(t)??null,a=n.toSorted((e,t)=>e.roundNumber-t.roundNumber).map(n=>FL({matchUp:n,participantId:t,ownElo:i?.elo??null,params:e})),o=a.filter(e=>!e.bye&&e.signedDelta!==null);return{participantId:t,rating:i,rounds:a,facedDifficulty:o.length?o.reduce((e,t)=>e+t.signedDelta,0)/o.length:null,matchesPlayed:a.filter(e=>!e.bye&&e.won!==void 0).length}})}function LL(e){let t=ML(e);if(!t.projections.length)return{series:[],projection:t,scaleName:t.scaleName,unratedCount:t.unratedCount};let n=new Map(IL({matchUps:e.matchUps,matchUpType:e.matchUpType,scaleName:e.scaleName}).map(e=>[e.participantId,e]));return{series:t.projections.map(e=>{let t=n.get(e.participantId),r=new Map((t?.rounds??[]).map(e=>[e.roundNumber,e])),i=e.rating?.elo??null,a=e.rounds.map(e=>{let t=r.get(e.roundNumber),n=e.opponentEloRange;return{roundNumber:e.roundNumber,projected:{expected:e.expectedSignedDelta,low:n&&i!==null?n[0]-i:null,high:n&&i!==null?n[1]-i:null},reachProbability:e.reachProbability,actual:t?.signedDelta??null,competitiveness:t?.competitiveness,won:t?.won,bye:e.bye||!!t?.bye,resolved:e.resolved}});return{participantId:e.participantId,participantName:e.participantName,drawPosition:e.drawPosition,rating:e.rating,pathDifficulty:e.pathDifficulty,slotDifficulty:e.slotDifficulty,facedDifficulty:t?.facedDifficulty??null,points:a}}),projection:t,scaleName:t.scaleName,unratedCount:t.unratedCount}}function RL(e){return e.toSorted((e,t)=>e.slotDifficulty===null&&t.slotDifficulty===null?(e.participantName??``).localeCompare(t.participantName??``,`en`,{numeric:!0}):e.slotDifficulty===null?1:t.slotDifficulty===null?-1:t.slotDifficulty-e.slotDifficulty)}var zL=150,BL=64;function VL(e){return zI(e.flatMap(e=>e.points))}function HL({series:e,options:t,chartOptions:n}){let r=document.createElement(`div`);r.className=`chc-psm__cell`,r.dataset.participantId=e.participantId;let i=document.createElement(`div`);return i.className=`chc-psm__label`,i.textContent=e.participantName??e.participantId,i.title=i.textContent,r.appendChild(i),eL(r,e,n),t.onSelect&&(r.classList.add(`is-clickable`),r.setAttribute(`role`,`button`),r.tabIndex=0,r.addEventListener(`click`,()=>t.onSelect?.(e)),r.addEventListener(`keydown`,n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t.onSelect?.(e))})),r}function UL(e,t=[],n={}){let r=document.createElement(`div`);r.className=`chc-psm`,e.appendChild(r);function i(e,t){r.replaceChildren();let n=RL(e).filter(e=>e.rating);if(!n.length){let e=document.createElement(`div`);e.className=`chc-pc__empty`,e.textContent=t.emptyMessage??`No rating data for this draw, so no pressure to plot.`,r.appendChild(e);return}let i=VL(n),a=document.createElement(`div`);a.className=`chc-psm__grid`;let o=t.limit?n.slice(0,t.limit):n;for(let e of o)a.appendChild(HL({series:e,options:t,chartOptions:{spark:!0,yDomain:i,width:t.cellWidth??zL,height:t.cellHeight??BL,scaleName:t.scaleName}}));r.appendChild(a);let s=document.createElement(`div`);s.className=`chc-psm__caption`;let c=e.length-n.length,l=[`hardest slot first · shared scale`];o.length<n.length&&l.push(`${n.length-o.length} of ${n.length} not shown`),c>0&&l.push(`${c} unrated omitted`),s.textContent=l.join(` · `),r.appendChild(s)}return i(t,n),{element:r,update:(e,t)=>i(e,{...n,...t})}}var WL=22,GL=460,KL=132,qL=3;function JL(e){if(e===null)return`—`;let t=Math.round(e);return t>0?`+${t}`:String(t)}function YL({series:e,options:t,scale:n,midpoint:r,barWidth:i}){let a=document.createElement(`div`);a.className=`chc-pdb__row`,a.dataset.participantId=e.participantId,a.style.height=`${t.rowHeight??WL}px`;let o=document.createElement(`span`);o.className=`chc-pdb__label`,o.style.width=`${t.labelWidth??KL}px`,o.textContent=e.participantName??e.participantId,o.title=o.textContent;let s=document.createElement(`span`);s.className=`chc-pdb__track`,s.style.width=`${i}px`;let c=document.createElement(`span`);if(c.className=`chc-pdb__zero`,c.style.left=`${r}px`,s.appendChild(c),e.slotDifficulty!==null){let t=n(e.slotDifficulty),i=document.createElement(`span`);i.className=e.slotDifficulty>=0?`chc-pdb__bar chc-pdb__bar--up`:`chc-pdb__bar chc-pdb__bar--down`,i.style.left=`${Math.min(r,t)}px`,i.style.width=`${Math.abs(t-r)}px`,i.style.borderRadius=e.slotDifficulty>=0?`0 ${qL}px ${qL}px 0`:`${qL}px 0 0 ${qL}px`,s.appendChild(i)}if(t.showActual&&e.facedDifficulty!==null){let t=document.createElement(`span`);t.className=`chc-pdb__actual`,t.style.left=`${n(e.facedDifficulty)}px`,t.title=`faced so far ${JL(e.facedDifficulty)}`,s.appendChild(t)}let l=document.createElement(`span`);return l.className=`chc-pdb__value`,l.textContent=JL(e.slotDifficulty),a.append(o,s,l),t.onSelect&&(a.classList.add(`is-clickable`),a.setAttribute(`role`,`button`),a.tabIndex=0,a.addEventListener(`click`,()=>t.onSelect?.(e)),a.addEventListener(`keydown`,n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t.onSelect?.(e))})),a}function XL(e,t=[],n={}){let r=document.createElement(`div`);r.className=`chc-pdb`,e.appendChild(r);function i(e,t){r.replaceChildren();let n=RL(e);if(!n.length){let e=document.createElement(`div`);e.className=`chc-pc__empty`,e.textContent=t.emptyMessage??`No rating data for this draw, so no path difficulty to rank.`,r.appendChild(e);return}let i=t.width??GL,a=t.labelWidth??KL,o=Math.max(40,i-a-52),s=o/2,c=n.flatMap(e=>[e.slotDifficulty,t.showActual?e.facedDifficulty:null]).filter(e=>e!==null),l=Math.max(...c.map(e=>Math.abs(e)),1),u=e=>s+e/l*(s-4),d=t.limit?n.slice(0,t.limit):n;for(let e of d)r.appendChild(YL({series:e,options:t,scale:u,midpoint:s,barWidth:o}));let f=document.createElement(`div`);f.className=`chc-pdb__caption`;let p=n.filter(e=>e.slotDifficulty===null).length,m=[`hardest slot first`];d.length<n.length&&m.push(`${n.length-d.length} of ${n.length} not shown`),p&&m.push(`${p} unrated`),f.textContent=m.join(` · `),r.appendChild(f)}return i(t,n),{element:r,update:(e,t)=>i(e,{...n,...t})}}var ZL=[`Round`,`Projected`,`Range`,`Reach`,`Faced`,`Scoreline`,`Result`];function QL(e){if(e==null)return`—`;let t=Math.round(e);return t>0?`+${t}`:String(t)}function $L(e){return e.points.map(e=>{let t=e.projected.low!==null&&e.projected.high!==null?`${QL(e.projected.low)} … ${QL(e.projected.high)}`:`—`,n=`—`;return e.bye?n=`bye`:e.won!==void 0&&(n=e.won?`won`:`lost`),[`R${e.roundNumber}`,QL(e.projected.expected),t,`${Math.round(e.reachProbability*100)}%`,QL(e.actual),e.competitiveness?e.competitiveness.toLowerCase():`—`,n]})}function eR(e,t){let n=document.createElement(`table`);n.className=`chc-pc__table`;let r=document.createElement(`caption`);r.textContent=`Projected and actual opponent difficulty by round — ${t.participantName??t.participantId}`,n.appendChild(r);let i=document.createElement(`thead`),a=document.createElement(`tr`);for(let e of ZL){let t=document.createElement(`th`);t.scope=`col`,t.textContent=e,a.appendChild(t)}i.appendChild(a),n.appendChild(i);let o=document.createElement(`tbody`);for(let e of $L(t)){let t=document.createElement(`tr`);e.forEach((e,n)=>{let r=document.createElement(n===0?`th`:`td`);n===0&&(r.scope=`row`),r.textContent=e,t.appendChild(r)}),o.appendChild(t)}return n.appendChild(o),e.appendChild(n),n}function tR(e){let t=e>>>0;return function(){t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function nR(e,t){let n=tR(t),r=[...e];for(let e=r.length-1;e>0;e--){let t=Math.floor(n()*(e+1));[r[e],r[t]]=[r[t],r[e]]}return r}function rR(e,t){return t.filter((t,n)=>t===e[n]).length}function iR(e,t,n=32){if(e.length<2)return{items:[...e],seed:t,deranged:!1};let r;for(let i=0;i<n;i++){let n=t+i,a=nR(e,n),o=rR(e,a);if(o===0)return{items:a,seed:n,deranged:!0};(!r||o<r.fixed)&&(r={items:a,seed:n,fixed:o})}return r?{items:r.items,seed:r.seed,deranged:!1}:{items:nR(e,t),seed:t,deranged:!1}}function aR(e){let t=[];for(let n=2;n<e&&e%n===0;n*=2)t.push(n);return t}function oR(e){return e.toSorted((e,t)=>e.localeCompare(t,`en`)).join(`|`)}function sR(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(oR(e.slice(r,r+t)));return n}function cR(e,t,n){let r=new Set(sR(t,n));return sR(e,n).filter(e=>r.has(e)).length}function lR(e){return Math.floor(e*e/2)}function uR({guess:e,actual:t}){if(e.length!==t.length||new Set(e).size!==e.length)throw Error(`scoreDrawOrder: guess must be a permutation of actual`);let n=new Map(t.map((e,t)=>[e,t]));if(e.some(e=>!n.has(e)))throw Error(`scoreDrawOrder: guess contains a participantId absent from actual`);let r=t.length,i=e.map((e,t)=>{let r=n.get(e)??-1;return{slotIndex:t,participantId:e,actualIndex:r,correct:r===t}}),a=i.filter(e=>e.correct).length,o=i.reduce((e,t)=>e+Math.abs(t.slotIndex-t.actualIndex),0),s=lR(r),c=s>0?1-o/s:1,l=aR(r).map(n=>({blockSize:n,matched:cR(e,t,n),total:r/n})),u=l.reduce((e,t)=>e+t.matched,0),d=l.reduce((e,t)=>e+t.total,0);return{slots:r,exact:a,displacement:o,maxDisplacement:s,proximity:c,levels:l,blocksMatched:u,blocksTotal:d,structureScore:Math.round(d>0?100*u/d:100*c),structurePerfect:d>0&&u===d,perfect:a===r,slotResults:i}}function dR({actualOrder:e,seed:t}){let n=iR(e,t);return{actualOrder:[...e],order:n.items,seed:n.seed,deranged:n.deranged,revealed:!1,score:null,moves:0}}function fR(e,t){return Number.isInteger(t)&&t>=0&&t<e.order.length}function pR(e,t,n){if(e.revealed||t===n||!fR(e,t)||!fR(e,n))return e;let r=[...e.order],[i]=r.splice(t,1);return r.splice(n,0,i),{...e,order:r,moves:e.moves+1}}function mR(e,t,n){if(e.revealed||t===n||!fR(e,t)||!fR(e,n))return e;let r=[...e.order];return[r[t],r[n]]=[r[n],r[t]],{...e,order:r,moves:e.moves+1}}function hR(e){return e.revealed?e:{...e,revealed:!0,score:uR({guess:e.order,actual:e.actualOrder})}}function gR(e,t){return dR({actualOrder:e.actualOrder,seed:t})}var _R=[.25,.75];function vR(e,t){if(!e.length)return null;let n=e.reduce((e,t)=>e+t.weight,0);if(!(n>0))return e[0].value;let r=t*n,i=0;for(let t of e)if(i+=t.weight,i>=r)return t.value;return e[e.length-1].value}function yR(e,t=_R){let n=e.filter(e=>typeof e.elo==`number`).map(e=>({value:e.elo,weight:Math.max(0,e.probability)})).toSorted((e,t)=>e.value-t.value);if(!n.length)return null;let r=vR(n,t[0]),i=vR(n,t[1]);return r===null||i===null?null:{outerLow:n[0].value,outerHigh:n[n.length-1].value,innerLow:Math.min(r,i),innerHigh:Math.max(r,i)}}var bR={PROJECTED:`projected`,ACTUAL:`actual`},xR={HARD:`hard`,EASY:`easy`},SR=60;function CR(e,t){return t===bR.ACTUAL&&e.actual!==null&&e.actual!==void 0?{value:e.actual,fromActual:!0}:{value:e.projected.expected,fromActual:!1}}function wR({magnitude:e,bands:t=4,domainMax:n}){if(!(n>0)||!(e>0)||t<1)return{layers:[],clipped:!1};let r=n/t,i=[];for(let n=0;n<t;n++){let t=e-n*r;if(t<=0)break;i.push({bandIndex:n,fraction:Math.min(1,t/r)})}return{layers:i,clipped:e>n}}function TR(e,t){let n=e.flatMap(e=>e.points.map(e=>CR(e,t).value).filter(e=>e!==null).map(Math.abs));return n.length?Math.max(60,...n):60}function ER({point:e,ownElo:t,round:n}){if(t!==null&&n?.possibleOpponents?.length){let e=yR(n.possibleOpponents);if(e)return{outerLow:e.outerLow-t,outerHigh:e.outerHigh-t,innerLow:e.innerLow-t,innerHigh:e.innerHigh-t,weighted:!0}}let{low:r,high:i}=e.projected;return r===null||i===null?null:{outerLow:r,outerHigh:i,innerLow:r,innerHigh:i,weighted:!1}}function DR(e,t){return{roundNumber:e,value:null,direction:null,layers:[],clipped:!1,fromActual:!1,reachProbability:t?.reachProbability??0,bye:!!t?.bye,resolved:!!t?.resolved,spread:null}}function OR(e){return e>=0?xR.HARD:xR.EASY}function kR({roundNumber:e,point:t,source:n,bands:r,domainMax:i,ownElo:a,round:o}){if(!t||t.bye)return DR(e,t);let{value:s,fromActual:c}=CR(t,n);if(s===null)return DR(e,t);let{layers:l,clipped:u}=wR({magnitude:Math.abs(s),bands:r,domainMax:i});return{roundNumber:e,value:s,direction:OR(s),layers:l,clipped:u,fromActual:c,reachProbability:t.reachProbability,bye:!1,resolved:t.resolved,spread:ER({point:t,ownElo:a,round:o})}}function AR(e){let t=new Map;for(let n of e?.projections??[])t.set(n.participantId,new Map(n.rounds.map(e=>[e.roundNumber,e])));return t}function jR({series:e,source:t=bR.PROJECTED,bands:n=4,domainMax:r,projection:i}){let a=[...new Set(e.flatMap(e=>e.points.map(e=>e.roundNumber)))].toSorted((e,t)=>e-t),o=r??TR(e,t),s=AR(i),c=e.map(e=>{let r=new Map(e.points.map(e=>[e.roundNumber,e])),i=s.get(e.participantId);return{participantId:e.participantId,participantName:e.participantName,drawPosition:e.drawPosition,cells:a.map(a=>kR({roundNumber:a,point:r.get(a),source:t,bands:n,domainMax:o,ownElo:e.rating?.elo??null,round:i?.get(a)}))}});return{rows:c,roundNumbers:a,domainMax:o,bands:n,clippedCells:c.flatMap(e=>e.cells).filter(e=>e.clipped).length}}var MR=`http://www.w3.org/2000/svg`,NR=`class`,PR=`path`,FR=0,IR=1.5;function LR(e,t){let n=document.createElementNS(MR,e);return t&&n.setAttribute(NR,t),n}function RR(e){let t=Math.round(e);return t>0?`+${t}`:String(t)}function zR(e){let t=e.layers.at(-1);return!t||!e.direction?`chc-ph__stop--none`:`chc-ph__stop--${e.direction}-${t.bandIndex}`}function BR(e,t,n,r){let i=LR(`linearGradient`);if(i.setAttribute(`id`,r),i.setAttribute(`gradientUnits`,`userSpaceOnUse`),i.setAttribute(`x1`,`0`),i.setAttribute(`y1`,`0`),i.setAttribute(`x2`,String(n)),i.setAttribute(`y2`,`0`),e.forEach((e,r)=>{let a=LR(`stop`,zR(e));a.setAttribute(`offset`,String(n>0?t(r)/n:0)),i.appendChild(a)}),e.length===1){let t=LR(`stop`,zR(e[0]));t.setAttribute(`offset`,`1`),i.appendChild(t)}return i}function VR(e,t,n){if(e.bye)return`${t}: bye`;if(e.value===null)return`${t}: no rated opponent`;let r=n?` ${n}-equivalent`:``,i=e.fromActual?`faced`:`projected`,a=e.spread?` · likely ${RR(e.spread.innerLow)} to ${RR(e.spread.innerHigh)}${e.spread.weighted?``:` (unweighted range)`}`:``,o=e.clipped?` · capped at the top band`:``;return`${t}: ${i} ${RR(e.value)}${r}${a}${o}`}function HR(e,t){let{width:n,height:r,domainMax:i,bands:a=4,positionBands:o=2,describe:s=!1,roundLabels:c,scaleName:l,showZeroLine:u=!0}=t,d=Math.max(1,e.cells.length),f=n/d,p=e=>(e+.5)*f,m=r/2,h=Math.max(1,r/2-IR),g=Math.max(1e-9,i/Math.max(1,a)*o),_=e=>m-Math.max(-1,Math.min(1,e/g))*h,v=LR(`svg`,`chc-ph__svg`);v.setAttribute(`width`,String(n)),v.setAttribute(`height`,String(r)),v.setAttribute(`viewBox`,`0 0 ${n} ${r}`),v.setAttribute(`role`,`img`),v.setAttribute(`aria-label`,t.ariaLabel??`Projected round-by-round path for ${e.participantName??e.participantId}`),FR+=1;let y=`chc-ph-grad-${FR}`,b=LR(`defs`);if(b.appendChild(BR(e.cells,p,n,y)),v.appendChild(b),u){let e=LR(`line`,`chc-ph__zero`);e.setAttribute(`x1`,`0`),e.setAttribute(`x2`,String(n)),e.setAttribute(`y1`,String(m)),e.setAttribute(`y2`,String(m)),v.appendChild(e)}let x=e.cells.map((e,t)=>({cell:e,index:t})),S=`url(#${y})`;for(let[e,t]of[[`outer`,`chc-ph__fan chc-ph__fan--outer`],[`inner`,`chc-ph__fan chc-ph__fan--inner`]]){let n=AP().curve(IP).defined(e=>e.cell.spread!==null).x(e=>p(e.index)).y0(t=>_(e===`outer`?t.cell.spread?.outerLow??0:t.cell.spread?.innerLow??0)).y1(t=>_(e===`outer`?t.cell.spread?.outerHigh??0:t.cell.spread?.innerHigh??0))(x);if(!n)continue;let r=LR(PR,t);r.setAttribute(`d`,n),r.setAttribute(`fill`,S),v.appendChild(r)}let C=kP().curve(IP).defined(e=>e.cell.value!==null).x(e=>p(e.index)).y(e=>_(e.cell.value??0))(x);if(C){let e=LR(PR,`chc-ph__trace`);e.setAttribute(`d`,C),e.setAttribute(`stroke`,S),v.appendChild(e)}return s&&e.cells.forEach((e,t)=>{let n=LR(`rect`,`chc-ph__hit`);n.setAttribute(`x`,String(t*f)),n.setAttribute(`y`,`0`),n.setAttribute(`width`,String(f)),n.setAttribute(`height`,String(r));let i=c?.(e.roundNumber,t,d)??`R${t+1}`,a=LR(`title`);a.textContent=VR(e,i,l),n.appendChild(a),v.appendChild(n)}),v}var UR=`http://www.w3.org/2000/svg`,WR=`class`,GR=`rect`,KR=`chc-ph__wall`,qR=2,JR=5,YR=2,XR=2;function ZR(e,t){let n=document.createElementNS(UR,e);return t&&n.setAttribute(WR,t),n}function QR(e){let t=Math.round(e);return t>0?`+${t}`:String(t)}function $R(e,t,n){if(e.bye)return`${t}: bye`;if(e.value===null)return`${t}: no rated opponent`;let r=e.fromActual?`faced`:`projected`,i=n?` ${n}-equivalent`:``,a=e.clipped?` (capped at the top band)`:``;return`${t}: ${r} ${QR(e.value)}${i}${a}`}function ez({group:e,cell:t,columnWidth:n,height:r}){if(!t.layers.length){let t=ZR(GR,`${KR} ${KR}--none`);t.setAttribute(`x`,`0`),t.setAttribute(`y`,String((r-XR)/2)),t.setAttribute(`width`,String(n)),t.setAttribute(`height`,String(XR)),e.appendChild(t);return}let i=t.direction===xR.HARD;for(let a of t.layers){let o=Math.max(1,a.fraction*r),s=ZR(GR,`${KR} ${KR}--${t.direction}-${a.bandIndex}`);s.setAttribute(`x`,`0`),s.setAttribute(`y`,String(i?r-o:0)),s.setAttribute(`width`,String(n)),s.setAttribute(`height`,String(o)),o>=JR&&s.setAttribute(`rx`,String(YR)),e.appendChild(s)}}function tz(e,t){let{width:n,height:r,gap:i=qR,describe:a=!1,roundLabels:o,scaleName:s}=t,c=Math.max(1,e.cells.length),l=Math.max(1,(n-i*(c-1))/c),u=ZR(`svg`,`chc-ph__svg`);return u.setAttribute(`width`,String(n)),u.setAttribute(`height`,String(r)),u.setAttribute(`viewBox`,`0 0 ${n} ${r}`),u.setAttribute(`role`,`img`),u.setAttribute(`aria-label`,t.ariaLabel??`Projected round-by-round path for ${e.participantName??e.participantId}`),e.cells.forEach((e,t)=>{let n=ZR(`g`,`chc-ph__column`);if(n.setAttribute(`transform`,`translate(${t*(l+i)},0)`),ez({group:n,cell:e,columnWidth:l,height:r}),a){let r=o?.(e.roundNumber,t,c)??`R${t+1}`,i=ZR(`title`);i.textContent=$R(e,r,s),n.appendChild(i)}u.appendChild(n)}),u}var nz=`http://www.w3.org/2000/svg`,rz=12,iz=2,az={walls:[`playing up — wall rises from the baseline`,`playing down — wall hangs from the top`],ribbon:[`playing up — trace above the centre line`,`playing down — trace below the centre line`]},oz=[xR.HARD,xR.EASY];function sz(e,t){let n=document.createElement(e);return t&&(n.className=t),n}function cz(e,t,n=!1){let r=rz*t+(t-1)*iz,i=document.createElementNS(nz,`svg`);i.setAttribute(`class`,`chc-ph__swatch`),i.setAttribute(`width`,String(r)),i.setAttribute(`height`,String(rz)),i.setAttribute(`viewBox`,`0 0 ${r} ${rz}`),i.setAttribute(`aria-hidden`,`true`);for(let r=0;r<t;r++){let a=rz*((r+1)/t),o=n?a/2:a,s=document.createElementNS(nz,`rect`);s.setAttribute(`class`,`chc-ph__wall chc-ph__wall--${e}-${r}`),s.setAttribute(`x`,String(r*14));let c=e===xR.HARD,l=rz/2;s.setAttribute(`y`,String(n?c?l-o:l:c?rz-o:0)),s.setAttribute(`width`,String(rz)),s.setAttribute(`height`,String(o)),i.appendChild(s)}return i}function lz(e,t){return e===`ribbon`?`The line is the expected opponent; the shading is who could actually arrive — solid for the likely middle, faint for the full range. Deeper colour means a larger ${t} gap.`:`Deeper, darker bands mean a larger ${t} gap. Rows share one domain.`}function uz({bands:e,scaleName:t,note:n,variant:r}){let i=sz(`div`,`chc-ph__legend`),a=r===`ribbon`,o=az[a?`ribbon`:`walls`];for(let[t,n]of oz.entries()){let r=sz(`div`,`chc-ph__legend-item`);r.appendChild(cz(n,e,a));let s=sz(`span`,`chc-ph__legend-label`);s.textContent=o[t],r.appendChild(s),i.appendChild(r)}let s=t?`${t}-equivalent rating`:`rating`,c=sz(`div`,`chc-ph__legend-note`);return c.textContent=n??lz(r,s),i.appendChild(c),i}var dz=`chc-ph`,fz=`chc-ph__row`,pz=520,mz=132,hz={walls:16,ribbon:28},gz=2,_z={DRAW:`draw`,DIFFICULTY:`difficulty`},vz={WALLS:`walls`,RIBBON:`ribbon`};function yz(e,t){let n=document.createElement(e);return t&&(n.className=t),n}function bz(e,t){return t===_z.DIFFICULTY?RL(e):e.toSorted((e,t)=>(e.drawPosition??0)-(t.drawPosition??0))}function xz({roundNumbers:e,width:t,columnGap:n,labelWidth:r,roundLabels:i}){let a=yz(`div`,`chc-ph__head`),o=yz(`div`,`chc-ph__label`);o.style.width=`${r}px`,a.appendChild(o);let s=yz(`div`,`chc-ph__rounds`);s.style.width=`${t}px`,s.style.gap=`${n}px`;for(let[t,n]of e.entries()){let r=yz(`span`,`chc-ph__round-label`);r.textContent=i(n,t,e.length),s.appendChild(r)}return a.appendChild(s),a}function Sz(e,t,n){e.classList.add(`is-clickable`),e.setAttribute(`role`,`button`),e.tabIndex=0,e.addEventListener(`click`,()=>n(t)),e.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n(t))})}function Cz(e,{variant:t,width:n,rowHeight:r,columnGap:i,roundLabels:a,scaleName:o,domainMax:s,bands:c}){return t===vz.RIBBON?HR(e,{width:n,height:r,domainMax:s,bands:c,positionBands:gz,describe:!0,roundLabels:a,scaleName:o}):tz(e,{width:n,height:r,gap:i,describe:!0,roundLabels:a,scaleName:o})}function wz({shown:e,ordered:t,dropped:n,domainMax:r,bands:i,clippedCells:a,order:o,variant:s,unweightedFan:c}){let l=yz(`div`,`chc-ph__caption`),u=[`${e} paths · ${o===_z.DRAW?`draw order`:`hardest slot first`}`,`shared domain ±${Math.round(r)} · ${i} bands`];return s===vz.RIBBON&&u.push(`trace saturates past ${gz} of ${i} bands — colour carries the rest`),s===vz.RIBBON&&c&&u.push("fan is the unweighted 1%-threshold range — pass `projection` to weight it"),e<t&&u.push(`${t-e} of ${t} not shown`),n>0&&u.push(`${n} unrated omitted`),a>0&&u.push(`${a} walls capped at the top band`),l.textContent=u.join(` · `),l}function Tz(e,t=[],n={}){let r=yz(`div`,dz);e.appendChild(r);function i(e,t){r.replaceChildren();let{width:n=pz,variant:i=vz.WALLS,rowHeight:a=hz[i],rowGap:o=2,columnGap:s=2,bands:c,source:l=bR.PROJECTED,domainMax:u,showLabels:d=!0,showLegend:f=!0,showRoundHeader:p=!0,order:m=_z.DRAW,limit:h,scaleName:g,onSelect:_,projection:v,roundLabels:y=II}=t,b=e.filter(e=>e.rating);if(!b.length){let e=yz(`div`,`chc-ph__empty`);e.textContent=t.emptyMessage??`No rating data for this draw, so there is no pressure to plot.`,r.appendChild(e);return}let x=bz(b,m),S=h?x.slice(0,h):x,C=jR({series:S,source:l,bands:c,domainMax:u,projection:v}),w=d?t.labelWidth??mz:0;p&&r.appendChild(xz({roundNumbers:C.roundNumbers,width:n,columnGap:s,labelWidth:w,roundLabels:y}));let T=yz(`div`,`chc-ph__rows`);T.style.gap=`${o}px`;for(let[e,t]of C.rows.entries()){let r=S[e],o=yz(`div`,fz);if(o.dataset.participantId=t.participantId,d){let e=yz(`div`,`chc-ph__label`);e.style.width=`${w}px`,e.textContent=`${t.drawPosition?`${t.drawPosition}. `:``}${t.participantName??t.participantId}`,e.title=e.textContent,o.appendChild(e)}o.appendChild(Cz(t,{variant:i,width:n,rowHeight:a,columnGap:s,roundLabels:y,scaleName:g,domainMax:C.domainMax,bands:C.bands})),_&&Sz(o,r,_),T.appendChild(o)}r.appendChild(T),f&&r.appendChild(uz({bands:C.bands,scaleName:g,variant:i})),r.appendChild(wz({shown:S.length,ordered:x.length,dropped:e.length-b.length,domainMax:C.domainMax,bands:C.bands,clippedCells:C.clippedCells,order:m,variant:i,unweightedFan:C.rows.some(e=>e.cells.some(e=>e.spread&&!e.spread.weighted))}))}return i(t,n),{element:r,update:(e,t)=>i(e,{...n,...t}),destroy:()=>r.remove()}}var Ez=`chc-dog`,Dz=`chc-dog__row`,Oz=`application/x-chc-draw-slot`,kz=`button`,Az=`is-drop-target`,jz=`New board dealt`,Mz=460,Nz={walls:20,ribbon:30},Pz=20260831;function Fz(e,t){let n=document.createElement(e);return t&&(n.className=t),n}function Iz(e,t){let n=document.createElement(kz);return n.type=kz,n.className=`chc-dog__button`,n.textContent=e,n.addEventListener(`click`,t),n}function Lz(e,t){return e===2?`first-round pairs`:e===t/2?`halves`:e===t/4?`quarters`:`groups of ${e}`}function Rz(e){let t=Fz(`div`,`chc-dog__score`),n=Fz(`div`,`chc-dog__score-headline`);n.textContent=`${e.structureScore}%`,t.appendChild(n);let r=Fz(`div`,`chc-dog__score-summary`);r.textContent=e.structurePerfect?`Every grouping in the real draw — you rebuilt the bracket.`:`${e.blocksMatched} of ${e.blocksTotal} real groupings recovered.`,t.appendChild(r);let i=Fz(`ul`,`chc-dog__score-levels`);for(let t of e.levels){let n=Fz(`li`);n.textContent=`${Lz(t.blockSize,e.slots)}: ${t.matched}/${t.total}`,i.appendChild(n)}t.appendChild(i);let a=Fz(`div`,`chc-dog__score-exact`);a.textContent=`${e.exact}/${e.slots} rows in the exact slot.`,t.appendChild(a);let o=Fz(`div`,`chc-dog__score-note`);return o.textContent=`A draw sheet is mirror-symmetric — swapping two halves, two quarters or the two players in a pair gives the same bracket with different slot numbers. The headline counts groupings, which survive that; exact slots do not, so a low exact count beside a high headline means you had the draw right and the sheet flipped.`,t.appendChild(o),t}function zz(e,t=[],n={}){let r=Fz(`div`,Ez);e.appendChild(r);let{width:i=Mz,rowHeight:a=Nz[n.variant??vz.WALLS],rowGap:o=2,columnGap:s=2,bands:c,variant:l=vz.WALLS,projection:u,scaleName:d,limit:f,roundLabels:p=II,onComplete:m}=n,h=t.filter(e=>e.rating&&e.drawPosition!==void 0),g=t.length-h.length,_=h.toSorted((e,t)=>(e.drawPosition??0)-(t.drawPosition??0)),v=f?_.slice(0,f):_,y=jR({series:v,source:bR.PROJECTED,bands:c,projection:u}),b=new Map(y.rows.map(e=>[e.participantId,e])),x=new Map(v.map(e=>[e.participantId,e])),S=dR({actualOrder:v.map(e=>e.participantId),seed:n.seed??Pz}),C=null,w=null,T=Fz(`div`,`chc-dog__live`);T.setAttribute(`aria-live`,`polite`);function E(e){T.textContent=e}function D(e,t){let n=e!==S;S=e,F(),t&&n&&E(t),S.revealed&&S.score&&m?.(S.score,S)}function O(e,t){let n=b.get(e),r=Fz(`div`,Dz);r.dataset.slot=String(t),r.tabIndex=0,r.setAttribute(`role`,`listitem`),r.setAttribute(`aria-label`,`Slot ${t+1} of ${S.order.length}`);let o=Fz(`div`,`chc-dog__slot`);if(o.textContent=String(t+1),r.appendChild(o),n){let e=l===vz.RIBBON?HR(n,{width:i,height:a,domainMax:y.domainMax,bands:y.bands,describe:!1,ariaLabel:`Path in slot ${t+1}`}):tz(n,{width:i,height:a,gap:s,describe:!1,ariaLabel:`Path in slot ${t+1}`});r.appendChild(e)}if(S.revealed){let n=x.get(e),i=S.score?.slotResults[t],a=Fz(`div`,`chc-dog__reveal${i?.correct?` is-correct`:``}`),o=(i?.actualIndex??0)+1;a.textContent=`${n?.participantName??e} · really ${o}`,r.appendChild(a)}else r.draggable=!0,k(r,t),A(r,t);return r}function k(e,t){e.addEventListener(`dragstart`,n=>{C=t,e.classList.add(`is-dragging`),n.dataTransfer?.setData(Oz,String(t)),n.dataTransfer&&(n.dataTransfer.effectAllowed=`move`)}),e.addEventListener(`dragend`,()=>{C=null,e.classList.remove(`is-dragging`)}),e.addEventListener(`dragover`,t=>{t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect=`move`),e.classList.add(Az)}),e.addEventListener(`dragleave`,()=>e.classList.remove(Az)),e.addEventListener(`drop`,n=>{n.preventDefault(),e.classList.remove(Az);let r=n.dataTransfer?.getData(Oz),i=r?Number.parseInt(r,10):C;i===null||Number.isNaN(i)||(w=t,D(pR(S,i,t),`Moved slot ${i+1} to slot ${t+1}`))})}function A(e,t){e.addEventListener(`keydown`,e=>{if(e.key!==`ArrowUp`&&e.key!==`ArrowDown`)return;let n=t+(e.key===`ArrowUp`?-1:1);n<0||n>=S.order.length||(e.preventDefault(),w=n,e.altKey||e.metaKey?D(mR(S,t,n),`Slot ${t+1} swapped with slot ${n+1}`):j(n))})}function j(e){r.querySelector(`.${Dz}[data-slot="${e}"]`)?.focus()}function M(){let e=Fz(`div`,`chc-dog__toolbar`);S.revealed?e.appendChild(Iz(`Play again`,()=>D(gR(S,S.seed+1),jz))):(e.appendChild(Iz(`Check my order`,()=>D(hR(S)))),e.appendChild(Iz(`Shuffle`,()=>D(gR(S,S.seed+1),jz))));let t=Fz(`span`,`chc-dog__meta`);return t.textContent=`puzzle #${S.seed} · ${S.order.length} paths · ${S.moves} moves`,e.appendChild(t),e}function N(){let e=Fz(`p`,`chc-dog__instructions`);return e.textContent=`These are the projected paths of every player in one draw, shuffled and unnamed. Drag them into the real draw order — or focus a row and hold Alt with the arrow keys. Players who meet in a round are each other’s opponent in that column, so `+(l===vz.RIBBON?`two traces that mirror each other about the centre line in the same column are probably a pair.`:`a deep-hard row and a pale-easy row of the same size in the same column are probably a pair.`),e}function P(){let e=Fz(`div`,`chc-dog__head`);e.appendChild(Fz(`div`,`chc-dog__slot-spacer`));let t=Fz(`div`,`chc-ph__rounds`);t.style.width=`${i}px`,t.style.gap=`${s}px`;for(let[e,n]of y.roundNumbers.entries()){let r=Fz(`span`,`chc-ph__round-label`);r.textContent=p(n,e,y.roundNumbers.length),t.appendChild(r)}return e.appendChild(t),e}function F(){if(r.replaceChildren(),!v.length){let e=Fz(`div`,`chc-ph__empty`);e.textContent=n.emptyMessage??`No rated draw to play — the game needs ratings and draw positions.`,r.appendChild(e);return}r.appendChild(N()),r.appendChild(M()),r.appendChild(P());let e=Fz(`div`,`chc-dog__rows`);e.setAttribute(`role`,`list`),e.style.gap=`${o}px`;for(let[t,n]of S.order.entries())e.appendChild(O(n,t));r.appendChild(e),r.appendChild(uz({bands:y.bands,scaleName:d,variant:l,note:`Deeper, darker bands mean a larger rating gap. Every path is on the same domain — that is what makes two rows comparable.`})),S.revealed&&S.score&&r.appendChild(Rz(S.score));let t=Fz(`div`,`chc-ph__caption`),i=d?` ${d}-equivalent`:``,a=[`shared domain ±${Math.round(y.domainMax)}${i} · ${y.bands} bands`];S.deranged||a.push(`this deal left a row in its true slot`),g>0&&a.push(`${g} unrated omitted`),y.clippedCells>0&&a.push(`${y.clippedCells} walls capped at the top band`),t.textContent=a.join(` · `),r.appendChild(t),r.appendChild(T),w!==null&&(j(w),w=null)}return F(),{element:r,getState:()=>S,reshuffle:e=>D(gR(S,e??S.seed+1),jz),reveal:()=>D(hR(S)),destroy:()=>r.remove()}}var Bz=`right`,Vz=`font-medium`;function Hz({target:e,button:t,stateChange:n}){let r=0,i=()=>(r+=1,`Item${r}`),a=document.createElement(`div`);t.class&&a.classList.add(t.class),a.classList.add(`dropdown`),t.id&&(a.id=t.id),t.align===Bz&&a.classList.add(`is-right`);let o=e=>e.classList.contains(`is-active`),s=()=>{o(a)&&a.classList.remove(`is-active`)},c=e=>o(e)?(e.classList.remove(`is-active`),!1):(e.classList.add(`is-active`),!0);a.onmouseleave=s,a.onclick=()=>c(a);let l=document.createElement(`div`);l.classList.add(`dropdown-trigger`);let u=document.createElement(`button`);u.className=`button font-medium`,t.intent&&u.classList.add(t.intent),u.setAttribute(`aria-haspopup`,`true`);let d=document.createElement(`span`);V(t.onClick)&&(d.onclick=t.onClick),d.style.cssText=`margin-right: 1em`,d.innerHTML=t.label,u.appendChild(d);let f=document.createElement(`span`);V(t.onClick)&&(f.onclick=t.onClick),f.innerHTML=`
216
216
  <span class="icon is-small font-medium">
217
217
  <i class="fas fa-angle-down font-medium" aria-hidden="true"></i>